TASEmulators / BizHawk

BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as full screen, and joypad support in addition to full rerecording and debugging tools for all system cores.
http://tasvideos.org/BizHawk.html
Other
2.09k stars 375 forks source link

[Genesis core] CDL missing table jump data #2588

Open g0me3 opened 3 years ago

g0me3 commented 3 years ago

Example. Game Toejam & Earl 2 (U) here MOVE.W OFF(PC,D0.L),D0 logged as code this opcode fetches one of the offsets in the table below no table entries logged as data so this one particular data fetch is missing from CDL (maybe there are others but this one I see for sure just now).

ROM:00023290 D080                                add.l   d0,d0           ; *c
ROM:00023292 303B 0806                           move.w  off_2329A(pc,d0.l),d0 ; *c
ROM:00023296 4EFB 0002                           jmp     off_2329A(pc,d0.w) ; *c
ROM:00023296                     ; ---------------------------------------------------------------------------
ROM:0002329A 0018                off_2329A:      dc.w sub_232B2-2-$23298 
ROM:0002329C 0034                                dc.w sub_232CE-2-$23298
ROM:0002329E 05C6                                dc.w sub_23860-2-$23298
ROM:000232A0 012A                                dc.w sub_233C4-2-$23298
ROM:000232A2 03C4                                dc.w sub_2365E-2-$23298
ROM:000232A4 028A                                dc.w sub_23524-2-$23298
ROM:000232A6 05C6                                dc.w sub_23860-2-$23298
ROM:000232A8 0474                                dc.w sub_2370E-2-$23298
ROM:000232AA 0512                                dc.w sub_237AC-2-$23298
ROM:000232AC 05C6                                dc.w sub_23860-2-$23298
ROM:000232AE 05C6                                dc.w sub_23860-2-$23298
ROM:000232B0 05A0                                dc.w sub_2383A-2-$23298
ROM:000232B2                     ; =============== S U B R O U T I N E =======================================
ROM:000232B2                     sub_232B2:   
ROM:000232B2 4A6A 000A                           tst.w   $A(a2)          ; *c
ROM:000232B6 6B00 05D2                           bmi.w   sub_2388A       ; *c
ROM:000232BA 08EA 0007 004B                      bset    #7,$4B(a2)      ; *c
ROM:000232C0 4A6A 000A                           tst.w   $A(a2)          ; *c
ROM:000232C4 6600 05C4                           bne.w   sub_2388A       ; *c
ROM:000232C8 08EA 0004 004B                      bset    #4,$4B(a2)      ; *c
g0me3 commented 3 years ago

ok, checked the core, all PC relative data instructions uses direct memory read handlers, they has no CDL code. so this for sure affects all PC relative instructions.

nattthebear commented 3 years ago

It will probably be a bit before I get to this. Are we saying that the genesis core (right now) doesn't support the D in CDL at all? move is just a plain data read, after all. Or is this something specific to the addressing mode?

g0me3 commented 3 years ago

No. Currently, gensx core does data logging in functions for regular data fetch: m68kiread*_fc But all PC relative instructions uses m68ki_read_pcrel_X -> m68k_read_pcrelative_X functions which are just immediare memory fetches, without any data logging -> m68k_read_immediate_X For this core there is no difference between opcodes for load immediate operands and opcodes that fetches the data using the relative PC offset, which is causes they are not logged as data as in any other addressing methods.

g0me3 commented 3 years ago

MOVEQ XX,REG - fetches data operand at PC + 1 MOVEW OFS(PC,REG),REG - the same but data operand is at PC + REG + OFS first one does not need to set data log flags, but the secod one need it same for all other opcodes with PC relative addressing mode.

nattthebear commented 3 years ago

Got it. I wonder if this bears any similarity to https://github.com/TASVideos/BizHawk/issues/1760; if immediate/pc relative fetches occur very commonly in real code, then this might have an unacceptable speed loss for normal use. We'll see.

g0me3 commented 3 years ago

we need to separate immediate operand fetches from PC relative addressing first i think. PC relative operands are not so frequent, mostly used for switch-case constructions. the regular data fetches are much more frequent and there is no significant loss in speed with them just now.

when I find any code that heavily abuses pc relative operands I will test if for sure, but doubt I can spot the difference on any current pc ;)