; Constants
BASE = $8000
-PAGES = 128
+PAGES = 127 ; Do not touch MMU
; ------------------------------------------------------------------------
; Data.
;
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.