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

@ -15,6 +15,7 @@ DEF MAP_LOCATION rb ; 5
DEF MAP_MUSIC rb ; 6
DEF MAP_PALETTE rb ; 7
DEF MAP_FISHGROUP rb ; 8
DEF MAP_BASECOINS rb ; 9
DEF MAP_LENGTH EQU _RS
; map environments (wEnvironment)

View File

@ -35,9 +35,10 @@ DEF NOON_HOUR EQU 12 ; 12 PM
DEF MAX_DAYS EQU 36 * 7 ; 252
; significant coins values
DEF START_COINS EQU 3000
DEF START_COINS EQU 100
DEF MOM_COINS EQU 2300
DEF MAX_COINS EQU 999999
DEF MAX_LEVEL_COINS EQU 99999
DEF MAX_CHIPS EQU 9999
; link record

View File

@ -14,7 +14,8 @@ DEF STRING_BUFFER_LENGTH EQU 19
; checkcoins/takecoins accounts
const_def
const YOUR_COINS ; 0
const MOMS_COINS ; 1
const CUR_LEVEL_COINS ; 1
const MOMS_COINS ; 2
; checkcoins/checkchips return values
const_def
@ -22,6 +23,9 @@ DEF STRING_BUFFER_LENGTH EQU 19
const HAVE_AMOUNT ; 1
const HAVE_LESS ; 2
; givecoins/takecoins/checkcoins special amount values
DEF BLUE_RED_SPACE_COINS EQU $ffffff
; checkpokemail return values
const_def
const POKEMAIL_WRONG_MAIL ; 0

View File

@ -7,11 +7,13 @@ MACRO map
;\6: phone service flag: TRUE to prevent phone calls
;\7: time of day: a PALETTE_* constant
;\8: fishing group: a FISHGROUP_* constant
;\9: base coins: 8-bit value
db BANK(\1_MapAttributes), \2, \3
dw \1_MapAttributes
db \4, \5
dn \6, \7
db \8
db \9
ENDM
MapGroupPointers::
@ -30,8 +32,8 @@ endc
MapGroup_Level1:
table_width MAP_LENGTH, MapGroup_Level1
map Level1_Map1, TILESET_PLAYERS_ROOM, INDOOR_BUILDING, LANDMARK_LEVEL_1, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE
; map Level1_Map2, TILESET_CHAMPIONS_ROOM, INDOOR_CAVE, LANDMARK_LEVEL_2, MUSIC_GYM, TRUE, PALETTE_NITE | IN_DARKNESS, FISHGROUP_SHORE
map Level1_Map1, TILESET_PLAYERS_ROOM, INDOOR_BUILDING, LANDMARK_LEVEL_1, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE, 1
; map Level1_Map2, TILESET_CHAMPIONS_ROOM, INDOOR_CAVE, LANDMARK_LEVEL_2, MUSIC_GYM, TRUE, PALETTE_NITE | IN_DARKNESS, FISHGROUP_SHORE, 1
assert_table_length NUM_LEVEL_1_MAPS
; MapGroup_Level2:
@ -42,27 +44,27 @@ MapGroup_Level1:
if DEF(_DEBUG)
MapGroup_DebugLevel1:
table_width MAP_LENGTH, MapGroup_DebugLevel1
map DebugLevel1_Map1, TILESET_PLAYERS_ROOM, INDOOR_BUILDING, LANDMARK_DEBUGLEVEL_1, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE
map DebugLevel1_Map1, TILESET_PLAYERS_ROOM, INDOOR_BUILDING, LANDMARK_DEBUGLEVEL_1, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_DAY, FISHGROUP_SHORE, 1
assert_table_length NUM_DEBUGLEVEL_1_MAPS
MapGroup_DebugLevel2:
table_width MAP_LENGTH, MapGroup_DebugLevel2
map DebugLevel2_Map1, TILESET_BOARD_DEBUG_2, INDOOR_CAVE, LANDMARK_DEBUGLEVEL_2, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_NITE, FISHGROUP_SHORE
map DebugLevel2_Map2, TILESET_BOARD_DEBUG_2, INDOOR_CAVE, LANDMARK_DEBUGLEVEL_2, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_NITE, FISHGROUP_SHORE
map DebugLevel2_Map1, TILESET_BOARD_DEBUG_2, INDOOR_CAVE, LANDMARK_DEBUGLEVEL_2, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_NITE, FISHGROUP_SHORE, 2
map DebugLevel2_Map2, TILESET_BOARD_DEBUG_2, INDOOR_CAVE, LANDMARK_DEBUGLEVEL_2, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_NITE, FISHGROUP_SHORE, 2
assert_table_length NUM_DEBUGLEVEL_2_MAPS
MapGroup_DebugLevel3:
table_width MAP_LENGTH, MapGroup_DebugLevel3
map DebugLevel3_Map1, TILESET_FOREST, INDOOR_FOREST, LANDMARK_DEBUGLEVEL_3, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
map DebugLevel3_Map1, TILESET_FOREST, INDOOR_FOREST, LANDMARK_DEBUGLEVEL_3, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_AUTO, FISHGROUP_SHORE, 3
assert_table_length NUM_DEBUGLEVEL_3_MAPS
MapGroup_DebugLevel4:
table_width MAP_LENGTH, MapGroup_DebugLevel4
map DebugLevel4_Map1, TILESET_BOARD_DEBUG_1, OUTDOOR_GRASSY, LANDMARK_DEBUGLEVEL_4, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
map DebugLevel4_Map1, TILESET_BOARD_DEBUG_1, OUTDOOR_GRASSY, LANDMARK_DEBUGLEVEL_4, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_AUTO, FISHGROUP_SHORE, 4
assert_table_length NUM_DEBUGLEVEL_4_MAPS
MapGroup_DebugLevel5:
table_width MAP_LENGTH, MapGroup_DebugLevel5
map DebugLevel5_Map1, TILESET_BOARD_DEBUG_1, OUTDOOR_GRASSY, LANDMARK_DEBUGLEVEL_5, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_AUTO, FISHGROUP_SHORE
map DebugLevel5_Map1, TILESET_BOARD_DEBUG_1, OUTDOOR_GRASSY, LANDMARK_DEBUGLEVEL_5, MUSIC_NEW_BARK_TOWN, FALSE, PALETTE_AUTO, FISHGROUP_SHORE, 5
assert_table_length NUM_DEBUGLEVEL_5_MAPS
endc

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

View File

@ -2548,6 +2548,8 @@ wScreenSave:: ds SCREEN_META_WIDTH * SCREEN_META_HEIGHT
wCurTurn:: db
wCurSpace:: db
wCurLevelCoins:: ds 3
wCurLevelExp:: ds 3
wCurSpaceStruct:: space_struct wCurSpace
wCurSpaceStructEnd::
@ -2646,6 +2648,8 @@ wMagikarpRecordHoldersName:: ds NAME_LENGTH
wPokemonDataEnd::
wGameDataEnd::
; requirement of GiveCoins
assert HIGH(wCoins) != HIGH(wCurLevelCoins)
SECTION "Pic Animations", WRAMX