Normalized coding style.

git-svn-id: svn://svn.cc65.org/cc65/trunk@5494 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
ol.sc
2012-02-07 22:37:13 +00:00
parent 286d5979a2
commit baa6c53dec
24 changed files with 1164 additions and 1169 deletions

View File

@@ -11,91 +11,92 @@
; sectnum_t - 16bit
;
.export _dio_phys_to_log
.export sectab_1541_l, sectab_1541_h ; for log_to_phys
.import popax,__oserror
.importzp ptr1,ptr2,ptr3,tmp1,tmp2,tmp3,tmp4
.include "dio.inc"
.include "geossym.inc"
.include "const.inc"
.export _dio_phys_to_log
.export sectab_1541_l, sectab_1541_h ; for log_to_phys
.import popax,__oserror
.importzp ptr1,ptr2,ptr3,tmp1,tmp2,tmp3,tmp4
.proc _dio_phys_to_log
sta ptr1
stx ptr1+1 ; pointer to result
.include "dio.inc"
.include "geossym.inc"
.include "const.inc"
jsr popax
sta ptr2
stx ptr2+1 ; pointer to input structure
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
ldy #diopp_head
lda (ptr2),y
bne _inv_data ; there is only head 0
ldy #diopp_track
lda (ptr2),y
beq _inv_data ; there is no track 0
sta tmp1
_dio_phys_to_log:
sta ptr1
stx ptr1+1 ; pointer to result
jsr popax
sta ptr2
stx ptr2+1 ; pointer to input structure
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
ldy #diopp_head
lda (ptr2),y
bne _inv_data ; there is only head 0
ldy #diopp_track
lda (ptr2),y
beq _inv_data ; there is no track 0
sta tmp1
iny
lda (ptr2),y
bne _inv_data ; there are no more than 256 tracks
dec tmp1 ; normalize track to start from 0
ldy #diopp_sector
lda (ptr2),y
sta tmp2
lda (ptr2),y
bne _inv_data ; there are no more than 256 tracks
dec tmp1 ; normalize track to start from 0
ldy #diopp_sector
lda (ptr2),y
sta tmp2
iny
lda (ptr2),y
bne _inv_data ; there are no more than 256 sectors
lda (ptr2),y
bne _inv_data ; there are no more than 256 sectors
; tmp1 (int) holds track+sector, translate it using device info
ldy #sst_driveno
lda (ptr3),y
ldy #sst_driveno
lda (ptr3),y
tay
lda driveType,y
and #%00000011 ; this is for RamDrive compatibility
cmp #DRV_1541
beq dio_cts1541
cmp #DRV_1571
beq dio_cts1571
cmp #DRV_1581
beq dio_cts1581
lda #DEV_NOT_FOUND ; unknown device
ldx #0
beq ret
lda driveType,y
and #%00000011 ; this is for RamDrive compatibility
cmp #DRV_1541
beq dio_cts1541
cmp #DRV_1571
beq dio_cts1571
cmp #DRV_1581
beq dio_cts1581
lda #DEV_NOT_FOUND ; unknown device
ldx #0
beq ret
dio_ctsend:
ldy #1
lda tmp2
sta (ptr1),y
ldy #1
lda tmp2
sta (ptr1),y
dey
lda tmp1
sta (ptr1),y
ldx #0
lda tmp1
sta (ptr1),y
ldx #0
txa
ret:
sta __oserror
ret:
sta __oserror
rts ; return success
; errors
_inv_data:
lda #INV_TRACK
lda #INV_TRACK
.byte $2c
_inv_hand:
lda #INCOMPATIBLE
ldx #0
beq ret
lda #INCOMPATIBLE
ldx #0
beq ret
; device-depended stuff, tmp1=track-1, tmp2=sector
@@ -145,23 +146,23 @@ dio_cts1581:
bcs _inv_data
; mul40 by Christian Groessler
sta tmp4
asl a
rol tmp3
asl a
rol tmp3 ; val * 4
adc tmp4
bcc L1
inc tmp3 ; val * 5
L1: asl a
rol tmp3 ; val * 10
asl a
rol tmp3
asl a
rol tmp3 ; val * 40 = AX
ldx tmp3
sta tmp3
stx tmp4
sta tmp4
asl a
rol tmp3
asl a
rol tmp3 ; val * 4
adc tmp4
bcc L1
inc tmp3 ; val * 5
L1: asl a
rol tmp3 ; val * 10
asl a
rol tmp3
asl a
rol tmp3 ; val * 40 = AX
ldx tmp3
sta tmp3
stx tmp4
_nomult:
lda tmp2
@@ -173,19 +174,17 @@ _nomult:
sta tmp2
jmp dio_ctsend
.endproc
.rodata
sectab_1541_l:
.byte $00, $15, $2a, $3f, $54, $69, $7e, $93
.byte $a8, $bd, $d2, $e7, $fc, $11, $26, $3b
.byte $50, $65, $78, $8b, $9e, $b1, $c4, $d7
.byte $ea, $fc, $0e, $20, $32, $44, $56, $67
.byte $78, $89, $9a, $ab
.byte $00, $15, $2a, $3f, $54, $69, $7e, $93
.byte $a8, $bd, $d2, $e7, $fc, $11, $26, $3b
.byte $50, $65, $78, $8b, $9e, $b1, $c4, $d7
.byte $ea, $fc, $0e, $20, $32, $44, $56, $67
.byte $78, $89, $9a, $ab
sectab_1541_h:
.byte $00, $00, $00, $00, $00, $00, $00, $00
.byte $00, $00, $00, $00, $00, $01, $01, $01
.byte $01, $01, $01, $01, $01, $01, $01, $01
.byte $01, $01, $02, $02, $02, $02, $02, $02
.byte $02, $02, $02, $02
.byte $00, $00, $00, $00, $00, $00, $00, $00
.byte $00, $00, $00, $00, $00, $01, $01, $01
.byte $01, $01, $01, $01, $01, $01, $01, $01
.byte $01, $01, $02, $02, $02, $02, $02, $02
.byte $02, $02, $02, $02

View File

@@ -10,22 +10,23 @@
; dio_open sets given device as current and initializes disk
; dio_close does nothing special
.export _dio_open, _dio_close
.import __oserror, _OpenDisk
.importzp ptr1, tmp1
.include "dio.inc"
.include "jumptab.inc"
.include "geossym.inc"
.include "const.inc"
.export _dio_open, _dio_close
.import __oserror, _OpenDisk
.importzp ptr1, tmp1
.include "dio.inc"
.include "jumptab.inc"
.include "geossym.inc"
.include "const.inc"
.bss
sectsizetab:
.res 4 * sst_size ; this is hardcoded
.res 4 * sst_size ; this is hardcoded
.code
.proc _dio_open
_dio_open:
pha
tax
lda driveType,x ; check if there's a device
@@ -39,28 +40,28 @@ sectsizetab:
pla
tay ; drive #
asl a ; make index from drive id
asl a
asl a ; make index from drive id
asl a
tax
lda #0
sta sectsizetab+sst_sectsize,x
lda #128
sta sectsizetab+sst_flag,x ; set flag that drive is "open"
lda #1
sta sectsizetab+sst_sectsize+1,x
lda #0
sta sectsizetab+sst_sectsize,x
lda #128
sta sectsizetab+sst_flag,x ; set flag that drive is "open"
lda #1
sta sectsizetab+sst_sectsize+1,x
tya
sta sectsizetab+sst_driveno,x
stx tmp1
lda #<sectsizetab
sta sectsizetab+sst_driveno,x
stx tmp1
lda #<sectsizetab
clc
adc tmp1
sta tmp1
lda #>sectsizetab
adc #0
adc tmp1
sta tmp1
lda #>sectsizetab
adc #0
tax
lda tmp1
lda tmp1
rts
@@ -71,15 +72,12 @@ _inv_drive:
tax
rts
.endproc
.proc _dio_close
sta ptr1
stx ptr1+1
lda #0
ldy #sst_flag
sta (ptr1),y
sta __oserror ; success
_dio_close:
sta ptr1
stx ptr1+1
lda #0
ldy #sst_flag
sta (ptr1),y
sta __oserror ; success
tax
rts ; return no error
.endproc

View File

@@ -5,19 +5,22 @@
; this function is used by dio_read and dio_write to fix parameters (secnum)
; this function calls SetDevice so that more than one drive can be used at once
.import popax,pushax,_dio_log_to_phys
.importzp ptr1
.export dio_params,dio_secnum
.include "geossym.inc"
.include "jumptab.inc"
.include "dio.inc"
.import popax,pushax,_dio_log_to_phys
.importzp ptr1
.export dio_params,dio_secnum
.include "geossym.inc"
.include "jumptab.inc"
.include "dio.inc"
.bss
dio_secnum: .res 2
dio_secnum:
.res 2
.code
.proc dio_params
dio_params:
sta r4L
stx r4H
@@ -47,5 +50,3 @@ dio_secnum: .res 2
lda #<r1L
ldx #>r1H
jmp _dio_log_to_phys
.endproc

View File

@@ -9,17 +9,15 @@
; sectnum_t - 16bit
;
.import dio_params, __oserror
.export _dio_read
.include "geossym.inc"
.include "jumptab.inc"
.import dio_params, __oserror
.export _dio_read
.proc _dio_read
.include "geossym.inc"
.include "jumptab.inc"
_dio_read:
jsr dio_params
jsr ReadBlock
stx __oserror
txa
rts
.endproc

View File

@@ -10,173 +10,171 @@
; sectnum_t - 16bit
;
.export _dio_log_to_phys
.importzp ptr1,ptr2,ptr3,tmp1,tmp2
.import popax,__oserror
.import sectab_1541_l, sectab_1541_h
.include "dio.inc"
.include "geossym.inc"
.include "const.inc"
.export _dio_log_to_phys
.importzp ptr1,ptr2,ptr3,tmp1,tmp2
.import popax,__oserror
.import sectab_1541_l, sectab_1541_h
.proc _dio_log_to_phys
.include "dio.inc"
.include "geossym.inc"
.include "const.inc"
_dio_log_to_phys:
; check device type
sta ptr1
stx ptr1+1 ; pointer to result (struct dio_phys_pos)
jsr popax
sta ptr2
stx ptr2+1 ; pointer to input structure (pointer to int)
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
sta ptr1
stx ptr1+1 ; pointer to result (struct dio_phys_pos)
jsr popax
sta ptr2
stx ptr2+1 ; pointer to input structure (pointer to int)
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
; fill in all we have
ldy #diopp_head
lda #0 ; head 0
sta (ptr1),y
ldy #diopp_track+1
sta (ptr1),y ; track <256
ldy #diopp_sector+1
sta (ptr1),y ; sector <256
ldy #0
lda (ptr2),y
sta tmp1
iny
lda (ptr2),y
sta tmp2
ldy #diopp_head
lda #0 ; head 0
sta (ptr1),y
ldy #diopp_track+1
sta (ptr1),y ; track <256
ldy #diopp_sector+1
sta (ptr1),y ; sector <256
ldy #0
lda (ptr2),y
sta tmp1
iny
lda (ptr2),y
sta tmp2
; get drive info
ldy #sst_driveno
lda (ptr3),y
tay
lda driveType,y
and #%00000011 ; this is for RamDrive compatibility
cmp #DRV_1541
beq dio_stc1541
cmp #DRV_1571
beq dio_stc1571
cmp #DRV_1581
beq dio_stc1581
lda #DEV_NOT_FOUND ; unknown device
ldx #0
beq _ret
ldy #sst_driveno
lda (ptr3),y
tay
lda driveType,y
and #%00000011 ; this is for RamDrive compatibility
cmp #DRV_1541
beq dio_stc1541
cmp #DRV_1571
beq dio_stc1571
cmp #DRV_1581
beq dio_stc1581
lda #DEV_NOT_FOUND ; unknown device
ldx #0
beq _ret
dio_stcend:
ldy #diopp_track
lda tmp1
sta (ptr1),y
ldy #diopp_sector
lda tmp2
sta (ptr1),y
ldx #0
txa
_ret:
sta __oserror
ldy #diopp_track
lda tmp1
sta (ptr1),y
ldy #diopp_sector
lda tmp2
sta (ptr1),y
ldx #0
txa
_ret:
sta __oserror
rts ; return success
; errors
_inv_data:
lda #INV_TRACK
lda #INV_TRACK
.byte $2c
_inv_hand:
lda #INCOMPATIBLE
ldx #0
beq _ret
lda #INCOMPATIBLE
ldx #0
beq _ret
dio_stc1541:
; if 1541:
; - compare with table to find track
; - subtract and find sector
ldx #0 ; index=(track-1)
ldx #0 ; index=(track-1)
_loop41:
lda tmp2
cmp sectab_1541_h+1,x
bne _nxt
lda tmp1
cmp sectab_1541_l+1,x
bcc _found
_nxt: inx
cpx #35
bne _loop41
beq _inv_data
_found:
lda tmp1
sec
sbc sectab_1541_l,x
sta tmp2
_fndend:
inx
stx tmp1
jmp dio_stcend
lda tmp2
cmp sectab_1541_h+1,x
bne _nxt
lda tmp1
cmp sectab_1541_l+1,x
bcc _found
_nxt: inx
cpx #35
bne _loop41
beq _inv_data
_found:
lda tmp1
sec
sbc sectab_1541_l,x
sta tmp2
_fndend:
inx
stx tmp1
jmp dio_stcend
dio_stc1571:
; if 1571:
; - check size, if too big - subtract and add 35 to track
; - fall down to 1541
lda tmp2
cmp #>683
bne _cnt71
lda tmp1
cmp #<683
bcc dio_stc1541
_cnt71:
lda tmp1
sec
sbc #<683
sta tmp1
lda tmp2
sbc #>683
sta tmp2
jsr dio_stc1541 ; will fall through here
ldy #diopp_track
lda (ptr1),y
clc
adc #35
sta (ptr1),y
lda #0
beq _ret
lda tmp2
cmp #>683
bne _cnt71
lda tmp1
cmp #<683
bcc dio_stc1541
_cnt71:
lda tmp1
sec
sbc #<683
sta tmp1
lda tmp2
sbc #>683
sta tmp2
jsr dio_stc1541 ; will fall through here
ldy #diopp_track
lda (ptr1),y
clc
adc #35
sta (ptr1),y
lda #0
beq _ret
; if 1581:
; - subtract 40 in loop (at most 80 times) to find track
; - the remainder is sector
dio_stc1581:
ldx #0 ; index=(track-1)
_loop81:
lda tmp2
bne _sub81
lda tmp1
cmp #40
bcc _got81
_sub81: lda tmp1
sec
sbc #40
sta tmp1
lda tmp2
sbc #0
sta tmp2
inx
cpx #81
bne _loop81
beq _inv_data
_got81: lda tmp1
sta tmp2
inx
stx tmp1
jmp dio_stcend
.endproc
ldx #0 ; index=(track-1)
_loop81:
lda tmp2
bne _sub81
lda tmp1
cmp #40
bcc _got81
_sub81: lda tmp1
sec
sbc #40
sta tmp1
lda tmp2
sbc #0
sta tmp2
inx
cpx #81
bne _loop81
beq _inv_data
_got81: lda tmp1
sta tmp2
inx
stx tmp1
jmp dio_stcend

View File

@@ -9,15 +9,13 @@
; sectnum_t - 16bit
;
.import dio_params, setoserror
.export _dio_write
.include "geossym.inc"
.include "jumptab.inc"
.import dio_params, setoserror
.export _dio_write
.proc _dio_write
.include "geossym.inc"
.include "jumptab.inc"
_dio_write:
jsr dio_params
jsr WriteBlock
jmp setoserror
.endproc

View File

@@ -9,17 +9,15 @@
; sectnum_t - 16bit
;
.import dio_params, __oserror
.export _dio_write_verify
.include "geossym.inc"
.include "jumptab.inc"
.import dio_params, __oserror
.export _dio_write_verify
.proc _dio_write_verify
.include "geossym.inc"
.include "jumptab.inc"
_dio_write_verify:
jsr dio_params
jsr VerWriteBlock
stx __oserror
txa
rts
.endproc