Jump to content
IGNORED

1-9 pause code


Recommended Posts

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.

  • Like 1
Link to comment
Share on other sites

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 by nanochess
Link to comment
Share on other sites

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.

  • Like 3
Link to comment
Share on other sites

  • 2 months later...
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 by mr_me
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by DZ-Jay
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by DZ-Jay
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.*.

 

 

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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:
	[...]

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...