You are not logged in.
Pages: 1
I'm working on solving a lot of the Safari Zone glitches for my hack, and many of them involve saving once inside. I decided to look first into having the start menu check if the current map is any of the Safari maps and if it is, don't display the save option.
This is the code for that from draw_start_menu.asm:
.storeMenuItemCount
ld [wMaxMenuItem], a ; number of menu items
ld de, StartMenuPokemonText
call PrintStartMenuItem
ld de, StartMenuItemText
call PrintStartMenuItem
ld de, wPlayerName ; player's name
call PrintStartMenuItem
; is the player in the Safari Zone Center?
ld a, [wCurMap]
cp SAFARI_ZONE_CENTER
jr z, .safariEast
call PrintStartMenuItem
ld de, StartMenuRetireText
call PrintStartMenuItem
ld de, StartMenuOptionText
call PrintStartMenuItem
ld de, StartMenuExitText
call PlaceString
ld hl, wd730
res 6, [hl] ; turn pauses between printing letters back on
ret
;.safariEast
; is the player in the Safari Zone East?
ld a, [wCurMap]
cp SAFARI_ZONE_EAST
jr z, .safariWest
call PrintStartMenuItem
ld de, StartMenuRetireText
call PrintStartMenuItem
ld de, StartMenuOptionText
call PrintStartMenuItem
ld de, StartMenuExitText
call PlaceString
;d hl, wd730
res 6, [hl] ; turn pauses between printing letters back on
ret
.safariWest
; is the player in the Safari Zone East?
ld a, [wCurMap]
cp SAFARI_ZONE_WEST
jr z, .safariNorth
call PrintStartMenuItem
ld de, StartMenuRetireText
call PrintStartMenuItem
ld de, StartMenuOptionText
call PrintStartMenuItem
ld de, StartMenuExitText
call PlaceString
ld hl, wd730
res 6, [hl] ; turn pauses between printing letters back on
ret
.safariNorth
; is the player in the Safari Zone East?
ld a, [wCurMap]
cp SAFARI_ZONE_NORTH
jr z, .safariHouse1
call PrintStartMenuItem
ld de, StartMenuRetireText
call PrintStartMenuItem
ld de, StartMenuOptionText
call PrintStartMenuItem
ld de, StartMenuExitText
call PlaceString
ld hl, wd730
res 6, [hl] ; turn pauses between printing letters back on
ret
.safariHouse1
; is the player in the Safari Zone East?
ld a, [wCurMap]
cp SAFARI_ZONE_REST_HOUSE_1
jr z, .safariHouse2
call PrintStartMenuItem
ld de, StartMenuRetireText
call PrintStartMenuItem
ld de, StartMenuOptionText
call PrintStartMenuItem
ld de, StartMenuExitText
call PlaceString
ld hl, wd730
res 6, [hl] ; turn pauses between printing letters back on
ret
.safariHouse2
; is the player in the Safari Zone East?
ld a, [wCurMap]
cp SAFARI_ZONE_REST_HOUSE_2
jr z, .safariHouse3
call PrintStartMenuItem
ld de, StartMenuRetireText
call PrintStartMenuItem
ld de, StartMenuOptionText
call PrintStartMenuItem
ld de, StartMenuExitText
call PlaceString
ld hl, wd730
res 6, [hl] ; turn pauses between printing letters back on
ret
.safariHouse3
; is the player in the Safari Zone East?
ld a, [wCurMap]
cp SAFARI_ZONE_REST_HOUSE_3
jr z, .safariHouse4
call PrintStartMenuItem
ld de, StartMenuRetireText
call PrintStartMenuItem
ld de, StartMenuOptionText
call PrintStartMenuItem
ld de, StartMenuExitText
call PlaceString
ld hl, wd730
res 6, [hl] ; turn pauses between printing letters back on
ret
.safariHouse4
; is the player in the Safari Zone East?
ld a, [wCurMap]
cp SAFARI_ZONE_REST_HOUSE_4
jr z, .safariSecretHouse
call PrintStartMenuItem
ld de, StartMenuRetireText
call PrintStartMenuItem
ld de, StartMenuOptionText
call PrintStartMenuItem
ld de, StartMenuExitText
call PlaceString
ld hl, wd730
res 6, [hl] ; turn pauses between printing letters back on
ret
.safariSecretHouse
; is the player in the Safari Zone East?
ld a, [wCurMap]
cp SAFARI_ZONE_SECRET_HOUSE
jr z, .notSafari
call PrintStartMenuItem
ld de, StartMenuRetireText
call PrintStartMenuItem
ld de, StartMenuOptionText
call PrintStartMenuItem
ld de, StartMenuExitText
call PlaceString
ld hl, wd730
res 6, [hl] ; turn pauses between printing letters back on
ret
.notSafari
ld a, [wd72e]
bit 6, a ; is the player using the link feature?
; case for not using link feature
ld de, StartMenuSaveText
jr z, .printSaveOrResetText
; case for using link feature
ld de, StartMenuResetText
.printSaveOrResetText
call PrintStartMenuItem
ld de, StartMenuOptionText
call PrintStartMenuItem
ld de, StartMenuExitText
call PlaceString
ld hl, wd730
res 6, [hl] ; turn pauses between printing letters back on
ret
The result being either the save option appearing as 9 with full functionality, or just shifting everything down after the 9 so exit is off the screen.
My second Idea was to go into start_sub_menu and play with the save function a little. Once again the goal was to have the routine check the map, then if its in the safari zone, when save is selected, print an error and thats it.
The code from start_sub_menu is this:
StartMenu_SaveReset:
; is the player in Safari Zone Center?
ld a, [wCurMap]
cp SAFARI_ZONE_CENTER
jr z, .safariEast
TX_FAR _CantSaveText
db "@"
.safariEast
; is the player in Safari Zone East?
ld a, [wCurMap]
cp SAFARI_ZONE_EAST
jr z, .safariWest
TX_FAR _CantSaveText
db "@"
.safariWest
; is the player in Safari Zone West?
ld a, [wCurMap]
cp SAFARI_ZONE_WEST
jr z, .safariNorth
TX_FAR _CantSaveText
db "@"
.safariNorth
; is the player in the Safari Zone North?
ld a, [wCurMap]
cp SAFARI_ZONE_NORTH
jr z, .safariHouse1
TX_FAR _CantSaveText
db "@"
.safariHouse1
; is the player in the Safari Zone Rest House 1?
ld a, [wCurMap]
cp SAFARI_ZONE_REST_HOUSE_1
jr z, .safariHouse2
TX_FAR _CantSaveText
db "@"
.safariHouse2
; is the player in the Safari Zone Rest House 2?
ld a, [wCurMap]
cp SAFARI_ZONE_REST_HOUSE_2
jr z, .safariHouse3
TX_FAR _CantSaveText
db "@"
.safariHouse3
; is the player in the Safari Zone Rest House 3?
ld a, [wCurMap]
cp SAFARI_ZONE_REST_HOUSE_3
jr z, .safariHouse4
TX_FAR _CantSaveText
db "@"
.safariHouse4
; is the player in the Safari Zone Rest House 4?
ld a, [wCurMap]
cp SAFARI_ZONE_REST_HOUSE_4
jr z, .safariSecretHouse
TX_FAR _CantSaveText
db "@"
.safariSecretHouse
; is the player in the Safari Zone Secret House?
ld a, [wCurMap]
cp SAFARI_ZONE_SECRET_HOUSE
jr z, .notSafari
TX_FAR _CantSaveText
db "@"
.notSafari
; Normal code resumes here.
ld a, [wd72e]
bit 6, a ; is the player using the link feature?
jp nz, Init
predef SaveSAV ; save the game
call LoadScreenTilesFromBuffer2 ; restore saved screen
jp HoldTextDisplayOpen
This time at least the menu looked correct, but save function fully works still.
The next place I can think to look is predef SaveSAV since its part of the menu script to save, but I'm not sure quite what to do from here.
Offline
You were closest with your first method :)
From what you described I think the issue was mostly because there's other sections of code where GameFreak assumed that the menu would have seven entries, so they start to break and be weird when it only has six. Luckily they already set us an example because they hide the Pokedex entry before you receive your Pokedex. Also I found the EVENT_IN_SAFARI_ZONE event constant which greatly simplifies checking if the player is in safari mode or not.
You can see how I implemented it here:
https://github.com/glodfinch/pokered/co … 3775f2e693
Let me know if there's anything I can explain in further detail from that commit.
Offline
It works perfectly! Thanks so much! I dont know why it never occurred to me that GameFreak probably hid the solution in multiple files considering how many ive had to keep open just to add a new pokemon.
And as I was typing the post I was thinking to myself "I bet there's an easier way of checking Safari mode than looking at each individual map." But i had done some things earlier that day with map checking and musta had it on the brain.
Offline
I'm glad! I was a little worried I'd messed it up when I split it off to a new branch.
Once I saw the amount of places that had to be modified with the check for safari zone I figured there had to be a better way. I found wSafariSteps in wram.asm, but that doesn't get reset to zero when you exit the safari zone, so I figured there had to be a bit somewhere marking if you're in safari mode or not.
Anyway, happy to help!
Last edited by glodfinch (2018-09-15 00:43:30)
Offline
Pages: 1