give/take coins action of blue/red space (#22)

This commit is contained in:
xCrystal
2023-12-24 18:42:07 +01:00
parent 4859b524b3
commit 28bd777632
9 changed files with 98 additions and 23 deletions

View File

@@ -4,6 +4,8 @@ BlueSpaceScript::
scall ArriveToRegularSpaceScript
iftrue .not_landed
scall LandedInRegularSpaceScript_BeforeSpaceEffect
givecoins CUR_LEVEL_COINS, BLUE_RED_SPACE_COINS
playsound SFX_TRANSACTION
scall LandedInRegularSpaceScript_AfterSpaceEffect
.not_landed
end
@@ -12,6 +14,8 @@ RedSpaceScript::
scall ArriveToRegularSpaceScript
iftrue .not_landed
scall LandedInRegularSpaceScript_BeforeSpaceEffect
takecoins CUR_LEVEL_COINS, BLUE_RED_SPACE_COINS
playsound SFX_TRANSACTION
scall LandedInRegularSpaceScript_AfterSpaceEffect
.not_landed
end
@@ -77,9 +81,7 @@ EndSpaceScript::
GreySpaceScript::
scall ArriveToRegularSpaceScript
iftrue .not_landed
wait 300
turnobject PLAYER, DOWN
wait 100
scall LandedInRegularSpaceScript_BeforeSpaceEffect
scall LandedInRegularSpaceScript_AfterSpaceEffect
.not_landed
end

View File

@@ -1,12 +1,12 @@
GiveCoins::
ld a, 3
call AddCoins
ld bc, MaxCoins
call LoadMaxCoins_bc
ld a, 3
call CompareCoins
jr z, .not_maxed_out
jr c, .not_maxed_out
ld hl, MaxCoins
call LoadMaxCoins_hl
ld a, [hli]
ld [de], a
inc de
@@ -22,9 +22,26 @@ GiveCoins::
and a
ret
LoadMaxCoins_bc:
ld a, d
cp HIGH(wCurLevelCoins)
ld bc, MaxCurLevelCoins ; CUR_LEVEL_COINS
ret z
ld bc, MaxCoins ; YOUR_COINS or MOMS_COINS
ret
LoadMaxCoins_hl:
call LoadMaxCoins_bc
ld h, b
ld l, c
ret
MaxCoins:
dt MAX_COINS
MaxCurLevelCoins:
dt MAX_LEVEL_COINS
TakeCoins::
ld a, 3
call SubtractCoins

View File

@@ -153,8 +153,15 @@ StartMap:
; initialize board state
xor a
ld [wCurTurn], a
ld [wCurSpace], a
ld hl, wCurTurn
ld [hli], a ; wCurTurn
ld [hli], a ; wCurSpace
ld [hli], a ; wCurLevelCoins
ld [hli], a ;
ld [hli], a ;
ld [hli], a ; wCurLevelExp
ld [hli], a ;
ld [hl], a ;
; initialize overworld state
ld hl, wNextWarp

View File

@@ -1874,13 +1874,18 @@ GetCoinsAccount:
and a
ld de, wCoins ; YOUR_COINS
ret z
dec a
ld de, wCurLevelCoins ; CUR_LEVEL_COINS
ret z
ld de, wMomsCoins ; MOMS_COINS
ret
LoadCoinsAmountToMem:
ld bc, hCoinsTemp
push bc
call GetScriptByte
cp HIGH(BLUE_RED_SPACE_COINS)
jr z, .blue_red_space_coins
push bc
ld [bc], a
inc bc
call GetScriptByte
@@ -1891,6 +1896,38 @@ LoadCoinsAmountToMem:
pop bc
ret
.blue_red_space_coins
push de
call GetScriptByte
call GetScriptByte
; return [hCoinsTemp] = MAP_BASECOINS * [wDieRoll]
ld de, MAP_BASECOINS
call GetMapField
ld a, [wDieRoll]
dec a
ld e, a
ld a, c
ld b, 0 ; c = ba = MAP_BASECOINS
jr z, .go
.loop
add c
jr nc, .ok
inc b
.ok
dec e
jr nz, .loop
.go
; ba = MAP_BASECOINS * [wDieRoll]
ld hl, hCoinsTemp + 2
ld [hld], a
ld a, b
ld [hld], a
xor a
ld [hl], a
ld bc, hCoinsTemp
pop de
ret
Script_givechips:
call LoadChipAmountToMem
farcall GiveChips
@@ -1904,7 +1941,7 @@ Script_takechips:
Script_checkchips:
call LoadChipAmountToMem
farcall CheckChips
jr CompareCoinsAction
jp CompareCoinsAction
LoadChipAmountToMem:
call GetScriptByte