2 ; Extended memory driver for the Apple II auxiliary memory
4 ; Stefan Haubenthal, 2003-12-12
5 ; Ullrich von Bassewitz, 2002-12-02
8 .include "zeropage.inc"
10 .include "em-kernel.inc"
11 .include "em-error.inc"
15 ; ------------------------------------------------------------------------
16 ; Header. Includes jump table
19 module_header _a2e_auxmem_emd
21 module_header _a2_auxmem_emd
26 .byte $65, $6d, $64 ; "emd"
27 .byte EMD_API_VERSION ; EM API version number
44 ; ------------------------------------------------------------------------
48 AUXCARD = $C30C ; Card signature
49 AUXMOVE = $C311 ; Auxiliary move routine
50 PAGES = ($C000 - BASE) / 256
52 ; ------------------------------------------------------------------------
56 curpage: .byte $FF ; Current page number (invalid)
59 window: .res 256 ; Memory "window"
63 ; ------------------------------------------------------------------------
64 ; INSTALL routine. Is called after the driver is loaded into memory. If
65 ; possible, check if the hardware is present and determine the amount of
67 ; Must return an EM_ERR_xx code in a/x.
78 @L1: lda #EM_ERR_NO_DEVICE
81 ; ------------------------------------------------------------------------
82 ; UNINSTALL routine. Is called before the driver is removed from memory.
83 ; Can do cleanup or whatever. Must not return anything.
90 ; ------------------------------------------------------------------------
91 ; PAGECOUNT: Return the total number of available pages in a/x.
99 ; ------------------------------------------------------------------------
100 ; MAP: Map the page in a/x into memory and return a pointer to the page in
101 ; a/x. The contents of the currently mapped page (if any) may be discarded
105 MAP: sta curpage ; Remember the new page
121 jsr transfer ; Transfer one page
123 ; Return the memory window
126 ldx #>window ; Return the window address
132 ; ------------------------------------------------------------------------
133 ; USE: Tell the driver that the window is now associated with a given page.
135 USE: sta curpage ; Remember the page
137 ldx #>window ; Return the window
140 ; ------------------------------------------------------------------------
141 ; COMMIT: Commit changes in the memory window to extended storage.
143 COMMIT: lda curpage ; Get the current page
145 beq done ; Jump if no page mapped
163 ; Transfer one page/all bytes
183 ; ------------------------------------------------------------------------
184 ; COPYFROM: Copy from extended into linear memory. A pointer to a structure
185 ; describing the request is passed in a/x.
186 ; The function must not return anything.
191 stx ptr3+1 ; Save the passed em_copy pointer
210 common: ldy #EM_COPY::COUNT
211 lda (ptr3),y ; Get bytes in last page
214 lda (ptr3),y ; Get number of pages
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.
226 stx ptr3+1 ; Save the passed em_copy pointer