X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Fatari%2Fsiocall.s;h=da8a62656730c64d4697f557fffa5a403248ab98;hb=6657214a18d41ce76e9ea1bc8b67977ee13d3645;hp=0a8f9acddd6ab3485b40ed83216ac4e0efdbf034;hpb=e32644afb0f4f014e950453b3a3e3015d5fcc01e;p=cc65 diff --git a/libsrc/atari/siocall.s b/libsrc/atari/siocall.s index 0a8f9acdd..da8a62656 100644 --- a/libsrc/atari/siocall.s +++ b/libsrc/atari/siocall.s @@ -6,19 +6,20 @@ ; generic (e.g. transfer size is fixed), it's used ; to save space with _dio_read and _dio_write functions. ; -; unsigned char __fastcall__ _sio_call(_driveid_t drive_id, -; _sectnum_t sect_num, +; unsigned char __fastcall__ _sio_call(dhandle_t handle, +; sectnum_t sect_num, ; void *buffer, ; unsigned int sio_val); -; _driveid_t - 8bit -; _sectnum_t - 16bit +; dhandle_t - 16bit (ptr) +; sectnum_t - 16bit ; sio_val is (sio_command | sio_direction << 8) ; .export __sio_call .include "atari.inc" .import popa,popax - .import sectsizetab + .import sectsizetab,__oserror + .importzp ptr1 .proc __sio_call @@ -30,19 +31,43 @@ jsr popax sta DAUX1 ; set sector # stx DAUX2 - jsr popa - cmp #NUMDRVS - bcs _inv_dev ; invalid device # + + jsr popax + sta ptr1 + stx ptr1+1 + + ldy #sst_flag + lda (ptr1),y + and #128 + beq _inv_hand ; handle not open or invalid + + ldy #sst_driveno + lda (ptr1),y + + clc adc #1 sta DUNIT ; unit number (d1,d2,d3,...) - sbc #0 + + lda DAUX2 ; high byte sector # + bne _realsz + lda DAUX1 + cmp #4 ; sectors 1 to 3 are special (always 128 bytes) + bcs _realsz + + lda #$80 + sta DBYTLO asl a - tax - lda sectsizetab,x - sta DBYTLO ; low byte of bytes to transfer - lda sectsizetab+1,x - sta DBYTHI ; high byte of bytes to transfer - lda #$31 ; D1 (drive_id == 0) has id $31 + sta DBYTHI + beq _cont + +_realsz:ldy #sst_sectsize + lda (ptr1),y + sta DBYTLO + iny + lda (ptr1),y + sta DBYTHI + +_cont: lda #DISKID ; SIO bus ID of diskette drive sta DDEVIC lda #15 sta DTIMLO ; value got from DOS source @@ -54,11 +79,12 @@ bmi _req_err ; error occurred txa ; no error occurred _req_err: + sta __oserror rts -_inv_dev: +_inv_hand: ldx #0 - lda #NONDEV ; non-existent device error - rts + lda #BADIOC + bne _req_err .endproc