Merge branch 'yenatch/split-predefs-specials-stds' into fix-split-predefs-specials-stds

https://github.com/kanzure/pokecrystal/pull/198
This commit is contained in:
Bryan Bishop 2013-09-09 16:00:05 -05:00
commit 33d7ef72fe
7 changed files with 2355 additions and 757 deletions

134
common/copy2.asm Normal file
View File

@ -0,0 +1,134 @@
CopyBytes: ; 0x3026
; copy bc bytes from hl to de
inc b ; we bail the moment b hits 0, so include the last run
inc c ; same thing; include last byte
jr .HandleLoop
.CopyByte
ld a, [hli]
ld [de], a
inc de
.HandleLoop
dec c
jr nz, .CopyByte
dec b
jr nz, .CopyByte
ret
SwapBytes: ; 0x3034
; swap bc bytes between hl and de
.Loop
; stash [hl] away on the stack
ld a, [hl]
push af
; copy a byte from [de] to [hl]
ld a, [de]
ld [hli], a
; retrieve the previous value of [hl]; put it in [de]
pop af
ld [de], a
inc de
; handle loop stuff
dec bc
ld a, b
or c
jr nz, .Loop
ret
ByteFill: ; 0x3041
; fill bc bytes with the value of a, starting at hl
inc b ; we bail the moment b hits 0, so include the last run
inc c ; same thing; include last byte
jr .HandleLoop
.PutByte
ld [hli], a
.HandleLoop
dec c
jr nz, .PutByte
dec b
jr nz, .PutByte
ret
GetFarByte: ; 0x304d
; retrieve a single byte from a:hl, and return it in a.
; bankswitch to new bank
ld [hBuffer], a
ld a, [hROMBank]
push af
ld a, [hBuffer]
rst Bankswitch
; get byte from new bank
ld a, [hl]
ld [hBuffer], a
; bankswitch to previous bank
pop af
rst Bankswitch
; return retrieved value in a
ld a, [hBuffer]
ret
GetFarHalfword: ; 0x305d
; retrieve a halfword from a:hl, and return it in hl.
; bankswitch to new bank
ld [hBuffer], a
ld a, [hROMBank]
push af
ld a, [hBuffer]
rst Bankswitch
; get halfword from new bank, put it in hl
ld a, [hli]
ld h, [hl]
ld l, a
; bankswitch to previous bank and return
pop af
rst Bankswitch
ret
; 0x306b
FarCopyWRAM: ; 306b
ld [hBuffer], a
ld a, [rSVBK]
push af
ld a, [hBuffer]
ld [rSVBK], a
call CopyBytes
pop af
ld [rSVBK], a
ret
; 307b
GetFarWRAMByte: ; 307b
ld [hBuffer], a
ld a, [rSVBK]
push af
ld a, [hBuffer]
ld [rSVBK], a
ld a, [hl]
ld [hBuffer], a
pop af
ld [rSVBK], a
ld a, [hBuffer]
ret
; 308d
GetFarWRAMWord: ; 308d
ld [hBuffer], a
ld a, [rSVBK]
push af
ld a, [hBuffer]
ld [rSVBK], a
ld a, [hli]
ld h, [hl]
ld l, a
pop af
ld [rSVBK], a
ret
; 309d

76
common/math.asm Normal file
View File

@ -0,0 +1,76 @@
SimpleMultiply: ; 3105
; Return a * c.
and a
ret z
push bc
ld b, a
xor a
.loop
add c
dec b
jr nz, .loop
pop bc
ret
; 3110
SimpleDivide: ; 3110
; Divide a by c. Return quotient b and remainder a.
ld b, 0
.loop
inc b
sub c
jr nc, .loop
dec b
add c
ret
; 3119
Multiply: ; 3119
; Multiply hMultiplicand (3 bytes) by hMultiplier. Result in hProduct.
; All values are big endian.
push hl
push bc
callab _Multiply
pop bc
pop hl
ret
; 3124
Divide: ; 3124
; Divide hDividend length b (max 4 bytes) by hDivisor. Result in hQuotient.
; All values are big endian.
push hl
push de
push bc
ld a, [hROMBank]
push af
ld a, BANK(_Divide)
rst Bankswitch
call _Divide
pop af
rst Bankswitch
pop bc
pop de
pop hl
ret
; 3136
SubtractSigned: ; 3136
; Return a - b, sign in carry.
sub b
ret nc
cpl
add 1
scf
ret
; 313d

236
event/name_rater.asm Normal file
View File

@ -0,0 +1,236 @@
NameRater: ; fb6ed
ld hl, UnknownText_0xfb80f
call PrintText
call Function1dcf
jp c, .asm_fb77e
ld hl, UnknownText_0xfb814
call PrintText
callba Function50000
jr c, .asm_fb77e
ld a, [CurPartySpecies]
cp EGG
jr z, .asm_fb783
call GetCurNick
call Functionfb78a
jr c, .asm_fb779
ld hl, UnknownText_0xfb819
call PrintText
call Function1dcf
jr c, .asm_fb77e
ld hl, UnknownText_0xfb81e
call PrintText
xor a
ld [MonType], a
ld a, [CurPartySpecies]
ld [$d265], a
ld [CurSpecies], a
call GetBaseData
ld b, 0
ld de, StringBuffer2
callba Function116b7
call Functionfb7be
ld hl, UnknownText_0xfb837
jr c, .asm_fb76c
call Functionfb7d3
ld hl, UnknownText_0xfb837
jr c, .asm_fb76c
ld hl, PartyMon1Nickname
ld bc, $000b
ld a, [CurPartyMon]
call AddNTimes
ld e, l
ld d, h
ld hl, StringBuffer2
ld bc, $000b
call CopyBytes
ld hl, UnknownText_0xfb823
.asm_fb76c
push hl
call GetCurNick
ld hl, UnknownText_0xfb83c
call PrintText
pop hl
jr .asm_fb786
.asm_fb779
ld hl, UnknownText_0xfb82d
jr .asm_fb786
.asm_fb77e
ld hl, UnknownText_0xfb828
jr .asm_fb786
.asm_fb783
ld hl, UnknownText_0xfb832
.asm_fb786
call PrintText
ret
; fb78a
Functionfb78a: ; fb78a
ld hl, PartyMon1OT
ld bc, $000b
ld a, [CurPartyMon]
call AddNTimes
ld de, PlayerName
ld c, $b
call .asm_fb7b1
jr c, .asm_fb7bc
ld hl, PartyMon1ID
ld bc, PartyMon2 - PartyMon1
ld a, [CurPartyMon]
call AddNTimes
ld de, PlayerID
ld c, $2
.asm_fb7b1
ld a, [de]
cp [hl]
jr nz, .asm_fb7bc
inc hl
inc de
dec c
jr nz, .asm_fb7b1
and a
ret
.asm_fb7bc
scf
ret
; fb7be
Functionfb7be: ; fb7be
ld hl, StringBuffer2
ld c, 10
.asm_fb7c3
ld a, [hli]
cp "@"
jr z, .asm_fb7cf
cp " "
jr nz, .asm_fb7d1
dec c
jr nz, .asm_fb7c3
.asm_fb7cf
scf
ret
.asm_fb7d1
and a
ret
; fb7d3
Functionfb7d3: ; fb7d3
ld hl, PartyMon1Nickname
ld bc, $000b
ld a, [CurPartyMon]
call AddNTimes
push hl
call Functionfb802
ld b, c
ld hl, StringBuffer2
call Functionfb802
pop hl
ld a, c
cp b
jr nz, .asm_fb7fe
ld de, StringBuffer2
.asm_fb7f2
ld a, [de]
cp "@"
jr z, .asm_fb800
cp [hl]
jr nz, .asm_fb7fe
inc hl
inc de
jr .asm_fb7f2
.asm_fb7fe
and a
ret
.asm_fb800
scf
ret
; fb802
Functionfb802: ; fb802
ld c, 0
.asm_fb804
ld a, [hli]
cp "@"
ret z
inc c
ld a, c
cp 10
jr nz, .asm_fb804
ret
; fb80f
UnknownText_0xfb80f: ; 0xfb80f
; Hello, hello! I'm the NAME RATER.
; I rate the names of #MON.
; Would you like me to rate names?
text_jump UnknownText_0x1c0043, BANK(UnknownText_0x1c0043)
db "@"
; 0xfb814
UnknownText_0xfb814: ; 0xfb814
; Which #MON's nickname should I rate for you?
text_jump UnknownText_0x1c00a0, BANK(UnknownText_0x1c00a0)
db "@"
; 0xfb819
UnknownText_0xfb819: ; 0xfb819
; Hm… @ … That's a fairly decent name.
; But, how about a slightly better nickname?
; Want me to give it a better name?
text_jump UnknownText_0x1c00cd, BANK(UnknownText_0x1c00cd)
db "@"
; 0xfb81e
UnknownText_0xfb81e: ; 0xfb81e
; All right. What name should we give it, then?
text_jump UnknownText_0x1c0142, BANK(UnknownText_0x1c0142)
db "@"
; 0xfb823
UnknownText_0xfb823: ; 0xfb823
; That's a better name than before! Well done!
text_jump UnknownText_0x1c0171, BANK(UnknownText_0x1c0171)
db "@"
; 0xfb828
UnknownText_0xfb828: ; 0xfb828
; OK, then. Come again sometime.
text_jump UnknownText_0x1c019e, BANK(UnknownText_0x1c019e)
db "@"
; 0xfb82d
UnknownText_0xfb82d: ; 0xfb82d
; Hm… @ ? What a great name! It's perfect.
; Treat @ with loving care.
text_jump UnknownText_0x1c01be, BANK(UnknownText_0x1c01be)
db "@"
; 0xfb832
UnknownText_0xfb832: ; 0xfb832
; Whoa… That's just an EGG.
text_jump UnknownText_0x1c0208, BANK(UnknownText_0x1c0208)
db "@"
; 0xfb837
UnknownText_0xfb837: ; 0xfb837
; It might look the same as before,
; but this new name is much better! Well done!
text_jump UnknownText_0x1c0222, BANK(UnknownText_0x1c0222)
db "@"
; 0xfb83c
UnknownText_0xfb83c: ; 0xfb83c
; All right. This #MON is now named @ .
text_jump UnknownText_0x1c0272, BANK(UnknownText_0x1c0272)
db "@"
; 0xfb841

1145
main.asm

File diff suppressed because it is too large Load Diff

922
predef/cgb.asm Normal file

File diff suppressed because it is too large Load Diff

591
predef/sgb.asm Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2026,12 +2026,12 @@ PartyMon6Nickname: ; de78
PartyMonNicknamesEnd
SECTION "Pokedex",WRAMX[$de99],BANK[1]
PokedexSeen: ; de99
ds 32
EndPokedexSeen:
PokedexCaught: ; deb9
PokedexCaught: ; de99
ds 32
EndPokedexCaught:
PokedexSeen: ; deb9
ds 32
EndPokedexSeen:
UnownDex: ; ded9
ds 26
UnlockedUnowns: ; def3