PrintLetterDelay and some battle init

This commit is contained in:
padz 2012-09-11 22:37:03 -04:00
parent f570fb7fb6
commit 4c1ef2aef5
2 changed files with 810 additions and 12 deletions

723
main.asm
View File

@ -125,7 +125,109 @@ EnableLCD: ; 58a
ret
; 0x591
INCBIN "baserom.gbc",$591,$e8d - $591
INCBIN "baserom.gbc",$591,$984 - $591
GetJoypadState; 984
push af
push hl
push de
push bc
ld a,[$c2c7]
cp a, $ff
jr z, .asm_9a7
ld a,[$ff00+$a4]
ld b, a
ld a,[$ff00+$a8]
ld e, a
xor b
ld d, a
and e
ld [$ff00+$a6], a
ld a, d
and b
ld [$ff00+$a7], a
ld c, a
ld a, b
ld [$ff00+$a8], a
.asm_9a2
pop bc
pop de
pop hl
pop af
ret
.asm_9a7
ld a,[$ff00+$9d]
push af
ld a, [$c2ca]
rst $10
ld hl, $c2c8
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [$c2cb]
and a
jr z, .asm_9c2
dec a
ld [$c2cb], a
pop af
rst $10
jr .asm_9a2
.asm_9c2
ld a, [hli]
cp a, $ff
jr z, .asm_9e0
ld b, a
ld a, [hli]
ld [$c2cb], a
cp a, $ff
jr nz, .asm_9d6
dec hl
dec hl
ld b, $00
jr .asm_9e5
.asm_9d6
ld a, l
ld [$c2c8], a
ld a, h
ld [$c2c9], a
jr .asm_9e5
.asm_9e0
call Functiona0a
ld b, $00
.asm_9e5
pop af
rst $10
ld a, b
ld [$ff00+$a7], a
ld [$ff00+$a8], a
jr .asm_9a2
ld [$c2ca], a
ld a, l
ld [$c2c8], a
ld a, h
ld [$c2c9], a
xor a
ld [$c2cb], a
xor a
ld [$ff00+$a7], a
ld [$ff00+$a6], a
ld [$ff00+$a8], a
ld a, $ff
ld [$c2c7], a
ret
;a0a
Functiona0a:
xor a
ld [$c2ca], a
ld [$c2c8], a
ld [$c2c9], a
ld [$c2cb], a
ld [$c2c7], a
ret
;a1b
INCBIN "baserom.gbc",$a1b,$e8d - $a1b
; copy bc bytes from a:hl to de
FarCopyBytes:
@ -355,7 +457,7 @@ CheckDict:
call $13c6
.asm_1174
ld [hli], a
call $313d
call PrintLetterDelay
jp NextChar
; 0x117b
@ -404,7 +506,7 @@ Char5D:
ld de, $c656
jr .asm_126a ; 0x1250 $18
push de
ld de, $d47d
ld de, PlayerName
call $1078
ld h, b
ld l, c
@ -814,8 +916,56 @@ PrintLetterDelay: ; 313d
; This function is used to wait a short period after printing a letter to the
; screen unless the player presses the A/B button or the delay is turned off
; through the [$cfcc] or [$cfcf] flags.
INCBIN "baserom.gbc",$313d,$318c - $313d
; 0x318c
ld a, [$cfcc]
bit 4, a
ret nz
ld a, [$cfcf]
bit 1, a
ret z
push hl
push de
push bc
ld hl, $ffd8
ld a, [hl]
push af
ld [hl], a
ld a, [$cfcf]
bit 0, a
jr z, .asm_3160
ld a, [$cfcc]
and a, $07
jr .asm_3162
.asm_3160
ld a, $01
.asm_3162
ld [$cfb2], a
.joypad
call GetJoypadState
ld a, [$c2d7]
and a
jr nz, .asm_317f
ld a, [$ff00+$a8] ; joypad
bit 0, a ; a
jr z, .asm_3176
jr .asm_317a
.asm_3176
bit 1, a ; b
jr z, .asm_317f
.asm_317a
call DelayFrame
jr .end
.asm_317f
ld a, [$cfb2]
and a
jr nz, .joypad
.end
pop af
ld [$ff00+$d8], a
pop bc
pop de
pop hl
ret
;318c
CopyDataUntil: ; 318c
; Copies [hl, bc) to [de, bc - hl).
@ -10624,7 +10774,418 @@ INCBIN "baserom.gbc",$3d14e,$3ddc2 - $3d14e
jp $3ad5
; 0x3ddc8
INCBIN "baserom.gbc",$3ddc8,$3fc8b - $3ddc8
INCBIN "baserom.gbc",$3ddc8,$3e8eb - $3ddc8
Function3e8eb: ; 3e8eb
;part of battle init
xor a
ld hl, EnemyMonSpecies2
ld bc, $0027
call ByteFill
ld a, [InLinkBattle]
and a
jp nz, $5abd
ld a, [$cfc0]
bit 0, a
jp nz, $5abd
ld a, [EnemyMonSpecies]
ld [EnemyMonSpecies2], a
ld [$cf60], a
ld [$d108], a
call $3856
ld a, [$d22d]
dec a
jr z, .asm_3e925
ld a, [$d109]
ld hl, $d289
call $3927
ld a, [hl]
jr .asm_3e945
.asm_3e925
ld a, [$d230]
cp a, $0a
ld a, [$d241]
jr z, .asm_3e945
call $2f9f
cp a, $c0
ld a, $00
jr c, .asm_3e945
call $2f9f
cp a, $14
ld a, [$d241]
jr nc, .asm_3e945
ld a, [$d242]
.asm_3e945
ld [EnemyMonItem], a
ld a, [$d22d]
and a
jr z, .asm_3e963
ld a, [$c671]
bit 3, a
jr z, .asm_3e963
ld hl, $c6f2
ld de, EnemyMonDVs
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
jp .asm_3ea1a
.asm_3e963
ld a, $09
ld hl, $70c4
rst $08
ld a, [$d22d]
dec a
jr nz, .asm_3e9a8
ld a, [$d230]
cp a, $05
jr nz, .asm_3e996
call $7a01
ld a, [hl]
and a
push af
call $7a19
inc hl
ld a, [hld]
ld c, a
ld b, [hl]
pop af
jr nz, .asm_3e9a8
call $7a19
inc hl
call $2f9f
ld [hld], a
ld c, a
call $2f9f
ld [hl], a
ld b, a
jr .asm_3e9a8
.asm_3e996
cp a, $07
jr nz, .asm_3e9a0
ld b, $ea
ld c, $aa
jr .asm_3e9a8
.asm_3e9a0
call $2f9f
ld b, a
call $2f9f
ld c, a
.asm_3e9a8
ld hl, EnemyMonDVs
ld a, b
ld [hli], a
ld [hl], c
ld a, [$d22d]
dec a
jr nz, .asm_3ea1a
ld a, [EnemyMonSpecies]
cp a, UNOWN
jr nz, .asm_3e9c8
ld hl, EnemyMonDVs
ld a, $2d
call $2d83
call CheckUnownLetter
jr c, .asm_3e9a0
.asm_3e9c8
ld a, [EnemyMonSpecies]
cp a, MAGIKARP
jr nz, .asm_3ea1a
ld de, $d20c
ld bc, PlayerID
ld hl, Functionfbbfc
ld a, BANK(Functionfbbfc)
rst $08
ld a, [$d1ea]
cp a, $06
jr nz, .asm_3e9fe
call $2f8c
cp a, $0c
jr c, .asm_3e9fe
ld a, [$d1eb]
cp a, $50
jr nc, .asm_3e9a0
call $2f8c
cp a, $32
jr c, .asm_3e9fe
ld a, [$d1eb]
cp a, $40
jr nc, .asm_3e9a0
.asm_3e9fe
ld a, [$dcb5]
cp a, $09
jr z, .asm_3ea1a
ld a, [$dcb6]
cp a, $06
jr z, .asm_3ea1a
call $2f8c
cp a, $64
jr c, .asm_3ea1a
ld a, [$d1ea]
cp a, $04
jr c, .asm_3e9a0
.asm_3ea1a
ld a, $46
ld [EnemyMonHappiness], a
ld a, [$d143]
ld [EnemyMonLevel], a
ld de, EnemyMonMaxHP
ld b, $00
ld hl, $d201
ld a, $0c
call $2d83
ld a, [$d22d]
cp a, $02
jr z, .asm_3ea74
and a
jr z, .asm_3ea44
ld a, [$c671]
bit 3, a
jp nz, .asm_3ea90
.asm_3ea44
call CheckSleepingWildMon
ld a, $07
jr c, .asm_3ea4c
xor a
.asm_3ea4c
ld hl, EnemyMonStatus
ld [hli], a
xor a
ld [hli], a
ld a, [$d218] ; EnemyMonMaxHP
ld [hli], a
ld a, [$d219] ; EnemyMonMaxHP + 1
ld [hl], a
ld a, [$d230]
cp a, $05
jr nz, .asm_3ea90
call $7a01
ld a, [hl]
and a
jr z, .asm_3ea6e
ld a, [hl]
ld [$d217], a ; EnemyMonHP + 1
jr .asm_3ea90
.asm_3ea6e
ld a, [$d217] ; EnemyMonHP + 1
ld [hl], a
jr .asm_3ea90
.asm_3ea74
ld hl, $d2ab
ld a, [$d109]
call $3927
ld a, [hld]
ld [$d217], a ; EnemyMonHP + 1
ld a, [hld]
ld [$d216], a ; EnemyMonHP
ld a, [$d109]
ld [$c663], a
dec hl
ld a, [hl]
ld [EnemyMonStatus], a
.asm_3ea90
ld hl, $d23d
ld de, $d224
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
ld de, EnemyMonMoves
ld a, [$d22d]
cp a, $02
jr nz, .asm_3eab6
ld hl, OTPartyMon1Moves
ld a, [$d109]
call $3927
ld bc, $0004
call CopyBytes
jr .asm_3eac5
.asm_3eab6
xor a
ld h, d
ld l, e
ld [hli], a
ld [hli], a
ld [hli], a
ld [hl], a
ld [$d1ea], a
ld a, $1b
call $2d83
.asm_3eac5
ld a, [$d22d]
cp a, $02
jr z, .asm_3ead9
ld hl, EnemyMonMoves
ld de, EnemyMonPP
ld a, $05
call $2d83
jr .asm_3eaeb
.asm_3ead9
ld hl, $d29f
ld a, [$d109]
call $3927
ld de, EnemyMonPP
ld bc, $0004
call CopyBytes
.asm_3eaeb
ld hl, $d237
ld de, $d226
ld b, $05
.asm_3eaf3
ld a, [hli]
ld [de], a
inc de
dec b
jr nz, .asm_3eaf3
ld a, [$d23f]
ld [de], a
inc de
ld a, [$d240]
ld [de], a
ld a, [EnemyMonSpecies]
ld [$d265], a
call $343b
ld a, [$d22d]
and a
ret z
ld hl, $d073
ld de, $c616
ld bc, $000b
call CopyBytes
ld a, [EnemyMonSpecies]
dec a
ld c, a
ld b, $01
ld hl, $deb9
ld a, $03
call $2d83
ld hl, EnemyMonAtk
ld de, $c6c1
ld bc, $000a
call CopyBytes
ret
; 3eb38
CheckSleepingWildMon: ; 3eb38
ld a, [$d230]
cp a, $08 ; headbutt encounter?
jr nz, .asm_3eb5b
ld hl, SleepingWildMonMornTable
ld a, [TimeOfDay]
cp a, $01
jr c, .asm_3eb51
ld hl, SleepingWildMonDayTable
jr z, .asm_3eb51
ld hl, SleepingWildMonNiteTable
.asm_3eb51
ld a, [EnemyMonSpecies]
ld de, $0001
call IsInArray
ret c
.asm_3eb5b
and a
ret
; 3eb5d
SleepingWildMonNiteTable: ; 3eb5d
db CATERPIE
db METAPOD
db BUTTERFREE
db WEEDLE
db KAKUNA
db BEEDRILL
db SPEAROW
db EKANS
db EXEGGCUTE
db LEDYBA
db AIPOM
db $ff ; end
; 3eb69
SleepingWildMonDayTable: ; 3eb69
db VENONAT
db HOOTHOOT
db NOCTOWL
db SPINARAK
db HERACROSS
db $ff ; end
; 3eb6f
SleepingWildMonMornTable ; 3eb6f
db VENONAT
db HOOTHOOT
db NOCTOWL
db SPINARAK
db HERACROSS
db $ff ; end
; 3eb75
CheckUnownLetter: ; 3eb75
ld a, [$def3]
ld c, a
ld de, $0000
.asm_3eb7c
srl c
jr nc, .asm_3eb96
ld hl, UnownLetterPointerTable
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
push de
ld a, [$d234]
ld de, $0001
push bc
call IsInArray
pop bc
pop de
jr c, .asm_3eb9f
.asm_3eb96
inc e
inc e
ld a, e
cp a, $08
jr c, .asm_3eb7c
scf
ret
.asm_3eb9f
and a
ret
UnownLetterPointerTable: ; 3eba1
dw UnownLetterTable
dw UnownLetterTable2
dw UnownLetterTable3
dw UnownLetterTable4
; 3eba9
UnownLetterTable: ; 3eba9
; A B C D E F G H I J K
db $01, $02, $03, $04, $05, $06, $07, $08, $09, $0a, $0b
db $ff
; 3ebb5
UnownLetterTable2: ; 3ebb5
; L M N O P Q R
db $0c, $0d, $0e, $0f, $10, $11, $12
db $ff
; 3ebbd
UnownLetterTable3: ; 3ebbd
; S T U V W
db $13, $14, $15, $16, $17
db $ff
; 3ebc3
UnownLetterTable4: ; 3ebc3
; X Y Z
db $18, $19, $1a
db $ff
;3ebc7
INCBIN "baserom.gbc",$3ebc7,$3fc8b - $3ebc7
; I have no clue what most of this does
@ -73086,7 +73647,153 @@ INCBIN "gfx/font.1bpp",$0,$400
FontBattleExtra:
INCBIN "gfx/font_battle_extra.2bpp",$0,$200
INCBIN "baserom.gbc",$F8800,$4000-$800
INCBIN "baserom.gbc",$F8800,$3bfc-$800
Functionfbbfc ; fbbfc
;input:
; d: $d2
; e: $0c
; b: $d4 ; PlayerID
; c: $7b ; PlayerID
; a: BANK(Functionfbbfc) $3e
ld h, b
ld l, c
ld a, [hli]
ld b, a
ld c, [hl] ; ld bc, [bc]
rrc b
rrc c
ld a, [de]
inc de
rrca
rrca
xor b
ld b, a
ld a, [de]
rrca
rrca
xor c
ld c, a
ld a, b
and a
jr nz, .asm_fbc21
ld a, c
cp a, $0a
jr nc, .asm_fbc21
ld hl, $00be
add hl, bc
ld d, h
ld e, l
jr .asm_fbc78
.asm_fbc21
ld hl, Tablefbca8
ld a, $02
ld [$d265], a
.asm_fbc29
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
call Functionfbc9a
jr nc, .asm_fbc63
call Functionfbca1
ld a, b
ld [$ff00+$b3], a
ld a, c
ld [$ff00+$b4], a
ld a, [hl]
ld [$ff00+$b7], a
ld b, $02
call Divide
ld a, [$ff00+$b6]
ld c, a
xor a
ld [$ff00+$b4], a
ld [$ff00+$b5], a
ld a, $64
ld [$ff00+$b6], a
ld a, [$d265]
ld [$ff00+$b7], a
call Multiply
ld b, $00
ld a, [$ff00+$b6]
add c
ld e, a
ld a, [$ff00+$b5]
adc b
ld d, a
jr .asm_fbc78
.asm_fbc63
inc hl
ld a, [$d265]
inc a
ld [$d265], a
cp a, $10
jr c, .asm_fbc29
call Functionfbca1
ld hl, $0640
add hl, bc
ld d, h
ld e, l
.asm_fbc78
ld h, d
ld l, e
add hl, hl
add hl, hl
add hl, de
add hl, hl
ld de, $ff02
ld a, $ff
.asm_fbc83
inc a
add hl, de
jr c, .asm_fbc83
ld d, $00
.asm_fbc89 ; mod $0c
cp a, $0c
jr c, .asm_fbc92
sub a, $0c
inc d
jr .asm_fbc89
.asm_fbc92
ld e, a
ld hl, $d1ea
ld [hl], d
inc hl
ld [hl], e
ret
; fbc9a
Functionfbc9a: ; fbc9a
ld a, b
cp d
ret c
ret nc
ld a, c
cp e
ret
; fbca1
Functionfbca1: ; fbca1
ld a, c
sub e
ld c, a
ld a, b
sbc d
ld b, a
ret
; fbcab
Tablefbca8: ; fbca8
db $6e, $00, $01, $36, $01, $02, $c6, $02
db $04, $96, $0a, $14, $1e, $1e, $32, $2e
db $45, $64, $c6, $7f, $96, $5e, $ba, $96
db $6e, $e1, $64, $f6, $f4, $32, $c6, $fc
db $14, $ba, $fe, $05, $82, $ff
db $02, $e6, $ff
; fbcd1
INCBIN "baserom.gbc",$FBCD1,$fc000-$fbcd1
SECTION "bank3F",DATA,BANK[$3F]
@ -115461,7 +116168,7 @@ UnknownText_0x1c5d03: ; 0x1c5d03
sound0
db $0, $51
db "@"
text_from_ram $d47d
text_from_ram PlayerName
db $0, " sent the", $4f
db "trophy home.", $58
; 0x1c5d3e

View File

@ -6,7 +6,10 @@ InLinkBattle: ; 0xc2dc
SECTION "BattleMons",BSS[$c62a]
BattleMonSpecies: ; c62a
ds 3 ; wtf?
ds 1
ds 1
BattleMonSpecies2: ; c62c
ds 1
BattleMonItem: ; c62d
ds 1
@ -41,9 +44,8 @@ BattleMonHappiness: ; c638
BattleMonLevel: ; c639
ds 1
; TODO this is probably wrong
EnemyMonPokerusStatus: ; c63a
ds 2 ; dunno
BattleMonStatus: ; c63a
ds 2
BattleMonHP: ; c63c
ds 2
@ -61,6 +63,66 @@ BattleMonSpclAtk: ; c646
BattleMonSpclDef: ; c648
ds 2
SECTION "EnemyMon",BSS[$d204]
EnemyMonSpecies: ; d204
ds 1
ds 1
EnemyMonSpecies2: ; d206
ds 1
EnemyMonItem: ; d207
ds 1
EnemyMonMoves:
EnemyMonMove1: ; d208
ds 1
EnemyMonMove2: ; d209
ds 1
EnemyMonMove3: ; d20a
ds 1
EnemyMonMove4: ; d20b
ds 1
EnemyMonDVs:
EnemyMonAtkDefDV: ; d20c
ds 1
EnemyMonSpdSpclDV: ; d20d
ds 1
EnemyMonPP:
EnemyMonPPMove1: ; d20e
ds 1
EnemyMonPPMove2: ; d20f
ds 1
EnemyMonPPMove3: ; d210
ds 1
EnemyMonPPMove4: ; d211
ds 1
EnemyMonHappiness: ; d212
ds 1
EnemyMonLevel: ; d213
ds 1
EnemyMonStatus: ; d214
ds 2
EnemyMonHP: ; d216
ds 2
EnemyMonMaxHP: ; d218
ds 2
EnemyMonAtk: ; d21a
ds 2
EnemyMonDef: ; d21c
ds 2
EnemyMonSpd: ; d21e
ds 2
EnemyMonSpclAtk: ; d220
ds 2
EnemyMonSpclDef: ; d222
ds 2
SECTION "OtherTrainerClass",BSS[$d22f]
OtherTrainerClass: ; 0xd22f
@ -621,6 +683,35 @@ PlayerID: ; 0xd47b
PlayerName: ; 0xd47d
ds 11
PlayerSprite: ; 0xd4d8
ds 1
SECTION "Misc",BSS[$d857]
Money: ; d84e
ds 3
Badges: ; d857
ds 2
SECTION "Items",BSS[$d8bd]
TMsHMs: ; d859
ds 57
NumItems: ; d892
ds 1
Items: ; d893
ds 69
NumKeyItems: ; d88c
ds 1
KeyItems: ; d88d
ds 13
NumBalls: ; d8d7
ds 1
Balls: ; d8d8
ds 25
SECTION "scriptram",BSS[$d962]
MooMooBerries: ; 0xd962
ds 1 ; how many berries fed to MooMoo