diff options
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | charmap.asm | 4 | ||||
-rw-r--r-- | engine/gfx/load_pics.asm | 12 | ||||
-rw-r--r-- | engine/pokemon/correct_nick_errors.asm | 2 | ||||
-rw-r--r-- | gfx/lz.mk | 2 | ||||
-rw-r--r-- | home/game_time.asm | 1 | ||||
-rw-r--r-- | home/gfx.asm | 34 | ||||
-rw-r--r-- | home/init.asm | 6 | ||||
-rw-r--r-- | home/map.asm | 2 | ||||
-rw-r--r-- | home/menu.asm | 3 | ||||
-rw-r--r-- | home/palettes.asm | 8 | ||||
-rw-r--r-- | home/print_num.asm | 36 | ||||
-rw-r--r-- | home/print_text.asm | 35 | ||||
-rw-r--r-- | home/region.asm | 8 | ||||
-rw-r--r-- | home/text.asm | 2 | ||||
-rw-r--r-- | home/tilemap.asm | 2 | ||||
-rw-r--r-- | home/vblank.asm | 15 | ||||
-rw-r--r-- | home/video.asm | 3 | ||||
-rw-r--r-- | macros/data.asm | 18 | ||||
-rw-r--r-- | wram.asm | 3 |
20 files changed, 108 insertions, 92 deletions
@@ -1,4 +1,4 @@ -# Pokémon Gold and Silver +# Pokémon Gold and Silver [![Build Status][travis-badge]][travis] This is a disassembly of Pokémon Gold and Pokémon Silver. @@ -35,3 +35,5 @@ Other disassembly projects: [pokeemerald]: https://github.com/pret/pokeemerald [discord]: https://discord.gg/d5dubZ3 [irc]: https://kiwiirc.com/client/irc.freenode.net/?#pret +[travis]: https://travis-ci.org/pret/pokegold +[travis-badge]: https://travis-ci.org/pret/pokegold.svg?branch=master diff --git a/charmap.asm b/charmap.asm index 728f7f3f..a3616d85 100644 --- a/charmap.asm +++ b/charmap.asm @@ -3,7 +3,6 @@ ; Control characters (see home/text.asm) charmap "<NULL>", $00 - charmap "<PLAY_G>", $14 ; "<PLAYER>くん" or "<PLAYER>ちゃん"; same as "<PLAYER>" in English charmap "<CR>", $16 charmap "¯", $1f ; soft linebreak charmap "<LF>", $22 @@ -210,7 +209,8 @@ ; Japanese control characters (see home/text.asm) - charmap "<JP_18>", $18 ; "ノ゛"? (ungrammatical) + charmap "<JP_14>", $14 ; "ナ゙" (ungrammatical) + charmap "<JP_18>", $18 ; "ノ゛" (ungrammatical) charmap "<NI>", $1d ; "に " charmap "<TTE>", $1e ; "って" charmap "<WO>", $1f ; "を " diff --git a/engine/gfx/load_pics.asm b/engine/gfx/load_pics.asm index 8b9f4f6a..869dc988 100644 --- a/engine/gfx/load_pics.asm +++ b/engine/gfx/load_pics.asm @@ -185,9 +185,9 @@ FixPicBank: ; Postcondition: a = repaired bank for pic ; ; Pic bank values that will get repaired (and what they'll be repaired to): -; $13 -> $1f -; $14 -> $20 -; $1f -> $2e +; $13 -> BANK("Pics 12") +; $14 -> BANK("Pics 13") +; $1f -> BANK("Pics 14") ; ; Otherwise, the repaired bank will match the defined bank. push hl @@ -211,9 +211,9 @@ FixPicBank: ret .FixPicBankTable: - db $13, $1f - db $14, $20 - db $1f, $2e + db $13, BANK("Pics 12") + db $14, BANK("Pics 13") + db $1f, BANK("Pics 14") db -1 Intro_GetMonFrontpic: diff --git a/engine/pokemon/correct_nick_errors.asm b/engine/pokemon/correct_nick_errors.asm index 421bf92d..e7635c1d 100644 --- a/engine/pokemon/correct_nick_errors.asm +++ b/engine/pokemon/correct_nick_errors.asm @@ -65,7 +65,7 @@ CorrectNickErrors:: ; format: ; ≥ < db "<NULL>", "ガ" - db "<PLAY_G>", "<JP_18>" + 1 + db "<JP_14>", "<JP_18>" + 1 db "<NI>", "<NO>" + 1 db "<ROUTE>", "<GREEN>" + 1 db "<ENEMY>", "<ENEMY>" + 1 @@ -10,7 +10,7 @@ gfx/diploma/diploma.2bpp.lz: LZFLAGS += --method 8 --align 1 gfx/dummy_game/dummy_game.2bpp.lz: LZFLAGS += --method 2 --align 4 -gfx/intro/%.2bpp.lz: LZFLAGS += --align 4 +gfx/intro/%.lz: LZFLAGS += --align 4 gfx/intro/water1.2bpp.lz: LZFLAGS += --method 2 --align 4 gfx/new_game/shrink1.2bpp.lz: LZFLAGS += --align 4 diff --git a/home/game_time.asm b/home/game_time.asm index 3751e4a4..b0039952 100644 --- a/home/game_time.asm +++ b/home/game_time.asm @@ -11,7 +11,6 @@ ResetGameTime:: GameTimer:: nop -UpdateGameTimer:: ; Increment the game timer by one frame. ; The game timer is capped at 999:59:59.00. diff --git a/home/gfx.asm b/home/gfx.asm index a1a2dee2..3ba6dbfe 100644 --- a/home/gfx.asm +++ b/home/gfx.asm @@ -1,3 +1,5 @@ +TILES_PER_CYCLE EQU 8 + FarCopyBytesDouble_DoubleBankSwitch:: ld b, a ldh a, [hROMBank] @@ -8,7 +10,7 @@ FarCopyBytesDouble_DoubleBankSwitch:: ld a, BANK(sDecompressBuffer) call OpenSRAM ld hl, sDecompressBuffer - ld bc, 7 * 7 * $10 + ld bc, 7 * 7 tiles xor a call ByteFill @@ -130,9 +132,9 @@ Request2bpp:: ld [wRequested2bppDest], a ld a, h ld [wRequested2bppDest + 1], a -.check +.loop ld a, c - cp 8 ; TilesPerCycle + cp TILES_PER_CYCLE jr nc, .cycle ld [wRequested2bpp], a @@ -146,14 +148,14 @@ Request2bpp:: ret .cycle - ld a, 8 ; TilesPerCycle + ld a, TILES_PER_CYCLE ld [wRequested2bpp], a call DelayFrame ld a, c - sub 8 ; TilesPerCycle + sub TILES_PER_CYCLE ld c, a - jr .check + jr .loop Request1bpp:: ; Load 1bpp at b:de to occupy c tiles of hl. @@ -175,9 +177,9 @@ Request1bpp:: ld [wRequested1bppDest], a ld a, h ld [wRequested1bppDest + 1], a -.check +.loop ld a, c - cp 8 ; TilesPerCycle + cp TILES_PER_CYCLE jr nc, .cycle ld [wRequested1bpp], a @@ -191,14 +193,14 @@ Request1bpp:: ret .cycle - ld a, 8 ; TilesPerCycle + ld a, TILES_PER_CYCLE ld [wRequested1bpp], a call DelayFrame ld a, c - sub 8 ; TilesPerCycle + sub TILES_PER_CYCLE ld c, a - jr .check + jr .loop Get2bpp:: ldh a, [rLCDC] @@ -216,7 +218,7 @@ Copy2bpp: ; bank ld a, b -; bc = c * $10 +; bc = c * LEN_2BPP_TILE push af swap c ld a, $f @@ -244,7 +246,7 @@ Copy1bpp:: ; bank ld a, b -; bc = c * $10 / 2 +; bc = c * LEN_1BPP_TILE push af ld h, 0 ld l, c @@ -258,19 +260,19 @@ Copy1bpp:: pop hl jp FarCopyBytesDouble -UnusedGet2bpp:: +Unreferenced_Get2bpp:: ldh a, [rLCDC] add a jp c, Request2bpp -UnusedCopy2bpp:: +Unreferenced_Copy2bpp:: push de push hl ; bank ld a, b -; bc = c * $10 +; bc = c * LEN_2BPP_TILE ld h, 0 ld l, c add hl, hl diff --git a/home/init.asm b/home/init.asm index 497e13c7..8c51e9dc 100644 --- a/home/init.asm +++ b/home/init.asm @@ -16,11 +16,11 @@ Reset:: _Start:: cp $11 jr z, .cgb - xor a + xor a ; FALSE jr .load .cgb - ld a, $1 + ld a, TRUE .load ldh [hCGB], a @@ -145,7 +145,7 @@ Init:: call DelayFrame - predef InitSGBBorder ; SGB init + predef InitSGBBorder call InitSound xor a diff --git a/home/map.asm b/home/map.asm index d3a67c71..b158f3a5 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1233,6 +1233,8 @@ LoadTilesetGFX:: ld de, vTiles2 ld a, [wTilesetBank] call FarDecompress + +; These tilesets support dynamic per-mapgroup roof tiles. ld a, [wMapTileset] cp TILESET_JOHTO jr z, .load_roof diff --git a/home/menu.asm b/home/menu.asm index 9efb2414..6aef1adf 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -345,6 +345,7 @@ VerticalMenu:: .cancel scf ret + .okay and a ret @@ -740,7 +741,7 @@ MenuClickSound:: push af and A_BUTTON | B_BUTTON jr z, .nosound - ld hl, wMenuHeader + ld hl, wMenuFlags bit 3, a jr nz, .nosound call PlayClickSFX diff --git a/home/palettes.asm b/home/palettes.asm index 41cbbde9..330233af 100644 --- a/home/palettes.asm +++ b/home/palettes.asm @@ -263,11 +263,11 @@ ReloadPalettes:: ld bc, SCREEN_WIDTH * SCREEN_HEIGHT .loop ld a, [hli] - cp $60 - jr c, .pal_map - ld a, 7 + cp "■" + jr c, .skip + ld a, PAL_BG_TEXT ld [de], a -.pal_map +.skip inc de dec bc ld a, b diff --git a/home/print_num.asm b/home/print_num.asm index 5bea7696..a1dca238 100644 --- a/home/print_num.asm +++ b/home/print_num.asm @@ -300,3 +300,39 @@ PrintNum:: .inc inc hl ret + +Unreferenced_PrintHexNumber:: +; Print c-digit hex number from de to hl +.loop + push bc + call .HandleByte + pop bc + dec c + jr nz, .loop + ret + +.HandleByte: + ld a, [de] + swap a + and $f + call .PrintDigit + ld [hli], a + ld a, [de] + and $f + call .PrintDigit + ld [hli], a + inc de + ret + +.PrintDigit: + ld bc, .HexDigits + add c + ld c, a + ld a, 0 + adc b + ld b, a + ld a, [bc] + ret + +.HexDigits: + db "0123456789ABCDEF" diff --git a/home/print_text.asm b/home/print_text.asm index 04bc8ece..df07955e 100644 --- a/home/print_text.asm +++ b/home/print_text.asm @@ -100,41 +100,6 @@ CopyDataUntil:: INCLUDE "home/print_num.asm" -Function33ce:: -; Print c-digit hex number from de to hl -.asm_33ce - push bc - call Function33d7 - pop bc - dec c - jr nz, .asm_33ce - ret - -Function33d7:: - ld a, [de] - swap a - and $f - call Function33e9 - ld [hli], a - ld a, [de] - and $f - call Function33e9 - ld [hli], a - inc de - ret - -Function33e9:: - ld bc, .digits - add c - ld c, a - ld a, $0 - adc b - ld b, a - ld a, [bc] - ret - -.digits db "0123456789ABCDEF" - FarPrintText:: ld [wTempBank], a ldh a, [hROMBank] diff --git a/home/region.asm b/home/region.asm index ee781759..b5fff82b 100644 --- a/home/region.asm +++ b/home/region.asm @@ -52,10 +52,10 @@ Function2ffe:: add $4 ld d, a ld a, [wPlayerStandingMapY] - ld a, $4 ; add $4 + ld a, $4 ; should be "add $4"? ld e, a push bc - ld c, $0 + ld c, 0 .loop ld a, [hl] cp $ff @@ -72,7 +72,7 @@ Function2ffe:: ld b, SET_FLAG push de push bc - ld d, $0 + ld d, 0 predef SmallFarFlagAction pop bc pop de @@ -83,7 +83,7 @@ Function2ffe:: inc hl inc c ld a, c - cp $20 + cp 32 jr c, .loop .done pop bc diff --git a/home/text.asm b/home/text.asm index c12bcdd6..be57ccfb 100644 --- a/home/text.asm +++ b/home/text.asm @@ -228,7 +228,7 @@ ENDM dict "<USER>", PlaceMoveUsersName dict "<ENEMY>", PlaceEnemysName dict "゚", .diacritic - cp $e5 + cp "゙" jr nz, .not_diacritic .diacritic diff --git a/home/tilemap.asm b/home/tilemap.asm index fac8d372..55b4c991 100644 --- a/home/tilemap.asm +++ b/home/tilemap.asm @@ -56,7 +56,7 @@ CGBOnly_CopyTilemapAtOnce:: ldh a, [hCGB] and a jr z, WaitBGMap -; fall through + CopyTilemapAtOnce:: ldh a, [hBGMapMode] push af diff --git a/home/vblank.asm b/home/vblank.asm index d150abf4..7e6adab0 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -1,5 +1,11 @@ ; VBlank is the interrupt responsible for updating VRAM. +; In Pokemon Gold and Silver, VBlank has been hijacked to act as the +; main loop. After time-sensitive graphics operations have been +; performed, joypad input and sound functions are executed. + +; This prevents the display and audio output from lagging. + VBlank:: push af push bc @@ -168,7 +174,7 @@ VBlank1:: jr z, .skip_lcd ld c, a ld a, [wLYOverrides] - ld [$ff00+c], a + ldh [c], a .skip_lcd xor a @@ -294,7 +300,7 @@ VBlank5:: xor a ldh [rIF], a ; enable ints - ld a, %11111 + ld a, IE_DEFAULT ldh [rIE], a ret @@ -372,9 +378,11 @@ VBlank3:: ld [wTextDelayFrames], a .okay + ; discard requested ints xor a ldh [rIF], a - ld a, %10 ; lcd stat + ; enable lcd stat + ld a, 1 << LCD_STAT ldh [rIE], a ; request lcd stat ldh [rIF], a @@ -387,6 +395,7 @@ VBlank3:: rst Bankswitch di + ; discard requested ints xor a ldh [rIF], a ; enable ints diff --git a/home/video.asm b/home/video.asm index 5354e7b6..dcf7b47c 100644 --- a/home/video.asm +++ b/home/video.asm @@ -10,8 +10,8 @@ UpdateBGMapBuffer:: and a ret z +; Relocate the stack pointer to wBGMapBufferPtrs ld [hSPBuffer], sp - ld hl, wBGMapBufferPtrs ld sp, hl @@ -59,6 +59,7 @@ endr jr nz, .next +; Restore the stack pointer ldh a, [hSPBuffer] ld l, a ldh a, [hSPBuffer + 1] diff --git a/macros/data.asm b/macros/data.asm index 36854d79..b6cedbf7 100644 --- a/macros/data.asm +++ b/macros/data.asm @@ -102,17 +102,17 @@ ENDM ; Reverses FixPicBank in engine/gfx/load_pics.asm ; -; Takes the actual bank of the pic in the ROM and returns the "defined" bank -; $1f -> $13 -; $20 -> $14 -; $2e -> $1f +; Takes the actual bank of the pic in the ROM and returns the "defined" bank: +; BANK("Pics 12") -> $13 +; BANK("Pics 13") -> $14 +; BANK("Pics 14") -> $1f ; ; Otherwise, the ROM bank will match the defined bank. dba_pic: MACRO ; dbw bank, address - db (BANK(\1) == $1f) * ($13 - $1f) \ - + (BANK(\1) == $20) * ($14 - $20) \ - + (BANK(\1) == $2e) * ($1f - $2e) \ - + (BANK(\1)) + db (BANK(\1) == BANK("Pics 12")) * ($13 - BANK("Pics 12")) \ + + (BANK(\1) == BANK("Pics 13")) * ($14 - BANK("Pics 13")) \ + + (BANK(\1) == BANK("Pics 14")) * ($1f - BANK("Pics 14")) \ + + (BANK(\1)) dw \1 ENDM @@ -128,6 +128,6 @@ sine_table: MACRO x = 0 rept \1 dw (sin(x) + (sin(x) & $ff)) >> 8 ; round up -x = x + DIV(32768, \1); a circle has 65536 "degrees" +x = x + DIV(32768, \1) ; a circle has 65536 "degrees" endr ENDM @@ -2034,8 +2034,7 @@ wScriptTextAddr:: ds 1 wWildEncounterCooldown:: db ; d179 wXYComparePointer:: dw ; d17a -wd17c:: ds 1 ; d17c - ds 3 +wd17c:: flag_array 32 ; d17c wBattleScriptFlags:: dw ; d180 wPlayerSpriteSetupFlags:: ; d182 db |