shithub: pokecrystal

Download patch

ref: d8b53bf8a0e26c9d8b7dd17b151788e7e89ec7bf
parent: fae070755617e9abf52bc48c5038e542a2469de8
parent: e7208f196419fbf9a6b1d56af85f369d00e1051d
author: Bryan Bishop <[email protected]>
date: Sun May 12 13:42:54 EDT 2013

Merge pull request #134 from iimarckus/oakintro

Add some naming screen stuff.

--- a/items/item_effects.asm
+++ b/items/item_effects.asm
@@ -402,7 +402,7 @@
 
 	pop hl
 	ld de, StringBuffer1
-	call $2ef9
+	call InitString
 
 	jp $6be2
 
@@ -466,7 +466,7 @@
 
 	ld hl, $b082
 	ld de, StringBuffer1
-	call $2ef9
+	call InitString
 
 	call CloseSRAM
 
--- a/main.asm
+++ b/main.asm
@@ -2421,8 +2421,37 @@
 	db "@"
 ; 0x26f7
 
-INCBIN "baserom.gbc", $26f7, $2bed-$26f7
+INCBIN "baserom.gbc", $26f7, $2b74-$26f7
 
+Function2b74: ; 0x2b74
+	push af
+	ld a, $1
+	ld [$c2ce], a
+	call WhiteBGMap
+	call ClearSprites
+	call $2bae
+	ld hl, $c590 ; tile 0, 12
+	ld bc, $0412
+	call TextBox
+	ld hl, VramState
+	set 0, [hl]
+	call $1ad2
+	call $3200
+	ld b, $9
+	call GetSGBLayout
+	ld a, $12
+	ld hl, $5409
+	rst $8
+	call $0485
+	call DelayFrame
+	ld a, $1
+	ld [$ffde], a
+	pop af
+	ret
+; 0x2bae
+
+INCBIN "baserom.gbc", $2bae, $2bed-$2bae
+
 GetMapHeaderPointer: ; 0x2bed
 ; Prior to calling this function, you must have switched banks so that
 ; MapGroupPointers is visible.
@@ -2707,8 +2736,55 @@
 	ret
 ; 0x2ead
 
-INCBIN "baserom.gbc", $2ead, $2f8c - $2ead
+INCBIN "baserom.gbc", $2ead, $2ed3 - $2ead
 
+Function2ed3: ; 0x2ed3
+; disables overworld sprite updating?
+	xor a
+	ld [$ffde], a
+	ld a, [VramState]
+	res 0, a
+	ld [VramState], a
+	ld a, $0
+	ld [$c2ce], a
+	ret
+; 0x2ee4
+
+INCBIN "baserom.gbc", $2ee4, $2ef9 - $2ee4
+
+InitString: ; 0x2ef9
+; if the string pointed to by hl is empty (defined as "zero or more spaces
+; followed by a null"), then initialize it to the string pointed to by de.
+;
+; Intended for names, so this function is limited to ten characters.
+	push hl
+	ld c, 10
+	push bc
+.loop
+	ld a, [hli]
+	cp "@"
+	jr z, .blank
+	cp " "
+	jr nz, .notblank
+	dec c
+	jr nz, .loop
+.blank
+	pop bc
+	ld l, e
+	ld h, d
+	pop de
+	ld b, $0
+	inc c
+	call CopyBytes
+	ret
+.notblank
+	pop bc
+	pop hl
+	ret
+; 0x2f17
+
+INCBIN "baserom.gbc", $2f17, $2f8c - $2f17
+
 RNG: ; 2f8c
 ; Two random numbers are generated by adding and subtracting
 ; the divider to the respective values every time it's called.
@@ -4623,7 +4699,7 @@
 	ld [$d123], a
 	ld [$d124], a
 	ld b, $1c
-	call $3340
+	call GetSGBLayout
 	call $6182
 	ld hl, OakText2
 	call PrintText
@@ -4637,7 +4713,7 @@
 	ld [TrainerClass], a
 	call $619c
 	ld b, $1c
-	call $3340
+	call GetSGBLayout
 	call $616a
 	ld hl, OakText5
 	call PrintText
@@ -4649,7 +4725,7 @@
 	ld hl, $4874
 	rst $8
 	ld b, $1c
-	call $3340
+	call GetSGBLayout
 	call $616a
 	ld hl, OakText6
 	call PrintText
@@ -5429,7 +5505,7 @@
 	dbw $0b, $4547
 	dbw $05, $6218
 	dbw $23, $4c04
-	dbw $03, $429d
+	dbw BANK(SpecialNameRival), SpecialNameRival
 	dbw $24, $4913
 	dbw $03, $42c0
 	dbw $03, $42cd
@@ -5445,7 +5521,7 @@
 	dbw $23, $4079
 	dbw $23, $40ab
 	dbw $00, $0d91
-	dbw $00, $31f3
+	dbw BANK(WhiteBGMap), WhiteBGMap
 	dbw $00, $0485
 	dbw BANK(ClearTileMap), ClearTileMap
 	dbw $00, $1ad2
@@ -5563,8 +5639,26 @@
 	dbw $24, $4a88
 	dbw $03, $4224
 
-INCBIN "baserom.gbc", $c224, $c3e2 - $c224
+INCBIN "baserom.gbc", $c224, $c29d - $c224
 
+SpecialNameRival: ; 0xc29d
+	ld b, $2 ; rival
+	ld de, WRivalName
+	ld a, BANK(Function116b7)
+	ld hl, Function116b7
+	rst $8
+	; default to "SILVER"
+	ld hl, WRivalName
+	ld de, DefaultRivalName
+	call InitString
+	ret
+; 0xc2b2
+
+DefaultRivalName: ; 0xc2b2
+	db "SILVER@"
+
+INCBIN "baserom.gbc", $c2b9, $c3e2 - $c2b9
+
 ScriptReturnCarry: ; c3e2
 	jr c, .carry
 	xor a
@@ -6354,8 +6448,17 @@
 	db WHIRLPOOL
 	db WATERFALL
 
-INCBIN "baserom.gbc", $116b3, $11ce7 - $116b3
+INCBIN "baserom.gbc", $116b3, $116b7 - $116b3
 
+Function116b7: ; 0x116b7
+	call Function2ed3
+	call $56c1
+	call $2b74
+	ret
+; 0x116c1
+
+INCBIN "baserom.gbc", $116c1, $11ce7 - $116c1
+
 NameInputLower:
 	db "a b c d e f g h i"
 	db "j k l m n o p q r"
@@ -6691,7 +6794,7 @@
 .choosemenu ; 1297f
 	xor a
 	ld [PartyMenuActionText], a ; Choose a POKéMON.
-	call $31f3 ; this is also a predef/special, something with delayframe
+	call WhiteBGMap
 .menu ; 12986
 	ld a, $14
 	ld hl, $404f
@@ -6790,7 +6893,7 @@
 
 OpenPartyStats: ; 12e00
 	call $1d6e
-	call $300b
+	call ClearSprites
 	xor a
 	ld [MonType], a ; partymon
 	call LowVolume
@@ -10122,7 +10225,7 @@
 	ld c, a
 	push bc
 	push hl
-	call $31f3
+	call WhiteBGMap
 	call ClearTileMap
 	call $1ad2
 	ld a, $3e
@@ -10130,7 +10233,7 @@
 	rst FarCall ; this loads graphics
 	pop hl
 	call JpHl
-	call $31f3
+	call WhiteBGMap
 	call ClearTileMap
 	pop bc
 	; restore old values
@@ -10361,7 +10464,7 @@
 PrintPartyMenuText: ; 5049a
 	ld hl, $c5b8
 	ld bc, $0212
-	call $0fe8 ; related to TextBoxBorder
+	call TextBox
 	ld a, [PartyCount]
 	and a
 	jr nz, .haspokemon
@@ -11249,7 +11352,7 @@
 	push af
 	ld a, $1
 	ld [$c2cd], a
-	call $2ed3
+	call Function2ed3
 	ld a, $1
 	ld [$d4b5], a
 
@@ -17033,8 +17136,8 @@
 	ld [$cf64], a
 	ld [$cf65], a
 	ld [$cf66], a
-	call $31f3
-	call $300b
+	call WhiteBGMap
+	call ClearSprites
 	ld a, $5c
 	ld hl, $6e78
 	rst FarCall
@@ -17045,8 +17148,8 @@
 ; 0x117ab4
 
 Function117ab4: ; 0x117ab4
-	call $31f3
-	call $300b
+	call WhiteBGMap
+	call ClearSprites
 	ld a, $5c
 	ld hl, $6e78
 	rst FarCall
@@ -17070,8 +17173,8 @@
 	rst FarCall
 	jr Function117acd
 .asm_117ae2
-	call $31f3
-	call $300b
+	call WhiteBGMap
+	call ClearSprites
 	ret
 
 Function117ae9: ; 0x117ae9
@@ -17194,7 +17297,7 @@
 	ld a, $46
 	ld hl, $4284
 	rst FarCall
-	call $300b
+	call ClearSprites
 	ld a, [$c300]
 	and a
 	jr z, .asm_117be7 ; 0x117bca $1b
--- a/wram.asm
+++ b/wram.asm
@@ -1408,10 +1408,16 @@
 	ds 2
 PlayerName: ; d47d
 	ds 11
-PlayerNameEnd: ; d478
+PlayerNameEnd: ; d488
 
-	ds 46
-	
+	ds 11
+
+WRivalName: ; d493
+	ds 11
+WRivalNameEnd: ; d49e
+
+	ds 24
+
 ; init time set at newgame
 StartDay: ; d4b6
 	ds 1