shithub: pokered

Download patch

ref: ef9e59101e10aed82184bd2fd063b1109e2e4f6a
parent: e25a7148d0a78549de4f33fa72d519dcaf660e97
author: dannye <corrnondacqb@yahoo.com>
date: Mon Jul 13 22:16:19 EDT 2015

Use more screen dimension constants

--- a/engine/HoF_room_pc.asm
+++ b/engine/HoF_room_pc.asm
@@ -202,7 +202,7 @@
 	add hl, bc
 	call PlaceString
 	pop hl
-	ld bc, $28
+	ld bc, SCREEN_WIDTH * 2
 	add hl, bc
 	pop de
 	jr .asm_7419b
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -1712,9 +1712,9 @@
 	call Func_79862
 	inc hl
 .asm_794eb
-	ld [hl], $7f
+	ld [hl], " "
 	pop hl
-	ld de, $14
+	ld de, SCREEN_WIDTH
 	add hl, de
 	pop bc
 	dec c
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -233,12 +233,12 @@
 	ld [wWhichTrade], a
 	hlCoord 0, 0
 	ld c, $11
-	ld de, $14
+	ld de, SCREEN_WIDTH
 	call BattleTransition_InwardSpiral_
 	inc c
 	jr .skip
 .loop
-	ld de, $14
+	ld de, SCREEN_WIDTH
 	call BattleTransition_InwardSpiral_
 .skip
 	inc c
@@ -246,10 +246,10 @@
 	call BattleTransition_InwardSpiral_
 	dec c
 	dec c
-	ld de, $ffec
+	ld de, -SCREEN_WIDTH
 	call BattleTransition_InwardSpiral_
 	inc c
-	ld de, rIE
+	ld de, -1
 	call BattleTransition_InwardSpiral_
 	dec c
 	dec c
@@ -278,8 +278,8 @@
 	ret
 
 BattleTransition_OutwardSpiral_: ; 70af9 (1c:4af9)
-	ld bc, $ffec
-	ld de, $14
+	ld bc, -SCREEN_WIDTH
+	ld de, SCREEN_WIDTH
 	ld a, [wd09b]
 	ld l, a
 	ld a, [wd09a]
@@ -366,7 +366,7 @@
 
 ; used for low level trainer dungeon battles
 BattleTransition_Shrink: ; 70b7f (1c:4b7f)
-	ld c, $9
+	ld c, SCREEN_HEIGHT / 2
 .loop
 	push bc
 	xor a
@@ -373,15 +373,15 @@
 	ld [H_AUTOBGTRANSFERENABLED], a
 	hlCoord 0, 7
 	deCoord 0, 8
-	ld bc, $ffd8
+	ld bc, -SCREEN_WIDTH * 2
 	call BattleTransition_CopyTiles1
 	hlCoord 0, 10
 	deCoord 0, 9
-	ld bc, $28
+	ld bc, SCREEN_WIDTH * 2
 	call BattleTransition_CopyTiles1
 	hlCoord 8, 0
 	deCoord 9, 0
-	ld bc, $fffe
+	ld bc, -2
 	call BattleTransition_CopyTiles2
 	hlCoord 11, 0
 	deCoord 10, 0
@@ -400,7 +400,7 @@
 
 ; used for high level trainer dungeon battles
 BattleTransition_Split: ; 70bca (1c:4bca)
-	ld c, $9
+	ld c, SCREEN_HEIGHT / 2
 	xor a
 	ld [H_AUTOBGTRANSFERENABLED], a
 .loop
@@ -407,15 +407,15 @@
 	push bc
 	hlCoord 0, 16
 	deCoord 0, 17
-	ld bc, $ffd8
+	ld bc, -SCREEN_WIDTH * 2
 	call BattleTransition_CopyTiles1
 	hlCoord 0, 1
 	deCoord 0, 0
-	ld bc, $28
+	ld bc, SCREEN_WIDTH * 2
 	call BattleTransition_CopyTiles1
 	hlCoord 18, 0
 	deCoord 19, 0
-	ld bc, $fffe
+	ld bc, -2
 	call BattleTransition_CopyTiles2
 	hlCoord 1, 0
 	deCoord 0, 0
@@ -440,7 +440,7 @@
 	push bc
 	push hl
 	push de
-	ld bc, $14
+	ld bc, SCREEN_WIDTH
 	call CopyData
 	pop hl
 	pop de
@@ -455,7 +455,7 @@
 	ld l, e
 	ld h, d
 	ld a, $ff
-	ld c, $14
+	ld c, SCREEN_WIDTH
 .loop2
 	ld [hli], a
 	dec c
@@ -467,23 +467,23 @@
 	ld [wWhichTrade], a
 	ld a, b
 	ld [wTrainerEngageDistance], a
-	ld c, $9
+	ld c, SCREEN_HEIGHT / 2
 .loop1
 	push bc
 	push hl
 	push de
-	ld c, $12
+	ld c, SCREEN_HEIGHT
 .loop2
 	ld a, [hl]
 	ld [de], a
 	ld a, e
-	add $14
+	add SCREEN_WIDTH
 	jr nc, .noCarry1
 	inc d
 .noCarry1
 	ld e, a
 	ld a, l
-	add $14
+	add SCREEN_WIDTH
 	jr nc, .noCarry2
 	inc h
 .noCarry2
@@ -502,8 +502,8 @@
 	jr nz, .loop1
 	ld l, e
 	ld h, d
-	ld de, $14
-	ld c, $12
+	ld de, SCREEN_WIDTH
+	ld c, SCREEN_HEIGHT
 .loop3
 	ld [hl], $ff
 	add hl, de
@@ -513,7 +513,7 @@
 
 ; used for high level wild dungeon battles
 BattleTransition_VerticalStripes: ; 70c7e (1c:4c7e)
-	ld c, $12
+	ld c, SCREEN_HEIGHT
 	hlCoord 0, 0
 	deCoord 1, 17
 	xor a
@@ -528,12 +528,12 @@
 	call BattleTransition_VerticalStripes_
 	call BattleTransition_TransferDelay3
 	pop hl
-	ld bc, $ffec
+	ld bc, -SCREEN_WIDTH
 	add hl, bc
 	ld e, l
 	ld d, h
 	pop hl
-	ld bc, $14
+	ld bc, SCREEN_WIDTH
 	add hl, bc
 	pop bc
 	dec c
@@ -541,7 +541,7 @@
 	jp BattleTransition_BlackScreen
 
 BattleTransition_VerticalStripes_: ; 70caa (1c:4caa)
-	ld c, $a
+	ld c, SCREEN_WIDTH / 2
 .loop
 	ld [hl], $ff
 	inc hl
@@ -552,7 +552,7 @@
 
 ; used for low level wild dungeon battles
 BattleTransition_HorizontalStripes: ; 70cb4 (1c:4cb4)
-	ld c, $14
+	ld c, SCREEN_WIDTH
 	hlCoord 0, 0
 	deCoord 19, 1
 	xor a
@@ -576,8 +576,8 @@
 	jp BattleTransition_BlackScreen
 
 BattleTransition_HorizontalStripes_: ; 70cd8 (1c:4cd8)
-	ld c, $9
-	ld de, $28
+	ld c, SCREEN_HEIGHT / 2
+	ld de, SCREEN_WIDTH * 2
 .loop
 	ld [hl], $ff
 	add hl, de
@@ -590,10 +590,10 @@
 ; by animating each half circle one at a time
 BattleTransition_Circle: ; 70ce4 (1c:4ce4)
 	call BattleTransition_FlashScreen
-	ld bc, $000a
+	ld bc, SCREEN_WIDTH / 2
 	ld hl, BattleTransition_HalfCircle1
 	call BattleTransition_Circle_Sub1
-	ld c, $a
+	ld c, SCREEN_WIDTH / 2
 	ld b, $1
 	ld hl, BattleTransition_HalfCircle2
 	call BattleTransition_Circle_Sub1
@@ -633,7 +633,7 @@
 ; by animating both half circles at the same time
 BattleTransition_DoubleCircle: ; 70d24 (1c:4d24)
 	call BattleTransition_FlashScreen
-	ld c, $a
+	ld c, SCREEN_WIDTH / 2
 	ld hl, BattleTransition_HalfCircle1
 	ld de, BattleTransition_HalfCircle2
 .loop
@@ -774,9 +774,9 @@
 	pop hl
 	ld a, [wWhichTrade]
 	and a
-	ld bc, $14
+	ld bc, SCREEN_WIDTH
 	jr z, .skip3
-	ld bc, $ffec
+	ld bc, -SCREEN_WIDTH
 .skip3
 	add hl, bc
 	ld a, [de]
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -7047,7 +7047,7 @@
 	ld a, [$ffe1]
 CopyUncompressedPicToHL: ; 3f0d0 (f:70d0)
 	ld bc, $707
-	ld de, $14
+	ld de, SCREEN_WIDTH
 	push af
 	ld a, [W_SPRITEFLIPPED]
 	and a
--- a/engine/battle/draw_hud_pokeball_gfx.asm
+++ b/engine/battle/draw_hud_pokeball_gfx.asm
@@ -148,7 +148,7 @@
 
 PlaceHUDTiles: ; 3a930 (e:6930)
 	ld [hl], $73
-	ld bc, $14
+	ld bc, SCREEN_WIDTH
 	add hl, bc
 	ld a, [wTrainerScreenY]
 	ld [hl], a
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -714,10 +714,10 @@
 SwitchPartyMon_OAM: ; 13625 (4:7625)
 	push af
 	hlCoord 0, 0
-	ld bc, $28
+	ld bc, SCREEN_WIDTH * 2
 	call AddNTimes
-	ld c, $28
-	ld a, $7f
+	ld c, SCREEN_WIDTH * 2
+	ld a, " "
 .asm_13633
 	ld [hli], a
 	dec c
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -280,7 +280,7 @@
 	push hl
 	call PrintNumber
 	pop hl
-	ld de, $0028
+	ld de, SCREEN_WIDTH * 2
 	add hl, de
 	ret
 
@@ -323,15 +323,15 @@
 	sub c
 	ld b, a ; Number of moves ?
 	hlCoord 11, 10
-	ld de, $0028
-	ld a, $72
-	call Func_12ccb ; Print "PP"
+	ld de, SCREEN_WIDTH * 2
+	ld a, $72 ; special P tile id
+	call StatusScreen_PrintPP ; Print "PP"
 	ld a, b
 	and a
 	jr z, .InitPP
 	ld c, a
 	ld a, "-"
-	call Func_12ccb ; Fill the rest with --
+	call StatusScreen_PrintPP ; Fill the rest with --
 .InitPP ; 12bbb
 	ld hl, wLoadedMonMoves
 	deCoord 14, 10
@@ -373,7 +373,7 @@
 	ld bc, $0102
 	call PrintNumber
 	pop hl
-	ld de, $0028
+	ld de, SCREEN_WIDTH * 2
 	add hl, de
 	ld d, h
 	ld e, l
@@ -411,9 +411,9 @@
 	ld bc, $0307
 	call PrintNumber
 	hlCoord 9, 0
-	call Func_12cc3
+	call StatusScreen_ClearName
 	hlCoord 9, 1
-	call Func_12cc3
+	call StatusScreen_ClearName
 	ld a, [W_MONHDEXNUM]
 	ld [wd11e], a
 	call GetMonName
@@ -463,15 +463,16 @@
 LevelUpText: ; 12cba (4:6cba)
 	db "LEVEL UP@"
 
-Func_12cc3: ; 12cc3 (4:6cc3)
-	ld bc, $a
-	ld a, $7f
+StatusScreen_ClearName: ; 12cc3 (4:6cc3)
+	ld bc, 10
+	ld a, " "
 	jp FillMemory
 
-Func_12ccb: ; 12ccb (4:6ccb)
+StatusScreen_PrintPP: ; 12ccb (4:6ccb)
+; print PP or -- c times, going down two rows each time
 	ld [hli], a
 	ld [hld], a
 	add hl, de
 	dec c
-	jr nz, Func_12ccb
+	jr nz, StatusScreen_PrintPP
 	ret
--- a/engine/oak_speech2.asm
+++ b/engine/oak_speech2.asm
@@ -250,6 +250,7 @@
 	ld de, wcd6d
 	ld bc, $14
 	jp CopyData
+
 IF DEF(_RED)
 DefaultNamesPlayerList: ; 6af2 (1:6af2)
 	db "NEW NAME@RED@ASH@JACK@"
--- a/engine/oam_dma.asm
+++ b/engine/oam_dma.asm
@@ -19,7 +19,8 @@
 
 	; wait for DMA to finish
 	ld a, $28
-.wait	dec a
+.wait
+	dec a
 	jr nz, .wait
 	ret
 DMARoutineEnd:
--- a/engine/overworld/cinnabar_lab.asm
+++ b/engine/overworld/cinnabar_lab.asm
@@ -103,7 +103,7 @@
 	call GetItemName
 	hlCoord 2, 2
 	ld a, [$ffdb]
-	ld bc, $28
+	ld bc, SCREEN_WIDTH * 2
 	call AddNTimes
 	ld de, wcd6d
 	call PlaceString
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -690,8 +690,8 @@
 	ld a, [hl]      ; c1x6: screen Y position
 	srl a
 	srl a
-	srl a           ; screen X tile
-	add $14         ; screen X tile + 20
+	srl a            ; screen X tile
+	add SCREEN_WIDTH ; screen X tile + 20
 	ld d, $0
 	ld e, a
 	hlCoord 0, 0
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -462,7 +462,7 @@
 	call Func_73a84
 	hlCoord 18, 1
 	ld de, wWhichTrade
-	ld bc, $14
+	ld bc, SCREEN_WIDTH
 	ld a, $c
 .asm_739c2
 	push af
--- a/engine/titlescreen.asm
+++ b/engine/titlescreen.asm
@@ -70,7 +70,7 @@
 	call Func_4519
 	hlCoord 2, 1
 	ld a, $80
-	ld de, $14
+	ld de, SCREEN_WIDTH
 	ld c, $6
 .asm_434d
 	ld b, $10
--- a/home.asm
+++ b/home.asm
@@ -3176,7 +3176,7 @@
 SaveScreenTilesToBuffer2:: ; 36f4 (0:36f4)
 	hlCoord 0, 0
 	ld de, wTileMapBackup2
-	ld bc, $168
+	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
 	call CopyData
 	ret
 
@@ -3199,7 +3199,7 @@
 SaveScreenTilesToBuffer1:: ; 3719 (0:3719)
 	hlCoord 0, 0
 	ld de, wTileMapBackup
-	ld bc, $168
+	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
 	jp CopyData
 
 LoadScreenTilesFromBuffer1:: ; 3725 (0:3725)
@@ -3207,7 +3207,7 @@
 	ld [H_AUTOBGTRANSFERENABLED], a
 	ld hl, wTileMapBackup
 	deCoord 0, 0
-	ld bc, $168
+	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
 	call CopyData
 	ld a, $1
 	ld [H_AUTOBGTRANSFERENABLED], a
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -1753,7 +1753,7 @@
 
 ScheduleColumnRedrawHelper:: ; 0ef2 (0:0ef2)
 	ld de,wScreenEdgeTiles
-	ld c,$12
+	ld c,SCREEN_HEIGHT
 .loop
 	ld a,[hli]
 	ld [de],a
--- a/home/text.asm
+++ b/home/text.asm
@@ -61,16 +61,16 @@
 .PlaceText
 	cp $4E
 	jr nz,.next
-	ld bc,$0028
+	ld bc,SCREEN_WIDTH * 2
 	ld a,[hFlags_0xFFF6]
 	bit 2,a
 	jr z,.next2
-	ld bc,$14
+	ld bc,SCREEN_WIDTH
 .next2
 	pop hl
 	add hl,bc
 	push hl
-	jp Next19E8
+	jp PlaceNextChar_inc
 
 .next
 	cp $4F
@@ -78,7 +78,7 @@
 	pop hl
 	hlCoord 1, 16
 	push hl
-	jp Next19E8
+	jp PlaceNextChar_inc
 
 .next3 ; Check against a dictionary
 	and a
@@ -123,7 +123,7 @@
 	jp z,Char5A
 	ld [hli],a
 	call PrintLetterDelay
-Next19E8:: ; 19e8 (0:19e8)
+PlaceNextChar_inc:: ; 19e8 (0:19e8)
 	inc de
 	jp PlaceNextChar
 
@@ -273,7 +273,7 @@
 Next1AA2:: ; 1aa2 (0:1aa2)
 	call ProtectedDelay3
 	call ManualTextScroll
-	ld a,$7F
+	ld a, " "
 	Coorda 18, 16
 Char57:: ; 1aad (0:1aad)
 	pop hl
@@ -297,7 +297,7 @@
 	call DelayFrames
 	pop de
 	hlCoord 1, 14
-	jp Next19E8
+	jp PlaceNextChar_inc
 
 Char49:: ; 1ad5 (0:1ad5)
 	push de
@@ -314,7 +314,7 @@
 	pop hl
 	hlCoord 1, 11
 	push hl
-	jp Next19E8
+	jp PlaceNextChar_inc
 
 Char4B:: ; 1af8 (0:1af8)
 	ld a,$EE
@@ -323,7 +323,7 @@
 	push de
 	call ManualTextScroll
 	pop de
-	ld a,$7F
+	ld a, " "
 	Coorda 18, 16
 	;fall through
 Char4C:: ; 1b0a (0:1b0a)
@@ -332,12 +332,12 @@
 	call Next1B18
 	hlCoord 1, 16
 	pop de
-	jp Next19E8
+	jp PlaceNextChar_inc
 
 Next1B18:: ; 1b18 (0:1b18)
 	hlCoord 0, 14
 	deCoord 0, 13
-	ld b,$3C
+	ld b,60
 .next
 	ld a,[hli]
 	ld [de],a
@@ -345,8 +345,8 @@
 	dec b
 	jr nz,.next
 	hlCoord 1, 16
-	ld a,$7F
-	ld b,$12
+	ld a, " "
+	ld b,SCREEN_WIDTH - 2
 .next2
 	ld [hli],a
 	dec b
--- a/main.asm
+++ b/main.asm
@@ -1157,7 +1157,7 @@
 	push hl
 	call PlaceString
 	pop hl
-	ld de,$28
+	ld de,SCREEN_WIDTH * 2
 	add hl,de
 	ret
 
@@ -1755,7 +1755,7 @@
 	sub e
 	ld c, a
 	pop af
-	ld de, $ffd8
+	ld de, -SCREEN_WIDTH * 2
 .asm_7725
 	add hl, de
 	inc b
@@ -1762,7 +1762,7 @@
 	inc b
 	dec a
 	jr nz, .asm_7725
-	ld de, $ffec
+	ld de, -SCREEN_WIDTH
 	add hl, de
 	inc b
 	call TextBoxBorder
@@ -1773,7 +1773,7 @@
 	ld e, a
 	ld d, $0
 	add hl, de
-	ld de, $ffd8
+	ld de, -SCREEN_WIDTH * 2
 	ld a, [wTrainerScreenX]
 .asm_7747
 	add hl, de
@@ -1806,7 +1806,7 @@
 	ld d, b
 	ld e, c
 	call PlaceString
-	ld bc, $28
+	ld bc, SCREEN_WIDTH * 2
 	add hl, bc
 	pop de
 	jr .asm_7752
@@ -4031,7 +4031,7 @@
 	ld [hli], a
 	ld d, h
 	ld e, l
-	ld bc, $ffee
+	ld bc, -18
 	add hl, bc
 	ld b, $1
 	call CalcStats
--- a/scripts/celadonmartroof.asm
+++ b/scripts/celadonmartroof.asm
@@ -202,7 +202,7 @@
 	call GetItemName
 	hlCoord 2, 2
 	ld a, [$ffdb]
-	ld bc, $28
+	ld bc, SCREEN_WIDTH * 2
 	call AddNTimes
 	ld de, wcd6d
 	call PlaceString