ref: da0a72cdbf45fa624b2d1151afe94a98d7da2ae0
parent: 229507e3f3722137c4b08ccbf8ee4b654db9baa4
author: yenatch <yenatch@gmail.com>
date: Wed May 28 21:31:46 EDT 2014
Use VRAM constants where applicable.
--- a/engine/HoF_room_pc.asm
+++ b/engine/HoF_room_pc.asm
@@ -4,13 +4,13 @@
ld c, $64
call DelayFrames
call DisableLCD
- ld hl, $8800
- ld bc, $400
+ ld hl, vFont
+ ld bc, $800 / 2
call Func_74171
- ld hl, $9600
- ld bc, $100
+ ld hl, vChars2 + $600
+ ld bc, $200 / 2
call Func_74171
- ld hl, $97e0
+ ld hl, vChars2 + $7e0
ld bc, $10
ld a, $ff
call FillMemory
@@ -66,16 +66,16 @@
ld hl,Coord
call GetMonHeader
call LoadFrontSpriteByMonIndex
- ld hl,$980C
+ ld hl,vBGMap0 + $c
call Func_74164
xor a
ld [H_AUTOBGTRANSFERENABLED],a
call LoadScreenTilesFromBuffer1
- ld hl,$9800
+ ld hl,vBGMap0
call Func_74164
ld a,$A7
ld [$FF4B],a
- ld hl,$9C00
+ ld hl,vBGMap1
call Func_74164
call FillMiddleOfScreenWithWhite
ld a,$FC
@@ -238,7 +238,7 @@
call FillMiddleOfScreenWithWhite
pop de
ld de, TheEndGfx
- ld hl, $9600
+ ld hl, vChars2 + $600
ld bc, (BANK(TheEndGfx) << 8) + $0a
call CopyVideoData
FuncCoord 4, 8
--- a/engine/battle/1c.asm
+++ b/engine/battle/1c.asm
@@ -45,9 +45,9 @@
jp ClearSprites
Func_7092a: ; 7092a (1c:492a)
- ld de, $9000
- ld hl, $8000
- ld bc, $31
+ ld de, vFrontPic
+ ld hl, vSprites
+ ld bc, 7 * 7
call CopyVideoData
ld a, $10
ld [W_BASECOORDY], a ; wd082
@@ -250,7 +250,7 @@
db $FF
LoadBattleTransitionTile: ; 70a4d (1c:4a4d)
- ld hl, $8ff0
+ ld hl, vChars1 + $7f0
ld de, BattleTransitionTile ; $4a59
ld bc, (BANK(BattleTransitionTile) << 8) + $01
jp CopyVideoData
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -341,7 +341,7 @@
ld e,a
ld a,[hl]
ld d,a ; de = address of tileset
- ld hl,$8310 ; destination address in VRAM
+ ld hl,vSprites + $310
ld b, BANK(AnimationTileset1) ; ROM bank
ld a,[wd07d]
ld c,a ; number of tiles
@@ -1960,17 +1960,17 @@
Func_79652: ; 79652 (1e:5652)
ld a, [H_WHOSETURN] ; $fff3
and a
- ld hl, $9310
+ ld hl, vBackPic
jr z, .asm_7965d
- ld hl, $9000
+ ld hl, vFrontPic
.asm_7965d
ld de, wTempPic
- ld bc, $31
+ ld bc, 7 * 7
jp CopyVideoData
AnimationWavyScreen: ; 79666 (1e:5666)
; used in Psywave/Psychic etc.
- ld hl, $9800
+ ld hl, vBGMap0
call Func_79e0d
call Delay3
xor a
@@ -2005,7 +2005,7 @@
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
call LoadScreenTilesFromBuffer2
- ld hl, $9c00
+ ld hl, vBGMap1
call Func_79e0d
ret
@@ -2751,22 +2751,22 @@
db $00,$84,$06,$81,$02,$88,$01,$83,$05,$89,$09,$80,$07,$87,$03,$82,$04,$85,$08,$86
AnimationShakeEnemyHUD: ; 79d77 (1e:5d77)
- ld de, $9310
- ld hl, $8000
- ld bc, $0031
+ ld de, vBackPic
+ ld hl, vSprites
+ ld bc, 7 * 7
call CopyVideoData
xor a
ld [$ffae], a
- ld hl, $9800
+ ld hl, vBGMap0
call Func_79e0d
ld a, $90
ld [$ffb0], a
- ld hl, $9b20
+ ld hl, vBGMap0 + $320
call Func_79e0d
ld a, $38
ld [$ffb0], a
call Func_792fd
- ld hl, $9800
+ ld hl, vBGMap0
call Func_79e0d
call AnimationHideMonPic
call Delay3
@@ -2776,17 +2776,17 @@
call ClearSprites
ld a, $90
ld [$ffb0], a
- ld hl, $9c00
+ ld hl, vBGMap1
call Func_79e0d
xor a
ld [$ffb0], a
call SaveScreenTilesToBuffer1
- ld hl, $9800
+ ld hl, vBGMap0
call Func_79e0d
call ClearScreen
call Delay3
call LoadScreenTilesFromBuffer1
- ld hl, $9c00
+ ld hl, vBGMap1
jp Func_79e0d
Func_79dda: ; 79dda (1e:5dda)
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -103,7 +103,7 @@
call DisableLCD
call LoadFontTilePatterns
call Func_3ee58
- ld hl, $9800
+ ld hl, vBGMap0
ld bc, $400
.asm_3c06f
ld a, $7f
@@ -113,7 +113,7 @@
or c
jr nz, .asm_3c06f
ld hl, wTileMap
- ld de, $9800
+ ld de, vBGMap0
ld b, $12
.asm_3c07f
ld c, $14
@@ -1462,7 +1462,7 @@
ld [wcf91],a
ld [wd0b5],a
call GetMonHeader
- ld de,$9000
+ ld de,vFrontPic
call LoadMonFrontSprite
ld a,$CF
ld [$FFE1],a
@@ -2400,7 +2400,7 @@
ld [wcf91], a
ld [wd0b5], a
call GetMonHeader
- ld de, $9000
+ ld de, vFrontPic
call LoadMonFrontSprite
jr .asm_3d187
.asm_3d182
@@ -6288,17 +6288,17 @@
ld e, a
dec b
jr nz, .asm_3ecb2
- ld de, $9310
+ ld de, vBackPic
call InterlaceMergeSpriteBuffers
ld a, $a
ld [$0], a
xor a
ld [$4000], a
- ld hl, $8000
+ ld hl, vSprites
ld de, S_SPRITEBUFFER1
ld a, [H_LOADEDROMBANK]
ld b, a
- ld c, $31
+ ld c, 7 * 7
call CopyVideoData
xor a
ld [$0], a
@@ -6552,22 +6552,22 @@
add a
jr c, .asm_3ee7c
ld hl, BattleHudTiles1 ; $6080
- ld de, $96d0
+ ld de, vChars2 + $6d0
ld bc, $18
ld a, BANK(BattleHudTiles1)
call FarCopyDataDouble
ld hl, BattleHudTiles2 ; $6098
- ld de, $9730
+ ld de, vChars2 + $730
ld bc, $30
ld a, BANK(BattleHudTiles2)
jp FarCopyDataDouble
.asm_3ee7c
ld de, BattleHudTiles1 ; $6080
- ld hl, $96d0
+ ld hl, vChars2 + $6d0
ld bc, (BANK(BattleHudTiles1) << 8) + $03
call CopyVideoDataDouble
ld de, BattleHudTiles2 ; $6098
- ld hl, $9730
+ ld hl, vChars2 + $730
ld bc, (BANK(BattleHudTiles2) << 8) + $06
jp CopyVideoDataDouble
@@ -6751,13 +6751,13 @@
push af
ld a, MON_GHOST
ld [wcf91], a
- ld de, $9000
+ ld de, vFrontPic
call LoadMonFrontSprite ; load ghost sprite
pop af
ld [wcf91], a
jr .spriteLoaded
.isNoGhost
- ld de, $9000
+ ld de, vFrontPic
call LoadMonFrontSprite ; load mon sprite
.spriteLoaded
xor a
@@ -6825,7 +6825,7 @@
ld a, Bank(RedPicFront)
.loadSprite
call UncompressSpriteFromDE
- ld de, $9000
+ ld de, vFrontPic
ld a, $77
ld c, a
jp LoadUncompressedSpriteData
@@ -6930,9 +6930,9 @@
jr nz, .asm_3f0f4
ret
-; loads back sprite of mon to $8000
-; assumes the corresponding mon header is already loaded
-LoadMonBackSprite: ; 3f103 (f:7103)
+LoadMonBackSprite:
+; Assumes the monster's attributes have
+; been loaded with GetMonHeader.
ld a, [wcfd9]
ld [wcf91], a
FuncCoord 1, 5
@@ -6944,10 +6944,10 @@
call UncompressMonSprite
ld a, $3
call Predef ; indirect jump to ScaleSpriteByTwo (2fe40 (b:7e40))
- ld de, $9310
+ ld de, vBackPic
call InterlaceMergeSpriteBuffers ; combine the two buffers to a single 2bpp sprite
- ld hl, $8000
- ld de, $9310
+ ld hl, vSprites
+ ld de, vBackPic
ld c, (2*SPRITEBUFFERSIZE)/16 ; count of 16-byte chunks to be copied
ld a, [H_LOADEDROMBANK]
ld b, a
--- a/engine/battle/e.asm
+++ b/engine/battle/e.asm
@@ -1382,7 +1382,7 @@
LoadPartyPokeballGfx: ; 3a85d (e:685d)
ld de, PokeballTileGraphics ; $697e
- ld hl, $8310
+ ld hl, vSprites + $310
ld bc, (BANK(PokeballTileGraphics) << 8) + $04
jp CopyVideoData
--- a/engine/evolution.asm
+++ b/engine/evolution.asm
@@ -28,9 +28,9 @@
ld [wcf91], a
ld [wd0b5], a
call Func_7beb9
- ld de, $9000
- ld hl, $9310
- ld bc, $31
+ ld de, vFrontPic
+ ld hl, vBackPic
+ ld bc, 7 * 7
call CopyVideoData
ld a, [wHPBarMaxHP]
ld [wcf91], a
--- a/engine/gamefreak.asm
+++ b/engine/gamefreak.asm
@@ -4,15 +4,15 @@
ld a, $a4
ld [rOBP1], a ; $ff49
ld de, AnimationTileset2 + $30 ; $471e ; star tile (top left quadrant)
- ld hl, $8a00
+ ld hl, vChars1 + $200
ld bc, (BANK(AnimationTileset2) << 8) + $01
call CopyVideoData
ld de, AnimationTileset2 + $130 ; $481e ; star tile (bottom left quadrant)
- ld hl, $8a10
+ ld hl, vChars1 + $210
ld bc, (BANK(AnimationTileset2) << 8) + $01
call CopyVideoData
ld de, FallingStar ; $4190
- ld hl, $8a20
+ ld hl, vChars1 + $220
ld bc, (BANK(FallingStar) << 8) + $01
call CopyVideoData
ld hl, GameFreakLogoOAMData ; $4140
--- a/engine/hall_of_fame.asm
+++ b/engine/hall_of_fame.asm
@@ -6,7 +6,7 @@
call LoadFontTilePatterns
call LoadTextBoxTilePatterns
call DisableLCD
- ld hl, $9800
+ ld hl,vBGMap0
ld bc, $800
ld a, $7f
call FillMemory
@@ -197,7 +197,7 @@
ld de, $a000
ld bc, $310
call CopyData
- ld de, $9000
+ ld de, vFrontPic
call InterlaceMergeSpriteBuffers
ld de, RedPicBack ; $7e0a
ld a, BANK(RedPicBack)
@@ -204,7 +204,7 @@
call UncompressSpriteFromDE
ld a, $3
call Predef ; indirect jump to ScaleSpriteByTwo (2fe40 (b:7e40))
- ld de, $9310
+ ld de, vBackPic
call InterlaceMergeSpriteBuffers
ld c, $1
--- a/engine/hidden_object_functions17.asm
+++ b/engine/hidden_object_functions17.asm
@@ -73,7 +73,7 @@
ld a, [wcf91]
ld [wd0b5], a
call GetMonHeader
- ld de, $8b10
+ ld de, vChars1 + $310
call LoadMonFrontSprite
ld a, $80
ld [$ffe1], a
--- a/engine/intro.asm
+++ b/engine/intro.asm
@@ -199,7 +199,7 @@
ret
Func_417f0: ; 417f0 (10:57f0)
- ld hl, $9c00
+ ld hl, vBGMap1
ld bc, $240
jr asm_417fe
@@ -275,22 +275,22 @@
LoadIntroGraphics: ; 41852 (10:5852)
ld hl, FightIntroBackMon ; $5a99
- ld de, $9000
+ ld de, vChars2
ld bc, $600
ld a, BANK(FightIntroBackMon)
call FarCopyData2
ld hl, GameFreakIntro ; $5959
- ld de, $9600
+ ld de, vChars2 + $600
ld bc, $140
ld a, BANK(GameFreakIntro)
call FarCopyData2
ld hl, GameFreakIntro ; $5959
- ld de, $8800
+ ld de, vChars1
ld bc, $140
ld a, BANK(GameFreakIntro)
call FarCopyData2
ld hl, FightIntroFrontMon ; $6099
- ld de, $8000
+ ld de, vChars0
ld bc, $6c0
ld a, BANK(FightIntroFrontMon)
jp FarCopyData2
@@ -341,10 +341,10 @@
ld hl, Coord
ld c, $50
call Func_41807
- ld hl, $9c00
+ ld hl, vBGMap1
ld c, $80
call Func_41807
- ld hl, $9dc0
+ ld hl, vBGMap1 + $1c0
ld c, $80
jp Func_41807
--- a/engine/load_pokedex_tiles.asm
+++ b/engine/load_pokedex_tiles.asm
@@ -2,10 +2,10 @@
LoadPokedexTilePatterns: ; 17840 (5:7840)
call LoadHpBarAndStatusTilePatterns
ld de,PokedexTileGraphics ; $6488
- ld hl,$9600
+ ld hl,vChars2 + $600
ld bc,(BANK(PokedexTileGraphics) << 8) + $12
call CopyVideoData
ld de,PokeballTileGraphics ; $697e
- ld hl,$9720
+ ld hl,vChars2 + $720
ld bc,(BANK(PokeballTileGraphics) << 8) + $01
jp CopyVideoData ; load pokeball tile for marking caught mons
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -137,7 +137,7 @@
BillsPCMenu:
ld a, [wccd3]
ld [wCurrentMenuItem], a ; wCurrentMenuItem
- ld hl, $9780
+ ld hl, vChars2 + $780
ld de, PokeballTileGraphics ; $697e
ld bc, (BANK(PokeballTileGraphics) << 8) + $01
call CopyVideoData
--- a/engine/menu/diploma.asm
+++ b/engine/menu/diploma.asm
@@ -8,7 +8,7 @@
set 6, [hl]
call DisableLCD
ld hl, CircleTile ; $7d88
- ld de, $9700
+ ld de, vChars2 + $700
ld bc, $0010
ld a, BANK(CircleTile)
call FarCopyData2
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -325,7 +325,7 @@
LoadEDTile: ; 675b (1:675b)
ld de, ED_Tile
- ld hl, $8f00
+ ld hl, vFont + $700
ld bc, $1
jp CopyVideoDataDouble
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -545,25 +545,25 @@
FuncCoord 1,2
ld hl,Coord
call TrainerInfo_DrawVerticalLine
- ld hl,$9070
- ld de,$9000
- ld bc,$01c0
+ ld hl,vChars2 + $70
+ ld de,vChars2
+ ld bc,$70 * 4
call CopyData
ld hl,TrainerInfoTextBoxTileGraphics ; $7b98 ; trainer info text box tile patterns
- ld de,$9770
+ ld de,vChars2 + $770
ld bc,$0080
push bc
call TrainerInfo_FarCopyData
ld hl,BlankLeaderNames ; $7c28
- ld de,$9600
+ ld de,vChars2 + $600
ld bc,$0170
call TrainerInfo_FarCopyData
pop bc
ld hl,BadgeNumbersTileGraphics ; $7d98 ; badge number tile patterns
- ld de,$8d80
+ ld de,vChars1 + $580
call TrainerInfo_FarCopyData
ld hl,GymLeaderFaceAndBadgeTileGraphics ; $6a9e ; gym leader face and badge tile patterns
- ld de,$9200
+ ld de,vChars2 + $200
ld bc,$0400
ld a,$03
call FarCopyData2
@@ -570,7 +570,7 @@
ld hl,TextBoxGraphics ; $6288
ld de,$00d0
add hl,de ; hl = colon tile pattern
- ld de,$8d60
+ ld de,vChars1 + $560
ld bc,$0010
ld a,$04
push bc
@@ -577,7 +577,7 @@
call FarCopyData2
pop bc
ld hl,TrainerInfoTextBoxTileGraphics + $80 ; $7c18 ; background tile pattern
- ld de,$8d70
+ ld de,vChars1 + $570
call TrainerInfo_FarCopyData
call EnableLCD
ld hl,wWhichTrade
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -21,19 +21,19 @@
call UpdateSprites ; move sprites (?)
call LoadHpBarAndStatusTilePatterns
ld de, BattleHudTiles1 ; $6080 ; source
- ld hl, $96d0 ; dest
+ ld hl, vChars2 + $6d0 ; dest
ld bc, (BANK(BattleHudTiles1) << 8) + $03 ; bank bytes/8
call CopyVideoDataDouble ; ·│ :L and halfarrow line end
ld de, BattleHudTiles2 ; $6098
- ld hl, $9780
+ ld hl, vChars2 + $780
ld bc, (BANK(BattleHudTiles2) << 8) + $01
call CopyVideoDataDouble ; │
ld de, BattleHudTiles3 ; $60b0
- ld hl, $9760
+ ld hl, vChars2 + $760
ld bc, (BANK(BattleHudTiles3) << 8) + $02
call CopyVideoDataDouble ; ─┘
ld de, PTile
- ld hl, $9720
+ ld hl, vChars2 + $720
ld bc,(BANK(PTile) << 8 | $01)
call CopyVideoDataDouble ; P (for PP), inline
ld a, [$ffd7]
--- a/engine/mon_party_sprites.asm
+++ b/engine/mon_party_sprites.asm
@@ -156,142 +156,142 @@
dw SlowbroSprite + $c0
db $40 / $10 ; 40 bytes
db BANK(SlowbroSprite)
- dw $8000
+ dw vSprites
dw BallSprite
db $80 / $10 ; $80 bytes
db BANK(BallSprite)
- dw $8040
+ dw vSprites + $40
dw ClefairySprite + $c0
db $40 / $10 ; $40 bytes
db BANK(ClefairySprite)
- dw $80C0
+ dw vSprites + $c0
dw BirdSprite + $c0
db $40 / $10 ; $40 bytes
db BANK(BirdSprite)
- dw $8100
+ dw vSprites + $100
dw SeelSprite
db $40 / $10 ; $40 bytes
db BANK(SeelSprite)
- dw $8140
+ dw vSprites + $140
dw MonPartySprites + $40
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $8180
+ dw vSprites + $180
dw MonPartySprites + $50
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $81A0
+ dw vSprites + $1a0
dw MonPartySprites + $60
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $81C0
+ dw vSprites + $1c0
dw MonPartySprites + $70
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $81E0
+ dw vSprites + $1e0
dw MonPartySprites + $80
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $8200
+ dw vSprites + $200
dw MonPartySprites + $90
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $8220
+ dw vSprites + $220
dw MonPartySprites + $A0
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $8240
+ dw vSprites + $240
dw MonPartySprites + $B0
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $8260
+ dw vSprites + $260
dw MonPartySprites + $100
db $40 / $10 ; $40 bytes
db BANK(MonPartySprites)
- dw $8380
+ dw vSprites + $380
dw SlowbroSprite
db $40 / $10 ; $40 bytes
db BANK(SlowbroSprite)
- dw $8400
+ dw vSprites + $400
dw BallSprite
db $80 / $10 ; $80 bytes
db BANK(BallSprite)
- dw $8440
+ dw vSprites + $440
dw ClefairySprite
db $40 / $10 ; $40 bytes
db BANK(ClefairySprite)
- dw $84C0
+ dw vSprites + $4c0
dw BirdSprite
db $40 / $10 ; $40 bytes
db BANK(BirdSprite)
- dw $8500
+ dw vSprites + $500
dw SeelSprite + $C0
db $40 / $10 ; $40 bytes
db BANK(SeelSprite)
- dw $8540
+ dw vSprites + $540
dw MonPartySprites
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $8580
+ dw vSprites + $580
dw MonPartySprites + $10
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $85A0
+ dw vSprites + $5a0
dw MonPartySprites + $20
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $85C0
+ dw vSprites + $5c0
dw MonPartySprites + $30
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $85E0
+ dw vSprites + $5E0
dw MonPartySprites + $C0
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $8600
+ dw vSprites + $600
dw MonPartySprites + $D0
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $8620
+ dw vSprites + $620
dw MonPartySprites + $E0
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $8640
+ dw vSprites + $640
dw MonPartySprites + $F0
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
- dw $8660
+ dw vSprites + $660
dw MonPartySprites + $140
db $40 / $10 ; $40 bytes
db BANK(MonPartySprites)
- dw $8780
+ dw vSprites + $780
Func_71868: ; 71868 (1c:5868)
push hl
@@ -323,11 +323,11 @@
ld a, [wcf91]
call GetPartyMonSpriteID
push af
- ld hl, $8000
+ ld hl, vSprites
call Func_718ac
pop af
add $54
- ld hl, $8040
+ ld hl, vSprites + $40
call Func_718ac
xor a
ld [wcd5d], a
--- a/engine/oak_speech.asm
+++ b/engine/oak_speech.asm
@@ -117,7 +117,7 @@
ld c,4
call DelayFrames
ld de,RedSprite ; $4180
- ld hl,$8000
+ ld hl,vSprites
ld bc,(BANK(RedSprite) << 8) | $0C
call CopyVideoData
ld de,ShrinkPic1
@@ -219,9 +219,9 @@
call UncompressSpriteFromDE
ld hl,S_SPRITEBUFFER1
ld de,$A000
- ld bc,$0310
+ ld bc,$310
call CopyData
- ld de,$9000
+ ld de,vFrontPic
call InterlaceMergeSpriteBuffers
pop bc
ld a,c
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -80,22 +80,22 @@
cp $52
jr z, .asm_f020
ld de, Overworld_GFX + $2d0 ; $42d0 ; cuttable tree sprite top row
- ld hl, $8fc0
+ ld hl, vChars1 + $7c0
ld bc, (BANK(Overworld_GFX) << 8) + $02
call CopyVideoData
ld de, Overworld_GFX + $3d0 ; $43d0 ; cuttable tree sprite bottom row
- ld hl, $8fe0
+ ld hl, vChars1 + $7e0
ld bc, (BANK(Overworld_GFX) << 8) + $02
call CopyVideoData
jr asm_f055
.asm_f020
- ld hl, $8fc0
+ ld hl, vChars1 + $7c0
call LoadCutTreeOAM
- ld hl, $8fd0
+ ld hl, vChars1 + $7d0
call LoadCutTreeOAM
- ld hl, $8fe0
+ ld hl, vChars1 + $7e0
call LoadCutTreeOAM
- ld hl, $8ff0
+ ld hl, vChars1 + $7f0
call LoadCutTreeOAM
call asm_f055
ld hl, wOAMBuffer + $93
--- a/engine/overworld/emotion_bubbles.asm
+++ b/engine/overworld/emotion_bubbles.asm
@@ -8,7 +8,7 @@
ld e, [hl]
inc hl
ld d, [hl]
- ld hl, $8f80
+ ld hl, vChars1 + $780
ld bc, (BANK(EmotionBubblesPointerTable) << 8) + $04
call CopyVideoData
ld a, [wcfcb]
--- a/engine/overworld/healing_machine.asm
+++ b/engine/overworld/healing_machine.asm
@@ -1,6 +1,6 @@
AnimateHealingMachine: ; 70433 (1c:4433)
ld de, PokeCenterFlashingMonitorAndHealBall ; $44b7
- ld hl, $87c0
+ ld hl, vChars0 + $7c0
ld bc, (BANK(PokeCenterFlashingMonitorAndHealBall) << 8) + $03
call CopyVideoData
ld hl, wcfcb
--- a/engine/overworld/ledges.asm
+++ b/engine/overworld/ledges.asm
@@ -69,7 +69,7 @@
db $FF
LoadHoppingShadowOAM: ; 1a6f0 (6:66f0)
- ld hl, $8ff0
+ ld hl, vChars1 + $7f0
ld de, LedgeHoppingShadow ; $6708
ld bc, (BANK(LedgeHoppingShadow) << 8) + $01
call CopyVideoDataDouble
--- a/engine/overworld/map_sprites.asm
+++ b/engine/overworld/map_sprites.asm
@@ -126,7 +126,7 @@
push af
push de
push bc
- ld hl,$8000 ; VRAM base address
+ ld hl,vNPCSprites ; VRAM base address
ld bc,$c0 ; number of bytes per VRAM slot
ld a,[$ff8d]
cp a,11 ; is it a 4-tile sprite?
@@ -141,12 +141,12 @@
jr nz,.calculateVRAMAddrLoop
jr .loadStillTilePattern
.fourTileSpriteVRAMAddr
- ld hl,$87c0 ; address for second 4-tile sprite
+ ld hl,vSprites + $7c0 ; address for second 4-tile sprite
ld a,[$ff8e] ; 4-tile sprite counter
and a ; is it the first 4-tile sprite?
jr nz,.loadStillTilePattern
; if it's the first 4-tile sprite
- ld hl,$8780 ; address for first 4-tile sprite
+ ld hl,vSprites + $780 ; address for first 4-tile sprite
inc a
ld [$ff8e],a ; 4-tile sprite counter
.loadStillTilePattern
--- a/engine/overworld/player_animations.asm
+++ b/engine/overworld/player_animations.asm
@@ -45,7 +45,7 @@
.asm_70568
pop hl
ld de, BirdSprite ; $4d80
- ld hl, $8000
+ ld hl, vNPCSprites
ld bc, (BANK(BirdSprite) << 8) + $0c
call CopyVideoData
call Func_706d7
@@ -244,11 +244,11 @@
Func_706d7: ; 706d7 (1c:46d7)
ld de, BirdSprite ; $4d80
- ld hl, $8000
+ ld hl, vNPCSprites
ld bc, (BANK(BirdSprite) << 8) + $0c
call CopyVideoData
ld de, BirdSprite + $c0 ; $4e40 ; moving amination sprite
- ld hl, $8800
+ ld hl, vNPCSprites2
ld bc, (BANK(BirdSprite) << 8) + $0c
jp CopyVideoData
@@ -379,7 +379,7 @@
ld hl, wd736
set 6, [hl]
ld de, RedSprite ; $4180
- ld hl, $8000
+ ld hl, vNPCSprites
ld bc, (BANK(RedSprite) << 8) + $0c
call CopyVideoData
ld a, $4
@@ -468,20 +468,20 @@
RedFishingTiles: ; 70866 (1c:4866)
dw RedFishingTilesFront
- db $02, $1E
- dw $8020
+ db 2, BANK(RedFishingTilesFront)
+ dw vNPCSprites + $20
dw RedFishingTilesBack
- db $02, $1E
- dw $8060
+ db 2, BANK(RedFishingTilesBack)
+ dw vNPCSprites + $60
dw RedFishingTilesSide
- db $02, $1E
- dw $80A0
+ db 2, BANK(RedFishingTilesSide)
+ dw vNPCSprites + $a0
dw RedFishingRodTiles
- db $03, $1E
- dw $8FD0
+ db 3, BANK(RedFishingRodTiles)
+ dw vNPCSprites2 + $7d0
_HandleMidJump: ; 7087e (1c:487e)
ld a, [wd714]
--- a/engine/overworld/ssanne.asm
+++ b/engine/overworld/ssanne.asm
@@ -65,7 +65,7 @@
dw Func_79337
LoadSmokeTileFourTimes: ; 79fc0 (1e:5fc0)
- ld hl, $8fc0
+ ld hl, vChars1 + $7c0
ld c, $4
.loop
push bc
--- a/engine/palettes.asm
+++ b/engine/palettes.asm
@@ -503,7 +503,7 @@
call DisableLCD
ld a, $e4
ld [rBGP], a ; $ff47
- ld de, $8800
+ ld de, vChars1
ld a, [wcf2d]
and a
jr z, .asm_72122
@@ -513,7 +513,7 @@
ld bc, $1000
call CopyData
.asm_72128
- ld hl, $9800
+ ld hl, vBGMap0
ld de, $c
ld a, $80
ld c, $d
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -824,18 +824,18 @@
LoadSlotMachineTiles: ; 378a8 (d:78a8)
call DisableLCD
ld hl, SlotMachineTiles2
- ld de, $8000
- ld bc, $01c0
+ ld de, vChars0
+ ld bc, $1c0
ld a, BANK(SlotMachineTiles2)
call FarCopyData2
ld hl, SlotMachineTiles1
- ld de, $9000
- ld bc, $0250
+ ld de, vChars2
+ ld bc, $250
ld a, BANK(SlotMachineTiles1)
call FarCopyData2
ld hl, SlotMachineTiles2
- ld de, $9250
- ld bc, $01c0
+ ld de, vChars2 + $250
+ ld bc, $1c0
ld a, BANK(SlotMachineTiles2)
call FarCopyData2
ld hl, SlotMachineMap
--- a/engine/titlescreen.asm
+++ b/engine/titlescreen.asm
@@ -36,33 +36,33 @@
call DisableLCD
call LoadFontTilePatterns
ld hl, NintendoCopyrightLogoGraphics ; $60c8
- ld de, $9410
+ ld de, vTitleLogo2 + $100
ld bc, $50
ld a, BANK(NintendoCopyrightLogoGraphics)
call FarCopyData2
ld hl, GamefreakLogoGraphics ; $61f8
- ld de, $9460
+ ld de, vTitleLogo2 + $100 + $50
ld bc, $90
ld a, BANK(GamefreakLogoGraphics)
call FarCopyData2
ld hl, PokemonLogoGraphics ; $5380
- ld de, $8800
+ ld de, vTitleLogo
ld bc, $600
ld a, BANK(PokemonLogoGraphics)
call FarCopyData2 ; first chunk
ld hl, PokemonLogoGraphics+$600 ; $5980
- ld de, $9310
+ ld de, vTitleLogo2
ld bc, $100
ld a, BANK(PokemonLogoGraphics)
call FarCopyData2 ; second chunk
ld hl, Version_GFX ; $402f
IF _RED
- ld de,$9600 ; where to put redgreenversion.2bpp in the VRAM
- ld bc,$50 ; how big that file is
+ ld de,vChars2 + $600
+ ld bc,$50
ENDC
IF _BLUE
- ld de,$9610 ; where to put blueversion.2bpp in the VRAM
- ld bc,$40 ; how big that file is
+ ld de,vChars2 + $600 + $10
+ ld bc,$50 - $10
ENDC
ld a, BANK(Version_GFX)
@@ -302,7 +302,7 @@
Func_44dd: ; 44dd (1:44dd)
ld hl, PlayerCharacterTitleGraphics ; $66a8
- ld de, $8000
+ ld de, vSprites
ld bc, $230
ld a, BANK(PlayerCharacterTitleGraphics)
call FarCopyData2
@@ -338,7 +338,7 @@
ret
Func_4519: ; 4519 (1:4519)
- ld hl, $9800
+ ld hl, vBGMap0
ld bc, $800
ld a, $7f
jp FillMemory
@@ -363,7 +363,7 @@
LoadCopyrightTiles: ; 4541 (1:4541)
ld de, NintendoCopyrightLogoGraphics ; $60c8
- ld hl, $9600
+ ld hl, vChars2 + $600
ld bc, (BANK(NintendoCopyrightLogoGraphics) << 8) + $1c
call CopyVideoData
FuncCoord 2, 7
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -19,7 +19,7 @@
ld de, wTileMapBackup
ld bc, $10
call CopyData
- ld hl, $8040
+ ld hl, vSprites + $40
ld de, TownMapCursor ; $4f40
ld bc, (BANK(TownMapCursor) << 8) + $04
call CopyVideoDataDouble
@@ -143,11 +143,11 @@
call LoadPlayerSpriteGraphics
call LoadFontTilePatterns
ld de, BirdSprite ; $4d80
- ld hl, $8040
+ ld hl, vSprites + $40
ld bc, (BANK(BirdSprite) << 8) + $0c
call CopyVideoData
ld de, TownMapUpArrow ; $5093
- ld hl, $8ed0
+ ld hl, vChars1 + $6d0
ld bc, (BANK(TownMapUpArrow) << 8) + $01
call CopyVideoDataDouble
call Func_71070
@@ -294,12 +294,12 @@
call TextBoxBorder
call DisableLCD
ld hl, WorldMapTileGraphics ; $65a8
- ld de, $9600
+ ld de, vChars2 + $600
ld bc, $100
ld a, BANK(WorldMapTileGraphics)
call FarCopyData2
ld hl, MonNestIcon ; $56be
- ld de, $8040
+ ld de, vSprites + $40
ld bc, $8
ld a, BANK(MonNestIcon)
call FarCopyDataDouble
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -104,16 +104,16 @@
call Func_41196
call DisableLCD
ld hl, TradingAnimationGraphics ; $69be
- ld de, $9310
+ ld de, vChars2 + $310
ld bc, $310
ld a, BANK(TradingAnimationGraphics)
call FarCopyData2
ld hl, TradingAnimationGraphics2 ; $6cce
- ld de, $87c0
+ ld de, vSprites + $7c0
ld bc, $40
ld a, BANK(TradingAnimationGraphics2)
call FarCopyData2
- ld hl, $9800
+ ld hl, vBGMap0
ld bc, $800
ld a, $7f
call FillMemory
@@ -220,7 +220,7 @@
call CopyScreenTileBufferToVRAM
ld b, $8
call GoPAL_SET
- ld hl, $9c8c
+ ld hl, vBGMap1 + $8c
call Func_414ae
ld a, $a0
ld [$ffae], a
@@ -340,7 +340,7 @@
call Func_4142d
call Func_41186
call Func_4149f
- ld hl, $9c8c
+ ld hl, vBGMap1 + $8c
call Func_414ae
ld b, $6
call Func_414c5
@@ -371,7 +371,7 @@
call Func_4145c
call Func_41186
call Func_4149f
- ld hl, $9c94
+ ld hl, vBGMap1 + $94
call Func_414ae
call Func_41525
ld b, $6
@@ -492,7 +492,7 @@
call ScheduleRowRedrawHelper
pop hl
ld a, h
- ld [$ffd2], a
+ ld [H_SCREENEDGEREDRAWADDR + 1], a
ld a, l
ld [H_SCREENEDGEREDRAWADDR], a ; $ffd1
ld a, $2
--- a/home.asm
+++ b/home.asm
@@ -1032,8 +1032,8 @@
ld l,a
ld a,[W_TILESETGFXPTR + 1]
ld h,a
- ld de,$9000
- ld bc,$0600
+ ld de,vTileset
+ ld bc,$600
ld a,[W_TILESETBANK]
jp FarCopyData2
@@ -2165,17 +2165,17 @@
LoadWalkingPlayerSpriteGraphics:: ; 104d (0:104d)
ld de,RedSprite ; $4180
- ld hl,$8000
+ ld hl,vNPCSprites
jr LoadPlayerSpriteGraphicsCommon
LoadSurfingPlayerSpriteGraphics:: ; 1055 (0:1055)
ld de,SeelSprite
- ld hl,$8000
+ ld hl,vNPCSprites
jr LoadPlayerSpriteGraphicsCommon
LoadBikePlayerSpriteGraphics:: ; 105d (0:105d)
ld de,RedCyclingSprite
- ld hl,$8000
+ ld hl,vNPCSprites
LoadPlayerSpriteGraphicsCommon:: ; 1063 (0:1063)
push de
@@ -2508,10 +2508,10 @@
call LoadCurrentMapView
; copy current map view to VRAM
ld hl,wTileMap
- ld de,$9800
- ld b,$12
+ ld de,vBGMap0
+ ld b,18
.vramCopyLoop
- ld c,$14
+ ld c,20
.vramCopyInnerLoop
ld a,[hli]
ld [de],a
@@ -2518,7 +2518,7 @@
inc e
dec c
jr nz,.vramCopyInnerLoop
- ld a,$0c
+ ld a,32 - 20
add e
ld e,a
jr nc,.noCarry
@@ -2749,7 +2749,7 @@
ret
.validDexNumber
push hl
- ld de, $9000
+ ld de, vFrontPic
call LoadMonFrontSprite
pop hl
ld a, [H_LOADEDROMBANK]
@@ -4795,7 +4795,7 @@
cp 21
jr z, .flower
- ld hl, $9140
+ ld hl, vTileset + $14 * $10
ld c, $10
ld a, [wd085]
@@ -4839,7 +4839,7 @@
jr z, .copy
ld hl, FlowerTile3
.copy
- ld de, $9030
+ ld de, vTileset + $3 * $10
ld c, $10
.loop
ld a, [hli]
@@ -4938,9 +4938,9 @@
ld a, $ff
ld [$ffaa], a
- ld h, $9800 / $100 ; bg map 0
+ ld h, vBGMap0 / $100
call ClearBgMap
- ld h, $9c00 / $100 ; bg map 1
+ ld h, vBGMap1 / $100
call ClearBgMap
ld a, rLCDC_DEFAULT
@@ -8471,13 +8471,13 @@
jr nz,.lcdEnabled
.lcdDisabled
ld hl,FontGraphics
- ld de,$8800
+ ld de,vFont
ld bc,$400
ld a,BANK(FontGraphics)
jp FarCopyDataDouble ; if LCD is off, transfer all at once
.lcdEnabled
ld de,FontGraphics
- ld hl,$8800
+ ld hl,vFont
ld bc,(BANK(FontGraphics) << 8 | $80)
jp CopyVideoDataDouble ; if LCD is on, transfer during V-blank
@@ -8488,13 +8488,13 @@
jr nz,.lcdEnabled
.lcdDisabled
ld hl,TextBoxGraphics
- ld de,$9600
- ld bc,$0200
+ ld de,vChars2 + $600
+ ld bc,$200
ld a,BANK(TextBoxGraphics)
jp FarCopyData2 ; if LCD is off, transfer all at once
.lcdEnabled
ld de,TextBoxGraphics
- ld hl,$9600
+ ld hl,vChars2 + $600
ld bc,(BANK(TextBoxGraphics) << 8 | $20)
jp CopyVideoData ; if LCD is on, transfer during V-blank
@@ -8505,13 +8505,13 @@
jr nz,.lcdEnabled
.lcdDisabled
ld hl,HpBarAndStatusGraphics
- ld de,$9620
- ld bc,$01e0
+ ld de,vChars2 + $620
+ ld bc,$1e0
ld a,BANK(HpBarAndStatusGraphics)
jp FarCopyData2 ; if LCD is off, transfer all at once
.lcdEnabled
ld de,HpBarAndStatusGraphics
- ld hl,$9620
+ ld hl,vChars2 + $620
ld bc,(BANK(HpBarAndStatusGraphics) << 8 | $1e)
jp CopyVideoData ; if LCD is on, transfer during V-blank
--- a/main.asm
+++ b/main.asm
@@ -500,7 +500,7 @@
LoadTrainerInfoTextBoxTiles: ; 5ae6 (1:5ae6)
ld de, TrainerInfoTextBoxTileGraphics ; $7b98
- ld hl, $9760
+ ld hl, vChars2 + $760
ld bc, (BANK(TrainerInfoTextBoxTileGraphics) << 8) +$09
jp CopyVideoData
--- a/scripts/rockethideout2.asm
+++ b/scripts/rockethideout2.asm
@@ -329,9 +329,9 @@
ld [wSpriteStateData1 + 2], a
ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
cp FACILITY
- ld hl, SpinnerArrowTilePointers1 ; $5023
+ ld hl, FacilitySpinnerArrows ; $5023
jr z, .asm_44ff6
- ld hl, SpinnerArrowTilePointers2 ; $5053
+ ld hl, GymSpinnerArrows ; $5053
.asm_44ff6
ld a, [wcd38]
bit 0, a
@@ -368,87 +368,41 @@
jr nz, .asm_45006
ret
-SpinnerArrowTilePointers1: ; 45023 (11:5023)
- dw SpinnerArrowAnimTiles ;address from within tileset graphics
- db 1 ;number of tiles to copy?
- db BANK(SpinnerArrowAnimTiles) ;bank of tileset graphics
- dw $9200 ;where to load in VRAM
+spinner: MACRO
+; \1: source
+; \2: offset (BANK() chokes on literals)
+; \3: length
+; \4: dest
+ dw \1 + \2
+ db \3, BANK(\1)
+ dw \4
+ENDM
- dw SpinnerArrowAnimTiles + $10
- db 1
- db BANK(SpinnerArrowAnimTiles)
- dw $9210
+FacilitySpinnerArrows:
+FACILITY_SPINNER EQU $20 * $10
+vFacilitySpinner EQU vTileset + FACILITY_SPINNER
- dw SpinnerArrowAnimTiles + $20
- db 1
- db BANK(SpinnerArrowAnimTiles)
- dw $9300
+ spinner SpinnerArrowAnimTiles, $00, 1, vFacilitySpinner
+ spinner SpinnerArrowAnimTiles, $10, 1, vFacilitySpinner + $10
+ spinner SpinnerArrowAnimTiles, $20, 1, vFacilitySpinner + $100
+ spinner SpinnerArrowAnimTiles, $30, 1, vFacilitySpinner + $110
+ spinner Facility_GFX, FACILITY_SPINNER + $000, 1, vFacilitySpinner
+ spinner Facility_GFX, FACILITY_SPINNER + $010, 1, vFacilitySpinner + $10
+ spinner Facility_GFX, FACILITY_SPINNER + $100, 1, vFacilitySpinner + $100
+ spinner Facility_GFX, FACILITY_SPINNER + $110, 1, vFacilitySpinner + $110
- dw SpinnerArrowAnimTiles + $30
- db 1
- db BANK(SpinnerArrowAnimTiles)
- dw $9310
+GymSpinnerArrows:
+GYM_SPINNER EQU $3c * $10
+vGymSpinner EQU vTileset + GYM_SPINNER
- dw Facility_GFX + $200
- db 1
- db BANK(Facility_GFX)
- dw $9200
-
- dw Facility_GFX + $210
- db 1
- db BANK(Facility_GFX)
- dw $9210
-
- dw Facility_GFX + $300
- db 1
- db BANK(Facility_GFX)
- dw $9300
-
- dw Facility_GFX + $310
- db 1
- db BANK(Facility_GFX)
- dw $9310
-
-SpinnerArrowTilePointers2: ; 45053 (11:5053)
- dw SpinnerArrowAnimTiles + $10
- db 1
- db BANK(SpinnerArrowAnimTiles)
- dw $93C0
-
- dw SpinnerArrowAnimTiles + $30
- db 1
- db BANK(SpinnerArrowAnimTiles)
- dw $93D0
-
- dw SpinnerArrowAnimTiles
- db 1
- db BANK(SpinnerArrowAnimTiles)
- dw $94C0
-
- dw SpinnerArrowAnimTiles + $20
- db 1
- db BANK(SpinnerArrowAnimTiles)
- dw $94D0
-
- dw Gym_GFX + $3C0
- db 1
- db BANK(Facility_GFX)
- dw $93C0
-
- dw Gym_GFX + $3D0
- db 1
- db BANK(Facility_GFX)
- dw $93D0
-
- dw Gym_GFX + $4C0
- db 1
- db BANK(Facility_GFX)
- dw $94C0
-
- dw Gym_GFX + $4D0
- db 1
- db BANK(Facility_GFX)
- dw $94D0
+ spinner SpinnerArrowAnimTiles, $10, 1, vGymSpinner
+ spinner SpinnerArrowAnimTiles, $30, 1, vGymSpinner + $10
+ spinner SpinnerArrowAnimTiles, $00, 1, vGymSpinner + $100
+ spinner SpinnerArrowAnimTiles, $20, 1, vGymSpinner + $110
+ spinner Gym_GFX, GYM_SPINNER + $000, 1, vGymSpinner
+ spinner Gym_GFX, GYM_SPINNER + $010, 1, vGymSpinner + $10
+ spinner Gym_GFX, GYM_SPINNER + $100, 1, vGymSpinner + $100
+ spinner Gym_GFX, GYM_SPINNER + $110, 1, vGymSpinner + $110
SpinnerPlayerFacingDirections: ; 45083 (11:5083)
; This isn't the order of the facing directions. Rather, it's a list of
--- a/scripts/vermiliondock.asm
+++ b/scripts/vermiliondock.asm
@@ -184,7 +184,7 @@
ld bc, $00b4
ld a, $14
call FillMemory
- ld hl, $9940
+ ld hl, vBGMap0 + 10 * 32
ld de, wcc5b
ld bc, $000c
call CopyVideoData