]> git.sur5r.net Git - cc65/blobdiff - libsrc/atari/diowrite.s
adapt to CHARGEN_RELOC
[cc65] / libsrc / atari / diowrite.s
index 6c037f379e73d15e3d371657e82003ba63baec0b..93c8763aca082a70975d0a2d22cb89f81190759f 100644 (file)
@@ -3,53 +3,20 @@
 ;
 ; this file provides the _dio_write function
 ;
-; unsigned char __fastcall__ _dio_write(_driveid_t drive_id, _sectnum_t sect_num, void *buffer);
-; _driveid_t - 8bit
-; _sectnum_t - 16bit
+; unsigned char __fastcall__ dio_write(dhandle_t handle,unsigned sect_num,const void *buffer);
+; dhandle_t - 16bit (ptr)
 ;
 
+        .import         __sio_call,pushax
+        .export         _dio_write
+        .include        "atari.inc"
 
-       .export         __dio_write
-       .import         popa,popax
-       .include        "atari.inc"
+.proc   _dio_write
 
-.proc  __dio_write
-
-       sta     DBUFLO          ; set buffer address into DCB
-       stx     DBUFHI
-       jsr     popax
-       sta     DAUX1           ; set sector #
-       stx     DAUX2
-       jsr     popa
-       cmp     #16
-       bcs     _inv_dev        ; invalid device #
-       adc     #1
-       sta     DUNIT           ; unit number (d1,d2,d3,...)
-       lda     #$31            ; D1 (drive_id == 0) has id $31
-       sta     DDEVIC
-       lda     #0
-       sta     DBYTHI          ; high byte of bytes to transfer
-       lda     #%10000000      ; indicate i/o direction (write)
-       sta     DSTATS
-       lda     #15
-       sta     DTIMLO          ; value got from DOS source
-       lda     #128
-       sta     DBYTLO          ; low byte of bytes to transfer 
-       lda     #SIO_WRITE      ; write sector
-       sta     DCOMND
-
-       jsr     SIOV            ; execute
-
-       ldx     #0
-       lda     DSTATS
-       bmi     _req_err        ; error occurred
-       txa                     ; no error occurred
-_req_err:
-       rts
-
-_inv_dev:
-       ldx     #0
-       lda     #NONDEV         ; non-existent device error
-       rts
+        jsr     pushax          ; push buffer address
+        ldx     #%10000000      ; indicate i/o direction (write)
+        lda     #SIO_WRITE      ; write sector command
+        jmp     __sio_call      ; do the call and return to the user
 
 .endproc
+