From b847f0d4a5753b5b39a9667adfafe1976489e392 Mon Sep 17 00:00:00 2001 From: sup39 Date: Sat, 22 Oct 2022 18:15:42 +0900 Subject: [PATCH] add RedCoinTimer --- NTSC-J 1.0/RedCoinTimer.txt | 29 +++++++++++++ src/RedCoinTimer.ld | 6 +++ src/RedCoinTimer.s | 81 +++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 NTSC-J 1.0/RedCoinTimer.txt create mode 100644 src/RedCoinTimer.ld create mode 100644 src/RedCoinTimer.s diff --git a/NTSC-J 1.0/RedCoinTimer.txt b/NTSC-J 1.0/RedCoinTimer.txt new file mode 100644 index 0000000..af0921b --- /dev/null +++ b/NTSC-J 1.0/RedCoinTimer.txt @@ -0,0 +1,29 @@ +$ Red Coin Timer (v0.1.0, 2022/10/22) [sup39] +041962F4 49661E0D +04206758 495F19C8 +077F8100 000000C4 +812300F4 3D408180 +394A8000 818D97E8 +816C005C 5529103E +7D6A492E 4A8EFC94 +38610E90 4A83D105 +3821FFE0 BF81000C +3D80817F 3BEC7FFC +818D97D0 83CC00F4 +3BA0009C 3B800000 +2C1E0000 41A10014 +BB81000C 38210020 +38610E90 4AA0E600 +859F0004 7C1C6050 +7D9C6378 1C0003E9 +39600078 7D405B96 +396003E8 7D2A5B96 +1D6903E8 7D4B5050 +3860020C 7FA4EB78 +38A0000F 38C0FFFF +38E0FFFF 48000011 +2532642E 25303364 +00000000 7D0802A6 +4CC63182 4BFF8085 +3BDEFFFF 3BBD000F +4BFFFF88 00000000 diff --git a/src/RedCoinTimer.ld b/src/RedCoinTimer.ld new file mode 100644 index 0000000..ebe12f4 --- /dev/null +++ b/src/RedCoinTimer.ld @@ -0,0 +1,6 @@ +$$ = 0x817f8100; +$RCST.times = 0x817f8000; + +$bl$.TCoinRed.taken.incFlag = 0x801962f4; +$b$.draw2D = 0x80206758; +drawText = 0x817f0238; diff --git a/src/RedCoinTimer.s b/src/RedCoinTimer.s new file mode 100644 index 0000000..679eaec --- /dev/null +++ b/src/RedCoinTimer.s @@ -0,0 +1,81 @@ +.TCoinRed.taken.incFlag: +### r3 = smInstance +### r9 = red coin count +### r10 = × + lwz r9, 0xF4(r3) + lis r10, $RCST.times@ha + la r10, $RCST.times@l(r10) +### r11 = global QF + lwz r12, gpMarDirector$r13(r13) + lwz r11, 0x5C(r12) +## store time + rlwinm r9, r9, 2, 0, 31 + stwx r11, r10, r9 +## DONE + b TFlagManager.incFlag + +.set rmw, 28 +.set rmwOff, 0xC +.set rmwAdd, 0x20 +.set x, 524 +.set y, 156 +.set fontSize, 15 +.draw2D: +## setup + addi r3, r1, 0xE90 + bl J2DGrafContext.setup2D +## pre draw + addi r1, r1, -rmwAdd + stmw rmw, rmwOff(r1) +.set rTPtr, r31 +.set rCnt, r30 +.set rY, r29 +.set rT0, r28 + lis r12, $RCST.times-4@ha + la rTPtr, $RCST.times-4@l(r12) + lwz r12, TFlagManager.smInstance$r13(r13) + lwz rCnt, 0xF4(r12) + li rY, y + li rT0, 0 +.draw2D.loop: + cmpwi rCnt, 0 + bgt+ .draw2D.loop.body +## post draw + lmw rmw, rmwOff(r1) + addi r1, r1, rmwAdd +## orig + addi r3, r1, 0xE90 + b 4+$b$.draw2D +.draw2D.loop.body: +### QF -> s + lwzu r12, 4(rTPtr) + sub r0, r12, rT0 + mr rT0, r12 +#### r0 = dQF*1001 + mulli r0, r0, 1001 +#### r10 = dQF*1001/120 = ms + li r11, 120 + divwu r10, r0, r11 +#### r9 = ms/1000 = s + li r11, 1000 + divwu r9, r10, r11 +#### r10 = ms-s*1000 = ms%1000 + mulli r11, r9, 1000 + sub r10, r10, r11 +### params + li r3, x + mr r4, rY + li r5, fontSize + li r6, -1 + li r7, -1 + bl .draw2D.fmt + .string "%2d.%03d" + .align 2 +.draw2D.fmt: + mflr r8 + crclr 6 + bl drawText +## next + addi rCnt, rCnt, -1 + addi rY, rY, fontSize + b .draw2D.loop