Code64 logo
 

Assembling your own cart ROM image

Cartridge ROM images are burnt or flashed into ROM/flash chips. The file formats of the ROM images vary, but common formats are either raw binary dumps or the special .crt file format.

Most emulators can handle both of these formats, and hardware such as Retro Replay and 1541U with flash ROM can be used if you want to run your cartridge image on the real hardware without having a EPROM burner or other special hardware.

Suitable assemblers for cartridge ROM development

Most assemblers can be used to write your own cartridge ROM, but some are more suitable than others. For example, if you are planning to write a cartridge ROM that uses more than one ROM bank, you might want to use an assembler that, in one way or another, supports writing several segments that have the same start address. DreamAss deserves a special comment here since it has even more features in this direction. In addition to plain support of segments, it also has:

  • a pseudo op that returns the bank number of a symbol. this makes it very easy to build tables with bank/address for a cross-bank-call-api
  • the assembler can put functions into banks as they fit automatically, so you don't have to worry about memory layout.

Simple cartridge skeleton sources

Here are two small sources from the net that might help you to get up and running with an autostarting cartridge.

CBM80 Autostart Cartridge

Version 1.0

By Alphaworks (?)

CHRGET    = $0073
TXTPTR    = $7A
IERROR    = $0300
IMAIN     = $0302
IGONE     = $0308
GONE      = $A7E4
CHKCOM    = $AEFD
FRMNUM    = $AD8A
GETADR    = $B7F7
CHROUT    = $FFD2
BORDER    = $D020
SCREEN    = $D021
TEXT	  = $0286


	* = $8000

	.BYTE	$09, $80			; Cartridge cold-start vector = $8009
	.BYTE	$25, $80			; Cartridge warm-start vector = $8025
	.BYTE	$C3, $C2, $CD, $38, $30		; CBM8O - Autostart key


;	KERNAL RESET ROUTINE
	STX $D016				; Turn on VIC for PAL / NTSC check
	JSR $FDA3				; IOINIT - Init CIA chips
	JSR $FD50				; RANTAM - Clear/test system RAM
	JSR $FD15				; RESTOR - Init KERNAL RAM vectors
	JSR $FF5B				; CINT   - Init VIC and screen editor
	CLI					; Re-enable IRQ interrupts


;	BASIC RESET  Routine

	JSR $E453				; Init BASIC RAM vectors
	JSR $E3BF				; Main BASIC RAM Init routine
	JSR $E422				; Power-up message / NEW command
	LDX #$FB
	TXS					; Reduce stack pointer for BASIC

	
;	START YOUR PROGRAM HERE ($8025)

    LDA #4		; CHANGE BORDER COLOUR TO 
    STA BORDER		; BLACK
    LDA #147		; PRINT CHR$(147) TO CLEAR
    JSR CHROUT		; SCREEN
    RTS

Copy a program from ROM to RAM and autostart it

By Enthusi

Taken from this CSDb discussion thread.

This code is used to create a .crt ROM image which includes a copy of an executable program. When started, the code in the ROM copies the program to C64 RAM (from $0801) and executes it. The cart-reset-routine copies the “launcher” to $0400, executes it and somewhere near $0430 it says JMP $080b.

These CRTs will run in VICE and MMCR Bios 0.55 - source is in XA syntax

;this is for a 8KB cart!!
*=$0000
	.asc "C64 CARTRIDGE "
	.byte $00,$00 ;header length
	.byte $00,$40 ;header length
	.word $0001 ;version
	.word $0000 ;crt type
	.byte $00 ;exrom line
	.byte $01 ;game line
	.byte $00,$00,$00,$00,$00,$00 ;unused
	.asc "CRT TITLE"
name
	.dsb ($0040-name),0
	;chip packets
	.asc "CHIP"
	.byte $00,$00,$20,$10 ;chip length
	.byte $00,$00 ;chip type
	.byte $00,$00 ;bank
	.byte $80,$00 ;adress
	.byte $20,$00 ;length
	
;ROM part
;---------------------------------
*=$8000
	.word launcher
	.word launcher
	.byte $c3 ;c
	.byte $c2 ;b
	.byte $cd ;m
	.byte $38 ;8
	.byte $30 ;0

launcher
	sei
	stx $d016
	jsr $fda3 ;prepare irq
	jsr $fd50 ;init memory
	jsr $fd15 ;init i/o
	jsr $ff5b ;init video
	cli
	;jsr $e453 ;load basic vectors
	;jsr $e3bf ;init basic ram
	;jsr $a68e
	;jmp $a7ae

	;ldx #$fb
	; txs
;---------------------------------
start_all
	lda $d011
	and #%11101111
	sta $d011

	ldx #$00
	sa1
	lda movecode1,x
	sta $0400,x
	inx
	bne sa1
	jmp $0400
;------------------------------
movecode1

	*=$0400
movecode2
	basic_move
	ldx #$00
	bm1
	lda main_file_start,x
	bm2
	sta $0801,x
	inx
	bne bm1
	inc bm1+2
	inc bm2+2
	lda bm1+2
	cmp #$c0
	bne basic_move
	jmp $080b
movecode3
;---------------------------------
	*=movecode1+(movecode3-movecode2)

main_file_start
	.bin 2,0,"game.bin"
main_file_end

	.dsb ($a000-main_file_end),0
 
base/assembling_your_own_cart_rom_image.txt · Last modified: 2009/03/03 02:23 by ftc
 
Code64 logo
Recent changes RSS feed Creative Commons License Driven by DokuWiki