]> git.sur5r.net Git - cc65/blob - libsrc/lynx/cartread.s
9330a085177aadad466dfb751840fa50287897a5
[cc65] / libsrc / lynx / cartread.s
1 ; ***
2 ; CC65 Lynx Library
3 ;
4 ; Originally by Bastian Schick
5 ; http://www.geocities.com/SiliconValley/Byte/4242/lynx/
6 ;
7 ; Ported to cc65 (http://www.cc65.org) by
8 ; Shawn Jefferson, June 2004
9 ;
10 ; ***
11 ;
12 ; void __fastcall__ read_cart_block(unsigned char block, char *dest)
13 ;
14 ; Reads an entire block (1024 bytes) from the cartridge into the buffer
15 ; pointed to by dest.
16
17
18         .export     _read_cart_block
19         .import     FileSelectBlock, FileReadBytes
20         .import     popa
21
22         .include    "extzp.inc"
23
24
25 .code
26
27 ;*******************************************
28 ; void read_cart_block (unsigned char block, char *dest);
29 ; loads one Block (1024 bytes) to pDest
30
31 _read_cart_block:
32         sta     _FileDestPtr            ;  lo
33         stx     _FileDestPtr+1          ;  hi
34
35         jsr     popa                    ; bBlock
36
37         sta     _FileCurrBlock
38         jsr     FileSelectBlock         ; select block# (Accu)
39
40         lda     #<1024                  ; load a whole block (1024 bytes)
41         eor     #$ff
42         tax
43         lda     #>1024
44         eor     #$ff
45         tay
46
47         jmp     FileReadBytes
48
49