diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | source/cpuaddr.h | 80 | ||||
-rw-r--r-- | source/cpuops.cpp | 36 | ||||
-rw-r--r-- | source/getset.h | 31 | ||||
-rw-r--r-- | source/globals.cpp | 4 | ||||
-rw-r--r-- | source/memmap.h | 9 | ||||
-rw-r--r-- | source/nds/gui.c | 8 | ||||
-rw-r--r-- | source/nds/message.h | 2 | ||||
-rw-r--r-- | source/ppu.cpp | 226 | ||||
-rw-r--r-- | source/ppu.h | 2 | ||||
-rw-r--r-- | source/sa1.cpp | 9 |
12 files changed, 345 insertions, 66 deletions
@@ -1,8 +1,8 @@ -build/ *.o *.plg *.elf *.dat *.zip +*~ depend [Tt]humbs.db
\ No newline at end of file @@ -71,7 +71,7 @@ CFLAGS := -mips32 -Os -mno-abicalls -fno-pic -fno-builtin \ DEFS := -DSPC700_C -DEXECUTE_SUPERFX_PER_LINE -DSDD1_DECOMP \
-DVAR_CYCLES -DCPU_SHUTDOWN -DSPC700_SHUTDOWN \
-DNO_INLINE_SET_GET -DNOASM -DHAVE_MKSTEMP '-DACCEPT_SIZE_T=size_t' \
- -DUNZIP_SUPPORT
+ -DUNZIP_SUPPORT -DNO_OPEN_BUS
.PHONY: clean makedirs
.SUFFIXES: .elf .dat .plg
diff --git a/source/cpuaddr.h b/source/cpuaddr.h index 76344db..4f5febf 100644 --- a/source/cpuaddr.h +++ b/source/cpuaddr.h @@ -146,10 +146,14 @@ void AbsoluteIndexedIndirect (AccessMode a) #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeedx2; #endif +#ifndef NO_OPEN_BUS OpenBus = *(CPU.PC + 1); +#endif CPU.PC += 2; OpAddress = S9xGetWord (ICPU.ShiftedPB + OpAddress); +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = (uint8)(OpAddress>>8); +#endif } void AbsoluteIndirectLong (AccessMode a) @@ -163,13 +167,19 @@ void AbsoluteIndirectLong (AccessMode a) #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeedx2; #endif +#ifndef NO_OPEN_BUS OpenBus = *(CPU.PC + 1); +#endif CPU.PC += 2; +#ifndef NO_OPEN_BUS if(a&READ) { OpAddress = S9xGetWord (OpAddress) | ((OpenBus=S9xGetByte (OpAddress + 2)) << 16); } else { +#endif OpAddress = S9xGetWord (OpAddress) | (S9xGetByte (OpAddress + 2) << 16); +#ifndef NO_OPEN_BUS } +#endif } void AbsoluteIndirect (AccessMode a) @@ -183,10 +193,14 @@ void AbsoluteIndirect (AccessMode a) #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeedx2; #endif +#ifndef NO_OPEN_BUS OpenBus = *(CPU.PC + 1); +#endif CPU.PC += 2; OpAddress = S9xGetWord (OpAddress); +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = (uint8)(OpAddress>>8); +#endif OpAddress += ICPU.ShiftedPB; } @@ -197,7 +211,9 @@ void Absolute (AccessMode a) #else OpAddress = *CPU.PC + (*(CPU.PC + 1) << 8) + ICPU.ShiftedDB; #endif +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = *(CPU.PC+1); +#endif CPU.PC += 2; #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeedx2; @@ -211,7 +227,9 @@ void AbsoluteLong (AccessMode a) #else OpAddress = *CPU.PC + (*(CPU.PC + 1) << 8) + (*(CPU.PC + 2) << 16); #endif +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = *(CPU.PC+2); +#endif CPU.PC += 3; #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeedx2 + CPU.MemSpeed; @@ -220,7 +238,9 @@ void AbsoluteLong (AccessMode a) void Direct(AccessMode a) { +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = *CPU.PC; +#endif OpAddress = (*CPU.PC++ + Registers.D.W) & 0xffff; #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeed; @@ -230,14 +250,18 @@ void Direct(AccessMode a) void DirectIndirectIndexed (AccessMode a) { +#ifndef NO_OPEN_BUS OpenBus = *CPU.PC; +#endif OpAddress = (*CPU.PC++ + Registers.D.W) & 0xffff; #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeed; #endif OpAddress = S9xGetWord (OpAddress); +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = (uint8)(OpAddress>>8); +#endif OpAddress += ICPU.ShiftedDB + Registers.Y.W; // if (Registers.DL != 0) CPU.Cycles += ONE_CYCLE; @@ -247,30 +271,40 @@ void DirectIndirectIndexed (AccessMode a) void DirectIndirectIndexedLong (AccessMode a) { +#ifndef NO_OPEN_BUS OpenBus = *CPU.PC; +#endif OpAddress = (*CPU.PC++ + Registers.D.W) & 0xffff; #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeed; #endif +#ifndef NO_OPEN_BUS if(a&READ){ OpAddress = S9xGetWord (OpAddress) + ((OpenBus = S9xGetByte (OpAddress + 2)) << 16) + Registers.Y.W; } else { +#endif OpAddress = S9xGetWord (OpAddress) + (S9xGetByte (OpAddress + 2) << 16) + Registers.Y.W; +#ifndef NO_OPEN_BUS } +#endif // if (Registers.DL != 0) CPU.Cycles += ONE_CYCLE; } void DirectIndexedIndirect(AccessMode a) { +#ifndef NO_OPEN_BUS OpenBus = *CPU.PC; +#endif OpAddress = (*CPU.PC++ + Registers.D.W + Registers.X.W) & 0xffff; #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeed; #endif OpAddress = S9xGetWord (OpAddress); +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = (uint8)(OpAddress>>8); +#endif OpAddress += ICPU.ShiftedDB; #ifndef SA1_OPCODES @@ -283,36 +317,34 @@ void DirectIndexedIndirect(AccessMode a) void DirectIndexedX (AccessMode a) { +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = *CPU.PC; +#endif OpAddress = (*CPU.PC++ + Registers.D.W + Registers.X.W); OpAddress &= CheckEmulation() ? 0xff : 0xffff; #ifndef SA1_OPCODES - CPU.Cycles += CPU.MemSpeed; -#endif - -#ifndef SA1_OPCODES + CPU.Cycles += CPU.MemSpeed + ONE_CYCLE; // if (Registers.DL != 0) // CPU.Cycles += TWO_CYCLES; // else - CPU.Cycles += ONE_CYCLE; +// CPU.Cycles += ONE_CYCLE; #endif } void DirectIndexedY (AccessMode a) { +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = *CPU.PC; +#endif OpAddress = (*CPU.PC++ + Registers.D.W + Registers.Y.W); OpAddress &= CheckEmulation() ? 0xff : 0xffff; #ifndef SA1_OPCODES - CPU.Cycles += CPU.MemSpeed; -#endif - -#ifndef SA1_OPCODES + CPU.Cycles += CPU.MemSpeed + ONE_CYCLE; // if (Registers.DL != 0) // CPU.Cycles += TWO_CYCLES; // else - CPU.Cycles += ONE_CYCLE; +// CPU.Cycles += ONE_CYCLE; #endif } @@ -324,7 +356,9 @@ void AbsoluteIndexedX (AccessMode a) OpAddress = ICPU.ShiftedDB + *CPU.PC + (*(CPU.PC + 1) << 8) + Registers.X.W; #endif +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = *(CPU.PC+1); +#endif CPU.PC += 2; #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeedx2; @@ -341,7 +375,9 @@ void AbsoluteIndexedY (AccessMode a) OpAddress = ICPU.ShiftedDB + *CPU.PC + (*(CPU.PC + 1) << 8) + Registers.Y.W; #endif +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = *(CPU.PC+1); +#endif CPU.PC += 2; #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeedx2; @@ -357,7 +393,9 @@ void AbsoluteLongIndexedX (AccessMode a) #else OpAddress = (*CPU.PC + (*(CPU.PC + 1) << 8) + (*(CPU.PC + 2) << 16) + Registers.X.W) & 0xffffff; #endif +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = *(CPU.PC+2); +#endif CPU.PC += 3; #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeedx2 + CPU.MemSpeed; @@ -366,13 +404,17 @@ void AbsoluteLongIndexedX (AccessMode a) void DirectIndirect (AccessMode a) { +#ifndef NO_OPEN_BUS OpenBus = *CPU.PC; +#endif OpAddress = (*CPU.PC++ + Registers.D.W) & 0xffff; #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeed; #endif OpAddress = S9xGetWord (OpAddress); +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = (uint8)(OpAddress>>8); +#endif OpAddress += ICPU.ShiftedDB; // if (Registers.DL != 0) CPU.Cycles += ONE_CYCLE; @@ -380,39 +422,49 @@ void DirectIndirect (AccessMode a) void DirectIndirectLong (AccessMode a) { +#ifndef NO_OPEN_BUS OpenBus = *CPU.PC; +#endif OpAddress = (*CPU.PC++ + Registers.D.W) & 0xffff; #ifndef SA1_OPCODES CPU.Cycles += CPU.MemSpeed; #endif +#ifndef NO_OPEN_BUS if(a&READ){ OpAddress = S9xGetWord (OpAddress) + ((OpenBus=S9xGetByte (OpAddress + 2)) << 16); } else { +#endif OpAddress = S9xGetWord (OpAddress) + (S9xGetByte (OpAddress + 2) << 16); +#ifndef NO_OPEN_BUS } +#endif // if (Registers.DL != 0) CPU.Cycles += ONE_CYCLE; } void StackRelative (AccessMode a) { +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = *CPU.PC; +#endif OpAddress = (*CPU.PC++ + Registers.S.W) & 0xffff; #ifndef SA1_OPCODES - CPU.Cycles += CPU.MemSpeed; - CPU.Cycles += ONE_CYCLE; + CPU.Cycles += CPU.MemSpeed + ONE_CYCLE; #endif } void StackRelativeIndirectIndexed (AccessMode a) { +#ifndef NO_OPEN_BUS OpenBus = *CPU.PC; +#endif OpAddress = (*CPU.PC++ + Registers.S.W) & 0xffff; #ifndef SA1_OPCODES - CPU.Cycles += CPU.MemSpeed; - CPU.Cycles += TWO_CYCLES; + CPU.Cycles += CPU.MemSpeed + TWO_CYCLES; #endif OpAddress = S9xGetWord (OpAddress); +#ifndef NO_OPEN_BUS if(a&READ) OpenBus = (uint8)(OpAddress>>8); +#endif OpAddress = (OpAddress + ICPU.ShiftedDB + Registers.Y.W) & 0xffffff; } diff --git a/source/cpuops.cpp b/source/cpuops.cpp index c5adc67..967ca9f 100644 --- a/source/cpuops.cpp +++ b/source/cpuops.cpp @@ -3556,7 +3556,9 @@ static void Op00 (void) PushW (CPU.PC - CPU.PCBase + 1); S9xPackStatus (); PushB (Registers.PL); +#ifndef NO_OPEN_BUS OpenBus = Registers.PL; +#endif ClearDecimal (); SetIRQ (); @@ -3572,7 +3574,9 @@ static void Op00 (void) PushW (CPU.PC - CPU.PCBase); S9xPackStatus (); PushB (Registers.PL); +#ifndef NO_OPEN_BUS OpenBus = Registers.PL; +#endif ClearDecimal (); SetIRQ (); @@ -3607,7 +3611,9 @@ void S9xOpcode_IRQ (void) PushW (CPU.PC - CPU.PCBase); S9xPackStatus (); PushB (Registers.PL); +#ifndef NO_OPEN_BUS OpenBus = Registers.PL; +#endif ClearDecimal (); SetIRQ (); @@ -3632,7 +3638,9 @@ void S9xOpcode_IRQ (void) PushW (CPU.PC - CPU.PCBase); S9xPackStatus (); PushB (Registers.PL); +#ifndef NO_OPEN_BUS OpenBus = Registers.PL; +#endif ClearDecimal (); SetIRQ (); @@ -3669,7 +3677,9 @@ void S9xOpcode_NMI (void) PushW (CPU.PC - CPU.PCBase); S9xPackStatus (); PushB (Registers.PL); +#ifndef NO_OPEN_BUS OpenBus = Registers.PL; +#endif ClearDecimal (); SetIRQ (); @@ -3694,7 +3704,9 @@ void S9xOpcode_NMI (void) PushW (CPU.PC - CPU.PCBase); S9xPackStatus (); PushB (Registers.PL); +#ifndef NO_OPEN_BUS OpenBus = Registers.PL; +#endif ClearDecimal (); SetIRQ (); @@ -3730,7 +3742,9 @@ static void Op02 (void) PushW (CPU.PC - CPU.PCBase + 1); S9xPackStatus (); PushB (Registers.PL); +#ifndef NO_OPEN_BUS OpenBus = Registers.PL; +#endif ClearDecimal (); SetIRQ (); @@ -3746,7 +3760,9 @@ static void Op02 (void) PushW (CPU.PC - CPU.PCBase); S9xPackStatus (); PushB (Registers.PL); +#ifndef NO_OPEN_BUS OpenBus = Registers.PL; +#endif ClearDecimal (); SetIRQ (); @@ -3905,7 +3921,10 @@ static void Op54X1 (void) Registers.DB = *CPU.PC++; ICPU.ShiftedDB = Registers.DB << 16; - OpenBus = SrcBank = *CPU.PC++; +#ifndef NO_OPEN_BUS + OpenBus = +#endif + SrcBank = *CPU.PC++; S9xSetByte (S9xGetByte ((SrcBank << 16) + Registers.X.W), ICPU.ShiftedDB + Registers.Y.W); @@ -3927,7 +3946,10 @@ static void Op54X0 (void) Registers.DB = *CPU.PC++; ICPU.ShiftedDB = Registers.DB << 16; - OpenBus = SrcBank = *CPU.PC++; +#ifndef NO_OPEN_BUS + OpenBus = +#endif + SrcBank = *CPU.PC++; S9xSetByte (S9xGetByte ((SrcBank << 16) + Registers.X.W), ICPU.ShiftedDB + Registers.Y.W); @@ -3948,7 +3970,10 @@ static void Op44X1 (void) #endif Registers.DB = *CPU.PC++; ICPU.ShiftedDB = Registers.DB << 16; - OpenBus = SrcBank = *CPU.PC++; +#ifndef NO_OPEN_BUS + OpenBus = +#endif + SrcBank = *CPU.PC++; S9xSetByte (S9xGetByte ((SrcBank << 16) + Registers.X.W), ICPU.ShiftedDB + Registers.Y.W); @@ -3968,7 +3993,10 @@ static void Op44X0 (void) #endif Registers.DB = *CPU.PC++; ICPU.ShiftedDB = Registers.DB << 16; - OpenBus = SrcBank = *CPU.PC++; +#ifndef NO_OPEN_BUS + OpenBus = +#endif + SrcBank = *CPU.PC++; S9xSetByte (S9xGetByte ((SrcBank << 16) + Registers.X.W), ICPU.ShiftedDB + Registers.Y.W); diff --git a/source/getset.h b/source/getset.h index f04bf95..9b94b22 100644 --- a/source/getset.h +++ b/source/getset.h @@ -98,10 +98,12 @@ #include "obc1.h" #include "seta.h" +#ifndef NO_OPEN_BUS extern "C" { extern uint8 OpenBus; } +#endif uint8 S9xGetByte (uint32 Address) { @@ -178,8 +180,11 @@ uint8 S9xGetByte (uint32 Address) #ifdef DEBUGGER printf ("DEBUG R(B) %06x\n", Address); #endif - return OpenBus; - +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif default: @@ -193,7 +198,11 @@ uint8 S9xGetByte (uint32 Address) #ifdef DEBUGGER printf ("R(B) %06x\n", Address); #endif +#ifndef NO_OPEN_BUS return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif } } @@ -201,8 +210,13 @@ uint16 S9xGetWord (uint32 Address) { if ((Address & 0x0fff) == 0x0fff) { - OpenBus=S9xGetByte (Address); +#ifndef NO_OPEN_BUS + OpenBus = S9xGetByte (Address); return (OpenBus | (S9xGetByte (Address + 1) << 8)); +#else + uint8 Split = S9xGetByte (Address); + return (Split | (S9xGetByte (Address + 1) << 8)); +#endif } int block; uint8 *GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK]; @@ -302,8 +316,11 @@ uint16 S9xGetWord (uint32 Address) #ifdef DEBUGGER printf ("DEBUG R(W) %06x\n", Address); #endif - return (OpenBus | (OpenBus<<8)); - +#ifndef NO_OPEN_BUS + return (OpenBus | (OpenBus<<8)); +#else + return 0; // Arbitrarily chosen value [Neb] +#endif default: case CMemory::MAP_NONE: @@ -316,7 +333,11 @@ uint16 S9xGetWord (uint32 Address) #ifdef DEBUGGER printf ("R(W) %06x\n", Address); #endif +#ifndef NO_OPEN_BUS return (OpenBus | (OpenBus<<8)); +#else + return 0; // Arbitrarily chosen value [Neb] +#endif } } diff --git a/source/globals.cpp b/source/globals.cpp index 0103f7e..f00a621 100644 --- a/source/globals.cpp +++ b/source/globals.cpp @@ -157,7 +157,9 @@ uint32 Work32 = 0; signed char Int8 = 0; short Int16 = 0; long Int32 = 0; -unsigned char OpenBus = 0; +#ifndef NO_OPEN_BUS +uint8 OpenBus = 0; +#endif END_EXTERN_C diff --git a/source/memmap.h b/source/memmap.h index 58f0c9f..f838065 100644 --- a/source/memmap.h +++ b/source/memmap.h @@ -276,7 +276,7 @@ bool8 LoadZip(const char* zipname, END_EXTERN_C extern "C" { -void S9xAutoSaveSRAM (); + void S9xAutoSaveSRAM (); } #ifdef NO_INLINE_SET_GET @@ -288,9 +288,12 @@ void S9xSetPCBase (uint32 Address); uint8 *S9xGetMemPointer (uint32 Address); uint8 *GetBasePointer (uint32 Address); -extern "C"{ -extern uint8 OpenBus; +#ifndef NO_OPEN_BUS +extern "C" { + extern uint8 OpenBus; } +#endif + #else #define INLINE inline #include "getset.h" diff --git a/source/nds/gui.c b/source/nds/gui.c index 3201665..61a3b58 100644 --- a/source/nds/gui.c +++ b/source/nds/gui.c @@ -40,6 +40,8 @@ char rom_path[MAX_PATH]; char gamepak_name[MAX_PATH]; char gcheat_filename[MAX_PATH]; +// If adding a language, make sure you update the size of the array in +// message.h too. char *lang[3] = { "English", // 0 @@ -2966,8 +2968,6 @@ u32 menu(u16 *screen) char *enable_disable_options[] = { (char*)&msg[MSG_EN_DIS_ABLE_0], (char*)&msg[MSG_EN_DIS_ABLE_1] }; - char *language_options[] = { (char*) &lang[0], (char*) &lang[1], (char*) &lang[2] }; - char *keyremap_options[] = {(char*)&msg[MSG_KEY_MAP_NONE], (char*)&msg[MSG_KEY_MAP_A], (char*)&msg[MSG_KEY_MAP_B], (char*)&msg[MSG_KEY_MAP_SL], (char*)&msg[MSG_KEY_MAP_ST], (char*)&msg[MSG_KEY_MAP_RT], (char*)&msg[MSG_KEY_MAP_LF], (char*)&msg[MSG_KEY_MAP_UP], (char*)&msg[MSG_KEY_MAP_DW], @@ -3124,8 +3124,8 @@ u32 menu(u16 *screen) //CPU speed /* 01 */ NUMERIC_SELECTION_OPTION(NULL, &msg[MSG_SUB_MENU_42], &clock_speed_number, 6, NULL, 1), - /* 02 */ STRING_SELECTION_OPTION(language_set, NULL, &msg[MSG_SUB_MENU_41], language_options, - &emu_config.language, sizeof(language_options) / sizeof(language_options[0]) /* number of possible languages */, NULL, ACTION_TYPE, 2), + /* 02 */ STRING_SELECTION_OPTION(language_set, NULL, &msg[MSG_SUB_MENU_41], lang, + &emu_config.language, sizeof(lang) / sizeof(lang[0]) /* number of possible languages */, NULL, ACTION_TYPE, 2), /* 03 */ STRING_SELECTION_OPTION(NULL, show_card_space, &msg[MSG_SUB_MENU_43], NULL, &desert, 2, NULL, PASSIVE_TYPE | HIDEN_TYPE, 3), diff --git a/source/nds/message.h b/source/nds/message.h index 9292d3f..4a0acd2 100644 --- a/source/nds/message.h +++ b/source/nds/message.h @@ -168,6 +168,8 @@ enum LANGUAGE{ FRENCH }; +extern char* lang[3]; // Allocated in gui.c, needs to match the languages ^ + char *msg[MSG_END+1]; char msg_data[16 * 1024]; diff --git a/source/ppu.cpp b/source/ppu.cpp index 389bdd2..8ba7a5f 100644 --- a/source/ppu.cpp +++ b/source/ppu.cpp @@ -1071,10 +1071,17 @@ void S9xSetPPU (uint8 Byte, uint16 Address) /******************************************************************************/ uint8 S9xGetPPU (uint16 Address) { +#ifndef NO_OPEN_BUS uint8 byte = OpenBus; - +#else + uint8 byte = 0; // Arbitrarily chosen value [Neb] +#endif if(Address<0x2100)//not a real PPU reg +#ifndef NO_OPEN_BUS return OpenBus; //treat as unmapped memory returning last byte on the bus +#else + return 0; // Arbitrarily chosen value [Neb] +#endif if (Address <= 0x2190) { switch (Address) @@ -1086,18 +1093,34 @@ uint8 S9xGetPPU (uint16 Address) #ifdef DEBUGGER missing.oam_address_read = 1; #endif - return OpenBus; +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x2104: case 0x2105: case 0x2106: +#ifndef NO_OPEN_BUS return PPU.OpenBus1; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x2107: +#ifndef NO_OPEN_BUS return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x2108: case 0x2109: case 0x210a: +#ifndef NO_OPEN_BUS return PPU.OpenBus1; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x210b: case 0x210c: case 0x210d: @@ -1107,8 +1130,14 @@ uint8 S9xGetPPU (uint16 Address) case 0x2111: case 0x2112: case 0x2113: - missing.bg_offset_read = 1; - return OpenBus; +#ifdef DEBUGGER + missing.bg_offset_read = 1; +#endif +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x2114: #ifdef DEBUGGER @@ -1116,15 +1145,27 @@ uint8 S9xGetPPU (uint16 Address) #endif case 0x2115: case 0x2116: - return PPU.OpenBus1; +#ifndef NO_OPEN_BUS + return PPU.OpenBus1; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x2117: - return OpenBus; +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x2118: case 0x2119: case 0x211a: - return PPU.OpenBus1; +#ifndef NO_OPEN_BUS + return PPU.OpenBus1; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x211b: case 0x211c: @@ -1135,25 +1176,45 @@ uint8 S9xGetPPU (uint16 Address) #ifdef DEBUGGER missing.matrix_read = 1; #endif - return OpenBus; +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x2121: case 0x2122: case 0x2123: - return OpenBus; +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x2124: case 0x2125: case 0x2126: - return PPU.OpenBus1; +#ifndef NO_OPEN_BUS + return PPU.OpenBus1; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x2127: - return OpenBus; +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x2128: case 0x2129: case 0x212a: - return PPU.OpenBus1; +#ifndef NO_OPEN_BUS + return PPU.OpenBus1; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x212b: case 0x212c: @@ -1164,7 +1225,11 @@ uint8 S9xGetPPU (uint16 Address) case 0x2131: case 0x2132: case 0x2133: - return OpenBus; +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x2134: case 0x2135: @@ -1182,10 +1247,18 @@ uint8 S9xGetPPU (uint16 Address) #ifdef DEBUGGER missing.matrix_multiply = 1; #endif - return (PPU.OpenBus1 = Memory.FillRAM[Address]); + return ( +#ifndef NO_OPEN_BUS + PPU.OpenBus1 = +#endif + Memory.FillRAM[Address]); case 0x2137: S9xLatchCounters(0); +#ifndef NO_OPEN_BUS return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x2138: // Read OAM (sprite) control data @@ -1230,7 +1303,11 @@ uint8 S9xGetPPU (uint16 Address) #ifdef DEBUGGER missing.oam_read = 1; #endif - return (PPU.OpenBus1 = byte); + return ( +#ifndef NO_OPEN_BUS + PPU.OpenBus1 = +#endif + byte); case 0x2139: // Read vram low byte @@ -1275,7 +1352,9 @@ uint8 S9xGetPPU (uint16 Address) IPPU.FirstVRAMRead = FALSE; } #endif +#ifndef NO_OPEN_BUS PPU.OpenBus1 = byte; +#endif break; case 0x213A: // Read vram high byte @@ -1319,7 +1398,9 @@ uint8 S9xGetPPU (uint16 Address) IPPU.FirstVRAMRead = FALSE; } #endif +#ifndef NO_OPEN_BUS PPU.OpenBus1 = byte; +#endif break; case 0x213B: @@ -1333,7 +1414,11 @@ uint8 S9xGetPPU (uint16 Address) byte = PPU.CGDATA [PPU.CGADD] & 0xff; PPU.CGFLIPRead ^= 1; - return (PPU.OpenBus2 = byte); + return ( +#ifndef NO_OPEN_BUS + PPU.OpenBus2 = +#endif + byte); case 0x213C: // Horizontal counter value 0-339 @@ -1341,10 +1426,19 @@ uint8 S9xGetPPU (uint16 Address) missing.h_counter_read = 1; #endif if (PPU.HBeamFlip) - byte = (PPU.OpenBus2 & 0xfe) | ((PPU.HBeamPosLatched >> 8) & 0x01); + byte = +#ifndef NO_OPEN_BUS + (PPU.OpenBus2 & 0xfe) +#else + 0 // Arbitrarily chosen value [Neb] +#endif + | ((PPU.HBeamPosLatched >> 8) & 0x01); + else byte = (uint8)PPU.HBeamPosLatched; +#ifndef NO_OPEN_BUS PPU.OpenBus2 = byte; +#endif PPU.HBeamFlip ^= 1; break; @@ -1354,10 +1448,18 @@ uint8 S9xGetPPU (uint16 Address) missing.v_counter_read = 1; #endif if (PPU.VBeamFlip) - byte = (PPU.OpenBus2 & 0xfe) | ((PPU.VBeamPosLatched >> 8) & 0x01); + byte = +#ifndef NO_OPEN_BUS + (PPU.OpenBus2 & 0xfe) +#else + 0 // Arbitrarily chosen value [Neb] +#endif + | ((PPU.VBeamPosLatched >> 8) & 0x01); else byte = (uint8)PPU.VBeamPosLatched; +#ifndef NO_OPEN_BUS PPU.OpenBus2 = byte; +#endif PPU.VBeamFlip ^= 1; break; @@ -1366,14 +1468,22 @@ uint8 S9xGetPPU (uint16 Address) FLUSH_REDRAW (); //so far, 5c77 version is always 1. - return (PPU.OpenBus1 = (Model->_5C77 | PPU.RangeTimeOver)); + return ( +#ifndef NO_OPEN_BUS + PPU.OpenBus1 = +#endif + (Model->_5C77 | PPU.RangeTimeOver)); case 0x213F: // NTSC/PAL and which field flags PPU.VBeamFlip = PPU.HBeamFlip = 0; //neviksti found a 2 and a 3 here. SNEeSe uses a 3. //XXX: field flags not emulated - return ((Settings.PAL ? 0x10 : 0) | (Memory.FillRAM[0x213f] & 0xc0)| Model->_5C78) | (~PPU.OpenBus2 & 0x20); + return ((Settings.PAL ? 0x10 : 0) | (Memory.FillRAM[0x213f] & 0xc0)| Model->_5C78) +#ifndef NO_OPEN_BUS + | (~PPU.OpenBus2 & 0x20) +#endif + ; case 0x2140: case 0x2141: case 0x2142: case 0x2143: case 0x2144: case 0x2145: case 0x2146: case 0x2147: @@ -1403,7 +1513,7 @@ uint8 S9xGetPPU (uint16 Address) { #ifdef CPU_SHUTDOWN // CPU.WaitAddress = CPU.PCAtOpcodeStart; -#endif +#endif if (SNESGameFixes.APU_OutPorts_ReturnValueFix && Address >= 0x2140 && Address <= 0x2143 && !CPU.V_Counter) { @@ -1457,10 +1567,18 @@ uint8 S9xGetPPU (uint16 Address) case 0x2181: case 0x2182: case 0x2183: - return OpenBus; +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif - default: - return OpenBus; + default: +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif } } else @@ -1474,15 +1592,23 @@ uint8 S9xGetPPU (uint16 Address) { case 0x21c2: if(Model->_5C77 ==2) - return (0x20); + return (0x20); // fprintf(stderr, "Read from $21c2!\n"); - return OpenBus; +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x21c3: - if(Model->_5C77 ==2) + if(Model->_5C77 ==2) return (0); // fprintf(stderr, "Read from $21c3!\n"); - return OpenBus; +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x2800: // For Dai Kaijyu Monogatari II if (Settings.SRTC) @@ -1498,12 +1624,20 @@ uint8 S9xGetPPU (uint16 Address) S9xMessage (S9X_TRACE, S9X_PPU_TRACE, String); } #endif - return OpenBus; +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif } } if (!Settings.SuperFX) - return OpenBus; +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif #ifdef ZSNES_FX if (Address < 0x3040) byte = S9xSuperFXReadReg (Address); @@ -2165,7 +2299,11 @@ uint8 S9xGetCPU (uint16 Address) S9xMessage (S9X_TRACE, S9X_PPU_TRACE, String); } #endif - return OpenBus; +#ifndef NO_OPEN_BUS + return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif } // return (Memory.FillRAM [Address]); @@ -2189,7 +2327,11 @@ uint8 S9xGetCPU (uint16 Address) case 0x420d: case 0x420e: case 0x420f: +#ifndef NO_OPEN_BUS return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif case 0x4210: #ifdef CPU_SHUTDOWN @@ -2198,7 +2340,11 @@ uint8 S9xGetCPU (uint16 Address) byte = Memory.FillRAM[0x4210]; Memory.FillRAM[0x4210] = Model->_5A22; //SNEeSe returns 2 for 5A22 version. - return ((byte&0x80)|(OpenBus&0x70)|Model->_5A22); + return ((byte&0x80) +#ifndef NO_OPEN_BUS + |(OpenBus&0x70) +#endif + |Model->_5A22); case 0x4211: byte = (CPU.IRQActive & (PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE)) ? 0x80 : 0; @@ -2207,7 +2353,9 @@ uint8 S9xGetCPU (uint16 Address) CLEAR_IRQ_SOURCE (PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE); // Maybe? Register Scan indicated open bus... +#ifndef NO_OPEN_BUS byte |= OpenBus&0x3f; +#endif return (byte); @@ -2216,7 +2364,11 @@ uint8 S9xGetCPU (uint16 Address) #ifdef CPU_SHUTDOWN CPU.WaitAddress = CPU.PCAtOpcodeStart; #endif - return (REGISTER_4212()|(OpenBus&0x3E)); + return (REGISTER_4212() +#ifndef NO_OPEN_BUS + |(OpenBus&0x3E) +#endif + ); case 0x4213: // I/O port input - returns 0 wherever $4201 is 0, and 1 elsewhere @@ -2401,7 +2553,11 @@ uint8 S9xGetCPU (uint16 Address) return Memory.FillRAM[Address]; } +#ifndef NO_OPEN_BUS return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif } // return (Memory.FillRAM[Address]); } @@ -2469,8 +2625,10 @@ void S9xResetPPU () PPU.OAMPriorityRotation = 0; PPU.OAMWriteRegister = 0; PPU.RangeTimeOver = 0; +#ifndef NO_OPEN_BUS PPU.OpenBus1 = 0; PPU.OpenBus2 = 0; +#endif PPU.OAMFlip = 0; PPU.OAMTileAddress = 0; @@ -2665,8 +2823,10 @@ void S9xSoftResetPPU () PPU.OAMPriorityRotation = 0; PPU.OAMWriteRegister = 0; PPU.RangeTimeOver = 0; +#ifndef NO_OPEN_BUS PPU.OpenBus1 = 0; PPU.OpenBus2 = 0; +#endif PPU.OAMFlip = 0; PPU.OAMTileAddress = 0; diff --git a/source/ppu.h b/source/ppu.h index 5a889ef..6daf473 100644 --- a/source/ppu.h +++ b/source/ppu.h @@ -266,8 +266,10 @@ struct SPPU { // XXX Do these need to be added to snapshot.cpp? uint16 OAMWriteRegister; uint8 BGnxOFSbyte; +#ifndef NO_OPEN_BUS uint8 OpenBus1; uint8 OpenBus2; +#endif }; #define CLIP_OR 0 diff --git a/source/sa1.cpp b/source/sa1.cpp index 39b08bb..eb10d33 100644 --- a/source/sa1.cpp +++ b/source/sa1.cpp @@ -228,14 +228,23 @@ uint8 S9xSA1GetByte (uint32 address) #ifdef DEBUGGER // printf ("R(B) %06x\n", address); #endif +#ifndef NO_OPEN_BUS return OpenBus; +#else + return 0; // Arbitrarily chosen value [Neb] +#endif } } uint16 S9xSA1GetWord (uint32 address) { +#ifndef NO_OPEN_BUS OpenBus = S9xSA1GetByte (address); return (OpenBus | (S9xSA1GetByte (address + 1) << 8)); +#else + uint8 Split = S9xSA1GetByte (address); + return (Split | (S9xSA1GetByte (address + 1) << 8)); +#endif } void S9xSA1SetByte (uint8 byte, uint32 address) |