deal with some strict aliasing issues

This commit is contained in:
notaz 2013-08-20 03:20:37 +03:00
parent a76fad4129
commit 895d15121b
6 changed files with 38 additions and 17 deletions

View file

@ -151,6 +151,16 @@ tools/textfilter: tools/textfilter.c
.s.o: .s.o:
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
# special flags - perhaps fix this someday instead?
pico/draw.o: CFLAGS += -fno-strict-aliasing
pico/draw2.o: CFLAGS += -fno-strict-aliasing
pico/mode4.o: CFLAGS += -fno-strict-aliasing
pico/cd/memory.o: CFLAGS += -fno-strict-aliasing
pico/cd/cd_file.o: CFLAGS += -fno-strict-aliasing
pico/cd/pcm.o: CFLAGS += -fno-strict-aliasing
pico/cd/LC89510.o: CFLAGS += -fno-strict-aliasing
pico/cd/gfx_cd.o: CFLAGS += -fno-strict-aliasing
# random deps # random deps
pico/carthw/svp/compiler.o : cpu/drc/emit_$(ARCH).c pico/carthw/svp/compiler.o : cpu/drc/emit_$(ARCH).c
cpu/sh2/compiler.o : cpu/drc/emit_$(ARCH).c cpu/sh2/compiler.o : cpu/drc/emit_$(ARCH).c

View file

@ -1110,8 +1110,11 @@ static void emit_or_t_if_eq(int srr)
// reg cache must be clean before call // reg cache must be clean before call
static int emit_memhandler_read_(int size, int ram_check) static int emit_memhandler_read_(int size, int ram_check)
{ {
int arg0, arg1; int arg1;
#if 0
int arg0;
host_arg2reg(arg0, 0); host_arg2reg(arg0, 0);
#endif
rcache_clean(); rcache_clean();
@ -3179,7 +3182,7 @@ void sh2_drc_flush_all(void)
void sh2_drc_mem_setup(SH2 *sh2) void sh2_drc_mem_setup(SH2 *sh2)
{ {
// fill the convenience pointers // fill the convenience pointers
sh2->p_bios = sh2->is_slave ? Pico32xMem->sh2_rom_s : Pico32xMem->sh2_rom_m; sh2->p_bios = sh2->is_slave ? Pico32xMem->sh2_rom_s.w : Pico32xMem->sh2_rom_m.w;
sh2->p_da = sh2->data_array; sh2->p_da = sh2->data_array;
sh2->p_sdram = Pico32xMem->sdram; sh2->p_sdram = Pico32xMem->sdram;
sh2->p_rom = Pico.rom; sh2->p_rom = Pico.rom;
@ -3293,7 +3296,7 @@ static void *dr_get_pc_base(u32 pc, int is_slave)
if ((pc & ~0x7ff) == 0) { if ((pc & ~0x7ff) == 0) {
// BIOS // BIOS
ret = is_slave ? Pico32xMem->sh2_rom_s : Pico32xMem->sh2_rom_m; ret = is_slave ? Pico32xMem->sh2_rom_s.w : Pico32xMem->sh2_rom_m.w;
mask = 0x7ff; mask = 0x7ff;
} }
else if ((pc & 0xfffff000) == 0xc0000000) { else if ((pc & 0xfffff000) == 0xc0000000) {

View file

@ -1208,9 +1208,9 @@ static u32 sh2_read8_cs0(u32 a, SH2 *sh2)
// TODO: mirroring? // TODO: mirroring?
if (!sh2->is_slave && a < sizeof(Pico32xMem->sh2_rom_m)) if (!sh2->is_slave && a < sizeof(Pico32xMem->sh2_rom_m))
return Pico32xMem->sh2_rom_m[a ^ 1]; return Pico32xMem->sh2_rom_m.b[a ^ 1];
if (sh2->is_slave && a < sizeof(Pico32xMem->sh2_rom_s)) if (sh2->is_slave && a < sizeof(Pico32xMem->sh2_rom_s))
return Pico32xMem->sh2_rom_s[a ^ 1]; return Pico32xMem->sh2_rom_s.b[a ^ 1];
if ((a & 0x3fe00) == 0x4200) { if ((a & 0x3fe00) == 0x4200) {
d = Pico32xMem->pal[(a & 0x1ff) / 2]; d = Pico32xMem->pal[(a & 0x1ff) / 2];
@ -1263,9 +1263,9 @@ static u32 sh2_read16_cs0(u32 a, SH2 *sh2)
} }
if (!sh2->is_slave && a < sizeof(Pico32xMem->sh2_rom_m)) if (!sh2->is_slave && a < sizeof(Pico32xMem->sh2_rom_m))
return *(u16 *)(Pico32xMem->sh2_rom_m + a); return Pico32xMem->sh2_rom_m.w[a / 2];
if (sh2->is_slave && a < sizeof(Pico32xMem->sh2_rom_s)) if (sh2->is_slave && a < sizeof(Pico32xMem->sh2_rom_s))
return *(u16 *)(Pico32xMem->sh2_rom_s + a); return Pico32xMem->sh2_rom_s.w[a / 2];
if ((a & 0x3fe00) == 0x4200) { if ((a & 0x3fe00) == 0x4200) {
d = Pico32xMem->pal[(a & 0x1ff) / 2]; d = Pico32xMem->pal[(a & 0x1ff) / 2];
@ -1619,17 +1619,17 @@ static void get_bios(void)
// MSH2 // MSH2
if (p32x_bios_m != NULL) { if (p32x_bios_m != NULL) {
elprintf(EL_STATUS|EL_32X, "32x: using supplied master SH2 BIOS"); elprintf(EL_STATUS|EL_32X, "32x: using supplied master SH2 BIOS");
Byteswap(Pico32xMem->sh2_rom_m, p32x_bios_m, sizeof(Pico32xMem->sh2_rom_m)); Byteswap(&Pico32xMem->sh2_rom_m, p32x_bios_m, sizeof(Pico32xMem->sh2_rom_m));
} }
else { else {
pl = (u32 *)Pico32xMem->sh2_rom_m; pl = (u32 *)&Pico32xMem->sh2_rom_m;
// fill exception vector table to our trap address // fill exception vector table to our trap address
for (i = 0; i < 128; i++) for (i = 0; i < 128; i++)
pl[i] = HWSWAP(0x200); pl[i] = HWSWAP(0x200);
// startup code // startup code
memcpy(Pico32xMem->sh2_rom_m + 0x200, msh2_code, sizeof(msh2_code)); memcpy(&Pico32xMem->sh2_rom_m.b[0x200], msh2_code, sizeof(msh2_code));
// reset SP // reset SP
pl[1] = pl[3] = HWSWAP(0x6040000); pl[1] = pl[3] = HWSWAP(0x6040000);
@ -1640,17 +1640,17 @@ static void get_bios(void)
// SSH2 // SSH2
if (p32x_bios_s != NULL) { if (p32x_bios_s != NULL) {
elprintf(EL_STATUS|EL_32X, "32x: using supplied slave SH2 BIOS"); elprintf(EL_STATUS|EL_32X, "32x: using supplied slave SH2 BIOS");
Byteswap(Pico32xMem->sh2_rom_s, p32x_bios_s, sizeof(Pico32xMem->sh2_rom_s)); Byteswap(&Pico32xMem->sh2_rom_s, p32x_bios_s, sizeof(Pico32xMem->sh2_rom_s));
} }
else { else {
pl = (u32 *)Pico32xMem->sh2_rom_s; pl = (u32 *)&Pico32xMem->sh2_rom_s;
// fill exception vector table to our trap address // fill exception vector table to our trap address
for (i = 0; i < 128; i++) for (i = 0; i < 128; i++)
pl[i] = HWSWAP(0x200); pl[i] = HWSWAP(0x200);
// startup code // startup code
memcpy(Pico32xMem->sh2_rom_s + 0x200, ssh2_code, sizeof(ssh2_code)); memcpy(&Pico32xMem->sh2_rom_s.b[0x200], ssh2_code, sizeof(ssh2_code));
// reset SP // reset SP
pl[1] = pl[3] = HWSWAP(0x603f800); pl[1] = pl[3] = HWSWAP(0x603f800);

View file

@ -43,7 +43,7 @@ PICO_INTERNAL int PicoResetMCD(void)
memset(&Pico_mcd->pcm, 0, sizeof(Pico_mcd->pcm)); memset(&Pico_mcd->pcm, 0, sizeof(Pico_mcd->pcm));
memset(&Pico_mcd->m, 0, sizeof(Pico_mcd->m)); memset(&Pico_mcd->m, 0, sizeof(Pico_mcd->m));
*(unsigned int *)(Pico_mcd->bios + 0x70) = 0xffffffff; // reset hint vector (simplest way to implement reg6) memset(Pico_mcd->bios + 0x70, 0xff, 4); // reset hint vector (simplest way to implement reg6)
Pico_mcd->m.state_flags |= 1; // s68k reset pending Pico_mcd->m.state_flags |= 1; // s68k reset pending
Pico_mcd->s68k_regs[3] = 1; // 2M word RAM mode with m68k access after reset Pico_mcd->s68k_regs[3] = 1; // 2M word RAM mode with m68k access after reset

View file

@ -441,6 +441,7 @@ typedef struct
unsigned char pcm_ram[0x10000]; unsigned char pcm_ram[0x10000];
unsigned char pcm_ram_b[0x10][0x1000]; unsigned char pcm_ram_b[0x10][0x1000];
}; };
// FIXME: should be short
unsigned char s68k_regs[0x200]; // 110000: GA, not CPU regs unsigned char s68k_regs[0x200]; // 110000: GA, not CPU regs
unsigned char bram[0x2000]; // 110200: 8K unsigned char bram[0x2000]; // 110200: 8K
struct mcd_misc m; // 112200: misc struct mcd_misc m; // 112200: misc
@ -543,8 +544,14 @@ struct Pico32xMem
#ifdef DRC_SH2 #ifdef DRC_SH2
unsigned short drcblk_da[2][1 << (12 - SH2_DRCBLK_DA_SHIFT)]; unsigned short drcblk_da[2][1 << (12 - SH2_DRCBLK_DA_SHIFT)];
#endif #endif
unsigned char sh2_rom_m[0x800]; union {
unsigned char sh2_rom_s[0x400]; unsigned char b[0x800];
unsigned short w[0x800/2];
} sh2_rom_m;
union {
unsigned char b[0x400];
unsigned short w[0x400/2];
} sh2_rom_s;
unsigned short pal[0x100]; unsigned short pal[0x100];
unsigned short pal_native[0x100]; // converted to native (for renderer) unsigned short pal_native[0x100]; // converted to native (for renderer)
signed short pwm[2*PWM_BUFF_LEN]; // PWM buffer for current frame signed short pwm[2*PWM_BUFF_LEN]; // PWM buffer for current frame

View file

@ -290,7 +290,8 @@ static int state_save(void *file)
SekPackCpu(buff, 1); SekPackCpu(buff, 1);
if (Pico_mcd->s68k_regs[3] & 4) // 1M mode? if (Pico_mcd->s68k_regs[3] & 4) // 1M mode?
wram_1M_to_2M(Pico_mcd->word_ram2M); wram_1M_to_2M(Pico_mcd->word_ram2M);
Pico_mcd->m.hint_vector = *(unsigned short *)(Pico_mcd->bios + 0x72); memcpy(&Pico_mcd->m.hint_vector, Pico_mcd->bios + 0x72,
sizeof(Pico_mcd->m.hint_vector));
CHECKED_WRITE_BUFF(CHUNK_S68K, buff); CHECKED_WRITE_BUFF(CHUNK_S68K, buff);
CHECKED_WRITE_BUFF(CHUNK_PRG_RAM, Pico_mcd->prg_ram); CHECKED_WRITE_BUFF(CHUNK_PRG_RAM, Pico_mcd->prg_ram);