1
0

Implement BG/SPPAGE

This commit is contained in:
otya128
2016-12-07 23:04:20 +09:00
parent 02fad28c82
commit d9161a07e0
3 changed files with 33 additions and 5 deletions

View File

@@ -1339,6 +1339,18 @@ class BuiltinFunction
{ {
return p.sprite.spchk(id); 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) static void BGMSTOP(PetitComputer p)
{ {
writeln("NOTIMPL:BGMSTOP"); writeln("NOTIMPL:BGMSTOP");
@@ -1486,6 +1498,18 @@ class BuiltinFunction
{ {
p.getBG(layer).fill(x, y, x2, y2, screendata); 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() static void EFCON()
{ {
} }

View File

@@ -267,7 +267,7 @@ class PetitComputer
this.y = y; this.y = y;
} }
} }
int sppage, bgpage; int bgpage;
Projects project; Projects project;
wstring currentProject; wstring currentProject;
void init() void init()
@@ -453,6 +453,7 @@ class PetitComputer
{ {
return bg; return bg;
} }
//TODO:extract class
bool[2] BGvisibles = [true, true]; bool[2] BGvisibles = [true, true];
bool BGvisible() bool BGvisible()
{ {
@@ -508,7 +509,7 @@ class PetitComputer
{ {
graphic.GRP[i] = createEmptyPage(); graphic.GRP[i] = createEmptyPage();
} }
sppage = 4; sprite.sppage = 4;
graphic.GRP[4] = createGRPF(spriteFile); graphic.GRP[4] = createGRPF(spriteFile);
bgpage = 5; bgpage = 5;
graphic.GRP[5] = createGRPF(BGFile); graphic.GRP[5] = createGRPF(BGFile);
@@ -848,7 +849,6 @@ class PetitComputer
keybuffer = new Key[128]; keybuffer = new Key[128];
init(); init();
graphic = new Graphic(this); graphic = new Graphic(this);
consolem = new Mutex();
keybuffermutex = new Mutex(); keybuffermutex = new Mutex();
grpmutex = new Mutex(); grpmutex = new Mutex();
sprite = new Sprite(this); sprite = new Sprite(this);
@@ -1232,7 +1232,10 @@ class PetitComputer
keybufferlen--; keybufferlen--;
return result.key.to!wstring; return result.key.to!wstring;
} }
Mutex consolem; public bool isValidGraphicPage(int page)
{
return page >= 0 && page < 6;
}
//プチコン内部表現はRGB5_A1 //プチコン内部表現はRGB5_A1
static uint toGLColor(GLenum format, ubyte r, ubyte g, ubyte b, ubyte a) static uint toGLColor(GLenum format, ubyte r, ubyte g, ubyte b, ubyte a)
{ {

View File

@@ -584,6 +584,7 @@ class Sprite
SpriteBucket[] buckets; SpriteBucket[] buckets;
SpriteBucket* listptr; SpriteBucket* listptr;
SpriteBucket* bucketsptr; SpriteBucket* bucketsptr;
int sppage;
void render() void render()
{ {
if ((!visibles[0] && !visibles[1]) || (petitcom.xscreenmode == 2 && !visibles[0])) if ((!visibles[0] && !visibles[1]) || (petitcom.xscreenmode == 2 && !visibles[0]))
@@ -665,7 +666,7 @@ class Sprite
dish2 = 480f; dish2 = 480f;
dis = -1; dis = -1;
} }
auto texture = petitcom.graphic.GRP[petitcom.sppage].glTexture; auto texture = petitcom.graphic.GRP[sppage].glTexture;
float aspect = disw2 / dish2; float aspect = disw2 / dish2;
float z = -0.01f; float z = -0.01f;
int spmax = petitcom.xscreenmode == 1 ? this.spmax : 512;//XSCREENが2,3じゃないと下画面は描画しない int spmax = petitcom.xscreenmode == 1 ? this.spmax : 512;//XSCREENが2,3じゃないと下画面は描画しない