; ; Extended memory driver for the C128 RAM in banks #1, #2 and #3. Driver works without ; problems when statically linked. ; ; Ullrich von Bassewitz, 2002-12-04 ; ; Updated to use banks 2 and 3 as well by ; Marco van den Heuvel, 2010-01-21 ; .include "zeropage.inc" .include "em-kernel.inc" .include "em-error.inc" .include "c128.inc" .macpack generic ; ------------------------------------------------------------------------ ; Header. Includes jump table .segment "JUMPTABLE" ; Driver signature .byte $65, $6d, $64 ; "emd" .byte EMD_API_VERSION ; EM API version number ; Jump table. .word INSTALL .word UNINSTALL .word PAGECOUNT .word MAP .word USE .word COMMIT .word COPYFROM .word COPYTO ; ------------------------------------------------------------------------ ; Constants BASE = $400 ; ------------------------------------------------------------------------ ; Data. .bss curpage: .res 2 ; Current page number curbank: .res 1 ; Current bank number copybank: .res 2 ; temp bank number window: .res 256 ; Memory "window" pagecount: .res 2 ; Number of available pages .code ; ------------------------------------------------------------------------ ; INSTALL routine. Is called after the driver is loaded into memory. If ; possible, check if the hardware is present and determine the amount of ; memory available. ; Must return an EM_ERR_xx code in a/x. ; INSTALL: ldx #0 stx ptr1 ldx #4 stx ptr1+1 ldx #BASE sta ptr1+1 ldy #$00 sty ptr1 lda #window ; Return the window address cli rts ; ------------------------------------------------------------------------ ; USE: Tell the driver that the window is now associated with a given page. USE: sta curpage stx curpage+1 ; Remember the page lda #window ; Return the window rts ; ------------------------------------------------------------------------ ; COMMIT: Commit changes in the memory window to extended storage. COMMIT: sei lda curpage ; Get the current page ldx curpage+1 bmi done ; Jump if no page mapped jsr calculate_bank_and_correct_page stx curbank clc adc #>BASE sta ptr1+1 ldy #$00 sty ptr1 lda #