]> git.sur5r.net Git - cc65/blob - libsrc/lynx/lynx-cart.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / lynx / lynx-cart.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 ; This version by Karri Kaksonen, December 2010
11 ;
12 ; Helper stuff for the cartridge file functions. This version can deal
13 ; with 1024 bytes/block carts that are using CART0 as a read strobe.
14 ; Also the default crt0.s supports this most common Lynx cart format.
15
16         .include "lynx.inc"
17         .include "extzp.inc"
18         .export  lynxskip0, lynxread0
19         .export  lynxblock 
20         .import  __BLOCKSIZE__
21
22         .code
23
24 ;**********************************
25 ; Skip bytes on bank 0
26 ; X:Y count (EOR $FFFF)
27 ;**********************************
28 lynxskip0:
29         inx
30         bne @0
31         iny
32         beq exit
33 @0:     jsr readbyte0
34         bra lynxskip0
35
36 ;**********************************
37 ; Read bytes from bank 0
38 ; X:Y count (EOR $ffff)
39 ;**********************************
40 lynxread0:
41         inx
42         bne @1
43         iny
44         beq exit
45 @1:     jsr readbyte0
46         sta (_FileDestPtr)
47         inc _FileDestPtr
48         bne lynxread0
49         inc _FileDestPtr+1
50         bra lynxread0
51
52 ;**********************************
53 ; Read one byte from cartridge
54 ;**********************************
55 readbyte0:
56         lda RCART0
57         inc _FileBlockByte
58         bne exit
59         inc _FileBlockByte+1
60         bne exit
61
62 ;**********************************
63 ; Select a block 
64 ;**********************************
65 lynxblock:
66         pha
67         phx
68         phy
69         lda __iodat
70         and #$fc
71         tay
72         ora #2
73         tax
74         lda _FileCurrBlock
75         inc _FileCurrBlock
76         sec
77         bra @2
78 @0:     bcc @1
79         stx IODAT
80         clc
81 @1:     inx
82         stx SYSCTL1
83         dex
84 @2:     stx SYSCTL1
85         rol
86         sty IODAT
87         bne @0
88         lda __iodat
89         sta IODAT
90         stz _FileBlockByte
91         lda #<($100-(>__BLOCKSIZE__))
92         sta _FileBlockByte+1
93         ply
94         plx
95         pla
96
97 exit:   rts
98