home *** CD-ROM | disk | FTP | other *** search
- ;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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-