2 ; Extended memory driver for the CBM610 additional RAM banks. Driver works
3 ; without problems when linked statically.
5 ; Ullrich von Bassewitz, 2002-12-09, 2003-12-20
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 EMD_API_VERSION ; 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
66 sta pagecount ; Assume all memory available
71 cmp #RAMBANK ; Top of memory in bank 2?
72 bne @L1 ; No: We can use all the memory
81 ; rts ; Run into UNINSTALL instead
83 ; ------------------------------------------------------------------------
84 ; UNINSTALL routine. Is called before the driver is removed from memory.
85 ; Can do cleanup or whatever. Must not return anything.
92 ; ------------------------------------------------------------------------
93 ; PAGECOUNT: Return the total number of available pages in a/x.
101 ; ------------------------------------------------------------------------
102 ; MAP: Map the page in a/x into memory and return a pointer to the page in
103 ; a/x. The contents of the currently mapped page (if any) may be discarded
107 MAP: sta curpage ; Remember the new page
129 ; Return the memory window
132 ldx #>window ; Return the window address
135 ; ------------------------------------------------------------------------
136 ; USE: Tell the driver that the window is now associated with a given page.
138 USE: sta curpage ; Remember the page
140 ldx #>window ; Return the window
143 ; ------------------------------------------------------------------------
144 ; COMMIT: Commit changes in the memory window to extended storage.
146 COMMIT: lda curpage ; Get the current page
148 beq done ; Jump if no page mapped
174 ; ------------------------------------------------------------------------
175 ; COPYFROM: Copy from extended into linear memory. A pointer to a structure
176 ; describing the request is passed in a/x.
177 ; The function must not return anything.
183 ; Setup the buffer address in this bank.
188 ; Check if we must copy full pages
202 ; Copy the remaining page
209 ; Restore the indirect segment
219 ; ------------------------------------------------------------------------
220 ; COPYTO: Copy from linear into extended memory. A pointer to a structure
221 ; describing the request is passed in a/x.
222 ; The function must not return anything.
227 ; Setup the buffer address in this bank.
232 ; Check if we must copy full pages
246 ; Copy the remaining page
253 ; Restore the indirect segment
262 ; ------------------------------------------------------------------------
263 ; setup: Helper function for COPYFROM and COPYTO, will setup parameters.
267 stx ptr3+1 ; Save the passed em_copy pointer
283 sta ptr2+1 ; Get count into ptr2
289 lda (ptr3),y ; Get the buffer pointer into a/x
298 ; ------------------------------------------------------------------------
311 ; ------------------------------------------------------------------------