Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GetText: ; 13f6
- ; pushes pointer for each character to the stack
- ; input: hl = text pointer
- .read
- ld a, [hli]
- cp a, "@"
- ret z ; terminator
- call GetChar
- jr .read
- GetChar: ; 13ff
- ; pushes pointer for given character to the stack
- ; input: a = char id
- push hl
- push bc
- ld c, a
- ld b, $00
- ld hl, Chars ; pointer table
- add hl, bc
- add hl, bc
- ld e, [hl]
- inc hl
- ld d, [hl]
- pop bc
- pop hl
- push de
- ret
- ; 1410
- Chars: ; 1410
- dw $143e
- dw $1449
- dw $1470
- dw $1480
- dw $148b
- dw $149b
- dw $149f
- dw $14ba
- dw $14c9
- dw $14d2
- dw $14ed
- dw $1500
- dw $1543
- dw $1562
- dw $1500
- dw $1500
- dw $1500
- dw $1500
- dw $1500
- dw $1500
- dw $156a
- dw $1582
- dw $1455
- GetTileType: ; 185d
- ; checks the properties of a tile
- ; input: a = tile id
- push de
- push hl
- ld hl, TileTypeTable
- ld e, a
- ld d, $00
- add hl, de
- ld a, [$ff00+$9d] ; current bank
- push af
- ld a, BANK(TileTypeTable)
- rst $10
- ld e, [hl] ; get tile type
- pop af
- rst $10 ; return to current bank
- ld a, e
- and a, $0f ; lo nybble only
- pop hl
- pop de
- ret
- Function1ad2: ; 1ad2
- ld a, [$d0ed]
- bit 0, a
- ret z
- ld a, BANK(Function55e0)
- ld hl, Function55e0
- rst $08
- ld a, $01 ; BANK(Function5920)
- ld hl, $5920 ; Function5920
- rst $08
- ret
- Function1c07: ; 1c07
- push af
- ld hl, Function243e8
- ld a, BANK(Function243e8)
- rst $08
- pop af
- ret
- ; 1c17
- Function1c17: ; 1c17
- push af
- call Function1c07
- call $321c
- call Function1ad2
- pop af
- ret
- ; 1c23
- Function1c23: ; 1c23
- call Function1cfd
- call ReverseCopyBytes
- call Function1d19
- call ReverseCopyBytes
- ret
- ; 1c30
- ReverseCopyBytes: ; 1c30
- ; copy bc bytes from de (dec) to hl (inc)
- call Function1c53
- inc b
- inc b
- .HandleLoop
- push bc
- push hl
- .CopyByte
- ld a, [de]
- ld [hli], a
- dec de
- dec c
- jr nz, .CopyByte
- pop hl
- ld bc, $0014
- add hl, bc
- pop bc
- dec b
- jr nz, .HandleLoop
- ret
- ; 1c47
- ReverseCopyBytes2: ; 1c47
- ; copy $10 bytes from hld into $cf81-$cf90
- ld b, $10
- ld de, $cf81
- .loop
- ld a, [hld]
- ld [de], a
- inc de
- dec b
- jr nz, .loop
- ret
- ; 1c53
- Function1c53: ; 1c53
- ; b=[$cf84]-[$cf82]
- ; c=[$cf85]-[$cf83]
- ld a, [$cf82]
- ld b, a
- ld a, [$cf84]
- sub b
- ld b, a
- ld a, [$cf83]
- ld c, a
- ld a, [$cf85]
- sub c
- ld c, a
- ret
- Function1c7e: ; 1c7e
- ; loads pointer from $cf71
- ; loads data from [pointer + 1] into hl
- ld hl, $cf71
- ld a, [hli]
- ld h, [hl]
- ld l, a
- inc hl
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ret
- Function1cfd: ; 1cfd
- ld a, [$cf83]
- ld c, a
- ld a, [$cf82]
- ld b, a
- xor a
- ld h, a
- ld l, b
- ld a, c
- ld b, h
- ld c, l
- add hl, hl
- add hl, hl
- add hl, bc
- add hl, hl
- add hl, hl
- ld c, a
- xor a
- ld b, a
- add hl, bc
- ld bc, $c4a0
- add hl, bc
- ret
- Function1d19: ; 1d19
- ld a, [$cf83]
- ld c, a
- ld a, [$cf82]
- ld b, a
- xor a
- ld h, a
- ld l, b
- ld a, c
- ld b, h
- ld c, l
- add hl, hl
- add hl, hl
- add hl, bc
- add hl, hl
- add hl, hl ; * 20
- ld c, a
- xor a
- ld b, a
- add hl, bc
- ld bc, $cdd9
- add hl, bc
- ret
- ; 1d35
- Function1d35: ; 1d35
- call Function1d3c
- call Function1c00
- ret
- ; 1d3c
- Function1d3c: ; 1d3c
- ld de, $cf81
- ld bc, $0010
- call CopyBytes ; copy $10 bytes from [hl] to $cf81
- ld a, [$ff00+$9d]
- ld [$cf8a], a
- ret ; might have been a ret nz once
- ; unused?
- ld [$cf88], a
- ret
- Function1d4f: ; 1d4f
- push hl
- call Function1d58
- pop hl
- jp $1057
- ret
- ; 1d58
- Function1d58: ; 1d58
- ld hl, Table1d5f
- call Function1d35
- ret
- ; 1d5f
- Table1d5f: ; 1d5f
- db $40, $0c, $00, $11, $13, $00, $80, $00
- ; 1d67
- Function1d67: ; 1d67
- call Function1d4f
- call Function1c17
- ret
- ; 1d6e
- Function261f: ; 261f
- ld [$d439], a
- ld a, l
- ld [$d43a], a
- ld a, h
- ld [$d43b], a
- ld a, $ff
- ld [$d438]. a
- scf
- ret
- ; 2631
- CopyName1: ; 30d6
- ld hl, $d086
- ; 30d9
- CopyName2: ; 30d9
- .loop
- ld a, [de]
- inc de
- ld [hli], a
- cp "@"
- jr nz, .loop
- ret
- ; 30e1
- GetNick: ; 38a2
- ; gets the nickname of a partymon
- ; stores the nick for use at $d073
- push hl
- push bc
- call SkipNames
- ld de, $d073
- push de
- ld bc, PKMN_NAME_LENGTH
- call CopyBytes
- pop de
- ld hl, Function669f ; errorchecking
- ld a, BANK(Function669f)
- rst $08
- pop bc
- pop hl
- ret
- ; 38bb
- Function55e0: ; 55e0
- ld a, [$d0ed]
- bit 0, a
- rt z
- ld bc, $d4d6
- xor a
- .asm_55ea
- ld [$ff00+$af], a
- call $1af1
- jr z, .asm_55f4
- call $565c
- .asm_55f4
- ld hl, $0028
- add hl, bc
- ld b, h
- ld c, l
- ld a, [$ff00+$af]
- inc a
- cp $0d
- jr nz, .asm_55ea
- ret
- Function669f: ; 669f
- ; error-check monster name before use
- push bc
- push de
- ld b, PKMN_NAME_LENGTH
- .asm_66a3
- ld a, [de]
- cp "@"
- jr z, .end
- ld hl, Table66cf
- dec hl
- .loop
- inc hl
- ld a, [hl]
- cp a, $ff ; reached end of table?
- jr z, .exit
- ld a, [de]
- cp [hl]
- inc hl
- jr c, .loop
- cp [hl]
- jr nc, .loop
- ld a, "?"
- ld [de], a
- jr .loop
- .exit
- inc de
- dec b
- jr nz, .asm_66a3 ; reached end of name?
- pop de
- push de
- ld a, "?"
- ld [de], a
- inc de
- ld a, "@"
- ld [de], a
- .end
- pop de
- pop bc
- ret
- ;66cf
- Table66cf: ; 66cf
- db $00, $05, $14, $19, $1d, $26, $35, $3a
- db $3f, $40, $49, $5d, $5e, $7f, $ff
- GetPartyNick: ; c706
- ; copies nickname of a partymon to $d073,
- ; $d086 and $d099 for use in textboxes
- ld hl, PartyMon1Nickname
- ld a, $02
- ld [$cf5f], a
- ld a, [$d109] ; partymon #
- call GetNick
- call CopyName1
- ld de, $d086
- ld hl, $d099
- call CopyName2
- ret
- ; c721
- Functionc731: ; c731
- call CheckFlag
- ret nc
- ld hl, Tablec73d
- call $1d67
- scf
- ret
- ; c73d
- Tablec73d: ; c73d
- db $16, $a7, $45, $70, $50
- ; c742
- CheckPartyMove: ; c742
- ; checks if a pokemon in your party has a move
- ; input: d = move id
- ld e, $00 ; mon #
- xor a
- ld [$d109], a
- .checkmon
- ; check for valid species
- ld c, e
- ld b, $00
- ld hl, PartySpecies
- add hl, bc
- ld a, [hl]
- and a ; no id
- jr z, .quit
- cp a, $ff ; terminator
- jr z, .quit
- cp a, EGG
- jr z, .nextmon
- ; navigate to appropriate move table
- ld bc, $0030
- ld hl, PartyMon1Moves
- ld a, e
- call AddNTimes
- ld b, $04 ; number of moves
- .checkmove
- ld a, [hli]
- cp d ; move id
- jr z, .end
- dec b ; how many moves left?
- jr nz, .checkmove
- .nextmon
- inc e ; mon #
- jr .checkmon
- .end
- ld a, e
- ld [d109], a ; which mon has the move
- xor a
- ret
- .quit
- ; $d109 = 0
- scf
- ret
- ;
- Scriptc986: ; c986
- 2call 00 00 ; o
- ;
- GetSurfSprite: ; c9b8
- ld a, [$d109] ; contains 0-5
- ld e, a
- ld d, $00
- ld hl, PartySpecies
- add hl, de
- ld a, [hl]
- cp PIKACHU
- ld a, $08 ; use surfing pikachu sprite
- ret z
- ld a, $04 ; use lapras sprite
- ret
- ; c9cb
- GetDirection: ; c9cb
- ; sets carry if direction is invalid ????
- ld a, [PlayerDirection]
- and a, %00001100 ; bits 2 and 3 contain direction
- rrca
- rrca
- ld e, a
- ld d, $00
- ld hl, DirectionTable
- add hl, de
- ld a, [$c2fe] ; normally $00
- and [hl]
- jr nz, .quit
- xor a
- ret
- .quit
- scf
- ret
- ; 49e3
- DirectionTable: ; c9e3
- db $08 ; down
- db $04 ; up
- db $02 ; left
- db $01 ; right
- ; c9e7
- CheckSurf: ; c9e7
- ; checks if you can surf
- ; returns carry if conditions are met
- ld a, [PlayerState]
- cp $08 ; ????
- jr z, .quit
- cp $04 ; check if you are already surfing
- jr z, .quit
- ld a, [$d03e] ; tile you are facing
- call GetTileType ; check if you are facing a surf tile
- cp $01 ; surfable
- jr nz, .quit
- call GetDirection ; make sure you can surf in that direction ????
- jr c, .quit
- ld de, $001e ; check for fog badge
- call CheckFlag
- jr c, .quit
- ld d, SURF ; check for surfmon
- call CheckPartyMove
- jr c, .quit
- ld hl, $dbf5 ; isn't this part of box6name?
- bit 1, [hl] ; maybe it uses another wrambank
- jr nz, .quit
- call GetSurfSprite ; returns $04, or $08 if pikachu
- ld [$d1eb], a
- call GetPartyNick
- ld a, BANK(Scriptca2c)
- ld hl, Scriptca2c
- call Function261f ; stores farpointer to Scriptca2c at $d439
- scf
- ret
- .quit
- xor a
- ret
- ; ca2c
- Scriptca2c: ; ca2c
- loadfont
- 2writetext AskSurfText
- yesorno
- iftrue Scriptc986
- loadmovesprites
- end
- AskSurfText: ; ca36
- TX_FAR _AskSurfText
- db "@"
- ; ca3b
- _AskSurfText ; 1c066c
- db $0, "The water is calm.", $4f
- db "Want to SURF?" $57
- ; 1c068e
- Function243e8: ; 243e8
- ; switches to wram bank 7
- ; does something
- ; switches back
- xor a
- ld [$ff00+$d4], a
- ld a, [$ff00+$70] ; wram bank
- push af
- ld a, $07
- ld [$ff00+$70], a ; wram bank
- call Function1c7e
- ld a, l
- or h
- jp z, $445d ; 2445d
- ld a, l
- ld [$cf71], a
- ld a, h
- ld [$cf72], a
- call ReverseCopyBytes2
- ld a, [$cf81]
- bit 0, a
- jr z, .asm_24411
- ld d, h
- ld e, l
- call Function1c23
- .asm_24411
- call Function1c7e
- ld a, h
- or l
- jr z, .asm_2441b
- call ReverseCopyBytes2
- .asm_2441b
- pop af
- ld [$ff00+$70], a ; wram bank
- ld hl, $cf78
- dec [hl]
- ret
- TileTypeTable: ; 4ce1f
- ; 256 tiletypes
- ; 01 = surfable
- db $00, $00, $00, $00, $00, $00, $00, $0f
- db $00, $00, $00, $00, $00, $00, $00, $0f
- db $00, $00, $1f, $00, $00, $1f, $00, $00
- db $00, $00, $1f, $00, $00, $1f, $00, $00
- db $01, $01, $11, $00, $11, $01, $01, $0f
- db $01, $01, $11, $00, $11, $01, $01, $0f
- db $01, $01, $01, $01, $01, $01, $01, $01
- db $01, $01, $01, $01, $01, $01, $01, $01
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $0f, $0f, $0f, $0f, $0f, $00, $00, $00
- db $0f, $0f, $0f, $0f, $0f, $00, $00, $00
- db $0f, $0f, $0f, $0f, $0f, $0f, $0f, $0f
- db $0f, $0f, $0f, $0f, $0f, $0f, $0f, $0f
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $01, $01, $01, $01, $01, $01, $01, $01
- db $01, $01, $01, $01, $01, $01, $01, $01
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $00
- db $00, $00, $00, $00, $00, $00, $00, $0f
- ; 4cf1f
- Function97c5f: ; 97c5f
- call $2a07
- ld [$d03e], a
- ld c, a
- ld a, $04
- ld hl, $765b
- rst $08 ; call 04:765b
- jr c, .asm_97cb9 ; quit?
- call $1894
- jr nz, .asm_97c7b ; skip?
- ld a, $03
- ld hl, $5186
- rst $08 ; call d186
- jr .asm_97cb9
- .asm_97c7b
- ld a, [$d03e]
- call $18b4
- jr nz, .asm_97c8b
- ld a, $03
- ld hl, $4e3e
- rst $08 ; call ce3e
- jr .asm_97cb9
- .asm_97c8b
- ld a, [$d03e]
- call $18bd
- jr nz, .asm_97c9b
- ld a, $03
- ld hl, $4b56
- rst $08 ; call cb56
- jr .asm_97cb9 ; quit?
- .asm_97c9b
- ld a, [$d03e]
- call $189a
- jr nz, .asm_97cad
- ld a, $03
- ld hl, $4ec9
- rst $08 ; call cec9
- jr c, .asm_97cb9
- jr .asm_97cb7
- .asm_97cad
- ld a, BANK(CheckSurf)
- ld hl, CheckSurf
- rst $08
- ;
Add Comment
Please, Sign In to add comment