aboutsummaryrefslogtreecommitdiff
path: root/checkmem.s
blob: a87bbd299683baa19550b74ac0bba3bccd37b877 (plain)
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

; initial load segment for taipan. intended to be a tiny (1-sector)
; routine that checks for the presence of BASIC or a cartridge, and aborts
; the load if found. Also, it resets RAMTOP to RAMSIZ and does a GRAPHICS
; 0, to avoid problems with funky loaders leaving the graphics screen
; in the wrong place (Atarimax flash cart leaves it at $9cxx) or in the
; wrong graphics mode (Fenders 3-sector loader doesn't set up GR.0).

; cl65 -o checkmem.xex -t none checkmem.s

 .include "atari.inc"

start = $0600 ; use page 6 for now

 .word $ffff
 .word start
 .word end-1

 .org start

; message is "Need 48K, remove cartridge" in screen codes.
msg:
 .byte $2e, $65, $65, $64, $00, $14, $18, $2b
 .byte $0c, $00, $72, $65, $6d, $6f, $76, $65
 .byte $00, $63, $61, $72, $74, $72, $69, $64
 .byte $67, $65
msglen = * - msg - 1

S: .byte "S:",0
init:
 lda RAMSIZ
 cmp #$c0
 php
 sta RAMTOP

 ldx #6*$10 ; CLOSE #6
 lda #CLOSE
 sta ICCOM,x
 jsr CIOV

 ; GRAPHICS 0
 ldx #6*$10 ; IOCB #6
 lda #OPEN
 sta ICCOM,x
 lda #$1c ; $c = read/write
 sta ICAX1,x
 lda #0   ; aux2 byte zero
 sta ICAX2,x
 lda #<S
 sta ICBAL,x
 lda #>S
 sta ICBAH,x
 jsr CIOV

 plp
 bcc have_cart

 ; if RAM size is $c000 or higher, we're OK, just exit.
 rts

have_cart:
 ; if RAM size is below $c000, we have a cartridge (or XL BASIC).
 ; print the "remove cart" message...
 lda #<msg
 sta FR0
 lda #>msg
 sta FR0+1

 ldy #msglen
msgloop:
 lda (FR0),y
 sta (SAVMSC),y
 dey
 bpl msgloop

 sty CH ; y == $ff at this point, clear keyboard
 ; ...wait for a keystroke...
wait4key:
 cpy CH
 beq wait4key

 ; ...and do a warmstart.
 jmp WARMSV

end:
 .word INITAD
 .word INITAD+1
 .word init