]> git.sur5r.net Git - cc65/blob - libsrc/lynx/read.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / lynx / read.s
1 ;
2 ; Karri Kaksonen, 2010
3 ;
4 ; This function reads count bytes from the place where the address counter is.
5 ; Use lseek to place the address counter where you want to read from.
6 ;
7 ; The file descriptor is ignored in this implementation. The read operation
8 ; reads bytes from a raw cart and does not understand the concept of files.
9 ; So if you read over the end of file you get data from the next file.
10 ;
11 ; The count-parameter is positive (Atari style).
12 ;
13 ; int __fastcall__ read(int fd,void *buf,int count)
14 ;
15         .importzp       _FileDestPtr
16         .import         lynxread0
17         .import         pushax,ldaxysp,ldax0sp,incsp6
18         .export         _read
19
20 .segment        "CODE"
21
22 .proc   _read: near
23
24 .segment        "CODE"
25
26         jsr     pushax
27         ldy     #$03
28         jsr     ldaxysp
29         sta     _FileDestPtr
30         stx     _FileDestPtr+1
31         jsr     ldax0sp
32         pha
33         txa
34         eor     #$FF
35         tay
36         pla
37         eor     #$FF
38         tax
39         jsr     lynxread0
40         jsr     ldax0sp
41         jmp     incsp6
42
43 .endproc
44