home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Brotikasten
/
BROTCD01.iso
/
c128
/
c119.d64
/
lrr.s
< prev
next >
Wrap
Text File
|
1995-08-09
|
12KB
|
718 lines
;╠ITTLE ╥ED ╥EADER ═╙-─╧╙ FILE COPIER PROGRAM
;WRITTEN 92/10/03 BY ├RAIG ┬RUCE FOR ├= ╚ACKING ╬ET ═AGAZINE
.ORG $8000
.OBJ "@:LRR.BIN"
;====JUMP TABLE AND PARAMETERS INTERFACE ====
JMP INIT╨ACKAGE
JMP LOAD─IRECTORY
JMP COPY╞ILE
.BYTE $CB,131 ;IDENTIFICATION
.BYTE 0,0,0,0
ERRNO .BUF 1 ;(LOCATION PK+15)
SOURCE─EVICE .BUF 1
SOURCE╘YPE .BUF 1 ;$00=1571, $FF=1581
START├LUSTER .BUF 2
LEN═╠ .BUF 2 ;LENGTH MEDIUM AND LOW BYTES
;====GLOBAL DECLARAIONS====
KERNEL╠ISTEN = $FFB1
KERNEL╙ECOND = $FF93
KERNEL╒NLSN = $FFAE
KERNEL┴CPTR = $FFA2
KERNEL├IOUT = $FFA8
KERNEL╙PINP = $FF47
KERNEL├HKOUT = $FFC9
KERNEL├LRCHN = $FFCC
KERNEL├HROUT = $FFD2
ST = $D0
CIA├LOCK = $DD00
CIA╞LAGS = $DC0D
CIA─ATA = $DC0C
CLUSTER┬LOCK├OUNT .BUF 1 ;1 OR 2
FAT┬LOCKS .BUF 1 ;UP TO 3
ROOT─IR┬LOCKS .BUF 1 ;UP TO 8
ROOT─IR┼NTRIES .BUF 1 ;UP TO 128
TOTAL╙ECTORS .BUF 2 ;UP TO 1440
FIRST╞ILE┬LOCK .BUF 1
FIRST╥OOT─IR┬LOCK .BUF 1
FILE├LUSTER├OUNT .BUF 2
BUF├YLINDER .BUF 1
BUF╙IDE .BUF 1
FORMAT╨ARMS .BUF 6
;====HARDWARE LEVEL====
SEND╒0 = * ;( .┴=BURST├OMMAND├ODE ) : .├╙=ERR
PHA
LDA #0
STA ST
LDA SOURCE─EVICE
JSR KERNEL╠ISTEN
LDA #$6F
JSR KERNEL╙ECOND
LDA #"U"
JSR KERNEL├IOUT
BIT ST
BMI SEND╒0┼RROR
LDA #"0"
JSR KERNEL├IOUT
PLA
JSR KERNEL├IOUT
BIT ST
BMI SEND╒0┼RROR
CLC
RTS
SEND╒0┼RROR = *
LDA #5
STA ERRNO
SEC
RTS
TOGGLE├LOCK = *
LDA CIA├LOCK
EOR #$10
STA CIA├LOCK
RTS
SERIAL╫AIT = *
LDA #$08
- BIT CIA╞LAGS
BEQ -
RTS
GET┬URST┬YTE = *
JSR SERIAL╫AIT
LDX CIA─ATA
JSR TOGGLE├LOCK
TXA
RTS
MOUNT─ISK = * ;() : .├╙=ERR
LDA #%00011010
JSR SEND╒0
BCC +
RTS
+ JSR KERNEL╒NLSN
BIT ST
BMI SEND╒0┼RROR
CLC
JSR KERNEL╙PINP
BIT CIA╞LAGS
JSR TOGGLE├LOCK
JSR GET┬URST┬YTE
STA ERRNO
AND #$0F
CMP #2
BCS MOUNT┼XIT
LDY #0
- JSR GET┬URST┬YTE
STA FORMAT╨ARMS,Y
INY
CPY #6
BCC -
CLC
;** SET INTERLEAVE
LDA #%00001000
JSR SEND╒0
BCC +
RTS
+ LDA #1 ;INTERLEAVE OF 1 FOR 1581
BIT SOURCE╘YPE
BMI +
LDA #4 ;INTERLEAVE OF 4 FOR 1571
+ JSR KERNEL├IOUT
JSR KERNEL╒NLSN
MOUNT┼XIT = *
RTS
BUFPTR = 2
SECNUM = 4
READ╘RACK = * ;( .┴=CYLINDER, .╪=SIDE ) : TRACKBUF, .├╙=ERR
PHA
TXA
AND #$01
ASL
ASL
ASL
ASL
BIT SOURCE╘YPE
BPL +
EOR #$10
+ JSR SEND╒0
BCC +
RTS
+ PLA ;CYLINDER NUMBER
JSR KERNEL├IOUT
LDA #1 ;START SECTOR NUMBER
JSR KERNEL├IOUT
LDA #9 ;SECTOR COUNT
JSR KERNEL├IOUT
JSR KERNEL╒NLSN
SEI
CLC
JSR KERNEL╙PINP
BIT CIA╞LAGS
JSR TOGGLE├LOCK
LDA #<TRACKBUF
LDY #>TRACKBUF
STA BUFPTR
STY BUFPTR+1
LDA #0
STA SECNUM
- BIT SOURCE╘YPE
BMI +
JSR GET1571┬UF╨TR
+ JSR READ╙ECTOR
BCS TRACK┼XIT
INC SECNUM
LDA SECNUM
CMP #9
BCC -
CLC
TRACK┼XIT = *
CLI
RTS
GET1571┬UF╨TR = *
LDA #<TRACKBUF
STA BUFPTR
LDX SECNUM
CLC
LDA #>TRACKBUF
ADC BUFPTR1571,X
STA BUFPTR+1
RTS
BUFPTR1571 = *
.BYTE 0,8,16,6,14,4,12,2,10
READ╙ECTOR = * ;( BUFPTR ) : .├╙=ERR
JSR GET┬URST┬YTE
STA ERRNO
AND #$0F
CMP #2
BCC +
RTS
+ LDX #2
LDY #0
READ┬YTE = *
LDA #$08
- BIT CIA╞LAGS
BEQ -
LDA CIA├LOCK
EOR #$10
STA CIA├LOCK
LDA CIA─ATA
STA (BUFPTR),Y
INY
BNE READ┬YTE
INC BUFPTR+1
DEX
BNE READ┬YTE
RTS
;====LOGICAL SECTOR LEVEL====
INIT╨ACKAGE = *
LDA #$0E
STA $FF00
LDA #$FF
STA BUF├YLINDER
STA BUF╙IDE
CLC
RTS
SECTOR╙AVE = 5
READ┬LOCK = * ;( .┴=CYLINDER,.╪=SIDE,.┘=SECTOR ) : .┴┘=BLK╨TR,.├╙=ERR
CMP BUF├YLINDER
BNE READ┬LOCK╨HYSICAL
CPX BUF╙IDE
BNE READ┬LOCK╨HYSICAL
DEY
TYA
ASL
CLC
ADC #>TRACKBUF
TAY
LDA #<TRACKBUF
CLC
RTS
READ┬LOCK╨HYSICAL = *
STA BUF├YLINDER
STX BUF╙IDE
STY SECTOR╙AVE
JSR READ╘RACK
BCC READ┬LOCK╨HYSICAL╧K
LDA ERRNO
AND #$0F
CMP #11 ;DISK CHANGE
BEQ +
SEC
RTS
+ JSR MOUNT─ISK
LDA BUF├YLINDER
LDX BUF╙IDE
LDY SECTOR╙AVE
BCC READ┬LOCK╨HYSICAL
RTS
READ┬LOCK╨HYSICAL╧K = *
LDA BUF├YLINDER
LDX BUF╙IDE
LDY SECTOR╙AVE
JMP READ┬LOCK
DIVIDE┬Y18 = * ;( .┴┘=NUMBER ) : .┴=QUOTIENT, .┘=REMAINDER
;** COULD REPEATEDLY SUBTRACT 360 HERE
LDX #$FF
- INX
SEC
SBC #18
BCS -
DEY
BPL -
CLC
ADC #18
INY
TAY
TXA
RTS
CONVERT╠OGICAL┬LOCK╬UM = * ;( .┴┘=BLOCK╬UM ) : .┴=CYL, .╪=SIDE, .┘=SEC
JSR DIVIDE┬Y18
LDX #0
CPY #9
BCC +
PHA
TYA
SBC #9
TAY
PLA
LDX #1
+ INY
RTS
DEST╨TR = 6
CUR├YLINDER = 8
CUR╙IDE = 9
CUR╙ECTOR = 10
BLOCK├OUNTDOWN = 11
SOURCE╨TR = 12
COPY┬LOCKS = * ;( .┴┘=START┬LOCK, .╪=BLOCK├OUNT, ($6)=DEST ) : .├╙=ERR
STX BLOCK├OUNTDOWN
JSR CONVERT╠OGICAL┬LOCK╬UM
STA CUR├YLINDER
STX CUR╙IDE
STY CUR╙ECTOR
COPY┬LOCK╠OOP = *
LDA CUR├YLINDER
LDX CUR╙IDE
LDY CUR╙ECTOR
JSR READ┬LOCK
BCC +
RTS
+ STA SOURCE╨TR
STY SOURCE╨TR+1
LDX #2
LDY #0
- LDA (SOURCE╨TR),Y
STA (DEST╨TR),Y
INY
LDA (SOURCE╨TR),Y
STA (DEST╨TR),Y
INY
BNE -
INC SOURCE╨TR+1
INC DEST╨TR+1
DEX
BNE -
INC CUR╙ECTOR
LDA CUR╙ECTOR
CMP #10
BCC +
LDA #1
STA CUR╙ECTOR
INC CUR╙IDE
LDA CUR╙IDE
CMP #2
BCC +
LDA #0
STA CUR╙IDE
INC CUR├YLINDER
+ DEC BLOCK├OUNTDOWN
BNE COPY┬LOCK╠OOP
CLC
RTS
READ├LUSTER = * ;( .┴┘=CLUSTER╬UMBER ) : CLUSTER┬UF, .├╙=ERR
;** CONVERT CLUSTER NUMBER TO LOGICAL BLOCK NUMBER
SEC
SBC #2
BCS +
DEY
+ LDX CLUSTER┬LOCK├OUNT
CPX #1
BEQ +
ASL
STY 7
ROL 7
LDY 7
+ CLC
ADC FIRST╞ILE┬LOCK
BCC +
INY
;** READ LOGICAL BLOCKS COMPRISING CLUSTER
+ LDX #<CLUSTER┬UF
STX 6
LDX #>CLUSTER┬UF
STX 7
LDX CLUSTER┬LOCK├OUNT
JMP COPY┬LOCKS
;====═╙-─╧╙ FORMAT LEVEL====
BOOT┬LOCK = 2
LOAD─IRECTORY = * ;( ) : .┴┘=DIRBUF, .╪=DIR┼NTRIES, .├╙=ERR
LDA #$0E
STA $FF00
;** GET PARAMETERS FROM BOOT SECTOR
LDA #0
LDY #0
JSR CONVERT╠OGICAL┬LOCK╬UM
JSR READ┬LOCK
BCC +
RTS
+ STA BOOT┬LOCK
STY BOOT┬LOCK+1
LDY #13 ;GET CLUSTER SIZE
LDA (BOOT┬LOCK),Y
STA CLUSTER┬LOCK├OUNT
CMP #3
BCC +
INVALID╨ARMS = *
LDA #60
STA ERRNO
SEC
RTS
+ LDY #16 ;CHECK ╞┴╘ REPLICATION COUNT, MUST BE 2
LDA (BOOT┬LOCK),Y
CMP #2
BNE INVALID╨ARMS
LDY #22 ;GET ╞┴╘ SIZE IN SECTORS
LDA (BOOT┬LOCK),Y
STA FAT┬LOCKS
CMP #4
BCS INVALID╨ARMS
LDY #17 ;GET DIRECTORY SIZE
LDA (BOOT┬LOCK),Y
STA ROOT─IR┼NTRIES
CMP #129
BCS INVALID╨ARMS
LSR
LSR
LSR
LSR
STA ROOT─IR┬LOCKS
LDY #19 ;GET TOTAL SECTOR COUNT
LDA (BOOT┬LOCK),Y
STA TOTAL╙ECTORS
INY
LDA (BOOT┬LOCK),Y
STA TOTAL╙ECTORS+1
LDY #24 ;CHECK SECTORS PER TRACK, MUST BE 9
LDA (BOOT┬LOCK),Y
CMP #9
BNE INVALID╨ARMS
LDY #26
LDA (BOOT┬LOCK),Y
CMP #2 ;CHECK NUMBER OF SIDES, MUST BE 2
BNE INVALID╨ARMS
LDY #14 ;CHECK NUMBER OF BOOT SECTORS, MUST BE 1
LDA (BOOT┬LOCK),Y
CMP #1
BNE INVALID╨ARMS
;** GET DERIVED PARAMETERS
LDA FAT┬LOCKS ;FIRST ROOT DIRECTORY SECTOR
ASL
CLC
ADC #1
STA FIRST╥OOT─IR┬LOCK
CLC ;FIRST FILE SECTOR
ADC ROOT─IR┬LOCKS
STA FIRST╞ILE┬LOCK
LDA TOTAL╙ECTORS ;NUMBER OF FILE CLUSTERS
LDY TOTAL╙ECTORS+1
SEC
SBC FIRST╞ILE┬LOCK
BCS +
DEY
+ STA FILE├LUSTER├OUNT
STY FILE├LUSTER├OUNT+1
LDA CLUSTER┬LOCK├OUNT
CMP #2
BNE +
LSR FILE├LUSTER├OUNT+1
ROR FILE├LUSTER├OUNT
;** LOAD ╞┴╘
+ LDA #<FATBUF
LDY #>FATBUF
STA 6
STY 7
LDA #1
LDY #0
LDX FAT┬LOCKS
JSR COPY┬LOCKS
BCC +
RTS
;** LOAD ACTUAL DIRECTORY
+ LDA #<DIRBUF
LDY #>DIRBUF
STA 6
STY 7
LDA FIRST╥OOT─IR┬LOCK
LDY #0
LDX ROOT─IR┬LOCKS
JSR COPY┬LOCKS
BCC +
RTS
+ LDA #<DIRBUF
LDY #>DIRBUF
LDX ROOT─IR┼NTRIES
CLC
RTS
ENTRY┴DDR = 2
ENTRY╫ORK = 4
ENTRY┬ITS = 5