Synchronize console operations
This commit is contained in:
@@ -100,6 +100,7 @@ class Console
|
|||||||
GraphicPage GRPF;
|
GraphicPage GRPF;
|
||||||
PetitComputer petitcom;
|
PetitComputer petitcom;
|
||||||
bool[2] visibles = [true, true];
|
bool[2] visibles = [true, true];
|
||||||
|
Object consoleSync = new Object();
|
||||||
|
|
||||||
int width()
|
int width()
|
||||||
{
|
{
|
||||||
@@ -107,36 +108,39 @@ class Console
|
|||||||
}
|
}
|
||||||
void width(int w)
|
void width(int w)
|
||||||
{
|
{
|
||||||
fontWidth = fontHeight = w;
|
synchronized(this)
|
||||||
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];
|
|
||||||
consoleForeColor = 15;//#T_WHITE
|
|
||||||
for(int i = 0; i < console.length; i++)
|
|
||||||
{
|
{
|
||||||
console[i] = new ConsoleCharacter[consoleWidth];
|
fontWidth = fontHeight = w;
|
||||||
console[i][] = ConsoleCharacter(0, consoleForeColor, consoleBackColor);
|
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];
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
consoleDisplay1[i] = new ConsoleCharacter[consoleWidthDisplay1];
|
||||||
|
consoleDisplay1[i][] = 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;
|
||||||
|
CSRZs[] = 0;
|
||||||
|
display(petitcom.displaynum);
|
||||||
}
|
}
|
||||||
for(int i = 0; i < consoleDisplay1.length; i++)
|
|
||||||
{
|
|
||||||
consoleDisplay1[i] = new ConsoleCharacter[consoleWidthDisplay1];
|
|
||||||
consoleDisplay1[i][] = 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;
|
|
||||||
CSRZs[] = 0;
|
|
||||||
display(petitcom.displaynum);
|
|
||||||
}
|
}
|
||||||
bool visible()
|
bool visible()
|
||||||
{
|
{
|
||||||
@@ -214,23 +218,26 @@ class Console
|
|||||||
}
|
}
|
||||||
void display(int number)
|
void display(int number)
|
||||||
{
|
{
|
||||||
if(petitcom.xscreenmode == 2)
|
synchronized(this)
|
||||||
{
|
{
|
||||||
consoleHeightC = consoleHeight4;
|
if(petitcom.xscreenmode == 2)
|
||||||
consoleWidthC = consoleWidth4;
|
{
|
||||||
consoleC = console4;
|
consoleHeightC = consoleHeight4;
|
||||||
return;
|
consoleWidthC = consoleWidth4;
|
||||||
|
consoleC = console4;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(number == 1)
|
||||||
|
{
|
||||||
|
consoleHeightC = consoleHeightDisplay1;
|
||||||
|
consoleWidthC = consoleWidthDisplay1;
|
||||||
|
consoleC = consoleDisplay1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
consoleHeightC = consoleHeight;
|
||||||
|
consoleWidthC = consoleWidth;
|
||||||
|
consoleC = console;
|
||||||
}
|
}
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -310,124 +317,127 @@ class Console
|
|||||||
{
|
{
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
}
|
}
|
||||||
if(petitcom.xscreenmode == 2 && (visibles[0] || showCursor)/*XSCREEN4*/)
|
synchronized(this)
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
|
if(petitcom.xscreenmode == 2 && (visibles[0] || showCursor)/*XSCREEN4*/)
|
||||||
glDisable(GL_TEXTURE_2D);
|
{
|
||||||
glBegin(GL_QUADS);
|
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
|
||||||
for(int y = 0; y < consoleHeight4; y++)
|
glDisable(GL_TEXTURE_2D);
|
||||||
for(int x = 0; x < consoleWidth4; x++)
|
glBegin(GL_QUADS);
|
||||||
{
|
for(int y = 0; y < consoleHeight4; y++)
|
||||||
auto back = consoleColorGL[console4[y][x].backColor];
|
for(int x = 0; x < consoleWidth4; x++)
|
||||||
if(back)
|
|
||||||
{
|
{
|
||||||
glColor4ubv(cast(ubyte*)&back);
|
auto back = consoleColorGL[console4[y][x].backColor];
|
||||||
glVertex3f(x * 8, y * 8 + 8, 1024);
|
if(back)
|
||||||
glVertex3f(x * 8, y * 8, 1024);
|
{
|
||||||
glVertex3f(x * 8 + 8, y * 8, 1024);
|
glColor4ubv(cast(ubyte*)&back);
|
||||||
glVertex3f(x * 8 + 8, y * 8 + 8, 1024);
|
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);
|
||||||
}
|
}
|
||||||
if(showCursor && animationCursor)
|
glEnd();
|
||||||
{
|
glEnable(GL_TEXTURE_2D);
|
||||||
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);
|
glBegin(GL_QUADS);
|
||||||
for(int y = 0; y < consoleHeight4; y++)
|
for(int y = 0; y < consoleHeight4; y++)
|
||||||
for(int x = 0; x < consoleWidth4; x++)
|
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);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
for(int y = 0; y < consoleHeight; y++)
|
|
||||||
for(int x = 0; x < consoleWidth; x++)
|
|
||||||
{
|
|
||||||
auto back = consoleColorGL[console[y][x].backColor];
|
|
||||||
if(back)
|
|
||||||
{
|
{
|
||||||
glColor4ubv(cast(ubyte*)&back);
|
drawCharacter(x, y, console4[y][x]);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
glEnd();
|
||||||
if(petitcom.displaynum == 0 && 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 < consoleHeight; y++)
|
|
||||||
for(int x = 0; x < consoleWidth; x++)
|
|
||||||
{
|
|
||||||
drawCharacter(x, y, console[y][x]);
|
|
||||||
}
|
|
||||||
glEnd();
|
|
||||||
if(petitcom.xscreenmode != 1)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
if (showCursor || visibles[0])
|
||||||
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]);
|
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
|
||||||
glVertex3f((CSRX * 8), (CSRY * 8 + 8), -256);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glVertex3f((CSRX * 8), (CSRY * 8), -256);
|
glBegin(GL_QUADS);
|
||||||
glVertex3f((CSRX * 8 + 2), (CSRY * 8), -256);
|
for(int y = 0; y < consoleHeight; y++)
|
||||||
glVertex3f((CSRX * 8 + 2), (CSRY * 8 + 8), -256);
|
for(int x = 0; x < consoleWidth; x++)
|
||||||
}
|
{
|
||||||
glEnd();
|
auto back = consoleColorGL[console[y][x].backColor];
|
||||||
glEnable(GL_TEXTURE_2D);
|
if(back)
|
||||||
|
{
|
||||||
glBegin(GL_QUADS);
|
glColor4ubv(cast(ubyte*)&back);
|
||||||
for(int y = 0; y < consoleHeightDisplay1; y++)
|
glVertex3f(x * 8, y * 8 + 8, 1024);
|
||||||
for(int x = 0; x < consoleWidthDisplay1; x++)
|
glVertex3f(x * 8, y * 8, 1024);
|
||||||
|
glVertex3f(x * 8 + 8, y * 8, 1024);
|
||||||
|
glVertex3f(x * 8 + 8, y * 8 + 8, 1024);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(petitcom.displaynum == 0 && showCursor && animationCursor)
|
||||||
{
|
{
|
||||||
drawCharacter(x, y, consoleDisplay1[y][x]);
|
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();
|
glEnd();
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void print(T...)(T args)
|
void print(T...)(T args)
|
||||||
|
|||||||
Reference in New Issue
Block a user