]> git.sur5r.net Git - cc65/blob - libsrc/atari/siocall.s
db71e44ec9483ef0d4f088bfb0bff703c052d509
[cc65] / libsrc / atari / siocall.s
1 ;
2 ; Christian Groessler, October 2000
3 ;
4 ; this file provides the __sio_call function
5 ; the function does a SIO call, it's not completely
6 ; generic (e.g. transfer size is fixed), it's used
7 ; to save space with _dio_read and _dio_write functions
8 ;
9 ; unsigned char __fastcall__ _sio_call(_driveid_t drive_id,
10 ;                                      _sectnum_t sect_num,
11 ;                                      void *buffer,
12 ;                                      unsigned int sio_val);
13 ; _driveid_t - 8bit
14 ; _sectnum_t - 16bit
15 ; sio_cal is (sio_command | sio_direction << 8)
16 ;
17
18         .export         __sio_call
19         .include        "atari.inc"
20         .import         popa,popax
21
22 .proc   __sio_call
23
24         sta     DCOMND          ; set command into DCB
25         stx     DSTATS          ; set data flow directon
26         jsr     popax           ; get buffer address
27         sta     DBUFLO          ; set buffer address into DCB
28         stx     DBUFHI
29         jsr     popax
30         sta     DAUX1           ; set sector #
31         stx     DAUX2
32         jsr     popa
33         cmp     #16
34         bcs     _inv_dev        ; invalid device #
35         adc     #1
36         sta     DUNIT           ; unit number (d1,d2,d3,...)
37         lda     #$31            ; D1 (drive_id == 0) has id $31
38         sta     DDEVIC
39         lda     #0
40         sta     DBYTHI          ; high byte of bytes to transfer
41         lda     #15
42         sta     DTIMLO          ; value got from DOS source
43         lda     #128
44         sta     DBYTLO          ; low byte of bytes to transfer 
45
46         jsr     SIOV            ; execute
47
48         ldx     #0
49         lda     DSTATS
50         bmi     _req_err        ; error occurred
51         txa                     ; no error occurred
52 _req_err:
53         rts
54
55 _inv_dev:
56         ldx     #0
57         lda     #NONDEV         ; non-existent device error
58         rts
59
60 .endproc