1
0

Fix XSCREEN 5,6

This commit is contained in:
otya128
2016-12-10 20:32:25 +09:00
parent f4c5683b86
commit 356951fb41
2 changed files with 41 additions and 10 deletions

View File

@@ -19,6 +19,7 @@ enum DrawType
PAINT, PAINT,
CLIPWRITE, CLIPWRITE,
PUTCHR, PUTCHR,
INIT,
} }
struct Circle struct Circle
{ {
@@ -68,14 +69,24 @@ class Graphic
{ {
petitcom = p; petitcom = p;
paint = new Paint(); paint = new Paint();
setSize(512, 512); width = 512;
height = 512;
//nnnue
paint.buffer = new uint[width * height];
} }
void setSize(int w, int h) void setSize(int w, int h)
{ {
width = w; width = w;
height = h; height = h;
//nnnue initGraphicPages();/*
paint.buffer = new uint[width * height]; DrawMessage dm;
dm.type = DrawType.INIT;
sendDrawMessage(dm);*/
}
void getSize(out int w, out int h)
{
w = width;
h = height;
} }
void initGraphicPages() void initGraphicPages()
{ {
@@ -88,11 +99,20 @@ class Graphic
GRP[4] = createGRPF(petitcom.spriteFile); GRP[4] = createGRPF(petitcom.spriteFile);
GRP[5] = createGRPF(petitcom.BGFile); GRP[5] = createGRPF(petitcom.BGFile);
} }
void initGLGraphicPages()
{
foreach(g; GRP)
{
g.createTexture(petitcom.renderer, petitcom.textureScaleMode);
g.createBuffer();
}
petitcom.console.GRPF.createTexture(petitcom.renderer, petitcom.textureScaleMode);
}
GraphicPage createGRPF(string file) GraphicPage createGRPF(string file)
{ {
SDL_RWops* stream = SDL_RWFromFile(toStringz(file), toStringz("rb")); SDL_RWops* stream = SDL_RWFromFile(toStringz(file), toStringz("rb"));
auto src = IMG_Load_RW(stream, 0); auto src = IMG_Load_RW(stream, 0);
SDL_Surface* surface = SDL_CreateRGBSurface(0, src.w, src.h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);//0xff000000, 0x00ff0000, 0x0000ff00, 0xFF); SDL_Surface* surface = SDL_CreateRGBSurface(0, width, height, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);//0xff000000, 0x00ff0000, 0x0000ff00, 0xFF);
SDL_Rect rect; SDL_Rect rect;
rect.x = 0; rect.x = 0;
rect.y = 0; rect.y = 0;
@@ -403,6 +423,10 @@ class Graphic
} }
void draw() void draw()
{ {
if (!GRP[0].glTexture)
{
initGLGraphicPages();
}
if(!drawMessageLength) return; if(!drawMessageLength) return;
drawflag = true; drawflag = true;
//betuni kouzoutai demo sonnnani sokudo kawaranasasou //betuni kouzoutai demo sonnnani sokudo kawaranasasou
@@ -533,6 +557,7 @@ class Graphic
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
} }
break;
default: default:
} }
if(SDL_GetTicks() - start >= 16 && i != len - 1) if(SDL_GetTicks() - start >= 16 && i != len - 1)

View File

@@ -402,6 +402,17 @@ class PetitComputer
currentDisplay = Display([display0, display1], Size(std.algorithm.max(resolutionTable[gamepad].width, resolutionTable[tv].width), resolutionTable[gamepad].height + resolutionTable[tv].height)); currentDisplay = Display([display0, display1], Size(std.algorithm.max(resolutionTable[gamepad].width, resolutionTable[tv].width), resolutionTable[gamepad].height + resolutionTable[tv].height));
xscreenmode = 4; xscreenmode = 4;
} }
int grpw, grph;
graphic.getSize(grpw, grph);
//1024*1024?
if ((mode == 5 || mode == 6) && (grpw != 1024 || grph != 1024))
{
graphic.setSize(1024, 1024);
}
else if (grpw != 512 || grph != 512)
{
graphic.setSize(512, 512);
}
displaynum = 0; displaynum = 0;
console.changeDisplay(currentDisplay); console.changeDisplay(currentDisplay);
for (int i = cast(int)currentDisplay.rect.length - 1; i >= 0; i--) for (int i = cast(int)currentDisplay.rect.length - 1; i >= 0; i--)
@@ -539,7 +550,6 @@ class PetitComputer
writeln(SDL_GetError.to!string); writeln(SDL_GetError.to!string);
return; return;
} }
console.GRPF.createTexture(renderer, textureScaleMode);
chScreen(0, 0, 400, 240); chScreen(0, 0, 400, 240);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
@@ -557,11 +567,7 @@ class PetitComputer
} }
int loopcnt; int loopcnt;
DerelictGL3.reload(); DerelictGL3.reload();
foreach(g; graphic.GRP) //3graphic.initGLGraphicPages();
{
g.createTexture(renderer, textureScaleMode);
g.createBuffer();
}
//glEnable(GL_BLEND); //glEnable(GL_BLEND);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glAlphaFunc(GL_GEQUAL, 0.5); //glAlphaFunc(GL_GEQUAL, 0.5);