diff options
author | João Silva | 2017-02-12 22:16:10 +0000 |
---|---|---|
committer | João Silva | 2017-02-12 22:16:10 +0000 |
commit | c3fadd966ae2a65a683d6cc0b07a26c2980f6bbd (patch) | |
tree | 34346e131ec88be8715ceb44b1c984de44d6f8e9 /source | |
parent | fb2517282da2fdfc26e58207bbb8e0a8bca35be2 (diff) | |
download | snes9x2005-c3fadd966ae2a65a683d6cc0b07a26c2980f6bbd.tar.gz snes9x2005-c3fadd966ae2a65a683d6cc0b07a26c2980f6bbd.tar.bz2 snes9x2005-c3fadd966ae2a65a683d6cc0b07a26c2980f6bbd.zip |
Fixed stupid mistake that broke some games. Other minor changes.
Diffstat (limited to 'source')
-rw-r--r-- | source/cheats.c | 7 | ||||
-rw-r--r-- | source/cpuexec.h | 3 | ||||
-rw-r--r-- | source/fxemu.c | 4 | ||||
-rw-r--r-- | source/fxemu.h | 4 | ||||
-rw-r--r-- | source/fxinst.h | 113 | ||||
-rw-r--r-- | source/memmap.h | 39 | ||||
-rw-r--r-- | source/pixform.h | 88 | ||||
-rw-r--r-- | source/ppu.c | 5 | ||||
-rw-r--r-- | source/snes9x.h | 28 | ||||
-rw-r--r-- | source/srtc.h | 10 |
10 files changed, 141 insertions, 160 deletions
diff --git a/source/cheats.c b/source/cheats.c index 5856769..7ddcbfb 100644 --- a/source/cheats.c +++ b/source/cheats.c @@ -14,15 +14,14 @@ static bool S9xAllHex(const char* code, int32_t len) int32_t 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')) + (code [i] < 'a' || code [i] > 'f') && + (code [i] < 'A' || code [i] > 'F')) return (false); return (true); } -const char* S9xProActionReplayToRaw(const char* code, uint32_t* address, - uint8_t* byte) +const char* S9xProActionReplayToRaw(const char* code, uint32_t* address, uint8_t* byte) { uint32_t data = 0; if (strlen(code) != 8 || !S9xAllHex(code, 8) || diff --git a/source/cpuexec.h b/source/cpuexec.h index 6d738dd..d6a1db0 100644 --- a/source/cpuexec.h +++ b/source/cpuexec.h @@ -120,8 +120,7 @@ static inline void S9xReschedule() (!PPU.VTimerEnabled || (PPU.VTimerEnabled && CPU.V_Counter == PPU.IRQVBeamPos))) { - which = (int32_t) PPU.HTimerPosition < Settings.HBlankStart ? - HTIMER_BEFORE_EVENT : HTIMER_AFTER_EVENT; + which = (int32_t) PPU.HTimerPosition < Settings.HBlankStart ? HTIMER_BEFORE_EVENT : HTIMER_AFTER_EVENT; max = PPU.HTimerPosition; } CPU.NextEvent = max; diff --git a/source/fxemu.c b/source/fxemu.c index d9c5082..3995a53 100644 --- a/source/fxemu.c +++ b/source/fxemu.c @@ -114,9 +114,7 @@ void fx_dirtySCBR() void fx_computeScreenPointers() { - if (GSU.vMode != GSU.vPrevMode || - GSU.vPrevScreenHeight != GSU.vScreenHeight || - GSU.vSCBRDirty) + if (GSU.vMode != GSU.vPrevMode || GSU.vPrevScreenHeight != GSU.vScreenHeight || GSU.vSCBRDirty) { int32_t i; diff --git a/source/fxemu.h b/source/fxemu.h index 2176976..0012c33 100644 --- a/source/fxemu.h +++ b/source/fxemu.h @@ -50,11 +50,11 @@ extern void fx_updateRamBank(uint8_t Byte); #define FX_FLAG_ROM_BUFFER 0x02 /* Return codes from FxEmulate(), FxStepInto() or FxStepOver() */ -#define FX_BREAKPOINT -1 +#define FX_BREAKPOINT -1 #define FX_ERROR_ILLEGAL_ADDRESS -2 /* Return the number of bytes in an opcode */ -#define OPCODE_BYTES(op) ((((op)>=0x05&&(op)<=0xf)||((op)>=0xa0&&(op)<=0xaf))?2:(((op)>=0xf0)?3:1)) +#define OPCODE_BYTES(op) ((((op) >= 0x05 && (op) <= 0xf) || ((op) >= 0xa0 && (op) <= 0xaf)) ? 2 : (((op) >= 0xf0) ? 3 : 1)) extern void fx_computeScreenPointers(); diff --git a/source/fxinst.h b/source/fxinst.h index ce9187d..657d7d2 100644 --- a/source/fxinst.h +++ b/source/fxinst.h @@ -150,7 +150,6 @@ struct FxRegs_s int32_t vOverflow; /* (v >= 0x8000 || v < -0x8000) */ /* Other emulator variables */ - int32_t vErrorCode; uint32_t vIllegalAddress; @@ -192,78 +191,82 @@ struct FxRegs_s }; /* GSU registers */ -#define GSU_R0 0x000 -#define GSU_R1 0x002 -#define GSU_R2 0x004 -#define GSU_R3 0x006 -#define GSU_R4 0x008 -#define GSU_R5 0x00a -#define GSU_R6 0x00c -#define GSU_R7 0x00e -#define GSU_R8 0x010 -#define GSU_R9 0x012 -#define GSU_R10 0x014 -#define GSU_R11 0x016 -#define GSU_R12 0x018 -#define GSU_R13 0x01a -#define GSU_R14 0x01c -#define GSU_R15 0x01e -#define GSU_SFR 0x030 -#define GSU_BRAMR 0x033 -#define GSU_PBR 0x034 -#define GSU_ROMBR 0x036 -#define GSU_CFGR 0x037 -#define GSU_SCBR 0x038 -#define GSU_CLSR 0x039 -#define GSU_SCMR 0x03a -#define GSU_VCR 0x03b -#define GSU_RAMBR 0x03c -#define GSU_CBR 0x03e +#define GSU_R0 0x000 +#define GSU_R1 0x002 +#define GSU_R2 0x004 +#define GSU_R3 0x006 +#define GSU_R4 0x008 +#define GSU_R5 0x00a +#define GSU_R6 0x00c +#define GSU_R7 0x00e +#define GSU_R8 0x010 +#define GSU_R9 0x012 +#define GSU_R10 0x014 +#define GSU_R11 0x016 +#define GSU_R12 0x018 +#define GSU_R13 0x01a +#define GSU_R14 0x01c +#define GSU_R15 0x01e +#define GSU_SFR 0x030 +#define GSU_BRAMR 0x033 +#define GSU_PBR 0x034 +#define GSU_ROMBR 0x036 +#define GSU_CFGR 0x037 +#define GSU_SCBR 0x038 +#define GSU_CLSR 0x039 +#define GSU_SCMR 0x03a +#define GSU_VCR 0x03b +#define GSU_RAMBR 0x03c +#define GSU_CBR 0x03e #define GSU_CACHERAM 0x100 /* SFR flags */ -#define FLG_Z (1<<1) -#define FLG_CY (1<<2) -#define FLG_S (1<<3) -#define FLG_OV (1<<4) -#define FLG_G (1<<5) -#define FLG_R (1<<6) -#define FLG_ALT1 (1<<8) -#define FLG_ALT2 (1<<9) -#define FLG_IL (1<<10) -#define FLG_IH (1<<11) -#define FLG_B (1<<12) -#define FLG_IRQ (1<<15) +#define FLG_Z (1 << 1) +#define FLG_CY (1 << 2) +#define FLG_S (1 << 3) +#define FLG_OV (1 << 4) +#define FLG_G (1 << 5) +#define FLG_R (1 << 6) +#define FLG_ALT1 (1 << 8) +#define FLG_ALT2 (1 << 9) +#define FLG_IL (1 << 10) +#define FLG_IH (1 << 11) +#define FLG_B (1 << 12) +#define FLG_IRQ (1 << 15) /* Test flag */ -#define TF(a) (GSU.vStatusReg & FLG_##a ) +#define TF(a) (GSU.vStatusReg & FLG_##a ) #define CF(a) (GSU.vStatusReg &= ~FLG_##a ) -#define SF(a) (GSU.vStatusReg |= FLG_##a ) +#define SF(a) (GSU.vStatusReg |= FLG_##a ) /* Test and set flag if condition, clear if not */ -#define TS(a,b) GSU.vStatusReg = ( (GSU.vStatusReg & (~FLG_##a)) | ( (!!(##b)) * FLG_##a ) ) +#define TS(a,b) GSU.vStatusReg = ((GSU.vStatusReg & (~FLG_##a)) | ((!!(##b)) * FLG_##a )) /* Testing ALT1 & ALT2 bits */ -#define ALT0 (!TF(ALT1)&&!TF(ALT2)) -#define ALT1 (TF(ALT1)&&!TF(ALT2)) -#define ALT2 (!TF(ALT1)&&TF(ALT2)) -#define ALT3 (TF(ALT1)&&TF(ALT2)) +#define ALT0 (!TF(ALT1) && !TF(ALT2)) +#define ALT1 ( TF(ALT1) && !TF(ALT2)) +#define ALT2 (!TF(ALT1) && TF(ALT2)) +#define ALT3 ( TF(ALT1) && TF(ALT2)) /* Sign extend from 8/16 bit to 32 bit */ #define SEX16(a) ((int32_t)((int16_t)(a))) -#define SEX8(a) ((int32_t)((int8_t)(a))) +#define SEX8(a) ((int32_t)((int8_t) (a))) /* Unsign extend from 8/16 bit to 32 bit */ #define USEX16(a) ((uint32_t)((uint16_t)(a))) -#define USEX8(a) ((uint32_t)((uint8_t)(a))) +#define USEX8(a) ((uint32_t)((uint8_t) (a))) #define SUSEX16(a) ((int32_t)((uint16_t)(a))) /* Set/Clr Sign and Zero flag */ -#define TSZ(num) TS(S, (num & 0x8000)); TS(Z, (!USEX16(num)) ) +#define TSZ(num) \ + TS(S, (num & 0x8000)); \ + TS(Z, (!USEX16(num))) /* Clear flags */ -#define CLRFLAGS GSU.vStatusReg &= ~(FLG_ALT1|FLG_ALT2|FLG_B); GSU.pvDreg = GSU.pvSreg = &R0; +#define CLRFLAGS \ + GSU.vStatusReg &= ~(FLG_ALT1|FLG_ALT2|FLG_B); \ + GSU.pvDreg = GSU.pvSreg = &R0; /* Read current RAM-Bank */ #define RAM(adr) GSU.pvRamBank[USEX16(adr)] @@ -336,8 +339,12 @@ struct FxRegs_s #define CLSR USEX8(GSU.pvRegisters[GSU_CLSR]) /* Execute instruction from the pipe, and fetch next byte to the pipe */ -#define FX_STEP { uint32_t vOpcode = (uint32_t)PIPE; FETCHPIPE; \ -(*fx_apfOpcodeTable[ (GSU.vStatusReg & 0x300) | vOpcode ])(); } \ +#define FX_STEP \ +{ \ + uint32_t vOpcode = (uint32_t) PIPE; \ + FETCHPIPE; \ + (*fx_apfOpcodeTable[ (GSU.vStatusReg & 0x300) | vOpcode ])(); \ +} extern void (*fx_apfOpcodeTable[])(); extern void (*fx_apfPlotTable[])(); diff --git a/source/memmap.h b/source/memmap.h index 3cf0138..3675357 100644 --- a/source/memmap.h +++ b/source/memmap.h @@ -6,35 +6,22 @@ #include "snes9x.h" #ifdef FAST_LSB_WORD_ACCESS -#define READ_WORD(s) (*(uint16_t *) (s)) -#define READ_DWORD(s) (*(uint32_t *) (s)) -#define WRITE_WORD(s, d) (*(uint16_t *) (s)) = (d) +#define READ_WORD(s) (*(uint16_t *) (s)) +#define READ_DWORD(s) (*(uint32_t *) (s)) +#define WRITE_WORD(s, d) (*(uint16_t *) (s)) = (d) #define WRITE_DWORD(s, d) (*(uint32_t *) (s)) = (d) -#define READ_3WORD(s) (0x00ffffff & *(uint32_t *) (s)) -#define WRITE_3WORD(s, d) *(uint16_t *) (s) = (uint16_t)(d),\ - *((uint8_t *) (s) + 2) = (uint8_t) ((d) >> 16) +#define READ_3WORD(s) (0x00ffffff & *(uint32_t *) (s)) +#define WRITE_3WORD(s, d) *(uint16_t *) (s) = (uint16_t)(d), *((uint8_t *) (s) + 2) = (uint8_t) ((d) >> 16) #else -#define READ_WORD(s) ( *(uint8_t *) (s) |\ - (*((uint8_t *) (s) + 1) << 8)) -#define READ_DWORD(s) ( *(uint8_t *) (s) |\ - (*((uint8_t *) (s) + 1) << 8) |\ - (*((uint8_t *) (s) + 2) << 16) |\ - (*((uint8_t *) (s) + 3) << 24)) -#define WRITE_WORD(s, d) *(uint8_t *) (s) = (d), \ - *((uint8_t *) (s) + 1) = (d) >> 8 -#define WRITE_DWORD(s, d) *(uint8_t *) (s) = (uint8_t) (d), \ - *((uint8_t *) (s) + 1) = (uint8_t) ((d) >> 8),\ - *((uint8_t *) (s) + 2) = (uint8_t) ((d) >> 16),\ - *((uint8_t *) (s) + 3) = (uint8_t) ((d) >> 24) -#define WRITE_3WORD(s, d) *(uint8_t *) (s) = (uint8_t) (d), \ - *((uint8_t *) (s) + 1) = (uint8_t) ((d) >> 8),\ - *((uint8_t *) (s) + 2) = (uint8_t) ((d) >> 16) -#define READ_3WORD(s) ( *(uint8_t *) (s) |\ - (*((uint8_t *) (s) + 1) << 8) |\ - (*((uint8_t *) (s) + 2) << 16)) +#define READ_WORD(s) (*(uint8_t *) (s) | (*((uint8_t *) (s) + 1) << 8)) +#define READ_DWORD(s) (*(uint8_t *) (s) | (*((uint8_t *) (s) + 1) << 8) | (*((uint8_t *) (s) + 2) << 16) | (*((uint8_t *) (s) + 3) << 24)) +#define WRITE_WORD(s, d) *(uint8_t *) (s) = (d), *((uint8_t *) (s) + 1) = (d) >> 8 +#define WRITE_DWORD(s, d) *(uint8_t *) (s) = (uint8_t) (d), *((uint8_t *) (s) + 1) = (uint8_t) ((d) >> 8), *((uint8_t *) (s) + 2) = (uint8_t) ((d) >> 16), *((uint8_t *) (s) + 3) = (uint8_t) ((d) >> 24) +#define WRITE_3WORD(s, d) *(uint8_t *) (s) = (uint8_t) (d), *((uint8_t *) (s) + 1) = (uint8_t) ((d) >> 8), *((uint8_t *) (s) + 2) = (uint8_t) ((d) >> 16) +#define READ_3WORD(s) (*(uint8_t *) (s) | (*((uint8_t *) (s) + 1) << 8) | (*((uint8_t *) (s) + 2) << 16)) #endif #define MEMMAP_BLOCK_SIZE (0x1000) @@ -42,7 +29,6 @@ #define MEMMAP_BLOCKS_PER_BANK (0x10000 / MEMMAP_BLOCK_SIZE) #define MEMMAP_SHIFT 12 #define MEMMAP_MASK (MEMMAP_BLOCK_SIZE - 1) -#define MEMMAP_MAX_SDD1_LOGGED_ENTRIES (0x10000 / 8) //Extended ROM Formats #define NOPE 0 @@ -149,9 +135,6 @@ typedef struct uint8_t* SDD1Index; uint8_t* SDD1Data; uint32_t SDD1Entries; - uint32_t SDD1LoggedDataCountPrev; - uint32_t SDD1LoggedDataCount; - uint8_t SDD1LoggedData [MEMMAP_MAX_SDD1_LOGGED_ENTRIES]; char ROMFilename [_MAX_PATH]; uint8_t ROMRegion; uint32_t ROMCRC32; diff --git a/source/pixform.h b/source/pixform.h index dc4eacc..f9c075c 100644 --- a/source/pixform.h +++ b/source/pixform.h @@ -9,9 +9,9 @@ #define DECOMPOSE_PIXEL_RGB565(PIX,R,G,B) {(R) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (B) = (PIX) & 0x1f; } #define SPARE_RGB_BIT_MASK_RGB565 (1 << 5) -#define MAX_RED_RGB565 31 -#define MAX_GREEN_RGB565 63 -#define MAX_BLUE_RGB565 31 +#define MAX_RED_RGB565 31 +#define MAX_GREEN_RGB565 63 +#define MAX_BLUE_RGB565 31 #define RED_LOW_BIT_MASK_RGB565 0x0800 #define GREEN_LOW_BIT_MASK_RGB565 0x0020 #define BLUE_LOW_BIT_MASK_RGB565 0x0001 @@ -29,9 +29,9 @@ #define DECOMPOSE_PIXEL_RGB555(PIX,R,G,B) {(R) = (PIX) >> 10; (G) = ((PIX) >> 5) & 0x1f; (B) = (PIX) & 0x1f; } #define SPARE_RGB_BIT_MASK_RGB555 (1 << 15) -#define MAX_RED_RGB555 31 -#define MAX_GREEN_RGB555 31 -#define MAX_BLUE_RGB555 31 +#define MAX_RED_RGB555 31 +#define MAX_GREEN_RGB555 31 +#define MAX_BLUE_RGB555 31 #define RED_LOW_BIT_MASK_RGB555 0x0400 #define GREEN_LOW_BIT_MASK_RGB555 0x0020 #define BLUE_LOW_BIT_MASK_RGB555 0x0001 @@ -49,9 +49,9 @@ #define DECOMPOSE_PIXEL_BGR565(PIX,R,G,B) {(B) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (R) = (PIX) & 0x1f; } #define SPARE_RGB_BIT_MASK_BGR565 (1 << 5) -#define MAX_RED_BGR565 31 -#define MAX_GREEN_BGR565 63 -#define MAX_BLUE_BGR565 31 +#define MAX_RED_BGR565 31 +#define MAX_GREEN_BGR565 63 +#define MAX_BLUE_BGR565 31 #define RED_LOW_BIT_MASK_BGR565 0x0001 #define GREEN_LOW_BIT_MASK_BGR565 0x0040 #define BLUE_LOW_BIT_MASK_BGR565 0x0800 @@ -69,9 +69,9 @@ #define DECOMPOSE_PIXEL_BGR555(PIX,R,G,B) {(B) = (PIX) >> 10; (G) = ((PIX) >> 5) & 0x1f; (R) = (PIX) & 0x1f; } #define SPARE_RGB_BIT_MASK_BGR555 (1 << 15) -#define MAX_RED_BGR555 31 -#define MAX_GREEN_BGR555 31 -#define MAX_BLUE_BGR555 31 +#define MAX_RED_BGR555 31 +#define MAX_GREEN_BGR555 31 +#define MAX_BLUE_BGR555 31 #define RED_LOW_BIT_MASK_BGR555 0x0001 #define GREEN_LOW_BIT_MASK_BGR555 0x0020 #define BLUE_LOW_BIT_MASK_BGR555 0x0400 @@ -156,45 +156,41 @@ #define BUILD_PIXEL2(R,G,B) BUILD_PIXEL2_D(PIXEL_FORMAT,R,G,B) #define DECOMPOSE_PIXEL(PIX,R,G,B) DECOMPOSE_PIXEL_D(PIXEL_FORMAT,PIX,R,G,B) -#define MAX_RED_D(F) CONCAT(MAX_RED_,F) -#define MAX_BLUE_D(F) CONCAT(MAX_BLUE_,F) -#define MAX_GREEN_D(F) CONCAT(MAX_GREEN_,F) -#define RED_LOW_BIT_MASK_D(F) CONCAT(RED_LOW_BIT_MASK_,F) -#define BLUE_LOW_BIT_MASK_D(F) CONCAT(BLUE_LOW_BIT_MASK_,F) -#define GREEN_LOW_BIT_MASK_D(F) CONCAT(GREEN_LOW_BIT_MASK_,F) -#define RED_HI_BIT_MASK_D(F) CONCAT(RED_HI_BIT_MASK_,F) -#define BLUE_HI_BIT_MASK_D(F) CONCAT(BLUE_HI_BIT_MASK_,F) -#define GREEN_HI_BIT_MASK_D(F) CONCAT(GREEN_HI_BIT_MASK_,F) +#define MAX_RED_D(F) CONCAT(MAX_RED_,F) +#define MAX_BLUE_D(F) CONCAT(MAX_BLUE_,F) +#define MAX_GREEN_D(F) CONCAT(MAX_GREEN_,F) +#define RED_LOW_BIT_MASK_D(F) CONCAT(RED_LOW_BIT_MASK_,F) +#define BLUE_LOW_BIT_MASK_D(F) CONCAT(BLUE_LOW_BIT_MASK_,F) +#define GREEN_LOW_BIT_MASK_D(F) CONCAT(GREEN_LOW_BIT_MASK_,F) +#define RED_HI_BIT_MASK_D(F) CONCAT(RED_HI_BIT_MASK_,F) +#define BLUE_HI_BIT_MASK_D(F) CONCAT(BLUE_HI_BIT_MASK_,F) +#define GREEN_HI_BIT_MASK_D(F) CONCAT(GREEN_HI_BIT_MASK_,F) #define FIRST_COLOR_MASK_D(F) CONCAT(FIRST_COLOR_MASK_,F) #define SECOND_COLOR_MASK_D(F) CONCAT(SECOND_COLOR_MASK_,F) #define THIRD_COLOR_MASK_D(F) CONCAT(THIRD_COLOR_MASK_,F) #define ALPHA_BITS_MASK_D(F) CONCAT(ALPHA_BITS_MASK_,F) -#define MAX_RED MAX_RED_D(PIXEL_FORMAT) -#define MAX_BLUE MAX_BLUE_D(PIXEL_FORMAT) -#define MAX_GREEN MAX_GREEN_D(PIXEL_FORMAT) +#define MAX_RED MAX_RED_D(PIXEL_FORMAT) +#define MAX_BLUE MAX_BLUE_D(PIXEL_FORMAT) +#define MAX_GREEN MAX_GREEN_D(PIXEL_FORMAT) #define RED_LOW_BIT_MASK RED_LOW_BIT_MASK_D(PIXEL_FORMAT) -#define BLUE_LOW_BIT_MASK BLUE_LOW_BIT_MASK_D(PIXEL_FORMAT) -#define GREEN_LOW_BIT_MASK GREEN_LOW_BIT_MASK_D(PIXEL_FORMAT) -#define RED_HI_BIT_MASK RED_HI_BIT_MASK_D(PIXEL_FORMAT) -#define BLUE_HI_BIT_MASK BLUE_HI_BIT_MASK_D(PIXEL_FORMAT) -#define GREEN_HI_BIT_MASK GREEN_HI_BIT_MASK_D(PIXEL_FORMAT) -#define FIRST_COLOR_MASK FIRST_COLOR_MASK_D(PIXEL_FORMAT) -#define SECOND_COLOR_MASK SECOND_COLOR_MASK_D(PIXEL_FORMAT) -#define THIRD_COLOR_MASK THIRD_COLOR_MASK_D(PIXEL_FORMAT) -#define ALPHA_BITS_MASK ALPHA_BITS_MASK_D(PIXEL_FORMAT) - -#define GREEN_HI_BIT ((MAX_GREEN + 1) >> 1) -#define RGB_LOW_BITS_MASK (RED_LOW_BIT_MASK | GREEN_LOW_BIT_MASK | \ - BLUE_LOW_BIT_MASK) -#define RGB_HI_BITS_MASK (RED_HI_BIT_MASK | GREEN_HI_BIT_MASK | \ - BLUE_HI_BIT_MASK) -#define RGB_HI_BITS_MASKx2 ((RED_HI_BIT_MASK | GREEN_HI_BIT_MASK | \ - BLUE_HI_BIT_MASK) << 1) -#define RGB_REMOVE_LOW_BITS_MASK (~RGB_LOW_BITS_MASK) -#define FIRST_THIRD_COLOR_MASK (FIRST_COLOR_MASK | THIRD_COLOR_MASK) -#define TWO_LOW_BITS_MASK (RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 1)) -#define HIGH_BITS_SHIFTED_TWO_MASK (( (FIRST_COLOR_MASK | SECOND_COLOR_MASK | THIRD_COLOR_MASK) & \ - ~TWO_LOW_BITS_MASK ) >> 2) +#define BLUE_LOW_BIT_MASK BLUE_LOW_BIT_MASK_D(PIXEL_FORMAT) +#define GREEN_LOW_BIT_MASK GREEN_LOW_BIT_MASK_D(PIXEL_FORMAT) +#define RED_HI_BIT_MASK RED_HI_BIT_MASK_D(PIXEL_FORMAT) +#define BLUE_HI_BIT_MASK BLUE_HI_BIT_MASK_D(PIXEL_FORMAT) +#define GREEN_HI_BIT_MASK GREEN_HI_BIT_MASK_D(PIXEL_FORMAT) +#define FIRST_COLOR_MASK FIRST_COLOR_MASK_D(PIXEL_FORMAT) +#define SECOND_COLOR_MASK SECOND_COLOR_MASK_D(PIXEL_FORMAT) +#define THIRD_COLOR_MASK THIRD_COLOR_MASK_D(PIXEL_FORMAT) +#define ALPHA_BITS_MASK ALPHA_BITS_MASK_D(PIXEL_FORMAT) + +#define GREEN_HI_BIT ((MAX_GREEN + 1) >> 1) +#define RGB_LOW_BITS_MASK (RED_LOW_BIT_MASK | GREEN_LOW_BIT_MASK | BLUE_LOW_BIT_MASK) +#define RGB_HI_BITS_MASK (RED_HI_BIT_MASK | GREEN_HI_BIT_MASK | BLUE_HI_BIT_MASK) +#define RGB_HI_BITS_MASKx2 ((RED_HI_BIT_MASK | GREEN_HI_BIT_MASK | BLUE_HI_BIT_MASK) << 1) +#define RGB_REMOVE_LOW_BITS_MASK (~RGB_LOW_BITS_MASK) +#define FIRST_THIRD_COLOR_MASK (FIRST_COLOR_MASK | THIRD_COLOR_MASK) +#define TWO_LOW_BITS_MASK (RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 1)) +#define HIGH_BITS_SHIFTED_TWO_MASK (((FIRST_COLOR_MASK | SECOND_COLOR_MASK | THIRD_COLOR_MASK) & ~TWO_LOW_BITS_MASK) >> 2) #endif diff --git a/source/ppu.c b/source/ppu.c index 80920b1..f48800d 100644 --- a/source/ppu.c +++ b/source/ppu.c @@ -131,6 +131,7 @@ static void S9xSetSuperFX(uint8_t Byte, uint16_t Address) case 0x3037: case 0x3039: case 0x303a: + case 0x303b: case 0x303f: break; case 0x3034: @@ -140,8 +141,6 @@ static void S9xSetSuperFX(uint8_t Byte, uint16_t Address) case 0x3038: fx_dirtySCBR(); break; - case 0x303b: - break; case 0x303c: fx_updateRamBank(Byte); break; @@ -1165,8 +1164,8 @@ void S9xSetCPU(uint8_t byte, uint16_t Address) CPU.Flags |= NMI_FLAG; CPU.NMIActive = true; CPU.NMICycleCount = CPU.Cycles + TWO_CYCLES; - break; } + break; case 0x4201: if ((byte & 0x80) == 0 && (Memory.FillRAM[0x4213] & 0x80) == 0x80) S9xLatchCounters(1); diff --git a/source/snes9x.h b/source/snes9x.h index 9d7019c..9ae1c1c 100644 --- a/source/snes9x.h +++ b/source/snes9x.h @@ -15,27 +15,27 @@ #define ROM_NAME_LEN 23 #define STREAM FILE* -#define READ_STREAM(p,l,s) fread (p,1,l,s) -#define WRITE_STREAM(p,l,s) fwrite (p,1,l,s) -#define OPEN_STREAM(f,m) fopen (f,m) -#define REOPEN_STREAM(f,m) fdopen (f,m) -#define FIND_STREAM(f) ftell(f) -#define REVERT_STREAM(f,o,s) fseek(f,o,s) -#define CLOSE_STREAM(s) fclose (s) +#define READ_STREAM(p,l,s) fread(p,1,l,s) +#define WRITE_STREAM(p,l,s) fwrite(p,1,l,s) +#define OPEN_STREAM(f,m) fopen(f,m) +#define REOPEN_STREAM(f,m) fdopen(f,m) +#define FIND_STREAM(f) ftell(f) +#define REVERT_STREAM(f,o,s) fseek(f,o,s) +#define CLOSE_STREAM(s) fclose(s) /* SNES screen width and height */ -#define SNES_WIDTH 256 -#define SNES_HEIGHT 224 +#define SNES_WIDTH 256 +#define SNES_HEIGHT 224 #define SNES_HEIGHT_EXTENDED 239 -#define IMAGE_WIDTH (Settings.SupportHiRes ? SNES_WIDTH * 2 : SNES_WIDTH) -#define IMAGE_HEIGHT (Settings.SupportHiRes ? SNES_HEIGHT_EXTENDED * 2 : SNES_HEIGHT_EXTENDED) +#define IMAGE_WIDTH (Settings.SupportHiRes ? SNES_WIDTH * 2 : SNES_WIDTH) +#define IMAGE_HEIGHT (Settings.SupportHiRes ? SNES_HEIGHT_EXTENDED * 2 : SNES_HEIGHT_EXTENDED) #define SNES_MAX_NTSC_VCOUNTER 262 #define SNES_MAX_PAL_VCOUNTER 312 -#define SNES_HCOUNTER_MAX 342 -#define SPC700_TO_65C816_RATIO 2 -#define AUTO_FRAMERATE 200 +#define SNES_HCOUNTER_MAX 341 +#define SPC700_TO_65C816_RATIO 2 +#define AUTO_FRAMERATE 200 /* NTSC master clock signal 21.47727MHz * PPU: master clock / 4 diff --git a/source/srtc.h b/source/srtc.h index 4306999..592a391 100644 --- a/source/srtc.h +++ b/source/srtc.h @@ -57,12 +57,12 @@ typedef struct extern SRTC_DATA rtc; void S9xUpdateSrtcTime(); -void S9xSetSRTC(uint8_t data, uint16_t Address); +void S9xSetSRTC(uint8_t data, uint16_t Address); uint8_t S9xGetSRTC(uint16_t Address); -void S9xSRTCPreSaveState(); -void S9xSRTCPostLoadState(); -void S9xResetSRTC(); -void S9xHardResetSRTC(); +void S9xSRTCPreSaveState(); +void S9xSRTCPostLoadState(); +void S9xResetSRTC(); +void S9xHardResetSRTC(); #define SRTC_SRAM_PAD (4 + 8 + 1 + MAX_RTC_INDEX) |