1
1
Fork 0
mirror of https://github.com/boxgaming/qbjs.git synced 2024-09-19 20:14:58 +00:00

Added keywords: _Readbit, _Setbit, _Resetbit, _Togglebit.

This commit is contained in:
William Barnes 2022-06-15 14:59:47 -04:00
parent 181d7ac281
commit f5fc0c9cd3
4 changed files with 38 additions and 6 deletions

View file

@ -38,9 +38,9 @@ CodeMirror.defineMode("qbjs", function(conf, parserConf) {
var builtinFuncsWords = ['_acos', '_acosh', '_alpha', '_alpha32', '_asin', '_asinh', '_atan2', '_atanh', '_autodisplay', '_blue', '_blue32', '_ceil', '_continue', '_copyimage', '_cosh', '_coth', '_csch', '_d2g', '_d2r', '_delay', '_dest',
'_display', '_fontwidth', '_freeimage', '_fullscreen', '_g2d', '_g2r', '_green', '_green32', '_height', '_hypot', '_instrrev', '_limit', '_keyclear', '_keydown',
'_keyhit', '_loadimage', '_mousebutton', '_mouseinput', '_mousex', '_mousey', '_newimage', '_pi', '_printstring', '_printwidth',
'_putimage', '_r2d', '_r2g', '_red', '_red32', '_resize', '_resizewidth', '_resizeheight', '_rgb', '_rgba', '_rgb32', '_rgba32', '_round',
'_screenexists', '_sech', '_shl', '_shr', '_sinh', '_source', '_sndclose', '_sndopen', '_sndplay', '_sndloop', '_sndpause', '_sndstop', '_sndvol', '_strcmp', '_stricmp', '_tanh',
'_title', '_trim', '_width', 'abs', 'asc', 'atn', 'beep', 'chr', 'circle', 'cls', 'color', 'command', 'cos', 'cvi', 'cvl', 'data', 'draw', 'exp',
'_putimage', '_r2d', '_r2g', '_readbit', '_red', '_red32', '_resetbit', '_resize', '_resizewidth', '_resizeheight', '_rgb', '_rgba', '_rgb32', '_rgba32', '_round',
'_screenexists', '_sech', '_setbit', '_shl', '_shr', '_sinh', '_source', '_sndclose', '_sndopen', '_sndplay', '_sndloop', '_sndpause', '_sndstop', '_sndvol', '_strcmp', '_stricmp', '_tanh',
'_title', '_trim', '_togglebit', '_width', 'abs', 'asc', 'atn', 'beep', 'chr', 'circle', 'cls', 'color', 'command', 'cos', 'cvi', 'cvl', 'data', 'draw', 'exp',
'fix', 'hex', 'input', 'inkey', 'instr', 'int', 'lbound', 'left', 'lcase', 'len', 'line', 'locate', 'log', 'ltrim', 'mid', 'mki', 'mkl',
'oct', 'paint', 'point', 'preset', 'print', 'pset', 'right', 'rtrim', 'randomize', 'read', 'restore', 'rnd', 'screen', 'shared', 'sgn', 'sin', 'sleep', 'space', 'sqr',
'str', 'swap', 'tan', 'time', 'timer', 'ubound', 'ucase', 'val', 'varptr', 'window',

28
qb.js
View file

@ -547,6 +547,15 @@ var QB = new function() {
return (x*(9/10))*180/Math.PI;
};
this.func__Readbit= function(x, y) {
var mask = 1 << y;
if ((x & mask) != 0) {
return -1;
} else {
return 0;
}
};
this.func__Red = function(rgb, imageHandle) {
// TODO: implement corresponding logic when an image handle is supplied (maybe)
return _color(rgb).r;
@ -557,6 +566,11 @@ var QB = new function() {
return _color(rgb).r;
};
this.func__Resetbit = function(x, y) {
var mask = 1 << y;
return x & ~mask;
};
this.func__Resize = function() {
var tmp = _resize;
_resize = false;
@ -613,6 +627,11 @@ var QB = new function() {
return 1/Math.cosh(x);
};
this.func__Setbit = function(x, y) {
var mask = 1 << y;
return x | mask;
};
this.func__Shl = function(x, y) {
return x << y;
};
@ -661,13 +680,13 @@ var QB = new function() {
};
this.func__Strcmp = function(x, y) {
return ( ( x == y ) ? 0 : ( ( x > y ) ? 1 : -1 ) );
return (( x == y ) ? 0 : (( x > y ) ? 1 : -1 ));
};
this.func__Stricmp = function(x, y) {
var a = x.toLowerCase();
var b = y.toLowerCase();
return ( ( a == b ) ? 0 : ( ( a > b ) ? 1 : -1 ) );
return (( a == b ) ? 0 : (( a > b ) ? 1 : -1 ));
};
this.func__Tanh = function(x) {
@ -682,6 +701,11 @@ var QB = new function() {
return value.trim();
};
this.func__Togglebit = function(x, y) {
var mask = 1 << y;
return x ^ mask;
};
this.func__Width = function(imageId) {
if (imageId == undefined) { imageId = _activeImage; }
if (_images[imageId].charSizeMode) {

View file

@ -2808,8 +2808,10 @@ if (QB.halted()) { return; }
await sub_AddQBMethod( "SUB", "_PutImage", False);
await sub_AddQBMethod( "FUNCTION", "_R2D", False);
await sub_AddQBMethod( "FUNCTION", "_R2G", False);
await sub_AddQBMethod( "FUNCTION", "_Readbit", False);
await sub_AddQBMethod( "FUNCTION", "_Red", False);
await sub_AddQBMethod( "FUNCTION", "_Red32", False);
await sub_AddQBMethod( "FUNCTION", "_Resetbit", False);
await sub_AddQBMethod( "FUNCTION", "_Resize", False);
await sub_AddQBMethod( "FUNCTION", "_ResizeHeight", False);
await sub_AddQBMethod( "FUNCTION", "_ResizeWidth", False);
@ -2820,6 +2822,7 @@ if (QB.halted()) { return; }
await sub_AddQBMethod( "FUNCTION", "_Round", False);
await sub_AddQBMethod( "FUNCTION", "_ScreenExists", False);
await sub_AddQBMethod( "FUNCTION", "_Sech", False);
await sub_AddQBMethod( "FUNCTION", "_Setbit", False);
await sub_AddQBMethod( "FUNCTION", "_Shl", False);
await sub_AddQBMethod( "FUNCTION", "_Shr", False);
await sub_AddQBMethod( "FUNCTION", "_Sinh", False);
@ -2836,6 +2839,7 @@ if (QB.halted()) { return; }
await sub_AddQBMethod( "FUNCTION", "_Stricmp", False);
await sub_AddQBMethod( "FUNCTION", "_Tanh", False);
await sub_AddQBMethod( "SUB", "_Title", False);
await sub_AddQBMethod( "FUNCTION", "_Togglebit", False);
await sub_AddQBMethod( "FUNCTION", "_Trim", False);
await sub_AddQBMethod( "FUNCTION", "_Width", False);
await sub_AddQBMethod( "FUNCTION", "Abs", False);

View file

@ -2996,8 +2996,10 @@ Sub InitQBMethods
AddQBMethod "SUB", "_PutImage", False
AddQBMethod "FUNCTION", "_R2D", False
AddQBMethod "FUNCTION", "_R2G", False
AddQBMethod "FUNCTION", "_Readbit", False
AddQBMethod "FUNCTION", "_Red", False
AddQBMethod "FUNCTION", "_Red32", False
AddQBMethod "FUNCTION", "_Resetbit", False
AddQBMethod "FUNCTION", "_Resize", False
AddQBMethod "FUNCTION", "_ResizeHeight", False
AddQBMethod "FUNCTION", "_ResizeWidth", False
@ -3008,6 +3010,7 @@ Sub InitQBMethods
AddQBMethod "FUNCTION", "_Round", False
AddQBMethod "FUNCTION", "_ScreenExists", False
AddQBMethod "FUNCTION", "_Sech", False
AddQBMethod "FUNCTION", "_Setbit", False
AddQBMethod "FUNCTION", "_Shl", False
AddQBMethod "FUNCTION", "_Shr", False
AddQBMethod "FUNCTION", "_Sinh", False
@ -3021,9 +3024,10 @@ Sub InitQBMethods
AddQBMethod "SUB", "_SndStop", False
AddQBMethod "SUB", "_SndVol", False
AddQBMethod "FUNCTION", "_Strcmp", False
AddQBMethod "FUNCTION", "_Stricmp", False
AddQBMethod "FUNCTION", "_Stricmp", False
AddQBMethod "FUNCTION", "_Tanh", False
AddQBMethod "SUB", "_Title", False
AddQBMethod "FUNCTION", "_Togglebit", False
AddQBMethod "FUNCTION", "_Trim", False
AddQBMethod "FUNCTION", "_Width", False