X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2Fcd%2Fgfx_cd.c;h=db2a406a4557053c497dfdf4337bd57bae249bb3;hb=00bd648e6308fbcfe759a56dc24c11435d358ec4;hp=64b52ddfdeef5ff7e4c66b7d4c30ae769b963264;hpb=01bc6b19934c89aef5a4def364b8eb61aae3f199;p=picodrive.git diff --git a/Pico/cd/gfx_cd.c b/Pico/cd/gfx_cd.c index 64b52dd..db2a406 100644 --- a/Pico/cd/gfx_cd.c +++ b/Pico/cd/gfx_cd.c @@ -35,9 +35,9 @@ static void gfx_cd_start(void) dprintf("gfx_cd_start()"); - rot_comp.XD_Mul = ((rot_comp.Reg_5C & 0x1f) + 1) * 4; + // rot_comp.XD_Mul = ((rot_comp.Reg_5C & 0x1f) + 1) * 4; // unused rot_comp.Function = (rot_comp.Reg_58 & 7) | (Pico_mcd->s68k_regs[3] & 0x18); // Jmp_Adr - rot_comp.Buffer_Adr = (rot_comp.Reg_5E & 0xfff8) << 2; + // rot_comp.Buffer_Adr = (rot_comp.Reg_5E & 0xfff8) << 2; // unused? rot_comp.YD = (rot_comp.Reg_60 >> 3) & 7; rot_comp.Vector_Adr = (rot_comp.Reg_66 & 0xfffe) << 2; @@ -79,75 +79,67 @@ static void gfx_completed(void) } -static void gfx_do(void) +static void gfx_do(unsigned int func, unsigned short *stamp_base, unsigned int H_Dot) { - unsigned int eax, ebx, ecx, edx, esi, edi, pixel = 0; - unsigned int func = rot_comp.Function; - unsigned short *ptrs; + unsigned int eax, ebx, ecx, edx, esi, edi, pixel; + unsigned int XD, Buffer_Adr; + int DYXS; - rot_comp.XD = rot_comp.Reg_60 & 7; - rot_comp.Buffer_Adr = ((rot_comp.Reg_5E & 0xfff8) + rot_comp.YD) << 2; - rot_comp.H_Dot = rot_comp.Reg_62 & 0x1ff; + XD = rot_comp.Reg_60 & 7; + Buffer_Adr = ((rot_comp.Reg_5E & 0xfff8) + rot_comp.YD) << 2; ecx = *(unsigned int *)(Pico_mcd->word_ram2M + rot_comp.Vector_Adr); edx = ecx >> 16; ecx = (ecx & 0xffff) << 8; edx <<= 8; - rot_comp.DXS = *(int *)(Pico_mcd->word_ram2M + rot_comp.Vector_Adr + 4); - rot_comp.DYS = rot_comp.DXS >> 16; - rot_comp.DXS = (rot_comp.DXS << 16) >> 16; // sign extend + DYXS = *(int *)(Pico_mcd->word_ram2M + rot_comp.Vector_Adr + 4); rot_comp.Vector_Adr += 8; // MAKE_IMAGE_LINE - while (rot_comp.H_Dot) + while (H_Dot) { if (func & 2) // mode 32x32 dot { if (func & 4) // 16x16 screen { - eax = (ecx >> (11+5)) & 0x007f; - ebx = (edx >> (11-2)) & 0x3f80; + ebx = ((ecx >> (11+5)) & 0x007f) | + ((edx >> (11-2)) & 0x3f80); } else // 1x1 screen { - eax = (ecx >> (11+5)) & 0x07; - ebx = (edx >> (11+2)) & 0x38; + ebx = ((ecx >> (11+5)) & 0x07) | + ((edx >> (11+2)) & 0x38); } } else // mode 16x16 dot { if (func & 4) // 16x16 screen { - eax = (ecx >> (11+4)) & 0x00ff; - ebx = (edx >> (11-4)) & 0xff00; + ebx = ((ecx >> (11+4)) & 0x00ff) | + ((edx >> (11-4)) & 0xff00); } else // 1x1 screen { - eax = (ecx >> (11+4)) & 0x0f; - ebx = (edx >> (11+0)) & 0xf0; + ebx = ((ecx >> (11+4)) & 0x0f) | + ((edx >> (11+0)) & 0xf0); } } - ebx += eax; - - // esi = rot_comp.Stamp_Map_Adr; - ptrs = (unsigned short *) (Pico_mcd->word_ram2M + rot_comp.Stamp_Map_Adr + ebx*2); - edi = ptrs[0] | (ptrs[1] << 16); // MAKE_IMAGE_PIXEL if (!(func & 1)) // NOT TILED { - if (func & 4) // 16x16 screen + int mask = (func & 4) ? 0x00800000 : 0x00f80000; + if ((ecx | edx) & mask) { - if ((edx & 0x00800000) || (ecx & 0x00800000)) goto Pixel_Out; - } - else // 1x1 screen - { - if ((edx & 0x00f80000) || (ecx & 0x00f80000)) goto Pixel_Out; + if (func & 0x18) goto Next_Pixel; + pixel = 0; + goto Pixel_Out; } } - esi = edi; + + edi = stamp_base[ebx];// | (stamp_base[ebx+1] << 16); + esi = (edi & 0x7ff) << 7; + if (!esi) { pixel = 0; goto Pixel_Out; } edi >>= (11+1); - esi = (esi & 0x7ff) << 7; - if (!esi) goto Pixel_Out; edi &= (0x1c>>1); eax = ecx; ebx = edx; @@ -254,15 +246,13 @@ static void gfx_do(void) pixel = *(Pico_mcd->word_ram2M + (edi >> 12) + eax); if (!(edi & 0x800)) pixel >>= 4; + else pixel &= 0x0f; Pixel_Out: -// pixel = 0; -//Finish: - pixel &= 0x0f; if (!pixel && (func & 0x18)) goto Next_Pixel; - esi = rot_comp.Buffer_Adr + ((rot_comp.XD>>1)^1); // pixel addr + esi = Buffer_Adr + ((XD>>1)^1); // pixel addr eax = *(Pico_mcd->word_ram2M + esi); // old pixel - if (rot_comp.XD & 1) + if (XD & 1) { if ((eax & 0x0f) && (func & 0x18) == 0x08) goto Next_Pixel; // underwrite *(Pico_mcd->word_ram2M + esi) = pixel | (eax & 0xf0); @@ -275,19 +265,20 @@ Pixel_Out: Next_Pixel: - ecx += rot_comp.DXS; - edx += rot_comp.DYS; - rot_comp.XD++; - if (rot_comp.XD >= 8) + ecx += (DYXS << 16) >> 16; // rot_comp.DXS; + edx += DYXS >> 16; // rot_comp.DYS; + XD++; + if (XD >= 8) { - rot_comp.Buffer_Adr += ((rot_comp.Reg_5C & 0x1f) + 1) << 5; - rot_comp.XD = 0; + Buffer_Adr += ((rot_comp.Reg_5C & 0x1f) + 1) << 5; + XD = 0; } - rot_comp.H_Dot--; + H_Dot--; } + // end while -//nothing_to_draw: +// nothing_to_draw: rot_comp.YD++; // rot_comp.V_Dot--; // will be done by caller } @@ -295,12 +286,12 @@ Next_Pixel: void gfx_cd_update(void) { - unsigned char *V_Dot = (unsigned char *) &rot_comp.Reg_64; + int V_Dot = rot_comp.Reg_64 & 0xff; int jobs; dprintf("gfx_cd_update, Reg_64 = %04x", rot_comp.Reg_64); - if (!*V_Dot) + if (!V_Dot) { gfx_completed(); return; @@ -317,20 +308,36 @@ void gfx_cd_update(void) rot_comp.Float_Part &= 0xffff; rot_comp.Float_Part += rot_comp.Draw_Speed; - while (jobs--) + if (PicoOpt & 0x1000) // scale/rot enabled { - if (PicoOpt & 0x1000) - gfx_do(); // jmp [Jmp_Adr]: + unsigned int func = rot_comp.Function; + unsigned int H_Dot = rot_comp.Reg_62 & 0x1ff; + unsigned short *stamp_base = (unsigned short *) (Pico_mcd->word_ram2M + rot_comp.Stamp_Map_Adr); - (*V_Dot)--; // dec byte [V_Dot] + while (jobs--) + { + gfx_do(func, stamp_base, H_Dot); // jmp [Jmp_Adr]: - if (!*V_Dot) + V_Dot--; // dec byte [V_Dot] + if (V_Dot == 0) + { + // GFX_Completed: + gfx_completed(); + return; + } + } + } + else + { + if (jobs >= V_Dot) { - // GFX_Completed: gfx_completed(); return; } + V_Dot -= jobs; } + + rot_comp.Reg_64 = V_Dot; }