2013-05-30 00:33:09 +00:00
|
|
|
;
|
2013-10-03 22:53:34 +00:00
|
|
|
; Atari startup system check
|
2013-05-30 00:33:09 +00:00
|
|
|
;
|
|
|
|
; This routine gets loaded prior to the main part of the executable
|
|
|
|
; and checks if the system is compatible to run the program.
|
2013-10-03 22:53:34 +00:00
|
|
|
; For the XL target it checks whether the system is an XL type one
|
|
|
|
; and that enough memory is installed (which isn't the case for a 600XL).
|
|
|
|
; For the non-XL target it checks whether there is enough memory
|
|
|
|
; installed to run the program.
|
2013-10-16 15:55:45 +00:00
|
|
|
; For both targets it checks that the program won't load below MEMLO.
|
|
|
|
; If one of the checks fails, the loading of the main program
|
2013-05-30 00:33:09 +00:00
|
|
|
; is aborted by jumping to DOSVEC.
|
|
|
|
;
|
|
|
|
; Christian Groessler, chris@groessler.org, 2013
|
|
|
|
;
|
|
|
|
|
2013-09-27 20:14:26 +00:00
|
|
|
;DEBUG = 1
|
2013-06-12 23:07:40 +00:00
|
|
|
|
2019-02-18 03:26:01 +00:00
|
|
|
.export __SYSTEM_CHECK__, __SYSCHK_END__
|
2013-10-03 22:53:34 +00:00
|
|
|
.import __STARTADDRESS__
|
|
|
|
|
|
|
|
; the following imports are only needed for the 'atari' target version
|
|
|
|
.import __BSS_SIZE__, __BSS_RUN__
|
|
|
|
.import __STACKSIZE__
|
|
|
|
.import __RESERVED_MEMORY__
|
2013-05-30 00:33:09 +00:00
|
|
|
|
2019-02-18 03:26:01 +00:00
|
|
|
; import our header and trailers
|
|
|
|
.forceimport __SYSCHKHDR__, __SYSCHKTRL__
|
|
|
|
|
2013-05-30 00:33:09 +00:00
|
|
|
.include "zeropage.inc"
|
|
|
|
.include "atari.inc"
|
|
|
|
|
|
|
|
.macro print_string text
|
2013-09-27 20:01:54 +00:00
|
|
|
.local start, cont
|
|
|
|
jmp cont
|
|
|
|
start: .byte text, ATEOL
|
|
|
|
cont: ldx #0 ; channel 0
|
|
|
|
lda #<start
|
|
|
|
sta ICBAL,x ; address
|
|
|
|
lda #>start
|
|
|
|
sta ICBAH,x
|
|
|
|
lda #<(cont - start)
|
|
|
|
sta ICBLL,x ; length
|
|
|
|
lda #>(cont - start)
|
|
|
|
sta ICBLH,x
|
|
|
|
lda #PUTCHR
|
|
|
|
sta ICCOM,x
|
|
|
|
jsr CIOV_org
|
2013-05-30 00:33:09 +00:00
|
|
|
.endmacro
|
|
|
|
|
2013-10-16 15:55:45 +00:00
|
|
|
.macro print_string2 addr, len
|
2013-09-27 20:01:54 +00:00
|
|
|
ldx #0 ; channel 0
|
|
|
|
lda #<addr
|
|
|
|
sta ICBAL,x ; address
|
|
|
|
lda #>addr
|
|
|
|
sta ICBAH,x
|
|
|
|
lda #<len
|
|
|
|
sta ICBLL,x ; length
|
|
|
|
lda #>len
|
|
|
|
sta ICBLH,x
|
|
|
|
lda #PUTCHR
|
|
|
|
sta ICCOM,x
|
|
|
|
jsr CIOV_org
|
2013-05-30 00:33:09 +00:00
|
|
|
.endmacro
|
|
|
|
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
2013-10-03 22:53:34 +00:00
|
|
|
; code
|
2013-05-30 00:33:09 +00:00
|
|
|
|
2013-10-03 22:53:34 +00:00
|
|
|
.segment "SYSCHK"
|
2013-05-30 00:33:09 +00:00
|
|
|
|
2018-09-11 23:05:52 +00:00
|
|
|
rts ; for older DOSes which unconditionally run the first load chunk
|
|
|
|
|
2013-10-03 22:53:34 +00:00
|
|
|
.ifdef __ATARIXL__
|
2013-05-30 00:33:09 +00:00
|
|
|
|
2018-09-11 23:05:52 +00:00
|
|
|
; check for SpartaDOS and its usage of RAM below ROM
|
2018-09-11 23:20:12 +00:00
|
|
|
; return CF 0/1 for ok/bad
|
2018-09-11 23:05:52 +00:00
|
|
|
sdcheck:lda DOS
|
|
|
|
cmp #'S'
|
|
|
|
bne sdcrts0 ; not SpartaDOS, assume RAM is not used
|
2018-09-27 15:37:59 +00:00
|
|
|
|
|
|
|
; check for BW-DOS, which always reports itself as SpartaDOS, but doesn't use memory under the ROM
|
|
|
|
lda DOS+3 ; 'B' in BW-DOS
|
|
|
|
cmp #'B'
|
|
|
|
bne sdnobw
|
|
|
|
lda DOS+4 ; 'W' in BW-DOS
|
|
|
|
cmp #'W'
|
|
|
|
beq sdcrts0 ; BW-DOS does not use RAM below ROM
|
|
|
|
|
|
|
|
sdnobw: lda DOS+1 ; SD version
|
2018-09-11 23:05:52 +00:00
|
|
|
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
|
|
|
|
|
2013-10-03 22:53:34 +00:00
|
|
|
lmemerrxl_txt:
|
|
|
|
.byte "Not enough memory to move screen", ATEOL
|
|
|
|
.byte "memory to low memory. Consider using", ATEOL
|
|
|
|
.byte "a higher load address.", ATEOL
|
|
|
|
lmemerrxl_txt_len = * - lmemerrxl_txt
|
2013-05-30 00:33:09 +00:00
|
|
|
|
2013-09-13 16:28:17 +00:00
|
|
|
; no XL machine
|
2013-09-27 20:01:54 +00:00
|
|
|
no_xl: print_string "This program needs an XL machine."
|
|
|
|
jmp fail
|
2013-09-13 16:28:17 +00:00
|
|
|
|
2013-10-03 22:53:34 +00:00
|
|
|
|
|
|
|
; ***** entry point (atarixl) *****
|
|
|
|
|
|
|
|
syschk: lda $fcd8 ; from ostype.s
|
2013-05-30 00:33:09 +00:00
|
|
|
cmp #$a2
|
2013-09-13 16:28:17 +00:00
|
|
|
beq no_xl
|
2013-05-30 00:33:09 +00:00
|
|
|
|
|
|
|
; we have an XL machine, now check memory
|
2013-09-27 20:01:54 +00:00
|
|
|
lda RAMSIZ
|
|
|
|
cmp #$80
|
|
|
|
bcs sys_ok
|
2013-05-30 00:33:09 +00:00
|
|
|
|
2013-10-03 22:53:34 +00:00
|
|
|
jmp mem_err
|
2013-05-30 00:33:09 +00:00
|
|
|
|
2018-09-11 23:05:52 +00:00
|
|
|
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
|
2013-05-30 00:33:09 +00:00
|
|
|
|
2013-09-27 20:01:54 +00:00
|
|
|
lda MEMLO
|
2013-10-04 10:40:35 +00:00
|
|
|
cmp lowadr
|
2013-09-27 20:01:54 +00:00
|
|
|
lda MEMLO+1
|
|
|
|
sbc lowadr+1
|
|
|
|
bcc memlo_ok
|
2013-05-30 00:33:09 +00:00
|
|
|
|
2013-10-03 22:53:34 +00:00
|
|
|
; load address was too low
|
|
|
|
print_string2 lmemerrxl_txt, lmemerrxl_txt_len
|
|
|
|
jsr delay ; long text takes longer to read, give user additional time
|
|
|
|
jmp fail
|
|
|
|
|
|
|
|
.else ; above 'atarixl', below 'atari'
|
|
|
|
|
|
|
|
.define CIOV_org CIOV ; the print_string macros use CIOV_org, map this to CIOV
|
|
|
|
|
|
|
|
lmemerr_txt:
|
|
|
|
.byte "Program would load below MEMLO.", ATEOL
|
|
|
|
.byte "Consider using a higher load address.", ATEOL
|
|
|
|
lmemerr_txt_len = * - lmemerr_txt
|
|
|
|
|
|
|
|
|
|
|
|
; ***** entry point (atari) *****
|
|
|
|
|
|
|
|
syschk:
|
|
|
|
sec
|
|
|
|
lda MEMTOP
|
|
|
|
sbc #<__RESERVED_MEMORY__
|
|
|
|
sta tmp
|
|
|
|
lda MEMTOP+1
|
|
|
|
sbc #>__RESERVED_MEMORY__
|
|
|
|
sta tmp+1
|
|
|
|
lda tmp
|
|
|
|
sec
|
|
|
|
sbc #<__STACKSIZE__
|
|
|
|
sta tmp
|
|
|
|
lda tmp+1
|
|
|
|
sbc #>__STACKSIZE__
|
|
|
|
sta tmp+1
|
|
|
|
|
|
|
|
;tmp contains address which must be above .bss's end
|
|
|
|
|
|
|
|
lda tmp
|
2013-10-04 10:40:35 +00:00
|
|
|
cmp #<(__BSS_RUN__ + __BSS_SIZE__)
|
2013-10-03 22:53:34 +00:00
|
|
|
lda tmp+1
|
|
|
|
sbc #>(__BSS_RUN__ + __BSS_SIZE__)
|
|
|
|
|
|
|
|
bcc mem_err ; program doesn't fit into memory
|
|
|
|
|
|
|
|
lda MEMLO
|
2013-10-04 10:40:35 +00:00
|
|
|
cmp #<__STARTADDRESS__
|
2013-10-03 22:53:34 +00:00
|
|
|
lda MEMLO+1
|
|
|
|
sbc #>__STARTADDRESS__
|
|
|
|
bcc memlo_ok
|
|
|
|
|
2013-05-30 00:33:09 +00:00
|
|
|
; load address was too low
|
2013-09-27 20:01:54 +00:00
|
|
|
print_string2 lmemerr_txt, lmemerr_txt_len
|
|
|
|
jsr delay ; long text takes longer to read, give user additional time
|
|
|
|
jmp fail
|
2013-05-30 00:33:09 +00:00
|
|
|
|
2013-10-03 22:53:34 +00:00
|
|
|
.endif
|
|
|
|
|
2013-05-30 00:33:09 +00:00
|
|
|
; all is well(tm), launch the application
|
|
|
|
memlo_ok:
|
2013-06-12 23:07:40 +00:00
|
|
|
.ifdef DEBUG
|
2013-09-27 20:01:54 +00:00
|
|
|
print_string "Stage #1 OK"
|
|
|
|
jsr delay
|
2013-06-12 23:07:40 +00:00
|
|
|
.endif
|
2013-09-27 20:01:54 +00:00
|
|
|
rts
|
2013-05-30 00:33:09 +00:00
|
|
|
|
2013-10-03 22:53:34 +00:00
|
|
|
; not enough memory
|
|
|
|
mem_err:print_string "Not enough memory."
|
|
|
|
fail: jsr delay
|
|
|
|
jmp (DOSVEC)
|
2013-05-30 00:33:09 +00:00
|
|
|
|
|
|
|
; short delay
|
2013-09-27 20:01:54 +00:00
|
|
|
.proc delay
|
|
|
|
|
|
|
|
lda #10
|
2013-10-03 22:53:34 +00:00
|
|
|
@loop: jsr delay1
|
2013-09-27 20:01:54 +00:00
|
|
|
clc
|
|
|
|
sbc #0
|
2013-10-03 22:53:34 +00:00
|
|
|
bne @loop
|
2013-09-27 20:01:54 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
delay1: ldx #0
|
|
|
|
ldy #0
|
2013-10-03 22:53:34 +00:00
|
|
|
@loop: dey
|
|
|
|
bne @loop
|
2013-09-27 20:01:54 +00:00
|
|
|
dex
|
2013-10-03 22:53:34 +00:00
|
|
|
bne @loop
|
2013-09-27 20:01:54 +00:00
|
|
|
rts
|
2013-05-30 00:33:09 +00:00
|
|
|
|
|
|
|
.endproc
|
|
|
|
|
2019-02-18 03:26:01 +00:00
|
|
|
__SYSTEM_CHECK__=syschk
|
|
|
|
__SYSCHK_END__:
|
2013-09-13 18:29:24 +00:00
|
|
|
|
2013-10-03 22:53:34 +00:00
|
|
|
.ifndef __ATARIXL__
|
2014-06-30 09:10:35 +00:00
|
|
|
tmp: ; outside of the load chunk, some kind of poor man's .bss
|
2013-10-03 22:53:34 +00:00
|
|
|
.endif
|
|
|
|
|