diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index d367753..1c710cf 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -1339,6 +1339,18 @@ class BuiltinFunction { return p.sprite.spchk(id); } + static void SPPAGE(PetitComputer p, int page) + { + if (!p.isValidGraphicPage(page)) + { + throw new OutOfRange("SPPAGE", 1); + } + p.sprite.sppage = page; + } + static int SPPAGE(PetitComputer p) + { + return p.sprite.sppage; + } static void BGMSTOP(PetitComputer p) { writeln("NOTIMPL:BGMSTOP"); @@ -1486,6 +1498,18 @@ class BuiltinFunction { p.getBG(layer).fill(x, y, x2, y2, screendata); } + static void BGPAGE(PetitComputer p, int page) + { + if (!p.isValidGraphicPage(page)) + { + throw new OutOfRange("BGPAGE", 1); + } + p.bgpage = page; + } + static int BGPAGE(PetitComputer p) + { + return p.bgpage; + } static void EFCON() { } diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index 5f6ac47..36c43f2 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -267,7 +267,7 @@ class PetitComputer this.y = y; } } - int sppage, bgpage; + int bgpage; Projects project; wstring currentProject; void init() @@ -453,6 +453,7 @@ class PetitComputer { return bg; } + //TODO:extract class bool[2] BGvisibles = [true, true]; bool BGvisible() { @@ -508,7 +509,7 @@ class PetitComputer { graphic.GRP[i] = createEmptyPage(); } - sppage = 4; + sprite.sppage = 4; graphic.GRP[4] = createGRPF(spriteFile); bgpage = 5; graphic.GRP[5] = createGRPF(BGFile); @@ -848,7 +849,6 @@ class PetitComputer keybuffer = new Key[128]; init(); graphic = new Graphic(this); - consolem = new Mutex(); keybuffermutex = new Mutex(); grpmutex = new Mutex(); sprite = new Sprite(this); @@ -1232,7 +1232,10 @@ class PetitComputer keybufferlen--; return result.key.to!wstring; } - Mutex consolem; + public bool isValidGraphicPage(int page) + { + return page >= 0 && page < 6; + } //プチコン内部表現はRGB5_A1 static uint toGLColor(GLenum format, ubyte r, ubyte g, ubyte b, ubyte a) { diff --git a/SMILEBASIC/sprite.d b/SMILEBASIC/sprite.d index 55298a4..94271ba 100644 --- a/SMILEBASIC/sprite.d +++ b/SMILEBASIC/sprite.d @@ -584,6 +584,7 @@ class Sprite SpriteBucket[] buckets; SpriteBucket* listptr; SpriteBucket* bucketsptr; + int sppage; void render() { if ((!visibles[0] && !visibles[1]) || (petitcom.xscreenmode == 2 && !visibles[0])) @@ -665,7 +666,7 @@ class Sprite dish2 = 480f; dis = -1; } - auto texture = petitcom.graphic.GRP[petitcom.sppage].glTexture; + auto texture = petitcom.graphic.GRP[sppage].glTexture; float aspect = disw2 / dish2; float z = -0.01f; int spmax = petitcom.xscreenmode == 1 ? this.spmax : 512;//XSCREENが2,3じゃないと下画面は描画しない