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
19 .include "geossym.inc"
22 .proc _dio_phys_to_log
24 stx ptr1+1 ; pointer to result
28 stx ptr2+1 ; pointer to input structure
32 stx ptr3+1 ; pointer to handle
37 beq _inv_hand ; handle not open or invalid
42 bne _inv_data ; there is only head 0
45 beq _inv_data ; there is no track 0
49 bne _inv_data ; there are no more than 256 tracks
50 dec tmp1 ; normalize track to start from 0
56 bne _inv_data ; there are no more than 256 sectors
58 ; tmp1 (int) holds track+sector, translate it using device info
64 and #%00000011 ; this is for RamDrive compatibility
72 lda #DEV_NOT_FOUND ; unknown device
100 ; device-depended stuff, tmp1=track-1, tmp2=sector
119 cmp #35 ; last track of one side
121 jmp dio_cts1541 ; track <=35 - same as 1541
127 jsr dio_cts1541 ; get offset on second side of disk
128 lda tmp1 ; add second side base
138 ; 1581 has 80 tracks, 40 sectors each secnum=track*40+sector
147 ; mul40 by Christian Groessler
161 rol tmp3 ; val * 40 = AX
181 .byte $00, $15, $2a, $3f, $54, $69, $7e, $93
182 .byte $a8, $bd, $d2, $e7, $fc, $11, $26, $3b
183 .byte $50, $65, $78, $8b, $9e, $b1, $c4, $d7
184 .byte $ea, $fc, $0e, $20, $32, $44, $56, $67
185 .byte $78, $89, $9a, $ab
187 .byte $00, $00, $00, $00, $00, $00, $00, $00
188 .byte $00, $00, $00, $00, $00, $01, $01, $01
189 .byte $01, $01, $01, $01, $01, $01, $01, $01
190 .byte $01, $01, $02, $02, $02, $02, $02, $02
191 .byte $02, $02, $02, $02