aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlcaro2014-12-07 20:44:57 +0100
committerAlcaro2014-12-07 20:44:57 +0100
commit26d62ef100d60e41bfc001888d789097da77a20f (patch)
treea95a1033b78a5092aa660f3b0061dd3769ff15f4
parentc1823bf865fd8c36521112fa20747ec417a75f86 (diff)
downloadsnesemu-26d62ef100d60e41bfc001888d789097da77a20f.tar.gz
snesemu-26d62ef100d60e41bfc001888d789097da77a20f.tar.bz2
snesemu-26d62ef100d60e41bfc001888d789097da77a20f.zip
Properly fix that aggressive loop opt bug.
That kind of overflow is undefined behaviour no matter what you do with it.
-rw-r--r--source/apu_blargg.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/source/apu_blargg.c b/source/apu_blargg.c
index 0a1c334..e06f2b6 100644
--- a/source/apu_blargg.c
+++ b/source/apu_blargg.c
@@ -1566,7 +1566,7 @@ static void spc_cpu_write_smp_reg_( int data, int time, int addr )
static int const bits_in_int = CHAR_BIT * sizeof (int);
-static void spc_cpu_write( int data, int addr, int time )
+static void spc_cpu_write( int data, uint16_t addr, int time )
{
int reg;
/* RAM */
@@ -1601,17 +1601,9 @@ static void spc_cpu_write( int data, int addr, int time )
reg -= ROM_ADDR - 0xF0;
if ( reg >= 0 ) /* 1% in IPL ROM area or address wrapped around */
{
- if ( reg < ROM_SIZE )
- {
- m.hi_ram [reg] = (uint8_t) data;
- if ( m.rom_enabled )
- m.ram.ram[reg + ROM_ADDR] = m.rom [reg]; /* restore overwritten ROM */
- }
- else
- {
- *(&(m.ram.ram[0]) + reg + ROM_ADDR) = CPU_PAD_FILL; /* restore overwritten padding */
- spc_cpu_write( data, addr & 0xFFFF, time );
- }
+ m.hi_ram [reg] = (uint8_t) data;
+ if ( m.rom_enabled )
+ m.ram.ram[reg + ROM_ADDR] = m.rom [reg]; /* restore overwritten ROM */
}
}
}
@@ -1619,7 +1611,7 @@ static void spc_cpu_write( int data, int addr, int time )
/* CPU read */
-static int spc_cpu_read( int addr, int time )
+static int spc_cpu_read( uint16_t addr, int time )
{
int result, reg;
@@ -1644,7 +1636,7 @@ static int spc_cpu_read( int addr, int time )
t->counter = 0;
}
/* Other registers */
- else if ( reg < 0 ) /* 10% */
+ else /* 10% */
{
int reg_tmp;
@@ -1663,8 +1655,6 @@ static int spc_cpu_read( int addr, int time )
}
}
}
- else /* 1% */
- result = spc_cpu_read( reg + (R_T0OUT + 0xF0 - 0x10000), time );
}
}