2 ; Extended memory driver for the ISEPIC cartridge.
3 ; Marco van den Heuvel, 2010-01-24
6 .include "zeropage.inc"
8 .include "em-kernel.inc"
9 .include "em-error.inc"
15 ; ------------------------------------------------------------------------
16 ; Header. Includes jump table
22 .byte $65, $6d, $64 ; "emd"
23 .byte EMD_API_VERSION ; EM API version number
36 ; ------------------------------------------------------------------------
39 IP_WINDOW = $DF00 ; Address of ISEPIC window
43 ; ------------------------------------------------------------------------
48 ; ------------------------------------------------------------------------
49 ; INSTALL routine. Is called after the driver is loaded into memory. If
50 ; possible, check if the hardware is present and determine the amount of
52 ; Must return an EM_ERR_xx code in a/x.
74 lda #<EM_ERR_NO_DEVICE
75 ldx #>EM_ERR_NO_DEVICE
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.
91 ; ------------------------------------------------------------------------
92 ; PAGECOUNT: Return the total number of available pages in a/x.
100 ; ------------------------------------------------------------------------
101 ; USE: Tell the driver that the window is now associated with a given page.
102 ; The Isepic cartridge does not copy but actually map the window, so USE is
107 ; ------------------------------------------------------------------------
108 ; MAP: Map the page in a/x into memory and return a pointer to the page in
109 ; a/x. The contents of the currently mapped page (if any) may be discarded
119 ; Use the RTS from COMMIT below to save a precious byte of storage
121 ; ------------------------------------------------------------------------
122 ; COMMIT: Commit changes in the memory window to extended storage.
127 ; ------------------------------------------------------------------------
128 ; COPYFROM: Copy from extended into linear memory. A pointer to a structure
129 ; describing the request is passed in a/x.
130 ; The function must not return anything.
138 ; - ptr1 contains the struct pointer
139 ; - ptr2 contains the linear memory buffer
140 ; - ptr3 contains -(count-1)
141 ; - tmp1 contains the low page register value
142 ; - X contains the page offset
157 ; Bump count and repeat
169 inc tmp1 ; Bump low page register
177 ; ------------------------------------------------------------------------
178 ; COPYTO: Copy from linear into extended memory. A pointer to a structure
179 ; describing the request is passed in a/x.
180 ; The function must not return anything.
188 ; - ptr1 contains the struct pointer
189 ; - ptr2 contains the linear memory buffer
190 ; - ptr3 contains -(count-1)
191 ; - tmp1 contains the low page register value
192 ; - X contains the page offset
207 ; Bump count and repeat
219 inc tmp1 ; Bump page register
227 ; ------------------------------------------------------------------------
228 ; Helper function for COPYFROM and COPYTO: Store the pointer to the request
229 ; structure and prepare data for the copy
233 stx ptr1+1 ; Save passed pointer
235 ; Get the page number from the struct and remember it.
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