Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document cycling road flag oversight #368

Closed
spixi opened this issue Jun 26, 2022 · 8 comments
Closed

Document cycling road flag oversight #368

spixi opened this issue Jun 26, 2022 · 8 comments
Labels

Comments

@spixi
Copy link

spixi commented Jun 26, 2022

The following interesting oversight can be documented in the dissambly. Maybe, the address wd732 also can be given a proper name like wWarpCyclingRoadAndDebugFlags or similar.

Address D732 is intentionally carried over to the next save file. It contained debug flags in early development, (see here)

In the final version of the games that byte stores the cycling road flag and warp related flags (dig/teleport/fly/escape rope), which is actually very clever, because you can fly out of the cycling road and that byte needs to be cleared after warping anyway.

Starting a new game while being on the cycling road, preserves this bit, making it impossible to surf or ride the bike unless you enter and leave the cycling road or use one of the warp techniques. Not unsetting that flag when blacking out was present in the Japanese but has been fixed in the US version.

@vulcandth
Copy link
Contributor

vulcandth commented Jun 27, 2022

From a cursory look at the address. I don't believe wd732 to be specific to Cycling Road. It appears to handle setting warp flags for all warps. It just also happens to contain a flag for Debug and Cycling Road Bike Riding.

It looks like the following addresses all contain various flags similar to pokecrystals' engine_flags... just without dedicated functions to process them like pokecrystal:

wd728:: db
wBeatGymFlags:: db
wd72c:: db
wd72d:: db
wd72e:: db
wd730:: db
wd732:: db
wFlags_D733:: db
wBeatLorelei:: db
wd736:: db
wCompletedInGameTradeFlags:: dw <- possibly.

My recommendation would be to rename these to something along the lines of wFlags#; and create constants for each of the bits referenced in their wram comments.

As far as the documentation piece goes, this can be something added when #258 is done. An easy fix for this could be something like (Assuming the end user wants to keep those debug features for the debug rom).

In engine/movie/oak_speech/oak_speech.asm

 SetDefaultNames:
 	ld a, [wLetterPrintingDelayFlags]
 	push af
 	ld a, [wOptions]
 	push af
+IF DEF(_DEBUG)
 	ld a, [wd732]
 	push af
+ENDC
 	ld hl, wPlayerName
... 
 	call FillMemory
+IF DEF(_DEBUG)
 	pop af
 	ld [wd732], a
+ENDC
 	pop af
 	ld [wOptions], a
 	pop af
 	ld [wLetterPrintingDelayFlags], a
....

@spixi
Copy link
Author

spixi commented Jun 27, 2022

As far as the documentation piece goes, this can be something added when #258 is done. An easy fix for this could be something like (Assuming the end user wants to keep those debug features for the debug rom).

The code which preserves that byte is in fact in the production build and not only in the debug build of the games.

@vulcandth
Copy link
Contributor

The code which preserves that byte is in fact in the production build and not only in the debug build of the games.

Hence, why my suggested bug fix action (to go in the future bug docs) forces the code to only build if you are building the debug rom.

@vulcandth
Copy link
Contributor

vulcandth commented Jul 11, 2022

It looks like the start of the Bug Documentation for this has been created here. This will eventually be included in pokered's future docs/bugs_and_glitches.md (#258). This wram address and the remaining unnamed wram addresses still require proper names, but this would be a seperate issue. I believe we can close this issue for now.

Edit: I guess it's been moved here now...

@SatoMew
Copy link
Contributor

SatoMew commented Jul 23, 2023

I added a temporary comment in #410 that documents this:

; Retrieve BIT_DEBUG_MODE set in DebugMenu for StartNewGameDebug.
; BUG: StartNewGame carries over bit 5 from previous save files,
; which causes CheckForceBikeOrSurf to not return.
; To fix this in debug builds, reset bit 5 here or in StartNewGame.
; In non-debug builds, the instructions can be removed.
ld a, [wd732]
push af

The simplest fix is to add res 5, [hl] here:

StartNewGame:
ld hl, wd732
; Ensure debug mode is not used when
; starting a regular new game.
; Debug mode persists in saved games for
; both debug and non-debug builds, and is
; only reset here by the main menu.
res BIT_DEBUG_MODE, [hl]
; fallthrough
StartNewGameDebug:
call OakSpeech
ld c, 20
call DelayFrames

Does this help, @spixi?

@spixi
Copy link
Author

spixi commented Jul 24, 2023

Well done @SatoMew, but I still think that wd732 needs a proper constant name.

@SatoMew
Copy link
Contributor

SatoMew commented Jul 26, 2023

I still think that wd732 needs a proper constant name.

That will be taken care of eventually.

@Rangi42
Copy link
Member

Rangi42 commented Oct 6, 2024

wd732 was identified as wStatusFlags6.

@Rangi42 Rangi42 closed this as completed Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants