X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fuiq3%2Fengine%2Fvid.cpp;h=d004bdfd9250848cf7fd4b1370269681b363e99e;hb=e59af1c9b829484ffa4c84b680c6ce9abcdfa53f;hp=bd1b3fd68e77c1f28e72123f774af6f260c39f7b;hpb=ca482e5de8bacb70db55f43afe02f93fe6fe3f16;p=picodrive.git diff --git a/platform/uiq3/engine/vid.cpp b/platform/uiq3/engine/vid.cpp index bd1b3fd..d004bdf 100644 --- a/platform/uiq3/engine/vid.cpp +++ b/platform/uiq3/engine/vid.cpp @@ -5,7 +5,7 @@ #include "vid.h" #include "../Engine.h" -#include +#include #include "../../common/emu.h" #include "blit.h" #include "debug.h" @@ -19,7 +19,7 @@ extern const char *actionNames[]; static void *screenbuff = 0; // pointer to real device video memory //static extern "C" { unsigned char *PicoDraw2FB = 0; } // temporary buffer -const int framebuffsize = (8+320)*(8+240+8)*2+8*2; // actual framebuffer size (in bytes+to support new rendering mode) +const int framebuffsize = (8+320)*(8+240+8)*2+8*2; // PicoDraw2FB size (in bytes+to support new rendering mode) // drawer function pointers static void (*drawTextFps)(const char *text) = 0; @@ -92,7 +92,7 @@ static const unsigned long mask_numbers[] = { static int EmuScanBegin8(unsigned int num) { - DrawLineDest = PicoDraw2FB + 328*num + 328*8 + 8; + DrawLineDest = PicoDraw2FB + 328*num + 8; return 0; } @@ -105,7 +105,7 @@ static int EmuScanEndFit0(unsigned int num) static int u = 0, num2 = 0; if(!num) u = num2 = 0; - DrawLineDest = PicoDraw2FB + 328*(++num2) + 328*8 + 8; + DrawLineDest = PicoDraw2FB + 328*(++num2) + 8; u += 6666; @@ -182,7 +182,7 @@ static void drawTextM2Fat(int x, int y, const char *text) static void drawTextFpsCenter0(const char *text) { if(!text) return; - drawTextM2(214, 216, text); + drawTextM2((Pico.video.reg[12]&1) ? 234 : 214, 216, text); } static void drawTextFpsFit0(const char *text) @@ -206,7 +206,7 @@ static void drawTextFps0(const char *text) static void drawTextNoticeCenter0(const char *text) { if(!text) return; - drawTextM2(2, 216, text); + drawTextM2(42, 216, text); } static void drawTextNoticeFit0(const char *text) @@ -250,12 +250,14 @@ static void fillLocalPal(void) memcpy32(localPal+0xc0, localPal+0x40, 0x40); localPal[0xe0] = 0x00000000; // reserved pixels for OSD localPal[0xf0] = 0x00ee0000; - } else if (rendstatus & 0x20) { // mid-frame palette changes + } + else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes vidConvCpyRGB32(localPal, Pico.cram, 0x40); vidConvCpyRGB32(localPal+0x40, HighPal, 0x40); vidConvCpyRGB32(localPal+0x80, HighPal+0x40, 0x40); } else { vidConvCpyRGB32(localPal, Pico.cram, 0x40); + memcpy32(localPal+0x80, localPal, 0x40); // for sprite prio mess } } @@ -266,15 +268,13 @@ static void vidBlit_90(int full) unsigned char *ps = PicoDraw2FB+328*8; unsigned long *pd = (unsigned long *) screenbuff; - if (Pico.m.dirtyPal) fillLocalPal(); - if(Pico.video.reg[12]&1) vidConvCpy_90(pd, ps, localPal, 320/8); else { if(full) vidClear(pd, 32); - pd += 256*32; + pd += (240+VID_BORDER_R)*32; vidConvCpy_90(pd, ps, localPal, 256/8); - if(full) vidClear(pd + 256*256, 32); + if(full) vidClear(pd + (240+VID_BORDER_R)*256, 32); } } @@ -284,16 +284,14 @@ static void vidBlit_270(int full) unsigned char *ps = PicoDraw2FB+328*8; unsigned long *pd = (unsigned long *) screenbuff; - if (Pico.m.dirtyPal) fillLocalPal(); - if(Pico.video.reg[12]&1) vidConvCpy_270(pd, ps, localPal, 320/8); else { if(full) vidClear(pd, 32); - pd += 256*32; + pd += (240+VID_BORDER_R)*32; ps -= 64; // the blitter starts copying from the right border, so we need to adjust vidConvCpy_270(pd, ps, localPal, 256/8); - if(full) vidClear(pd + 256*256, 32); + if(full) vidClear(pd + (240+VID_BORDER_R)*256, 32); } } @@ -303,11 +301,9 @@ static void vidBlitCenter_0(int full) unsigned char *ps = PicoDraw2FB+328*8+8; unsigned long *pd = (unsigned long *) screenbuff; - if (Pico.m.dirtyPal) fillLocalPal(); - if(Pico.video.reg[12]&1) ps += 32; vidConvCpy_center_0(pd, ps, localPal); - if(full) vidClear(pd + 224*256, 96); + if(full) vidClear(pd + (240+VID_BORDER_R)*224, 96); } @@ -316,58 +312,47 @@ static void vidBlitCenter_180(int full) unsigned char *ps = PicoDraw2FB+328*8+8; unsigned long *pd = (unsigned long *) screenbuff; - if (Pico.m.dirtyPal) fillLocalPal(); - if(Pico.video.reg[12]&1) ps += 32; vidConvCpy_center_180(pd, ps, localPal); - if(full) vidClear(pd + 224*256, 96); + if(full) vidClear(pd + (240+VID_BORDER_R)*224, 96); } static void vidBlitFit_0(int full) { - if (Pico.m.dirtyPal) fillLocalPal(); - if(Pico.video.reg[12]&1) - vidConvCpy_center2_40c_0(screenbuff, PicoDraw2FB+328*8, localPal, 168); + vidConvCpy_center2_40c_0(screenbuff, PicoDraw2FB+328*8, localPal, 168); else vidConvCpy_center2_32c_0(screenbuff, PicoDraw2FB+328*8, localPal, 168); - if(full) vidClear((unsigned long *)screenbuff + 168*256, 320-168); + if(full) vidClear((unsigned long *)screenbuff + (240+VID_BORDER_R)*168, 320-168); } static void vidBlitFit_180(int full) { - if (Pico.m.dirtyPal) fillLocalPal(); - if(Pico.video.reg[12]&1) vidConvCpy_center2_40c_180(screenbuff, PicoDraw2FB+328*8, localPal, 168); else vidConvCpy_center2_32c_180(screenbuff, PicoDraw2FB+328*8-64, localPal, 168); - if(full) vidClear((unsigned long *)screenbuff + 168*256, 320-168); + if(full) vidClear((unsigned long *)screenbuff + (240+VID_BORDER_R)*168, 320-168); } static void vidBlitFit2_0(int full) { - if (Pico.m.dirtyPal) fillLocalPal(); - if(Pico.video.reg[12]&1) vidConvCpy_center2_40c_0(screenbuff, PicoDraw2FB+328*8, localPal, 224); else vidConvCpy_center2_32c_0(screenbuff, PicoDraw2FB+328*8, localPal, 224); - if(full) vidClear((unsigned long *)screenbuff + 224*256, 96); + if(full) vidClear((unsigned long *)screenbuff + (240+VID_BORDER_R)*224, 96); } static void vidBlitFit2_180(int full) { - if (Pico.m.dirtyPal) fillLocalPal(); - if(Pico.video.reg[12]&1) vidConvCpy_center2_40c_180(screenbuff, PicoDraw2FB+328*8, localPal, 224); else vidConvCpy_center2_32c_180(screenbuff, PicoDraw2FB+328*8-64, localPal, 224); - if(full) vidClear((unsigned long *)screenbuff + 224*256, 96); + if(full) vidClear((unsigned long *)screenbuff + (240+VID_BORDER_R)*224, 96); } - static void vidBlitCfg(void) { unsigned short *ps = (unsigned short *) PicoDraw2FB; @@ -378,7 +363,7 @@ static void vidBlitCfg(void) //for (int i = 1; i < 320; i++, ps += 240, pd += 256) // vidConvCpyRGB32(pd, ps, 240); - for (i = 0; i < 320; i++, pd += 16) + for (i = 0; i < 320; i++, pd += VID_BORDER_R) for (int u = 0; u < 240; u++, ps++, pd++) *pd = ((*ps & 0xf) << 20) | ((*ps & 0xf0) << 8) | ((*ps & 0xf00) >> 4); } @@ -403,6 +388,7 @@ int vidInit(void *vidmem, int reinit) // select suitable blitters vidBlit = vidBlit_270; PicoScanBegin = EmuScanBegin8; + PicoScanEnd = NULL; drawTextFps = drawTextFps0; drawTextNotice = drawTextNotice0; @@ -425,6 +411,7 @@ int vidInit(void *vidmem, int reinit) vidBlit = vidBlitFit_0; drawTextFps = drawTextFpsFit0; drawTextNotice = drawTextNoticeFit0; + PicoScanBegin = NULL; PicoScanEnd = EmuScanEndFit0; } } else if (currentConfig.rotation == TPicoConfig::PRot90) { @@ -446,6 +433,7 @@ int vidInit(void *vidmem, int reinit) vidBlit = vidBlitFit_180; drawTextFps = drawTextFpsFit0; drawTextNotice = drawTextNoticeFit0; + PicoScanBegin = NULL; PicoScanEnd = EmuScanEndFit0; } } @@ -453,6 +441,7 @@ int vidInit(void *vidmem, int reinit) vidBlit = vidBlit_270; } + fillLocalPal(); vidBlit(1); PicoOpt |= 0x100; Pico.m.dirtyPal = 1; @@ -475,6 +464,7 @@ void vidDrawFrame(char *noticeStr, char *fpsStr, int num) drawTextFps(fpsStr); drawTextNotice(noticeStr); + if (Pico.m.dirtyPal) fillLocalPal(); vidBlit(!num); // copy full frame once a second }