diff --git a/NTSC-J 1.0/LagFrameCounter.txt b/NTSC-J 1.0/LagFrameCounter.txt new file mode 100644 index 0000000..441b630 --- /dev/null +++ b/NTSC-J 1.0/LagFrameCounter.txt @@ -0,0 +1,18 @@ +$ LagFrameCounter (2022/11/02) [sup39] +C210C3AC 00000003 +39600001 3D808180 +996C9FF7 7C0802A6 +60000000 00000000 +C2203238 00000002 +3C608180 80639FFC +60000000 00000000 +C20ED1AC 00000009 +3CC08180 84669FFC +808D9440 80A6FFFC +9086FFFC 39850002 +7D8C2050 7C636214 +8806FFFB 7C000379 +41A20010 38000000 +9806FFFB 38600000 +90660000 3B000000 +60000000 00000000 diff --git a/src/LagFrameCounter.ld b/src/LagFrameCounter.ld new file mode 100644 index 0000000..7f83d39 --- /dev/null +++ b/src/LagFrameCounter.ld @@ -0,0 +1,11 @@ +$$ = 0; +$C2$.showCounter = 0x80203238; +$C2$.updateCounter = 0x800ed1ac; +$C2$.resetCounter = TMarDirector.setupObjects; + +$counter = 0x817f9ffc; +/** + * [-5] resetFlag + * [-4] retraceCount0 + * [ 0] counter + */ diff --git a/src/LagFrameCounter.s b/src/LagFrameCounter.s new file mode 100644 index 0000000..de3f6aa --- /dev/null +++ b/src/LagFrameCounter.s @@ -0,0 +1,51 @@ +/** + * Show lag frame count at coin counter + */ + +.set a$ptr, $counter +.set off$counter, 0 +.set off$retraceCount0, -4 +.set off$resetFlag, -5 + +.showCounter: + lis r3, $counter@ha + lwz r3, $counter@l(r3) + +.updateCounter: + .set r$cnt, 3 # counter + .set r$rtcnt, 4 # retraceCount + .set r$rtcnt0, 5 # retraceCount0 + .set r$ptr, 6 # &counter + lis r$ptr, a$ptr@ha + lwzu r$cnt, a$ptr@l(r$ptr) + lwz r$rtcnt, vi.retraceCount$r13(r13) + lwz r$rtcnt0, off$retraceCount0(r$ptr) +## store retraceCount + stw r$rtcnt, off$retraceCount0(r$ptr) +## cnt += rtcnt - (rtcnt0 + 2) + addi r12, r$rtcnt0, 2 + sub r12, r$rtcnt, r12 + add r$cnt, r$cnt, r12 +## check resetFlag + lbz r0, off$resetFlag(r$ptr) + mr. r0, r0 + beq+ .updateCounter.done +.updateCounter.reset: +### resetFlag = 0 + li r0, 0 + stb r0, off$resetFlag(r$ptr) +### counter = 0 + li r$cnt, 0 +.updateCounter.done: +## store counter + stw r$cnt, off$counter(r$ptr) +## orig + li r24, 0 + +.resetCounter: + .set $resetFlag, a$ptr+off$resetFlag + li r11, 1 + lis r12, $resetFlag@ha + stb r11, $resetFlag@l(r12) +## orig + mflr r0