diff options
-rw-r--r-- | libretro/libretro.c | 35 | ||||
-rw-r--r-- | src/gfx.c | 98 | ||||
-rw-r--r-- | src/gfx.h | 10 | ||||
-rw-r--r-- | src/tile.c | 141 | ||||
-rw-r--r-- | src/tile.h | 2 |
5 files changed, 171 insertions, 115 deletions
diff --git a/libretro/libretro.c b/libretro/libretro.c index 930053b..1f409d7 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -247,8 +247,9 @@ static void snes_init (void) Settings.TurboSkipFrames = 15; Settings.ThreadSound = FALSE; Settings.SoundSync = FALSE; +#ifdef ASMCPU Settings.asmspc700 = TRUE; -// Settings.asmspc700 = FALSE; +#endif Settings.SpeedHacks = TRUE; Settings.HBlankStart = (256 * Settings.H_Max) / SNES_HCOUNTER_MAX; @@ -306,16 +307,21 @@ static void snes_init (void) GFX.Pitch = use_overscan ? 1024 : 2048; + const int safety = 128; // hack to make sure GFX.Delta is always (2048 * 512 * 2) >> 1, needed for tile16_t.h #ifdef _3DS - GFX.Screen = (uint8 *) linearMemAlign(2048 * 512 * 2 * 2, 0x80); + GFX.Screen_buffer = (uint8 *) linearMemAlign(2048 * 512 * 2 * 2 + safety, 0x80); memset(GFX.Screen, 0x0, 2048 * 512 * 2 * 2); #else - GFX.Screen = (uint8 *) calloc(1, 2048 * 512 * 2 * 2); + GFX.Screen_buffer = (uint8 *) calloc(1, 2048 * 512 * 2 * 2 + safety); #endif + GFX.Screen = GFX.Screen_buffer + safety; + GFX.SubScreen = GFX.Screen + 2048 * 512 * 2; - GFX.ZBuffer = (uint8 *) calloc(1, GFX.Pitch * 512 * sizeof(uint16)); - GFX.SubZBuffer = (uint8 *) calloc(1, GFX.Pitch * 512 * sizeof(uint16)); + GFX.ZBuffer_buffer = (uint8 *) calloc(1, GFX.Pitch * 512 * sizeof(uint16) + safety); + GFX.ZBuffer = GFX.ZBuffer_buffer + safety; + GFX.SubZBuffer_buffer = (uint8 *) calloc(1, GFX.Pitch * 512 * sizeof(uint16) + safety); + GFX.SubZBuffer = GFX.SubZBuffer_buffer + safety; GFX.Delta = 1048576; //(GFX.SubScreen - GFX.Screen) >> 1; if (GFX.Delta != ((GFX.SubScreen - GFX.Screen) >> 1)) @@ -356,13 +362,25 @@ void retro_deinit(void) MemoryDeinit(); S9xGraphicsDeinit(); //S9xUnmapAllControls(); - if(GFX.Screen) + if(GFX.Screen_buffer) #ifdef _3DS - linearFree(GFX.Screen); + linearFree(GFX.Screen_buffer); #else - free(GFX.Screen); + free(GFX.Screen_buffer); #endif + GFX.Screen_buffer = NULL; GFX.Screen = NULL; + GFX.SubScreen = NULL; + + if(GFX.ZBuffer_buffer) + free(GFX.ZBuffer_buffer); + GFX.ZBuffer_buffer = NULL; + + if(GFX.SubZBuffer_buffer) + free(GFX.SubZBuffer_buffer); + + GFX.SubZBuffer_buffer = NULL; + } @@ -510,7 +528,6 @@ bool retro_load_game(const struct retro_game_info *game) //S9xGraphicsInit(); S9xReset(); -// Settings.asmspc700 = false; CPU.APU_APUExecuting = Settings.APUEnabled = 1; Settings.SixteenBitSound = true; so.stereo = Settings.Stereo; @@ -137,109 +137,109 @@ extern uint8 Mode7Depths [2]; #define BLACK BUILD_PIXEL(0,0,0) -void DrawTile(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -void DrawClippedTile(uint32 Tile, uint32 Offset, +void DrawClippedTile(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawTilex2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTilex2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -void DrawClippedTilex2(uint32 Tile, uint32 Offset, +void DrawClippedTilex2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawTilex2x2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTilex2x2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -void DrawClippedTilex2x2(uint32 Tile, uint32 Offset, +void DrawClippedTilex2x2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawLargePixel(uint32 Tile, uint32 Offset, +void DrawLargePixel(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount); -void DrawTile16(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -void DrawTile16_OBJ(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16_OBJ(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -void DrawClippedTile16(uint32 Tile, uint32 Offset, +void DrawClippedTile16(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawTile16x2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16x2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -void DrawClippedTile16x2(uint32 Tile, uint32 Offset, +void DrawClippedTile16x2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawTile16x2x2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16x2x2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -void DrawClippedTile16x2x2(uint32 Tile, uint32 Offset, +void DrawClippedTile16x2x2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawLargePixel16(uint32 Tile, uint32 Offset, +void DrawLargePixel16(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount); -void DrawTile16Add(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16Add(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -void DrawClippedTile16Add(uint32 Tile, uint32 Offset, +void DrawClippedTile16Add(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawTile16Add1_2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16Add1_2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -void DrawClippedTile16Add1_2(uint32 Tile, uint32 Offset, +void DrawClippedTile16Add1_2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawTile16FixedAdd1_2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16FixedAdd1_2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -void DrawClippedTile16FixedAdd1_2(uint32 Tile, uint32 Offset, +void DrawClippedTile16FixedAdd1_2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawTile16Sub(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16Sub(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -void DrawClippedTile16Sub(uint32 Tile, uint32 Offset, +void DrawClippedTile16Sub(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawTile16Sub1_2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16Sub1_2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -void DrawClippedTile16Sub1_2(uint32 Tile, uint32 Offset, +void DrawClippedTile16Sub1_2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawTile16FixedSub1_2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16FixedSub1_2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -void DrawClippedTile16FixedSub1_2(uint32 Tile, uint32 Offset, +void DrawClippedTile16FixedSub1_2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawLargePixel16Add(uint32 Tile, uint32 Offset, +void DrawLargePixel16Add(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount); -void DrawLargePixel16Add1_2(uint32 Tile, uint32 Offset, +void DrawLargePixel16Add1_2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount); -void DrawLargePixel16Sub(uint32 Tile, uint32 Offset, +void DrawLargePixel16Sub(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount); -void DrawLargePixel16Sub1_2(uint32 Tile, uint32 Offset, +void DrawLargePixel16Sub1_2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount); -void DrawHiResClippedTile16(uint32 Tile, uint32 Offset, +void DrawHiResClippedTile16(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawHiResTile16(uint32 Tile, uint32 Offset, +void DrawHiResTile16(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); bool8_32 S9xGraphicsInit() @@ -252,9 +252,11 @@ bool8_32 S9xGraphicsInit() S9xSetRenderPixelFormat(RGB565); #endif - for (uint8 bitshift = 0; bitshift < 4; bitshift++) + uint8 bitshift; + for (bitshift = 0; bitshift < 4; bitshift++) { - for (register int i = 0; i < 16; i++) + register int i; + for (i = 0; i < 16; i++) { register uint32 h = 0; register uint32 l = 0; @@ -676,7 +678,7 @@ void S9xSetInfoString(const char* string) { } -static INLINE void SelectTileRenderer(bool8_32 normal) +static INLINE void SelectTileRenderer(bool8_32 normal, bool NoZ) { if (normal) { @@ -803,7 +805,7 @@ void S9xSetupOBJ() IPPU.OBJChanged = FALSE; } -void DrawOBJS(bool8_32 OnMain = FALSE, uint8 D = 0) +void DrawOBJS(bool8_32 OnMain, uint8 D) { uint32 O; uint32 BaseTile, Tile; @@ -821,6 +823,8 @@ void DrawOBJS(bool8_32 OnMain = FALSE, uint8 D = 0) BG.NameSelect = PPU.OBJNameSelect; BG.DirectColourMode = FALSE; + SelectPalette(); + GFX.Z1 = D + 2; if (DrawTilePtr == DrawTile16) @@ -838,7 +842,7 @@ void DrawOBJS(bool8_32 OnMain = FALSE, uint8 D = 0) if (OnMain && SUB_OR_ADD(4)) { - SelectTileRenderer(!GFX.Pseudo && PPU.OBJ [S].Palette < 4); + SelectTileRenderer(!GFX.Pseudo && PPU.OBJ [S].Palette < 4, false); if (DrawTilePtr == DrawTile16) DrawTilePtr = DrawTile16_OBJ; } @@ -973,6 +977,8 @@ void DrawBackgroundMosaic(uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) else BG.StartPalette = 0; + SelectPalette(); + SC0 = (uint16*) &Memory.VRAM[PPU.BG[bg].SCBase << 1]; if (PPU.BG[bg].SCSize & 1) @@ -1197,6 +1203,7 @@ void DrawBackgroundOffset(uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) uint8 depths [2] = {Z1, Z2}; BG.StartPalette = 0; + SelectPalette(); BPS0 = (uint16*) &Memory.VRAM[PPU.BG[2].SCBase << 1]; @@ -1316,7 +1323,7 @@ void DrawBackgroundOffset(uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) uint32 VOffset; uint32 HOffset; uint32 LineHOffset = LineData [Y].BG[bg].HOffset; - uint32 Offset; + int32 Offset; uint32 HPos; uint32 Quot; uint32 Count; @@ -1451,7 +1458,7 @@ void DrawBackgroundOffset(uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) } } -void DrawBackgroundMode5(uint32 /* BGMODE */, uint32 bg, uint8 Z1, uint8 Z2) +void DrawBackgroundMode5(uint32 BGMODE, uint32 bg, uint8 Z1, uint8 Z2) { CHECK_SOUND(); @@ -1465,6 +1472,7 @@ void DrawBackgroundMode5(uint32 /* BGMODE */, uint32 bg, uint8 Z1, uint8 Z2) uint32 Width; BG.StartPalette = 0; + SelectPalette(); SC0 = (uint16*) &Memory.VRAM[PPU.BG[bg].SCBase << 1]; @@ -1866,7 +1874,7 @@ void DrawBackground_8(uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) // Left hand edge clipped tile if (HPos & 7) { - uint32 Offset = (HPos & 7); + int32 Offset = (HPos & 7); Count = 8 - Offset; if (Count > Width) Count = Width; s -= Offset; @@ -2018,7 +2026,7 @@ void DrawBackground_16(uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) // Left hand edge clipped tile if (HPos & 7) { - uint32 Offset = (HPos & 7); + int32 Offset = (HPos & 7); Count = 8 - Offset; if (Count > Width) Count = Width; s -= Offset; @@ -2070,7 +2078,7 @@ void DrawBackground_16(uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) GFX.Z1 = GFX.Z2 = depths [(Tile & 0x2000) >> 13]; } -inline void DrawBackground(uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) +static inline void DrawBackground(uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) { //StartAnalyze(); @@ -2113,6 +2121,8 @@ inline void DrawBackground(uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) BG.StartPalette = bg << 5; else BG.StartPalette = 0; + SelectPalette(); + if (BG.TileSize == 8) DrawBackground_8(BGMode, bg, Z1, Z2); else @@ -3557,7 +3567,7 @@ void S9xUpdateScreen() // ~30-50ms! (called from FLUSH_REDRAW()) back = black; else { - SelectTileRenderer(TRUE); //selects the tile renderers to be used + SelectTileRenderer(TRUE, FALSE); //selects the tile renderers to be used // TRUE means to use the default // FALSE means use best renderer based on current // graphics register settings @@ -52,6 +52,10 @@ typedef struct { // Initialize these variables + uint8* Screen_buffer; + uint8* ZBuffer_buffer; + uint8* SubZBuffer_buffer; + uint8* Screen; uint8* SubScreen; uint8* ZBuffer; @@ -231,12 +235,12 @@ GFX.ZERO_OR_X2 [(((C1) | RGB_HI_BITS_MASKx2) - \ GFX.ZERO [(((C1) | RGB_HI_BITS_MASKx2) - \ ((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1] -typedef void (*NormalTileRenderer)(uint32 Tile, uint32 Offset, +typedef void (*NormalTileRenderer)(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount); -typedef void (*ClippedTileRenderer)(uint32 Tile, uint32 Offset, +typedef void (*ClippedTileRenderer)(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -typedef void (*LargePixelRenderer)(uint32 Tile, uint32 Offset, +typedef void (*LargePixelRenderer)(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount); @@ -164,7 +164,30 @@ uint8 ConvertTile(uint8* pCache, uint32 TileAddr) return (non_zero ? TRUE : BLANK_TILE); } -static INLINE void WRITE_4PIXELS(uint32 Offset, uint8* Pixels) +void SelectPalette() +{ + // GFX.ScreenColors = &GFX.ScreenColorsPre[(Tile & GFX.PaletteMask) >> GFX.PaletteShift]; + if (BG.DirectColourMode) + { + // GFX.ScreenColors = DirectColourMaps [(Tile >> 10) & BG.PaletteMask]; + + GFX.ScreenColorsPre = DirectColourMaps[0]; + GFX.PaletteMask = BG.PaletteMask << 10; + GFX.PaletteShift = 10; + } + else + { + // GFX.ScreenColors = &IPPU.ScreenColors [(((Tile >> 10) & BG.PaletteMask) << BG.PaletteShift) + BG.StartPalette]; + + GFX.ScreenColorsPre = &IPPU.ScreenColors[BG.StartPalette]; + GFX.PaletteMask = BG.PaletteMask << 10; + GFX.PaletteShift = 10 - BG.PaletteShift; + } + +} + + +static INLINE void WRITE_4PIXELS(int32 Offset, uint8* Pixels) { register uint8 Pixel; uint8* Screen = GFX.S + Offset; @@ -184,7 +207,7 @@ static INLINE void WRITE_4PIXELS(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS_FLIPPED(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS_FLIPPED(int32 Offset, uint8* Pixels) { register uint8 Pixel; uint8* Screen = GFX.S + Offset; @@ -204,7 +227,7 @@ static INLINE void WRITE_4PIXELS_FLIPPED(uint32 Offset, uint8* Pixels) #undef FN } -inline void WRITE_4PIXELSHI16(uint32 Offset, uint8* Pixels) +static inline void WRITE_4PIXELSHI16(int32 Offset, uint8* Pixels) { uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -224,7 +247,7 @@ inline void WRITE_4PIXELSHI16(uint32 Offset, uint8* Pixels) #undef FN } -inline void WRITE_4PIXELSHI16_FLIPPED(uint32 Offset, uint8* Pixels) +static inline void WRITE_4PIXELSHI16_FLIPPED(int32 Offset, uint8* Pixels) { uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -244,7 +267,7 @@ inline void WRITE_4PIXELSHI16_FLIPPED(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELSx2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELSx2(int32 Offset, uint8* Pixels) { register uint8 Pixel; uint8* Screen = GFX.S + Offset; @@ -264,7 +287,7 @@ static INLINE void WRITE_4PIXELSx2(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS_FLIPPEDx2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS_FLIPPEDx2(int32 Offset, uint8* Pixels) { register uint8 Pixel; uint8* Screen = GFX.S + Offset; @@ -284,7 +307,7 @@ static INLINE void WRITE_4PIXELS_FLIPPEDx2(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELSx2x2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELSx2x2(int32 Offset, uint8* Pixels) { register uint8 Pixel; uint8* Screen = GFX.S + Offset; @@ -306,7 +329,7 @@ static INLINE void WRITE_4PIXELSx2x2(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS_FLIPPEDx2x2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS_FLIPPEDx2x2(int32 Offset, uint8* Pixels) { register uint8 Pixel; uint8* Screen = GFX.S + Offset; @@ -328,7 +351,7 @@ static INLINE void WRITE_4PIXELS_FLIPPEDx2x2(uint32 Offset, uint8* Pixels) #undef FN } -void DrawTile(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -338,7 +361,7 @@ void DrawTile(uint32 Tile, uint32 Offset, uint32 StartLine, RENDER_TILE(WRITE_4PIXELS, WRITE_4PIXELS_FLIPPED, 4) } -void DrawClippedTile(uint32 Tile, uint32 Offset, +void DrawClippedTile(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { @@ -349,7 +372,7 @@ void DrawClippedTile(uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS, WRITE_4PIXELS_FLIPPED, 4) } -void DrawTilex2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTilex2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -359,7 +382,7 @@ void DrawTilex2(uint32 Tile, uint32 Offset, uint32 StartLine, RENDER_TILE(WRITE_4PIXELSx2, WRITE_4PIXELS_FLIPPEDx2, 8) } -void DrawClippedTilex2(uint32 Tile, uint32 Offset, +void DrawClippedTilex2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { @@ -370,7 +393,7 @@ void DrawClippedTilex2(uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELSx2, WRITE_4PIXELS_FLIPPEDx2, 8) } -void DrawTilex2x2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTilex2x2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -380,7 +403,7 @@ void DrawTilex2x2(uint32 Tile, uint32 Offset, uint32 StartLine, RENDER_TILE(WRITE_4PIXELSx2x2, WRITE_4PIXELS_FLIPPEDx2x2, 8) } -void DrawClippedTilex2x2(uint32 Tile, uint32 Offset, +void DrawClippedTilex2x2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { @@ -391,7 +414,7 @@ void DrawClippedTilex2x2(uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELSx2x2, WRITE_4PIXELS_FLIPPEDx2x2, 8) } -void DrawLargePixel(uint32 Tile, uint32 Offset, +void DrawLargePixel(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) { @@ -405,7 +428,7 @@ void DrawLargePixel(uint32 Tile, uint32 Offset, RENDER_TILE_LARGE(((uint8) GFX.ScreenColors [pixel]), PLOT_PIXEL) } -static INLINE void WRITE_4PIXELS16(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -425,7 +448,7 @@ static INLINE void WRITE_4PIXELS16(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16_FLIPPED(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -445,7 +468,7 @@ static INLINE void WRITE_4PIXELS16_FLIPPED(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16x2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16x2(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -465,7 +488,7 @@ static INLINE void WRITE_4PIXELS16x2(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16_FLIPPEDx2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPEDx2(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -485,7 +508,7 @@ static INLINE void WRITE_4PIXELS16_FLIPPEDx2(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16x2x2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16x2x2(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -507,7 +530,7 @@ static INLINE void WRITE_4PIXELS16x2x2(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16_FLIPPEDx2x2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPEDx2x2(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -529,7 +552,7 @@ static INLINE void WRITE_4PIXELS16_FLIPPEDx2x2(uint32 Offset, uint8* Pixels) #undef FN } -void DrawTile16_OBJ(uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) +void DrawTile16_OBJ(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { // TILE_PREAMBLE @@ -636,7 +659,7 @@ void DrawTile16_OBJ(uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCou } } -void DrawTile16(uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) +void DrawTile16(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { // TILE_PREAMBLE @@ -748,7 +771,7 @@ void DrawTile16(uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) } } -void DrawClippedTile16(uint32 Tile, uint32 Offset, +void DrawClippedTile16(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { @@ -759,7 +782,7 @@ void DrawClippedTile16(uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4) } -void DrawTile16x2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16x2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -768,7 +791,7 @@ void DrawTile16x2(uint32 Tile, uint32 Offset, uint32 StartLine, RENDER_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8) } -void DrawClippedTile16x2(uint32 Tile, uint32 Offset, +void DrawClippedTile16x2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { @@ -779,7 +802,7 @@ void DrawClippedTile16x2(uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8) } -void DrawTile16x2x2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16x2x2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -788,7 +811,7 @@ void DrawTile16x2x2(uint32 Tile, uint32 Offset, uint32 StartLine, RENDER_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8) } -void DrawClippedTile16x2x2(uint32 Tile, uint32 Offset, +void DrawClippedTile16x2x2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { @@ -799,7 +822,7 @@ void DrawClippedTile16x2x2(uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8) } -void DrawLargePixel16(uint32 Tile, uint32 Offset, +void DrawLargePixel16(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) { @@ -812,7 +835,7 @@ void DrawLargePixel16(uint32 Tile, uint32 Offset, RENDER_TILE_LARGE(GFX.ScreenColors [pixel], PLOT_PIXEL) } -static INLINE void WRITE_4PIXELS16_ADD(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_ADD(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -844,7 +867,7 @@ static INLINE void WRITE_4PIXELS16_ADD(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16_FLIPPED_ADD(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED_ADD(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -876,7 +899,7 @@ static INLINE void WRITE_4PIXELS16_FLIPPED_ADD(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16_ADD1_2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_ADD1_2(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -908,7 +931,7 @@ static INLINE void WRITE_4PIXELS16_ADD1_2(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16_FLIPPED_ADD1_2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED_ADD1_2(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -940,7 +963,7 @@ static INLINE void WRITE_4PIXELS16_FLIPPED_ADD1_2(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16_SUB(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_SUB(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -972,7 +995,7 @@ static INLINE void WRITE_4PIXELS16_SUB(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16_FLIPPED_SUB(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED_SUB(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -1004,7 +1027,7 @@ static INLINE void WRITE_4PIXELS16_FLIPPED_SUB(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16_SUB1_2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_SUB1_2(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -1036,7 +1059,7 @@ static INLINE void WRITE_4PIXELS16_SUB1_2(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16_FLIPPED_SUB1_2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED_SUB1_2(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -1069,7 +1092,7 @@ static INLINE void WRITE_4PIXELS16_FLIPPED_SUB1_2(uint32 Offset, uint8* Pixels) } -void DrawTile16Add(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16Add(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -1078,7 +1101,7 @@ void DrawTile16Add(uint32 Tile, uint32 Offset, uint32 StartLine, RENDER_TILE(WRITE_4PIXELS16_ADD, WRITE_4PIXELS16_FLIPPED_ADD, 4) } -void DrawClippedTile16Add(uint32 Tile, uint32 Offset, +void DrawClippedTile16Add(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { @@ -1089,7 +1112,7 @@ void DrawClippedTile16Add(uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADD, WRITE_4PIXELS16_FLIPPED_ADD, 4) } -void DrawTile16Add1_2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16Add1_2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -1098,7 +1121,7 @@ void DrawTile16Add1_2(uint32 Tile, uint32 Offset, uint32 StartLine, RENDER_TILE(WRITE_4PIXELS16_ADD1_2, WRITE_4PIXELS16_FLIPPED_ADD1_2, 4) } -void DrawClippedTile16Add1_2(uint32 Tile, uint32 Offset, +void DrawClippedTile16Add1_2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { @@ -1109,7 +1132,7 @@ void DrawClippedTile16Add1_2(uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADD1_2, WRITE_4PIXELS16_FLIPPED_ADD1_2, 4) } -void DrawTile16Sub(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16Sub(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -1118,7 +1141,7 @@ void DrawTile16Sub(uint32 Tile, uint32 Offset, uint32 StartLine, RENDER_TILE(WRITE_4PIXELS16_SUB, WRITE_4PIXELS16_FLIPPED_SUB, 4) } -void DrawClippedTile16Sub(uint32 Tile, uint32 Offset, +void DrawClippedTile16Sub(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { @@ -1129,7 +1152,7 @@ void DrawClippedTile16Sub(uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUB, WRITE_4PIXELS16_FLIPPED_SUB, 4) } -void DrawTile16Sub1_2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16Sub1_2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -1138,7 +1161,7 @@ void DrawTile16Sub1_2(uint32 Tile, uint32 Offset, uint32 StartLine, RENDER_TILE(WRITE_4PIXELS16_SUB1_2, WRITE_4PIXELS16_FLIPPED_SUB1_2, 4) } -void DrawClippedTile16Sub1_2(uint32 Tile, uint32 Offset, +void DrawClippedTile16Sub1_2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { @@ -1149,7 +1172,7 @@ void DrawClippedTile16Sub1_2(uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUB1_2, WRITE_4PIXELS16_FLIPPED_SUB1_2, 4) } -static INLINE void WRITE_4PIXELS16_ADDF1_2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_ADDF1_2(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -1175,7 +1198,7 @@ static INLINE void WRITE_4PIXELS16_ADDF1_2(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16_FLIPPED_ADDF1_2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED_ADDF1_2(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -1201,7 +1224,7 @@ static INLINE void WRITE_4PIXELS16_FLIPPED_ADDF1_2(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16_SUBF1_2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_SUBF1_2(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -1227,7 +1250,7 @@ static INLINE void WRITE_4PIXELS16_SUBF1_2(uint32 Offset, uint8* Pixels) #undef FN } -static INLINE void WRITE_4PIXELS16_FLIPPED_SUBF1_2(uint32 Offset, uint8* Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED_SUBF1_2(int32 Offset, uint8* Pixels) { register uint32 Pixel; uint16* Screen = (uint16*) GFX.S + Offset; @@ -1253,7 +1276,7 @@ static INLINE void WRITE_4PIXELS16_FLIPPED_SUBF1_2(uint32 Offset, uint8* Pixels) #undef FN } -void DrawTile16FixedAdd1_2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16FixedAdd1_2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -1262,7 +1285,7 @@ void DrawTile16FixedAdd1_2(uint32 Tile, uint32 Offset, uint32 StartLine, RENDER_TILE(WRITE_4PIXELS16_ADDF1_2, WRITE_4PIXELS16_FLIPPED_ADDF1_2, 4) } -void DrawClippedTile16FixedAdd1_2(uint32 Tile, uint32 Offset, +void DrawClippedTile16FixedAdd1_2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { @@ -1274,7 +1297,7 @@ void DrawClippedTile16FixedAdd1_2(uint32 Tile, uint32 Offset, WRITE_4PIXELS16_FLIPPED_ADDF1_2, 4) } -void DrawTile16FixedSub1_2(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawTile16FixedSub1_2(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -1283,7 +1306,7 @@ void DrawTile16FixedSub1_2(uint32 Tile, uint32 Offset, uint32 StartLine, RENDER_TILE(WRITE_4PIXELS16_SUBF1_2, WRITE_4PIXELS16_FLIPPED_SUBF1_2, 4) } -void DrawClippedTile16FixedSub1_2(uint32 Tile, uint32 Offset, +void DrawClippedTile16FixedSub1_2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { @@ -1295,7 +1318,7 @@ void DrawClippedTile16FixedSub1_2(uint32 Tile, uint32 Offset, WRITE_4PIXELS16_FLIPPED_SUBF1_2, 4) } -void DrawLargePixel16Add(uint32 Tile, uint32 Offset, +void DrawLargePixel16Add(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) { @@ -1314,7 +1337,7 @@ void DrawLargePixel16Add(uint32 Tile, uint32 Offset, RENDER_TILE_LARGE(GFX.ScreenColors [pixel], LARGE_ADD_PIXEL) } -void DrawLargePixel16Add1_2(uint32 Tile, uint32 Offset, +void DrawLargePixel16Add1_2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) { @@ -1333,7 +1356,7 @@ void DrawLargePixel16Add1_2(uint32 Tile, uint32 Offset, RENDER_TILE_LARGE(GFX.ScreenColors [pixel], LARGE_ADD_PIXEL1_2) } -void DrawLargePixel16Sub(uint32 Tile, uint32 Offset, +void DrawLargePixel16Sub(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) { @@ -1352,7 +1375,7 @@ void DrawLargePixel16Sub(uint32 Tile, uint32 Offset, RENDER_TILE_LARGE(GFX.ScreenColors [pixel], LARGE_SUB_PIXEL) } -void DrawLargePixel16Sub1_2(uint32 Tile, uint32 Offset, +void DrawLargePixel16Sub1_2(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) { @@ -1371,7 +1394,7 @@ void DrawLargePixel16Sub1_2(uint32 Tile, uint32 Offset, RENDER_TILE_LARGE(GFX.ScreenColors [pixel], LARGE_SUB_PIXEL1_2) } -void DrawHiResTile16(uint32 Tile, uint32 Offset, uint32 StartLine, +void DrawHiResTile16(uint32 Tile, int32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -1380,7 +1403,7 @@ void DrawHiResTile16(uint32 Tile, uint32 Offset, uint32 StartLine, RENDER_TILEHI(WRITE_4PIXELSHI16, WRITE_4PIXELSHI16_FLIPPED, 4) } -void DrawHiResClippedTile16(uint32 Tile, uint32 Offset, +void DrawHiResClippedTile16(uint32 Tile, int32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount) { @@ -41,6 +41,8 @@ #ifndef _TILE_H_ #define _TILE_H_ +void SelectPalette(); + extern uint32 TileBlank; #define TILE_PREAMBLE \ |