From: kub Date: Thu, 22 Apr 2021 21:23:54 +0000 (+0200) Subject: fixes for big endian (mostly mcd) X-Git-Tag: v2.00~540 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d8d97f87c8c13a7883682cce01cf65b112dbfb7;p=picodrive.git fixes for big endian (mostly mcd) --- diff --git a/pico/cart.c b/pico/cart.c index 81fc7fb0..1804db28 100644 --- a/pico/cart.c +++ b/pico/cart.c @@ -187,7 +187,7 @@ zip_failed: else if (strcasecmp(ext, "cso") == 0) { cso_struct *cso = NULL, *tmp = NULL; - int size; + int i, size; f = fopen(path, "rb"); if (f == NULL) goto cso_failed; @@ -229,6 +229,8 @@ zip_failed: elprintf(EL_STATUS, "cso: premature EOF"); goto cso_failed; } + for (i = 0; i < size/4; i++) + cso->index[i] = CPU_LE4(cso->index[i]); // all ok cso->fpos_in = ftell(f); @@ -280,7 +282,7 @@ cso_failed: chd->file.file = chd; chd->file.type = PMT_CHD; // subchannel data is skipped, remove it from total size - chd->file.size = chd_get_header(cf)->logicalbytes / CD_FRAME_SIZE * CD_MAX_SECTOR_DATA; + chd->file.size = head->logicalbytes / CD_FRAME_SIZE * CD_MAX_SECTOR_DATA; strncpy(chd->file.ext, ext, sizeof(chd->file.ext) - 1); return &chd->file; @@ -359,7 +361,7 @@ static size_t _pm_read_chd(void *ptr, size_t bytes, pm_file *stream, int is_audi if (len > bytes) len = bytes; -#ifdef CPU_IS_LE +#if CPU_IS_LE if (is_audio) { // convert big endian audio samples u16 *dst = ptr, v; @@ -1309,7 +1311,7 @@ static void PicoCartDetect(const char *carthw_cfg) // Unusual region 'code' if (rom_strcmp(0x1f0, "EUROPE") == 0 || rom_strcmp(0x1f0, "Europe") == 0) - *(int *) (Pico.rom + 0x1f0) = 0x20204520; + *(u32 *) (Pico.rom + 0x1f0) = CPU_LE4(0x20204520); } // vim:shiftwidth=2:expandtab diff --git a/pico/cd/memory.c b/pico/cd/memory.c index 7cf9ffd5..a315391f 100644 --- a/pico/cd/memory.c +++ b/pico/cd/memory.c @@ -205,10 +205,10 @@ void m68k_reg_write8(u32 a, u32 d) goto write_comm; case 6: - Pico_mcd->bios[0x72 + 1] = d; // simple hint vector changer + Pico_mcd->bios[MEM_BE2(0x72)] = d; // simple hint vector changer return; case 7: - Pico_mcd->bios[0x72] = d; + Pico_mcd->bios[MEM_BE2(0x73)] = d; elprintf(EL_CDREGS, "hint vector set to %04x%04x", ((u16 *)Pico_mcd->bios)[0x70/2], ((u16 *)Pico_mcd->bios)[0x72/2]); return; @@ -277,7 +277,7 @@ u32 s68k_poll_detect(u32 a, u32 d) #define READ_FONT_DATA(basemask) \ { \ - unsigned int fnt = *(unsigned int *)(Pico_mcd->s68k_regs + 0x4c); \ + unsigned int fnt = CPU_LE4(*(u32 *)(Pico_mcd->s68k_regs + 0x4c)); \ unsigned int col0 = (fnt >> 8) & 0x0f, col1 = (fnt >> 12) & 0x0f; \ if (fnt & (basemask << 0)) d = col1 ; else d = col0; \ if (fnt & (basemask << 1)) d |= col1 << 4; else d |= col0 << 4; \ diff --git a/pico/cd/pcm.c b/pico/cd/pcm.c index 27fb2ac9..f1375f34 100644 --- a/pico/cd/pcm.c +++ b/pico/cd/pcm.c @@ -88,7 +88,7 @@ void pcd_pcm_sync(unsigned int to) } addr = ch->addr; - inc = *(unsigned short *)&ch->regs[2]; + inc = ch->regs[2] + (ch->regs[3]<<8); mul_l = ((int)ch->regs[0] * (ch->regs[1] & 0xf)) >> (5+1); mul_r = ((int)ch->regs[0] * (ch->regs[1] >> 4)) >> (5+1); @@ -99,7 +99,7 @@ void pcd_pcm_sync(unsigned int to) // test for loop signal if (smp == 0xff) { - addr = *(unsigned short *)&ch->regs[4]; // loop_addr + addr = ch->regs[4] + (ch->regs[5]<<8); // loop_addr smp = Pico_mcd->pcm_ram[addr]; addr <<= PCM_STEP_SHIFT; if (smp == 0xff) diff --git a/pico/pico_port.h b/pico/pico_port.h index a5f8a582..d2b78e05 100644 --- a/pico/pico_port.h +++ b/pico/pico_port.h @@ -57,7 +57,7 @@ #define MEM_LE2(a) (a) #define MEM_LE4(a) (a) // swapping -#define CPU_BE2(v) ((u32)((u64)(v)<<16)|((v)>>16)) +#define CPU_BE2(v) ((u32)((u64)(v)<<16)|((u32)(v)>>16)) #define CPU_BE4(v) (((u32)(v)>>24)|(((v)>>8)&0x00ff00)| \ (((v)<<8)&0xff0000)|(u32)((v)<<24)) #define CPU_LE2(v) (v) // swap of 2*u16 in u32 @@ -71,7 +71,7 @@ // swapping #define CPU_BE2(v) (v) #define CPU_BE4(v) (v) -#define CPU_LE2(v) ((u32)((u64)(v)<<16)|((v)>>16)) +#define CPU_LE2(v) ((u32)((u64)(v)<<16)|((u32)(v)>>16)) #define CPU_LE4(v) (((u32)(v)>>24)|(((v)>>8)&0x00ff00)| \ (((v)<<8)&0xff0000)|(u32)((v)<<24)) #endif