Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions mos-platform/atari8-common/fdtable.s
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,18 @@ fdtoiocb_down:
bne inval
cmp #MAX_FD_INDEX
bcs inval
tax
lda fd_index,x ; get index
tay
lda #$ff
sta fd_index,x ; clear entry
tya
lda fd_index,y ; get index
asl a ; create index into fd table
asl a
tax
lda #$ff
sta fd_index,y ; clear entry
cmp fd_table+ft_iocb,x ; entry in use?
beq inval ; no, return error
lda fd_table+ft_usa,x ; get usage counter
beq ok_notlast ; 0? (shouldn't happen)
sec
sbc #1 ; decr usage counter
sbc #1 ; decr usage counter, C=1
sta fd_table+ft_usa,x
retiocb:php
txa
Expand Down Expand Up @@ -109,8 +105,7 @@ fddecusage:
beq ret ; no, do nothing
lda fd_table+ft_usa,x ; get usage counter
beq ret ; 0? should not happen
sec
sbc #1 ; decrement by one
sbc #1 ; decrement by one, C=1
sta fd_table+ft_usa,x
bne ret ; not 0
lda #$ff ; 0, table entry unused now
Expand Down
13 changes: 6 additions & 7 deletions mos-platform/atari8-common/getfd.s
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
; get fd_table entry in A
; return C = 0/1 for OK/error
; return fd_index entry in A if OK
; return ft_table entry in Y (for getfd below)
; registers destroyed
fdt_to_fdi:

tay
lda #$ff
tax
inx
loop: cmp fd_index,x
loop: inx
cmp fd_index,x
beq found
inx
cpx #MAX_FD_INDEX
cpx #MAX_FD_INDEX-1
bcc loop
rts

Expand All @@ -48,15 +48,14 @@ found: tya
; A - fd_table entry
; return C = 0/1 for OK/error
; returns fd in A if OK
; registers destroyed, tmp1 destroyed
; registers destroyed
getfd:

sta __rc10 ; save fd_table entry
jsr fdt_to_fdi
bcs error

pha
lda __rc10
tya
asl a
asl a ; also clears C
tax
Expand Down