erichenneke Posted March 23, 2017 Share Posted March 23, 2017 I want to use the keyboard arrow keys to control left and right in a basic game, as an alternative to a joystick option. I thought this would be simple, but realized I guess I've never done this before on the Atari because it's actually not working very well! What I want is just a momentary on switch. If the left arrow is pressed do something ( but only while it is pressed ), if the right arrow is pressed do something else ( but only while it is pressed ). If neither are pressed, do nothing. If I use a PEEK(764) the problem is that then it stays the same value until another key is pressed. So if the left arrow is pressed once and then released, it continues to read as if it is pressed until another key is pressed. That is not what I need. I tried POKEing 0 or 255 into 764 in between each PEEK(764) but that results in a very jerky and inconsistent reading. Like you have to tap the arrow key over and over. I want to be able to press the arrow key and hold it down as long as the user wants....just like a joystick would work. I also tried OPENing K: and GET, but that is no good because it pauses and waits for input. In Turbo Basic XL i tried using the INKEY$ function, but it essentially seems to behave similar to PEEK(764) from this standpoint. Surely there is a way to do this because I know of multiple games that allow a keyboard control option with similar behavior to a joystick. What's the trick? And can it be done from basic ( or TBXL) ? Thanks!!! -Eric Quote Link to comment Share on other sites More sharing options...
Xuel Posted March 23, 2017 Share Posted March 23, 2017 First PEEK SKTAT to see if bit 2 is 0 which indicates that a key is being pressed. Then PEEK KBCODE to get the raw POKEY keyboard code. See Compute's Third Book of Atari for a table of keycodes. 0 KBCODE=$D209:SKSTAT=$D20F 10 IF NOT PEEK(SKSTAT)&4:CODE=PEEK(KBCODE):XD=(CODE=7)-(CODE=6):ELSE:XD=0:ENDIF 20 PRINT XD:GOTO 10 2 Quote Link to comment Share on other sites More sharing options...
Rybags Posted March 24, 2017 Share Posted March 24, 2017 (edited) Keyboard isn't a very good control method on the Atari because the time-saving Pokey key scan in fact limits detecting multiple key presses. That means multiplayer simultaneous kb games are near impossible and single player ones are cumbersome. Exceptions are - the console keys are always independant and not affected by each other or normal keys. - Shift key can be detected independantly but there's no differentiation between each of them. - Control key can only be "assumed" by it's bit in the keyboard code. You can release Ctrl but keep holding the normal key and it'll still return the code indicating Ctrl is being pressed. Ctrl key on it's own or with console key returns nothing. - Shift + Ctrl + third key won't work for keys that are on the same scan row as them, ie - Help B V C X Z J K L ; + * So, keyboard is sort of a poor arcade input method. For something like a Galaxian type game it would be OK since the directions aren't needed at the same time and you could use Shift as the fire button. Edited March 24, 2017 by Rybags 1 Quote Link to comment Share on other sites More sharing options...
José Pereira Posted March 24, 2017 Share Posted March 24, 2017 (edited) For Breakout/Arkanoid type games keyboard are also fine because you move only to left and right so is each time always a single press. Back in the 80s Arkanoid and untill now on A8 and others I only use keyboard because joystick always seemed impossible to me. In Arkanoid case is that you also, like Rybags said, can use with no constraints, the SHIFT key for fire . Others that is the same for me are Tetris type of games. Edited March 24, 2017 by José Pereira 1 Quote Link to comment Share on other sites More sharing options...
Rybags Posted March 24, 2017 Share Posted March 24, 2017 Those types suffer too but it's equivalent to joystick. It's fixed speed movement vs variable for paddle. About all that can be done is assign fire button or Shift which can be held to give slower or faster velocity. 1 Quote Link to comment Share on other sites More sharing options...
José Pereira Posted March 24, 2017 Share Posted March 24, 2017 (edited) Those types suffer too but it's equivalent to joystick. It's fixed speed movement vs variable for paddle. About all that can be done is assign fire button or Shift which can be held to give slower or faster velocity.I never had a paddle and ever remember to saw in any of stores in here at that time. Edited March 24, 2017 by José Pereira Quote Link to comment Share on other sites More sharing options...
erichenneke Posted March 24, 2017 Author Share Posted March 24, 2017 First PEEK SKTAT to see if bit 2 is 0 which indicates that a key is being pressed. Then PEEK KBCODE to get the raw POKEY keyboard code. See Compute's Third Book of Atari for a table of keycodes. 0 KBCODE=$D209:SKSTAT=$D20F 10 IF NOT PEEK(SKSTAT)&4:CODE=PEEK(KBCODE):XD=(CODE=7)-(CODE=6):ELSE:XD=0:ENDIF 20 PRINT XD:GOTO 10 Thank you! Checking SKSTAT first was the piece of the puzzle i was missing ! Quote Link to comment Share on other sites More sharing options...
erichenneke Posted March 24, 2017 Author Share Posted March 24, 2017 The game i want to use this on is only a left/right situation ( like space invaders, etc. ) so this is PERFECT. Thanks all ! -Eric 1 Quote Link to comment Share on other sites More sharing options...
José Pereira Posted March 24, 2017 Share Posted March 24, 2017 (edited) The game i want to use this on is only a left/right situation ( like space invaders, etc. ) so this is PERFECT. Thanks all ! -Eric I would suggest predefined left/right: Z<->X and . <->/ keys that fit to left and right hand users that is near SHIFT if you need it for fire or jump (or you can always let the user to choose but SHIFT need always to be). Edited March 24, 2017 by José Pereira Quote Link to comment Share on other sites More sharing options...
José Pereira Posted March 24, 2017 Share Posted March 24, 2017 (edited) I would suggest predefined left/right: Z<->X and .<->/ keys that fit to left and right hand users that is near SHIFT if you need it for fire or jump (or you can always let the user to choose but SHIFT need always to be).And like Rybags said, the A8 doesn't distinguish between the two SHIFT keys so if having those left/right keys that will fit to all because you can:-> If you're left hand and want to only use that hand one finger gets to left SHIFT; -> The same for right hand user get right SHIFT; -> Use Z<->X and the right hand one finger to press SHIFT (the one I prefer:)); -> Use .<->/ and the left hand one finger to press SHIFT; Edited March 24, 2017 by José Pereira Quote Link to comment Share on other sites More sharing options...
José Pereira Posted March 24, 2017 Share Posted March 24, 2017 (edited) Other type games that work with keyboard are 2d Pac-Man type of games because he's always moving and you'll need to press a single key each time to change direction. You can have the up/down left/right 4keys predefined or give the user the possibility to choose them. P.s.- Strange or perhaps not that although I'm right hand and on joystick always prefered and had the ones with the stick on the right to use with the right hand and button on the left to use it with left hand one finger but keyboard that on Arkanoyd I used two fingers of the left hand on the Z<->X keys and a finger of the right hand to press SHIFT for fire. Edited March 24, 2017 by José Pereira Quote Link to comment Share on other sites More sharing options...
Rybags Posted March 24, 2017 Share Posted March 24, 2017 I'd suggest allow redefining input keys. Some people are just used to WASD for FPS games so might want AD for L/R. Also some prefer adjacent keys and others like them apart a bit more. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.