Commodore 64 stuff

A friend of mine gave me his C64 recently (beginning of 2009, something like that).

I tried a few hacks with it.

Here they are.

1541 rom

Here is the rom of the 1541 I have. It's a late model, as one can see by comparing this rom with those available on the internet. Some patches have been made, mostly dealing with a bug in the rom. They use lda $ff,x which stays in page 0, which seems to be unwanted. Funny.

Some tools

c64hacks-1.0.tar.gz contains an assembler, a disassembler, a simulator, a tool to "speak out" a binary file (so you can type the program with your C64 without switching to the PC screen to read the bytes) (only french, but you can adapt easily), and few utilities to deal with D64 floppies.

Some code

The README from the file tests.tar.gz is reproduced below.

Ok, some stuff.
The most important are disk/1541_driver.s and disk/rom_reader.s
disk/1541_driver.s has to be loaded into the 1541. Then you
have to let the 1541 execute at address 500 (how you do that is explained
in some books available on the internet).
After that the 1541 cannot be used normally anymore.
disk/rom_reader.s has to be loaded in the memory of the C64 at address
c000. You must also load routines/printint.s at address c300.
Once again how you do that is well known in the internet.
Check my website (http://sed.free.fr/c64) for some links.

What these programs do?
My idea was to hack the 1541 to read/write MFM floppies (floppies from
PC). So I made a new communication protocol between the 1541 and
the C64. How does the protocol work? Well we have 3 lines. One for
data out, one for ack, one for data in. Data in/out are obviously
reversed for the C64 and the 1541. Then to transmit a byte of data,
you send the 8 bits the one after the other. You first set the bit
on data out, then you flip ack. Then you wait for ack to flip
again and you transmit the next bit. More or less. See the code to
get what bit does exactly what. We use clock, data, and attention
bits. Don't remember what does what. I know one bit is for C64->1541
link, one for 1541->C64 link, and one for ack. Or something like
that, I don't remember.

At startup the 1541 is waiting for a command, which is a byte.
Depending on this byte, it will do something, like receiving
an address and some data to store at the address or sending
a byte at a requested address, or turn the led on/off.

Anyway, I didn't go any further, by lack of motivation. The protocol
works. But routines to read/write MFM stuff have not been done
(and by the way I didn't read the documentation on how to access
the disk/motor stuff). I'm sure it would be easy to do. If someone
feels the need and wants to contribute...

Note that I don't think it's possible to read or write MFM stuff
with 360 RPM floppies, you need a 300 RPM one. See the site
of disk2fdi for gory details.

Links

We find a lot of books(!) on the internet to program a C64. That's amazing. I mean, young hackers generally start with a cheap computer and one or two books. Imagine what they could achieve with so much documentation available from scratch? Imagine what free software could create if well presented? We need good documentation to make good hackers, definitely.

Anyway, 25 years ago you had to pay for these books. So young hackers had to struggle hard to learn. And now, who would learn with a C64, huh? Nevertheless for old beards (like me!) this is cool to see so much stuff available.

So here come some cool links.

(This is the content of a file I use to store links for C64 stuff.)


http://www.bombjack.org/commodore/books.htm

	where "inside commodore DOS" can be downloaded
	many many books

http://www.commodore.ca/

	many many stuff
	there is: http://www.commodore.ca/manuals/1541_drive/1541_drive.htm
	with schematics of the 1541, inside construction and so on
	(in case the drive crashes)
	many manuals as well

http://project64.c64.org/hw/peri.html

	many docs on the c64
	c64.org is a good site as well

http://www.6502.org

	nice ressource as well

http://www.classiccmp.org/cini/systems.htm

	some docs on the c64
	especially "MCS6500 Microcomputer Family Hardware Manual" and
	"MCS6500 Microcomputer Family Programming Manual"

http://www.unusedino.de/ec64/technical/formats/g64.html

	raw format of a track (this file is in the local repository)

http://pinouts.ru/VideoCables/C128toScartSVideo_pinout.shtml

	pinout of video OUT/scart IN to connect the C64 to the TV
	beware the scrat pinout has to be taken as a "plug out"
	as found at http://www.hardwarebook.info/Video_to_TV_SCART
	(wires 1/2, 3/6, 17/18, 19/20 are reversed one by one)

http://www.fairlight.to/tools/pc.html

	some tools to read c64 floppies
	see also disk2fdi which actually works on my setup
	(and is a nice and dirty hack)


http://www.kjthacker.f2s.com/docs/upd765a/necfdc.htm

	commands of the FDC of the PC (nec 765)

http://www.oldlinux.org/Linux.old/study/hardware/Floppy/FLOPPY.txt

	more or less same stuff, text only


http://en.wikipedia.org/wiki/Group_Code_Recording

	how data is stored on a 1541 floppy

http://www.pcguide.com/ref/hdd/geom/dataFM-c.html

	FM encoding

http://www.pcguide.com/ref/hdd/geom/dataMFM-c.html


http://en.wikipedia.org/wiki/Modified_Frequency_Modulation

	MFM encoding


http://www.zimmers.net/anonftp/pub/cbm/manuals/anthology/p048.jpg

	raw disk sector format, the site has other docs and softs


http://www.kotinet.com/1541/

	an 1541 emulator for PC, just in case I get rid of
	the 1541 drive but still want one, emulated
	(contains a small prog to dump the 1541 rom)

Disk2fdi, a program to read C64 floppies with a PC. People long thought it was impossible. Well, it is possible, with a few tricks. (I could read C64 floppies successfully with disk2fdi).

Unfortunately you cannot write C64 floppies with a PC. So I wanted to hack the C64 to write PC floppies instead, so that it would have been possible to communicate through floppies between a C64 and a PC. But, as already written above, lack of motivation... I'm positively sure it's possible! If one wants to do it... (or if it has already been done, tell me, so I can put a link)


Contact: sed@free.fr

Created: Mon, 06 Jul 2009 17:03:23 +0200
Last update: Mon, 06 Jul 2009 17:03:23 +0200