A2osX/ProDOS.203/ProDOS.S.RAMX.txt

323 lines
9.6 KiB
Plaintext
Raw Normal View History

2019-04-29 20:36:58 +00:00
NEW
AUTO 3,1
2019-09-11 15:53:33 +00:00
* object code = ram_0
2019-04-29 20:36:58 +00:00
* /RAM driver (aux bank portion)
* this code is packed into $200 length with no room for expansion !!
* (see note at end of this obj)
* after the main /RAM routine has determined that the command is ok and the
* block to be read/written is within range, it transfers control to this
* aux /RAM routine which remaps the block requested as follows:
2019-09-10 20:53:18 +00:00
* request blocks 0,1: invalid
* 2: returns VDIR (card block 3)
* 3: returns BITMAP (synthesized)
* 4: returns card block 0
* $05-$5F: returns card blocks $05-$5F
* $60-$67: returns blocks $68-$7F in bank 1 of language card
* $68-$7F: returns blocks $68-$7F in bank 2 of language card
2019-04-29 20:36:58 +00:00
2019-09-15 15:13:48 +00:00
H5100 lda RD80STORE read 80 store
2019-09-13 20:48:05 +00:00
pha save for later
sta CLR80STORE turn off 80 store
ldx #$04 move the parameters for use:
L5109 lda A4L,x cmd, unit, bufptr and block (lo)
sta tcmd,x -> tcmd, tunit, R2L, R2H, R01
2019-09-10 20:53:18 +00:00
dex
bpl L5109
2019-09-13 20:48:05 +00:00
and formatflg format the volume first time
bne L514F thru, or when requested.
ldx bloknml save R01 during format.
lda /vblock1 block to be cleared.
jsr clrbuf1 clears all buffers.
ldy #$03 format volume in 2 chunks.
L511F lda VDIR,y
2019-09-10 20:53:18 +00:00
sta vblock1+4,y
dey
bpl L511F
2019-09-13 20:48:05 +00:00
lda #$FE set last block as unusable
sta BITMAP+15 to protect vectors.
tya set bitmap bits to $FF.
ldy #$0E 15 bytes to set
L5130 sta BITMAP,y
2019-09-10 20:53:18 +00:00
dey
bne L5130
2019-09-13 20:48:05 +00:00
sty BITMAP first byte = 0.
ldy #$07 do other chunk
L513B lda access,y
2019-09-10 20:53:18 +00:00
sta vblock1+34,y
dey
bpl L513B
2019-09-13 20:48:05 +00:00
lda formatflg if 0, set to $FF
bne L51AA else exitcard.
sty formatflg y = $FF, won't format next time.
stx R01 restore R01
2019-04-29 20:36:58 +00:00
* use the requested block number to determine
* which routine performs the transfer
2019-09-13 20:48:05 +00:00
L514F asl R01 block requested -> page requested.
lda R01 get page requested.
cmp #$BF in language card ?
bcs L5163 yes, do it.
cmp #$06 bitmap ?
2019-09-10 20:53:18 +00:00
bne L5160
2019-09-13 20:48:05 +00:00
jmp tbmap yes, transfer bitmap
L5160 jmp treg else normal transfer.
2019-04-29 20:36:58 +00:00
* when a block between $60 and $7F is requested, it must be spirited into/from
* the language card area of the 64k card. this requires a 2 stage move:
* into the temp buffer and then to it's real destination.
2019-09-13 20:48:05 +00:00
L5163 tax save R1 for later.
jsr setptr get direction
php and save it.
bcs L51B8 if it's a write.
2019-09-15 15:13:48 +00:00
lcrd txa get R1 back
2019-09-13 20:48:05 +00:00
cmp #$CF which bank is it in ?
bcs L5173 in main bank.
ora #$10 in secondary bank.
bne L5179 branch always.
L5173 sta RRAMWRAMBNK2 turn on main $D000
2019-09-12 06:39:47 +00:00
sta RRAMWRAMBNK2
2019-09-13 20:48:05 +00:00
L5179 sta R01 restore R1.
lda R2H save R2 for later
2019-09-10 20:53:18 +00:00
pha
ldx R2L
2019-09-13 20:48:05 +00:00
sta SETALTZP use alternate zero page/stack
lda /dbuf set R2 to dbuf
2019-09-10 20:53:18 +00:00
sta R2H
2019-09-11 15:53:33 +00:00
lda #dbuf
2019-09-10 20:53:18 +00:00
sta R2L
2019-09-13 20:48:05 +00:00
jsr setptr set pointers
tay A > 0 from setptr
L5194 lda (A1L),y move A1,A2 to A4,A3
2019-09-10 20:53:18 +00:00
sta (A4L),y
lda (A2L),y
sta (A3L),y
dey
bne L5194
2019-09-13 20:48:05 +00:00
sta CLRALTZP use main zero page/stack
L51A2 stx R2L
pla restore R2
2019-09-10 20:53:18 +00:00
sta R2H
2019-09-13 20:48:05 +00:00
plp get direction.
L51AA bcs L51B5 write, done with move.
sta RRAMWRAMBNK1 switch in MLI part of LC
2019-09-12 06:39:47 +00:00
sta RRAMWRAMBNK1
2019-09-10 20:53:18 +00:00
jsr blockdo0 read, transfer dbuf to main
2019-09-13 20:48:05 +00:00
L51B5 jmp exitcard
L51B8 jsr blockdo0 transfer main to dbuf.
jmp lcrd transfer dbuf to language card
2019-04-29 20:36:58 +00:00
* blockdo0 transfers a block between main memory and the 64k card. R1 contains
* the page address of the block in the card; R2 contains the page address of
* the block in main memory. the address in main memory is always in the
* language card, so the language card is always switched in. if cmd is 2, a
* write is done (R2->R1); if cmd is 1, a read is done (R1->R2).
2019-09-15 15:13:48 +00:00
blockdo0 lda /dbuf set up R1 = dbuf
blockdo1 sta R01
blockdo jsr setptr set pointers.
2019-09-13 20:48:05 +00:00
bcs L51DB it's a write.
sta CLRWRITEAUX transfer buffer directly to main.
tay 0 left from setptr.
L51CC lda (A1L),y transfer A1,A2 to A4,A3
2019-09-10 20:53:18 +00:00
sta (A4L),y
lda (A2L),y
sta (A3L),y
dey
bne L51CC
2019-09-13 20:48:05 +00:00
sta SETWRITEAUX back the way it was.
2019-09-15 15:13:48 +00:00
donewrt rts mainwrt returns here
2019-09-13 20:48:05 +00:00
L51DB lda #mainwrt pointers set up,
sta passit pass control to main ram
2019-09-11 15:53:33 +00:00
lda /mainwrt
2019-09-13 20:48:05 +00:00
jmp ex1 set passit+1 and transfer
2019-04-29 20:36:58 +00:00
* setptr is used by other routines to set up pointers and dtect read or write
2019-09-15 15:13:48 +00:00
setptr lda tcmd is it read or write ?
2019-09-11 15:53:33 +00:00
lsr
2019-09-13 20:48:05 +00:00
bcs L5208 taken if write.
lda R2H destination page
2019-09-10 20:53:18 +00:00
sta A4L+1
sta A3L+1
lda R2L
sta A4L
sta A3L
2019-09-13 20:48:05 +00:00
lda R01 source page
2019-09-10 20:53:18 +00:00
sta A1L+1
sta A2L+1
2019-09-13 20:48:05 +00:00
lda #$00 source page aligned
2019-09-10 20:53:18 +00:00
sta A1L
sta A2L
beq L5223
2019-09-13 20:48:05 +00:00
L5208 lda R2H source page
2019-09-10 20:53:18 +00:00
sta A1L+1
sta A2L+1
lda R2L
sta A1L
sta A2L
2019-09-13 20:48:05 +00:00
lda R01 destination page
2019-09-10 20:53:18 +00:00
sta A4L+1
sta A3L+1
2019-09-13 20:48:05 +00:00
lda #$00 destination page aligned
2019-09-10 20:53:18 +00:00
sta A4L
sta A3L
2019-09-11 15:53:33 +00:00
L5223 inc A2L+1
inc A3L+1
2019-09-10 20:53:18 +00:00
rts
2019-04-29 20:36:58 +00:00
* tzip is called if blocks 0,1,4,5 are requested.
* on write it does nothing, on read it returns 0's.
2019-09-13 20:48:05 +00:00
tzip jsr clrbuf0 fill dbuf with 0's
jsr blockdo transfer the 0's
jmp exitcard and return
2019-04-29 20:36:58 +00:00
* clrbuf fills the buffer indicated by R01 to 0's.
* should only be called on a read or format.
2019-09-15 15:13:48 +00:00
clrbuf0 lda /dbuf dbuf is temp buffer.
clrbuf1 sta R01 assign to block.
clrbuf2 jsr setptr set pointers
2019-09-13 20:48:05 +00:00
tay acc = 0
L523A sta (A1L),y
2019-09-10 20:53:18 +00:00
sta (A2L),y
dey
bne L523A
rts
2019-04-29 20:36:58 +00:00
* treg maps the requested block into the aux card
* so that 8k data files will be contiguous (the index
* blocks will not be placed within data).
2019-09-15 15:13:48 +00:00
treg cmp #$04 page 4 = vdir
2019-09-13 20:48:05 +00:00
bne L524A not vdir, continue
lda #$07 else transfer block 7
2019-09-10 20:53:18 +00:00
bne L5258
2019-09-13 20:48:05 +00:00
L524A cmp #$0F if any page < $F (block 8) requested,
bcc tzip it is invalid.
ldx #$00 x = # of iterations.
lda bloknml use true block #.
cmp #$5D beyond 8k blocks ?
bcc L525B no, do normal
sbc #$50 else subtract offset
L5258 jmp times2 and multiply by 2
2019-04-29 20:36:58 +00:00
* determine which 8k chunk it is in, place in x;
* block offset into chunk goes into y.
2019-09-13 20:48:05 +00:00
L525B sec
sbc #$08 block=block-6
L525E cmp #$11 if <=17 then done
2019-09-10 20:53:18 +00:00
bcc L5268
2019-09-13 20:48:05 +00:00
sbc #$11 else block=block-17.
inx iteration count.
bpl L525E should branch always
2019-09-15 15:13:48 +00:00
brk otherwise crash !!!
2019-09-13 20:48:05 +00:00
L5268 tay remainder in y
2019-04-29 20:36:58 +00:00
* if remainder is 1 then it's an index block:
* start index blocks at $1000,$2000...$19FF.
* if remainder is 0 then it is first data block
* in 8k chunk. page is 32 + (16 * x).
* otherwise, it is some other data block.
* page is 32 + (16 * x) + (2 * y)
2019-09-13 20:48:05 +00:00
cpy #$01 is it index block ?
bne L5273 no.
txa index = 2 * (8 + x)
2019-09-10 20:53:18 +00:00
clc
adc #$08
2019-09-15 15:13:48 +00:00
bne times2 multiply by 2.
2019-09-13 20:48:05 +00:00
L5273 inx iteration + 1.
txa page = 2 * (16 + 8x)
2019-09-10 20:53:18 +00:00
asl
asl
asl
asl
sta R01
2019-09-13 20:48:05 +00:00
tya get offset into 8k chunk
beq L5281 if 0, no offset
dey else offset = 2 * y
2019-09-10 20:53:18 +00:00
tya
2019-09-13 20:48:05 +00:00
L5281 clc
2019-09-10 20:53:18 +00:00
adc R01
2019-09-15 15:13:48 +00:00
times2 asl acc = 2 * acc
2019-09-13 20:48:05 +00:00
jsr blockdo1 store in R01 and transfer
jmp exitcard and return
2019-04-29 20:36:58 +00:00
* when block 3 is requested, the bitmap is returned. the real bitmap is only
* 16 bytes long; the rest of the block is synthesized. the temporary buffer
* at $800 is used to build/read a full size bitmap block.
2019-09-15 15:13:48 +00:00
tbmap lda /dbuf use temp buffer as block
2019-09-10 20:53:18 +00:00
sta R01
2019-09-13 20:48:05 +00:00
jsr setptr set pointers, test read/write.
bcs L52A9 branch if it's write.
2019-09-10 20:53:18 +00:00
jsr clrbuf2
2019-09-13 20:48:05 +00:00
ldy #$0F put real bitmap there
L529B lda BITMAP,y
2019-09-10 20:53:18 +00:00
sta (A1L),y
dey
bpl L529B
2019-09-13 20:48:05 +00:00
jsr blockdo move temp buf to user buf
2019-09-10 20:53:18 +00:00
jmp exitcard
2019-09-13 20:48:05 +00:00
L52A9 jsr blockdo move user buf to temp buf
2019-09-10 20:53:18 +00:00
jsr setptr
2019-09-13 20:48:05 +00:00
ldy #$0F move temp buf to bitmap.
L52B1 lda (A4L),y (pointer set by setptr)
2019-09-10 20:53:18 +00:00
sta BITMAP,y
dey
bpl L52B1
jmp exitcard
2019-04-29 20:36:58 +00:00
2019-09-15 15:13:48 +00:00
formatflg .HS 00 not formatted yet
tcmd .HS 00 command
2019-09-13 20:48:05 +00:00
.HS 00 unit (not used)
2019-09-15 15:13:48 +00:00
R2L .HS 00 R2 = user buffer
R2H .HS 00
R01 .HS 00 page requested
BITMAP .HS 00FFFFFF blocks 0-7 used
2019-09-10 15:46:56 +00:00
.HS FFFFFFFF
2019-09-13 20:48:05 +00:00
.HS FFFFFFFF
.HS FFFFFFFE
2019-09-15 15:13:48 +00:00
VDIR .HS F3 storage type = F, name length = 3
2019-09-13 20:48:05 +00:00
.AS "RAM"
2019-09-15 15:13:48 +00:00
access .DA #$C3 destroy, rename, read enabled
2019-09-13 20:48:05 +00:00
.HS 27 entry length
2019-09-10 15:46:56 +00:00
.HS 0D
.HS 0000
2019-09-13 20:48:05 +00:00
.HS 0300 block 3
.HS 7F 128 blocks
2019-04-29 20:36:58 +00:00
2019-09-15 15:13:48 +00:00
exitcard lda RRAMWRAMBNK1 restore language card
2019-09-12 06:39:47 +00:00
lda RRAMWRAMBNK1
2019-09-13 20:48:05 +00:00
pla get 80store
bpl L52EA 80store wasn't on
sta SET80STORE enable 80store
L52EA jmp bypass jump around passit
2019-09-15 15:13:48 +00:00
passit .HS 0000
bypass lda #noerr set up return to noerr
2019-09-10 15:46:56 +00:00
sta passit
lda /noerr
2019-09-15 15:13:48 +00:00
ex1 sta passit+1 also used by blockwrite
2019-09-13 20:48:05 +00:00
clc transfer card to main
clv use standard zeropage/stack
jmp xfer jmp back from language card.
2019-04-29 20:36:58 +00:00
* NOTE: the previous section of code MUST NOT use $3FE or $3FF
2019-09-10 20:53:18 +00:00
* since the interrupt vector must go there if aux interrupts
* are to be used. no room for expansion here !!
2019-04-29 20:36:58 +00:00
2019-09-13 20:48:05 +00:00
.HS 0000 $3FE-$3FF
2019-04-29 20:36:58 +00:00
* end of obj ram_0
*--------------------------------------
MAN
SAVE usr/src/prodos.203/prodos.s.ramx
LOAD usr/src/prodos.203/prodos.s
2019-04-29 20:36:58 +00:00
ASM