]> git.sur5r.net Git - cc65/blobdiff - libsrc/c64/c64-reu.s
As a test, remove the SYS header from the startup code and use the one
[cc65] / libsrc / c64 / c64-reu.s
index a5f57d1f7eecdff7965110eea9c68b897034ef1a..59dbb791337f76019034c4dcedb53c782af7c682 100644 (file)
@@ -1,5 +1,6 @@
 ;
-; Extended memory driver for the Commodore REU
+; Extended memory driver for the Commodore REU. Driver works without
+; problems when statically linked.
 ;
 ; Ullrich von Bassewitz, 2002-11-29
 ;
@@ -21,7 +22,7 @@
 ; Driver signature
 
         .byte   $65, $6d, $64           ; "emd"
-        .byte   $00                     ; EM API version number
+        .byte   EMD_API_VERSION                ; EM API version number
 
 ; Jump table.
 
@@ -76,35 +77,34 @@ reu_params:     .word       $0000           ; Host address, lo, hi
 ;
 
 INSTALL:
+        ldx     #$00                    ; High byte of return code
         lda     #$55
         sta     REU_REUADDR
         cmp     REU_REUADDR             ; Check for presence of REU
         bne     nodevice
-        lda     #$AA
+        asl     a                       ; A = $AA
         sta     REU_REUADDR
         cmp     REU_REUADDR             ; Check for presence of REU
         bne     nodevice
 
-        ldx     #>(128*4)               ; Assume 128KB
+        ldy     #>(128*4)               ; Assume 128KB
         lda     REU_STATUS
         and     #$10                    ; Check size bit
         beq     @L1
-        ldx     #>(256*4)               ; 256KB when size bit is set
-@L1:    stx     pagecount+1
-         
-        ldx     #$FF
-        stx     curpage
-        stx     curpage+1               ; Invalidate the current page
-        inx
+        ldy     #>(256*4)               ; 256KB when size bit is set
+@L1:    sty     pagecount+1
+
+        ldy     #$FF
+        sty     curpage
+        sty     curpage+1               ; Invalidate the current page
         txa                             ; X = A = EM_ERR_OK
         rts
 
 ; No REU found
 
 nodevice:
-        lda     #<EM_ERR_NO_DEVICE
-        ldx     #>EM_ERR_NO_DEVICE
-        rts
+        lda     #EM_ERR_NO_DEVICE
+;       rts                             ; Run into UNINSTALL instead
 
 ; ------------------------------------------------------------------------
 ; UNINSTALL routine. Is called before the driver is removed from memory.
@@ -142,7 +142,7 @@ done:   rts
 
 ; ------------------------------------------------------------------------
 ; USE: Tell the driver that the window is now associated with a given page.
-
+                                       
 USE:    sta     curpage
         stx     curpage+1               ; Remember the page
         lda     #<window