1
0

Implement SPCLIP, Fix Sprite for BIG

This commit is contained in:
otya128
2016-12-10 18:40:54 +09:00
parent 8afb32dd88
commit 3d068e3fef
3 changed files with 50 additions and 8 deletions

View File

@@ -1414,6 +1414,14 @@ class BuiltinFunction
{ {
return p.sprite.sppage; return p.sprite.sppage;
} }
static void SPCLIP(PetitComputer p)
{
p.sprite.spclip;
}
static void SPCLIP(PetitComputer p, int x1, int y1, int x2, int y2)
{
p.sprite.spclip(x1, y1, x2, y2);
}
static void BGMSTOP(PetitComputer p) static void BGMSTOP(PetitComputer p)
{ {
writeln("NOTIMPL:BGMSTOP"); writeln("NOTIMPL:BGMSTOP");

View File

@@ -401,7 +401,15 @@ class PetitComputer
glViewport(x, currentDisplay.windowSize.height - h - y, w, h); glViewport(x, currentDisplay.windowSize.height - h - y, w, h);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
glOrtho(0, w, h, 0, 1024, -2048); glOrtho(x, x + w, y + h, y, 1024, -2048);
}
void chRenderingDisplay(int i)
{
chScreen2(currentDisplay.rect[i].x, currentDisplay.rect[i].y, currentDisplay.rect[i].w, currentDisplay.rect[i].h);
}
void chRenderingDisplay(int i, int x, int y, int w, int h)
{
chScreen2(currentDisplay.rect[i].x + x, currentDisplay.rect[i].y + y, w, h);
} }
Button[] buttonTable; Button[] buttonTable;
Sprite sprite; Sprite sprite;
@@ -466,6 +474,7 @@ class PetitComputer
display(i); display(i);
graphic.clip(false); graphic.clip(false);
graphic.clip(true); graphic.clip(true);
this.sprite.spclip;
} }
} }

View File

@@ -656,7 +656,13 @@ class Sprite
} }
} }
} }
float disw = 200f, dish = 120f, disw2 = 400f, dish2 = 240f; float disw, dish, disw2, dish2;
disw = petitcom.currentDisplay.rect[0].w / 2;
disw2 = petitcom.currentDisplay.rect[0].w;
dish = petitcom.currentDisplay.rect[0].h / 2;
dish2 = petitcom.currentDisplay.rect[0].h;
petitcom.chRenderingDisplay(0, clipRect[0].x, clipRect[0].y, clipRect[0].w, clipRect[0].h);
glMatrixMode(GL_MODELVIEW);
int dis; int dis;
if(petitcom.xscreenmode == 2) if(petitcom.xscreenmode == 2)
{ {
@@ -691,9 +697,10 @@ class Sprite
dis = true; dis = true;
if (!visibles[1]) if (!visibles[1])
continue; continue;
disw = 160f; //display:1
disw2 = 320f; disw = petitcom.currentDisplay.rect[1].w / 2;
petitcom.chScreen(40, 0, 320, 240); disw2 = petitcom.currentDisplay.rect[1].w;
petitcom.chRenderingDisplay(1, clipRect[1].x, clipRect[1].y, clipRect[1].w, clipRect[1].h);
aspect = disw2 / dish2; aspect = disw2 / dish2;
} }
else else
@@ -703,9 +710,9 @@ class Sprite
dis = false; dis = false;
if (!visibles[0]) if (!visibles[0])
continue; continue;
disw = 200f; disw = petitcom.currentDisplay.rect[0].w / 2;
disw2 = 400f; disw2 = petitcom.currentDisplay.rect[0].w;
petitcom.chScreen(0, 240, 400, 240); petitcom.chRenderingDisplay(0, clipRect[0].x, clipRect[0].y, clipRect[0].w, clipRect[0].h);
aspect = disw2 / dish2; aspect = disw2 / dish2;
} }
} }
@@ -1127,4 +1134,22 @@ class Sprite
id = spid(id); id = spid(id);
return sprites[id].var[var]; return sprites[id].var[var];
} }
SDL_Rect[2] clipRect;
void spclip()
{
spclip(0, 0, petitcom.currentScreenWidth, petitcom.currentScreenHeight);
}
void spclip(int x1, int y1, int x2, int y2)
{
import std.algorithm : swap;
if (x1 > x2)
{
swap(x1, x2);
}
if (y1 > y2)
{
swap(y1, y2);
}
clipRect[petitcom.displaynum] = SDL_Rect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
}
} }