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

BBSB warp to screen 4 does not work #199

Closed
Shamus397 opened this issue Nov 21, 2023 · 9 comments
Closed

BBSB warp to screen 4 does not work #199

Shamus397 opened this issue Nov 21, 2023 · 9 comments

Comments

@Shamus397
Copy link
Contributor

When you clear level 5 in Bounty Bob Strikes Back! (cartridge version) you get a message telling you how to warp from screen 1 to screen 4:

"IN LEVEL 1, IMMEDIATELY AFTER PICKING UP THE FLOWER POT, HOLD DOWN THE NUMBER 1 ON THE KEYBOARD AND PRESS START TO WARP TO LEVEL 4."

However, this doesn't work; if you follow the instructions (pick up the flower pot, hold down "1", then press START), nothing happens. Just for the sake of completeness, I checked the tape version of BBSB and it suffers from the same problem.

All on a stock NTSC 800XL--nothing fancy added.

@mikrosk
Copy link
Member

mikrosk commented Nov 21, 2023

Does this work in e.g. Altirra?

@phaeron1024
Copy link

It does. I ran an execution trace in Altirra and this is the code that detects the 1+Start combination:

    7010:  9: 61 | A=0E X=01 Y=01 S=FF P=77 ( V IZC) |     0E0B: AD 5F D2          LDA $D25F    ;SKSTAT
    7010:  9: 65 | A=FB X=01 Y=01 S=FF P=F5 (NV I C) |     0E0E: 29 04             AND #$04
    7010:  9: 67 | A=00 X=01 Y=01 S=FF P=77 ( V IZC) |     0E10: D0 ED             BNE $0DFF
    7010:  9: 69 | A=00 X=01 Y=01 S=FF P=77 ( V IZC) |     0E12: AD 59 D2          LDA $D259    ;KBCODE
    7010:  9: 73 | A=1F X=01 Y=01 S=FF P=75 ( V I C) |     0E15: 29 3F             AND #$3F
    7010:  9: 75 | A=1F X=01 Y=01 S=FF P=75 ( V I C) |     0E17: A8                TAY
    7010:  9: 77 | A=1F X=01 Y=1F S=FF P=75 ( V I C) |     0E18: B9 E9 AA          LDA $AAE9,Y  ;$AB08
    7010:  9: 82 | A=11 X=01 Y=1F S=FF P=75 ( V I C) |     0E1B: 38                SEC
    7010:  9: 84 | A=11 X=01 Y=1F S=FF P=75 ( V I C) |     0E1C: E9 11             SBC #$11
    7010:  9: 86 | A=00 X=01 Y=1F S=FF P=37 (   IZC) |     0E1E: 85 AD             STA $AD
    7010:  9: 89 | A=00 X=01 Y=1F S=FF P=37 (   IZC) |     0E20: CA                DEX
    7010:  9: 91 | A=00 X=00 Y=1F S=FF P=37 (   IZC) |     0E21: 8A                TXA
    7010:  9: 93 | A=00 X=00 Y=1F S=FF P=37 (   IZC) |     0E22: E8                INX
    7010:  9: 95 | A=00 X=01 Y=1F S=FF P=35 (   I C) |     0E23: 4A                LSR
    7010:  9: 97 | A=00 X=01 Y=1F S=FF P=36 (   IZ ) |     0E24: A8                TAY
    7010:  9: 99 | A=00 X=01 Y=00 S=FF P=36 (   IZ ) |     0E25: B9 1D BA          LDA $BA1D,Y  ;$BA1D
    7010:  9:103 | A=07 X=01 Y=00 S=FF P=34 (   I  ) |     0E28: B0 04             BCS $0E2E
    7010:  9:105 | A=07 X=01 Y=00 S=FF P=34 (   I  ) |     0E2A: 4A                LSR
    7010:  9:107 | A=03 X=01 Y=00 S=FF P=35 (   I C) |     0E2B: 4A                LSR
    7010:  9:109 | A=01 X=01 Y=00 S=FF P=35 (   I C) |     0E2C: 4A                LSR
    7010:  9:111 | A=00 X=01 Y=00 S=FF P=37 (   IZC) |     0E2D: 4A                LSR
    7010:  9:113 | A=00 X=01 Y=00 S=FF P=36 (   IZ ) |     0E2E: 29 0F             AND #$0F
    7010: 10:  6 | A=00 X=01 Y=00 S=FF P=36 (   IZ ) |     0E30: C5 AD             CMP $AD
    7010: 10:  9 | A=00 X=01 Y=00 S=FF P=37 (   IZC) |     0E32: D0 CB             BNE $0DFF
    7010: 10: 11 | A=00 X=01 Y=00 S=FF P=37 (   IZC) |     0E34: E0 05             CPX #$05
    7010: 10: 13 | A=00 X=01 Y=00 S=FF P=B4 (N  I  ) |     0E36: 90 0F             BCC $0E47
    7010: 10: 16 | A=00 X=01 Y=00 S=FF P=B4 (N  I  ) |     0E47: A9 05             LDA #$05
    7010: 10: 18 | A=05 X=01 Y=00 S=FF P=34 (   I  ) |     0E49: 85 19             STA $19
    7010: 10: 21 | A=05 X=01 Y=00 S=FF P=34 (   I  ) |     0E4B: AD 5F D0          LDA $D05F    ;CONSOL
    7010: 10: 26 | A=06 X=01 Y=00 S=FF P=34 (   I  ) |     0E4E: 4A                LSR
    7010: 10: 28 | A=03 X=01 Y=00 S=FF P=34 (   I  ) |     0E4F: B0 AE             BCS $0DFF
    7010: 10: 31 | A=03 X=01 Y=00 S=FF P=34 (   I  ) |     0E51: BC 84 9E          LDY $9E84,X  ;$9E85

This code polls the keyboard by checking SKSTAT bit 2 to detect the key down. At least in the Windows SDL version of Atari800 5.0.0, the problem is that SKSTAT bit 2 is resetting back to 1 when Start is pressed, even if the 1 key is still being held.

@mikrosk
Copy link
Member

mikrosk commented Nov 23, 2023

Avery, thank you very much for your analysis. I'll take a look. @Shamus397 if you could provide a saved state from Atari800 so I don't have to beat all five levels, that would helped a lot. :-)

@Shamus397
Copy link
Contributor Author

Shamus397 commented Nov 27, 2023

bbsb-l6.zip

@mikrosk Here you go; starting at level 6. Though I don't think you have to trigger the message for it to activate the warp (IIRC, the warp is always active).

I should also mention that the message doesn't trigger until you lose your last life (it shows up on the "Game Over" screen).

@Shamus397
Copy link
Contributor Author

Shamus397 commented Nov 29, 2023

@mikrosk
The problem is here, in atari_x11.c (lines 443-454):

case XK_F2:
keyboard_consol &= (~INPUT_CONSOL_OPTION);
keycode = AKEY_NONE;
break;
case XK_F3:
keyboard_consol &= (~INPUT_CONSOL_SELECT);
keycode = AKEY_NONE;
break;
case XK_F4:
keyboard_consol &= (~INPUT_CONSOL_START);
keycode = AKEY_NONE;
break;

Each one of those keycode = AKEY_NONE; lines is killing any other key that may be held down. I believe removing those lines should solve the problem, but I'm not 100% sure of that. : )

@mikrosk
Copy link
Member

mikrosk commented Nov 29, 2023

I have already investigated it. However the fix isn't so easy; for starters, you're looking into wrong file (X11 backend isn't the same as SDL). In the SDL backend there is no concept of "pressed key while some another one is pressed". So that require some rework (or at least a fix as I might have overlooked something).

But yeah, in the end, most likely the fix will be needed in all backends.

@Shamus397
Copy link
Contributor Author

Shamus397 commented Nov 30, 2023

@mikrosk
Actually, there is a concept of "pressed key while some another one is pressed" in SDL, and it's your kbhits[] array. : ) Turns out the solution isn't so bad, and the code required to fix this is pretty minimal:

diff --git a/src/sdl/input.c b/src/sdl/input.c
index 89aa3f65..79dc0edd 100644
--- a/src/sdl/input.c
+++ b/src/sdl/input.c
@@ -451,11 +451,25 @@ int PLATFORM_Keyboard(void)
                event_found = 1;
                switch (event.type) {
                case SDL_KEYDOWN:
+
+                       /* If the KEYDOWN event we get here is OPTION, SELECT, or START, then ignore it here as it's supposed to be it's own independent (i.e., separate from the keyboard) subsystem. */
+                       if ((event.key.keysym.sym == KBD_OPTION)
+                               || (event.key.keysym.sym == KBD_SELECT)
+                               || (event.key.keysym.sym == KBD_START))
+                               break;
+
                        lastkey = event.key.keysym.sym;
                        lastuni = event.key.keysym.unicode;
                        key_pressed = 1;
                        break;
                case SDL_KEYUP:
+
+                       /* Need to ignore KEYUP as well... */
+                       if ((event.key.keysym.sym == KBD_OPTION)
+                               || (event.key.keysym.sym == KBD_SELECT)
+                               || (event.key.keysym.sym == KBD_START))
+                               break;
+
                        lastkey = event.key.keysym.sym;
                        lastuni = 0; /* event.key.keysym.unicode is not defined for KEYUP */
                        key_pressed = 0;

The fix I proposed up above (for atari_x11.c) should take care of the X11 backend, though I haven't tested it at all. So, assuming that one works too, that's two down, eight or so more to go? : P

@mikrosk
Copy link
Member

mikrosk commented Nov 30, 2023

Nice work! Yes, this is way closer to what I had imagined.

Unfortunately, still other backends are prone to this bug but since you were the first one to notice, it either works on other popular backends (Android?) or they are not that much used anymore.

I'll try your test case on Atari Falcon, as this is the platform I know, and try to fix/test it there as well. Feel free to prepare a PR in the meantime (assuming that your own patch works ;-)).

Shamus397 added a commit to Shamus397/atari800 that referenced this issue Nov 30, 2023
joysfera added a commit that referenced this issue Nov 30, 2023
Fix for issue #199 (BBSB warp doesn't work)
@joysfera
Copy link
Member

Fixed in #203

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

4 participants