X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fscreen.cpp;fp=src%2Fscreen.cpp;h=f08927073766ea2f26c7b9cda0fcaca437a5a2ca;hb=8ba4c4438d796f83851cd53914dff928193ed658;hp=d3f5672c214db805ef7779b2e120f6a7c34e933e;hpb=d22f243fc585a46e4c29d00bd32727d9f9f4055c;p=thunder diff --git a/src/screen.cpp b/src/screen.cpp index d3f5672..f089270 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -41,7 +41,6 @@ uint8_t spr_color_index; // Sprite color index extern bool show_text; // Whether or not to show text - // // Render the NAMCO screen // @@ -109,7 +108,6 @@ PP = which 4K block to write to? RenderScreenBuffer(); } - // // Render tilemap // @@ -121,14 +119,10 @@ static inline void DrawScreen(uint16_t ramBlock, uint16_t xAddress, uint16_t yAd for(uint8_t sy=0; sy<29; sy++) { for(uint8_t sx=0; sx<37; sx++) - { - DrawChar(sx, sy, ramBase, tileBase << 16, xAddress & 0x07, yAddress & 0x07, transparent); - } } } - // // Draw character on screen // @@ -174,10 +168,8 @@ static inline void DrawChar(uint8_t sx, uint8_t sy, uint16_t ramBase, uint32_t t } } - // // Copy sprites in sprite RAM from positions 4-9 to 10-15 -// (N.B.: This still doesn't solve the shifting signs on the walls problem...) // void CopySprites(void) { @@ -192,9 +184,10 @@ void CopySprites(void) } } - // -// Draw sprites at priority level (new code) +// Draw sprites at priority level +// We read from the sprite copy RAM to render sprites, as that seems to be the +// way the real H/W does it. // void DrawSprites(uint8_t priority) { @@ -202,42 +195,44 @@ void DrawSprites(uint8_t priority) // // Offset Note // ------ -------------------------------------------------------------------- -// 4 h.fb .nnn (f = horz. flip, h = horz. expand, b = sprite offset lo +// 4 (10) h.fb .nnn (f = horz. flip, h = horz. expand, b = sprite offset lo // bit, nnn = upper bits of sprite #) -// 5 Lower 7 bits of sprite # -// 6 Sprite color index (top 7 bits only), bottom bit is bit 8 of X +// 5 (11) Lower 7 bits of sprite # +// 6 (12) Sprite color index (top 7 bits only), bottom bit is bit 8 of X // position -// 7 Sprite X position (bits 0-7) -// 8 Top two bits are sprite priority, bits 4 & 2 are sprite offset hi +// 7 (13) Sprite X position (bits 0-7) +// 8 (14) Top two bits are sprite priority, bits 4 & 2 are sprite offset hi // bit, vert. expand -// 9 Sprite Y position (192 - value) +// 9 (15) Sprite Y position (192 - value) - extern uint8_t gram1[]; // Game RAM space + extern uint8_t gram1[]; // Game RAM space for(uint16_t i=0x5800; i<0x6000; i+=0x10) { - if ((gram1[i + 8 + 6] & 0xC0) == priority) // Check for correct layer... - { - spr_color_index = gram1[i + 6 + 6] >> 1; // Set color... - uint16_t x = ((gram1[i + 6 + 6] & 0x01) << 8) | gram1[i + 7 + 6]; + uint8_t * sprRAM = &gram1[i]; - if (x > 512 - 32) - x -= 512; // Handle neg x values + // Skip sprite if it's not on the correct layer... + if ((sprRAM[14] & 0xC0) != priority) + continue; - uint16_t y = 192 - gram1[i + 9 + 6]; - uint8_t flip = gram1[i + 4 + 6] & 0x20; // Horizontal flip - uint32_t spr_num = ((gram1[i + 4 + 6] & 0x07) << 9) - | ((gram1[i + 5 + 6] & 0x7F) << 2) - | ((gram1[i + 4 + 6] & 0x10) >> 4) - | ((gram1[i + 8 + 6] & 0x10) >> 3); + spr_color_index = sprRAM[12] >> 1; // Set color... + uint16_t x = ((sprRAM[12] & 0x01) << 8) | sprRAM[13]; - // Draw sprite... - Sprite(spr_num, x, y, flip, gram1[i + 4 + 6] & 0x80, gram1[i + 8 + 6] & 0x04); - } + if (x > 512 - 32) + x -= 512; // Handle neg x values + + uint16_t y = 192 - sprRAM[15]; + uint8_t horzFlip = sprRAM[10] & 0x20; + uint32_t spr_num = ((sprRAM[10] & 0x07) << 9) + | ((sprRAM[11] & 0x7F) << 2) + | ((sprRAM[10] & 0x10) >> 4) + | ((sprRAM[14] & 0x10) >> 3); + + // Draw the sprite... + Sprite(spr_num, x, y, horzFlip, sprRAM[10] & 0x80, sprRAM[14] & 0x04); } } - static inline void DrawSpriteBlock(uint32_t & sprnum, uint16_t x, uint16_t y, uint16_t xStart, uint16_t xEnd, int16_t xInc) { extern uint8_t spr_rom[]; @@ -263,7 +258,6 @@ static inline void DrawSpriteBlock(uint32_t & sprnum, uint16_t x, uint16_t y, ui } } - static inline void DrawSpriteBlock2(uint32_t & sprnum, uint16_t x, uint16_t y, uint16_t xStart, uint16_t xEnd, int16_t xInc) { extern uint8_t spr_rom[]; @@ -289,7 +283,6 @@ static inline void DrawSpriteBlock2(uint32_t & sprnum, uint16_t x, uint16_t y, u } } - // // Sprite handler // @@ -343,7 +336,6 @@ void Sprite(uint32_t sprnum, uint16_t x, uint16_t y, uint8_t flip, } } - int FindPCXName(void) { static int pcxNum = -1; // This needs to go elsewhere... (or does it?) @@ -366,7 +358,6 @@ int FindPCXName(void) return -1; } - void SavePCXSnapshot(void) { char filename[30]; @@ -465,4 +456,3 @@ void SavePCXSnapshot(void) // Success! fclose(fw); } -