]> git.sur5r.net Git - cc65/blobdiff - libsrc/c128/emd/c128-ifnram.s
Finished adding c128 internal/external function ram emd's.
[cc65] / libsrc / c128 / emd / c128-ifnram.s
index 774678f332c127c183733884bea7a9e0f4c6bfa2..e670fe069c62743bc4b0df8de7dfb2414da5732b 100755 (executable)
@@ -44,7 +44,7 @@
 ; Constants
 
 BASE    = $8000
-PAGES   = 128
+PAGES   = 127      ; Do not touch MMU
 
 ; ------------------------------------------------------------------------
 ; Data.
@@ -64,11 +64,40 @@ window:         .res    256             ; Memory "window"
 ;
 
 INSTALL:
+        sei
+        ldx     #0
+        stx     ptr1
+        ldx     #$80
+        stx     ptr1+1
+        ldx     #<ptr1
+        stx     FETVEC
+        stx     STAVEC
+        ldy     #0
+        ldx     #MMU_CFG_INT_FROM
+        jsr     FETCH
+        tax
+        inx
+        txa
+        sta     tmp1
+        ldx     #MMU_CFG_INT_FROM
+        jsr     STASH
+        ldx     #MMU_CFG_INT_FROM
+        jsr     FETCH
+        cmp     tmp1
+        beq     @ram_present
+        lda     #<EM_ERR_NO_DEVICE
+        ldx     #>EM_ERR_NO_DEVICE
+        cli
+        rts
+
+@ram_present:
         ldx     #$FF
         stx     curpage
         stx     curpage+1               ; Invalidate the current page
         inx
         txa                             ; A = X = EM_ERR_OK
+        cli
+;       rts                             ; Run into UNINSTALL instead
 
 ; ------------------------------------------------------------------------
 ; UNINSTALL routine. Is called before the driver is removed from memory.