]> git.sur5r.net Git - cc65/blob - libsrc/atmos/write.s
Exposed, to C code, the names of the Atmos ROM's sound effect functions.
[cc65] / libsrc / atmos / write.s
1 ;
2 ; Ullrich von Bassewitz, 2003-04-13
3 ;
4 ; int write (int fd, const void* buf, int count);
5 ;
6 ; This function is a hack!
7 ;
8
9         .export         _write
10         .import         popax
11         .importzp       ptr1, ptr2, ptr3, tmp1
12
13         .include        "atmos.inc"
14
15 .proc   _write
16
17         sta     ptr3
18         stx     ptr3+1          ; save count as result
19
20         eor     #$FF
21         sta     ptr2
22         txa
23         eor     #$FF
24         sta     ptr2+1          ; Remember -count-1
25
26         jsr     popax           ; get buf
27         sta     ptr1
28         stx     ptr1+1
29         jsr     popax           ; get fd and discard
30 L1:     inc     ptr2
31         bne     L2
32         inc     ptr2+1
33         beq     L9
34 L2:     ldy     #0
35         lda     (ptr1),y
36         tax
37         cpx     #$0A            ; Check for \n
38         bne     L3
39         jsr     PRINT
40         ldx     #$0D
41 L3:     jsr     PRINT
42         inc     ptr1
43         bne     L1
44         inc     ptr1+1
45         jmp     L1
46
47 ; No error, return count
48
49 L9:     lda     ptr3
50         ldx     ptr3+1
51         rts
52
53 .endproc
54
55