From 6a712d8b9e6c9b53b9d30a5af6895e7ba399d515 Mon Sep 17 00:00:00 2001 From: uz Date: Fri, 12 Feb 2010 10:46:57 +0000 Subject: [PATCH] More driver cleanup. git-svn-id: svn://svn.cc65.org/cc65/trunk@4585 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/c64/c64-c256k.s | 85 ++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/libsrc/c64/c64-c256k.s b/libsrc/c64/c64-c256k.s index c1455595b..f66118f4c 100755 --- a/libsrc/c64/c64-c256k.s +++ b/libsrc/c64/c64-c256k.s @@ -38,9 +38,7 @@ BASE = $4000 PAGES = 3 * 256 -CHECKC256K = $0200 -TRANSFERC256K = $0200 -STASHOPCODE = $91 +TARGETLOC = $200 ; Target location for copy/check code pia = $DFC0 ; ------------------------------------------------------------------------ @@ -50,11 +48,14 @@ pia = $DFC0 ; This function is used to copy code from and to the extended memory -.proc c256kcopycode -.org ::TRANSFERC256K ; Assemble for target location +.proc copy +template: +.org ::TARGETLOC ; Assemble for target location +entry: stx pia -::STASHC256K := * ; Location and opcode is patched at runtime -::VECC256K := *+1 +stashop = $91 ; 'sta' opcode +operation := * ; Location and opcode is patched at runtime +address := *+1 lda ($00),y ldx #$dc stx pia @@ -63,8 +64,10 @@ pia = $DFC0 .endproc ; This function is used to check for the existence of the extended memory -.proc c256kcheckcode -.org ::CHECKC256K +.proc check +template: +.org ::TARGETLOC +entry: ldy #$00 ; Assume hardware not present lda #$fc @@ -99,7 +102,7 @@ window: .res 256 ; Memory "window" ; Since the functions above are copied to $200, the current contents of this ; memory area must be saved into backup storage. Allocate enough space. -backup: .res .max (.sizeof (c256kcopycode), .sizeof (c256kcheckcode)) +backup: .res .max (.sizeof (copy), .sizeof (check)) @@ -144,9 +147,9 @@ INSTALL: sty pia+3 jsr backup_and_setup_check_routine - jsr CHECKC256K + jsr check::entry cli - ldx #.sizeof (c256kcheckcode) - 1 + ldx #.sizeof (check) - 1 jsr restore_data cpy #$01 beq @present @@ -157,7 +160,7 @@ INSTALL: @present: lda #EM_ERR_OK -; rts ; Run into UNINSTALL instead +; rts ; Run into UNINSTALL instead ; ------------------------------------------------------------------------ ; UNINSTALL routine. Is called before the driver is removed from memory. @@ -185,7 +188,7 @@ PAGECOUNT: MAP: sei - sta curpage ; Remember the new page + sta curpage ; Remember the new page stx curpage+1 jsr adjust_page_and_bank stx curbank @@ -196,10 +199,10 @@ MAP: sty ptr1 jsr backup_and_setup_copy_routine ldx #window ; Return the window address + ldx #>window ; Return the window address cli rts ; ------------------------------------------------------------------------ ; USE: Tell the driver that the window is now associated with a given page. -USE: sta curpage ; Remember the page +USE: sta curpage ; Remember the page stx curpage+1 lda #window ; Return the window + ldx #>window ; Return the window rts ; ------------------------------------------------------------------------ @@ -227,7 +230,7 @@ USE: sta curpage ; Remember the page COMMIT: sei - lda curpage ; Get the current page + lda curpage ; Get the current page ldx curpage+1 jsr adjust_page_and_bank @@ -239,14 +242,14 @@ COMMIT: sty ptr1 jsr backup_and_setup_copy_routine ldx #