From: kub Date: Thu, 22 Apr 2021 21:28:35 +0000 (+0200) Subject: improvements for type issues X-Git-Tag: v2.00~539 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91ea9406e2b0288d0f0d2fc40173de2000aa8c75;p=picodrive.git improvements for type issues --- diff --git a/pico/32x/32x.c b/pico/32x/32x.c index e75a2775..a34e8075 100644 --- a/pico/32x/32x.c +++ b/pico/32x/32x.c @@ -142,9 +142,9 @@ void p32x_reset_sh2s(void) unsigned int vbr; // initial data - idl_src = CPU_BE2(*(unsigned int *)(Pico.rom + 0x3d4)) & ~0xf0000000; - idl_dst = CPU_BE2(*(unsigned int *)(Pico.rom + 0x3d8)) & ~0xf0000000; - idl_size= CPU_BE2(*(unsigned int *)(Pico.rom + 0x3dc)); + idl_src = CPU_BE2(*(u32 *)(Pico.rom + 0x3d4)) & ~0xf0000000; + idl_dst = CPU_BE2(*(u32 *)(Pico.rom + 0x3d8)) & ~0xf0000000; + idl_size= CPU_BE2(*(u32 *)(Pico.rom + 0x3dc)); 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)) { 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); // VBR - vbr = CPU_BE2(*(unsigned int *)(Pico.rom + 0x3e8)); + vbr = CPU_BE2(*(u32 *)(Pico.rom + 0x3e8)); sh2_set_vbr(0, vbr); // 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 } @@ -168,7 +168,7 @@ void p32x_reset_sh2s(void) unsigned int 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_vbr(1, vbr); // program will set S_OK diff --git a/pico/32x/memory.c b/pico/32x/memory.c index 0bdf2eb8..8cd1c198 100644 --- a/pico/32x/memory.c +++ b/pico/32x/memory.c @@ -324,7 +324,7 @@ static u32 sh2_comm_faker(u32 a) static int f = 0; if (a == 0x28 && !p32x_csum_faked) { p32x_csum_faked = 1; - return *(unsigned short *)(Pico.rom + 0x18e); + return *(u16 *)(Pico.rom + 0x18e); } if (f >= sizeof(comm_fakevals) / sizeof(comm_fakevals[0])) f = 0; diff --git a/pico/cart.c b/pico/cart.c index 1804db28..35c449fd 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -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. // note: 4 bytes are padded to every ROM if (rom != NULL) - *(unsigned long *)(rom+romsize) = CPU_BE2(0x4EFAFFFE); + *(u32 *)(rom+romsize) = CPU_BE2(0x4EFAFFFE); Pico.rom=rom; Pico.romsize=romsize; diff --git a/pico/cd/memory.c b/pico/cd/memory.c index a315391f..255461de 100644 --- a/pico/cd/memory.c +++ b/pico/cd/memory.c @@ -1094,7 +1094,7 @@ void pcd_state_loaded_mem(void) Pico_mcd->m.dmna_ret_2m &= 3; // 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 diff --git a/pico/cd/pcm.c b/pico/cd/pcm.c index f1375f34..b77196a4 100644 --- a/pico/cd/pcm.c +++ b/pico/cd/pcm.c @@ -120,7 +120,7 @@ end: 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 p = 0; diff --git a/pico/patch.c b/pico/patch.c index 4b6b5472..b4c2d898 100644 --- a/pico/patch.c +++ b/pico/patch.c @@ -446,11 +446,11 @@ void PicoPatchPrepare(void) addr=PicoPatches[i].addr; addr &= ~1; if (addr < Pico.romsize) - PicoPatches[i].data_old = *(unsigned short *)(Pico.rom + addr); + PicoPatches[i].data_old = *(u16 *)(Pico.rom + addr); else { if(!(PicoIn.AHW & PAHW_SMS)) - PicoPatches[i].data_old = (unsigned short) m68k_read16(addr); + PicoPatches[i].data_old = (u16) m68k_read16(addr); else ;// wrong: PicoPatches[i].data_old = (unsigned char) PicoRead8_z80(addr); } @@ -473,7 +473,7 @@ void PicoPatchApply(void) if (PicoPatches[i].active) { 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)) *(char *)(Pico.rom + addr) = (char) PicoPatches[i].data; } @@ -485,13 +485,13 @@ void PicoPatchApply(void) if (u == i) { if (!(PicoIn.AHW & PAHW_SMS)) - *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old; + *(u16 *)(Pico.rom + addr) = PicoPatches[i].data_old; else *(char *)(Pico.rom + addr) = (char) PicoPatches[i].data_old; } } // fprintf(stderr, "patched %i: %06x:%04x\n", PicoPatches[i].active, addr, - // *(unsigned short *)(Pico.rom + addr)); + // *(u16 *)(Pico.rom + addr)); } else { diff --git a/pico/pico_int.h b/pico/pico_int.h index cc3d2f44..84bd2010 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -780,7 +780,7 @@ void pcd_state_loaded(void); // cd/pcm.c 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); unsigned int pcd_pcm_read(unsigned int a); diff --git a/pico/sek.c b/pico/sek.c index 6c340672..bd8f70f5 100644 --- a/pico/sek.c +++ b/pico/sek.c @@ -192,14 +192,14 @@ PICO_INTERNAL void SekSetRealTAS(int use_real) // XXX: rename PICO_INTERNAL void SekPackCpu(unsigned char *cpu, int is_sub) { - unsigned int pc=0; + u32 pc=0; #if defined(EMU_C68K) struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k; memcpy(cpu,context->d,0x40); pc=context->pc-context->membase; - *(unsigned int *)(cpu+0x44)=CycloneGetSr(context); - *(unsigned int *)(cpu+0x48)=context->osp; + *(u32 *)(cpu+0x44)=CycloneGetSr(context); + *(u32 *)(cpu+0x48)=context->osp; cpu[0x4c] = context->irq; cpu[0x4d] = context->state_flags & 1; #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); memcpy(cpu,m68ki_cpu_p->dar,0x40); pc=m68ki_cpu_p->pc; - *(unsigned int *)(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+0x44)=m68k_get_reg(NULL, M68K_REG_SR); + *(u32 *)(cpu+0x48)=m68ki_cpu_p->sp[m68ki_cpu_p->s_flag^SFLAG_SET]; cpu[0x4c] = CPU_INT_LEVEL>>8; cpu[0x4d] = CPU_STOPPED; 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; memcpy(cpu,context->dreg,0x40); pc=context->pc; - *(unsigned int *)(cpu+0x44)=context->sr; - *(unsigned int *)(cpu+0x48)=context->asp; + *(u32 *)(cpu+0x44)=context->sr; + *(u32 *)(cpu+0x48)=context->asp; cpu[0x4c] = context->interrupts[0]; cpu[0x4d] = (context->execinfo & FM68K_HALTED) ? 1 : 0; #endif - *(unsigned int *)(cpu+0x40) = pc; - *(unsigned int *)(cpu+0x50) = + *(u32 *)(cpu+0x40) = pc; + *(u32 *)(cpu+0x50) = 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) struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k; - CycloneSetSr(context, *(unsigned int *)(cpu+0x44)); - context->osp=*(unsigned int *)(cpu+0x48); + CycloneSetSr(context, *(u32 *)(cpu+0x44)); + context->osp=*(u32 *)(cpu+0x48); memcpy(context->d,cpu,0x40); context->membase = 0; - context->pc = *(unsigned int *)(cpu+0x40); + context->pc = *(u32 *)(cpu+0x40); CycloneUnpack(context, NULL); // rebase PC context->irq = cpu[0x4c]; context->state_flags = 0; @@ -244,27 +244,27 @@ PICO_INTERNAL void SekUnpackCpu(const unsigned char *cpu, int is_sub) #elif defined(EMU_M68K) void *oldcontext = m68ki_cpu_p; 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); - m68ki_cpu_p->pc=*(unsigned int *)(cpu+0x40); - m68ki_cpu_p->sp[m68ki_cpu_p->s_flag^SFLAG_SET]=*(unsigned int *)(cpu+0x48); + m68ki_cpu_p->pc=*(u32 *)(cpu+0x40); + m68ki_cpu_p->sp[m68ki_cpu_p->s_flag^SFLAG_SET]=*(u32 *)(cpu+0x48); CPU_INT_LEVEL = cpu[0x4c] << 8; CPU_STOPPED = cpu[0x4d]; m68k_set_context(oldcontext); #elif defined(EMU_F68K) M68K_CONTEXT *context = is_sub ? &PicoCpuFS68k : &PicoCpuFM68k; memcpy(context->dreg,cpu,0x40); - context->pc =*(unsigned int *)(cpu+0x40); - context->sr =*(unsigned int *)(cpu+0x44); - context->asp=*(unsigned int *)(cpu+0x48); + context->pc =*(u32 *)(cpu+0x40); + context->sr =*(u32 *)(cpu+0x44); + context->asp=*(u32 *)(cpu+0x48); context->interrupts[0] = cpu[0x4c]; context->execinfo &= ~FM68K_HALTED; if (cpu[0x4d]&1) context->execinfo |= FM68K_HALTED; #endif if (is_sub) - SekCycleCntS68k = *(unsigned int *)(cpu+0x50); + SekCycleCntS68k = *(u32 *)(cpu+0x50); else - Pico.t.m68c_cnt = *(unsigned int *)(cpu+0x50); + Pico.t.m68c_cnt = *(u32 *)(cpu+0x50); } diff --git a/pico/sound/sound.c b/pico/sound/sound.c index 806a597b..76a9be84 100644 --- a/pico/sound/sound.c +++ b/pico/sound/sound.c @@ -17,10 +17,10 @@ void (*PsndMix_32_to_16l)(short *dest, int *src, int count) = mix_32_to_16l_stereo; // master int buffer to mix to -static int PsndBuffer[2*(44100+100)/50]; +static s32 PsndBuffer[2*(44100+100)/50]; // cdda output buffer -short cdda_out_buffer[2*1152]; +s16 cdda_out_buffer[2*1152]; // sn76496 extern int *sn76496_regs; @@ -236,7 +236,7 @@ PICO_INTERNAL void PsndDoFM(int cyc_to) // Q16, number of samples since last call 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) return;