Question about ROM code

Basic and Machine Language

Moderator: Moderators

Post Reply
unebonnevie
Vic 20 Drifter
Posts: 35
Joined: Sat Oct 11, 2014 3:25 pm

Question about ROM code

Post by unebonnevie »

Hi,

I am looking to make a fun project by loading the ROM code into BLK5 area, that is, a cartridge that I put in any ROM code to run. Looking over the net, I see a lot of ROMs that end with .PRG (Program) extension and some end with .BIN (binary) extension.

If I were to directly dump into a flash IC, so that the VIC20 would recognize the ROM cartridge upon booting up or after a reset, I take I would use the .BIN ROM files?

Thanks!
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: Question about ROM code

Post by srowe »

Yes, you must have

$A000 - cold start address
$A002 - warm start address
$A004 - magic 'A0CBM' (with the top bit set of the last three chars)

A .PRG file has the load address as the first two bytes. That's only useful for tape/disk not ROM.
rhurst
Omega Star Commander
Posts: 1369
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Re: Question about ROM code

Post by rhurst »

A .prg file with the 2-byte load address into $A000 is still useful, as you can put an 8k RAM expansion into that block -- it's not only for ROM. If it's .bin (or .a0 or .rom) with the assumption of no 2-byte load address, then it's also assumed to be read-only.

So why the fuss by having two formats and enforcing read-only or read-write with this?

Mostly because of a (stupid) software copy-protection technique that might be in play. If a manufacturer sold a ROM cart, and it had an embedded instruction to WRITE, say a $00 which is a BRK opcode, to a read-only address, then the game would fail if it was a copy loaded into RAM expansion instead.
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
Post Reply