2 ; Extended memory driver for the CBM510 additional RAM banks. Driver works
3 ; without problems when linked statically.
5 ; Ullrich von Bassewitz, 2002-12-09 !!! UNTESTED !!!
8 .include "zeropage.inc"
10 .include "em-kernel.inc"
11 .include "em-error.inc"
17 ; ------------------------------------------------------------------------
18 ; Header. Includes jump table
24 .byte $65, $6d, $64 ; "emd"
25 .byte $00 ; EM API version number
38 ; ------------------------------------------------------------------------
44 ; ------------------------------------------------------------------------
48 curpage: .res 1 ; Current page number
50 window: .res 256 ; Memory "window"
51 pagecount: .res 1 ; Number of available pages
56 ; ------------------------------------------------------------------------
57 ; INSTALL routine. Is called after the driver is loaded into memory. If
58 ; possible, check if the hardware is present and determine the amount of
60 ; Must return an EM_ERR_xx code in a/x.
65 sta curpage ; Invalidate the current page
68 cpx #RAMBANK ; Top of memory in bank 2?
69 bne @L1 ; No: We can use all the memory
78 ; ------------------------------------------------------------------------
79 ; UNINSTALL routine. Is called before the driver is removed from memory.
80 ; Can do cleanup or whatever. Must not return anything.
87 ; ------------------------------------------------------------------------
88 ; PAGECOUNT: Return the total number of available pages in a/x.
96 ; ------------------------------------------------------------------------
97 ; MAP: Map the page in a/x into memory and return a pointer to the page in
98 ; a/x. The contents of the currently mapped page (if any) may be discarded
102 MAP: sta curpage ; Remember the new page
125 ; Return the memory window
128 ldx #>window ; Return the window address
131 ; ------------------------------------------------------------------------
132 ; USE: Tell the driver that the window is now associated with a given page.
134 USE: sta curpage ; Remember the page
136 ldx #>window ; Return the window
139 ; ------------------------------------------------------------------------
140 ; COMMIT: Commit changes in the memory window to extended storage.
142 COMMIT: lda curpage ; Get the current page
144 beq done ; Jump if no page mapped
171 ; ------------------------------------------------------------------------
172 ; COPYFROM: Copy from extended into linear memory. A pointer to a structure
173 ; describing the request is passed in a/x.
174 ; The function must not return anything.
180 ; Setup the buffer address in this bank.
185 ; Check if we must copy full pages
199 ; Copy the remaining page
206 ; Restore the indirect segment
216 ; ------------------------------------------------------------------------
217 ; COPYTO: Copy from linear into extended memory. A pointer to a structure
218 ; describing the request is passed in a/x.
219 ; The function must not return anything.
224 ; Setup the buffer address in this bank.
229 ; Check if we must copy full pages
243 ; Copy the remaining page
250 ; Restore the indirect segment
259 ; ------------------------------------------------------------------------
260 ; setup: Helper function for COPYFROM and COPYTO, will setup parameters.
264 stx ptr3+1 ; Save the passed em_copy pointer
280 sta ptr2+1 ; Get count into ptr2
286 lda (ptr1),y ; Get the buffer pointer into a/x
295 ; ------------------------------------------------------------------------
308 ; ------------------------------------------------------------------------