mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-06-07 08:30:20 +00:00
mist: another demake
This commit is contained in:
parent
05ebecfeeb
commit
4732a8c5c7
BIN
mist/MIST_TITLE.LZ4
Normal file
BIN
mist/MIST_TITLE.LZ4
Normal file
Binary file not shown.
44
mist/Makefile
Normal file
44
mist/Makefile
Normal file
|
@ -0,0 +1,44 @@
|
|||
include ../Makefile.inc
|
||||
|
||||
DOS33 = ../dos33fs-utils/dos33
|
||||
PNG_TO_40x96 = ../gr-utils/png_to_40x96
|
||||
PNG_TO_40x48D = ../gr-utils/png_to_40x48d
|
||||
PNG2RLE = ../gr-utils/png2rle
|
||||
B2D = ../bmp2dhr/b2d
|
||||
|
||||
all: mist.dsk
|
||||
|
||||
mist.dsk: HELLO MIST MIST_TITLE.LZ4
|
||||
cp empty.dsk mist.dsk
|
||||
$(DOS33) -y mist.dsk SAVE A HELLO
|
||||
$(DOS33) -y mist.dsk BSAVE -a 0x1000 MIST
|
||||
$(DOS33) -y mist.dsk BSAVE -a 0xa000 MIST_TITLE.LZ4
|
||||
|
||||
###
|
||||
|
||||
HELLO: hello.bas
|
||||
../asoft_basic-utils/tokenize_asoft < hello.bas > HELLO
|
||||
|
||||
####
|
||||
|
||||
MIST: mist.o
|
||||
ld65 -o MIST mist.o -C ../linker_scripts/apple2_1000.inc
|
||||
|
||||
mist.o: mist.s zp.inc hardware.inc
|
||||
#gr_copy.s gr_unrle.s gr_unrle_large.s gr_copy_large.s
|
||||
ca65 -o mist.o mist.s -l mist.lst
|
||||
|
||||
####
|
||||
|
||||
MIST_TITLE.LZ4: MIST_TITLEC.BIN
|
||||
lz4 -f -16 MIST_TITLEC.BIN
|
||||
dd if=MIST_TITLEC.BIN.lz4 of=MIST_TITLE.LZ4 bs=1 skip=11
|
||||
truncate MIST_TITLE.LZ4 -s -8
|
||||
|
||||
MIST_TITLEC.BIN: mist_title.bmp
|
||||
$(B2D) mist_title.bmp HGR -d
|
||||
|
||||
####
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o *.lst MIST_TITLEC.BIN MIST
|
BIN
mist/empty.dsk
Normal file
BIN
mist/empty.dsk
Normal file
Binary file not shown.
86
mist/hardware.inc
Normal file
86
mist/hardware.inc
Normal file
|
@ -0,0 +1,86 @@
|
|||
;; HARDWARE LOCATIONS
|
||||
|
||||
KEYPRESS = $C000
|
||||
KEYRESET = $C010
|
||||
|
||||
;; SOFT SWITCHES
|
||||
CLR80COL = $C000 ; PAGE0/PAGE1 normal
|
||||
SET80COL = $C001 ; PAGE0/PAGE1 switches PAGE0 in Aux instead
|
||||
EIGHTYCOLOFF = $C00C
|
||||
EIGHTYCOLON = $C00D
|
||||
SPEAKER = $C030
|
||||
SET_GR = $C050
|
||||
SET_TEXT = $C051
|
||||
FULLGR = $C052
|
||||
TEXTGR = $C053
|
||||
PAGE0 = $C054
|
||||
PAGE1 = $C055
|
||||
LORES = $C056 ; Enable LORES graphics
|
||||
HIRES = $C057 ; Enable HIRES graphics
|
||||
AN3 = $C05E ; Annunciator 3
|
||||
|
||||
PADDLE_BUTTON0 = $C061
|
||||
PADDL0 = $C064
|
||||
PTRIG = $C070
|
||||
|
||||
;; BASIC ROUTINES
|
||||
|
||||
NORMAL = $F273
|
||||
|
||||
;; MONITOR ROUTINES
|
||||
|
||||
HLINE = $F819 ;; HLINE Y,$2C at A
|
||||
VLINE = $F828 ;; VLINE A,$2D at Y
|
||||
CLRSCR = $F832 ;; Clear low-res screen
|
||||
CLRTOP = $F836 ;; clear only top of low-res screen
|
||||
SETCOL = $F864 ;; COLOR=A
|
||||
TEXT = $FB36
|
||||
TABV = $FB5B ;; VTAB to A
|
||||
BELL = $FBDD ;; ring the bell
|
||||
BASCALC = $FBC1 ;;
|
||||
VTAB = $FC22 ;; VTAB to CV
|
||||
HOME = $FC58 ;; Clear the text screen
|
||||
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
|
||||
CROUT1 = $FD8B
|
||||
SETINV = $FE80 ;; INVERSE
|
||||
SETNORM = $FE84 ;; NORMAL
|
||||
COUT = $FDED ;; output A to screen
|
||||
COUT1 = $FDF0 ;; output A to screen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
COLOR_BLACK = 0
|
||||
COLOR_RED = 1
|
||||
COLOR_DARKBLUE = 2
|
||||
COLOR_PURPLE = 3
|
||||
COLOR_DARKGREEN = 4
|
||||
COLOR_GREY = 5
|
||||
COLOR_MEDIUMBLUE = 6
|
||||
COLOR_LIGHTBLUE = 7
|
||||
COLOR_BROWN = 8
|
||||
COLOR_ORANGE = 9
|
||||
COLOR_GREY2 = 10
|
||||
COLOR_PINK = 11
|
||||
COLOR_LIGHTGREEN = 12
|
||||
COLOR_YELLOW = 13
|
||||
COLOR_AQUA = 14
|
||||
COLOR_WHITE = 15
|
||||
|
||||
COLOR_BOTH_BLACK = $00
|
||||
COLOR_BOTH_RED = $11
|
||||
COLOR_BOTH_DARKBLUE = $22
|
||||
COLOR_BOTH_DARKGREEN = $44
|
||||
COLOR_BOTH_GREY = $55
|
||||
COLOR_BOTH_MEDIUMBLUE = $66
|
||||
COLOR_BOTH_LIGHTBLUE = $77
|
||||
COLOR_BOTH_BROWN = $88
|
||||
COLOR_BOTH_ORANGE = $99
|
||||
COLOR_BOTH_PINK = $BB
|
||||
COLOR_BOTH_LIGHTGREEN = $CC
|
||||
COLOR_BOTH_YELLOW = $DD
|
||||
COLOR_BOTH_AQUA = $EE
|
||||
COLOR_BOTH_WHITE = $FF
|
||||
|
7
mist/hello.bas
Normal file
7
mist/hello.bas
Normal file
|
@ -0,0 +1,7 @@
|
|||
5 HOME
|
||||
10 PRINT " LOADING MIST"
|
||||
90 PRINT
|
||||
100 PRINT" ______"
|
||||
100 PRINT" A \/\/\/ SOFTWARE PRODUCTION"
|
||||
110 PRINT
|
||||
120 PRINT CHR$(4);"BRUN MIST"
|
201
mist/lz4_decode.s
Normal file
201
mist/lz4_decode.s
Normal file
|
@ -0,0 +1,201 @@
|
|||
; LZ4 data decompressor for Apple II
|
||||
|
||||
; Code by Peter Ferrie (qkumba) (peter.ferrie@gmail.com)
|
||||
; "LZ4 unpacker in 143 bytes (6502 version) (2013)"
|
||||
; http://pferrie.host22.com/misc/appleii.htm
|
||||
; This is that code, but with comments and labels added for clarity.
|
||||
; I also found a bug when decoding with runs of multiples of 256
|
||||
; which has since been fixed upstream.
|
||||
|
||||
; For LZ4 reference see
|
||||
; https://github.com/lz4/lz4/wiki/lz4_Frame_format.md
|
||||
|
||||
; LZ4 summary:
|
||||
;
|
||||
; HEADER:
|
||||
; Should: check for magic number 04 22 4d 18
|
||||
; FLG: 64 in our case (01=version, block.index=1, block.checksum=0
|
||||
; size=0, checksum=1, reserved
|
||||
; MAX Blocksize: 40 (64kB)
|
||||
; HEADER CHECKSUM: a7
|
||||
; BLOCK HEADER: 4 bytes (le) length If highest bit set, uncompressed!
|
||||
; data (see below), followed by checksum?
|
||||
; BLOCKS:
|
||||
; Token byte. High 4-bits literal length, low 4-bits copy length
|
||||
; + If literal length==15, then following byte gets added to length
|
||||
; If that byte was 255, then keep adding bytes until not 255
|
||||
; + The literal bytes follow. There may be zero of them
|
||||
; + Next is block copy info. little-endian 2-byte offset to
|
||||
; be subtracted from current read position indicating source
|
||||
; + The low 4-bits of the token are the copy length, which needs
|
||||
; 4 added to it. As with the literal length, if it is 15 then
|
||||
; you read a byte and add (and if that byte is 255, keep adding)
|
||||
|
||||
; At end you have 4 byte end-of-block marker (all zeros?) then
|
||||
; 4 bytes of checksum (if marked in flags)
|
||||
; our code does that, so be sure to set end -8
|
||||
|
||||
|
||||
;LZ4_SRC EQU $00
|
||||
;LZ4_DST EQU $02
|
||||
;LZ4_END EQU $04
|
||||
;COUNT EQU $06
|
||||
;DELTA EQU $08
|
||||
|
||||
|
||||
;======================
|
||||
; LZ4 decode
|
||||
;======================
|
||||
; input buffer in LZ4_SRC
|
||||
; end of input in LZ4_END
|
||||
; output buffer in LZ4_DST
|
||||
|
||||
|
||||
lz4_decode:
|
||||
|
||||
|
||||
unpmain:
|
||||
ldy #0 ; used to index, always zero
|
||||
|
||||
parsetoken:
|
||||
jsr getsrc ; get next token
|
||||
pha ; save for later (need bottom 4 bits)
|
||||
|
||||
lsr ; number of literals in top 4 bits
|
||||
lsr ; so shift into place
|
||||
lsr
|
||||
lsr
|
||||
beq copymatches ; if zero, then no literals
|
||||
; jump ahead and copy
|
||||
|
||||
jsr buildcount ; add up all the literal sizes
|
||||
; result is in ram[count+1]-1:A
|
||||
tax ; now in ram[count+1]-1:X
|
||||
jsr docopy ; copy the literals
|
||||
|
||||
lda LZ4_SRC ; 16-bit compare
|
||||
cmp LZ4_END ; to see if we have reached the end
|
||||
lda LZ4_SRC+1
|
||||
sbc LZ4_END+1
|
||||
bcs done
|
||||
|
||||
copymatches:
|
||||
jsr getsrc ; get 16-bit delta value
|
||||
sta DELTA
|
||||
jsr getsrc
|
||||
sta DELTA+1
|
||||
|
||||
pla ; restore token
|
||||
and #$0f ; get bottom 4 bits
|
||||
; match count. 0 means 4
|
||||
; 15 means 19+, must be calculated
|
||||
|
||||
jsr buildcount ; add up count bits, in ram[count+1]-:A
|
||||
|
||||
clc
|
||||
adc #4 ; adjust count by 4 (minmatch)
|
||||
|
||||
tax ; now in ramp[count+1]-1:X
|
||||
|
||||
beq copy_no_adjust ; BUGFIX, don't increment if
|
||||
; exactly a multiple of 0x100
|
||||
bcc copy_no_adjust
|
||||
|
||||
inc COUNT+1 ; increment if we overflowed
|
||||
copy_no_adjust:
|
||||
|
||||
lda LZ4_SRC+1 ; save src on stack
|
||||
pha
|
||||
lda LZ4_SRC
|
||||
pha
|
||||
|
||||
sec ; subtract delta
|
||||
lda LZ4_DST ; from destination, make new src
|
||||
sbc DELTA
|
||||
sta LZ4_SRC
|
||||
lda LZ4_DST+1
|
||||
sbc DELTA+1
|
||||
sta LZ4_SRC+1
|
||||
|
||||
jsr docopy ; do the copy
|
||||
|
||||
pla ; restore the src
|
||||
sta LZ4_SRC
|
||||
pla
|
||||
sta LZ4_SRC+1
|
||||
|
||||
jmp parsetoken ; back to parsing tokens
|
||||
|
||||
done:
|
||||
pla
|
||||
rts
|
||||
|
||||
;=========
|
||||
; getsrc
|
||||
;=========
|
||||
; gets byte from src into A, increments pointer
|
||||
getsrc:
|
||||
lda (LZ4_SRC), Y ; get a byte from src
|
||||
inc LZ4_SRC ; increment pointer
|
||||
bne done_getsrc ; update 16-bit pointer
|
||||
inc LZ4_SRC+1 ; on 8-bit overflow
|
||||
done_getsrc:
|
||||
rts
|
||||
|
||||
;============
|
||||
; buildcount
|
||||
;============
|
||||
buildcount:
|
||||
ldx #1 ; high count starts at 1
|
||||
stx COUNT+1 ; (loops at zero?)
|
||||
cmp #$0f ; if LITERAL_COUNT < 15, we are done
|
||||
bne done_buildcount
|
||||
buildcount_loop:
|
||||
sta COUNT ; save LITERAL_COUNT (15)
|
||||
jsr getsrc ; get the next byte
|
||||
tax ; put in X
|
||||
clc
|
||||
adc COUNT ; add new byte to old value
|
||||
bcc bc_8bit_oflow ; if overflow, increment high byte
|
||||
inc COUNT+1
|
||||
bc_8bit_oflow:
|
||||
inx ; check if read value was 255
|
||||
beq buildcount_loop ; if it was, keep looping and adding
|
||||
done_buildcount:
|
||||
rts
|
||||
|
||||
;============
|
||||
; getput
|
||||
;============
|
||||
; gets a byte, then puts the byte
|
||||
getput:
|
||||
jsr getsrc
|
||||
; fallthrough to putdst
|
||||
|
||||
;=============
|
||||
; putdst
|
||||
;=============
|
||||
; store A into destination
|
||||
putdst:
|
||||
sta (LZ4_DST), Y ; store A into destination
|
||||
inc LZ4_DST ; increment 16-bit pointer
|
||||
bne putdst_end ; if overflow, increment top byte
|
||||
inc LZ4_DST+1
|
||||
putdst_end:
|
||||
rts
|
||||
|
||||
;=============================
|
||||
; docopy
|
||||
;=============================
|
||||
; copies ram[count+1]-1:X bytes
|
||||
; from src to dst
|
||||
docopy:
|
||||
|
||||
docopy_loop:
|
||||
jsr getput ; get/put byte
|
||||
dex ; decrement count
|
||||
bne docopy_loop ; if not zero, loop
|
||||
dec COUNT+1 ; if zero, decrement high byte
|
||||
bne docopy_loop ; if not zero, loop
|
||||
|
||||
rts
|
100
mist/mist.s
Normal file
100
mist/mist.s
Normal file
|
@ -0,0 +1,100 @@
|
|||
; Mist
|
||||
|
||||
; a version of Myst?
|
||||
; (yes there's a subtle German joke here)
|
||||
|
||||
; by deater (Vince Weaver) <vince@deater.net>
|
||||
|
||||
; Zero Page
|
||||
.include "zp.inc"
|
||||
.include "hardware.inc"
|
||||
|
||||
|
||||
mist_start:
|
||||
;===================
|
||||
; init screen
|
||||
jsr TEXT
|
||||
jsr HOME
|
||||
bit KEYRESET
|
||||
|
||||
bit SET_GR
|
||||
bit PAGE0
|
||||
bit HIRES
|
||||
bit FULLGR
|
||||
|
||||
|
||||
;===================
|
||||
; Init RTS disk code
|
||||
;===================
|
||||
|
||||
jsr rts_init
|
||||
|
||||
;===================
|
||||
; Load graphics
|
||||
;===================
|
||||
reload_everything:
|
||||
; load MIST_TITLE.LZ4 to $a000
|
||||
; then decompress it to $2000 (HGR PAGE0)
|
||||
|
||||
lda #<mist_title_filename
|
||||
sta OUTL
|
||||
lda #>mist_title_filename
|
||||
sta OUTH
|
||||
jsr opendir_filename ; open and read entire file into memory
|
||||
|
||||
; size in ldsizeh:ldsizel (f1/f0)
|
||||
|
||||
clc
|
||||
lda #<($a000)
|
||||
sta LZ4_SRC
|
||||
adc ldsizel
|
||||
sta LZ4_END
|
||||
|
||||
lda #>($a000)
|
||||
sta LZ4_SRC+1
|
||||
adc ldsizeh
|
||||
sta LZ4_END+1
|
||||
|
||||
; lda #<($a000+4103-8) ; skip checksum at end
|
||||
; sta LZ4_END
|
||||
; lda #>($a000+4103-8) ; skip checksum at end
|
||||
; sta LZ4_END+1
|
||||
|
||||
lda #<$2000
|
||||
sta LZ4_DST
|
||||
lda #>$2000
|
||||
sta LZ4_DST+1
|
||||
|
||||
jsr lz4_decode
|
||||
|
||||
|
||||
;===================
|
||||
; set graphics mode
|
||||
;===================
|
||||
jsr HOME
|
||||
|
||||
|
||||
bit PAGE0
|
||||
|
||||
blah:
|
||||
jmp blah
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; .include "gr_putsprite.s"
|
||||
; .include "gr_offsets.s"
|
||||
; .include "gr_fast_clear.s"
|
||||
; .include "gr_hline.s"
|
||||
; .include "wait_keypress.s"
|
||||
.include "lz4_decode.s"
|
||||
.include "rts.s"
|
||||
|
||||
|
||||
; filename to open is 30-character Apple text:
|
||||
mist_title_filename: ; .byte "MIST_TITLE.LZ4",0
|
||||
.byte 'M'|$80,'I'|$80,'S'|$80,'T'|$80,'_'|$80,'T'|$80,'I'|$80,'T'|$80
|
||||
.byte 'L'|$80,'E'|$80,'.'|$80,'L'|$80,'Z'|$80,'4'|$80,$00
|
||||
|
||||
|
557
mist/rts.s
Normal file
557
mist/rts.s
Normal file
|
@ -0,0 +1,557 @@
|
|||
; read any file slot 6 version
|
||||
; based on FASTLD6 and RTS copyright (c) Peter Ferrie 2011-2013,2018
|
||||
|
||||
; modified to assembled with ca64 -- vmw
|
||||
; added code to patch it to run from current disk slot -- vmw
|
||||
|
||||
; USAGE:
|
||||
; file to load in namlo:namhi
|
||||
; Loads file contents to addr from filesystem
|
||||
; also stores filesize in ldsizel:ldsizeh
|
||||
|
||||
dirbuf = $900
|
||||
; note, don't put this immediately below
|
||||
; the value being read as destaddr-4
|
||||
; is temporarily overwritten during read
|
||||
; process
|
||||
|
||||
;======================
|
||||
|
||||
|
||||
|
||||
; filename to open is 30-character Apple text:
|
||||
filename:
|
||||
.byte $A0,$A0,$A0,$A0,$A0,$A0,$A0,$A0
|
||||
.byte $A0,$A0,$A0,$A0,$A0,$A0,$A0,$A0
|
||||
.byte $A0,$A0,$A0,$A0,$A0,$A0,$A0,$A0
|
||||
.byte $A0,$A0,$A0,$A0,$A0,$A0
|
||||
|
||||
;=======================================================
|
||||
;=======================================================
|
||||
;=======================================================
|
||||
;unhook DOS and build nibble table
|
||||
rts_init:
|
||||
; patch to use current drive
|
||||
|
||||
; locate input paramater list
|
||||
jsr $3E3
|
||||
; result is in A:Y
|
||||
sta $FF
|
||||
sty $FE
|
||||
ldy #1
|
||||
lda ($FE),y
|
||||
|
||||
; list+1 should have slot<<8
|
||||
|
||||
|
||||
ora #$80 ; add in $80
|
||||
|
||||
; c0e0
|
||||
sta mlsmc06+1
|
||||
|
||||
; c0e8
|
||||
clc
|
||||
adc #8
|
||||
sta mlsmc02+1
|
||||
|
||||
; c0e9
|
||||
clc
|
||||
adc #1
|
||||
sta mlsmc01+1
|
||||
|
||||
; c0ec
|
||||
clc
|
||||
adc #3
|
||||
sta mlsmc03+1
|
||||
sta mlsmc04+1
|
||||
sta mlsmc05+1
|
||||
|
||||
jsr $fe93 ; clear COUT
|
||||
jsr $fe89 ; clear KEYIN
|
||||
|
||||
;========================
|
||||
; Create nibble table
|
||||
; Note: the table starts 16 bytes in, and is sparse
|
||||
; so it doesn't entirely look like the DOS33 table at
|
||||
|
||||
ldy #0
|
||||
ldx #3
|
||||
L1: stx $3c ; store tempx (3?)
|
||||
txa ; a=x (a=3)
|
||||
asl ; a*=2 (a=6)
|
||||
bit $3c ; a&tempx, set N/V (a=6)
|
||||
beq L3 ; if 0, skip to L3
|
||||
ora $3c ; a|=tempx (a=7)
|
||||
eor #$ff ; a=~a (a=f8)
|
||||
and #$7e ; a&=0x7e 0111 1110 (a=78)
|
||||
L2: bcs L3 ; this set way back at asl??
|
||||
lsr ; a>>1 a=3c c=0
|
||||
; a=1e c=0
|
||||
; a=0f c=0
|
||||
; a=07 c=1
|
||||
bne L2 ; if a!=0 goto l2
|
||||
tya ; if a==0, a=y
|
||||
sta nibtbl, x ; write out to table
|
||||
iny ; increment y
|
||||
L3: inx ; increment x x=4, a=0f
|
||||
bpl L1 ; loop while high bit not set
|
||||
|
||||
rts
|
||||
|
||||
|
||||
;=======================================================
|
||||
;=======================================================
|
||||
;=======================================================
|
||||
|
||||
; filename in OUTL:OUTH
|
||||
|
||||
opendir_filename:
|
||||
|
||||
; clear out the filename with $A0 (space)
|
||||
|
||||
lda #<filename
|
||||
sta namlo
|
||||
lda #>filename
|
||||
sta namhi
|
||||
|
||||
ldy #29
|
||||
wipe_filename_loop:
|
||||
lda #$A0
|
||||
sta (namlo),Y
|
||||
dey
|
||||
bpl wipe_filename_loop
|
||||
|
||||
ldy #0
|
||||
copy_filename_loop:
|
||||
lda (OUTL),Y
|
||||
beq copy_filename_done
|
||||
sta (namlo),Y
|
||||
iny
|
||||
bne copy_filename_loop
|
||||
|
||||
copy_filename_done:
|
||||
|
||||
; fallthrough
|
||||
|
||||
;=======================================================
|
||||
;=======================================================
|
||||
;=======================================================
|
||||
|
||||
;===========================
|
||||
; opendir
|
||||
;===========================
|
||||
|
||||
; turn on drive and read volume table of contents
|
||||
opendir:
|
||||
mlsmc01:lda $c0e9 ; turn slot#6 drive on
|
||||
ldx #0
|
||||
stx adrlo ; zero out adrlo
|
||||
stx secsize ; zero out secsize
|
||||
lda #$11 ; a=$11 (VTOC)
|
||||
jsr readdirsec
|
||||
firstent:
|
||||
|
||||
lda dirbuf+1
|
||||
|
||||
; lock if entry not found
|
||||
entry_not_found:
|
||||
beq entry_not_found
|
||||
|
||||
; read directory sector
|
||||
|
||||
ldx dirbuf+2
|
||||
jsr seekread1
|
||||
ldy #7 ;number of directory entries in a sector
|
||||
ldx #$2b ;offset of filename in directory entry
|
||||
nextent:
|
||||
tya
|
||||
pha ; was **phy**
|
||||
txa
|
||||
pha ; was **phx**
|
||||
ldy #$1d
|
||||
|
||||
; match name backwards (slower but smaller)
|
||||
|
||||
L4:
|
||||
lda (namlo), y
|
||||
cmp dirbuf, x
|
||||
beq foundname
|
||||
pla
|
||||
|
||||
; move to next directory in this block, if possible
|
||||
|
||||
clc
|
||||
adc #$23
|
||||
tax
|
||||
pla
|
||||
tay ; was **ply**
|
||||
dey
|
||||
bne nextent
|
||||
beq firstent ; was **bra**
|
||||
|
||||
foundname:
|
||||
dex
|
||||
dey
|
||||
bpl L4
|
||||
pla
|
||||
tay ; was **ply**
|
||||
pla
|
||||
|
||||
; read track/sector list
|
||||
|
||||
lda dirbuf-32, y
|
||||
ldx dirbuf-31, y
|
||||
jsr seekread1
|
||||
|
||||
; read load offset and length info only, initially
|
||||
|
||||
lda #<filbuf
|
||||
sta adrlo
|
||||
lda #4
|
||||
sta secsize
|
||||
lda dirbuf+12
|
||||
ldx dirbuf+13
|
||||
ldy #>filbuf
|
||||
jsr seekread
|
||||
|
||||
; reduce load offset by 4, to account for offset and length
|
||||
|
||||
sec
|
||||
lda filbuf
|
||||
sbc #4
|
||||
sta adrlo
|
||||
|
||||
lda filbuf+1
|
||||
sbc #0
|
||||
sta adrhi
|
||||
|
||||
; save on stack bytes that will be overwritten by extra read
|
||||
|
||||
ldy #3
|
||||
L5:
|
||||
lda (adrlo), y
|
||||
pha
|
||||
dey
|
||||
bpl L5
|
||||
|
||||
lda adrhi
|
||||
pha
|
||||
lda adrlo
|
||||
pha
|
||||
|
||||
; increase load size by 4, to account for offst and length
|
||||
|
||||
lda filbuf+2
|
||||
sta ldsizel ; store out raw size
|
||||
|
||||
adc #3
|
||||
sta sizelo
|
||||
sta secsize
|
||||
|
||||
lda filbuf+3
|
||||
sta ldsizeh ; store out raw size
|
||||
|
||||
adc #0
|
||||
sta sizehi
|
||||
sta ldsizeh
|
||||
beq readfirst
|
||||
lda #0 ; was **stz secsize**
|
||||
sta secsize
|
||||
|
||||
readfirst:
|
||||
ldy #$0c
|
||||
|
||||
; read a file sector
|
||||
|
||||
readnext:
|
||||
tya
|
||||
pha
|
||||
lda dirbuf, y ; A = track
|
||||
ldx dirbuf+1, y ; x = sector
|
||||
jsr seekread1
|
||||
pla
|
||||
tay
|
||||
|
||||
; if low count is non-zero then we are done
|
||||
; (can happen only for partial last block)
|
||||
|
||||
lda secsize
|
||||
bne readdone
|
||||
|
||||
; continue if more than $100 bytes left
|
||||
|
||||
dec sizehi
|
||||
bne L6
|
||||
|
||||
; set read size to min(length, $100)
|
||||
|
||||
lda sizelo
|
||||
beq readdone
|
||||
sta secsize
|
||||
L6:
|
||||
inc adrhi
|
||||
iny
|
||||
iny
|
||||
bne readnext
|
||||
|
||||
; save current address for after t/s read
|
||||
|
||||
lda adrhi
|
||||
pha
|
||||
lda adrlo
|
||||
pha
|
||||
lda #0
|
||||
sta adrlo ; was **stz adrlo**
|
||||
|
||||
; read next track/sector sector
|
||||
|
||||
lda dirbuf+1
|
||||
ldx dirbuf+2
|
||||
jsr readdirsec
|
||||
clc
|
||||
|
||||
; restore current address
|
||||
readdone:
|
||||
pla
|
||||
; sta adrhi
|
||||
; pla
|
||||
sta adrlo ; code originally had this backwards
|
||||
pla
|
||||
sta adrhi
|
||||
bcc readfirst
|
||||
|
||||
mlsmc02:lda $c0e8
|
||||
|
||||
; restore from stack bytes that were overwritten by extra read
|
||||
|
||||
ldx #3
|
||||
ldy #0
|
||||
L7:
|
||||
pla
|
||||
sta (adrlo), y
|
||||
iny
|
||||
dex
|
||||
bpl L7
|
||||
rts
|
||||
|
||||
|
||||
;======================
|
||||
; readdirsec
|
||||
;======================
|
||||
; a = track?
|
||||
; x = sector?
|
||||
readdirsec:
|
||||
ldy #>dirbuf
|
||||
seekread:
|
||||
sty adrhi
|
||||
seekread1:
|
||||
sta phase
|
||||
lda sectbl, x
|
||||
sta reqsec
|
||||
jsr readadr
|
||||
|
||||
; if track does not match, then seek
|
||||
|
||||
cpx phase
|
||||
beq checksec
|
||||
jsr seek
|
||||
|
||||
|
||||
;=========================================
|
||||
; re merge in with qkumba's recent changes
|
||||
; to fix seek problem?
|
||||
;=========================================
|
||||
|
||||
; [re-]read sector
|
||||
|
||||
re_read_addr:
|
||||
jsr readadr
|
||||
checksec:
|
||||
cmp reqsec
|
||||
bne re_read_addr
|
||||
|
||||
;=========================
|
||||
; read sector data
|
||||
;=========================
|
||||
|
||||
readdata:
|
||||
jsr readd5aa
|
||||
eor #$ad ; zero A if match
|
||||
bne re_read_addr
|
||||
|
||||
L12:
|
||||
mlsmc03:ldx $c0ec ; read until valid data (high bit set)
|
||||
bpl L12
|
||||
eor nibtbl-$80, x
|
||||
sta bit2tbl-$aa, y
|
||||
iny
|
||||
bne L12
|
||||
L13:
|
||||
mlsmc04:ldx $c0ec ; read until valid data (high bit set)
|
||||
bpl L13
|
||||
eor nibtbl-$80, x
|
||||
sta (adrlo), y ; the real address
|
||||
iny
|
||||
cpy secsize
|
||||
bne L13
|
||||
ldy #0
|
||||
L14:
|
||||
ldx #$a9
|
||||
L15:
|
||||
inx
|
||||
beq L14
|
||||
lda (adrlo), y
|
||||
lsr bit2tbl-$aa, x
|
||||
rol
|
||||
lsr bit2tbl-$aa, x
|
||||
rol
|
||||
sta (adrlo), y
|
||||
iny
|
||||
cpy secsize
|
||||
bne L15
|
||||
rts
|
||||
|
||||
; no tricks here, just the regular stuff
|
||||
|
||||
;=======================
|
||||
; readaddr -- read the address field
|
||||
;=======================
|
||||
; Find address field, put track in cutrk, sector in tmpsec
|
||||
|
||||
readadr:
|
||||
jsr readd5aa
|
||||
cmp #$96
|
||||
bne readadr
|
||||
ldy #3 ; three?
|
||||
; first read volume/volume
|
||||
; then track/track
|
||||
; then sector/sector?
|
||||
adr_read_two_bytes:
|
||||
tax
|
||||
jsr readnib
|
||||
rol
|
||||
sta tmpsec
|
||||
jsr readnib
|
||||
and tmpsec
|
||||
dey
|
||||
bne adr_read_two_bytes
|
||||
rts
|
||||
|
||||
;========================
|
||||
; make sure we see the $D5 $AA pattern
|
||||
|
||||
readd5aa:
|
||||
L16:
|
||||
jsr readnib
|
||||
L17:
|
||||
cmp #$d5
|
||||
bne L16
|
||||
jsr readnib
|
||||
cmp #$aa
|
||||
bne L17
|
||||
tay ; we need Y=#$AA later
|
||||
|
||||
readnib:
|
||||
mlsmc05:lda $c0ec ; read until valid (high bit set)
|
||||
bpl readnib
|
||||
|
||||
seekret:
|
||||
rts
|
||||
|
||||
;=====================
|
||||
; SEEK
|
||||
;=====================
|
||||
; current track in X?
|
||||
; desired track in phase
|
||||
|
||||
seek:
|
||||
ldy #0
|
||||
sty step
|
||||
asl phase ; multiply by two
|
||||
txa ; current track?
|
||||
asl ; mul by two
|
||||
copy_cur:
|
||||
tax
|
||||
sta tmptrk
|
||||
sec
|
||||
sbc phase
|
||||
beq L22
|
||||
bcs L18
|
||||
eor #$ff
|
||||
inx
|
||||
bcc L19
|
||||
L18:
|
||||
sbc #1
|
||||
dex
|
||||
L19:
|
||||
cmp step
|
||||
bcc L20
|
||||
lda step
|
||||
L20:
|
||||
cmp #8
|
||||
bcs L21
|
||||
tay
|
||||
sec
|
||||
L21:
|
||||
txa
|
||||
pha
|
||||
ldx step1, y
|
||||
L22:
|
||||
php
|
||||
bne L24
|
||||
L23:
|
||||
clc
|
||||
lda tmptrk
|
||||
ldx step2, y
|
||||
L24:
|
||||
stx tmpsec
|
||||
and #3
|
||||
rol
|
||||
tax
|
||||
lsr
|
||||
mlsmc06:lda $c0e0, x
|
||||
L25:
|
||||
ldx #$12
|
||||
L26:
|
||||
dex
|
||||
bpl L26
|
||||
dec tmpsec
|
||||
bne L25
|
||||
bcs L23
|
||||
plp
|
||||
beq seekret
|
||||
pla
|
||||
inc step
|
||||
bne copy_cur
|
||||
|
||||
|
||||
step1: .byte $01, $30, $28, $24, $20, $1e, $1d, $1c
|
||||
step2: .byte $70, $2c, $26, $22, $1f, $1e, $1d, $1c
|
||||
|
||||
sectbl: .byte $00,$0d,$0b,$09,$07,$05,$03,$01,$0e,$0c,$0a,$08,$06,$04,$02,$0f
|
||||
|
||||
|
||||
; From $BA96 of DOS33
|
||||
nibtbl: .res 128 ; = *
|
||||
; .byte $00,$01,$98,$99,$02,$03,$9C,$04 ; $BA96 ; 00
|
||||
; .byte $05,$06,$A0,$A1,$A2,$A4,$A4,$A5 ; $BA9E ; 08
|
||||
; .byte $07,$08,$A8,$A9,$AA,$09,$0A,$0B ; $BAA6 ; 10
|
||||
; .byte $0C,$0D,$B0,$B1,$0E,$0F,$10,$11 ; $BAAE ; 18
|
||||
; .byte $12,$13,$B8,$14,$15,$16,$17,$18 ; $BAB6 ; 20
|
||||
; .byte $19,$1A,$C0,$C1,$C2,$C3,$C4,$C5 ; $BABE ; 28
|
||||
; .byte $C6,$C7,$C8,$C9,$CA,$1B,$CC,$1C ; $BAC6 ; 30
|
||||
; .byte $1D,$1E,$D0,$D1,$D2,$1E,$D4,$D5 ; $BACE ; 38
|
||||
; .byte $20,$21,$D8,$22,$23,$24,$25,$26 ; $BAD6 ; 40
|
||||
; .byte $27,$28,$E0,$E1,$E2,$E3,$E4,$29 ; $BADE ; 48
|
||||
; .byte $2A,$2B,$E8,$2C,$2D,$2E,$2F,$30 ; $BAE6 ; 50
|
||||
; .byte $31,$32,$F0,$F1,$33,$34,$35,$36 ; $BAEE ; 58
|
||||
; .byte $37,$38,$F8,$39,$3A,$3B,$3C,$3D ; $BAF6 ; 60
|
||||
; .byte $3E,$3F,$13,$00,$01,$02,$01,$00 ; $BAFE ; 68
|
||||
; .byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
; .byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||
|
||||
|
||||
bit2tbl: .res 86 ; = nibtbl+128
|
||||
filbuf: .res 4 ; = bit2tbl+86
|
||||
;dataend = filbuf+4
|
||||
|
77
mist/zp.inc
Normal file
77
mist/zp.inc
Normal file
|
@ -0,0 +1,77 @@
|
|||
;; Zero Page
|
||||
|
||||
;; LZ4 addresses
|
||||
|
||||
LZ4_SRC = $00
|
||||
LZ4_DST = $02
|
||||
LZ4_END = $04
|
||||
WHICH_LOAD = $05
|
||||
COUNT = $06
|
||||
MENU_BASE = $06
|
||||
MENU_HIGHLIGHT = $07
|
||||
DELTA = $08
|
||||
|
||||
|
||||
;; Zero page monitor routines addresses
|
||||
|
||||
WNDLFT = $20
|
||||
WNDWDTH = $21
|
||||
WNDTOP = $22
|
||||
WNDBTM = $23
|
||||
CH = $24
|
||||
CV = $25
|
||||
GBASL = $26
|
||||
GBASH = $27
|
||||
BASL = $28
|
||||
BASH = $29
|
||||
H2 = $2C
|
||||
V2 = $2D
|
||||
MASK = $2E
|
||||
COLOR_MASK = $2F
|
||||
COLOR = $30
|
||||
|
||||
|
||||
SEEDL = $4e
|
||||
SEEDH = $4f
|
||||
|
||||
DISP_PAGE = $ED ; ALL
|
||||
DRAW_PAGE = $EE ; ALL
|
||||
|
||||
|
||||
TINL = $F0
|
||||
TINH = $F1
|
||||
BINL = $F2
|
||||
BINH = $F3
|
||||
|
||||
|
||||
SCROLL_COUNT = $F9
|
||||
TEMP = $FA
|
||||
TEMPY = $FB
|
||||
INL = $FC
|
||||
INH = $FD
|
||||
OUTL = $FE
|
||||
OUTH = $FF
|
||||
|
||||
; read any file slot 6 version
|
||||
; based on FASTLD6 and RTS copyright (c) Peter Ferrie 2011-2013,2018
|
||||
|
||||
; modified to assembled with ca64 -- vmw
|
||||
; added code to patch it to run from current disk slot -- vmw
|
||||
|
||||
|
||||
adrlo = $26 ; constant from boot prom
|
||||
adrhi = $27 ; constant from boot prom
|
||||
tmpsec = $3c ; constant from boot prom
|
||||
reqsec = $3d ; constant from boot prom
|
||||
sizelo = $44
|
||||
sizehi = $45
|
||||
secsize = $46
|
||||
|
||||
ldsizel = $70
|
||||
ldsizeh = $71
|
||||
namlo = $7b
|
||||
namhi = $7c
|
||||
step = $7d ; state for stepper motor
|
||||
tmptrk = $7e ; temporary copy of current track
|
||||
phase = $7f ; current phase for /seek
|
||||
|
Loading…
Reference in New Issue
Block a user