]> git.sur5r.net Git - cc65/blobdiff - libsrc/atari/dio_stc.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / atari / dio_stc.s
index 992eebe7060f9c2d9a8fa82b6ae307555457f533..52b3af4a610d36ca3d2e5bd0ff1caca5bc0b1bd3 100644 (file)
@@ -1,52 +1,72 @@
 ;
 ; Christian Groessler, October 2000
 ;
-; this file provides the _dio_snum_to_chs function
+; this file provides the _dio_log_to_phys function
+; (previously called _dio_snum_to_chs, so the filename)
 ;
 ; on the Atari this function is a dummy, it returns
 ; cylinder and head 0 and as sector the sectnum it got
 ;
-; void __fastcall__ _dio_snum_to_chs(_sectnum_t sect_num,
-;                                   unsigned int *cyl,
-;                                   unsigned int *head,
-;                                   unsigned int *sector);
-; _sectnum_t - 16bit
+; unsigned char __fastcall__ dio_log_to_phys(dhandle_t handle,
+;                                            unsigned *sectnum,         /* input */
+;                                            dio_phys_pos *physpos);    /* output */
 ;
+; dhandle_t - 16bit (ptr)
+;
+
+        .export         _dio_log_to_phys
+        .include        "atari.inc"
+        .importzp       ptr1,ptr2,ptr3
+        .import         popax,__oserror
+
+.proc   _dio_log_to_phys
+
+        sta     ptr2
+        stx     ptr2+1          ; pointer to output structure
+
+        jsr     popax
+        sta     ptr1
+        stx     ptr1+1          ; save pointer to input data
+
+        jsr     popax
+        sta     ptr3
+        stx     ptr3+1          ; pointer to handle
+
+        ldy     #sst_flag
+        lda     (ptr3),y
+        and     #128
+        beq     _inv_hand       ; handle not open or invalid
+
+        lda     #0
+        tay
+        tax
+        sta     (ptr2),y        ; head
+        iny
+        sta     (ptr2),y        ; track (low)
+        iny
+        sta     (ptr2),y        ; track (high)
+        iny
+
+        lda     (ptr1,x)
+        sta     (ptr2),y
+        iny
+        inc     ptr1
+        bne     _l1
+        inc     ptr1+1
+_l1:    lda     (ptr1,x)
+        sta     (ptr2),y
+
+        txa
+ret:
+        sta     __oserror
+        rts                     ; return success
+
+; invalid handle
 
-       .export         __dio_snum_to_chs
-       .include        "atari.inc"
-       .importzp       ptr1,ptr2
-       .import         popax
-
-.proc  __dio_snum_to_chs
-
-       sta     ptr1
-       stx     ptr1+1          ; save pointer to sector #
-       jsr     popax           ; get pointer to head
-       sta     ptr2
-       stx     ptr2+1
-       lda     #0
-       tay
-       sta     (ptr2),y        ; set head number
-       iny
-       sta     (ptr2),y
-       jsr     popax           ; get pointer to cyl
-       sta     ptr2
-       stx     ptr2+1
-       dey
-       tya
-       sta     (ptr2),y        ; set cylinder number
-       iny
-       sta     (ptr2),y
-       jsr     popax           ; get sector #
-
-       dey
-       sta     (ptr1),y
-       iny
-       txa
-       sta     (ptr1),y
-
-       rts
+_inv_hand:
+        ldx     #0
+        lda     #BADIOC
+        bne     ret
 
 .endproc