2 ; Extended memory driver for the CBM510 additional RAM banks
4 ; Ullrich von Bassewitz, 2002-12-09 !!! UNTESTED !!!
7 .include "zeropage.inc"
9 .include "em-kernel.inc"
10 .include "em-error.inc"
16 ; ------------------------------------------------------------------------
17 ; Header. Includes jump table
23 .byte $65, $6d, $64 ; "emd"
24 .byte $00 ; EM API version number
37 ; ------------------------------------------------------------------------
43 ; ------------------------------------------------------------------------
47 curpage: .byte $FF ; Current page number (invalid)
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.
67 cpx #RAMBANK ; Top of memory in bank 2?
68 bne @L1 ; No: We can use all the memory
77 ; ------------------------------------------------------------------------
78 ; DEINSTALL routine. Is called before the driver is removed from memory.
79 ; Can do cleanup or whatever. Must not return anything.
86 ; ------------------------------------------------------------------------
87 ; PAGECOUNT: Return the total number of available pages in a/x.
95 ; ------------------------------------------------------------------------
96 ; MAP: Map the page in a/x into memory and return a pointer to the page in
97 ; a/x. The contents of the currently mapped page (if any) may be discarded
101 MAP: sta curpage ; Remember the new page
124 ; Return the memory window
127 ldx #>window ; Return the window address
130 ; ------------------------------------------------------------------------
131 ; USE: Tell the driver that the window is now associated with a given page.
133 USE: sta curpage ; Remember the page
135 ldx #>window ; Return the window
138 ; ------------------------------------------------------------------------
139 ; COMMIT: Commit changes in the memory window to extended storage.
141 COMMIT: lda curpage ; Get the current page
143 beq done ; Jump if no page mapped
170 ; ------------------------------------------------------------------------
171 ; COPYFROM: Copy from extended into linear memory. A pointer to a structure
172 ; describing the request is passed in a/x.
173 ; The function must not return anything.
179 ; Setup the buffer address in this bank.
184 ; Check if we must copy full pages
198 ; Copy the remaining page
205 ; Restore the indirect segment
215 ; ------------------------------------------------------------------------
216 ; COPYTO: Copy from linear into extended memory. A pointer to a structure
217 ; describing the request is passed in a/x.
218 ; The function must not return anything.
223 ; Setup the buffer address in this bank.
228 ; Check if we must copy full pages
242 ; Copy the remaining page
249 ; Restore the indirect segment
258 ; ------------------------------------------------------------------------
259 ; setup: Helper function for COPYFROM and COPYTO, will setup parameters.
263 stx ptr3+1 ; Save the passed em_copy pointer
279 sta ptr2+1 ; Get count into ptr2
285 lda (ptr1),y ; Get the buffer pointer into a/x
294 ; ------------------------------------------------------------------------
307 ; ------------------------------------------------------------------------