mirror of
https://github.com/boxgaming/qbjs.git
synced 2024-09-20 04:24:45 +00:00
Merge pull request #13 from WFBarnes/main
Implemented Hex$, Enabled Val to receive &H+hex$ input.
This commit is contained in:
commit
40536c85b0
4 changed files with 25 additions and 3 deletions
|
@ -41,8 +41,8 @@ CodeMirror.defineMode("qbjs", function(conf, parserConf) {
|
||||||
'_putimage', '_red', '_red32', '_resize', '_resizewidth', '_resizeheight', '_rgb', '_rgba', '_rgb32', '_rgba32', '_round',
|
'_putimage', '_red', '_red32', '_resize', '_resizewidth', '_resizeheight', '_rgb', '_rgba', '_rgb32', '_rgba32', '_round',
|
||||||
'_screenexists', '_sndclose', '_sndopen', '_sndplay', '_sndloop', '_sndpause', '_sndstop', '_sndvol',
|
'_screenexists', '_sndclose', '_sndopen', '_sndplay', '_sndloop', '_sndpause', '_sndstop', '_sndvol',
|
||||||
'_title', '_trim', '_width', 'abs', 'asc', 'atn', 'chr', 'circle', 'cls', 'color', 'command', 'cos', 'cvi', 'cvl', 'exp',
|
'_title', '_trim', '_width', 'abs', 'asc', 'atn', 'chr', 'circle', 'cls', 'color', 'command', 'cos', 'cvi', 'cvl', 'exp',
|
||||||
'fix', 'input', 'inkey', 'instr', 'int', 'lbound', 'left', 'lcase', 'len', 'line', 'locate', 'log', 'ltrim', 'mid', 'mki', 'mkl',
|
'fix', 'hex', 'input', 'inkey', 'instr', 'int', 'lbound', 'left', 'lcase', 'len', 'line', 'locate', 'log', 'ltrim', 'mid', 'mki', 'mkl',
|
||||||
'print', 'pset', 'right', 'rtrim', 'rnd', 'screen', 'shared', 'sgn', 'sin', 'sleep', 'space', 'sqr', 'str', 'swap', 'tan',
|
'point', 'print', 'pset', 'right', 'rtrim', 'rnd', 'screen', 'shared', 'sgn', 'sin', 'sleep', 'space', 'sqr', 'str', 'swap', 'tan',
|
||||||
'timer', 'ubound', 'ucase', 'val',
|
'timer', 'ubound', 'ucase', 'val',
|
||||||
// QBJS-specific
|
// QBJS-specific
|
||||||
'alert', 'confirm', 'domadd', 'domcontainer', 'domcreate', 'domevent','domget', 'domgetimage', 'domremove', 'export',
|
'alert', 'confirm', 'domadd', 'domcontainer', 'domcreate', 'domevent','domget', 'domgetimage', 'domremove', 'export',
|
||||||
|
|
20
qb.js
20
qb.js
|
@ -620,6 +620,10 @@ var QB = new function() {
|
||||||
return Math.floor(QB.func__Height() / QB.func__FontHeight());
|
return Math.floor(QB.func__Height() / QB.func__FontHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.func_Hex = function(n) {
|
||||||
|
return n.toString(16).toUpperCase();
|
||||||
|
};
|
||||||
|
|
||||||
this.sub_Input = async function(values, preventNewline, addQuestionPrompt, prompt) {
|
this.sub_Input = async function(values, preventNewline, addQuestionPrompt, prompt) {
|
||||||
_lastKey = null;
|
_lastKey = null;
|
||||||
var str = "";
|
var str = "";
|
||||||
|
@ -850,6 +854,14 @@ var QB = new function() {
|
||||||
return ascii.split("").reverse().join("");
|
return ascii.split("").reverse().join("");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.func_Point = function(x, y) {
|
||||||
|
var screen = _images[_activeImage];
|
||||||
|
var ctx = screen.ctx;
|
||||||
|
var data = ctx.getImageData(x, y, 1, 1).data;
|
||||||
|
var ret = QB.func__RGBA(data[0],data[1],data[2],data[3]);
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
this.sub_Print = async function(args) {
|
this.sub_Print = async function(args) {
|
||||||
// Print called with no arguments
|
// Print called with no arguments
|
||||||
if (args == undefined || args == null || args.length < 1) {
|
if (args == undefined || args == null || args.length < 1) {
|
||||||
|
@ -1087,7 +1099,13 @@ var QB = new function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.func_Val = function(value) {
|
this.func_Val = function(value) {
|
||||||
return Number(value);
|
var ret;
|
||||||
|
if (value.substring(0, 2) == "&H") {
|
||||||
|
ret = parseInt(value.slice(2), 16);
|
||||||
|
} else {
|
||||||
|
ret = Number(value);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
2
qb2js.js
2
qb2js.js
|
@ -2515,6 +2515,7 @@ if (QB.halted()) { return; }
|
||||||
await sub_AddQBMethod( "FUNCTION", "Cvl", False);
|
await sub_AddQBMethod( "FUNCTION", "Cvl", False);
|
||||||
await sub_AddQBMethod( "FUNCTION", "Exp", False);
|
await sub_AddQBMethod( "FUNCTION", "Exp", False);
|
||||||
await sub_AddQBMethod( "FUNCTION", "Fix", False);
|
await sub_AddQBMethod( "FUNCTION", "Fix", False);
|
||||||
|
await sub_AddQBMethod( "FUNCTION", "Hex$", False);
|
||||||
await sub_AddQBMethod( "SUB", "Input", True);
|
await sub_AddQBMethod( "SUB", "Input", True);
|
||||||
await sub_AddQBMethod( "FUNCTION", "InKey$", False);
|
await sub_AddQBMethod( "FUNCTION", "InKey$", False);
|
||||||
await sub_AddQBMethod( "FUNCTION", "InStr", False);
|
await sub_AddQBMethod( "FUNCTION", "InStr", False);
|
||||||
|
@ -2530,6 +2531,7 @@ if (QB.halted()) { return; }
|
||||||
await sub_AddQBMethod( "FUNCTION", "Mid$", False);
|
await sub_AddQBMethod( "FUNCTION", "Mid$", False);
|
||||||
await sub_AddQBMethod( "FUNCTION", "Mki$", False);
|
await sub_AddQBMethod( "FUNCTION", "Mki$", False);
|
||||||
await sub_AddQBMethod( "FUNCTION", "Mkl$", False);
|
await sub_AddQBMethod( "FUNCTION", "Mkl$", False);
|
||||||
|
await sub_AddQBMethod( "FUNCTION", "Point", False);
|
||||||
await sub_AddQBMethod( "SUB", "Print", True);
|
await sub_AddQBMethod( "SUB", "Print", True);
|
||||||
await sub_AddQBMethod( "SUB", "PSet", False);
|
await sub_AddQBMethod( "SUB", "PSet", False);
|
||||||
await sub_AddQBMethod( "FUNCTION", "Right$", False);
|
await sub_AddQBMethod( "FUNCTION", "Right$", False);
|
||||||
|
|
|
@ -2657,6 +2657,7 @@ Sub InitQBMethods
|
||||||
AddQBMethod "FUNCTION", "Cvl", False
|
AddQBMethod "FUNCTION", "Cvl", False
|
||||||
AddQBMethod "FUNCTION", "Exp", False
|
AddQBMethod "FUNCTION", "Exp", False
|
||||||
AddQBMethod "FUNCTION", "Fix", False
|
AddQBMethod "FUNCTION", "Fix", False
|
||||||
|
AddQBMethod "FUNCTION", "Hex$", False
|
||||||
AddQBMethod "SUB", "Input", True
|
AddQBMethod "SUB", "Input", True
|
||||||
AddQBMethod "FUNCTION", "InKey$", False
|
AddQBMethod "FUNCTION", "InKey$", False
|
||||||
AddQBMethod "FUNCTION", "InStr", False
|
AddQBMethod "FUNCTION", "InStr", False
|
||||||
|
@ -2672,6 +2673,7 @@ Sub InitQBMethods
|
||||||
AddQBMethod "FUNCTION", "Mid$", False
|
AddQBMethod "FUNCTION", "Mid$", False
|
||||||
AddQBMethod "FUNCTION", "Mki$", False
|
AddQBMethod "FUNCTION", "Mki$", False
|
||||||
AddQBMethod "FUNCTION", "Mkl$", False
|
AddQBMethod "FUNCTION", "Mkl$", False
|
||||||
|
AddQBMethod "FUNCTION", "Point", False
|
||||||
AddQBMethod "SUB", "Print", True
|
AddQBMethod "SUB", "Print", True
|
||||||
AddQBMethod "SUB", "PSet", False
|
AddQBMethod "SUB", "PSet", False
|
||||||
AddQBMethod "FUNCTION", "Right$", False
|
AddQBMethod "FUNCTION", "Right$", False
|
||||||
|
|
Loading…
Reference in a new issue