From 1524b0c13f4672a8f29ef7f4cc78f14064c96844 Mon Sep 17 00:00:00 2001 From: uz Date: Mon, 1 Feb 2010 17:56:37 +0000 Subject: [PATCH] Added code to the driver to use also banks 2 and 3 if present. Contributed by Marco van den Heuvel. git-svn-id: svn://svn.cc65.org/cc65/trunk@4569 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/c128/c128-ram.s | 362 ++++++++++++++++++++++++++++------------- 1 file changed, 250 insertions(+), 112 deletions(-) diff --git a/libsrc/c128/c128-ram.s b/libsrc/c128/c128-ram.s index 1211c444d..6b384392c 100644 --- a/libsrc/c128/c128-ram.s +++ b/libsrc/c128/c128-ram.s @@ -1,8 +1,11 @@ ; -; Extended memory driver for the C128 RAM in bank #1. Driver works without +; 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" @@ -40,17 +43,19 @@ ; Constants BASE = $400 -TOPMEM = $FF00 -PAGES = (TOPMEM - BASE) / 256 ; ------------------------------------------------------------------------ ; Data. .bss -curpage: .res 1 ; Current page number +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 ; ------------------------------------------------------------------------ @@ -61,12 +66,46 @@ window: .res 256 ; Memory "window" ; INSTALL: + ldx #0 + stx ptr1 + ldx #4 + stx ptr1+1 + ldx #PAGES + lda pagecount + ldx pagecount+1 rts ; ------------------------------------------------------------------------ @@ -92,21 +131,25 @@ PAGECOUNT: ; by the driver. ; -MAP: sta curpage +MAP: sei + sta curpage stx curpage+1 ; Remember the new page - clc - adc #>BASE - sta ptr1+1 - ldy #$00 - sty ptr1 + jsr calculate_bank_and_correct_page + stx curbank + clc + adc #>BASE + sta ptr1+1 + ldy #$00 + sty ptr1 lda #window ; Return the window address + cli rts ; ------------------------------------------------------------------------ @@ -130,15 +174,19 @@ USE: sta curpage ; ------------------------------------------------------------------------ ; COMMIT: Commit changes in the memory window to extended storage. -COMMIT: lda curpage ; Get the current page +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 + 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 + sei + jsr setup - lda #BASE - sta ptr1+1 ; To - - ldy #EM_COPY::BUF - lda (ptr3),y - sta ptr2 - iny - lda (ptr3),y - sta ptr2+1 ; From - - lda #