mirror of
https://github.com/boxgaming/qbjs.git
synced 2024-09-19 20:14:58 +00:00
Added remaining trig and hyperbolic functions.
This commit is contained in:
parent
a528e50b81
commit
4d092eb680
4 changed files with 59 additions and 5 deletions
|
@ -35,11 +35,11 @@ CodeMirror.defineMode("qbjs", function(conf, parserConf) {
|
|||
// TODO: adjust for QB
|
||||
var atomWords = ['true', 'false', 'nothing', 'empty', 'null'];
|
||||
|
||||
var builtinFuncsWords = ['_alpha', '_alpha32', '_atan2', '_autodisplay', '_blue', '_blue32', '_continue', '_copyimage', '_cosh', '_d2r', '_delay', '_dest',
|
||||
var builtinFuncsWords = ['_acos', '_acosh', '_alpha', '_alpha32', '_asin', '_asinh', '_atan2', '_atanh', '_autodisplay', '_blue', '_blue32', '_continue', '_copyimage', '_cosh', '_coth', '_csch', '_d2r', '_delay', '_dest',
|
||||
'_display', '_fontwidth', '_freeimage', '_fullscreen', '_green', '_green32', '_height', '_instrrev', '_limit', '_keyclear', '_keydown',
|
||||
'_keyhit', '_loadimage', '_mousebutton', '_mouseinput', '_mousex', '_mousey', '_newimage', '_pi', '_printstring', '_printwidth',
|
||||
'_putimage', '_r2d', '_red', '_red32', '_resize', '_resizewidth', '_resizeheight', '_rgb', '_rgba', '_rgb32', '_rgba32', '_round',
|
||||
'_screenexists', '_sinh', '_source', '_sndclose', '_sndopen', '_sndplay', '_sndloop', '_sndpause', '_sndstop', '_sndvol',
|
||||
'_screenexists', '_sech', '_sinh', '_source', '_sndclose', '_sndopen', '_sndplay', '_sndloop', '_sndpause', '_sndstop', '_sndvol', '_tanh',
|
||||
'_title', '_trim', '_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',
|
||||
|
|
42
qb.js
42
qb.js
|
@ -152,6 +152,15 @@ var QB = new function() {
|
|||
|
||||
// Extended QB64 Keywords
|
||||
// --------------------------------------------
|
||||
|
||||
this.func__Acos = function(x) {
|
||||
return Math.acos(x);
|
||||
};
|
||||
|
||||
this.func__Acosh = function(x) {
|
||||
return Math.acosh(x);
|
||||
};
|
||||
|
||||
this.func__Alpha = function(rgb, imageHandle) {
|
||||
// TODO: implement corresponding logic when an image handle is supplied (maybe)
|
||||
return _color(rgb).a;
|
||||
|
@ -162,6 +171,18 @@ var QB = new function() {
|
|||
return _color(rgb).a;
|
||||
};
|
||||
|
||||
this.func__Asin = function(x) {
|
||||
return Math.asin(x);
|
||||
};
|
||||
|
||||
this.func__Asinh = function(x) {
|
||||
return Math.asinh(x);
|
||||
};
|
||||
|
||||
this.func__Atanh = function(x) {
|
||||
return Math.atanh(x);
|
||||
};
|
||||
|
||||
this.func__Atan2 = function(y, x) {
|
||||
return Math.atan2(y, x);
|
||||
};
|
||||
|
@ -191,7 +212,15 @@ var QB = new function() {
|
|||
};
|
||||
|
||||
this.func__Cosh = function(x) {
|
||||
return (Math.exp(x)+Math.exp(-x))/2;
|
||||
return Math.cosh(x);
|
||||
};
|
||||
|
||||
this.func__Coth = function(x) {
|
||||
return 1/Math.tanh(x);
|
||||
};
|
||||
|
||||
this.func__Csch = function(x) {
|
||||
return 1/Math.sinh(x);
|
||||
};
|
||||
|
||||
this.func__D2R = function(x) {
|
||||
|
@ -556,8 +585,12 @@ var QB = new function() {
|
|||
return true;
|
||||
};
|
||||
|
||||
this.func__Sech = function(x) {
|
||||
return 1/Math.cosh(x);
|
||||
};
|
||||
|
||||
this.func__Sinh = function(x) {
|
||||
return (Math.exp(x)-Math.exp(-x))/2;
|
||||
return Math.sinh(x);
|
||||
};
|
||||
|
||||
this.func__Source = function() {
|
||||
|
@ -595,6 +628,9 @@ var QB = new function() {
|
|||
GX.soundVolumne(sid, v);
|
||||
};
|
||||
|
||||
this.func__Tanh = function(x) {
|
||||
return Math.tanh(x);
|
||||
};
|
||||
|
||||
this.sub__Title = function(title) {
|
||||
document.title = title;
|
||||
|
@ -616,7 +652,7 @@ var QB = new function() {
|
|||
if (imageId == undefined) { imageId = _activeImage; }
|
||||
return _images[imageId].canvas.width;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// QB45 Keywords
|
||||
// --------------------------------------------
|
||||
|
|
9
qb2js.js
9
qb2js.js
|
@ -2759,6 +2759,11 @@ async function sub_InitQBMethods() {
|
|||
if (QB.halted()) { return; }
|
||||
await sub_AddQBMethod( "FUNCTION", "_Alpha", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Alpha32", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Acos", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Acosh", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Atanh", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Asin", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Asinh", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Atan2", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_AutoDisplay", False);
|
||||
await sub_AddQBMethod( "SUB", "_AutoDisplay", False);
|
||||
|
@ -2766,6 +2771,8 @@ if (QB.halted()) { return; }
|
|||
await sub_AddQBMethod( "FUNCTION", "_Blue32", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_CopyImage", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Cosh", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Coth", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Csch", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_D2R", False);
|
||||
await sub_AddQBMethod( "SUB", "_Delay", True);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Dest", False);
|
||||
|
@ -2806,6 +2813,7 @@ if (QB.halted()) { return; }
|
|||
await sub_AddQBMethod( "FUNCTION", "_RGBA32", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Round", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_ScreenExists", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Sech", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Sinh", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Source", False);
|
||||
await sub_AddQBMethod( "SUB", "_Source", False);
|
||||
|
@ -2816,6 +2824,7 @@ if (QB.halted()) { return; }
|
|||
await sub_AddQBMethod( "SUB", "_SndPause", False);
|
||||
await sub_AddQBMethod( "SUB", "_SndStop", False);
|
||||
await sub_AddQBMethod( "SUB", "_SndVol", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Tanh", False);
|
||||
await sub_AddQBMethod( "SUB", "_Title", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Trim", False);
|
||||
await sub_AddQBMethod( "FUNCTION", "_Width", False);
|
||||
|
|
|
@ -2947,6 +2947,11 @@ Sub InitQBMethods
|
|||
' ----------------------------------------------------------
|
||||
AddQBMethod "FUNCTION", "_Alpha", False
|
||||
AddQBMethod "FUNCTION", "_Alpha32", False
|
||||
AddQBMethod "FUNCTION", "_Acos", False
|
||||
AddQBMethod "FUNCTION", "_Acosh", False
|
||||
AddQBMethod "FUNCTION", "_Atanh", False
|
||||
AddQBMethod "FUNCTION", "_Asin", False
|
||||
AddQBMethod "FUNCTION", "_Asinh", False
|
||||
AddQBMethod "FUNCTION", "_Atan2", False
|
||||
AddQBMethod "FUNCTION", "_AutoDisplay", False
|
||||
AddQBMethod "SUB", "_AutoDisplay", False
|
||||
|
@ -2954,6 +2959,8 @@ Sub InitQBMethods
|
|||
AddQBMethod "FUNCTION", "_Blue32", False
|
||||
AddQBMethod "FUNCTION", "_CopyImage", False
|
||||
AddQBMethod "FUNCTION", "_Cosh", False
|
||||
AddQBMethod "FUNCTION", "_Coth", False
|
||||
AddQBMethod "FUNCTION", "_Csch", False
|
||||
AddQBMethod "FUNCTION", "_D2R", False
|
||||
AddQBMethod "SUB", "_Delay", True
|
||||
AddQBMethod "FUNCTION", "_Dest", False
|
||||
|
@ -2994,6 +3001,7 @@ Sub InitQBMethods
|
|||
AddQBMethod "FUNCTION", "_RGBA32", False
|
||||
AddQBMethod "FUNCTION", "_Round", False
|
||||
AddQBMethod "FUNCTION", "_ScreenExists", False
|
||||
AddQBMethod "FUNCTION", "_Sech", False
|
||||
AddQBMethod "FUNCTION", "_Sinh", False
|
||||
AddQBMethod "FUNCTION", "_Source", False
|
||||
AddQBMethod "SUB", "_Source", False
|
||||
|
@ -3004,6 +3012,7 @@ Sub InitQBMethods
|
|||
AddQBMethod "SUB", "_SndPause", False
|
||||
AddQBMethod "SUB", "_SndStop", False
|
||||
AddQBMethod "SUB", "_SndVol", False
|
||||
AddQBMethod "FUNCTION", "_Tanh", False
|
||||
AddQBMethod "SUB", "_Title", False
|
||||
AddQBMethod "FUNCTION", "_Trim", False
|
||||
AddQBMethod "FUNCTION", "_Width", False
|
||||
|
|
Loading…
Reference in a new issue