mirror of https://github.com/pret/pokecrystal.git
commit
cb1d7f812b
156
main.asm
156
main.asm
|
@ -4839,7 +4839,39 @@ OpenPartyStats: ; 12e00
|
|||
ret
|
||||
; 0x12e1b
|
||||
|
||||
INCBIN "baserom.gbc",$12e1b,$13d96 - $12e1b
|
||||
INCBIN "baserom.gbc",$12e1b,$13b87 - $12e1b
|
||||
|
||||
GetSquareRoot: ; 13b87
|
||||
; Return the square root of de in b.
|
||||
|
||||
; Rather than calculating the result, we take the index of the
|
||||
; first value in a table of squares that isn't lower than de.
|
||||
|
||||
ld hl, Squares
|
||||
ld b, 0
|
||||
.loop
|
||||
; Make sure we don't go past the end of the table.
|
||||
inc b
|
||||
ld a, b
|
||||
cp $ff
|
||||
ret z
|
||||
|
||||
; Iterate over the table until b**2 >= de.
|
||||
ld a, [hli]
|
||||
sub e
|
||||
ld a, [hli]
|
||||
sbc d
|
||||
|
||||
jr c, .loop
|
||||
ret
|
||||
|
||||
Squares: ; 13b98
|
||||
root set 1
|
||||
rept $ff
|
||||
dw root*root
|
||||
root set root+1
|
||||
endr
|
||||
; 13d96
|
||||
|
||||
|
||||
SECTION "bank5",DATA,BANK[$5]
|
||||
|
@ -7137,9 +7169,129 @@ Dragon:
|
|||
Dark:
|
||||
db "DARK@"
|
||||
|
||||
INCBIN "baserom.gbc",$50A28, $51424 - $50A28
|
||||
INCBIN "baserom.gbc", $50a28, $50bdd - $50a28
|
||||
|
||||
|
||||
GetGender: ; 50bdd
|
||||
; Return the gender of a given monster in a.
|
||||
|
||||
; 1: male
|
||||
; 0: female
|
||||
; c: genderless
|
||||
|
||||
; This is determined by comparing the Attack and Speed DVs
|
||||
; with the species' gender ratio.
|
||||
|
||||
|
||||
; Figure out what type of monster struct we're looking at.
|
||||
|
||||
; 0: PartyMon
|
||||
ld hl, PartyMon1DVs
|
||||
ld bc, PartyMon2 - PartyMon1
|
||||
ld a, [MonType]
|
||||
and a
|
||||
jr z, .PartyMon
|
||||
|
||||
; 1: OTPartyMon
|
||||
ld hl, OTPartyMon1DVs
|
||||
dec a
|
||||
jr z, .PartyMon
|
||||
|
||||
; 2: BoxMon
|
||||
ld hl, $ad26 + $15 ; BoxMon1DVs
|
||||
ld bc, $20 ; BoxMon2 - BoxMon1
|
||||
dec a
|
||||
jr z, .BoxMon
|
||||
|
||||
; 3: Unknown
|
||||
ld hl, $d123 ; DVBuffer
|
||||
dec a
|
||||
jr z, .DVs
|
||||
|
||||
; else: WildMon
|
||||
ld hl, EnemyMonDVs
|
||||
jr .DVs
|
||||
|
||||
|
||||
; Get our place in the party/box.
|
||||
|
||||
.PartyMon
|
||||
.BoxMon
|
||||
ld a, [CurPartyMon]
|
||||
call AddNTimes
|
||||
|
||||
|
||||
.DVs
|
||||
|
||||
; BoxMon data is read directly from SRAM.
|
||||
ld a, [MonType]
|
||||
cp 2
|
||||
ld a, 1
|
||||
call z, GetSRAMBank
|
||||
|
||||
; Attack DV
|
||||
ld a, [hli]
|
||||
and $f0
|
||||
ld b, a
|
||||
; Speed DV
|
||||
ld a, [hl]
|
||||
and $f0
|
||||
swap a
|
||||
|
||||
; Put our DVs together.
|
||||
or b
|
||||
ld b, a
|
||||
|
||||
; Close SRAM if we were dealing with a BoxMon.
|
||||
ld a, [MonType] ; MonType
|
||||
cp 2 ; BOXMON
|
||||
call z, CloseSRAM
|
||||
|
||||
|
||||
; We need the gender ratio to do anything with this.
|
||||
push bc
|
||||
ld a, [CurPartySpecies]
|
||||
dec a
|
||||
ld hl, BaseStats + 13 ; BASE_GENDER
|
||||
ld bc, BaseStats1 - BaseStats
|
||||
call AddNTimes
|
||||
pop bc
|
||||
|
||||
ld a, BANK(BaseStats)
|
||||
call GetFarByte
|
||||
|
||||
|
||||
; The higher the ratio, the more likely the monster is to be female.
|
||||
|
||||
cp $ff
|
||||
jr z, .Genderless
|
||||
|
||||
and a
|
||||
jr z, .Male
|
||||
|
||||
cp $fe
|
||||
jr z, .Female
|
||||
|
||||
; Values below the ratio are male, and vice versa.
|
||||
cp b
|
||||
jr c, .Male
|
||||
|
||||
.Female
|
||||
xor a
|
||||
ret
|
||||
|
||||
.Male
|
||||
ld a, 1
|
||||
and a
|
||||
ret
|
||||
|
||||
.Genderless
|
||||
scf
|
||||
ret
|
||||
; 50c50
|
||||
|
||||
INCBIN "baserom.gbc", $50c50, $51424 - $50c50
|
||||
|
||||
BaseStats:
|
||||
INCLUDE "stats/base_stats.asm"
|
||||
|
||||
|
|
Loading…
Reference in New Issue