Skip to content

Commit

Permalink
Commented/labelled misc functions
Browse files Browse the repository at this point in the history
  • Loading branch information
YamaArashi committed Sep 14, 2014
1 parent 0c916ae commit 2ed65d9
Show file tree
Hide file tree
Showing 114 changed files with 733 additions and 668 deletions.
20 changes: 5 additions & 15 deletions constants/hardware_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,17 @@

GBC EQU $11

; MBC3
MBC3SRamEnable EQU $0000
MBC3RomBank EQU $2000
MBC3SRamBank EQU $4000
MBC3LatchClock EQU $6000
MBC3RTC EQU $a000
; MBC1
MBC1SRamEnable EQU $0000
MBC1RomBank EQU $2000
MBC1SRamBank EQU $4000
MBC1SRamBankingMode EQU $6000

SRAM_DISABLE EQU $00
SRAM_ENABLE EQU $0a

NUM_SRAM_BANKS EQU 4

RTC_S EQU $08 ; Seconds 0-59 (0-3Bh)
RTC_M EQU $09 ; Minutes 0-59 (0-3Bh)
RTC_H EQU $0a ; Hours 0-23 (0-17h)
RTC_DL EQU $0b ; Lower 8 bits of Day Counter (0-FFh)
RTC_DH EQU $0c ; Upper 1 bit of Day Counter, Carry Bit, Halt Flag
; Bit 0 Most significant bit of Day Counter (Bit 8)
; Bit 6 Halt (0=Active, 1=Stop Timer)
; Bit 7 Day Counter Carry Bit (1=Counter Overflow)

; interrupt flags
VBLANK EQU 0
LCD_STAT EQU 1
Expand Down
2 changes: 1 addition & 1 deletion engine/battle/14.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Func_525af: ; 525af (14:65af)
ld a, [$ffd7]
ld a, [hTilesetType]
ld [wd0d4], a
xor a
ld [wcd6a], a
Expand Down
8 changes: 4 additions & 4 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c)
ld [hVBlankWY], a
ld [rWY], a
xor a
ld [$ffd7], a
ld [hTilesetType], a
ld [hVBlankSCY], a
dec a
ld [wUpdateSpritesEnabled], a
Expand Down Expand Up @@ -1015,7 +1015,7 @@ TrainerBattleVictory: ; 3c696 (f:4696)
call ScrollTrainerPicAfterBattle
ld c, $28
call DelayFrames
call Func_3381
call PrintEndBattleText
ld hl, MoneyForWinningText
call PrintText
ld de, wPlayerMoney + 2
Expand Down Expand Up @@ -6263,7 +6263,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32)
ld [H_AUTOBGTRANSFERENABLED], a
ld [hVBlankWY], a
ld [rWY], a
ld [$ffd7], a
ld [hTilesetType], a
ld hl, wd060
ld [hli], a
ld [hli], a
Expand Down Expand Up @@ -6851,7 +6851,7 @@ InitBattle_Common: ; 3efeb (f:6feb)
pop af
ld [wMapPalOffset], a
ld a, [wd0d4]
ld [$ffd7], a
ld [hTilesetType], a
scf
ret
.emptyString
Expand Down
2 changes: 1 addition & 1 deletion engine/cable_club.asm
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ Func_577d: ; 577d (1:577d)
dec a
ld [wDestinationWarpID], a
call LoadMapData
callba Func_c335
callba ClearVariablesAfterLoadingMapData
pop hl
pop af
ld [hl], a
Expand Down
2 changes: 1 addition & 1 deletion engine/evolution.asm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Func_7bde9: ; 7bde9 (1e:7de9)
call Delay3
xor a
ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
ld [$ffd7], a
ld [hTilesetType], a
ld a, [wHPBarMaxHP]
ld [wcf1d], a
ld c, $0
Expand Down
4 changes: 2 additions & 2 deletions engine/evos_moves.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ TryEvolvingMon: ; 3ad0e (e:6d0e)
; this is only called after battle
; it is supposed to do level up evolutions, though there is a bug that allows item evolutions to occur
EvolutionAfterBattle: ; 3ad1c (e:6d1c)
ld a, [$ffd7]
ld a, [hTilesetType]
push af
xor a
ld [wd121], a
Expand Down Expand Up @@ -245,7 +245,7 @@ Evolution_PartyMonLoop: ; loop over party mons
pop bc
pop hl
pop af
ld [$ffd7], a
ld [hTilesetType], a
ld a, [W_ISLINKBATTLE]
cp $32
ret z
Expand Down
2 changes: 1 addition & 1 deletion engine/hall_of_fame.asm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0)
call FillMemory
xor a
ld [wUpdateSpritesEnabled], a
ld [$ffd7], a
ld [hTilesetType], a
ld [W_SPRITEFLIPPED], a
ld [wd358], a
ld [wTrainerScreenY], a
Expand Down
2 changes: 1 addition & 1 deletion engine/hidden_object_functions18.asm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ PrintBenchGuyText: ; 6245d (18:645d)
ld a, [hl]
jp PrintPredefTextID

; format: db map id, 08, text id of PointerTable_3f22
; format: db map id, 08, text id of PredefTextIDPointerTable
PokeCenterMapIDList: ; 6247e (18:647e)
db VIRIDIAN_POKECENTER,$08,$0F
db PEWTER_POKECENTER,$08,$10
Expand Down
27 changes: 14 additions & 13 deletions engine/hidden_object_functions3.asm
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
; prints text for bookshelves in buildings without sign events
PrintBookshelfText: ; fb50 (3:7b50)
ld a, [wSpriteStateData1 + 9]
cp $4
jr nz, .asm_fb7f
ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
cp SPRITE_FACING_UP
jr nz, .noMatch
; facing up
ld a, [W_CURMAPTILESET]
ld b, a
aCoord 8, 7
ld c, a
ld hl, BookshelfTileIDs ; $7b8b
.asm_fb62
ld hl, BookshelfTileIDs
.loop
ld a, [hli]
cp $ff
jr z, .asm_fb7f
jr z, .noMatch
cp b
jr nz, .asm_fb7b
jr nz, .nextBookshelfEntry1
ld a, [hli]
cp c
jr nz, .asm_fb7c
jr nz, .nextBookshelfEntry2
ld a, [hl]
push af
call EnableAutoTextBoxDrawing
Expand All @@ -25,12 +26,12 @@ PrintBookshelfText: ; fb50 (3:7b50)
xor a
ld [$ffdb], a
ret
.asm_fb7b
.nextBookshelfEntry1
inc hl
.asm_fb7c
.nextBookshelfEntry2
inc hl
jr .asm_fb62
.asm_fb7f
jr .loop
.noMatch
ld a, $ff
ld [$ffdb], a
ld b, BANK(PrintCardKeyText)
Expand Down
6 changes: 3 additions & 3 deletions engine/hidden_object_functions7.asm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ SafariZoneCheckSteps: ; 1e997 (7:6997)
ld [wSafariSteps + 1], a ; wd70e
asm_1e9ab: ; 1e9ab (7:69ab)
xor a
ld [wda46], a
ld [wSafariZoneGameOver], a
ret
asm_1e9b0: ; 1e9b0 (7:69b0)
call EnableAutoTextBoxDrawing
Expand Down Expand Up @@ -89,7 +89,7 @@ asm_1e9b0: ; 1e9b0 (7:69b0)
ld hl, wd790
set 6, [hl]
ld a, $1
ld [wda46], a
ld [wSafariZoneGameOver], a
ret

PrintSafariGameOverText: ; 1e9ed (7:69ed)
Expand Down Expand Up @@ -291,7 +291,7 @@ CinnabarGymQuiz_1eb0a: ; 1eb0a (7:6b0a)
.asm_1eb38
pop bc
ld [wd09f], a
predef Func_ee9e
predef ReplaceTileBlock
ld hl, $ffdb
dec [hl]
jr nz, .asm_1eb0e
Expand Down
2 changes: 1 addition & 1 deletion engine/in_game_trades.asm
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Func_71c07: ; 71c07 (1c:5c07)
callab EvolveTradeMon
call ClearScreen
call Func_71ca2
callba Func_eedc
callba RedrawMapView
and a
ld a,$3
jr .asm_ee803 ; 0x71c9b $1
Expand Down
2 changes: 1 addition & 1 deletion engine/menu/bills_pc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ Func_21673: ; 21673 (8:5673)
jp Func_214e8

Func_216b3: ; 216b3 (8:56b3)
callba Func_738a1
callba ChangeBox
jp Func_214e8

Func_216be: ; 216be (8:56be)
Expand Down
6 changes: 3 additions & 3 deletions engine/menu/league_pc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ PKMNLeaguePC: ; 0x7657e
push hl
ld a, [wUpdateSpritesEnabled]
push af
ld a, [$ffD7]
ld a, [hTilesetType]
push af
xor a
ld [$ffD7], a
ld [hTilesetType], a
ld [W_SPRITEFLIPPED], a
ld [wUpdateSpritesEnabled], a
ld [wTrainerScreenX], a
Expand Down Expand Up @@ -38,7 +38,7 @@ PKMNLeaguePC: ; 0x7657e
jr nz, .first
.second
pop af
ld [$ffD7], a
ld [hTilesetType], a
pop af
ld [wUpdateSpritesEnabled], a
pop hl
Expand Down
6 changes: 3 additions & 3 deletions engine/menu/pokedex.asm
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
call GoPAL_SET
pop af
ld [wd11e],a
ld a,[$ffd7]
ld a,[hTilesetType]
push af
xor a
ld [$ffd7],a
ld [hTilesetType],a
hlCoord 0, 0
ld de,1
ld bc,$6414
Expand Down Expand Up @@ -554,7 +554,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
and a,%00000011 ; A button and B button
jr z,.waitForButtonPress
pop af
ld [$ffd7],a
ld [hTilesetType],a
call GBPalWhiteOut
call ClearScreen
call GoPAL_SET_CF1C
Expand Down
6 changes: 3 additions & 3 deletions engine/menu/start_sub_menus.asm
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,10 @@ StartMenu_TrainerInfo: ; 13460 (4:7460)
call GBPalWhiteOut
call ClearScreen
call UpdateSprites ; move sprites
ld a,[$ffd7]
ld a,[hTilesetType]
push af
xor a
ld [$ffd7],a
ld [hTilesetType],a
call DrawTrainerInfo
predef DrawBadges ; draw badges
ld b,$0d
Expand All @@ -517,7 +517,7 @@ StartMenu_TrainerInfo: ; 13460 (4:7460)
call ReloadMapData
call LoadGBPal
pop af
ld [$ffd7],a
ld [hTilesetType],a
jp RedisplayStartMenu

; loads tile patterns and draws everything except for gym leader faces / badges
Expand Down
12 changes: 6 additions & 6 deletions engine/menu/status_screen.asm
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ StatusScreen: ; 12953 (4:6953)
ld hl, vChars2 + $720
ld bc,(BANK(PTile) << 8 | $01)
call CopyVideoDataDouble ; P (for PP), inline
ld a, [$ffd7]
ld a, [hTilesetType]
push af
xor a
ld [$ffd7], a
ld [hTilesetType], a
hlCoord 19, 1
ld bc, $060a
call DrawLineBox ; Draws the box around name, HP and status
Expand Down Expand Up @@ -109,7 +109,7 @@ StatusScreen: ; 12953 (4:6953)
call PlayCry ; play Pokémon cry
call WaitForTextScrollButtonPress ; wait for button
pop af
ld [$ffd7], a
ld [hTilesetType], a
ret
.unk_12a7e ; 0x12a7e ; I don't know what this does, iterates over pointers?
ld a, [wcc49]
Expand Down Expand Up @@ -227,10 +227,10 @@ StatsText: ; 12b3a (4:6b3a)
next "SPECIAL@"

StatusScreen2: ; 12b57 (4:6b57)
ld a, [$ffd7]
ld a, [hTilesetType]
push af
xor a
ld [$ffd7], a
ld [hTilesetType], a
ld [$ffba], a
ld bc, $0005
ld hl, wd0dc
Expand Down Expand Up @@ -360,7 +360,7 @@ StatusScreen2: ; 12b57 (4:6b57)
call Delay3
call WaitForTextScrollButtonPress ; wait for button
pop af
ld [$ffd7], a
ld [hTilesetType], a
ld hl, wd72c
res 1, [hl]
ld a, $77
Expand Down
2 changes: 1 addition & 1 deletion engine/oak_speech.asm
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ OakSpeech: ; 6115 (1:6115)
ld [wDestinationMap],a
call SpecialWarpIn
xor a
ld [$FFD7],a
ld [hTilesetType],a
ld a,[wd732]
bit 1,a ; XXX when is bit 1 set?
jp nz,Func_61bc ; easter egg: skip the intro
Expand Down
Loading

0 comments on commit 2ed65d9

Please sign in to comment.