]> git.sur5r.net Git - cc65/blobdiff - libsrc/cbm610/cbm610-ram.s
Ignore only top level directories.
[cc65] / libsrc / cbm610 / cbm610-ram.s
index 2798f83ad6da3a30af9b7a62ff560cbb5ddf7a2f..ccdcb4290505f2aa172591ccd5c2ea486da0a4d0 100644 (file)
@@ -2,7 +2,7 @@
 ; Extended memory driver for the CBM610 additional RAM banks. Driver works
 ; without problems when linked statically.
 ;
-; Ullrich von Bassewitz, 2002-12-09        !!! UNTESTED !!!
+; Ullrich von Bassewitz, 2002-12-09, 2003-12-20
 ;
 
        .include        "zeropage.inc"
@@ -22,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.
 
@@ -63,17 +63,22 @@ pagecount:  .res    1               ; Number of available pages
 INSTALL:
                lda     #$FF
         sta     curpage                 ; Invalidate the current page
+        sta     pagecount               ; Assume all memory available
 
-       ldx     UsrMemTop+2
-       cpx     #RAMBANK                ; Top of memory in bank 2?
+        sec
+        jsr     $FF99                   ; MEMTOP
+
+               cmp     #RAMBANK                ; Top of memory in bank 2?
         bne     @L1                     ; No: We can use all the memory
-        clc
-        adc     UsrMemTop+1
-@L1:    sta     pagecount
+        txa
+        sub     #OFFS
+        tya
+        sbc     #$00
+        sta     pagecount
 
-        lda     #<EM_ERR_OK
+@L1:    lda     #<EM_ERR_OK
         ldx     #>EM_ERR_OK
-        rts
+;       rts                            ; Run into UNINSTALL instead
 
 ; ------------------------------------------------------------------------
 ; UNINSTALL routine. Is called before the driver is removed from memory.
@@ -112,12 +117,11 @@ MAP:    sta     curpage                   ; Remember the new page
         sta     IndReg
 
         ldy     #$00
-@L1:    lda     (ptr1),y
-        sta     window,y
-        iny
+@L1:    .repeat 2
         lda     (ptr1),y
         sta     window,y
         iny
+        .endrepeat
         bne     @L1
 
         stx     IndReg
@@ -154,12 +158,11 @@ COMMIT: lda     curpage                   ; Get the current page
         sta     IndReg
 
         ldy     #$00
-@L1:    lda     window,y
-        sta     (ptr1),y
-        iny
+@L1:    .repeat 2
         lda     window,y
         sta     (ptr1),y
         iny
+        .endrepeat
         bne     @L1
 
         stx     IndReg
@@ -263,27 +266,27 @@ COPYTO: jsr     setup
 setup:  sta     ptr3
         stx     ptr3+1                  ; Save the passed em_copy pointer
 
-        ldy     #EM_COPY_OFFS
+        ldy     #EM_COPY::OFFS
         lda     (ptr3),y
         add     #OFFS
         sta     ptr1
-        ldy     #EM_COPY_PAGE
+        ldy     #EM_COPY::PAGE
         lda     (ptr3),y
         adc     #$00
         sta     ptr1+1
 
-        ldy     #EM_COPY_COUNT
+        ldy     #EM_COPY::COUNT
         lda     (ptr3),y
         sta     ptr2
         iny
         lda     (ptr3),y
         sta     ptr2+1                  ; Get count into ptr2
 
-        ldy     #EM_COPY_BUF+1
-        lda     (ptr1),y
+        ldy     #EM_COPY::BUF+1
+        lda     (ptr3),y
         tax
         dey
-        lda     (ptr1),y                ; Get the buffer pointer into a/x
+        lda     (ptr3),y                ; Get the buffer pointer into a/x
 
         ldy     #RAMBANK
         sty     IndReg