Hello!
Like many of you, I have decided to write a little game for the VIC-20, something I'd never got round to when I should have i.e. as a kid.
In my game there are a series of consecutive informational screens before/after each stage (eg.: the start screen followed by the level info screen; the game over screen followed by the home screen) each one of which requires to hit the fire button to go on. If the button is kept pressed, or is pressed long enough, the first screen is kinda skipped (the VIC registers two consecutive hits of the button in a row).
Is there any way to make sure that the player releases the button if pressed, and then hits it again to go on?
Thanks
Equivalent of POKE 198,0 for joystick?
Moderator: Moderators
- LoadError
- Vic 20 Hobbyist
- Posts: 120
- Joined: Sat Feb 17, 2007 2:44 pm
- Website: http://digilander.libero.it/pyrotech/
- Location: Italy
- Occupation: FG Soft
Equivalent of POKE 198,0 for joystick?
Commodore VIC-20 n. WG-C-275517 - manufactured in Western Germany in 1983
Re: Equivalent of POKE 198,0 for joystick?
you first check for button press, and then loop/wait until its no more pressed.... there is no other way than doing it "manually"
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
Re: Equivalent of POKE 198,0 for joystick?
E.g.
Waits for button-press and then waits for button-release
Code: Select all
wait 37151,32,32:wait 37151,32
- LoadError
- Vic 20 Hobbyist
- Posts: 120
- Joined: Sat Feb 17, 2007 2:44 pm
- Website: http://digilander.libero.it/pyrotech/
- Location: Italy
- Occupation: FG Soft
Re: Equivalent of POKE 198,0 for joystick?
Great, thanks, this code works well. Now, I'd like to understand _why_ it works
I did not even know you could use more than one argument with WAIT.
Is 32 the button press/release momentum? Hence, wait for press-release-press?
Why does not WAIT 198,1,1 work the same way (WAIT 198,1 returns control after a key is pressed, WAIT 198,1,1 returns control immediately)?
[edited: mind trip, wrote POKE meant WAIT]
I did not even know you could use more than one argument with WAIT.
Is 32 the button press/release momentum? Hence, wait for press-release-press?
Why does not WAIT 198,1,1 work the same way (WAIT 198,1 returns control after a key is pressed, WAIT 198,1,1 returns control immediately)?
[edited: mind trip, wrote POKE meant WAIT]
Last edited by LoadError on Tue Mar 15, 2016 8:28 am, edited 1 time in total.
Commodore VIC-20 n. WG-C-275517 - manufactured in Western Germany in 1983
Re: Equivalent of POKE 198,0 for joystick?
that seems to be a lesser known feature of WAIT.... see here: http://www.c64-wiki.com/index.php/WAIT
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
- LoadError
- Vic 20 Hobbyist
- Posts: 120
- Joined: Sat Feb 17, 2007 2:44 pm
- Website: http://digilander.libero.it/pyrotech/
- Location: Italy
- Occupation: FG Soft
Re: Equivalent of POKE 198,0 for joystick?
Thanks, all clear now.
Commodore VIC-20 n. WG-C-275517 - manufactured in Western Germany in 1983
- Mike
- Herr VC
- Posts: 4831
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Equivalent of POKE 198,0 for joystick?
I should add, that POKE 198,0 does not at all "wait" until there's no more any key pressed. Rather it will clear the keyboard input buffer. This buffer can hold up to 10 non-processed key-strokes (those with an equivalent PETSCII-Code - Shift and other control keys don't count here). That means, in the construction:
the POKE just makes sure that all unprocessed keys in the buffer entered before line 10 are discarded.
Another, quite often used construction is "POKE198,0:WAIT198,1". Here, once again POKE198,0 clears the buffer, and then WAIT198,1 (doh!) waits untils there's one key in the buffer. BTW, that key is then still unread, and would need to be cleared by either another POKE198,0 or a GETA$, where A$ then isn't used later.
So, actually there's *no* equivalent to POKE198,0 for the joystick. There is no buffer for joystick movements or fire, the directions and the buttons are read out directly. And then, of course, you just need to check that the button is released before you check that it is (once again) pressed.
I would thus actually revert the WAIT instructions tokra gave, to: WAIT 37151,32:WAIT37151,32,32 so the program already continues to the next page of text with the button press, not upon its release. If the user then keeps the fire button pressed, the next use of WAIT37151,32:WAIT37151,32,32 then will first make sure that fire button is released.
Code: Select all
10 POKE198,0
20 GETA$:IFA$=""THEN20
Another, quite often used construction is "POKE198,0:WAIT198,1". Here, once again POKE198,0 clears the buffer, and then WAIT198,1 (doh!) waits untils there's one key in the buffer. BTW, that key is then still unread, and would need to be cleared by either another POKE198,0 or a GETA$, where A$ then isn't used later.
So, actually there's *no* equivalent to POKE198,0 for the joystick. There is no buffer for joystick movements or fire, the directions and the buttons are read out directly. And then, of course, you just need to check that the button is released before you check that it is (once again) pressed.
I would thus actually revert the WAIT instructions tokra gave, to: WAIT 37151,32:WAIT37151,32,32 so the program already continues to the next page of text with the button press, not upon its release. If the user then keeps the fire button pressed, the next use of WAIT37151,32:WAIT37151,32,32 then will first make sure that fire button is released.
- LoadError
- Vic 20 Hobbyist
- Posts: 120
- Joined: Sat Feb 17, 2007 2:44 pm
- Website: http://digilander.libero.it/pyrotech/
- Location: Italy
- Occupation: FG Soft
Re: Equivalent of POKE 198,0 for joystick?
Sorry.... I've edited my previous post, I wrote "POKE 198,1,1" whereas what I meant was WAIT 198,1,1
Commodore VIC-20 n. WG-C-275517 - manufactured in Western Germany in 1983