Bad joystick move on converted Tape games played from floppy

Discuss anything related to the VIC
Post Reply
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Bad joystick move on converted Tape games played from floppy

Post by nbla000 »

Sometimes, converting games from tape to floppy, i find games that don't work well and have some problem on joystick moves like go left and not right or similar.
The last one is Chomper, a Pac-Man clone for unexpanded Vic present in Zimmers archive in PRG format.
If you play it as is in PRG format from VICE the joystick moves are not correct, same if you start it from a D64 or D81 disk image but if you copy the program to a TAP image and load the game from it, the joystick moves are corrects. What may be the problem?

My work:
Download of Chomper.prg from Zimmers
Transfer of Chomper.prg to D64 using StarCommander
In VICE with 8k in bank 1, D64 image attached in drive 8 and a created empty TAP image attached too
LOAD"CHOMPER",8
SAVE"CHOMPER"

OK now if i attach the tape image and load it (without expansion) the games works properly conversely of the game loaded from Floppy.

I've tested it in real vic with a 1541, 1581 and datassette obtaining the same result.
User avatar
Schema
factor
Posts: 1430
Joined: Tue Mar 23, 2004 7:07 am
Website: http://www.jammingsignal.com
Location: Toronto, Ontario

Post by Schema »

It could be relying on a default value in the tape buffers or zero page, that would be set differently when loaded from floppy. Sloppy programming.

I ran into a couple of examples of this when testing JiffyDOS (which has no tape routunes). But nothing as severe as you describe.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Yes, in particular since both (!) VIAs are shared with cassette.

5 POKE37154,127
10 PRINTPEEK(37137);PEEK(37152):GOTO10

37137 is the port A output register on VIA #1
37139 is the port A data direction register on VIA #1 (normal = 128)
37152 is the port B output register on VIA #2
37154 is the port B data direction register on VIA #2 (normal = 255)

It appears like some of these tape loaders affect the VIA data direction registers, and the game then assumes a value. I saw this when I helped with one of the other games, but couldn't figure out quite what happened.
Anders Carlsson

Image Image Image Image Image
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

OK, after loading the game from TAPE these are the values:
37137 = 126
37139 = 128
37152 = 247
37154 = 255

and after loading the game from DISK these are the values:
37137 = 127 <== different value
37139 = 128
37152 = 247
37154 = 255

Using the Carlsson routine i've verified that the results of peek(37137) in UP/LEFT/DOWN moves if the program is loaded from floppy are 1 less than when you load from floppy, how i can obtain the same result using the floppy ? There is a way or you must hack the LM ?
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

126 = 0111 1110, 127 = 0111 1111

Bit 0 is set when there is a serial clock signal from the IEC bus. I'm not entirely sure, but I think you can clear it in this way:

LDA $9111
ORA #$01 (or #$03 if you want to clear both CLK and DATA)
STA $9111

Technically, maybe you can simply do LDA #$00 ; STA $9111 to clear that register upon loading.
Anders Carlsson

Image Image Image Image Image
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

after loading from tape or disk and before RUN (SYS4162)
i modify the program as you describe

Code: Select all

1000   AD 11 91   LDA $9111
1003   05 01      ORA $01
1005   8D 11 91   STA $9111
1008   4C 42 10   JMP $1042
and after SYS4096 to start.

but the problem is the same, there is a my mistake ?
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

ORA #$01 (immediate value), not ORA $01 (zeropage reference).
Anders Carlsson

Image Image Image Image Image
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

OPS! here new code but the problem is the same :(

Code: Select all

1000   AD 11 91   LDA $9111
1003   09 01      ORA #$01
1005   8D 11 91   STA $9111
1008   4C 42 10   JMP $1042
 
to start i use obviously SYS4096
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Hm. I'm not entirely sure what you safely can do with the VIA data direction register. At least I would leave bits 2-5 (joystick) alone, but perhaps something like this can work:

LDA #$83 ; enable bits 0 and 1 for output
STA $9113 ; 37139 = DDR
LDA #$7E ; 126
STA $9111 ; 37139 = data output register
LDA #$80
STA $9113 ; restore DDR to original value
JMP $1042

Better test it in emulation first. If it still doesn't solve your problem, I'm not sure how to fix it. My theory still is that the drive leaves a CLK signal that the VIA doesn't clear, but I don't know why and other programs loaded from disk should suffer similar issues.
Anders Carlsson

Image Image Image Image Image
User avatar
Schema
factor
Posts: 1430
Joined: Tue Mar 23, 2004 7:07 am
Website: http://www.jammingsignal.com
Location: Toronto, Ontario

Post by Schema »

I've just run into the same problem.

For me, it's the BASIC game "Downhill Skiing". Though I'm sure I played it from disk before. I thought it might have been caused by JiffyDOS, but turning it off still leaves the same problem. :?

All the PEEKs() to 37137 are wrong, off by 1 it seems. At least it's easy to change in the code, as long as whatever caused this doesn't flip back again!
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Did you try something like the above? It sounds like a CLK signal from the disk drive is left on the VIA chip after loading, but I'm not so technically skilled in this matter.
Anders Carlsson

Image Image Image Image Image
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

Schema wrote:I've just run into the same problem.
For me, it's the BASIC game "Downhill Skiing".
The zimmer PRG files seems doesn't have this problem

For Chomper i've solved using POKEs before RUN

LOAD"CHOMPER",8
POKE37139,131
POKE37137,126
RUN

Using the same method i've solved some other Tape games:

Hidden Maze
-----------------
POKE37139,131
POKE37137,62

Dodge Cars
-----------------
POKE37139,131
POKE37137,62

New York Blitz
-----------------
POKE37139,131
POKE37137,62

Thank's again Carlsson

Now i'm working in some other multiload protected TAP games, now it's time for Grid Trap downloaded from Arma's
Post Reply