1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
|