]> git.sur5r.net Git - cc65/blob - libsrc/lynx/lseek.s
Fixed _textcolor definition.
[cc65] / libsrc / lynx / lseek.s
1 ;
2 ; Karri Kaksonen, 2010
3 ;
4 ; This function is used to place the Lynx hardware to point to any byte in
5 ; the Lynx cart.
6 ;
7 ; This function supports all available block sizes (512, 1024 and 2048 bytes).
8 ; No other block sizes have been used afaik.
9 ;
10 ; Only SEEK_SET operation mode is implemented.
11 ;
12 ; off_t __fastcall__ lseek(int fd, off_t offset, int whence);
13
14         .importzp       sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
15         .macpack        longbranch
16         .export         _lseek
17         .import         addysp, stax0sp, tosand0ax, pusheax, asreax2
18         .import         ldeaxysp, decsp2, pushax, incsp8
19         .import         tosandeax,decax1,tosdiveax,axlong,ldaxysp
20         .import         lynxskip0, lynxblock,tosasreax
21         .import         __BLOCKSIZE__
22         .importzp       _FileCurrBlock
23
24 .segment        "CODE"
25
26 .proc   _lseek: near
27
28 .segment        "CODE"
29
30         jsr     pushax
31         ldy     #$05
32         jsr     ldeaxysp
33         jsr     pusheax
34         ldx     #$00
35         lda     #<(__BLOCKSIZE__/1024 + 9)
36         jsr     tosasreax
37         sta     _FileCurrBlock
38         jsr     lynxblock
39         ldy     #$05
40         jsr     ldeaxysp
41         jsr     pusheax
42         lda     #<(__BLOCKSIZE__-1)
43         ldx     #>(__BLOCKSIZE__-1)
44         jsr     axlong
45         jsr     tosandeax
46         eor     #$FF
47         pha
48         txa
49         eor     #$FF
50         tay
51         plx
52         jsr     lynxskip0
53         ldy     #$05
54         jsr     ldeaxysp
55         jmp     incsp8
56
57 .endproc
58