shithub: pokecrystal

Download patch

ref: 56d0175ad89c9c242c8945355ab1cf5675c4c3a5
parent: fdc1609f2a658b26599a9191bfbe99095248b6fc
author: IIMarckus <[email protected]>
date: Tue May 21 13:03:31 EDT 2013

Add Prof. Oak's PC.

--- a/main.asm
+++ b/main.asm
@@ -7766,7 +7766,290 @@
 
 SECTION "bank9",DATA,BANK[$9]
 
-INCBIN "baserom.gbc", $24000, $270c4 - $24000
+INCBIN "baserom.gbc", $24000, $265d3 - $24000
+
+ProfOaksPC: ; 0x265d3
+	ld hl, OakPCText1
+	call $1d4f
+	call $1dcf
+	jr c, .shutdown
+	call ProfOaksPCBoot ; player chose "yes"?
+.shutdown
+	ld hl, OakPCText4
+	call PrintText
+	call $0a36
+	call $1c07
+	ret
+; 0x265ee
+
+ProfOaksPCBoot ; 0x265ee
+	ld hl, OakPCText2
+	call PrintText
+	call Rate
+	call StartSFX ; sfx loaded by previous Rate function call
+	call $0a36
+	call WaitSFX
+	ret
+; 0x26601
+
+Function26601: ; 0x26601
+	call Rate
+	push de
+	ld de, MUSIC_NONE
+	call StartMusic
+	pop de
+	call StartSFX
+	call $0a36
+	call $3c55
+	ret
+; 0x26616
+
+Rate: ; 0x26616
+; calculate Seen/Owned
+	ld hl, PokedexCaught
+	ld b, EndPokedexCaught - PokedexCaught
+	call CountSetBits
+	ld [DefaultFlypoint], a
+	ld hl, PokedexSeen
+	ld b, EndPokedexSeen - PokedexSeen
+	call CountSetBits
+	ld [$d003], a
+
+; print appropriate rating
+	call ClearOakRatingBuffers
+	ld hl, OakPCText3
+	call PrintText
+	call $0a36
+	ld a, [$d003]
+	ld hl, OakRatings
+	call FindOakRating
+	push de
+	call PrintText
+	pop de
+	ret
+; 0x26647
+
+ClearOakRatingBuffers: ; 0x26647
+	ld hl, StringBuffer3
+	ld de, DefaultFlypoint
+	call ClearOakRatingBuffer
+	ld hl, StringBuffer4
+	ld de, $d003
+	call ClearOakRatingBuffer
+	ret
+; 0x2665a
+
+ClearOakRatingBuffer: ; 0x2665a
+	push hl
+	ld a, "@"
+	ld bc, $000d
+	call ByteFill
+	pop hl
+	ld bc, $4103
+	call $3198
+	ret
+; 0x2666b
+
+FindOakRating: ; 0x2666b
+; return sound effect in de
+; return text pointer in hl
+	nop
+	ld c, a
+.loop
+	ld a, [hli]
+	cp c
+	jr nc, .match
+	inc hl
+	inc hl
+	inc hl
+	inc hl
+	jr .loop
+
+.match
+	ld a, [hli]
+	ld e, a
+	ld a, [hli]
+	ld d, a
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	ret
+; 0x2667f
+
+OakRatings: ; 0x2667f
+; db count (if number caught ≤ this number, then this entry is used)
+; dw sound effect
+; dw text pointer
+
+	db 9
+	dw SFX_DEX_FANFARE_LESS_THAN_20
+	dw OakRating01
+
+	db 19
+	dw SFX_DEX_FANFARE_LESS_THAN_20
+	dw OakRating02
+
+	db 34
+	dw SFX_DEX_FANFARE_20_49
+	dw OakRating03
+
+	db 49
+	dw SFX_DEX_FANFARE_20_49
+	dw OakRating04
+
+	db 64
+	dw SFX_DEX_FANFARE_50_79
+	dw OakRating05
+
+	db 79
+	dw SFX_DEX_FANFARE_50_79
+	dw OakRating06
+
+	db 94
+	dw SFX_DEX_FANFARE_80_109
+	dw OakRating07
+
+	db 109
+	dw SFX_DEX_FANFARE_80_109
+	dw OakRating08
+
+	db 124
+	dw SFX_CAUGHT_MON
+	dw OakRating09
+
+	db 139
+	dw SFX_CAUGHT_MON
+	dw OakRating10
+
+	db 154
+	dw SFX_DEX_FANFARE_140_169
+	dw OakRating11
+
+	db 169
+	dw SFX_DEX_FANFARE_140_169
+	dw OakRating12
+
+	db 184
+	dw SFX_DEX_FANFARE_170_199
+	dw OakRating13
+
+	db 199
+	dw SFX_DEX_FANFARE_170_199
+	dw OakRating14
+
+	db 214
+	dw SFX_DEX_FANFARE_200_229
+	dw OakRating15
+
+	db 229
+	dw SFX_DEX_FANFARE_200_229
+	dw OakRating16
+
+	db 239
+	dw SFX_DEX_FANFARE_230_PLUS
+	dw OakRating17
+
+	db 248
+	dw SFX_DEX_FANFARE_230_PLUS
+	dw OakRating18
+
+	db 255
+	dw SFX_DEX_FANFARE_230_PLUS
+	dw OakRating19
+
+OakPCText1: ; 0x266de
+	TX_FAR _OakPCText1
+	db "@"
+
+OakPCText2: ; 0x266e3
+	TX_FAR _OakPCText2
+	db "@"
+
+OakPCText3: ; 0x266e8
+	TX_FAR _OakPCText3
+	db "@"
+
+OakRating01:
+	TX_FAR _OakRating01
+	db "@"
+
+OakRating02:
+	TX_FAR _OakRating02
+	db "@"
+
+OakRating03:
+	TX_FAR _OakRating03
+	db "@"
+
+OakRating04:
+	TX_FAR _OakRating04
+	db "@"
+
+OakRating05:
+	TX_FAR _OakRating05
+	db "@"
+
+OakRating06:
+	TX_FAR _OakRating06
+	db "@"
+
+OakRating07:
+	TX_FAR _OakRating07
+	db "@"
+
+OakRating08:
+	TX_FAR _OakRating08
+	db "@"
+
+OakRating09:
+	TX_FAR _OakRating09
+	db "@"
+
+OakRating10:
+	TX_FAR _OakRating10
+	db "@"
+
+OakRating11:
+	TX_FAR _OakRating11
+	db "@"
+
+OakRating12:
+	TX_FAR _OakRating12
+	db "@"
+
+OakRating13:
+	TX_FAR _OakRating13
+	db "@"
+
+OakRating14:
+	TX_FAR _OakRating14
+	db "@"
+
+OakRating15:
+	TX_FAR _OakRating15
+	db "@"
+
+OakRating16:
+	TX_FAR _OakRating16
+	db "@"
+
+OakRating17:
+	TX_FAR _OakRating17
+	db "@"
+
+OakRating18:
+	TX_FAR _OakRating18
+	db "@"
+
+OakRating19:
+	TX_FAR _OakRating19
+	db "@"
+
+OakPCText4: ; 0x2674c
+	TX_FAR _OakPCText4
+	db "@"
+
+INCBIN "baserom.gbc", $26751, $270c4 - $26751
 
 GetTrainerDVs: ; 270c4
 ; get dvs based on trainer class
--- a/text/common_2.asm
+++ b/text/common_2.asm
@@ -1184,17 +1184,17 @@
 	db "Link closed…", $57
 ; 1c1515
 
-UnknownText_0x1c1515: ; 1c1515
+_OakPCText1: ; 1c1515
 	db $0, "Want to get your", $4f
 	db "#DEX rated?", $57
 ; 1c1533
 
-UnknownText_0x1c1533: ; 1c1533
+_OakPCText2: ; 1c1533
 	db $0, "Current #DEX", $4f
 	db "completion level:", $58
 ; 1c1553
 
-UnknownText_0x1c1553: ; 1c1553
+_OakPCText3: ; 1c1553
 	text_from_ram $d099
 	db $0, " #MON seen", $4f
 	db "@"
@@ -1204,18 +1204,18 @@
 	db "Rating:", $57
 ; 1c1585
 
-UnknownText_0x1c1585: ; 1c1585
+_OakRating01: ; 1c1585
 	db $0, "Look for #MON", $4f
 	db "in grassy areas!", $57
 ; 1c15a5
 
-UnknownText_0x1c15a5: ; 1c15a5
+_OakRating02: ; 1c15a5
 	db $0, "Good. I see you", $4f
 	db "understand how to", $55
 	db "use # BALLS.", $57
 ; 1c15d5
 
-UnknownText_0x1c15d5: ; 1c15d5
+_OakRating03: ; 1c15d5
 	db $0, "You're getting", $4f
 	db "good at this.", $51
 	db "But you have a", $4f
@@ -1222,7 +1222,7 @@
 	db "long way to go.", $57
 ; 1c1611
 
-UnknownText_0x1c1611: ; 1c1611
+_OakRating04: ; 1c1611
 	db $0, "You need to fill", $4f
 	db "up the #DEX.", $51
 	db "Catch different", $4f
@@ -1229,7 +1229,7 @@
 	db "kinds of #MON!", $57
 ; 1c164f
 
-UnknownText_0x1c164f: ; 1c164f
+_OakRating05: ; 1c164f
 	db $0, "You're trying--I", $4f
 	db "can see that.", $51
 	db "Your #DEX is", $4f
@@ -1236,7 +1236,7 @@
 	db "coming together.", $57
 ; 1c168c
 
-UnknownText_0x1c168c: ; 1c168c
+_OakRating06: ; 1c168c
 	db $0, "To evolve, some", $4f
 	db "#MON grow,", $51
 	db "others use the", $4f
@@ -1243,7 +1243,7 @@
 	db "effects of STONES.", $57
 ; 1c16ca
 
-UnknownText_0x1c16ca: ; 1c16ca
+_OakRating07: ; 1c16ca
 	db $0, "Have you gotten a", $4f
 	db "fishing ROD? You", $51
 	db "can catch #MON", $4f
@@ -1250,13 +1250,13 @@
 	db "by fishing.", $57
 ; 1c1709
 
-UnknownText_0x1c1709: ; 1c1709
+_OakRating08: ; 1c1709
 	db $0, "Excellent! You", $4f
 	db "seem to like col-", $55
 	db "lecting things!", $57
 ; 1c173b
 
-UnknownText_0x1c173b: ; 1c173b
+_OakRating09: ; 1c173b
 	db $0, "Some #MON only", $4f
 	db "appear during", $51
 	db "certain times of", $4f
@@ -1263,13 +1263,13 @@
 	db "the day.", $57
 ; 1c1773
 
-UnknownText_0x1c1773: ; 1c1773
+_OakRating10: ; 1c1773
 	db $0, "Your #DEX is", $4f
 	db "filling up. Keep", $55
 	db "up the good work!", $57
 ; 1c17a4
 
-UnknownText_0x1c17a4: ; 1c17a4
+_OakRating11: ; 1c17a4
 	db $0, "I'm impressed.", $4f
 	db "You're evolving", $51
 	db "#MON, not just", $4f
@@ -1276,13 +1276,13 @@
 	db "catching them.", $57
 ; 1c17e0
 
-UnknownText_0x1c17e0: ; 1c17e0
+_OakRating12: ; 1c17e0
 	db $0, "Have you met KURT?", $4f
 	db "His custom BALLS", $55
 	db "should help.", $57
 ; 1c1812
 
-UnknownText_0x1c1812: ; 1c1812
+_OakRating13: ; 1c1812
 	db $0, "Wow. You've found", $4f
 	db "more #MON than", $51
 	db "the last #DEX", $4f
@@ -1289,7 +1289,7 @@
 	db "research project.", $57
 ; 1c1853
 
-UnknownText_0x1c1853: ; 1c1853
+_OakRating14: ; 1c1853
 	db $0, "Are you trading", $4f
 	db "your #MON?", $51
 	db "It's tough to do", $4f
@@ -1296,13 +1296,13 @@
 	db "this alone!", $57
 ; 1c188b
 
-UnknownText_0x1c188b: ; 1c188b
+_OakRating15: ; 1c188b
 	db $0, "Wow! You've hit", $4f
 	db "200! Your #DEX", $55
 	db "is looking great!", $57
 ; 1c18bc
 
-UnknownText_0x1c18bc: ; 1c18bc
+_OakRating16: ; 1c18bc
 	db $0, "You've found so", $4f
 	db "many #MON!", $51
 	db "You've really", $4f
@@ -1309,7 +1309,7 @@
 	db "helped my studies!", $57
 ; 1c18f7
 
-UnknownText_0x1c18f7: ; 1c18f7
+_OakRating17: ; 1c18f7
 	db $0, "Magnificent! You", $4f
 	db "could become a", $51
 	db "#MON professor", $4f
@@ -1316,7 +1316,7 @@
 	db "right now!", $57
 ; 1c1932
 
-UnknownText_0x1c1932: ; 1c1932
+_OakRating18: ; 1c1932
 	db $0, "Your #DEX is", $4f
 	db "amazing! You're", $51
 	db "ready to turn", $4f
@@ -1323,7 +1323,7 @@
 	db "professional!", $57
 ; 1c196b
 
-UnknownText_0x1c196b: ; 1c196b
+_OakRating19: ; 1c196b
 	db $0, "Whoa! A perfect", $4f
 	db "#DEX! I've", $51
 	db "dreamt about this!", $4f
@@ -1330,7 +1330,7 @@
 	db "Congratulations!", $57
 ; 1c19aa
 
-UnknownText_0x1c19aa: ; 1c19aa
+_OakPCText4: ; 1c19aa
 	db $0, "The link to PROF.", $4f
 	db "OAK's PC closed.", $57
 ; 1c19cd
--- a/wram.asm
+++ b/wram.asm
@@ -918,8 +918,10 @@
 	ds 19
 StringBuffer3: ; d099
 	ds 19
+StringBuffer4: ; d0ac
+	ds 19
 
-	ds 40
+	ds 21
 
 CurBattleMon: ; d0d4
 	ds 1
@@ -1811,8 +1813,10 @@
 SECTION "Pokedex",BSS[$de99]
 PokedexSeen: ; de99
 	ds 32
+EndPokedexSeen:
 PokedexCaught: ; deb9
 	ds 32
+EndPokedexCaught:
 UnownDex: ; ded9
 	ds 26
 UnlockedUnowns: ; def3