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) may be discarded
104 ; Use the RTS from COMMIT below to save a precious byte of storage
106 ; ------------------------------------------------------------------------
107 ; COMMIT: Commit changes in the memory window to extended storage.
111 ; ------------------------------------------------------------------------
112 ; COPYFROM: Copy from extended into linear memory. A pointer to a structure
113 ; describing the request is passed in a/x.
114 ; The function must not return anything.
122 ; - ptr1 contains the struct pointer
123 ; - ptr2 contains the linear memory buffer
124 ; - ptr3 contains -(count-1)
125 ; - tmp1 contains the low page register value
126 ; - tmp2 contains the high page register value
127 ; - X contains the page offset
140 ; Bump count and repeat
150 @L4: inc tmp1 ; Bump low page register
151 bit tmp1 ; Check for overflow in bit 6
152 bvc @L6 ; Jump if no overflow
160 ; ------------------------------------------------------------------------
161 ; COPYTO: Copy from linear into extended memory. A pointer to a structure
162 ; describing the request is passed in a/x.
163 ; The function must not return anything.
171 ; - ptr1 contains the struct pointer
172 ; - ptr2 contains the linear memory buffer
173 ; - ptr3 contains -(count-1)
174 ; - tmp1 contains the low page register value
175 ; - tmp2 contains the high page register value
176 ; - X contains the page offset
189 ; Bump count and repeat
199 @L4: inc tmp1 ; Bump low page register
200 bit tmp1 ; Check for overflow in bit 6
201 bvc @L6 ; Jump if no overflow
209 ; ------------------------------------------------------------------------
210 ; Helper function for COPYFROM and COPYTO: Store the pointer to the request
211 ; structure and prepare data for the copy
214 stx ptr1+1 ; Save passed pointer
216 ; Get the page number from the struct and adjust it so that it may be used
217 ; with the hardware. That is: lower 6 bits in tmp1, high bits in tmp2.
232 ; Get the buffer pointer into ptr2
241 ; Get the count, calculate -(count-1) and store it into ptr3
252 ; Get the page offset into X and clear Y