1
0

Fix console for BIG

This commit is contained in:
otya128
2016-12-10 17:02:17 +09:00
parent 1a6332d830
commit 92e5f3abc4
3 changed files with 170 additions and 255 deletions

View File

@@ -1418,7 +1418,7 @@ class BuiltinFunction
}
static int CHKCHR(PetitComputer p, int x, int y)
{
return cast(int)(p.console.console[y][x].character);
return cast(int)(p.console.console[p.displaynum][y][x].character);
}
struct FixedBuffer(T, size_t S)
{

View File

@@ -63,9 +63,7 @@ class Console
0xFFFFFFFF,
];
int[] consoleColorGL = new int[16];
ConsoleCharacter[][] console;
ConsoleCharacter[][] consoleDisplay1;
ConsoleCharacter[][] console4;
ConsoleCharacter[][][] console;
int[2] CSRXs;
int[2] CSRYs;
int[2] CSRZs;
@@ -113,28 +111,16 @@ class Console
fontWidth = fontHeight = w;
consoleWidth = petitcom.screenWidth / fontWidth;
consoleHeight = petitcom.screenHeight / fontHeight;
consoleWidthDisplay1 = petitcom.screenWidthDisplay1 / fontWidth;
consoleHeightDisplay1 = petitcom.screenHeightDisplay1 / fontHeight;
consoleWidth4 = 320 / fontWidth;
consoleHeight4 = 480 / fontHeight;
console = new ConsoleCharacter[][consoleHeight];
consoleDisplay1 = new ConsoleCharacter[][consoleHeightDisplay1];
console4 = new ConsoleCharacter[][consoleHeight4];
console = new ConsoleCharacter[][][petitcom.currentDisplay.rect.length];
consoleForeColor = 15;//#T_WHITE
for(int i = 0; i < console.length; i++)
{
console[i] = new ConsoleCharacter[consoleWidth];
console[i][] = ConsoleCharacter(0, consoleForeColor, consoleBackColor);
}
for(int i = 0; i < consoleDisplay1.length; i++)
console[i] = new ConsoleCharacter[][petitcom.currentDisplay.rect[i].h / fontHeight];
for(int j = 0; j < console[i].length; j++)
{
consoleDisplay1[i] = new ConsoleCharacter[consoleWidthDisplay1];
consoleDisplay1[i][] = ConsoleCharacter(0, consoleForeColor, consoleBackColor);
console[i][j] = new ConsoleCharacter[petitcom.currentDisplay.rect[i].w / fontWidth];
console[i][j][] = ConsoleCharacter(0, consoleForeColor, consoleBackColor);
}
for(int i = 0; i < console4.length; i++)
{
console4[i] = new ConsoleCharacter[consoleWidth4];
console4[i][] = ConsoleCharacter(0, consoleForeColor, consoleBackColor);
}
CSRXs[] = 0;
CSRYs[] = 0;
@@ -142,6 +128,11 @@ class Console
display(petitcom.displaynum);
}
}
//FIXME:画面サイズが変わらないと画面はクリアされないのにクリアされる
void changeDisplay(ref Display display)
{
width(fontWidth);
}
bool visible()
{
return visibles[petitcom.displaynum];
@@ -220,23 +211,9 @@ class Console
{
synchronized(this)
{
if(petitcom.xscreenmode == 2)
{
consoleHeightC = consoleHeight4;
consoleWidthC = consoleWidth4;
consoleC = console4;
return;
}
if(number == 1)
{
consoleHeightC = consoleHeightDisplay1;
consoleWidthC = consoleWidthDisplay1;
consoleC = consoleDisplay1;
return;
}
consoleHeightC = consoleHeight;
consoleWidthC = consoleWidth;
consoleC = console;
consoleHeightC = petitcom.currentDisplay.rect[number].h / fontHeight;
consoleWidthC = petitcom.currentDisplay.rect[number].w / fontWidth;
consoleC = console[number];
}
}
void drawCharacter(int x, int y, ConsoleCharacter ch)
@@ -318,54 +295,21 @@ class Console
glLoadIdentity();
}
synchronized(this)
{
if(petitcom.xscreenmode == 2 && (visibles[0] || showCursor)/*XSCREEN4*/)
{
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
glDisable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
for(int y = 0; y < consoleHeight4; y++)
for(int x = 0; x < consoleWidth4; x++)
for (int i = 0; i < petitcom.currentDisplay.rect.length; i++)
{
auto back = consoleColorGL[console4[y][x].backColor];
if(back)
{
glColor4ubv(cast(ubyte*)&back);
glVertex3f(x * 8, y * 8 + 8, 1024);
glVertex3f(x * 8, y * 8, 1024);
glVertex3f(x * 8 + 8, y * 8, 1024);
glVertex3f(x * 8 + 8, y * 8 + 8, 1024);
}
}
if(showCursor && animationCursor)
{
glColor4ubv(cast(ubyte*)&consoleColorGL[15]);
glVertex3f((CSRX * 8), (CSRY * 8 + 8), -256);
glVertex3f((CSRX * 8), (CSRY * 8), -256);
glVertex3f((CSRX * 8 + 2), (CSRY * 8), -256);
glVertex3f((CSRX * 8 + 2), (CSRY * 8 + 8), -256);
}
glEnd();
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
for(int y = 0; y < consoleHeight4; y++)
for(int x = 0; x < consoleWidth4; x++)
{
drawCharacter(x, y, console4[y][x]);
}
glEnd();
return;
}
if (showCursor || visibles[0])
{
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
if (!visibles[i] && !showCursor)
continue;
petitcom.chScreen2(petitcom.currentDisplay.rect[i].x, petitcom.currentDisplay.rect[i].y, petitcom.currentDisplay.rect[i].w, petitcom.currentDisplay.rect[i].h);
int consoleWidth = petitcom.currentDisplay.rect[i].w / fontWidth;
int consoleHeight = petitcom.currentDisplay.rect[i].h / fontHeight;
glDisable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
for(int y = 0; y < consoleHeight; y++)
for(int x = 0; x < consoleWidth; x++)
{
auto back = consoleColorGL[console[y][x].backColor];
auto back = consoleColorGL[console[i][y][x].backColor];
if(back)
{
glColor4ubv(cast(ubyte*)&back);
@@ -375,7 +319,7 @@ class Console
glVertex3f(x * 8 + 8, y * 8 + 8, 1024);
}
}
if(petitcom.displaynum == 0 && showCursor && animationCursor)
if(petitcom.displaynum == i && showCursor && animationCursor)
{
glColor4ubv(cast(ubyte*)&consoleColorGL[15]);
glVertex3f((CSRX * 8), (CSRY * 8 + 8), -256);
@@ -390,51 +334,7 @@ class Console
for(int y = 0; y < consoleHeight; y++)
for(int x = 0; x < consoleWidth; x++)
{
drawCharacter(x, y, console[y][x]);
}
glEnd();
if(petitcom.xscreenmode != 1)
{
return;
}
}
if (visibles[1] || showCursor)
{
//下画面
petitcom.chScreen(40, 0, 400, 240);
adjustScreen();
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
glDisable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
for(int y = 0; y < consoleHeightDisplay1; y++)
for(int x = 0; x < consoleWidthDisplay1; x++)
{
auto back = consoleColorGL[consoleDisplay1[y][x].backColor];
if(back)
{
glColor4ubv(cast(ubyte*)&back);
glVertex3f(x * 8, y * 8 + 8, 1024);
glVertex3f(x * 8, y * 8, 1024);
glVertex3f(x * 8 + 8, y * 8, 1024);
glVertex3f(x * 8 + 8, y * 8 + 8, 1024);
}
}
if(petitcom.displaynum == 1 && showCursor && animationCursor)
{
glColor4ubv(cast(ubyte*)&consoleColorGL[15]);
glVertex3f((CSRX * 8), (CSRY * 8 + 8), -256);
glVertex3f((CSRX * 8), (CSRY * 8), -256);
glVertex3f((CSRX * 8 + 2), (CSRY * 8), -256);
glVertex3f((CSRX * 8 + 2), (CSRY * 8 + 8), -256);
}
glEnd();
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
for(int y = 0; y < consoleHeightDisplay1; y++)
for(int x = 0; x < consoleWidthDisplay1; x++)
{
drawCharacter(x, y, consoleDisplay1[y][x]);
drawCharacter(x, y, console[i][y][x]);
}
glEnd();
}

View File

@@ -156,9 +156,14 @@ struct Slot
}
}
}
struct Size
{
int width, height;
}
struct Display
{
SDL_Rect[] rect;
Size windowSize;
}
class PetitComputer
{
@@ -306,6 +311,7 @@ class PetitComputer
screenHeight = 240;
screenWidthDisplay1 = 320;
screenHeightDisplay1 = 240;
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight)]);
console = new Console(this);
if(!exists(fontTableFile))
{
@@ -317,7 +323,6 @@ class PetitComputer
{
console.loadFontTable();
}
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight)]);
display(0);
writeln("OK");
}
@@ -391,12 +396,15 @@ class PetitComputer
glLoadIdentity();
glOrtho(0, w, h, 0, 1024, -2048);
}
void chScreen2(int x, int y, int w, int h)
{
glViewport(x, currentDisplay.windowSize.height - h - y, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, w, h, 0, 1024, -2048);
}
Button[] buttonTable;
Sprite sprite;
struct Size
{
int width, height;
}
Size[7] resolutionTable = [Size(256, 192), Size(320, 200), Size(320, 240), Size(400, 240), Size(640, 400), Size(640, 480), Size(854, 480)];
int xscreenmode = 0;
int bgmax;
@@ -410,35 +418,30 @@ class PetitComputer
}
Display currentDisplay;
void xscreen(int mode, int tv, int gamepad, int sprite, int bg)
{
int mode2 = mode / 2;
synchronized(renderSync)
{
this.sprite.spclr();
this.sprite.spmax = sprite;
this.bgmax = bg;
//BG
int mode2 = mode / 2;
xscreenmode = mode2;
if(mode2 == 0)
{
SDL_SetWindowSize(window, 400, 240);
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight)]);
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight)], Size(400, 240));
}
if(mode2 == 1)
{
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight), SDL_Rect((screenWidth - screenWidthDisplay1) / 2, screenHeight, screenWidthDisplay1, screenHeightDisplay1)]);
SDL_SetWindowSize(window, 400, 480);
display(1);
graphic.clip(false);
graphic.clip(true);
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight), SDL_Rect((screenWidth - screenWidthDisplay1) / 2, screenHeight, screenWidthDisplay1, screenHeightDisplay1)], Size(400, 480));
}
if(mode == 4)
{
SDL_SetWindowSize(window, 320, 240 * 2);
currentDisplay = Display([SDL_Rect(0, 0, screenWidthDisplay1, screenHeight + screenHeightDisplay1)]);
currentDisplay = Display([SDL_Rect(0, 0, screenWidthDisplay1, screenHeight + screenHeightDisplay1)], Size(320, 480));
}
if (mode == 5)
{
SDL_SetWindowSize(window, resolutionTable[tv].width, resolutionTable[tv].height);
currentDisplay = Display([SDL_Rect(0, 0, resolutionTable[tv].width, resolutionTable[tv].height)]);
currentDisplay = Display([SDL_Rect(0, 0, resolutionTable[tv].width, resolutionTable[tv].height)], Size(resolutionTable[tv].width, resolutionTable[tv].height));
xscreenmode = 3;
}
if (mode == 6)
@@ -453,14 +456,22 @@ class PetitComputer
{
display0.x = (resolutionTable[gamepad].width - resolutionTable[tv].width) / 2;
}
currentDisplay = Display([display0, display1]);
SDL_SetWindowSize(window, std.algorithm.max(resolutionTable[gamepad].width, resolutionTable[tv].width), std.algorithm.max(resolutionTable[gamepad].height, resolutionTable[tv].height));
currentDisplay = Display([display0, display1], Size(std.algorithm.max(resolutionTable[gamepad].width, resolutionTable[tv].width), std.algorithm.max(resolutionTable[gamepad].height, resolutionTable[tv].height)));
xscreenmode = 4;
}
display(0);
displaynum = 0;
console.changeDisplay(currentDisplay);
for (int i = currentDisplay.rect.length - 1; i >= 0; i--)
{
display(i);
graphic.clip(false);
graphic.clip(true);
}
}
SDL_SetWindowSize(window, currentDisplay.windowSize.width, currentDisplay.windowSize.height);
}
BG getBG(int layer)
{
if(displaynum)
@@ -517,6 +528,7 @@ class PetitComputer
{
return petitcomBackcolor;
}
Object renderSync = new Object();
void render()
{
try
@@ -640,6 +652,8 @@ class PetitComputer
loopcnt = 0;
}
}
synchronized(renderSync)
{
glLoadIdentity();
graphic.draw();
chScreen(0, 0, 400, 240);
@@ -735,6 +749,7 @@ class PetitComputer
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
SDL_GL_SwapWindow(window);
}
auto renderticks = (SDL_GetTicks() - profile);
if(renderprofile) writeln(renderticks);
int mousex, mousey;