Weird joystick issue with ugly fix

Basic and Machine Language

Moderator: Moderators

Post Reply
jim_20
Vic 20 Newbie
Posts: 8
Joined: Wed Sep 17, 2014 7:38 pm

Weird joystick issue with ugly fix

Post by jim_20 »

I coded this game for the 10 line BASIC contest. I got 5th place which I was very happy with. :D
http://cloud.cbm8bit.com/jim_64/10%20run10-vic%2020.prg
http://sleepingelephant.com/ipw-web/bul ... f=1&t=7911

This was my first program for the VIC-20. To read the VIC joystick port up and down, I simply PEEKed 37137. I read that you are supposed to POKE 37154 before and after the joystick read, but I didn't have room for that, and it worked without it!

During development, I used emulation and a SD2IEC on my real VIC 20. For ECCC 2016, I tried to put the game on tape. The joystick didn't work!! :evil:

Then I discovered that if I stopped the tape drive after loading and tried, but failed, to load something off the disk drive, something was reset and my simple 10 line game worked again.

So, as an ugly hack, I made a loader that asks the user to stop the tape after loading and press return which tries to LOAD"*",30, which fails and then runs the game.
http://cloud.cbm8bit.com/jim_64/10%20run%2010.t64

As you can tell, I'm not sure what is going on here. Probably something with the state of the I/O chips.

Is there a better way to reset whatever after the tape load?
User avatar
tokra
Vic 20 Scientist
Posts: 1120
Joined: Tue Apr 27, 2010 5:32 pm
Location: Scheessel, Germany

Re: Weird joystick issue with ugly fix

Post by tokra »

Take a look here:

http://sleepingelephant.com/ipw-web/bul ... 89&p=79625

Basically your program assumes that it is loaded from disk and you check the joystick-direction-values accordingly. You coud just check for 118 and 122 instead and insert a SYS65017 at the start of your program. This will make sure it works from both tape and disk.

Maybe you can squeeze some more bytes to put this in there somewhere. Oh, BTW, instead of "GOTO0" you can just use "GOTO" - works the same.
jim_20
Vic 20 Newbie
Posts: 8
Joined: Wed Sep 17, 2014 7:38 pm

Re: Weird joystick issue with ugly fix

Post by jim_20 »

Thanks Tokra for the answer to my question plus a tip to eliminate one more character! I will try to fit it in there.
jim_20
Vic 20 Newbie
Posts: 8
Joined: Wed Sep 17, 2014 7:38 pm

Re: Weird joystick issue with ugly fix

Post by jim_20 »

Well I think I got this now. Bits in memory location 37137 toggle differently if the last load was from a disk, the cassette with play still down, or the cassette with played stopped. Since I'm reading the whole byte and not doing bitwise comparisons (to save code space), the byte value changes based on the prior load condition.

So I made a version that loads from tape as single 10 line program (leave play button down after load)
http://cloud.cbm8bit.com/jim_64/10rU10-vic-tap-p.prg

But this makes me really happy!! :mrgreen:
https://www.mdawson.net/vic20chrome/vic ... c-tp-s.prg
Post Reply