added dio interface, standard mouse and joystick functions, osmaperrno
git-svn-id: svn://svn.cc65.org/cc65/trunk@773 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -11,7 +11,8 @@ S_OBJS = blkalloc.o calcblksfree.o changediskdevice.o chkdkgeos.o enterturbo.o e
|
||||
findbambit.o freeblock.o getblock.o getdirhead.o getptrcurdknm.o newdisk.o\
|
||||
nxtblkalloc.o opendisk.o purgeturbo.o putblock.o putdirhead.o readblock.o\
|
||||
readbuff.o setnextfree.o setgeosdisk.o writeblock.o writebuff.o verwriteblock.o\
|
||||
gettrse.o
|
||||
gettrse.o\
|
||||
dio_openclose.o dio_cts.o dio_stc.o dio_read.o dio_write.o dio_writev.o
|
||||
|
||||
all: $(S_OBJS)
|
||||
|
||||
|
||||
188
libsrc/geos/disk/dio_cts.s
Normal file
188
libsrc/geos/disk/dio_cts.s
Normal file
@@ -0,0 +1,188 @@
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
; 2.7.2001
|
||||
;
|
||||
;
|
||||
; unsigned char __fastcall__ dio_phys_to_log(dhandle_t handle,
|
||||
; dio_phys_pos *physpos, /* input */
|
||||
; sectnum_t *sectnum); /* output */
|
||||
;
|
||||
; dhandle_t - 16bit (ptr)
|
||||
; 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 "../inc/dio.inc"
|
||||
.include "../inc/geossym.inc"
|
||||
.include "../inc/const.inc"
|
||||
|
||||
.proc _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
|
||||
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
|
||||
iny
|
||||
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
|
||||
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
|
||||
|
||||
; unknown device, return what you have got
|
||||
|
||||
dio_ctsend:
|
||||
ldy #1
|
||||
lda tmp2
|
||||
sta (ptr1),y
|
||||
dey
|
||||
lda tmp1
|
||||
sta (ptr1),y
|
||||
|
||||
ldx #0
|
||||
txa
|
||||
ret:
|
||||
sta __oserror
|
||||
rts ; return success
|
||||
|
||||
; errors
|
||||
|
||||
_inv_data:
|
||||
lda #INV_TRACK
|
||||
.byte $2c
|
||||
_inv_hand:
|
||||
lda #INCOMPATIBLE
|
||||
ldx #0
|
||||
beq ret
|
||||
|
||||
; device-depended stuff, tmp1=track-1, tmp2=sector
|
||||
|
||||
dio_cts1541:
|
||||
ldy tmp1
|
||||
cpy #35
|
||||
bcs _inv_data
|
||||
lda sectab_1541_l,y
|
||||
clc
|
||||
adc tmp2
|
||||
sta tmp1
|
||||
lda sectab_1541_h,y
|
||||
adc #0
|
||||
sta tmp2
|
||||
jmp dio_ctsend
|
||||
|
||||
dio_cts1571:
|
||||
lda tmp1
|
||||
cmp #70
|
||||
bcs _inv_data
|
||||
cmp #35 ; last track of one side
|
||||
bcs _sub35
|
||||
jmp dio_cts1541 ; track <=35 - same as 1541
|
||||
|
||||
_sub35:
|
||||
sec
|
||||
sbc #35
|
||||
sta tmp1
|
||||
jsr dio_cts1541 ; get offset on second side of disk
|
||||
lda tmp1 ; add second side base
|
||||
clc
|
||||
adc #<683
|
||||
sta tmp1
|
||||
lda tmp2
|
||||
adc #>683
|
||||
sta tmp2
|
||||
jmp dio_ctsend
|
||||
|
||||
dio_cts1581:
|
||||
; 1581 has 80 tracks, 40 sectors each secnum=track*40+sector
|
||||
ldx #0
|
||||
stx tmp3
|
||||
stx tmp4
|
||||
lda tmp1
|
||||
beq _nomult
|
||||
cmp #80
|
||||
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
|
||||
|
||||
_nomult:
|
||||
lda tmp2
|
||||
clc
|
||||
adc tmp3
|
||||
sta tmp1
|
||||
lda tmp4
|
||||
adc #0
|
||||
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
|
||||
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
|
||||
84
libsrc/geos/disk/dio_openclose.s
Normal file
84
libsrc/geos/disk/dio_openclose.s
Normal file
@@ -0,0 +1,84 @@
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
;
|
||||
; based on Atari version by Christian Groessler
|
||||
; 2.7.2001
|
||||
;
|
||||
; dhandle_t __fastcall__ dio_open (driveid_t drive_id);
|
||||
; unsigned char __fastcall__ dio_close (dhandle_t handle);
|
||||
;
|
||||
; 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 "../inc/dio.inc"
|
||||
.include "../inc/jumptab.inc"
|
||||
.include "../inc/geossym.inc"
|
||||
.include "../inc/const.inc"
|
||||
|
||||
.bss
|
||||
|
||||
sectsizetab:
|
||||
.res 4 * sst_size ; this is hardcoded
|
||||
|
||||
.code
|
||||
|
||||
.proc _dio_open
|
||||
pha
|
||||
tax
|
||||
lda driveType,x ; check if there's a device
|
||||
bne _inv_drive
|
||||
clc
|
||||
adc #8 ; normalize devnum
|
||||
sta curDevice
|
||||
jsr SetDevice
|
||||
jsr _OpenDisk ; take care for errors there
|
||||
|
||||
pla
|
||||
tay ; drive #
|
||||
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
|
||||
tya
|
||||
sta sectsizetab+sst_driveno,x
|
||||
|
||||
stx tmp1
|
||||
lda #<sectsizetab
|
||||
clc
|
||||
adc tmp1
|
||||
sta tmp1
|
||||
lda #>sectsizetab
|
||||
adc #0
|
||||
tax
|
||||
lda tmp1
|
||||
|
||||
rts
|
||||
|
||||
_inv_drive:
|
||||
lda #DEV_NOT_FOUND
|
||||
sta __oserror
|
||||
lda #0
|
||||
tax
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
.proc _dio_close
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
lda #0
|
||||
ldy #sst_flag
|
||||
sta (ptr1),y
|
||||
sta __oserror ; success
|
||||
tax
|
||||
rts ; return no error
|
||||
.endproc
|
||||
32
libsrc/geos/disk/dio_params.s
Normal file
32
libsrc/geos/disk/dio_params.s
Normal file
@@ -0,0 +1,32 @@
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
; 2.7.2001
|
||||
;
|
||||
; this function is used by dio_read and dio_write to fix parameters (secnum)
|
||||
;
|
||||
|
||||
.import popax,pushax,_dio_log_to_phys
|
||||
.export dio_params,dio_secnum
|
||||
.include "../inc/geossym.inc"
|
||||
|
||||
.bss
|
||||
dio_secnum: .res 2
|
||||
|
||||
.code
|
||||
.proc dio_params
|
||||
|
||||
sta r4L
|
||||
stx r4H
|
||||
|
||||
jsr popax
|
||||
sta dio_secnum
|
||||
stx dio_secnum
|
||||
lda #<dio_secnum
|
||||
ldx #>dio_secnum
|
||||
jsr pushax
|
||||
|
||||
lda #<r1L
|
||||
ldx #>r1H
|
||||
jmp _dio_log_to_phys
|
||||
|
||||
.endproc
|
||||
25
libsrc/geos/disk/dio_read.s
Normal file
25
libsrc/geos/disk/dio_read.s
Normal file
@@ -0,0 +1,25 @@
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
; 2.7.2001
|
||||
;
|
||||
; this file provides the _dio_read function
|
||||
;
|
||||
; unsigned char __fastcall__ dio_read(dhandle_t handle,sectnum_t sect_num,void *buffer);
|
||||
; dhandle_t - 16bit (ptr)
|
||||
; sectnum_t - 16bit
|
||||
;
|
||||
|
||||
.import dio_params
|
||||
.export _dio_read
|
||||
.include "../inc/geossym.inc"
|
||||
.include "../inc/jumptab.inc"
|
||||
|
||||
.proc _dio_read
|
||||
|
||||
jsr dio_params
|
||||
jsr ReadBlock
|
||||
stx errno
|
||||
txa
|
||||
rts
|
||||
|
||||
.endproc
|
||||
180
libsrc/geos/disk/dio_stc.s
Normal file
180
libsrc/geos/disk/dio_stc.s
Normal file
@@ -0,0 +1,180 @@
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
; 2.7.2001
|
||||
;
|
||||
; unsigned char __fastcall__ dio_log_to_phys(dhandle_t handle,
|
||||
; sectnum_t *sectnum, /* input */
|
||||
; dio_phys_pos *physpos); /* output */
|
||||
;
|
||||
; dhandle_t - 16bit (ptr)
|
||||
; 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 "../inc/dio.inc"
|
||||
.include "../inc/geossym.inc"
|
||||
.include "../inc/const.inc"
|
||||
|
||||
.proc _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
|
||||
|
||||
; 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
|
||||
|
||||
; 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
|
||||
|
||||
; ...
|
||||
|
||||
dio_stcend:
|
||||
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
|
||||
.byte $2c
|
||||
_inv_hand:
|
||||
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)
|
||||
_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
|
||||
|
||||
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
|
||||
|
||||
; 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
|
||||
25
libsrc/geos/disk/dio_write.s
Normal file
25
libsrc/geos/disk/dio_write.s
Normal file
@@ -0,0 +1,25 @@
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
; 2.7.2001
|
||||
;
|
||||
; this file provides the _dio_write function
|
||||
;
|
||||
; unsigned char __fastcall__ dio_write(dhandle_t handle,sectnum_t sect_num,const void *buffer);
|
||||
; dhandle_t - 16bit (ptr)
|
||||
; sectnum_t - 16bit
|
||||
;
|
||||
|
||||
.import dio_params
|
||||
.export _dio_write
|
||||
.include "../inc/geossym.inc"
|
||||
.include "../inc/jumptab.inc"
|
||||
|
||||
.proc _dio_write
|
||||
|
||||
jsr dio_params
|
||||
jsr WriteBlock
|
||||
stx errno
|
||||
txa
|
||||
rts
|
||||
|
||||
.endproc
|
||||
25
libsrc/geos/disk/dio_writev.s
Normal file
25
libsrc/geos/disk/dio_writev.s
Normal file
@@ -0,0 +1,25 @@
|
||||
;
|
||||
; Maciej 'YTM/Elysium' Witkowiak
|
||||
; 2.7.2001
|
||||
;
|
||||
; this file provides the _dio_write function
|
||||
;
|
||||
; unsigned char __fastcall__ dio_write_verify(dhandle_t handle,sectnum_t sect_num,const void *buffer);
|
||||
; dhandle_t - 16bit (ptr)
|
||||
; sectnum_t - 16bit
|
||||
;
|
||||
|
||||
.import dio_params
|
||||
.export _dio_write_verify
|
||||
.include "../inc/geossym.inc"
|
||||
.include "../inc/jumptab.inc"
|
||||
|
||||
.proc _dio_write_verify
|
||||
|
||||
jsr dio_params
|
||||
jsr VerWriteBlock
|
||||
stx errno
|
||||
txa
|
||||
rts
|
||||
|
||||
.endproc
|
||||
Reference in New Issue
Block a user