Brian's Man Cave Posted March 9, 2022 Share Posted March 9, 2022 Hey, I am not sure how to check if 2 buttons are being held together... example holding down 1 and 9 at same time to trigger a pause! Any help is appreciated Thanks Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/ Share on other sites More sharing options...
Zendocon Posted March 9, 2022 Share Posted March 9, 2022 Short answer: do a PEEK on addresses $1fe and $1ff and check for the value $55. It would look like this: IF (PEEK($1ff) = $55) + (PEEK($1fe) = $55) THEN ' pause END IF I can give you more information if you need it. 1 Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5018301 Share on other sites More sharing options...
+nanochess Posted March 10, 2022 Share Posted March 10, 2022 I prefer to avoid using PEEK, as IntyBASIC provides enough idiom to do it: c = CONT IF c = $a5 THEN GOSUB global_pause While the procedure global_pause is like this: ' ' A procedure to be called when pressing 1+9 is detected ' global_pause: PROCEDURE IF debounce THEN debounce = debounce - 1 RETURN END IF c = sound_effect sound_effect = 0 PLAY NONE SOUND 0,,0 SOUND 1,,0 SOUND 4,,$38 debounce = 50 DO WAIT IF cont.button THEN IF debounce < 10 THEN debounce = 10 debounce = debounce - 1 LOOP WHILE debounce > 0 DO WAIT LOOP WHILE cont <> $A5 debounce = 25 PLAY SIMPLE NO DRUMS sound_effect = c c = 0 END The debounce variable makes sure there is no reentry after exiting the pause mode (pressing again 1+9) If you are using sound effects in the style shown in my books, sound_effect = 0 stops the current playing sound effect. Notice how the sound effect is restored just before exiting the procedure. If you are using music make sure to replace PLAY SIMPLE NO DRUMS with the mode you are using, or simply remove both PLAY statements if you don't use music. The statements PLAY NONE and the following SOUND statements are required in order to turn off any upstanding note playing. This code comes from my game Frankenstein's Monster. It processes the controller code using c = CONT, that's the cause of the final c = 0 in order to avoid moving player after exiting the pause mode. BTW, a good way to know the code you need for some combination of keys is using this inside a loop: PRINT AT 0 COLOR 7,<>CONT Notice that most key combinations "crash" with real usage of disc and buttons. 1 Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5018744 Share on other sites More sharing options...
+cmadruga Posted March 10, 2022 Share Posted March 10, 2022 5 minutes ago, nanochess said: Notice that most key combinations "crash" with real usage of disc and buttons. What do you mean? Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5018747 Share on other sites More sharing options...
+nanochess Posted March 10, 2022 Share Posted March 10, 2022 3 minutes ago, cmadruga said: What do you mean? I mean these replicate valid codes of movement, and/or button usage. Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5018748 Share on other sites More sharing options...
+cmadruga Posted March 10, 2022 Share Posted March 10, 2022 1 minute ago, nanochess said: I mean these replicate valid codes of movement, and/or button usage. Oh, so you mean there is always a likelihood pause can get called by mistake? If yes, is 1+9 any better than let's say, using a single key? Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5018750 Share on other sites More sharing options...
+nanochess Posted March 10, 2022 Share Posted March 10, 2022 (edited) 33 minutes ago, cmadruga said: Oh, so you mean there is always a likelihood pause can get called by mistake? If yes, is 1+9 any better than let's say, using a single key? Yes, with some double key combinations. But typically if you use all the keys, 1+9 is like getting an extra key. Besides, Mattel games started using it as pause, so it is like a standard. Edited March 10, 2022 by nanochess Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5018773 Share on other sites More sharing options...
Kiwi Posted March 11, 2022 Share Posted March 11, 2022 On 3/9/2022 at 8:14 PM, nanochess said: Notice that most key combinations "crash" with real usage of disc and buttons. I remembered Space Hawk and you could accidentally trigger the warp keypad button by pressing both fire button and a direction with the controller. The instruction said that you could accidentally fall into the black hole. 3 Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5019843 Share on other sites More sharing options...
artrag Posted May 25, 2022 Share Posted May 25, 2022 Is there a keypad combination of two keys that doesn't crash with fire buttons? Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5063409 Share on other sites More sharing options...
mr_me Posted May 25, 2022 Share Posted May 25, 2022 (edited) 2 hours ago, artrag said: Is there a keypad combination of two keys that doesn't crash with fire buttons? Assuming the controller is working reliably, keypad combinations that are two rows apart produce a code that's not replicated by any disc and/or side button presses. If the software isn't checking for the keypad combination, the code from pressing two keypad buttons in different columns is similar to a side button code. So a keypad combination in the same column would avoid it. Edited May 25, 2022 by mr_me Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5063443 Share on other sites More sharing options...
+DZ-Jay Posted May 26, 2022 Share Posted May 26, 2022 On 5/25/2022 at 6:59 AM, artrag said: Is there a keypad combination of two keys that doesn't crash with fire buttons? The typical 3+7 or 1+9 typically work for this, which is why they were chosen for pause. I don’t have access to the key codes at the moment, so I can’t confirm what the actual patterns is for each. dZ. Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064055 Share on other sites More sharing options...
artrag Posted May 26, 2022 Share Posted May 26, 2022 https://web.archive.org/web/20060317144849/http://users.erols.com/tiltonj/games/tech/intvcont.html Buttons S1,S2,S3 crash with keys as follows: K1,K4,K7,clear rise pin 6 (used by S1 and S3) K0,K8,K5,K2 rise pin 7 (used by S1 and S3 ) Enter,K9,K6,K3 rise pin 8 (used by S1 and S2 ) Thus both combinations 1+9 and 3+7 rise lines 6 and 8 and give S1 Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064108 Share on other sites More sharing options...
mr_me Posted May 26, 2022 Share Posted May 26, 2022 As I said, pressing two keypad buttons in two different columns will produce a code similar to a side button press. But pressing keypad 1+9 will also close pins two and four in addition to pins six and eight. If the software checks for that condition then there is no conflict with side buttons. If the software doesn't check for that condition than it will think a side button has been pressed. However, if the software doesn't check for the keypad 1+9 condition, then there's no reason for the user to press that keypad combination. Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064114 Share on other sites More sharing options...
artrag Posted May 26, 2022 Share Posted May 26, 2022 When I test for buttons (while shooting), I should add a test on line 2 and 4 to filter the pressure of 1+9 on the keypad Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064118 Share on other sites More sharing options...
mr_me Posted May 26, 2022 Share Posted May 26, 2022 (edited) You only need to that if your program makes use of a keypad 1+9 combination, e.g. pausing the game. If you aren't doing that then I don't see any point of adding any extra code. Edited May 26, 2022 by mr_me Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064121 Share on other sites More sharing options...
+DZ-Jay Posted May 26, 2022 Share Posted May 26, 2022 21 minutes ago, artrag said: https://web.archive.org/web/20060317144849/http://users.erols.com/tiltonj/games/tech/intvcont.html Buttons S1,S2,S3 crash with keys as follows: K1,K4,K7,clear rise pin 6 (used by S1 and S3) K0,K8,K5,K2 rise pin 7 (used by S1 and S3 ) Enter,K9,K6,K3 rise pin 8 (used by S1 and S2 ) Thus both combinations 1+9 and 3+7 rise lines 6 and 8 and give S1 If you are looking for a combination of keys that do not raise any signal in common with action buttons, it does not exist. For better or worse, at least one signal is shared with other controls. However, the set is comprised of Grey Codes, so they are designed to not overlap in contiguous surfaces. Moreover, even though the keypad keys share a signal with the buttons, none share all. So it is easy to disambiguate a valid button from a key combination, since the additional signals in the keys will not overlap with the buttons, and vice-versa. A similar thing happens to multiple buttons: because they share a common signal, you can detect that more than one button is pressed , but you cannot disambiguate them. dZ. Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064122 Share on other sites More sharing options...
+DZ-Jay Posted May 26, 2022 Share Posted May 26, 2022 (edited) 10 minutes ago, artrag said: When I test for buttons (while shooting), I should add a test on line 2 and 4 to filter the pressure of 1+9 on the keypad The problem is that the Intellivision hand controller has been designed with two specific use cases in mind: keypad entry, or “run and shoot” (i.e., disc + action buttons). Attempting to detect buttons or disc at the same time as keys is fraught with potential errors, since they all share signals in some fashion. To exacerbate the problem, the hardware is imperfect, most likely very old and overused, and prone to analog signal noise and switch bouncing. All of which makes it difficult to distinguish a glitchy or noisy signal from valid input. And on top of it all, it is ergonomically impractical or awkward to press the disc and a key, or a button and a key, simultaneously, which makes such control schemes less than optimal. dZ. Edited May 26, 2022 by DZ-Jay Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064124 Share on other sites More sharing options...
mr_me Posted May 26, 2022 Share Posted May 26, 2022 30 minutes ago, DZ-Jay said: If you are looking for a combination of keys that do not raise any signal in common with action buttons, it does not exist. ... A keypad combo in the same column, e.g. 1+7, doesn't make a side button code. However, it's a problem because it can be replicated with a disc + keypad button. Normally you don't press disc and keypad at the same time but it can happen accidentally in games that use the keypad, e.g. basketball, deadly discs, etc. So it's best not to use keypad combos in the same column. Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064135 Share on other sites More sharing options...
+DZ-Jay Posted May 26, 2022 Share Posted May 26, 2022 (edited) 24 minutes ago, mr_me said: A keypad combo in the same column, e.g. 1+7, doesn't make a side button code. However, it's a problem because it can be replicated with a disc + keypad button. Normally you don't press disc and keypad at the same time but it can happen accidentally in games that use the keypad, e.g. basketball, deadly discs, etc. So it's best not to use keypad combos in the same column. Sorry, that’s sort of what I was getting at, as the rest of my post attests: multiple controls (other than one disc + one action button) are not easy, or perhaps even impossible, to disambiguate — precisely because they were not designed for it. dZ. Edited May 26, 2022 by DZ-Jay Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064148 Share on other sites More sharing options...
mr_me Posted May 27, 2022 Share Posted May 27, 2022 13 hours ago, artrag said: When I test for buttons (while shooting), I should add a test on line 2 and 4 to filter the pressure of 1+9 on the keypad There is a conflict with single keypad button presses that sends a code similar to one of the four cardinal disc directions, each keypad row being a different direction. Again, if the game doesn't use the keypad then there's no reason to filter it with extra programming. It might already be taken care of by the compiler. Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064322 Share on other sites More sharing options...
+DZ-Jay Posted May 27, 2022 Share Posted May 27, 2022 15 minutes ago, mr_me said: There is a conflict with single keypad button presses that sends a code similar to one of the four cardinal disc directions, each keypad row being a different direction. Again, if the game doesn't use the keypad then there's no reason to filter it with extra programming. It might already be taken care of by the compiler. The compiler attempts to condition and debounce the keypad input if you try to read CONT.KEY, otherwise, it just adds code to read the hardware directly whenever you call CONT.*. Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064325 Share on other sites More sharing options...
+DZ-Jay Posted May 27, 2022 Share Posted May 27, 2022 @artrag, What precisely is the input scheme you plan to use? Is it only disc+action buttons, or does it involve keypad as well? As mentioned before, you should not attempt to combine those, especially in a fast-paced shooter, where the player presses the controller under stress. It is fine to expect them separately (as in a menu where you use the disc to move the cursor, the action buttons to select an option, the keypad to select a mode, etc.). I typically treat these as three distinct use cases: Run+shoot (disc + action buttons) Key entry (keypad) General Purpose (disc + action buttons, keypad) In my own code, depending on the use case, I write specialized code for the first two, which typically involves ignoring any input which is not appropriate (e.g., if expecting keypad entry only, ignore any input which has a signal that distinctly suggests a disc or action button entry). For the third case, I use a state machine: I first attempt to discern the "mode," either key entry or run+shoot using some simple heuristics. Then once a decision is made on which kind of input we are dealing with, the rest follows the same specialization as the described above. I can share some code or algorithms I have prepared in the past, including some IntyBASIC code that may at least illustrate the approach. -dZ. Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064329 Share on other sites More sharing options...
artrag Posted May 27, 2022 Share Posted May 27, 2022 My game is using only left,right (i.e. D13 and D5) and buttons (S1,S2,S3) for shooting I've added a pause with K1+K9 but pressing K1 or K9 triggers a shoot due to the fact that lines 6 and 8 are also shared by S1 My test for buttons is MVI $1FE,R0 XOR $1FF,R0 ANDI #$E0,R0 BEQ NotFire Fire: [...] NotFire: [...] where $E0 in binary (011100000) corresponds to pins 6,7,8 I test for 1+9 by testing $A5 the input ports MVI $1FE,R0 XOR $1FF,R0 CMPI #$A5,R0 BNE NotPause Pause: [...] NotPause: [...] Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064424 Share on other sites More sharing options...
mr_me Posted May 27, 2022 Share Posted May 27, 2022 You should test for pause first, and if it's met skip the buttons test. Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064428 Share on other sites More sharing options...
+DZ-Jay Posted May 27, 2022 Share Posted May 27, 2022 10 minutes ago, artrag said: My game is using only left,right (i.e. D13 and D5) and buttons (S1,S2,S3) for shooting I've added a pause with K1+K9 but pressing K1 or K9 triggers a shoot due to the fact that lines 6 and 8 are also shared by S1 My test for buttons is MVI $1FE,R0 XOR $1FF,R0 ANDI #$E0,R0 BEQ NotFire Fire: [...] NotFire: [...] where $E0 in binary (011100000) corresponds to pins 6,7,8 I test for 1+9 by testing $A5 the input ports MVI $1FE,R0 XOR $1FF,R0 CMPI #$A5,R0 BNE NotPause Pause: [...] NotPause: [...] Ah, I see. When testing for pause input, I perform that test first: I check if the input is exactly the signal for the combined keys, and if so, switch to the pause state. I only proceed with testing for other input when the initial test fails. Also, and this is important, I make sure that all transitions between modes (e.g., switching to pause, using disc, using keypad, etc.) are preceded by the controller being idled first. dZ. Quote Link to comment https://forums.atariage.com/topic/332377-1-9-pause-code/#findComment-5064429 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.