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"
17 ; ------------------------------------------------------------------------
18 ; Header. Includes jump table
24 .byte $65, $6d, $64 ; "emd"
25 .byte EMD_API_VERSION ; EM API version number
38 ; ------------------------------------------------------------------------
42 AUXCARD = $C30C ; Card signature
43 AUXMOVE = $C311 ; Auxiliary move routine
44 PAGES = ($C000 - BASE) / 256
46 ; ------------------------------------------------------------------------
50 curpage: .byte $FF ; Current page number (invalid)
53 window: .res 256 ; Memory "window"
57 ; ------------------------------------------------------------------------
58 ; INSTALL routine. Is called after the driver is loaded into memory. If
59 ; possible, check if the hardware is present and determine the amount of
61 ; Must return an EM_ERR_xx code in a/x.
72 @L1: lda #EM_ERR_NO_DEVICE
75 ; ------------------------------------------------------------------------
76 ; DEINSTALL routine. Is called before the driver is removed from memory.
77 ; Can do cleanup or whatever. Must not return anything.
84 ; ------------------------------------------------------------------------
85 ; PAGECOUNT: Return the total number of available pages in a/x.
93 ; ------------------------------------------------------------------------
94 ; MAP: Map the page in a/x into memory and return a pointer to the page in
95 ; a/x. The contents of the currently mapped page (if any) may be discarded
99 MAP: sta curpage ; Remember the new page
114 jsr transfer ; Transfer one page
116 ; Return the memory window
119 ldx #>window ; Return the window address
125 ; ------------------------------------------------------------------------
126 ; USE: Tell the driver that the window is now associated with a given page.
128 USE: sta curpage ; Remember the page
130 ldx #>window ; Return the window
133 ; ------------------------------------------------------------------------
134 ; COMMIT: Commit changes in the memory window to extended storage.
136 COMMIT: lda curpage ; Get the current page
138 beq done ; Jump if no page mapped
155 ; Transfer one page/all bytes
174 ; ------------------------------------------------------------------------
175 ; COPYFROM: Copy from extended into linear memory. A pointer to a structure
176 ; describing the request is passed in a/x.
177 ; The function must not return anything.
182 stx ptr3+1 ; Save the passed em_copy pointer
200 common: ldy #EM_COPY::COUNT
201 lda (ptr3),y ; Get bytes in last page
204 lda (ptr3),y ; Get number of pages
209 ; ------------------------------------------------------------------------
210 ; COPYTO: Copy from linear into extended memory. A pointer to a structure
211 ; describing the request is passed in a/x.
212 ; The function must not return anything.
216 stx ptr3+1 ; Save the passed em_copy pointer