ref: 61ee39678695479816feff4b58baaa6953ff219f
parent: fd2235e678c58cebd6255b5e658e704ee5138591
author: YamaArashi <shadow962@live.com>
date: Sat Jun 11 20:51:59 EDT 2016
more syncing with pokeyellow
--- a/engine/hidden_object_functions18.asm
+++ b/engine/hidden_object_functions18.asm
@@ -73,29 +73,29 @@
; format: db map id, player sprite facing direction, text id of PredefTextIDPointerTable
BenchGuyTextPointers:
db VIRIDIAN_POKECENTER, SPRITE_FACING_LEFT
- db (ViridianCityPokecenterBenchGuyText_id - TextPredefs) / 2 + 1
+ db_tx_pre ViridianCityPokecenterBenchGuyText
db PEWTER_POKECENTER, SPRITE_FACING_LEFT
- db (PewterCityPokecenterBenchGuyText_id - TextPredefs) / 2 + 1
+ db_tx_pre PewterCityPokecenterBenchGuyText
db CERULEAN_POKECENTER, SPRITE_FACING_LEFT
- db (CeruleanCityPokecenterBenchGuyText_id - TextPredefs) / 2 + 1
+ db_tx_pre CeruleanCityPokecenterBenchGuyText
db LAVENDER_POKECENTER, SPRITE_FACING_LEFT
- db (LavenderCityPokecenterBenchGuyText_id - TextPredefs) / 2 + 1
+ db_tx_pre LavenderCityPokecenterBenchGuyText
db VERMILION_POKECENTER, SPRITE_FACING_LEFT
- db (VermilionCityPokecenterBenchGuyText_id - TextPredefs) / 2 + 1
+ db_tx_pre VermilionCityPokecenterBenchGuyText
db CELADON_POKECENTER, SPRITE_FACING_LEFT
- db (CeladonCityPokecenterBenchGuyText_id - TextPredefs) / 2 + 1
+ db_tx_pre CeladonCityPokecenterBenchGuyText
db CELADON_HOTEL, SPRITE_FACING_LEFT
- db (CeladonCityHotelText_id - TextPredefs) / 2 + 1
+ db_tx_pre CeladonCityHotelText
db FUCHSIA_POKECENTER, SPRITE_FACING_LEFT
- db (FuchsiaCityPokecenterBenchGuyText_id - TextPredefs) / 2 + 1
+ db_tx_pre FuchsiaCityPokecenterBenchGuyText
db CINNABAR_POKECENTER, SPRITE_FACING_LEFT
- db (CinnabarIslandPokecenterBenchGuyText_id - TextPredefs) / 2 + 1
+ db_tx_pre CinnabarIslandPokecenterBenchGuyText
db SAFFRON_POKECENTER, SPRITE_FACING_LEFT
- db (SaffronCityPokecenterBenchGuyText_id - TextPredefs) / 2 + 1
+ db_tx_pre SaffronCityPokecenterBenchGuyText
db MT_MOON_POKECENTER, SPRITE_FACING_LEFT
- db (MtMoonPokecenterBenchGuyText_id - TextPredefs) / 2 + 1
+ db_tx_pre MtMoonPokecenterBenchGuyText
db ROCK_TUNNEL_POKECENTER,SPRITE_FACING_LEFT
- db (RockTunnelPokecenterBenchGuyText_id - TextPredefs) / 2 + 1
+ db_tx_pre RockTunnelPokecenterBenchGuyText
db $FF
ViridianCityPokecenterBenchGuyText:
--- a/engine/hidden_object_functions3.asm
+++ b/engine/hidden_object_functions3.asm
@@ -39,39 +39,39 @@
; format: db tileset id, bookshelf tile id, text id
BookshelfTileIDs:
db PLATEAU, $30
- db (IndigoPlateauStatues_id - TextPredefs) / 2 + 1
+ db_tx_pre IndigoPlateauStatues
db HOUSE, $3D
- db (TownMapText_id - TextPredefs) / 2 + 1
+ db_tx_pre TownMapText
db HOUSE, $1E
- db (BookOrSculptureText_id - TextPredefs) / 2 + 1
+ db_tx_pre BookOrSculptureText
db MANSION, $32
- db (BookOrSculptureText_id - TextPredefs) / 2 + 1
+ db_tx_pre BookOrSculptureText
db REDS_HOUSE_1, $32
- db (BookOrSculptureText_id - TextPredefs) / 2 + 1
+ db_tx_pre BookOrSculptureText
db LAB, $28
- db (BookOrSculptureText_id - TextPredefs) / 2 + 1
+ db_tx_pre BookOrSculptureText
db LOBBY, $16
- db (ElevatorText_id - TextPredefs) / 2 + 1
+ db_tx_pre ElevatorText
db GYM, $1D
- db (BookOrSculptureText_id - TextPredefs) / 2 + 1
+ db_tx_pre BookOrSculptureText
db DOJO, $1D
- db (BookOrSculptureText_id - TextPredefs) / 2 + 1
+ db_tx_pre BookOrSculptureText
db GATE, $22
- db (BookOrSculptureText_id - TextPredefs) / 2 + 1
+ db_tx_pre BookOrSculptureText
db MART, $54
- db (PokemonStuffText_id - TextPredefs) / 2 + 1
+ db_tx_pre PokemonStuffText
db MART, $55
- db (PokemonStuffText_id - TextPredefs) / 2 + 1
+ db_tx_pre PokemonStuffText
db POKECENTER, $54
- db (PokemonStuffText_id - TextPredefs) / 2 + 1
+ db_tx_pre PokemonStuffText
db POKECENTER, $55
- db (PokemonStuffText_id - TextPredefs) / 2 + 1
+ db_tx_pre PokemonStuffText
db LOBBY, $50
- db (PokemonStuffText_id - TextPredefs) / 2 + 1
+ db_tx_pre PokemonStuffText
db LOBBY, $52
- db (PokemonStuffText_id - TextPredefs) / 2 + 1
+ db_tx_pre PokemonStuffText
db SHIP, $36
- db (BookOrSculptureText_id - TextPredefs) / 2 + 1
+ db_tx_pre BookOrSculptureText
db $FF
IndigoPlateauStatues:
--- a/home/text.asm
+++ b/home/text.asm
@@ -52,28 +52,28 @@
ld a,[de]
cp "@"
- jr nz,.PlaceText
+ jr nz, Char4ETest
ld b,h
ld c,l
pop hl
ret
-.PlaceText
- cp $4E
- jr nz,.next
- ld bc,SCREEN_WIDTH * 2
+Char4ETest::
+ cp $4E ; next
+ jr nz, .char4FTest
+ ld bc, 2 * SCREEN_WIDTH
ld a,[hFlags_0xFFF6]
bit 2,a
- jr z,.next2
+ jr z,.ok
ld bc,SCREEN_WIDTH
-.next2
+.ok
pop hl
add hl,bc
push hl
jp PlaceNextChar_inc
-.next
- cp $4F
+.char4FTest
+ cp $4F ; line
jr nz,.next3
pop hl
coord hl, 1, 16
@@ -81,46 +81,36 @@
jp PlaceNextChar_inc
.next3 ; Check against a dictionary
+dict: macro
+if \1 == 0
and a
- jp z,Char00
- cp $4C
- jp z,Char4C
- cp $4B
- jp z,Char4B
- cp $51
- jp z,Char51
- cp $49
- jp z,Char49
- cp $52
- jp z,Char52
- cp $53
- jp z,Char53
- cp $54
- jp z,Char54
- cp $5B
- jp z,Char5B
- cp $5E
- jp z,Char5E
- cp $5C
- jp z,Char5C
- cp $5D
- jp z,Char5D
- cp $55
- jp z,Char55
- cp $56
- jp z,Char56
- cp $57
- jp z,Char57
- cp $58
- jp z,Char58
- cp $4A
- jp z,Char4A
- cp $5F
- jp z,Char5F
- cp $59
- jp z,Char59
- cp $5A
- jp z,Char5A
+else
+ cp \1
+endc
+ jp z, \2
+endm
+
+ dict $00, Char00 ; error
+ dict $4C, Char4C ; autocont
+ dict $4B, Char4B ; cont_
+ dict $51, Char51 ; para
+ dict $49, Char49 ; page
+ dict $52, Char52 ; player
+ dict $53, Char53 ; rival
+ dict $54, Char54 ; POKé
+ dict $5B, Char5B ; PC
+ dict $5E, Char5E ; ROCKET
+ dict $5C, Char5C ; TM
+ dict $5D, Char5D ; TRAINER
+ dict $55, Char55 ; cont
+ dict $56, Char56 ; 6 dots
+ dict $57, Char57 ; done
+ dict $58, Char58 ; prompt
+ dict $4A, Char4A ; PKMN
+ dict $5F, Char5F ; dex
+ dict $59, Char59 ; TARGET
+ dict $5A, Char5A ; USER
+
ld [hli],a
call PrintLetterDelay
PlaceNextChar_inc::
@@ -211,7 +201,6 @@
; print “Enemy ”
ld de,Char5AText
call PlaceString
-
ld h,b
ld l,c
ld de,wEnemyMonNick ; enemy active monster name
@@ -264,20 +253,20 @@
pop hl
ret
-Char58::
+Char58:: ; prompt
ld a,[wLinkState]
cp LINK_STATE_BATTLING
- jp z,Next1AA2
- ld a,$EE
+ jp z, .ok
+ ld a, $EE
Coorda 18, 16
-Next1AA2::
+.ok
call ProtectedDelay3
call ManualTextScroll
ld a, " "
Coorda 18, 16
-Char57::
+Char57:: ; done
pop hl
- ld de,Char58Text
+ ld de, Char58Text
dec de
ret
@@ -284,9 +273,9 @@
Char58Text::
db "@"
-Char51::
+Char51:: ; para
push de
- ld a,$EE
+ ld a, $EE
Coorda 18, 16
call ProtectedDelay3
call ManualTextScroll
@@ -293,7 +282,7 @@
coord hl, 1, 13
lb bc, 4, 18
call ClearScreenArea
- ld c,20
+ ld c, 20
call DelayFrames
pop de
coord hl, 1, 14
@@ -328,13 +317,13 @@
;fall through
Char4C::
push de
- call Next1B18
- call Next1B18
+ call ScrollTextUpOneLine
+ call ScrollTextUpOneLine
coord hl, 1, 16
pop de
jp PlaceNextChar_inc
-Next1B18::
+ScrollTextUpOneLine::
coord hl, 0, 14
coord de, 0, 13
ld b,60
@@ -372,7 +361,7 @@
push af
set 1,a
ld e,a
- ld a,[$fff4]
+ ld a, [$fff4]
xor e
ld [wLetterPrintingDelayFlags],a
ld a,c
@@ -389,22 +378,22 @@
ret
.doTextCommand
push hl
- cp a,$17
- jp z,TextCommand17
- cp a,$0e
+ cp a, $17
+ jp z, TextCommand17
+ cp a, $0e
jp nc,TextCommand0B ; if a != 0x17 and a >= 0xE, go to command 0xB
; if a < 0xE, use a jump table
ld hl,TextCommandJumpTable
push bc
add a
- ld b,$00
- ld c,a
- add hl,bc
+ ld b, 0
+ ld c, a
+ add hl, bc
pop bc
- ld a,[hli]
- ld h,[hl]
- ld l,a
- jp [hl]
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
; draw box
; 04AAAABBCC
@@ -523,10 +512,10 @@
; 07
; (no arguments)
TextCommand07::
- ld a," "
+ ld a, " "
Coorda 18, 16 ; place blank space in lower right corner of dialogue text box
- call Next1B18 ; scroll up text
- call Next1B18
+ call ScrollTextUpOneLine
+ call ScrollTextUpOneLine
pop hl
coord bc, 1, 16 ; address of second line of dialogue text box
jp NextTextCommand
@@ -537,7 +526,7 @@
pop hl
ld de,NextTextCommand
push de ; return address
- jp [hl]
+ jp hl
; print decimal number (converted from binary number)
; 09AAAABB
@@ -626,16 +615,16 @@
; format: text command ID, sound ID or cry ID
TextCommandSounds::
- db $0B,SFX_GET_ITEM_1
- db $12,SFX_CAUGHT_MON
- db $0E,SFX_POKEDEX_RATING
- db $0F,SFX_GET_ITEM_1
- db $10,SFX_GET_ITEM_2
- db $11,SFX_GET_KEY_ITEM
- db $13,SFX_DEX_PAGE_ADDED
- db $14,NIDORINA ; used in OakSpeech
- db $15,PIDGEOT ; used in SaffronCityText12
- db $16,DEWGONG ; unused?
+ db $0B, SFX_GET_ITEM_1
+ db $12, SFX_CAUGHT_MON
+ db $0E, SFX_POKEDEX_RATING
+ db $0F, SFX_GET_ITEM_1
+ db $10, SFX_GET_ITEM_2
+ db $11, SFX_GET_KEY_ITEM
+ db $13, SFX_DEX_PAGE_ADDED
+ db $14, NIDORINA ; used in OakSpeech
+ db $15, PIDGEOT ; used in SaffronCityText12
+ db $16, DEWGONG ; unused?
; draw ellipses
; 0CAA
--- a/macros.asm
+++ b/macros.asm
@@ -81,29 +81,62 @@
coins equs "bcd2"
money equs "bcd3"
+validateCoords: MACRO
+ if \1 >= SCREEN_WIDTH
+ fail "x coord out of range"
+ endc
+ if \2 >= SCREEN_HEIGHT
+ fail "y coord out of range"
+ endc
+ endm
+
;\1 = r
;\2 = X
;\3 = Y
+;\4 = which tilemap (optional)
coord: MACRO
- ld \1, wTileMap + 20 * \3 + \2
+ validateCoords \2, \3
+if _NARG >= 4
+ ld \1, \4 + SCREEN_WIDTH * \3 + \2
+else
+ ld \1, wTileMap + SCREEN_WIDTH * \3 + \2
+endc
ENDM
;\1 = X
;\2 = Y
+;\3 = which tilemap (optional)
aCoord: MACRO
- ld a, [wTileMap + 20 * \2 + \1]
+ validateCoords \1, \2
+if _NARG >= 3
+ ld a, [\3 + SCREEN_WIDTH * \2 + \1]
+else
+ ld a, [wTileMap + SCREEN_WIDTH * \2 + \1]
+endc
ENDM
;\1 = X
;\2 = Y
+;\3 = which tilemap (optional)
Coorda: MACRO
- ld [wTileMap + 20 * \2 + \1], a
+ validateCoords \1, \2
+if _NARG >= 3
+ ld [\3 + SCREEN_WIDTH * \2 + \1], a
+else
+ ld [wTileMap + SCREEN_WIDTH * \2 + \1], a
+endc
ENDM
;\1 = X
;\2 = Y
+;\3 = which tilemap (optional)
dwCoord: MACRO
- dw wTileMap + 20 * \2 + \1
+ validateCoords \1, \2
+if _NARG >= 3
+ dw \3 + SCREEN_WIDTH * \2 + \1
+else
+ dw wTileMap + SCREEN_WIDTH * \2 + \1
+endc
ENDM
;\1 = r
@@ -134,7 +167,7 @@
; nybble: y-coordinate
; nybble: x-coordinate
; word : pointer to map name
- db (\1 + (\2 << 4))
+ dn \2, \1
dw \3
ENDM
@@ -146,7 +179,7 @@
; nybble: x-coordinate
; word : pointer to map name
db \1 + 1
- db \2 + \3 << 4
+ dn \3, \2
dw \4
ENDM
@@ -174,28 +207,30 @@
dw \2
ENDM
-; data format macros
-RGB: MACRO
- dw (\3 << 10 | \2 << 5 | \1)
+dba: MACRO
+ dbw BANK(\1), \1
ENDM
-; text macros
-TX_NUM: MACRO
-; print a big-endian decimal number.
-; \1: address to read from
-; \2: number of bytes to read
-; \3: number of digits to display
- db $09
+dwb: MACRO
dw \1
- db \2 << 4 | \3
+ db \2
ENDM
-TX_FAR: MACRO
- db $17
- dw \1
- db BANK(\1)
+dab: MACRO
+ dwb \1, BANK(\1)
ENDM
+dbbw: MACRO
+ db \1, \2
+ dw \3
+ ENDM
+
+; data format macros
+RGB: MACRO
+ dw (\3 << 10 | \2 << 5 | \1)
+ ENDM
+
+; text macros
; text engine command $1
TX_RAM: MACRO
; prints text to screen
@@ -212,23 +247,39 @@
db \2
ENDM
-TX_MART: MACRO
- db $FE, _NARG
- rept _NARG
- db \1
- shift
- endr
- db $FF
+TX_CURSOR: MACRO
+; Move cursor to (\1, \2)
+; \1: X coord (0 - 19)
+; \2: Y coord (0 - 17)
+ db $3
+ dwCoord \1, \2
ENDM
TX_LINE EQUS "db $05"
TX_BUTTON_SOUND EQUS "db $06"
TX_ASM EQUS "db $08"
+
+TX_NUM: MACRO
+; print a big-endian decimal number.
+; \1: address to read from
+; \2: number of bytes to read
+; \3: number of digits to display
+ db $09
+ dw \1
+ db \2 << 4 | \3
+ ENDM
+
TX_SFX_ITEM EQUS "db $0b"
TX_WAIT_BUTTON EQUS "db $0d"
TX_SFX_CONGRATS EQUS "db $10"
TX_SFX_KEY_ITEM EQUS "db $11"
+TX_FAR: MACRO
+; 17AAAABB (call text at BB:AAAA)
+ db $17
+ dab \1
+ ENDM
+
TX_VENDING_MACHINE EQUS "db $f5"
TX_CABLE_CLUB_RECEPTIONIST EQUS "db $f6"
TX_PRIZE_VENDOR EQUS "db $f7"
@@ -235,9 +286,23 @@
TX_POKECENTER_PC EQUS "db $f9"
TX_PLAYERS_PC EQUS "db $fc"
TX_BILLS_PC EQUS "db $fd"
+
+TX_MART: MACRO
+ db $FE, _NARG
+ rept _NARG
+ db \1
+ shift
+ endr
+ db $FF
+ ENDM
+
TX_POKECENTER_NURSE EQUS "db $ff"
; Predef macro.
+predef_const: MACRO
+ const \1PredefID
+ ENDM
+
add_predef: MACRO
\1Predef::
db BANK(\1)
@@ -258,11 +323,18 @@
jp Predef
ENDM
+tx_pre_const: MACRO
+ const \1_id
+ ENDM
add_tx_pre: MACRO
\1_id:: dw \1
ENDM
+db_tx_pre: MACRO
+ db (\1_id - TextPredefs) / 2 + 1
+ENDM
+
tx_pre_id: MACRO
ld a, (\1_id - TextPredefs) / 2 + 1
ENDM
@@ -674,9 +746,9 @@
tmlearn: MACRO
x = 0
rept _NARG
-if \1 != 0
+IF \1 != 0
x = x | (1 << ((\1 - 1) % 8))
-endc
+ENDC
shift
endr
db x