1
0
Fork 0

migrated and rewrote AttemptCounter with C2

This commit is contained in:
sup39 2023-02-05 23:34:20 +09:00
parent b798226c14
commit 0ccbd6b3c0
2 changed files with 94 additions and 82 deletions

View file

@ -1,15 +1,26 @@
$$ = 0x817f9f0c;
$$ = 0;
$bl$.onStart = 0x8010c3c8;
$bl$.onShineGet = 0x800edb34;
$bl$.onMoveStage = 0x3C + TMarDirector.moveStage;
$b$.onRender = 0x80206898;
$C2$.onStart = TMarDirector.setupObjects + 0x1C;
$C2$.onShineGet = TMarDirector.fireGetStar;
$C2$.onMoveStage = TMarDirector.moveStage + 0x3C;
$C2$.onRender = drawWater - 0x28;
drawText = 0x817f0238;
/**
* u32 success count
* u32 total count
* u16 last area
* u16 freeze count
*/
$data = 0x817f9f00;
/** size = 2 */
area0 = 0x817f0476;
/** size = 1 */
showTimer = 0x817f0478;
showLength = 0x817f0479;
/** size = 6 */
fmt = 0x817f047a;
/** size = 0x10 */
textOpt = 0x817f0480;
/** size = 0x14 */
rectOpt = 0x817f0490;
/** size = 2 */
succnt = 0x817f04a4;
totcnt = 0x817f04a6;
/** size = 1 */
gotShineFlag = 0x817f04a8;
gpApplication = DEFINED(SMS__GMSE01) ? 0x803E9700 : gpApplication;

View file

@ -1,102 +1,103 @@
.include "./macros.s"
.set x, 144
.set y, 124
.set fontSize, 28
.set color, 0x99ffffff
.set freezeDuration, 60
.set off$succnt, 0
.set off$tolcnt, 4
.set off$area0, 8
.set off$freeze, 10
.onStart:
.set r$$, 12
.set off$$, off$area0
.set a$$, $data+off$$
## orig
### r30 = gpMarDirector
mr r30, r3
## check last area
### r0 = last area
### r11 = current area
lis r$$, a$$@ha
lhzu r0, a$$@l(r$$)
### r12 = 0x817F0000
lis r12, 0x817F
lhz r0, area0@l(r12)
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), success count (r10)
### if curArea != area0, totalCount = 1
sth r11, area0@l(r12)
## set timer
lbz r11, showLength@l(r12)
stb r11, showTimer@l(r12)
## reset gotShineFlag
li r11, 0
stb r11, gotShineFlag@l(r12)
## update count: r11 = (successCount, totalCount)
### if curArea != area0, (suc, tot) = (0, 1)
li r11, 1
li r10, 0
bne .onStart.done
### else total Count += 1
lwz r11, off$tolcnt-off$$(r$$)
### else (suc, tot) += (0, 1)
lwz r11, succnt@l(r12)
addi r11, r11, 1
lwz r10, off$succnt-off$$(r$$)
.onStart.done:
stw r11, off$tolcnt-off$$(r$$)
stw r10, off$succnt-off$$(r$$)
blr
stw r11, succnt@l(r12)
.onShineGet:
## orig
li r8, 0
.doSuccess:
.set r$$, 12
.set off$$, off$succnt
.set a$$, $data+off$$
mflr r0
## success count += 1
lis r$$, a$$@ha
lwzu r11, a$$@l(r$$)
addi r11, r11, 1
stw r11, 0(r$$)
### r11 = (suc, tot)
### r12 = 0x817F0000
lis r12, 0x817F
lwz r11, succnt@l(r12)
addis r11, r11, 1
stw r11, succnt@l(r12)
## set freeze
li r11, freezeDuration
sth r11, off$freeze-off$$(r$$)
blr
lbz r11, showLength@l(r12)
stb r11, showTimer@l(r12)
## set gotShineFlag
li r11, 1
stb r11, gotShineFlag@l(r12)
.onMoveStage:
## orig
addi r28, r3, gpApplication@l # TODO check version
## r31 = this
## r12, r11 = curArea, prevArea
addi r28, r3, gpApplication@l
### r31 = this
### r12, r11 = curArea, prevArea
lhz r12, 0xe(r28)
lhz r11, 0xa(r28)
cmpw r12, r11
beqlr # same area -> reset -> not success
b .doSuccess
## ignore if curArea == prevArea (set by IR/ILS when resetting manually)
## else count as success
beq .onMoveStage.done
## if gotShineFlag, skip
lis r12, 0x817F
lbz r11, gotShineFlag@l(r12)
mr. r11, r11
bne .onMoveStage.done
## success count += 1
### r11 = (suc, tot)
### r12 = 0x817F0000
lwz r11, succnt@l(r12)
addis r11, r11, 1
stw r11, succnt@l(r12)
## set freeze
lbz r11, showLength@l(r12)
stb r11, showTimer@l(r12)
.onMoveStage.done:
.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$$)
### r12 = 0x817F0000
### r3 = showTimer
lis r12, 0x817F
lbz r3, showTimer@l(r12)
addic. r3, r3, -1
## if freezeCount < 0, return
blt .onRender.done
## update freezeCount
sth r3, off$freeze-off$$(r$$)
blt+ .onRender.done
## update timer
stb r3, showTimer@l(r12)
.onRender.fillRect:
la r3, rectOpt@l(r12)
addi r4, r3, 0x10
lis r12, fill_rect@ha
la r12, fill_rect@l(r12)
mtlr r12
blrl
.onRender.drawText:
li r3, x
li r4, y
li r5, fontSize
liDX r6, color
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
lis r12, 0x817F
la r3, textOpt@l(r12)
la r4, fmt@l(r12)
lhz r5, succnt@l(r12)
lhz r6, totcnt@l(r12)
la r12, drawText@l(r12)
mtlr r12
blrl
.onRender.done:
## orig
b 4+$b$.onRender