; 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"
; Driver signature
.byte $65, $6d, $64 ; "emd"
- .byte $00 ; EM API version number
+ .byte EMD_API_VERSION ; EM API version number
; Jump table.
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.
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
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
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