2 ; Extended memory driver for the GEORAM cartridge
4 ; Ullrich von Bassewitz, 2002-11-29
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
36 ; ------------------------------------------------------------------------
39 GR_WINDOW = $DE00 ; Address of GEORAM window
40 GR_PAGE_LO = $DFFE ; Page register low
41 GR_PAGE_HI = $DFFF ; Page register high
43 ; ------------------------------------------------------------------------
48 pagecount: .word 2048 ; Currently fixed
52 ; ------------------------------------------------------------------------
53 ; INSTALL routine. Is called after the driver is loaded into memory. If
54 ; possible, check if the hardware is present and determine the amount of
56 ; Must return an EM_ERR_xx code in a/x.
64 ; ------------------------------------------------------------------------
65 ; DEINSTALL routine. Is called before the driver is removed from memory.
66 ; Can do cleanup or whatever. Must not return anything.
73 ; ------------------------------------------------------------------------
74 ; PAGECOUNT: Return the total number of available pages in a/x.
82 ; ------------------------------------------------------------------------
83 ; MAP: Map the page in a/x into memory and return a pointer to the page in
84 ; a/x. The contents of the currently mapped page (if any) are assumed to be
85 ; dirty and must be saved into secondary storage if this is necessary.
105 ; ------------------------------------------------------------------------
106 ; MAPCLEAN: Map the page in a/x into memory and return a pointer to the page
107 ; in a/x. The contents of the currently mapped page (if any) are assumed to
108 ; be clean, so if this is an advantage for the driver, the current contents
111 MAPCLEAN = MAP ; Identical for GEORAM
114 ; ------------------------------------------------------------------------
115 ; COPYFROM: Copy from extended into linear memory. A pointer to a structure
116 ; describing the request is passed in a/x.
117 ; The function must not return anything.
125 ; - ptr1 contains the struct pointer
126 ; - ptr2 contains the linear memory buffer
127 ; - ptr3 contains -(count-1)
128 ; - tmp1 contains the low page register value
129 ; - tmp2 contains the high page register value
130 ; - X contains the page offset
143 ; Bump count and repeat
153 @L4: inc tmp1 ; Bump low page register
154 bit tmp1 ; Check for overflow in bit 6
155 bvc @L6 ; Jump if no overflow
163 ; ------------------------------------------------------------------------
164 ; COPYTO: Copy from linear into extended memory. A pointer to a structure
165 ; describing the request is passed in a/x.
166 ; The function must not return anything.
174 ; - ptr1 contains the struct pointer
175 ; - ptr2 contains the linear memory buffer
176 ; - ptr3 contains -(count-1)
177 ; - tmp1 contains the low page register value
178 ; - tmp2 contains the high page register value
179 ; - X contains the page offset
192 ; Bump count and repeat
202 @L4: inc tmp1 ; Bump low page register
203 bit tmp1 ; Check for overflow in bit 6
204 bvc @L6 ; Jump if no overflow
212 ; ------------------------------------------------------------------------
213 ; Helper function for COPYFROM and COPYTO: Store the pointer to the request
214 ; structure and prepare data for the copy
217 stx ptr1+1 ; Save passed pointer
219 ; Get the page number from the struct and adjust it so that it may be used
220 ; with the hardware. That is: lower 6 bits in tmp1, high bits in tmp2.
235 ; Get the buffer pointer into ptr2
244 ; Get the count, calculate -(count-1) and store it into ptr3
255 ; Get the page offset into X and clear Y