shithub: pokecrystal

Download patch

ref: c552390a15ae27a24109f369264f1caa6b9f8295
parent: 7b2515d1e47198322407081dfe57c7ca49f22c5f
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Tue Jun 16 11:49:32 EDT 2020

Harmonize home/ with pokegold

--- a/charmap.asm
+++ b/charmap.asm
@@ -211,7 +211,7 @@
 
 ; Japanese control characters (see home/text.asm)
 
-	charmap "<JP_18>",   $18 ; "ノ゛"? (ungrammatical)
+	charmap "<JP_18>",   $18 ; "ノ゛" (ungrammatical)
 	charmap "<NI>",      $1d ; "に "
 	charmap "<TTE>",     $1e ; "って"
 	charmap "<WO>",      $1f ; "を "
--- a/home/game_time.asm
+++ b/home/game_time.asm
@@ -16,13 +16,13 @@
 	ld a, BANK(wGameTime)
 	ldh [rSVBK], a
 
-	call UpdateGameTimer
+	call .Function
 
 	pop af
 	ldh [rSVBK], a
 	ret
 
-UpdateGameTimer::
+.Function
 ; Increment the game timer by one frame.
 ; The game timer is capped at 999:59:59.00.
 
--- a/home/gfx.asm
+++ b/home/gfx.asm
@@ -1,4 +1,5 @@
-; Functions to copy data from ROM.
+TILES_PER_CYCLE EQU 8
+MOBILE_TILES_PER_CYCLE EQU 6
 
 Get2bppViaHDMA::
 	ldh a, [rLCDC]
@@ -31,7 +32,7 @@
 	rst Bankswitch
 	ret
 
-UnreferencedOldDMATransfer:
+Unreferenced_DMATransfer:
 	dec c
 	ldh a, [hBGMapMode]
 	push af
@@ -55,12 +56,12 @@
 	ld a, l
 	and $f0
 	ldh [rHDMA4], a ; target LSB
-; stop when c < 8
+; stop when c < TILES_PER_CYCLE
 	ld a, c
-	cp $8
+	cp TILES_PER_CYCLE
 	jr c, .done
-; decrease c by 8
-	sub $8
+; decrease c by TILES_PER_CYCLE
+	sub TILES_PER_CYCLE
 	ld c, a
 ; DMA transfer state
 	ld a, $f
@@ -198,7 +199,7 @@
 
 	ldh a, [hTilesPerCycle]
 	push af
-	ld a, $8
+	ld a, TILES_PER_CYCLE
 	ldh [hTilesPerCycle], a
 
 	ld a, [wLinkMode]
@@ -207,7 +208,7 @@
 	ldh a, [hMobile]
 	and a
 	jr nz, .NotMobile
-	ld a, $6
+	ld a, MOBILE_TILES_PER_CYCLE
 	ldh [hTilesPerCycle], a
 
 .NotMobile:
@@ -223,7 +224,7 @@
 	ld a, c
 	ld hl, hTilesPerCycle
 	cp [hl]
-	jr nc, .iterate
+	jr nc, .cycle
 
 	ld [wRequested2bpp], a
 .wait
@@ -242,7 +243,7 @@
 	ldh [hBGMapMode], a
 	ret
 
-.iterate
+.cycle
 	ldh a, [hTilesPerCycle]
 	ld [wRequested2bpp], a
 
@@ -272,7 +273,7 @@
 
 	ldh a, [hTilesPerCycle]
 	push af
-	ld a, $8
+	ld a, TILES_PER_CYCLE
 	ldh [hTilesPerCycle], a
 
 	ld a, [wLinkMode]
@@ -281,7 +282,7 @@
 	ldh a, [hMobile]
 	and a
 	jr nz, .NotMobile
-	ld a, $6
+	ld a, MOBILE_TILES_PER_CYCLE
 	ldh [hTilesPerCycle], a
 
 .NotMobile:
@@ -297,7 +298,7 @@
 	ld a, c
 	ld hl, hTilesPerCycle
 	cp [hl]
-	jr nc, .iterate
+	jr nc, .cycle
 
 	ld [wRequested1bpp], a
 .wait
@@ -316,7 +317,7 @@
 	ldh [hBGMapMode], a
 	ret
 
-.iterate
+.cycle
 	ldh a, [hTilesPerCycle]
 	ld [wRequested1bpp], a
 
@@ -348,7 +349,7 @@
 ; bank
 	ld a, b
 
-; bc = c * $10
+; bc = c * LEN_2BPP_TILE
 	push af
 	swap c
 	ld a, $f
@@ -376,7 +377,7 @@
 ; bank
 	ld a, b
 
-; bc = c * $10 / 2
+; bc = c * LEN_1BPP_TILE
 	push af
 	ld h, 0
 	ld l, c
--- a/home/init.asm
+++ b/home/init.asm
@@ -21,15 +21,15 @@
 _Start::
 	cp $11
 	jr z, .cgb
-	xor a
+	xor a ; FALSE
 	jr .load
 
 .cgb
-	ld a, $1
+	ld a, TRUE
 
 .load
 	ldh [hCGB], a
-	ld a, $1
+	ld a, TRUE
 	ldh [hSystemBooted], a
 
 Init::
@@ -74,7 +74,7 @@
 	or c
 	jr nz, .ByteFill
 
-	ld sp, wStack
+	ld sp, wStackTop
 
 ; Clear HRAM
 	ldh a, [hCGB]
@@ -97,7 +97,7 @@
 	call ClearSprites
 	call ClearsScratch
 
-	ld a, BANK(GameInit) ; aka BANK(WriteOAMDMACodeToHRAM)
+	ld a, BANK(WriteOAMDMACodeToHRAM) ; aka BANK(GameInit)
 	rst Bankswitch
 
 	call WriteOAMDMACodeToHRAM
@@ -142,7 +142,7 @@
 
 	farcall StartClock
 
-	xor a
+	xor a ; SRAM_DISABLE
 	ld [MBC3LatchClock], a
 	ld [MBC3SRamEnable], a
 
@@ -160,7 +160,7 @@
 
 	call DelayFrame
 
-	predef InitSGBBorder ; SGB init
+	predef InitSGBBorder
 
 	call InitSound
 	xor a
--- a/home/lcd.asm
+++ b/home/lcd.asm
@@ -15,7 +15,7 @@
 	and a
 	jr z, .done
 
-; At this point it's assumed we're in WRAM bank 5!
+; At this point it's assumed we're in BANK(wLYOverrides)!
 	push bc
 	ldh a, [rLY]
 	ld c, a
--- a/home/menu.asm
+++ b/home/menu.asm
@@ -116,8 +116,8 @@
 	ret
 
 PopWindow::
-	ld b, $10
-	ld de, wMenuFlags
+	ld b, wMenuHeaderEnd - wMenuHeader
+	ld de, wMenuHeader
 .loop
 	ld a, [hld]
 	ld [de], a
@@ -148,8 +148,8 @@
 	ld a, [hli]
 	ld h, [hl]
 	ld l, a
-	ld de, wMenuDataFlags
-	ld bc, wMenuDataEnd - wMenuDataFlags
+	ld de, wMenuData
+	ld bc, wMenuDataEnd - wMenuData
 	call CopyBytes
 	pop af
 	pop bc
--- a/home/palettes.asm
+++ b/home/palettes.asm
@@ -81,6 +81,7 @@
 	push hl
 	push de
 	push bc
+
 	ldh a, [rSVBK]
 	push af
 
@@ -102,6 +103,7 @@
 
 	pop af
 	ldh [rSVBK], a
+
 	pop bc
 	pop de
 	pop hl
@@ -127,6 +129,7 @@
 	push hl
 	push de
 	push bc
+
 	ldh a, [rSVBK]
 	push af
 
@@ -148,6 +151,7 @@
 
 	pop af
 	ldh [rSVBK], a
+
 	pop bc
 	pop de
 	pop hl
--- a/home/trainers.asm
+++ b/home/trainers.asm
@@ -15,7 +15,7 @@
 
 ; Skip the player object.
 	ld a, 1
-	ld de, wMapObjects + MAPOBJECT_LENGTH
+	ld de, wMap1Object
 
 .loop
 
--- a/home/vblank.asm
+++ b/home/vblank.asm
@@ -184,8 +184,8 @@
 	call Serve2bppRequest_VBlank
 
 	call hTransferVirtualOAM
-.done
 
+.done
 	xor a
 	ld [wVBlankOccurred], a
 
--- a/home/video.asm
+++ b/home/video.asm
@@ -31,8 +31,9 @@
 
 	ldh a, [rVBK]
 	push af
-	ld [hSPBuffer], sp
 
+; Relocate the stack pointer to wBGMapBufferPtrs
+	ld [hSPBuffer], sp
 	ld hl, wBGMapBufferPtrs
 	ld sp, hl
 
@@ -80,6 +81,7 @@
 
 	jr nz, .next
 
+; Restore the stack pointer
 	ldh a, [hSPBuffer]
 	ld l, a
 	ldh a, [hSPBuffer + 1]
--- a/macros/wram.asm
+++ b/macros/wram.asm
@@ -242,14 +242,14 @@
 ENDM
 
 trademon: MACRO
-\1Species::     db ; wc6d0 | wc702
-\1SpeciesName:: ds MON_NAME_LENGTH ; wc6d1 | wc703
-\1Nickname::    ds MON_NAME_LENGTH ; wc6dc | wc70e
-\1SenderName::  ds NAME_LENGTH ; wc6e7 | wc719
-\1OTName::      ds NAME_LENGTH ; wc6f2 | wc724
-\1DVs::         dw ; wc6fd | wc72f
-\1ID::          dw ; wc6ff | wc731
-\1CaughtData::  db ; wc701 | wc733
+\1Species::     db
+\1SpeciesName:: ds MON_NAME_LENGTH
+\1Nickname::    ds MON_NAME_LENGTH
+\1SenderName::  ds NAME_LENGTH
+\1OTName::      ds NAME_LENGTH
+\1DVs::         dw
+\1ID::          dw
+\1CaughtData::  db
 \1End::
 ENDM