aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bigint48.s6
-rw-r--r--cartname_5200.s14
-rw-r--r--cartyear_5200.s11
-rw-r--r--crt0_5200.s183
-rw-r--r--hello52.c20
5 files changed, 232 insertions, 2 deletions
diff --git a/bigint48.s b/bigint48.s
index 1971af2..d8fdb2b 100644
--- a/bigint48.s
+++ b/bigint48.s
@@ -3,8 +3,10 @@
; the Atari 800/XL/XE build doesn't use this, it's only for
; the 5200 (though the A8 build can be tested with it).
-; .include "atari.inc" ; don't include atari.inc on the 5200, I'll get confused.
- FR0 = $d4 ; this is the only label we need from atari.inc
+; .include "atari.inc" ; don't include atari.inc on the 5200,
+ ; I'll get confused even if ca65 doesn't.
+ FR0 = $d4 ; this is the only label we need from atari.inc. on
+ ; the 5200, $d4 and up are free zero page.
.export _big_copy, _ulong_to_big, _big_cmp, _big_to_ulong, _big_add, _big_sub, _big_negate
.export _big_div, _big_mul
diff --git a/cartname_5200.s b/cartname_5200.s
new file mode 100644
index 0000000..412afaa
--- /dev/null
+++ b/cartname_5200.s
@@ -0,0 +1,14 @@
+; default cartridge name
+;
+; Christian Groessler, 01-Mar-2014
+; modified for taipan
+
+; anything in CAPS will rotate colors
+
+.include "atari.mac"
+
+.export __CART_NAME__: absolute = 1
+
+.segment "CARTNAME"
+
+ scrcode " taipan ALPHA "
diff --git a/cartyear_5200.s b/cartyear_5200.s
new file mode 100644
index 0000000..e5f1b40
--- /dev/null
+++ b/cartyear_5200.s
@@ -0,0 +1,11 @@
+; Cartridge copyright year
+;
+; Christian Groessler, 01-Mar-2014
+
+; modified for taipan
+
+.export __CART_YEAR__: absolute = 1
+
+.segment "CARTYEAR"
+
+ .byte $ff, $ff ; $ff in 2nd byte means diagnostic cart
diff --git a/crt0_5200.s b/crt0_5200.s
new file mode 100644
index 0000000..5210ec1
--- /dev/null
+++ b/crt0_5200.s
@@ -0,0 +1,183 @@
+;
+; Startup code for cc65 (Atari5200 version)
+;
+; Christian Groessler (chris@groessler.org), 2014
+
+; modified for taipan, to work as a diagnostic cart.
+; contains code adapted from the 5200 OS ROM.
+
+ .export _exit, start
+ .export __STARTUP__ : absolute = 1 ; Mark as startup
+ .import __RAM_START__, __RAM_SIZE__
+ .import __RESERVED_MEMORY__
+
+ .import initlib, donelib, callmain
+ .import zerobss, copydata
+
+ .include "zeropage.inc"
+ .include "atari5200.inc"
+
+;;; start of (slightly modified) OS ROM code. the OS calls us with
+;;; interrupts disabled, decimal mode cleared, with the stack pointer
+;;; set to $FF. Since this is a diagnostic cart, we have to init the
+;;; hardware and set up the interrupt vector table at $0200 (the OS
+;;; doesn't do it for us, like it would for a non-diag cart).
+
+;;; This code is based on Dan Boris's commented disassembly of the 4-port
+;;; 5200 BIOS, retrieved from <http://atarihq.com/danb/files/5200BIOS.txt>.
+
+;;; I've copied just the initialization code, minus the logo/copyright
+;;; screen, and modified it to work with either OS revision.
+
+;;; Everything I've read tells me that the 4-port OS will work on a 2-port
+;;; machine (the hardware changes don't break compatibility), so the code
+;;; here comes from the 4-port OS.
+
+; I've gone to a lot of trouble to get the vectors and display list
+; set up correctly for either ROM revision... but the display list, at
+; least, was really a waste of time: conio is going to set up a GR.1
+; display list... at least until I modify it to use GR.0 instead.
+
+start:
+ ldx #0
+ txa
+@clrloop:
+ sta POKEY,x ;Clear POKEY registers
+ sta GTIA,x ;Clear GTIA registers
+ sta ANTIC,x ;Clear ANTIC registers
+ sta $00,x ;Clear zero page
+ inx
+ bne @clrloop
+ lda #$F8
+ sta CHBASE ;Set Character base to $F800
+
+; determine which OS revision we're running under. This affects
+; the locations of the vector table and display list in the ROM,
+; and is probably the reason a few published 5200 games are
+; incompatible with the Rev A ROM.
+; rev A has $07 at $fee5, original OS has $61. If there are other
+; OS revisions out there in the wild, this code will likely fail
+; on them.
+
+ lda #$fe
+ sta $fb
+; sta $fd
+; sta $ff
+ lda $fee5
+ cmp #$07
+ beq @rev_a
+
+ ; set up $fa to point to vector table,
+ ; $fc to point to display list start,
+ ; $fe to point to DL end.
+
+ ; old OS:
+ lda #$95
+ sta $fa
+; lda #$c8
+; sta $fc
+; lda #$cf
+; sta $fe
+ bne @copy_vectors
+
+@rev_a:
+ lda #$ab
+ sta $fa
+; lda #$de
+; sta $fc
+; lda #$e5
+; sta $fe
+
+@copy_vectors:
+ ldy #$0B
+@cploop:
+ lda ($fa),y
+ sta VIMIRQ,y ;Copy vectors to vector table
+ dey
+ bpl @cploop
+
+ lda #$3C ;Set pointer to $3C00
+ sta $12
+ lda #$00
+ sta $11
+
+ ldx #$0C
+ tay
+@vecloop:
+ sta ($11),y
+ dey
+ bne @vecloop
+ dec $12
+ dex
+ bpl @vecloop
+
+;;; taipan doesn't need the OS-provided display list.
+;;; conio init will set up a GR.1 DL (at least, until
+;;; I modify it to the GR.0 that taipan needs)
+;Build display list
+; lda #$0D ;Antic mode 13
+; ldx #$4D
+;@dl13loop:
+; sta $2007,x ;write to display list
+; dex
+; bpl @dl13loop
+;
+; ldy #$06 ;Copy start of display list
+;@dlloop:
+; lda ($fc),y
+; sta $2000,y
+; dey
+; bpl @dlloop
+;
+; ldy #$04 ;Copy end of display list
+;@dlendloop:
+; lda ($fe),y
+; sta $2055,y
+; dey
+; bpl @dlendloop
+;
+; lda #$00 ;Set Display List pointer to $2000
+; sta $05
+; lda #$20
+; sta $06
+
+ lda #$22 ;Set DMACTL, dlist on/normal background
+ sta SDMCTL
+
+ lda #$C0
+ sta NMIEN ;Enable DLI and VBI
+ lda #$02
+ sta SKCTL ;Enable Keyboard scanning
+
+ .out .sprintf("%d bytes", * - start)
+;;; end of OS ROM code, rest of file is standard 5200 crt0.s.
+
+; Clear the BSS data.
+
+ jsr zerobss
+
+; Initialize the data.
+ jsr copydata
+
+; Set up the stack.
+
+ lda #<(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
+ sta sp
+ lda #>(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
+ sta sp+1 ; Set argument stack ptr
+
+; Call the module constructors.
+
+ jsr initlib
+
+; Push the command-line arguments; and, call main().
+
+ jsr callmain
+
+; Call the module destructors. This is also the exit() entry.
+
+_exit: jsr donelib ; Run module destructors
+
+; A 5200 program isn't supposed to exit.
+
+halt: jmp halt
diff --git a/hello52.c b/hello52.c
new file mode 100644
index 0000000..eba835d
--- /dev/null
+++ b/hello52.c
@@ -0,0 +1,20 @@
+/*
+ build as a 32K diagnostic cart:
+ cl65 -m hello52.map -t atari5200 -Wl -D__CARTSIZE__=0x8000 -o 1.bin hello52.c cartname_5200.s cartyear_5200.s crt0_5200.s
+
+ run with original OS:
+ atari800 -5200 -cart-type 4 -cart 1.bin
+
+ or run with rev A:
+ atari800 -5200 -5200-rev a -cart-type 4 -cart 1.bin
+
+*/
+
+#include <conio.h>
+
+int main(void) {
+ gotoxy(5, 11);
+ cputs("HELLO WORLD");
+hang: goto hang;
+ return 0;
+}