Merge pull request #44 from yenatch/master

CheckSurfOW
This commit is contained in:
Bryan Bishop 2012-11-24 06:21:38 -08:00
commit 947bb5eeb2
3 changed files with 765 additions and 22 deletions

View File

@ -1343,6 +1343,7 @@ MAP_MR_POKEMONS_HOUSE EQU $0a
MAP_ROUTE_31_VIOLET_GATE EQU $0b
; item constants
NO_ITEM EQU $00
MASTER_BALL EQU $01
ULTRA_BALL EQU $02
BRIGHTPOWDER EQU $03
@ -3345,4 +3346,106 @@ callchannel: MACRO
ENDM
endchannel: MACRO
db $ff
ENDM
ENDM
; specials
NUM_SPECIALS EQU $a8
SPECIAL_UPDATESPRITETILES EQU $0038
SPECIAL_WAITSFX EQU $003b
SPECIAL_BIKESURFMUSIC EQU $003c
SPECIAL_LOADFACESTEP EQU $003f
SPECIAL_SNORLAXAWAKE EQU $0060
SPECIAL_GAMEBOYCHECK EQU $0066
SPECIAL_TRAINERHOUSE EQU $0067
SPECIAL_RUSTLETREE EQU $006a
SPECIAL_ODDEGG EQU $007d
SPECIAL_MOVETUTOR EQU $0083
SPECIAL_OMANYTECHAMBER EQU $0084
SPECIAL_RUINCHAMBERWALL EQU $0087
SPECIAL_HOOHCHAMBER EQU $008d
SPECIAL_CELEBI EQU $008f
SPECIAL_AFTERCELEBI EQU $0090
SPECIAL_POKESEER EQU $0091
SPECIAL_DRATINI EQU $0094
SPECIAL_BEASTSCHECK EQU $0096
SPECIAL_MONCHECK EQU $0097
; battle scripts
BATTLE_FILLPP EQU $05
BATTLE_FILLSTATS EQU $0C
BATTLE_FILLMOVES EQU $1B
BATTLE_GETUNOWNLETTER EQU $2D
; vars
NUM_VARS EQU $1b
VAR_MOVEMENT EQU $08
; player states
PLAYER_NORMAL EQU $00
PLAYER_BIKE EQU $01
PLAYER_SLIP EQU $02
PLAYER_SURF EQU $04
PLAYER_SURF_PIKA EQU $08
; battle
MAX_LEVEL EQU 100
NUM_MOVES EQU 4
; move struct
MOVE_LENGTH EQU 7
MOVE_ANIM EQU 0
MOVE_EFFECT EQU 1
MOVE_POWER EQU 2
MOVE_TYPE EQU 3
MOVE_ACC EQU 4
MOVE_PP EQU 5
MOVE_CHANCE EQU 6
; stat constants
NUM_STATS EQU 6
STAT_HP EQU 1
STAT_ATK EQU 2
STAT_DEF EQU 3
STAT_SPD EQU 4
STAT_SATK EQU 5
STAT_SDEF EQU 6
STAT_MIN_NORMAL EQU 5
STAT_MIN_HP EQU 10
; shiny dvs
ATKDEFDV_SHINY EQU $EA
SPDSPCDV_SHINY EQU $AA
; battle classes
WILD_BATTLE EQU $00
TRAINER_BATTLE EQU $02
; battle types
BATTLETYPE_NORMAL EQU $00
BATTLETYPE_TUTORIAL EQU $03
BATTLETYPE_FISH EQU $04
BATTLETYPE_ROAMING EQU $05
BATTLETYPE_SHINY EQU $07
BATTLETYPE_TREE EQU $08
BATTLETYPE_FORCEITEM EQU $0a
BATTLETYPE_SUICUNE EQU $0c

511
main.asm
View File

@ -561,7 +561,56 @@ Char5F: ; 0x1356
pop hl
ret
INCBIN "baserom.gbc",$135a,$26ef - $135a
INCBIN "baserom.gbc",$135a,$185d - $135a
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
; 1875
INCBIN "baserom.gbc",$1875,$261f - $1875
PushScriptPointer: ; 261f
; used to call a script from asm
; input:
; a: bank
; hl: address
; bank
ld [$d439], a ; ScriptBank
; address
ld a, l
ld [$d43a], a ; ScriptAddressLo
ld a, h
ld [$d43b], a ; ScriptAddressHi
ld a, $ff
ld [$d438], a
scf
ret
; 2631
INCBIN "baserom.gbc",$2631,$26ef - $2631
ObjectEvent: ; 0x26ef
jumptextfaceplayer ObjectEventText
@ -891,7 +940,20 @@ GetFarHalfword: ; 0x305d
ret
; 0x306b
INCBIN "baserom.gbc",$306b,$30e1-$306b
INCBIN "baserom.gbc",$306b,$30d6-$306b
CopyName1: ; 30d6
ld hl, StringBuffer2
; 30d9
CopyName2: ; 30d9
.loop
ld a, [de]
inc de
ld [hli], a
cp "@"
jr nz, .loop
ret
; 30e1
IsInArray: ; 30e1
; searches an array at hl for the value in a.
@ -1185,7 +1247,32 @@ GetItemName: ; 3468
ret
; 0x3487
INCBIN "baserom.gbc",$3487,$38bb - $3487
INCBIN "baserom.gbc",$3487,$38a2 - $3487
GetNick: ; 38a2
; get the nickname of a partymon
; write nick to StringBuffer1
; input: a = which mon (0-5)
push hl
push bc
; skip [a] nicks
call SkipNames
ld de, StringBuffer1
; write nick
push de
ld bc, PKMN_NAME_LENGTH
call CopyBytes
; error-check
pop de
callab CheckNickErrors
; we're done
pop bc
pop hl
ret
; 38bb
PrintBCDNumber: ; 38bb
; function to print a BCD (Binary-coded decimal) number
; de = address of BCD number
@ -1425,8 +1512,89 @@ IntroFadePalettes: ; 0x617c
db %11111000
db %11110100
db %11100100
; 6182
INCBIN "baserom.gbc",$6182,$8000 - $6182
INCBIN "baserom.gbc",$6182,$669f - $6182
CheckNickErrors: ; 669f
; error-check monster nick before use
; must be a peace offering to gamesharkers
; input: de = nick location
push bc
push de
ld b, PKMN_NAME_LENGTH
.checkchar
; end of nick?
ld a, [de]
cp "@" ; terminator
jr z, .end
; check if this char is a text command
ld hl, .textcommands
dec hl
.loop
; next entry
inc hl
; reached end of commands table?
ld a, [hl]
cp a, $ff
jr z, .done
; is the current char between this value (inclusive)...
ld a, [de]
cp [hl]
inc hl
jr c, .loop
; ...and this one?
cp [hl]
jr nc, .loop
; replace it with a "?"
ld a, "?"
ld [de], a
jr .loop
.done
; next char
inc de
; reached end of nick without finding a terminator?
dec b
jr nz, .checkchar
; change nick to "?@"
pop de
push de
ld a, "?"
ld [de], a
inc de
ld a, "@"
ld [de], a
.end
; if the nick has any errors at this point it's out of our hands
pop de
pop bc
ret
; 66cf
.textcommands ; 66cf
; table definining which characters
; are actually text commands
; format:
; >= <
db $00, $05
db $14, $19
db $1d, $26
db $35, $3a
db $3f, $40
db $49, $5d
db $5e, $7f
db $ff ; end
; 66de
INCBIN "baserom.gbc",$66de,$8000 - $66de
SECTION "bank2",DATA,BANK[$2]
@ -1757,16 +1925,29 @@ PrintNumber_AdvancePointer: ; c64a
ret
; 0xc658
INCBIN "baserom.gbc",$c658,$c721 - $c658
INCBIN "baserom.gbc",$c658,$c706 - $c658
GetPartyNick: ; c706
; write CurPartyMon nickname to StringBuffer1-3
ld hl, PartyMon1Nickname
ld a, $02
ld [$cf5f], a
ld a, [CurPartyMon]
call GetNick
call CopyName1
; copy text from StringBuffer2 to StringBuffer3
ld de, StringBuffer2
ld hl, StringBuffer3
call CopyName2
ret
; c721
CheckFlag2: ; c721
; uses bittable2
; checks flag id in de
; returns carry if flag is not set
; using bittable2
; check flag id in de
; return carry if flag is not set
ld b, $02 ; check flag
ld a, BANK(GetFlag2)
ld hl, GetFlag2
rst $08
callba GetFlag2
ld a, c
and a
jr nz, .isset
@ -1777,7 +1958,226 @@ CheckFlag2: ; c721
ret
; c731
INCBIN "baserom.gbc",$c731,$ffff - $c731
CheckBadge: ; c731
; input: a = badge flag id ($1b-$2b)
call CheckFlag2
ret nc
ld hl, BadgeRequiredText
call $1d67 ; push text to queue
scf
ret
; c73d
BadgeRequiredText: ; c73d
TX_FAR _BadgeRequiredText ; Sorry! A new BADGE
db "@" ; is required.
; c742
CheckPartyMove: ; c742
; checks if a pokemon in your party has a move
; e = partymon being checked
; input: d = move id
ld e, $00 ; mon #
xor a
ld [CurPartyMon], 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, PartyMon2 - PartyMon1
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 [CurPartyMon], a ; which mon has the move
xor a
ret
.quit
scf
ret
; c779
INCBIN "baserom.gbc",$c779,$c986 - $c779
UsedSurfScript: ; c986
; print "[MON] used SURF!"
2writetext UsedSurfText
closetext
loadmovesprites
; this does absolutely nothing
3callasm BANK(Functionc9a2), Functionc9a2
; write surftype to PlayerState
copybytetovar $d1eb ; Buffer2
writevarcode VAR_MOVEMENT
; update sprite tiles
special SPECIAL_UPDATESPRITETILES
; start surf music
special SPECIAL_BIKESURFMUSIC
; step into the water
special SPECIAL_LOADFACESTEP ; (slow_step_x, step_end)
applymovement $00, $d007 ; PLAYER, MovementBuffer
end
; c9a2
Functionc9a2: ; c9a2
callba Function1060bb ; empty
ret
; c9a9
UsedSurfText: ; c9a9
TX_FAR _UsedSurfText ; [MONSTER] used
db "@" ; SURF!
; c9ae
CantSurfText: ; c9ae
TX_FAR _CantSurfText ; You can't SURF
db "@" ; here.
; c9b3
AlreadySurfingText: ; c9b3
TX_FAR _AlreadySurfingText ; You're already
db "@" ; SURFING.
; c9b8
GetSurfType: ; c9b8
; get surfmon species
ld a, [CurPartyMon]
ld e, a
ld d, $00
ld hl, PartySpecies
add hl, de
; is pikachu surfing?
ld a, [hl]
cp PIKACHU
ld a, PLAYER_SURF_PIKA
ret z
ld a, PLAYER_SURF
ret
; c9cb
CheckDirection: ; c9cb
; set carry if a tile permission prevents you
; from moving in the direction you are facing
; get player direction
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
; can you walk in this direction?
ld a, [TilePermissions]
and [hl]
jr nz, .quit
xor a
ret
.quit
scf
ret
; c9e3
.DirectionTable ; c9e3
db %00001000 ; down
db %00000100 ; up
db %00000010 ; left
db %00000001 ; right
; c9e7
CheckSurfOW: ; c9e7
; called when checking a tile in the overworld
; check if you can surf
; return carry if conditions are met
; can we surf?
ld a, [PlayerState]
; are you already surfing (pikachu)?
cp PLAYER_SURF_PIKA
jr z, .quit
; are you already surfing (normal)?
cp PLAYER_SURF
jr z, .quit
; are you facing a surf tile?
ld a, [$d03e] ; buffer for the tile you are facing (used for other things too)
call GetTileType
cp $01 ; surfable
jr nz, .quit
; does this contradict tile permissions?
call CheckDirection
jr c, .quit
; do you have fog badge?
ld de, $001e ; FLAG_FOG_BADGE
call CheckFlag2
jr c, .quit
; do you have a monster with surf?
ld d, SURF
call CheckPartyMove
jr c, .quit
; can you get off the bike (cycling road)?
ld hl, $dbf5 ; overworld flags
bit 1, [hl] ; always on bike (can't surf)
jr nz, .quit
; load surftype into MovementType
call GetSurfType
ld [$d1eb], a ; MovementType
; get surfmon nick
call GetPartyNick
; run AskSurfScript
ld a, BANK(AskSurfScript)
ld hl, AskSurfScript
call PushScriptPointer
; conditions were met
scf
ret
.quit
; conditions were not met
xor a
ret
; ca2c
AskSurfScript: ; ca2c
loadfont
2writetext AskSurfText
yesorno
iftrue UsedSurfScript
loadmovesprites
end
AskSurfText: ; ca36
TX_FAR _AskSurfText ; The water is calm.
db "@" ; Want to SURF?
; ca3b
INCBIN "baserom.gbc",$ca3b,$10000 - $ca3b
SECTION "bank4",DATA,BANK[$4]
@ -16527,7 +16927,49 @@ INCBIN "baserom.gbc",$4a843,$4C000 - $4a843
SECTION "bank13",DATA,BANK[$13]
INCBIN "baserom.gbc",$4C000,$50000 - $4C000
INCBIN "baserom.gbc",$4C000,$4ce1f - $4C000
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, $0f, $00, $00, $00, $00, $00
db $00, $00, $0f, $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
INCBIN "baserom.gbc",$4cf1f,$50000 - $4cf1f
SECTION "bank14",DATA,BANK[$14]
@ -78179,7 +78621,14 @@ INCBIN "baserom.gbc",$100000,$4000
SECTION "bank41",DATA,BANK[$41]
INCBIN "baserom.gbc",$104000,$4000
INCBIN "baserom.gbc",$104000,$1060bb - $104000
Function1060bb: ; 1060bb
; commented out
ret
; 1060bc
INCBIN "baserom.gbc",$1060bc,$108000 - $1060bc
SECTION "bank42",DATA,BANK[$42]
@ -119262,9 +119711,39 @@ INCBIN "baserom.gbc",$1BC000,$4000
SECTION "bank70",DATA,BANK[$70]
INCBIN "baserom.gbc",$1C0000,$1c1ec9-$1c0000
INCBIN "baserom.gbc",$1C0000,$1c05a7-$1c0000
INCBIN "baserom.gbc",$1C1EC9,$1c4000-$1c1ec9 ; empty
_BadgeRequiredText: ; 1c05a7
db $0, "Sorry! A new BADGE", $4f
db "is required.", $58
; 1c05c8
INCBIN "baserom.gbc",$1c05c8,$1c062f-$1c05c8
_UsedSurfText: ; 1c062f
dbw $1, StringBuffer2
db $0, " used", $4f
db "SURF!", $57
; 1c063f
_CantSurfText: ; 1c063f
db $0, "You can't SURF", $4f
db "here.", $58
; 1c0654
_AlreadySurfingText: ; 1c0654
db $0, "You're already", $4f
db "SURFING.", $58
; 1c066c
_AskSurfText ; 1c066c
db $0, "The water is calm.", $4f
db "Want to SURF?", $57
; 1c068e
INCBIN "baserom.gbc",$1c068e,$1c1ec9-$1c068e
INCBIN "baserom.gbc",$1c1ec9,$1c4000-$1c1ec9 ; empty
SECTION "bank71",DATA,BANK[$71]

171
wram.asm
View File

@ -278,6 +278,25 @@ SECTION "linkbattle",BSS[$c2dc]
InLinkBattle: ; 0xc2dc
ds 1 ; nonzero when in a link battle
SECTION "tiles",BSS[$c2fa]
TileDown: ; c2fa
ds 1
TileUp: ; c2fb
ds 1
TileLeft: ; c2fc
ds 1
TileRight: ; c2fd
ds 1
TilePermissions: ; c2fe
; set if tile behavior prevents
; you from walking in that direction
; bit 3: down
; bit 2: up
; bit 1: left
; bit 0: right
ds 1
SECTION "BattleMons",BSS[$c62a]
BattleMonSpecies: ; c62a
@ -338,6 +357,10 @@ BattleMonSpclAtk: ; c646
BattleMonSpclDef: ; c648
ds 2
SECTION "prng",BSS[$c6e5]
LinkBattleRNCount: ; c6e5
ds 1
SECTION "Engine",BSS[$cfcc]
Options: ; cfcc
; bit 0-2: number of frames to delay when printing text
@ -347,10 +370,14 @@ Options: ; cfcc
; bit 6: battle style shift/set
; bit 7: battle scene off/on
ds 1
ds 1
TextBoxFrame: ; cfce
; bits 0-2: textbox frame 0-7
ds 1
ds 1
GBPrinter: ; cfd0
; bit 0-6: brightness
@ -365,6 +392,16 @@ Options2: ; cfd1
; bit 1: menu account off/on
ds 1
ds 161
StringBuffer1: ; d073
ds 19
StringBuffer2: ; d086
ds 19
StringBuffer3: ; d099
ds 19
ds 65
VramState: ; d0ed
; bit 0: overworld sprite updating on/off
@ -373,13 +410,36 @@ VramState: ; d0ed
; flickers when climbing waterfall
ds 1
ds 26
CurPartySpecies: ; d108
ds 1
CurPartyMon: ; d109
; contains which monster in your party
; contains which monster in a party
; is being dealt with at the moment
; 0-5
ds 1
ds 57
CurPartyLevel: ; d143
ds 1
ds 166
Buffer1:
MagikarpLength:
MagikarpLengthHi: ; d1ea
ds 1
Buffer2:
MagikarpLengthLo: ; d1eb
ds 1
SECTION "prng2",BSS[$d1fa]
LinkBattleRNs: ; d1fa
ds 10
SECTION "EnemyMon",BSS[$d204]
EnemyMonSpecies: ; d204
@ -447,7 +507,15 @@ EnemyMonSpclAtk: ; d220
EnemyMonSpclDef: ; d222
ds 2
SECTION "OtherTrainerClass",BSS[$d22f]
SECTION "Battle",BSS[$d22d]
BattleClass: ; d22d
; 0: wild battle
; 1:
; 2: trainer battle
ds 1
ds 1
OtherTrainerClass: ; 0xd22f
; class (Youngster, Bug Catcher, etc.) of opposing trainer
@ -455,8 +523,19 @@ OtherTrainerClass: ; 0xd22f
ds 1
BattleType: ; 0xd230
; 00 normal
; 08 headbutt/rock smash. probably bit 3
; $00 normal
; $01
; $02
; $03 dude
; $04 fishing
; $05 roaming
; $06
; $07 shiny
; $08 headbutt/rock smash
; $09
; $0a force Item1
; $0b
; $0c suicune
ds 1
OtherTrainerID: ; 0xd231
@ -464,6 +543,16 @@ OtherTrainerID: ; 0xd231
; (Joey, Mikey, Albert, etc.)
ds 1
ds 2
UnownLetter: ; d234
ds 1
ds 1
CurBaseStats: ; d236
ds 32
SECTION "TimeOfDay",BSS[$d269]
TimeOfDay: ; 0xd269
@ -1002,15 +1091,37 @@ OTPartyMon5Nickname: ; d416
OTPartyMon6Nickname: ; d421
ds 11
SECTION "Player",BSS[$d47b]
PlayerID: ; 0xd47b
ds 2
PlayerName: ; 0xd47d
ds 11
ds 46
; init time set at newgame
StartDay: ; d4b6
ds 1
StartHour: ; d4b7
ds 1
StartMinute: ; d4b8
ds 1
StartSecond: ; d4b9
ds 1
ds 17
CurDay: ; d4cb
ds 1
ds 12
PlayerSprite: ; 0xd4d8
ds 1
ds 5
PlayerDirection: ; d4de
; uses bits 2 and 3 / $0c / %00001100
; %00 down
@ -1572,6 +1683,16 @@ PartyMon5Nickname: ; 0xde6d
PartyMon6Nickname: ; 0xde78
ds 11
SECTION "Pokedex",BSS[$de99]
PokedexSeen: ; de99
ds 32
PokedexCaught: ; deb9
ds 32
UnownDex: ; ded9
ds 26
UnownUnlockedGroups: ; def3
ds 1
SECTION "Breeding",BSS[$def5]
DaycareMan: ; def5
; bit 7: active
@ -1621,3 +1742,43 @@ EggStats:
EggSpecies: ; df7b
ds 1
ds 31
SECTION "RoamMons",BSS[$dfcf]
RoamMon1Species: ; dfcf
ds 1
RoamMon1Level: ; dfd0
ds 1
RoamMon1MapGroup: ; dfd1
ds 1
RoamMon1MapNumber: ; dfd2
ds 1
RoamMon1CurHP: ; dfd3
ds 1
RoamMon1DVs: ; dfd4
ds 2
RoamMon2Species: ; dfd6
ds 1
RoamMon2Level: ; dfd7
ds 1
RoamMon2MapGroup: ; dfd8
ds 1
RoamMon2MapNumber: ; dfd9
ds 1
RoamMon2CurHP: ; dfda
ds 1
RoamMon2DVs: ; dfdb
ds 2
RoamMon3Species: ; dfdd
ds 1
RoamMon3Level: ; dfde
ds 1
RoamMon3MapGroup: ; dfdf
ds 1
RoamMon3MapNumber: ; dfe0
ds 1
RoamMon3CurHP: ; dfe1
ds 1
RoamMon3DVs: ; dfe2
ds 2