shithub: pokecrystal

Download patch

ref: 1fc7430a2baa2835f4dad4676a3e7ae513275a7d
parent: 778d57ba217e9f0da9af03beceab0cc5fbd153b5
author: mid-kid <esteve.varela@gmail.com>
date: Tue Jul 17 19:08:04 EDT 2018

Fix misnamed character codes

Some character codes were erroneously named after their text command
counterparts. This has caused a lot of confusion with naming their
functions and with other things.

I've also removed the `dict2` macro and expanded the `dict` macro. This
really isn't something we should be doing for macros but I can't deny it
looks a lot neater than repeated code.

--- a/charmap.asm
+++ b/charmap.asm
@@ -2,9 +2,12 @@
 
 ; Control characters (see home/text.asm)
 
+	charmap "<NULL>",    $00
 	charmap "<PLAY_G>",  $14 ; "<PLAYER>くん" or "<PLAYER>ちゃん"; same as "<PLAYER>" in English
+	charmap "<MOBILE>",  $15
+	charmap "<CR>",      $16
 	charmap "¯",         $1f ; soft linebreak
-	charmap "<LNBRK>",   $22
+	charmap "<LF>",      $22
 	charmap "<POKE>",    $24 ; "<PO><KE>"
 	charmap "%",         $25 ; soft linebreak in landmark names
 	charmap "<RED>",     $38 ; wRedsName
--- a/data/phone/non_trainer_names.asm
+++ b/data/phone/non_trainer_names.asm
@@ -12,4 +12,4 @@
 .bill:     db "BILL:@"
 .elm:      db "PROF.ELM:@"
 .bikeshop: db "BIKE SHOP:@"
-.buena:    db "BUENA:<LNBRK>   DISC JOCKEY@"
+.buena:    db "BUENA:<LF>   DISC JOCKEY@"
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -8578,7 +8578,7 @@
 	db "   0    0    0@"
 
 .Format:
-	db "  ---  <LNBRK>"
+	db "  ---  <LF>"
 	db "         -    -    -@"
 .Record:
 	db "<PLAYER>'s RECORD@"
--- a/engine/menus/options_menu.asm
+++ b/engine/menus/options_menu.asm
@@ -61,20 +61,20 @@
 	ret
 
 StringOptions:
-	db "TEXT SPEED<LNBRK>"
-	db "        :<LNBRK>"
-	db "BATTLE SCENE<LNBRK>"
-	db "        :<LNBRK>"
-	db "BATTLE STYLE<LNBRK>"
-	db "        :<LNBRK>"
-	db "SOUND<LNBRK>"
-	db "        :<LNBRK>"
-	db "PRINT<LNBRK>"
-	db "        :<LNBRK>"
-	db "MENU ACCOUNT<LNBRK>"
-	db "        :<LNBRK>"
-	db "FRAME<LNBRK>"
-	db "        :TYPE<LNBRK>"
+	db "TEXT SPEED<LF>"
+	db "        :<LF>"
+	db "BATTLE SCENE<LF>"
+	db "        :<LF>"
+	db "BATTLE STYLE<LF>"
+	db "        :<LF>"
+	db "SOUND<LF>"
+	db "        :<LF>"
+	db "PRINT<LF>"
+	db "        :<LF>"
+	db "MENU ACCOUNT<LF>"
+	db "        :<LF>"
+	db "FRAME<LF>"
+	db "        :TYPE<LF>"
 	db "CANCEL@"
 
 GetOptionPointer:
--- a/engine/pokegear/townmap_convertlinebreakcharacters.asm
+++ b/engine/pokegear/townmap_convertlinebreakcharacters.asm
@@ -5,14 +5,14 @@
 	cp "@"
 	jr z, .end
 	cp "%"
-	jr z, .line_break
+	jr z, .line_feed
 	cp "¯"
-	jr z, .line_break
+	jr z, .line_feed
 	inc hl
 	jr .loop
 
-.line_break
-	ld [hl], "<LNBRK>"
+.line_feed
+	ld [hl], "<LF>"
 
 .end
 	ld de, wStringBuffer1
--- a/home/text.asm
+++ b/home/text.asm
@@ -178,26 +178,30 @@
 
 CheckDict::
 dict: MACRO
-if \1 == 0
+if \1 == "<NULL>"
 	and a
 else
 	cp \1
 endc
-	jp z, \2
-ENDM
 
-dict2: MACRO
-	cp \1
+if STRSUB("\2", 1, 1) == "\""
+; Replace a character with another one
 	jr nz, ._\@
 	ld a, \2
 ._\@:
+elif STRSUB("\2", 1, 1) == "."
+; Locals can use a short jump
+	jr z, \2
+else
+	jp z, \2
+endc
 ENDM
 
-	dict TX_DAY,      DayOfWeekChar
+	dict "<MOBILE>",  MobileScriptChar
 	dict "<LINE>",    LineChar
 	dict "<NEXT>",    NextLineChar
-	dict TX_FAR,      TextFar
-	dict TX_START,    NullChar
+	dict "<CR>",      CarriageReturnChar
+	dict "<NULL>",    NullChar
 	dict "<SCROLL>",  _ContTextNoPause
 	dict "<_CONT>",   _ContText
 	dict "<PARA>",    Paragraph
@@ -215,7 +219,7 @@
 	dict "<TM>",      TMChar
 	dict "<TRAINER>", TrainerChar
 	dict "<KOUGEKI>", PlaceKougeki
-	dict "<LNBRK>",   LineBreakChar
+	dict "<LF>",      LineFeedChar
 	dict "<CONT>",    ContText
 	dict "<……>",      SixDotsChar
 	dict "<DONE>",    DoneText
@@ -223,17 +227,14 @@
 	dict "<PKMN>",    PlacePKMN
 	dict "<POKE>",    PlacePOKE
 	dict "%",         NextChar
-	dict2 "¯",        " "
+	dict "¯",         " "
 	dict "<DEXEND>",  PlaceDexEnd
 	dict "<TARGET>",  PlaceMoveTargetsName
 	dict "<USER>",    PlaceMoveUsersName
 	dict "<ENEMY>",   PlaceEnemysName
 	dict "<PLAY_G>",  PlaceGenderedPlayerName
-
-	cp "゚"
-	jr z, .place ; should be .diacritic
-	cp "゙"
-	jr z, .place ; should be .diacritic
+	dict "゚",         .place ; should be .diacritic
+	dict "゙",         .place ; should be .diacritic
 	jr .not_diacritic
 
 .diacritic
@@ -276,10 +277,10 @@
 	call PrintLetterDelay
 	jp NextChar
 
-DayOfWeekChar::
+MobileScriptChar::
 	ld c, l
 	ld b, h
-	farcall Function17f036
+	farcall RunMobileScript
 	jp PlaceNextChar
 
 print_name: MACRO
@@ -409,7 +410,7 @@
 	push hl
 	jp NextChar
 
-LineBreakChar::
+LineFeedChar::
 	pop hl
 	ld bc, SCREEN_WIDTH
 	add hl, bc
@@ -416,7 +417,7 @@
 	push hl
 	jp NextChar
 
-TextFar::
+CarriageReturnChar::
 	pop hl
 	push de
 	ld bc, -wTileMap + $10000
--- a/mobile/mobile_22.asm
+++ b/mobile/mobile_22.asm
@@ -3894,7 +3894,7 @@
 	ret
 
 String_8aaf0:
-	db "あたらしい めいし<PKMN>できまし<LNBRK>@"
+	db "あたらしい めいし<PKMN>できまし<LF>@"
 
 Function8ab00:
 	ld de, String_8911c
--- a/mobile/mobile_5f.asm
+++ b/mobile/mobile_5f.asm
@@ -3570,25 +3570,25 @@
 	RGB 24, 16,  3
 	RGB  0,  0,  0
 
-Function17f036::
+RunMobileScript::
 	ld a, $6
 	call GetSRAMBank
 	inc de
-.asm_17f03c
-	call Function17f047
-	jr c, .asm_17f043
-	jr .asm_17f03c
+.loop
+	call _RunMobileScript
+	jr c, .finished
+	jr .loop
 
-.asm_17f043
+.finished
 	call CloseSRAM
 	ret
 
-Function17f047:
+_RunMobileScript:
 	ld a, [de]
 	inc de
 	cp $50
 	jr z, .finished
-	cp $10
+	cp $10 ; jumptable size
 	jr nc, .finished
 	dec a
 	push de