2 ; Extended memory driver for the GEORAM cartridge. Driver works without
3 ; problems when statically linked.
5 ; Ullrich von Bassewitz, 2002-11-29
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 ; ------------------------------------------------------------------------
41 GR_WINDOW = $DE00 ; Address of GEORAM window
42 GR_PAGE_LO = $DFFE ; Page register low
43 GR_PAGE_HI = $DFFF ; Page register high
45 ; ------------------------------------------------------------------------
50 pagecount: .word 2048 ; Currently fixed
54 ; ------------------------------------------------------------------------
55 ; INSTALL routine. Is called after the driver is loaded into memory. If
56 ; possible, check if the hardware is present and determine the amount of
58 ; Must return an EM_ERR_xx code in a/x.
64 ; rts ; Run into UNINSTALL instead
66 ; ------------------------------------------------------------------------
67 ; UNINSTALL routine. Is called before the driver is removed from memory.
68 ; Can do cleanup or whatever. Must not return anything.
75 ; ------------------------------------------------------------------------
76 ; PAGECOUNT: Return the total number of available pages in a/x.
84 ; ------------------------------------------------------------------------
85 ; USE: Tell the driver that the window is now associated with a given page.
86 ; The GeoRAM cartridge does not copy but actually map the window, so USE is
91 ; ------------------------------------------------------------------------
92 ; MAP: Map the page in a/x into memory and return a pointer to the page in
93 ; a/x. The contents of the currently mapped page (if any) may be discarded
113 ; Use the RTS from COMMIT below to save a precious byte of storage
115 ; ------------------------------------------------------------------------
116 ; COMMIT: Commit changes in the memory window to extended storage.
120 ; ------------------------------------------------------------------------
121 ; COPYFROM: Copy from extended into linear memory. A pointer to a structure
122 ; describing the request is passed in a/x.
123 ; The function must not return anything.
131 ; - ptr1 contains the struct pointer
132 ; - ptr2 contains the linear memory buffer
133 ; - ptr3 contains -(count-1)
134 ; - tmp1 contains the low page register value
135 ; - tmp2 contains the high page register value
136 ; - X contains the page offset
149 ; Bump count and repeat
159 @L4: inc tmp1 ; Bump low page register
160 bit tmp1 ; Check for overflow in bit 6
161 bvc @L6 ; Jump if no overflow
169 ; ------------------------------------------------------------------------
170 ; COPYTO: Copy from linear into extended memory. A pointer to a structure
171 ; describing the request is passed in a/x.
172 ; The function must not return anything.
180 ; - ptr1 contains the struct pointer
181 ; - ptr2 contains the linear memory buffer
182 ; - ptr3 contains -(count-1)
183 ; - tmp1 contains the low page register value
184 ; - tmp2 contains the high page register value
185 ; - X contains the page offset
198 ; Bump count and repeat
208 @L4: inc tmp1 ; Bump low page register
209 bit tmp1 ; Check for overflow in bit 6
210 bvc @L6 ; Jump if no overflow
218 ; ------------------------------------------------------------------------
219 ; Helper function for COPYFROM and COPYTO: Store the pointer to the request
220 ; structure and prepare data for the copy
223 stx ptr1+1 ; Save passed pointer
225 ; Get the page number from the struct and adjust it so that it may be used
226 ; with the hardware. That is: lower 6 bits in tmp1, high bits in tmp2.
241 ; Get the buffer pointer into ptr2
250 ; Get the count, calculate -(count-1) and store it into ptr3
261 ; Get the page offset into X and clear Y