From 87531388f94afe257658df2a9bca105a658451a2 Mon Sep 17 00:00:00 2001 From: cuz Date: Wed, 4 Dec 2002 22:29:45 +0000 Subject: [PATCH] Added C128 extended memory driver for memory in bank #1 git-svn-id: svn://svn.cc65.org/cc65/trunk@1715 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/c128/Makefile | 2 +- libsrc/c128/c128-ram.s | 273 +++++++++++++++++++++++++++++++++++++++++ libsrc/c128/c128.inc | 6 +- 3 files changed, 279 insertions(+), 2 deletions(-) create mode 100644 libsrc/c128/c128-ram.s diff --git a/libsrc/c128/Makefile b/libsrc/c128/Makefile index 6ab8bd0ea..80c768423 100644 --- a/libsrc/c128/Makefile +++ b/libsrc/c128/Makefile @@ -45,7 +45,7 @@ OBJS = _scrsize.o \ TGIS = -EMDS = c128-georam.emd c128-reu.emd +EMDS = c128-georam.emd c128-ram.emd c128-reu.emd #-------------------------------------------------------------------------- # Targets diff --git a/libsrc/c128/c128-ram.s b/libsrc/c128/c128-ram.s new file mode 100644 index 000000000..806192edf --- /dev/null +++ b/libsrc/c128/c128-ram.s @@ -0,0 +1,273 @@ +; +; Extended memory driver for the C128 RAM in bank #1 +; +; Ullrich von Bassewitz, 2002-12-04 +; + + .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 $00 ; EM API version number + +; Jump table. + + .word INSTALL + .word DEINSTALL + .word PAGECOUNT + .word MAP + .word COMMIT + .word COPYFROM + .word COPYTO + +; ------------------------------------------------------------------------ +; Constants + +BASE = $400 +TOPMEM = $FF00 +PAGES = (TOPMEM - BASE) / 256 + +; ------------------------------------------------------------------------ +; Data. + +.data +curpage: .word $FFFF ; Current page number (invalid) + +.bss +window: .res 256 ; Memory "window" + +.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: + lda #EM_ERR_OK + rts + +; ------------------------------------------------------------------------ +; DEINSTALL routine. Is called before the driver is removed from memory. +; Can do cleanup or whatever. Must not return anything. +; + +DEINSTALL: + rts + + +; ------------------------------------------------------------------------ +; PAGECOUNT: Return the total number of available pages in a/x. +; + +PAGECOUNT: + lda #PAGES + rts + +; ------------------------------------------------------------------------ +; MAP: Map the page in a/x into memory and return a pointer to the page in +; a/x. The contents of the currently mapped page (if any) may be discarded +; by the driver. +; + +MAP: sta curpage + stx curpage+1 ; Remember the new page + + clc + adc #>BASE + sta ptr1+1 + ldy #$00 + sty ptr1 + + lda #window ; Return the window address + rts + +; ------------------------------------------------------------------------ +; COMMIT: Commit changes in the memory window to extended storage. + +COMMIT: lda curpage ; Get the current page + ldx curpage+1 + bmi done ; Jump if no page mapped + + clc + adc #>BASE + sta ptr1+1 + ldy #$00 + sty ptr1 + + lda #BASE + sta ptr1+1 ; From + + ldy #EM_COPY_BUF + lda (ptr3),y + sta ptr2 + iny + lda (ptr3),y + sta ptr2+1 ; To + + lda #BASE + sta ptr1+1 ; To + + ldy #EM_COPY_BUF + lda (ptr3),y + sta ptr2 + iny + lda (ptr3),y + sta ptr2+1 ; From + + lda #