home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.elysium.pl
/
ftp.elysium.pl.tar
/
ftp.elysium.pl
/
docs
/
hardware
/
64hdproj.sfx
/
c64sat.src
< prev
next >
Wrap
Text File
|
1990-02-12
|
4KB
|
172 lines
;BPUT"SAT.SRC
;RPUT"SAT.SRC
;
;+++++++++++++++++++++++++++++++++
;+ ALLOCATE AND DE-ALLOCATE +
;+ A SECTOR IN THE SECTOR +
;+ ALLOCATION TABLE. +
;+ +
;+ INPUT FOR DE-ALLOCATE: +
;+ SECTOR NUMBER TO FREE. +
;+ +
;+ OUTPUT FOR DE-ALLOCATE: +
;+ SATBIT IS SET ON. +
;+ +
;+ INPUT FOR ALLOCATE: NONE +
;+ +
;+ OUTPUT FOR ALLOCATE: +
;+ SATBIT TURNED OFF, AND +
;+ SECTOR NUMBER OF THE +
;+ NEWLY ALLOCATED SECTOR. +
;+++++++++++++++++++++++++++++++++
;
SATSECPTR = $FB ;AND FC
;
ALLOCATESAT LDA FREESATSECTOR
CMP CURRENTSAT ;IS IT SAME AS SAT IN BUFFER?
BEQ ALLOCATESAT1
ALLOCATEREAD JSR READSATSECTOR ;GO GET THE SECTOR
BCC ALLOCATESAT1
RTS ;RETURN WITH ERROR
ALLOCATESAT1 JSR SETSATPTRS
LDX #0 ;SET COUNTER
LDY #0 ;INDEX POINTER
ALLOCATESAT2 LDA (SATSECPTR),Y ;ANY FREE?
BNE ALLOCATESAT3 ;GO IF SO
INY
BNE ALLOCATESAT2
INX
CPX #2 ;GOT EM ALL?
BEQ ALLOCATESAT2A
INC SATSECPTR+1 ;BUMP PAGE
BNE ALLOCATESAT2
ALLOCATESAT2A = *
INC FREESATSECTOR ;BUMP
JSR DEFSET ;GET X PTR TO TABLE
LDA FREESATSECTOR ;GET NUMBER
CMP PTFDIR,X ;WAS THERE NO ROOM?
BNE ALLOCATEREAD
SEC ;RETURN WITH CARRY FOR NO ROOM
RTS
ALLOCATESAT3 STY SATBYT ;SAVE OFFSET
STX SATBYT+1
LDX #$80 ;SET BIT POINTER
STX SATBIT
ALLOCATESAT4 ASL A ;SHIFT A BIT
BCS ALLOCATESAT5
LSR SATBIT
BNE ALLOCATESAT4
ALLOCATESAT5 JSR DEFSET ;GET DRIVE PTR
LDA CURRENTSAT
STA SATSEC ;SAVE THE SECTOR NUMBER
LDA (SATSECPTR),Y ;TURN OFF BIT
EOR SATBIT
STA (SATSECPTR),Y ;TO ALLOCATE
LDA #1 ;SET SATBUFFER NEEDS TO BE
STA SATBUFFERFLAG ;WRITTEN
CLC
RTS ;RETURN TO CALLER WITH SUCCESS
;
;++ DE-ALLOCATE A SECTOR BY TURNING
;++ ON THE BIT IN THE SAT SECTOR.
;
DEALLOCATESATS TAY ;SETUP FOR CONVERSION
LDA #0
TAX
JSR SECTOR2SAT ;TO SAT FORMAT
JMP DEALLOCATESAT
;++ THE FOLLOWING REQUIRES THAT
;++ SATSEC, SATBYT, AND SATBIT BE
;++ PRIMED.
ALLOCABSOLUTES TAY ;SET UP FOR CONVERSION
LDA #0
TAX
JSR SECTOR2SAT
ALLOCABSOLUTE LDA SATBIT ;INVERT
EOR #$FF ;THE BITS
STA SATBIT
LDA #255 ;SET ABSOLUTE ALLOC FLAG
.BYT $2C ;BIT
DEALLOCATESAT LDA #0
STA ALLOCDEALLOCFL
LDA SATSEC ;SEE IF IN MEMORY
CMP CURRENTSAT
BEQ DEALLOCATESAT1
JSR READSATSECTOR
BCC DEALLOCATESAT1
RTS ;RETURN IF ERROR
DEALLOCATESAT1 JSR SETSATPTRS ;ADDRRESS BUFFER
LDA #>SATBUFFER
CLC
ADC SATBYT
STA SATSECPTR+1
LDY SATBYT+1 ;GET REST OF OFFSET
LDA (SATSECPTR),Y
LDX ALLOCDEALLOCFL ;CHECK TYPE
BMI ALLOCABSOL
ORA SATBIT
JMP ALLOCDEALLOCSV
ALLOCABSOL AND SATBIT
ALLOCDEALLOCSV = *
STA (SATSECPTR),Y
LDA #1 ;SET NEED WRITE FLAG
STA SATBUFFERFLAG
CLC ;INDICATE SUCCESS
RTS ;RETURN TO CALLER
;
READSATSECTOR = * ;READ SAT SECTOR
PHA
LDX SATBUFFERFLAG ;BUFFER NEED TO BE WRITTEN?
BEQ READSATSECTOR1 ;ON IF NOT
LDA CURRENTSAT ;GET SECTOR TO SAVE
JSR WRITESATSECTOR ;WRITE IT OUT
BCC READSATSECTOR1
PLA
RTS ;RETURN WITH CARRY FOR ERROR
READSATSECTOR1 PLA ;GET SAVED SECTOR
STA CURRENTSAT ;MAKE IT CURRENT
JSR SATSETUPDCB
JSR READ
RTS
SATSETUPDCB PHA ;SAVE FOR A JIFFY
JSR DEFSET ;GET TABLE OFFSET
PLA
CLC ;ADD OFFSET
ADC PTFSAT,X ;SECTOR NUMBER
STA SECNUM+2
LDA #0
STA SECNUM
STA SECNUM+1
JSR SEC2CYLDCB ;CONVERT TO DCB FORMAT
JSR DEFSET
TXA
ORA HEAD ;GET DRIVE AND HEAD
STA HDNUM
LDA CYLMSB
STA SECADR
LDA CYLLSB
STA CYLNUM
LDA #1 ;ENSURE ONLY ONE SECTOR
STA BLKCNT
LDA #<SATBUFFER
STA BUFADR
LDA #>SATBUFFER
STA BUFADR+1
RTS
WRITESATSECTOR JSR SATSETUPDCB
JSR WRITE
BCC WRITESATSECTOX
LDA #0
STA SATBUFFERFLAG
SEC
WRITESATSECTOX RTS ;RETURN
FREESATSECTOR .BYT 0 ;FIRST SAT WITH ROOM
SETSATPTRS LDA #<SATBUFFER
STA SATSECPTR
LDA #>SATBUFFER
STA SATSECPTR+1
RTS
SATBUFFERFLAG .BYT 0 ;SECTOR CHANGED FLAG
CURRENTSAT .BYT 0 ;SAT IN BUFFER
ALLOCDEALLOCFL .BYT 0 ;FLAG
.END SAT.SRC