-
Notifications
You must be signed in to change notification settings - Fork 253
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
simple cursor #34
Comments
Maybe take a look at the snake game: if you cut the snake down to one cell, and stop it moving, it's pretty close to a cursor, perhaps. |
I have a similar problem. You can't stop something moving, because $ff only contains the last key pressed, |
Ah, that's a bit of a problem. Here in the JavaScript we see (Just to note: with this simple change, typing say 'L' would give you keypress for shift, keypress for L, and then two key-up events, the first of which would clear $ff.) |
Interesting. I hope @skilldrick takes a look and considers a patch. |
Try this - it has the right effect I think, but it does mean that the Snake demo (and anything else) can now easily miss a short keypress. Previously keys were sticky. |
But hang on, your approach of writing $00 to $ff should have worked. It seems to work with this demo:
|
Okay that works. But not this:
Basically, the pixel in the upper left should be visible when I press a key and disappear when I release the key. I guess it is a timing thing... Not enough time to recognize the pressed key. Would be cool to have a robust code snippet that works. |
I had a look, and it doesn't quite do that: $ff isn't a register which holds the code for the currently-pressed key, like a keyboard interface might do, instead it's a register which holds the code of the last key pressed. So, if you read it and set it to zero, you see each keypress just once. If you don't set it to zero, you keep seeing the same key, even if released. (If the key is held down, then after a short delay the keyboard will start auto-repeating, and that will appear as a succession of keypresses.) You can see this with this program:
The code in my fork is presently different: it will clear the register when the key is released. That opens the possibility of missing the key, whereas the presently published code in the main fork can't miss a keypress. (It has no rollover: if two keys were pressed in quick succession, you'd only see the second.) |
Ahh I see. But your example works quite well for many use cases I guess. |
Here's a simple cursor routine: a bit of a spoiler so encoded with rot13
|
Wait, I got it! This is the code:
The only trouble that's left is how I can make the dot go further down. Also, the dot glitches a bit when moving vertically. |
I finally got this to work, don't use absolute addressing mode for the reason that it only wraps around the last 2 bytes. Use indexed indirect because then you will be able to update both the high and low bytes. Edit: I did not define at all, sorry, I am putting in comments to make it easier to read. ;up is #$77 LDA #$02 ;$XX00 High LDA #$00 ;$00XX low JMP UPLEFT ;follow the comments to loop UPLEFT MINUS: ;and finally at this loop I refresh the screen and finish the $06 counter for up and down OVERFLOWUPLEFT: DONE: PLUS: OVERFLOWDOWNRIGHT: DONE2: RESET: ;in here I refresh the screen and then I check each input, I need to fix this part, it is LDA $06 UPLEFT: JMP RESET JMP RESET DOWNRIGHT: JMP RESET |
I'm just getting used to the built-in 6502 emulator. I'm having problems trying a code even a simple cursor. All I want is a single dot that could move up, down, left, and right by my command. What could I do to accomplish this?
The text was updated successfully, but these errors were encountered: