Skip to content

Commit

Permalink
fix galpani3 bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
dinkc64 committed Nov 8, 2024
1 parent 6af8a99 commit 3ab3376
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions src/burn/drv/pst90s/d_galpani3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static INT32 scrolly[3];
static INT32 enable[3];
static INT32 fbbright1[3];
static INT32 fbbright2[3];
static INT32 c1c[3];
static INT32 regs1_address[4][2];
static INT32 prio_scrollx;
static INT32 prio_scrolly;
Expand Down Expand Up @@ -146,7 +147,7 @@ static void toybox_mcu_com_write(UINT16 data, INT32 select)
toybox_mcu_run();
}

static void do_rle(INT32 which)
static void do_rle(INT32 which, INT32 data)
{
INT32 rle_count = 0;
INT32 normal_count = 0;
Expand All @@ -156,6 +157,16 @@ static void do_rle(INT32 which)
UINT32 address = regs1_address[which][1] | (regs1_address[which][0]<<16);
UINT16 *framebuffer = DrvFrameBuffer[which];

switch (data & 0xf000) {
case 0x2000:
return; // not used?
case 0x3000:
// data = framebuffer destination address "x" offset
// c1c = framebuffer destination address "y" offset -dink Nov, 2024
dstaddress += (data & 0x1ff) | ((c1c[which] & 0x1ff) * 0x200);
break;
}

while (dstaddress<0x40000)
{
if (rle_count==0 && normal_count==0)
Expand All @@ -176,7 +187,9 @@ static void do_rle(INT32 which)
else if (rle_count)
{
thebyte = DrvGfxROM[address & 0xffffff];
framebuffer[dstaddress] = BURN_ENDIAN_SWAP_INT16(thebyte);
if (dstaddress >= 0) {
framebuffer[dstaddress] = BURN_ENDIAN_SWAP_INT16(thebyte);
}
dstaddress++;
rle_count--;

Expand All @@ -188,7 +201,9 @@ static void do_rle(INT32 which)
else if (normal_count)
{
thebyte = DrvGfxROM[address & 0xffffff];
framebuffer[dstaddress] = BURN_ENDIAN_SWAP_INT16(thebyte);
if (dstaddress >= 0) {
framebuffer[dstaddress] = BURN_ENDIAN_SWAP_INT16(thebyte);
}
dstaddress++;
normal_count--;
address++;
Expand Down Expand Up @@ -261,11 +276,17 @@ static void __fastcall galpani3_write_word(UINT32 address, UINT16 data)
regs1_address[(address / 0x200000) & 3][(address / 2) & 1] = data;
return;

case 0x800c1c:
case 0xa00c1c:
case 0xc00c1c:
c1c[(address / 0x200000) & 3] = data;
return;

case 0x800c1e:
case 0xa00c1e:
case 0xc00c1e:
if ((data & 0xefff) == 0x2000) do_rle((address / 0x200000) & 3);
return;
do_rle((address / 0x200000) & 3, data);
return;

case 0xe80000:
prio_scrollx = data;
Expand Down Expand Up @@ -369,6 +390,7 @@ static INT32 DrvDoReset(INT32 clear_mem)
memset (scrollx, 0, sizeof(scrollx));
memset (scrolly, 0, sizeof(scrolly));
memset (enable, 0, sizeof(enable));
memset (c1c, 0, sizeof(c1c));
memset (fbbright1, 0, sizeof(fbbright1));
memset (fbbright2, 0, sizeof(fbbright2));
memset (regs1_address, 0, sizeof(regs1_address));
Expand Down Expand Up @@ -605,7 +627,7 @@ static inline UINT32 alpha_blend(UINT32 d, UINT32 s, UINT32 p)
static INT32 DrvDraw()
{
DrvPaletteUpdate();

pBurnDrvPalette = DrvPalette;
// Clear sknsspr bitmap register (assumed only used by galpani3)
UINT32 *sprite_regs = (UINT32*)DrvSprRegs;
if (~BURN_ENDIAN_SWAP_INT32(sprite_regs[0x04/4]) & 0x04) {
Expand Down Expand Up @@ -663,9 +685,9 @@ static INT32 DrvDraw()
if (nSpriteEnable & 1) COPY_SPRITE_PIXEL(0x0000);
if (nBurnLayer & 1 && enable[1]) DRAW_BLITLAYER2();
if (nSpriteEnable & 2) COPY_SPRITE_PIXEL(0x4000);
if (nBurnLayer & 2 && dat1 && enable[0]) DRAW_BLITLAYER1();
if (nBurnLayer & 2 && enable[0]) DRAW_BLITLAYER1();
if (nSpriteEnable & 4) COPY_SPRITE_PIXEL(0x8000);
if (nBurnLayer & 4 && dat3 && enable[1]) DRAW_BLITLAYER3();
if (nBurnLayer & 4 && dat3 && enable[2]) DRAW_BLITLAYER3();
if (nSpriteEnable & 8) COPY_SPRITE_PIXEL(0xc000);
}
else
Expand Down

0 comments on commit 3ab3376

Please sign in to comment.