diff --git a/codemirror/qb-lang.js b/codemirror/qb-lang.js index b1e15d7..5564736 100644 --- a/codemirror/qb-lang.js +++ b/codemirror/qb-lang.js @@ -35,15 +35,27 @@ CodeMirror.defineMode("qbjs", function(conf, parserConf) { // TODO: adjust for QB var atomWords = ['true', 'false', 'nothing', 'empty', 'null']; - 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', '_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', 'cdbl', 'cint', 'clng', 'csng', 'circle', 'cls', 'color', 'command', 'cos', 'cvi', 'cvl', 'data', 'date', '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', + 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', + '_palettecolor', '_pi', '_printstring', '_printwidth', '_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', 'cdbl', 'cint', 'clng', 'csng', 'circle', 'cls', 'color', 'command', 'cos', 'cvi', 'cvl', + 'data', 'date', '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', // QBJS-specific 'export', 'from', 'import', '_label'] diff --git a/qb.js b/qb.js index 126520e..1b1717d 100644 --- a/qb.js +++ b/qb.js @@ -127,6 +127,7 @@ var QB = new function() { _rndSeed = 327680; _runningFlag = true; _sourceImage = 0; + _initColorTable(); GX._enableTouchMouse(true); GX.registerGameEvents(function(e){}); QB.sub_Screen(0); @@ -412,6 +413,10 @@ var QB = new function() { return tmpId; }; + this.sub__PaletteColor = function(x, y) { + _colormap[x] = _color(y); + }; + this.sub__PrintString = function(x, y, s) { // TODO: check the background opacity mode // Draw the text background diff --git a/qb2js.js b/qb2js.js index 8f046a4..cc3a265 100644 --- a/qb2js.js +++ b/qb2js.js @@ -2833,6 +2833,7 @@ if (QB.halted()) { return; } await sub_AddQBMethod( "FUNCTION", "_MouseY", False); await sub_AddQBMethod( "FUNCTION", "_NewImage", False); await sub_AddQBMethod( "FUNCTION", "_Pi", False); + await sub_AddQBMethod( "SUB", "_PaletteColor", False); await sub_AddQBMethod( "SUB", "_PrintString", False); await sub_AddQBMethod( "FUNCTION", "_PrintWidth", False); await sub_AddQBMethod( "SUB", "_PutImage", False); diff --git a/tools/qb2js.bas b/tools/qb2js.bas index ca6e0f5..6307582 100644 --- a/tools/qb2js.bas +++ b/tools/qb2js.bas @@ -2,7 +2,9 @@ Option _Explicit $Console:Only '$ExeIcon:'./../gx/resource/gx.ico' -' In console, after creating qb2js.exe, run: qb2js qb2js.bas > ../qb2js.js +'1) Edit this file as needed. +'2) Compile to EXE only. +'3) In console, run: qb2js qb2js.bas > ../qb2js.js Const FILE = 1 Const TEXT = 2 @@ -3015,6 +3017,7 @@ Sub InitQBMethods AddQBMethod "FUNCTION", "_MouseY", False AddQBMethod "FUNCTION", "_NewImage", False AddQBMethod "FUNCTION", "_Pi", False + AddQBMethod "SUB", "_PaletteColor", False AddQBMethod "SUB", "_PrintString", False AddQBMethod "FUNCTION", "_PrintWidth", False AddQBMethod "SUB", "_PutImage", False