From 8faa3242b26a7db98290669b3db57ab7e3138849 Mon Sep 17 00:00:00 2001 From: otya128 Date: Sat, 10 Dec 2016 22:31:36 +0900 Subject: [PATCH] Fix BG/SPPAGE --- SMILEBASIC/builtinfunctions.d | 8 ++++---- SMILEBASIC/petitcomputer.d | 9 +++++---- SMILEBASIC/sprite.d | 8 ++++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index 8acd05e..62dc722 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -1428,11 +1428,11 @@ class BuiltinFunction { throw new OutOfRange("SPPAGE", 1); } - p.sprite.sppage = page; + p.sprite.sppage[p.displaynum] = page; } static int SPPAGE(PetitComputer p) { - return p.sprite.sppage; + return p.sprite.sppage[p.displaynum]; } static void SPCLIP(PetitComputer p) { @@ -1668,11 +1668,11 @@ class BuiltinFunction { throw new OutOfRange("BGPAGE", 1); } - p.bgpage = page; + p.bgpage[p.displaynum] = page; } static int BGPAGE(PetitComputer p) { - return p.bgpage; + return p.bgpage[p.displaynum]; } static void BGSHOW(PetitComputer p, int layer) { diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index 3b2da23..95c3ec3 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -208,7 +208,7 @@ class PetitComputer this.y = y; } } - int bgpage; + int[2] bgpage; Projects project; wstring currentProject; void init() @@ -506,8 +506,8 @@ class PetitComputer DerelictSDL2.load(); DerelictSDL2Image.load(); graphic.initGraphicPages(); - sprite.sppage = 4; - bgpage = 5; + sprite.sppage[] = 4; + bgpage[] = 5; SDL_Init(SDL_INIT_VIDEO); DerelictGL.load(); @@ -650,11 +650,11 @@ class PetitComputer } version(test) glLoadIdentity(); version(test) glRotatef(rot_test_deg, rot_test_x, rot_test_y, rot_test_z); - glBindTexture(GL_TEXTURE_2D, graphic.GRP[bgpage].glTexture); if (BGvisibles[0]) { chRenderingDisplay(0); + glBindTexture(GL_TEXTURE_2D, graphic.GRP[bgpage[0]].glTexture); for(int i = 0; i < bgmax; i++) { bg[i].render(0, currentDisplay.rect[0].w, currentDisplay.rect[0].h); @@ -663,6 +663,7 @@ class PetitComputer if(currentDisplay.rect.length > 1 && BGvisibles[1]) { chRenderingDisplay(1); + glBindTexture(GL_TEXTURE_2D, graphic.GRP[bgpage[0]].glTexture); for(int i = bgmax; i < bg.length; i++) { bg[i].render(1, currentDisplay.rect[1].w, currentDisplay.rect[1].h); diff --git a/SMILEBASIC/sprite.d b/SMILEBASIC/sprite.d index 6429c3d..0822211 100644 --- a/SMILEBASIC/sprite.d +++ b/SMILEBASIC/sprite.d @@ -584,7 +584,7 @@ class Sprite SpriteBucket[] buckets; SpriteBucket* listptr; SpriteBucket* bucketsptr; - int sppage; + int[2] sppage; void render() { if ((!visibles[0] && !visibles[1]) || (petitcom.xscreenmode == 2 && !visibles[0])) @@ -672,7 +672,7 @@ class Sprite dish2 = 480f; dis = -1; } - auto texture = petitcom.graphic.GRP[sppage].glTexture; + auto texture = petitcom.graphic.GRP[sppage[0]].glTexture; float aspect = disw2 / dish2; float z = -0.01f; int spmax = petitcom.xscreenmode == 1 ? this.spmax : 512;//XSCREENが2,3じゃないと下画面は描画しない @@ -702,6 +702,8 @@ class Sprite disw2 = petitcom.currentDisplay.rect[1].w; petitcom.chRenderingDisplay(1, clipRect[1].x, clipRect[1].y, clipRect[1].w, clipRect[1].h); aspect = disw2 / dish2; + texture = petitcom.graphic.GRP[sppage[1]].glTexture; + glBindTexture(GL_TEXTURE_2D, texture); } else { @@ -714,6 +716,8 @@ class Sprite disw2 = petitcom.currentDisplay.rect[0].w; petitcom.chRenderingDisplay(0, clipRect[0].x, clipRect[0].y, clipRect[0].w, clipRect[0].h); aspect = disw2 / dish2; + texture = petitcom.graphic.GRP[sppage[0]].glTexture; + glBindTexture(GL_TEXTURE_2D, texture); } } if (!visibles[dis])