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

Explanation for Side View Connections That Make No Sense #9

Open
deusprogrammer opened this issue May 24, 2023 · 1 comment
Open

Explanation for Side View Connections That Make No Sense #9

deusprogrammer opened this issue May 24, 2023 · 1 comment

Comments

@deusprogrammer
Copy link

deusprogrammer commented May 24, 2023

I wanted to provide you with this info as I went through the asm code and found the answer.

Essentially if the map number is greater than 29 it always treats all of it's exits as 0. But here is the 6502 code snippet that shows it in action.

A:00 X:09 Y:00 S:F9 P:nvUBdIZc       $CF52: AD 61 05  LDA $0561 current scene/map index = #$21
A:21 X:09 Y:00 S:F9 P:nvUBdIzc       $CF55: AC 07 07  LDY $0707 World = #$00
A:21 X:09 Y:00 S:F9 P:nvUBdIZc       $CF58: D0 06     BNE $CF60
A:21 X:09 Y:00 S:F9 P:nvUBdIZc       $CF5A: C9 1D     CMP #$1D
A:21 X:09 Y:00 S:F9 P:nvUBdIzC       $CF5C: 90 02     BCC $CF60
A:21 X:09 Y:00 S:F9 P:nvUBdIzC       $CF5E: A9 00     LDA #$00
A:00 X:09 Y:00 S:F9 P:nvUBdIZC       $CF60: 0A        ASL
A:00 X:09 Y:00 S:F9 P:nvUBdIZc       $CF61: 0A        ASL
A:00 X:09 Y:00 S:F9 P:nvUBdIZc       $CF62: 65 3B     ADC $3B = #$03
A:03 X:09 Y:00 S:F9 P:nvUBdIzc       $CF64: A8        TAY
A:03 X:09 Y:03 S:F9 P:nvUBdIzc       $CF65: B9 FC 6A  LDA $6AFC Room Connectivity Data,Y @ $6AFF Do

On line $CF5A the mapNumber is compared to $1D (29).
So basically if the mapNumber is greater than 29 and the "world" is zero (meaning it's overworld or in technical terms banks 1 and 2), then it uses the level exits at mapNumber 0 (which has 63 for all four exits).
LDA loads the data at the provided memory location into the accumulator.
LDY does the same but it loads into the Y register
BNE branches if the Z flag is set.  The Z flag gets set when a LD operation loads a zero value or when a CMP op finds the two values equal.
CMP compares the accumulator with the value in a memory location.  It sets the Z flag if the two are equal, and it sets the C flag if the accumulator is less.
ASL shifts left (multiplies by 2)
ADC adds the value at memory address to the accumulator
TAY transfers the value of the accumulator to the Y register

Note #$XX is an immediate value instead of a memory address.  So for example #$FF is the byte 0xFF.

ASL is multiplying by 4 (because each level connection entry is 4 bytes).
LDA $6AFC,Y is loading from $6AFC + Y
$3B holds the current map page
$0707 holds the world
$0561 holds the current map (edited)
I am in world 0 (#$00)
I am in trophy cave (#$21)
I am in map page 3 (#$03) (edited)

If you update the wiki, please just leave me credit =). Also, I would really love to chat about Zelda 2 as I am building an alternative randomizer and I have so many questions.

@deusprogrammer
Copy link
Author

Discord: thetruekingofspace#7687 (don't feel pressured, no need to respond if you don't feel like it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant