1
0

Implement VISIBLE

This commit is contained in:
otya128
2016-12-04 18:43:30 +09:00
parent 19a20f7c5a
commit 4fb9c55cec
5 changed files with 148 additions and 75 deletions

View File

@@ -268,8 +268,17 @@ class BuiltinFunction
} }
return p.button; return p.button;
} }
static void VISIBLE(PetitComputer p, DefaultValue!(int) console, DefaultValue!(int) graphic, DefaultValue!(int) BG, DefaultValue!(int) sprite) static void VISIBLE(PetitComputer p, int console, int graphic, int BG, int sprite)
{ {
import std.exception : enforce;
enforce(console == 0 || console == 1, new OutOfRange("VISIBLE", 1));
enforce(graphic == 0 || graphic == 1, new OutOfRange("VISIBLE", 2));
enforce(BG == 0 || BG == 1, new OutOfRange("VISIBLE", 3));
enforce(sprite == 0 || sprite == 1, new OutOfRange("VISIBLE", 4));
p.console.visible = cast(bool)console;
p.graphic.visible = cast(bool)graphic;
p.BGvisible = cast(bool)BG;
p.sprite.visible = cast(bool)sprite;
} }
static void XON(PetitComputer p, Value mode/*!?!???!?*/) static void XON(PetitComputer p, Value mode/*!?!???!?*/)
{ {

View File

@@ -75,6 +75,15 @@ class Console
SDL_Rect[] fontTable = new SDL_Rect[65536]; SDL_Rect[] fontTable = new SDL_Rect[65536];
GraphicPage GRPF; GraphicPage GRPF;
PetitComputer petitcom; PetitComputer petitcom;
bool[2] visibles = [true, true];
bool visible()
{
return visibles[petitcom.displaynum];
}
void visible(bool value)
{
visibles[petitcom.displaynum] = value;
}
this(PetitComputer p) this(PetitComputer p)
{ {
petitcom = p; petitcom = p;
@@ -253,7 +262,7 @@ class Console
} }
void render() void render()
{ {
if(petitcom.xscreenmode == 2) if(petitcom.xscreenmode == 2 && (visibles[0] || showCursor)/*XSCREEN4*/)
{ {
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture); glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
@@ -291,6 +300,8 @@ class Console
glEnd(); glEnd();
return; return;
} }
if (showCursor || visibles[0])
{
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture); glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glBegin(GL_QUADS); glBegin(GL_QUADS);
@@ -329,6 +340,9 @@ class Console
{ {
return; return;
} }
}
if (visibles[1] || showCursor)
{
//下画面 //下画面
petitcom.chScreen(40, 0, 400, 240); petitcom.chScreen(40, 0, 400, 240);
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture); glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
@@ -366,6 +380,7 @@ class Console
} }
glEnd(); glEnd();
} }
}
void print(T...)(T args) void print(T...)(T args)
{ {
foreach(i; args) foreach(i; args)

View File

@@ -15,9 +15,17 @@ class Graphic
paint.buffer = new uint[512 * 512]; paint.buffer = new uint[512 * 512];
} }
bool visibleGRP = true; bool[2] visibles = [true, true];
private int[2] showPage = [0, 1]; private int[2] showPage = [0, 1];
private int[2] usePage = [0, 1]; private int[2] usePage = [0, 1];
bool visible()
{
return visibles[petitcom.displaynum];
}
void visible(bool value)
{
visibles[petitcom.displaynum] = value;
}
@property int useGRP() @property int useGRP()
{ {
return usePage[petitcom.displaynum]; return usePage[petitcom.displaynum];
@@ -471,6 +479,8 @@ class Graphic
int gprio; int gprio;
void render(int display, float w, float h) void render(int display, float w, float h)
{ {
if (!visibles[display])
return;
float z = gprio; float z = gprio;
glColor3f(1.0, 1.0, 1.0); glColor3f(1.0, 1.0, 1.0);
glBindTexture(GL_TEXTURE_2D, GRP[showPage[display]].glTexture); glBindTexture(GL_TEXTURE_2D, GRP[showPage[display]].glTexture);

View File

@@ -413,6 +413,15 @@ class PetitComputer
{ {
return bg; return bg;
} }
bool[2] BGvisibles = [true, true];
bool BGvisible()
{
return BGvisibles[displaynum];
}
void BGvisible(bool value)
{
BGvisibles[displaynum] = value;
}
protected BG[4] bg; protected BG[4] bg;
bool quit; bool quit;
Condition renderCondition; Condition renderCondition;
@@ -586,7 +595,7 @@ class PetitComputer
version(test) glLoadIdentity(); version(test) glLoadIdentity();
version(test) glRotatef(rot_test_deg, rot_test_x, rot_test_y, rot_test_z); version(test) glRotatef(rot_test_deg, rot_test_x, rot_test_y, rot_test_z);
glBindTexture(GL_TEXTURE_2D, graphic.GRP[bgpage].glTexture); glBindTexture(GL_TEXTURE_2D, graphic.GRP[bgpage].glTexture);
if(xscreenmode == 2) if(xscreenmode == 2 && BGvisibles[0])
{ {
for(int i = 0; i < bgmax; i++) for(int i = 0; i < bgmax; i++)
{ {
@@ -594,18 +603,24 @@ class PetitComputer
} }
} }
else else
{
if (BGvisibles[0])
{ {
for(int i = 0; i < bgmax; i++) for(int i = 0; i < bgmax; i++)
{ {
bg[i].render(400f, 240f); bg[i].render(400f, 240f);
} }
}
if(xscreenmode == 1) if(xscreenmode == 1)
{
if (BGvisibles[1])
{ {
chScreen(40, 0, 320, 240); chScreen(40, 0, 320, 240);
for(int i = bgmax; i < bg.length; i++) for(int i = bgmax; i < bg.length; i++)
{ {
bg[i].render(320f, 240f); bg[i].render(320f, 240f);
} }
}
chScreen(0, 240, 400, 240); chScreen(0, 240, 400, 240);
} }
} }

View File

@@ -300,6 +300,15 @@ class Sprite
PetitComputer petitcom; PetitComputer petitcom;
string spdefTableFile = "spdef.csv"; string spdefTableFile = "spdef.csv";
int spmax = 512; int spmax = 512;
bool[2] visibles = [true, true];
bool visible()
{
return visibles[petitcom.displaynum];
}
void visible(bool value)
{
visibles[petitcom.displaynum] = value;
}
void initUVTable() void initUVTable()
{ {
SPDEFTable = new SpriteDef[4096]; SPDEFTable = new SpriteDef[4096];
@@ -558,6 +567,17 @@ class Sprite
SpriteBucket* bucketsptr; SpriteBucket* bucketsptr;
void render() void render()
{ {
if (!visibles[0] && !visibles[1])
{
foreach(ref sprite; sprites)
{
if(sprite.define)
{
animation(&sprite);
}
}
return;
}
//とりあえずZ更新されたら描画時にまとめてソート //とりあえずZ更新されたら描画時にまとめてソート
//thread safe..... //thread safe.....
if(zChange) if(zChange)
@@ -648,6 +668,8 @@ class Sprite
{ {
if(!dis && sprite.id >= spmax) if(!dis && sprite.id >= spmax)
{ {
if (!visibles[1])
continue;
disw = 160f; disw = 160f;
disw2 = 320f; disw2 = 320f;
petitcom.chScreen(40, 0, 320, 240); petitcom.chScreen(40, 0, 320, 240);
@@ -658,6 +680,8 @@ class Sprite
{ {
if(sprite.id < spmax && dis) if(sprite.id < spmax && dis)
{ {
if (!visibles[0])
continue;
disw = 200f; disw = 200f;
disw2 = 400f; disw2 = 400f;
petitcom.chScreen(0, 240, 400, 240); petitcom.chScreen(0, 240, 400, 240);