diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | Makefile.common | 98 | ||||
-rw-r--r-- | jni/Android.mk | 2 | ||||
-rw-r--r-- | libretro/libretro.c (renamed from libretro/libretro.cpp) | 17 | ||||
-rw-r--r-- | old/clip.cpp.new | 4 | ||||
-rw-r--r-- | old/gfx16.cpp.last | 44 | ||||
-rw-r--r-- | old/gfx16.cpp.old2 | 44 | ||||
-rw-r--r-- | old/spc700/debug/apumem.h | 8 | ||||
-rw-r--r-- | src/65c816.h | 5 | ||||
-rw-r--r-- | src/DSP1_gp32.c (renamed from src/DSP1_gp32.cpp) | 0 | ||||
-rw-r--r-- | src/apu.c (renamed from src/apu.cpp) | 57 | ||||
-rw-r--r-- | src/apu.h | 12 | ||||
-rw-r--r-- | src/apumem.h | 8 | ||||
-rw-r--r-- | src/asmmemfuncs.h | 4 | ||||
-rw-r--r-- | src/c4.c (renamed from src/c4.cpp) | 5 | ||||
-rw-r--r-- | src/c4.h | 4 | ||||
-rw-r--r-- | src/c4emu.c (renamed from src/c4emu.cpp) | 80 | ||||
-rw-r--r-- | src/cheats.c (renamed from src/cheats.cpp) | 44 | ||||
-rw-r--r-- | src/cheats.h | 12 | ||||
-rw-r--r-- | src/cheats2.c (renamed from src/cheats2.cpp) | 18 | ||||
-rw-r--r-- | src/clip.c (renamed from src/clip.cpp) | 20 | ||||
-rw-r--r-- | src/cpu.c (renamed from src/cpu.cpp) | 2 | ||||
-rw-r--r-- | src/cpuexec.c (renamed from src/cpuexec.cpp) | 0 | ||||
-rw-r--r-- | src/cpuexec.h | 25 | ||||
-rw-r--r-- | src/cpuops.c (renamed from src/cpuops.cpp) | 12 | ||||
-rw-r--r-- | src/data.c (renamed from src/data.cpp) | 0 | ||||
-rw-r--r-- | src/display.h | 7 | ||||
-rw-r--r-- | src/dma.c (renamed from src/dma.cpp) | 12 | ||||
-rw-r--r-- | src/dsp1.c (renamed from src/dsp1.cpp) | 0 | ||||
-rw-r--r-- | src/dsp1.h | 7 | ||||
-rw-r--r-- | src/fxemu.c (renamed from src/fxemu.cpp) | 6 | ||||
-rw-r--r-- | src/fxemu.h | 6 | ||||
-rw-r--r-- | src/fxinst.c (renamed from src/fxinst.cpp) | 2 | ||||
-rw-r--r-- | src/fxinst.h | 4 | ||||
-rw-r--r-- | src/getset.h | 168 | ||||
-rw-r--r-- | src/gfx.c (renamed from src/gfx.cpp) | 44 | ||||
-rw-r--r-- | src/gfx.h | 23 | ||||
-rw-r--r-- | src/gfx16.c (renamed from src/gfx16.cpp) | 38 | ||||
-rw-r--r-- | src/globals.c (renamed from src/globals.cpp) | 49 | ||||
-rw-r--r-- | src/memmap.c | 2759 | ||||
-rw-r--r-- | src/memmap.cpp | 2758 | ||||
-rw-r--r-- | src/memmap.h | 15 | ||||
-rw-r--r-- | src/missing.h | 12 | ||||
-rw-r--r-- | src/mode7.c (renamed from src/mode7.cpp) | 18 | ||||
-rw-r--r-- | src/mode7_t.h | 16 | ||||
-rw-r--r-- | src/mode7_t.h.new | 16 | ||||
-rw-r--r-- | src/mode7add.c (renamed from src/mode7add.cpp) | 0 | ||||
-rw-r--r-- | src/mode7add1_2.c (renamed from src/mode7add1_2.cpp) | 0 | ||||
-rw-r--r-- | src/mode7add1_2prio.c (renamed from src/mode7add1_2prio.cpp) | 0 | ||||
-rw-r--r-- | src/mode7addprio.c (renamed from src/mode7addprio.cpp) | 0 | ||||
-rw-r--r-- | src/mode7new.c (renamed from src/mode7new.cpp) | 18 | ||||
-rw-r--r-- | src/mode7prio.c (renamed from src/mode7prio.cpp) | 18 | ||||
-rw-r--r-- | src/mode7prio_t.h | 16 | ||||
-rw-r--r-- | src/mode7prio_t.h.last | 16 | ||||
-rw-r--r-- | src/mode7sub.c (renamed from src/mode7sub.cpp) | 0 | ||||
-rw-r--r-- | src/mode7sub1_2.c (renamed from src/mode7sub1_2.cpp) | 0 | ||||
-rw-r--r-- | src/mode7sub1_2prio.c (renamed from src/mode7sub1_2prio.cpp) | 0 | ||||
-rw-r--r-- | src/mode7subprio.c (renamed from src/mode7subprio.cpp) | 0 | ||||
-rw-r--r-- | src/os9x_asm_cpu.c (renamed from src/os9x_asm_cpu.cpp) | 0 | ||||
-rw-r--r-- | src/port.h | 1 | ||||
-rw-r--r-- | src/ppu.c (renamed from src/ppu.cpp) | 21 | ||||
-rw-r--r-- | src/ppu.h | 33 | ||||
-rw-r--r-- | src/ppu_.c (renamed from src/ppu_.cpp) | 10 | ||||
-rw-r--r-- | src/rops.c (renamed from src/rops.cpp) | 0 | ||||
-rw-r--r-- | src/rops.h | 2 | ||||
-rw-r--r-- | src/sa1.c (renamed from src/sa1.cpp) | 50 | ||||
-rw-r--r-- | src/sa1.h | 26 | ||||
-rw-r--r-- | src/sa1cpu.c (renamed from src/sa1cpu.cpp) | 2 | ||||
-rw-r--r-- | src/sar.h | 13 | ||||
-rw-r--r-- | src/sdd1.c (renamed from src/sdd1.cpp) | 0 | ||||
-rw-r--r-- | src/sdd1emu.c (renamed from src/sdd1emu.cpp) | 0 | ||||
-rw-r--r-- | src/sdd1emu.h | 4 | ||||
-rw-r--r-- | src/seta.c (renamed from src/seta.cpp) | 0 | ||||
-rw-r--r-- | src/seta010.c (renamed from src/seta010.cpp) | 0 | ||||
-rw-r--r-- | src/seta011.c (renamed from src/seta011.cpp) | 0 | ||||
-rw-r--r-- | src/seta018.c (renamed from src/seta018.cpp) | 0 | ||||
-rw-r--r-- | src/snaporig.c (renamed from src/snaporig.cpp) | 2 | ||||
-rw-r--r-- | src/snapshot.c (renamed from src/snapshot.cpp) | 52 | ||||
-rw-r--r-- | src/snes9x.cpp | 655 | ||||
-rw-r--r-- | src/snes9x.h | 22 | ||||
-rw-r--r-- | src/soundux.c (renamed from src/soundux.cpp) | 4 | ||||
-rw-r--r-- | src/soundux.h | 3 | ||||
-rw-r--r-- | src/spc700.c (renamed from src/spc700.cpp) | 2 | ||||
-rw-r--r-- | src/spc700.h | 5 | ||||
-rw-r--r-- | src/srtc.c (renamed from src/srtc.cpp) | 0 | ||||
-rw-r--r-- | src/tile.c (renamed from src/tile.cpp) | 48 | ||||
-rw-r--r-- | src/tile16.c (renamed from src/tile16.cpp) | 90 | ||||
-rw-r--r-- | src/tile16.cpp.bak | 24 | ||||
-rw-r--r-- | src/tile16_t.h | 24 | ||||
-rw-r--r-- | src/tile16add.c (renamed from src/tile16add.cpp) | 0 | ||||
-rw-r--r-- | src/tile16add1_2.c (renamed from src/tile16add1_2.cpp) | 0 | ||||
-rw-r--r-- | src/tile16f_t.h | 16 | ||||
-rw-r--r-- | src/tile16fadd1_2.c (renamed from src/tile16fadd1_2.cpp) | 0 | ||||
-rw-r--r-- | src/tile16fsub1_2.c (renamed from src/tile16fsub1_2.cpp) | 0 | ||||
-rw-r--r-- | src/tile16noprio.c (renamed from src/tile16noprio.cpp) | 16 | ||||
-rw-r--r-- | src/tile16sub.c (renamed from src/tile16sub.cpp) | 0 | ||||
-rw-r--r-- | src/tile16sub1_2.c (renamed from src/tile16sub1_2.cpp) | 0 |
97 files changed, 3538 insertions, 4142 deletions
@@ -79,7 +79,7 @@ OBJECTS := $(OBJECTS:.cpp=.o) OBJECTS := $(OBJECTS:.S=.o) OBJECTS := $(OBJECTS:.s=.o) -CFLAGS += $(DEFINES) $(COMMON_DEFINES) $(INCLUDES) +CFLAGS += $(DEFINES) $(COMMON_DEFINES) $(INCLUDES) --std=c99 all: $(TARGET) diff --git a/Makefile.common b/Makefile.common index 90dbff0..341f874 100644 --- a/Makefile.common +++ b/Makefile.common @@ -6,61 +6,61 @@ DEFINES += -O3 -DNDEBUG=1 endif SOURCES := -SOURCES += $(CORE_DIR)/apu.cpp +SOURCES += $(CORE_DIR)/apu.c SOURCES += $(CORE_DIR)/apuaux.c -SOURCES += $(CORE_DIR)/c4.cpp -SOURCES += $(CORE_DIR)/c4emu.cpp -SOURCES += $(CORE_DIR)/cheats.cpp -SOURCES += $(CORE_DIR)/cheats2.cpp -SOURCES += $(CORE_DIR)/clip.cpp -SOURCES += $(CORE_DIR)/data.cpp -SOURCES += $(CORE_DIR)/dsp1.cpp -SOURCES += $(CORE_DIR)/fxemu.cpp -SOURCES += $(CORE_DIR)/fxinst.cpp -SOURCES += $(CORE_DIR)/globals.cpp -SOURCES += $(CORE_DIR)/ppu.cpp -SOURCES += $(CORE_DIR)/dma.cpp -SOURCES += $(CORE_DIR)/memmap.cpp -SOURCES += $(CORE_DIR)/cpu.cpp -SOURCES += $(CORE_DIR)/cpuexec.cpp -SOURCES += $(CORE_DIR)/cpuops.cpp -SOURCES += $(CORE_DIR)/sa1.cpp -SOURCES += $(CORE_DIR)/sa1cpu.cpp -SOURCES += $(CORE_DIR)/sdd1.cpp -SOURCES += $(CORE_DIR)/sdd1emu.cpp -SOURCES += $(CORE_DIR)/snapshot.cpp -SOURCES += $(CORE_DIR)/soundux.cpp -SOURCES += $(CORE_DIR)/spc700.cpp -SOURCES += $(CORE_DIR)/srtc.cpp -SOURCES += $(CORE_DIR)/mode7new.cpp -SOURCES += $(CORE_DIR)/mode7.cpp -SOURCES += $(CORE_DIR)/mode7add.cpp -SOURCES += $(CORE_DIR)/mode7add1_2.cpp -SOURCES += $(CORE_DIR)/mode7sub.cpp -SOURCES += $(CORE_DIR)/mode7sub1_2.cpp -SOURCES += $(CORE_DIR)/mode7prio.cpp -SOURCES += $(CORE_DIR)/mode7addprio.cpp -SOURCES += $(CORE_DIR)/mode7add1_2prio.cpp -SOURCES += $(CORE_DIR)/mode7subprio.cpp -SOURCES += $(CORE_DIR)/mode7sub1_2prio.cpp -SOURCES += $(CORE_DIR)/gfx16.cpp -SOURCES += $(CORE_DIR)/rops.cpp -SOURCES += $(LIBRETRO_DIR)/libretro.cpp +SOURCES += $(CORE_DIR)/c4.c +SOURCES += $(CORE_DIR)/c4emu.c +SOURCES += $(CORE_DIR)/cheats.c +SOURCES += $(CORE_DIR)/cheats2.c +SOURCES += $(CORE_DIR)/clip.c +SOURCES += $(CORE_DIR)/data.c +SOURCES += $(CORE_DIR)/dsp1.c +SOURCES += $(CORE_DIR)/fxemu.c +SOURCES += $(CORE_DIR)/fxinst.c +SOURCES += $(CORE_DIR)/globals.c +SOURCES += $(CORE_DIR)/ppu.c +SOURCES += $(CORE_DIR)/dma.c +SOURCES += $(CORE_DIR)/memmap.c +SOURCES += $(CORE_DIR)/cpu.c +SOURCES += $(CORE_DIR)/cpuexec.c +SOURCES += $(CORE_DIR)/cpuops.c +SOURCES += $(CORE_DIR)/sa1.c +SOURCES += $(CORE_DIR)/sa1cpu.c +SOURCES += $(CORE_DIR)/sdd1.c +SOURCES += $(CORE_DIR)/sdd1emu.c +SOURCES += $(CORE_DIR)/snapshot.c +SOURCES += $(CORE_DIR)/soundux.c +SOURCES += $(CORE_DIR)/spc700.c +SOURCES += $(CORE_DIR)/srtc.c +SOURCES += $(CORE_DIR)/mode7new.c +SOURCES += $(CORE_DIR)/mode7.c +SOURCES += $(CORE_DIR)/mode7add.c +SOURCES += $(CORE_DIR)/mode7add1_2.c +SOURCES += $(CORE_DIR)/mode7sub.c +SOURCES += $(CORE_DIR)/mode7sub1_2.c +SOURCES += $(CORE_DIR)/mode7prio.c +SOURCES += $(CORE_DIR)/mode7addprio.c +SOURCES += $(CORE_DIR)/mode7add1_2prio.c +SOURCES += $(CORE_DIR)/mode7subprio.c +SOURCES += $(CORE_DIR)/mode7sub1_2prio.c +SOURCES += $(CORE_DIR)/gfx16.c +SOURCES += $(CORE_DIR)/rops.c +SOURCES += $(LIBRETRO_DIR)/libretro.c SOURCES += $(LIBRETRO_DIR)/memstream.c ifeq ($(ARM_ASM), 1) SOURCES += $(CORE_DIR)/spc700a.s \ $(CORE_DIR)/spc_decode.S -SOURCES += $(CORE_DIR)/tile16.cpp -SOURCES += $(CORE_DIR)/tile16add.cpp -SOURCES += $(CORE_DIR)/tile16add1_2.cpp -SOURCES += $(CORE_DIR)/tile16fadd1_2.cpp -SOURCES += $(CORE_DIR)/tile16sub.cpp -SOURCES += $(CORE_DIR)/tile16sub1_2.cpp -SOURCES += $(CORE_DIR)/tile16fsub1_2.cpp +SOURCES += $(CORE_DIR)/tile16.c +SOURCES += $(CORE_DIR)/tile16add.c +SOURCES += $(CORE_DIR)/tile16add1_2.c +SOURCES += $(CORE_DIR)/tile16fadd1_2.c +SOURCES += $(CORE_DIR)/tile16sub.c +SOURCES += $(CORE_DIR)/tile16sub1_2.c +SOURCES += $(CORE_DIR)/tile16fsub1_2.c else -SOURCES += $(CORE_DIR)/tile_c.cpp +SOURCES += $(CORE_DIR)/tile_c.c endif SOURCES += $(CORE_DIR)/os9x_65c816_global.s @@ -69,7 +69,7 @@ SOURCES += $(CORE_DIR)/os9x_65c816_spcc.s #SOURCES += $(CORE_DIR)/os9x_65c816.s -SOURCES += $(CORE_DIR)/os9x_asm_cpu.cpp +SOURCES += $(CORE_DIR)/os9x_asm_cpu.c #DEFINES += -D__GP2X__ #DEFINES += -DASMCPU @@ -88,11 +88,13 @@ DEFINES += -ffast-math -funroll-loops -fomit-frame-pointer INCLUDES = -I$(LIBRETRO_DIR) -I$(CORE_DIR) -I. DEFINES += -DHAVE_STRINGS_H -DHAVE_STDINT_H -DHAVE_INTTYPES_H -D__LIBRETRO__ -DINLINE=inline +#DEFINES += -DRIGHTSHIFT_IS_SAR DEFINES += -DUSE_SA1 ifeq ($(ARM_ASM), 1) DEFINES += -mstructure-size-boundary=32 DEFINES += -DARM_ASM +DEFINES += -DRIGHTSHIFT_IS_SAR endif ifeq ($(platform), sncps3) diff --git a/jni/Android.mk b/jni/Android.mk index 92c30db..c95e870 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -28,7 +28,7 @@ LIBRETRO_DIR := ../libretro include ../Makefile.common LOCAL_SRC_FILES := $(SOURCES) -LOCAL_CFLAGS += $(DEFINES) $(COMMON_DEFINES) $(INCLUDES) +LOCAL_CFLAGS += $(DEFINES) $(COMMON_DEFINES) $(INCLUDES) --std=c99 LOCAL_ASFLAGS += $(DEFINES) $(COMMON_DEFINES) $(INCLUDES) include $(BUILD_SHARED_LIBRARY) diff --git a/libretro/libretro.cpp b/libretro/libretro.c index 826e3ca..c1665b4 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.c @@ -291,9 +291,9 @@ static void snes_init (void) CPU.Flags = 0; - if (!Memory.Init() || !S9xInitAPU()) + if (!MemoryInit() || !S9xInitAPU()) { - Memory.Deinit(); + MemoryDeinit(); S9xDeinitAPU(); fprintf(stderr, "[libsnes]: Failed to init Memory or APU.\n"); exit(1); @@ -351,7 +351,7 @@ void retro_init (void) void retro_deinit(void) { S9xDeinitAPU(); - Memory.Deinit(); + MemoryDeinit(); S9xGraphicsDeinit(); //S9xUnmapAllControls(); if(GFX.Screen) @@ -466,9 +466,9 @@ void retro_cheat_set(unsigned index, bool enable, const char* in_code) uint32 address; uint8 byte; - if ( S9xProActionReplayToRaw(clean_code, address, byte) == NULL) + if ( S9xProActionReplayToRaw(clean_code, &address, &byte) == NULL) S9xAddCheat(true, true, address, byte); - else if ( S9xGameGenieToRaw(clean_code, address, byte) == NULL) + else if ( S9xGameGenieToRaw(clean_code, &address, &byte) == NULL) S9xAddCheat(true, true, address, byte); // else, silently ignore } @@ -487,7 +487,7 @@ bool retro_load_game(const struct retro_game_info *game) /* Hack. S9x cannot do stuff from RAM. <_< */ memstream_set_buffer((uint8_t*)game->data, game->size); - loaded = Memory.LoadROM(""); + loaded = LoadROM(""); if (!loaded) { fprintf(stderr, "[libretro]: Rom loading failed...\n"); @@ -576,9 +576,8 @@ bool8 S9xContinueUpdate(int width, int height) { return TRUE; } void S9xSetPalette() {} void S9xAutoSaveSRAM() {} void S9xLoadSDD1Data() {} -bool8 S9xReadMousePosition (int which1_0_to_1, int &x, int &y, uint32 &buttons) { return FALSE; } -bool8 S9xReadSuperScopePosition (int &x, int &y, uint32 &buttons) { return FALSE; } -void JustifierButtons(uint32& x) {} +bool8 S9xReadMousePosition (int which1_0_to_1, int* x, int* y, uint32* buttons) { return FALSE; } +bool8 S9xReadSuperScopePosition (int* x, int* y, uint32* buttons) { return FALSE; } bool JustifierOffscreen() { return false; } START_EXTERN_C diff --git a/old/clip.cpp.new b/old/clip.cpp.new index 8e6baa3..895ea48 100644 --- a/old/clip.cpp.new +++ b/old/clip.cpp.new @@ -188,7 +188,7 @@ static uint8 region_map[6][6] = }; static inline uint8 CalcWindowMask (int, uint8, uint8); -static inline void StoreWindowRegions (uint8, struct ClipData *, int, int16 *, uint8 *, bool8, bool8 s = FALSE); +static inline void StoreWindowRegions (uint8, ClipData *, int, int16 *, uint8 *, bool8, bool8 s = FALSE); static inline uint8 CalcWindowMask (int i, uint8 W1, uint8 W2) @@ -240,7 +240,7 @@ static inline uint8 CalcWindowMask (int i, uint8 W1, uint8 W2) return (0); } -static inline void StoreWindowRegions (uint8 Mask, struct ClipData *Clip, int n_regions, int16 *windows, uint8 *drawing_modes, bool8 sub, bool8 StoreMode0) +static inline void StoreWindowRegions (uint8 Mask, ClipData *Clip, int n_regions, int16 *windows, uint8 *drawing_modes, bool8 sub, bool8 StoreMode0) { int ct = 0; diff --git a/old/gfx16.cpp.last b/old/gfx16.cpp.last index 0ebb820..fb57f65 100644 --- a/old/gfx16.cpp.last +++ b/old/gfx16.cpp.last @@ -110,10 +110,10 @@ extern NormalTileRenderer DrawHiResTilePtr; extern ClippedTileRenderer DrawHiResClippedTilePtr; extern LargePixelRenderer DrawLargePixelPtr; -extern struct SBG BG; +extern SBG BG; -extern struct SLineData LineData[240]; -extern struct SLineMatrixData LineMatrixData [240]; +extern SLineData LineData[240]; +extern SLineMatrixData LineMatrixData [240]; extern uint8 Mode7Depths [2]; @@ -581,7 +581,7 @@ void RenderLine (uint8 C) if (PPU.BGMode == 7) { - struct SLineMatrixData *p = &LineMatrixData [C]; + SLineMatrixData *p = &LineMatrixData [C]; p->MatrixA = PPU.MatrixA; p->MatrixB = PPU.MatrixB; p->MatrixC = PPU.MatrixC; @@ -699,7 +699,7 @@ TileRendererSet TileRenderersNoZ[] = { {DrawNoZTile16Sub1_2, DrawClippedTile16Sub1_2, DrawLargePixel16Sub1_2}, // 7 -> GFX.r2131:7 = 1, GFX.r2131:6 = 1, GFX.r2130:1 = 1 {DrawNoZTile16, DrawClippedTile16, DrawLargePixel16} // 8 -> normal }; -INLINE void SelectTileRenderer (bool8_32 normal, bool NoZ = false) +static INLINE void SelectTileRenderer (bool8_32 normal, bool NoZ = false) { if (normal) { TileRenderer = 8; @@ -2226,23 +2226,23 @@ void RenderScreen (uint8 *Screen, bool8_32 sub, bool8_32 force_no_add, uint8 D) } if (BG0) { - SelectTileRenderer (sub || !SUB_OR_ADD(0)); + SelectTileRenderer (sub || !SUB_OR_ADD(0), false); DrawBackground (PPU.BGMode, 0, D + 10, D + 14); } if (BG1) { - SelectTileRenderer (sub || !SUB_OR_ADD(1)); + SelectTileRenderer (sub || !SUB_OR_ADD(1), false); DrawBackground (PPU.BGMode, 1, D + 9, D + 13); } if (BG2) { - SelectTileRenderer (sub || !SUB_OR_ADD(2)); + SelectTileRenderer (sub || !SUB_OR_ADD(2), false); DrawBackground (PPU.BGMode, 2, D + 3, PPU.BG3Priority ? D + 17 : D + 6); } if (BG3 && PPU.BGMode == 0) { - SelectTileRenderer (sub || !SUB_OR_ADD(3)); + SelectTileRenderer (sub || !SUB_OR_ADD(3), false); DrawBackground (PPU.BGMode, 3, D + 2, D + 5); } } @@ -2255,12 +2255,12 @@ void RenderScreen (uint8 *Screen, bool8_32 sub, bool8_32 force_no_add, uint8 D) } if (BG0) { - SelectTileRenderer (sub || !SUB_OR_ADD(0)); + SelectTileRenderer (sub || !SUB_OR_ADD(0), false); DrawBackground (PPU.BGMode, 0, D + 5, D + 13); } if (PPU.BGMode != 6 && BG1) { - SelectTileRenderer (sub || !SUB_OR_ADD(1)); + SelectTileRenderer (sub || !SUB_OR_ADD(1), false); DrawBackground (PPU.BGMode, 1, D + 2, D + 9); } } @@ -2472,7 +2472,7 @@ void S9xUpdateScreen () // ~30-50ms! (called from FLUSH_REDRAW()) !((GFX.r2130 & 0x30) == 0x10 && IPPU.Clip[1].Count[5] == 0)) { // transparency effects in use, so lets get busy! - struct ClipData *pClip; + ClipData *pClip; uint32 fixedColour; GFX.FixedColour = BUILD_PIXEL (IPPU.XB [PPU.FixedColourRed], IPPU.XB [PPU.FixedColourGreen], @@ -2517,7 +2517,7 @@ void S9xUpdateScreen () // ~30-50ms! (called from FLUSH_REDRAW()) register unsigned int width = pClip->Right [c][5] - pClip->Left [c][5]; if (width > 0) { - asm volatile ( + __asm__ volatile ( " mov r0, %[fixedcolour] \n" " subs %[width], %[width], #4 \n" " bmi 2f \n" @@ -2575,7 +2575,7 @@ void S9xUpdateScreen () // ~30-50ms! (called from FLUSH_REDRAW()) if (IPPU.Clip [0].Count [5]) { - asm volatile ( + __asm__ volatile ( "1: \n" " mov r1, #(256 >> 2) \n" @@ -2655,7 +2655,7 @@ void S9xUpdateScreen () // ~30-50ms! (called from FLUSH_REDRAW()) } #define SUBSCREEN_BG(rop, half) \ \ -asm volatile (\ +__asm__ volatile (\ " ldrb r0, [%[d]], #1 \n"\ "71: \n"\ \ @@ -2722,7 +2722,7 @@ ROP_##rop##half (r0, r1)\ // copy the sub-screen to the main screen // or fill it with the back-drop colour if the // sub-screen is clear. - asm volatile ( + __asm__ volatile ( " ldrb r0, [%[d]], #1 \n" "31: \n" @@ -2775,7 +2775,7 @@ ROP_##rop##half (r0, r1)\ uint32 Left = pClip->Left [b][5]; uint32 Right = pClip->Right [b][5]; if (Left >= Right) continue; - asm volatile ( + __asm__ volatile ( " tst %[c], #1 \n" " bne 21f \n" @@ -2815,7 +2815,7 @@ ROP_##rop##half (r0, r1)\ } else { - asm volatile ( + __asm__ volatile ( "@ -- SubScreen clear \n" "1113: \n" " mov r1, #(256/8) \n" @@ -2902,7 +2902,7 @@ ROP_##rop##half (r0, r1)\ { register unsigned int width = IPPU.Clip [0].Right [c][5] - IPPU.Clip [0].Left [c][5]; if (width > 0) { - asm volatile ( + __asm__ volatile ( " mov r0, %[back] \n" " subs %[width], %[width], #4 \n" " bmi 2f \n" @@ -3063,7 +3063,7 @@ else \ if (OB) { FIXCLIP(4); - DrawOBJS (); + DrawOBJS (FALSE, 0); } if (BG0) { @@ -3093,7 +3093,7 @@ else \ if (OB) { FIXCLIP(4); - DrawOBJS (); + DrawOBJS (FALSE, 0); } if (BG0) { @@ -3113,7 +3113,7 @@ else \ if (OB) { FIXCLIP(4); - DrawOBJS (); + DrawOBJS (FALSE, 0); } } } diff --git a/old/gfx16.cpp.old2 b/old/gfx16.cpp.old2 index 36358a5..80133c3 100644 --- a/old/gfx16.cpp.old2 +++ b/old/gfx16.cpp.old2 @@ -115,10 +115,10 @@ extern NormalTileRenderer DrawHiResTilePtr; extern ClippedTileRenderer DrawHiResClippedTilePtr; extern LargePixelRenderer DrawLargePixelPtr; -extern struct SBG BG; +extern SBG BG; -extern struct SLineData LineData[240]; -extern struct SLineMatrixData LineMatrixData [240]; +extern SLineData LineData[240]; +extern SLineMatrixData LineMatrixData [240]; extern uint8 Mode7Depths [2]; @@ -586,7 +586,7 @@ void RenderLine (uint8 C) if (PPU.BGMode == 7) { - struct SLineMatrixData *p = &LineMatrixData [C]; + SLineMatrixData *p = &LineMatrixData [C]; p->MatrixA = PPU.MatrixA; p->MatrixB = PPU.MatrixB; p->MatrixC = PPU.MatrixC; @@ -704,7 +704,7 @@ TileRendererSet TileRenderersNoZ[] = { {DrawNoZTile16Sub1_2, DrawClippedTile16Sub1_2, DrawLargePixel16Sub1_2}, // 7 -> GFX.r2131:7 = 1, GFX.r2131:6 = 1, GFX.r2130:1 = 1 {DrawNoZTile16, DrawClippedTile16, DrawLargePixel16} // 8 -> normal }; -INLINE void SelectTileRenderer (bool8_32 normal, bool NoZ = false) +static INLINE void SelectTileRenderer (bool8_32 normal, bool NoZ = false) { if (normal) { TileRenderer = 8; @@ -2242,23 +2242,23 @@ void RenderScreen (uint8 *Screen, bool8_32 sub, bool8_32 force_no_add, uint8 D) } if (BG0) { - SelectTileRenderer (sub || !SUB_OR_ADD(0)); + SelectTileRenderer (sub || !SUB_OR_ADD(0), false); DrawBackground (PPU.BGMode, 0, D + 10, D + 14); } if (BG1) { - SelectTileRenderer (sub || !SUB_OR_ADD(1)); + SelectTileRenderer (sub || !SUB_OR_ADD(1), false); DrawBackground (PPU.BGMode, 1, D + 9, D + 13); } if (BG2) { - SelectTileRenderer (sub || !SUB_OR_ADD(2)); + SelectTileRenderer (sub || !SUB_OR_ADD(2), false); DrawBackground (PPU.BGMode, 2, D + 3, PPU.BG3Priority ? D + 17 : D + 6); } if (BG3 && PPU.BGMode == 0) { - SelectTileRenderer (sub || !SUB_OR_ADD(3)); + SelectTileRenderer (sub || !SUB_OR_ADD(3), false); DrawBackground (PPU.BGMode, 3, D + 2, D + 5); } } @@ -2271,12 +2271,12 @@ void RenderScreen (uint8 *Screen, bool8_32 sub, bool8_32 force_no_add, uint8 D) } if (BG0) { - SelectTileRenderer (sub || !SUB_OR_ADD(0)); + SelectTileRenderer (sub || !SUB_OR_ADD(0), false); DrawBackground (PPU.BGMode, 0, D + 5, D + 13); } if (PPU.BGMode != 6 && BG1) { - SelectTileRenderer (sub || !SUB_OR_ADD(1)); + SelectTileRenderer (sub || !SUB_OR_ADD(1), false); DrawBackground (PPU.BGMode, 1, D + 2, D + 9); } } @@ -2488,7 +2488,7 @@ void S9xUpdateScreen () // ~30-50ms! (called from FLUSH_REDRAW()) !((GFX.r2130 & 0x30) == 0x10 && IPPU.Clip[1].Count[5] == 0)) { // transparency effects in use, so lets get busy! - struct ClipData *pClip; + ClipData *pClip; uint32 fixedColour; GFX.FixedColour = BUILD_PIXEL (IPPU.XB [PPU.FixedColourRed], IPPU.XB [PPU.FixedColourGreen], @@ -2533,7 +2533,7 @@ void S9xUpdateScreen () // ~30-50ms! (called from FLUSH_REDRAW()) register unsigned int width = pClip->Right [c][5] - pClip->Left [c][5]; if (width > 0) { - asm volatile ( + __asm__ volatile ( " mov r0, %[fixedcolour] \n" " subs %[width], %[width], #4 \n" " bmi 2f \n" @@ -2591,7 +2591,7 @@ void S9xUpdateScreen () // ~30-50ms! (called from FLUSH_REDRAW()) if (IPPU.Clip [0].Count [5]) { - asm volatile ( + __asm__ volatile ( "1: \n" " mov r1, #(256 >> 2) \n" @@ -2671,7 +2671,7 @@ void S9xUpdateScreen () // ~30-50ms! (called from FLUSH_REDRAW()) } #define SUBSCREEN_BG(rop, half) \ \ -asm volatile (\ +__asm__ volatile (\ " ldrb r0, [%[d]], #1 \n"\ "71: \n"\ \ @@ -2738,7 +2738,7 @@ ROP_##rop##half (r0, r1)\ // copy the sub-screen to the main screen // or fill it with the back-drop colour if the // sub-screen is clear. - asm volatile ( + __asm__ volatile ( " ldrb r0, [%[d]], #1 \n" "31: \n" @@ -2791,7 +2791,7 @@ ROP_##rop##half (r0, r1)\ uint32 Left = pClip->Left [b][5]; uint32 Right = pClip->Right [b][5]; if (Left >= Right) continue; - asm volatile ( + __asm__ volatile ( " tst %[c], #1 \n" " bne 21f \n" @@ -2831,7 +2831,7 @@ ROP_##rop##half (r0, r1)\ } else { - asm volatile ( + __asm__ volatile ( "@ -- SubScreen clear \n" "1113: \n" " mov r1, #(256/8) \n" @@ -2918,7 +2918,7 @@ ROP_##rop##half (r0, r1)\ { register unsigned int width = IPPU.Clip [0].Right [c][5] - IPPU.Clip [0].Left [c][5]; if (width > 0) { - asm volatile ( + __asm__ volatile ( " mov r0, %[back] \n" " subs %[width], %[width], #4 \n" " bmi 2f \n" @@ -3079,7 +3079,7 @@ else \ if (OB) { FIXCLIP(4); - DrawOBJS (); + DrawOBJS (FALSE, 0); } if (BG0) { @@ -3109,7 +3109,7 @@ else \ if (OB) { FIXCLIP(4); - DrawOBJS (); + DrawOBJS (FALSE, 0); } if (BG0) { @@ -3129,7 +3129,7 @@ else \ if (OB) { FIXCLIP(4); - DrawOBJS (); + DrawOBJS (FALSE, 0); } } } diff --git a/old/spc700/debug/apumem.h b/old/spc700/debug/apumem.h index b1b5f65..499bd3f 100644 --- a/old/spc700/debug/apumem.h +++ b/old/spc700/debug/apumem.h @@ -48,7 +48,7 @@ END_EXTERN_C // TODO: restore nondebug version
-INLINE uint8 S9xAPUGetByteZ (uint8 Address)
+static INLINE uint8 S9xAPUGetByteZ (uint8 Address)
{
uint8 res = 0;
pIAPU->memread_addr = Address;
@@ -86,7 +86,7 @@ INLINE uint8 S9xAPUGetByteZ (uint8 Address) return res;
}
-INLINE void S9xAPUSetByteZ (uint8 val, uint8 Address)
+static INLINE void S9xAPUSetByteZ (uint8 val, uint8 Address)
{
pIAPU->memwrite_addr = Address;
pIAPU->memwrite_data = val;
@@ -120,7 +120,7 @@ INLINE void S9xAPUSetByteZ (uint8 val, uint8 Address) pIAPU->DirectPage [Address] = val;
}
-INLINE uint8 S9xAPUGetByte (uint32 Address)
+static INLINE uint8 S9xAPUGetByte (uint32 Address)
{
Address &= 0xffff;
uint8 res = 0;
@@ -159,7 +159,7 @@ INLINE uint8 S9xAPUGetByte (uint32 Address) return res;
}
-INLINE void S9xAPUSetByte (uint8 val, uint32 Address)
+static INLINE void S9xAPUSetByte (uint8 val, uint32 Address)
{
Address &= 0xffff;
pIAPU->memwrite_addr = Address;
diff --git a/src/65c816.h b/src/65c816.h index aa251dc..1ab8e54 100644 --- a/src/65c816.h +++ b/src/65c816.h @@ -105,7 +105,8 @@ typedef union uint16 W;
} ALIGN_BY_ONE pair;
-struct SRegisters{
+typedef struct
+{
uint8 PB;
uint8 DB;
pair P;
@@ -115,7 +116,7 @@ struct SRegisters{ pair S;
pair Y;
uint16 PC;
-} PACKING;
+}PACKING SRegisters;
#define Registers CPU.Regs
//EXTERN_C struct SRegisters Registers;
diff --git a/src/DSP1_gp32.cpp b/src/DSP1_gp32.c index 7c89cbf..7c89cbf 100644 --- a/src/DSP1_gp32.cpp +++ b/src/DSP1_gp32.c @@ -4,7 +4,7 @@ * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
* Jerremy Koot (jkoot@snes9x.com)
*
- * Super FX C emulator code
+ * Super FX C emulator code
* (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
* Gary Henderson.
* Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
@@ -70,7 +70,7 @@ unsigned long SustainRate [32] = { 1200, 880, 740, 590, 440, 370, 290, 220,
180, 150, 110, 92, 74, 55, 37, 18
};
-
+
unsigned long IncreaseRate [32] = {
/*~0*/0xFFFFFFFF, 4100, 3100, 2600, 2000, 1500, 1300, 1000,
770, 640, 510, 380, 320, 260, 190, 160,
@@ -83,7 +83,7 @@ unsigned long DecreaseRateExp [32] = { 7100, 5900, 4700, 3500, 2900, 2400, 1800, 1500,
1200, 880, 740, 590, 440, 370, 290, 220,
180, 150, 110, 92, 74, 55, 37, 18
-};
+};
// precalculated env rates for S9xSetEnvRate
unsigned long AttackERate [16][10];
@@ -105,8 +105,8 @@ static inline void S9xSetSoundADSR (int channel, int attack_ind, int decay_ind, int attack_rate = AttackRate [attack_ind];
int decay_rate = DecayRate [decay_ind];
int sustain_rate = SustainRate [sustain_ind];
-
- // Hack for ROMs that use a very short attack rate, key on a
+
+ // Hack for ROMs that use a very short attack rate, key on a
// channel, then switch to decay mode. e.g. Final Fantasy II.
if (attack_rate == 1)
attack_rate = 0;
@@ -233,7 +233,7 @@ static inline bool8 S9xSetSoundMode (int channel, int mode) return (TRUE);
}
break;
-
+
case MODE_DECREASE_LINEAR:
case MODE_DECREASE_EXPONENTIAL:
case MODE_GAIN:
@@ -276,7 +276,7 @@ static inline bool8 S9xSetSoundMode (int channel, int mode) static inline void S9xPlaySample (int channel)
{
Channel *ch = &SoundData.channels[channel];
-
+
ch->state = SOUND_SILENT;
ch->mode = MODE_NONE;
ch->envx = 0;
@@ -286,7 +286,7 @@ static inline void S9xPlaySample (int channel) ch->gaussian[0]=ch->gaussian[1]=ch->gaussian[2]=ch->gaussian[3]=0;
S9xFixEnvelope (channel,
- APU.DSP [APU_GAIN + (channel << 4)],
+ APU.DSP [APU_GAIN + (channel << 4)],
APU.DSP [APU_ADSR1 + (channel << 4)],
APU.DSP [APU_ADSR2 + (channel << 4)]);
@@ -322,7 +322,7 @@ static inline void S9xPlaySample (int channel) {
ch->state = SOUND_DECAY;
ch->envx = MAX_ENVELOPE_HEIGHT;
- S9xSetEnvRate (ch, ch->decay_rate, -1,
+ S9xSetEnvRate (ch, ch->decay_rate, -1,
(MAX_ENVELOPE_HEIGHT * ch->sustain_level) >> 3, 1<<28);
}
ch-> left_vol_level = (ch->envx * ch->volume_left) / 128;
@@ -364,12 +364,12 @@ static inline void S9xPlaySample (int channel) }
S9xFixEnvelope (channel,
- APU.DSP [APU_GAIN + (channel << 4)],
+ APU.DSP [APU_GAIN + (channel << 4)],
APU.DSP [APU_ADSR1 + (channel << 4)],
APU.DSP [APU_ADSR2 + (channel << 4)]);
}
-extern "C" uint32 Spc700JumpTab_15;
+uint32 Spc700JumpTab_15;
bool8 S9xInitAPU ()
{
@@ -414,6 +414,7 @@ EXTERN_C uint8 APUROM [64]; void S9xResetAPU ()
{
+ int i, j;
// Settings.APUEnabled = Settings.NextAPUEnabled;
ZeroMemory(IAPU.RAM, 0x100);
@@ -422,7 +423,8 @@ void S9xResetAPU () memset(IAPU.RAM+0xA0, 0xFF, 0x20);
memset(IAPU.RAM+0xE0, 0xFF, 0x20);
- for(int i=1;i<256;i++)
+
+ for(i=1;i<256;i++)
{
memcpy(IAPU.RAM+(i<<8), IAPU.RAM, 0x100);
}
@@ -447,8 +449,6 @@ void S9xResetAPU () APU.ShowROM = TRUE;
IAPU.RAM [0xf1] = 0x80;
- int i;
-
for (i = 0; i < 3; i++)
{
APU.TimerEnabled [i] = FALSE;
@@ -456,7 +456,7 @@ void S9xResetAPU () APU.TimerTarget [i] = 0;
APU.Timer [i] = 0;
}
- for (int j = 0; j < 0x80; j++)
+ for (j = 0; j < 0x80; j++)
APU.DSP [j] = 0;
IAPU.TwoCycles = IAPU.OneCycle * 2;
@@ -481,7 +481,7 @@ void S9xSetAPUDSP (uint8 byte) static uint8 KeyOn;
static uint8 KeyOnPrev;
int i;
-
+
/* char str[64];
if (byte!=0)
{
@@ -528,8 +528,9 @@ void S9xSetAPUDSP (uint8 byte) case APU_NON:
if (byte != APU.DSP [APU_NON])
{
+ int c;
uint8 mask = 1;
- for (int c = 0; c < 8; c++, mask <<= 1)
+ for (c = 0; c < 8; c++, mask <<= 1)
{
int type;
if (byte & mask)
@@ -579,8 +580,9 @@ void S9xSetAPUDSP (uint8 byte) case APU_KOFF:
// if (byte)
{
+ int c;
uint8 mask = 1;
- for (int c = 0; c < 8; c++, mask <<= 1)
+ for (c = 0; c < 8; c++, mask <<= 1)
{
if ((byte & mask) != 0)
{
@@ -613,8 +615,9 @@ void S9xSetAPUDSP (uint8 byte) if (byte)
{
+ int c;
uint8 mask = 1;
- for (int c = 0; c < 8; c++, mask <<= 1)
+ for (c = 0; c < 8; c++, mask <<= 1)
{
if ((byte & mask) != 0)
{
@@ -635,7 +638,7 @@ void S9xSetAPUDSP (uint8 byte) }
//spc_is_dumping_temp = byte;
return;
-
+
case APU_VOL_LEFT + 0x00:
case APU_VOL_LEFT + 0x10:
case APU_VOL_LEFT + 0x20:
@@ -686,7 +689,7 @@ void S9xSetAPUDSP (uint8 byte) case APU_P_HIGH + 0x50:
case APU_P_HIGH + 0x60:
case APU_P_HIGH + 0x70:
- S9xSetSoundHertz (reg >> 4,
+ S9xSetSoundHertz (reg >> 4,
(((byte << 8) + APU.DSP [reg - 1]) & FREQUENCY_MASK) * 8);
break;
@@ -703,7 +706,7 @@ void S9xSetAPUDSP (uint8 byte) //S9xSetSoundSample (reg >> 4, byte); // notaz: seems to be unused?
}
break;
-
+
case APU_ADSR1 + 0x00:
case APU_ADSR1 + 0x10:
case APU_ADSR1 + 0x20:
@@ -715,7 +718,7 @@ void S9xSetAPUDSP (uint8 byte) if (byte != APU.DSP [reg])
{
{
- S9xFixEnvelope (reg >> 4, APU.DSP [reg + 2], byte,
+ S9xFixEnvelope (reg >> 4, APU.DSP [reg + 2], byte,
APU.DSP [reg + 1]);
}
}
@@ -774,7 +777,7 @@ void S9xSetAPUDSP (uint8 byte) case APU_OUTX + 0x60:
case APU_OUTX + 0x70:
break;
-
+
case APU_DIR:
break;
@@ -821,7 +824,7 @@ void S9xSetAPUDSP (uint8 byte) KeyOnPrev|=KeyOn;
KeyOn=0;
-
+
if (reg < 0x80)
APU.DSP [reg] = byte;
}
@@ -831,7 +834,7 @@ void S9xFixEnvelope (int channel, uint8 gain, uint8 adsr1, uint8 adsr2) if (adsr1 & 0x80)
{
// ADSR mode
-
+
// XXX: can DSP be switched to ADSR mode directly from GAIN/INCREASE/
// DECREASE mode? And if so, what stage of the sequence does it start
// at?
@@ -853,7 +856,7 @@ void S9xFixEnvelope (int channel, uint8 gain, uint8 adsr1, uint8 adsr2) }
else
{
-
+
if (gain & 0x40)
{
// Increase mode
@@ -51,7 +51,7 @@ typedef union } YAndA;
*/
-struct SAPU
+typedef struct
{
int32 Cycles; // 0x00
bool8 ShowROM; // 0x04
@@ -64,9 +64,9 @@ struct SAPU uint16 TimerTarget [3];
bool8 TimerEnabled [3];
bool8 TimerValueWritten [3];
-};
+}SAPU;
-struct SIAPU
+typedef struct
{
uint8 *DirectPage; // 0x00
uint32 Address; // 0x04 c core only
@@ -97,11 +97,11 @@ struct SIAPU uint8 *RAM; // 0x44
uint8 *ExtraRAM; // 0x48 shortcut to APU.ExtraRAM
-};
+}SIAPU;
-EXTERN_C struct SAPU APU;
-EXTERN_C struct SIAPU IAPU;
+EXTERN_C SAPU APU;
+EXTERN_C SIAPU IAPU;
STATIC inline void S9xAPUUnpackStatus()
{
diff --git a/src/apumem.h b/src/apumem.h index 2abe3d9..27390be 100644 --- a/src/apumem.h +++ b/src/apumem.h @@ -47,7 +47,7 @@ extern uint8 W4; extern uint8 APUROM[64]; END_EXTERN_C -INLINE uint8 S9xAPUGetByteZ (uint8 Address) +static INLINE uint8 S9xAPUGetByteZ (uint8 Address) { if (Address >= 0xf0 && IAPU.DirectPage == IAPU.RAM) { @@ -65,7 +65,7 @@ INLINE uint8 S9xAPUGetByteZ (uint8 Address) return (IAPU.DirectPage [Address]); } -INLINE void S9xAPUSetByteZ (uint8 val, uint8 Address) +static INLINE void S9xAPUSetByteZ (uint8 val, uint8 Address) { if (Address >= 0xf0 && IAPU.DirectPage == IAPU.RAM) { @@ -94,7 +94,7 @@ INLINE void S9xAPUSetByteZ (uint8 val, uint8 Address) IAPU.DirectPage [Address] = val; } -INLINE uint8 S9xAPUGetByte (uint32 Address) +static INLINE uint8 S9xAPUGetByte (uint32 Address) { Address &= 0xffff; @@ -113,7 +113,7 @@ INLINE uint8 S9xAPUGetByte (uint32 Address) return (IAPU.RAM [Address]); } -INLINE void S9xAPUSetByte (uint8 val, uint32 Address) +static INLINE void S9xAPUSetByte (uint8 val, uint32 Address) { Address &= 0xffff; diff --git a/src/asmmemfuncs.h b/src/asmmemfuncs.h index 0f4e514..aee7a27 100644 --- a/src/asmmemfuncs.h +++ b/src/asmmemfuncs.h @@ -3,7 +3,7 @@ #ifdef ARM_ASM
#define memset32(_dst, _c, _count) \
-({ uint32_t *dst = (_dst); register uint32_t c asm ("r7") = (_c); int count = (_count); register uint32_t dummy0 asm ("r4"), dummy1 asm ("r5"), dummy2 asm ("r6"); \
+({ uint32_t *dst = (_dst); register uint32_t c __asm__ ("r7") = (_c); int count = (_count); register uint32_t dummy0 __asm__ ("r4"), dummy1 __asm__ ("r5"), dummy2 __asm__ ("r6"); \
__asm__ __volatile__ ( \
" cmp %[count], #4\n" \
" blt 2f\n" \
@@ -36,7 +36,7 @@ })
#define memset16(_dst, _c, _count) \
-({ uint16_t *dst = (_dst); register uint16_t c asm ("r7") = (_c); int count = (_count); register uint32_t dummy0 asm ("r4"), dummy1 asm ("r5"), dummy2 asm ("r6"); \
+({ uint16_t *dst = (_dst); register uint16_t c __asm__ ("r7") = (_c); int count = (_count); register uint32_t dummy0 __asm__ ("r4"), dummy1 __asm__ ("r5"), dummy2 __asm__ ("r6"); \
__asm__ __volatile__ ( \
" cmp %[count], #2\n" \
" blt 3f\n" \
@@ -81,7 +81,7 @@ #include "c4.h"
//#include "memmap.h"
-extern "C" {
+START_EXTERN_C
short C4WFXVal;
short C4WFYVal;
@@ -427,5 +427,6 @@ void C4LoaDMem(char *C4RAM) READ_WORD(C4RAM+0x1f43));
}
#endif
-}//end extern C
+
+END_EXTERN_C
@@ -78,7 +78,7 @@ #include "port.h" #include "memmap.h" -extern "C" { +START_EXTERN_C extern int16 C4WFXVal; extern int16 C4WFYVal; @@ -105,7 +105,7 @@ void C4Op0D(); extern int16 C4CosTable[]; extern int16 C4SinTable[]; -} +END_EXTERN_C static inline uint8 *C4GetMemPointer(uint32 Address){ return (Memory.ROM + ((Address&0xff0000)>>1) + (Address&0x7fff)); diff --git a/src/c4emu.cpp b/src/c4emu.c index efe8cb8..d7a47a4 100644 --- a/src/c4emu.cpp +++ b/src/c4emu.c @@ -118,10 +118,11 @@ static uint8 C4TestPattern [12 * 4] = static void C4ConvOAM(void){ + uint8 *ptr; uint8 *OAMptr=Memory.C4RAM+(Memory.C4RAM[0x626]<<2); - for(uint8 *i=Memory.C4RAM+0x1fd; i>OAMptr; i-=4){ + for(ptr=Memory.C4RAM+0x1fd; ptr>OAMptr; ptr-=4){ // Clear OAM-to-be - *i=0xe0; + *ptr=0xe0; } uint16 globalX, globalY; @@ -135,10 +136,11 @@ static void C4ConvOAM(void){ OAMptr2=Memory.C4RAM+0x200+(Memory.C4RAM[0x626]>>2); if(Memory.C4RAM[0x0620]!=0){ + int i; SprCount=128-Memory.C4RAM[0x626]; uint8 offset=(Memory.C4RAM[0x626]&3)*2; uint8 *srcptr=Memory.C4RAM+0x220; - for(int i=Memory.C4RAM[0x0620]; i>0 && SprCount>0; i--, srcptr+=16){ + for(i=Memory.C4RAM[0x0620]; i>0 && SprCount>0; i--, srcptr+=16){ SprX=READ_WORD(srcptr)-globalX; SprY=READ_WORD(srcptr+2)-globalY; SprName=srcptr[5]; @@ -147,7 +149,8 @@ static void C4ConvOAM(void){ uint8 *sprptr=C4GetMemPointer(READ_3WORD(srcptr+7)); if(*sprptr!=0){ int16 X, Y; - for(int SprCnt=*sprptr++; SprCnt>0 && SprCount>0; SprCnt--, sprptr+=4){ + int SprCnt; + for(SprCnt=*sprptr++; SprCnt>0 && SprCount>0; SprCnt--, sprptr+=4){ X=(int8)sprptr[1]; if(SprAttr&0x40){ // flip X X=-X-((sprptr[0]&0x20)?16:8); @@ -229,10 +232,10 @@ static void C4DoScaleRotate(int row_padding){ C=(int16)(-XScale); D=0; } else { - A=(int16)SAR(C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*XScale, 15); - B=(int16)(-SAR(C4SinTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*YScale, 15)); - C=(int16)SAR(C4SinTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*XScale, 15); - D=(int16)SAR(C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*YScale, 15); + A=(int16)SAR16(C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*XScale, 15); + B=(int16)(-SAR16(C4SinTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*YScale, 15)); + C=(int16)SAR16(C4SinTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*XScale, 15); + D=(int16)SAR16(C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*YScale, 15); } // Calculate Pixel Resolution @@ -261,10 +264,12 @@ static void C4DoScaleRotate(int row_padding){ uint8 byte; int outidx=0; uint8 bit=0x80; - for(int y=0; y<h; y++){ + int y; + for(y=0; y<h; y++){ X=LineX; Y=LineY; - for(int x=0; x<w; x++){ + int x; + for(x=0; x<w; x++){ if((X>>12)>=w || (Y>>12)>=h){ byte=0; } else { @@ -330,7 +335,8 @@ static void C4DrawLine(int32 X1, int32 Y1, int16 Z1, Y2=(int16)C4WFYVal; // render line - for(int i=C4WFDist?C4WFDist:1; i>0; i--) + int i; + for(i=C4WFDist?C4WFDist:1; i>0; i--) { //.loop if(X1>0xff && Y1>0xff && X1<0x6000 && Y1<0x6000) { @@ -355,7 +361,8 @@ static void C4DrawWireFrame(void) int16 X2, Y2, Z2; uint8 Color; - for(int i=Memory.C4RAM[0x0295]; i>0; i--, line+=5){ + int i; + for(i=Memory.C4RAM[0x0295]; i>0; i--, line+=5){ if(line[0]==0xff && line[1]==0xff){ uint8 *tmp=line-5; while(tmp[2]==0xff && tmp[3]==0xff) tmp-=5; @@ -385,7 +392,8 @@ static void C4TransformLines(void){ // transform vertices uint8 *ptr=Memory.C4RAM; { - for(int i=READ_WORD(Memory.C4RAM+0x1f80); i>0; i--, ptr+=0x10) + int i; + for(i=READ_WORD(Memory.C4RAM+0x1f80); i>0; i--, ptr+=0x10) { C4WFXVal=READ_WORD(ptr+1); C4WFYVal=READ_WORD(ptr+5); @@ -407,7 +415,8 @@ static void C4TransformLines(void){ ptr=Memory.C4RAM+0xb02; uint8 *ptr2=Memory.C4RAM; { - for(int i=READ_WORD(Memory.C4RAM+0xb00); i>0; i--, ptr+=2, ptr2+=8) + int i; + for(i=READ_WORD(Memory.C4RAM+0xb00); i>0; i--, ptr+=2, ptr2+=8) { C4WFXVal=READ_WORD(Memory.C4RAM+(ptr[0]<<4)+1); C4WFYVal=READ_WORD(Memory.C4RAM+(ptr[0]<<4)+5); @@ -434,10 +443,12 @@ static void C4BitPlaneWave(){ uint16 mask1=0xc0c0; uint16 mask2=0x3f3f; - for(int j=0; j<0x10; j++){ + int j; + for(j=0; j<0x10; j++){ do { int16 height=-((int8)Memory.C4RAM[waveptr+0xb00])-16; - for(int i=0; i<40; i++){ + int i; + for(i=0; i<40; i++){ uint16 tmp=READ_WORD(dst+bmpdata[i]) & mask2; if(height>=0){ if(height<8){ @@ -457,7 +468,8 @@ static void C4BitPlaneWave(){ do { int16 height=-((int8)Memory.C4RAM[waveptr+0xb00])-16; - for(int i=0; i<40; i++){ + int i; + for(i=0; i<40; i++){ uint16 tmp=READ_WORD(dst+bmpdata[i]) & mask2; if(height>=0){ if(height<8){ @@ -498,9 +510,11 @@ static void C4SprDisintegrate() memset(Memory.C4RAM, 0, width*height/2); - for(uint32 y=StartY, i=0; i<height; i++, y+=scaleY) + uint32 y, i; + for(y=StartY, i=0; i<height; i++, y+=scaleY) { - for(uint32 x=StartX, j=0; j<width; j++, x+=scaleX) + uint32 x, j; + for(x=StartX, j=0; j<width; j++, x+=scaleX) { if((x>>8)<width && (y>>8)<height && (y>>8)*width+(x>>8)<0x2000) { @@ -582,7 +596,7 @@ void S9xSetC4 (uint8 byte, uint16 Address) { int32 tmp=0x10000; if(READ_WORD(Memory.C4RAM+0x1f83)){ - tmp=SAR((tmp/READ_WORD(Memory.C4RAM+0x1f83))*READ_WORD(Memory.C4RAM+0x1f81), 8); + tmp=SAR32((tmp/READ_WORD(Memory.C4RAM+0x1f83))*READ_WORD(Memory.C4RAM+0x1f81), 8); } WRITE_WORD(Memory.C4RAM+0x1f80, (uint16)tmp); } @@ -599,18 +613,18 @@ void S9xSetC4 (uint8 byte, uint16 Address) case 0x10: // Polar to rectangluar { - int32 tmp=SAR((int32)READ_WORD(Memory.C4RAM+0x1f83)*C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*2, 16); + int32 tmp=SAR32((int32)READ_WORD(Memory.C4RAM+0x1f83)*C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*2, 16); WRITE_3WORD(Memory.C4RAM+0x1f86, tmp); - tmp=SAR((int32)READ_WORD(Memory.C4RAM+0x1f83)*C4SinTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*2, 16); - WRITE_3WORD(Memory.C4RAM+0x1f89, (tmp-SAR(tmp, 6))); + tmp=SAR32((int32)READ_WORD(Memory.C4RAM+0x1f83)*C4SinTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*2, 16); + WRITE_3WORD(Memory.C4RAM+0x1f89, (tmp-SAR32(tmp, 6))); } break; case 0x13: // Polar to rectangluar { - int32 tmp=SAR((int32)READ_WORD(Memory.C4RAM+0x1f83)*C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*2, 8); + int32 tmp=SAR32((int32)READ_WORD(Memory.C4RAM+0x1f83)*C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*2, 8); WRITE_3WORD(Memory.C4RAM+0x1f86, tmp); - tmp=SAR((int32)READ_WORD(Memory.C4RAM+0x1f83)*C4SinTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*2, 8); + tmp=SAR32((int32)READ_WORD(Memory.C4RAM+0x1f83)*C4SinTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*2, 8); WRITE_3WORD(Memory.C4RAM+0x1f89, tmp); } break; @@ -633,18 +647,19 @@ void S9xSetC4 (uint8 byte, uint16 Address) { int16 angle1=READ_WORD(Memory.C4RAM+0x1f8c)&0x1ff; int16 angle2=READ_WORD(Memory.C4RAM+0x1f8f)&0x1ff; - int32 tan1=(C4CosTable[angle1]!=0)?((((int32)C4SinTable[angle1])<<16)/C4CosTable[angle1]):0x80000000; - int32 tan2=(C4CosTable[angle2]!=0)?((((int32)C4SinTable[angle2])<<16)/C4CosTable[angle2]):0x80000000; + int32 tan1=(C4CosTable[angle1]!=0)?((((int32)C4SinTable[angle1])<<16)/C4CosTable[angle1]):(int32)0x80000000; + int32 tan2=(C4CosTable[angle2]!=0)?((((int32)C4SinTable[angle2])<<16)/C4CosTable[angle2]):(int32)0x80000000; int16 y = READ_WORD(Memory.C4RAM+0x1f83) - READ_WORD(Memory.C4RAM+0x1f89); int16 left, right; - for(int j=0; j<225; j++) + int j; + for(j=0; j<225; j++) { if(y>=0) { - left = SAR((int32)tan1*y, 16) - + left = SAR32((int32)tan1*y, 16) - READ_WORD(Memory.C4RAM+0x1f80) + READ_WORD(Memory.C4RAM+0x1f86); - right = SAR((int32)tan2*y, 16) - + right = SAR32((int32)tan2*y, 16) - READ_WORD(Memory.C4RAM+0x1f80) + READ_WORD(Memory.C4RAM+0x1f86) + READ_WORD(Memory.C4RAM+0x1f93); @@ -703,14 +718,15 @@ void S9xSetC4 (uint8 byte, uint16 Address) case 0x40: // Sum { uint16 sum=0; - for(int i=0; i<0x800; sum+=Memory.C4RAM[i++]); + int i; + for(i=0; i<0x800; sum+=Memory.C4RAM[i++]); WRITE_WORD(Memory.C4RAM+0x1f80, sum); } break; case 0x54: // Square { - int64 a=SAR((int64)READ_3WORD(Memory.C4RAM+0x1f80)<<40, 40); + int64 a=SAR64((int64)READ_3WORD(Memory.C4RAM+0x1f80)<<40, 40); // printf("%08X%08X\n", (uint32)(a>>32), (uint32)(a&0xFFFFFFFF)); a*=a; // printf("%08X%08X\n", (uint32)(a>>32), (uint32)(a&0xFFFFFFFF)); diff --git a/src/cheats.cpp b/src/cheats.c index 966e0b9..863f174 100644 --- a/src/cheats.cpp +++ b/src/cheats.c @@ -43,11 +43,12 @@ #include <string.h> #include "snes9x.h" #include "cheats.h" -#include "memmap.h"
+#include "memmap.h" static bool8 S9xAllHex (const char *code, int len) { - for (int i = 0; i < len; i++) + int i; + for (i = 0; i < len; i++) if ((code [i] < '0' || code [i] > '9') && (code [i] < 'a' || code [i] > 'f') && (code [i] < 'A' || code [i] > 'F')) @@ -56,20 +57,20 @@ static bool8 S9xAllHex (const char *code, int len) return (TRUE); } -const char *S9xProActionReplayToRaw (const char *code, uint32 &address, uint8 &byte) +const char *S9xProActionReplayToRaw (const char *code, uint32* address, uint8* byte) { uint32 data = 0; if (strlen (code) != 8 || !S9xAllHex (code, 8) || sscanf (code, "%x", &data) != 1) return ("Invalid Pro Action Replay code - should be 8 hex digits in length."); - address = data >> 8; - byte = (uint8) data; + *address = data >> 8; + *byte = (uint8) data; return (NULL); } -const char *S9xGoldFingerToRaw (const char *code, uint32 &address, bool8 &sram, - uint8 &num_bytes, uint8 bytes[3]) +const char *S9xGoldFingerToRaw (const char *code, uint32* address, bool8* sram, + uint8* num_bytes, uint8 bytes[3]) { char tmp [15]; if (strlen (code) != 14) @@ -77,7 +78,7 @@ const char *S9xGoldFingerToRaw (const char *code, uint32 &address, bool8 &sram, strncpy (tmp, code, 5); tmp [5] = 0; - if (sscanf (tmp, "%x", &address) != 1) + if (sscanf (tmp, "%x", address) != 1) return ("Invalid Gold Finger code."); int i; @@ -90,12 +91,12 @@ const char *S9xGoldFingerToRaw (const char *code, uint32 &address, bool8 &sram, break; bytes [i] = (uint8) byte; } - num_bytes = i; - sram = code [13] == '1'; + *num_bytes = i; + *sram = code [13] == '1'; return (NULL); } -const char *S9xGameGenieToRaw (const char *code, uint32 &address, uint8 &byte) +const char *S9xGameGenieToRaw (const char *code, uint32* address, uint8* byte) { char new_code [12]; @@ -110,7 +111,8 @@ const char *S9xGameGenieToRaw (const char *code, uint32 &address, uint8 &byte) static char *real_hex = "0123456789ABCDEF"; static char *genie_hex = "DF4709156BC8A23E"; - for (int i = 2; i < 10; i++) + int i; + for (i = 2; i < 10; i++) { if (islower (new_code [i])) new_code [i] = toupper (new_code [i]); @@ -128,15 +130,15 @@ const char *S9xGameGenieToRaw (const char *code, uint32 &address, uint8 &byte) } uint32 data = 0; sscanf (new_code, "%x", &data); - byte = (uint8)(data >> 24); - address = data & 0xffffff; - address = ((address & 0x003c00) << 10) + - ((address & 0x00003c) << 14) + - ((address & 0xf00000) >> 8) + - ((address & 0x000003) << 10) + - ((address & 0x00c000) >> 6) + - ((address & 0x0f0000) >> 12) + - ((address & 0x0003c0) >> 6); + *byte = (uint8)(data >> 24); + *address = data & 0xffffff; + *address = ((*address & 0x003c00) << 10) + + ((*address & 0x00003c) << 14) + + ((*address & 0xf00000) >> 8) + + ((*address & 0x000003) << 10) + + ((*address & 0x00c000) >> 6) + + ((*address & 0x0f0000) >> 12) + + ((*address & 0x0003c0) >> 6); return (NULL); } diff --git a/src/cheats.h b/src/cheats.h index 0ac09ec..ca800b4 100644 --- a/src/cheats.h +++ b/src/cheats.h @@ -53,7 +53,7 @@ struct SCheat #define MAX_CHEATS 75 -struct SCheatData +typedef struct { struct SCheat c [MAX_CHEATS]; uint32 num_cheats; @@ -66,7 +66,7 @@ struct SCheatData uint32 WRAM_BITS [0x20000 >> 3]; uint32 SRAM_BITS [0x10000 >> 3]; uint32 IRAM_BITS [0x2000 >> 3]; -}; +}SCheatData; typedef enum { @@ -81,10 +81,10 @@ typedef enum void S9xInitCheatData (); -const char *S9xGameGenieToRaw (const char *code, uint32 &address, uint8 &byte); -const char *S9xProActionReplayToRaw (const char *code, uint32 &address, uint8 &byte); -const char *S9xGoldFingerToRaw (const char *code, uint32 &address, bool8 &sram, - uint8 &num_bytes, uint8 bytes[3]); +const char *S9xGameGenieToRaw (const char *code, uint32 *address, uint8 *byte); +const char *S9xProActionReplayToRaw (const char *code, uint32 *address, uint8 *byte); +const char *S9xGoldFingerToRaw (const char *code, uint32* address, bool8* sram, + uint8* num_bytes, uint8 bytes[3]); void S9xApplyCheats (); void S9xApplyCheat (uint32 which1); void S9xRemoveCheats (); diff --git a/src/cheats2.cpp b/src/cheats2.c index ec8062a..3e8017e 100644 --- a/src/cheats2.cpp +++ b/src/cheats2.c @@ -37,7 +37,7 @@ * * Super NES and Super Nintendo Entertainment System are trademarks of * Nintendo Co., Limited and its subsidiary companies. - */
+ */ #include <stdio.h> #include <ctype.h> #include <string.h> @@ -50,7 +50,7 @@ extern SCheatData Cheat; void S9xInitCheatData () { Cheat.RAM = Memory.RAM; - Cheat.SRAM = ::SRAM; + Cheat.SRAM = SRAM; Cheat.FillRAM = Memory.FillRAM; } @@ -117,7 +117,7 @@ void S9xRemoveCheat (uint32 which1) int block = (address >> MEMMAP_SHIFT) & MEMMAP_MASK; uint8 *ptr = Memory.Map [block]; - if (ptr >= (uint8 *) CMemory::MAP_LAST) + if (ptr >= (uint8 *) MAP_LAST) *(ptr + (address & 0xffff)) = Cheat.c [which1].saved_byte; else S9xSetByte (address, Cheat.c [which1].saved_byte); @@ -134,7 +134,7 @@ void S9xApplyCheat (uint32 which1) int block = (address >> MEMMAP_SHIFT) & MEMMAP_MASK; uint8 *ptr = Memory.Map [block]; - if (ptr >= (uint8 *) CMemory::MAP_LAST) + if (ptr >= (uint8 *) MAP_LAST) *(ptr + (address & 0xffff)) = Cheat.c [which1].byte; else S9xSetByte (address, Cheat.c [which1].byte); @@ -145,7 +145,8 @@ void S9xApplyCheats () { if (Settings.ApplyCheats) { - for (uint32 i = 0; i < Cheat.num_cheats; i++) + uint32 i; + for (i = 0; i < Cheat.num_cheats; i++) if (Cheat.c [i].enabled) S9xApplyCheat (i); } @@ -153,7 +154,8 @@ void S9xApplyCheats () void S9xRemoveCheats () { - for (uint32 i = 0; i < Cheat.num_cheats; i++) + uint32 i; + for (i = 0; i < Cheat.num_cheats; i++) if (Cheat.c [i].enabled) S9xRemoveCheat (i); } @@ -186,8 +188,8 @@ bool8 S9xLoadCheatFile (const char *filename) bool8 S9xSaveCheatFile (const char *filename) { if (Cheat.num_cheats == 0) - {
- (void) remove (filename);
+ { + (void) remove (filename); return (TRUE); } diff --git a/src/clip.cpp b/src/clip.c index e991b92..a6d0292 100644 --- a/src/clip.cpp +++ b/src/clip.c @@ -91,7 +91,7 @@ static int BandCompare (const void *d1, const void *d2) return (((struct Band *) d1)->Left - ((struct Band *) d2)->Left); } -void ComputeClipWindow(bool8_32 invert, int w, int wok, struct ClipData *pClip) { +void ComputeClipWindow(bool8_32 invert, int w, int wok, ClipData *pClip) { pClip->Count[w] = 0; if (!Settings.DisableGraphicWindows) @@ -515,7 +515,8 @@ void ComputeClipWindow(bool8_32 invert, int w, int wok, struct ClipData *pClip) } else { - for (int j = 0; j < B; j++) + int j; + for (j = 0; j < B; j++) { pClip->Left[j][w] = Bands[j].Left; pClip->Right[j][w] = Bands[j].Right; @@ -573,7 +574,8 @@ void ComputeClipWindow(bool8_32 invert, int w, int wok, struct ClipData *pClip) } else { - for (uint32 j = 0; j < Window1Enabled; j++) + uint32 j; + for (j = 0; j < Window1Enabled; j++) { pClip->Left [j][w] = Win1[j].Left; pClip->Right [j][w] = Win1[j].Right; @@ -626,7 +628,8 @@ void ComputeClipWindow(bool8_32 invert, int w, int wok, struct ClipData *pClip) } else { - for (uint32 j = 0; j < Window2Enabled; j++) + uint32 j; + for (j = 0; j < Window2Enabled; j++) { pClip->Left [j][w] = Win2[j].Left; pClip->Right [j][w] = Win2[j].Right; @@ -646,7 +649,8 @@ void ComputeClipWindow(bool8_32 invert, int w, int wok, struct ClipData *pClip) if (pClip->Count [w] == 0) { pClip->Count [w] = pClip->Count [5]; - for (int i = pClip->Count[w]-1; i >= 0 ; i--) + int i; + for (i = pClip->Count[w]-1; i >= 0 ; i--) { pClip->Left [i][w] = pClip->Left [i][5]; pClip->Right [i][w] = pClip->Right [i][5]; @@ -690,7 +694,8 @@ void ComputeClipWindows () if ((GFX.r2130_s & 0xc0) == 0xc0) { // The whole of the main screen is switched off, // completely clip everything. - for (int i = 0; i < 6; i++) { + int i; + for (i = 0; i < 6; i++) { IPPU.Clip [0].Count [i] = 1; IPPU.Clip [0].Left [0][i] = 1; IPPU.Clip [0].Right [0][i] = 0; @@ -711,7 +716,8 @@ void ComputeClipWindows () if ((GFX.r2130_s & 0x30) == 0x30) { // The sub-screen is switched off, completely // clip everything. - for (int i = 0; i < 6; i++) { + int i; + for (i = 0; i < 6; i++) { IPPU.Clip [1].Count [i] = 1; IPPU.Clip [1].Left [0][i] = 1; IPPU.Clip [1].Right [0][i] = 0; @@ -58,7 +58,7 @@ #ifdef SUPER_FX
#include "fxemu.h"
-extern struct FxInit_s SuperFX;
+extern FxInit_s SuperFX;
void S9xResetSuperFX ()
{
diff --git a/src/cpuexec.cpp b/src/cpuexec.c index 3cd25c3..3cd25c3 100644 --- a/src/cpuexec.cpp +++ b/src/cpuexec.c diff --git a/src/cpuexec.h b/src/cpuexec.h index 649d0ec..de057bf 100644 --- a/src/cpuexec.h +++ b/src/cpuexec.h @@ -40,26 +40,27 @@ */
#ifndef _CPUEXEC_H_
#define _CPUEXEC_H_
-#include "ppu.h"
-#include "memmap.h"
+//#include "ppu.h"
+//#include "memmap.h"
+#include "snes9x.h"
#include "65c816.h"
#define DO_HBLANK_CHECK() \
if (CPU.Cycles >= CPU.NextEvent) \
S9xDoHBlankProcessing ();
-struct SOpcodes {
+typedef struct{
#ifdef __WIN32__
void (__cdecl *S9xOpcode)( void);
#else
void (*S9xOpcode)( void);
#endif
-};
+}SOpcodes;
-struct SICPU
+typedef struct
{
uint8 *Speed;
- struct SOpcodes *S9xOpcodes;
+ SOpcodes *S9xOpcodes;
uint8 _Carry;
uint8 _Zero;
uint8 _Negative;
@@ -70,7 +71,7 @@ struct SICPU uint32 Frame;
uint32 Scanline;
uint32 FrameAdvanceCount;
-};
+}SICPU;
START_EXTERN_C
void S9xMainLoop (void);
@@ -79,10 +80,10 @@ void S9xDoHBlankProcessing (); void S9xClearIRQ (uint32);
void S9xSetIRQ (uint32);
-extern struct SOpcodes S9xOpcodesM1X1 [256];
-extern struct SOpcodes S9xOpcodesM1X0 [256];
-extern struct SOpcodes S9xOpcodesM0X1 [256];
-extern struct SOpcodes S9xOpcodesM0X0 [256];
+extern SOpcodes S9xOpcodesM1X1 [256];
+extern SOpcodes S9xOpcodesM1X0 [256];
+extern SOpcodes S9xOpcodesM0X1 [256];
+extern SOpcodes S9xOpcodesM0X0 [256];
#ifndef VAR_CYCLES
extern uint8 S9xE1M1X1 [256];
@@ -92,7 +93,7 @@ extern uint8 S9xE0M0X0 [256]; extern uint8 S9xE0M0X1 [256];
#endif
-extern struct SICPU ICPU;
+extern SICPU ICPU;
END_EXTERN_C
STATIC inline void CLEAR_IRQ_SOURCE (uint32 M)
diff --git a/src/cpuops.cpp b/src/cpuops.c index 6e4499b..011ef73 100644 --- a/src/cpuops.cpp +++ b/src/cpuops.c @@ -2492,7 +2492,7 @@ static void Op0CM0 (void) #ifdef CPU_SHUTDOWN
#ifndef SA1_OPCODES
-inline void CPUShutdown() {
+static inline void CPUShutdown() {
if (Settings.Shutdown && CPU.PC == CPU.WaitAddress) {
// Don't skip cycles with a pending NMI or IRQ - could cause delayed
// interrupt. Interrupts are delayed for a few cycles already, but
@@ -2514,7 +2514,7 @@ inline void CPUShutdown() { }
}
#else
-inline void CPUShutdown()
+static inline void CPUShutdown()
{
if (Settings.Shutdown && CPU.PC == CPU.WaitAddress)
{
@@ -4020,7 +4020,7 @@ static void Op42 (void) { /**********************************************************************************************/
/* CPU-S9xOpcodes Definitions */
/**********************************************************************************************/
-struct SOpcodes S9xOpcodesM1X1[256] =
+SOpcodes S9xOpcodesM1X1[256] =
{
{Op00}, {Op01M1}, {Op02}, {Op03M1}, {Op04M1},
{Op05M1}, {Op06M1}, {Op07M1}, {Op08}, {Op09M1},
@@ -4077,7 +4077,7 @@ struct SOpcodes S9xOpcodesM1X1[256] = {OpFFM1}
};
-struct SOpcodes S9xOpcodesM1X0[256] =
+SOpcodes S9xOpcodesM1X0[256] =
{
{Op00}, {Op01M1}, {Op02}, {Op03M1}, {Op04M1},
{Op05M1}, {Op06M1}, {Op07M1}, {Op08}, {Op09M1},
@@ -4133,7 +4133,7 @@ struct SOpcodes S9xOpcodesM1X0[256] = {OpFFM1}
};
-struct SOpcodes S9xOpcodesM0X0[256] =
+SOpcodes S9xOpcodesM0X0[256] =
{
{Op00}, {Op01M0}, {Op02}, {Op03M0}, {Op04M0},
{Op05M0}, {Op06M0}, {Op07M0}, {Op08}, {Op09M0},
@@ -4189,7 +4189,7 @@ struct SOpcodes S9xOpcodesM0X0[256] = {OpFFM0}
};
-struct SOpcodes S9xOpcodesM0X1[256] =
+SOpcodes S9xOpcodesM0X1[256] =
{
{Op00}, {Op01M0}, {Op02}, {Op03M0}, {Op04M0},
{Op05M0}, {Op06M0}, {Op07M0}, {Op08}, {Op09M0},
diff --git a/src/data.cpp b/src/data.c index 2a25eab..2a25eab 100644 --- a/src/data.cpp +++ b/src/data.c diff --git a/src/display.h b/src/display.h index 753652b..77ee89c 100644 --- a/src/display.h +++ b/src/display.h @@ -46,12 +46,10 @@ START_EXTERN_C void S9xSetPalette (); void S9xTextMode (); void S9xGraphicsMode (); -char *S9xParseArgs (char **argv, int argc); -void S9xParseArg (char **argv, int &index, int argc); void S9xExtraUsage (); uint32 S9xReadJoypad (int which1_0_to_4); -bool8_32 S9xReadMousePosition (int which1_0_to_1, int &x, int &y, uint32 &buttons); -bool8_32 S9xReadSuperScopePosition (int &x, int &y, uint32 &buttons); +bool8_32 S9xReadMousePosition (int which1_0_to_1, int* x, int* y, uint32* buttons); +bool8_32 S9xReadSuperScopePosition (int* x, int* y, uint32* buttons); void S9xUsage (); void S9xInitDisplay (int argc, char **argv); @@ -60,7 +58,6 @@ void S9xInitInputDevices (); void S9xSetTitle (const char *title); void S9xProcessEvents (bool8_32 block); void S9xPutImage (int width, int height); -void S9xParseDisplayArg (char **argv, int &index, int argc); void S9xToggleSoundChannel (int channel); void S9xSetInfoString (const char *string); int S9xMinCommandLineArgs (); @@ -199,7 +199,7 @@ void S9xDoDMA (uint8 Channel) int char_line_bytes = bytes_per_char * num_chars;
uint32 addr = (d->AAddress / char_line_bytes) * char_line_bytes;
uint8 *base = GetBasePointer ((d->ABank << 16) + addr) + addr;
- uint8 *buffer = &Memory.ROM [CMemory::MAX_ROM_SIZE - 0x10000];
+ uint8 *buffer = &Memory.ROM [MAX_ROM_SIZE - 0x10000];
uint8 *p = buffer;
uint32 inc = char_line_bytes - (d->AAddress % char_line_bytes);
uint32 char_count = inc / bytes_per_char;
@@ -250,9 +250,11 @@ void S9xDoDMA (uint8 Channel) j++, line += 4)
{
uint8 *q = line;
- for (int l = 0; l < 8; l++, q += bytes_per_line)
+ int l;
+ for (l = 0; l < 8; l++, q += bytes_per_line)
{
- for (int b = 0; b < 4; b++)
+ int b;
+ for (b = 0; b < 4; b++)
{
uint8 r = *(q + b);
*(p + 0) = (*(p + 0) << 1) | ((r >> 0) & 1);
@@ -320,7 +322,7 @@ void S9xDoDMA (uint8 Channel) if (in_sa1_dma)
{
- base = &Memory.ROM [CMemory::MAX_ROM_SIZE - 0x10000];
+ base = &Memory.ROM [MAX_ROM_SIZE - 0x10000];
p = 0;
}
@@ -705,7 +707,7 @@ void S9xStartHDMA () uint8 S9xDoHDMA (uint8 byte)
{
- struct SDMA *p = &DMA [0];
+ SDMA *p = &DMA [0];
int d = 0;
diff --git a/src/dsp1.cpp b/src/dsp1.c index f2ea308..f2ea308 100644 --- a/src/dsp1.cpp +++ b/src/dsp1.c @@ -106,7 +106,8 @@ void DSP3_Reset(); void DSP4SetByte(uint8 byte, uint16 address);
uint8 DSP4GetByte(uint16 address);
-struct SDSP1 {
+typedef struct
+{
uint8 version;
bool8 waiting4command;
bool8 first_parameter;
@@ -117,7 +118,7 @@ struct SDSP1 { uint32 out_index;
uint8 parameters [512];
uint8 output [512];
-};
+}SDSP1;
START_EXTERN_C
void S9xResetDSP1 ();
@@ -125,6 +126,6 @@ uint8 S9xGetDSP (uint16 Address); void S9xSetDSP (uint8 Byte, uint16 Address);
END_EXTERN_C
-extern struct SDSP1 DSP1;
+extern SDSP1 DSP1;
#endif
diff --git a/src/fxemu.cpp b/src/fxemu.c index b958862..0fda5e5 100644 --- a/src/fxemu.cpp +++ b/src/fxemu.c @@ -93,7 +93,7 @@ #include <stdio.h>
/* The FxChip Emulator's internal variables */
-struct FxRegs_s GSU = FxRegs_s_null;
+FxRegs_s GSU = FxRegs_s_null;
uint32 (**fx_ppfFunctionTable)(uint32) = 0;
void (**fx_ppfPlotTable)() = 0;
@@ -486,7 +486,7 @@ static inline void fx_writeRegisterSpace() }
/* Reset the FxChip */
-void FxReset(struct FxInit_s *psFxInfo)
+void FxReset(FxInit_s *psFxInfo)
{
int i;
static uint32 (**appfFunction[])(uint32) = {
@@ -520,7 +520,7 @@ void FxReset(struct FxInit_s *psFxInfo) fx_ppfOpcodeTable = appfOpcode[psFxInfo->vFlags & 0x3];
/* Clear all internal variables */
- memset((uint8*)&GSU,0,sizeof(struct FxRegs_s));
+ memset((uint8*)&GSU,0,sizeof(FxRegs_s));
/* Set default registers */
GSU.pvSreg = GSU.pvDreg = &R0;
diff --git a/src/fxemu.h b/src/fxemu.h index 01ce839..00fc41a 100644 --- a/src/fxemu.h +++ b/src/fxemu.h @@ -112,7 +112,7 @@ typedef int int32; #endif
/* The FxInfo_s structure, the link between the FxEmulator and the Snes Emulator */
-struct FxInit_s
+typedef struct
{
uint32 vFlags;
uint8 * pvRegisters; /* 768 bytes located in the memory at address 0x3000 */
@@ -120,10 +120,10 @@ struct FxInit_s uint8 * pvRam; /* Pointer to GSU-RAM */
uint32 nRomBanks; /* Number of 32kb-banks in Cart-ROM */
uint8 * pvRom; /* Pointer to Cart-ROM */
-};
+}FxInit_s;
/* Reset the FxChip */
-extern void FxReset(struct FxInit_s *psFxInfo);
+extern void FxReset(FxInit_s *psFxInfo);
/* Execute until the next stop instruction */
extern int FxEmulate(uint32 nInstructions);
diff --git a/src/fxinst.cpp b/src/fxinst.c index acdca50..ec21723 100644 --- a/src/fxinst.cpp +++ b/src/fxinst.c @@ -93,7 +93,7 @@ #include <string.h>
#include <stdio.h>
-extern struct FxRegs_s GSU;
+extern FxRegs_s GSU;
int gsu_bank [512] = {0};
/* Set this define if you wish the plot instruction to check for y-pos limits */
diff --git a/src/fxinst.h b/src/fxinst.h index bc0143c..ace3b12 100644 --- a/src/fxinst.h +++ b/src/fxinst.h @@ -216,7 +216,7 @@ /* Address checking (definately slow) */
/* #define FX_ADDRESS_CHECK */
-struct FxRegs_s
+typedef struct
{
/* FxChip registers */
uint32 avReg[16]; /* 16 Generic registers */
@@ -281,7 +281,7 @@ struct FxRegs_s uint32 vCounter;
uint32 vInstCount;
uint32 vSCBRDirty; /* if SCBR is written, our cached screen pointers need updating */
-};
+}FxRegs_s;
#define FxRegs_s_null { \
{0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
diff --git a/src/getset.h b/src/getset.h index 00387e1..0351cd3 100644 --- a/src/getset.h +++ b/src/getset.h @@ -52,7 +52,7 @@ extern int oppause;
//extern uint16 mem_check;
-INLINE uint8 S9xGetByte (uint32 Address)
+static INLINE uint8 S9xGetByte (uint32 Address)
{
#ifdef __show_io__
char str[64];
@@ -69,7 +69,7 @@ INLINE uint8 S9xGetByte (uint32 Address) #else
uint8 *GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
#endif
- if (GetAddress >= (uint8 *) CMemory::MAP_LAST)
+ if (GetAddress >= (uint8 *) MAP_LAST)
{
#ifdef VAR_CYCLES
CPU.Cycles += Memory.MemorySpeed [block];
@@ -83,52 +83,52 @@ INLINE uint8 S9xGetByte (uint32 Address) switch ((intptr_t) GetAddress)
{
- case CMemory::MAP_PPU:
+ case MAP_PPU:
#ifdef VAR_CYCLES
if (!CPU.InDMA)
CPU.Cycles += ONE_CYCLE;
#endif
return (S9xGetPPU (Address & 0xffff));
- case CMemory::MAP_CPU:
+ case MAP_CPU:
#ifdef VAR_CYCLES
CPU.Cycles += ONE_CYCLE;
#endif
return (S9xGetCPU (Address & 0xffff));
- case CMemory::MAP_DSP:
+ case MAP_DSP:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE;
#endif
return (S9xGetDSP (Address & 0xffff));
- case CMemory::MAP_SA1RAM:
- case CMemory::MAP_LOROM_SRAM:
+ case MAP_SA1RAM:
+ case MAP_LOROM_SRAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE;
#endif
return (*(Memory.SRAM + ((Address & CPU.Memory_SRAMMask))));
- case CMemory::MAP_HIROM_SRAM:
+ case MAP_HIROM_SRAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE;
#endif
return (*(Memory.SRAM + (((Address & 0x7fff) - 0x6000 +
((Address & 0xf0000) >> 3)) & CPU.Memory_SRAMMask)));
- case CMemory::MAP_DEBUG:
+ case MAP_DEBUG:
#ifdef DEBUGGER
printf ("R(B) %06x\n", Address);
#endif
- case CMemory::MAP_BWRAM:
+ case MAP_BWRAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE;
#endif
return (*(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)));
//#ifndef __GP32__
- case CMemory::MAP_C4:
+ case MAP_C4:
return (S9xGetC4 (Address & 0xffff));
//#endif
default:
- case CMemory::MAP_NONE:
+ case MAP_NONE:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE;
#endif
@@ -139,7 +139,7 @@ INLINE uint8 S9xGetByte (uint32 Address) }
}
-INLINE uint16 S9xGetWord (uint32 Address)
+static INLINE uint16 S9xGetWord (uint32 Address)
{
#ifdef __show_io__
char str[64];
@@ -160,7 +160,7 @@ INLINE uint16 S9xGetWord (uint32 Address) #else
uint8 *GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
#endif
- if (GetAddress >= (uint8 *) CMemory::MAP_LAST)
+ if (GetAddress >= (uint8 *) MAP_LAST)
{
#ifdef VAR_CYCLES
CPU.Cycles += Memory.MemorySpeed [block] << 1;
@@ -179,34 +179,34 @@ INLINE uint16 S9xGetWord (uint32 Address) switch ((intptr_t) GetAddress)
{
- case CMemory::MAP_PPU:
+ case MAP_PPU:
#ifdef VAR_CYCLES
if (!CPU.InDMA)
CPU.Cycles += TWO_CYCLES;
#endif
return (S9xGetPPU (Address & 0xffff) |
(S9xGetPPU ((Address + 1) & 0xffff) << 8));
- case CMemory::MAP_CPU:
+ case MAP_CPU:
#ifdef VAR_CYCLES
CPU.Cycles += TWO_CYCLES;
#endif
return (S9xGetCPU (Address & 0xffff) |
(S9xGetCPU ((Address + 1) & 0xffff) << 8));
- case CMemory::MAP_DSP:
+ case MAP_DSP:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE * 2;
#endif
return (S9xGetDSP (Address & 0xffff) |
(S9xGetDSP ((Address + 1) & 0xffff) << 8));
- case CMemory::MAP_SA1RAM:
- case CMemory::MAP_LOROM_SRAM:
+ case MAP_SA1RAM:
+ case MAP_LOROM_SRAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE * 2;
#endif
return (*(Memory.SRAM + (Address & CPU.Memory_SRAMMask)) |
(*(Memory.SRAM + ((Address + 1) & CPU.Memory_SRAMMask)) << 8));
- case CMemory::MAP_HIROM_SRAM:
+ case MAP_HIROM_SRAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE * 2;
#endif
@@ -217,25 +217,25 @@ INLINE uint16 S9xGetWord (uint32 Address) ((((Address + 1) & 0x7fff) - 0x6000 +
(((Address + 1) & 0xf0000) >> 3)) & CPU.Memory_SRAMMask)) << 8));
- case CMemory::MAP_BWRAM:
+ case MAP_BWRAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE * 2;
#endif
return (*(Memory.BWRAM + ((Address & 0x7fff) - 0x6000)) |
(*(Memory.BWRAM + (((Address + 1) & 0x7fff) - 0x6000)) << 8));
- case CMemory::MAP_DEBUG:
+ case MAP_DEBUG:
#ifdef DEBUGGER
printf ("R(W) %06x\n", Address);
#endif
//#ifndef __GP32__
- case CMemory::MAP_C4:
+ case MAP_C4:
return (S9xGetC4 (Address & 0xffff) |
(S9xGetC4 ((Address + 1) & 0xffff) << 8));
//#endif
default:
- case CMemory::MAP_NONE:
+ case MAP_NONE:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE * 2;
#endif
@@ -246,7 +246,7 @@ INLINE uint16 S9xGetWord (uint32 Address) }
}
-INLINE void S9xSetByte (uint8 Byte, uint32 Address)
+static INLINE void S9xSetByte (uint8 Byte, uint32 Address)
{
#ifdef __show_io__
char str[64];
@@ -268,7 +268,7 @@ INLINE void S9xSetByte (uint8 Byte, uint32 Address) uint8 *SetAddress = Memory.WriteMap [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
#endif
- if (SetAddress >= (uint8 *) CMemory::MAP_LAST)
+ if (SetAddress >= (uint8 *) MAP_LAST)
{
#ifdef VAR_CYCLES
CPU.Cycles += Memory.MemorySpeed [block];
@@ -292,7 +292,7 @@ INLINE void S9xSetByte (uint8 Byte, uint32 Address) switch ((intptr_t) SetAddress)
{
- case CMemory::MAP_PPU:
+ case MAP_PPU:
#ifdef VAR_CYCLES
if (!CPU.InDMA)
CPU.Cycles += ONE_CYCLE;
@@ -300,21 +300,21 @@ INLINE void S9xSetByte (uint8 Byte, uint32 Address) S9xSetPPU (Byte, Address & 0xffff);
return;
- case CMemory::MAP_CPU:
+ case MAP_CPU:
#ifdef VAR_CYCLES
CPU.Cycles += ONE_CYCLE;
#endif
S9xSetCPU (Byte, Address & 0xffff);
return;
- case CMemory::MAP_DSP:
+ case MAP_DSP:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE;
#endif
S9xSetDSP (Byte, Address & 0xffff);
return;
- case CMemory::MAP_LOROM_SRAM:
+ case MAP_LOROM_SRAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE;
#endif
@@ -325,7 +325,7 @@ INLINE void S9xSetByte (uint8 Byte, uint32 Address) }
return;
- case CMemory::MAP_HIROM_SRAM:
+ case MAP_HIROM_SRAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE;
#endif
@@ -337,7 +337,7 @@ INLINE void S9xSetByte (uint8 Byte, uint32 Address) }
return;
- case CMemory::MAP_BWRAM:
+ case MAP_BWRAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE;
#endif
@@ -345,12 +345,12 @@ INLINE void S9xSetByte (uint8 Byte, uint32 Address) CPU.SRAMModified = TRUE;
return;
- case CMemory::MAP_DEBUG:
+ case MAP_DEBUG:
#ifdef DEBUGGER
printf ("W(B) %06x\n", Address);
#endif
- case CMemory::MAP_SA1RAM:
+ case MAP_SA1RAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE;
#endif
@@ -360,12 +360,12 @@ INLINE void S9xSetByte (uint8 Byte, uint32 Address) #endif
break;
//#ifndef __GP32__
- case CMemory::MAP_C4:
+ case MAP_C4:
S9xSetC4 (Byte, Address & 0xffff);
return;
//#endif
default:
- case CMemory::MAP_NONE:
+ case MAP_NONE:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE;
#endif
@@ -376,7 +376,7 @@ INLINE void S9xSetByte (uint8 Byte, uint32 Address) }
}
-INLINE void S9xSetWord (uint16 Word, uint32 Address)
+static INLINE void S9xSetWord (uint16 Word, uint32 Address)
{
#ifdef __show_io__
char str[64];
@@ -397,7 +397,7 @@ INLINE void S9xSetWord (uint16 Word, uint32 Address) uint8 *SetAddress = Memory.WriteMap [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
#endif
- if (SetAddress >= (uint8 *) CMemory::MAP_LAST)
+ if (SetAddress >= (uint8 *) MAP_LAST)
{
#ifdef VAR_CYCLES
CPU.Cycles += Memory.MemorySpeed [block] << 1;
@@ -430,7 +430,7 @@ INLINE void S9xSetWord (uint16 Word, uint32 Address) switch ((intptr_t) SetAddress)
{
- case CMemory::MAP_PPU:
+ case MAP_PPU:
#ifdef VAR_CYCLES
if (!CPU.InDMA)
CPU.Cycles += TWO_CYCLES;
@@ -439,7 +439,7 @@ INLINE void S9xSetWord (uint16 Word, uint32 Address) S9xSetPPU (Word >> 8, (Address & 0xffff) + 1);
return;
- case CMemory::MAP_CPU:
+ case MAP_CPU:
#ifdef VAR_CYCLES
CPU.Cycles += TWO_CYCLES;
#endif
@@ -447,7 +447,7 @@ INLINE void S9xSetWord (uint16 Word, uint32 Address) S9xSetCPU (Word >> 8, (Address & 0xffff) + 1);
return;
- case CMemory::MAP_DSP:
+ case MAP_DSP:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE * 2;
#endif
@@ -455,7 +455,7 @@ INLINE void S9xSetWord (uint16 Word, uint32 Address) S9xSetDSP (Word >> 8, (Address & 0xffff) + 1);
return;
- case CMemory::MAP_LOROM_SRAM:
+ case MAP_LOROM_SRAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE * 2;
#endif
@@ -467,7 +467,7 @@ INLINE void S9xSetWord (uint16 Word, uint32 Address) }
return;
- case CMemory::MAP_HIROM_SRAM:
+ case MAP_HIROM_SRAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE * 2;
#endif
@@ -483,7 +483,7 @@ INLINE void S9xSetWord (uint16 Word, uint32 Address) }
return;
- case CMemory::MAP_BWRAM:
+ case MAP_BWRAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE * 2;
#endif
@@ -492,12 +492,12 @@ INLINE void S9xSetWord (uint16 Word, uint32 Address) CPU.SRAMModified = TRUE;
return;
- case CMemory::MAP_DEBUG:
+ case MAP_DEBUG:
#ifdef DEBUGGER
printf ("W(W) %06x\n", Address);
#endif
- case CMemory::MAP_SA1RAM:
+ case MAP_SA1RAM:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE;
#endif
@@ -508,13 +508,13 @@ INLINE void S9xSetWord (uint16 Word, uint32 Address) #endif
break;
//#ifndef __GP32__
- case CMemory::MAP_C4:
+ case MAP_C4:
S9xSetC4 (Word & 0xff, Address & 0xffff);
S9xSetC4 ((uint8) (Word >> 8), (Address + 1) & 0xffff);
return;
//#endif
default:
- case CMemory::MAP_NONE:
+ case MAP_NONE:
#ifdef VAR_CYCLES
CPU.Cycles += SLOW_ONE_CYCLE * 2;
#endif
@@ -525,38 +525,38 @@ INLINE void S9xSetWord (uint16 Word, uint32 Address) }
}
-INLINE uint8 *GetBasePointer (uint32 Address)
+static INLINE uint8 *GetBasePointer (uint32 Address)
{
uint8 *GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (GetAddress >= (uint8 *) CMemory::MAP_LAST)
+ if (GetAddress >= (uint8 *) MAP_LAST)
return (GetAddress);
switch ((intptr_t) GetAddress)
{
- case CMemory::MAP_PPU:
+ case MAP_PPU:
return (Memory.FillRAM - 0x2000);
- case CMemory::MAP_CPU:
+ case MAP_CPU:
return (Memory.FillRAM - 0x4000);
- case CMemory::MAP_DSP:
+ case MAP_DSP:
return (Memory.FillRAM - 0x6000);
- case CMemory::MAP_SA1RAM:
- case CMemory::MAP_LOROM_SRAM:
+ case MAP_SA1RAM:
+ case MAP_LOROM_SRAM:
return (Memory.SRAM);
- case CMemory::MAP_BWRAM:
+ case MAP_BWRAM:
return (Memory.BWRAM - 0x6000);
- case CMemory::MAP_HIROM_SRAM:
+ case MAP_HIROM_SRAM:
return (Memory.SRAM - 0x6000);
//#ifndef __GP32__
- case CMemory::MAP_C4:
+ case MAP_C4:
return (Memory.C4RAM - 0x6000);
//#endif
- case CMemory::MAP_DEBUG:
+ case MAP_DEBUG:
#ifdef DEBUGGER
printf ("GBP %06x\n", Address);
#endif
default:
- case CMemory::MAP_NONE:
+ case MAP_NONE:
#ifdef DEBUGGER
printf ("GBP %06x\n", Address);
#endif
@@ -564,37 +564,37 @@ INLINE uint8 *GetBasePointer (uint32 Address) }
}
-INLINE uint8 *S9xGetMemPointer (uint32 Address)
+static INLINE uint8 *S9xGetMemPointer (uint32 Address)
{
uint8 *GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (GetAddress >= (uint8 *) CMemory::MAP_LAST)
+ if (GetAddress >= (uint8 *) MAP_LAST)
return (GetAddress + (Address & 0xffff));
switch ((intptr_t) GetAddress)
{
- case CMemory::MAP_PPU:
+ case MAP_PPU:
return (Memory.FillRAM - 0x2000 + (Address & 0xffff));
- case CMemory::MAP_CPU:
+ case MAP_CPU:
return (Memory.FillRAM - 0x4000 + (Address & 0xffff));
- case CMemory::MAP_DSP:
+ case MAP_DSP:
return (Memory.FillRAM - 0x6000 + (Address & 0xffff));
- case CMemory::MAP_SA1RAM:
- case CMemory::MAP_LOROM_SRAM:
+ case MAP_SA1RAM:
+ case MAP_LOROM_SRAM:
return (Memory.SRAM + (Address & 0xffff));
- case CMemory::MAP_BWRAM:
+ case MAP_BWRAM:
return (Memory.BWRAM - 0x6000 + (Address & 0xffff));
- case CMemory::MAP_HIROM_SRAM:
+ case MAP_HIROM_SRAM:
return (Memory.SRAM - 0x6000 + (Address & 0xffff));
//#ifndef __GP32__
- case CMemory::MAP_C4:
+ case MAP_C4:
return (Memory.C4RAM - 0x6000 + (Address & 0xffff));
//#endif
- case CMemory::MAP_DEBUG:
+ case MAP_DEBUG:
#ifdef DEBUGGER
printf ("GMP %06x\n", Address);
#endif
default:
- case CMemory::MAP_NONE:
+ case MAP_NONE:
#ifdef DEBUGGER
printf ("GMP %06x\n", Address);
#endif
@@ -602,7 +602,7 @@ INLINE uint8 *S9xGetMemPointer (uint32 Address) }
}
-INLINE void S9xSetPCBase (uint32 Address)
+static INLINE void S9xSetPCBase (uint32 Address)
{
#ifdef VAR_CYCLES
int block;
@@ -610,7 +610,7 @@ INLINE void S9xSetPCBase (uint32 Address) #else
uint8 *GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
#endif
- if (GetAddress >= (uint8 *) CMemory::MAP_LAST)
+ if (GetAddress >= (uint8 *) MAP_LAST)
{
#ifdef VAR_CYCLES
CPU.MemSpeed = Memory.MemorySpeed [block];
@@ -623,7 +623,7 @@ INLINE void S9xSetPCBase (uint32 Address) switch ((intptr_t) GetAddress)
{
- case CMemory::MAP_PPU:
+ case MAP_PPU:
#ifdef VAR_CYCLES
CPU.MemSpeed = ONE_CYCLE;
CPU.MemSpeedx2 = TWO_CYCLES;
@@ -632,7 +632,7 @@ INLINE void S9xSetPCBase (uint32 Address) CPU.PC = CPU.PCBase + (Address & 0xffff);
return;
- case CMemory::MAP_CPU:
+ case MAP_CPU:
#ifdef VAR_CYCLES
CPU.MemSpeed = ONE_CYCLE;
CPU.MemSpeedx2 = TWO_CYCLES;
@@ -641,7 +641,7 @@ INLINE void S9xSetPCBase (uint32 Address) CPU.PC = CPU.PCBase + (Address & 0xffff);
return;
- case CMemory::MAP_DSP:
+ case MAP_DSP:
#ifdef VAR_CYCLES
CPU.MemSpeed = SLOW_ONE_CYCLE;
CPU.MemSpeedx2 = SLOW_ONE_CYCLE * 2;
@@ -650,8 +650,8 @@ INLINE void S9xSetPCBase (uint32 Address) CPU.PC = CPU.PCBase + (Address & 0xffff);
return;
- case CMemory::MAP_SA1RAM:
- case CMemory::MAP_LOROM_SRAM:
+ case MAP_SA1RAM:
+ case MAP_LOROM_SRAM:
#ifdef VAR_CYCLES
CPU.MemSpeed = SLOW_ONE_CYCLE;
CPU.MemSpeedx2 = SLOW_ONE_CYCLE * 2;
@@ -660,7 +660,7 @@ INLINE void S9xSetPCBase (uint32 Address) CPU.PC = CPU.PCBase + (Address & 0xffff);
return;
- case CMemory::MAP_BWRAM:
+ case MAP_BWRAM:
#ifdef VAR_CYCLES
CPU.MemSpeed = SLOW_ONE_CYCLE;
CPU.MemSpeedx2 = SLOW_ONE_CYCLE * 2;
@@ -668,7 +668,7 @@ INLINE void S9xSetPCBase (uint32 Address) CPU.PCBase = Memory.BWRAM - 0x6000;
CPU.PC = CPU.PCBase + (Address & 0xffff);
return;
- case CMemory::MAP_HIROM_SRAM:
+ case MAP_HIROM_SRAM:
#ifdef VAR_CYCLES
CPU.MemSpeed = SLOW_ONE_CYCLE;
CPU.MemSpeedx2 = SLOW_ONE_CYCLE * 2;
@@ -677,7 +677,7 @@ INLINE void S9xSetPCBase (uint32 Address) CPU.PC = CPU.PCBase + (Address & 0xffff);
return;
//#ifndef __GP32__
- case CMemory::MAP_C4:
+ case MAP_C4:
#ifdef VAR_CYCLES
CPU.MemSpeed = SLOW_ONE_CYCLE;
CPU.MemSpeedx2 = SLOW_ONE_CYCLE * 2;
@@ -686,13 +686,13 @@ INLINE void S9xSetPCBase (uint32 Address) CPU.PC = CPU.PCBase + (Address & 0xffff);
return;
//#endif
- case CMemory::MAP_DEBUG:
+ case MAP_DEBUG:
#ifdef DEBUGGER
printf ("SBP %06x\n", Address);
#endif
default:
- case CMemory::MAP_NONE:
+ case MAP_NONE:
#ifdef VAR_CYCLES
CPU.MemSpeed = SLOW_ONE_CYCLE;
CPU.MemSpeedx2 = SLOW_ONE_CYCLE * 2;
@@ -107,10 +107,10 @@ extern NormalTileRenderer DrawHiResTilePtr; extern ClippedTileRenderer DrawHiResClippedTilePtr; extern LargePixelRenderer DrawLargePixelPtr; -extern struct SBG BG; +extern SBG BG; -extern struct SLineData LineData[240]; -extern struct SLineMatrixData LineMatrixData [240]; +extern SLineData LineData[240]; +extern SLineMatrixData LineMatrixData [240]; extern uint8 Mode7Depths [2]; @@ -584,7 +584,7 @@ void RenderLine (uint8 C) if (PPU.BGMode == 7) { - struct SLineMatrixData *p = &LineMatrixData [C]; + SLineMatrixData *p = &LineMatrixData [C]; p->MatrixA = PPU.MatrixA; p->MatrixB = PPU.MatrixB; p->MatrixC = PPU.MatrixC; @@ -677,7 +677,7 @@ void S9xSetInfoString (const char *string) { } -INLINE void SelectTileRenderer (bool8_32 normal) +static INLINE void SelectTileRenderer (bool8_32 normal) { if (normal) { @@ -2127,7 +2127,7 @@ inline void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) ClipCount = 1; \ \ Screen += GFX.StartY * GFX_PITCH; \ - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; \ + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; \ \ for (uint32 Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, l++) \ { \ @@ -2265,7 +2265,7 @@ inline void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) \ Screen += GFX.StartY * GFX_PITCH; \ uint8 *Depth = GFX.DB + GFX.StartY * GFX_PPL; \ - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; \ + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; \ \ for (uint32 Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) \ { \ @@ -2407,7 +2407,7 @@ inline void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) \ Screen += GFX.StartY * GFX_PITCH; \ uint8 *Depth = GFX.DB + GFX.StartY * GFX_PPL; \ - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; \ + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; \ \ for (uint32 Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) \ { \ @@ -2700,28 +2700,28 @@ void RenderScreen (uint8 *Screen, bool8_32 sub, bool8_32 force_no_add, uint8 D) { if (OB) { - SelectTileRenderer (sub || !SUB_OR_ADD(4)); + SelectTileRenderer (sub || !SUB_OR_ADD(4), false); DrawOBJS (!sub, D); } if (BG0) { - SelectTileRenderer (sub || !SUB_OR_ADD(0)); + SelectTileRenderer (sub || !SUB_OR_ADD(0), false); DrawBackground (PPU.BGMode, 0, D + 10, D + 14); } if (BG1) { - SelectTileRenderer (sub || !SUB_OR_ADD(1)); + SelectTileRenderer (sub || !SUB_OR_ADD(1), false); DrawBackground (PPU.BGMode, 1, D + 9, D + 13); } if (BG2) { - SelectTileRenderer (sub || !SUB_OR_ADD(2)); + SelectTileRenderer (sub || !SUB_OR_ADD(2), false); DrawBackground (PPU.BGMode, 2, D + 3, PPU.BG3Priority ? D + 17 : D + 6); } if (BG3 && PPU.BGMode == 0) { - SelectTileRenderer (sub || !SUB_OR_ADD(3)); + SelectTileRenderer (sub || !SUB_OR_ADD(3), false); DrawBackground (PPU.BGMode, 3, D + 2, D + 5); } } @@ -2729,17 +2729,17 @@ void RenderScreen (uint8 *Screen, bool8_32 sub, bool8_32 force_no_add, uint8 D) { if (OB) { - SelectTileRenderer (sub || !SUB_OR_ADD(4)); + SelectTileRenderer (sub || !SUB_OR_ADD(4), false); DrawOBJS (!sub, D); } if (BG0) { - SelectTileRenderer (sub || !SUB_OR_ADD(0)); + SelectTileRenderer (sub || !SUB_OR_ADD(0), false); DrawBackground (PPU.BGMode, 0, D + 5, D + 13); } if (PPU.BGMode != 6 && BG1) { - SelectTileRenderer (sub || !SUB_OR_ADD(1)); + SelectTileRenderer (sub || !SUB_OR_ADD(1), false); DrawBackground (PPU.BGMode, 1, D + 2, D + 9); } } @@ -2747,7 +2747,7 @@ void RenderScreen (uint8 *Screen, bool8_32 sub, bool8_32 force_no_add, uint8 D) { if (OB && ((SNESGameFixes.Mode7Hack && D) || !SNESGameFixes.Mode7Hack)) { - SelectTileRenderer (sub || !SUB_OR_ADD(4)); + SelectTileRenderer (sub || !SUB_OR_ADD(4), false); DrawOBJS (!sub, D); } if (BG0 || ((Memory.FillRAM [0x2133] & 0x40) && BG1)) @@ -2828,7 +2828,7 @@ void RenderScreen (uint8 *Screen, bool8_32 sub, bool8_32 force_no_add, uint8 D) } if (OB && SNESGameFixes.Mode7Hack && D==0) { - SelectTileRenderer (sub || !SUB_OR_ADD(4)); + SelectTileRenderer (sub || !SUB_OR_ADD(4), false); DrawOBJS (!sub, D); } @@ -2993,7 +2993,7 @@ void S9xUpdateScreen () // ~30-50ms! (called from FLUSH_REDRAW()) !((GFX.r2130 & 0x30) == 0x10 && IPPU.Clip[1].Count[5] == 0)) { // transparency effects in use, so lets get busy! - struct ClipData *pClip; + ClipData *pClip; uint32 fixedColour; GFX.FixedColour = BUILD_PIXEL (IPPU.XB [PPU.FixedColourRed], IPPU.XB [PPU.FixedColourGreen], @@ -3620,7 +3620,7 @@ else \ if (OB) { FIXCLIP(4); - DrawOBJS (); + DrawOBJS (FALSE, 0); } if (BG0) { @@ -3650,7 +3650,7 @@ else \ if (OB) { FIXCLIP(4); - DrawOBJS (); + DrawOBJS (FALSE, 0); } if (BG0) { @@ -3673,7 +3673,7 @@ else \ if (OB) { FIXCLIP(4); - DrawOBJS (); + DrawOBJS (FALSE, 0); } } } @@ -42,13 +42,14 @@ #define _GFX_H_ #include "port.h" +#include "ppu.h" #define GFX_PIXSIZE 1 #define GFX_PITCH 640 #define GFX_ZPITCH 320 #define GFX_PPL 320 -struct SGFX{ +typedef struct{ // Initialize these variables uint8 *Screen; uint8 *SubScreen; @@ -73,7 +74,7 @@ struct SGFX{ uint32 FixedColour; uint32 StartY; uint32 EndY; - struct ClipData *pCurrentClip; + ClipData *pCurrentClip; uint32 Mode7Mask; uint32 Mode7PriorityMask; @@ -99,20 +100,20 @@ struct SGFX{ uint32 (*BuildPixel2) (uint32 R, uint32 G, uint32 B); void (*DecomposePixel) (uint32 Pixel, uint32 &R, uint32 &G, uint32 &B); #endif -}; +}SGFX; -struct SLineData { +typedef struct { struct { uint16 VOffset; uint16 HOffset; } BG [4]; -}; +}SLineData; #define H_FLIP 0x4000 #define V_FLIP 0x8000 #define BLANK_TILE 2 -struct SBG +typedef struct { uint32 TileSize; uint32 BitShift; @@ -128,9 +129,9 @@ struct SBG uint8 *Buffer; uint8 *Buffered; bool8 DirectColourMode; -}; +}SBG; -struct SLineMatrixData +typedef struct { short MatrixA; short MatrixB; @@ -138,7 +139,7 @@ struct SLineMatrixData short MatrixD; short CentreX; short CentreY; -}; +}SLineMatrixData; extern uint32 odd_high [4][16]; extern uint32 odd_low [4][16]; @@ -249,7 +250,7 @@ START_EXTERN_C void S9xStartScreenRefresh (); void S9xDrawScanLine (uint8 Line); void S9xEndScreenRefresh (); -void S9xSetupOBJ (struct SOBJ *); +void S9xSetupOBJ (); void S9xUpdateScreen (); //extern void (*S9xUpdateScreen)(); //void SelectUpdateScreen(); @@ -258,7 +259,7 @@ void S9xBuildDirectColourMaps (); // External port interface which must be implemented or initialised for each // port. -extern struct SGFX GFX; +extern SGFX GFX; bool8_32 S9xGraphicsInit (); void S9xGraphicsDeinit(); diff --git a/src/gfx16.cpp b/src/gfx16.c index 3ac95ca..0012b78 100644 --- a/src/gfx16.cpp +++ b/src/gfx16.c @@ -119,10 +119,10 @@ extern NormalTileRenderer DrawHiResTilePtr; extern ClippedTileRenderer DrawHiResClippedTilePtr; extern LargePixelRenderer DrawLargePixelPtr; -extern struct SBG BG; +extern SBG BG; -extern struct SLineData LineData[240]; -extern struct SLineMatrixData LineMatrixData [240]; +extern SLineData LineData[240]; +extern SLineMatrixData LineMatrixData [240]; extern uint8 Mode7Depths [2]; @@ -603,7 +603,7 @@ void RenderLine (uint8 C) //if (PPU.BGMode == 7) if ((Memory.FillRAM[0x2105] & 7) == 7) { - struct SLineMatrixData *p = &LineMatrixData [C]; + SLineMatrixData *p = &LineMatrixData [C]; p->MatrixA = PPU.MatrixA; p->MatrixB = PPU.MatrixB; p->MatrixC = PPU.MatrixC; @@ -722,7 +722,7 @@ TileRendererSet TileRenderersNoZ[] = { {DrawNoZTile16, DrawClippedTile16, DrawLargePixel16} // 8 -> normal }; #endif -INLINE void SelectTileRenderer (bool8_32 normal, bool NoZ = false) +static INLINE void SelectTileRenderer (bool8_32 normal, bool NoZ) { if (normal) { TileRenderer = 8; @@ -843,7 +843,7 @@ void S9xSetupOBJ () IPPU.OBJChanged = FALSE; } -void DrawOBJS (bool8_32 OnMain = FALSE, uint8 D = 0) +void DrawOBJS (bool8_32 OnMain, uint8 D) { int bg_ta_ns; int bg_ta; @@ -1526,7 +1526,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) { #ifdef __DEBUG__ printf("DrawBackgroundMode5(?, %i, %i, %i)\n", bg, Z1, Z2); @@ -2190,7 +2190,7 @@ void DrawBackground_16 (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) } -inline void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) +static inline void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) { //StartAnalyze(); @@ -2550,7 +2550,7 @@ static void S9xUpdateScreenTransparency () // ~30-50ms! (called from FLUSH_REDRA { DBG("Transparency in use\n"); // transparency effects in use, so lets get busy! - struct ClipData *pClip; + ClipData *pClip; uint32 fixedColour; GFX.FixedColour = BUILD_PIXEL (IPPU.XB[PPU.FixedColourRed], IPPU.XB[PPU.FixedColourGreen] , IPPU.XB[PPU.FixedColourBlue]); fixedColour = (GFX.FixedColour<<16|GFX.FixedColour); @@ -2597,7 +2597,7 @@ static void S9xUpdateScreenTransparency () // ~30-50ms! (called from FLUSH_REDRA // the main screen that will allow the sub-screen // 'underneath' to show through. - asm volatile ( + __asm__ volatile ( " mov r0, %[fixedcolour] \n" " subs %[width], %[width], #8 \n" " bmi 2f \n" @@ -2665,7 +2665,7 @@ static void S9xUpdateScreenTransparency () // ~30-50ms! (called from FLUSH_REDRA { DBG("Copying from SubScreen to the Main Screen\n"); - asm volatile ( + __asm__ volatile ( "1: \n" " mov r1, #(256 >> 2) \n" @@ -2773,7 +2773,7 @@ static void S9xUpdateScreenTransparency () // ~30-50ms! (called from FLUSH_REDRA #define SUBSCREEN_BG(rop, half) \ \ -asm volatile (\ +__asm__ volatile (\ " ldrb r0, [%[d]] \n"\ "71: \n"\ \ @@ -2840,7 +2840,7 @@ _ROP_##rop##half \ // copy the sub-screen to the main screen // or fill it with the back-drop colour if the // sub-screen is clear. - asm volatile ( + __asm__ volatile ( " ldrb r0, [%[d]] \n" "31: \n" @@ -2898,7 +2898,7 @@ _ROP_##rop##half \ uint32 Left = pClip->Left [b][5]; uint32 Right = pClip->Right [b][5]; if (Left >= Right) continue; - asm volatile ( + __asm__ volatile ( " tst %[c], #1 \n" " bne 21f \n" @@ -2940,7 +2940,7 @@ _ROP_##rop##half \ { DBG("Copying SubScreen with no clipping...\n"); - asm volatile ( + __asm__ volatile ( "@ -- SubScreen clear \n" "1113: \n" " mov r1, #(256/8) \n" @@ -3032,7 +3032,7 @@ _ROP_##rop##half \ register int width = IPPU.Clip [0].Right [c][5] - IPPU.Clip [0].Left [c][5]; if (width <= 0) continue; - asm volatile ( + __asm__ volatile ( " mov r0, %[back] \n" " subs %[width], %[width], #8 \n" " bmi 2f \n" @@ -3168,7 +3168,7 @@ else \ if (OB) { FIXCLIP(4); - DrawOBJS (); + DrawOBJS (FALSE, 0); } if (BG0) { @@ -3198,7 +3198,7 @@ else \ if (OB) { FIXCLIP(4); - DrawOBJS (); + DrawOBJS (FALSE, 0); } if (BG0) { @@ -3218,7 +3218,7 @@ else \ if (OB) { FIXCLIP(4); - DrawOBJS (); + DrawOBJS (FALSE, 0); } } } diff --git a/src/globals.cpp b/src/globals.c index 9f9bbbd..89649cb 100644 --- a/src/globals.cpp +++ b/src/globals.c @@ -38,7 +38,7 @@ * Super NES and Super Nintendo Entertainment System are trademarks of * Nintendo Co., Limited and its subsidiary companies. */ - extern "C" { +// START_EXTERN_C #include "snes9x.h" #include "memmap.h" #include "ppu.h" @@ -52,34 +52,35 @@ #include "soundux.h" #include "cheats.h" #include "sa1.h" - } +// END_EXTERN_C + START_EXTERN_C char String[513]; int (*APUMainLoop)(int); -struct Missing missing; +Missing missing; -struct SICPU ICPU; +SICPU ICPU; -struct SCPUState CPU; +SCPUState CPU; -//struct SRegisters Registers; +//SRegisters Registers; -struct SAPU APU; +SAPU APU; -struct SIAPU IAPU; +SIAPU IAPU; -struct SAPURegisters APURegisters; +SAPURegisters APURegisters; -struct SSettings Settings; +SSettings Settings; -struct SDSP1 DSP1; +SDSP1 DSP1; #ifdef USE_SA1 -struct SSA1Registers SA1Registers; +SSA1Registers SA1Registers; -struct SSA1 SA1; +SSA1 SA1; uint8 *SA1_Map [MEMMAP_NUM_BLOCKS]; uint8 *SA1_WriteMap [MEMMAP_NUM_BLOCKS]; @@ -94,31 +95,31 @@ long OpAddress = 0; CMemory Memory; -struct SSNESGameFixes SNESGameFixes; +SSNESGameFixes SNESGameFixes; END_EXTERN_C #ifndef ZSNES_FX -struct FxInit_s SuperFX; +FxInit_s SuperFX; #else START_EXTERN_C uint8 *SFXPlotTable = NULL; END_EXTERN_C #endif -struct SPPU PPU; -struct InternalPPU IPPU; +SPPU PPU; +InternalPPU IPPU; -struct SDMA DMA[8]; +SDMA DMA[8]; uint8 *HDMAMemPointers [8]; uint8 *HDMABasePointers [8]; -struct SBG BG; +SBG BG; -struct SGFX GFX; -struct SLineData LineData[240]; -struct SLineMatrixData LineMatrixData [240]; +SGFX GFX; +SLineData LineData[240]; +SLineMatrixData LineMatrixData [240]; uint8 Mode7Depths [2]; NormalTileRenderer DrawTilePtr = NULL; @@ -167,7 +168,7 @@ uint32 current_graphic_format = RGB565; #endif uint8 GetBank = 0; -struct SCheatData Cheat; +SCheatData Cheat; SoundStatus so; SSoundData SoundData; @@ -288,7 +289,7 @@ uint8 APUROM [64] = }; #ifdef NETPLAY_SUPPORT -struct SNetPlay NetPlay; +SNetPlay NetPlay; #endif // Raw SPC700 instruction cycle lengths diff --git a/src/memmap.c b/src/memmap.c new file mode 100644 index 0000000..df5dec1 --- /dev/null +++ b/src/memmap.c @@ -0,0 +1,2759 @@ +/*
+ * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
+ *
+ * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
+ * Jerremy Koot (jkoot@snes9x.com)
+ *
+ * Super FX C emulator code
+ * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
+ * Gary Henderson.
+ * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
+ *
+ * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson.
+ * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_.
+ * C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com).
+ *
+ * DOS port code contains the works of other authors. See headers in
+ * individual files.
+ *
+ * Snes9x homepage: http://www.snes9x.com
+ *
+ * Permission to use, copy, modify and distribute Snes9x in both binary and
+ * source form, for non-commercial purposes, is hereby granted without fee,
+ * providing that this license information and copyright notice appear with
+ * all copies and any derived work.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event shall the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Snes9x is freeware for PERSONAL USE only. Commercial users should
+ * seek permission of the copyright holders first. Commercial use includes
+ * charging money for Snes9x or software derived from Snes9x.
+ *
+ * The copyright holders request that bug fixes and improvements to the code
+ * should be forwarded to them so everyone can benefit from the modifications
+ * in future versions.
+ *
+ * Super NES and Super Nintendo Entertainment System are trademarks of
+ * Nintendo Co., Limited and its subsidiary companies.
+ */
+#include <string.h>
+#include <ctype.h>
+
+#ifdef __linux
+//#include <unistd.h>
+#endif
+
+#include "snes9x.h"
+#include "memmap.h"
+#include "cpuexec.h"
+#include "ppu.h"
+#include "display.h"
+#include "cheats.h"
+#include "apu.h"
+#include "sa1.h"
+#include "srtc.h"
+#include "sdd1.h"
+
+#ifndef ZSNES_FX
+#include "fxemu.h"
+extern FxInit_s SuperFX;
+#else
+START_EXTERN_C
+extern uint8 *SFXPlotTable;
+END_EXTERN_C
+#endif
+
+static uint8 bytes0x2000 [0x2000];
+
+extern bool8 ROMAPUEnabled;
+
+extern char *rom_filename;
+extern bool8 LoadZip(const char* , int32 *, int32 *);
+
+bool8_32 AllASCII (uint8 *b, int size)
+{
+ for (int i = 0; i < size; i++)
+ {
+ if (b[i] < 32 || b[i] > 126)
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+int ScoreHiROM (bool8_32 skip_header)
+{
+ int score = 0;
+ int o = skip_header ? 0xff00 + 0x200 : 0xff00;
+
+ if ((Memory.ROM [o + 0xdc] + (Memory.ROM [o + 0xdd] << 8) +
+ Memory.ROM [o + 0xde] + (Memory.ROM [o + 0xdf] << 8)) == 0xffff)
+ score += 2;
+
+ if (Memory.ROM [o + 0xda] == 0x33)
+ score += 2;
+ if ((Memory.ROM [o + 0xd5] & 0xf) < 4)
+ score += 2;
+ if (!(Memory.ROM [o + 0xfd] & 0x80))
+ score -= 4;
+ if (Memory.CalculatedSize > 1024 * 1024 * 3)
+ score += 4;
+ if ((1 << (Memory.ROM [o + 0xd7] - 7)) > 48)
+ score -= 1;
+ if (!AllASCII (&Memory.ROM [o + 0xb0], 6))
+ score -= 1;
+ if (!AllASCII (&Memory.ROM [o + 0xc0], ROM_NAME_LEN - 1))
+ score -= 1;
+
+ return (score);
+}
+
+int ScoreLoROM (bool8_32 skip_header)
+{
+ int score = 0;
+ int o = skip_header ? 0x7f00 + 0x200 : 0x7f00;
+
+ if ((Memory.ROM [o + 0xdc] + (Memory.ROM [o + 0xdd] << 8) +
+ Memory.ROM [o + 0xde] + (Memory.ROM [o + 0xdf] << 8)) == 0xffff)
+ score += 2;
+
+ if (Memory.ROM [o + 0xda] == 0x33)
+ score += 2;
+ if ((Memory.ROM [o + 0xd5] & 0xf) < 4)
+ score += 2;
+ if (Memory.CalculatedSize <= 1024 * 1024 * 16)
+ score += 2;
+ if (!(Memory.ROM [o + 0xfd] & 0x80))
+ score -= 4;
+ if ((1 << (Memory.ROM [o + 0xd7] - 7)) > 48)
+ score -= 1;
+ if (!AllASCII (&Memory.ROM [o + 0xb0], 6))
+ score -= 1;
+ if (!AllASCII (&Memory.ROM [o + 0xc0], ROM_NAME_LEN - 1))
+ score -= 1;
+
+ return (score);
+}
+
+char *Safe (const char *s)
+{
+ static char *safe = NULL;
+ static int safe_len = 0;
+
+ int len = strlen (s);
+ if (!safe || len + 1 > safe_len)
+ {
+ if (safe)
+ free ((char *) safe);
+ safe = (char *) malloc (safe_len = len + 1);
+ }
+
+ for (int i = 0; i < len; i++)
+ {
+ if (s [i] >= 32 && s [i] < 127)
+ safe [i] = s[i];
+ else
+ safe [i] = '?';
+ }
+ safe [len] = 0;
+ return (safe);
+}
+
+/**********************************************************************************************/
+/* Init() */
+/* This function allocates all the memory needed by the emulator */
+/**********************************************************************************************/
+bool8_32 MemoryInit ()
+{
+ Memory.RAM = (uint8 *) malloc (0x20000);
+ Memory.SRAM = (uint8 *) malloc (0x20000);
+ Memory.VRAM = (uint8 *) malloc (0x10000);
+ Memory.ROM = (uint8 *) malloc (MAX_ROM_SIZE + 0x200 + 0x8000);
+ Memory.FillRAM = NULL;
+
+ IPPU.TileCache [TILE_2BIT] = (uint8 *) malloc (MAX_2BIT_TILES * 128);
+ IPPU.TileCache [TILE_4BIT] = (uint8 *) malloc (MAX_4BIT_TILES * 128);
+ IPPU.TileCache [TILE_8BIT] = (uint8 *) malloc (MAX_8BIT_TILES * 128);
+
+ IPPU.TileCached [TILE_2BIT] = (uint8 *) malloc (MAX_2BIT_TILES);
+ IPPU.TileCached [TILE_4BIT] = (uint8 *) malloc (MAX_4BIT_TILES);
+ IPPU.TileCached [TILE_8BIT] = (uint8 *) malloc (MAX_8BIT_TILES);
+
+ if (!Memory.RAM || !Memory.SRAM || !Memory.VRAM || !Memory.ROM ||
+ !IPPU.TileCache [TILE_2BIT] || !IPPU.TileCache [TILE_4BIT] ||
+ !IPPU.TileCache [TILE_8BIT] || !IPPU.TileCached [TILE_2BIT] ||
+ !IPPU.TileCached [TILE_4BIT] || !IPPU.TileCached [TILE_8BIT])
+ {
+ MemoryDeinit ();
+ return (FALSE);
+ }
+
+ // FillRAM uses first 32K of ROM image area, otherwise space just
+ // wasted. Might be read by the SuperFX code.
+
+ Memory.FillRAM = Memory.ROM;
+
+ // Add 0x8000 to ROM image pointer to stop SuperFX code accessing
+ // unallocated memory (can cause crash on some ports).
+ Memory.ROM += 0x8000;
+
+ Memory.C4RAM = Memory.ROM + 0x400000 + 8192 * 8;
+ ROM = Memory.ROM;
+ SRAM = Memory.SRAM;
+ RegRAM = Memory.FillRAM;
+
+#ifdef ZSNES_FX
+ SFXPlotTable = ROM + 0x400000;
+#else
+ SuperFX.pvRegisters = &Memory.FillRAM [0x3000];
+ SuperFX.nRamBanks = 1;
+ SuperFX.pvRam = SRAM;
+ SuperFX.nRomBanks = (2 * 1024 * 1024) / (32 * 1024);
+ SuperFX.pvRom = (uint8 *) Memory.ROM;
+#endif
+
+ ZeroMemory (IPPU.TileCached [TILE_2BIT], MAX_2BIT_TILES);
+ ZeroMemory (IPPU.TileCached [TILE_4BIT], MAX_4BIT_TILES);
+ ZeroMemory (IPPU.TileCached [TILE_8BIT], MAX_8BIT_TILES);
+
+ Memory.SDD1Data = NULL;
+ Memory.SDD1Index = NULL;
+
+ return (TRUE);
+}
+
+void MemoryDeinit ()
+{
+ if (Memory.RAM)
+ {
+ free ((char *) Memory.RAM);
+ Memory.RAM = NULL;
+ }
+ if (Memory.SRAM)
+ {
+ free ((char *) Memory.SRAM);
+ Memory.SRAM = NULL;
+ }
+ if (Memory.VRAM)
+ {
+ free ((char *) Memory.VRAM);
+ Memory.VRAM = NULL;
+ }
+ if (Memory.ROM)
+ {
+ Memory.ROM -= 0x8000;
+ free ((char *) Memory.ROM);
+ Memory.ROM = NULL;
+ }
+
+ if (IPPU.TileCache [TILE_2BIT])
+ {
+ free ((char *) IPPU.TileCache [TILE_2BIT]);
+ IPPU.TileCache [TILE_2BIT] = NULL;
+ }
+ if (IPPU.TileCache [TILE_4BIT])
+ {
+ free ((char *) IPPU.TileCache [TILE_4BIT]);
+ IPPU.TileCache [TILE_4BIT] = NULL;
+ }
+ if (IPPU.TileCache [TILE_8BIT])
+ {
+ free ((char *) IPPU.TileCache [TILE_8BIT]);
+ IPPU.TileCache [TILE_8BIT] = NULL;
+ }
+
+ if (IPPU.TileCached [TILE_2BIT])
+ {
+ free ((char *) IPPU.TileCached [TILE_2BIT]);
+ IPPU.TileCached [TILE_2BIT] = NULL;
+ }
+ if (IPPU.TileCached [TILE_4BIT])
+ {
+ free ((char *) IPPU.TileCached [TILE_4BIT]);
+ IPPU.TileCached [TILE_4BIT] = NULL;
+ }
+ if (IPPU.TileCached [TILE_8BIT])
+ {
+ free ((char *) IPPU.TileCached [TILE_8BIT]);
+ IPPU.TileCached [TILE_8BIT] = NULL;
+ }
+
+ FreeSDD1Data ();
+}
+
+void FreeSDD1Data ()
+{
+ if (Memory.SDD1Index)
+ {
+ free ((char *) Memory.SDD1Index);
+ Memory.SDD1Index = NULL;
+ }
+ if (Memory.SDD1Data)
+ {
+ free ((char *) Memory.SDD1Data);
+ Memory.SDD1Data = NULL;
+ }
+}
+
+/**********************************************************************************************/
+/* checkext() */
+/**********************************************************************************************/
+int checkzip( char * fn )
+{
+ int cnt = strlen(fn);
+ if( ( (fn[cnt-1] == 'p') || (fn[cnt-1] == 'P') ) &&
+ ( (fn[cnt-2] == 'i') || (fn[cnt-2] == 'I') ) &&
+ ( (fn[cnt-3] == 'z') || (fn[cnt-3] == 'Z') ) ){
+ return true;
+
+ }
+ return false;
+}
+
+/**********************************************************************************************/
+/* LoadROM() */
+/* This function loads a Snes-Backup image */
+/**********************************************************************************************/
+bool8_32 LoadROM (const char *filename)
+{
+ unsigned long FileSize = 0;
+ int retry_count = 0;
+ STREAM ROMFile;
+ bool8_32 Interleaved = FALSE;
+ bool8_32 Tales = FALSE;
+ char dir [_MAX_DIR + 1];
+ char drive [_MAX_DRIVE + 1];
+ char name [_MAX_FNAME + 1];
+ char ext [_MAX_EXT + 1];
+ char fname [_MAX_PATH + 1];
+ int i;
+
+ memset (&SNESGameFixes, 0, sizeof(SNESGameFixes));
+ SNESGameFixes.SRAMInitialValue = 0x60;
+
+ memset (bytes0x2000, 0, 0x2000);
+ CPU.TriedInterleavedMode2 = FALSE;
+
+ Memory.CalculatedSize = 0;
+again:
+ _splitpath (filename, drive, dir, name, ext);
+ _makepath (fname, drive, dir, name, ext);
+
+#ifdef __WIN32__
+ memmove (&ext [0], &ext[1], 4);
+#endif
+
+ int32 TotalFileSize = 0;
+
+ {
+ if ((ROMFile = OPEN_STREAM (fname, "rb")) == NULL)
+ return (FALSE);
+
+ strcpy (Memory.ROMFilename, fname);
+
+ Memory.HeaderCount = 0;
+ uint8 *ptr = Memory.ROM;
+ bool8_32 more = FALSE;
+
+ do
+ {
+ FileSize = READ_STREAM (ptr, MAX_ROM_SIZE + 0x200 - (ptr - Memory.ROM), ROMFile);
+ CLOSE_STREAM (ROMFile);
+ int calc_size = (FileSize / 0x2000) * 0x2000;
+
+ if ((FileSize - calc_size == 512 && !Settings.ForceNoHeader) ||
+ Settings.ForceHeader)
+ {
+ memmove (ptr, ptr + 512, calc_size);
+ Memory.HeaderCount++;
+ FileSize -= 512;
+ }
+ ptr += FileSize;
+ TotalFileSize += FileSize;
+
+ int len;
+ if (ptr - Memory.ROM < MAX_ROM_SIZE + 0x200 &&
+ (isdigit (ext [0]) && ext [1] == 0 && ext [0] < '9'))
+ {
+ more = TRUE;
+ ext [0]++;
+#ifdef __WIN32__
+ memmove (&ext [1], &ext [0], 4);
+ ext [0] = '.';
+#endif
+ _makepath (fname, drive, dir, name, ext);
+ }
+ else
+ if (ptr - Memory.ROM < MAX_ROM_SIZE + 0x200 &&
+ (((len = strlen (name)) == 7 || len == 8) &&
+ strncasecmp (name, "sf", 2) == 0 &&
+ isdigit (name [2]) && isdigit (name [3]) && isdigit (name [4]) &&
+ isdigit (name [5]) && isalpha (name [len - 1])))
+ {
+ more = TRUE;
+ name [len - 1]++;
+#ifdef __WIN32__
+ memmove (&ext [1], &ext [0], 4);
+ ext [0] = '.';
+#endif
+ _makepath (fname, drive, dir, name, ext);
+ }
+ else
+ more = FALSE;
+ } while (more && (ROMFile = OPEN_STREAM (fname, "rb")) != NULL);
+ }
+
+ if (Memory.HeaderCount == 0)
+ S9xMessage (S9X_INFO, S9X_HEADERS_INFO, "No ROM file header found.");
+ else
+ {
+ if (Memory.HeaderCount == 1)
+ S9xMessage (S9X_INFO, S9X_HEADERS_INFO,
+ "Found ROM file header (and ignored it).");
+ else
+ S9xMessage (S9X_INFO, S9X_HEADERS_INFO,
+ "Found multiple ROM file headers (and ignored them).");
+ }
+
+ CheckForIPSPatch (filename, Memory.HeaderCount != 0, &TotalFileSize);
+ int orig_hi_score, orig_lo_score;
+ int hi_score, lo_score;
+
+ orig_hi_score = hi_score = ScoreHiROM (FALSE);
+ orig_lo_score = lo_score = ScoreLoROM (FALSE);
+
+ if (Memory.HeaderCount == 0 && !Settings.ForceNoHeader &&
+ ((hi_score > lo_score && ScoreHiROM (TRUE) > hi_score) ||
+ (hi_score <= lo_score && ScoreLoROM (TRUE) > lo_score)))
+ {
+ memmove (Memory.ROM, Memory.ROM + 512, TotalFileSize - 512);
+ TotalFileSize -= 512;
+ S9xMessage (S9X_INFO, S9X_HEADER_WARNING,
+ "Try specifying the -nhd command line option if the game doesn't work\n");
+ }
+
+ Memory.CalculatedSize = (TotalFileSize / 0x2000) * 0x2000;
+ ZeroMemory (Memory.ROM + Memory.CalculatedSize, MAX_ROM_SIZE - Memory.CalculatedSize);
+
+ // Check for cherryroms.com DAIKAIJYUMONOGATARI2
+
+ if (Memory.CalculatedSize == 0x500000 &&
+ strncmp ((const char *)&Memory.ROM [0x40ffc0], "DAIKAIJYUMONOGATARI2", 20) == 0 &&
+ strncmp ((const char *)&Memory.ROM [0x40ffb0], "18AE6J", 6) == 0 &&
+ memcmp (&Memory.ROM[0x40ffb0], &Memory.ROM [0xffb0], 0x30))
+ {
+ memmove (&Memory.ROM[0x100000], Memory.ROM, 0x500000);
+ memmove (Memory.ROM, &Memory.ROM[0x500000], 0x100000);
+ }
+
+ Interleaved = Settings.ForceInterleaved || Settings.ForceInterleaved2;
+ if (Settings.ForceLoROM || (!Settings.ForceHiROM && lo_score >= hi_score))
+ {
+ Memory.LoROM = TRUE;
+ Memory.HiROM = FALSE;
+
+ // Ignore map type byte if not 0x2x or 0x3x
+ if ((Memory.ROM [0x7fd5] & 0xf0) == 0x20 || (Memory.ROM [0x7fd5] & 0xf0) == 0x30)
+ {
+ switch (Memory.ROM [0x7fd5] & 0xf)
+ {
+ case 1:
+ if (strncmp ((char *) &Memory.ROM [0x7fc0], "TREASURE HUNTER G", 17) != 0)
+ Interleaved = TRUE;
+ break;
+ case 2:
+#if 0
+ if (!Settings.ForceLoROM &&
+ strncmp ((char *) &ROM [0x7fc0], "SUPER FORMATION SOCCE", 21) != 0 &&
+ strncmp ((char *) &ROM [0x7fc0], "Star Ocean", 10) != 0)
+ {
+ LoROM = FALSE;
+ HiROM = TRUE;
+ }
+#endif
+ break;
+ case 5:
+ Interleaved = TRUE;
+ Tales = TRUE;
+ break;
+ }
+ }
+ }
+ else
+ {
+ if ((Memory.ROM [0xffd5] & 0xf0) == 0x20 || (Memory.ROM [0xffd5] & 0xf0) == 0x30)
+ {
+ switch (Memory.ROM [0xffd5] & 0xf)
+ {
+ case 0:
+ case 3:
+ Interleaved = TRUE;
+ break;
+ }
+ }
+ Memory.LoROM = FALSE;
+ Memory.HiROM = TRUE;
+ }
+
+ // More
+ if (!Settings.ForceHiROM && !Settings.ForceLoROM &&
+ !Settings.ForceInterleaved && !Settings.ForceInterleaved2 &&
+ !Settings.ForceNotInterleaved && !Settings.ForcePAL &&
+ !Settings.ForceSuperFX && !Settings.ForceDSP1 &&
+ !Settings.ForceSA1 && !Settings.ForceC4 &&
+ !Settings.ForceSDD1)
+ {
+ if (strncmp ((char *) &Memory.ROM [0x7fc0], "YUYU NO QUIZ DE GO!GO!", 22) == 0)
+ {
+ Memory.LoROM = TRUE;
+ Memory.HiROM = FALSE;
+ Interleaved = FALSE;
+ }
+ else
+ if (strncmp ((char *) &Memory.ROM [0x7fc0], "SP MOMOTAROU DENTETSU2", 22) == 0)
+ {
+ Memory.LoROM = TRUE;
+ Memory.HiROM = FALSE;
+ Interleaved = FALSE;
+ }
+ else
+ if (Memory.CalculatedSize == 0x100000 &&
+ strncmp ((char *) &Memory.ROM [0xffc0], "WWF SUPER WRESTLEMANIA", 22) == 0)
+ {
+ int cvcount;
+
+ memmove (&Memory.ROM[0x100000] , Memory.ROM, 0x100000);
+ for (cvcount = 0; cvcount < 16; cvcount++)
+ {
+ memmove (&Memory.ROM[0x8000 * cvcount], &Memory.ROM[0x10000 * cvcount + 0x100000 + 0x8000], 0x8000);
+ memmove (&Memory.ROM[0x8000 * cvcount + 0x80000], &Memory.ROM[0x10000 * cvcount + 0x100000], 0x8000);
+ }
+ Memory.LoROM = TRUE;
+ Memory.HiROM = FALSE;
+ ZeroMemory (Memory.ROM + Memory.CalculatedSize, MAX_ROM_SIZE - Memory.CalculatedSize);
+ }
+ }
+
+ if (!Settings.ForceNotInterleaved && Interleaved)
+ {
+ CPU.TriedInterleavedMode2 = TRUE;
+ S9xMessage (S9X_INFO, S9X_ROM_INTERLEAVED_INFO,
+ "ROM image is in interleaved format - converting...");
+
+ int nblocks = Memory.CalculatedSize >> 16;
+#if 0
+ int step = 64;
+
+ while (nblocks <= step)
+ step >>= 1;
+
+ nblocks = step;
+#endif
+ uint8 blocks [256];
+
+ if (Tales)
+ {
+ nblocks = 0x60;
+ for (i = 0; i < 0x40; i += 2)
+ {
+ blocks [i + 0] = (i >> 1) + 0x20;
+ blocks [i + 1] = (i >> 1) + 0x00;
+ }
+ for (i = 0; i < 0x80; i += 2)
+ {
+ blocks [i + 0x40] = (i >> 1) + 0x80;
+ blocks [i + 0x41] = (i >> 1) + 0x40;
+ }
+ Memory.LoROM = FALSE;
+ Memory.HiROM = TRUE;
+ }
+ else
+ if (Settings.ForceInterleaved2)
+ {
+ for (i = 0; i < nblocks * 2; i++)
+ {
+ blocks [i] = (i & ~0x1e) | ((i & 2) << 2) | ((i & 4) << 2) |
+ ((i & 8) >> 2) | ((i & 16) >> 2);
+ }
+ }
+ else
+ {
+ bool8_32 t = Memory.LoROM;
+
+ Memory.LoROM = Memory.HiROM;
+ Memory.HiROM = t;
+
+ for (i = 0; i < nblocks; i++)
+ {
+ blocks [i * 2] = i + nblocks;
+ blocks [i * 2 + 1] = i;
+ }
+ }
+
+ uint8 *tmp = (uint8 *) malloc (0x8000);
+ if (tmp)
+ {
+ for (i = 0; i < nblocks * 2; i++)
+ {
+ for (int j = i; j < nblocks * 2; j++)
+ {
+ if (blocks [j] == i)
+ {
+ memmove (tmp, &Memory.ROM [blocks [j] * 0x8000], 0x8000);
+ memmove (&Memory.ROM [blocks [j] * 0x8000],
+ &Memory.ROM [blocks [i] * 0x8000], 0x8000);
+ memmove (&Memory.ROM [blocks [i] * 0x8000], tmp, 0x8000);
+ uint8 b = blocks [j];
+ blocks [j] = blocks [i];
+ blocks [i] = b;
+ break;
+ }
+ }
+ }
+ free ((char *) tmp);
+ }
+
+ hi_score = ScoreHiROM (FALSE);
+ lo_score = ScoreLoROM (FALSE);
+
+ if ((Memory.HiROM &&
+ (lo_score >= hi_score || hi_score < 0)) ||
+ (Memory.LoROM &&
+ (hi_score > lo_score || lo_score < 0)))
+ {
+ if (retry_count == 0)
+ {
+ S9xMessage (S9X_INFO, S9X_ROM_CONFUSING_FORMAT_INFO,
+ "ROM lied about its type! Trying again.");
+ Settings.ForceNotInterleaved = TRUE;
+ Settings.ForceInterleaved = FALSE;
+ retry_count++;
+ goto again;
+ }
+ }
+ }
+ FreeSDD1Data ();
+ InitROM (Tales);
+
+ S9xLoadCheatFile (S9xGetFilename(".cht"));
+ S9xInitCheatData ();
+ S9xApplyCheats ();
+
+ S9xReset ();
+
+ return (TRUE);
+}
+
+void S9xDeinterleaveMode2 ()
+{
+ S9xMessage (S9X_INFO, S9X_ROM_INTERLEAVED_INFO,
+ "ROM image is in interleaved format - converting...");
+
+ int nblocks = Memory.CalculatedSize >> 15;
+ int step = 64;
+
+ while (nblocks <= step)
+ step >>= 1;
+
+ nblocks = step;
+ uint8 blocks [256];
+ int i;
+
+ for (i = 0; i < nblocks * 2; i++)
+ {
+ blocks [i] = (i & ~0x1e) | ((i & 2) << 2) | ((i & 4) << 2) |
+ ((i & 8) >> 2) | ((i & 16) >> 2);
+ }
+
+ uint8 *tmp = (uint8 *) malloc (0x8000);
+
+ if (tmp)
+ {
+ for (i = 0; i < nblocks * 2; i++)
+ {
+ for (int j = i; j < nblocks * 2; j++)
+ {
+ if (blocks [j] == i)
+ {
+ memmove (tmp, &Memory.ROM [blocks [j] * 0x8000], 0x8000);
+ memmove (&Memory.ROM [blocks [j] * 0x8000],
+ &Memory.ROM [blocks [i] * 0x8000], 0x8000);
+ memmove (&Memory.ROM [blocks [i] * 0x8000], tmp, 0x8000);
+ uint8 b = blocks [j];
+ blocks [j] = blocks [i];
+ blocks [i] = b;
+ break;
+ }
+ }
+ }
+ free ((char *) tmp);
+ }
+ InitROM (FALSE);
+ S9xReset ();
+}
+
+void InitROM (bool8_32 Interleaved)
+{
+#ifndef ZSNES_FX
+ SuperFX.nRomBanks = Memory.CalculatedSize >> 15;
+#endif
+ Settings.MultiPlayer5Master = Settings.MultiPlayer5;
+ Settings.MouseMaster = Settings.Mouse;
+ Settings.SuperScopeMaster = Settings.SuperScope;
+ Settings.DSP1Master = Settings.ForceDSP1;
+ Settings.SuperFX = FALSE;
+ Settings.SA1 = FALSE;
+ Settings.C4 = FALSE;
+ Settings.SDD1 = FALSE;
+ Settings.SRTC = FALSE;
+
+ ZeroMemory (Memory.BlockIsRAM, MEMMAP_NUM_BLOCKS);
+ ZeroMemory (Memory.BlockIsROM, MEMMAP_NUM_BLOCKS);
+
+ SRAM = Memory.SRAM;
+ memset (Memory.ROMId, 0, 5);
+ memset (Memory.CompanyId, 0, 3);
+
+ if (Memory.HiROM)
+ {
+ Memory.SRAMSize = Memory.ROM [0xffd8];
+ strncpy (Memory.ROMName, (char *) &Memory.ROM[0xffc0], ROM_NAME_LEN - 1);
+ Memory.ROMSpeed = Memory.ROM [0xffd5];
+ Memory.ROMType = Memory.ROM [0xffd6];
+ Memory.ROMSize = Memory.ROM [0xffd7];
+ Memory.ROMChecksum = Memory.ROM [0xffde] + (Memory.ROM [0xffdf] << 8);
+ Memory.ROMComplementChecksum = Memory.ROM [0xffdc] + (Memory.ROM [0xffdd] << 8);
+
+ memmove (Memory.ROMId, &Memory.ROM [0xffb2], 4);
+ memmove (Memory.CompanyId, &Memory.ROM [0xffb0], 2);
+
+ // Try to auto-detect the DSP1 chip
+ if (!Settings.ForceNoDSP1 &&
+ (Memory.ROMType & 0xf) >= 3 && (Memory.ROMType & 0xf0) == 0)
+ Settings.DSP1Master = TRUE;
+
+ Settings.SDD1 = Settings.ForceSDD1;
+ if ((Memory.ROMType & 0xf0) == 0x40)
+ Settings.SDD1 = !Settings.ForceNoSDD1;
+
+ if (Settings.BS)
+ BSHiROMMap ();
+ else
+ if ((Memory.ROMSpeed & ~0x10) == 0x25)
+ TalesROMMap (Interleaved);
+ else
+ if ((Memory.ROMSpeed & ~0x10) == 0x22 &&
+ strncmp (Memory.ROMName, "Super Street Fighter", 20) != 0)
+ {
+ AlphaROMMap ();
+ }
+ else
+ HiROMMap ();
+ }
+ else
+ {
+ Memory.HiROM = FALSE;
+ Memory.SRAMSize = Memory.ROM [0x7fd8];
+ Memory.ROMSpeed = Memory.ROM [0x7fd5];
+ Memory.ROMType = Memory.ROM [0x7fd6];
+ Memory.ROMSize = Memory.ROM [0x7fd7];
+ Memory.ROMChecksum = Memory.ROM [0x7fde] + (Memory.ROM [0x7fdf] << 8);
+ Memory.ROMComplementChecksum = Memory.ROM [0x7fdc] + (Memory.ROM [0x7fdd] << 8);
+ memmove (Memory.ROMId, &Memory.ROM [0x7fb2], 4);
+ memmove (Memory.CompanyId, &Memory.ROM [0x7fb0], 2);
+
+ strncpy (Memory.ROMName, (char *) &Memory.ROM[0x7fc0], ROM_NAME_LEN - 1);
+ Settings.SuperFX = Settings.ForceSuperFX;
+
+ if ((Memory.ROMType & 0xf0) == 0x10)
+ Settings.SuperFX = !Settings.ForceNoSuperFX;
+
+ // Try to auto-detect the DSP1 chip
+ if (!Settings.ForceNoDSP1 &&
+ (Memory.ROMType & 0xf) >= 3 && (Memory.ROMType & 0xf0) == 0)
+ Settings.DSP1Master = TRUE;
+
+ Settings.SDD1 = Settings.ForceSDD1;
+ if ((Memory.ROMType & 0xf0) == 0x40)
+ Settings.SDD1 = !Settings.ForceNoSDD1;
+
+ if (Settings.SDD1)
+ S9xLoadSDD1Data ();
+
+ Settings.C4 = Settings.ForceC4;
+ if ((Memory.ROMType & 0xf0) == 0xf0 &&
+ (strncmp (Memory.ROMName, "MEGAMAN X", 9) == 0 ||
+ strncmp (Memory.ROMName, "ROCKMAN X", 9) == 0))
+ {
+ Settings.C4 = !Settings.ForceNoC4;
+ }
+
+ if (Settings.SuperFX)
+ {
+ //SRAM = ROM + 1024 * 1024 * 4;
+ SuperFXROMMap ();
+ Settings.MultiPlayer5Master = FALSE;
+ //Settings.MouseMaster = FALSE;
+ //Settings.SuperScopeMaster = FALSE;
+ Settings.DSP1Master = FALSE;
+ Settings.SA1 = FALSE;
+ Settings.C4 = FALSE;
+ Settings.SDD1 = FALSE;
+ }
+ else
+ if (Settings.ForceSA1 ||
+ (!Settings.ForceNoSA1 && (Memory.ROMSpeed & ~0x10) == 0x23 &&
+ (Memory.ROMType & 0xf) > 3 && (Memory.ROMType & 0xf0) == 0x30))
+ {
+ Settings.SA1 = TRUE;
+ Settings.MultiPlayer5Master = FALSE;
+ //Settings.MouseMaster = FALSE;
+ //Settings.SuperScopeMaster = FALSE;
+ Settings.DSP1Master = FALSE;
+ Settings.C4 = FALSE;
+ Settings.SDD1 = FALSE;
+ SA1ROMMap ();
+ }
+ else
+ if ((Memory.ROMSpeed & ~0x10) == 0x25)
+ TalesROMMap (Interleaved);
+ else
+ if (strncmp ((char *) &Memory.ROM [0x7fc0], "SOUND NOVEL-TCOOL", 17) == 0 ||
+ strncmp ((char *) &Memory.ROM [0x7fc0], "DERBY STALLION 96", 17) == 0)
+ {
+ LoROM24MBSMap ();
+ Settings.DSP1Master = FALSE;
+ }
+ else
+ if (strncmp ((char *) &Memory.ROM [0x7fc0], "THOROUGHBRED BREEDER3", 21) == 0 ||
+ strncmp ((char *) &Memory.ROM [0x7fc0], "RPG-TCOOL 2", 11) == 0)
+ {
+ SRAM512KLoROMMap ();
+ Settings.DSP1Master = FALSE;
+ }
+ else
+ if (strncmp ((char *) &Memory.ROM [0x7fc0], "DEZAEMON ", 10) == 0)
+ {
+ Settings.DSP1Master = FALSE;
+ SRAM1024KLoROMMap ();
+ }
+ else
+ if (strncmp ((char *) &Memory.ROM [0x7fc0], "ADD-ON BASE CASSETE", 19) == 0)
+ {
+ Settings.MultiPlayer5Master = FALSE;
+ Settings.MouseMaster = FALSE;
+ Settings.SuperScopeMaster = FALSE;
+ Settings.DSP1Master = FALSE;
+ SufamiTurboLoROMMap();
+ Memory.SRAMSize = 3;
+ }
+ else
+ if ((Memory.ROMSpeed & ~0x10) == 0x22 &&
+ strncmp (Memory.ROMName, "Super Street Fighter", 20) != 0)
+ {
+ AlphaROMMap ();
+ }
+ else
+ LoROMMap ();
+ }
+
+ int power2 = 0;
+ int size = Memory.CalculatedSize;
+
+ while (size >>= 1)
+ power2++;
+
+ size = 1 << power2;
+ uint32 remainder = Memory.CalculatedSize - size;
+
+ uint32 sum1 = 0;
+ uint32 sum2 = 0;
+
+ int i;
+
+ for (i = 0; i < size; i++)
+ sum1 += Memory.ROM [i];
+
+ for (i = 0; i < (int) remainder; i++)
+ sum2 += Memory.ROM [size + i];
+
+ if (remainder)
+ {
+ //for Tengai makyou
+ if (Memory.CalculatedSize == 0x500000 && Memory.HiROM &&
+ strncmp ((const char *)&Memory.ROM[0xffb0], "18AZ", 4) == 0 &&
+ !memcmp(&Memory.ROM[0xffd5], "\x3a\xf9\x0d\x03\x00\x33\x00", 7))
+ sum1 += sum2;
+ else
+ sum1 += sum2 * (size / remainder);
+ }
+
+ sum1 &= 0xffff;
+
+ Memory.CalculatedChecksum = caCRC32(&Memory.ROM[0], Memory.CalculatedSize);
+ if (Settings.ForceNTSC)
+ Settings.PAL = FALSE;
+ else
+ if (Settings.ForcePAL)
+ Settings.PAL = TRUE;
+ else
+ if (Memory.HiROM)
+ // Country code
+ Settings.PAL = Memory.ROM [0xffd9] >= 2;
+ else
+ Settings.PAL = Memory.ROM [0x7fd9] >= 2;
+
+ if (Settings.PAL)
+ {
+ Settings.FrameTime = Settings.FrameTimePAL;
+ Memory.ROMFramesPerSecond = 50;
+ }
+ else
+ {
+ Settings.FrameTime = Settings.FrameTimeNTSC;
+ Memory.ROMFramesPerSecond = 60;
+ }
+
+ Memory.ROMName[ROM_NAME_LEN - 1] = 0;
+ if (strlen (Memory.ROMName))
+ {
+ char *p = Memory.ROMName + strlen (Memory.ROMName) - 1;
+
+ while (p > Memory.ROMName && *(p - 1) == ' ')
+ p--;
+ *p = 0;
+ }
+
+ if (Settings.SuperFX)
+ {
+ CPU.Memory_SRAMMask = 0xffff;
+ Memory.SRAMSize = 16;
+ }
+ else
+ {
+ CPU.Memory_SRAMMask = Memory.SRAMSize ?
+ ((1 << (Memory.SRAMSize + 3)) * 128) - 1 : 0;
+ }
+
+ IAPU.OneCycle = ONE_APU_CYCLE;
+ Settings.Shutdown = Settings.ShutdownMaster;
+
+ SetDSP = &DSP1SetByte;
+ GetDSP = &DSP1GetByte;
+
+ ApplyROMFixes ();
+ sprintf (Memory.ROMName, "%s", Safe (Memory.ROMName));
+ sprintf (Memory.ROMId, "%s", Safe (Memory.ROMId));
+ sprintf (Memory.CompanyId, "%s", Safe (Memory.CompanyId));
+
+ sprintf (String, "\"%s\" [%s] %s, %s, Type: %s, Mode: %s, TV: %s, S-RAM: %s, ROMId: %s Company: %2.2s",
+ Memory.ROMName,
+ (Memory.ROMChecksum + Memory.ROMComplementChecksum != 0xffff ||
+ Memory.ROMChecksum != sum1) ? "bad checksum" : "checksum ok",
+ MapType (),
+ Size (),
+ KartContents (),
+ MapMode (),
+ TVStandard (),
+ StaticRAMSize (),
+ Memory.ROMId,
+ Memory.CompanyId);
+
+ S9xMessage (S9X_INFO, S9X_ROM_INFO, String);
+}
+
+bool8_32 LoadSRAM (const char *filename)
+{
+ int size = Memory.SRAMSize ?
+ (1 << (Memory.SRAMSize + 3)) * 128 : 0;
+
+ memset (Memory.SRAM, SNESGameFixes.SRAMInitialValue, 0x20000);
+
+ if (size > 0x20000)
+ size = 0x20000;
+
+ if (size)
+ {
+ FILE *file;
+ if ((file = fopen(filename, "rb")))
+ {
+ int len = fread ((char*) SRAM, 1, 0x20000, file);
+ fclose (file);
+ if (len - size == 512)
+ {
+ // S-RAM file has a header - remove it
+ memmove (SRAM, SRAM + 512, size);
+ }
+ if (len == size + SRTC_SRAM_PAD)
+ {
+ S9xSRTCPostLoadState ();
+ S9xResetSRTC ();
+ rtc.index = -1;
+ rtc.mode = MODE_READ;
+ }
+ else
+ S9xHardResetSRTC ();
+
+ return (TRUE);
+ }
+ S9xHardResetSRTC ();
+ return (FALSE);
+ }
+
+ return (TRUE);
+}
+
+bool8_32 SaveSRAM (const char *filename)
+{
+ int size = Memory.SRAMSize ?
+ (1 << (Memory.SRAMSize + 3)) * 128 : 0;
+ if (Settings.SRTC)
+ {
+ size += SRTC_SRAM_PAD;
+ S9xSRTCPreSaveState ();
+ }
+
+
+ if (size > 0x20000)
+ size = 0x20000;
+
+ if (size && *Memory.ROMFilename)
+ {
+ FILE *file;
+ if ((file = fopen (filename, "wb")))
+ {
+ fwrite ((char *) SRAM, size, 1, file);
+ fclose (file);
+ //sync();
+#if defined(__linux)
+ //chown (filename, getuid (), getgid ());
+#endif
+ return (TRUE);
+ }
+ }
+ return (FALSE);
+}
+
+void FixROMSpeed ()
+{
+ int c;
+
+ for (c = 0x800; c < 0x1000; c++)
+ {
+ if (Memory.BlockIsROM [c])
+ Memory.MemorySpeed [c] = (uint8) CPU.FastROMSpeed;
+ }
+}
+
+void WriteProtectROM ()
+{
+ memmove ((void *) Memory.WriteMap, (void *) Memory.Map, sizeof (Memory.Map));
+ for (int c = 0; c < 0x1000; c++)
+ {
+ if (Memory.BlockIsROM [c])
+ Memory.WriteMap [c] = (uint8 *) MAP_NONE;
+ }
+}
+
+void MapRAM ()
+{
+ int c;
+
+ // Banks 7e->7f, RAM
+ for (c = 0; c < 16; c++)
+ {
+ Memory.Map [c + 0x7e0] = Memory.RAM;
+ Memory.Map [c + 0x7f0] = Memory.RAM + 0x10000;
+ Memory.BlockIsRAM [c + 0x7e0] = TRUE;
+ Memory.BlockIsRAM [c + 0x7f0] = TRUE;
+ Memory.BlockIsROM [c + 0x7e0] = FALSE;
+ Memory.BlockIsROM [c + 0x7f0] = FALSE;
+ }
+
+ // Banks 70->77, S-RAM
+ for (c = 0; c < 0x80; c++)
+ {
+ Memory.Map [c + 0x700] = (uint8 *) MAP_LOROM_SRAM;
+ Memory.BlockIsRAM [c + 0x700] = TRUE;
+ Memory.BlockIsROM [c + 0x700] = FALSE;
+ }
+}
+
+void MapExtraRAM ()
+{
+ int c;
+
+ // Banks 7e->7f, RAM
+ for (c = 0; c < 16; c++)
+ {
+ Memory.Map [c + 0x7e0] = Memory.RAM;
+ Memory.Map [c + 0x7f0] = Memory.RAM + 0x10000;
+ Memory.BlockIsRAM [c + 0x7e0] = TRUE;
+ Memory.BlockIsRAM [c + 0x7f0] = TRUE;
+ Memory.BlockIsROM [c + 0x7e0] = FALSE;
+ Memory.BlockIsROM [c + 0x7f0] = FALSE;
+ }
+
+ // Banks 70->73, S-RAM
+ for (c = 0; c < 16; c++)
+ {
+ Memory.Map [c + 0x700] = SRAM;
+ Memory.Map [c + 0x710] = SRAM + 0x8000;
+ Memory.Map [c + 0x720] = SRAM + 0x10000;
+ Memory.Map [c + 0x730] = SRAM + 0x18000;
+
+ Memory.BlockIsRAM [c + 0x700] = TRUE;
+ Memory.BlockIsROM [c + 0x700] = FALSE;
+ Memory.BlockIsRAM [c + 0x710] = TRUE;
+ Memory.BlockIsROM [c + 0x710] = FALSE;
+ Memory.BlockIsRAM [c + 0x720] = TRUE;
+ Memory.BlockIsROM [c + 0x720] = FALSE;
+ Memory.BlockIsRAM [c + 0x730] = TRUE;
+ Memory.BlockIsROM [c + 0x730] = FALSE;
+ }
+}
+
+void LoROMMap ()
+{
+ int c;
+ int i;
+
+ // Banks 00->3f and 80->bf
+ for (c = 0; c < 0x400; c += 16)
+ {
+ Memory.Map [c + 0] = Memory.Map [c + 0x800] = Memory.RAM;
+ Memory.Map [c + 1] = Memory.Map [c + 0x801] = Memory.RAM;
+ Memory.BlockIsRAM [c + 0] = Memory.BlockIsRAM [c + 0x800] = TRUE;
+ Memory.BlockIsRAM [c + 1] = Memory.BlockIsRAM [c + 0x801] = TRUE;
+
+ Memory.Map [c + 2] = Memory.Map [c + 0x802] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 4] = Memory.Map [c + 0x804] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8 *) MAP_CPU;
+ if (Settings.DSP1Master)
+ {
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) MAP_DSP;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) MAP_DSP;
+ }
+ else
+ if (Settings.C4)
+ {
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) MAP_C4;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) MAP_C4;
+ }
+ else
+ {
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) bytes0x2000 - 0x6000;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) bytes0x2000 - 0x6000;
+ }
+
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [(c << 11) % Memory.CalculatedSize] - 0x8000;
+ Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = TRUE;
+ }
+
+ for (i = c; i < c + 16; i++)
+ {
+ int ppu = i & 15;
+
+ Memory.MemorySpeed [i] =
+ Memory.MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
+ }
+ }
+
+ if (Settings.DSP1Master)
+ {
+ // Banks 30->3f and b0->bf
+ for (c = 0x300; c < 0x400; c += 16)
+ {
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = Memory.Map [i + 0x800] = (uint8 *) MAP_DSP;
+ Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = FALSE;
+ }
+ }
+ }
+
+ // Banks 40->7f and c0->ff
+ for (c = 0; c < 0x400; c += 16)
+ {
+ for (i = c; i < c + 8; i++)
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) % Memory.CalculatedSize];
+
+ for (i = c + 8; i < c + 16; i++)
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [((c << 11) + 0x200000) % Memory.CalculatedSize - 0x8000];
+
+ for (i = c; i < c + 16; i++)
+ {
+ Memory.MemorySpeed [i + 0x400] = Memory.MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
+ Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = TRUE;
+ }
+ }
+
+ if (Settings.DSP1Master)
+ {
+ for (c = 0; c < 0x100; c++)
+ {
+ Memory.Map [c + 0xe00] = (uint8 *) MAP_DSP;
+ Memory.MemorySpeed [c + 0xe00] = SLOW_ONE_CYCLE;
+ Memory.BlockIsROM [c + 0xe00] = FALSE;
+ }
+ }
+ MapRAM ();
+ WriteProtectROM ();
+}
+
+void HiROMMap ()
+{
+ int c;
+ int i;
+
+ // Banks 00->3f and 80->bf
+ for (c = 0; c < 0x400; c += 16)
+ {
+ Memory.Map [c + 0] = Memory.Map [c + 0x800] = Memory.RAM;
+ Memory.BlockIsRAM [c + 0] = Memory.BlockIsRAM [c + 0x800] = TRUE;
+ Memory.Map [c + 1] = Memory.Map [c + 0x801] = Memory.RAM;
+ Memory.BlockIsRAM [c + 1] = Memory.BlockIsRAM [c + 0x801] = TRUE;
+
+ Memory.Map [c + 2] = Memory.Map [c + 0x802] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 4] = Memory.Map [c + 0x804] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8 *) MAP_CPU;
+ if (Settings.DSP1Master)
+ {
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) MAP_DSP;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) MAP_DSP;
+ }
+ else
+ {
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) MAP_NONE;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) MAP_NONE;
+ }
+
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [(c << 12) % Memory.CalculatedSize];
+ Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = TRUE;
+ }
+
+ for (i = c; i < c + 16; i++)
+ {
+ int ppu = i & 15;
+
+ Memory.MemorySpeed [i] =
+ Memory.MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
+ }
+ }
+
+ // Banks 30->3f and b0->bf, address ranges 6000->7fff is S-RAM.
+ for (c = 0; c < 16; c++)
+ {
+ Memory.Map [0x306 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
+ Memory.Map [0x307 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
+ Memory.Map [0xb06 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
+ Memory.Map [0xb07 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
+ Memory.BlockIsRAM [0x306 + (c << 4)] = TRUE;
+ Memory.BlockIsRAM [0x307 + (c << 4)] = TRUE;
+ Memory.BlockIsRAM [0xb06 + (c << 4)] = TRUE;
+ Memory.BlockIsRAM [0xb07 + (c << 4)] = TRUE;
+ }
+
+ // Banks 40->7f and c0->ff
+ for (c = 0; c < 0x400; c += 16)
+ {
+ for (i = c; i < c + 16; i++)
+ {
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 12) % Memory.CalculatedSize];
+ Memory.MemorySpeed [i + 0x400] = Memory.MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
+ Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = TRUE;
+ }
+ }
+
+ MapRAM ();
+ WriteProtectROM ();
+}
+
+void TalesROMMap (bool8_32 Interleaved)
+{
+ int c;
+ int i;
+
+ uint32 OFFSET0 = 0x400000;
+ uint32 OFFSET1 = 0x400000;
+ uint32 OFFSET2 = 0x000000;
+
+ if (Interleaved)
+ {
+ OFFSET0 = 0x000000;
+ OFFSET1 = 0x000000;
+ OFFSET2 = 0x200000;
+ }
+
+ // Banks 00->3f and 80->bf
+ for (c = 0; c < 0x400; c += 16)
+ {
+ Memory.Map [c + 0] = Memory.Map [c + 0x800] = Memory.RAM;
+ Memory.Map [c + 1] = Memory.Map [c + 0x801] = Memory.RAM;
+ Memory.BlockIsRAM [c + 0] = Memory.BlockIsRAM [c + 0x800] = TRUE;
+ Memory.BlockIsRAM [c + 1] = Memory.BlockIsRAM [c + 0x801] = TRUE;
+
+ Memory.Map [c + 2] = Memory.Map [c + 0x802] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 4] = Memory.Map [c + 0x804] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) MAP_NONE;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) MAP_NONE;
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = &Memory.ROM [((c << 12) + OFFSET0) % Memory.CalculatedSize];
+ Memory.Map [i + 0x800] = &Memory.ROM [((c << 12) + OFFSET0) % Memory.CalculatedSize];
+ Memory.BlockIsROM [i] = TRUE;
+ Memory.BlockIsROM [i + 0x800] = TRUE;
+ }
+
+ for (i = c; i < c + 16; i++)
+ {
+ int ppu = i & 15;
+
+ Memory.MemorySpeed [i] =
+ Memory.MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
+ }
+ }
+
+ // Banks 30->3f and b0->bf, address ranges 6000->7ffff is S-RAM.
+ for (c = 0; c < 16; c++)
+ {
+ Memory.Map [0x306 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
+ Memory.Map [0x307 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
+ Memory.Map [0xb06 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
+ Memory.Map [0xb07 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
+ Memory.BlockIsRAM [0x306 + (c << 4)] = TRUE;
+ Memory.BlockIsRAM [0x307 + (c << 4)] = TRUE;
+ Memory.BlockIsRAM [0xb06 + (c << 4)] = TRUE;
+ Memory.BlockIsRAM [0xb07 + (c << 4)] = TRUE;
+ }
+
+ // Banks 40->7f and c0->ff
+ for (c = 0; c < 0x400; c += 16)
+ {
+ for (i = c; i < c + 8; i++)
+ {
+ Memory.Map [i + 0x400] = &Memory.ROM [((c << 12) + OFFSET1) % Memory.CalculatedSize];
+ Memory.Map [i + 0x408] = &Memory.ROM [((c << 12) + OFFSET1) % Memory.CalculatedSize];
+ Memory.Map [i + 0xc00] = &Memory.ROM [((c << 12) + OFFSET2) % Memory.CalculatedSize];
+ Memory.Map [i + 0xc08] = &Memory.ROM [((c << 12) + OFFSET2) % Memory.CalculatedSize];
+ Memory.BlockIsROM [i + 0x400] = TRUE;
+ Memory.BlockIsROM [i + 0x408] = TRUE;
+ Memory.BlockIsROM [i + 0xc00] = TRUE;
+ Memory.BlockIsROM [i + 0xc08] = TRUE;
+ Memory.MemorySpeed [i + 0x400] = Memory.MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
+ Memory.MemorySpeed [i + 0x408] = Memory.MemorySpeed [i + 0xc08] = SLOW_ONE_CYCLE;
+ }
+ }
+ MapRAM ();
+ WriteProtectROM ();
+}
+
+void AlphaROMMap ()
+{
+ int c;
+ int i;
+
+ // Banks 00->3f and 80->bf
+ for (c = 0; c < 0x400; c += 16)
+ {
+ Memory.Map [c + 0] = Memory.Map [c + 0x800] = Memory.RAM;
+ Memory.Map [c + 1] = Memory.Map [c + 0x801] = Memory.RAM;
+ Memory.BlockIsRAM [c + 0] = Memory.BlockIsRAM [c + 0x800] = TRUE;
+ Memory.BlockIsRAM [c + 1] = Memory.BlockIsRAM [c + 0x801] = TRUE;
+
+ Memory.Map [c + 2] = Memory.Map [c + 0x802] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 4] = Memory.Map [c + 0x804] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) MAP_DSP;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) MAP_DSP;
+
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [c << 11] - 0x8000;
+ Memory.BlockIsROM [i] = TRUE;
+ }
+
+ for (i = c; i < c + 16; i++)
+ {
+ int ppu = i & 15;
+
+ Memory.MemorySpeed [i] =
+ Memory.MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
+ }
+ }
+
+ // Banks 40->7f and c0->ff
+
+ for (c = 0; c < 0x400; c += 16)
+ {
+ for (i = c; i < c + 16; i++)
+ {
+ Memory.Map [i + 0x400] = &Memory.ROM [(c << 12) % Memory.CalculatedSize];
+ Memory.Map [i + 0xc00] = &Memory.ROM [(c << 12) % Memory.CalculatedSize];
+ Memory.MemorySpeed [i + 0x400] = Memory.MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
+ Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = TRUE;
+ }
+ }
+
+ MapRAM ();
+ WriteProtectROM ();
+}
+
+void SuperFXROMMap ()
+{
+ int c;
+ int i;
+
+ // Banks 00->3f and 80->bf
+ for (c = 0; c < 0x400; c += 16)
+ {
+ Memory.Map [c + 0] = Memory.Map [c + 0x800] = Memory.RAM;
+ Memory.Map [c + 1] = Memory.Map [c + 0x801] = Memory.RAM;
+ Memory.BlockIsRAM [c + 0] = Memory.BlockIsRAM [c + 0x800] = TRUE;
+ Memory.BlockIsRAM [c + 1] = Memory.BlockIsRAM [c + 0x801] = TRUE;
+
+ Memory.Map [c + 2] = Memory.Map [c + 0x802] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 4] = Memory.Map [c + 0x804] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) MAP_DSP;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) MAP_DSP;
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [c << 11] - 0x8000;
+ Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = TRUE;
+ }
+
+ for (i = c; i < c + 8; i++)
+ {
+ int ppu = i & 15;
+
+ Memory.MemorySpeed [i] =
+ Memory.MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
+ }
+ }
+
+ // Banks 40->7f and c0->ff
+ for (c = 0; c < 0x400; c += 16)
+ {
+ for (i = c; i < c + 16; i++)
+ {
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 12) % Memory.CalculatedSize];
+ Memory.MemorySpeed [i + 0x400] = Memory.MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
+ Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = TRUE;
+ }
+ }
+
+ // Banks 7e->7f, RAM
+ for (c = 0; c < 16; c++)
+ {
+ Memory.Map [c + 0x7e0] = Memory.RAM;
+ Memory.Map [c + 0x7f0] = Memory.RAM + 0x10000;
+ Memory.BlockIsRAM [c + 0x7e0] = TRUE;
+ Memory.BlockIsRAM [c + 0x7f0] = TRUE;
+ Memory.BlockIsROM [c + 0x7e0] = FALSE;
+ Memory.BlockIsROM [c + 0x7f0] = FALSE;
+ }
+
+ // Banks 70->71, S-RAM
+ for (c = 0; c < 32; c++)
+ {
+ Memory.Map [c + 0x700] = SRAM + (((c >> 4) & 1) << 16);
+ Memory.BlockIsRAM [c + 0x700] = TRUE;
+ Memory.BlockIsROM [c + 0x700] = FALSE;
+ }
+
+ // Banks 00->3f and 80->bf address ranges 6000->7fff is RAM.
+ for (c = 0; c < 0x40; c++)
+ {
+ Memory.Map [0x006 + (c << 4)] = (uint8 *) SRAM - 0x6000;
+ Memory.Map [0x007 + (c << 4)] = (uint8 *) SRAM - 0x6000;
+ Memory.Map [0x806 + (c << 4)] = (uint8 *) SRAM - 0x6000;
+ Memory.Map [0x807 + (c << 4)] = (uint8 *) SRAM - 0x6000;
+ Memory.BlockIsRAM [0x006 + (c << 4)] = TRUE;
+ Memory.BlockIsRAM [0x007 + (c << 4)] = TRUE;
+ Memory.BlockIsRAM [0x806 + (c << 4)] = TRUE;
+ Memory.BlockIsRAM [0x807 + (c << 4)] = TRUE;
+ }
+ // Replicate the first 2Mb of the ROM at ROM + 2MB such that each 32K
+ // block is repeated twice in each 64K block.
+ for (c = 0; c < 64; c++)
+ {
+ memmove (&Memory.ROM [0x200000 + c * 0x10000], &Memory.ROM [c * 0x8000], 0x8000);
+ memmove (&Memory.ROM [0x208000 + c * 0x10000], &Memory.ROM [c * 0x8000], 0x8000);
+ }
+
+ WriteProtectROM ();
+}
+
+void SA1ROMMap ()
+{
+ int c;
+ int i;
+
+ // Banks 00->3f and 80->bf
+ for (c = 0; c < 0x400; c += 16)
+ {
+ Memory.Map [c + 0] = Memory.Map [c + 0x800] = Memory.RAM;
+ Memory.Map [c + 1] = Memory.Map [c + 0x801] = Memory.RAM;
+ Memory.BlockIsRAM [c + 0] = Memory.BlockIsRAM [c + 0x800] = TRUE;
+ Memory.BlockIsRAM [c + 1] = Memory.BlockIsRAM [c + 0x801] = TRUE;
+
+ Memory.Map [c + 2] = Memory.Map [c + 0x802] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8 *) &Memory.FillRAM [0x3000] - 0x3000;
+ Memory.Map [c + 4] = Memory.Map [c + 0x804] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) MAP_BWRAM;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) MAP_BWRAM;
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [c << 11] - 0x8000;
+ Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = TRUE;
+ }
+
+ for (i = c; i < c + 16; i++)
+ {
+ int ppu = i & 15;
+
+ Memory.MemorySpeed [i] =
+ Memory.MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
+ }
+ }
+
+ // Banks 40->7f
+ for (c = 0; c < 0x400; c += 16)
+ {
+ for (i = c; i < c + 16; i++)
+ Memory.Map [i + 0x400] = (uint8 *) &Memory.SRAM [(c << 12) & 0x1ffff];
+
+ for (i = c; i < c + 16; i++)
+ {
+ Memory.MemorySpeed [i + 0x400] = SLOW_ONE_CYCLE;
+ Memory.BlockIsROM [i + 0x400] = FALSE;
+ }
+ }
+
+ // c0->ff
+ for (c = 0; c < 0x400; c += 16)
+ {
+ for (i = c; i < c + 16; i++)
+ {
+ Memory.Map [i + 0xc00] = &Memory.ROM [(c << 12) % Memory.CalculatedSize];
+ Memory.MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
+ Memory.BlockIsROM [i + 0xc00] = TRUE;
+ }
+ }
+
+ for (c = 0; c < 16; c++)
+ {
+ Memory.Map [c + 0x7e0] = Memory.RAM;
+ Memory.Map [c + 0x7f0] = Memory.RAM + 0x10000;
+ Memory.BlockIsRAM [c + 0x7e0] = TRUE;
+ Memory.BlockIsRAM [c + 0x7f0] = TRUE;
+ Memory.BlockIsROM [c + 0x7e0] = FALSE;
+ Memory.BlockIsROM [c + 0x7f0] = FALSE;
+ }
+ WriteProtectROM ();
+
+#ifdef USE_SA1
+ // Now copy the map and correct it for the SA1 CPU.
+ memmove ((void *) SA1_WriteMap, (void *) Memory.WriteMap, sizeof (Memory.WriteMap));
+ memmove ((void *) SA1_Map, (void *) Memory.Map, sizeof (Memory.Map));
+
+ // Banks 00->3f and 80->bf
+ for (c = 0; c < 0x400; c += 16)
+ {
+ SA1_Map [c + 0] = SA1_Map [c + 0x800] = &Memory.FillRAM [0x3000];
+ SA1_Map [c + 1] = SA1_Map [c + 0x801] = (uint8 *) MAP_NONE;
+ SA1_WriteMap [c + 0] = SA1_WriteMap [c + 0x800] = &Memory.FillRAM [0x3000];
+ SA1_WriteMap [c + 1] = SA1_WriteMap [c + 0x801] = (uint8 *) MAP_NONE;
+ }
+
+ // Banks 60->6f
+ for (c = 0; c < 0x100; c++)
+ SA1_Map [c + 0x600] = SA1_WriteMap [c + 0x600] = (uint8 *) MAP_BWRAM_BITMAP;
+#endif // USE_SA1
+
+ Memory.BWRAM = Memory.SRAM;
+}
+
+void LoROM24MBSMap ()
+{
+ int c;
+ int i;
+
+ // Banks 00->3f and 80->bf
+ for (c = 0; c < 0x400; c += 16)
+ {
+ Memory.Map [c + 0] = Memory.Map [c + 0x800] = Memory.RAM;
+ Memory.Map [c + 1] = Memory.Map [c + 0x801] = Memory.RAM;
+ Memory.BlockIsRAM [c + 0] = Memory.BlockIsRAM [c + 0x800] = TRUE;
+ Memory.BlockIsRAM [c + 1] = Memory.BlockIsRAM [c + 0x801] = TRUE;
+
+ Memory.Map [c + 2] = Memory.Map [c + 0x802] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 4] = Memory.Map [c + 0x804] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) MAP_NONE;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) MAP_NONE;
+
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [c << 11] - 0x8000;
+ Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = TRUE;
+ }
+
+ for (i = c; i < c + 16; i++)
+ {
+ int ppu = i & 15;
+
+ Memory.MemorySpeed [i] =
+ Memory.MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
+ }
+ }
+
+ // Banks 00->3f and 80->bf
+ for (c = 0; c < 0x200; c += 16)
+ {
+ Memory.Map [c + 0x800] = Memory.RAM;
+ Memory.Map [c + 0x801] = Memory.RAM;
+ Memory.BlockIsRAM [c + 0x800] = TRUE;
+ Memory.BlockIsRAM [c + 0x801] = TRUE;
+
+ Memory.Map [c + 0x802] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 0x803] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 0x804] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 0x805] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 0x806] = (uint8 *) MAP_NONE;
+ Memory.Map [c + 0x807] = (uint8 *) MAP_NONE;
+
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i + 0x800] = &Memory.ROM [c << 11] - 0x8000 + 0x200000;
+ Memory.BlockIsROM [i + 0x800] = TRUE;
+ }
+
+ for (i = c; i < c + 16; i++)
+ {
+ int ppu = i & 15;
+
+ Memory.MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
+ }
+ }
+
+ // Banks 40->7f and c0->ff
+ for (c = 0; c < 0x400; c += 16)
+ {
+ for (i = c; i < c + 8; i++)
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) + 0x200000];
+
+ for (i = c + 8; i < c + 16; i++)
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) + 0x200000 - 0x8000];
+
+ for (i = c; i < c + 16; i++)
+ {
+ Memory.MemorySpeed [i + 0x400] = Memory.MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
+ Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = TRUE;
+ }
+ }
+
+ MapExtraRAM ();
+ WriteProtectROM ();
+}
+
+void SufamiTurboLoROMMap ()
+{
+ int c;
+ int i;
+
+ // Banks 00->3f and 80->bf
+ for (c = 0; c < 0x400; c += 16)
+ {
+ Memory.Map [c + 0] = Memory.Map [c + 0x800] = Memory.RAM;
+ Memory.Map [c + 1] = Memory.Map [c + 0x801] = Memory.RAM;
+ Memory.BlockIsRAM [c + 0] = Memory.BlockIsRAM [c + 0x800] = TRUE;
+ Memory.BlockIsRAM [c + 1] = Memory.BlockIsRAM [c + 0x801] = TRUE;
+
+ Memory.Map [c + 2] = Memory.Map [c + 0x802] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 4] = Memory.Map [c + 0x804] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8 *) MAP_CPU;
+ if (Settings.DSP1Master)
+ {
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) MAP_DSP;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) MAP_DSP;
+ }
+ else
+ {
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) MAP_NONE;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) MAP_NONE;
+ }
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [c << 11] - 0x8000;
+ Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = TRUE;
+ }
+
+ for (i = c; i < c + 16; i++)
+ {
+ int ppu = i & 15;
+
+ Memory.MemorySpeed [i] =
+ Memory.MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
+ }
+ }
+
+ if (Settings.DSP1Master)
+ {
+ // Banks 30->3f and b0->bf
+ for (c = 0x300; c < 0x400; c += 16)
+ {
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = Memory.Map [i + 0x800] = (uint8 *) MAP_DSP;
+ Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = FALSE;
+ }
+ }
+ }
+
+ // Banks 40->7f and c0->ff
+ for (c = 0; c < 0x400; c += 16)
+ {
+ for (i = c; i < c + 8; i++)
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) + 0x200000];
+
+ for (i = c + 8; i < c + 16; i++)
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) + 0x200000 - 0x8000];
+
+ for (i = c; i < c + 16; i++)
+ {
+ Memory.MemorySpeed [i + 0x400] = Memory.MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
+ Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = TRUE;
+ }
+ }
+
+ if (Settings.DSP1Master)
+ {
+ for (c = 0; c < 0x100; c++)
+ {
+ Memory.Map [c + 0xe00] = (uint8 *) MAP_DSP;
+ Memory.MemorySpeed [c + 0xe00] = SLOW_ONE_CYCLE;
+ Memory.BlockIsROM [c + 0xe00] = FALSE;
+ }
+ }
+
+ // Banks 7e->7f, RAM
+ for (c = 0; c < 16; c++)
+ {
+ Memory.Map [c + 0x7e0] = Memory.RAM;
+ Memory.Map [c + 0x7f0] = Memory.RAM + 0x10000;
+ Memory.BlockIsRAM [c + 0x7e0] = TRUE;
+ Memory.BlockIsRAM [c + 0x7f0] = TRUE;
+ Memory.BlockIsROM [c + 0x7e0] = FALSE;
+ Memory.BlockIsROM [c + 0x7f0] = FALSE;
+ }
+
+ // Banks 60->67, S-RAM
+ for (c = 0; c < 0x80; c++)
+ {
+ Memory.Map [c + 0x600] = (uint8 *) MAP_LOROM_SRAM;
+ Memory.BlockIsRAM [c + 0x600] = TRUE;
+ Memory.BlockIsROM [c + 0x600] = FALSE;
+ }
+
+ WriteProtectROM ();
+}
+
+void SRAM512KLoROMMap ()
+{
+ int c;
+ int i;
+
+ // Banks 00->3f and 80->bf
+ for (c = 0; c < 0x400; c += 16)
+ {
+ Memory.Map [c + 0] = Memory.Map [c + 0x800] = Memory.RAM;
+ Memory.Map [c + 1] = Memory.Map [c + 0x801] = Memory.RAM;
+ Memory.BlockIsRAM [c + 0] = Memory.BlockIsRAM [c + 0x800] = TRUE;
+ Memory.BlockIsRAM [c + 1] = Memory.BlockIsRAM [c + 0x801] = TRUE;
+
+ Memory.Map [c + 2] = Memory.Map [c + 0x802] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 4] = Memory.Map [c + 0x804] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) MAP_NONE;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) MAP_NONE;
+
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [c << 11] - 0x8000;
+ Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = TRUE;
+ }
+
+ for (i = c; i < c + 16; i++)
+ {
+ int ppu = i & 15;
+
+ Memory.MemorySpeed [i] =
+ Memory.MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
+ }
+ }
+
+ // Banks 40->7f and c0->ff
+ for (c = 0; c < 0x400; c += 16)
+ {
+ for (i = c; i < c + 8; i++)
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) + 0x200000];
+
+ for (i = c + 8; i < c + 16; i++)
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 11) + 0x200000 - 0x8000];
+
+ for (i = c; i < c + 16; i++)
+ {
+ Memory.MemorySpeed [i + 0x400] = Memory.MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
+ Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = TRUE;
+
+
+ }
+ }
+
+ MapExtraRAM ();
+ WriteProtectROM ();
+}
+
+void SRAM1024KLoROMMap ()
+{
+ int c;
+ int i;
+
+ // Banks 00->3f and 80->bf
+ for (c = 0; c < 0x400; c += 16)
+ {
+ Memory.Map [c + 0] = Memory.Map [c + 0x800] = Memory.Map [c + 0x400] = Memory.Map [c + 0xc00] = Memory.RAM;
+ Memory.Map [c + 1] = Memory.Map [c + 0x801] = Memory.Map [c + 0x401] = Memory.Map [c + 0xc01] = Memory.RAM;
+ Memory.BlockIsRAM [c + 0] = Memory.BlockIsRAM [c + 0x800] = Memory.BlockIsRAM [c + 0x400] = Memory.BlockIsRAM [c + 0xc00] = TRUE;
+ Memory.BlockIsRAM [c + 1] = Memory.BlockIsRAM [c + 0x801] = Memory.BlockIsRAM [c + 0x401] = Memory.BlockIsRAM [c + 0xc01] = TRUE;
+
+ Memory.Map [c + 2] = Memory.Map [c + 0x802] = Memory.Map [c + 0x402] = Memory.Map [c + 0xc02] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 3] = Memory.Map [c + 0x803] = Memory.Map [c + 0x403] = Memory.Map [c + 0xc03] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 4] = Memory.Map [c + 0x804] = Memory.Map [c + 0x404] = Memory.Map [c + 0xc04] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 5] = Memory.Map [c + 0x805] = Memory.Map [c + 0x405] = Memory.Map [c + 0xc05] = (uint8 *) MAP_CPU;
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = Memory.Map [c + 0x406] = Memory.Map [c + 0xc06] = (uint8 *) MAP_NONE;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = Memory.Map [c + 0x407] = Memory.Map [c + 0xc07] = (uint8 *) MAP_NONE;
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = Memory.Map [i + 0x800] = Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [c << 11] - 0x8000;
+ Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = TRUE;
+ }
+
+ for (i = c; i < c + 16; i++)
+ {
+ int ppu = i & 15;
+
+ Memory.MemorySpeed [i] = Memory.MemorySpeed [i + 0x800] =
+ Memory.MemorySpeed [i + 0x400] = Memory.MemorySpeed [i + 0xc00] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
+ }
+ }
+
+ MapExtraRAM ();
+ WriteProtectROM ();
+}
+
+void BSHiROMMap ()
+{
+ int c;
+ int i;
+
+ // Banks 00->3f and 80->bf
+ for (c = 0; c < 0x400; c += 16)
+ {
+ Memory.Map [c + 0] = Memory.Map [c + 0x800] = Memory.RAM;
+ Memory.BlockIsRAM [c + 0] = Memory.BlockIsRAM [c + 0x800] = TRUE;
+ Memory.Map [c + 1] = Memory.Map [c + 0x801] = Memory.RAM;
+ Memory.BlockIsRAM [c + 1] = Memory.BlockIsRAM [c + 0x801] = TRUE;
+
+ Memory.Map [c + 2] = Memory.Map [c + 0x802] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 3] = Memory.Map [c + 0x803] = (uint8 *) MAP_PPU;
+ Memory.Map [c + 4] = Memory.Map [c + 0x804] = (uint8 *) MAP_CPU;
+ // XXX: How large is SRAM??
+ Memory.Map [c + 5] = Memory.Map [c + 0x805] = (uint8 *) Memory.SRAM;
+ Memory.BlockIsRAM [c + 5] = Memory.BlockIsRAM [c + 0x805] = TRUE;
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = (uint8 *) MAP_NONE;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = (uint8 *) MAP_NONE;
+
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = Memory.Map [i + 0x800] = &Memory.ROM [(c << 12) % Memory.CalculatedSize];
+ Memory.BlockIsROM [i] = Memory.BlockIsROM [i + 0x800] = TRUE;
+ }
+
+ for (i = c; i < c + 16; i++)
+ {
+ int ppu = i & 15;
+
+ Memory.MemorySpeed [i] =
+ Memory.MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
+ }
+ }
+
+ // Banks 60->7d offset 0000->7fff & 60->7f offset 8000->ffff PSRAM
+ // XXX: How large is PSRAM?
+ for (c = 0x600; c < 0x7e0; c += 16)
+ {
+ for (i = c; i < c + 8; i++)
+ {
+ Memory.Map [i] = &Memory.ROM [0x400000 + (c << 11)];
+ Memory.BlockIsRAM [i] = TRUE;
+ }
+ for (i = c + 8; i < c + 16; i++)
+ {
+ Memory.Map [i] = &Memory.ROM [0x400000 + (c << 11) - 0x8000];
+ Memory.BlockIsRAM [i] = TRUE;
+ }
+ }
+
+ // Banks 40->7f and c0->ff
+ for (c = 0; c < 0x400; c += 16)
+ {
+ for (i = c; i < c + 16; i++)
+ {
+ Memory.Map [i + 0x400] = Memory.Map [i + 0xc00] = &Memory.ROM [(c << 12) % Memory.CalculatedSize];
+ Memory.MemorySpeed [i + 0x400] = Memory.MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
+ Memory.BlockIsROM [i + 0x400] = Memory.BlockIsROM [i + 0xc00] = TRUE;
+ }
+ }
+
+ MapRAM ();
+ WriteProtectROM ();
+}
+
+const char *TVStandard ()
+{
+ return (Settings.PAL ? "PAL" : "NTSC");
+}
+
+const char *Speed ()
+{
+ return (Memory.ROMSpeed & 0x10 ? "120ns" : "200ns");
+}
+
+const char *MapType ()
+{
+ return (Memory.HiROM ? "HiROM" : "LoROM");
+}
+
+const char *StaticRAMSize ()
+{
+ static char tmp [20];
+
+ if (Memory.SRAMSize > 16)
+ return ("Corrupt");
+ sprintf (tmp, "%dKb", (CPU.Memory_SRAMMask + 1) / 1024);
+ return (tmp);
+}
+
+const char *Size ()
+{
+ static char tmp [20];
+
+ if (Memory.ROMSize < 7 || Memory.ROMSize - 7 > 23)
+ return ("Corrupt");
+ sprintf (tmp, "%dMbits", 1 << (Memory.ROMSize - 7));
+ return (tmp);
+}
+
+const char *KartContents ()
+{
+ static char tmp [30];
+ static const char *CoPro [16] = {
+ "DSP1", "SuperFX", "OBC1", "SA-1", "S-DD1", "S-RTC", "CoPro#6",
+ "CoPro#7", "CoPro#8", "CoPro#9", "CoPro#10", "CoPro#11", "CoPro#12",
+ "CoPro#13", "CoPro#14", "CoPro-Custom"
+ };
+ static const char *Contents [3] = {
+ "ROM", "ROM+RAM", "ROM+RAM+BAT"
+ };
+ if (Memory.ROMType == 0)
+ return ("ROM only");
+
+ sprintf (tmp, "%s", Contents [(Memory.ROMType & 0xf) % 3]);
+
+ if ((Memory.ROMType & 0xf) >= 3)
+ sprintf (tmp, "%s+%s", tmp, CoPro [(Memory.ROMType & 0xf0) >> 4]);
+
+ return (tmp);
+}
+
+const char *MapMode ()
+{
+ static char tmp [4];
+ sprintf (tmp, "%02x", Memory.ROMSpeed & ~0x10);
+ return (tmp);
+}
+
+const char *ROMID ()
+{
+ return (Memory.ROMId);
+}
+
+void ApplyROMFixes ()
+{
+ ROMAPUEnabled = 0;
+ DSP1.version = 0;
+ //Settings.HBlankStart = (256 * Settings.H_Max) / SNES_HCOUNTER_MAX;
+ if (strncmp(Memory.ROMName, "DUNGEON MASTER", 14) == 0)
+ {
+ DSP1.version = 1;
+ SetDSP=&DSP2SetByte;
+ GetDSP=&DSP2GetByte;
+ }
+
+ //OAM hacks because we don't fully understand the
+ //behavior of the SNES.
+
+ //possibly an RTO issue?
+ //part of Fred's club is drawn over his face.
+ if(strncmp(Memory.ROMName, "THE FLINTSTONES TTOSM", 21)==0)
+ {
+ SNESGameFixes.Flintstones=true;
+ }
+
+ if(strncmp(Memory.ROMName, "SUPER MARIO KART", 16)==0
+ || strncmp(Memory.ROMName, "F-ZERO", 6)==0)
+ {
+ SNESGameFixes.Mode7Hack=true;
+ }
+
+ //Totally wacky display...
+ //seems to need a disproven behavior, so
+ //we're definitely overlooking some other bug?
+ if(strncmp(Memory.ROMName, "UNIRACERS", 9)==0)
+ SNESGameFixes.Uniracers=true;
+
+ // Enable S-RTC (Real Time Clock) emulation for Dai Kaijyu Monogatari 2
+ Settings.SRTC = ((Memory.ROMType & 0xf0) >> 4) == 5;
+
+ Settings.StrikeGunnerOffsetHack = strcmp (Memory.ROMName, "STRIKE GUNNER") == 0 ? 7 : 0;
+
+ CPU.NMITriggerPoint = 4;
+ if (strcmp (Memory.ROMName, "CACOMA KNIGHT") == 0)
+ CPU.NMITriggerPoint = 25;
+
+ // These games complain if the multi-player adaptor is 'connected'
+ if (strcmp (Memory.ROMName, "TETRIS&Dr.MARIO") == 0 ||
+ strcmp (Memory.ROMName, "JIGSAW PARTY") == 0 ||
+ strcmp (Memory.ROMName, "SUPER PICROSS") == 0 ||
+ strcmp (Memory.ROMName, "KIRBY NO KIRA KIZZU") == 0 ||
+ strcmp (Memory.ROMName, "BLOCK") == 0 ||
+ strncmp (Memory.ROMName, "SUPER BOMBLISS", 14) == 0 ||
+ strcmp (Memory.ROMId, "ABOJ") == 0)
+ {
+ Settings.MultiPlayer5Master = FALSE;
+ Settings.MouseMaster = FALSE;
+ Settings.SuperScopeMaster = FALSE;
+ }
+
+ // Games which spool sound samples between the SNES and sound CPU using
+ // H-DMA as the sample is playing.
+ if (strcmp (Memory.ROMName, "EARTHWORM JIM 2") == 0 ||
+ strcmp (Memory.ROMName, "PRIMAL RAGE") == 0 ||
+ strcmp (Memory.ROMName, "CLAY FIGHTER") == 0 ||
+ strcmp (Memory.ROMName, "ClayFighter 2") == 0 ||
+ strncasecmp (Memory.ROMName, "MADDEN", 6) == 0 ||
+ strncmp (Memory.ROMName, "NHL", 3) == 0 ||
+ strcmp (Memory.ROMName, "WEAPONLORD") == 0)
+ {
+ Settings.Shutdown = FALSE;
+ }
+
+
+ // Stunt Racer FX
+ if (strcmp (Memory.ROMId, "CQ ") == 0 ||
+ // Illusion of Gaia
+ strncmp (Memory.ROMId, "JG", 2) == 0 ||
+ strcmp (Memory.ROMName, "GAIA GENSOUKI 1 JPN") == 0)
+ {
+ IAPU.OneCycle = 13;
+ ROMAPUEnabled |= 2;
+ CPU.APU_APUExecuting |= 2;
+ }
+
+ // RENDERING RANGER R2
+ if (strcmp (Memory.ROMId, "AVCJ") == 0 ||
+ // Star Ocean
+ strncmp (Memory.ROMId, "ARF", 3) == 0 ||
+ // Tales of Phantasia
+ strncmp (Memory.ROMId, "ATV", 3) == 0 ||
+ // Act Raiser 1 & 2
+ strncasecmp (Memory.ROMName, "ACTRAISER", 9) == 0 ||
+ strncasecmp (Memory.ROMName, "ActRaiser", 9) == 0 || // I kown both sentences are supposed to be equivalent each other but they aren't on my compiler
+ // Soulblazer
+ strcmp (Memory.ROMName, "SOULBLAZER - 1 USA") == 0 ||
+ strcmp (Memory.ROMName, "SOULBLADER - 1") == 0 ||
+ strncmp (Memory.ROMName, "SOULBLAZER 1",12) == 0 ||
+ // Terranigma
+ strncmp (Memory.ROMId, "AQT", 3) == 0 ||
+ // Robotrek
+ strncmp (Memory.ROMId, "E9 ", 3) == 0 ||
+ strcmp (Memory.ROMName, "SLAP STICK 1 JPN") == 0 ||
+ // ZENNIHON PURORESU2
+ strncmp (Memory.ROMId, "APR", 3) == 0 ||
+ // Bomberman 4
+ strncmp (Memory.ROMId, "A4B", 3) == 0 ||
+ // UFO KAMEN YAKISOBAN
+ strncmp (Memory.ROMId, "Y7 ", 3) == 0 ||
+ strncmp (Memory.ROMId, "Y9 ", 3) == 0 ||
+ // Panic Bomber World
+ strncmp (Memory.ROMId, "APB", 3) == 0 ||
+ ((strncmp (Memory.ROMName, "Parlor", 6) == 0 ||
+ strcmp (Memory.ROMName, "HEIWA PARLOR!MINI8") == 0 ||
+ strncmp (Memory.ROMName, "SANKYO Fever! フィーバー!", 21) == 0) &&
+ strcmp (Memory.CompanyId, "A0") == 0) ||
+ strcmp (Memory.ROMName, "DARK KINGDOM") == 0 ||
+ strcmp (Memory.ROMName, "ZAN3 SFC") == 0 ||
+ strcmp (Memory.ROMName, "HIOUDEN") == 0 ||
+ strcmp (Memory.ROMName, "テンシノウタ") == 0 ||
+ strcmp (Memory.ROMName, "FORTUNE QUEST") == 0 ||
+ strcmp (Memory.ROMName, "FISHING TO BASSING") == 0 ||
+ strncmp (Memory.ROMName, "TOKYODOME '95BATTLE 7", 21) == 0 ||
+ strcmp (Memory.ROMName, "OHMONO BLACKBASS") == 0)
+ {
+ IAPU.OneCycle = 15;
+ // notaz: strangely enough, these games work properly with my hack enabled
+ if (strcmp (Memory.ROMId, "AVCJ") != 0)
+ ROMAPUEnabled |= 2;
+ CPU.APU_APUExecuting |= 2;
+ }
+
+ if (strcmp (Memory.ROMName, "BATMAN--REVENGE JOKER") == 0)
+ {
+ Memory.HiROM = FALSE;
+ Memory.LoROM = TRUE;
+ LoROMMap ();
+ }
+ Settings.StarfoxHack = strcmp (Memory.ROMName, "STAR FOX") == 0 ||
+ strcmp (Memory.ROMName, "STAR WING") == 0;
+ Settings.WinterGold = strcmp (Memory.ROMName, "FX SKIING NINTENDO 96") == 0 ||
+ strcmp (Memory.ROMName, "DIRT RACER") == 0 ||
+ strcmp (Memory.ROMName, "Stunt Race FX") == 0 ||
+ Settings.StarfoxHack;
+ Settings.ChuckRock = strcmp (Memory.ROMName, "CHUCK ROCK") == 0;
+ Settings.Dezaemon = strcmp (Memory.ROMName, "DEZAEMON") == 0;
+
+ if (strcmp (Memory.ROMName, "RADICAL DREAMERS") == 0 ||
+ strcmp (Memory.ROMName, "TREASURE CONFLIX") == 0)
+ {
+ int c;
+
+ for (c = 0; c < 0x80; c++)
+ {
+ Memory.Map [c + 0x700] = Memory.ROM + 0x200000 + 0x1000 * (c & 0xf0);
+ Memory.BlockIsRAM [c + 0x700] = TRUE;
+ Memory.BlockIsROM [c + 0x700] = FALSE;
+ }
+ for (c = 0; c < 0x400; c += 16)
+ {
+ Memory.Map [c + 5] = Memory.Map [c + 0x805] = Memory.ROM + 0x300000;
+ Memory.BlockIsRAM [c + 5] = Memory.BlockIsRAM [c + 0x805] = TRUE;
+ }
+ WriteProtectROM ();
+ }
+
+ Settings.H_Max = (SNES_CYCLES_PER_SCANLINE *
+ Settings.CyclesPercentage) / 100;
+
+ // A Couple of HDMA related hacks - Lantus
+ if ((strcmp(Memory.ROMName, "SFX SUPERBUTOUDEN2")==0) ||
+ (strcmp(Memory.ROMName, "ALIEN vs. PREDATOR")==0) ||
+ (strcmp(Memory.ROMName, "STONE PROTECTORS")==0) ||
+ (strcmp(Memory.ROMName, "SUPER BATTLETANK 2")==0))
+ Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 130) / 100;
+
+ if (strcmp (Memory.ROMId, "ASRJ") == 0 && Settings.CyclesPercentage == 100)
+ // Street Racer
+ Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 95) / 100;
+
+ // Power Rangers Fight
+ if (strncmp (Memory.ROMId, "A3R", 3) == 0 ||
+ // Clock Tower
+ strncmp (Memory.ROMId, "AJE", 3) == 0)
+ Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 103) / 100;
+
+ if (strcmp (Memory.ROMId, "AWVP") == 0 || strcmp (Memory.ROMId, "AWVE") == 0 ||
+ strcmp (Memory.ROMId, "AWVJ") == 0)
+ {
+ // Wrestlemania Arcade
+#if 0
+ if (Settings.CyclesPercentage == 100)
+ Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 140) / 100; // Fixes sound
+#endif
+ Settings.WrestlemaniaArcade = TRUE;
+ }
+ // Theme Park - disable offset-per-tile mode.
+ if (strcmp (Memory.ROMId, "ATQP") == 0)
+ Settings.WrestlemaniaArcade = TRUE;
+
+ if (strncmp (Memory.ROMId, "A3M", 3) == 0 && Settings.CyclesPercentage == 100)
+ // Mortal Kombat 3. Fixes cut off speech sample
+ Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 110) / 100;
+
+ if (strcmp (Memory.ROMName, "\x0bd\x0da\x0b2\x0d4\x0b0\x0bd\x0de") == 0 &&
+ Settings.CyclesPercentage == 100)
+ Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 101) / 100;
+
+ if (strcmp (Memory.ROMName, "WILD TRAX") == 0 ||
+ strcmp (Memory.ROMName, "YOSSY'S ISLAND") == 0 ||
+ strcmp (Memory.ROMName, "YOSHI'S ISLAND") == 0)
+ CPU.TriedInterleavedMode2 = TRUE;
+
+ // Start Trek: Deep Sleep 9
+ if (strncmp (Memory.ROMId, "A9D", 3) == 0 && Settings.CyclesPercentage == 100)
+ Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 110) / 100;
+
+ Settings.APURAMInitialValue = 0xff;
+
+ if (strcmp (Memory.ROMName, "キュウヤク・メガミテンセイ") == 0 ||
+ strcmp (Memory.ROMName, "KENTOUOU WORLDCHAMPIO") == 0 ||
+ strcmp (Memory.ROMName, "TKO SUPERCHAMPIONSHIP") == 0 ||
+ strcmp (Memory.ROMName, "TKO SUPER CHAMPIONSHI") == 0 ||
+ strcmp (Memory.ROMName, "IHATOVO STORY") == 0 ||
+ strcmp (Memory.ROMName, "WANDERERS FROM YS") == 0 ||
+ strcmp (Memory.ROMName, "SUPER GENTYOUHISHI") == 0 ||
+ // Panic Bomber World
+ strncmp (Memory.ROMId, "APB", 3) == 0)
+ {
+ Settings.APURAMInitialValue = 0;
+ }
+
+ Settings.DaffyDuck = strcmp (Memory.ROMName, "DAFFY DUCK: MARV MISS") == 0;
+ Settings.HBlankStart = (256 * Settings.H_Max) / SNES_HCOUNTER_MAX;
+
+#ifdef USE_SA1
+ SA1.WaitAddress = NULL;
+ SA1.WaitByteAddress1 = NULL;
+ SA1.WaitByteAddress2 = NULL;
+
+ /* Bass Fishing */
+ if (strcmp (Memory.ROMId, "ZBPJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x0093f1 >> MEMMAP_SHIFT] + 0x93f1;
+ SA1.WaitByteAddress1 = Memory.FillRAM + 0x304a;
+ }
+ /* DAISENRYAKU EXPERTWW2 */
+ if (strcmp (Memory.ROMId, "AEVJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x0ed18d >> MEMMAP_SHIFT] + 0xd18d;
+ SA1.WaitByteAddress1 = Memory.FillRAM + 0x3000;
+ }
+ /* debjk2 */
+ if (strcmp (Memory.ROMId, "A2DJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x008b62 >> MEMMAP_SHIFT] + 0x8b62;
+ }
+ /* Dragon Ballz HD */
+ if (strcmp (Memory.ROMId, "AZIJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x008083 >> MEMMAP_SHIFT] + 0x8083;
+ SA1.WaitByteAddress1 = Memory.FillRAM + 0x3020;
+ }
+ /* SFC SDGUNDAMGNEXT */
+ if (strcmp (Memory.ROMId, "ZX3J") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x0087f2 >> MEMMAP_SHIFT] + 0x87f2;
+ SA1.WaitByteAddress1 = Memory.FillRAM + 0x30c4;
+ }
+ /* ShougiNoHanamichi */
+ if (strcmp (Memory.ROMId, "AARJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0xc1f85a >> MEMMAP_SHIFT] + 0xf85a;
+ SA1.WaitByteAddress1 = Memory.SRAM + 0x0c64;
+ SA1.WaitByteAddress2 = Memory.SRAM + 0x0c66;
+ }
+ /* KATO HIFUMI9DAN SYOGI */
+ if (strcmp (Memory.ROMId, "A23J") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0xc25037 >> MEMMAP_SHIFT] + 0x5037;
+ SA1.WaitByteAddress1 = Memory.SRAM + 0x0c06;
+ SA1.WaitByteAddress2 = Memory.SRAM + 0x0c08;
+ }
+ /* idaten */
+ if (strcmp (Memory.ROMId, "AIIJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0xc100be >> MEMMAP_SHIFT] + 0x00be;
+ SA1.WaitByteAddress1 = Memory.SRAM + 0x1002;
+ SA1.WaitByteAddress2 = Memory.SRAM + 0x1004;
+ }
+ /* igotais */
+ if (strcmp (Memory.ROMId, "AITJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x0080b7 >> MEMMAP_SHIFT] + 0x80b7;
+ }
+ /* J96 DREAM STADIUM */
+ if (strcmp (Memory.ROMId, "AJ6J") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0xc0f74a >> MEMMAP_SHIFT] + 0xf74a;
+ }
+ /* JumpinDerby */
+ if (strcmp (Memory.ROMId, "AJUJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x00d926 >> MEMMAP_SHIFT] + 0xd926;
+ }
+ /* JKAKINOKI SHOUGI */
+ if (strcmp (Memory.ROMId, "AKAJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x00f070 >> MEMMAP_SHIFT] + 0xf070;
+ }
+ /* HOSHI NO KIRBY 3 & KIRBY'S DREAM LAND 3 JAP & US */
+ if (strcmp (Memory.ROMId, "AFJJ") == 0 || strcmp (Memory.ROMId, "AFJE") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x0082d4 >> MEMMAP_SHIFT] + 0x82d4;
+ SA1.WaitByteAddress1 = Memory.SRAM + 0x72a4;
+ }
+ /* KIRBY SUPER DELUXE JAP */
+ if (strcmp (Memory.ROMId, "AKFJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x008c93 >> MEMMAP_SHIFT] + 0x8c93;
+ SA1.WaitByteAddress1 = Memory.FillRAM + 0x300a;
+ SA1.WaitByteAddress2 = Memory.FillRAM + 0x300e;
+ }
+ /* KIRBY SUPER DELUXE US */
+ if (strcmp (Memory.ROMId, "AKFE") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x008cb8 >> MEMMAP_SHIFT] + 0x8cb8;
+ SA1.WaitByteAddress1 = Memory.FillRAM + 0x300a;
+ SA1.WaitByteAddress2 = Memory.FillRAM + 0x300e;
+ }
+ /* SUPER MARIO RPG JAP & US */
+ if (strcmp (Memory.ROMId, "ARWJ") == 0 || strcmp (Memory.ROMId, "ARWE") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0xc0816f >> MEMMAP_SHIFT] + 0x816f;
+ SA1.WaitByteAddress1 = Memory.FillRAM + 0x3000;
+ }
+ /* marvelous.zip */
+ if (strcmp (Memory.ROMId, "AVRJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x0085f2 >> MEMMAP_SHIFT] + 0x85f2;
+ SA1.WaitByteAddress1 = Memory.FillRAM + 0x3024;
+ }
+ /* AUGUSTA3 MASTERS NEW */
+ if (strcmp (Memory.ROMId, "AO3J") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x00dddb >> MEMMAP_SHIFT] + 0xdddb;
+ SA1.WaitByteAddress1 = Memory.FillRAM + 0x37b4;
+ }
+ /* OSHABERI PARODIUS */
+ if (strcmp (Memory.ROMId, "AJOJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x8084e5 >> MEMMAP_SHIFT] + 0x84e5;
+ }
+ /* PANIC BOMBER WORLD */
+ if (strcmp (Memory.ROMId, "APBJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x00857a >> MEMMAP_SHIFT] + 0x857a;
+ }
+ /* PEBBLE BEACH NEW */
+ if (strcmp (Memory.ROMId, "AONJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x00df33 >> MEMMAP_SHIFT] + 0xdf33;
+ SA1.WaitByteAddress1 = Memory.FillRAM + 0x37b4;
+ }
+ /* PGA EUROPEAN TOUR */
+ if (strcmp (Memory.ROMId, "AEPE") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x003700 >> MEMMAP_SHIFT] + 0x3700;
+ SA1.WaitByteAddress1 = Memory.FillRAM + 0x3102;
+ }
+ /* PGA TOUR 96 */
+ if (strcmp (Memory.ROMId, "A3GE") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x003700 >> MEMMAP_SHIFT] + 0x3700;
+ SA1.WaitByteAddress1 = Memory.FillRAM + 0x3102;
+ }
+ /* POWER RANGERS 4 */
+ if (strcmp (Memory.ROMId, "A4RE") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x009899 >> MEMMAP_SHIFT] + 0x9899;
+ SA1.WaitByteAddress1 = Memory.FillRAM + 0x3000;
+ }
+ /* PACHISURO PALUSUPE */
+ if (strcmp (Memory.ROMId, "AGFJ") == 0)
+ {
+ // Never seems to turn on the SA-1!
+ }
+ /* SD F1 GRAND PRIX */
+ if (strcmp (Memory.ROMId, "AGFJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x0181bc >> MEMMAP_SHIFT] + 0x81bc;
+ }
+ /* SHOUGI MARJONG */
+ if (strcmp (Memory.ROMId, "ASYJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x00f2cc >> MEMMAP_SHIFT] + 0xf2cc;
+ SA1.WaitByteAddress1 = Memory.SRAM + 0x7ffe;
+ SA1.WaitByteAddress2 = Memory.SRAM + 0x7ffc;
+ }
+ /* shogisai2 */
+ if (strcmp (Memory.ROMId, "AX2J") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0x00d675 >> MEMMAP_SHIFT] + 0xd675;
+ }
+
+ /* SHINING SCORPION */
+ if (strcmp (Memory.ROMId, "A4WJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0xc048be >> MEMMAP_SHIFT] + 0x48be;
+ }
+ /* SHIN SHOUGI CLUB */
+ if (strcmp (Memory.ROMId, "AHJJ") == 0)
+ {
+ SA1.WaitAddress = SA1_Map [0xc1002a >> MEMMAP_SHIFT] + 0x002a;
+ SA1.WaitByteAddress1 = Memory.SRAM + 0x0806;
+ SA1.WaitByteAddress2 = Memory.SRAM + 0x0808;
+ }
+#endif // USE_SA1
+
+ // Additional game fixes by sanmaiwashi ...
+ if (strcmp (Memory.ROMName, "SFX ナイトガンダムモノガタリ 1") == 0)
+ {
+ bytes0x2000 [0xb18] = 0x4c;
+ bytes0x2000 [0xb19] = 0x4b;
+ bytes0x2000 [0xb1a] = 0xea;
+ }
+
+ if (strcmp (Memory.ROMName, "GOGO ACKMAN3") == 0 ||
+ strcmp (Memory.ROMName, "HOME ALONE") == 0)
+ {
+ // Banks 00->3f and 80->bf
+ for (int c = 0; c < 0x400; c += 16)
+ {
+ Memory.Map [c + 6] = Memory.Map [c + 0x806] = Memory.SRAM;
+ Memory.Map [c + 7] = Memory.Map [c + 0x807] = Memory.SRAM;
+ Memory.BlockIsROM [c + 6] = Memory.BlockIsROM [c + 0x806] = FALSE;
+ Memory.BlockIsROM [c + 7] = Memory.BlockIsROM [c + 0x807] = FALSE;
+ Memory.BlockIsRAM [c + 6] = Memory.BlockIsRAM [c + 0x806] = TRUE;
+ Memory.BlockIsRAM [c + 7] = Memory.BlockIsRAM [c + 0x807] = TRUE;
+ }
+ WriteProtectROM ();
+ }
+
+ if (strncmp (Memory.ROMName, "SWORD WORLD SFC", 15) == 0 ||
+ strcmp (Memory.ROMName, "SFC カメンライダー") == 0)
+ {
+ IAPU.OneCycle = 15;
+ SNESGameFixes.NeedInit0x2137 = TRUE;
+ ROMAPUEnabled |= 2;
+ CPU.APU_APUExecuting |= 2;
+ }
+
+ if (strncmp (Memory.ROMName, "SHIEN THE BLADE CHASE", 21) == 0)
+ SNESGameFixes.Old_Read0x4200 = TRUE;
+
+ if (strcmp (Memory.ROMName, "ゴジラ カイジュウダイケッセン") == 0)
+ SNESGameFixes.NeedInit0x2137 = TRUE;
+
+ if (strcmp (Memory.ROMName, "UMIHARAKAWASE") == 0)
+ SNESGameFixes.umiharakawaseFix = TRUE;
+
+ if (strcmp (Memory.ROMName, "ALIENS vs. PREDATOR") == 0)
+ SNESGameFixes.alienVSpredetorFix = TRUE;
+
+ if (strcmp (Memory.ROMName, "demon's blazon") == 0 ||
+ strcmp (Memory.ROMName, "demon's crest") == 0 ||
+ strcmp (Memory.ROMName, "ROCKMAN X") == 0 ||
+ strcmp (Memory.ROMName, "MEGAMAN X") == 0)
+ {
+
+ // CAPCOM's protect
+ // Banks 0x808000, 0x408000 are mirroring.
+ for (int c = 0; c < 8; c++)
+ Memory.Map [0x408 + c] = Memory.ROM - 0x8000;
+ }
+
+ if (strcmp (Memory.ROMName, "スーパーファミスタ") == 0 ||
+ strcmp (Memory.ROMName, "スーパーファミスタ 2") == 0 ||
+ strcmp (Memory.ROMName, "ZENKI TENCHIMEIDOU") == 0 ||
+ strcmp (Memory.ROMName, "GANBA LEAGUE") == 0)
+ {
+ SNESGameFixes.APU_OutPorts_ReturnValueFix = TRUE;
+ }
+
+ // HITOMI3
+ if (strcmp (Memory.ROMName, "HITOMI3") == 0)
+ {
+ Memory.SRAMSize = 1;
+ CPU.Memory_SRAMMask = Memory.SRAMSize ?
+ ((1 << (Memory.SRAMSize + 3)) * 128) - 1 : 0;
+ }
+
+ if (strcmp (Memory.ROMName, "goemon 4") == 0)
+ SNESGameFixes.SRAMInitialValue = 0x00;
+
+ if (strcmp (Memory.ROMName, "PACHISLO ケンキュウ") == 0)
+ SNESGameFixes._0x213E_ReturnValue = 1;
+
+ if (strcmp (Memory.ROMName, "ザ マージャン トウハイデン") == 0)
+ SNESGameFixes.TouhaidenControllerFix = TRUE;
+
+ if (strcmp (Memory.ROMName, "DRAGON KNIGHT 4") == 0)
+ {
+ // Banks 70->7e, S-RAM
+ for (int c = 0; c < 0xe0; c++)
+ {
+ Memory.Map [c + 0x700] = (uint8 *) MAP_LOROM_SRAM;
+ Memory.BlockIsRAM [c + 0x700] = TRUE;
+ Memory.BlockIsROM [c + 0x700] = FALSE;
+ }
+ WriteProtectROM ();
+ }
+
+ if (strncmp (Memory.ROMName, "LETs PACHINKO(", 14) == 0)
+ {
+ IAPU.OneCycle = 15;
+ ROMAPUEnabled |= 2;
+ CPU.APU_APUExecuting |= 2;
+ if (!Settings.ForceNTSC && !Settings.ForcePAL)
+ {
+ Settings.PAL = FALSE;
+ Settings.FrameTime = Settings.FrameTimeNTSC;
+ Memory.ROMFramesPerSecond = 60;
+ }
+ }
+
+ if (strcmp (Memory.ROMName, "FURAI NO SIREN") == 0)
+ SNESGameFixes.SoundEnvelopeHeightReading2 = TRUE;
+#if 0
+ if(strcmp (ROMName, "XBAND JAPANESE MODEM") == 0)
+ {
+ for (c = 0x200; c < 0x400; c += 16)
+ {
+ for (int i = c; i < c + 16; i++)
+ {
+ Map [i + 0x400] = Map [i + 0xc00] = &ROM[c * 0x1000];
+ MemorySpeed [i + 0x400] = MemorySpeed [i + 0xc00] = 8;
+ BlockIsRAM [i + 0x400] = BlockIsRAM [i + 0xc00] = TRUE;
+ BlockIsROM [i + 0x400] = BlockIsROM [i + 0xc00] = FALSE;
+ }
+ }
+ WriteProtectROM ();
+ }
+#endif
+
+#define RomPatch(adr,ov,nv) \
+if (ROM [adr] == ov) \
+ ROM [adr] = nv
+
+ // Love Quest
+ if (strcmp (Memory.ROMName, "LOVE QUEST") == 0)
+ {
+ RomPatch (0x1385ec, 0xd0, 0xea);
+ RomPatch (0x1385ed, 0xb2, 0xea);
+ }
+
+ // Nangoku Syonen Papuwa Kun
+ if (strcmp (Memory.ROMName, "NANGOKUSYONEN PAPUWA") == 0)
+ RomPatch (0x1f0d1, 0xa0, 0x6b);
+
+ // Tetsuwan Atom
+ if (strcmp (Memory.ROMName, "Tetsuwan Atom") == 0)
+ {
+ RomPatch (0xe24c5, 0x90, 0xea);
+ RomPatch (0xe24c6, 0xf3, 0xea);
+ }
+
+ // Oda Nobunaga
+ if (strcmp (Memory.ROMName, "SFC ODA NOBUNAGA") == 0)
+ {
+ RomPatch (0x7497, 0x80, 0xea);
+ RomPatch (0x7498, 0xd5, 0xea);
+ }
+
+ // Super Batter Up
+ if (strcmp (Memory.ROMName, "Super Batter Up") == 0)
+ {
+ RomPatch (0x27ae0, 0xd0, 0xea);
+ RomPatch (0x27ae1, 0xfa, 0xea);
+ }
+
+ // Super Professional Baseball 2
+ if (strcmp (Memory.ROMName, "SUPER PRO. BASE BALL2") == 0)
+ {
+ RomPatch (0x1e4, 0x50, 0xea);
+ RomPatch (0x1e5, 0xfb, 0xea);
+ }
+
+}
+
+// Read variable size MSB int from a file
+static long ReadInt (FILE *f, unsigned nbytes)
+{
+ long v = 0;
+ while (nbytes--)
+ {
+ int c = fgetc(f);
+ if (c == EOF)
+ return -1;
+ v = (v << 8) | (c & 0xFF);
+ }
+ return (v);
+}
+
+#define IPS_EOF 0x00454F46l
+
+void CheckForIPSPatch (const char *rom_filename, bool8_32 header,
+ int32* rom_size)
+{
+ char dir [_MAX_DIR + 1];
+ char drive [_MAX_DRIVE + 1];
+ char name [_MAX_FNAME + 1];
+ char ext [_MAX_EXT + 1];
+ char fname [_MAX_PATH + 1];
+ FILE *patch_file = NULL;
+ long offset = header ? 512 : 0;
+
+ if (!(patch_file = fopen(S9xGetFilename (".ips"), "rb"))) return;
+
+ if (fread (fname, 1, 5, patch_file) != 5 || strncmp (fname, "PATCH", 5) != 0)
+ {
+ fclose (patch_file);
+ return;
+ }
+
+ int32 ofs;
+
+ for (;;)
+ {
+ long len;
+ long rlen;
+ int rchar;
+
+ ofs = ReadInt (patch_file, 3);
+ if (ofs == -1)
+ goto err_eof;
+
+ if (ofs == IPS_EOF)
+ break;
+
+ ofs -= offset;
+
+ len = ReadInt (patch_file, 2);
+ if (len == -1)
+ goto err_eof;
+
+ /* Apply patch block */
+ if (len)
+ {
+ if (ofs + len > MAX_ROM_SIZE)
+ goto err_eof;
+
+ while (len--)
+ {
+ rchar = fgetc (patch_file);
+ if (rchar == EOF)
+ goto err_eof;
+ Memory.ROM [ofs++] = (uint8) rchar;
+ }
+ if (ofs > *rom_size)
+ *rom_size = ofs;
+ }
+ else
+ {
+ rlen = ReadInt (patch_file, 2);
+ if (rlen == -1)
+ goto err_eof;
+
+
+ rchar = fgetc (patch_file);
+ if (rchar == EOF)
+ goto err_eof;
+
+ if (ofs + rlen > MAX_ROM_SIZE)
+ goto err_eof;
+
+ while (rlen--)
+ Memory.ROM [ofs++] = (uint8) rchar;
+
+ if (ofs > *rom_size)
+ *rom_size = ofs;
+ }
+ }
+
+ // Check if ROM image needs to be truncated
+ ofs = ReadInt (patch_file, 3);
+ if (ofs != -1 && ofs - offset < *rom_size)
+ {
+ // Need to truncate ROM image
+ *rom_size = ofs - offset;
+ }
+ fclose (patch_file);
+ return;
+
+err_eof:
+ if (patch_file)
+ fclose (patch_file);
+}
+
+const uint32 crc32Table[256] = {
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
+ 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+ 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
+ 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
+ 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+ 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
+ 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
+ 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
+ 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
+ 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+ 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
+ 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
+ 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+ 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
+ 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
+ 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+ 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
+ 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
+ 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+ 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
+ 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
+ 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
+ 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
+ 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+ 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
+ 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
+ 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+ 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
+ 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
+ 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
+};
+
+//CRC32 for char arrays
+uint32 caCRC32(uint8 *array, uint32 size) {
+ register uint32 crc32 = 0xFFFFFFFF;
+ for (register uint32 i = 0; i < size; i++) {
+ crc32 = ((crc32 >> 8) & 0x00FFFFFF) ^ crc32Table[(crc32 ^ array[i]) & 0xFF];
+ }
+ return ~crc32;
+}
+#include "getset.h"
diff --git a/src/memmap.cpp b/src/memmap.cpp deleted file mode 100644 index 4436fe3..0000000 --- a/src/memmap.cpp +++ /dev/null @@ -1,2758 +0,0 @@ -/*
- * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
- *
- * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
- * Jerremy Koot (jkoot@snes9x.com)
- *
- * Super FX C emulator code
- * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
- * Gary Henderson.
- * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
- *
- * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson.
- * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_.
- * C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com).
- *
- * DOS port code contains the works of other authors. See headers in
- * individual files.
- *
- * Snes9x homepage: http://www.snes9x.com
- *
- * Permission to use, copy, modify and distribute Snes9x in both binary and
- * source form, for non-commercial purposes, is hereby granted without fee,
- * providing that this license information and copyright notice appear with
- * all copies and any derived work.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event shall the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Snes9x is freeware for PERSONAL USE only. Commercial users should
- * seek permission of the copyright holders first. Commercial use includes
- * charging money for Snes9x or software derived from Snes9x.
- *
- * The copyright holders request that bug fixes and improvements to the code
- * should be forwarded to them so everyone can benefit from the modifications
- * in future versions.
- *
- * Super NES and Super Nintendo Entertainment System are trademarks of
- * Nintendo Co., Limited and its subsidiary companies.
- */
-#include <string.h>
-#include <ctype.h>
-
-#ifdef __linux
-//#include <unistd.h>
-#endif
-
-#include "snes9x.h"
-#include "memmap.h"
-#include "cpuexec.h"
-#include "ppu.h"
-#include "display.h"
-#include "cheats.h"
-#include "apu.h"
-#include "sa1.h"
-#include "srtc.h"
-#include "sdd1.h"
-
-#ifndef ZSNES_FX
-#include "fxemu.h"
-extern struct FxInit_s SuperFX;
-#else
-START_EXTERN_C
-extern uint8 *SFXPlotTable;
-END_EXTERN_C
-#endif
-
-static uint8 bytes0x2000 [0x2000];
-
-extern bool8 ROMAPUEnabled;
-
-extern char *rom_filename;
-extern bool8 LoadZip(const char* , int32 *, int32 *);
-
-bool8_32 CMemory::AllASCII (uint8 *b, int size)
-{
- for (int i = 0; i < size; i++)
- {
- if (b[i] < 32 || b[i] > 126)
- return (FALSE);
- }
- return (TRUE);
-}
-
-int CMemory::ScoreHiROM (bool8_32 skip_header)
-{
- int score = 0;
- int o = skip_header ? 0xff00 + 0x200 : 0xff00;
-
- if ((Memory.ROM [o + 0xdc] + (Memory.ROM [o + 0xdd] << 8) +
- Memory.ROM [o + 0xde] + (Memory.ROM [o + 0xdf] << 8)) == 0xffff)
- score += 2;
-
- if (Memory.ROM [o + 0xda] == 0x33)
- score += 2;
- if ((Memory.ROM [o + 0xd5] & 0xf) < 4)
- score += 2;
- if (!(Memory.ROM [o + 0xfd] & 0x80))
- score -= 4;
- if (CalculatedSize > 1024 * 1024 * 3)
- score += 4;
- if ((1 << (Memory.ROM [o + 0xd7] - 7)) > 48)
- score -= 1;
- if (!AllASCII (&Memory.ROM [o + 0xb0], 6))
- score -= 1;
- if (!AllASCII (&Memory.ROM [o + 0xc0], ROM_NAME_LEN - 1))
- score -= 1;
-
- return (score);
-}
-
-int CMemory::ScoreLoROM (bool8_32 skip_header)
-{
- int score = 0;
- int o = skip_header ? 0x7f00 + 0x200 : 0x7f00;
-
- if ((Memory.ROM [o + 0xdc] + (Memory.ROM [o + 0xdd] << 8) +
- Memory.ROM [o + 0xde] + (Memory.ROM [o + 0xdf] << 8)) == 0xffff)
- score += 2;
-
- if (Memory.ROM [o + 0xda] == 0x33)
- score += 2;
- if ((Memory.ROM [o + 0xd5] & 0xf) < 4)
- score += 2;
- if (CalculatedSize <= 1024 * 1024 * 16)
- score += 2;
- if (!(Memory.ROM [o + 0xfd] & 0x80))
- score -= 4;
- if ((1 << (Memory.ROM [o + 0xd7] - 7)) > 48)
- score -= 1;
- if (!AllASCII (&Memory.ROM [o + 0xb0], 6))
- score -= 1;
- if (!AllASCII (&Memory.ROM [o + 0xc0], ROM_NAME_LEN - 1))
- score -= 1;
-
- return (score);
-}
-
-char *CMemory::Safe (const char *s)
-{
- static char *safe = NULL;
- static int safe_len = 0;
-
- int len = strlen (s);
- if (!safe || len + 1 > safe_len)
- {
- if (safe)
- free ((char *) safe);
- safe = (char *) malloc (safe_len = len + 1);
- }
-
- for (int i = 0; i < len; i++)
- {
- if (s [i] >= 32 && s [i] < 127)
- safe [i] = s[i];
- else
- safe [i] = '?';
- }
- safe [len] = 0;
- return (safe);
-}
-
-/**********************************************************************************************/
-/* Init() */
-/* This function allocates all the memory needed by the emulator */
-/**********************************************************************************************/
-bool8_32 CMemory::Init ()
-{
- RAM = (uint8 *) malloc (0x20000);
- SRAM = (uint8 *) malloc (0x20000);
- VRAM = (uint8 *) malloc (0x10000);
- ROM = (uint8 *) malloc (MAX_ROM_SIZE + 0x200 + 0x8000);
- FillRAM = NULL;
-
- IPPU.TileCache [TILE_2BIT] = (uint8 *) malloc (MAX_2BIT_TILES * 128);
- IPPU.TileCache [TILE_4BIT] = (uint8 *) malloc (MAX_4BIT_TILES * 128);
- IPPU.TileCache [TILE_8BIT] = (uint8 *) malloc (MAX_8BIT_TILES * 128);
-
- IPPU.TileCached [TILE_2BIT] = (uint8 *) malloc (MAX_2BIT_TILES);
- IPPU.TileCached [TILE_4BIT] = (uint8 *) malloc (MAX_4BIT_TILES);
- IPPU.TileCached [TILE_8BIT] = (uint8 *) malloc (MAX_8BIT_TILES);
-
- if (!RAM || !SRAM || !VRAM || !ROM ||
- !IPPU.TileCache [TILE_2BIT] || !IPPU.TileCache [TILE_4BIT] ||
- !IPPU.TileCache [TILE_8BIT] || !IPPU.TileCached [TILE_2BIT] ||
- !IPPU.TileCached [TILE_4BIT] || !IPPU.TileCached [TILE_8BIT])
- {
- Deinit ();
- return (FALSE);
- }
-
- // FillRAM uses first 32K of ROM image area, otherwise space just
- // wasted. Might be read by the SuperFX code.
-
- FillRAM = ROM;
-
- // Add 0x8000 to ROM image pointer to stop SuperFX code accessing
- // unallocated memory (can cause crash on some ports).
- ROM += 0x8000;
-
- C4RAM = ROM + 0x400000 + 8192 * 8;
- ::ROM = ROM;
- ::SRAM = SRAM;
- ::RegRAM = FillRAM;
-
-#ifdef ZSNES_FX
- SFXPlotTable = ROM + 0x400000;
-#else
- SuperFX.pvRegisters = &Memory.FillRAM [0x3000];
- SuperFX.nRamBanks = 1;
- SuperFX.pvRam = ::SRAM;
- SuperFX.nRomBanks = (2 * 1024 * 1024) / (32 * 1024);
- SuperFX.pvRom = (uint8 *) ROM;
-#endif
-
- ZeroMemory (IPPU.TileCached [TILE_2BIT], MAX_2BIT_TILES);
- ZeroMemory (IPPU.TileCached [TILE_4BIT], MAX_4BIT_TILES);
- ZeroMemory (IPPU.TileCached [TILE_8BIT], MAX_8BIT_TILES);
-
- SDD1Data = NULL;
- SDD1Index = NULL;
-
- return (TRUE);
-}
-
-void CMemory::Deinit ()
-{
- if (RAM)
- {
- free ((char *) RAM);
- RAM = NULL;
- }
- if (SRAM)
- {
- free ((char *) SRAM);
- SRAM = NULL;
- }
- if (VRAM)
- {
- free ((char *) VRAM);
- VRAM = NULL;
- }
- if (ROM)
- {
- ROM -= 0x8000;
- free ((char *) ROM);
- ROM = NULL;
- }
-
- if (IPPU.TileCache [TILE_2BIT])
- {
- free ((char *) IPPU.TileCache [TILE_2BIT]);
- IPPU.TileCache [TILE_2BIT] = NULL;
- }
- if (IPPU.TileCache [TILE_4BIT])
- {
- free ((char *) IPPU.TileCache [TILE_4BIT]);
- IPPU.TileCache [TILE_4BIT] = NULL;
- }
- if (IPPU.TileCache [TILE_8BIT])
- {
- free ((char *) IPPU.TileCache [TILE_8BIT]);
- IPPU.TileCache [TILE_8BIT] = NULL;
- }
-
- if (IPPU.TileCached [TILE_2BIT])
- {
- free ((char *) IPPU.TileCached [TILE_2BIT]);
- IPPU.TileCached [TILE_2BIT] = NULL;
- }
- if (IPPU.TileCached [TILE_4BIT])
- {
- free ((char *) IPPU.TileCached [TILE_4BIT]);
- IPPU.TileCached [TILE_4BIT] = NULL;
- }
- if (IPPU.TileCached [TILE_8BIT])
- {
- free ((char *) IPPU.TileCached [TILE_8BIT]);
- IPPU.TileCached [TILE_8BIT] = NULL;
- }
-
- FreeSDD1Data ();
-}
-
-void CMemory::FreeSDD1Data ()
-{
- if (SDD1Index)
- {
- free ((char *) SDD1Index);
- SDD1Index = NULL;
- }
- if (SDD1Data)
- {
- free ((char *) SDD1Data);
- SDD1Data = NULL;
- }
-}
-
-/**********************************************************************************************/
-/* checkext() */
-/**********************************************************************************************/
-int checkzip( char * fn )
-{
- int cnt = strlen(fn);
- if( ( (fn[cnt-1] == 'p') || (fn[cnt-1] == 'P') ) &&
- ( (fn[cnt-2] == 'i') || (fn[cnt-2] == 'I') ) &&
- ( (fn[cnt-3] == 'z') || (fn[cnt-3] == 'Z') ) ){
- return true;
-
- }
- return false;
-}
-
-/**********************************************************************************************/
-/* LoadROM() */
-/* This function loads a Snes-Backup image */
-/**********************************************************************************************/
-bool8_32 CMemory::LoadROM (const char *filename)
-{
- unsigned long FileSize = 0;
- int retry_count = 0;
- STREAM ROMFile;
- bool8_32 Interleaved = FALSE;
- bool8_32 Tales = FALSE;
- char dir [_MAX_DIR + 1];
- char drive [_MAX_DRIVE + 1];
- char name [_MAX_FNAME + 1];
- char ext [_MAX_EXT + 1];
- char fname [_MAX_PATH + 1];
- int i;
-
- memset (&SNESGameFixes, 0, sizeof(SNESGameFixes));
- SNESGameFixes.SRAMInitialValue = 0x60;
-
- memset (bytes0x2000, 0, 0x2000);
- CPU.TriedInterleavedMode2 = FALSE;
-
- CalculatedSize = 0;
-again:
- _splitpath (filename, drive, dir, name, ext);
- _makepath (fname, drive, dir, name, ext);
-
-#ifdef __WIN32__
- memmove (&ext [0], &ext[1], 4);
-#endif
-
- int32 TotalFileSize = 0;
-
- {
- if ((ROMFile = OPEN_STREAM (fname, "rb")) == NULL)
- return (FALSE);
-
- strcpy (ROMFilename, fname);
-
- HeaderCount = 0;
- uint8 *ptr = ROM;
- bool8_32 more = FALSE;
-
- do
- {
- FileSize = READ_STREAM (ptr, MAX_ROM_SIZE + 0x200 - (ptr - ROM), ROMFile);
- CLOSE_STREAM (ROMFile);
- int calc_size = (FileSize / 0x2000) * 0x2000;
-
- if ((FileSize - calc_size == 512 && !Settings.ForceNoHeader) ||
- Settings.ForceHeader)
- {
- memmove (ptr, ptr + 512, calc_size);
- HeaderCount++;
- FileSize -= 512;
- }
- ptr += FileSize;
- TotalFileSize += FileSize;
-
- int len;
- if (ptr - ROM < MAX_ROM_SIZE + 0x200 &&
- (isdigit (ext [0]) && ext [1] == 0 && ext [0] < '9'))
- {
- more = TRUE;
- ext [0]++;
-#ifdef __WIN32__
- memmove (&ext [1], &ext [0], 4);
- ext [0] = '.';
-#endif
- _makepath (fname, drive, dir, name, ext);
- }
- else
- if (ptr - ROM < MAX_ROM_SIZE + 0x200 &&
- (((len = strlen (name)) == 7 || len == 8) &&
- strncasecmp (name, "sf", 2) == 0 &&
- isdigit (name [2]) && isdigit (name [3]) && isdigit (name [4]) &&
- isdigit (name [5]) && isalpha (name [len - 1])))
- {
- more = TRUE;
- name [len - 1]++;
-#ifdef __WIN32__
- memmove (&ext [1], &ext [0], 4);
- ext [0] = '.';
-#endif
- _makepath (fname, drive, dir, name, ext);
- }
- else
- more = FALSE;
- } while (more && (ROMFile = OPEN_STREAM (fname, "rb")) != NULL);
- }
-
- if (HeaderCount == 0)
- S9xMessage (S9X_INFO, S9X_HEADERS_INFO, "No ROM file header found.");
- else
- {
- if (HeaderCount == 1)
- S9xMessage (S9X_INFO, S9X_HEADERS_INFO,
- "Found ROM file header (and ignored it).");
- else
- S9xMessage (S9X_INFO, S9X_HEADERS_INFO,
- "Found multiple ROM file headers (and ignored them).");
- }
-
- CheckForIPSPatch (filename, HeaderCount != 0, TotalFileSize);
- int orig_hi_score, orig_lo_score;
- int hi_score, lo_score;
-
- orig_hi_score = hi_score = ScoreHiROM (FALSE);
- orig_lo_score = lo_score = ScoreLoROM (FALSE);
-
- if (HeaderCount == 0 && !Settings.ForceNoHeader &&
- ((hi_score > lo_score && ScoreHiROM (TRUE) > hi_score) ||
- (hi_score <= lo_score && ScoreLoROM (TRUE) > lo_score)))
- {
- memmove (Memory.ROM, Memory.ROM + 512, TotalFileSize - 512);
- TotalFileSize -= 512;
- S9xMessage (S9X_INFO, S9X_HEADER_WARNING,
- "Try specifying the -nhd command line option if the game doesn't work\n");
- }
-
- CalculatedSize = (TotalFileSize / 0x2000) * 0x2000;
- ZeroMemory (ROM + CalculatedSize, MAX_ROM_SIZE - CalculatedSize);
-
- // Check for cherryroms.com DAIKAIJYUMONOGATARI2
-
- if (CalculatedSize == 0x500000 &&
- strncmp ((const char *)&ROM [0x40ffc0], "DAIKAIJYUMONOGATARI2", 20) == 0 &&
- strncmp ((const char *)&ROM [0x40ffb0], "18AE6J", 6) == 0 &&
- memcmp (&ROM[0x40ffb0], &ROM [0xffb0], 0x30))
- {
- memmove (&ROM[0x100000], ROM, 0x500000);
- memmove (ROM, &ROM[0x500000], 0x100000);
- }
-
- Interleaved = Settings.ForceInterleaved || Settings.ForceInterleaved2;
- if (Settings.ForceLoROM || (!Settings.ForceHiROM && lo_score >= hi_score))
- {
- LoROM = TRUE;
- HiROM = FALSE;
-
- // Ignore map type byte if not 0x2x or 0x3x
- if ((ROM [0x7fd5] & 0xf0) == 0x20 || (ROM [0x7fd5] & 0xf0) == 0x30)
- {
- switch (ROM [0x7fd5] & 0xf)
- {
- case 1:
- if (strncmp ((char *) &ROM [0x7fc0], "TREASURE HUNTER G", 17) != 0)
- Interleaved = TRUE;
- break;
- case 2:
-#if 0
- if (!Settings.ForceLoROM &&
- strncmp ((char *) &ROM [0x7fc0], "SUPER FORMATION SOCCE", 21) != 0 &&
- strncmp ((char *) &ROM [0x7fc0], "Star Ocean", 10) != 0)
- {
- LoROM = FALSE;
- HiROM = TRUE;
- }
-#endif
- break;
- case 5:
- Interleaved = TRUE;
- Tales = TRUE;
- break;
- }
- }
- }
- else
- {
- if ((ROM [0xffd5] & 0xf0) == 0x20 || (ROM [0xffd5] & 0xf0) == 0x30)
- {
- switch (ROM [0xffd5] & 0xf)
- {
- case 0:
- case 3:
- Interleaved = TRUE;
- break;
- }
- }
- LoROM = FALSE;
- HiROM = TRUE;
- }
-
- // More
- if (!Settings.ForceHiROM && !Settings.ForceLoROM &&
- !Settings.ForceInterleaved && !Settings.ForceInterleaved2 &&
- !Settings.ForceNotInterleaved && !Settings.ForcePAL &&
- !Settings.ForceSuperFX && !Settings.ForceDSP1 &&
- !Settings.ForceSA1 && !Settings.ForceC4 &&
- !Settings.ForceSDD1)
- {
- if (strncmp ((char *) &ROM [0x7fc0], "YUYU NO QUIZ DE GO!GO!", 22) == 0)
- {
- LoROM = TRUE;
- HiROM = FALSE;
- Interleaved = FALSE;
- }
- else
- if (strncmp ((char *) &ROM [0x7fc0], "SP MOMOTAROU DENTETSU2", 22) == 0)
- {
- LoROM = TRUE;
- HiROM = FALSE;
- Interleaved = FALSE;
- }
- else
- if (CalculatedSize == 0x100000 &&
- strncmp ((char *) &ROM [0xffc0], "WWF SUPER WRESTLEMANIA", 22) == 0)
- {
- int cvcount;
-
- memmove (&ROM[0x100000] , ROM, 0x100000);
- for (cvcount = 0; cvcount < 16; cvcount++)
- {
- memmove (&ROM[0x8000 * cvcount], &ROM[0x10000 * cvcount + 0x100000 + 0x8000], 0x8000);
- memmove (&ROM[0x8000 * cvcount + 0x80000], &ROM[0x10000 * cvcount + 0x100000], 0x8000);
- }
- LoROM = TRUE;
- HiROM = FALSE;
- ZeroMemory (ROM + CalculatedSize, MAX_ROM_SIZE - CalculatedSize);
- }
- }
-
- if (!Settings.ForceNotInterleaved && Interleaved)
- {
- CPU.TriedInterleavedMode2 = TRUE;
- S9xMessage (S9X_INFO, S9X_ROM_INTERLEAVED_INFO,
- "ROM image is in interleaved format - converting...");
-
- int nblocks = CalculatedSize >> 16;
-#if 0
- int step = 64;
-
- while (nblocks <= step)
- step >>= 1;
-
- nblocks = step;
-#endif
- uint8 blocks [256];
-
- if (Tales)
- {
- nblocks = 0x60;
- for (i = 0; i < 0x40; i += 2)
- {
- blocks [i + 0] = (i >> 1) + 0x20;
- blocks [i + 1] = (i >> 1) + 0x00;
- }
- for (i = 0; i < 0x80; i += 2)
- {
- blocks [i + 0x40] = (i >> 1) + 0x80;
- blocks [i + 0x41] = (i >> 1) + 0x40;
- }
- LoROM = FALSE;
- HiROM = TRUE;
- }
- else
- if (Settings.ForceInterleaved2)
- {
- for (i = 0; i < nblocks * 2; i++)
- {
- blocks [i] = (i & ~0x1e) | ((i & 2) << 2) | ((i & 4) << 2) |
- ((i & 8) >> 2) | ((i & 16) >> 2);
- }
- }
- else
- {
- bool8_32 t = LoROM;
-
- LoROM = HiROM;
- HiROM = t;
-
- for (i = 0; i < nblocks; i++)
- {
- blocks [i * 2] = i + nblocks;
- blocks [i * 2 + 1] = i;
- }
- }
-
- uint8 *tmp = (uint8 *) malloc (0x8000);
- if (tmp)
- {
- for (i = 0; i < nblocks * 2; i++)
- {
- for (int j = i; j < nblocks * 2; j++)
- {
- if (blocks [j] == i)
- {
- memmove (tmp, &ROM [blocks [j] * 0x8000], 0x8000);
- memmove (&ROM [blocks [j] * 0x8000],
- &ROM [blocks [i] * 0x8000], 0x8000);
- memmove (&ROM [blocks [i] * 0x8000], tmp, 0x8000);
- uint8 b = blocks [j];
- blocks [j] = blocks [i];
- blocks [i] = b;
- break;
- }
- }
- }
- free ((char *) tmp);
- }
-
- hi_score = ScoreHiROM (FALSE);
- lo_score = ScoreLoROM (FALSE);
-
- if ((HiROM &&
- (lo_score >= hi_score || hi_score < 0)) ||
- (LoROM &&
- (hi_score > lo_score || lo_score < 0)))
- {
- if (retry_count == 0)
- {
- S9xMessage (S9X_INFO, S9X_ROM_CONFUSING_FORMAT_INFO,
- "ROM lied about its type! Trying again.");
- Settings.ForceNotInterleaved = TRUE;
- Settings.ForceInterleaved = FALSE;
- retry_count++;
- goto again;
- }
- }
- }
- FreeSDD1Data ();
- InitROM (Tales);
-
- S9xLoadCheatFile (S9xGetFilename(".cht"));
- S9xInitCheatData ();
- S9xApplyCheats ();
-
- S9xReset ();
-
- return (TRUE);
-}
-
-void S9xDeinterleaveMode2 ()
-{
- S9xMessage (S9X_INFO, S9X_ROM_INTERLEAVED_INFO,
- "ROM image is in interleaved format - converting...");
-
- int nblocks = Memory.CalculatedSize >> 15;
- int step = 64;
-
- while (nblocks <= step)
- step >>= 1;
-
- nblocks = step;
- uint8 blocks [256];
- int i;
-
- for (i = 0; i < nblocks * 2; i++)
- {
- blocks [i] = (i & ~0x1e) | ((i & 2) << 2) | ((i & 4) << 2) |
- ((i & 8) >> 2) | ((i & 16) >> 2);
- }
-
- uint8 *tmp = (uint8 *) malloc (0x8000);
-
- if (tmp)
- {
- for (i = 0; i < nblocks * 2; i++)
- {
- for (int j = i; j < nblocks * 2; j++)
- {
- if (blocks [j] == i)
- {
- memmove (tmp, &Memory.ROM [blocks [j] * 0x8000], 0x8000);
- memmove (&Memory.ROM [blocks [j] * 0x8000],
- &Memory.ROM [blocks [i] * 0x8000], 0x8000);
- memmove (&Memory.ROM [blocks [i] * 0x8000], tmp, 0x8000);
- uint8 b = blocks [j];
- blocks [j] = blocks [i];
- blocks [i] = b;
- break;
- }
- }
- }
- free ((char *) tmp);
- }
- Memory.InitROM (FALSE);
- S9xReset ();
-}
-
-void CMemory::InitROM (bool8_32 Interleaved)
-{
-#ifndef ZSNES_FX
- SuperFX.nRomBanks = CalculatedSize >> 15;
-#endif
- Settings.MultiPlayer5Master = Settings.MultiPlayer5;
- Settings.MouseMaster = Settings.Mouse;
- Settings.SuperScopeMaster = Settings.SuperScope;
- Settings.DSP1Master = Settings.ForceDSP1;
- Settings.SuperFX = FALSE;
- Settings.SA1 = FALSE;
- Settings.C4 = FALSE;
- Settings.SDD1 = FALSE;
- Settings.SRTC = FALSE;
-
- ZeroMemory (BlockIsRAM, MEMMAP_NUM_BLOCKS);
- ZeroMemory (BlockIsROM, MEMMAP_NUM_BLOCKS);
-
- ::SRAM = SRAM;
- memset (ROMId, 0, 5);
- memset (CompanyId, 0, 3);
-
- if (Memory.HiROM)
- {
- Memory.SRAMSize = ROM [0xffd8];
- strncpy (ROMName, (char *) &ROM[0xffc0], ROM_NAME_LEN - 1);
- ROMSpeed = ROM [0xffd5];
- ROMType = ROM [0xffd6];
- ROMSize = ROM [0xffd7];
- ROMChecksum = ROM [0xffde] + (ROM [0xffdf] << 8);
- ROMComplementChecksum = ROM [0xffdc] + (ROM [0xffdd] << 8);
-
- memmove (ROMId, &ROM [0xffb2], 4);
- memmove (CompanyId, &ROM [0xffb0], 2);
-
- // Try to auto-detect the DSP1 chip
- if (!Settings.ForceNoDSP1 &&
- (ROMType & 0xf) >= 3 && (ROMType & 0xf0) == 0)
- Settings.DSP1Master = TRUE;
-
- Settings.SDD1 = Settings.ForceSDD1;
- if ((ROMType & 0xf0) == 0x40)
- Settings.SDD1 = !Settings.ForceNoSDD1;
-
- if (Settings.BS)
- BSHiROMMap ();
- else
- if ((ROMSpeed & ~0x10) == 0x25)
- TalesROMMap (Interleaved);
- else
- if ((ROMSpeed & ~0x10) == 0x22 &&
- strncmp (ROMName, "Super Street Fighter", 20) != 0)
- {
- AlphaROMMap ();
- }
- else
- HiROMMap ();
- }
- else
- {
- Memory.HiROM = FALSE;
- Memory.SRAMSize = ROM [0x7fd8];
- ROMSpeed = ROM [0x7fd5];
- ROMType = ROM [0x7fd6];
- ROMSize = ROM [0x7fd7];
- ROMChecksum = ROM [0x7fde] + (ROM [0x7fdf] << 8);
- ROMComplementChecksum = ROM [0x7fdc] + (ROM [0x7fdd] << 8);
- memmove (ROMId, &ROM [0x7fb2], 4);
- memmove (CompanyId, &ROM [0x7fb0], 2);
-
- strncpy (ROMName, (char *) &ROM[0x7fc0], ROM_NAME_LEN - 1);
- Settings.SuperFX = Settings.ForceSuperFX;
-
- if ((ROMType & 0xf0) == 0x10)
- Settings.SuperFX = !Settings.ForceNoSuperFX;
-
- // Try to auto-detect the DSP1 chip
- if (!Settings.ForceNoDSP1 &&
- (ROMType & 0xf) >= 3 && (ROMType & 0xf0) == 0)
- Settings.DSP1Master = TRUE;
-
- Settings.SDD1 = Settings.ForceSDD1;
- if ((ROMType & 0xf0) == 0x40)
- Settings.SDD1 = !Settings.ForceNoSDD1;
-
- if (Settings.SDD1)
- S9xLoadSDD1Data ();
-
- Settings.C4 = Settings.ForceC4;
- if ((ROMType & 0xf0) == 0xf0 &&
- (strncmp (ROMName, "MEGAMAN X", 9) == 0 ||
- strncmp (ROMName, "ROCKMAN X", 9) == 0))
- {
- Settings.C4 = !Settings.ForceNoC4;
- }
-
- if (Settings.SuperFX)
- {
- //::SRAM = ROM + 1024 * 1024 * 4;
- SuperFXROMMap ();
- Settings.MultiPlayer5Master = FALSE;
- //Settings.MouseMaster = FALSE;
- //Settings.SuperScopeMaster = FALSE;
- Settings.DSP1Master = FALSE;
- Settings.SA1 = FALSE;
- Settings.C4 = FALSE;
- Settings.SDD1 = FALSE;
- }
- else
- if (Settings.ForceSA1 ||
- (!Settings.ForceNoSA1 && (ROMSpeed & ~0x10) == 0x23 &&
- (ROMType & 0xf) > 3 && (ROMType & 0xf0) == 0x30))
- {
- Settings.SA1 = TRUE;
- Settings.MultiPlayer5Master = FALSE;
- //Settings.MouseMaster = FALSE;
- //Settings.SuperScopeMaster = FALSE;
- Settings.DSP1Master = FALSE;
- Settings.C4 = FALSE;
- Settings.SDD1 = FALSE;
- SA1ROMMap ();
- }
- else
- if ((ROMSpeed & ~0x10) == 0x25)
- TalesROMMap (Interleaved);
- else
- if (strncmp ((char *) &Memory.ROM [0x7fc0], "SOUND NOVEL-TCOOL", 17) == 0 ||
- strncmp ((char *) &Memory.ROM [0x7fc0], "DERBY STALLION 96", 17) == 0)
- {
- LoROM24MBSMap ();
- Settings.DSP1Master = FALSE;
- }
- else
- if (strncmp ((char *) &Memory.ROM [0x7fc0], "THOROUGHBRED BREEDER3", 21) == 0 ||
- strncmp ((char *) &Memory.ROM [0x7fc0], "RPG-TCOOL 2", 11) == 0)
- {
- SRAM512KLoROMMap ();
- Settings.DSP1Master = FALSE;
- }
- else
- if (strncmp ((char *) &Memory.ROM [0x7fc0], "DEZAEMON ", 10) == 0)
- {
- Settings.DSP1Master = FALSE;
- SRAM1024KLoROMMap ();
- }
- else
- if (strncmp ((char *) &Memory.ROM [0x7fc0], "ADD-ON BASE CASSETE", 19) == 0)
- {
- Settings.MultiPlayer5Master = FALSE;
- Settings.MouseMaster = FALSE;
- Settings.SuperScopeMaster = FALSE;
- Settings.DSP1Master = FALSE;
- SufamiTurboLoROMMap();
- Memory.SRAMSize = 3;
- }
- else
- if ((ROMSpeed & ~0x10) == 0x22 &&
- strncmp (ROMName, "Super Street Fighter", 20) != 0)
- {
- AlphaROMMap ();
- }
- else
- LoROMMap ();
- }
-
- int power2 = 0;
- int size = CalculatedSize;
-
- while (size >>= 1)
- power2++;
-
- size = 1 << power2;
- uint32 remainder = CalculatedSize - size;
-
- uint32 sum1 = 0;
- uint32 sum2 = 0;
-
- int i;
-
- for (i = 0; i < size; i++)
- sum1 += ROM [i];
-
- for (i = 0; i < (int) remainder; i++)
- sum2 += ROM [size + i];
-
- if (remainder)
- {
- //for Tengai makyou
- if (CalculatedSize == 0x500000 && Memory.HiROM &&
- strncmp ((const char *)&ROM[0xffb0], "18AZ", 4) == 0 &&
- !memcmp(&ROM[0xffd5], "\x3a\xf9\x0d\x03\x00\x33\x00", 7))
- sum1 += sum2;
- else
- sum1 += sum2 * (size / remainder);
- }
-
- sum1 &= 0xffff;
-
- CalculatedChecksum = caCRC32(&ROM[0], CalculatedSize);
- if (Settings.ForceNTSC)
- Settings.PAL = FALSE;
- else
- if (Settings.ForcePAL)
- Settings.PAL = TRUE;
- else
- if (Memory.HiROM)
- // Country code
- Settings.PAL = ROM [0xffd9] >= 2;
- else
- Settings.PAL = ROM [0x7fd9] >= 2;
-
- if (Settings.PAL)
- {
- Settings.FrameTime = Settings.FrameTimePAL;
- Memory.ROMFramesPerSecond = 50;
- }
- else
- {
- Settings.FrameTime = Settings.FrameTimeNTSC;
- Memory.ROMFramesPerSecond = 60;
- }
-
- ROMName[ROM_NAME_LEN - 1] = 0;
- if (strlen (ROMName))
- {
- char *p = ROMName + strlen (ROMName) - 1;
-
- while (p > ROMName && *(p - 1) == ' ')
- p--;
- *p = 0;
- }
-
- if (Settings.SuperFX)
- {
- CPU.Memory_SRAMMask = 0xffff;
- Memory.SRAMSize = 16;
- }
- else
- {
- CPU.Memory_SRAMMask = Memory.SRAMSize ?
- ((1 << (Memory.SRAMSize + 3)) * 128) - 1 : 0;
- }
-
- IAPU.OneCycle = ONE_APU_CYCLE;
- Settings.Shutdown = Settings.ShutdownMaster;
-
- SetDSP = &DSP1SetByte;
- GetDSP = &DSP1GetByte;
-
- ApplyROMFixes ();
- sprintf (ROMName, "%s", Safe (ROMName));
- sprintf (ROMId, "%s", Safe (ROMId));
- sprintf (CompanyId, "%s", Safe (CompanyId));
-
- sprintf (String, "\"%s\" [%s] %s, %s, Type: %s, Mode: %s, TV: %s, S-RAM: %s, ROMId: %s Company: %2.2s",
- ROMName,
- (ROMChecksum + ROMComplementChecksum != 0xffff ||
- ROMChecksum != sum1) ? "bad checksum" : "checksum ok",
- MapType (),
- Size (),
- KartContents (),
- MapMode (),
- TVStandard (),
- StaticRAMSize (),
- ROMId,
- CompanyId);
-
- S9xMessage (S9X_INFO, S9X_ROM_INFO, String);
-}
-
-bool8_32 CMemory::LoadSRAM (const char *filename)
-{
- int size = Memory.SRAMSize ?
- (1 << (Memory.SRAMSize + 3)) * 128 : 0;
-
- memset (SRAM, SNESGameFixes.SRAMInitialValue, 0x20000);
-
- if (size > 0x20000)
- size = 0x20000;
-
- if (size)
- {
- FILE *file;
- if ((file = fopen(filename, "rb")))
- {
- int len = fread ((char*) ::SRAM, 1, 0x20000, file);
- fclose (file);
- if (len - size == 512)
- {
- // S-RAM file has a header - remove it
- memmove (::SRAM, ::SRAM + 512, size);
- }
- if (len == size + SRTC_SRAM_PAD)
- {
- S9xSRTCPostLoadState ();
- S9xResetSRTC ();
- rtc.index = -1;
- rtc.mode = MODE_READ;
- }
- else
- S9xHardResetSRTC ();
-
- return (TRUE);
- }
- S9xHardResetSRTC ();
- return (FALSE);
- }
-
- return (TRUE);
-}
-
-bool8_32 CMemory::SaveSRAM (const char *filename)
-{
- int size = Memory.SRAMSize ?
- (1 << (Memory.SRAMSize + 3)) * 128 : 0;
- if (Settings.SRTC)
- {
- size += SRTC_SRAM_PAD;
- S9xSRTCPreSaveState ();
- }
-
-
- if (size > 0x20000)
- size = 0x20000;
-
- if (size && *Memory.ROMFilename)
- {
- FILE *file;
- if ((file = fopen (filename, "wb")))
- {
- fwrite ((char *) ::SRAM, size, 1, file);
- fclose (file);
- //sync();
-#if defined(__linux)
- //chown (filename, getuid (), getgid ());
-#endif
- return (TRUE);
- }
- }
- return (FALSE);
-}
-
-void CMemory::FixROMSpeed ()
-{
- int c;
-
- for (c = 0x800; c < 0x1000; c++)
- {
- if (BlockIsROM [c])
- MemorySpeed [c] = (uint8) CPU.FastROMSpeed;
- }
-}
-
-void CMemory::WriteProtectROM ()
-{
- memmove ((void *) WriteMap, (void *) Map, sizeof (Map));
- for (int c = 0; c < 0x1000; c++)
- {
- if (BlockIsROM [c])
- WriteMap [c] = (uint8 *) MAP_NONE;
- }
-}
-
-void CMemory::MapRAM ()
-{
- int c;
-
- // Banks 7e->7f, RAM
- for (c = 0; c < 16; c++)
- {
- Map [c + 0x7e0] = RAM;
- Map [c + 0x7f0] = RAM + 0x10000;
- BlockIsRAM [c + 0x7e0] = TRUE;
- BlockIsRAM [c + 0x7f0] = TRUE;
- BlockIsROM [c + 0x7e0] = FALSE;
- BlockIsROM [c + 0x7f0] = FALSE;
- }
-
- // Banks 70->77, S-RAM
- for (c = 0; c < 0x80; c++)
- {
- Map [c + 0x700] = (uint8 *) MAP_LOROM_SRAM;
- BlockIsRAM [c + 0x700] = TRUE;
- BlockIsROM [c + 0x700] = FALSE;
- }
-}
-
-void CMemory::MapExtraRAM ()
-{
- int c;
-
- // Banks 7e->7f, RAM
- for (c = 0; c < 16; c++)
- {
- Map [c + 0x7e0] = RAM;
- Map [c + 0x7f0] = RAM + 0x10000;
- BlockIsRAM [c + 0x7e0] = TRUE;
- BlockIsRAM [c + 0x7f0] = TRUE;
- BlockIsROM [c + 0x7e0] = FALSE;
- BlockIsROM [c + 0x7f0] = FALSE;
- }
-
- // Banks 70->73, S-RAM
- for (c = 0; c < 16; c++)
- {
- Map [c + 0x700] = ::SRAM;
- Map [c + 0x710] = ::SRAM + 0x8000;
- Map [c + 0x720] = ::SRAM + 0x10000;
- Map [c + 0x730] = ::SRAM + 0x18000;
-
- BlockIsRAM [c + 0x700] = TRUE;
- BlockIsROM [c + 0x700] = FALSE;
- BlockIsRAM [c + 0x710] = TRUE;
- BlockIsROM [c + 0x710] = FALSE;
- BlockIsRAM [c + 0x720] = TRUE;
- BlockIsROM [c + 0x720] = FALSE;
- BlockIsRAM [c + 0x730] = TRUE;
- BlockIsROM [c + 0x730] = FALSE;
- }
-}
-
-void CMemory::LoROMMap ()
-{
- int c;
- int i;
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x400; c += 16)
- {
- Map [c + 0] = Map [c + 0x800] = RAM;
- Map [c + 1] = Map [c + 0x801] = RAM;
- BlockIsRAM [c + 0] = BlockIsRAM [c + 0x800] = TRUE;
- BlockIsRAM [c + 1] = BlockIsRAM [c + 0x801] = TRUE;
-
- Map [c + 2] = Map [c + 0x802] = (uint8 *) MAP_PPU;
- Map [c + 3] = Map [c + 0x803] = (uint8 *) MAP_PPU;
- Map [c + 4] = Map [c + 0x804] = (uint8 *) MAP_CPU;
- Map [c + 5] = Map [c + 0x805] = (uint8 *) MAP_CPU;
- if (Settings.DSP1Master)
- {
- Map [c + 6] = Map [c + 0x806] = (uint8 *) MAP_DSP;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) MAP_DSP;
- }
- else
- if (Settings.C4)
- {
- Map [c + 6] = Map [c + 0x806] = (uint8 *) MAP_C4;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) MAP_C4;
- }
- else
- {
- Map [c + 6] = Map [c + 0x806] = (uint8 *) bytes0x2000 - 0x6000;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) bytes0x2000 - 0x6000;
- }
-
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = Map [i + 0x800] = &ROM [(c << 11) % CalculatedSize] - 0x8000;
- BlockIsROM [i] = BlockIsROM [i + 0x800] = TRUE;
- }
-
- for (i = c; i < c + 16; i++)
- {
- int ppu = i & 15;
-
- MemorySpeed [i] =
- MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
- }
- }
-
- if (Settings.DSP1Master)
- {
- // Banks 30->3f and b0->bf
- for (c = 0x300; c < 0x400; c += 16)
- {
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = Map [i + 0x800] = (uint8 *) MAP_DSP;
- BlockIsROM [i] = BlockIsROM [i + 0x800] = FALSE;
- }
- }
- }
-
- // Banks 40->7f and c0->ff
- for (c = 0; c < 0x400; c += 16)
- {
- for (i = c; i < c + 8; i++)
- Map [i + 0x400] = Map [i + 0xc00] = &ROM [(c << 11) % CalculatedSize];
-
- for (i = c + 8; i < c + 16; i++)
- Map [i + 0x400] = Map [i + 0xc00] = &ROM [((c << 11) + 0x200000) % CalculatedSize - 0x8000];
-
- for (i = c; i < c + 16; i++)
- {
- MemorySpeed [i + 0x400] = MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
- BlockIsROM [i + 0x400] = BlockIsROM [i + 0xc00] = TRUE;
- }
- }
-
- if (Settings.DSP1Master)
- {
- for (c = 0; c < 0x100; c++)
- {
- Map [c + 0xe00] = (uint8 *) MAP_DSP;
- MemorySpeed [c + 0xe00] = SLOW_ONE_CYCLE;
- BlockIsROM [c + 0xe00] = FALSE;
- }
- }
- MapRAM ();
- WriteProtectROM ();
-}
-
-void CMemory::HiROMMap ()
-{
- int c;
- int i;
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x400; c += 16)
- {
- Map [c + 0] = Map [c + 0x800] = RAM;
- BlockIsRAM [c + 0] = BlockIsRAM [c + 0x800] = TRUE;
- Map [c + 1] = Map [c + 0x801] = RAM;
- BlockIsRAM [c + 1] = BlockIsRAM [c + 0x801] = TRUE;
-
- Map [c + 2] = Map [c + 0x802] = (uint8 *) MAP_PPU;
- Map [c + 3] = Map [c + 0x803] = (uint8 *) MAP_PPU;
- Map [c + 4] = Map [c + 0x804] = (uint8 *) MAP_CPU;
- Map [c + 5] = Map [c + 0x805] = (uint8 *) MAP_CPU;
- if (Settings.DSP1Master)
- {
- Map [c + 6] = Map [c + 0x806] = (uint8 *) MAP_DSP;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) MAP_DSP;
- }
- else
- {
- Map [c + 6] = Map [c + 0x806] = (uint8 *) MAP_NONE;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) MAP_NONE;
- }
-
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = Map [i + 0x800] = &ROM [(c << 12) % CalculatedSize];
- BlockIsROM [i] = BlockIsROM [i + 0x800] = TRUE;
- }
-
- for (i = c; i < c + 16; i++)
- {
- int ppu = i & 15;
-
- MemorySpeed [i] =
- MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
- }
- }
-
- // Banks 30->3f and b0->bf, address ranges 6000->7fff is S-RAM.
- for (c = 0; c < 16; c++)
- {
- Map [0x306 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
- Map [0x307 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
- Map [0xb06 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
- Map [0xb07 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
- BlockIsRAM [0x306 + (c << 4)] = TRUE;
- BlockIsRAM [0x307 + (c << 4)] = TRUE;
- BlockIsRAM [0xb06 + (c << 4)] = TRUE;
- BlockIsRAM [0xb07 + (c << 4)] = TRUE;
- }
-
- // Banks 40->7f and c0->ff
- for (c = 0; c < 0x400; c += 16)
- {
- for (i = c; i < c + 16; i++)
- {
- Map [i + 0x400] = Map [i + 0xc00] = &ROM [(c << 12) % CalculatedSize];
- MemorySpeed [i + 0x400] = MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
- BlockIsROM [i + 0x400] = BlockIsROM [i + 0xc00] = TRUE;
- }
- }
-
- MapRAM ();
- WriteProtectROM ();
-}
-
-void CMemory::TalesROMMap (bool8_32 Interleaved)
-{
- int c;
- int i;
-
- uint32 OFFSET0 = 0x400000;
- uint32 OFFSET1 = 0x400000;
- uint32 OFFSET2 = 0x000000;
-
- if (Interleaved)
- {
- OFFSET0 = 0x000000;
- OFFSET1 = 0x000000;
- OFFSET2 = 0x200000;
- }
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x400; c += 16)
- {
- Map [c + 0] = Map [c + 0x800] = RAM;
- Map [c + 1] = Map [c + 0x801] = RAM;
- BlockIsRAM [c + 0] = BlockIsRAM [c + 0x800] = TRUE;
- BlockIsRAM [c + 1] = BlockIsRAM [c + 0x801] = TRUE;
-
- Map [c + 2] = Map [c + 0x802] = (uint8 *) MAP_PPU;
- Map [c + 3] = Map [c + 0x803] = (uint8 *) MAP_PPU;
- Map [c + 4] = Map [c + 0x804] = (uint8 *) MAP_CPU;
- Map [c + 5] = Map [c + 0x805] = (uint8 *) MAP_CPU;
- Map [c + 6] = Map [c + 0x806] = (uint8 *) MAP_NONE;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) MAP_NONE;
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = &ROM [((c << 12) + OFFSET0) % CalculatedSize];
- Map [i + 0x800] = &ROM [((c << 12) + OFFSET0) % CalculatedSize];
- BlockIsROM [i] = TRUE;
- BlockIsROM [i + 0x800] = TRUE;
- }
-
- for (i = c; i < c + 16; i++)
- {
- int ppu = i & 15;
-
- MemorySpeed [i] =
- MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
- }
- }
-
- // Banks 30->3f and b0->bf, address ranges 6000->7ffff is S-RAM.
- for (c = 0; c < 16; c++)
- {
- Map [0x306 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
- Map [0x307 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
- Map [0xb06 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
- Map [0xb07 + (c << 4)] = (uint8 *) MAP_HIROM_SRAM;
- BlockIsRAM [0x306 + (c << 4)] = TRUE;
- BlockIsRAM [0x307 + (c << 4)] = TRUE;
- BlockIsRAM [0xb06 + (c << 4)] = TRUE;
- BlockIsRAM [0xb07 + (c << 4)] = TRUE;
- }
-
- // Banks 40->7f and c0->ff
- for (c = 0; c < 0x400; c += 16)
- {
- for (i = c; i < c + 8; i++)
- {
- Map [i + 0x400] = &ROM [((c << 12) + OFFSET1) % CalculatedSize];
- Map [i + 0x408] = &ROM [((c << 12) + OFFSET1) % CalculatedSize];
- Map [i + 0xc00] = &ROM [((c << 12) + OFFSET2) % CalculatedSize];
- Map [i + 0xc08] = &ROM [((c << 12) + OFFSET2) % CalculatedSize];
- BlockIsROM [i + 0x400] = TRUE;
- BlockIsROM [i + 0x408] = TRUE;
- BlockIsROM [i + 0xc00] = TRUE;
- BlockIsROM [i + 0xc08] = TRUE;
- MemorySpeed [i + 0x400] = MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
- MemorySpeed [i + 0x408] = MemorySpeed [i + 0xc08] = SLOW_ONE_CYCLE;
- }
- }
- MapRAM ();
- WriteProtectROM ();
-}
-
-void CMemory::AlphaROMMap ()
-{
- int c;
- int i;
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x400; c += 16)
- {
- Map [c + 0] = Map [c + 0x800] = RAM;
- Map [c + 1] = Map [c + 0x801] = RAM;
- BlockIsRAM [c + 0] = BlockIsRAM [c + 0x800] = TRUE;
- BlockIsRAM [c + 1] = BlockIsRAM [c + 0x801] = TRUE;
-
- Map [c + 2] = Map [c + 0x802] = (uint8 *) MAP_PPU;
- Map [c + 3] = Map [c + 0x803] = (uint8 *) MAP_PPU;
- Map [c + 4] = Map [c + 0x804] = (uint8 *) MAP_CPU;
- Map [c + 5] = Map [c + 0x805] = (uint8 *) MAP_CPU;
- Map [c + 6] = Map [c + 0x806] = (uint8 *) MAP_DSP;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) MAP_DSP;
-
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = Map [i + 0x800] = &ROM [c << 11] - 0x8000;
- BlockIsROM [i] = TRUE;
- }
-
- for (i = c; i < c + 16; i++)
- {
- int ppu = i & 15;
-
- MemorySpeed [i] =
- MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
- }
- }
-
- // Banks 40->7f and c0->ff
-
- for (c = 0; c < 0x400; c += 16)
- {
- for (i = c; i < c + 16; i++)
- {
- Map [i + 0x400] = &ROM [(c << 12) % CalculatedSize];
- Map [i + 0xc00] = &ROM [(c << 12) % CalculatedSize];
- MemorySpeed [i + 0x400] = MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
- BlockIsROM [i + 0x400] = BlockIsROM [i + 0xc00] = TRUE;
- }
- }
-
- MapRAM ();
- WriteProtectROM ();
-}
-
-void CMemory::SuperFXROMMap ()
-{
- int c;
- int i;
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x400; c += 16)
- {
- Map [c + 0] = Map [c + 0x800] = RAM;
- Map [c + 1] = Map [c + 0x801] = RAM;
- BlockIsRAM [c + 0] = BlockIsRAM [c + 0x800] = TRUE;
- BlockIsRAM [c + 1] = BlockIsRAM [c + 0x801] = TRUE;
-
- Map [c + 2] = Map [c + 0x802] = (uint8 *) MAP_PPU;
- Map [c + 3] = Map [c + 0x803] = (uint8 *) MAP_PPU;
- Map [c + 4] = Map [c + 0x804] = (uint8 *) MAP_CPU;
- Map [c + 5] = Map [c + 0x805] = (uint8 *) MAP_CPU;
- Map [c + 6] = Map [c + 0x806] = (uint8 *) MAP_DSP;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) MAP_DSP;
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = Map [i + 0x800] = &ROM [c << 11] - 0x8000;
- BlockIsROM [i] = BlockIsROM [i + 0x800] = TRUE;
- }
-
- for (i = c; i < c + 8; i++)
- {
- int ppu = i & 15;
-
- MemorySpeed [i] =
- MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
- }
- }
-
- // Banks 40->7f and c0->ff
- for (c = 0; c < 0x400; c += 16)
- {
- for (i = c; i < c + 16; i++)
- {
- Map [i + 0x400] = Map [i + 0xc00] = &ROM [(c << 12) % CalculatedSize];
- MemorySpeed [i + 0x400] = MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
- BlockIsROM [i + 0x400] = BlockIsROM [i + 0xc00] = TRUE;
- }
- }
-
- // Banks 7e->7f, RAM
- for (c = 0; c < 16; c++)
- {
- Map [c + 0x7e0] = RAM;
- Map [c + 0x7f0] = RAM + 0x10000;
- BlockIsRAM [c + 0x7e0] = TRUE;
- BlockIsRAM [c + 0x7f0] = TRUE;
- BlockIsROM [c + 0x7e0] = FALSE;
- BlockIsROM [c + 0x7f0] = FALSE;
- }
-
- // Banks 70->71, S-RAM
- for (c = 0; c < 32; c++)
- {
- Map [c + 0x700] = ::SRAM + (((c >> 4) & 1) << 16);
- BlockIsRAM [c + 0x700] = TRUE;
- BlockIsROM [c + 0x700] = FALSE;
- }
-
- // Banks 00->3f and 80->bf address ranges 6000->7fff is RAM.
- for (c = 0; c < 0x40; c++)
- {
- Map [0x006 + (c << 4)] = (uint8 *) ::SRAM - 0x6000;
- Map [0x007 + (c << 4)] = (uint8 *) ::SRAM - 0x6000;
- Map [0x806 + (c << 4)] = (uint8 *) ::SRAM - 0x6000;
- Map [0x807 + (c << 4)] = (uint8 *) ::SRAM - 0x6000;
- BlockIsRAM [0x006 + (c << 4)] = TRUE;
- BlockIsRAM [0x007 + (c << 4)] = TRUE;
- BlockIsRAM [0x806 + (c << 4)] = TRUE;
- BlockIsRAM [0x807 + (c << 4)] = TRUE;
- }
- // Replicate the first 2Mb of the ROM at ROM + 2MB such that each 32K
- // block is repeated twice in each 64K block.
- for (c = 0; c < 64; c++)
- {
- memmove (&ROM [0x200000 + c * 0x10000], &ROM [c * 0x8000], 0x8000);
- memmove (&ROM [0x208000 + c * 0x10000], &ROM [c * 0x8000], 0x8000);
- }
-
- WriteProtectROM ();
-}
-
-void CMemory::SA1ROMMap ()
-{
- int c;
- int i;
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x400; c += 16)
- {
- Map [c + 0] = Map [c + 0x800] = RAM;
- Map [c + 1] = Map [c + 0x801] = RAM;
- BlockIsRAM [c + 0] = BlockIsRAM [c + 0x800] = TRUE;
- BlockIsRAM [c + 1] = BlockIsRAM [c + 0x801] = TRUE;
-
- Map [c + 2] = Map [c + 0x802] = (uint8 *) MAP_PPU;
- Map [c + 3] = Map [c + 0x803] = (uint8 *) &Memory.FillRAM [0x3000] - 0x3000;
- Map [c + 4] = Map [c + 0x804] = (uint8 *) MAP_CPU;
- Map [c + 5] = Map [c + 0x805] = (uint8 *) MAP_CPU;
- Map [c + 6] = Map [c + 0x806] = (uint8 *) MAP_BWRAM;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) MAP_BWRAM;
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = Map [i + 0x800] = &ROM [c << 11] - 0x8000;
- BlockIsROM [i] = BlockIsROM [i + 0x800] = TRUE;
- }
-
- for (i = c; i < c + 16; i++)
- {
- int ppu = i & 15;
-
- MemorySpeed [i] =
- MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
- }
- }
-
- // Banks 40->7f
- for (c = 0; c < 0x400; c += 16)
- {
- for (i = c; i < c + 16; i++)
- Map [i + 0x400] = (uint8 *) &SRAM [(c << 12) & 0x1ffff];
-
- for (i = c; i < c + 16; i++)
- {
- MemorySpeed [i + 0x400] = SLOW_ONE_CYCLE;
- BlockIsROM [i + 0x400] = FALSE;
- }
- }
-
- // c0->ff
- for (c = 0; c < 0x400; c += 16)
- {
- for (i = c; i < c + 16; i++)
- {
- Map [i + 0xc00] = &ROM [(c << 12) % CalculatedSize];
- MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
- BlockIsROM [i + 0xc00] = TRUE;
- }
- }
-
- for (c = 0; c < 16; c++)
- {
- Map [c + 0x7e0] = RAM;
- Map [c + 0x7f0] = RAM + 0x10000;
- BlockIsRAM [c + 0x7e0] = TRUE;
- BlockIsRAM [c + 0x7f0] = TRUE;
- BlockIsROM [c + 0x7e0] = FALSE;
- BlockIsROM [c + 0x7f0] = FALSE;
- }
- WriteProtectROM ();
-
-#ifdef USE_SA1
- // Now copy the map and correct it for the SA1 CPU.
- memmove ((void *) SA1_WriteMap, (void *) WriteMap, sizeof (WriteMap));
- memmove ((void *) SA1_Map, (void *) Map, sizeof (Map));
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x400; c += 16)
- {
- SA1_Map [c + 0] = SA1_Map [c + 0x800] = &Memory.FillRAM [0x3000];
- SA1_Map [c + 1] = SA1_Map [c + 0x801] = (uint8 *) MAP_NONE;
- SA1_WriteMap [c + 0] = SA1_WriteMap [c + 0x800] = &Memory.FillRAM [0x3000];
- SA1_WriteMap [c + 1] = SA1_WriteMap [c + 0x801] = (uint8 *) MAP_NONE;
- }
-
- // Banks 60->6f
- for (c = 0; c < 0x100; c++)
- SA1_Map [c + 0x600] = SA1_WriteMap [c + 0x600] = (uint8 *) MAP_BWRAM_BITMAP;
-#endif // USE_SA1
-
- BWRAM = SRAM;
-}
-
-void CMemory::LoROM24MBSMap ()
-{
- int c;
- int i;
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x400; c += 16)
- {
- Map [c + 0] = Map [c + 0x800] = RAM;
- Map [c + 1] = Map [c + 0x801] = RAM;
- BlockIsRAM [c + 0] = BlockIsRAM [c + 0x800] = TRUE;
- BlockIsRAM [c + 1] = BlockIsRAM [c + 0x801] = TRUE;
-
- Map [c + 2] = Map [c + 0x802] = (uint8 *) MAP_PPU;
- Map [c + 3] = Map [c + 0x803] = (uint8 *) MAP_PPU;
- Map [c + 4] = Map [c + 0x804] = (uint8 *) MAP_CPU;
- Map [c + 5] = Map [c + 0x805] = (uint8 *) MAP_CPU;
- Map [c + 6] = Map [c + 0x806] = (uint8 *) MAP_NONE;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) MAP_NONE;
-
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = Map [i + 0x800] = &ROM [c << 11] - 0x8000;
- BlockIsROM [i] = BlockIsROM [i + 0x800] = TRUE;
- }
-
- for (i = c; i < c + 16; i++)
- {
- int ppu = i & 15;
-
- MemorySpeed [i] =
- MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
- }
- }
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x200; c += 16)
- {
- Map [c + 0x800] = RAM;
- Map [c + 0x801] = RAM;
- BlockIsRAM [c + 0x800] = TRUE;
- BlockIsRAM [c + 0x801] = TRUE;
-
- Map [c + 0x802] = (uint8 *) MAP_PPU;
- Map [c + 0x803] = (uint8 *) MAP_PPU;
- Map [c + 0x804] = (uint8 *) MAP_CPU;
- Map [c + 0x805] = (uint8 *) MAP_CPU;
- Map [c + 0x806] = (uint8 *) MAP_NONE;
- Map [c + 0x807] = (uint8 *) MAP_NONE;
-
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i + 0x800] = &ROM [c << 11] - 0x8000 + 0x200000;
- BlockIsROM [i + 0x800] = TRUE;
- }
-
- for (i = c; i < c + 16; i++)
- {
- int ppu = i & 15;
-
- MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
- }
- }
-
- // Banks 40->7f and c0->ff
- for (c = 0; c < 0x400; c += 16)
- {
- for (i = c; i < c + 8; i++)
- Map [i + 0x400] = Map [i + 0xc00] = &ROM [(c << 11) + 0x200000];
-
- for (i = c + 8; i < c + 16; i++)
- Map [i + 0x400] = Map [i + 0xc00] = &ROM [(c << 11) + 0x200000 - 0x8000];
-
- for (i = c; i < c + 16; i++)
- {
- MemorySpeed [i + 0x400] = MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
- BlockIsROM [i + 0x400] = BlockIsROM [i + 0xc00] = TRUE;
- }
- }
-
- MapExtraRAM ();
- WriteProtectROM ();
-}
-
-void CMemory::SufamiTurboLoROMMap ()
-{
- int c;
- int i;
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x400; c += 16)
- {
- Map [c + 0] = Map [c + 0x800] = RAM;
- Map [c + 1] = Map [c + 0x801] = RAM;
- BlockIsRAM [c + 0] = BlockIsRAM [c + 0x800] = TRUE;
- BlockIsRAM [c + 1] = BlockIsRAM [c + 0x801] = TRUE;
-
- Map [c + 2] = Map [c + 0x802] = (uint8 *) MAP_PPU;
- Map [c + 3] = Map [c + 0x803] = (uint8 *) MAP_PPU;
- Map [c + 4] = Map [c + 0x804] = (uint8 *) MAP_CPU;
- Map [c + 5] = Map [c + 0x805] = (uint8 *) MAP_CPU;
- if (Settings.DSP1Master)
- {
- Map [c + 6] = Map [c + 0x806] = (uint8 *) MAP_DSP;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) MAP_DSP;
- }
- else
- {
- Map [c + 6] = Map [c + 0x806] = (uint8 *) MAP_NONE;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) MAP_NONE;
- }
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = Map [i + 0x800] = &ROM [c << 11] - 0x8000;
- BlockIsROM [i] = BlockIsROM [i + 0x800] = TRUE;
- }
-
- for (i = c; i < c + 16; i++)
- {
- int ppu = i & 15;
-
- MemorySpeed [i] =
- MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
- }
- }
-
- if (Settings.DSP1Master)
- {
- // Banks 30->3f and b0->bf
- for (c = 0x300; c < 0x400; c += 16)
- {
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = Map [i + 0x800] = (uint8 *) MAP_DSP;
- BlockIsROM [i] = BlockIsROM [i + 0x800] = FALSE;
- }
- }
- }
-
- // Banks 40->7f and c0->ff
- for (c = 0; c < 0x400; c += 16)
- {
- for (i = c; i < c + 8; i++)
- Map [i + 0x400] = Map [i + 0xc00] = &ROM [(c << 11) + 0x200000];
-
- for (i = c + 8; i < c + 16; i++)
- Map [i + 0x400] = Map [i + 0xc00] = &ROM [(c << 11) + 0x200000 - 0x8000];
-
- for (i = c; i < c + 16; i++)
- {
- MemorySpeed [i + 0x400] = MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
- BlockIsROM [i + 0x400] = BlockIsROM [i + 0xc00] = TRUE;
- }
- }
-
- if (Settings.DSP1Master)
- {
- for (c = 0; c < 0x100; c++)
- {
- Map [c + 0xe00] = (uint8 *) MAP_DSP;
- MemorySpeed [c + 0xe00] = SLOW_ONE_CYCLE;
- BlockIsROM [c + 0xe00] = FALSE;
- }
- }
-
- // Banks 7e->7f, RAM
- for (c = 0; c < 16; c++)
- {
- Map [c + 0x7e0] = RAM;
- Map [c + 0x7f0] = RAM + 0x10000;
- BlockIsRAM [c + 0x7e0] = TRUE;
- BlockIsRAM [c + 0x7f0] = TRUE;
- BlockIsROM [c + 0x7e0] = FALSE;
- BlockIsROM [c + 0x7f0] = FALSE;
- }
-
- // Banks 60->67, S-RAM
- for (c = 0; c < 0x80; c++)
- {
- Map [c + 0x600] = (uint8 *) MAP_LOROM_SRAM;
- BlockIsRAM [c + 0x600] = TRUE;
- BlockIsROM [c + 0x600] = FALSE;
- }
-
- WriteProtectROM ();
-}
-
-void CMemory::SRAM512KLoROMMap ()
-{
- int c;
- int i;
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x400; c += 16)
- {
- Map [c + 0] = Map [c + 0x800] = RAM;
- Map [c + 1] = Map [c + 0x801] = RAM;
- BlockIsRAM [c + 0] = BlockIsRAM [c + 0x800] = TRUE;
- BlockIsRAM [c + 1] = BlockIsRAM [c + 0x801] = TRUE;
-
- Map [c + 2] = Map [c + 0x802] = (uint8 *) MAP_PPU;
- Map [c + 3] = Map [c + 0x803] = (uint8 *) MAP_PPU;
- Map [c + 4] = Map [c + 0x804] = (uint8 *) MAP_CPU;
- Map [c + 5] = Map [c + 0x805] = (uint8 *) MAP_CPU;
- Map [c + 6] = Map [c + 0x806] = (uint8 *) MAP_NONE;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) MAP_NONE;
-
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = Map [i + 0x800] = &ROM [c << 11] - 0x8000;
- BlockIsROM [i] = BlockIsROM [i + 0x800] = TRUE;
- }
-
- for (i = c; i < c + 16; i++)
- {
- int ppu = i & 15;
-
- MemorySpeed [i] =
- MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
- }
- }
-
- // Banks 40->7f and c0->ff
- for (c = 0; c < 0x400; c += 16)
- {
- for (i = c; i < c + 8; i++)
- Map [i + 0x400] = Map [i + 0xc00] = &ROM [(c << 11) + 0x200000];
-
- for (i = c + 8; i < c + 16; i++)
- Map [i + 0x400] = Map [i + 0xc00] = &ROM [(c << 11) + 0x200000 - 0x8000];
-
- for (i = c; i < c + 16; i++)
- {
- MemorySpeed [i + 0x400] = MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
- BlockIsROM [i + 0x400] = BlockIsROM [i + 0xc00] = TRUE;
-
-
- }
- }
-
- MapExtraRAM ();
- WriteProtectROM ();
-}
-
-void CMemory::SRAM1024KLoROMMap ()
-{
- int c;
- int i;
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x400; c += 16)
- {
- Map [c + 0] = Map [c + 0x800] = Map [c + 0x400] = Map [c + 0xc00] = RAM;
- Map [c + 1] = Map [c + 0x801] = Map [c + 0x401] = Map [c + 0xc01] = RAM;
- BlockIsRAM [c + 0] = BlockIsRAM [c + 0x800] = BlockIsRAM [c + 0x400] = BlockIsRAM [c + 0xc00] = TRUE;
- BlockIsRAM [c + 1] = BlockIsRAM [c + 0x801] = BlockIsRAM [c + 0x401] = BlockIsRAM [c + 0xc01] = TRUE;
-
- Map [c + 2] = Map [c + 0x802] = Map [c + 0x402] = Map [c + 0xc02] = (uint8 *) MAP_PPU;
- Map [c + 3] = Map [c + 0x803] = Map [c + 0x403] = Map [c + 0xc03] = (uint8 *) MAP_PPU;
- Map [c + 4] = Map [c + 0x804] = Map [c + 0x404] = Map [c + 0xc04] = (uint8 *) MAP_CPU;
- Map [c + 5] = Map [c + 0x805] = Map [c + 0x405] = Map [c + 0xc05] = (uint8 *) MAP_CPU;
- Map [c + 6] = Map [c + 0x806] = Map [c + 0x406] = Map [c + 0xc06] = (uint8 *) MAP_NONE;
- Map [c + 7] = Map [c + 0x807] = Map [c + 0x407] = Map [c + 0xc07] = (uint8 *) MAP_NONE;
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = Map [i + 0x800] = Map [i + 0x400] = Map [i + 0xc00] = &ROM [c << 11] - 0x8000;
- BlockIsROM [i] = BlockIsROM [i + 0x800] = BlockIsROM [i + 0x400] = BlockIsROM [i + 0xc00] = TRUE;
- }
-
- for (i = c; i < c + 16; i++)
- {
- int ppu = i & 15;
-
- MemorySpeed [i] = MemorySpeed [i + 0x800] =
- MemorySpeed [i + 0x400] = MemorySpeed [i + 0xc00] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
- }
- }
-
- MapExtraRAM ();
- WriteProtectROM ();
-}
-
-void CMemory::BSHiROMMap ()
-{
- int c;
- int i;
-
- // Banks 00->3f and 80->bf
- for (c = 0; c < 0x400; c += 16)
- {
- Map [c + 0] = Map [c + 0x800] = RAM;
- BlockIsRAM [c + 0] = BlockIsRAM [c + 0x800] = TRUE;
- Map [c + 1] = Map [c + 0x801] = RAM;
- BlockIsRAM [c + 1] = BlockIsRAM [c + 0x801] = TRUE;
-
- Map [c + 2] = Map [c + 0x802] = (uint8 *) MAP_PPU;
- Map [c + 3] = Map [c + 0x803] = (uint8 *) MAP_PPU;
- Map [c + 4] = Map [c + 0x804] = (uint8 *) MAP_CPU;
- // XXX: How large is SRAM??
- Map [c + 5] = Map [c + 0x805] = (uint8 *) SRAM;
- BlockIsRAM [c + 5] = BlockIsRAM [c + 0x805] = TRUE;
- Map [c + 6] = Map [c + 0x806] = (uint8 *) MAP_NONE;
- Map [c + 7] = Map [c + 0x807] = (uint8 *) MAP_NONE;
-
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = Map [i + 0x800] = &ROM [(c << 12) % CalculatedSize];
- BlockIsROM [i] = BlockIsROM [i + 0x800] = TRUE;
- }
-
- for (i = c; i < c + 16; i++)
- {
- int ppu = i & 15;
-
- MemorySpeed [i] =
- MemorySpeed [i + 0x800] = ppu >= 2 && ppu <= 3 ? ONE_CYCLE : SLOW_ONE_CYCLE;
- }
- }
-
- // Banks 60->7d offset 0000->7fff & 60->7f offset 8000->ffff PSRAM
- // XXX: How large is PSRAM?
- for (c = 0x600; c < 0x7e0; c += 16)
- {
- for (i = c; i < c + 8; i++)
- {
- Map [i] = &ROM [0x400000 + (c << 11)];
- BlockIsRAM [i] = TRUE;
- }
- for (i = c + 8; i < c + 16; i++)
- {
- Map [i] = &ROM [0x400000 + (c << 11) - 0x8000];
- BlockIsRAM [i] = TRUE;
- }
- }
-
- // Banks 40->7f and c0->ff
- for (c = 0; c < 0x400; c += 16)
- {
- for (i = c; i < c + 16; i++)
- {
- Map [i + 0x400] = Map [i + 0xc00] = &ROM [(c << 12) % CalculatedSize];
- MemorySpeed [i + 0x400] = MemorySpeed [i + 0xc00] = SLOW_ONE_CYCLE;
- BlockIsROM [i + 0x400] = BlockIsROM [i + 0xc00] = TRUE;
- }
- }
-
- MapRAM ();
- WriteProtectROM ();
-}
-
-const char *CMemory::TVStandard ()
-{
- return (Settings.PAL ? "PAL" : "NTSC");
-}
-
-const char *CMemory::Speed ()
-{
- return (ROMSpeed & 0x10 ? "120ns" : "200ns");
-}
-
-const char *CMemory::MapType ()
-{
- return (HiROM ? "HiROM" : "LoROM");
-}
-
-const char *CMemory::StaticRAMSize ()
-{
- static char tmp [20];
-
- if (Memory.SRAMSize > 16)
- return ("Corrupt");
- sprintf (tmp, "%dKb", (CPU.Memory_SRAMMask + 1) / 1024);
- return (tmp);
-}
-
-const char *CMemory::Size ()
-{
- static char tmp [20];
-
- if (ROMSize < 7 || ROMSize - 7 > 23)
- return ("Corrupt");
- sprintf (tmp, "%dMbits", 1 << (ROMSize - 7));
- return (tmp);
-}
-
-const char *CMemory::KartContents ()
-{
- static char tmp [30];
- static const char *CoPro [16] = {
- "DSP1", "SuperFX", "OBC1", "SA-1", "S-DD1", "S-RTC", "CoPro#6",
- "CoPro#7", "CoPro#8", "CoPro#9", "CoPro#10", "CoPro#11", "CoPro#12",
- "CoPro#13", "CoPro#14", "CoPro-Custom"
- };
- static const char *Contents [3] = {
- "ROM", "ROM+RAM", "ROM+RAM+BAT"
- };
- if (ROMType == 0)
- return ("ROM only");
-
- sprintf (tmp, "%s", Contents [(ROMType & 0xf) % 3]);
-
- if ((ROMType & 0xf) >= 3)
- sprintf (tmp, "%s+%s", tmp, CoPro [(ROMType & 0xf0) >> 4]);
-
- return (tmp);
-}
-
-const char *CMemory::MapMode ()
-{
- static char tmp [4];
- sprintf (tmp, "%02x", ROMSpeed & ~0x10);
- return (tmp);
-}
-
-const char *CMemory::ROMID ()
-{
- return (ROMId);
-}
-
-void CMemory::ApplyROMFixes ()
-{
- ROMAPUEnabled = 0;
- DSP1.version = 0;
- //Settings.HBlankStart = (256 * Settings.H_Max) / SNES_HCOUNTER_MAX;
- if (strncmp(ROMName, "DUNGEON MASTER", 14) == 0)
- {
- DSP1.version = 1;
- SetDSP=&DSP2SetByte;
- GetDSP=&DSP2GetByte;
- }
-
- //OAM hacks because we don't fully understand the
- //behavior of the SNES.
-
- //possibly an RTO issue?
- //part of Fred's club is drawn over his face.
- if(strncmp(ROMName, "THE FLINTSTONES TTOSM", 21)==0)
- {
- SNESGameFixes.Flintstones=true;
- }
-
- if(strncmp(ROMName, "SUPER MARIO KART", 16)==0
- || strncmp(ROMName, "F-ZERO", 6)==0)
- {
- SNESGameFixes.Mode7Hack=true;
- }
-
- //Totally wacky display...
- //seems to need a disproven behavior, so
- //we're definitely overlooking some other bug?
- if(strncmp(ROMName, "UNIRACERS", 9)==0)
- SNESGameFixes.Uniracers=true;
-
- // Enable S-RTC (Real Time Clock) emulation for Dai Kaijyu Monogatari 2
- Settings.SRTC = ((ROMType & 0xf0) >> 4) == 5;
-
- Settings.StrikeGunnerOffsetHack = strcmp (ROMName, "STRIKE GUNNER") == 0 ? 7 : 0;
-
- CPU.NMITriggerPoint = 4;
- if (strcmp (ROMName, "CACOMA KNIGHT") == 0)
- CPU.NMITriggerPoint = 25;
-
- // These games complain if the multi-player adaptor is 'connected'
- if (strcmp (ROMName, "TETRIS&Dr.MARIO") == 0 ||
- strcmp (ROMName, "JIGSAW PARTY") == 0 ||
- strcmp (ROMName, "SUPER PICROSS") == 0 ||
- strcmp (ROMName, "KIRBY NO KIRA KIZZU") == 0 ||
- strcmp (ROMName, "BLOCK") == 0 ||
- strncmp (ROMName, "SUPER BOMBLISS", 14) == 0 ||
- strcmp (ROMId, "ABOJ") == 0)
- {
- Settings.MultiPlayer5Master = FALSE;
- Settings.MouseMaster = FALSE;
- Settings.SuperScopeMaster = FALSE;
- }
-
- // Games which spool sound samples between the SNES and sound CPU using
- // H-DMA as the sample is playing.
- if (strcmp (ROMName, "EARTHWORM JIM 2") == 0 ||
- strcmp (ROMName, "PRIMAL RAGE") == 0 ||
- strcmp (ROMName, "CLAY FIGHTER") == 0 ||
- strcmp (ROMName, "ClayFighter 2") == 0 ||
- strncasecmp (ROMName, "MADDEN", 6) == 0 ||
- strncmp (ROMName, "NHL", 3) == 0 ||
- strcmp (ROMName, "WEAPONLORD") == 0)
- {
- Settings.Shutdown = FALSE;
- }
-
-
- // Stunt Racer FX
- if (strcmp (ROMId, "CQ ") == 0 ||
- // Illusion of Gaia
- strncmp (ROMId, "JG", 2) == 0 ||
- strcmp (ROMName, "GAIA GENSOUKI 1 JPN") == 0)
- {
- IAPU.OneCycle = 13;
- ROMAPUEnabled |= 2;
- CPU.APU_APUExecuting |= 2;
- }
-
- // RENDERING RANGER R2
- if (strcmp (ROMId, "AVCJ") == 0 ||
- // Star Ocean
- strncmp (ROMId, "ARF", 3) == 0 ||
- // Tales of Phantasia
- strncmp (ROMId, "ATV", 3) == 0 ||
- // Act Raiser 1 & 2
- strncasecmp (ROMName, "ACTRAISER", 9) == 0 ||
- strncasecmp (ROMName, "ActRaiser", 9) == 0 || // I kown both sentences are supposed to be equivalent each other but they aren't on my compiler
- // Soulblazer
- strcmp (ROMName, "SOULBLAZER - 1 USA") == 0 ||
- strcmp (ROMName, "SOULBLADER - 1") == 0 ||
- strncmp (ROMName, "SOULBLAZER 1",12) == 0 ||
- // Terranigma
- strncmp (ROMId, "AQT", 3) == 0 ||
- // Robotrek
- strncmp (ROMId, "E9 ", 3) == 0 ||
- strcmp (ROMName, "SLAP STICK 1 JPN") == 0 ||
- // ZENNIHON PURORESU2
- strncmp (ROMId, "APR", 3) == 0 ||
- // Bomberman 4
- strncmp (ROMId, "A4B", 3) == 0 ||
- // UFO KAMEN YAKISOBAN
- strncmp (ROMId, "Y7 ", 3) == 0 ||
- strncmp (ROMId, "Y9 ", 3) == 0 ||
- // Panic Bomber World
- strncmp (ROMId, "APB", 3) == 0 ||
- ((strncmp (ROMName, "Parlor", 6) == 0 ||
- strcmp (ROMName, "HEIWA PARLOR!MINI8") == 0 ||
- strncmp (ROMName, "SANKYO Fever! フィーバー!", 21) == 0) &&
- strcmp (CompanyId, "A0") == 0) ||
- strcmp (ROMName, "DARK KINGDOM") == 0 ||
- strcmp (ROMName, "ZAN3 SFC") == 0 ||
- strcmp (ROMName, "HIOUDEN") == 0 ||
- strcmp (ROMName, "テンシノウタ") == 0 ||
- strcmp (ROMName, "FORTUNE QUEST") == 0 ||
- strcmp (ROMName, "FISHING TO BASSING") == 0 ||
- strncmp (ROMName, "TOKYODOME '95BATTLE 7", 21) == 0 ||
- strcmp (ROMName, "OHMONO BLACKBASS") == 0)
- {
- IAPU.OneCycle = 15;
- // notaz: strangely enough, these games work properly with my hack enabled
- if (strcmp (ROMId, "AVCJ") != 0)
- ROMAPUEnabled |= 2;
- CPU.APU_APUExecuting |= 2;
- }
-
- if (strcmp (ROMName, "BATMAN--REVENGE JOKER") == 0)
- {
- Memory.HiROM = FALSE;
- Memory.LoROM = TRUE;
- LoROMMap ();
- }
- Settings.StarfoxHack = strcmp (ROMName, "STAR FOX") == 0 ||
- strcmp (ROMName, "STAR WING") == 0;
- Settings.WinterGold = strcmp (ROMName, "FX SKIING NINTENDO 96") == 0 ||
- strcmp (ROMName, "DIRT RACER") == 0 ||
- strcmp (ROMName, "Stunt Race FX") == 0 ||
- Settings.StarfoxHack;
- Settings.ChuckRock = strcmp (ROMName, "CHUCK ROCK") == 0;
- Settings.Dezaemon = strcmp (ROMName, "DEZAEMON") == 0;
-
- if (strcmp (ROMName, "RADICAL DREAMERS") == 0 ||
- strcmp (ROMName, "TREASURE CONFLIX") == 0)
- {
- int c;
-
- for (c = 0; c < 0x80; c++)
- {
- Map [c + 0x700] = ROM + 0x200000 + 0x1000 * (c & 0xf0);
- BlockIsRAM [c + 0x700] = TRUE;
- BlockIsROM [c + 0x700] = FALSE;
- }
- for (c = 0; c < 0x400; c += 16)
- {
- Map [c + 5] = Map [c + 0x805] = ROM + 0x300000;
- BlockIsRAM [c + 5] = BlockIsRAM [c + 0x805] = TRUE;
- }
- WriteProtectROM ();
- }
-
- Settings.H_Max = (SNES_CYCLES_PER_SCANLINE *
- Settings.CyclesPercentage) / 100;
-
- // A Couple of HDMA related hacks - Lantus
- if ((strcmp(ROMName, "SFX SUPERBUTOUDEN2")==0) ||
- (strcmp(ROMName, "ALIEN vs. PREDATOR")==0) ||
- (strcmp(ROMName, "STONE PROTECTORS")==0) ||
- (strcmp(ROMName, "SUPER BATTLETANK 2")==0))
- Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 130) / 100;
-
- if (strcmp (ROMId, "ASRJ") == 0 && Settings.CyclesPercentage == 100)
- // Street Racer
- Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 95) / 100;
-
- // Power Rangers Fight
- if (strncmp (ROMId, "A3R", 3) == 0 ||
- // Clock Tower
- strncmp (ROMId, "AJE", 3) == 0)
- Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 103) / 100;
-
- if (strcmp (ROMId, "AWVP") == 0 || strcmp (ROMId, "AWVE") == 0 ||
- strcmp (ROMId, "AWVJ") == 0)
- {
- // Wrestlemania Arcade
-#if 0
- if (Settings.CyclesPercentage == 100)
- Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 140) / 100; // Fixes sound
-#endif
- Settings.WrestlemaniaArcade = TRUE;
- }
- // Theme Park - disable offset-per-tile mode.
- if (strcmp (ROMId, "ATQP") == 0)
- Settings.WrestlemaniaArcade = TRUE;
-
- if (strncmp (ROMId, "A3M", 3) == 0 && Settings.CyclesPercentage == 100)
- // Mortal Kombat 3. Fixes cut off speech sample
- Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 110) / 100;
-
- if (strcmp (ROMName, "\x0bd\x0da\x0b2\x0d4\x0b0\x0bd\x0de") == 0 &&
- Settings.CyclesPercentage == 100)
- Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 101) / 100;
-
- if (strcmp (ROMName, "WILD TRAX") == 0 ||
- strcmp (ROMName, "YOSSY'S ISLAND") == 0 ||
- strcmp (ROMName, "YOSHI'S ISLAND") == 0)
- CPU.TriedInterleavedMode2 = TRUE;
-
- // Start Trek: Deep Sleep 9
- if (strncmp (ROMId, "A9D", 3) == 0 && Settings.CyclesPercentage == 100)
- Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 110) / 100;
-
- Settings.APURAMInitialValue = 0xff;
-
- if (strcmp (ROMName, "キュウヤク・メガミテンセイ") == 0 ||
- strcmp (ROMName, "KENTOUOU WORLDCHAMPIO") == 0 ||
- strcmp (ROMName, "TKO SUPERCHAMPIONSHIP") == 0 ||
- strcmp (ROMName, "TKO SUPER CHAMPIONSHI") == 0 ||
- strcmp (ROMName, "IHATOVO STORY") == 0 ||
- strcmp (ROMName, "WANDERERS FROM YS") == 0 ||
- strcmp (ROMName, "SUPER GENTYOUHISHI") == 0 ||
- // Panic Bomber World
- strncmp (ROMId, "APB", 3) == 0)
- {
- Settings.APURAMInitialValue = 0;
- }
-
- Settings.DaffyDuck = strcmp (ROMName, "DAFFY DUCK: MARV MISS") == 0;
- Settings.HBlankStart = (256 * Settings.H_Max) / SNES_HCOUNTER_MAX;
-
-#ifdef USE_SA1
- SA1.WaitAddress = NULL;
- SA1.WaitByteAddress1 = NULL;
- SA1.WaitByteAddress2 = NULL;
-
- /* Bass Fishing */
- if (strcmp (ROMId, "ZBPJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x0093f1 >> MEMMAP_SHIFT] + 0x93f1;
- SA1.WaitByteAddress1 = FillRAM + 0x304a;
- }
- /* DAISENRYAKU EXPERTWW2 */
- if (strcmp (ROMId, "AEVJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x0ed18d >> MEMMAP_SHIFT] + 0xd18d;
- SA1.WaitByteAddress1 = FillRAM + 0x3000;
- }
- /* debjk2 */
- if (strcmp (ROMId, "A2DJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x008b62 >> MEMMAP_SHIFT] + 0x8b62;
- }
- /* Dragon Ballz HD */
- if (strcmp (ROMId, "AZIJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x008083 >> MEMMAP_SHIFT] + 0x8083;
- SA1.WaitByteAddress1 = FillRAM + 0x3020;
- }
- /* SFC SDGUNDAMGNEXT */
- if (strcmp (ROMId, "ZX3J") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x0087f2 >> MEMMAP_SHIFT] + 0x87f2;
- SA1.WaitByteAddress1 = FillRAM + 0x30c4;
- }
- /* ShougiNoHanamichi */
- if (strcmp (ROMId, "AARJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0xc1f85a >> MEMMAP_SHIFT] + 0xf85a;
- SA1.WaitByteAddress1 = SRAM + 0x0c64;
- SA1.WaitByteAddress2 = SRAM + 0x0c66;
- }
- /* KATO HIFUMI9DAN SYOGI */
- if (strcmp (ROMId, "A23J") == 0)
- {
- SA1.WaitAddress = SA1_Map [0xc25037 >> MEMMAP_SHIFT] + 0x5037;
- SA1.WaitByteAddress1 = SRAM + 0x0c06;
- SA1.WaitByteAddress2 = SRAM + 0x0c08;
- }
- /* idaten */
- if (strcmp (ROMId, "AIIJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0xc100be >> MEMMAP_SHIFT] + 0x00be;
- SA1.WaitByteAddress1 = SRAM + 0x1002;
- SA1.WaitByteAddress2 = SRAM + 0x1004;
- }
- /* igotais */
- if (strcmp (ROMId, "AITJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x0080b7 >> MEMMAP_SHIFT] + 0x80b7;
- }
- /* J96 DREAM STADIUM */
- if (strcmp (ROMId, "AJ6J") == 0)
- {
- SA1.WaitAddress = SA1_Map [0xc0f74a >> MEMMAP_SHIFT] + 0xf74a;
- }
- /* JumpinDerby */
- if (strcmp (ROMId, "AJUJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x00d926 >> MEMMAP_SHIFT] + 0xd926;
- }
- /* JKAKINOKI SHOUGI */
- if (strcmp (ROMId, "AKAJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x00f070 >> MEMMAP_SHIFT] + 0xf070;
- }
- /* HOSHI NO KIRBY 3 & KIRBY'S DREAM LAND 3 JAP & US */
- if (strcmp (ROMId, "AFJJ") == 0 || strcmp (ROMId, "AFJE") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x0082d4 >> MEMMAP_SHIFT] + 0x82d4;
- SA1.WaitByteAddress1 = SRAM + 0x72a4;
- }
- /* KIRBY SUPER DELUXE JAP */
- if (strcmp (ROMId, "AKFJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x008c93 >> MEMMAP_SHIFT] + 0x8c93;
- SA1.WaitByteAddress1 = FillRAM + 0x300a;
- SA1.WaitByteAddress2 = FillRAM + 0x300e;
- }
- /* KIRBY SUPER DELUXE US */
- if (strcmp (ROMId, "AKFE") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x008cb8 >> MEMMAP_SHIFT] + 0x8cb8;
- SA1.WaitByteAddress1 = FillRAM + 0x300a;
- SA1.WaitByteAddress2 = FillRAM + 0x300e;
- }
- /* SUPER MARIO RPG JAP & US */
- if (strcmp (ROMId, "ARWJ") == 0 || strcmp (ROMId, "ARWE") == 0)
- {
- SA1.WaitAddress = SA1_Map [0xc0816f >> MEMMAP_SHIFT] + 0x816f;
- SA1.WaitByteAddress1 = FillRAM + 0x3000;
- }
- /* marvelous.zip */
- if (strcmp (ROMId, "AVRJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x0085f2 >> MEMMAP_SHIFT] + 0x85f2;
- SA1.WaitByteAddress1 = FillRAM + 0x3024;
- }
- /* AUGUSTA3 MASTERS NEW */
- if (strcmp (ROMId, "AO3J") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x00dddb >> MEMMAP_SHIFT] + 0xdddb;
- SA1.WaitByteAddress1 = FillRAM + 0x37b4;
- }
- /* OSHABERI PARODIUS */
- if (strcmp (ROMId, "AJOJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x8084e5 >> MEMMAP_SHIFT] + 0x84e5;
- }
- /* PANIC BOMBER WORLD */
- if (strcmp (ROMId, "APBJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x00857a >> MEMMAP_SHIFT] + 0x857a;
- }
- /* PEBBLE BEACH NEW */
- if (strcmp (ROMId, "AONJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x00df33 >> MEMMAP_SHIFT] + 0xdf33;
- SA1.WaitByteAddress1 = FillRAM + 0x37b4;
- }
- /* PGA EUROPEAN TOUR */
- if (strcmp (ROMId, "AEPE") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x003700 >> MEMMAP_SHIFT] + 0x3700;
- SA1.WaitByteAddress1 = FillRAM + 0x3102;
- }
- /* PGA TOUR 96 */
- if (strcmp (ROMId, "A3GE") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x003700 >> MEMMAP_SHIFT] + 0x3700;
- SA1.WaitByteAddress1 = FillRAM + 0x3102;
- }
- /* POWER RANGERS 4 */
- if (strcmp (ROMId, "A4RE") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x009899 >> MEMMAP_SHIFT] + 0x9899;
- SA1.WaitByteAddress1 = FillRAM + 0x3000;
- }
- /* PACHISURO PALUSUPE */
- if (strcmp (ROMId, "AGFJ") == 0)
- {
- // Never seems to turn on the SA-1!
- }
- /* SD F1 GRAND PRIX */
- if (strcmp (ROMId, "AGFJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x0181bc >> MEMMAP_SHIFT] + 0x81bc;
- }
- /* SHOUGI MARJONG */
- if (strcmp (ROMId, "ASYJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x00f2cc >> MEMMAP_SHIFT] + 0xf2cc;
- SA1.WaitByteAddress1 = SRAM + 0x7ffe;
- SA1.WaitByteAddress2 = SRAM + 0x7ffc;
- }
- /* shogisai2 */
- if (strcmp (ROMId, "AX2J") == 0)
- {
- SA1.WaitAddress = SA1_Map [0x00d675 >> MEMMAP_SHIFT] + 0xd675;
- }
-
- /* SHINING SCORPION */
- if (strcmp (ROMId, "A4WJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0xc048be >> MEMMAP_SHIFT] + 0x48be;
- }
- /* SHIN SHOUGI CLUB */
- if (strcmp (ROMId, "AHJJ") == 0)
- {
- SA1.WaitAddress = SA1_Map [0xc1002a >> MEMMAP_SHIFT] + 0x002a;
- SA1.WaitByteAddress1 = SRAM + 0x0806;
- SA1.WaitByteAddress2 = SRAM + 0x0808;
- }
-#endif // USE_SA1
-
- // Additional game fixes by sanmaiwashi ...
- if (strcmp (ROMName, "SFX ナイトガンダムモノガタリ 1") == 0)
- {
- bytes0x2000 [0xb18] = 0x4c;
- bytes0x2000 [0xb19] = 0x4b;
- bytes0x2000 [0xb1a] = 0xea;
- }
-
- if (strcmp (ROMName, "GOGO ACKMAN3") == 0 ||
- strcmp (ROMName, "HOME ALONE") == 0)
- {
- // Banks 00->3f and 80->bf
- for (int c = 0; c < 0x400; c += 16)
- {
- Map [c + 6] = Map [c + 0x806] = SRAM;
- Map [c + 7] = Map [c + 0x807] = SRAM;
- BlockIsROM [c + 6] = BlockIsROM [c + 0x806] = FALSE;
- BlockIsROM [c + 7] = BlockIsROM [c + 0x807] = FALSE;
- BlockIsRAM [c + 6] = BlockIsRAM [c + 0x806] = TRUE;
- BlockIsRAM [c + 7] = BlockIsRAM [c + 0x807] = TRUE;
- }
- WriteProtectROM ();
- }
-
- if (strncmp (ROMName, "SWORD WORLD SFC", 15) == 0 ||
- strcmp (ROMName, "SFC カメンライダー") == 0)
- {
- IAPU.OneCycle = 15;
- SNESGameFixes.NeedInit0x2137 = TRUE;
- ROMAPUEnabled |= 2;
- CPU.APU_APUExecuting |= 2;
- }
-
- if (strncmp (ROMName, "SHIEN THE BLADE CHASE", 21) == 0)
- SNESGameFixes.Old_Read0x4200 = TRUE;
-
- if (strcmp (ROMName, "ゴジラ カイジュウダイケッセン") == 0)
- SNESGameFixes.NeedInit0x2137 = TRUE;
-
- if (strcmp (ROMName, "UMIHARAKAWASE") == 0)
- SNESGameFixes.umiharakawaseFix = TRUE;
-
- if (strcmp (ROMName, "ALIENS vs. PREDATOR") == 0)
- SNESGameFixes.alienVSpredetorFix = TRUE;
-
- if (strcmp (ROMName, "demon's blazon") == 0 ||
- strcmp (ROMName, "demon's crest") == 0 ||
- strcmp (ROMName, "ROCKMAN X") == 0 ||
- strcmp (ROMName, "MEGAMAN X") == 0)
- {
-
- // CAPCOM's protect
- // Banks 0x808000, 0x408000 are mirroring.
- for (int c = 0; c < 8; c++)
- Map [0x408 + c] = ROM - 0x8000;
- }
-
- if (strcmp (ROMName, "スーパーファミスタ") == 0 ||
- strcmp (ROMName, "スーパーファミスタ 2") == 0 ||
- strcmp (ROMName, "ZENKI TENCHIMEIDOU") == 0 ||
- strcmp (ROMName, "GANBA LEAGUE") == 0)
- {
- SNESGameFixes.APU_OutPorts_ReturnValueFix = TRUE;
- }
-
- // HITOMI3
- if (strcmp (ROMName, "HITOMI3") == 0)
- {
- Memory.SRAMSize = 1;
- CPU.Memory_SRAMMask = Memory.SRAMSize ?
- ((1 << (Memory.SRAMSize + 3)) * 128) - 1 : 0;
- }
-
- if (strcmp (ROMName, "goemon 4") == 0)
- SNESGameFixes.SRAMInitialValue = 0x00;
-
- if (strcmp (ROMName, "PACHISLO ケンキュウ") == 0)
- SNESGameFixes._0x213E_ReturnValue = 1;
-
- if (strcmp (ROMName, "ザ マージャン トウハイデン") == 0)
- SNESGameFixes.TouhaidenControllerFix = TRUE;
-
- if (strcmp (ROMName, "DRAGON KNIGHT 4") == 0)
- {
- // Banks 70->7e, S-RAM
- for (int c = 0; c < 0xe0; c++)
- {
- Map [c + 0x700] = (uint8 *) MAP_LOROM_SRAM;
- BlockIsRAM [c + 0x700] = TRUE;
- BlockIsROM [c + 0x700] = FALSE;
- }
- WriteProtectROM ();
- }
-
- if (strncmp (ROMName, "LETs PACHINKO(", 14) == 0)
- {
- IAPU.OneCycle = 15;
- ROMAPUEnabled |= 2;
- CPU.APU_APUExecuting |= 2;
- if (!Settings.ForceNTSC && !Settings.ForcePAL)
- {
- Settings.PAL = FALSE;
- Settings.FrameTime = Settings.FrameTimeNTSC;
- Memory.ROMFramesPerSecond = 60;
- }
- }
-
- if (strcmp (ROMName, "FURAI NO SIREN") == 0)
- SNESGameFixes.SoundEnvelopeHeightReading2 = TRUE;
-#if 0
- if(strcmp (ROMName, "XBAND JAPANESE MODEM") == 0)
- {
- for (c = 0x200; c < 0x400; c += 16)
- {
- for (int i = c; i < c + 16; i++)
- {
- Map [i + 0x400] = Map [i + 0xc00] = &ROM[c * 0x1000];
- MemorySpeed [i + 0x400] = MemorySpeed [i + 0xc00] = 8;
- BlockIsRAM [i + 0x400] = BlockIsRAM [i + 0xc00] = TRUE;
- BlockIsROM [i + 0x400] = BlockIsROM [i + 0xc00] = FALSE;
- }
- }
- WriteProtectROM ();
- }
-#endif
-
-#define RomPatch(adr,ov,nv) \
-if (ROM [adr] == ov) \
- ROM [adr] = nv
-
- // Love Quest
- if (strcmp (ROMName, "LOVE QUEST") == 0)
- {
- RomPatch (0x1385ec, 0xd0, 0xea);
- RomPatch (0x1385ed, 0xb2, 0xea);
- }
-
- // Nangoku Syonen Papuwa Kun
- if (strcmp (ROMName, "NANGOKUSYONEN PAPUWA") == 0)
- RomPatch (0x1f0d1, 0xa0, 0x6b);
-
- // Tetsuwan Atom
- if (strcmp (ROMName, "Tetsuwan Atom") == 0)
- {
- RomPatch (0xe24c5, 0x90, 0xea);
- RomPatch (0xe24c6, 0xf3, 0xea);
- }
-
- // Oda Nobunaga
- if (strcmp (ROMName, "SFC ODA NOBUNAGA") == 0)
- {
- RomPatch (0x7497, 0x80, 0xea);
- RomPatch (0x7498, 0xd5, 0xea);
- }
-
- // Super Batter Up
- if (strcmp (ROMName, "Super Batter Up") == 0)
- {
- RomPatch (0x27ae0, 0xd0, 0xea);
- RomPatch (0x27ae1, 0xfa, 0xea);
- }
-
- // Super Professional Baseball 2
- if (strcmp (ROMName, "SUPER PRO. BASE BALL2") == 0)
- {
- RomPatch (0x1e4, 0x50, 0xea);
- RomPatch (0x1e5, 0xfb, 0xea);
- }
-
-}
-
-// Read variable size MSB int from a file
-static long ReadInt (FILE *f, unsigned nbytes)
-{
- long v = 0;
- while (nbytes--)
- {
- int c = fgetc(f);
- if (c == EOF)
- return -1;
- v = (v << 8) | (c & 0xFF);
- }
- return (v);
-}
-
-#define IPS_EOF 0x00454F46l
-
-void CMemory::CheckForIPSPatch (const char *rom_filename, bool8_32 header,
- int32 &rom_size)
-{
- char dir [_MAX_DIR + 1];
- char drive [_MAX_DRIVE + 1];
- char name [_MAX_FNAME + 1];
- char ext [_MAX_EXT + 1];
- char fname [_MAX_PATH + 1];
- FILE *patch_file = NULL;
- long offset = header ? 512 : 0;
-
- if (!(patch_file = fopen(S9xGetFilename (".ips"), "rb"))) return;
-
- if (fread (fname, 1, 5, patch_file) != 5 || strncmp (fname, "PATCH", 5) != 0)
- {
- fclose (patch_file);
- return;
- }
-
- int32 ofs;
-
- for (;;)
- {
- long len;
- long rlen;
- int rchar;
-
- ofs = ReadInt (patch_file, 3);
- if (ofs == -1)
- goto err_eof;
-
- if (ofs == IPS_EOF)
- break;
-
- ofs -= offset;
-
- len = ReadInt (patch_file, 2);
- if (len == -1)
- goto err_eof;
-
- /* Apply patch block */
- if (len)
- {
- if (ofs + len > MAX_ROM_SIZE)
- goto err_eof;
-
- while (len--)
- {
- rchar = fgetc (patch_file);
- if (rchar == EOF)
- goto err_eof;
- ROM [ofs++] = (uint8) rchar;
- }
- if (ofs > rom_size)
- rom_size = ofs;
- }
- else
- {
- rlen = ReadInt (patch_file, 2);
- if (rlen == -1)
- goto err_eof;
-
-
- rchar = fgetc (patch_file);
- if (rchar == EOF)
- goto err_eof;
-
- if (ofs + rlen > MAX_ROM_SIZE)
- goto err_eof;
-
- while (rlen--)
- ROM [ofs++] = (uint8) rchar;
-
- if (ofs > rom_size)
- rom_size = ofs;
- }
- }
-
- // Check if ROM image needs to be truncated
- ofs = ReadInt (patch_file, 3);
- if (ofs != -1 && ofs - offset < rom_size)
- {
- // Need to truncate ROM image
- rom_size = ofs - offset;
- }
- fclose (patch_file);
- return;
-
-err_eof:
- if (patch_file)
- fclose (patch_file);
-}
-
-const uint32 crc32Table[256] = {
- 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
- 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
- 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
- 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
- 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
- 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
- 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
- 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
- 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
- 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
- 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
- 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
- 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
- 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
- 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
- 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
- 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
- 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
- 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
- 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
- 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
- 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
- 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
- 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
- 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
- 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
- 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
- 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
- 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
- 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
- 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
- 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
- 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
- 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
- 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
- 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
- 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
- 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
- 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
- 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
- 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
- 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
- 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
-};
-
-//CRC32 for char arrays
-uint32 CMemory::caCRC32(uint8 *array, uint32 size, register uint32 crc32) {
- for (register uint32 i = 0; i < size; i++) {
- crc32 = ((crc32 >> 8) & 0x00FFFFFF) ^ crc32Table[(crc32 ^ array[i]) & 0xFF];
- }
- return ~crc32;
-}
-#include "getset.h"
diff --git a/src/memmap.h b/src/memmap.h index 96c5e50..6f82f0a 100644 --- a/src/memmap.h +++ b/src/memmap.h @@ -80,14 +80,12 @@ #define MEMMAP_MASK (MEMMAP_BLOCK_SIZE - 1) #define MEMMAP_MAX_SDD1_LOGGED_ENTRIES (0x10000 / 8) -class CMemory { -public: bool8_32 LoadROM (const char *); void InitROM (bool8_32); bool8_32 LoadSRAM (const char *); bool8_32 SaveSRAM (const char *); - bool8_32 Init (); - void Deinit (); + bool8_32 MemoryInit (); + void MemoryDeinit (); void FreeSDD1Data (); void WriteProtectROM (); @@ -112,7 +110,7 @@ public: int ScoreLoROM (bool8_32 skip_header); void ApplyROMFixes (); void CheckForIPSPatch (const char *rom_filename, bool8_32 header, - int32 &rom_size); + int32 *rom_size); const char *TVStandard (); const char *Speed (); @@ -124,7 +122,7 @@ public: const char *Headers (); const char *ROMID (); const char *CompanyID (); - uint32 caCRC32(uint8 *array, uint32 size, register uint32 crc32= 0xFFFFFFFF); + uint32 caCRC32(uint8 *array, uint32 size); enum { MAP_PPU, MAP_CPU, MAP_DSP, MAP_LOROM_SRAM, MAP_HIROM_SRAM, @@ -132,7 +130,8 @@ public: MAP_BWRAM_BITMAP2, MAP_SA1RAM, MAP_LAST }; enum { MAX_ROM_SIZE = 0x600000 }; - +typedef struct { + uint8 *RAM; uint8 *ROM; uint8 *VRAM; @@ -168,7 +167,7 @@ public: uint32 SDD1LoggedDataCount; uint8 SDD1LoggedData [MEMMAP_MAX_SDD1_LOGGED_ENTRIES]; char ROMFilename [_MAX_PATH]; -}; +}CMemory; START_EXTERN_C extern CMemory Memory; diff --git a/src/missing.h b/src/missing.h index 804f8b5..3c0681b 100644 --- a/src/missing.h +++ b/src/missing.h @@ -41,7 +41,7 @@ #ifndef _MISSING_H_ #define _MISSING_H_ -struct HDMA +typedef struct { uint8 used; uint8 bbus_address; @@ -52,9 +52,9 @@ struct HDMA uint8 force_table_address_read; uint8 line_count_write; uint8 line_count_read; -}; +}HDMA; -struct Missing +typedef struct { uint8 emulate6502; uint8 decimal_mode; @@ -63,7 +63,7 @@ struct Missing uint8 interlace; uint8 lines_239; uint8 pseudo_512; - struct HDMA hdma [8]; + HDMA hdma [8]; uint8 modes [8]; uint8 mode7_fx; uint8 mode7_flip; @@ -108,7 +108,7 @@ struct Missing uint16 unknowncpu_write; uint16 unknowndsp_read; uint16 unknowndsp_write; -}; +}Missing; -EXTERN_C struct Missing missing; +EXTERN_C Missing missing; #endif diff --git a/src/mode7.cpp b/src/mode7.c index db65ab9..9e2b47d 100644 --- a/src/mode7.cpp +++ b/src/mode7.c @@ -6,8 +6,8 @@ #include "gfx.h" #include "apu.h" -extern struct SLineData LineData[240]; -extern struct SLineMatrixData LineMatrixData [240]; +extern SLineData LineData[240]; +extern SLineMatrixData LineMatrixData [240]; extern uint8 Mode7Depths [2]; #define M7 19 @@ -87,7 +87,7 @@ void DrawBGMode7Background16R3 (uint8 *Screen, int bg, int depth) Screen += GFX.StartY * GFX_PITCH; Depth = GFX.DB + GFX.StartY * GFX_PPL; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -134,7 +134,7 @@ void DrawBGMode7Background16R3 (uint8 *Screen, int bg, int depth) if (dir == 1) { - asm volatile ( + __asm__ volatile ( "1: \n" " ldrb r0, [%[d]] \n" " mov r3, %[AA], asr #18 \n" @@ -213,7 +213,7 @@ void DrawBGMode7Background16R3 (uint8 *Screen, int bg, int depth) } else { - asm volatile ( + __asm__ volatile ( "1: \n" " ldrb r0, [%[d]] \n" " mov r3, %[AA], asr #18 \n" @@ -329,7 +329,7 @@ void DrawBGMode7Background16R1R2 (uint8 *Screen, int bg, int depth) Screen += GFX.StartY * GFX_PITCH; Depth = GFX.DB + GFX.StartY * GFX_PPL; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -365,7 +365,7 @@ void DrawBGMode7Background16R1R2 (uint8 *Screen, int bg, int depth) aa = l->MatrixA; cc = l->MatrixC; } - asm volatile ( + __asm__ volatile ( "1: \n" " ldrb r0, [%[d]] \n" " mov r3, %[AA], asr #18 \n" @@ -453,7 +453,7 @@ void DrawBGMode7Background16R0 (uint8 *Screen, int bg, int depth) int DD; uint32 Line; uint32 clip; - struct SLineMatrixData *l; + SLineMatrixData *l; uint8 *Depth; @@ -508,7 +508,7 @@ void DrawBGMode7Background16R0 (uint8 *Screen, int bg, int depth) aa = l->MatrixA; cc = l->MatrixC; } - asm volatile ( + __asm__ volatile ( " b 1f \n" //"7: \n" // AndByX //" .word (0x3ff << 1) \n" diff --git a/src/mode7_t.h b/src/mode7_t.h index 5d67aa6..9a35c41 100644 --- a/src/mode7_t.h +++ b/src/mode7_t.h @@ -7,8 +7,8 @@ #include "gfx.h" #include "apu.h" -extern struct SLineData LineData[240]; -extern struct SLineMatrixData LineMatrixData [240]; +extern SLineData LineData[240]; +extern SLineMatrixData LineMatrixData [240]; extern uint8 Mode7Depths [2]; #define M7 19 @@ -50,7 +50,7 @@ static void DrawBGMode7Background16R3 (uint8 *Screen, int bg, int depth) Screen += GFX.StartY * GFX_PITCH; Depth = GFX.DB + GFX.StartY * GFX_PPL; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -96,7 +96,7 @@ static void DrawBGMode7Background16R3 (uint8 *Screen, int bg, int depth) xx3 = (startx + HOffset); #define M7R3(dir) \ - asm volatile (\ + __asm__ volatile (\ "1: \n"\ " ldrb r0, [%[d], #1]! \n"\ " mov r3, %[AA], asr #18 \n"\ @@ -238,7 +238,7 @@ static void DrawBGMode7Background16R1R2 (uint8 *Screen, int bg, int depth) Screen += GFX.StartY * GFX_PITCH; Depth = GFX.DB + GFX.StartY * GFX_PPL; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -279,7 +279,7 @@ static void DrawBGMode7Background16R1R2 (uint8 *Screen, int bg, int depth) AA = (l->MatrixA * (startx + xx) + BB); CC = (l->MatrixC * (startx + xx) + DD); - asm volatile ( + __asm__ volatile ( "1: \n" " ldrb r0, [%[d], #1]! \n" " mov r3, %[AA], asr #18 \n" @@ -375,7 +375,7 @@ static void DrawBGMode7Background16R0 (uint8 *Screen, int bg, int depth) int DD; uint32 Line; uint32 clip; - struct SLineMatrixData *l; + SLineMatrixData *l; uint8 *Depth; unsigned int fixedColour = GFX.FixedColour; @@ -432,7 +432,7 @@ static void DrawBGMode7Background16R0 (uint8 *Screen, int bg, int depth) AA = (l->MatrixA * (startx + xx) + BB); CC = (l->MatrixC * (startx + xx) + DD); - asm volatile ( + __asm__ volatile ( " ldrb r0, [%[d], #1]! \n" "1: \n" " ldr r3, %[AndByY] \n" diff --git a/src/mode7_t.h.new b/src/mode7_t.h.new index f37e332..2ebfefe 100644 --- a/src/mode7_t.h.new +++ b/src/mode7_t.h.new @@ -7,8 +7,8 @@ #include "gfx.h" #include "apu.h" -extern struct SLineData LineData[240]; -extern struct SLineMatrixData LineMatrixData [240]; +extern SLineData LineData[240]; +extern SLineMatrixData LineMatrixData [240]; extern uint8 Mode7Depths [2]; #define M7 19 @@ -50,7 +50,7 @@ static void DrawBGMode7Background16R3 (uint8 *Screen, int bg, int depth) Screen += GFX.StartY * GFX_PITCH; Depth = GFX.DB + GFX.StartY * GFX_PPL; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -96,7 +96,7 @@ static void DrawBGMode7Background16R3 (uint8 *Screen, int bg, int depth) xx3 = (startx + HOffset); #define M7R3(dir) \ - asm volatile (\ + __asm__ volatile (\ "1: \n"\ " ldrb r0, [%[d], #1]! \n"\ " mov r3, %[AA], asr #18 \n"\ @@ -237,7 +237,7 @@ static void DrawBGMode7Background16R1R2 (uint8 *Screen, int bg, int depth) Screen += GFX.StartY * GFX_PITCH; Depth = GFX.DB + GFX.StartY * GFX_PPL; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -278,7 +278,7 @@ static void DrawBGMode7Background16R1R2 (uint8 *Screen, int bg, int depth) AA = (l->MatrixA * (startx + xx) + BB); CC = (l->MatrixC * (startx + xx) + DD); - asm volatile ( + __asm__ volatile ( "1: \n" " ldrb r0, [%[d], #1]! \n" " mov r3, %[AA], asr #18 \n" @@ -373,7 +373,7 @@ static void DrawBGMode7Background16R0 (uint8 *Screen, int bg, int depth) int DD; uint32 Line; uint32 clip; - struct SLineMatrixData *l; + SLineMatrixData *l; uint8 *Depth; unsigned int fixedColour = GFX.FixedColour; @@ -430,7 +430,7 @@ static void DrawBGMode7Background16R0 (uint8 *Screen, int bg, int depth) AA = (l->MatrixA * (startx + xx) + BB); CC = (l->MatrixC * (startx + xx) + DD); - asm volatile ( + __asm__ volatile ( " ldrb r0, [%[d], #1]! \n" "1: \n" " ldr r3, %[AndByY] \n" diff --git a/src/mode7add.cpp b/src/mode7add.c index 0670b89..0670b89 100644 --- a/src/mode7add.cpp +++ b/src/mode7add.c diff --git a/src/mode7add1_2.cpp b/src/mode7add1_2.c index c01ef6f..c01ef6f 100644 --- a/src/mode7add1_2.cpp +++ b/src/mode7add1_2.c diff --git a/src/mode7add1_2prio.cpp b/src/mode7add1_2prio.c index 0826461..0826461 100644 --- a/src/mode7add1_2prio.cpp +++ b/src/mode7add1_2prio.c diff --git a/src/mode7addprio.cpp b/src/mode7addprio.c index 38cbdfd..38cbdfd 100644 --- a/src/mode7addprio.cpp +++ b/src/mode7addprio.c diff --git a/src/mode7new.cpp b/src/mode7new.c index b71e835..b09dc36 100644 --- a/src/mode7new.cpp +++ b/src/mode7new.c @@ -6,8 +6,8 @@ #include "gfx.h" #include "apu.h" -extern struct SLineData LineData[240]; -extern struct SLineMatrixData LineMatrixData [240]; +extern SLineData LineData[240]; +extern SLineMatrixData LineMatrixData [240]; extern uint8 Mode7Depths [2]; #define M7 19 @@ -77,7 +77,7 @@ void DrawBGMode7Background16NewR3 (uint8 *Screen) if (!ClipCount) ClipCount = 1; Screen += GFX.StartY * GFX_PITCH; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -129,7 +129,7 @@ void DrawBGMode7Background16NewR3 (uint8 *Screen) if (dir == 1) { - asm volatile ( + __asm__ volatile ( "1: \n" " mov r3, %[AA], asr #18 \n" " orrs r3, r3, %[CC], asr #18 \n" @@ -192,7 +192,7 @@ void DrawBGMode7Background16NewR3 (uint8 *Screen) } else { - asm volatile ( + __asm__ volatile ( "1: \n" " mov r3, %[AA], asr #18 \n" " orrs r3, r3, %[CC], asr #18 \n" @@ -289,7 +289,7 @@ void DrawBGMode7Background16NewR1R2 (uint8 *Screen) if (!ClipCount) ClipCount = 1; Screen += GFX.StartY * GFX_PITCH; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -324,7 +324,7 @@ void DrawBGMode7Background16NewR1R2 (uint8 *Screen) aa = l->MatrixA; cc = l->MatrixC; } - asm volatile ( + __asm__ volatile ( "1: \n" " mov r3, %[AA], asr #18 \n" " orrs r3, r3, %[CC], asr #18 \n" @@ -402,7 +402,7 @@ uint8 *z; int DD; uint32 Line; uint32 clip; - struct SLineMatrixData *l; + SLineMatrixData *l; @@ -456,7 +456,7 @@ uint8 *z; aa = l->MatrixA; cc = l->MatrixC; } - asm volatile ( + __asm__ volatile ( " \n" "1: \n" " and r1, %[AndByY], %[CC], asr #4 \n" diff --git a/src/mode7prio.cpp b/src/mode7prio.c index c149eb5..2b9a3a2 100644 --- a/src/mode7prio.cpp +++ b/src/mode7prio.c @@ -6,8 +6,8 @@ #include "gfx.h" #include "apu.h" -extern struct SLineData LineData[240]; -extern struct SLineMatrixData LineMatrixData [240]; +extern SLineData LineData[240]; +extern SLineMatrixData LineMatrixData [240]; extern uint8 Mode7Depths [2]; #define M7 19 @@ -87,7 +87,7 @@ void DrawBGMode7Background16PrioR3 (uint8 *Screen, int bg) Screen += GFX.StartY * GFX_PITCH; Depth = GFX.DB + GFX.StartY * GFX_PPL; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -129,7 +129,7 @@ void DrawBGMode7Background16PrioR3 (uint8 *Screen, int bg) if (dir == 1) { - asm volatile ( + __asm__ volatile ( "1: \n" " mov r3, %[AA], lsr #18 \n" " orrs r3, r3, %[CC], lsr #18 \n" @@ -224,7 +224,7 @@ void DrawBGMode7Background16PrioR3 (uint8 *Screen, int bg) } else { - asm volatile ( + __asm__ volatile ( "1: \n" " mov r3, %[AA], lsr #18 \n" " orrs r3, r3, %[CC], lsr #18 \n" @@ -357,7 +357,7 @@ void DrawBGMode7Background16PrioR1R2 (uint8 *Screen, int bg) Screen += GFX.StartY * GFX_PITCH; Depth = GFX.DB + GFX.StartY * GFX_PPL; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -393,7 +393,7 @@ void DrawBGMode7Background16PrioR1R2 (uint8 *Screen, int bg) aa = l->MatrixA; cc = l->MatrixC; } - asm volatile ( + __asm__ volatile ( "1: \n" " mov r3, %[AA], lsr #18 \n" " orrs r3, r3, %[CC], lsr #18 \n" @@ -485,7 +485,7 @@ void DrawBGMode7Background16PrioR0 (uint8 *Screen, int bg) int DD; uint32 Line; uint32 clip; - struct SLineMatrixData *l; + SLineMatrixData *l; uint8 *Depth; uint32 depth = Mode7Depths[0] | (Mode7Depths[1] << 8); @@ -536,7 +536,7 @@ void DrawBGMode7Background16PrioR0 (uint8 *Screen, int bg) aa = l->MatrixA; cc = l->MatrixC; } - asm volatile ( + __asm__ volatile ( " b 1f \n" "7: \n" // AndByX " .word (0x3ff << 1) \n" diff --git a/src/mode7prio_t.h b/src/mode7prio_t.h index 8f1e7e4..889d8b9 100644 --- a/src/mode7prio_t.h +++ b/src/mode7prio_t.h @@ -6,8 +6,8 @@ #include "gfx.h" #include "apu.h" -extern struct SLineData LineData[240]; -extern struct SLineMatrixData LineMatrixData [240]; +extern SLineData LineData[240]; +extern SLineMatrixData LineMatrixData [240]; extern uint8 Mode7Depths [2]; #define M7 19 @@ -48,7 +48,7 @@ static void DrawBGMode7Background16R3 (uint8 *Screen, int bg) Screen += GFX.StartY * GFX_PITCH; Depth = GFX.DB + GFX.StartY * GFX_PPL; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -93,7 +93,7 @@ static void DrawBGMode7Background16R3 (uint8 *Screen, int bg) xx3 = (startx + HOffset); - asm volatile ( + __asm__ volatile ( "1: \n" " mov r3, %[AA], asr #18 \n" " orrs r3, r3, %[CC], asr #18 \n" @@ -249,7 +249,7 @@ static void DrawBGMode7Background16R1R2 (uint8 *Screen, int bg) Screen += GFX.StartY * GFX_PITCH; Depth = GFX.DB + GFX.StartY * GFX_PPL; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -285,7 +285,7 @@ static void DrawBGMode7Background16R1R2 (uint8 *Screen, int bg) aa = l->MatrixA; cc = l->MatrixC; } - asm volatile ( + __asm__ volatile ( "1: \n" " mov r3, %[AA], asr #18 \n" " orrs r3, r3, %[CC], asr #18 \n" @@ -384,7 +384,7 @@ static void DrawBGMode7Background16R0 (uint8 *Screen, int bg) int DD; uint32 Line; uint32 clip; - struct SLineMatrixData *l; + SLineMatrixData *l; uint8 *Depth; unsigned int fixedColour = GFX.FixedColour; uint32 depth = Mode7Depths[0] | (Mode7Depths[1] << 8); @@ -437,7 +437,7 @@ static void DrawBGMode7Background16R0 (uint8 *Screen, int bg) aa = l->MatrixA; cc = l->MatrixC; } - asm volatile ( + __asm__ volatile ( " ldr r3, %[AndByY] \n" "1: \n" " and r1, r3, %[CC], asr #4 \n" diff --git a/src/mode7prio_t.h.last b/src/mode7prio_t.h.last index 444c1fd..d97e314 100644 --- a/src/mode7prio_t.h.last +++ b/src/mode7prio_t.h.last @@ -6,8 +6,8 @@ #include "gfx.h" #include "apu.h" -extern struct SLineData LineData[240]; -extern struct SLineMatrixData LineMatrixData [240]; +extern SLineData LineData[240]; +extern SLineMatrixData LineMatrixData [240]; extern uint8 Mode7Depths [2]; #define M7 19 @@ -48,7 +48,7 @@ static void DrawBGMode7Background16R3 (uint8 *Screen, int bg) Screen += GFX.StartY * GFX_PITCH; Depth = GFX.DB + GFX.StartY * GFX_PPL; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -93,7 +93,7 @@ static void DrawBGMode7Background16R3 (uint8 *Screen, int bg) xx3 = (startx + HOffset); - asm volatile ( + __asm__ volatile ( "1: \n" " mov r3, %[AA], asr #18 \n" " orrs r3, r3, %[CC], asr #18 \n" @@ -245,7 +245,7 @@ static void DrawBGMode7Background16R1R2 (uint8 *Screen, int bg) Screen += GFX.StartY * GFX_PITCH; Depth = GFX.DB + GFX.StartY * GFX_PPL; - struct SLineMatrixData *l = &LineMatrixData [GFX.StartY]; + SLineMatrixData *l = &LineMatrixData [GFX.StartY]; for (Line = GFX.StartY; Line <= GFX.EndY; Line++, Screen += GFX_PITCH, Depth += GFX_PPL, l++) { HOffset = ((int32) LineData[Line].BG[0].HOffset << M7) >> M7; @@ -281,7 +281,7 @@ static void DrawBGMode7Background16R1R2 (uint8 *Screen, int bg) aa = l->MatrixA; cc = l->MatrixC; } - asm volatile ( + __asm__ volatile ( "1: \n" " mov r3, %[AA], asr #18 \n" " orrs r3, r3, %[CC], asr #18 \n" @@ -378,7 +378,7 @@ static void DrawBGMode7Background16R0 (uint8 *Screen, int bg) int DD; uint32 Line; uint32 clip; - struct SLineMatrixData *l; + SLineMatrixData *l; uint8 *Depth; unsigned int fixedColour = GFX.FixedColour; uint32 depth = Mode7Depths[0] | (Mode7Depths[1] << 8); @@ -431,7 +431,7 @@ static void DrawBGMode7Background16R0 (uint8 *Screen, int bg) aa = l->MatrixA; cc = l->MatrixC; } - asm volatile ( + __asm__ volatile ( //" b 1f \n" //"7: \n" // AndByX //" .word (0x3ff << 1) \n" diff --git a/src/mode7sub.cpp b/src/mode7sub.c index 2ba1209..2ba1209 100644 --- a/src/mode7sub.cpp +++ b/src/mode7sub.c diff --git a/src/mode7sub1_2.cpp b/src/mode7sub1_2.c index 0b87cbf..0b87cbf 100644 --- a/src/mode7sub1_2.cpp +++ b/src/mode7sub1_2.c diff --git a/src/mode7sub1_2prio.cpp b/src/mode7sub1_2prio.c index 6da6869..6da6869 100644 --- a/src/mode7sub1_2prio.cpp +++ b/src/mode7sub1_2prio.c diff --git a/src/mode7subprio.cpp b/src/mode7subprio.c index 61a3870..61a3870 100644 --- a/src/mode7subprio.cpp +++ b/src/mode7subprio.c diff --git a/src/os9x_asm_cpu.cpp b/src/os9x_asm_cpu.c index bfd2ec5..bfd2ec5 100644 --- a/src/os9x_asm_cpu.cpp +++ b/src/os9x_asm_cpu.c @@ -63,6 +63,7 @@ I can't take it anymore, it's too convoluted. So I've commented out the entire //#include <windows.h> #include <limits.h> #include <string.h> +#include <stdbool.h> //Types Defined typedef unsigned char bool8; typedef unsigned char uint8; @@ -56,8 +56,8 @@ #ifndef ZSNES_FX #include "fxemu.h" #include "fxinst.h" -extern struct FxInit_s SuperFX; -extern struct FxRegs_s GSU; +extern FxInit_s SuperFX; +extern FxRegs_s GSU; #else EXTERN_C void S9xSuperFXWriteReg (uint8, uint32); EXTERN_C uint8 S9xSuperFXReadReg (uint32); @@ -128,7 +128,8 @@ void S9xFixColourBrightness () IPPU.XB = mul_brightness [PPU.Brightness]; if (Settings.SixteenBit) { - for (unsigned int i = 0; i < 256; i++) + unsigned int i; + for (i = 0; i < 256; i++) { //IPPU.Red [i] = IPPU.XB [PPU.CGDATA [i] & 0x1f]; //IPPU.Green [i] = IPPU.XB [(PPU.CGDATA [i] >> 5) & 0x1f]; @@ -385,7 +386,7 @@ void S9xSetCPU(uint8 byte, uint16 Address) else CPU.FastROMSpeed = SLOW_ONE_CYCLE; - Memory.FixROMSpeed(); + FixROMSpeed(); } /* FALL */ case 0x420e : @@ -985,7 +986,8 @@ void S9xResetPPU() PPU.VMA.FullGraphicCount = 0; PPU.VMA.Shift = 0; - for (uint8 B = 0; B != 4; B++) + uint8 B; + for (B = 0; B != 4; B++) { PPU.BG[B].SCBase = 0; PPU.BG[B].VOffset = 0; @@ -1023,7 +1025,8 @@ void S9xResetPPU() PPU.FirstSprite = 0; PPU.LastSprite = 127; - for (int Sprite = 0; Sprite < 128; Sprite++) + int Sprite; + for (Sprite = 0; Sprite < 128; Sprite++) { PPU.OBJ[Sprite].HPos = 0; PPU.OBJ[Sprite].VPos = 0; @@ -1131,7 +1134,7 @@ void S9xResetPPU() S9xNextController(); for (c = 0; c < 2; c++) - memset(& IPPU.Clip[c], 0, sizeof(struct ClipData)); + memset(& IPPU.Clip[c], 0, sizeof(ClipData)); if (Settings.MouseMaster) { @@ -1169,7 +1172,7 @@ void S9xProcessMouse(int which1) if ((IPPU.Controller == SNES_MOUSE || IPPU.Controller == SNES_MOUSE_SWAPPED) - && S9xReadMousePosition(which1, x, y, buttons)) + && S9xReadMousePosition(which1, &x, &y, &buttons)) { int delta_x, delta_y; #define MOUSE_SIGNATURE 0x1 @@ -1237,7 +1240,7 @@ void ProcessSuperScope() uint32 buttons; if (IPPU.Controller == SNES_SUPERSCOPE - && S9xReadSuperScopePosition(x, y, buttons)) + && S9xReadSuperScopePosition(&x, &y, &buttons)) { #define SUPERSCOPE_SIGNATURE 0x00ff uint32 scope; @@ -62,13 +62,13 @@ extern uint16 SignExtend [2]; #define SA1_IRQ_SOURCE (1 << 7) #define SA1_DMA_IRQ_SOURCE (1 << 5) -struct ClipData { +typedef struct { uint32 Count [6]; uint32 Left [6][6]; uint32 Right [6][6]; -}; +}ClipData; -struct InternalPPU { +typedef struct{ bool8 ColorsChanged; uint8 HDMA; bool8 HDMAStarted; @@ -102,10 +102,10 @@ struct InternalPPU { uint32 Mouse[2]; int PrevMouseX[2]; int PrevMouseY[2]; - struct ClipData Clip [2]; -}; + ClipData Clip [2]; +}InternalPPU; -struct SOBJ +typedef struct { short HPos; uint16 VPos; @@ -115,9 +115,10 @@ struct SOBJ uint8 Priority; uint8 Palette; uint8 Size; -}; +}SOBJ; -struct SPPU { +typedef struct +{ uint8 BGMode; uint8 BG3Priority; uint8 Brightness; @@ -145,7 +146,7 @@ struct SPPU { uint16 CGDATA [256]; uint8 FirstSprite; uint8 LastSprite; - struct SOBJ OBJ [128]; + SOBJ OBJ [128]; uint8 OAMPriorityRotation; uint16 OAMAddr; @@ -212,14 +213,14 @@ struct SPPU { uint16 SavedOAMAddr2; uint16 OAMWriteRegister; uint8 BGnxOFSbyte; -}; +}SPPU; #define CLIP_OR 0 #define CLIP_AND 1 #define CLIP_XOR 2 #define CLIP_XNOR 3 -struct SDMA { +typedef struct { bool8 TransferDirection; bool8 AAddressFixed; bool8 AAddressDecrement; @@ -240,7 +241,7 @@ struct SDMA { uint8 Repeat; uint8 LineCount; uint8 FirstLine; -}; +}SDMA; START_EXTERN_C //void S9xUpdateScreen (); @@ -261,9 +262,9 @@ uint8 S9xGetC4 (uint16 Address); void S9xSetC4RAM (uint8 Byte, uint16 Address); uint8 S9xGetC4RAM (uint16 Address); -extern struct SPPU PPU; -extern struct SDMA DMA [8]; -extern struct InternalPPU IPPU; +extern SPPU PPU; +extern SDMA DMA [8]; +extern InternalPPU IPPU; END_EXTERN_C #include "gfx.h" @@ -309,7 +310,7 @@ STATIC INLINE void REGISTER_2104 (uint8 byte) IPPU.OBJChanged = TRUE; // X position high bit, and sprite size (x4) - struct SOBJ *pObj = &PPU.OBJ [(addr & 0x1f) * 4]; + SOBJ *pObj = &PPU.OBJ [(addr & 0x1f) * 4]; pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 0) & 1]; pObj++->Size = byte & 2; diff --git a/src/ppu_.cpp b/src/ppu_.c index 1e29935..e6cfecb 100644 --- a/src/ppu_.cpp +++ b/src/ppu_.c @@ -55,8 +55,8 @@ #ifndef ZSNES_FX #include "fxemu.h" #include "fxinst.h" -extern struct FxInit_s SuperFX; -extern struct FxRegs_s GSU; +extern FxInit_s SuperFX; +extern FxRegs_s GSU; #else EXTERN_C void S9xSuperFXWriteReg (uint8, uint32); EXTERN_C uint8 S9xSuperFXReadReg (uint32); @@ -2236,7 +2236,7 @@ void S9xResetPPU () S9xNextController (); for (c = 0; c < 2; c++) - memset (&IPPU.Clip [c], 0, sizeof (struct ClipData)); + memset (&IPPU.Clip [c], 0, sizeof (ClipData)); if (Settings.MouseMaster) { @@ -2259,7 +2259,7 @@ void S9xProcessMouse (int which1) uint32 buttons; if ((IPPU.Controller == SNES_MOUSE || IPPU.Controller == SNES_MOUSE_SWAPPED) && - S9xReadMousePosition (which1, x, y, buttons)) + S9xReadMousePosition (which1, &x, &y, &buttons)) { int delta_x, delta_y; #define MOUSE_SIGNATURE 0x1 @@ -2327,7 +2327,7 @@ void ProcessSuperScope () uint32 buttons; if (IPPU.Controller == SNES_SUPERSCOPE && - S9xReadSuperScopePosition (x, y, buttons)) + S9xReadSuperScopePosition (&x, &y, &buttons)) { #define SUPERSCOPE_SIGNATURE 0x00ff uint32 scope; diff --git a/src/rops.cpp b/src/rops.c index e4eab04..e4eab04 100644 --- a/src/rops.cpp +++ b/src/rops.c @@ -1,6 +1,8 @@ #ifndef __ROPS_H__ #define __ROPS_H__ +#include "stdbool.h" + /* Raster Operations macros */ @@ -112,10 +112,10 @@ void S9xSA1SetBWRAMMemMap (uint8 val) {
for (c = 0; c < 0x400; c += 16)
{
- SA1_Map [c + 6] = SA1_Map [c + 0x806] = (uint8 *) CMemory::MAP_BWRAM_BITMAP2;
- SA1_Map [c + 7] = SA1_Map [c + 0x807] = (uint8 *) CMemory::MAP_BWRAM_BITMAP2;
- SA1_WriteMap [c + 6] = SA1_WriteMap [c + 0x806] = (uint8 *) CMemory::MAP_BWRAM_BITMAP2;
- SA1_WriteMap [c + 7] = SA1_WriteMap [c + 0x807] = (uint8 *) CMemory::MAP_BWRAM_BITMAP2;
+ SA1_Map [c + 6] = SA1_Map [c + 0x806] = (uint8 *) MAP_BWRAM_BITMAP2;
+ SA1_Map [c + 7] = SA1_Map [c + 0x807] = (uint8 *) MAP_BWRAM_BITMAP2;
+ SA1_WriteMap [c + 6] = SA1_WriteMap [c + 0x806] = (uint8 *) MAP_BWRAM_BITMAP2;
+ SA1_WriteMap [c + 7] = SA1_WriteMap [c + 0x807] = (uint8 *) MAP_BWRAM_BITMAP2;
}
SA1.BWRAM = Memory.SRAM + (val & 0x7f) * 0x2000 / 4;
}
@@ -123,10 +123,10 @@ void S9xSA1SetBWRAMMemMap (uint8 val) {
for (c = 0; c < 0x400; c += 16)
{
- SA1_Map [c + 6] = SA1_Map [c + 0x806] = (uint8 *) CMemory::MAP_BWRAM;
- SA1_Map [c + 7] = SA1_Map [c + 0x807] = (uint8 *) CMemory::MAP_BWRAM;
- SA1_WriteMap [c + 6] = SA1_WriteMap [c + 0x806] = (uint8 *) CMemory::MAP_BWRAM;
- SA1_WriteMap [c + 7] = SA1_WriteMap [c + 0x807] = (uint8 *) CMemory::MAP_BWRAM;
+ SA1_Map [c + 6] = SA1_Map [c + 0x806] = (uint8 *) MAP_BWRAM;
+ SA1_Map [c + 7] = SA1_Map [c + 0x807] = (uint8 *) MAP_BWRAM;
+ SA1_WriteMap [c + 6] = SA1_WriteMap [c + 0x806] = (uint8 *) MAP_BWRAM;
+ SA1_WriteMap [c + 7] = SA1_WriteMap [c + 0x807] = (uint8 *) MAP_BWRAM;
}
SA1.BWRAM = Memory.SRAM + (val & 7) * 0x2000;
}
@@ -202,9 +202,9 @@ uint8 (*S9xSA1GetByte_JumpTable[(1 << (16 - 12))]) (uint32 address) = { uint8 S9xSA1GetByte (uint32 address)
{
uint8 *GetAddress = SA1_Map [(address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (GetAddress >= (uint8 *) CMemory::MAP_LAST) return (*(GetAddress + (address & 0xffff)));
+ if (GetAddress >= (uint8 *) MAP_LAST) return (*(GetAddress + (address & 0xffff)));
return S9xSA1GetByte_JumpTable[(intptr_t) GetAddress](address);
-// return (SA1_Map [(address >> MEMMAP_SHIFT) & MEMMAP_MASK] >= (uint8 *)CMemory::MAP_LAST) ?
+// return (SA1_Map [(address >> MEMMAP_SHIFT) & MEMMAP_MASK] >= (uint8 *)MAP_LAST) ?
// (*((uint8 *)(SA1_Map [(address >> MEMMAP_SHIFT) & MEMMAP_MASK]) + (address & 0xffff))) :
// S9xSA1GetByte_JumpTable[(int) SA1_Map [(address >> MEMMAP_SHIFT) & MEMMAP_MASK]](address);
}
@@ -213,7 +213,7 @@ uint8 S9xSA1GetByte (uint32 address) uint16 S9xSA1GetWord (uint32 address)
{
uint8 *GetAddress = SA1_Map [(address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (GetAddress >= (uint8 *) CMemory::MAP_LAST)
+ if (GetAddress >= (uint8 *) MAP_LAST)
return (*(GetAddress + (address & 0xffff))) | ((*(GetAddress + ((address+1) & 0xffff))) << 8);
return (S9xSA1GetByte_JumpTable[(int) GetAddress](address)) | ((S9xSA1GetByte_JumpTable[(int) GetAddress](address+1)) << 8);
}
@@ -287,7 +287,7 @@ void S9xSA1SetByte (uint8 byte, uint32 address) // MEMMAP_MASK 0xFFF
uint8 *Setaddress = SA1_WriteMap [(address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (Setaddress >= (uint8 *) CMemory::MAP_LAST)
+ if (Setaddress >= (uint8 *) MAP_LAST)
{
*(Setaddress + (address & 0xffff)) = byte;
return;
@@ -298,7 +298,7 @@ void S9xSA1SetByte (uint8 byte, uint32 address) void S9xSA1SetPCBase (uint32 address)
{
uint8 *GetAddress = SA1_Map [(address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (GetAddress >= (uint8 *) CMemory::MAP_LAST)
+ if (GetAddress >= (uint8 *) MAP_LAST)
{
SA1.PCBase = GetAddress;
SA1.PC = GetAddress + (address & 0xffff);
@@ -307,43 +307,43 @@ void S9xSA1SetPCBase (uint32 address) switch ((intptr_t) GetAddress)
{
- case CMemory::MAP_PPU:
+ case MAP_PPU:
SA1.PCBase = Memory.FillRAM - 0x2000;
SA1.PC = SA1.PCBase + (address & 0xffff);
return;
- case CMemory::MAP_CPU:
+ case MAP_CPU:
SA1.PCBase = Memory.FillRAM - 0x4000;
SA1.PC = SA1.PCBase + (address & 0xffff);
return;
- case CMemory::MAP_DSP:
+ case MAP_DSP:
SA1.PCBase = Memory.FillRAM - 0x6000;
SA1.PC = SA1.PCBase + (address & 0xffff);
return;
- case CMemory::MAP_SA1RAM:
- case CMemory::MAP_LOROM_SRAM:
+ case MAP_SA1RAM:
+ case MAP_LOROM_SRAM:
SA1.PCBase = Memory.SRAM;
SA1.PC = SA1.PCBase + (address & 0xffff);
return;
- case CMemory::MAP_BWRAM:
+ case MAP_BWRAM:
SA1.PCBase = SA1.BWRAM - 0x6000;
SA1.PC = SA1.PCBase + (address & 0xffff);
return;
- case CMemory::MAP_HIROM_SRAM:
+ case MAP_HIROM_SRAM:
SA1.PCBase = Memory.SRAM - 0x6000;
SA1.PC = SA1.PCBase + (address & 0xffff);
return;
- case CMemory::MAP_DEBUG:
+ case MAP_DEBUG:
#ifdef DEBUGGER
printf ("SBP %06x\n", address);
#endif
default:
- case CMemory::MAP_NONE:
+ case MAP_NONE:
SA1.PCBase = Memory.RAM;
SA1.PC = Memory.RAM + (address & 0xffff);
return;
@@ -582,7 +582,7 @@ void S9xSetSA1 (uint8 byte, uint32 address) if ((Memory.FillRAM [0x2230] & 0xb0) == 0xa0)
{
// Char conversion 2 DMA enabled
- memmove (&Memory.ROM [CMemory::MAX_ROM_SIZE - 0x10000] + (SA1.in_char_dma << 4),
+ memmove (&Memory.ROM [MAX_ROM_SIZE - 0x10000] + (SA1.in_char_dma << 4),
&Memory.FillRAM [0x2240], 16);
SA1.in_char_dma = (SA1.in_char_dma + 1) & 7;
if ((SA1.in_char_dma & 3) == 0)
@@ -656,7 +656,7 @@ static void S9xSA1CharConv2 () (Memory.FillRAM [0x2231] & 3) == 1 ? 4 : 2;
int bytes_per_char = 8 * depth;
uint8 *p = &Memory.FillRAM [0x3000] + dest + offset * bytes_per_char;
- uint8 *q = &Memory.ROM [CMemory::MAX_ROM_SIZE - 0x10000] + offset * 64;
+ uint8 *q = &Memory.ROM [MAX_ROM_SIZE - 0x10000] + offset * 64;
if (depth == 8)
{
@@ -697,7 +697,7 @@ static void S9xSA1DMA () {
case 0: // ROM
s = SA1_Map [(src >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (s >= (uint8 *) CMemory::MAP_LAST)
+ if (s >= (uint8 *) MAP_LAST)
s += (src & 0xffff);
else
s = Memory.ROM + (src & 0xffff);
@@ -46,8 +46,10 @@ #define _sa1_h_
#include "memmap.h"
+#include "cpuexec.h"
-struct SSA1Registers {
+typedef struct
+{
uint8 PB;
uint8 DB;
pair P;
@@ -57,10 +59,11 @@ struct SSA1Registers { pair X;
pair Y;
uint16 PC;
-};
+}SSA1Registers ;
-struct SSA1 {
- struct SOpcodes *S9xOpcodes;
+typedef struct
+{
+ SOpcodes *S9xOpcodes;
uint8 _Carry;
uint8 _Zero;
uint8 _Negative;
@@ -95,10 +98,10 @@ struct SSA1 { uint8 VirtualBitmapFormat;
bool8 in_char_dma;
uint8 variable_bit_pos;
-};
+}SSA1;
-extern struct SSA1Registers SA1Registers;
-extern struct SSA1 SA1;
+extern SSA1Registers SA1Registers;
+extern SSA1 SA1;
extern uint8 *SA1_Map [MEMMAP_NUM_BLOCKS];
extern uint8 *SA1_WriteMap [MEMMAP_NUM_BLOCKS];
@@ -120,7 +123,6 @@ extern uint8 *SA1_WriteMap [MEMMAP_NUM_BLOCKS]; #define SA1SetFlags(f) (SA1Registers.P.W |= (f))
#define SA1CheckFlag(f) (SA1Registers.PL & (f))
-
START_EXTERN_C
uint8 S9xSA1GetByte (uint32);
//uint16 S9xSA1GetWord (uint32);
@@ -132,10 +134,10 @@ void S9xSA1SetPCBase (uint32); uint8 S9xGetSA1 (uint32);
void S9xSetSA1 (uint8, uint32);
-extern struct SOpcodes S9xSA1OpcodesM1X1 [256];
-extern struct SOpcodes S9xSA1OpcodesM1X0 [256];
-extern struct SOpcodes S9xSA1OpcodesM0X1 [256];
-extern struct SOpcodes S9xSA1OpcodesM0X0 [256];
+extern SOpcodes S9xSA1OpcodesM1X1 [256];
+extern SOpcodes S9xSA1OpcodesM1X0 [256];
+extern SOpcodes S9xSA1OpcodesM0X1 [256];
+extern SOpcodes S9xSA1OpcodesM0X0 [256];
void S9xSA1MainLoop ();
void S9xSA1Init ();
diff --git a/src/sa1cpu.cpp b/src/sa1cpu.c index 0e571cb..eddccfb 100644 --- a/src/sa1cpu.cpp +++ b/src/sa1cpu.c @@ -94,7 +94,7 @@ #undef VAR_CYCLES
#define SA1_OPCODES
-#include "cpuops.cpp"
+#include "cpuops.c"
void S9xSA1MainLoop ()
{
@@ -96,31 +96,34 @@ typedef int int32; #endif #ifdef RIGHTSHIFT_IS_SAR -#define SAR(b, n) ((b)>>(n)) +#define SAR8(b, n) ((b)>>(n)) +#define SAR16(b, n) ((b)>>(n)) +#define SAR32(b, n) ((b)>>(n)) +#define SAR64(b, n) ((b)>>(n)) #else -static inline int8 SAR(const int8 b, const int n){ +static inline int8 SAR8(const int8 b, const int n){ #ifndef RIGHTSHIFT_INT8_IS_SAR if(b<0) return (b>>n)|(-1<<(8-n)); #endif return b>>n; } -static inline int16 SAR(const int16 b, const int n){ +static inline int16 SAR16(const int16 b, const int n){ #ifndef RIGHTSHIFT_INT16_IS_SAR if(b<0) return (b>>n)|(-1<<(16-n)); #endif return b>>n; } -static inline int32 SAR(const int32 b, const int n){ +static inline int32 SAR32(const int32 b, const int n){ #ifndef RIGHTSHIFT_INT32_IS_SAR if(b<0) return (b>>n)|(-1<<(32-n)); #endif return b>>n; } -static inline int64 SAR(const int64 b, const int n){ +static inline int64 SAR64(const int64 b, const int n){ #ifndef RIGHTSHIFT_INT64_IS_SAR if(b<0) return (b>>n)|(-1<<(64-n)); #endif diff --git a/src/sdd1.cpp b/src/sdd1.c index 878bf4c..878bf4c 100644 --- a/src/sdd1.cpp +++ b/src/sdd1.c diff --git a/src/sdd1emu.cpp b/src/sdd1emu.c index 3f97ee2..3f97ee2 100644 --- a/src/sdd1emu.cpp +++ b/src/sdd1emu.c diff --git a/src/sdd1emu.h b/src/sdd1emu.h index e9d4785..829ac4a 100644 --- a/src/sdd1emu.h +++ b/src/sdd1emu.h @@ -92,13 +92,13 @@ /* for START_EXTERN_C/END_EXTERN_C */ #include "port.h" -extern "C" { +START_EXTERN_C void SDD1_decompress(uint8 *out, uint8 *in, int output_length); void SDD1_init(uint8 *in); uint8 SDD1_get_byte(void); -} +END_EXTERN_C #endif diff --git a/src/seta.cpp b/src/seta.c index 0600a07..0600a07 100644 --- a/src/seta.cpp +++ b/src/seta.c diff --git a/src/seta010.cpp b/src/seta010.c index c6dc266..c6dc266 100644 --- a/src/seta010.cpp +++ b/src/seta010.c diff --git a/src/seta011.cpp b/src/seta011.c index 364e9ef..364e9ef 100644 --- a/src/seta011.cpp +++ b/src/seta011.c diff --git a/src/seta018.cpp b/src/seta018.c index 5390a35..5390a35 100644 --- a/src/seta018.cpp +++ b/src/seta018.c diff --git a/src/snaporig.cpp b/src/snaporig.c index 26ee8b7..3ede5af 100644 --- a/src/snaporig.cpp +++ b/src/snaporig.c @@ -315,7 +315,7 @@ static int ReadOrigSnapshot (STREAM snap) return (result); if ((result = ReadBlock ("RAM:", Memory.RAM, 0x20000, snap)) != SUCCESS) return (result); - if ((result = ReadBlock ("SRA:", ::SRAM, 0x10000, snap)) != SUCCESS) + if ((result = ReadBlock ("SRA:", SRAM, 0x10000, snap)) != SUCCESS) return (result); if ((result = ReadBlock ("FIL:", Memory.FillRAM, 0x8000, snap)) != SUCCESS) return (result); diff --git a/src/snapshot.cpp b/src/snapshot.c index fbcf81f..c44610c 100644 --- a/src/snapshot.cpp +++ b/src/snapshot.c @@ -102,7 +102,7 @@ enum { #define COUNT(ARRAY) (sizeof (ARRAY) / sizeof (ARRAY[0]))
#undef OFFSET
-#define OFFSET(f) Offset(f,struct SCPUState *)
+#define OFFSET(f) Offset(f, SCPUState *)
static FreezeData SnapCPU [] = {
{OFFSET (Flags), 4, INT_V},
@@ -120,7 +120,7 @@ static FreezeData SnapCPU [] = { };
#undef OFFSET
-#define OFFSET(f) Offset(f,struct SRegisters *)
+#define OFFSET(f) Offset(f, SRegisters *)
static FreezeData SnapRegisters [] = {
{OFFSET (PB), 1, INT_V},
@@ -135,7 +135,7 @@ static FreezeData SnapRegisters [] = { };
#undef OFFSET
-#define OFFSET(f) Offset(f,struct SPPU *)
+#define OFFSET(f) Offset(f, SPPU *)
static FreezeData SnapPPU [] = {
{OFFSET (BGMode), 1, INT_V},
@@ -268,32 +268,32 @@ static FreezeData SnapPPU [] = { };
#undef OFFSET
-#define OFFSET(f) Offset(f,struct SDMA *)
+#define OFFSET(f) Offset(f, SDMA *)
static FreezeData SnapDMA [] = {
#define O(N) \
- {OFFSET (TransferDirection) + N * sizeof (struct SDMA), 1, INT_V}, \
- {OFFSET (AAddressFixed) + N * sizeof (struct SDMA), 1, INT_V}, \
- {OFFSET (AAddressDecrement) + N * sizeof (struct SDMA), 1, INT_V}, \
- {OFFSET (TransferMode) + N * sizeof (struct SDMA), 1, INT_V}, \
- {OFFSET (ABank) + N * sizeof (struct SDMA), 1, INT_V}, \
- {OFFSET (AAddress) + N * sizeof (struct SDMA), 2, INT_V}, \
- {OFFSET (Address) + N * sizeof (struct SDMA), 2, INT_V}, \
- {OFFSET (BAddress) + N * sizeof (struct SDMA), 1, INT_V}, \
- {OFFSET (TransferBytes) + N * sizeof (struct SDMA), 2, INT_V}, \
- {OFFSET (HDMAIndirectAddressing) + N * sizeof (struct SDMA), 1, INT_V}, \
- {OFFSET (IndirectAddress) + N * sizeof (struct SDMA), 2, INT_V}, \
- {OFFSET (IndirectBank) + N * sizeof (struct SDMA), 1, INT_V}, \
- {OFFSET (Repeat) + N * sizeof (struct SDMA), 1, INT_V}, \
- {OFFSET (LineCount) + N * sizeof (struct SDMA), 1, INT_V}, \
- {OFFSET (FirstLine) + N * sizeof (struct SDMA), 1, INT_V}
+ {OFFSET (TransferDirection) + N * sizeof ( SDMA), 1, INT_V}, \
+ {OFFSET (AAddressFixed) + N * sizeof ( SDMA), 1, INT_V}, \
+ {OFFSET (AAddressDecrement) + N * sizeof ( SDMA), 1, INT_V}, \
+ {OFFSET (TransferMode) + N * sizeof ( SDMA), 1, INT_V}, \
+ {OFFSET (ABank) + N * sizeof ( SDMA), 1, INT_V}, \
+ {OFFSET (AAddress) + N * sizeof ( SDMA), 2, INT_V}, \
+ {OFFSET (Address) + N * sizeof ( SDMA), 2, INT_V}, \
+ {OFFSET (BAddress) + N * sizeof ( SDMA), 1, INT_V}, \
+ {OFFSET (TransferBytes) + N * sizeof ( SDMA), 2, INT_V}, \
+ {OFFSET (HDMAIndirectAddressing) + N * sizeof ( SDMA), 1, INT_V}, \
+ {OFFSET (IndirectAddress) + N * sizeof ( SDMA), 2, INT_V}, \
+ {OFFSET (IndirectBank) + N * sizeof ( SDMA), 1, INT_V}, \
+ {OFFSET (Repeat) + N * sizeof ( SDMA), 1, INT_V}, \
+ {OFFSET (LineCount) + N * sizeof ( SDMA), 1, INT_V}, \
+ {OFFSET (FirstLine) + N * sizeof ( SDMA), 1, INT_V}
O(0), O(1), O(2), O(3), O(4), O(5), O(6), O(7)
#undef O
};
#undef OFFSET
-#define OFFSET(f) Offset(f,struct SAPU *)
+#define OFFSET(f) Offset(f, SAPU *)
static FreezeData SnapAPU [] = {
{OFFSET (Cycles), 4, INT_V},
@@ -310,7 +310,7 @@ static FreezeData SnapAPU [] = { };
#undef OFFSET
-#define OFFSET(f) Offset(f,struct SAPURegisters *)
+#define OFFSET(f) Offset(f, SAPURegisters *)
static FreezeData SnapAPURegisters [] = {
{OFFSET (P) , 1, INT_V},
@@ -374,7 +374,7 @@ static FreezeData SnapSoundData [] = { #ifdef USE_SA1
#undef OFFSET
-#define OFFSET(f) Offset(f,struct SSA1Registers *)
+#define OFFSET(f) Offset(f, SSA1Registers *)
static FreezeData SnapSA1Registers [] = {
{OFFSET (PB), 1, INT_V},
@@ -389,7 +389,7 @@ static FreezeData SnapSA1Registers [] = { };
#undef OFFSET
-#define OFFSET(f) Offset(f,struct SSA1 *)
+#define OFFSET(f) Offset(f, SSA1 *)
static FreezeData SnapSA1 [] = {
{OFFSET (Flags), 4, INT_V},
@@ -499,7 +499,7 @@ static void Freeze () // RAM and VRAM
FreezeBlock ("VRA", Memory.VRAM, 0x10000);
FreezeBlock ("RAM", Memory.RAM, 0x20000);
- FreezeBlock ("SRA", ::SRAM, 0x20000);
+ FreezeBlock ("SRA", SRAM, 0x20000);
FreezeBlock ("FIL", Memory.FillRAM, 0x8000);
if (Settings.APUEnabled)
{
@@ -581,7 +581,7 @@ static int Unfreeze() return (result);
- Memory.FixROMSpeed ();
+ FixROMSpeed ();
CPU.Flags |= old_flags & (DEBUG_MODE_FLAG | TRACE_FLAG |
SINGLE_STEP_FLAG | FRAME_ADVANCE_FLAG);
if ((result = UnfreezeStruct("REG", &Registers, SnapRegisters, COUNT (SnapRegisters))) != SUCCESS)
@@ -613,7 +613,7 @@ static int Unfreeze() if ((result = UnfreezeBlock ("RAM", Memory.RAM, 0x20000)) != SUCCESS)
return (result);
- if ((result = UnfreezeBlock ("SRA", ::SRAM, 0x20000)) != SUCCESS)
+ if ((result = UnfreezeBlock ("SRA", SRAM, 0x20000)) != SUCCESS)
return (result);
if ((result = UnfreezeBlock ("FIL", Memory.FillRAM, 0x8000)) != SUCCESS)
diff --git a/src/snes9x.cpp b/src/snes9x.cpp deleted file mode 100644 index 36e3f44..0000000 --- a/src/snes9x.cpp +++ /dev/null @@ -1,655 +0,0 @@ -/* - * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - * - * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and - * Jerremy Koot (jkoot@snes9x.com) - * - * Super FX C emulator code - * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and - * Gary Henderson. - * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_. - * - * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson. - * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_. - * C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com). - * - * DOS port code contains the works of other authors. See headers in - * individual files. - * - * Snes9x homepage: http://www.snes9x.com - * - * Permission to use, copy, modify and distribute Snes9x in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Snes9x is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Snes9x or software derived from Snes9x. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so everyone can benefit from the modifications - * in future versions. - * - * Super NES and Super Nintendo Entertainment System are trademarks of - * Nintendo Co., Limited and its subsidiary companies. - */ -#include <stdlib.h> -#include <stdio.h> - -#include "snes9x.h" -#include "memmap.h" -#include "display.h" -#include "cheats.h" - -#ifdef DEBUGGER -extern FILE *trace; -#endif - -void S9xUsage () -{ - S9xMessage (S9X_INFO, S9X_USAGE, "snes9x: S9xUsage: snes9x <options> <rom image filename>\n\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "Where <options> can be:\n"); - - S9xMessage (S9X_INFO, S9X_USAGE, "\ --cycles or -h <num> Percentage of CPU cycles to execute every scan line (default 90)\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --frameskip or -f <num> Screen update frame skip rate (default 2)\n"); - S9xExtraUsage (); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --forcehirom or -F or -FH Force Hi-ROM memory map, useful for hacked ROM imagess.\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --forcelorom or -FL Force Lo-ROM memory map, useful for hacked ROM images.\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --old or -o Enable old-style SNES joypad emulation\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --noold or -no Disbale old-style SNES joypad emulation\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --soundskip or -ss <num> Sound CPU skip-waiting method, 0 - 3 (default 0)\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --sound or -S Enable digital sound output (default: enabled)\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --nosound or -NS Disable digital sound output\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --sound or -S Enable digital sound output (default: off)\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --soundquality or -r <num> Sound sample playback rate/quality, 0-7 (default 4)\n"); - -#ifdef __sgi -/* BS: changed the sample rate values to match the IRIX options */ - S9xMessage (S9X_INFO, S9X_USAGE, "\ - 0 - off, 1 - 8192, 2 - 11025, 3 - 16000,\n\ - 4 - 22050 (default), 5 - 32000, 6 - 44100,\n\ - 7 - 48000\n"); -#else - S9xMessage (S9X_INFO, S9X_USAGE, "\ - 0 - off, 1 - 8192, 2 - 11025, 3 - 16500,\n\ - 4 - 22050 (default), 5 - 29300, 6 - 36600,\n\ - 7 - 44000\n"); -#endif - - S9xMessage (S9X_INFO, S9X_USAGE, "\ --stereo Enable stereo sound (default: mono sound)\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --mono Enable mono sound (default: mono sound)\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --buffersize or -B Sound playback buffer size (default auto for playback rate)\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --nospeedhacks or -N Disable some internal speed ups that break a few ROMs\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --speedhacks or -SH Enable some internal speed ups that break a few ROMs\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --loadsnapshot or -l <filename>\n\ - Load saved game position snapshot file & required ROM\n\ - image.\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --swapjoypads or -s Swap joypad 1 and 2 around\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --pal or -p Fool ROM into thinking that this is a PAL SNES system\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --ntsc or -n Fool ROM into thinking that this is a NTCS SNES system\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --interleaved or -i ROM image is in interleaved format.\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --interleaved2 or -i2 ROM image is in interleaved 2 format\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --nohdma or -H Disable H-DMA emulation (default: enabled)\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --hdma or -NH Enable H-DMA emulation (default: enabled)\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --layering or -L Swap some background priority levels - helps some games\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --graphicwindows Enable graphic window effects (default: enabled)\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --nographicwindows or -nw Disable graphic window effects (default: enabled)\n"); -#ifdef DEBUGGER - S9xMessage (S9X_INFO, S9X_USAGE, "\ --noirq or -I Disable processor IRQ (for debugging)\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --debug or -d Enter debug mode once ROM has loaded\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --trace or -t Trace CPU instructions to file (WARNING: file gets very large!)\n"); -#endif - -#ifdef JOYSTICK_SUPPORT -#ifdef __linux - S9xMessage (S9X_INFO, S9X_USAGE, "\ --joydevX /dev/jsY Use joystick device /dev/jsY for emulation of gamepad X\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --joymapX 0 1 2 3 4 5 6 7 Joystick buttons which should be assigned to gamepad X - A B X Y TL TR Start and Select\n"); -#else - S9xMessage (S9X_INFO, S9X_USAGE, "\ --four or -4 Single standard PC joystick has four buttons\n"); - S9xMessage (S9X_INFO, S9X_USAGE, "\ --six or -6 Single standard PC joystick has six buttons\n"); -#endif - S9xMessage (S9X_INFO, S9X_USAGE, "\ --nojoy or -j Disable joystick support\n"); -#endif - - S9xMessage (S9X_INFO, S9X_USAGE, "\ -\nROM image needs to be in Super MagiCom (*.smc), Super FamiCom (*.sfc),\n\ -*.fig, or split (*.1, *.2, or sf32527a, sf32527b, etc) format and can be\n\ -compressed with gzip or compress.\n"); - - exit (1); -} - -#ifdef STORM -extern int dofps; -extern int hicolor; -extern int secondjoy; -extern int minimal; -int prelude=0; -extern int unit; -#endif - -char *S9xParseArgs (char **argv, int argc) -{ - char *rom_filename = NULL; - - for (int i = 1; i < argc; i++) - { - if (*argv[i] == '-') - { - if (strcasecmp (argv [i], "-so") == 0 || - strcasecmp (argv [i], "-sound") == 0) - { - Settings.NextAPUEnabled = TRUE; - } - else if (strcasecmp (argv [i], "-ns") == 0 || - strcasecmp (argv [i], "-nosound") == 0) - { - Settings.NextAPUEnabled = FALSE; - } - else if (strcasecmp (argv [i], "-soundskip") == 0 || - strcasecmp (argv [i], "-sk") == 0) - { - if (i + 1 < argc) - Settings.SoundSkipMethod = atoi (argv [++i]); - else - S9xUsage (); - } - else if (strcasecmp (argv [i], "-ra") == 0 || - strcasecmp (argv [i], "-ratio") == 0) - { - if (i + 1 < argc) - { - } - else - S9xUsage (); - } - else if (strcasecmp (argv [i], "-h") == 0 || - strcasecmp (argv [i], "-cycles") == 0) - { - if (i + 1 < argc) - { - int p = atoi (argv [++i]); - if (p > 0 && p < 200) - Settings.CyclesPercentage = p; - } - else - S9xUsage (); - } - else if (strcasecmp (argv [i], "-nh") == 0 || - strcasecmp (argv [i], "-nohdma") == 0) - { - Settings.DisableHDMA = TRUE; - } - else if (strcasecmp (argv [i], "-ha") == 0 || - strcasecmp (argv [i], "-hdma") == 0) - { - Settings.DisableHDMA = FALSE; - } - else if (strcasecmp (argv [i], "-n") == 0 || - strcasecmp (argv [i], "-nospeedhacks") == 0) - { - Settings.ShutdownMaster = FALSE; - } - else if (strcasecmp (argv [i], "-sh") == 0 || - strcasecmp (argv [i], "-speedhacks") == 0) - { - Settings.ShutdownMaster = TRUE; - } - else if (strcasecmp (argv [i], "-p") == 0 || - strcasecmp (argv [i], "-pal") == 0) - { - Settings.ForcePAL = TRUE; - } - else if (strcasecmp (argv [i], "-n") == 0 || - strcasecmp (argv [i], "-ntsc") == 0) - { - Settings.ForceNTSC = TRUE; - } - else if (strcasecmp (argv [i], "-f") == 0 || - strcasecmp (argv [i], "-frameskip") == 0) - { - if (i + 1 < argc) - Settings.SkipFrames = atoi (argv [++i]) + 1; - else - S9xUsage (); - } - else if (strcasecmp (argv [i], "-fh") == 0 || - strcasecmp (argv [i], "-hr") == 0 || - strcasecmp (argv [i], "-hirom") == 0) - Settings.ForceHiROM = TRUE; - else if (strcasecmp (argv [i], "-fl") == 0 || - strcasecmp (argv [i], "-lr") == 0 || - strcasecmp (argv [i], "-lorom") == 0) - Settings.ForceLoROM = TRUE; - else if (strcasecmp (argv [i], "-hd") == 0 || - strcasecmp (argv [i], "-header") == 0 || - strcasecmp (argv [i], "-he") == 0) - { - Settings.ForceHeader = TRUE; - } - else if (strcasecmp (argv [i], "-nhd") == 0 || - strcasecmp (argv [i], "-noheader") == 0) - { - Settings.ForceNoHeader = TRUE; - } - else if (strcasecmp (argv [i], "-bs") == 0) - { - Settings.BS = TRUE; - } -#ifdef DEBUGGER - else if (strcasecmp (argv [i], "-d") == 0 || - strcasecmp (argv [i], "-debug") == 0) - { - CPU.Flags |= DEBUG_MODE_FLAG; - } - else if (strcasecmp (argv [i], "-t") == 0 || - strcasecmp (argv [i], "-trace") == 0) - { - trace = fopen ("trace.log", "wb"); - CPU.Flags |= TRACE_FLAG; - } -#endif - else if (strcasecmp (argv [i], "-L") == 0 || - strcasecmp (argv [i], "-layering") == 0) - Settings.BGLayering = TRUE; - else if (strcasecmp (argv [i], "-nl") == 0 || - strcasecmp (argv [i], "-nolayering") == 0) - Settings.BGLayering = FALSE; - else if (strcasecmp (argv [i], "-O") == 0 || - strcasecmp (argv [i], "-tileredraw") == 0) - { - } - else if (strcasecmp (argv [i], "-no") == 0 || - strcasecmp (argv [i], "-lineredraw") == 0) - { - } - else if (strcasecmp (argv [i], "-tr") == 0 || - strcasecmp (argv [i], "-transparency") == 0) - { - Settings.ForceTransparency = TRUE; - Settings.ForceNoTransparency = FALSE; - } - else if (strcasecmp (argv [i], "-nt") == 0 || - strcasecmp (argv [i], "-notransparency") == 0) - { - Settings.ForceNoTransparency = TRUE; - Settings.ForceTransparency = FALSE; - } - else if (strcasecmp (argv [i], "-hi") == 0 || - strcasecmp (argv [i], "-hires") == 0) - { - Settings.SupportHiRes = TRUE; - } - else if (strcasecmp (argv [i], "-16") == 0 || - strcasecmp (argv [i], "-sixteen") == 0) - { - Settings.SixteenBit = TRUE; - } - else if (strcasecmp (argv [i], "-displayframerate") == 0 || - strcasecmp (argv [i], "-dfr") == 0) - { - Settings.DisplayFrameRate = TRUE; - } - else if (strcasecmp (argv [i], "-s") == 0 || - strcasecmp (argv [i], "-swapjoypads") == 0 || - strcasecmp (argv [i], "-sw") == 0) - Settings.SwapJoypads = TRUE; - else if (strcasecmp (argv [i], "-i") == 0 || - strcasecmp (argv [i], "-interleaved") == 0) - Settings.ForceInterleaved = TRUE; - else if (strcasecmp (argv [i], "-i2") == 0 || - strcasecmp (argv [i], "-interleaved2") == 0) - Settings.ForceInterleaved2 = TRUE; - else if (strcasecmp (argv [i], "-ni") == 0 || - strcasecmp (argv [i], "-nointerleave") == 0) - Settings.ForceNotInterleaved = TRUE; - else if (strcasecmp (argv [i], "-noirq") == 0) - Settings.DisableIRQ = TRUE; - else if (strcasecmp (argv [i], "-nw") == 0 || - strcasecmp (argv [i], "-nowindows") == 0) - { - Settings.DisableGraphicWindows = TRUE; - } - else if (strcasecmp (argv [i], "-windows") == 0) - { - Settings.DisableGraphicWindows = FALSE; - } - else if (strcasecmp (argv [i], "-im7") == 0) - { - Settings.Mode7Interpolate = TRUE; - } - else if (strcasecmp (argv [i], "-gg") == 0 || - strcasecmp (argv [i], "-gamegenie") == 0) - { - if (i + 1 < argc) - { - uint32 address; - uint8 byte; - const char *error; - if ((error = S9xGameGenieToRaw (argv [++i], address, byte)) == NULL) - S9xAddCheat (TRUE, FALSE, address, byte); - else - S9xMessage (S9X_ERROR, S9X_GAME_GENIE_CODE_ERROR, - error); - } - else - S9xUsage (); - } - else if (strcasecmp (argv [i], "-ar") == 0 || - strcasecmp (argv [i], "-actionreplay") == 0) - { - if (i + 1 < argc) - { - uint32 address; - uint8 byte; - const char *error; - if ((error = S9xProActionReplayToRaw (argv [++i], address, byte)) == NULL) - S9xAddCheat (TRUE, FALSE, address, byte); - else - S9xMessage (S9X_ERROR, S9X_ACTION_REPLY_CODE_ERROR, - error); - } - else - S9xUsage (); - } - else if (strcasecmp (argv [i], "-gf") == 0 || - strcasecmp (argv [i], "-goldfinger") == 0) - { - if (i + 1 < argc) - { - uint32 address; - uint8 bytes [3]; - bool8 sram; - uint8 num_bytes; - const char *error; - if ((error = S9xGoldFingerToRaw (argv [++i], address, sram, - num_bytes, bytes)) == NULL) - { - for (int c = 0; c < num_bytes; c++) - S9xAddCheat (TRUE, FALSE, address + c, bytes [c]); - } - else - S9xMessage (S9X_ERROR, S9X_GOLD_FINGER_CODE_ERROR, - error); - } - else - S9xUsage (); - } - else if (strcasecmp (argv[i], "-ft") == 0 || - strcasecmp (argv [i], "-frametime") == 0) - { - if (i + 1 < argc) - { - double ft; - if (sscanf (argv [++i], "%lf", &ft) == 1) - { -#ifdef __WIN32__ - Settings.FrameTimePAL = (int32) (ft * 1000); - Settings.FrameTimeNTSC = (int32) (ft * 1000); -#else - Settings.FrameTimePAL = (int32) ft; - Settings.FrameTimeNTSC = (int32) ft; -#endif - - } - } - else - S9xUsage (); - } - else if (strcasecmp (argv [i], "-e") == 0 || - strcasecmp (argv [i], "-echo") == 0) - Settings.DisableSoundEcho = FALSE; - else if (strcasecmp (argv [i], "-ne") == 0 || - strcasecmp (argv [i], "-noecho") == 0) - Settings.DisableSoundEcho = TRUE; - else if (strcasecmp (argv [i], "-r") == 0 || - strcasecmp (argv [i], "-soundquality") == 0 || - strcasecmp (argv [i], "-sq") == 0) - { - if (i + 1 < argc) - Settings.SoundPlaybackRate = atoi (argv [++i]) & 7; - else - S9xUsage (); - } - else if (strcasecmp (argv [i], "-stereo") == 0 || - strcasecmp (argv [i], "-st") == 0) - { - Settings.Stereo = TRUE; - Settings.APUEnabled = TRUE; - Settings.NextAPUEnabled = TRUE; - } - else if (strcasecmp (argv [i], "-mono") == 0) - { - Settings.Stereo = FALSE; - Settings.NextAPUEnabled = TRUE; - } - else if (strcasecmp (argv [i], "-envx") == 0 || - strcasecmp (argv [i], "-ex") == 0) - { - Settings.SoundEnvelopeHeightReading = TRUE; - } - else if (strcasecmp (argv [i], "-nosamplecaching") == 0 || - strcasecmp (argv [i], "-nsc") == 0 || - strcasecmp (argv [i], "-nc") == 0) - { - Settings.DisableSampleCaching = TRUE; - } - else if (strcasecmp (argv [i], "-nomastervolume") == 0 || - strcasecmp (argv [i], "-nmv") == 0) - { - Settings.DisableMasterVolume = TRUE; - } - else if (strcasecmp (argv [i], "-soundsync") == 0 || - strcasecmp (argv [i], "-sy") == 0) - { - Settings.SoundSync = TRUE; - Settings.SoundEnvelopeHeightReading = TRUE; - Settings.InterpolatedSound = TRUE; - } - else if (strcasecmp (argv [i], "-soundsync2") == 0 || - strcasecmp (argv [i], "-sy2") == 0) - { - Settings.SoundSync = 2; - Settings.SoundEnvelopeHeightReading = TRUE; - Settings.InterpolatedSound = TRUE; - } - else if (strcasecmp (argv [i], "-interpolatedsound") == 0 || - strcasecmp (argv [i], "-is") == 0) - { - Settings.InterpolatedSound = TRUE; - } -#ifdef USE_THREADS - else if (strcasecmp (argv [i], "-threadsound") == 0 || - strcasecmp (argv [i], "-ts") == 0) - { - Settings.ThreadSound = TRUE; - } -#endif - else if (strcasecmp (argv [i], "-alt") == 0 || - strcasecmp (argv [i], "-altsampledecode") == 0) - { - Settings.AltSampleDecode = 1; - } - else if (strcasecmp (argv [i], "-fix") == 0) - { - Settings.FixFrequency = 1; - } - else if (strcasecmp (argv [i], "-nosuperfx") == 0 || - strcasecmp (argv [i], "-nosfx") == 0) - Settings.ForceNoSuperFX = TRUE; - else if (strcasecmp (argv [i], "-superfx") == 0 || - strcasecmp (argv [i], "-sfx") == 0) - Settings.ForceSuperFX = TRUE; - else if (strcasecmp (argv [i], "-dsp1") == 0) - Settings.ForceDSP1 = TRUE; - else if (strcasecmp (argv [i], "-nodsp1") == 0) - Settings.ForceNoDSP1 = TRUE; - else if (strcasecmp (argv [i], "-nomultiplayer5") == 0 || - strcasecmp (argv [i], "-nmp") == 0) - Settings.MultiPlayer5 = FALSE; - else if (strcasecmp (argv [i], "-multiplayer5") == 0 || - strcasecmp (argv [i], "-mp") == 0) - { - Settings.MultiPlayer5 = TRUE; - Settings.ControllerOption = SNES_MULTIPLAYER5; - } - else if (strcasecmp (argv [i], "-mouse") == 0 || - strcasecmp (argv [i], "-mo") == 0) - { - Settings.ControllerOption = SNES_MOUSE_SWAPPED; - Settings.Mouse = TRUE; - } - else if (strcasecmp (argv [i], "-nomouse") == 0 || - strcasecmp (argv [i], "-nm") == 0) - { - Settings.Mouse = FALSE; - } - else if (strcasecmp (argv [i], "-superscope") == 0 || - strcasecmp (argv [i], "-ss") == 0) - { - Settings.SuperScope = TRUE; - Settings.ControllerOption = SNES_SUPERSCOPE; - } - else if (strcasecmp (argv [i], "-nosuperscope") == 0 || - strcasecmp (argv [i], "-nss") == 0) - { - Settings.SuperScope = FALSE; - } -#ifdef NETPLAY_SUPPORT - else if (strcasecmp (argv [i], "-port") == 0 || - strcasecmp (argv [i], "-po") == 0) - { - if (i + 1 < argc) - { - Settings.NetPlay = TRUE; - Settings.Port = -atoi (argv [++i]); - } - else - S9xUsage (); - } - else if (strcasecmp (argv [i], "-server") == 0 || - strcasecmp (argv [i], "-srv") == 0) - { - if (i + 1 < argc) - { - Settings.NetPlay = TRUE; - strncpy (Settings.ServerName, argv [++i], 127); - Settings.ServerName [127] = 0; - } - else - S9xUsage (); - } - else if (strcasecmp (argv [i], "-net") == 0) - { - Settings.NetPlay = TRUE; - } -#endif -#ifdef STORM - else if (strcasecmp(argv[i],"-nosecondjoy")==0){secondjoy=0;} - else if (strcasecmp(argv[i],"-showfps")==0){dofps=1;} - else if (strcasecmp(argv[i],"-hicolor")==0){hicolor=1;} - else if (strcasecmp(argv[i],"-minimal")==0){minimal=1;printf("Keyboard with exception of ESC switched off!\n");} - else if (strcasecmp(argv[i],"-ahiunit")==0) - { - if (i+1<argc) - { - fprintf(stderr,"AHI Unit set to: Unit %i\n",atoi(argv[++i])); - unit=atoi(argv[++i]); - } - } -#endif - - else - S9xParseArg (argv, i, argc); - } - else - rom_filename = argv [i]; - } - - return (rom_filename); -} - -void S9xParseCheatsFile (const char *rom_filename) -{ - FILE *f; - char dir [_MAX_DIR]; - char drive [_MAX_DRIVE]; - char name [_MAX_FNAME]; - char ext [_MAX_EXT]; - char fname [_MAX_PATH]; - char buf [80]; - uint32 address; - uint8 byte; - uint8 bytes [3]; - bool8 sram; - uint8 num_bytes; - const char *error; - char *p; - - _splitpath (rom_filename, drive, dir, name, ext); - _makepath (fname, drive, dir, name, "pat"); - - if ((f = fopen(fname, "r")) != NULL) - { - while(fgets(buf, 80, f) != NULL) - { - if ((p = strrchr (buf, '\n')) != NULL) - *p = '\0'; -/* if (((error = S9xGameGenieToRaw (buf, address, byte)) == NULL) || - ((error = S9xProActionReplayToRaw (buf, address, byte)) == NULL)) - { - S9xAddCheat (TRUE, FALSE, address, byte); - } - else - if ((error = S9xGoldFingerToRaw (buf, address, sram, - num_bytes, bytes)) == NULL) - { - for (int c = 0; c < num_bytes; c++) - S9xAddCheat (TRUE, FALSE, address + c, bytes [c]); - } - else - S9xMessage (S9X_ERROR, S9X_GAME_GENIE_CODE_ERROR, error);*/ - } - fclose(f); - } -} diff --git a/src/snes9x.h b/src/snes9x.h index 787b60d..8a37095 100644 --- a/src/snes9x.h +++ b/src/snes9x.h @@ -199,13 +199,14 @@ enum { #undef MEMMAP_NUM_BLOCKS
#define MEMMAP_NUM_BLOCKS (0x1000000 / MEMMAP_BLOCK_SIZE)
-struct SCPUState{
+typedef struct
+{
uint32 Flags; //0
bool8 BranchSkip; //4
bool8 NMIActive; //5
bool8 IRQActive; //6
bool8 WaitingForInterrupt; //7
- struct SRegisters Regs; //8
+ SRegisters Regs; //8
//uint8 PB; //8 --> status
//uint8 DB; //9
//pair P; //10
@@ -254,7 +255,7 @@ struct SCPUState{ void *DSPGet;
void *DSPSet;
int32 rstatus;
-};
+}SCPUState;
#define HBLANK_START_EVENT 0
@@ -263,7 +264,8 @@ struct SCPUState{ #define HTIMER_AFTER_EVENT 3
#define NO_EVENT 4
-struct SSettings{
+typedef struct
+{
// CPU options
bool8 APUEnabled;
bool8 Shutdown;
@@ -398,9 +400,9 @@ struct SSettings{ #ifdef __WIN32__
int SoundDriver;
#endif
-};
+}SSettings;
-struct SSNESGameFixes
+typedef struct
{
uint8 NeedInit0x2137;
uint8 umiharakawaseFix;
@@ -414,12 +416,12 @@ struct SSNESGameFixes uint8 Uniracers;
uint8 Flintstones;
uint8 Mode7Hack;
-};
+}SSNESGameFixes;
START_EXTERN_C
-extern struct SSettings Settings;
-extern struct SCPUState CPU;
-extern struct SSNESGameFixes SNESGameFixes;
+extern SSettings Settings;
+extern SCPUState CPU;
+extern SSNESGameFixes SNESGameFixes;
extern char String [513];
void S9xExit ();
diff --git a/src/soundux.cpp b/src/soundux.c index d4b7cb9..50b737b 100644 --- a/src/soundux.cpp +++ b/src/soundux.c @@ -105,7 +105,7 @@ extern long FilterValues[4][2]; #define VOL_DIV16 0x0080
#define ENVX_SHIFT 24
-extern "C" void DecodeBlockAsm (int8 *, int16 *, int32 *, int32 *);
+void DecodeBlockAsm (int8 *, int16 *, int32 *, int32 *);
// F is channel's current frequency and M is the 16-bit modulation waveform
// from the previous channel multiplied by the current envelope volume level.
@@ -211,7 +211,7 @@ void S9xSetEnvelopeHeight (int channel, int level) }
#if 1
-void S9xSetSoundSample (int, uint16)
+void S9xSetSoundSample (int channel, uint16 sample_number)
{
}
#else
diff --git a/src/soundux.h b/src/soundux.h index 4b313df..9d084bd 100644 --- a/src/soundux.h +++ b/src/soundux.h @@ -270,6 +270,7 @@ static inline void S9xSetEnvRate (Channel *ch, unsigned long rate, int direction static inline void S9xSetEchoEnable (uint8 byte)
{
+ int i;
SoundData.echo_channel_enable = byte;
if (!SoundData.echo_write_enabled || Settings.DisableSoundEcho)
byte = 0;
@@ -280,7 +281,7 @@ static inline void S9xSetEchoEnable (uint8 byte) }
SoundData.echo_enable = byte;
- for (int i = 0; i < 8; i++)
+ for (i = 0; i < 8; i++)
{
if (byte & (1 << i))
SoundData.channels [i].echo_buf_ptr = EchoBuffer;
diff --git a/src/spc700.cpp b/src/spc700.c index 637d2db..8fd1230 100644 --- a/src/spc700.cpp +++ b/src/spc700.c @@ -50,7 +50,7 @@ // we only need the memhandlers
#undef INLINE
-#define INLINE extern "C"
+#define INLINE
#include "apumem.h"
#define OP1 (*(IAPU.PC + 1))
diff --git a/src/spc700.h b/src/spc700.h index 6b73f44..66ef814 100644 --- a/src/spc700.h +++ b/src/spc700.h @@ -95,13 +95,14 @@ typedef union uint32 _padder; // make sure this whole thing takes 4 bytes
} YAndA;
-struct SAPURegisters{
+typedef struct
+{
uint8 P;
YAndA YA;
uint8 X;
uint8 S;
uint16 PC;
-};
+}SAPURegisters;
//EXTERN_C struct SAPURegisters APURegisters;
diff --git a/src/srtc.cpp b/src/srtc.c index be390f0..be390f0 100644 --- a/src/srtc.cpp +++ b/src/srtc.c diff --git a/src/tile.cpp b/src/tile.c index 34735a7..b1e53d1 100644 --- a/src/tile.cpp +++ b/src/tile.c @@ -164,7 +164,7 @@ uint8 ConvertTile (uint8 *pCache, uint32 TileAddr) return (non_zero ? TRUE : BLANK_TILE); } -INLINE void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels) { register uint8 Pixel; uint8 *Screen = GFX.S + Offset; @@ -184,7 +184,7 @@ INLINE void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS_FLIPPED (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS_FLIPPED (uint32 Offset, uint8 *Pixels) { register uint8 Pixel; uint8 *Screen = GFX.S + Offset; @@ -244,7 +244,7 @@ inline void WRITE_4PIXELSHI16_FLIPPED (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELSx2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELSx2 (uint32 Offset, uint8 *Pixels) { register uint8 Pixel; uint8 *Screen = GFX.S + Offset; @@ -264,7 +264,7 @@ INLINE void WRITE_4PIXELSx2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) { register uint8 Pixel; uint8 *Screen = GFX.S + Offset; @@ -284,7 +284,7 @@ INLINE void WRITE_4PIXELS_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELSx2x2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELSx2x2 (uint32 Offset, uint8 *Pixels) { register uint8 Pixel; uint8 *Screen = GFX.S + Offset; @@ -306,7 +306,7 @@ INLINE void WRITE_4PIXELSx2x2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) { register uint8 Pixel; uint8 *Screen = GFX.S + Offset; @@ -405,7 +405,7 @@ void DrawLargePixel (uint32 Tile, uint32 Offset, RENDER_TILE_LARGE (((uint8) GFX.ScreenColors [pixel]), PLOT_PIXEL) } -INLINE void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -425,7 +425,7 @@ INLINE void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -445,7 +445,7 @@ INLINE void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -465,7 +465,7 @@ INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -485,7 +485,7 @@ INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -507,7 +507,7 @@ INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -766,7 +766,7 @@ void DrawLargePixel16 (uint32 Tile, uint32 Offset, RENDER_TILE_LARGE (GFX.ScreenColors [pixel], PLOT_PIXEL) } -INLINE void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -798,7 +798,7 @@ INLINE void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -830,7 +830,7 @@ INLINE void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -862,7 +862,7 @@ INLINE void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -894,7 +894,7 @@ INLINE void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -926,7 +926,7 @@ INLINE void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -958,7 +958,7 @@ INLINE void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -990,7 +990,7 @@ INLINE void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1103,7 +1103,7 @@ void DrawClippedTile16Sub1_2 (uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUB1_2, WRITE_4PIXELS16_FLIPPED_SUB1_2, 4) } -INLINE void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1129,7 +1129,7 @@ INLINE void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1155,7 +1155,7 @@ INLINE void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1181,7 +1181,7 @@ INLINE void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; diff --git a/src/tile16.cpp b/src/tile16.c index 3dc6e2a..c2825df 100644 --- a/src/tile16.cpp +++ b/src/tile16.c @@ -87,7 +87,7 @@ uint8 ConvertTile8bpp (uint8 *pCache, uint32 TileAddr) register uint32 *p = (uint32 *) pCache; register uint32 non_zero; - asm volatile ( + __asm__ volatile ( " mov r0, #8 \n" " mov %[non_zero], #0 \n" @@ -132,7 +132,7 @@ uint8 ConvertTile4bpp (uint8 *pCache, uint32 TileAddr) register uint32 *p = (uint32 *) pCache; register uint32 non_zero; - asm volatile ( + __asm__ volatile ( " mov r0, #8 \n" " mov %[non_zero], #0 \n" "1: \n" @@ -170,7 +170,7 @@ uint8 ConvertTile2bpp (uint8 *pCache, uint32 TileAddr) register uint32 *p = (uint32 *) pCache; register uint32 non_zero; - asm volatile ( + __asm__ volatile ( " mov r0, #8 \n" " mov %[non_zero], #0 \n" "1: \n" @@ -356,7 +356,7 @@ void SelectPalette() { } -inline void WRITE_4PIXELSHI16 (uint32 Offset, uint8 *Pixels) +static inline void WRITE_4PIXELSHI16 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -376,7 +376,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 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -396,7 +396,7 @@ inline void WRITE_4PIXELSHI16_FLIPPED (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -416,7 +416,7 @@ INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -436,7 +436,7 @@ INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -458,7 +458,7 @@ INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -488,7 +488,7 @@ void DrawNoZTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCou TILE_PREAMBLE if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" #define FN(p) \ " ldrb r1, [%[bp], #" #p "] \n"\ @@ -526,7 +526,7 @@ if (Tile & V_FLIP){ : "r0", "r1", "cc" // r8 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" #define FN1(p) \ " ldrb r1, [%[bp], #( 7 - " #p ")] \n"\ @@ -566,7 +566,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) FN(2) @@ -590,7 +590,7 @@ if (Tile & V_FLIP){ : "r0", "r1", "cc" // r8 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) FN1(2) @@ -629,7 +629,7 @@ void DrawTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" #define FN(p) \ " ldrb r9, [%[depth], #" #p "] \n"\ @@ -674,7 +674,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r8 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" #define FN1(p) \ " ldrb r9, [%[depth], #" #p "] \n"\ @@ -721,7 +721,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) FN(2) @@ -746,7 +746,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r8 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) FN1(2) @@ -819,7 +819,7 @@ switch(Width) { // -- Width = 1 ------ if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) // Loop @@ -844,7 +844,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) // Loop @@ -871,7 +871,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) // Loop @@ -896,7 +896,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) // Loop @@ -928,7 +928,7 @@ if (Tile & V_FLIP){ // -- Width = 2 ------ if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) @@ -955,7 +955,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) @@ -984,7 +984,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) FN(1) @@ -1010,7 +1010,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) FN1(1) @@ -1044,7 +1044,7 @@ if (Tile & V_FLIP){ // -- Width = 3 ------ if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) @@ -1072,7 +1072,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) @@ -1102,7 +1102,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) FN(1) @@ -1129,7 +1129,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) FN1(1) @@ -1164,7 +1164,7 @@ if (Tile & V_FLIP){ // -- Width = 4 ------ if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) @@ -1193,7 +1193,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) @@ -1224,7 +1224,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) FN(1) @@ -1252,7 +1252,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) FN1(1) @@ -1288,7 +1288,7 @@ if (Tile & V_FLIP){ // -- Width = 5 ------ if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) @@ -1318,7 +1318,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) @@ -1350,7 +1350,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) FN(1) @@ -1379,7 +1379,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) FN1(1) @@ -1416,7 +1416,7 @@ if (Tile & V_FLIP){ // -- Width = 6 ------ if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) @@ -1447,7 +1447,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) @@ -1480,7 +1480,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) FN(1) @@ -1510,7 +1510,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) FN1(1) @@ -1548,7 +1548,7 @@ if (Tile & V_FLIP){ // -- Width = 7 ------ if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) @@ -1580,7 +1580,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) @@ -1614,7 +1614,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN(0) FN(1) @@ -1645,7 +1645,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r9 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1(0) FN1(1) diff --git a/src/tile16.cpp.bak b/src/tile16.cpp.bak index 3d199ff..76c6eb7 100644 --- a/src/tile16.cpp.bak +++ b/src/tile16.cpp.bak @@ -209,7 +209,7 @@ inline void WRITE_4PIXELSHI16_FLIPPED (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -229,7 +229,7 @@ INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -249,7 +249,7 @@ INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -271,7 +271,7 @@ INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) +static INLINE void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -300,7 +300,7 @@ void DrawTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" #define FN(p, p2, p3, p4) \ " ldrb r9, [%[depth], #" p "] \n"\ @@ -346,7 +346,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r8 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" #define FN1(p, p2, p3, p4, p5, p6) \ " ldrb r9, [%[depth], #" p "] \n"\ @@ -394,7 +394,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN("0", "0", "1", "2") FN("2", "4", "3", "6") @@ -420,7 +420,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r8 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1("0", "0", "7", "1", "2", "6") FN1("2", "4", "5", "3", "6", "4") @@ -466,7 +466,7 @@ Offset = Offset + StartPixel; if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" #define FN(p) \ " ldrb r9, [%[depth], #" p "] \n"\ @@ -519,7 +519,7 @@ if (Tile & V_FLIP){ : "r9", "cc" // r8 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" #define FN1(p) \ " ldrb r9, [%[depth], #" p "] \n"\ @@ -571,7 +571,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN("0") C("0") @@ -610,7 +610,7 @@ if (Tile & V_FLIP){ : "r9", "cc" // r8 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1("0") C("0") diff --git a/src/tile16_t.h b/src/tile16_t.h index f4a0a57..cda914f 100644 --- a/src/tile16_t.h +++ b/src/tile16_t.h @@ -80,7 +80,7 @@ DEC_DRAWNOZ(ROPNAME) if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" ROW("#8") @@ -106,7 +106,7 @@ DEC_DRAWNOZ(ROPNAME) : "r8", "r9", "r10", "cc" ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" ROW1("#8") @@ -132,7 +132,7 @@ DEC_DRAWNOZ(ROPNAME) } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" ROW("#8") @@ -156,7 +156,7 @@ DEC_DRAWNOZ(ROPNAME) : "r8", "r9", "r10", "cc" ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" ROW1("#8") @@ -268,7 +268,7 @@ DEC_DRAW(ROPNAME) if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" ROW("#8") @@ -294,7 +294,7 @@ DEC_DRAW(ROPNAME) : "r8", "r9", "r10", "cc" ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" ROW1("#8") @@ -320,7 +320,7 @@ DEC_DRAW(ROPNAME) } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" ROW("#8") @@ -344,7 +344,7 @@ DEC_DRAW(ROPNAME) : "r8", "r9", "r10", "cc" ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" ROW1("#8") @@ -384,7 +384,7 @@ if (Width == 0) return; Offset = Offset + StartPixel; if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" ROW("%[width]") @@ -418,7 +418,7 @@ if (Tile & V_FLIP){ : "r8", "r9", "r10", "cc" ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" ROW1("%[width]") // Loop @@ -452,7 +452,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" ROW("%[width]") // Loop @@ -484,7 +484,7 @@ if (Tile & V_FLIP){ : "r8", "r9", "r10", "cc" ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" ROW1("%[width]") // Loop diff --git a/src/tile16add.cpp b/src/tile16add.c index 2211644..2211644 100644 --- a/src/tile16add.cpp +++ b/src/tile16add.c diff --git a/src/tile16add1_2.cpp b/src/tile16add1_2.c index ad52769..ad52769 100644 --- a/src/tile16add1_2.cpp +++ b/src/tile16add1_2.c diff --git a/src/tile16f_t.h b/src/tile16f_t.h index 493f76f..5aac300 100644 --- a/src/tile16f_t.h +++ b/src/tile16f_t.h @@ -87,7 +87,7 @@ DEC_DRAW(ROPNAME) if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" ROW("#8") @@ -113,7 +113,7 @@ DEC_DRAW(ROPNAME) : "r8", "r9", "r10", "cc" ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" ROW1("#8") @@ -139,7 +139,7 @@ DEC_DRAW(ROPNAME) } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" ROW("#8") @@ -163,7 +163,7 @@ DEC_DRAW(ROPNAME) : "r8", "r9", "r10", "cc" ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" ROW1("#8") @@ -203,7 +203,7 @@ if (Width == 0) return; Offset = Offset + StartPixel; if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" ROW("%[width]") @@ -237,7 +237,7 @@ if (Tile & V_FLIP){ : "r8", "r9", "r10", "cc" ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" ROW1("%[width]") // Loop @@ -271,7 +271,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" ROW("%[width]") // Loop @@ -303,7 +303,7 @@ if (Tile & V_FLIP){ : "r8", "r9", "r10", "cc" ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" ROW1("%[width]") // Loop diff --git a/src/tile16fadd1_2.cpp b/src/tile16fadd1_2.c index 752416b..752416b 100644 --- a/src/tile16fadd1_2.cpp +++ b/src/tile16fadd1_2.c diff --git a/src/tile16fsub1_2.cpp b/src/tile16fsub1_2.c index b7f2adb..b7f2adb 100644 --- a/src/tile16fsub1_2.cpp +++ b/src/tile16fsub1_2.c diff --git a/src/tile16noprio.cpp b/src/tile16noprio.c index 00da0dc..4f3eabe 100644 --- a/src/tile16noprio.cpp +++ b/src/tile16noprio.c @@ -62,7 +62,7 @@ void DrawTile16NoPrio (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 Line if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" #define FN(p, p2, p3, p4) \ " ldrb r9, [%[bp], #" p "] \n"\ @@ -102,7 +102,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r8 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" #define FN1(p, p2, p3, p4, p5, p6) \ " ldrb r9, [%[bp], #" p3 "] \n"\ @@ -144,7 +144,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN("0", "0", "1", "2") FN("2", "4", "3", "6") @@ -170,7 +170,7 @@ if (Tile & V_FLIP){ : "r9", "r8", "cc" // r8 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1("0", "0", "7", "1", "2", "6") FN1("2", "4", "5", "3", "6", "4") @@ -216,7 +216,7 @@ Offset = Offset + StartPixel; if (Tile & V_FLIP){ if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" #define FN(p) \ " ldrb r9, [%[bp], #" p "] \n"\ @@ -266,7 +266,7 @@ if (Tile & V_FLIP){ : "r9", "cc" // r8 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" #define FN1(p) \ " ldrb r9, [%[bp], #(7 - " p ")] \n"\ @@ -315,7 +315,7 @@ if (Tile & V_FLIP){ } } else { if (!(Tile & H_FLIP)){ - asm volatile ( + __asm__ volatile ( "2: \n" FN("0") C("0") @@ -354,7 +354,7 @@ if (Tile & V_FLIP){ : "r9", "cc" // r8 & flags ); } else { - asm volatile ( + __asm__ volatile ( "2: \n" FN1("0") C("0") diff --git a/src/tile16sub.cpp b/src/tile16sub.c index 9066e23..9066e23 100644 --- a/src/tile16sub.cpp +++ b/src/tile16sub.c diff --git a/src/tile16sub1_2.cpp b/src/tile16sub1_2.c index 0adaa0c..0adaa0c 100644 --- a/src/tile16sub1_2.cpp +++ b/src/tile16sub1_2.c |