pcercuei / lightrec Goto Github PK
View Code? Open in Web Editor NEWMIPS-to-everything dynamic recompiler for PSX emulators
License: Other
MIPS-to-everything dynamic recompiler for PSX emulators
License: Other
The game crashes right after the first loading screen in Wiistation and WiiSX.
When removing the BEQ "never taken" conversion in optimizer.c the crash goes away.
If I only allow the conversion if the BEQ doesn't have a load delay in its delay slot, the crash is also fixed.
Like the title says F1 2000 and F1 2001, both from EA (and possibly other games) when trying to play them using Lightrec, they crash on the first copyright screen.
Playing the USA versions of the game.
Tried latest PCSX-ReARMed, latest WiiSX... no luck with these.
Maybe it's related to missing ICache emulation in Lightrec, or something else?
Any fix for these? Thanks ;)
WARNING: Unknown opcode: 0x00001770 at PC 0x80166518
WARNING: Unknown opcode: 0x00001770 at PC 0x80130c80
WARNING: Unknown opcode: 0x00001770 at PC 0x80130cb4
WARNING: Unknown opcode: 0x00001770 at PC 0x80130ce4
WARNING: Unknown opcode: 0x00001770 at PC 0x80130d34
WARNING: Unknown opcode: 0x00001770 at PC 0x80130d7c
WARNING: Unknown opcode: 0x00001770 at PC 0x801321a0
L̶i̶k̶e̶ ̶t̶h̶e̶ ̶t̶i̶t̶l̶e̶ ̶s̶a̶y̶s̶ ̶o̶n̶ ̶t̶h̶e̶ ̶g̶a̶m̶e̶ ̶D̶i̶g̶i̶m̶o̶n̶ ̶R̶u̶m̶b̶l̶e̶ ̶A̶r̶e̶n̶a̶ ̶t̶h̶e̶ ̶g̶a̶m̶e̶ ̶c̶r̶a̶s̶h̶e̶s̶ ̶a̶t̶ ̶s̶t̶a̶r̶t̶ ̶o̶f̶ ̶b̶a̶t̶t̶l̶e̶s̶.̶ (see update)
Playing the USA release, on the latest implementation of Lightrec on WiiSX/CubeSX.
WARNING: Unimplemented opcode 0x00001174
WARNING: Unimplemented opcode 0x000015f8
WARNING: Unknown opcode: 0x00001174 at PC 0x00000874
WARNING: Unknown opcode: 0x000015f8 at PC 0x0000087c
Seems to be an invalid opcode, both beetle and pcsx_rearmed have the same behavior.
So, i've saw your work at this (very old but still maintained) PlayStation 1 emulator for Wii, WiiSX (formerly PCSXGC), that you implemented Lightrec: https://github.com/pcercuei/pcsxgc/tree/lightrec
I was going to ask...
Since WiiSXRX (https://github.com/niuus/WiiSXRX) and WiiStation (formerly WiiSXRX_2022, https://github.com/xjsxjs197/WiiSXRX_2022) are both much better emulators of PS1 for Wii than the old PCSXGC, i was going to ask if you could try implementing your Lightrec to these PS1 emulators for Wii?
Thanks for your great work, it's so appreciated ;)
Considering adding support for other cpus? PSP cpu is quite similar for example
I have been thinking about porting this to FBNeo and i was wondering if you would give authorization to use this under FBNeo's non-commercial license ? (we can't add GPL code to our codebase)
Mismatch!
CYCLE 0x5fd313aa PC 0x8008f578 CP0 0x7fbedad6 CP2D 0x3d7fe434 CP2C 0xe5c30193 INT 0x0804 INTCYCLE 0x2ebf30b4 GPU 0x5402200f GPR 0x0fcf30dc - Interpreter
CYCLE 0x5fd313aa PC 0x8008f578 CP0 0x7fbedad6 CP2D 0x3d7fe434 CP2C 0xe5c30193 INT 0x0804 INTCYCLE 0x2ebf30b4 GPU 0x54022112 GPR 0x0fcf30dc - Dynarec
State before the mismatch:
CYCLE 0x5fd31382 PC 0x80091a10 CP0 0x7fbedad6 CP2D 0x3d7fe434 CP2C 0xe5c30193 INT 0x0804 INTCYCLE 0x2ebf30b4 GPU 0x5402200f GPR 0xf675572e
Haven't been able to get any debug info yet, but it occurs in pcsx_rearmed and beetle
51d42d5 introduces a call to jit_ldxi_ui which is 64-bit only according to gnu-lightning docs, and so this doesn't build for 32-bit
Hi, is there any tip on how to use your library within other application?
On Windows, I am compilling lightrec as a statically linked object instead of a DLL.
Due to how lightrec.h
defines __api
as either __declspec("dllimport")
or __declspec("dllexport")
, I am getting warnings the while compiling lightrec.c
related to these attributes, e.g.:
path/to/lightrec.c:692:5: warning: 'lightrec_execute' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
692 | u32 lightrec_execute(struct lightrec_state *state, u32 pc, u32 target_cycle)
and afterwards I errors related to undeclared references to all the functions declared in lightrec.h
, e.g.:
ld.exe: lightrec_user.o:lightrec_user.cpp:(.text+0x1ab1): undefined reference to `__imp_lightrec_execute'
I can work around those errors by adding a new macro that changes how __api
is defined for static compilation and defining it during compilation, like so:
#ifndef lightrec_STATIC
# ifdef _WIN32
# ifdef lightrec_EXPORTS
# define __api __declspec(dllexport)
# else
# define __api __declspec(dllimport)
# endif
# elif __GNUC__ >= 4
# define __api __attribute__((visibility ("default")))
# else
# define __api
# endif
#else
# define __api
#endif
Because this works for me, it suggests the attributes - as warned by the compiler - are causing my linker errors. Perhaps the workaround should be part of the codebase? Or maybe the function definitions in lightrec.c
also need matching attributes?
When building lightning with --enable-assertions, upon starting emulator using lightrec (tried beetle and pcsx_rearmed):
lightning/lib/lightning.c:2126: _jit_trampoline: Assertion `_jitc->tail && _jitc->tail->code == jit_code_prolog' failed.
Tried to bisect but had many skips due to segfaults:
There are only 'skip'ped commits left to test.
The first bad commit could be any of:
4e6308b
53fd0e1
2d43186
8c9b3b2
627b913
634aeaa
1f4d72e
9c34c17
c257610
We cannot bisect more!
The game Sled Storm works fine but the musics aren't playing.
Few things to note:
The MULT2 conversion seems to cause Gex 3 to crash shortly after starting a new game on Wiistation. Removing the conversion makes it work again.
If I add a is_known check on both registers it seems to fix the crash. I don't know if that is right though.
Like so:
case OP_SPECIAL_MULTU:
if (is_known(v, op->r.rs) && is_known(v, op->r.rt) &&
is_power_of_two(v[op->r.rs].value)) {
tmp = op->c.i.rs;
op->c.i.rs = op->c.i.rt;
op->c.i.rt = tmp;
} else if (!is_known(v, op->r.rt) || !is_known(v, op->r.rs) ||
!is_power_of_two(v[op->r.rt].value)) {
break;
}
This may crash if the memory block ends up at the end of page:
==1134698== Invalid read of size 1
==1134698== at 0x17287058: lightrec_emit_end_of_block (emitter.c:109)
==1134698== by 0x172872ED: rec_mtc (emitter.c:2130)
==1134698== by 0x17286E66: lightrec_rec_opcode (emitter.c:3060)
==1134698== by 0x1728D016: lightrec_compile_block (lightrec.c:1619)
==1134698== by 0x1728F3B4: get_next_block_func (lightrec.c:788)
==1134698== by 0x1728F480: lightrec_execute (lightrec.c:1814)
==1134698== by 0x1724F930: lightrec_plugin_execute_internal (plugin.c:515)
==1134698== by 0x17234DA3: psxExecuteBios (r3000a.c:252)
==1134698== by 0x17234EA6: psxReset (r3000a.c:78)
==1134698== by 0x1732394C: SysReset (main.c:816)
==1134698== by 0x17322134: retro_load_game (libretro.c:1675)
==1134698== by 0x1A6F88: core_load_game (in /home/notaz/src/emu/RetroArch/retroarch)
==1134698== Address 0x16798728 is 4 bytes after a block of size 484 alloc'd
==1134698== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1134698== by 0x1728F865: lightrec_malloc (memmanager.c:67)
==1134698== by 0x1728F01D: lightrec_disassemble (lightrec.c:1394)
==1134698== by 0x1728F01D: lightrec_precompile_block (lightrec.c:1434)
==1134698== by 0x1728F01D: lightrec_get_block (lightrec.c:715)
==1134698== by 0x1728F30D: get_next_block_func (lightrec.c:740)
==1134698== by 0x1728F480: lightrec_execute (lightrec.c:1814)
==1134698== by 0x1724F930: lightrec_plugin_execute_internal (plugin.c:515)
==1134698== by 0x17234DA3: psxExecuteBios (r3000a.c:252)
==1134698== by 0x17234EA6: psxReset (r3000a.c:78)
==1134698== by 0x1732394C: SysReset (main.c:816)
==1134698== by 0x17322134: retro_load_game (libretro.c:1675)
==1134698== by 0x1A6F88: core_load_game (in /home/notaz/src/emu/RetroArch/retroarch)
==1134698== by 0x24C3FC: content_file_load (in /home/notaz/src/emu/RetroArch/retroarch)
==1134698==
==1134698== Invalid read of size 4
==1134698== at 0x1728705E: lightrec_emit_end_of_block (emitter.c:110)
==1134698== by 0x172872ED: rec_mtc (emitter.c:2130)
==1134698== by 0x17286E66: lightrec_rec_opcode (emitter.c:3060)
==1134698== by 0x1728D016: lightrec_compile_block (lightrec.c:1619)
==1134698== by 0x1728F3B4: get_next_block_func (lightrec.c:788)
==1134698== by 0x1728F480: lightrec_execute (lightrec.c:1814)
==1134698== by 0x1724F930: lightrec_plugin_execute_internal (plugin.c:515)
==1134698== by 0x17234DA3: psxExecuteBios (r3000a.c:252)
==1134698== by 0x17234EA6: psxReset (r3000a.c:78)
==1134698== by 0x1732394C: SysReset (main.c:816)
==1134698== by 0x17322134: retro_load_game (libretro.c:1675)
==1134698== by 0x1A6F88: core_load_game (in /home/notaz/src/emu/RetroArch/retroarch)
==1134698== Address 0x6547d8c is 0 bytes after a block of size 44 alloc'd
==1134698== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1134698== by 0x1728F865: lightrec_malloc (memmanager.c:67)
==1134698== by 0x1728F01D: lightrec_disassemble (lightrec.c:1394)
==1134698== by 0x1728F01D: lightrec_precompile_block (lightrec.c:1434)
==1134698== by 0x1728F01D: lightrec_get_block (lightrec.c:715)
==1134698== by 0x1728F30D: get_next_block_func (lightrec.c:740)
==1134698== by 0x1728F480: lightrec_execute (lightrec.c:1814)
==1134698== by 0x1724F930: lightrec_plugin_execute_internal (plugin.c:515)
==1134698== by 0x17234DA3: psxExecuteBios (r3000a.c:252)
==1134698== by 0x17234EA6: psxReset (r3000a.c:78)
==1134698== by 0x1732394C: SysReset (main.c:816)
==1134698== by 0x17322134: retro_load_game (libretro.c:1675)
==1134698== by 0x1A6F88: core_load_game (in /home/notaz/src/emu/RetroArch/retroarch)
==1134698== by 0x24C3FC: content_file_load (in /home/notaz/src/emu/RetroArch/retroarch)
==1134698== Invalid read of size 1
==1134698== at 0x17287058: lightrec_emit_end_of_block (emitter.c:109)
==1134698== by 0x17288961: rec_exit_early (emitter.c:2079)
==1134698== by 0x17286E66: lightrec_rec_opcode (emitter.c:3060)
==1134698== by 0x1728D016: lightrec_compile_block (lightrec.c:1619)
==1134698== by 0x1728F3B4: get_next_block_func (lightrec.c:788)
==1134698== by 0x40801AE8: ???
==1134698== Address 0x76a7488 is 4 bytes after a block of size 20 alloc'd
==1134698== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1134698== by 0x1728F865: lightrec_malloc (memmanager.c:67)
==1134698== by 0x1728F01D: lightrec_disassemble (lightrec.c:1394)
==1134698== by 0x1728F01D: lightrec_precompile_block (lightrec.c:1434)
==1134698== by 0x1728F01D: lightrec_get_block (lightrec.c:715)
==1134698== by 0x1728F30D: get_next_block_func (lightrec.c:740)
==1134698== by 0x40801AE8: ???
Hi, dear pcercuei:
I don't know if this issue should be mentioned here.
I also imported this very cool lightrec into the WiiStation(https://github.com/xjsxjs197/WiiSXRX_2022/).
Now, when press reset on the console, an exception occurred with DSI crash.
I'm trying to investigate and solve this problem, Basically confirm that have reached the following code branch.
vm.c
int vm_dsi_handler(u32 DSISR, u32 DAR)
{
u16 v_index;
u16 p_index;
if (DAR<(u32)VM_Base || DAR>=0x80000000)
// Maybe this point
if ((DSISR&~0x02000000)!=0x40000000)
// Maybe this point
.....
When press reset button, Is Virtual Memory mapping corrupted?
There's no clue at all. Can you help solve this issue ?
Thanks a lot.
See: libretro/pcsx_rearmed#530 and libretro/beetle-psx-libretro#805
This doesn't help with games but does help for testing ports to new systems.
It appears the r3000 puts the whole register on bus regardless if you write byte, half or full word. It's up to the receiving device to figure out what kind of write it is from the control signals. But apparently some hw registers don't look at the control signals at all and just latch the whole bus. There is at least scph7001 BIOS that relies on this behavior:
lhu $t9, 0($v1) # v1 = 1f8010f0
lui $at, 0xFFF0
ori $at, $at, 0xFFFF
and $t0, $t9, $at
lui $at, 8
or $t1, $t0, $at
sh $t1, 0($v1)
Lightrec's memhandlers seem to use u8 and u16 for data of sb and sh memhandlers respectively. My request is to have full u32 there.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.