2 ; Maciej 'YTM/Elysium' Witkowiak
6 ; unsigned char __fastcall__ dio_phys_to_log(dhandle_t handle,
7 ; dio_phys_pos *physpos, /* input */
8 ; sectnum_t *sectnum); /* output */
10 ; dhandle_t - 16bit (ptr)
14 .export _dio_phys_to_log
15 .export sectab_1541_l, sectab_1541_h ; for log_to_phys
16 .import popax,__oserror
17 .importzp ptr1,ptr2,ptr3,tmp1,tmp2,tmp3,tmp4
20 .include "geossym.inc"
25 stx ptr1+1 ; pointer to result
29 stx ptr2+1 ; pointer to input structure
33 stx ptr3+1 ; pointer to handle
38 beq _inv_hand ; handle not open or invalid
43 bne _inv_data ; there is only head 0
46 beq _inv_data ; there is no track 0
50 bne _inv_data ; there are no more than 256 tracks
51 dec tmp1 ; normalize track to start from 0
57 bne _inv_data ; there are no more than 256 sectors
59 ; tmp1 (int) holds track+sector, translate it using device info
65 and #%00000011 ; this is for RamDrive compatibility
73 lda #DEV_NOT_FOUND ; unknown device
101 ; device-depended stuff, tmp1=track-1, tmp2=sector
120 cmp #35 ; last track of one side
122 jmp dio_cts1541 ; track <=35 - same as 1541
128 jsr dio_cts1541 ; get offset on second side of disk
129 lda tmp1 ; add second side base
139 ; 1581 has 80 tracks, 40 sectors each secnum=track*40+sector
148 ; mul40 by Christian Groessler
162 rol tmp3 ; val * 40 = AX
180 .byte $00, $15, $2a, $3f, $54, $69, $7e, $93
181 .byte $a8, $bd, $d2, $e7, $fc, $11, $26, $3b
182 .byte $50, $65, $78, $8b, $9e, $b1, $c4, $d7
183 .byte $ea, $fc, $0e, $20, $32, $44, $56, $67
184 .byte $78, $89, $9a, $ab
186 .byte $00, $00, $00, $00, $00, $00, $00, $00
187 .byte $00, $00, $00, $00, $00, $01, $01, $01
188 .byte $01, $01, $01, $01, $01, $01, $01, $01
189 .byte $01, $01, $02, $02, $02, $02, $02, $02
190 .byte $02, $02, $02, $02