Lynx update including file routines that access a file system on a cartridge
by Karri Kaksonen. git-svn-id: svn://svn.cc65.org/cc65/trunk@4892 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
99
libsrc/lynx/lynx-cart.s
Normal file
99
libsrc/lynx/lynx-cart.s
Normal file
@@ -0,0 +1,99 @@
|
||||
; ***
|
||||
; CC65 Lynx Library
|
||||
;
|
||||
; Originally by Bastian Schick
|
||||
; http://www.geocities.com/SiliconValley/Byte/4242/lynx/
|
||||
;
|
||||
; Ported to cc65 (http://www.cc65.org) by
|
||||
; Shawn Jefferson, June 2004
|
||||
;
|
||||
; This version by Karri Kaksonen, December 2010
|
||||
;
|
||||
; Helper stuff for the cartridge file functions. This version can deal
|
||||
; with 1024 bytes/block carts that are using CART0 as a read strobe.
|
||||
; Also the default crt0.s supports this most common Lynx cart format.
|
||||
|
||||
.include "lynx.inc"
|
||||
.include "extzp.inc"
|
||||
.export lynxskip0, lynxread0
|
||||
.export lynxblock
|
||||
|
||||
__BLOCKSIZE0__ = 1024
|
||||
|
||||
.code
|
||||
|
||||
;**********************************
|
||||
; Skip bytes on bank 0
|
||||
; X:Y count (EOR $FFFF)
|
||||
;**********************************
|
||||
lynxskip0:
|
||||
inx
|
||||
bne @0
|
||||
iny
|
||||
beq exit
|
||||
@0: jsr readbyte0
|
||||
bra lynxskip0
|
||||
|
||||
;**********************************
|
||||
; Read bytes from bank 0
|
||||
; X:Y count (EOR $ffff)
|
||||
;**********************************
|
||||
lynxread0:
|
||||
inx
|
||||
bne @1
|
||||
iny
|
||||
beq exit
|
||||
@1: jsr readbyte0
|
||||
sta (_FileDestPtr)
|
||||
inc _FileDestPtr
|
||||
bne lynxread0
|
||||
inc _FileDestPtr+1
|
||||
bra lynxread0
|
||||
|
||||
;**********************************
|
||||
; Read one byte from cartridge
|
||||
;**********************************
|
||||
readbyte0:
|
||||
lda RCART0
|
||||
inc _FileBlockByte
|
||||
bne exit
|
||||
inc _FileBlockByte+1
|
||||
bne exit
|
||||
|
||||
;**********************************
|
||||
; Select a block
|
||||
;**********************************
|
||||
lynxblock:
|
||||
pha
|
||||
phx
|
||||
phy
|
||||
lda __iodat
|
||||
and #$fc
|
||||
tay
|
||||
ora #2
|
||||
tax
|
||||
lda _FileCurrBlock
|
||||
inc _FileCurrBlock
|
||||
sec
|
||||
bra @2
|
||||
@0: bcc @1
|
||||
stx IODAT
|
||||
clc
|
||||
@1: inx
|
||||
stx SYSCTL1
|
||||
dex
|
||||
@2: stx SYSCTL1
|
||||
rol
|
||||
sty IODAT
|
||||
bne @0
|
||||
lda __iodat
|
||||
sta IODAT
|
||||
stz _FileBlockByte
|
||||
lda #$100-(>__BLOCKSIZE0__)
|
||||
sta _FileBlockByte+1
|
||||
ply
|
||||
plx
|
||||
pla
|
||||
|
||||
exit: rts
|
||||
|
||||
Reference in New Issue
Block a user