]> git.sur5r.net Git - cc65/blobdiff - libsrc/atari/system_check.s
more atarixl linker cfg file cleanups; adapt atarixl-overlay.cfg
[cc65] / libsrc / atari / system_check.s
index 19e57424386243ec4947fc4a22b0c9118d0a0f3d..b1d80b0c2885acdd507be78414da6808decfe5fd 100644 (file)
 ; Christian Groessler, chris@groessler.org, 2013
 ;
 
+DEBUG  =       1
+
 .if .defined(__ATARIXL__)
 
        .export         syschk
         .import         __SYSCHK_LOAD__
-        .import         __SAVEAREA_LOAD__
+        .import         __STARTADDRESS__       ; needed by xlmemchk.inc
 
         .include        "zeropage.inc"
         .include        "atari.inc"
@@ -62,24 +64,25 @@ cont:       ldx     #0              ; channel 0
 .segment        "SYSCHKHDR"
 
         .word   __SYSCHK_LOAD__
-        .word   trailer - 1
+        .word   end - 1
 
 ; ------------------------------------------------------------------------
 ; Actual code
 
 .segment        "SYSCHK"
 
+; no XL machine
+no_xl: print_string "This program needs an XL machine."
+       jmp     fail
+
+; entry point
 syschk:
        lda     $fcd8           ; from ostype.s
         cmp     #$a2
-        bne     is_xl
-
-; no XL machine
-       print_string "This program needs an XL machine."
-       jmp     fail
+        beq     no_xl
 
 ; we have an XL machine, now check memory
-is_xl: lda     RAMSIZ
+       lda     RAMSIZ
        cmp     #$80
        bcs     sys_ok
 
@@ -88,21 +91,9 @@ is_xl:       lda     RAMSIZ
 fail:  jsr     delay
        jmp     (DOSVEC)
 
-lowadr:        .res    2               ; lowest address we need in order to move screen memory down, depending on start address of program
 
-
-; system is basically supported, check if there is enough space btw. MEMLO and our start address
-; to move screen memory there
-
-CMPVAL = 64+255+992            ; you may ask, why these values...   @@@ document
-
-sys_ok:        lda     #<__SAVEAREA_LOAD__
-       sec
-       sbc     #<CMPVAL
-       sta     lowadr
-       lda     #>__SAVEAREA_LOAD__
-       sbc     #>CMPVAL
-       sta     lowadr+1
+sys_ok:
+       .include "xlmemchk.inc"         ; calculate lowest address we will use when we move the screen buffer down
 
        sec
        lda     MEMLO
@@ -118,6 +109,10 @@ sys_ok:    lda     #<__SAVEAREA_LOAD__
 
 ; all is well(tm), launch the application
 memlo_ok:
+.ifdef DEBUG
+       print_string "Stage #1 OK"
+       jsr     delay
+.endif
        rts
 
 
@@ -148,12 +143,15 @@ loop:     dey
 
 .endproc
 
+end:
+
 ; ------------------------------------------------------------------------
 ; Chunk "trailer" - sets INITAD
 
-trailer:
+.segment        "SYSCHKTRL"
+
         .word   INITAD
         .word   INITAD+1
-        .word   __SYSCHK_LOAD__
+        .word   syschk
 
 .endif ; .if .defined(__ATARIXL__)