diff --git a/common.h b/common.h index ba5cfc5..b3f9b3b 100644 --- a/common.h +++ b/common.h @@ -21,7 +21,7 @@ #define COMMON_H #define ror(dest, value, shift) \ - dest = ((value) >> shift) | ((value) << (32 - shift)) \ + dest = ((value) >> (shift)) | ((value) << (32 - (shift))) \ #if defined(_WIN32) #define PATH_SEPARATOR "\\" diff --git a/cpu.c b/cpu.c index 6fbecf0..e0530fa 100644 --- a/cpu.c +++ b/cpu.c @@ -954,7 +954,7 @@ const u32 psr_masks[16] = } \ if(((_address >> 24) == 0) && (pc >= 0x4000)) \ { \ - dest = *((type *)((u8 *)&bios_read_protect + (_address & 0x03))); \ + ror(dest, bios_read_protect, (_address & 0x03) << 3); \ } \ else \ \ diff --git a/gba_memory.c b/gba_memory.c index e37c262..1d7a9c9 100644 --- a/gba_memory.c +++ b/gba_memory.c @@ -574,7 +574,7 @@ u32 function_cc read_eeprom(void) case 0x00: \ /* BIOS */ \ if(reg[REG_PC] >= 0x4000) \ - value = readaddress##type(&bios_read_protect, address & 0x03); \ + ror(value, bios_read_protect, (address & 0x03) << 3); \ else \ value = readaddress##type(bios_rom, address & 0x3FFF); \ break; \ diff --git a/sound.c b/sound.c index 6529663..e767a85 100644 --- a/sound.c +++ b/sound.c @@ -77,7 +77,7 @@ void sound_timer_queue32(u32 channel, u32 value) void sound_timer(fixed8_24 frequency_step, u32 channel) { direct_sound_status_type sample_status = DIRECT_SOUND_INACTIVE; - direct_sound_struct *ds = direct_sound_channel + channel; + direct_sound_struct *ds = &direct_sound_channel[channel]; fixed8_24 fifo_fractional = ds->fifo_fractional; u32 buffer_index = ds->buffer_index; @@ -172,9 +172,7 @@ void sound_timer(fixed8_24 frequency_step, u32 channel) void sound_reset_fifo(u32 channel) { - direct_sound_struct *ds = direct_sound_channel; - - memset(ds->fifo, 0, 32); + memset(direct_sound_channel[channel].fifo, 0, 32); } // Initial pattern data = 4bits (signed) diff --git a/x86/x86_emit.h b/x86/x86_emit.h index 98b93df..28f2d65 100644 --- a/x86/x86_emit.h +++ b/x86/x86_emit.h @@ -1355,7 +1355,8 @@ void function_cc execute_store_spsr(u32 new_spsr, u32 store_mask) \ if(((address >> 24) == 0) && (reg[REG_PC] >= 0x4000)) \ { \ - dest = *((type *)((u8 *)&bios_read_protect + (address & 0x03))); \ + ror(dest, bios_read_protect, (address & 0x03) << 3); \ + dest = (type)dest; \ } \ else \ \ @@ -1376,7 +1377,8 @@ void function_cc execute_store_spsr(u32 new_spsr, u32 store_mask) \ if(((address >> 24) == 0) && (reg[REG_PC] >= 0x4000)) \ { \ - dest = *((s16 *)((u8 *)&bios_read_protect + (address & 0x03))); \ + ror(dest, bios_read_protect, (address & 0x03) << 3); \ + dest = (s16)dest; \ } \ else \ \