1
0
Fork 0

add LagFrameCounter

This commit is contained in:
sup39 2022-11-02 00:28:50 +09:00
parent 18d90d06a2
commit 8b4b5244e9
3 changed files with 80 additions and 0 deletions

View file

@ -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

11
src/LagFrameCounter.ld Normal file
View file

@ -0,0 +1,11 @@
$$ = 0;
$C2$.showCounter = 0x80203238;
$C2$.updateCounter = 0x800ed1ac;
$C2$.resetCounter = TMarDirector.setupObjects;
$counter = 0x817f9ffc;
/**
* [-5] resetFlag
* [-4] retraceCount0
* [ 0] counter
*/

51
src/LagFrameCounter.s Normal file
View file

@ -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