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 ; ------------------------------------------------------------------------
74 .byte "Not enough memory to move screen", ATEOL
75 .byte "memory to low memory. Consider using", ATEOL
76 .byte "a higher load address.", ATEOL
77 lmemerrxl_txt_len = * - lmemerrxl_txt
80 no_xl: print_string "This program needs an XL machine."
84 ; ***** entry point (atarixl) *****
86 syschk: lda $fcd8 ; from ostype.s
90 ; we have an XL machine, now check memory
98 .include "xlmemchk.inc" ; calculate lowest address we will use when we move the screen buffer down
106 ; load address was too low
107 print_string2 lmemerrxl_txt, lmemerrxl_txt_len
108 jsr delay ; long text takes longer to read, give user additional time
111 .else ; above 'atarixl', below 'atari'
113 .define CIOV_org CIOV ; the print_string macros use CIOV_org, map this to CIOV
116 .byte "Program would load below MEMLO.", ATEOL
117 .byte "Consider using a higher load address.", ATEOL
118 lmemerr_txt_len = * - lmemerr_txt
121 ; ***** entry point (atari) *****
126 sbc #<__RESERVED_MEMORY__
129 sbc #>__RESERVED_MEMORY__
139 ;tmp contains address which must be above .bss's end
142 cmp #<(__BSS_RUN__ + __BSS_SIZE__)
144 sbc #>(__BSS_RUN__ + __BSS_SIZE__)
146 bcc mem_err ; program doesn't fit into memory
149 cmp #<__STARTADDRESS__
151 sbc #>__STARTADDRESS__
154 ; load address was too low
155 print_string2 lmemerr_txt, lmemerr_txt_len
156 jsr delay ; long text takes longer to read, give user additional time
161 ; all is well(tm), launch the application
164 print_string "Stage #1 OK"
170 mem_err:print_string "Not enough memory."
197 tmp: ; outside of the load chunk, some kind of poor man's .bss
200 ; ------------------------------------------------------------------------
205 .word __SYSCHK_LOAD__
208 ; ------------------------------------------------------------------------
209 ; Chunk "trailer" - sets INITAD