Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > CBM tape routines reverse engineering
2023-08-17 01:22
Fungus

Registered: Sep 2002
Posts: 617
CBM tape routines reverse engineering

I've spent a little over a week reverse engineering the CBM tape routines code. The read timing correction code is not entirely clear to me, I've made some guesses on how it works. Chuck Peddle never documented it, and in interviews he said 3 other Commodore programmers were supposed to do so and never did. With his passing I guess it would never get done, so I took it upon myself to do so. It's one of the last things about the C64 that is currently not completely documented, or not to a level that I feel it deserves.

I've messaged enthusi, but he doesn't seem to be about to have a look at it. I was wondering if any of the other expert coders would like to take a look privately and go over it looking for errors or adding any additional knowledge to it before I package it up in a document to release publicly.

Full acknowledgement and credit for any help/feedback will be added with gratitude.

Shoot me a message or reply if anyone is willing to have a go.
 
... 3 posts hidden. Click here to view all posts....
 
2023-08-17 12:38
Martin Piper

Registered: Nov 2007
Posts: 634
Tape with full $89-$81/$09-$01 countdown headers...
..\..\bin\TapeTool.exe wn "test.tap" ocl$6a10 ocn $89 $88 $87 $86 $85 $84 $83 $82 $81 ocnr $03 $00 $04 $07 $04 @"Loaders.bin" 0 187 ! oce ocl$4f ocn $9 $8 $7 $6 $5 $4 $3 $2 $1 ocnr $03 $00 $04 $07 $04 @"Loaders.bin" 0 187 ! oce ocl$1500 ocn $89 $88 $87 $86 $85 $84 $83 $82 $81 ocnr $00 $01 $02 $03 $04 $05 $06 ! oce ocl$4f ocn $9 $8 $7 $6 $5 $4 $3 $2 $1 ocnr $00 $01 $02 $03 $04 $05 $06 ! oce ocl$1500 c


Tape with just $81/$01 as the headers...
..\..\bin\TapeTool.exe wn "test.tap" ocl$6a10 ocn $81 ocnr $03 $00 $04 $07 $04 @"Loaders.bin" 0 187 ! oce ocl$4f ocn $1 ocnr $03 $00 $04 $07 $04 @"Loaders.bin" 0 187 ! oce ocl$1500 ocn $81 ocnr $00 $01 $02 $03 $04 $05 $06 ! oce ocl$4f ocn $1 ocnr $00 $01 $02 $03 $04 $05 $06 ! oce ocl$1500 c

Both will load.
2023-08-17 13:29
Martin Piper

Registered: Nov 2007
Posts: 634
Creating long tapes with just short or medium pulses, the adjustment value in $b0 remains within a narrow range, $fe-$01.

However if the tape just contains long pulses, the $b0 adjustment value quickly escapes the normal range and starts rapidly increasing way beyond what would be considered to be normal.

This behaviour indicates the kernal is able to differentiate and calibrate on short and medium pulses, but cannot handle calibration using repeated long pulses.
2023-08-17 20:18
Fungus

Registered: Sep 2002
Posts: 617
The timing delta is calculated based on drift from the mean time for each pulse. I believe the multiplication by 4 is to account for the load instruction, which 1 cycle = 4 cycles. Basically it tries to keep the deviation between wow/flutter inside a center range. It can adjust the timing in either direction. It can compensate for tapes saved with any commodore computer on any video standard. The PET, VIC20 and C128 all have different timings to a C64 and depending on region. The loader can compensate for all of them. It can change during loading too but only if the loader detects a pair of long pulses, which are also added to each file between each copy of the file and between each file.
2023-08-17 22:22
Martin Piper

Registered: Nov 2007
Posts: 634
There are some multiplies in there but doesn't seem to be any mean calculation. It just nudges the adjustment to fit the recent measurement.
2023-08-18 04:49
Martin Piper

Registered: Nov 2007
Posts: 634
The "adjustment code" at $f9d5 reads the accumulated value from $92, if it's zero then it doesn't change the adjustment value.
Otherwise it nudges (+/- 1) the adjustment value at $b0, based on if the value at $92 is positive or negative, and then resets the accumulated value at $92 to zero.

The "adjustment code" is executed every other bit received from the tape by the $f9a4 eor and $f9a8 beq test.

This means the accumulated value in $92 has two "variations between received and expected" timings accumulated into it.
2023-08-18 07:34
Fungus

Registered: Sep 2002
Posts: 617
OK, then my guesses are correct.

Never thought I would be thanking you, but thanks.
2023-08-18 12:36
Oswald

Registered: Apr 2002
Posts: 5017
ammazing I have no idea what you are talking about
2023-08-18 22:24
Fungus

Registered: Sep 2002
Posts: 617
I'll post the document later when I convert it to PDF, I still want to go over it a bit first. It's basically a raw commented disasm with some other info on structure.

I want to work out a flow chart for the code so that I understand it completely first.
2023-08-20 18:37
Richard

Registered: Dec 2001
Posts: 619
Intriguing :) Are you intending to make a tape turbo yourself?
2023-08-20 20:32
Fungus

Registered: Sep 2002
Posts: 617
I've made several tape turbos. I've documented dozen of loaders and cracked thousands of tapes (but never released much of them).

I might make a new one that's fast but works somewhat like bleepload and mixed with other stuff that the modern games can use to make the "cracking" scene work a little bit.
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
CA$H/TRiAD
Steveboy
iceout/Avatar/HF
K-reator/CMS/F4CG
Scooby/G★P/Light
Guests online: 110
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Logo Graphicians
1 Sander  (10)
2 Facet  (9.7)
3 Mermaid  (9.4)
4 Pal  (9.4)
5 Shine  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.041 sec.