2 ; Atari startup system check
4 ; This routine gets loaded prior to the main part of the executable
5 ; and checks if the system is compatible to run the program.
6 ; For the XL target it checks whether the system is an XL type one
7 ; and that enough memory is installed (which isn't the case for a 600XL).
8 ; For the non-XL target it checks whether there is enough memory
9 ; installed to run the program.
10 ; For both targets it checks that the program won't load below MEMLO.
11 ; If one of the checks fails, the loading of the main program
12 ; is aborted by jumping to DOSVEC.
14 ; Christian Groessler, chris@groessler.org, 2013
19 .export __SYSTEM_CHECK__: absolute = 1
20 .import __SYSCHK_LOAD__
21 .import __STARTADDRESS__
23 ; the following imports are only needed for the 'atari' target version
24 .import __BSS_SIZE__, __BSS_RUN__
26 .import __RESERVED_MEMORY__
28 .include "zeropage.inc"
32 .macro print_string text
35 start: .byte text, ATEOL
36 cont: ldx #0 ; channel 0
50 .macro print_string2 addr, len
66 ; ------------------------------------------------------------------------
71 rts ; for older DOSes which unconditionally run the first load chunk
75 ; check for SpartaDOS and its usage of RAM below ROM
76 ; return CF 0/1 for bad/ok
79 bne sdcrts0 ; not SpartaDOS, assume RAM is not used
80 lda DOS+1 ; SD version
81 cmp #$40 ; SD-X has $40 or higher
82 bcc sdcrts1 ; older versions (except maybe 1.x) always use the RAM under the ROM
83 ldy #31 ; offset for OSRMFLG
84 lda (DOSVEC),y ; get OSRMFLG
93 .byte "Memory under ROM is in use.", ATEOL
94 .byte "Cannot run this program.", ATEOL
95 ramrom_txt_len = * - ramrom_txt
98 .byte "Not enough memory to move screen", ATEOL
99 .byte "memory to low memory. Consider using", ATEOL
100 .byte "a higher load address.", ATEOL
101 lmemerrxl_txt_len = * - lmemerrxl_txt
104 no_xl: print_string "This program needs an XL machine."
108 ; ***** entry point (atarixl) *****
110 syschk: lda $fcd8 ; from ostype.s
114 ; we have an XL machine, now check memory
121 sys_ok: jsr sdcheck ; check for SpartaDOS-X, and if found, whether it uses the RAM under the ROM
124 print_string2 ramrom_txt, ramrom_txt_len
127 sd_ok: .include "xlmemchk.inc" ; calculate lowest address we will use when we move the screen buffer down
135 ; load address was too low
136 print_string2 lmemerrxl_txt, lmemerrxl_txt_len
137 jsr delay ; long text takes longer to read, give user additional time
140 .else ; above 'atarixl', below 'atari'
142 .define CIOV_org CIOV ; the print_string macros use CIOV_org, map this to CIOV
145 .byte "Program would load below MEMLO.", ATEOL
146 .byte "Consider using a higher load address.", ATEOL
147 lmemerr_txt_len = * - lmemerr_txt
150 ; ***** entry point (atari) *****
155 sbc #<__RESERVED_MEMORY__
158 sbc #>__RESERVED_MEMORY__
168 ;tmp contains address which must be above .bss's end
171 cmp #<(__BSS_RUN__ + __BSS_SIZE__)
173 sbc #>(__BSS_RUN__ + __BSS_SIZE__)
175 bcc mem_err ; program doesn't fit into memory
178 cmp #<__STARTADDRESS__
180 sbc #>__STARTADDRESS__
183 ; load address was too low
184 print_string2 lmemerr_txt, lmemerr_txt_len
185 jsr delay ; long text takes longer to read, give user additional time
190 ; all is well(tm), launch the application
193 print_string "Stage #1 OK"
199 mem_err:print_string "Not enough memory."
226 tmp: ; outside of the load chunk, some kind of poor man's .bss
229 ; ------------------------------------------------------------------------
234 .word __SYSCHK_LOAD__
237 ; ------------------------------------------------------------------------
238 ; Chunk "trailer" - sets INITAD