Commit 3ee8270a authored by aliaspider's avatar aliaspider
Browse files

can be built and run for non arm platforms, gfx not working.

parent feb7ddab
......@@ -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);
......
This diff is collapsed.
......@@ -41,6 +41,8 @@
#ifndef _TILE_H_
#define _TILE_H_
void SelectPalette();
extern uint32 TileBlank;
#define TILE_PREAMBLE \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment