improvements for type issues

This commit is contained in:
kub 2021-04-22 23:28:35 +02:00
parent 0d8d97f87c
commit 91ea9406e2
9 changed files with 39 additions and 39 deletions

View file

@ -142,9 +142,9 @@ void p32x_reset_sh2s(void)
unsigned int vbr; unsigned int vbr;
// initial data // initial data
idl_src = CPU_BE2(*(unsigned int *)(Pico.rom + 0x3d4)) & ~0xf0000000; idl_src = CPU_BE2(*(u32 *)(Pico.rom + 0x3d4)) & ~0xf0000000;
idl_dst = CPU_BE2(*(unsigned int *)(Pico.rom + 0x3d8)) & ~0xf0000000; idl_dst = CPU_BE2(*(u32 *)(Pico.rom + 0x3d8)) & ~0xf0000000;
idl_size= CPU_BE2(*(unsigned int *)(Pico.rom + 0x3dc)); idl_size= CPU_BE2(*(u32 *)(Pico.rom + 0x3dc));
if (idl_size > Pico.romsize || idl_src + idl_size > Pico.romsize || if (idl_size > Pico.romsize || idl_src + idl_size > Pico.romsize ||
idl_size > 0x40000 || idl_dst + idl_size > 0x40000 || (idl_src & 3) || (idl_dst & 3)) { idl_size > 0x40000 || idl_dst + idl_size > 0x40000 || (idl_src & 3) || (idl_dst & 3)) {
elprintf(EL_STATUS|EL_ANOMALY, "32x: invalid initial data ptrs: %06x -> %06x, %06x", elprintf(EL_STATUS|EL_ANOMALY, "32x: invalid initial data ptrs: %06x -> %06x, %06x",
@ -154,11 +154,11 @@ void p32x_reset_sh2s(void)
memcpy(Pico32xMem->sdram + idl_dst, Pico.rom + idl_src, idl_size); memcpy(Pico32xMem->sdram + idl_dst, Pico.rom + idl_src, idl_size);
// VBR // VBR
vbr = CPU_BE2(*(unsigned int *)(Pico.rom + 0x3e8)); vbr = CPU_BE2(*(u32 *)(Pico.rom + 0x3e8));
sh2_set_vbr(0, vbr); sh2_set_vbr(0, vbr);
// checksum and M_OK // checksum and M_OK
Pico32x.regs[0x28 / 2] = *(unsigned short *)(Pico.rom + 0x18e); Pico32x.regs[0x28 / 2] = *(u16 *)(Pico.rom + 0x18e);
} }
// program will set M_OK // program will set M_OK
} }
@ -168,7 +168,7 @@ void p32x_reset_sh2s(void)
unsigned int vbr; unsigned int vbr;
// GBR/VBR // GBR/VBR
vbr = CPU_BE2(*(unsigned int *)(Pico.rom + 0x3ec)); vbr = CPU_BE2(*(u32 *)(Pico.rom + 0x3ec));
sh2_set_gbr(1, 0x20004000); sh2_set_gbr(1, 0x20004000);
sh2_set_vbr(1, vbr); sh2_set_vbr(1, vbr);
// program will set S_OK // program will set S_OK

View file

@ -324,7 +324,7 @@ static u32 sh2_comm_faker(u32 a)
static int f = 0; static int f = 0;
if (a == 0x28 && !p32x_csum_faked) { if (a == 0x28 && !p32x_csum_faked) {
p32x_csum_faked = 1; p32x_csum_faked = 1;
return *(unsigned short *)(Pico.rom + 0x18e); return *(u16 *)(Pico.rom + 0x18e);
} }
if (f >= sizeof(comm_fakevals) / sizeof(comm_fakevals[0])) if (f >= sizeof(comm_fakevals) / sizeof(comm_fakevals[0]))
f = 0; f = 0;

View file

@ -823,7 +823,7 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_
// This will hang the emu, but will prevent nasty crashes. // This will hang the emu, but will prevent nasty crashes.
// note: 4 bytes are padded to every ROM // note: 4 bytes are padded to every ROM
if (rom != NULL) if (rom != NULL)
*(unsigned long *)(rom+romsize) = CPU_BE2(0x4EFAFFFE); *(u32 *)(rom+romsize) = CPU_BE2(0x4EFAFFFE);
Pico.rom=rom; Pico.rom=rom;
Pico.romsize=romsize; Pico.romsize=romsize;

View file

@ -1094,7 +1094,7 @@ void pcd_state_loaded_mem(void)
Pico_mcd->m.dmna_ret_2m &= 3; Pico_mcd->m.dmna_ret_2m &= 3;
// restore hint vector // restore hint vector
*(unsigned short *)(Pico_mcd->bios + 0x72) = Pico_mcd->m.hint_vector; *(u16 *)(Pico_mcd->bios + 0x72) = Pico_mcd->m.hint_vector;
} }
#ifdef EMU_M68K #ifdef EMU_M68K

View file

@ -120,7 +120,7 @@ end:
Pico_mcd->pcm_mixpos += steps; Pico_mcd->pcm_mixpos += steps;
} }
void pcd_pcm_update(int *buf32, int length, int stereo) void pcd_pcm_update(s32 *buf32, int length, int stereo)
{ {
int step, *pcm; int step, *pcm;
int p = 0; int p = 0;

View file

@ -446,11 +446,11 @@ void PicoPatchPrepare(void)
addr=PicoPatches[i].addr; addr=PicoPatches[i].addr;
addr &= ~1; addr &= ~1;
if (addr < Pico.romsize) if (addr < Pico.romsize)
PicoPatches[i].data_old = *(unsigned short *)(Pico.rom + addr); PicoPatches[i].data_old = *(u16 *)(Pico.rom + addr);
else else
{ {
if(!(PicoIn.AHW & PAHW_SMS)) if(!(PicoIn.AHW & PAHW_SMS))
PicoPatches[i].data_old = (unsigned short) m68k_read16(addr); PicoPatches[i].data_old = (u16) m68k_read16(addr);
else else
;// wrong: PicoPatches[i].data_old = (unsigned char) PicoRead8_z80(addr); ;// wrong: PicoPatches[i].data_old = (unsigned char) PicoRead8_z80(addr);
} }
@ -473,7 +473,7 @@ void PicoPatchApply(void)
if (PicoPatches[i].active) if (PicoPatches[i].active)
{ {
if (!(PicoIn.AHW & PAHW_SMS)) if (!(PicoIn.AHW & PAHW_SMS))
*(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data; *(u16 *)(Pico.rom + addr) = PicoPatches[i].data;
else if (!PicoPatches[i].comp || PicoPatches[i].comp == *(char *)(Pico.rom + addr)) else if (!PicoPatches[i].comp || PicoPatches[i].comp == *(char *)(Pico.rom + addr))
*(char *)(Pico.rom + addr) = (char) PicoPatches[i].data; *(char *)(Pico.rom + addr) = (char) PicoPatches[i].data;
} }
@ -485,13 +485,13 @@ void PicoPatchApply(void)
if (u == i) if (u == i)
{ {
if (!(PicoIn.AHW & PAHW_SMS)) if (!(PicoIn.AHW & PAHW_SMS))
*(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old; *(u16 *)(Pico.rom + addr) = PicoPatches[i].data_old;
else else
*(char *)(Pico.rom + addr) = (char) PicoPatches[i].data_old; *(char *)(Pico.rom + addr) = (char) PicoPatches[i].data_old;
} }
} }
// fprintf(stderr, "patched %i: %06x:%04x\n", PicoPatches[i].active, addr, // fprintf(stderr, "patched %i: %06x:%04x\n", PicoPatches[i].active, addr,
// *(unsigned short *)(Pico.rom + addr)); // *(u16 *)(Pico.rom + addr));
} }
else else
{ {

View file

@ -780,7 +780,7 @@ void pcd_state_loaded(void);
// cd/pcm.c // cd/pcm.c
void pcd_pcm_sync(unsigned int to); void pcd_pcm_sync(unsigned int to);
void pcd_pcm_update(int *buffer, int length, int stereo); void pcd_pcm_update(s32 *buffer, int length, int stereo);
void pcd_pcm_write(unsigned int a, unsigned int d); void pcd_pcm_write(unsigned int a, unsigned int d);
unsigned int pcd_pcm_read(unsigned int a); unsigned int pcd_pcm_read(unsigned int a);

View file

@ -192,14 +192,14 @@ PICO_INTERNAL void SekSetRealTAS(int use_real)
// XXX: rename // XXX: rename
PICO_INTERNAL void SekPackCpu(unsigned char *cpu, int is_sub) PICO_INTERNAL void SekPackCpu(unsigned char *cpu, int is_sub)
{ {
unsigned int pc=0; u32 pc=0;
#if defined(EMU_C68K) #if defined(EMU_C68K)
struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k; struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k;
memcpy(cpu,context->d,0x40); memcpy(cpu,context->d,0x40);
pc=context->pc-context->membase; pc=context->pc-context->membase;
*(unsigned int *)(cpu+0x44)=CycloneGetSr(context); *(u32 *)(cpu+0x44)=CycloneGetSr(context);
*(unsigned int *)(cpu+0x48)=context->osp; *(u32 *)(cpu+0x48)=context->osp;
cpu[0x4c] = context->irq; cpu[0x4c] = context->irq;
cpu[0x4d] = context->state_flags & 1; cpu[0x4d] = context->state_flags & 1;
#elif defined(EMU_M68K) #elif defined(EMU_M68K)
@ -207,8 +207,8 @@ PICO_INTERNAL void SekPackCpu(unsigned char *cpu, int is_sub)
m68k_set_context(is_sub ? &PicoCpuMS68k : &PicoCpuMM68k); m68k_set_context(is_sub ? &PicoCpuMS68k : &PicoCpuMM68k);
memcpy(cpu,m68ki_cpu_p->dar,0x40); memcpy(cpu,m68ki_cpu_p->dar,0x40);
pc=m68ki_cpu_p->pc; pc=m68ki_cpu_p->pc;
*(unsigned int *)(cpu+0x44)=m68k_get_reg(NULL, M68K_REG_SR); *(u32 *)(cpu+0x44)=m68k_get_reg(NULL, M68K_REG_SR);
*(unsigned int *)(cpu+0x48)=m68ki_cpu_p->sp[m68ki_cpu_p->s_flag^SFLAG_SET]; *(u32 *)(cpu+0x48)=m68ki_cpu_p->sp[m68ki_cpu_p->s_flag^SFLAG_SET];
cpu[0x4c] = CPU_INT_LEVEL>>8; cpu[0x4c] = CPU_INT_LEVEL>>8;
cpu[0x4d] = CPU_STOPPED; cpu[0x4d] = CPU_STOPPED;
m68k_set_context(oldcontext); m68k_set_context(oldcontext);
@ -216,14 +216,14 @@ PICO_INTERNAL void SekPackCpu(unsigned char *cpu, int is_sub)
M68K_CONTEXT *context = is_sub ? &PicoCpuFS68k : &PicoCpuFM68k; M68K_CONTEXT *context = is_sub ? &PicoCpuFS68k : &PicoCpuFM68k;
memcpy(cpu,context->dreg,0x40); memcpy(cpu,context->dreg,0x40);
pc=context->pc; pc=context->pc;
*(unsigned int *)(cpu+0x44)=context->sr; *(u32 *)(cpu+0x44)=context->sr;
*(unsigned int *)(cpu+0x48)=context->asp; *(u32 *)(cpu+0x48)=context->asp;
cpu[0x4c] = context->interrupts[0]; cpu[0x4c] = context->interrupts[0];
cpu[0x4d] = (context->execinfo & FM68K_HALTED) ? 1 : 0; cpu[0x4d] = (context->execinfo & FM68K_HALTED) ? 1 : 0;
#endif #endif
*(unsigned int *)(cpu+0x40) = pc; *(u32 *)(cpu+0x40) = pc;
*(unsigned int *)(cpu+0x50) = *(u32 *)(cpu+0x50) =
is_sub ? SekCycleCntS68k : Pico.t.m68c_cnt; is_sub ? SekCycleCntS68k : Pico.t.m68c_cnt;
} }
@ -231,11 +231,11 @@ PICO_INTERNAL void SekUnpackCpu(const unsigned char *cpu, int is_sub)
{ {
#if defined(EMU_C68K) #if defined(EMU_C68K)
struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k; struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k;
CycloneSetSr(context, *(unsigned int *)(cpu+0x44)); CycloneSetSr(context, *(u32 *)(cpu+0x44));
context->osp=*(unsigned int *)(cpu+0x48); context->osp=*(u32 *)(cpu+0x48);
memcpy(context->d,cpu,0x40); memcpy(context->d,cpu,0x40);
context->membase = 0; context->membase = 0;
context->pc = *(unsigned int *)(cpu+0x40); context->pc = *(u32 *)(cpu+0x40);
CycloneUnpack(context, NULL); // rebase PC CycloneUnpack(context, NULL); // rebase PC
context->irq = cpu[0x4c]; context->irq = cpu[0x4c];
context->state_flags = 0; context->state_flags = 0;
@ -244,27 +244,27 @@ PICO_INTERNAL void SekUnpackCpu(const unsigned char *cpu, int is_sub)
#elif defined(EMU_M68K) #elif defined(EMU_M68K)
void *oldcontext = m68ki_cpu_p; void *oldcontext = m68ki_cpu_p;
m68k_set_context(is_sub ? &PicoCpuMS68k : &PicoCpuMM68k); m68k_set_context(is_sub ? &PicoCpuMS68k : &PicoCpuMM68k);
m68k_set_reg(M68K_REG_SR, *(unsigned int *)(cpu+0x44)); m68k_set_reg(M68K_REG_SR, *(u32 *)(cpu+0x44));
memcpy(m68ki_cpu_p->dar,cpu,0x40); memcpy(m68ki_cpu_p->dar,cpu,0x40);
m68ki_cpu_p->pc=*(unsigned int *)(cpu+0x40); m68ki_cpu_p->pc=*(u32 *)(cpu+0x40);
m68ki_cpu_p->sp[m68ki_cpu_p->s_flag^SFLAG_SET]=*(unsigned int *)(cpu+0x48); m68ki_cpu_p->sp[m68ki_cpu_p->s_flag^SFLAG_SET]=*(u32 *)(cpu+0x48);
CPU_INT_LEVEL = cpu[0x4c] << 8; CPU_INT_LEVEL = cpu[0x4c] << 8;
CPU_STOPPED = cpu[0x4d]; CPU_STOPPED = cpu[0x4d];
m68k_set_context(oldcontext); m68k_set_context(oldcontext);
#elif defined(EMU_F68K) #elif defined(EMU_F68K)
M68K_CONTEXT *context = is_sub ? &PicoCpuFS68k : &PicoCpuFM68k; M68K_CONTEXT *context = is_sub ? &PicoCpuFS68k : &PicoCpuFM68k;
memcpy(context->dreg,cpu,0x40); memcpy(context->dreg,cpu,0x40);
context->pc =*(unsigned int *)(cpu+0x40); context->pc =*(u32 *)(cpu+0x40);
context->sr =*(unsigned int *)(cpu+0x44); context->sr =*(u32 *)(cpu+0x44);
context->asp=*(unsigned int *)(cpu+0x48); context->asp=*(u32 *)(cpu+0x48);
context->interrupts[0] = cpu[0x4c]; context->interrupts[0] = cpu[0x4c];
context->execinfo &= ~FM68K_HALTED; context->execinfo &= ~FM68K_HALTED;
if (cpu[0x4d]&1) context->execinfo |= FM68K_HALTED; if (cpu[0x4d]&1) context->execinfo |= FM68K_HALTED;
#endif #endif
if (is_sub) if (is_sub)
SekCycleCntS68k = *(unsigned int *)(cpu+0x50); SekCycleCntS68k = *(u32 *)(cpu+0x50);
else else
Pico.t.m68c_cnt = *(unsigned int *)(cpu+0x50); Pico.t.m68c_cnt = *(u32 *)(cpu+0x50);
} }

View file

@ -17,10 +17,10 @@
void (*PsndMix_32_to_16l)(short *dest, int *src, int count) = mix_32_to_16l_stereo; void (*PsndMix_32_to_16l)(short *dest, int *src, int count) = mix_32_to_16l_stereo;
// master int buffer to mix to // master int buffer to mix to
static int PsndBuffer[2*(44100+100)/50]; static s32 PsndBuffer[2*(44100+100)/50];
// cdda output buffer // cdda output buffer
short cdda_out_buffer[2*1152]; s16 cdda_out_buffer[2*1152];
// sn76496 // sn76496
extern int *sn76496_regs; extern int *sn76496_regs;
@ -236,7 +236,7 @@ PICO_INTERNAL void PsndDoFM(int cyc_to)
// Q16, number of samples since last call // Q16, number of samples since last call
len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.fm_pos; len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.fm_pos;
// don't do this too often (about once every canline) // don't do this too often (about once every scanline)
if (len >> 16 <= PicoIn.sndRate >> 10) if (len >> 16 <= PicoIn.sndRate >> 10)
return; return;