From 9e13a87a7501497aefd29ba3dd921fdacd468a04 Mon Sep 17 00:00:00 2001 From: sup39 Date: Wed, 2 Nov 2022 16:25:16 +0900 Subject: [PATCH] add AttemptCounter --- NTSC-J 1.0/AttemptCounter.customized.txt | 37 +++++++++ NTSC-J 1.0/AttemptCounter.txt | 26 +++++++ src/AttemptCounter.ld | 14 ++++ src/AttemptCounter.s | 98 ++++++++++++++++++++++++ 4 files changed, 175 insertions(+) create mode 100644 NTSC-J 1.0/AttemptCounter.customized.txt create mode 100644 NTSC-J 1.0/AttemptCounter.txt create mode 100644 src/AttemptCounter.ld create mode 100644 src/AttemptCounter.s diff --git a/NTSC-J 1.0/AttemptCounter.customized.txt b/NTSC-J 1.0/AttemptCounter.customized.txt new file mode 100644 index 0000000..94172a4 --- /dev/null +++ b/NTSC-J 1.0/AttemptCounter.customized.txt @@ -0,0 +1,37 @@ +Configuration: +* xxxx: x coordinate of the text +* yyyy: y coordinate of the text +* ssss: font size of the text +* rrggbbaa: color of the text +You can use the preview function of "Customized display" in https://gct.zint.ch/ +by setting the format to + 0 + 1 +or something else + +$ AttemptCounter (2022/11/02) [sup39] +0410C3C8 496EDB45 +040EDB34 4970C411 +04206898 495F36CC +077F9F0C 000000A8 +7C7E1B78 3D808180 +A40C9F08 A17E007C +7C005800 B16C0000 +3960003C B16C0002 +39600001 4082000C +816CFFFC 396B0001 +916CFFFC 4E800020 +3D808180 856C9F00 +396B0001 916C0000 +3960003C B16C000A +39000000 4E800020 +4A83B2C5 3D808180 +A46C9F0A 3463FFFF +4180003C B06C0000 +3860xxxx 3880yyyy +38A0ssss 3CC0rrgg +60C6bbaa 7CC73378 +4800000D 25640A25 +64000000 7D0802A6 +812CFFF6 814CFFFA +4BFF628D 4AA0C8EC diff --git a/NTSC-J 1.0/AttemptCounter.txt b/NTSC-J 1.0/AttemptCounter.txt new file mode 100644 index 0000000..a8b08ba --- /dev/null +++ b/NTSC-J 1.0/AttemptCounter.txt @@ -0,0 +1,26 @@ +$ AttemptCounter (2022/11/02) [sup39] +0410C3C8 496EDB45 +040EDB34 4970C411 +04206898 495F36CC +077F9F0C 000000A8 +7C7E1B78 3D808180 +A40C9F08 A17E007C +7C005800 B16C0000 +3960003C B16C0002 +39600001 4082000C +816CFFFC 396B0001 +916CFFFC 4E800020 +3D808180 856C9F00 +396B0001 916C0000 +3960003C B16C000A +39000000 4E800020 +4A83B2C5 3D808180 +A46C9F0A 3463FFFF +4180003C B06C0000 +38600090 3880007C +38A0001C 3CC0FFFF +60C6FFFF 7CC73378 +4800000D 25640A25 +64000000 7D0802A6 +812CFFF6 814CFFFA +4BFF628D 4AA0C8EC diff --git a/src/AttemptCounter.ld b/src/AttemptCounter.ld new file mode 100644 index 0000000..2429379 --- /dev/null +++ b/src/AttemptCounter.ld @@ -0,0 +1,14 @@ +$$ = 0x817f9f0c; + +$bl$.onStart = 0x8010c3c8; +$bl$.onShineGet = 0x800edb34; +$b$.onRender = 0x80206898; +drawText = 0x817f0238; + +/** + * u32 success count + * u32 total count + * u16 last area + * u16 freeze count + */ +$data = 0x817f9f00; diff --git a/src/AttemptCounter.s b/src/AttemptCounter.s new file mode 100644 index 0000000..7e4d698 --- /dev/null +++ b/src/AttemptCounter.s @@ -0,0 +1,98 @@ +.set x, 144 +.set y, 124 +.set fontSize, 28 +.set color, 0xffffffff +.set freezeDuration, 60 + +.set off$succnt, 0 +.set off$tolcnt, 4 +.set off$area0, 8 +.set off$freeze, 10 + +.macro liDX reg val + .if -0x8000 <= \val && \val < 0x8000 || 0xffff8000 <= \val + li \reg, \val@l + .else + lis \reg, \val@h + .if \val&0xffff != 0 + ori \reg, \reg, \val@l + .endif + .endif +.endm + +.onStart: + .set r$$, 12 + .set off$$, off$area0 + .set a$$, $data+off$$ +## orig + mr r30, r3 +## check last area +### r0 = last area +### r11 = current area + lis r$$, a$$@ha + lhzu r0, a$$@l(r$$) + lhz r11, 0x7c(r30) + cmpw r0, r11 +### store current area + sth r11, off$area0-off$$@l(r$$) +## set freeze + li r11, freezeDuration + sth r11, off$freeze-off$$(r$$) +## total count (r11) +### if curArea != area0, totalCount = 1 + li r11, 1 + bne .onStart.done +### else total Count += 1 + lwz r11, off$tolcnt-off$$(r$$) + addi r11, r11, 1 +.onStart.done: + stw r11, off$tolcnt-off$$(r$$) + blr + +.onShineGet: + .set r$$, 12 + .set off$$, off$succnt + .set a$$, $data+off$$ +## success count += 1 + lis r$$, a$$@ha + lwzu r11, a$$@l(r$$) + addi r11, r11, 1 + stw r11, 0(r$$) +## set freeze + li r11, freezeDuration + sth r11, off$freeze-off$$(r$$) +## orig + li r8, 0 + blr + +.onRender: +## orig (setup2D) + bl setup2D +## check freeze count + .set r$$, 12 + .set off$$, off$freeze + .set a$$, $data+off$$ +### r$$ = &freezeCount +### r3 = freezeCount + lis r$$, a$$@ha + lhzu r3, a$$@l(r$$) + addic. r3, r3, -1 + ## if freezeCount < 0, return + blt .onRender.done +## update freezeCount + sth r3, off$freeze-off$$(r$$) +.onRender.drawText: + li r3, x + li r4, y + li r5, fontSize + #liDX r6, color # colorTop + lis r6, color@h + ori r6, r6, color@l + mr r7, r6 # colorBot + bl .onRender.fmt; .string "%d\n%d"; .align 2; .onRender.fmt: mflr r8 + lwz r9, off$succnt-off$$(r$$) + lwz r10, off$tolcnt-off$$(r$$) + bl drawText +.onRender.done: +## orig + b 4+$b$.onRender