From: notaz Date: Sun, 9 Jul 2023 15:57:54 +0000 (+0300) Subject: Merge pull request #292 from pcercuei/dfsound-big-endian X-Git-Tag: r24~262 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=commitdiff_plain;h=4d66d894c6563cbfb78fe8ccc0b374809fc44b0d;hp=a4621d435f84acf094a6601c3a444cc550f82929 Merge pull request #292 from pcercuei/dfsound-big-endian dfsound: Fix issues on big-endian systems --- diff --git a/frontend/blit320.s b/frontend/blit320.s index 201fdea6..2d50dfd7 100644 --- a/frontend/blit320.s +++ b/frontend/blit320.s @@ -25,6 +25,7 @@ blit320_640: stmfd sp!, {r4-r8,lr} mov r12, #40 + bic r1, r1, #3 0: ldmia r1!, {r2-r8,lr} lhw_str r2, r3 @@ -40,6 +41,7 @@ blit320_640: blit320_512: stmfd sp!, {r4-r8,lr} mov r12, #32 + bic r1, r1, #3 0: ldmia r1!, {r2-r8,lr} lsl r2, #16 @@ -73,6 +75,7 @@ blit320_512: blit320_368: stmfd sp!, {r4-r8,lr} mov r12, #23 + bic r1, r1, #3 0: ldmia r1!, {r2-r8,lr} unaligned_str r2, r3 @ 1,2 diff --git a/frontend/cspace.c b/frontend/cspace.c index 2b528a5a..785b3d13 100644 --- a/frontend/cspace.c +++ b/frontend/cspace.c @@ -8,6 +8,7 @@ * See the COPYING file in the top-level directory. */ +#include #include "cspace.h" /* @@ -30,7 +31,6 @@ || (defined(__GNUC__) && __GNUC__ >= 5)) \ && __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ -#include #include #if defined(__ARM_NEON) || defined(__ARM_NEON__) @@ -93,7 +93,8 @@ void bgr555_to_rgb565(void * __restrict__ dst_, const void * __restrict__ src_, void bgr555_to_rgb565(void *dst_, const void *src_, int bytes) { - const unsigned int *src = src_; + // source can be misaligned, but it's very rare, so just force + const unsigned int *src = (const void *)((intptr_t)src_ & ~3); unsigned int *dst = dst_; unsigned int x, p, r, g, b; diff --git a/frontend/cspace_arm.S b/frontend/cspace_arm.S index 67778da5..177b0858 100644 --- a/frontend/cspace_arm.S +++ b/frontend/cspace_arm.S @@ -34,6 +34,12 @@ FUNCTION(bgr555_to_rgb565): @ void *dst, const void *src, int bytes orr lr, lr, lsl #16 blt 1f + @ src can be unaligned, but that's very rare, so just force it. + @ The manual says unaligned ldm should fault, and it does on + @ cortex-a78's 32bit mode, but curiously on cortex-a8 it just + @ works and loads the data correctly. + bic r1, r1, #3 + 0: ldmia r1!, {r3-r10} subs r2, #4*8 diff --git a/frontend/cspace_neon.S b/frontend/cspace_neon.S index 4928b44a..3a89fdb9 100644 --- a/frontend/cspace_neon.S +++ b/frontend/cspace_neon.S @@ -40,7 +40,8 @@ FUNCTION(bgr555_to_rgb565): @ dst, src, bytes pld [r1, #64*2] @ Pulls 15-bit BGR color values (which are actually 16 bits) into q0-q3. @ example: q0 = 0111 1110 0101 0011 - vldmia r1!, {q0-q3} + vld1.16 {d0-d3}, [r1]! + vld1.16 {d4-d7}, [r1]! @ Shift BGR color 1 bit to the left, discarding MSB and preparing for vbit. @ MSB is used for transparency (not needed here, and can mess with green). @ example: q0 = 1111 1100 1010 0110 @@ -113,7 +114,8 @@ FUNCTION(bgr555_to_rgb565_b): @ dst, src, bytes, int brightness2k // 0-0x0800 vdup.16 q14, r3 0: pld [r1, #64*2] - vldmia r1!, {q0-q3} + vld1.16 {d0-d3}, [r1]! + vld1.16 {d4-d7}, [r1]! vand.u16 q8, q0, q14 vand.u16 q9, q1, q14 vand.u16 q10, q2, q14 @@ -270,4 +272,4 @@ FUNCTION(rgb888_to_rgb565): @ dst, src, bytes bx lr -@ vim:filetype=armasm +@ vim:filetype=armasm:expandtab diff --git a/frontend/libretro.c b/frontend/libretro.c index 3e74b230..f4b23cdf 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -2074,6 +2074,16 @@ static void update_variables(bool in_flight) spu_config.iUseInterpolation = 0; } + var.value = NULL; + var.key = "pcsx_rearmed_spu_thread"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "enabled") == 0) + spu_config.iUseThread = 1; + else + spu_config.iUseThread = 0; + } + #ifndef _WIN32 var.value = NULL; var.key = "pcsx_rearmed_async_cd"; diff --git a/frontend/libretro_core_options.h b/frontend/libretro_core_options.h index 935c6f97..7d070f9a 100644 --- a/frontend/libretro_core_options.h +++ b/frontend/libretro_core_options.h @@ -752,6 +752,22 @@ struct retro_core_option_v2_definition option_defs_us[] = { }, "enabled", }, +#if !defined(THREAD_ENABLED) && !defined(_WIN32) && !defined(NO_OS) + { + "pcsx_rearmed_spu_thread", + "Threaded SPU", + NULL, + "Emulates the PSX SPU on another CPU thread. May cause audio glitches in some games.", + NULL, + "audio", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled", + }, +#endif // THREAD_ENABLED { "pcsx_rearmed_show_input_settings", "Show Input Settings", diff --git a/frontend/main.c b/frontend/main.c index 2773f7a1..e0635ef4 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -158,7 +158,8 @@ void emu_set_default_config(void) spu_config.iXAPitch = 0; spu_config.iVolume = 768; spu_config.iTempo = 0; - spu_config.iUseThread = 1; // no effect if only 1 core is detected + // may cause issues, no effect if only 1 core is detected + spu_config.iUseThread = 0; #if defined(HAVE_PRE_ARMV7) && !defined(_3DS) /* XXX GPH hack */ spu_config.iUseReverb = 0; spu_config.iUseInterpolation = 0; diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index 171296d2..d5cec766 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -402,8 +402,6 @@ static void pl_vout_flip(const void *vram, int stride, int bgr24, int w, int h) #endif else { - src = (void *)((uintptr_t)src & ~3); // align for the blitter - for (; h1-- > 0; dest += dstride * 2, src += stride) { bgr555_to_rgb565(dest, src, w * 2); diff --git a/include/arm_features.h b/include/arm_features.h index 7c82ff38..4f216a3c 100644 --- a/include/arm_features.h +++ b/include/arm_features.h @@ -47,7 +47,10 @@ #endif -/* no need for HAVE_NEON - GCC defines __ARM_NEON__ consistently */ +/* gcc defines __ARM_NEON__ consistently for 32bit, but apple clang defines it for 64bit also... */ +#if defined(HAVE_ARMV7) && defined(__ARM_NEON__) +#define HAVE_NEON32 +#endif /* global function/external symbol */ #ifndef __MACH__ diff --git a/libpcsxcore/new_dynarec/assem_arm.c b/libpcsxcore/new_dynarec/assem_arm.c index 95007dfa..6af93e22 100644 --- a/libpcsxcore/new_dynarec/assem_arm.c +++ b/libpcsxcore/new_dynarec/assem_arm.c @@ -430,7 +430,7 @@ static void emit_loadreg(int r, int hr) //case HIREG: addr = &hi; break; //case LOREG: addr = &lo; break; case CCREG: addr = &cycle_count; break; - case CSREG: addr = &Status; break; + case CSREG: addr = &psxRegs.CP0.n.Status; break; case INVCP: addr = &invc_ptr; break; case ROREG: addr = &ram_offset; break; default: @@ -1752,7 +1752,7 @@ static void inline_readstub(enum stub_type type, int i, u_int addr, emit_readword(&last_count,3); emit_addimm(cc<0?2:cc,adj,2); emit_add(2,3,2); - emit_writeword(2,&Count); + emit_writeword(2,&psxRegs.cycle); } emit_far_call(handler); diff --git a/libpcsxcore/new_dynarec/assem_arm64.c b/libpcsxcore/new_dynarec/assem_arm64.c index 271bee58..67ce02ad 100644 --- a/libpcsxcore/new_dynarec/assem_arm64.c +++ b/libpcsxcore/new_dynarec/assem_arm64.c @@ -463,7 +463,7 @@ static void emit_loadreg(u_int r, u_int hr) //case HIREG: addr = &hi; break; //case LOREG: addr = &lo; break; case CCREG: addr = &cycle_count; break; - case CSREG: addr = &Status; break; + case CSREG: addr = &psxRegs.CP0.n.Status; break; case INVCP: addr = &invc_ptr; is64 = 1; break; case ROREG: addr = &ram_offset; is64 = 1; break; default: diff --git a/libpcsxcore/new_dynarec/emu_if.c b/libpcsxcore/new_dynarec/emu_if.c index dc17f2d4..aac9f78c 100644 --- a/libpcsxcore/new_dynarec/emu_if.c +++ b/libpcsxcore/new_dynarec/emu_if.c @@ -84,7 +84,7 @@ static void irq_test(void) } } - if ((psxHu32(0x1070) & psxHu32(0x1074)) && (Status & 0x401) == 0x401) { + if ((psxHu32(0x1070) & psxHu32(0x1074)) && (psxRegs.CP0.n.Status & 0x401) == 0x401) { psxException(0x400, 0); pending_exception = 1; } @@ -110,7 +110,7 @@ void pcsx_mtc0(u32 reg, u32 val) evprintf("MTC0 %d #%x @%08x %u\n", reg, val, psxRegs.pc, psxRegs.cycle); MTC0(&psxRegs, reg, val); gen_interupt(); - if (Cause & Status & 0x0300) // possible sw irq + if (psxRegs.CP0.n.Cause & psxRegs.CP0.n.Status & 0x0300) // possible sw irq pending_exception = 1; } @@ -370,19 +370,15 @@ static void ari64_clear(u32 addr, u32 size) } static void ari64_notify(int note, void *data) { - /* - Should be fixed when ARM dynarec has proper icache emulation. switch (note) { - case R3000ACPU_NOTIFY_CACHE_UNISOLATED: - break; - case R3000ACPU_NOTIFY_CACHE_ISOLATED: - Sent from psxDma3(). - case R3000ACPU_NOTIFY_DMA3_EXE_LOAD: - default: - break; + case R3000ACPU_NOTIFY_CACHE_UNISOLATED: + case R3000ACPU_NOTIFY_CACHE_ISOLATED: + new_dyna_pcsx_mem_isolate(note == R3000ACPU_NOTIFY_CACHE_ISOLATED); + break; + default: + break; } - */ } static void ari64_apply_config() @@ -430,7 +426,7 @@ int new_dynarec_hacks_old; int new_dynarec_hacks; void *psxH_ptr; void *zeromem_ptr; -u8 zero_mem[0x1000]; +u32 zero_mem[0x1000/4]; void *mem_rtab; void *scratch_buf_ptr; void new_dynarec_init() {} @@ -442,6 +438,7 @@ void new_dynarec_invalidate_range(unsigned int start, unsigned int end) {} void new_dyna_pcsx_mem_init(void) {} void new_dyna_pcsx_mem_reset(void) {} void new_dyna_pcsx_mem_load_state(void) {} +void new_dyna_pcsx_mem_isolate(int enable) {} void new_dyna_pcsx_mem_shutdown(void) {} int new_dynarec_save_blocks(void *save, int size) { return 0; } void new_dynarec_load_blocks(const void *save, int size) {} diff --git a/libpcsxcore/new_dynarec/emu_if.h b/libpcsxcore/new_dynarec/emu_if.h index 7fa0a171..b49b84ba 100644 --- a/libpcsxcore/new_dynarec/emu_if.h +++ b/libpcsxcore/new_dynarec/emu_if.h @@ -14,11 +14,6 @@ extern int hi, lo; /* same as psxRegs.CP0.n.* */ extern int reg_cop0[]; -#define Status psxRegs.CP0.n.Status -#define Cause psxRegs.CP0.n.Cause -#define EPC psxRegs.CP0.n.EPC -#define BadVAddr psxRegs.CP0.n.BadVAddr -#define Count psxRegs.cycle // psxRegs.CP0.n.Count /* COP2/GTE */ enum gte_opcodes { diff --git a/libpcsxcore/new_dynarec/linkage_offsets.h b/libpcsxcore/new_dynarec/linkage_offsets.h index 0c189d78..23935b87 100644 --- a/libpcsxcore/new_dynarec/linkage_offsets.h +++ b/libpcsxcore/new_dynarec/linkage_offsets.h @@ -24,8 +24,10 @@ #define LO_intCycle (LO_interrupt + 4) #define LO_gteBusyCycle (LO_intCycle + 256) #define LO_muldivBusyCycle (LO_gteBusyCycle + 4) -#define LO_psxRegs_reserved (LO_muldivBusyCycle + 4) -#define LO_psxRegs_end (LO_psxRegs_reserved + 4*2) +#define LO_psxRegs_subCycle (LO_muldivBusyCycle + 4) +#define LO_psxRegs_biuReg (LO_psxRegs_subCycle + 4*2) +#define LO_psxRegs_reserved (LO_psxRegs_biuReg + 4) +#define LO_psxRegs_end (LO_psxRegs_reserved + 4*3) #define LO_rcnts (LO_psxRegs_end) #define LO_rcnts_end (LO_rcnts + 7*4*4) #define LO_inv_code_start (LO_rcnts_end) diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index 276ef8af..2673a6ea 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -783,10 +783,10 @@ static void noinline *get_addr(u_int vaddr, int can_compile) return ndrc_get_addr_ht(vaddr); // generate an address error - Status|=2; - Cause=(vaddr<<31)|(4<<2); - EPC=(vaddr&1)?vaddr-5:vaddr; - BadVAddr=(vaddr&~1); + psxRegs.CP0.n.Status |= 2; + psxRegs.CP0.n.Cause = (vaddr<<31) | (4<<2); + psxRegs.CP0.n.EPC = (vaddr&1) ? vaddr-5 : vaddr; + psxRegs.CP0.n.BadVAddr = vaddr & ~1; return ndrc_get_addr_ht(0x80000080); } @@ -3500,7 +3500,7 @@ static void cop0_assemble(int i, const struct regstat *i_regs, int ccadj_) emit_loadreg(CCREG,HOST_CCREG); // TODO: do proper reg alloc emit_add(HOST_CCREG,HOST_TEMPREG,HOST_CCREG); emit_addimm(HOST_CCREG,ccadj_,HOST_CCREG); - emit_writeword(HOST_CCREG,&Count); + emit_writeword(HOST_CCREG,&psxRegs.cycle); } // What a mess. The status register (12) can enable interrupts, // so needs a special case to handle a pending interrupt. @@ -3532,7 +3532,7 @@ static void cop0_assemble(int i, const struct regstat *i_regs, int ccadj_) emit_movimm(copr,0); emit_far_call(pcsx_mtc0); if(copr==9||copr==11||copr==12||copr==13) { - emit_readword(&Count,HOST_CCREG); + emit_readword(&psxRegs.cycle,HOST_CCREG); emit_readword(&next_interupt,HOST_TEMPREG); emit_addimm(HOST_CCREG,-ccadj_,HOST_CCREG); emit_sub(HOST_CCREG,HOST_TEMPREG,HOST_CCREG); @@ -3558,11 +3558,11 @@ static void cop0_assemble(int i, const struct regstat *i_regs, int ccadj_) assert(dops[i].opcode2==0x10); //if((source[i]&0x3f)==0x10) // RFE { - emit_readword(&Status,0); + emit_readword(&psxRegs.CP0.n.Status,0); emit_andimm(0,0x3c,1); emit_andimm(0,~0xf,0); emit_orrshr_imm(1,2,0); - emit_writeword(0,&Status); + emit_writeword(0,&psxRegs.CP0.n.Status); } } } diff --git a/libpcsxcore/new_dynarec/pcsxmem.c b/libpcsxcore/new_dynarec/pcsxmem.c index 69a4c99d..8057b7ed 100644 --- a/libpcsxcore/new_dynarec/pcsxmem.c +++ b/libpcsxcore/new_dynarec/pcsxmem.c @@ -26,6 +26,7 @@ static uintptr_t *mem_readtab; static uintptr_t *mem_writetab; static uintptr_t mem_iortab[(1+2+4) * 0x1000 / 4]; static uintptr_t mem_iowtab[(1+2+4) * 0x1000 / 4]; +static uintptr_t mem_ffrtab[(1+2+4) * 0x1000 / 4]; static uintptr_t mem_ffwtab[(1+2+4) * 0x1000 / 4]; //static uintptr_t mem_unmrtab[(1+2+4) * 0x1000 / 4]; static uintptr_t mem_unmwtab[(1+2+4) * 0x1000 / 4]; @@ -47,22 +48,28 @@ void map_item(uintptr_t *out, const void *h, uintptr_t flag) // size must be power of 2, at least 4k #define map_l1_mem(tab, i, addr, size, base) \ - map_item(&tab[((addr)>>12) + i], (u8 *)(base) - (u32)(addr) - ((i << 12) & ~(size - 1)), 0) + map_item(&tab[((u32)(addr) >> 12) + i], \ + (u8 *)(base) - (u32)((addr) + ((i << 12) & ~(size - 1))), 0) #define IOMEM32(a) (((a) & 0xfff) / 4) #define IOMEM16(a) (0x1000/4 + (((a) & 0xfff) / 2)) #define IOMEM8(a) (0x1000/4 + 0x1000/2 + ((a) & 0xfff)) -u8 zero_mem[0x1000]; +u32 zero_mem[0x1000/4]; +static u32 ffff_mem[0x1000/4]; -u32 read_mem_dummy() +static u32 read_mem_dummy(u32 addr) { - return 0; + // use 'addr' and not 'address', yes the api is weird... + memprintf("unmapped r %08x @%08x %u\n", addr, psxRegs.pc, psxRegs.cycle); + return 0xffffffff; } static void write_mem_dummy(u32 data) { - memprintf("unmapped w %08x, %08x @%08x %u\n", address, data, psxRegs.pc, psxRegs.cycle); + if (!(psxRegs.CP0.n.Status & (1 << 16))) + memprintf("unmapped w %08x, %08x @%08x %u\n", + address, data, psxRegs.pc, psxRegs.cycle); } /* IO handlers */ @@ -239,46 +246,51 @@ static void io_gpu_write_status(u32 value) gpuSyncPluginSR(); } -static void map_ram_write(void) +void new_dyna_pcsx_mem_isolate(int enable) { int i; - for (i = 0; i < (0x800000 >> 12); i++) { - map_l1_mem(mem_writetab, i, 0x80000000, 0x200000, psxM); - map_l1_mem(mem_writetab, i, 0x00000000, 0x200000, psxM); - map_l1_mem(mem_writetab, i, 0xa0000000, 0x200000, psxM); + // note: apparently 0xa0000000 uncached access still works, + // at least read does for sure, so assume write does too + memprintf("mem isolate %d\n", enable); + if (enable) { + for (i = 0; i < (0x800000 >> 12); i++) { + map_item(&mem_writetab[0x80000|i], mem_unmwtab, 1); + map_item(&mem_writetab[0x00000|i], mem_unmwtab, 1); + //map_item(&mem_writetab[0xa0000|i], mem_unmwtab, 1); + } + } + else { + for (i = 0; i < (0x800000 >> 12); i++) { + map_l1_mem(mem_writetab, i, 0x80000000, 0x200000, psxM); + map_l1_mem(mem_writetab, i, 0x00000000, 0x200000, psxM); + map_l1_mem(mem_writetab, i, 0xa0000000, 0x200000, psxM); + } } } -static void unmap_ram_write(void) +static u32 read_biu(u32 addr) { - int i; - - for (i = 0; i < (0x800000 >> 12); i++) { - map_item(&mem_writetab[0x80000|i], mem_unmwtab, 1); - map_item(&mem_writetab[0x00000|i], mem_unmwtab, 1); - map_item(&mem_writetab[0xa0000|i], mem_unmwtab, 1); - } + if (addr != 0xfffe0130) + return read_mem_dummy(addr); + + FILE *f = fopen("/tmp/psxbiu.bin", "wb"); + fwrite(psxM, 1, 0x200000, f); + fclose(f); + memprintf("read_biu %08x @%08x %u\n", + psxRegs.biuReg, psxRegs.pc, psxRegs.cycle); + return psxRegs.biuReg; } static void write_biu(u32 value) { - memprintf("write_biu %08x, %08x @%08x %u\n", address, value, psxRegs.pc, psxRegs.cycle); - - if (address != 0xfffe0130) + if (address != 0xfffe0130) { + write_mem_dummy(value); return; - - switch (value) { - case 0x800: case 0x804: - unmap_ram_write(); - break; - case 0: case 0x1e988: - map_ram_write(); - break; - default: - printf("write_biu: unexpected val: %08x\n", value); - break; } + + memprintf("write_biu %08x @%08x %u\n", value, psxRegs.pc, psxRegs.cycle); + psxRegs.biuReg = value; } void new_dyna_pcsx_mem_load_state(void) @@ -301,6 +313,8 @@ void new_dyna_pcsx_mem_init(void) { int i; + memset(ffff_mem, 0xff, sizeof(ffff_mem)); + // have to map these further to keep tcache close to .text mem_readtab = psxMap(0x08000000, 0x200000 * sizeof(mem_readtab[0]), 0, MAP_TAG_LUTS); if (mem_readtab == NULL) { @@ -319,7 +333,7 @@ void new_dyna_pcsx_mem_init(void) // default/unmapped memhandlers for (i = 0; i < 0x100000; i++) { //map_item(&mem_readtab[i], mem_unmrtab, 1); - map_l1_mem(mem_readtab, i, 0, 0x1000, zero_mem); + map_l1_mem(mem_readtab, i, 0, 0x1000, ffff_mem); map_item(&mem_writetab[i], mem_unmwtab, 1); } @@ -329,7 +343,7 @@ void new_dyna_pcsx_mem_init(void) map_l1_mem(mem_readtab, i, 0x00000000, 0x200000, psxM); map_l1_mem(mem_readtab, i, 0xa0000000, 0x200000, psxM); } - map_ram_write(); + new_dyna_pcsx_mem_isolate(0); // BIOS and it's mirrors for (i = 0; i < (0x80000 >> 12); i++) { @@ -344,12 +358,12 @@ void new_dyna_pcsx_mem_init(void) map_l1_mem(mem_writetab, 0, 0x9f800000, 0x1000, psxH); // I/O - map_item(&mem_readtab[0x1f801000 >> 12], mem_iortab, 1); - map_item(&mem_readtab[0x9f801000 >> 12], mem_iortab, 1); - map_item(&mem_readtab[0xbf801000 >> 12], mem_iortab, 1); - map_item(&mem_writetab[0x1f801000 >> 12], mem_iowtab, 1); - map_item(&mem_writetab[0x9f801000 >> 12], mem_iowtab, 1); - map_item(&mem_writetab[0xbf801000 >> 12], mem_iowtab, 1); + map_item(&mem_readtab[0x1f801000u >> 12], mem_iortab, 1); + map_item(&mem_readtab[0x9f801000u >> 12], mem_iortab, 1); + map_item(&mem_readtab[0xbf801000u >> 12], mem_iortab, 1); + map_item(&mem_writetab[0x1f801000u >> 12], mem_iowtab, 1); + map_item(&mem_writetab[0x9f801000u >> 12], mem_iowtab, 1); + map_item(&mem_writetab[0xbf801000u >> 12], mem_iowtab, 1); // L2 // unmapped tables @@ -460,9 +474,12 @@ void new_dyna_pcsx_mem_init(void) } // misc - map_item(&mem_writetab[0xfffe0130 >> 12], mem_ffwtab, 1); - for (i = 0; i < 0x1000/4 + 0x1000/2 + 0x1000; i++) + map_item(&mem_readtab[0xfffe0130u >> 12], mem_ffrtab, 1); + map_item(&mem_writetab[0xfffe0130u >> 12], mem_ffwtab, 1); + for (i = 0; i < 0x1000/4 + 0x1000/2 + 0x1000; i++) { + map_item(&mem_ffrtab[i], read_biu, 1); map_item(&mem_ffwtab[i], write_biu, 1); + } mem_rtab = mem_readtab; mem_wtab = mem_writetab; diff --git a/libpcsxcore/new_dynarec/pcsxmem.h b/libpcsxcore/new_dynarec/pcsxmem.h index 72892a8e..7f8283d1 100644 --- a/libpcsxcore/new_dynarec/pcsxmem.h +++ b/libpcsxcore/new_dynarec/pcsxmem.h @@ -1,9 +1,10 @@ -extern u8 zero_mem[0x1000]; +extern u32 zero_mem[0x1000/4]; void new_dyna_pcsx_mem_init(void); void new_dyna_pcsx_mem_reset(void); void new_dyna_pcsx_mem_load_state(void); +void new_dyna_pcsx_mem_isolate(int enable); void new_dyna_pcsx_mem_shutdown(void); int pcsxmem_is_handler_dynamic(unsigned int addr); diff --git a/libpcsxcore/ppf.c b/libpcsxcore/ppf.c index 18c5413e..454290d0 100644 --- a/libpcsxcore/ppf.c +++ b/libpcsxcore/ppf.c @@ -355,6 +355,8 @@ fail_io: unsigned char *sbi_sectors; int LoadSBI(const char *fname, int sector_count) { + int good_sectors = 0; + int clean_eof = 0; char buffer[16]; FILE *sbihandle; u8 sbitime[3], t; @@ -365,21 +367,33 @@ int LoadSBI(const char *fname, int sector_count) { return -1; sbi_sectors = calloc(1, sector_count / 8); - if (sbi_sectors == NULL) { - fclose(sbihandle); - return -1; - } + if (sbi_sectors == NULL) + goto end; // 4-byte SBI header if (fread(buffer, 1, 4, sbihandle) != 4) - goto fail_io; + goto end; while (1) { s = fread(sbitime, 1, 3, sbihandle); if (s != 3) - goto fail_io; + { + if (s == 0) + clean_eof = 1; + break; + } + s = MSF2SECT(btoi(sbitime[0]), btoi(sbitime[1]), btoi(sbitime[2])); + if (s < sector_count) { + sbi_sectors[s >> 3] |= 1 << (s&7); + good_sectors++; + } + else + SysPrintf(_("SBI sector %d >= %d?\n"), s, sector_count); + + // skip to the next record if (fread(&t, 1, sizeof(t), sbihandle) != sizeof(t)) - goto fail_io; + break; + s = -1; switch (t) { default: case 1: @@ -390,24 +404,24 @@ int LoadSBI(const char *fname, int sector_count) { s = 3; break; } - fseek(sbihandle, s, SEEK_CUR); - - s = MSF2SECT(btoi(sbitime[0]), btoi(sbitime[1]), btoi(sbitime[2])); - if (s < sector_count) - sbi_sectors[s >> 3] |= 1 << (s&7); - else - SysPrintf(_("SBI sector %d >= %d?\n"), s, sector_count); + if (s < 0) + break; + if (fseek(sbihandle, s, SEEK_CUR)) + break; } fclose(sbihandle); return 0; -fail_io: -#ifndef NDEBUG - SysPrintf(_("File IO error in <%s:%s>.\n"), __FILE__, __func__); -#endif +end: + if (!clean_eof) + SysPrintf(_("SBI: parse failure at 0x%lx\n"), ftell(sbihandle)); + if (!good_sectors) { + free(sbi_sectors); + sbi_sectors = NULL; + } fclose(sbihandle); - return -1; + return sbi_sectors ? 0 : -1; } void UnloadSBI(void) { diff --git a/libpcsxcore/psxinterpreter.c b/libpcsxcore/psxinterpreter.c index 3d083645..9ece259c 100644 --- a/libpcsxcore/psxinterpreter.c +++ b/libpcsxcore/psxinterpreter.c @@ -911,7 +911,9 @@ void MTC0(psxRegisters *regs_, int reg, u32 val) { // SysPrintf("MTC0 %d: %x\n", reg, val); switch (reg) { case 12: // Status - regs_->CP0.r[12] = val; + if ((regs_->CP0.n.Status ^ val) & (1 << 16)) + psxMemOnIsolate((val >> 16) & 1); + regs_->CP0.n.Status = val; psxTestSWInts(regs_); break; @@ -1114,7 +1116,7 @@ static void intClear(u32 Addr, u32 Size) { } void intNotify (int note, void *data) { - /* Gameblabla - Only clear the icache if it's isolated */ + /* Armored Core won't boot without this */ if (note == R3000ACPU_NOTIFY_CACHE_ISOLATED) { memset(&ICache, 0xff, sizeof(ICache)); diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c index 37a0efd0..fb48f77b 100644 --- a/libpcsxcore/psxmem.c +++ b/libpcsxcore/psxmem.c @@ -195,8 +195,8 @@ int psxMemInit(void) return -1; } - memset(psxMemRLUT, (uintptr_t)INVALID_PTR, 0x10000 * sizeof(void *)); - memset(psxMemWLUT, (uintptr_t)INVALID_PTR, 0x10000 * sizeof(void *)); + memset(psxMemRLUT, (int)(uintptr_t)INVALID_PTR, 0x10000 * sizeof(void *)); + memset(psxMemWLUT, (int)(uintptr_t)INVALID_PTR, 0x10000 * sizeof(void *)); // MemR for (i = 0; i < 0x80; i++) psxMemRLUT[i + 0x0000] = (u8 *)&psxM[(i & 0x1f) << 16]; @@ -265,7 +265,22 @@ void psxMemShutdown() { free(psxMemWLUT); psxMemWLUT = NULL; } -static int writeok = 1; +void psxMemOnIsolate(int enable) +{ + if (enable) { + memset(psxMemWLUT + 0x0000, (int)(uintptr_t)INVALID_PTR, 0x80 * sizeof(void *)); + memset(psxMemWLUT + 0x8000, (int)(uintptr_t)INVALID_PTR, 0x80 * sizeof(void *)); + //memset(psxMemWLUT + 0xa000, (int)(uintptr_t)INVALID_PTR, 0x80 * sizeof(void *)); + } else { + int i; + for (i = 0; i < 0x80; i++) + psxMemWLUT[i + 0x0000] = (void *)&psxM[(i & 0x1f) << 16]; + memcpy(psxMemWLUT + 0x8000, psxMemWLUT, 0x80 * sizeof(void *)); + memcpy(psxMemWLUT + 0xa000, psxMemWLUT, 0x80 * sizeof(void *)); + } + psxCpu->Notify(enable ? R3000ACPU_NOTIFY_CACHE_ISOLATED + : R3000ACPU_NOTIFY_CACHE_UNISOLATED, NULL); +} u8 psxMemRead8(u32 mem) { char *p; @@ -334,8 +349,10 @@ u32 psxMemRead32(u32 mem) { DebugCheckBP((mem & 0xffffff) | 0x80000000, R4); return SWAPu32(*(u32 *)(p + (mem & 0xffff))); } else { + if (mem == 0xfffe0130) + return psxRegs.biuReg; #ifdef PSXMEM_LOG - if (writeok) { PSXMEM_LOG("err lw %8.8lx\n", mem); } + PSXMEM_LOG("err lw %8.8lx\n", mem); #endif return 0xFFFFFFFF; } @@ -417,44 +434,13 @@ void psxMemWrite32(u32 mem, u32 value) { psxCpu->Clear(mem, 1); #endif } else { - if (mem != 0xfffe0130) { -#ifndef DRC_DISABLE - if (!writeok) - psxCpu->Clear(mem, 1); -#endif - -#ifdef PSXMEM_LOG - if (writeok) { PSXMEM_LOG("err sw %8.8lx\n", mem); } -#endif - } else { - int i; - - switch (value) { - case 0x800: case 0x804: - if (writeok == 0) break; - writeok = 0; - memset(psxMemWLUT + 0x0000, (uintptr_t)INVALID_PTR, 0x80 * sizeof(void *)); - memset(psxMemWLUT + 0x8000, (uintptr_t)INVALID_PTR, 0x80 * sizeof(void *)); - memset(psxMemWLUT + 0xa000, (uintptr_t)INVALID_PTR, 0x80 * sizeof(void *)); - /* Required for icache interpreter otherwise Armored Core won't boot on icache interpreter */ - psxCpu->Notify(R3000ACPU_NOTIFY_CACHE_ISOLATED, NULL); - break; - case 0x00: case 0x1e988: - if (writeok == 1) break; - writeok = 1; - for (i = 0; i < 0x80; i++) psxMemWLUT[i + 0x0000] = (void *)&psxM[(i & 0x1f) << 16]; - memcpy(psxMemWLUT + 0x8000, psxMemWLUT, 0x80 * sizeof(void *)); - memcpy(psxMemWLUT + 0xa000, psxMemWLUT, 0x80 * sizeof(void *)); - /* Dynarecs might take this opportunity to flush their code cache */ - psxCpu->Notify(R3000ACPU_NOTIFY_CACHE_UNISOLATED, NULL); - break; - default: + if (mem == 0xfffe0130) { + psxRegs.biuReg = value; + return; + } #ifdef PSXMEM_LOG - PSXMEM_LOG("unk %8.8lx = %x\n", mem, value); + PSXMEM_LOG("err sw %8.8lx\n", mem); #endif - break; - } - } } } } diff --git a/libpcsxcore/psxmem.h b/libpcsxcore/psxmem.h index 14ff0033..129973cf 100644 --- a/libpcsxcore/psxmem.h +++ b/libpcsxcore/psxmem.h @@ -127,6 +127,7 @@ extern u8 **psxMemRLUT; int psxMemInit(); void psxMemReset(); +void psxMemOnIsolate(int enable); void psxMemShutdown(); u8 psxMemRead8 (u32 mem); diff --git a/libpcsxcore/r3000a.h b/libpcsxcore/r3000a.h index 2339d595..6973afe8 100644 --- a/libpcsxcore/r3000a.h +++ b/libpcsxcore/r3000a.h @@ -32,7 +32,6 @@ extern "C" { enum { R3000ACPU_NOTIFY_CACHE_ISOLATED = 0, R3000ACPU_NOTIFY_CACHE_UNISOLATED = 1, - R3000ACPU_NOTIFY_DMA3_EXE_LOAD = 2 }; typedef struct { @@ -193,6 +192,8 @@ typedef struct { u32 muldivBusyCycle; u32 subCycle; /* interpreter cycle counting */ u32 subCycleStep; + u32 biuReg; + u32 reserved[3]; // warning: changing anything in psxRegisters requires update of all // asm in libpcsxcore/new_dynarec/ } psxRegisters; diff --git a/plugins/dfsound/dma.c b/plugins/dfsound/dma.c index 43019f1d..eb85a731 100644 --- a/plugins/dfsound/dma.c +++ b/plugins/dfsound/dma.c @@ -20,6 +20,7 @@ #define _IN_DMA #include "externals.h" +#include "registers.h" //////////////////////////////////////////////////////////////////////// // READ DMA (one value) @@ -28,6 +29,7 @@ unsigned short CALLBACK SPUreadDMA(void) { unsigned short s = *(unsigned short *)(spu.spuMemC + spu.spuAddr); + check_irq_io(spu.spuAddr); spu.spuAddr += 2; spu.spuAddr &= 0x7fffe; @@ -41,26 +43,27 @@ unsigned short CALLBACK SPUreadDMA(void) void CALLBACK SPUreadDMAMem(unsigned short *pusPSXMem, int iSize, unsigned int cycles) { - int i; + unsigned int addr = spu.spuAddr, irq_addr = regAreaGet(H_SPUirqAddr) << 3; + int i, irq; do_samples_if_needed(cycles, 1); - - for(i=0;i freq change in simple interpolation mode: set flag + spu.s_chan[ch].bNewPitch = 1; // don't mess spu.dwChannelsAudible as adsr runs independently } diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 1127cd71..ebebd2a2 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -18,8 +18,7 @@ * * ***************************************************************************/ -#if !defined(_WIN32) && !defined(NO_OS) -#include // gettimeofday in xa.c +#if !defined(THREAD_ENABLED) && !defined(_WIN32) && !defined(NO_OS) #define THREAD_ENABLED 1 #endif #include "stdafx.h" @@ -212,7 +211,7 @@ static void do_irq(void) static int check_irq(int ch, unsigned char *pos) { - if((spu.spuCtrl & CTRL_IRQ) && pos == spu.pSpuIrq) + if((spu.spuCtrl & (CTRL_ON|CTRL_IRQ)) == (CTRL_ON|CTRL_IRQ) && pos == spu.pSpuIrq) { //printf("ch%d irq %04x\n", ch, pos - spu.spuMemC); do_irq(); @@ -221,6 +220,17 @@ static int check_irq(int ch, unsigned char *pos) return 0; } +void check_irq_io(unsigned int addr) +{ + unsigned int irq_addr = regAreaGet(H_SPUirqAddr) << 3; + //addr &= ~7; // ? + if((spu.spuCtrl & (CTRL_ON|CTRL_IRQ)) == (CTRL_ON|CTRL_IRQ) && addr == irq_addr) + { + //printf("io irq %04x\n", irq_addr); + do_irq(); + } +} + //////////////////////////////////////////////////////////////////////// // START SOUND... called by main thread to setup a new sound on a channel //////////////////////////////////////////////////////////////////////// @@ -275,9 +285,8 @@ INLINE int FModChangeFrequency(int *SB, int pitch, int ns) if(NP<0x1) NP=0x1; sinc=NP<<4; // calc frequency - if(spu_config.iUseInterpolation==1) // freq change in simple interpolation mode - SB[32]=1; iFMod[ns]=0; + SB[32]=1; // reset interpolation return sinc; } @@ -769,6 +778,9 @@ static void do_channels(int ns_to) s_chan = &spu.s_chan[ch]; SB = spu.SB + ch * SB_SIZE; sinc = s_chan->sinc; + if (spu.s_chan[ch].bNewPitch) + SB[32] = 1; // reset interpolation + spu.s_chan[ch].bNewPitch = 0; if (s_chan->bNoise) d = do_samples_noise(ch, ns_to); @@ -857,11 +869,14 @@ static struct spu_worker { int sinc; int start; int loop; - int ns_to; short vol_l; short vol_r; + unsigned short ns_to; + unsigned short bNoise:1; + unsigned short bFMod:2; + unsigned short bRVBActive:1; + unsigned short bNewPitch:1; ADSRInfoEx adsr; - // might also want to add fmod flags.. } ch[24]; int SSumLR[NSSIZE * 2]; } i[4]; @@ -939,6 +954,10 @@ static void queue_channel_work(int ns_to, unsigned int silentch) work->ch[ch].vol_r = s_chan->iRightVolume; work->ch[ch].start = s_chan->pCurr - spu.spuMemC; work->ch[ch].loop = s_chan->pLoop - spu.spuMemC; + work->ch[ch].bNoise = s_chan->bNoise; + work->ch[ch].bFMod = s_chan->bFMod; + work->ch[ch].bRVBActive = s_chan->bRVBActive; + work->ch[ch].bNewPitch = s_chan->bNewPitch; if (s_chan->prevflags & 1) work->ch[ch].start = work->ch[ch].loop; @@ -952,6 +971,7 @@ static void queue_channel_work(int ns_to, unsigned int silentch) s_chan->ADSRX.State = ADSR_RELEASE; s_chan->ADSRX.EnvelopeVol = 0; } + s_chan->bNewPitch = 0; } work->rvb_addr = 0; @@ -971,8 +991,6 @@ static void queue_channel_work(int ns_to, unsigned int silentch) static void do_channel_work(struct work_item *work) { unsigned int mask; - unsigned int decode_dirty_ch = 0; - const SPUCHAN *s_chan; int *SB, sinc, spos, sbpos; int d, ch, ns_to; @@ -997,15 +1015,16 @@ static void do_channel_work(struct work_item *work) sbpos = work->ch[ch].sbpos; sinc = work->ch[ch].sinc; - s_chan = &spu.s_chan[ch]; SB = spu.SB + ch * SB_SIZE; + if (work->ch[ch].bNewPitch) + SB[32] = 1; // reset interpolation - if (s_chan->bNoise) + if (work->ch[ch].bNoise) do_lsfr_samples(d, work->ctrl, &spu.dwNoiseCount, &spu.dwNoiseVal); - else if (s_chan->bFMod == 2 - || (s_chan->bFMod == 0 && spu_config.iUseInterpolation == 0)) + else if (work->ch[ch].bFMod == 2 + || (work->ch[ch].bFMod == 0 && spu_config.iUseInterpolation == 0)) do_samples_noint(decode_block_work, work, ch, d, SB, sinc, &spos, &sbpos); - else if (s_chan->bFMod == 0 && spu_config.iUseInterpolation == 1) + else if (work->ch[ch].bFMod == 0 && spu_config.iUseInterpolation == 1) do_samples_simple(decode_block_work, work, ch, d, SB, sinc, &spos, &sbpos); else do_samples_default(decode_block_work, work, ch, d, SB, sinc, &spos, &sbpos); @@ -1017,14 +1036,11 @@ static void do_channel_work(struct work_item *work) } if (ch == 1 || ch == 3) - { - do_decode_bufs(spu.spuMem, ch/2, ns_to, work->decode_pos); - decode_dirty_ch |= 1 << ch; - } + do_decode_bufs(spu.spuMem, ch/2, ns_to, work->decode_pos); - if (s_chan->bFMod == 2) // fmod freq channel + if (work->ch[ch].bFMod == 2) // fmod freq channel memcpy(iFMod, &ChanBuf, ns_to * sizeof(iFMod[0])); - if (s_chan->bRVBActive && work->rvb_addr) + if (work->ch[ch].bRVBActive && work->rvb_addr) mix_chan_rvb(work->SSumLR, ns_to, work->ch[ch].vol_l, work->ch[ch].vol_r, RVB); else @@ -1136,6 +1152,7 @@ void do_samples(unsigned int cycles_to, int do_direct) do_irq(); } } + check_irq_io(spu.spuAddr); if (unlikely(spu.rvb->dirty)) REVERBPrep(); @@ -1146,6 +1163,7 @@ void do_samples(unsigned int cycles_to, int do_direct) } else { queue_channel_work(ns_to, silentch); + //sync_worker_thread(1); // uncomment for debug } // advance "stopped" channels that can cause irqs diff --git a/plugins/gpu-gles/gpuDraw.c b/plugins/gpu-gles/gpuDraw.c index c49eac5f..d6670ee2 100644 --- a/plugins/gpu-gles/gpuDraw.c +++ b/plugins/gpu-gles/gpuDraw.c @@ -111,7 +111,7 @@ BOOL bCheckMask=FALSE; int iUseMask=0; int iSetMask=0; unsigned short sSetMask=0; -unsigned long lSetMask=0; +unsigned int lSetMask=0; // drawing/coord vars @@ -921,14 +921,14 @@ void offsetST(void) ///////////////////////////////////////////////////////// -void offsetScreenUpload(long Position) +void offsetScreenUpload(int Position) { if(bDisplayNotSet) SetOGLDisplaySettings(1); if(Position==-1) { - long lmdx,lmdy; + int lmdx,lmdy; lmdx=xrUploadArea.x0; lmdy=xrUploadArea.y0; diff --git a/plugins/gpu-gles/gpuDraw.h b/plugins/gpu-gles/gpuDraw.h index a45bf462..153e1e50 100644 --- a/plugins/gpu-gles/gpuDraw.h +++ b/plugins/gpu-gles/gpuDraw.h @@ -64,7 +64,7 @@ unsigned short offsetline(void); #endif void offsetST(void); void offsetBlk(void); -void offsetScreenUpload(long Position); +void offsetScreenUpload(int Position); void assignTexture3(void); void assignTexture4(void); void assignTextureSprite(void); diff --git a/plugins/gpu-gles/gpuExternals.h b/plugins/gpu-gles/gpuExternals.h index 0a8acf59..a6dbceb2 100644 --- a/plugins/gpu-gles/gpuExternals.h +++ b/plugins/gpu-gles/gpuExternals.h @@ -143,10 +143,10 @@ extern void ( APIENTRY * glPixelStorei )(GLenum pname, GLint param); #define bool unsigned short #endif #define LOWORD(l) ((unsigned short)(l)) -#define HIWORD(l) ((unsigned short)(((unsigned long)(l) >> 16) & 0xFFFF)) +#define HIWORD(l) ((unsigned short)(((unsigned int)(l) >> 16) & 0xFFFF)) #define max(a,b) (((a) > (b)) ? (a) : (b)) #define min(a,b) (((a) < (b)) ? (a) : (b)) -#define DWORD unsigned long +#define DWORD unsigned int typedef struct RECTTAG { @@ -173,8 +173,8 @@ typedef struct VRAMLOADTAG typedef struct PSXPOINTTAG { - long x; - long y; + int x; + int y; } PSXPoint_t; typedef struct PSXSPOINTTAG @@ -211,19 +211,19 @@ typedef struct PSXDISPLAYTAG PSXPoint_t DisplayPosition; PSXPoint_t DisplayEnd; - long Double; - long Height; - long PAL; - long InterlacedNew; - long Interlaced; - long InterlacedTest; - long RGB24New; - long RGB24; + int Double; + int Height; + int PAL; + int InterlacedNew; + int Interlaced; + int InterlacedTest; + int RGB24New; + int RGB24; PSXSPoint_t DrawOffset; PSXRect_t DrawArea; PSXPoint_t GDrawOffset; PSXPoint_t CumulOffset; - long Disabled; + int Disabled; PSXRect_t Range; } PSXDisplay_t; @@ -242,7 +242,7 @@ typedef struct OGLVertexTag COLTAG { unsigned char col[4]; - unsigned long lcol; + unsigned int lcol; } c; } OGLVertex; @@ -256,7 +256,7 @@ typedef union EXShortTag typedef union EXLongTag { unsigned char c[4]; - unsigned long l; + unsigned int l; EXShort s[2]; } EXLong; @@ -299,7 +299,7 @@ extern int iSetMask; extern int iDepthFunc; extern BOOL bCheckMask; extern unsigned short sSetMask; -extern unsigned long lSetMask; +extern unsigned int lSetMask; extern BOOL bSetClip; extern GLuint gTexScanName; @@ -309,8 +309,8 @@ extern GLuint gTexScanName; #ifndef _IN_SOFT -extern long GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP; -extern long GlobalTextREST,GlobalTextABR,GlobalTextPAGE; +extern int GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP; +extern int GlobalTextREST,GlobalTextABR,GlobalTextPAGE; extern short ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3; extern short g_m1; extern short g_m2; @@ -347,22 +347,22 @@ extern GLubyte ubGloAlpha; extern short sSprite_ux2; extern short sSprite_vy2; extern BOOL bRenderFrontBuffer; -extern unsigned long ulOLDCOL; -extern unsigned long ulClutID; +extern unsigned int ulOLDCOL; +extern unsigned int ulClutID; extern void (*primTableJ[256])(unsigned char *); extern void (*primTableSkip[256])(unsigned char *); extern unsigned short usMirror; -extern unsigned long dwCfgFixes; -extern unsigned long dwActFixes; -extern unsigned long dwEmuFixes; +extern unsigned int dwCfgFixes; +extern unsigned int dwActFixes; +extern unsigned int dwEmuFixes; extern BOOL bUseFixes; extern int iSpriteTex; extern int iDrawnSomething; -extern long drawX; -extern long drawY; -extern long drawW; -extern long drawH; +extern int drawX; +extern int drawY; +extern int drawW; +extern int drawH; extern short sxmin; extern short sxmax; extern short symin; @@ -383,10 +383,10 @@ extern GLint giWantedRGBA; extern GLint giWantedFMT; extern GLint giWantedTYPE; extern void (*LoadSubTexFn) (int,int,short,short); -extern long GlobalTexturePage; -extern unsigned long (*TCF[]) (unsigned long); +extern int GlobalTexturePage; +extern unsigned int (*TCF[]) (unsigned int ); extern unsigned short (*PTCF[]) (unsigned short); -extern unsigned long (*PalTexturedColourFn) (unsigned long); +extern unsigned int (*PalTexturedColourFn) (unsigned int); extern BOOL bUseFastMdec; extern BOOL bUse15bitMdec; extern int iFrameTexType; @@ -420,32 +420,32 @@ extern char szDispBuf[]; extern char szGPUKeys[]; extern PSXDisplay_t PSXDisplay; extern PSXDisplay_t PreviousPSXDisplay; -//extern unsigned long ulKeybits; +//extern unsigned int ulKeybits; extern TWin_t TWin; extern BOOL bDisplayNotSet; -extern long lGPUstatusRet; +extern int lGPUstatusRet; extern short imageX0,imageX1; extern short imageY0,imageY1; -extern long lClearOnSwap,lClearOnSwapColor; +extern int lClearOnSwap,lClearOnSwapColor; extern unsigned char * psxVub; extern char * psxVsb; extern unsigned short * psxVuw; extern signed short * psxVsw; -extern unsigned long * psxVul; -extern signed long * psxVsl; +extern unsigned int * psxVul; +extern signed int * psxVsl; extern GLfloat gl_z; extern BOOL bNeedRGB24Update; extern BOOL bChangeWinMode; extern GLuint uiScanLine; extern int iUseScanLines; -extern long lSelectedSlot; +extern int lSelectedSlot; extern int iScanBlend; extern BOOL bInitCap; extern int iBlurBuffer; extern int iLastRGB24; extern int iRenderFVR; extern int iNoScreenSaver; -extern unsigned long ulGPUInfoVals[]; +extern unsigned int ulGPUInfoVals[]; extern BOOL bNeedInterlaceUpdate; extern BOOL bNeedWriteUpload; extern BOOL bSkipNextFrame; @@ -461,7 +461,7 @@ extern int bFullScreen; #ifndef _IN_MENU -//extern unsigned long dwCoreFlags; +//extern unsigned int dwCoreFlags; extern GLuint gTexPicName; //extern PSXPoint_t ptCursorPoint[]; //extern unsigned short usCursorActive; @@ -539,7 +539,7 @@ typedef struct { #ifndef _IN_KEY -//extern unsigned long ulKeybits; +//extern unsigned int ulKeybits; #endif @@ -547,7 +547,7 @@ typedef struct { #ifndef _IN_ZN -extern unsigned long dwGPUVersion; +extern unsigned int dwGPUVersion; extern int iGPUHeight; extern int iGPUHeightMask; extern int GlobalTextIL; diff --git a/plugins/gpu-gles/gpuPrim.c b/plugins/gpu-gles/gpuPrim.c index 218ff66d..ed16e4a9 100644 --- a/plugins/gpu-gles/gpuPrim.c +++ b/plugins/gpu-gles/gpuPrim.c @@ -77,15 +77,15 @@ BOOL bUsingMovie=FALSE; // movie active flag PSXRect_t xrMovieArea; // rect for movie upload short sSprite_ux2; // needed for sprire adjust short sSprite_vy2; // -unsigned long ulOLDCOL=0; // active color -unsigned long ulClutID; // clut +unsigned int ulOLDCOL=0; // active color +unsigned int ulClutID; // clut -unsigned long dwCfgFixes; // game fixes -unsigned long dwActFixes=0; -unsigned long dwEmuFixes=0; +unsigned int dwCfgFixes; // game fixes +unsigned int dwActFixes=0; +unsigned int dwEmuFixes=0; BOOL bUseFixes; -long drawX,drawY,drawW,drawH; // offscreen drawing checkers +int drawX,drawY,drawW,drawH; // offscreen drawing checkers short sxmin,sxmax,symin,symax; unsigned int CSVERTEX=0,CSCOLOR=0,CSTEXTURE=0; @@ -147,9 +147,9 @@ void UpdateGlobalTP(unsigned short gdata) //////////////////////////////////////////////////////////////////////// -unsigned long DoubleBGR2RGB (unsigned long BGR) +unsigned int DoubleBGR2RGB (unsigned int BGR) { - unsigned long ebx,eax,edx; + unsigned int ebx,eax,edx; ebx=(BGR&0x000000ff)<<1; if(ebx&0x00000100) ebx=0x000000ff; @@ -163,7 +163,7 @@ unsigned long DoubleBGR2RGB (unsigned long BGR) return (ebx|eax|edx); } -unsigned short BGR24to16 (unsigned long BGR) +unsigned short BGR24to16 (unsigned int BGR) { return ((BGR>>3)&0x1f)|((BGR&0xf80000)>>9)|((BGR&0xf800)>>6); } @@ -947,7 +947,7 @@ void SetZMask3NT(void) //////////////////////////////////////////////////////////////////////// - void SetRenderState(unsigned long DrawAttributes) + void SetRenderState(unsigned int DrawAttributes) { bDrawNonShaded = (SHADETEXBIT(DrawAttributes)) ? TRUE : FALSE; DrawSemiTrans = (SEMITRANSBIT(DrawAttributes)) ? TRUE : FALSE; @@ -955,7 +955,7 @@ void SetZMask3NT(void) //////////////////////////////////////////////////////////////////////// - void SetRenderColor(unsigned long DrawAttributes) + void SetRenderColor(unsigned int DrawAttributes) { if(bDrawNonShaded) {g_m1=g_m2=g_m3=128;} else @@ -968,7 +968,7 @@ void SetZMask3NT(void) //////////////////////////////////////////////////////////////////////// -void SetRenderMode(unsigned long DrawAttributes,BOOL bSCol) +void SetRenderMode(unsigned int DrawAttributes,BOOL bSCol) { if((bUseMultiPass) && (bDrawTextured) && !(bDrawNonShaded)) {bDrawMultiPass = TRUE; SetSemiTransMulti(0);} @@ -1024,7 +1024,7 @@ void SetRenderMode(unsigned long DrawAttributes,BOOL bSCol) // Set Opaque multipass color //////////////////////////////////////////////////////////////////////// -void SetOpaqueColor(unsigned long DrawAttributes) +void SetOpaqueColor(unsigned int DrawAttributes) { if(bDrawNonShaded) return; // no shading? bye @@ -1399,7 +1399,7 @@ BOOL CheckAgainstFrontScreen(short imageX0,short imageY0,short imageX1,short ima //////////////////////////////////////////////////////////////////////// -void PrepareFullScreenUpload (long Position) +void PrepareFullScreenUpload (int Position) { if (Position==-1) // rgb24 { @@ -1481,7 +1481,7 @@ void PrepareFullScreenUpload (long Position) unsigned char * LoadDirectMovieFast(void); -void UploadScreenEx(long Position) +void UploadScreenEx(int Position) { short ya,yb,xa,xb,x, y, YStep, XStep, U, UStep,ux[4],vy[4]; @@ -1565,7 +1565,7 @@ void UploadScreenEx(long Position) //////////////////////////////////////////////////////////////////////// -void UploadScreen(long Position) +void UploadScreen(int Position) { short x, y, YStep, XStep, U, s, UStep,ux[4],vy[4]; short xa,xb,ya,yb; @@ -1646,8 +1646,8 @@ void UploadScreen(long Position) gl_vy[2] = gl_vy[3] = s; gl_ux[0] = gl_ux[3] = gl_vy[0] = gl_vy[1] = 0; - SetRenderState((unsigned long)0x01000000); - SetRenderMode((unsigned long)0x01000000, FALSE); // upload texture data + SetRenderState((unsigned int)0x01000000); + SetRenderMode((unsigned int)0x01000000, FALSE); // upload texture data offsetScreenUpload(Position); assignTextureVRAMWrite(); @@ -1712,7 +1712,7 @@ BOOL IsInsideNextScreen(short x, short y, short xoff, short yoff) void cmdSTP(unsigned char * baseAddr) { - unsigned long gdata = ((unsigned long*)baseAddr)[0]; + unsigned int gdata = ((unsigned int*)baseAddr)[0]; STATUSREG&=~0x1800; // clear the necessary bits STATUSREG|=((gdata & 0x03) << 11); // set the current bits @@ -1745,7 +1745,7 @@ void cmdSTP(unsigned char * baseAddr) void cmdTexturePage(unsigned char * baseAddr) { - unsigned long gdata = ((unsigned long*)baseAddr)[0]; + unsigned int gdata = ((unsigned int*)baseAddr)[0]; UpdateGlobalTP((unsigned short)gdata); GlobalTextREST = (gdata&0x00ffffff)>>9; } @@ -1756,9 +1756,9 @@ void cmdTexturePage(unsigned char * baseAddr) void cmdTextureWindow(unsigned char *baseAddr) { - unsigned long gdata = ((unsigned long*)baseAddr)[0]; + unsigned int gdata = ((unsigned int*)baseAddr)[0]; - unsigned long YAlign,XAlign; + unsigned int YAlign,XAlign; ulGPUInfoVals[INFO_TW]=gdata&0xFFFFF; @@ -1792,8 +1792,8 @@ void cmdTextureWindow(unsigned char *baseAddr) // Re-calculate the bit field, because we can't trust what is passed in the data - YAlign = (unsigned long)(32 - (TWin.Position.y1 >> 3)); - XAlign = (unsigned long)(32 - (TWin.Position.x1 >> 3)); + YAlign = (unsigned int)(32 - (TWin.Position.y1 >> 3)); + XAlign = (unsigned int)(32 - (TWin.Position.x1 >> 3)); // Absolute position of the start of the texture window @@ -1965,7 +1965,7 @@ void ClampToPSXScreenOffset(short *x0, short *y0, short *x1, short *y1) void cmdDrawAreaStart(unsigned char * baseAddr) { - unsigned long gdata = ((unsigned long*)baseAddr)[0]; + unsigned int gdata = ((unsigned int*)baseAddr)[0]; drawX = gdata & 0x3ff; // for soft drawing if(drawX>=1024) drawX=1023; @@ -1996,7 +1996,7 @@ void cmdDrawAreaStart(unsigned char * baseAddr) void cmdDrawAreaEnd(unsigned char * baseAddr) { - unsigned long gdata = ((unsigned long*)baseAddr)[0]; + unsigned int gdata = ((unsigned int*)baseAddr)[0]; drawW = gdata & 0x3ff; // for soft drawing if(drawW>=1024) drawW=1023; @@ -2031,7 +2031,7 @@ void cmdDrawAreaEnd(unsigned char * baseAddr) void cmdDrawOffset(unsigned char * baseAddr) { - unsigned long gdata = ((unsigned long*)baseAddr)[0]; + unsigned int gdata = ((unsigned int*)baseAddr)[0]; PreviousPSXDisplay.DrawOffset.x = PSXDisplay.DrawOffset.x = (short)(gdata & 0x7ff); @@ -2241,7 +2241,7 @@ void primStoreImage(unsigned char * baseAddr) void primBlkFill(unsigned char * baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); iDrawnSomething=1; @@ -2292,8 +2292,8 @@ void primBlkFill(unsigned char * baseAddr) { bDrawTextured = FALSE; bDrawSmoothShaded = FALSE; - SetRenderState((unsigned long)0x01000000); - SetRenderMode((unsigned long)0x01000000, FALSE); + SetRenderState((unsigned int)0x01000000); + SetRenderMode((unsigned int)0x01000000, FALSE); vertex[0].c.lcol=0xff000000; SETCOL(vertex[0]); if(ly0>pd->DisplayPosition.y) @@ -2320,8 +2320,8 @@ void primBlkFill(unsigned char * baseAddr) { bDrawTextured = FALSE; bDrawSmoothShaded = FALSE; - SetRenderState((unsigned long)0x01000000); - SetRenderMode((unsigned long)0x01000000, FALSE); + SetRenderState((unsigned int)0x01000000); + SetRenderMode((unsigned int)0x01000000, FALSE); vertex[0].c.lcol=gpuData[0]|0xff000000; SETCOL(vertex[0]); //glDisable(GL_SCISSOR_TEST); glError(); @@ -2491,12 +2491,12 @@ void primMoveImage(unsigned char * baseAddr) } else { - unsigned long *SRCPtr, *DSTPtr; + unsigned int *SRCPtr, *DSTPtr; unsigned short LineOffset; int dx=imageSX>>1; - SRCPtr = (unsigned long *)(psxVuw + (1024*imageY0) + imageX0); - DSTPtr = (unsigned long *)(psxVuw + (1024*imageY1) + imageX1); + SRCPtr = (unsigned int *)(psxVuw + (1024*imageY0) + imageX0); + DSTPtr = (unsigned int *)(psxVuw + (1024*imageY1) + imageX1); LineOffset = 512 - dx; @@ -2597,7 +2597,7 @@ void primMoveImage(unsigned char * baseAddr) void primTileS(unsigned char * baseAddr) { - unsigned long *gpuData = ((unsigned long*)baseAddr); + unsigned int *gpuData = ((unsigned int*)baseAddr); short *sgpuData = ((short *) baseAddr); sprtX = sgpuData[2]; @@ -2662,7 +2662,7 @@ void primTileS(unsigned char * baseAddr) void primTile1(unsigned char * baseAddr) { - unsigned long *gpuData = ((unsigned long*)baseAddr); + unsigned int *gpuData = ((unsigned int*)baseAddr); short *sgpuData = ((short *) baseAddr); sprtX = sgpuData[2]; @@ -2709,7 +2709,7 @@ void primTile1(unsigned char * baseAddr) void primTile8(unsigned char * baseAddr) { - unsigned long *gpuData = ((unsigned long*)baseAddr); + unsigned int *gpuData = ((unsigned int*)baseAddr); short *sgpuData = ((short *) baseAddr); sprtX = sgpuData[2]; @@ -2756,7 +2756,7 @@ void primTile8(unsigned char * baseAddr) void primTile16(unsigned char * baseAddr) { - unsigned long *gpuData = ((unsigned long*)baseAddr); + unsigned int *gpuData = ((unsigned int*)baseAddr); short *sgpuData = ((short *) baseAddr); sprtX = sgpuData[2]; @@ -2803,7 +2803,7 @@ void primTile16(unsigned char * baseAddr) /*void DrawMultiBlur(void) { - long lABR,lDST;float fx,fy; + int lABR,lDST;float fx,fy; lABR=GlobalTextABR; lDST=DrawSemiTrans; @@ -2836,7 +2836,7 @@ void primTile16(unsigned char * baseAddr) void DrawMultiFilterSprite(void) { - long lABR,lDST; + int lABR,lDST; if(bUseMultiPass || DrawSemiTrans || ubOpaqueDraw) { @@ -2867,7 +2867,7 @@ void DrawMultiFilterSprite(void) void primSprt8(unsigned char * baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); short s; @@ -2988,7 +2988,7 @@ void primSprt8(unsigned char * baseAddr) void primSprt16(unsigned char * baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); short s; @@ -3108,7 +3108,7 @@ void primSprt16(unsigned char * baseAddr) void primSprtSRest(unsigned char * baseAddr,unsigned short type) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); short s;unsigned short sTypeRest=0; @@ -3279,7 +3279,7 @@ void primSprtSRest(unsigned char * baseAddr,unsigned short type) void primSprtS(unsigned char * baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); short s;unsigned short sTypeRest=0; @@ -3418,7 +3418,7 @@ void primSprtS(unsigned char * baseAddr) void primPolyF4(unsigned char *baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); lx0 = sgpuData[2]; @@ -3513,7 +3513,7 @@ BOOL bCheckFF9G4(unsigned char * baseAddr) if(iFF9Fix==2) { - long labr=GlobalTextABR; + int labr=GlobalTextABR; GlobalTextABR=1; primPolyG4(pFF9G4Cache); GlobalTextABR=labr; @@ -3527,7 +3527,7 @@ BOOL bCheckFF9G4(unsigned char * baseAddr) void primPolyG4(unsigned char * baseAddr) { - unsigned long *gpuData = (unsigned long *)baseAddr; + unsigned int *gpuData = (unsigned int *)baseAddr; short *sgpuData = ((short *) baseAddr); lx0 = sgpuData[2]; @@ -3578,7 +3578,7 @@ void primPolyG4(unsigned char * baseAddr) // cmd: flat shaded Texture3 //////////////////////////////////////////////////////////////////////// -BOOL DoLineCheck(unsigned long * gpuData) +BOOL DoLineCheck(unsigned int * gpuData) { BOOL bQuad=FALSE;short dx,dy; @@ -3745,7 +3745,7 @@ BOOL DoLineCheck(unsigned long * gpuData) void primPolyFT3(unsigned char * baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); lx0 = sgpuData[2]; @@ -4181,7 +4181,7 @@ void RectTexAlign(void) void primPolyFT4(unsigned char * baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); lx0 = sgpuData[2]; @@ -4269,7 +4269,7 @@ void primPolyFT4(unsigned char * baseAddr) void primPolyGT3(unsigned char *baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); lx0 = sgpuData[2]; @@ -4378,7 +4378,7 @@ void primPolyGT3(unsigned char *baseAddr) void primPolyG3(unsigned char *baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); lx0 = sgpuData[2]; @@ -4423,7 +4423,7 @@ void primPolyG3(unsigned char *baseAddr) void primPolyGT4(unsigned char *baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); lx0 = sgpuData[2]; @@ -4543,7 +4543,7 @@ void primPolyGT4(unsigned char *baseAddr) void primPolyF3(unsigned char *baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); lx0 = sgpuData[2]; @@ -4587,7 +4587,7 @@ void primPolyF3(unsigned char *baseAddr) void primLineGSkip(unsigned char *baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); int iMax=255; int i=2; @@ -4612,7 +4612,7 @@ void primLineGSkip(unsigned char *baseAddr) void primLineGEx(unsigned char *baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); int iMax=255; short cx0,cx1,cy0,cy1;int i;BOOL bDraw=TRUE; @@ -4676,7 +4676,7 @@ void primLineGEx(unsigned char *baseAddr) void primLineG2(unsigned char *baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); lx0 = sgpuData[2]; @@ -4721,7 +4721,7 @@ void primLineG2(unsigned char *baseAddr) void primLineFSkip(unsigned char *baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); int i=2,iMax=255; ly1 = (short)((gpuData[1]>>16) & 0xffff); @@ -4741,7 +4741,7 @@ void primLineFSkip(unsigned char *baseAddr) void primLineFEx(unsigned char *baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); int iMax; short cx0,cx1,cy0,cy1;int i; @@ -4799,7 +4799,7 @@ void primLineFEx(unsigned char *baseAddr) void primLineF2(unsigned char *baseAddr) { - unsigned long *gpuData = ((unsigned long *) baseAddr); + unsigned int *gpuData = ((unsigned int *) baseAddr); short *sgpuData = ((short *) baseAddr); lx0 = sgpuData[2]; diff --git a/plugins/gpu-gles/gpuPrim.h b/plugins/gpu-gles/gpuPrim.h index dc497671..c533acea 100644 --- a/plugins/gpu-gles/gpuPrim.h +++ b/plugins/gpu-gles/gpuPrim.h @@ -39,8 +39,8 @@ extern EGLSurface surface; extern EGLDisplay display; #endif -void UploadScreen (long Position); -void PrepareFullScreenUpload (long Position); +void UploadScreen (int Position); +void PrepareFullScreenUpload (int Position); BOOL CheckAgainstScreen(short imageX0,short imageY0,short imageX1,short imageY1); BOOL CheckAgainstFrontScreen(short imageX0,short imageY0,short imageX1,short imageY1); BOOL FastCheckAgainstScreen(short imageX0,short imageY0,short imageX1,short imageY1); diff --git a/plugins/gpu-gles/gpuTexture.c b/plugins/gpu-gles/gpuTexture.c index 2f96482a..5136682b 100644 --- a/plugins/gpu-gles/gpuTexture.c +++ b/plugins/gpu-gles/gpuTexture.c @@ -88,12 +88,12 @@ GLuint gTexMovieName=0; GLuint gTexBlurName=0; GLuint gTexFrameName=0; int iTexGarbageCollection=1; -unsigned long dwTexPageComp=0; +unsigned int dwTexPageComp=0; int iVRamSize=0; int iClampType=GL_CLAMP_TO_EDGE; int iFilter = GL_LINEAR; void (*LoadSubTexFn) (int,int,short,short); -unsigned long (*PalTexturedColourFn) (unsigned long); +unsigned int (*PalTexturedColourFn) (unsigned int); //////////////////////////////////////////////////////////////////////// // defines @@ -127,7 +127,7 @@ unsigned long (*PalTexturedColourFn) (unsigned long); //////////////////////////////////////////////////////////////////////// -unsigned char * CheckTextureInSubSCache(long TextureMode,unsigned long GivenClutId,unsigned short * pCache); +unsigned char * CheckTextureInSubSCache(int TextureMode,unsigned int GivenClutId,unsigned short * pCache); void LoadSubTexturePageSort(int pageid, int mode, short cx, short cy); void LoadPackedSubTexturePageSort(int pageid, int mode, short cx, short cy); void DefineSubTextureSort(void); @@ -136,7 +136,7 @@ void DefineSubTextureSort(void); // some globals //////////////////////////////////////////////////////////////////////// -long GlobalTexturePage; +int GlobalTexturePage; GLint XTexS; GLint YTexS; GLint DXTexS; @@ -147,7 +147,7 @@ BOOL bUse15bitMdec=FALSE; int iFrameTexType=0; int iFrameReadType=0; -unsigned long (*TCF[2]) (unsigned long); +unsigned int (*TCF[2]) (unsigned int); unsigned short (*PTCF[2]) (unsigned short); //////////////////////////////////////////////////////////////////////// @@ -158,7 +158,7 @@ unsigned short (*PTCF[2]) (unsigned short); typedef struct textureWndCacheEntryTag { - unsigned long ClutID; + unsigned int ClutID; short pageid; short textureMode; short Opaque; @@ -171,7 +171,7 @@ typedef struct textureWndCacheEntryTag typedef struct textureSubCacheEntryTagS { - unsigned long ClutID; + unsigned int ClutID; EXLong pos; unsigned char posTX; unsigned char posTY; @@ -200,7 +200,7 @@ int iTexWndLimit=MAXWNDTEXCACHE/2; GLubyte * texturepart=NULL; GLubyte * texturebuffer=NULL; -unsigned long g_x1,g_y1,g_x2,g_y2; +unsigned int g_x1,g_y1,g_x2,g_y2; unsigned char ubOpaqueDraw=0; unsigned short MAXTPAGES = 32; @@ -213,7 +213,7 @@ unsigned short MAXSORTTEX = 196; // porting... and honestly: nowadays the speed gain would be pointless //////////////////////////////////////////////////////////////////////// -unsigned long XP8RGBA(unsigned long BGR) +unsigned int XP8RGBA(unsigned int BGR) { if(!(BGR&0xffff)) return 0x50000000; if(DrawSemiTrans && !(BGR&0x8000)) @@ -221,7 +221,7 @@ unsigned long XP8RGBA(unsigned long BGR) return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8RGBAEx(unsigned long BGR) +unsigned int XP8RGBAEx(unsigned int BGR) { if(!(BGR&0xffff)) return 0x03000000; if(DrawSemiTrans && !(BGR&0x8000)) @@ -229,9 +229,9 @@ unsigned long XP8RGBAEx(unsigned long BGR) return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long CP8RGBA(unsigned long BGR) +unsigned int CP8RGBA(unsigned int BGR) { - unsigned long l; + unsigned int l; if(!(BGR&0xffff)) return 0x50000000; if(DrawSemiTrans && !(BGR&0x8000)) {ubOpaqueDraw=1;return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff);} @@ -240,9 +240,9 @@ unsigned long CP8RGBA(unsigned long BGR) return l; } -unsigned long CP8RGBAEx(unsigned long BGR) +unsigned int CP8RGBAEx(unsigned int BGR) { - unsigned long l; + unsigned int l; if(!(BGR&0xffff)) return 0x03000000; if(DrawSemiTrans && !(BGR&0x8000)) {ubOpaqueDraw=1;return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff);} @@ -251,33 +251,33 @@ unsigned long CP8RGBAEx(unsigned long BGR) return l; } -unsigned long XP8RGBA_0(unsigned long BGR) +unsigned int XP8RGBA_0(unsigned int BGR) { if(!(BGR&0xffff)) return 0x50000000; return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8RGBAEx_0(unsigned long BGR) +unsigned int XP8RGBAEx_0(unsigned int BGR) { if(!(BGR&0xffff)) return 0x03000000; return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8BGRA_0(unsigned long BGR) +unsigned int XP8BGRA_0(unsigned int BGR) { if(!(BGR&0xffff)) return 0x50000000; return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8BGRAEx_0(unsigned long BGR) +unsigned int XP8BGRAEx_0(unsigned int BGR) { if(!(BGR&0xffff)) return 0x03000000; return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; } -unsigned long CP8RGBA_0(unsigned long BGR) +unsigned int CP8RGBA_0(unsigned int BGR) { - unsigned long l; + unsigned int l; if(!(BGR&0xffff)) return 0x50000000; l=((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; @@ -285,9 +285,9 @@ unsigned long CP8RGBA_0(unsigned long BGR) return l; } -unsigned long CP8RGBAEx_0(unsigned long BGR) +unsigned int CP8RGBAEx_0(unsigned int BGR) { - unsigned long l; + unsigned int l; if(!(BGR&0xffff)) return 0x03000000; l=((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; @@ -295,9 +295,9 @@ unsigned long CP8RGBAEx_0(unsigned long BGR) return l; } -unsigned long CP8BGRA_0(unsigned long BGR) +unsigned int CP8BGRA_0(unsigned int BGR) { - unsigned long l; + unsigned int l; if(!(BGR&0xffff)) return 0x50000000; l=((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; @@ -305,9 +305,9 @@ unsigned long CP8BGRA_0(unsigned long BGR) return l; } -unsigned long CP8BGRAEx_0(unsigned long BGR) +unsigned int CP8BGRAEx_0(unsigned int BGR) { - unsigned long l; + unsigned int l; if(!(BGR&0xffff)) return 0x03000000; l=((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; @@ -315,41 +315,41 @@ unsigned long CP8BGRAEx_0(unsigned long BGR) return l; } -unsigned long XP8RGBA_1(unsigned long BGR) +unsigned int XP8RGBA_1(unsigned int BGR) { if(!(BGR&0xffff)) return 0x50000000; if(!(BGR&0x8000)) {ubOpaqueDraw=1;return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff);} return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8RGBAEx_1(unsigned long BGR) +unsigned int XP8RGBAEx_1(unsigned int BGR) { if(!(BGR&0xffff)) return 0x03000000; if(!(BGR&0x8000)) {ubOpaqueDraw=1;return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff);} return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8BGRA_1(unsigned long BGR) +unsigned int XP8BGRA_1(unsigned int BGR) { if(!(BGR&0xffff)) return 0x50000000; if(!(BGR&0x8000)) {ubOpaqueDraw=1;return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff);} return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8BGRAEx_1(unsigned long BGR) +unsigned int XP8BGRAEx_1(unsigned int BGR) { if(!(BGR&0xffff)) return 0x03000000; if(!(BGR&0x8000)) {ubOpaqueDraw=1;return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff);} return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; } -unsigned long P8RGBA(unsigned long BGR) +unsigned int P8RGBA(unsigned int BGR) { if(!(BGR&0xffff)) return 0; return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long P8BGRA(unsigned long BGR) +unsigned int P8BGRA(unsigned int BGR) { if(!(BGR&0xffff)) return 0; return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; @@ -680,7 +680,7 @@ void ResetTextureArea(BOOL bDelTex) // Invalidate tex windows //////////////////////////////////////////////////////////////////////// -void InvalidateWndTextureArea(long X,long Y,long W, long H) +void InvalidateWndTextureArea(int X,int Y,int W, int H) { int i,px1,px2,py1,py2,iYM=1; textureWndCacheEntry * tsw=wcWndtexStore; @@ -771,11 +771,11 @@ void MarkFree(textureSubCacheEntryS * tsx) } } -void InvalidateSubSTextureArea(long X,long Y,long W, long H) +void InvalidateSubSTextureArea(int X,int Y,int W, int H) { int i,j,k,iMax,px,py,px1,px2,py1,py2,iYM=1; EXLong npos;textureSubCacheEntryS * tsb; - long x1,x2,y1,y2,xa,sw; + int x1,x2,y1,y2,xa,sw; W+=X-1; H+=Y-1; @@ -875,7 +875,7 @@ void InvalidateTextureAreaEx(void) //////////////////////////////////////////////////////////////////////// -void InvalidateTextureArea(long X,long Y,long W, long H) +void InvalidateTextureArea(int X,int Y,int W, int H) { if(W==0 && H==0) return; @@ -920,12 +920,12 @@ void DefineTextureWnd(void) void LoadStretchPackedWndTexturePage(int pageid, int mode, short cx, short cy) { - unsigned long start,row,column,j,sxh,sxm,ldx,ldy,ldxo; + unsigned int start,row,column,j,sxh,sxm,ldx,ldy,ldxo; unsigned int palstart; unsigned short *px,*pa,*ta; unsigned char *cSRCPtr,*cOSRCPtr; unsigned short *wSRCPtr,*wOSRCPtr; - unsigned long LineOffset;unsigned short s; + unsigned int LineOffset;unsigned short s; int pmult=pageid/16; unsigned short (*LPTCOL)(unsigned short); @@ -1112,22 +1112,22 @@ void LoadStretchPackedWndTexturePage(int pageid, int mode, short cx, short cy) void LoadStretchWndTexturePage(int pageid, int mode, short cx, short cy) { - unsigned long start,row,column,j,sxh,sxm,ldx,ldy,ldxo,s; + unsigned int start,row,column,j,sxh,sxm,ldx,ldy,ldxo,s; unsigned int palstart; - unsigned long *px,*pa,*ta; + unsigned int *px,*pa,*ta; unsigned char *cSRCPtr,*cOSRCPtr; unsigned short *wSRCPtr,*wOSRCPtr; - unsigned long LineOffset; + unsigned int LineOffset; int pmult=pageid/16; - unsigned long (*LTCOL)(unsigned long); + unsigned int (*LTCOL)(unsigned int); LTCOL=TCF[DrawSemiTrans]; ldxo=TWin.Position.x1-TWin.OPosition.x1; ldy =TWin.Position.y1-TWin.OPosition.y1; - pa=px=(unsigned long *)ubPaletteBuffer; - ta=(unsigned long *)texturepart; + pa=px=(unsigned int *)ubPaletteBuffer; + ta=(unsigned int *)texturepart; palstart=cx+(cy*1024); ubOpaqueDraw=0; @@ -1323,12 +1323,12 @@ void LoadStretchWndTexturePage(int pageid, int mode, short cx, short cy) void LoadPackedWndTexturePage(int pageid, int mode, short cx, short cy) { - unsigned long start,row,column,j,sxh,sxm; + unsigned int start,row,column,j,sxh,sxm; unsigned int palstart; unsigned short *px,*pa,*ta; unsigned char *cSRCPtr; unsigned short *wSRCPtr; - unsigned long LineOffset; + unsigned int LineOffset; int pmult=pageid/16; unsigned short (*LPTCOL)(unsigned short); @@ -1465,19 +1465,19 @@ void LoadPackedWndTexturePage(int pageid, int mode, short cx, short cy) void LoadWndTexturePage(int pageid, int mode, short cx, short cy) { - unsigned long start,row,column,j,sxh,sxm; + unsigned int start,row,column,j,sxh,sxm; unsigned int palstart; - unsigned long *px,*pa,*ta; + unsigned int *px,*pa,*ta; unsigned char *cSRCPtr; unsigned short *wSRCPtr; - unsigned long LineOffset; + unsigned int LineOffset; int pmult=pageid/16; - unsigned long (*LTCOL)(unsigned long); + unsigned int (*LTCOL)(unsigned int); LTCOL=TCF[DrawSemiTrans]; - pa=px=(unsigned long *)ubPaletteBuffer; - ta=(unsigned long *)texturepart; + pa=px=(unsigned int *)ubPaletteBuffer; + ta=(unsigned int *)texturepart; palstart=cx+(cy*1024); ubOpaqueDraw=0; @@ -1627,7 +1627,7 @@ void UploadTexWndPal(int mode,short cx,short cy) { unsigned int i,iSize; unsigned short * wSrcPtr; - unsigned long * ta=(unsigned long *)texturepart; + unsigned int * ta=(unsigned int *)texturepart; wSrcPtr=psxVuw+cx+(cy*1024); if(mode==0) i=4; else i=64; @@ -1677,10 +1677,10 @@ void DefinePalTextureWnd(void) void LoadPalWndTexturePage(int pageid, int mode, short cx, short cy) { - unsigned long start,row,column,j,sxh,sxm; + unsigned int start,row,column,j,sxh,sxm; unsigned char *ta; unsigned char *cSRCPtr; - unsigned long LineOffset; + unsigned int LineOffset; int pmult=pageid/16; ta=(unsigned char *)texturepart; @@ -1737,10 +1737,10 @@ void LoadPalWndTexturePage(int pageid, int mode, short cx, short cy) void LoadStretchPalWndTexturePage(int pageid, int mode, short cx, short cy) { - unsigned long start,row,column,j,sxh,sxm,ldx,ldy,ldxo; + unsigned int start,row,column,j,sxh,sxm,ldx,ldy,ldxo; unsigned char *ta,s; unsigned char *cSRCPtr,*cOSRCPtr; - unsigned long LineOffset; + unsigned int LineOffset; int pmult=pageid/16; ldxo=TWin.Position.x1-TWin.OPosition.x1; @@ -1815,7 +1815,7 @@ void LoadStretchPalWndTexturePage(int pageid, int mode, short cx, short cy) // tex window: main selecting, cache handler included //////////////////////////////////////////////////////////////////////// -GLuint LoadTextureWnd(long pageid,long TextureMode,unsigned long GivenClutId) +GLuint LoadTextureWnd(int pageid,int TextureMode,unsigned int GivenClutId) { textureWndCacheEntry * ts, * tsx=NULL; int i;short cx,cy; @@ -1837,8 +1837,8 @@ GLuint LoadTextureWnd(long pageid,long TextureMode,unsigned long GivenClutId) // palette check sum { - unsigned long l=0,row; - unsigned long * lSRCPtr=(unsigned long *)(psxVuw+cx+(cy*1024)); + unsigned int l=0,row; + unsigned int * lSRCPtr=(unsigned int *)(psxVuw+cx+(cy*1024)); if(TextureMode==1) for(row=1;row<129;row++) l+=((*lSRCPtr++)-1)*row; else for(row=1;row<9;row++) l+=((*lSRCPtr++)-1)<ClutID&(1<<30)) DrawSemiTrans=1; else DrawSemiTrans=0; - *((unsigned long *)&gl_ux[4])=r.l; + *((unsigned int *)&gl_ux[4])=r.l; gTexName=uiStexturePage[tsx->cTexID]; LoadSubTexFn(k,j,cx,cy); @@ -4117,7 +4117,7 @@ void CompressTextureSpace(void) if(dwTexPageComp==0xffffffff) dwTexPageComp=0; - *((unsigned long *)&gl_ux[4])=opos.l; + *((unsigned int *)&gl_ux[4])=opos.l; GlobalTexturePage=lOGTP; DrawSemiTrans=sOldDST; } @@ -4132,7 +4132,7 @@ void CompressTextureSpace(void) ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -GLuint SelectSubTextureS(long TextureMode, unsigned long GivenClutId) +GLuint SelectSubTextureS(int TextureMode, unsigned int GivenClutId) { unsigned char * OPtr;unsigned short iCache;short cx,cy; @@ -4174,9 +4174,9 @@ GLuint SelectSubTextureS(long TextureMode, unsigned long GivenClutId) // palette check sum.. removed MMX asm, this easy func works as well { - unsigned long l=0,row; + unsigned int l=0,row; - unsigned long * lSRCPtr=(unsigned long *)(psxVuw+cx+(cy*1024)); + unsigned int * lSRCPtr=(unsigned int *)(psxVuw+cx+(cy*1024)); if(TextureMode==1) for(row=1;row<129;row++) l+=((*lSRCPtr++)-1)*row; else for(row=1;row<9;row++) l+=((*lSRCPtr++)-1)<>24)&0xff) { diff --git a/plugins/gpulib/gpu.h b/plugins/gpulib/gpu.h index 717d2fe2..4637a71c 100644 --- a/plugins/gpulib/gpu.h +++ b/plugins/gpulib/gpu.h @@ -76,6 +76,7 @@ struct psx_gpu { uint32_t hcnt; } last_list; uint32_t last_vram_read_frame; + uint32_t w_out_old, h_out_old, status_vo_old; } state; struct { int32_t set:3; /* -1 auto, 0 off, 1-3 fixed */ diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 1c98b55a..a6a3f63c 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -27,8 +27,6 @@ int vout_finish(void) static void check_mode_change(int force) { - static uint32_t old_status; - static int old_h; int w = gpu.screen.hres; int h = gpu.screen.h; int w_out = w; @@ -44,10 +42,12 @@ static void check_mode_change(int force) } // width|rgb24 change? - if (force || (gpu.status ^ old_status) & ((7<<16)|(1<<21)) || h != old_h) + if (force || (gpu.status ^ gpu.state.status_vo_old) & ((7<<16)|(1<<21)) + || w_out != gpu.state.w_out_old || h_out != gpu.state.h_out_old) { - old_status = gpu.status; - old_h = h; + gpu.state.status_vo_old = gpu.status; + gpu.state.w_out_old = w_out; + gpu.state.h_out_old = h_out; cbs->pl_vout_set_mode(w_out, h_out, w, h, (gpu.status & PSX_GPU_STATUS_RGB24) ? 24 : 16);