.segment "SYSCHK"
+ rts ; for older DOSes which unconditionally run the first load chunk
+
.ifdef __ATARIXL__
+; check for SpartaDOS and its usage of RAM below ROM
+; return CF 0/1 for bad/ok
+sdcheck:lda DOS
+ cmp #'S'
+ bne sdcrts0 ; not SpartaDOS, assume RAM is not used
+ lda DOS+1 ; SD version
+ cmp #$40 ; SD-X has $40 or higher
+ bcc sdcrts1 ; older versions (except maybe 1.x) always use the RAM under the ROM
+ ldy #31 ; offset for OSRMFLG
+ lda (DOSVEC),y ; get OSRMFLG
+ bne sdcrts1
+
+sdcrts0:clc
+ rts
+sdcrts1:sec
+ rts
+
+ramrom_txt:
+ .byte "Memory under ROM is in use.", ATEOL
+ .byte "Cannot run this program.", ATEOL
+ramrom_txt_len = * - ramrom_txt
+
lmemerrxl_txt:
.byte "Not enough memory to move screen", ATEOL
.byte "memory to low memory. Consider using", ATEOL
jmp mem_err
-sys_ok:
- .include "xlmemchk.inc" ; calculate lowest address we will use when we move the screen buffer down
+sys_ok: jsr sdcheck ; check for SpartaDOS-X, and if found, whether it uses the RAM under the ROM
+ bcc sd_ok
+
+ print_string2 ramrom_txt, ramrom_txt_len
+ jmp fail
+
+sd_ok: .include "xlmemchk.inc" ; calculate lowest address we will use when we move the screen buffer down
lda MEMLO
cmp lowadr