aboutsummaryrefslogtreecommitdiff
path: root/loader.s
diff options
context:
space:
mode:
Diffstat (limited to 'loader.s')
-rw-r--r--loader.s114
1 files changed, 114 insertions, 0 deletions
diff --git a/loader.s b/loader.s
new file mode 100644
index 0000000..3b78fbd
--- /dev/null
+++ b/loader.s
@@ -0,0 +1,114 @@
+; Use CIO to set up S: as GR.8 or GR.15
+; Relocatable code.
+; Assemble with:
+; cl65 -t none -o loader.xex loader.s
+
+ .include "atari.inc"
+
+dataptr = FR0
+tmp = FR0+2
+
+start = $0400
+
+; segment header
+ .org start-6
+ .word $FFFF
+ .word start
+ .word endmain-1
+
+ .org start
+ .byte $c0 ; default RAMTOP
+ .byte $0f ; GR. mode (8 or 15)
+ .byte $04 ; COLOR0 (01 pixels in GR.15)
+ .byte $08 ; COLOR1 (10 pixels in GR.15, 1 pixels in GR.8)
+ .byte $0c ; COLOR2 (11 pixels in GR.15, 0 pixels in GR.8)
+ .byte $00 ; COLOR3 (unused)
+ .byte $00 ; COLOR4 (00 pixels in GR.15, border in GR.8)
+ .byte $22 ; SDMCTL ($21 for narrow, $22 for normal)
+
+main:
+; find our datablock's start address. this song and dance routine
+; allows us to be fully relocatable, and have all the data in a
+; single block (easily modified by the shell script that uses this).
+
+ sei ; disable interrupts so they don't clobber the stack
+ lda #$00
+ sta NMIEN
+ lda #$60 ; RTS opcode
+ sta dataptr
+ jsr dataptr
+ret: ; here is where the RTS returns to
+
+; address is now in the stack area, fix it up and save it
+ tsx
+ dex
+ lda $100,x ; lo byte
+ sec
+ sbc #ret-start-1
+ sta dataptr
+ lda $101,x ; hi byte
+ sbc #0
+ sta dataptr+1 ; $d4/$d5 is now a pointer to 'start'
+
+ cli ; re-enable interrupts
+ lda #$40
+ sta NMIEN
+
+; set RAMTOP
+ ldy #0
+ lda (dataptr),y
+ sta RAMTOP
+
+; close device #6
+ ldx #$60
+ lda #CLOSE
+ sta ICCOM,x
+ jsr CIOV
+
+; open device #6 (GRAPHICS command basically)
+ ldx #$60
+ lda #$0c ; read/write, no +16 or +32
+ sta ICAX1,x
+ ldy #$01
+ lda (dataptr),y
+ sta ICAX2,x ; just the mode (8 or 16)
+ lda #OPEN
+ sta ICCOM,x
+ lda #'S'
+ sta tmp
+ lda #<tmp
+ sta ICBAL,x
+ lda #>tmp
+ sta ICBAH,x
+ jsr CIOV
+
+; set up color regs
+ ldy #$02
+cloop:
+ lda (dataptr),y
+ sta COLOR0-2,y
+ iny
+ cpy #$07
+ bne cloop
+
+; set up display width
+ lda (dataptr),y
+ sta SDMCTL
+
+ rts
+;;; put some stuff in screen RAM so we can see it
+;; lda #$ff
+;; sta $a150
+;; lda #$aa
+;; sta $a151
+;; lda #$55
+;; sta $a152
+;;hang: jmp hang
+
+endmain:
+
+; segment header
+ .word INITAD
+ .word INITAD+1
+ .word main
+