A2osX/SYS/KM.RAMWORKS.S.txt

718 lines
15 KiB
Plaintext
Raw Normal View History

2015-03-14 21:48:35 +00:00
NEW
2019-10-09 10:05:08 +00:00
AUTO 3,1
2015-03-14 21:48:35 +00:00
.LIST OFF
.OP 65C02
.OR $2000
2020-04-10 11:22:09 +00:00
.TF sys/km.ramworks
2015-03-14 21:48:35 +00:00
*--------------------------------------
2021-02-26 20:13:48 +00:00
.INB inc/macros.i
.INB inc/io.i
.INB inc/monitor.i
.INB inc/mli.i
.INB inc/mli.e.i
2015-03-14 21:48:35 +00:00
*--------------------------------------
TmpPtr1 .EQ $0
TmpPtr2 .EQ $2
Type .EQ $4
2015-03-14 21:48:35 +00:00
*--------------------------------------
RW.SAVEZP0 .EQ $800
RW.SAVEZP1 .EQ $900
*--------------------------------------
RW.BLOCK .EQ $A00
*--------------------------------------
* A2OSX.SYSTEM relocated at $1000 !!!
*--------------------------------------
SEBankSelect .EQ $C071
2015-03-14 21:48:35 +00:00
RWBankSelect .EQ $C073
*--------------------------------------
2018-07-12 15:20:39 +00:00
RW.Init >LDYAI RW.MSG
jsr PrintFYA
jsr RW.DetectRAM3
2015-03-14 21:48:35 +00:00
bcs .10
2018-07-12 15:20:39 +00:00
>LDYAI RW.MSG.OK
jsr PrintFYA
2015-03-14 21:48:35 +00:00
rts
.10 lda #RWBankSelect
jsr RW.DetectHW
bcc .1
lda #SEBankSelect
jsr RW.DetectHW
2015-03-14 21:48:35 +00:00
bcc .1
2020-07-18 14:04:21 +00:00
2018-07-12 15:20:39 +00:00
>LDYAI RW.MSG.KO1
2020-08-07 19:49:24 +00:00
bra .9
.1 tay save RAM drive pages
pha
lsr divide by 4 to compute KB size
ror .12+1
lsr
ror .12+1
.12 ldx #$00 X,A = RAM drive size
phx Push Kbyte LO
pha Push Kbyte HI
2020-07-18 14:04:21 +00:00
2020-08-07 19:49:24 +00:00
tya
inc + 1 page AUX mem
2021-02-26 20:13:48 +00:00
2020-08-07 19:49:24 +00:00
pha Total page detected
lsr divide by 4 to compute KB size
ror .11+1
lsr
ror .11+1
2020-08-07 19:49:24 +00:00
.11 ldx #$00 X,A = Total KB detected
phx Push Kbyte LO
pha Push Kbyte HI
2018-07-12 15:20:39 +00:00
>LDYAI RW.MSG.OK1
jsr PrintFYA
2015-03-14 21:48:35 +00:00
jsr RW.Install
bcc .2
2018-07-12 15:20:39 +00:00
>LDYAI RW.MSG.KO2
2020-08-07 19:49:24 +00:00
bra .9
2015-03-14 21:48:35 +00:00
2018-07-12 15:20:39 +00:00
.2 >LDYAI RW.MSG.OK2
jsr PrintFYA
2015-03-14 21:48:35 +00:00
jsr RW.Format
bcc .3
2018-07-12 15:20:39 +00:00
>LDYAI RW.MSG.KO3
2020-08-07 19:49:24 +00:00
bra .9
2021-02-26 20:13:48 +00:00
2018-07-12 15:20:39 +00:00
.3 >LDYAI RW.MSG.OK3
2020-08-07 19:49:24 +00:00
.9 jsr PrintFYA
2015-03-14 21:48:35 +00:00
rts
*--------------------------------------
RW.DetectRAM3 jsr MLI
2015-03-14 21:48:35 +00:00
.DA #MLIONLINE
.DA RW.ONLINE
rts
*--------------------------------------
RW.ONLINE .DA #2
.DA #$B0 Slot 3,Drive 2
2015-03-14 21:48:35 +00:00
.DA RW.ONLINEBUFFER
RW.ONLINEBUFFER .BS 16
*--------------------------------------
RW.DetectHW php
2015-03-14 21:48:35 +00:00
sei
sta Type
sta .1+1
sta .2+1
sta .3+1
sta .6+1
2015-03-14 21:48:35 +00:00
sta SETALTZP
2020-07-18 14:04:21 +00:00
2015-03-14 21:48:35 +00:00
ldx #0 start detection at page $00
2020-07-18 14:04:21 +00:00
2015-03-14 21:48:35 +00:00
.1 stx RWBankSelect
lda 0
2020-07-18 14:04:21 +00:00
sta RW.SAVEZP0,x save Bank 0 $0000 to prevent ALTZP trash
2015-03-14 21:48:35 +00:00
lda 1
sta RW.SAVEZP1,x
inx
bpl .1
2020-07-18 14:04:21 +00:00
2015-03-14 21:48:35 +00:00
lda #0
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
.2 sta RWBankSelect
2016-01-06 18:45:59 +00:00
*--------------------------------------
2016-03-13 21:46:25 +00:00
* Added after David Finnigan from macgui.com testing sessions
2021-02-26 20:13:48 +00:00
*
pha
pla
2021-02-26 20:13:48 +00:00
*
2016-03-13 21:46:25 +00:00
* to address possibly a timing issue with Accelerators
2016-01-06 18:45:59 +00:00
*--------------------------------------
2015-03-14 21:48:35 +00:00
sta 0
eor #$FF
sta 1
eor #$FF
inc
bpl .2
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
ldx #0
2021-02-26 20:13:48 +00:00
2020-12-15 13:23:22 +00:00
.3 stx RWBankSelect
2016-06-23 20:18:29 +00:00
*--------------------------------------
* Added after David Finnigan from macgui.com testing sessions
2021-02-26 20:13:48 +00:00
*
pha
pla
2021-02-26 20:13:48 +00:00
*
2016-06-23 20:18:29 +00:00
* to address possibly a timing issue with Accelerators
*--------------------------------------
2020-12-15 13:23:22 +00:00
lda 0
tay
eor #$ff
2015-03-14 21:48:35 +00:00
cmp 1
bne .4
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
inx
2020-07-18 14:04:21 +00:00
2020-12-15 13:23:22 +00:00
cpy #127
bne .3
2020-07-18 14:04:21 +00:00
2021-02-26 20:13:48 +00:00
.4 ldy #127 X = detected page count
2015-03-14 21:48:35 +00:00
.6 sty RWBankSelect
2016-03-13 21:46:25 +00:00
2015-03-14 21:48:35 +00:00
lda RW.SAVEZP0,y
sta 0
lda RW.SAVEZP1,y
sta 1
dey
bpl .6
2015-03-14 21:48:35 +00:00
sta CLRALTZP
plp
2020-07-18 14:04:21 +00:00
txa PGCNT > 0 ?
beq .9
2021-02-26 20:13:48 +00:00
2020-08-07 19:49:24 +00:00
dec minus 1 for AUX mem
beq .9
2021-02-26 20:13:48 +00:00
2020-08-07 19:49:24 +00:00
sta RW.PGCNT PGCNT = last detected page
2015-03-14 21:48:35 +00:00
clc
rts
2020-07-17 15:18:31 +00:00
2019-10-03 06:25:27 +00:00
.9 sec
2015-03-14 21:48:35 +00:00
rts
*--------------------------------------
RW.Install lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
ldx #RWDRV.SIZE
2020-07-18 14:04:21 +00:00
2015-03-14 21:48:35 +00:00
.1 lda RWDRV.B.START-1,x
sta RWDRV.START-1,x
dex
bne .1
2020-07-18 14:04:21 +00:00
2015-03-14 21:48:35 +00:00
lda RW.PGCNT
lsr
sta RWDRV.MAXHI+1
2020-07-18 14:04:21 +00:00
2015-03-14 21:48:35 +00:00
lda #0
ror
sta RWDRV.MAXLO+1
2020-07-18 14:04:21 +00:00
lda Type
sta RWDRV.IO1+1
sta RWDRV.EXIT+1
2015-03-14 21:48:35 +00:00
lda RROMBNK1
2015-03-14 21:48:35 +00:00
sta SETWRITEAUX
2020-07-18 14:04:21 +00:00
2015-03-14 21:48:35 +00:00
ldx #RWDRVX.SIZE
2020-07-18 14:04:21 +00:00
2015-03-14 21:48:35 +00:00
.2 lda RWDRVX.B.START-1,x
sta RWDRVX.START-1,x
dex
bne .2
2020-07-18 14:04:21 +00:00
lda Type
sta RWDRVX.XM.IO1+1
sta RWDRVX.XM.IO2+1
sta RWDRVX.XM.IO3+1
2015-03-14 21:48:35 +00:00
sta CLRWRITEAUX
inc DEVCNT
ldx DEVCNT
lda #$B0 Slot 3,Drive 2,0=Not Removable, 0=no int, 00=1 Volume
2015-03-14 21:48:35 +00:00
sta DEVLST,x
2020-07-18 14:04:21 +00:00
2015-03-14 21:48:35 +00:00
lda #RWDRV.START
sta DEVPTRS3D2
2015-03-14 21:48:35 +00:00
lda /RWDRV.START
sta DEVPTRS3D2+1
2020-07-18 14:04:21 +00:00
2015-03-14 21:48:35 +00:00
clc
rts
*--------------------------------------
RW.Format jsr RW.BLOCK.SET00
lda RW.PGCNT
lsr
sta RW.BLOCK2.TB+1
lda #0
ror
sta RW.BLOCK2.TB
jsr MLI
.DA #MLIGETTIME
.DA 0
ldx #3
2019-10-03 06:25:27 +00:00
.1 lda DATELO,x
2015-03-14 21:48:35 +00:00
sta RW.BLOCK2.CT,x
dex
bpl .1
ldx #RW.BLOCK2.END-RW.BLOCK2
.2 lda RW.BLOCK2-1,x
sta RW.BLOCK-1,x
dex
bne .2
jsr MLI Write Block 2,First VOL directory block
.DA #MLIWRITEBLOCK
.DA RW.MLIWRITEBLOCK
bcc .22
rts
*--------------------------------------
.22 jsr RW.BLOCK.SET00
lda #2
sta RW.BLOCK LO byte of previous block pointer
inc RW.MLIWRITEBLOCK.BLK
jsr MLI Write Block 3,Last VOL directory block
.DA #MLIWRITEBLOCK
.DA RW.MLIWRITEBLOCK
bcc .33
rts
*--------------------------------------
.33 lda RW.PGCNT divide RW.PGCNT by 32 to get how many bitmap
lsr blocks we need :
lsr 1 page = 128 blocks = 16 bytes
lsr 32 pages = 512 bytes = 1 Block
lsr
lsr
sta RW.FBITMAPCNT store FULL bitmap block count needed
tax
lda RW.PGCNT
and #$1F need an extra incomplete bitmap block?
beq .3
inx
.3 stx RW.BITMAPCNT store TOTAL bitmap block needed
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
.4 lda RW.FBITMAPCNT
beq .49
dec RW.FBITMAPCNT
jsr RW.BLOCK.SETFF
bra .5
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
.49 jsr RW.BLOCK.SET00
lda RW.PGCNT
and #$1F compute incomplete bitmap block
asl
asl
asl
asl times 16 for byte count
tay
lda #$FF
2021-02-26 20:13:48 +00:00
bcc .42 first half of block only
2015-03-14 21:48:35 +00:00
ldx #0
.40 sta RW.BLOCK,x
inx
bne .40
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
cpy #0
beq .5
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
.41 sta RW.BLOCK+$ff,y
dey
bne .41
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
bra .5
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
.42 sta RW.BLOCK-1,y
dey
bne .42
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
.5 inc RW.MLIWRITEBLOCK.BLK
lda RW.MLIWRITEBLOCK.BLK
cmp #4 Are we writing first volume bitmap ?
bne .63 no, regular one
2015-06-03 18:30:57 +00:00
* lda #$CF Mark Block 0 & 1 free, 2,3 used (vol hdr)
lda #$0F
2021-02-26 20:13:48 +00:00
sta RW.BLOCK
2015-03-14 21:48:35 +00:00
ldy #0
lda #$8 Start a BLOCK 4 (%00001000)
ldx RW.BITMAPCNT
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
.62 pha
eor RW.BLOCK,y Mark bitmap blocks as "used"
sta RW.BLOCK,y
pla
dex
beq .63
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
lsr
bne .62
2021-02-26 20:13:48 +00:00
2019-10-03 06:25:27 +00:00
lda #$80
2015-03-14 21:48:35 +00:00
iny
bra .62
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
.63 jsr MLI Write Block 4,5...
.DA #MLIWRITEBLOCK
.DA RW.MLIWRITEBLOCK
bcs .9
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
dec RW.BITMAPCNT another bitmap block needed ?
bne .4
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
clc
2019-10-03 06:25:27 +00:00
.9 rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
RW.BLOCK.SETFF lda #$FF
2021-02-26 20:13:48 +00:00
.HS 2C BIT ABS
2015-03-14 21:48:35 +00:00
RW.BLOCK.SET00 lda #$00
2021-02-26 20:13:48 +00:00
ldx #0
2015-03-14 21:48:35 +00:00
.1 sta RW.BLOCK,x
sta RW.BLOCK+$100,x
inx
bne .1
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
rts
*--------------------------------------
RW.MLIWRITEBLOCK
.DA #3
.DA #$B0 Slot 3,Drive 2
2015-03-14 21:48:35 +00:00
.DA RW.BLOCK
RW.MLIWRITEBLOCK.BLK
.DA 2 Start writing block at #2
*--------------------------------------
RW.PGCNT .BS 1
RW.FBITMAPCNT .BS 1
RW.BITMAPCNT .BS 1
*--------------------------------------
RW.BLOCK2 .DA 0 pointer to previous block
.DA 3 pointer to next block
.DA #$F4 $F=Vol Dir Header, 4=name len
.AS 'RAM3'
.BS 11 (RAM3 len=4, fill to 15)
2015-03-14 21:48:35 +00:00
.HS 0000000000000000
RW.BLOCK2.CT .BS 4 Creation time
.HS 0100C3270D version/min version/access/EL/EPB
.DA 0 File Count
.DA 4 bitmap pointer (Block 2&3 are Volume directory)
RW.BLOCK2.TB .BS 2 Total Blocks
RW.BLOCK2.END .EQ *
*--------------------------------------
2021-02-26 20:13:48 +00:00
.INB usr/src/shared/x.printf.s
2015-03-14 21:48:35 +00:00
*--------------------------------------
RW.MSG .AZ "SuperExpander E, RAMWorks (I,II,III,z-Ram) Driver For A2osX\n"
RW.MSG.OK .AZ "/RAM3 Device Already Installed.\n"
2020-08-07 19:49:24 +00:00
RW.MSG.OK1 .AZ "%D KB Detected (%d Pages), %D KB (%d Pages) Available for RamDrive.\n"
RW.MSG.KO1 .AZ "Not Detected.\n"
RW.MSG.OK2 .AZ "RamWorks Driver Installed.\n"
RW.MSG.KO2 .AZ "RamWorks Driver Install Error.\n"
RW.MSG.OK3 .AZ "RamWorks Drive Formatted as /RAM3.\n"
RW.MSG.KO3 .AZ "RamWorks Drive Format Error.\n"
2015-03-14 21:48:35 +00:00
*--------------------------------------
* Driver for Ramworks in main LC
* $FF00 -> $FF9A (Inclusive)
* $FF58 MUST BE $60 (RTS)
2021-02-26 20:13:48 +00:00
* DO NOT trash DRV.COMMAND...DRV.BLKNUM as ProDOS
2015-03-14 21:48:35 +00:00
* reuses it after Block operation
2021-02-26 20:13:48 +00:00
* A1,A2 are used by Disk II Driver,
2015-06-03 18:30:57 +00:00
* so we use it safely as Tmp Ptr
2015-03-14 21:48:35 +00:00
*--------------------------------------
2015-06-03 18:30:57 +00:00
DRV.A2L .EQ $3E
DRV.A2H .EQ $3F
2015-03-14 21:48:35 +00:00
DRV.COMMAND .EQ $42
2021-02-26 20:13:48 +00:00
DRV.BUFF .EQ $44
DRV.BLKNUM .EQ $46
2015-03-14 21:48:35 +00:00
*--------------------------------------
2020-07-17 15:18:31 +00:00
RWDRV.B.START .PH $FF00
2021-02-26 20:13:48 +00:00
RWDRV.START ldy DRV.COMMAND 0 = Status ?
2015-03-14 21:48:35 +00:00
beq RMDRV.CMDSTATUS
2020-08-28 17:10:23 +00:00
2015-03-14 21:48:35 +00:00
cpy #3
2020-08-28 15:11:27 +00:00
2015-03-14 21:48:35 +00:00
beq RWDRV.EXITOK 3 = Format : nothing to do, exit with no error
2020-08-28 17:10:23 +00:00
bcs RWDRV.IOERR > 3 = Invalid OP, IO error
2015-03-14 21:48:35 +00:00
2020-07-14 20:17:15 +00:00
ldx DRV.BLKNUM
cpx RWDRV.MAXLO+1
2015-03-14 21:48:35 +00:00
lda DRV.BLKNUM+1
sbc RWDRV.MAXHI+1
bcs RWDRV.IOERR DRV.BLKNUM >= RW.DRV.SIZE, IO error
2020-07-14 20:17:15 +00:00
2020-08-28 15:11:27 +00:00
bit RD80STORE save 80 Store status
2020-07-18 14:04:21 +00:00
php Disable IRQ as no vector set in RW Banks
sei
2021-02-26 20:13:48 +00:00
sta CLR80STORE make sure SETREADAUX/SETWRITEAUX effective everywhere
2020-07-14 20:17:15 +00:00
txa Get Back DRV.BLKNUM
2015-06-03 18:30:57 +00:00
asl compute PAGE = blocknumLO *2
2015-03-14 21:48:35 +00:00
pha
lda DRV.BLKNUM+1 compute BANK = blocknumHI *2
rol
inc +1 for skipping Aux BANK 0
2020-07-18 14:04:21 +00:00
2015-03-14 21:48:35 +00:00
plx move page into X
beq RWDRV.GOAUX move from/to aux page0/1
2020-07-18 14:04:21 +00:00
2015-03-14 21:48:35 +00:00
cpx #$C0
bcs RWDRV.GOAUX move from/to aux LC
*--------------------------------------
* X=Page($02 -> $BF),A=Bank,Y=CMD
*--------------------------------------
RWDRV.IO1 sta RWBankSelect Select RAMWorks Bank
2015-03-14 21:48:35 +00:00
2015-06-03 18:30:57 +00:00
inx second 256 bytes first
stx DRV.A2H Use DRV.A1L/H for RAM PTR
stz DRV.A2L
inc DRV.BUFF+1
2015-03-14 21:48:35 +00:00
dey Y=CMD, zero if read
2015-06-03 18:30:57 +00:00
bne RWDRV.W non zero, go write
2019-10-09 10:05:08 +00:00
2015-03-14 21:48:35 +00:00
sta SETREADAUX
2015-06-03 18:30:57 +00:00
ldx #DRV.A2L READ:copy from RAM to BUFF
lda #DRV.BUFF
2015-03-14 21:48:35 +00:00
bra RWDRV.RW
2019-10-09 10:05:08 +00:00
2019-10-03 06:25:27 +00:00
RWDRV.W sta SETWRITEAUX
2015-03-14 21:48:35 +00:00
ldx #DRV.BUFF
2015-06-03 18:30:57 +00:00
lda #DRV.A2L WRITE:copy from BUFF to RAM
dey Make sure Y=0 for main loop below
2015-03-14 21:48:35 +00:00
RWDRV.RW stx RWDRV.RW.SRC+1
2015-06-03 18:30:57 +00:00
sta RWDRV.RW.DST+1
2015-03-14 21:48:35 +00:00
2020-07-20 15:19:32 +00:00
* clc 2 pages to copy
.HS B0 BCS
RWDRV.RW.LOOP sec
2015-03-14 21:48:35 +00:00
RWDRV.RW.SRC lda ($FF),y
RWDRV.RW.DST sta ($FF),y
iny
bne RWDRV.RW.SRC
2015-06-03 18:30:57 +00:00
dec DRV.BUFF+1
dec DRV.A2H
2020-07-20 15:19:32 +00:00
bcc RWDRV.RW.LOOP
2015-03-14 21:48:35 +00:00
2020-08-28 15:11:27 +00:00
RWDRV.EXIT stz RWBankSelect
2015-03-14 21:48:35 +00:00
sta CLRREADAUX
sta CLRWRITEAUX
2019-10-09 10:05:08 +00:00
2020-07-14 20:17:15 +00:00
plp restore IRQ
2015-03-14 21:48:35 +00:00
2020-08-28 15:11:27 +00:00
bpl RMDRV.CMDSTATUS
sta SET80STORE
2020-07-20 15:19:32 +00:00
2019-10-03 06:25:27 +00:00
RMDRV.CMDSTATUS
2015-03-14 21:48:35 +00:00
RWDRV.MAXLO ldx #$FF return device block count in X,Y...
RWDRV.MAXHI ldy #$FF
RWDRV.EXITOK lda #0 make A=0
clc
rts
2020-08-28 17:10:23 +00:00
RWDRV.IOERR lda #MLI.E.IO Carry already set
rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
* X=Page(0/1 or LC),A=Bank
*--------------------------------------
RWDRV.GOAUX pha save BANK
2021-02-26 20:13:48 +00:00
sta SETWRITEAUX
2015-03-14 21:48:35 +00:00
ldy #RWDRVX.XM.SIZE Backup begining of $300 to generate move code
2019-10-09 10:05:08 +00:00
2015-03-14 21:48:35 +00:00
.1 lda RWDRV.XM.RUN-1,y
sta RWDRVX.XM.SAVE-1,y
dey
bne .1
2019-10-09 10:05:08 +00:00
2015-03-14 21:48:35 +00:00
pla restore BANK
2019-10-09 10:05:08 +00:00
2015-03-14 21:48:35 +00:00
sta SETREADAUX
jsr RWDRVX.START Setup Code in main mem at $300 for data move
* returns : CC=WRITE, CS=READ
sta CLRREADAUX CLRWRITEAUX already triggered by code copy
jsr RWDRV.XM.RUN Now execute generated code in main memory
2020-08-28 15:11:27 +00:00
2015-03-14 21:48:35 +00:00
sta SETREADAUX
2020-08-28 15:11:27 +00:00
jmp RWDRVX.RESTORE
2019-10-09 10:05:08 +00:00
2015-03-14 21:48:35 +00:00
RWDRV.END .EP
RWDRV.B.END
2020-07-20 15:19:32 +00:00
.LIST ON
2015-03-14 21:48:35 +00:00
RWDRV.SIZE .EQ RWDRV.B.END-RWDRV.B.START
2020-07-20 15:19:32 +00:00
.LIST OFF
2015-03-14 21:48:35 +00:00
*--------------------------------------
* Driver for Ramworks in aux memory
* $0200 -> $02FF TMP buffer for PAGE copy
* $0300 -> $03FD (Inclusive)
* do not trash $03FE-$03FF (IRQ Vector)
2021-02-26 20:13:48 +00:00
* X=Page(0/1 or LC),A=Bank
2015-03-14 21:48:35 +00:00
*--------------------------------------
RMDRVX.TMP .EQ $200
RWDRV.XM.RUN .EQ $300
*--------------------------------------
2021-02-27 14:54:51 +00:00
RWDRVX.B.START .PH $0300
2015-03-14 21:48:35 +00:00
RWDRVX.START sta RWDRVX.XM.BANK+1 setup BANK
2021-02-27 14:54:51 +00:00
lda DRV.COMMAND DRV.COMMAND: 1=READ,2=WRITE
lsr
php
2021-02-26 20:13:48 +00:00
ldy #RRAMWRAMBNK1
2015-03-14 21:48:35 +00:00
txa
beq .1 page 0/1, no need to check BANK
2019-10-31 15:59:11 +00:00
2015-03-14 21:48:35 +00:00
cmp #$D0 $C0 <= PAGE < $D0 ?
bcs .1 no, store in BNK1
2019-10-31 15:59:11 +00:00
2015-03-14 21:48:35 +00:00
ora #$10 Remap $C0 page to $D0 BNK2
2019-10-31 15:59:11 +00:00
2021-02-26 20:13:48 +00:00
ldy #RRAMWRAMBNK2
.1 sty RWDRVX.XM.RWLC+1 Save to select proper RW bank later
2015-03-14 21:48:35 +00:00
ldy DRV.BUFF
ldx DRV.BUFF+1
2021-02-26 20:13:48 +00:00
2021-02-27 14:54:51 +00:00
plp
2015-03-14 21:48:35 +00:00
bcc .2 CC=WRITE, CS=READ
2019-10-31 15:59:11 +00:00
2015-03-14 21:48:35 +00:00
stz RWDRVX.XM.SRC+1 READ from src LO = 0
sta RWDRVX.XM.SRC+2 READ from src HI = PAGE
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
sty RWDRVX.XM.DST+1 WRITE to DRV.BUFF
stx RWDRVX.XM.DST+2
bra .3
2019-10-31 15:59:11 +00:00
2015-03-14 21:48:35 +00:00
.2 sty RWDRVX.XM.SRC+1 READ from DRV.BUFF
stx RWDRVX.XM.SRC+2
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
stz RWDRVX.XM.DST+1 WRITE to dst LO = 0
sta RWDRVX.XM.DST+2 WRITE to dst HI = PAGE
2019-10-31 15:59:11 +00:00
2015-03-14 21:48:35 +00:00
.3 sta CLRWRITEAUX
ldy #RWDRVX.XM.SIZE
2019-10-31 15:59:11 +00:00
2015-03-14 21:48:35 +00:00
.4 lda RWDRVX.XM.START-1,y
sta RWDRV.XM.RUN-1,y
dey
bne .4
2019-10-31 15:59:11 +00:00
2015-03-14 21:48:35 +00:00
rts
*--------------------------------------
* Called form Main LC after RWDRVX.XM execution
*--------------------------------------
2021-02-26 20:13:48 +00:00
RWDRVX.RESTORE ldy #RWDRVX.XM.SIZE Now, restore begining of $300
2020-07-18 14:04:21 +00:00
2015-03-14 21:48:35 +00:00
.1 lda RWDRVX.XM.SAVE-1,y
sta RWDRV.XM.RUN-1,y
dey
bne .1
2020-07-18 14:04:21 +00:00
2020-08-28 15:11:27 +00:00
jmp RWDRV.EXIT
2015-03-14 21:48:35 +00:00
*--------------------------------------
2020-09-09 12:47:18 +00:00
* LC Copy Code, moved from Aux to main $300
* $0200 -> $02FF TMP buffer for 2 steps move between LCs
2015-03-14 21:48:35 +00:00
* CC=WRITE :
* CS=READ :
*--------------------------------------
2020-09-09 12:47:18 +00:00
RWDRVX.XM.START ldy #2 2 pages to copy
2020-12-15 13:23:22 +00:00
RWDRVX.XM.COPY sta CLRALTZP
2021-02-26 20:13:48 +00:00
2020-12-15 13:23:22 +00:00
jsr RWDRV.XM.RUN+RWDRVX.XM.SRCLC-RWDRVX.XM.START
sta $C000,x select proper Main/Aux ZP/LC
RWDRVX.XM.IO1 sta RWBankSelect
2021-02-26 20:13:48 +00:00
2020-09-09 12:47:18 +00:00
ldx #0
2015-03-14 21:48:35 +00:00
RWDRVX.XM.SRC lda $FFFF,x
sta RMDRVX.TMP,x
inx
bne RWDRVX.XM.SRC
2019-10-31 15:59:11 +00:00
2020-12-15 13:23:22 +00:00
sta CLRALTZP
2021-02-26 20:13:48 +00:00
2020-09-09 12:47:18 +00:00
jsr RWDRV.XM.RUN+RWDRVX.XM.DSTLC-RWDRVX.XM.START
2020-12-15 13:23:22 +00:00
sta $C000,x select proper Main/Aux ZP/LC
RWDRVX.XM.IO2 sta RWBankSelect
2021-02-26 20:13:48 +00:00
2020-09-09 12:47:18 +00:00
ldx #0
2019-10-31 15:59:11 +00:00
2020-09-09 12:47:18 +00:00
RWDRVX.XM.2 lda RMDRVX.TMP,x
2015-03-14 21:48:35 +00:00
RWDRVX.XM.DST sta $FFFF,x
inx
2020-09-09 12:47:18 +00:00
bne RWDRVX.XM.2
2015-03-14 21:48:35 +00:00
inc RWDRV.XM.RUN+RWDRVX.XM.SRC+2-RWDRVX.XM.START
inc RWDRV.XM.RUN+RWDRVX.XM.DST+2-RWDRVX.XM.START
dey
bne RWDRVX.XM.COPY
2021-02-26 20:13:48 +00:00
2020-09-09 12:47:18 +00:00
sta CLRALTZP
RWDRVX.XM.IO3 stz RWBankSelect
2020-09-09 12:47:18 +00:00
*--------------------------------------
RWDRVX.XM.MNLC bit RRAMWRAMBNK1 ProDOS always uses LCBANK1
2021-02-26 20:13:48 +00:00
2020-09-09 12:47:18 +00:00
lda #0
2021-02-26 20:13:48 +00:00
2020-09-09 12:47:18 +00:00
ldx #CLRALTZP
2019-10-21 14:25:37 +00:00
2020-09-09 12:47:18 +00:00
rts
*--------------------------------------
RWDRVX.XM.SRCLC bcc RWDRVX.XM.MNLC CC=WRITE,CS=READ?
.HS 2C BIT ABS
2021-02-26 20:13:48 +00:00
RWDRVX.XM.DSTLC bcs RWDRVX.XM.MNLC CC=WRITE,CS=READ?
2020-09-09 12:47:18 +00:00
*--------------------------------------
2021-02-27 14:54:51 +00:00
RWDRVX.XM.RWLC bit $C000
2019-10-21 14:25:37 +00:00
2015-03-14 21:48:35 +00:00
RWDRVX.XM.BANK lda #$FF
2021-02-26 20:13:48 +00:00
2020-09-09 12:47:18 +00:00
ldx #SETALTZP
2021-02-26 20:13:48 +00:00
2015-03-14 21:48:35 +00:00
rts
*--------------------------------------
2020-09-09 12:47:18 +00:00
.LIST ON
RWDRVX.XM.SIZE .EQ *-RWDRVX.XM.START
.LIST OFF
2015-03-14 21:48:35 +00:00
*--------------------------------------
RWDRVX.XM.SAVE .BS RWDRVX.XM.SIZE
*--------------------------------------
.EP
*--------------------------------------
2020-09-09 12:47:18 +00:00
RWDRVX.B.END .LIST ON
2019-10-09 10:05:08 +00:00
RWDRVX.SIZE .EQ RWDRVX.B.END-RWDRVX.B.START
.LIST OFF
2015-03-14 21:48:35 +00:00
*--------------------------------------
* CONTROL SECTION :
*--------------------------------------
.DO RWDRV.SIZE>$9B
ERROR:RWDRV.SIZE too big
.FIN
.DO RWDRVX.SIZE>$FE
ERROR:RWDRVX.SIZE too big
.FIN
.DO RWDRVX.XM.SIZE>$F0
ERROR:RWDRVX.XM.SIZE too big
.FIN
*--------------------------------------
MAN
2021-02-26 20:13:48 +00:00
SAVE usr/src/sys/km.ramworks.s
2015-03-14 21:48:35 +00:00
ASM