2 ; Maciej 'YTM/Elysium' Witkowiak
6 ; unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle,
7 ; dio_phys_pos *physpos, /* input */
8 ; unsigned *sectnum); /* output */
11 .export _dio_phys_to_log
12 .export sectab_1541_l, sectab_1541_h ; for log_to_phys
13 .import popax,__oserror
14 .importzp ptr1,ptr2,ptr3,tmp1,tmp2,tmp3,tmp4
17 .include "geossym.inc"
22 stx ptr1+1 ; pointer to result
26 stx ptr2+1 ; pointer to input structure
30 stx ptr3+1 ; pointer to handle
35 beq _inv_hand ; handle not open or invalid
40 bne _inv_data ; there is only head 0
43 beq _inv_data ; there is no track 0
47 bne _inv_data ; there are no more than 256 tracks
48 dec tmp1 ; normalize track to start from 0
54 bne _inv_data ; there are no more than 256 sectors
56 ; tmp1 (int) holds track+sector, translate it using device info
62 and #%00000011 ; this is for RamDrive compatibility
70 lda #DEV_NOT_FOUND ; unknown device
98 ; device-depended stuff, tmp1=track-1, tmp2=sector
117 cmp #35 ; last track of one side
119 jmp dio_cts1541 ; track <=35 - same as 1541
125 jsr dio_cts1541 ; get offset on second side of disk
126 lda tmp1 ; add second side base
136 ; 1581 has 80 tracks, 40 sectors each secnum=track*40+sector
145 ; mul40 by Christian Groessler
159 rol tmp3 ; val * 40 = AX
177 .byte $00, $15, $2a, $3f, $54, $69, $7e, $93
178 .byte $a8, $bd, $d2, $e7, $fc, $11, $26, $3b
179 .byte $50, $65, $78, $8b, $9e, $b1, $c4, $d7
180 .byte $ea, $fc, $0e, $20, $32, $44, $56, $67
181 .byte $78, $89, $9a, $ab
183 .byte $00, $00, $00, $00, $00, $00, $00, $00
184 .byte $00, $00, $00, $00, $00, $01, $01, $01
185 .byte $01, $01, $01, $01, $01, $01, $01, $01
186 .byte $01, $01, $02, $02, $02, $02, $02, $02
187 .byte $02, $02, $02, $02