X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=inline;f=libsrc%2Fatari%2Fgetfd.s;h=a4e34833b4bd39b8f0d1a21d6c102e19cb081c79;hb=85170998ad45cadb2064fa68349bb3a8975efd89;hp=6fb38e9ae9d4feb694ca0d0c00a38bd1c53b7200;hpb=ea6c5c8d434316fabcbae444ee0efa98257cb1fd;p=cc65 diff --git a/libsrc/atari/getfd.s b/libsrc/atari/getfd.s index 6fb38e9ae..a4e34833b 100644 --- a/libsrc/atari/getfd.s +++ b/libsrc/atari/getfd.s @@ -2,35 +2,17 @@ ; Christian Groessler, Oct-2000 ; ; allocates a new fd in the indirection table -; the fdtable itself is defined here ; - .include "atari.inc" - .include "fd.inc" - .importzp tmp1 + .include "atari.inc" + .include "fd.inc" + .include "_file.inc" + .importzp tmp1 + .import fd_table, fd_index - .export fdt_to_fdi,getfd - .export fd_table,fd_index - .export ___fd_table,___fd_index ; for test(debug purposes only + .export fdt_to_fdi,getfd - .data - -___fd_index: -fd_index: ; fd number is index into this table, entry's value specifies the fd_table entry - .res MAX_FD_INDEX,$ff - -___fd_table: -fd_table: ; each entry represents an open iocb - .byte 0,0,'E',0 ; system console, app starts with opened iocb #0 for E: - .byte 0,$ff,0,0 - .byte 0,$ff,0,0 - .byte 0,$ff,0,0 - .byte 0,$ff,0,0 - .byte 0,$ff,0,0 - .byte 0,$ff,0,0 - .byte 0,$ff,0,0 - - .code + .code ; fdt_to_fdi ; returns a fd_index entry pointing to the given ft_table entry @@ -38,24 +20,24 @@ fd_table: ; each entry represents an open iocb ; return C = 0/1 for OK/error ; return fd_index entry in A if OK ; registers destroyed -.proc fdt_to_fdi +.proc fdt_to_fdi - tay - lda #$ff - tax - inx -loop: cmp fd_index,x - beq found - inx - cpx #MAX_FD_INDEX - bcc loop - rts + tay + lda #$ff + tax + inx +loop: cmp fd_index,x + beq found + inx + cpx #MAX_FD_INDEX + bcc loop + rts -found: tya - sta fd_index,x - txa - clc - rts +found: tya + sta fd_index,x + txa + clc + rts .endproc @@ -66,19 +48,19 @@ found: tya ; return C = 0/1 for OK/error ; returns fd in A if OK ; registers destroyed, tmp1 destroyed -.proc getfd +.proc getfd - sta tmp1 ; save fd_table entry - jsr fdt_to_fdi - bcs error + sta tmp1 ; save fd_table entry + jsr fdt_to_fdi + bcs error - pha - lda tmp1 - asl a - asl a ; also clears C - tax - inc fd_table+ft_usa,x ; increment usage counter - pla -error: rts + pha + lda tmp1 + asl a + asl a ; also clears C + tax + inc fd_table+ft_usa,x ; increment usage counter + pla +error: rts .endproc