Completed the REU driver

git-svn-id: svn://svn.cc65.org/cc65/trunk@1683 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2002-12-01 18:07:06 +00:00
parent 0c38839e79
commit ef166c1fa8

View file

@ -29,7 +29,7 @@
.word DEINSTALL .word DEINSTALL
.word PAGECOUNT .word PAGECOUNT
.word MAP .word MAP
.word MAPCLEAN .word COMMIT
.word COPYFROM .word COPYFROM
.word COPYTO .word COPYTO
@ -43,6 +43,7 @@ REU_REUADDR = $DF04 ; REU base address register
REU_COUNT = $DF07 ; Transfer count register REU_COUNT = $DF07 ; Transfer count register
REU_IRQMASK = $DF09 ; IRQ mask register REU_IRQMASK = $DF09 ; IRQ mask register
REU_CONTROL = $DF0A ; Control register REU_CONTROL = $DF0A ; Control register
REU_TRIGGER = $FF00 ; REU command trigger
OP_COPYFROM = $ED OP_COPYFROM = $ED
OP_COPYTO = $EC OP_COPYTO = $EC
@ -65,8 +66,6 @@ reu_params: .word $0000 ; Host address, lo, hi
.byte $00 ; Interrupt mask reg. .byte $00 ; Interrupt mask reg.
.byte $00 ; Adress control reg. .byte $00 ; Adress control reg.
.code .code
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
@ -128,40 +127,25 @@ PAGECOUNT:
; dirty and must be saved into secondary storage if this is necessary. ; dirty and must be saved into secondary storage if this is necessary.
; ;
MAP: ldy curpage+1 ; Do we have a page mapped? MAP: sta curpage
bmi MAPCLEAN ; Jump if no page mapped stx curpage+1 ; Remember the new page
ldy #<window ldy #OP_COPYFROM
sty REU_C64ADDR jsr common ; Copy the window
ldy #>window
sty REU_C64ADDR+1
ldy #0 lda #<window
sty REU_COUNT+0 ldx #>window ; Return the window address
sty REU_REUADDR+0 done: rts
ldy curpage
sty REU_REUADDR+1
ldy curpage+1
sty REU_REUADDR+2
ldy #1
sty REU_COUNT+1 ; Move 256 bytes
ldy #OP_COPYTO
pha
jsr Transfer ; Transfer 256 bytes into REU
pla
; Run straight into MAPCLEAN
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
; MAPCLEAN: Map the page in a/x into memory and return a pointer to the page ; COMMIT: Commit changes in the memory window to extended storage.
; in a/x. The contents of the currently mapped page (if any) are assumed to
; be clean, so if this is an advantage for the driver, the current contents
; may be discarded.
MAPCLEAN: COMMIT: lda curpage
sta curpage ldx curpage+1 ; Do we have a page mapped?
stx curpage+1 ; Remember the new page bmi done ; Jump if no page mapped
ldy #OP_COPYTO
common: sty tmp1
ldy #<window ldy #<window
sty REU_C64ADDR sty REU_C64ADDR
@ -176,12 +160,7 @@ MAPCLEAN:
ldy #1 ldy #1
sty REU_COUNT+1 ; Move 256 bytes sty REU_COUNT+1 ; Move 256 bytes
ldy #OP_COPYFROM bne transfer1 ; Transfer 256 bytes into REU
jsr Transfer ; Transfer 256 bytes into REU
lda #<window
ldx #>window ; Return the window address
rts
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
; COPYFROM: Copy from extended into linear memory. A pointer to a structure ; COPYFROM: Copy from extended into linear memory. A pointer to a structure
@ -190,7 +169,8 @@ MAPCLEAN:
; ;
COPYFROM: COPYFROM:
ldy #OP_COPYFROM
.byte $2C
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
; COPYTO: Copy from linear into extended memory. A pointer to a structure ; COPYTO: Copy from linear into extended memory. A pointer to a structure
@ -199,24 +179,46 @@ COPYFROM:
; ;
COPYTO: COPYTO:
lda #0 ldy #OP_COPYTO
tax sty tmp1
rts
; Remember the passed pointer
sta ptr1
stx ptr1+1 ; Save the pointer
; The structure passed to the functions has the same layout as the registers
; of the Commodore REU, so register programming is easy.
ldy #7-1
@L1: lda (ptr1),y
sta REU_C64ADDR,y
dey
bpl @L1
; Invalidate the page in the memory window
sty curpage+1 ; Y = $FF
; Reload the REU command and start the transfer
transfer1:
ldy tmp1
; ---------------------------------------------------------------------------
; Transfer subroutine for the REU. Expects command in Y. ; Transfer subroutine for the REU. Expects command in Y.
Transfer: transfer:
sty $df01 ; Issue command sty REU_COMMAND ; Issue command
sei ; Save the value of the ldy $01 ; Save the value of the c64 control port...
ldy $01 ; the c64 control port tya ;
tya ; and turn on lower 3 bits ora #$03 ; Turn on lower 3 bits to bank out ROMs, I/O.
ora #$03 ; to bank out ROMs, I/O. sei ;
sta $01 sta $01
lda $ff00 lda REU_TRIGGER ; Don't change $FF00
sta $ff00 ; Now start transfer... sta REU_TRIGGER ; Start the transfer...
sty $01 ; Restore the old configuration sty $01 ; Restore the old configuration
cli cli
rts rts