diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index 433698f..443fe6a 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -1920,6 +1920,18 @@ class BuiltinFunction } p.sprite.sphome(i, hx, hy); } + static void SPHOME(PetitComputer p, int i, out int hx, out int hy) + { + if (!p.sprite.isValidSpriteId(i)) + { + throw new OutOfRange(smilebasicFunctionName, 1); + } + if (!p.sprite.isSpriteDefined(i)) + { + throw new IllegalFunctionCall("SPHOME", 1); + } + p.sprite.getsphome(i, hx, hy); + } static void SPSCALE(PetitComputer p, int i, double x, double y) { if (!p.sprite.isValidSpriteId(i)) @@ -1956,6 +1968,18 @@ class BuiltinFunction } p.sprite.sprot(i, rot); } + static void SPROT(PetitComputer p, int i, out double rot) + { + if (!p.sprite.isValidSpriteId(i)) + { + throw new OutOfRange(smilebasicFunctionName, 1); + } + if (!p.sprite.isSpriteDefined(i)) + { + throw new IllegalFunctionCall("SPROT", 1); + } + p.sprite.getsprot(i, rot); + } static void SPCOLOR(PetitComputer p, int id, int color) { if (!p.sprite.isValidSpriteId(id)) @@ -1968,6 +1992,18 @@ class BuiltinFunction } p.sprite.spcolor(id, cast(uint)color); } + static void SPCOLOR(PetitComputer p, int id, out int color) + { + if (!p.sprite.isValidSpriteId(id)) + { + throw new OutOfRange(smilebasicFunctionName, 1); + } + if (!p.sprite.isSpriteDefined(id)) + { + throw new IllegalFunctionCall("SPCOLOR", 1); + } + p.sprite.getspcolor(id, color); + } static void SPLINK(PetitComputer p, int child, int parent) { if (!p.sprite.isValidSpriteId(child)) diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index 6e32d73..d739aff 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -250,6 +250,11 @@ class PetitComputer //ARGB -> ABGR return (color & 0xFF00FF00) | (color >> 16 & 0xFF) | ((color & 0xFF) << 16); } + uint fromGLColor(uint color) + { + //ARGB <- ABGR + return (color & 0xFF00FF00) | (color >> 16 & 0xFF) | ((color & 0xFF) << 16); + } struct ConsoleCharacter { wchar character; diff --git a/SMILEBASIC/sprite.d b/SMILEBASIC/sprite.d index 512da81..3cbbb7a 100644 --- a/SMILEBASIC/sprite.d +++ b/SMILEBASIC/sprite.d @@ -1021,6 +1021,15 @@ class Sprite sprites[i].homey = hy; } } + void getsphome(int i, out int hx, out int hy) + { + i = spid(i); + synchronized (this) + { + hx = sprites[i].homex; + hy = sprites[i].homey; + } + } void spscale(int i, double x, double y) { i = spid(i); @@ -1044,11 +1053,21 @@ class Sprite i = spid(i); sprites[i].r = rot; } + void getsprot(int i, out double rot) + { + i = spid(i); + rot = sprites[i].r; + } void spcolor(int id, uint color) { id = spid(id); sprites[id].color = petitcom.toGLColor(color); } + void getspcolor(int id, out int color) + { + id = spid(id); + petitcom.fromGLColor(sprites[id].color); + } void splink(int child, int parent) { if(parent >= child)