DXGL r796 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r795‎ | r796 | r797 >
Date:20:27, 30 March 2018
Author:admin
Status:new
Tags:
Comment:
Implement 512x448 to 640x480 automatic scaling.
Tested working in Zelda Classic and ZSNES.
Modified paths:
  • /ReadMe.md (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

Index: ReadMe.md
@@ -1,4 +1,4 @@
2 -# DXGL 0.5.11
 2+# DXGL 0.5.13
33 https://www.dxgl.info
44
55 ## Introduction
Index: ddraw/glRenderer.cpp
@@ -3549,10 +3549,69 @@
35503550 glUtil_SetFBO(This->util, NULL);
35513551 }
35523552
 3553+BOOL Is512448Scale(glRenderer *This, glTexture *primary, glTexture *palette)
 3554+{
 3555+ DWORD *ptr32;
 3556+ WORD *ptr16;
 3557+ BYTE *ptr8;
 3558+ if (dxglcfg.HackAutoScale512448to640480)
 3559+ {
 3560+ if ((primary->levels[0].ddsd.dwWidth == 640) && (primary->levels[0].ddsd.dwHeight == 480))
 3561+ {
 3562+ if (primary->levels[0].dirty & 2) glTexture__Download(primary, 0);
 3563+ if (primary->levels[0].ddsd.ddpfPixelFormat.dwRGBBitCount == 8)
 3564+ {
 3565+ ptr8 = (BYTE*)primary->levels[0].buffer;
 3566+ ptr32 = (DWORD*)palette->levels[0].buffer;
 3567+ if (!(ptr32[ptr8[0]] & 0xFFFFFF)) return TRUE;
 3568+ else return FALSE;
 3569+ }
 3570+ else if (primary->levels[0].ddsd.ddpfPixelFormat.dwRGBBitCount == 16)
 3571+ {
 3572+ ptr16 = (WORD*)primary->levels[0].buffer;
 3573+ if (!ptr16[0]) return TRUE;
 3574+ else return FALSE;
 3575+ }
 3576+ else
 3577+ {
 3578+ ptr32 = (DWORD*)primary->levels[0].buffer;
 3579+ if (!(ptr32[0] & 0xFFFFFF)) return TRUE;
 3580+ else return FALSE;
 3581+ }
 3582+ }
 3583+ else if ((primary->levels[0].ddsd.dwWidth == 320) && (primary->levels[0].ddsd.dwHeight == 240))
 3584+ {
 3585+ if (primary->levels[0].dirty & 2) glTexture__Download(primary, 0);
 3586+ if (primary->levels[0].ddsd.ddpfPixelFormat.dwRGBBitCount == 8)
 3587+ {
 3588+ ptr8 = (BYTE*)primary->levels[0].buffer;
 3589+ ptr32 = (DWORD*)palette->levels[0].buffer;
 3590+ if (!(ptr32[ptr8[0]] & 0xFFFFFF)) return TRUE;
 3591+ else return FALSE;
 3592+ }
 3593+ else if (primary->levels[0].ddsd.ddpfPixelFormat.dwRGBBitCount == 16)
 3594+ {
 3595+ ptr16 = (WORD*)primary->levels[0].buffer;
 3596+ if (!ptr16[0]) return TRUE;
 3597+ else return FALSE;
 3598+ }
 3599+ else
 3600+ {
 3601+ ptr32 = (DWORD*)primary->levels[0].buffer;
 3602+ if (!(ptr32[0] & 0xFFFFFF)) return TRUE;
 3603+ else return FALSE;
 3604+ }
 3605+ }
 3606+ else return FALSE;
 3607+ }
 3608+ else return FALSE;
 3609+}
 3610+
35533611 void glRenderer__DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync, glTexture *previous, BOOL setsync)
35543612 {
35553613 int progtype;
35563614 RECT r, r2;
 3615+ BOOL scale512448 = Is512448Scale(This, texture, paltex);
35573616 glUtil_BlendEnable(This->util, FALSE);
35583617 if (previous) previous->levels[0].ddsd.ddsCaps.dwCaps &= ~DDSCAPS_FRONTBUFFER;
35593618 texture->levels[0].ddsd.ddsCaps.dwCaps |= DDSCAPS_FRONTBUFFER;
@@ -3669,8 +3728,18 @@
36703729 This->bltvertices[0].y = This->bltvertices[1].y = This->bltvertices[1].x = This->bltvertices[3].x = 0.;
36713730 This->bltvertices[2].y = This->bltvertices[3].y = (float)texture->bigheight;
36723731 }
3673 - This->bltvertices[0].s = This->bltvertices[0].t = This->bltvertices[1].t = This->bltvertices[2].s = 1.;
3674 - This->bltvertices[1].s = This->bltvertices[2].t = This->bltvertices[3].s = This->bltvertices[3].t = 0.;
 3732+ if (scale512448)
 3733+ {
 3734+ This->bltvertices[0].s = This->bltvertices[2].s = 0.9f;
 3735+ This->bltvertices[0].t = This->bltvertices[1].t = 0.966666667f;
 3736+ This->bltvertices[1].s = This->bltvertices[3].s = 0.1f;
 3737+ This->bltvertices[2].t = This->bltvertices[3].t = 0.0333333333f;
 3738+ }
 3739+ else
 3740+ {
 3741+ This->bltvertices[0].s = This->bltvertices[0].t = This->bltvertices[1].t = This->bltvertices[2].s = 1.;
 3742+ This->bltvertices[1].s = This->bltvertices[2].t = This->bltvertices[3].s = This->bltvertices[3].t = 0.;
 3743+ }
36753744 glUtil_EnableArray(This->util, This->shaders->shaders[progtype].pos, TRUE);
36763745 This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos,2,GL_FLOAT,GL_FALSE,sizeof(BltVertex),&This->bltvertices[0].x);
36773746 glUtil_EnableArray(This->util, This->shaders->shaders[progtype].texcoord, TRUE);