The Big One Again

Pushing everything I've done, currently doesn't build because the Galarian Birds filesize is too thicc for the section but I need to push this before I go mad
This commit is contained in:
Martha Schilling 2024-08-25 19:39:01 +01:00
parent 1466465f63
commit 14f08c941d
57 changed files with 3676 additions and 370 deletions

View file

@ -1936,6 +1936,7 @@ DrawPlayerHUDAndHPBar:
hlcoord 10, 7
call CenterMonName
call PlaceString
call PrintEXPBar
ld hl, wBattleMonSpecies
ld de, wLoadedMon
ld bc, wBattleMonDVs - wBattleMonSpecies
@ -7308,3 +7309,187 @@ MeltanIncrement:
MeltanFullJar:
text_far _MeltanFullJar
text_end
PrintEXPBar:
call CalcEXPBarPixelLength
ld a, [hQuotient + 3] ; pixel length
ld [wEXPBarPixelLength], a
ld b, a
ld c, $08
ld d, $08
coord hl, 17, 11
.loop
ld a, b
sub c
jr nc, .skip
ld c, b
jr .loop
.skip
ld b, a
ld a, $c0
add c
.loop2
ld [hld], a
dec d
ret z
ld a, b
and a
jr nz, .loop
ld a, $c0
jr .loop2
CalcEXPBarPixelLength:
ld hl, wEXPBarKeepFullFlag
bit 0, [hl]
jr z, .start
res 0, [hl]
ld a, $40
ld [hQuotient + 3], a
ret
.start
; get the base exp needed for the current level
ld a, [wPlayerBattleStatus3]
ld hl, wBattleMonSpecies
bit 3, a
jr z, .skip
ld hl, wPartyMon1
call BattleMonPartyAttr
.skip
ld a, [hl]
ld [wd0b5], a
call GetMonHeader
ld a, [wBattleMonLevel]
ld d, a
ld hl, CalcExperience
ld b, BANK(CalcExperience)
call Bankswitch
ld hl, hMultiplicand
ld de, wEXPBarBaseEXP
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
; get the exp needed to gain a level
ld a, [wBattleMonLevel]
ld d, a
inc d
ld hl, CalcExperience
ld b, BANK(CalcExperience)
call Bankswitch
; get the address of the active Pokemon's current experience
ld hl, wPartyMon1Exp
call BattleMonPartyAttr
; current exp - base exp
ld b, h
ld c, l
ld hl, wEXPBarBaseEXP
ld de, wEXPBarCurEXP
call SubThreeByteNum
; exp needed - base exp
ld bc, hMultiplicand
ld hl, wEXPBarBaseEXP
ld de, wEXPBarNeededEXP
call SubThreeByteNum
; make the divisor an 8-bit number
ld hl, wEXPBarNeededEXP
ld de, wEXPBarCurEXP + 1
ld a, [hli]
and a
jr z, .twoBytes
ld a, [hli]
ld [hld], a
dec hl
ld a, [hli]
ld [hld], a
ld a, [de]
inc de
ld [de], a
dec de
dec de
ld a, [de]
inc de
ld [de], a
dec de
xor a
ld [hli], a
ld [de], a
inc de
.twoBytes
ld a, [hl]
and a
jr z, .oneByte
srl a
ld [hli], a
ld a, [hl]
rr a
ld [hld], a
ld a, [de]
srl a
ld [de], a
inc de
ld a, [de]
rr a
ld [de], a
dec de
jr .twoBytes
.oneByte
; current exp * (8 tiles * 8 pixels)
ld hl, hMultiplicand
ld de, wEXPBarCurEXP
ld a, [de]
inc de
ld [hli], a
ld a, [de]
inc de
ld [hli], a
ld a, [de]
ld [hl], a
ld a, $40
ld [hMultiplier], a
call Multiply
; product / needed exp = pixel length
ld a, [wEXPBarNeededEXP + 2]
ld [hDivisor], a
ld b, $04
jp Divide
; calculates the three byte number starting at [bc]
; minus the three byte number starting at [hl]
; and stores it into the three bytes starting at [de]
; assumes that [hl] is smaller than [bc]
SubThreeByteNum:
call .subByte
call .subByte
.subByte
ld a, [bc]
inc bc
sub [hl]
inc hl
ld [de], a
jr nc, .noCarry
dec de
ld a, [de]
dec a
ld [de], a
inc de
.noCarry
inc de
ret
; return the address of the BattleMon's party struct attribute in hl
BattleMonPartyAttr:
ld a, [wPlayerMonNumber]
ld bc, wPartyMon2 - wPartyMon1
jp AddNTimes

View file

@ -804,7 +804,6 @@ ThrashPetalDanceEffect:
inc a
ld [de], a ; set thrash/petal dance counter to 2 or 3 at random
ldh a, [hWhoseTurn]
add SHRINKING_SQUARE_ANIM
jp PlayBattleAnimation2
SwitchAndTeleportEffect:

View file

@ -167,6 +167,7 @@ GainExperience:
xor a ; PLAYER_PARTY_DATA
ld [wMonDataLocation], a
call LoadMonData
call AnimateEXPBar
pop hl
ld bc, wPartyMon1Level - wPartyMon1Exp
add hl, bc
@ -177,6 +178,7 @@ GainExperience:
ld [wTempLevel], a
cp d
jp z, .nextMon ; if level didn't change, go to next mon
call KeepEXPBarFull
ld a, [wCurEnemyLVL]
push af
push hl
@ -399,3 +401,71 @@ GrewLevelText:
text_far _GrewLevelText
sound_level_up
text_end
AnimateEXPBarAgain:
call IsCurrentMonBattleMon
ret nz
xor a
ld [wEXPBarPixelLength], a
coord hl, 17, 11
ld a, $c0
ld c, $08
.loop
ld [hld], a
dec c
jr nz, .loop
AnimateEXPBar:
call IsCurrentMonBattleMon
ret nz
ld a, SFX_HEAL_HP
call PlaySoundWaitForCurrent
ld hl, CalcEXPBarPixelLength
ld b, BANK(CalcEXPBarPixelLength)
call Bankswitch
ld hl, wEXPBarPixelLength
ld a, [hl]
ld b, a
ld a, [hQuotient + 3]
ld [hl], a
sub b
jr z, .done
ld b, a
ld c, $08
coord hl, 17, 11
.loop1
ld a, [hl]
cp $c8
jr nz, .loop2
dec hl
dec c
jr z, .done
jr .loop1
.loop2
inc a
ld [hl], a
call DelayFrame
dec b
jr z, .done
jr .loop1
.done
ld bc, $08
coord hl, 10, 11
ld de, wTileMapBackup + 10 + 11 * 20
call CopyData
ld c, $20
jp DelayFrames
KeepEXPBarFull:
call IsCurrentMonBattleMon
ret nz
ld a, [wEXPBarKeepFullFlag]
set 0, a
ld [wEXPBarKeepFullFlag], a
ret
IsCurrentMonBattleMon:
ld a, [wPlayerMonNumber]
ld b, a
ld a, [wWhichPokemon]
cp b
ret

View file

@ -196,7 +196,7 @@ DebugItemsList:
db CARD_KEY, 1
db S_S_TICKET, 1
db CITRINE_PASS, 1
db SUPER_ROD, 1
db FISHING_ROD, 1
db COIN_CASE, 1
db POKE_FLUTE, 1
db SILPH_SCOPE, 1

View file

@ -72,7 +72,7 @@ ItemUsePtrTable:
dw ItemUseMedicine ; REVIVE
dw ItemUseMedicine ; MAX_REVIVE
dw ItemUseGuardSpec ; GUARD_SPEC
dw ItemUseSuperRepel ; SUPER_REPL
dw ItemUseSuperRepel ; SUPER_REPEL
dw ItemUseMaxRepel ; MAX_REPEL
dw ItemUseDireHit ; DIRE_HIT
dw UnusableItem ; COIN
@ -92,10 +92,10 @@ ItemUsePtrTable:
dw ItemUsePokeflute ; POKE_FLUTE
dw UnusableItem ; LIFT_KEY
dw UnusableItem ; EXP_ALL
dw ItemUseCandyJar ; was OLD_ROD, now CANDY_JAR
dw UnusableItem ; was GOOD_ROD, now BOTTLE_CAP
dw ItemUseSuperRod ; SUPER_ROD
dw ItemUsePPUp ; PP_UP (real one)
dw ItemUseCandyJar ; was OLD_ROD, now CANDY_JAR
dw UnusableItem ; was GOOD_ROD, now BOTTLE_CAP
dw ItemUseFishingRod ; FISHING_ROD
dw ItemUsePPUp ; PP_UP
dw ItemUsePPRestore ; ETHER
dw ItemUsePPRestore ; MAX_ETHER
dw ItemUsePPRestore ; ELIXER
@ -110,11 +110,11 @@ ItemUsePtrTable:
dw ItemUseEvoStone ; UP_GRADE
dw ItemUseEvoStone ; METAL_COAT
dw ItemUseMysteryBox ; MYSTERY_BOX
dw UnusableItem ; TEA
dw ItemUseLetter ; SILPHLETTER
dw UnusableItem ; TEA
dw ItemUseLetter ; SILPHLETTER
dw UnusableItem ; FLOOR_B2F
dw UnusableItem ; FLOOR_B1F
dw UnusableItem ; FLOOR_1F
dw UnusableItem ; FLOOR_1F
dw UnusableItem ; FLOOR_2F
dw UnusableItem ; FLOOR_3F
dw UnusableItem ; FLOOR_4F
@ -851,6 +851,10 @@ SurfingGotOnText:
text_far _SurfingGotOnText
text_end
SurfingGotOnLaprasText:
text_far _SurfingGotOnLaprasText
text_end
SurfingNoPlaceToGetOffText:
text_far _SurfingNoPlaceToGetOffText
text_end
@ -1986,16 +1990,31 @@ CoinCaseNumCoinsText:
;INCLUDE "data/wild/good_rod.asm"
ItemUseSuperRod:
ItemUseFishingRod:
call FishingInit
jp c, ItemUseNotTime
call ReadSuperRodData
ld a, e
call ReadFishingRodData
ld c, e
ld b, d
ld a, $2
ld [wRodResponse], a
ld a, c
and a ; are there fish in the map?
jr z, DoNotGenerateFishingEncounter ; if not, do not generate an encounter
ld a, $1
ld [wRodResponse], a
call Random
and $1
jr nz, RodResponse
xor a
ld [wRodResponse], a
jr DoNotGenerateFishingEncounter
RodResponse:
ld [wRodResponse], a
dec a ; is there a bite?
jr nz, .next
jr nz, DoNotGenerateFishingEncounter
; if yes, store level and species data
ld a, 1
ld [wMoveMissed], a
@ -2004,7 +2023,7 @@ RodResponse:
ld a, c ; species
ld [wCurOpponent], a
.next
DoNotGenerateFishingEncounter:
ld hl, wWalkBikeSurfState
ld a, [hl] ; store the value in a
push af
@ -2029,7 +2048,7 @@ FishingInit:
ret c
ld a, [wWalkBikeSurfState]
cp 2 ; Surfing?
jr z, .surfing
jr z, .cannotFish
call ItemUseReloadOverworldData
ld hl, ItemUseText00
call PrintText
@ -2039,7 +2058,7 @@ FishingInit:
call DelayFrames
and a
ret
.surfing
.cannotFish
scf ; can't fish when surfing
ret
@ -2971,52 +2990,47 @@ IsNextTileShoreOrWater:
INCLUDE "data/tilesets/water_tilesets.asm"
ReadSuperRodData:
; return e = 2 if no fish on this map
; return e = 1 if a bite, bc = level,species
; return e = 0 if no bite
ReadFishingRodData:
ld a, [wCurMap]
ld de, 3 ; each fishing group is three bytes wide
ld hl, SuperRodData
call IsInArray
jr c, .ReadFishingGroup
ld e, $2 ; $2 if no fishing groups found
ret
.ReadFishingGroup
; hl points to the fishing group entry in the index
inc hl ; skip map id
; read fishing group address
ld a, [hli]
ld h, [hl]
ld l, a
ld b, [hl] ; how many mons in group
inc hl ; point to data
ld e, $0 ; no bite yet
.RandomLoop
call Random
srl a
ret c ; 50% chance of no battle
and %11 ; 2-bit random number
cp b
jr nc, .RandomLoop ; if a is greater than the number of mons, regenerate
; get the mon
add a
ld c, a
ld b, $0
add hl, bc
ld b, [hl] ; level
inc hl
ld c, [hl] ; species
ld e, $1 ; $1 if there's a bite
ld hl, FishingRodSlots
.loop
ld a, [hli]
cp $ff
jr z, .notfound
cp c
jr z, .found
ld de, $8
add hl, de
jr .loop
.found
call GenerateRandomFishingEncounter
ret
.notfound
ld de, $0
ret
INCLUDE "data/wild/super_rod.asm"
GenerateRandomFishingEncounter:
call Random
cp $66
jr c, .asm_f5ed6
inc hl
inc hl
cp $b2
jr c, .asm_f5ed6
inc hl
inc hl
cp $e5
jr c, .asm_f5ed6
inc hl
inc hl
.asm_f5ed6
ld e, [hl]
inc hl
ld d, [hl]
ret
INCLUDE "data/wild/fishing_rod.asm"
; reloads map view and processes sprite data
; for items that cause the overworld to be displayed

View file

@ -72,6 +72,8 @@ ExitPlayerPC:
call WaitForSoundToFinish
.next
ld hl, wFlags_0xcd60
res 2, [hl]
res 4, [hl]
res 5, [hl]
call LoadScreenTilesFromBuffer2
xor a
@ -94,6 +96,9 @@ PlayerPCDeposit:
call PrintText
jp PlayerPCMenu
.loop
ld hl, wFlags_0xcd60
set 2, [hl]
res 4, [hl]
ld hl, WhatToDepositText
call PrintText
ld hl, wNumBagItems
@ -106,6 +111,7 @@ PlayerPCDeposit:
ld a, ITEMLISTMENU
ld [wListMenuID], a
call DisplayListMenuID
jp nz, .sortItems
jp c, PlayerPCMenu
call IsKeyItem
ld a, 1
@ -120,6 +126,9 @@ PlayerPCDeposit:
cp $ff
jp z, .loop
.next
ld hl, wFlags_0xcd60
res 2, [hl]
res 4, [hl]
ld hl, wNumBoxItems
call AddItemToInventory
jr c, .roomAvailable
@ -136,7 +145,9 @@ PlayerPCDeposit:
ld hl, ItemWasStoredText
call PrintText
jp .loop
.sortItems
call SortItems
jp .loop
PlayerPCWithdraw:
xor a
ld [wCurrentMenuItem], a
@ -148,6 +159,9 @@ PlayerPCWithdraw:
call PrintText
jp PlayerPCMenu
.loop
ld hl, wFlags_0xcd60
set 2, [hl]
set 4, [hl]
ld hl, WhatToWithdrawText
call PrintText
ld hl, wNumBoxItems
@ -160,6 +174,7 @@ PlayerPCWithdraw:
ld a, ITEMLISTMENU
ld [wListMenuID], a
call DisplayListMenuID
jp nz, .sortItems
jp c, PlayerPCMenu
call IsKeyItem
ld a, 1
@ -174,6 +189,9 @@ PlayerPCWithdraw:
cp $ff
jp z, .loop
.next
ld hl, wFlags_0xcd60
res 2, [hl]
res 4, [hl]
ld hl, wNumBagItems
call AddItemToInventory
jr c, .roomAvailable
@ -190,7 +208,9 @@ PlayerPCWithdraw:
ld hl, WithdrewItemText
call PrintText
jp .loop
.sortItems
call SortItems
jp .loop
PlayerPCToss:
xor a
ld [wCurrentMenuItem], a
@ -202,6 +222,9 @@ PlayerPCToss:
call PrintText
jp PlayerPCMenu
.loop
ld hl, wFlags_0xcd60
set 2, [hl]
set 4, [hl]
ld hl, WhatToTossText
call PrintText
ld hl, wNumBoxItems
@ -216,6 +239,7 @@ PlayerPCToss:
push hl
call DisplayListMenuID
pop hl
jp nz, .sortItems
jp c, PlayerPCMenu
push hl
call IsKeyItem
@ -237,8 +261,14 @@ PlayerPCToss:
cp $ff
jp z, .loop
.next
ld hl, wFlags_0xcd60
res 2, [hl]
res 4, [hl]
call TossItem ; disallows tossing key items
jp .loop
.sortItems
call SortItems
jp .loop
PlayersPCMenuEntries:
db "WITHDRAW ITEM"

View file

@ -319,6 +319,9 @@ StartMenu_Item::
call PrintText
jr .exitMenu
.notInCableClubRoom
ld hl,wFlags_0xcd60
set 2, [hl]
res 4, [hl]
ld bc, wNumBagItems
ld hl, wListPointer
ld a, c
@ -336,6 +339,9 @@ StartMenu_Item::
ld [wBagSavedMenuItem], a
jr nc, .choseItem
.exitMenu
ld hl,wFlags_0xcd60
res 2, [hl]
res 4, [hl]
call LoadScreenTilesFromBuffer2 ; restore saved screen
call LoadTextBoxTilePatterns
call UpdateSprites

View file

@ -179,7 +179,7 @@ SortItems::
ld de, 0
ld hl, ItemSortList
ld b, [hl] ; This is the first item to check for
ld hl, wBagItems
call .ldHLbagorbox
ld c, 0 ; Relative to wBagItems, this is where we'd like to begin swapping
.loopCurrItemInBag
ld a, [hl] ; Load the value of hl to a (which is an item number) and Increments to the quantity
@ -196,7 +196,7 @@ SortItems::
ld hl, ItemSortList
add hl, de
ld b, [hl]
ld hl, wBagItems ; Resets hl to start at the beginning of the bag
call .ldHLbagorbox ; Resets hl to start at the beginning of the bag
ld a, b
cp -1 ; Check if we got through all of the items, to the last one
jr z, .finishedSwapping
@ -207,7 +207,7 @@ SortItems::
push de
ld d, h
ld e, l
ld hl, wBagItems
call .ldHLbagorbox
ld a, b
ld b, 0
add hl, bc ; hl now holds where we'd like to swap to
@ -240,6 +240,15 @@ SortItems::
pop de
jr .findNextItem
;Allow for sorting both the bag and the item PC box
.ldHLbagorbox
ld hl, wBagItems
ld a, [wFlags_0xcd60]
bit 4, a
ret z
ld hl, wBoxItems
ret
SortItemsText::
text_far _SortItemsText
db "@"
@ -255,7 +264,7 @@ NothingToSort::
ItemSortList::
; Used Key Items
db BICYCLE
db SUPER_ROD
db FISHING_ROD
db POCKET_LAPRAS
db ITEMFINDER
db TOWN_MAP

View file

@ -129,13 +129,13 @@ DisplayTitleScreen:
call Random
ldh a, [hRandomSub]
cp 129
jr c, .notshocks
ld a, SANDY_SHOCKS
jr c, .notscreamtail
ld a, SCREAM_TAIL
ld [wTitleMonSpecies], a
call LoadTitleMonSprite
jr .skip
.notshocks
ld a, SCREAM_TAIL
.notscreamtail
ld a, SANDY_SHOCKS
ld [wTitleMonSpecies], a
call LoadTitleMonSprite
.skip

View file

@ -69,8 +69,25 @@ UpdatePlayerSprite:
ld a, [hl]
inc a
ld [hl], a
cp 4
jr nz, .calcImageIndex
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;joenote - If B is being held to go faster and full joypad is enabled (i.e. not in a cutscene),
;Then increase player animation speed by 25%
push bc
ld c, 4
ld b, a
ld a, [wJoyIgnore]
and a
jr nz, .doneSpeed
ld a, [hJoyHeld]
and B_BUTTON
jr z, .doneSpeed
ld c, 3
.doneSpeed
ld a, b
cp c
pop bc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
jr c, .calcImageIndex ;joenote - prevents interframe counter from increasing forever
xor a
ld [hl], a
inc hl