]> git.sur5r.net Git - cc65/commitdiff
added _dio_read() and _dio_write() handlers
authorcpg <cpg@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 9 Oct 2000 22:43:01 +0000 (22:43 +0000)
committercpg <cpg@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 9 Oct 2000 22:43:01 +0000 (22:43 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@349 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/atari/dioread.s [new file with mode: 0644]
libsrc/atari/diowrite.s [new file with mode: 0644]

diff --git a/libsrc/atari/dioread.s b/libsrc/atari/dioread.s
new file mode 100644 (file)
index 0000000..06ea0d4
--- /dev/null
@@ -0,0 +1,55 @@
+;
+; Christian Groessler, October 2000
+;
+; this file provides the _dio_read function
+;
+; unsigned char __fastcall__ _dio_read(_driveid_t drive_id, _sectnum_t sect_num, void *buffer);
+; _driveid_t - 8bit
+; _sectnum_t - 16bit
+;
+
+
+       .export         __dio_read
+       .import         popa,popax
+       .include        "atari.inc"
+
+.proc  __dio_read
+
+       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     #%01000000      ; indicate i/o direction (read)
+       sta     DSTATS
+       lda     #15
+       sta     DTIMLO          ; value got from DOS source
+       lda     #128
+       sta     DBYTLO          ; low byte of bytes to transfer 
+       lda     #SIO_READ       ; read 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
+
+.endproc
diff --git a/libsrc/atari/diowrite.s b/libsrc/atari/diowrite.s
new file mode 100644 (file)
index 0000000..6c037f3
--- /dev/null
@@ -0,0 +1,55 @@
+;
+; Christian Groessler, October 2000
+;
+; 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
+;
+
+
+       .export         __dio_write
+       .import         popa,popax
+       .include        "atari.inc"
+
+.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
+
+.endproc