Fix console for BIG
This commit is contained in:
@@ -1418,7 +1418,7 @@ class BuiltinFunction
|
|||||||
}
|
}
|
||||||
static int CHKCHR(PetitComputer p, int x, int y)
|
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)
|
struct FixedBuffer(T, size_t S)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,9 +63,7 @@ class Console
|
|||||||
0xFFFFFFFF,
|
0xFFFFFFFF,
|
||||||
];
|
];
|
||||||
int[] consoleColorGL = new int[16];
|
int[] consoleColorGL = new int[16];
|
||||||
ConsoleCharacter[][] console;
|
ConsoleCharacter[][][] console;
|
||||||
ConsoleCharacter[][] consoleDisplay1;
|
|
||||||
ConsoleCharacter[][] console4;
|
|
||||||
int[2] CSRXs;
|
int[2] CSRXs;
|
||||||
int[2] CSRYs;
|
int[2] CSRYs;
|
||||||
int[2] CSRZs;
|
int[2] CSRZs;
|
||||||
@@ -113,28 +111,16 @@ class Console
|
|||||||
fontWidth = fontHeight = w;
|
fontWidth = fontHeight = w;
|
||||||
consoleWidth = petitcom.screenWidth / fontWidth;
|
consoleWidth = petitcom.screenWidth / fontWidth;
|
||||||
consoleHeight = petitcom.screenHeight / fontHeight;
|
consoleHeight = petitcom.screenHeight / fontHeight;
|
||||||
consoleWidthDisplay1 = petitcom.screenWidthDisplay1 / fontWidth;
|
console = new ConsoleCharacter[][][petitcom.currentDisplay.rect.length];
|
||||||
consoleHeightDisplay1 = petitcom.screenHeightDisplay1 / fontHeight;
|
|
||||||
consoleWidth4 = 320 / fontWidth;
|
|
||||||
consoleHeight4 = 480 / fontHeight;
|
|
||||||
console = new ConsoleCharacter[][consoleHeight];
|
|
||||||
consoleDisplay1 = new ConsoleCharacter[][consoleHeightDisplay1];
|
|
||||||
console4 = new ConsoleCharacter[][consoleHeight4];
|
|
||||||
consoleForeColor = 15;//#T_WHITE
|
consoleForeColor = 15;//#T_WHITE
|
||||||
for(int i = 0; i < console.length; i++)
|
for(int i = 0; i < console.length; i++)
|
||||||
{
|
{
|
||||||
console[i] = new ConsoleCharacter[consoleWidth];
|
console[i] = new ConsoleCharacter[][petitcom.currentDisplay.rect[i].h / fontHeight];
|
||||||
console[i][] = ConsoleCharacter(0, consoleForeColor, consoleBackColor);
|
for(int j = 0; j < console[i].length; j++)
|
||||||
}
|
|
||||||
for(int i = 0; i < consoleDisplay1.length; i++)
|
|
||||||
{
|
{
|
||||||
consoleDisplay1[i] = new ConsoleCharacter[consoleWidthDisplay1];
|
console[i][j] = new ConsoleCharacter[petitcom.currentDisplay.rect[i].w / fontWidth];
|
||||||
consoleDisplay1[i][] = ConsoleCharacter(0, consoleForeColor, consoleBackColor);
|
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;
|
CSRXs[] = 0;
|
||||||
CSRYs[] = 0;
|
CSRYs[] = 0;
|
||||||
@@ -142,6 +128,11 @@ class Console
|
|||||||
display(petitcom.displaynum);
|
display(petitcom.displaynum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//FIXME:画面サイズが変わらないと画面はクリアされないのにクリアされる
|
||||||
|
void changeDisplay(ref Display display)
|
||||||
|
{
|
||||||
|
width(fontWidth);
|
||||||
|
}
|
||||||
bool visible()
|
bool visible()
|
||||||
{
|
{
|
||||||
return visibles[petitcom.displaynum];
|
return visibles[petitcom.displaynum];
|
||||||
@@ -220,23 +211,9 @@ class Console
|
|||||||
{
|
{
|
||||||
synchronized(this)
|
synchronized(this)
|
||||||
{
|
{
|
||||||
if(petitcom.xscreenmode == 2)
|
consoleHeightC = petitcom.currentDisplay.rect[number].h / fontHeight;
|
||||||
{
|
consoleWidthC = petitcom.currentDisplay.rect[number].w / fontWidth;
|
||||||
consoleHeightC = consoleHeight4;
|
consoleC = console[number];
|
||||||
consoleWidthC = consoleWidth4;
|
|
||||||
consoleC = console4;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(number == 1)
|
|
||||||
{
|
|
||||||
consoleHeightC = consoleHeightDisplay1;
|
|
||||||
consoleWidthC = consoleWidthDisplay1;
|
|
||||||
consoleC = consoleDisplay1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
consoleHeightC = consoleHeight;
|
|
||||||
consoleWidthC = consoleWidth;
|
|
||||||
consoleC = console;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void drawCharacter(int x, int y, ConsoleCharacter ch)
|
void drawCharacter(int x, int y, ConsoleCharacter ch)
|
||||||
@@ -318,54 +295,21 @@ class Console
|
|||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
}
|
}
|
||||||
synchronized(this)
|
synchronized(this)
|
||||||
{
|
|
||||||
if(petitcom.xscreenmode == 2 && (visibles[0] || showCursor)/*XSCREEN4*/)
|
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
|
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
|
||||||
glDisable(GL_TEXTURE_2D);
|
for (int i = 0; i < petitcom.currentDisplay.rect.length; i++)
|
||||||
glBegin(GL_QUADS);
|
|
||||||
for(int y = 0; y < consoleHeight4; y++)
|
|
||||||
for(int x = 0; x < consoleWidth4; x++)
|
|
||||||
{
|
{
|
||||||
auto back = consoleColorGL[console4[y][x].backColor];
|
if (!visibles[i] && !showCursor)
|
||||||
if(back)
|
continue;
|
||||||
{
|
petitcom.chScreen2(petitcom.currentDisplay.rect[i].x, petitcom.currentDisplay.rect[i].y, petitcom.currentDisplay.rect[i].w, petitcom.currentDisplay.rect[i].h);
|
||||||
glColor4ubv(cast(ubyte*)&back);
|
int consoleWidth = petitcom.currentDisplay.rect[i].w / fontWidth;
|
||||||
glVertex3f(x * 8, y * 8 + 8, 1024);
|
int consoleHeight = petitcom.currentDisplay.rect[i].h / fontHeight;
|
||||||
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);
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
for(int y = 0; y < consoleHeight; y++)
|
for(int y = 0; y < consoleHeight; y++)
|
||||||
for(int x = 0; x < consoleWidth; x++)
|
for(int x = 0; x < consoleWidth; x++)
|
||||||
{
|
{
|
||||||
auto back = consoleColorGL[console[y][x].backColor];
|
auto back = consoleColorGL[console[i][y][x].backColor];
|
||||||
if(back)
|
if(back)
|
||||||
{
|
{
|
||||||
glColor4ubv(cast(ubyte*)&back);
|
glColor4ubv(cast(ubyte*)&back);
|
||||||
@@ -375,7 +319,7 @@ class Console
|
|||||||
glVertex3f(x * 8 + 8, y * 8 + 8, 1024);
|
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]);
|
glColor4ubv(cast(ubyte*)&consoleColorGL[15]);
|
||||||
glVertex3f((CSRX * 8), (CSRY * 8 + 8), -256);
|
glVertex3f((CSRX * 8), (CSRY * 8 + 8), -256);
|
||||||
@@ -390,51 +334,7 @@ class Console
|
|||||||
for(int y = 0; y < consoleHeight; y++)
|
for(int y = 0; y < consoleHeight; y++)
|
||||||
for(int x = 0; x < consoleWidth; x++)
|
for(int x = 0; x < consoleWidth; x++)
|
||||||
{
|
{
|
||||||
drawCharacter(x, y, console[y][x]);
|
drawCharacter(x, y, console[i][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]);
|
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,9 +156,14 @@ struct Slot
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
struct Size
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
}
|
||||||
struct Display
|
struct Display
|
||||||
{
|
{
|
||||||
SDL_Rect[] rect;
|
SDL_Rect[] rect;
|
||||||
|
Size windowSize;
|
||||||
}
|
}
|
||||||
class PetitComputer
|
class PetitComputer
|
||||||
{
|
{
|
||||||
@@ -306,6 +311,7 @@ class PetitComputer
|
|||||||
screenHeight = 240;
|
screenHeight = 240;
|
||||||
screenWidthDisplay1 = 320;
|
screenWidthDisplay1 = 320;
|
||||||
screenHeightDisplay1 = 240;
|
screenHeightDisplay1 = 240;
|
||||||
|
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight)]);
|
||||||
console = new Console(this);
|
console = new Console(this);
|
||||||
if(!exists(fontTableFile))
|
if(!exists(fontTableFile))
|
||||||
{
|
{
|
||||||
@@ -317,7 +323,6 @@ class PetitComputer
|
|||||||
{
|
{
|
||||||
console.loadFontTable();
|
console.loadFontTable();
|
||||||
}
|
}
|
||||||
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight)]);
|
|
||||||
display(0);
|
display(0);
|
||||||
writeln("OK");
|
writeln("OK");
|
||||||
}
|
}
|
||||||
@@ -391,12 +396,15 @@ class PetitComputer
|
|||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(0, w, h, 0, 1024, -2048);
|
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;
|
Button[] buttonTable;
|
||||||
Sprite sprite;
|
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)];
|
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 xscreenmode = 0;
|
||||||
int bgmax;
|
int bgmax;
|
||||||
@@ -410,35 +418,30 @@ class PetitComputer
|
|||||||
}
|
}
|
||||||
Display currentDisplay;
|
Display currentDisplay;
|
||||||
void xscreen(int mode, int tv, int gamepad, int sprite, int bg)
|
void xscreen(int mode, int tv, int gamepad, int sprite, int bg)
|
||||||
|
{
|
||||||
|
int mode2 = mode / 2;
|
||||||
|
synchronized(renderSync)
|
||||||
{
|
{
|
||||||
this.sprite.spclr();
|
this.sprite.spclr();
|
||||||
this.sprite.spmax = sprite;
|
this.sprite.spmax = sprite;
|
||||||
this.bgmax = bg;
|
this.bgmax = bg;
|
||||||
//BG
|
//BG
|
||||||
int mode2 = mode / 2;
|
|
||||||
xscreenmode = mode2;
|
xscreenmode = mode2;
|
||||||
if(mode2 == 0)
|
if(mode2 == 0)
|
||||||
{
|
{
|
||||||
SDL_SetWindowSize(window, 400, 240);
|
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight)], Size(400, 240));
|
||||||
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight)]);
|
|
||||||
}
|
}
|
||||||
if(mode2 == 1)
|
if(mode2 == 1)
|
||||||
{
|
{
|
||||||
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight), SDL_Rect((screenWidth - screenWidthDisplay1) / 2, screenHeight, screenWidthDisplay1, screenHeightDisplay1)]);
|
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight), SDL_Rect((screenWidth - screenWidthDisplay1) / 2, screenHeight, screenWidthDisplay1, screenHeightDisplay1)], Size(400, 480));
|
||||||
SDL_SetWindowSize(window, 400, 480);
|
|
||||||
display(1);
|
|
||||||
graphic.clip(false);
|
|
||||||
graphic.clip(true);
|
|
||||||
}
|
}
|
||||||
if(mode == 4)
|
if(mode == 4)
|
||||||
{
|
{
|
||||||
SDL_SetWindowSize(window, 320, 240 * 2);
|
currentDisplay = Display([SDL_Rect(0, 0, screenWidthDisplay1, screenHeight + screenHeightDisplay1)], Size(320, 480));
|
||||||
currentDisplay = Display([SDL_Rect(0, 0, screenWidthDisplay1, screenHeight + screenHeightDisplay1)]);
|
|
||||||
}
|
}
|
||||||
if (mode == 5)
|
if (mode == 5)
|
||||||
{
|
{
|
||||||
SDL_SetWindowSize(window, 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));
|
||||||
currentDisplay = Display([SDL_Rect(0, 0, resolutionTable[tv].width, resolutionTable[tv].height)]);
|
|
||||||
xscreenmode = 3;
|
xscreenmode = 3;
|
||||||
}
|
}
|
||||||
if (mode == 6)
|
if (mode == 6)
|
||||||
@@ -453,14 +456,22 @@ class PetitComputer
|
|||||||
{
|
{
|
||||||
display0.x = (resolutionTable[gamepad].width - resolutionTable[tv].width) / 2;
|
display0.x = (resolutionTable[gamepad].width - resolutionTable[tv].width) / 2;
|
||||||
}
|
}
|
||||||
currentDisplay = Display([display0, display1]);
|
currentDisplay = Display([display0, display1], Size(std.algorithm.max(resolutionTable[gamepad].width, resolutionTable[tv].width), std.algorithm.max(resolutionTable[gamepad].height, resolutionTable[tv].height)));
|
||||||
SDL_SetWindowSize(window, std.algorithm.max(resolutionTable[gamepad].width, resolutionTable[tv].width), std.algorithm.max(resolutionTable[gamepad].height, resolutionTable[tv].height));
|
|
||||||
xscreenmode = 4;
|
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(false);
|
||||||
graphic.clip(true);
|
graphic.clip(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetWindowSize(window, currentDisplay.windowSize.width, currentDisplay.windowSize.height);
|
||||||
|
}
|
||||||
|
|
||||||
BG getBG(int layer)
|
BG getBG(int layer)
|
||||||
{
|
{
|
||||||
if(displaynum)
|
if(displaynum)
|
||||||
@@ -517,6 +528,7 @@ class PetitComputer
|
|||||||
{
|
{
|
||||||
return petitcomBackcolor;
|
return petitcomBackcolor;
|
||||||
}
|
}
|
||||||
|
Object renderSync = new Object();
|
||||||
void render()
|
void render()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -640,6 +652,8 @@ class PetitComputer
|
|||||||
loopcnt = 0;
|
loopcnt = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
synchronized(renderSync)
|
||||||
|
{
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
graphic.draw();
|
graphic.draw();
|
||||||
chScreen(0, 0, 400, 240);
|
chScreen(0, 0, 400, 240);
|
||||||
@@ -735,6 +749,7 @@ class PetitComputer
|
|||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
|
}
|
||||||
auto renderticks = (SDL_GetTicks() - profile);
|
auto renderticks = (SDL_GetTicks() - profile);
|
||||||
if(renderprofile) writeln(renderticks);
|
if(renderprofile) writeln(renderticks);
|
||||||
int mousex, mousey;
|
int mousex, mousey;
|
||||||
|
|||||||
Reference in New Issue
Block a user