mirror of
https://github.com/a2-4am/million-perfect-letters.git
synced 2024-06-12 13:29:29 +00:00
simplify progress file access, compress level data, roll clock and ProDOS
This commit is contained in:
parent
52c32774f1
commit
a3a231f1c8
50
Makefile
50
Makefile
|
@ -19,26 +19,46 @@ ACME=acme
|
||||||
# version 1.4.0 or later
|
# version 1.4.0 or later
|
||||||
CADIUS=cadius
|
CADIUS=cadius
|
||||||
|
|
||||||
BUILDDISK=build/million
|
EXOMIZER=exomizer mem -lnone -P23 -f -q
|
||||||
|
|
||||||
asm:
|
BUILDDISK=build/million.po
|
||||||
mkdir -p build
|
DISKVOLUME=MILLION
|
||||||
$(ACME) -r build/million.lst src/million.a 2>build/log
|
|
||||||
cp res/work.po "$(BUILDDISK)".po >>build/log
|
asm: dirs
|
||||||
cp res/_FileInformation.txt build/ >>build/log
|
$(ACME) -r build/million.lst src/million.a
|
||||||
$(CADIUS) ADDFILE "${BUILDDISK}".po "/MILLION/" "res/PROGRESS" >>build/log
|
|
||||||
$(CADIUS) ADDFILE "${BUILDDISK}".po "/MILLION/" "res/PREFS" >>build/log
|
compress: dirs
|
||||||
$(CADIUS) ADDFILE "${BUILDDISK}".po "/MILLION/" "build/MILLION.SYSTEM" >>build/log
|
for f in res/levels/*; do \
|
||||||
for f in res/levels/*; do $(CADIUS) ADDFILE "${BUILDDISK}".po "/MILLION/" "$$f" >>build/log; done
|
$(EXOMIZER) "$$f"@0x9000 -o build/LEVEL."$$(basename $$f)"; \
|
||||||
bin/po2do.py build/ build/
|
done
|
||||||
rm "$(BUILDDISK)".po
|
rm -f src/data.index.a
|
||||||
|
rm -f res/DATA
|
||||||
|
touch res/DATA
|
||||||
|
for f in build/LEVEL.*; do \
|
||||||
|
echo "!word $$(wc -c < res/DATA)" >> src/data.index.a ;\
|
||||||
|
echo "!word $$(wc -c < $$f)" >> src/data.index.a; \
|
||||||
|
cat "$$f" >> res/DATA; \
|
||||||
|
done
|
||||||
|
|
||||||
|
dsk: asm
|
||||||
|
$(CADIUS) CREATEVOLUME "$(BUILDDISK)" "$(DISKVOLUME)" 140KB -C
|
||||||
|
cp res/_FileInformation.txt build/
|
||||||
|
$(CADIUS) ADDFILE "${BUILDDISK}" "/$(DISKVOLUME)/" "res/PROGRESS"
|
||||||
|
$(CADIUS) ADDFILE "${BUILDDISK}" "/$(DISKVOLUME)/" "res/PREFS"
|
||||||
|
$(CADIUS) ADDFILE "${BUILDDISK}" "/$(DISKVOLUME)/" "res/DATA"
|
||||||
|
$(CADIUS) ADDFILE "${BUILDDISK}" "/$(DISKVOLUME)/" "res/CLOCK.SYSTEM#FF0000"
|
||||||
|
$(CADIUS) ADDFILE "${BUILDDISK}" "/$(DISKVOLUME)/" "build/MILLION.SYSTEM"
|
||||||
|
$(CADIUS) ADDFILE "${BUILDDISK}" "/$(DISKVOLUME)/" "res/PRODOS#FF0000"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf build/
|
rm -rf build/
|
||||||
|
|
||||||
mount:
|
dirs:
|
||||||
open "$(BUILDDISK)".dsk
|
mkdir -p build
|
||||||
|
|
||||||
all: clean asm mount
|
mount:
|
||||||
|
open "$(BUILDDISK)"
|
||||||
|
|
||||||
|
all: clean dsk mount
|
||||||
|
|
||||||
al: all
|
al: all
|
||||||
|
|
BIN
res/CLOCK.SYSTEM#FF0000
Normal file
BIN
res/CLOCK.SYSTEM#FF0000
Normal file
Binary file not shown.
BIN
res/PRODOS#FF0000
Normal file
BIN
res/PRODOS#FF0000
Normal file
Binary file not shown.
|
@ -1,3 +1,4 @@
|
||||||
MILLION.SYSTEM=Type(FF),AuxType(2000),Access(C3)
|
MILLION.SYSTEM=Type(FF),AuxType(2000),Access(C3)
|
||||||
PROGRESS=Type(06),AuxType(8E10),Access(C3)
|
PROGRESS=Type(06),AuxType(8E10),Access(C3)
|
||||||
PREFS=Type(04),AuxType(0000),Access(C3)
|
PREFS=Type(04),AuxType(0000),Access(C3)
|
||||||
|
DATA=Type(06),AuxType(0000),Access(C3)
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
A=Type(04),AuxType(0000),Access(C3)
|
|
||||||
B=Type(04),AuxType(0000),Access(C3)
|
|
||||||
C=Type(04),AuxType(0000),Access(C3)
|
|
||||||
D=Type(04),AuxType(0000),Access(C3)
|
|
||||||
E=Type(04),AuxType(0000),Access(C3)
|
|
||||||
F=Type(04),AuxType(0000),Access(C3)
|
|
||||||
G=Type(04),AuxType(0000),Access(C3)
|
|
||||||
H=Type(04),AuxType(0000),Access(C3)
|
|
||||||
I=Type(04),AuxType(0000),Access(C3)
|
|
||||||
J=Type(04),AuxType(0000),Access(C3)
|
|
||||||
K=Type(04),AuxType(0000),Access(C3)
|
|
||||||
L=Type(04),AuxType(0000),Access(C3)
|
|
BIN
res/work.po
BIN
res/work.po
Binary file not shown.
|
@ -10,11 +10,10 @@
|
||||||
; 0400..07FF - text page (kept black for switching)
|
; 0400..07FF - text page (kept black for switching)
|
||||||
; 0800..19FF - scroll routines (generated at startup)
|
; 0800..19FF - scroll routines (generated at startup)
|
||||||
; 1A00..1BFF - HGR lookup tables
|
; 1A00..1BFF - HGR lookup tables
|
||||||
; 1C00..1FFF - ProDOS file buffer for puzzle files
|
; 1C00..1FFF - ProDOS file buffer
|
||||||
; 2000..3FFF - hi-res page
|
; 2000..3FFF - hi-res page
|
||||||
; 4000+ - program code (relocated to here at startup)
|
; 4000+ - program code (relocated to here at startup)
|
||||||
; ...unused...
|
; ...unused...
|
||||||
; 8A00..8DFF - ProDOS file buffer for PROGRESS file
|
|
||||||
; 8E10..8F37 - progress of puzzles in current world
|
; 8E10..8F37 - progress of puzzles in current world
|
||||||
; 8F38..8FFF - address lookup table for puzzles within following world data
|
; 8F38..8FFF - address lookup table for puzzles within following world data
|
||||||
; 9000..BEB3 - world data (read from disk)
|
; 9000..BEB3 - world data (read from disk)
|
||||||
|
@ -68,9 +67,8 @@ GENSCROLLUP = $1100 ; 0x0900 bytes
|
||||||
HGRLO = $1A00 ; 0x00C0 bytes
|
HGRLO = $1A00 ; 0x00C0 bytes
|
||||||
HGRHI = $1B00 ; 0x00C0 bytes
|
HGRHI = $1B00 ; 0x00C0 bytes
|
||||||
WORLDFILEBUFFER = $1C00 ; 0x0400 bytes
|
WORLDFILEBUFFER = $1C00 ; 0x0400 bytes
|
||||||
PREFSFILEBUFFER = $1C00 ; 0x0400 bytes (note: same as WORLDFILEBUFFER)
|
PREFSFILEBUFFER = WORLDFILEBUFFER
|
||||||
|
PROGRESSFILEBUFFER = PREFSFILEBUFFER
|
||||||
PROGRESSFILEBUFFER = $8A00; 0x0400 bytes
|
|
||||||
PACKEDPROGRESS = $8E10 ; 0x00C0 bytes
|
PACKEDPROGRESS = $8E10 ; 0x00C0 bytes
|
||||||
PROGRESS = $8ED0 ; 0x0068 bytes
|
PROGRESS = $8ED0 ; 0x0068 bytes
|
||||||
PUZZLELO = $8F38 ; 0x0064 bytes
|
PUZZLELO = $8F38 ; 0x0064 bytes
|
||||||
|
|
24
src/data.index.a
Normal file
24
src/data.index.a
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
!word 0
|
||||||
|
!word 2514
|
||||||
|
!word 2514
|
||||||
|
!word 2947
|
||||||
|
!word 5461
|
||||||
|
!word 3431
|
||||||
|
!word 8892
|
||||||
|
!word 3965
|
||||||
|
!word 12857
|
||||||
|
!word 3299
|
||||||
|
!word 16156
|
||||||
|
!word 3683
|
||||||
|
!word 19839
|
||||||
|
!word 3990
|
||||||
|
!word 23829
|
||||||
|
!word 4704
|
||||||
|
!word 28533
|
||||||
|
!word 3822
|
||||||
|
!word 32355
|
||||||
|
!word 4363
|
||||||
|
!word 36718
|
||||||
|
!word 5108
|
||||||
|
!word 41826
|
||||||
|
!word 5779
|
487
src/exodecrunch.a
Normal file
487
src/exodecrunch.a
Normal file
|
@ -0,0 +1,487 @@
|
||||||
|
; This source code is altered and is not the original version found on
|
||||||
|
; the Exomizer homepage.
|
||||||
|
; It contains modifications made by qkumba to depack a packed file
|
||||||
|
; optionally crunched forward, and additional modifications by 4am
|
||||||
|
; for an optional progress UI.
|
||||||
|
;
|
||||||
|
; Original copyright statement follows:
|
||||||
|
;
|
||||||
|
; Copyright (c) 2002 - 2018 Magnus Lind.
|
||||||
|
;
|
||||||
|
; This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
; In no event will the authors be held liable for any damages arising from
|
||||||
|
; the use of this software.
|
||||||
|
;
|
||||||
|
; Permission is granted to anyone to use this software for any purpose,
|
||||||
|
; including commercial applications, and to alter it and redistribute it
|
||||||
|
; freely, subject to the following restrictions:
|
||||||
|
;
|
||||||
|
; 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
; claim that you wrote the original software. If you use this software in a
|
||||||
|
; product, an acknowledgment in the product documentation would be
|
||||||
|
; appreciated but is not required.
|
||||||
|
;
|
||||||
|
; 2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
; be misrepresented as being the original software.
|
||||||
|
;
|
||||||
|
; 3. This notice may not be removed or altered from any distribution.
|
||||||
|
;
|
||||||
|
; 4. The names of this software and/or it's copyright holders may not be
|
||||||
|
; used to endorse or promote products derived from this software without
|
||||||
|
; specific prior written permission.
|
||||||
|
;
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; The decruncher jsr:s to the get_crunched_byte address when it wants to
|
||||||
|
; read a crunched byte into A. This subroutine has to preserve X and Y
|
||||||
|
; register and must not modify the state of the carry nor the overflow flag.
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
;.import get_crunched_byte
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; this function is the heart of the decruncher.
|
||||||
|
; It initializes the decruncher zeropage locations and precalculates the
|
||||||
|
; decrunch tables and decrunches the data
|
||||||
|
; This function will not change the interrupt status bit and it will not
|
||||||
|
; modify the memory configuration.
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
;.export decrunch
|
||||||
|
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; Controls if the shared get_bits routines should be inlined or not.
|
||||||
|
;INLINE_GET_BITS=1
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; if literal sequences is not used (the data was crunched with the -c
|
||||||
|
; flag) then the following line can be uncommented for shorter and.
|
||||||
|
; slightly faster code.
|
||||||
|
;LITERAL_SEQUENCES_NOT_USED = 1
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; if the sequence length is limited to 256 (the data was crunched with
|
||||||
|
; the -M256 flag) then the following line can be uncommented for
|
||||||
|
; shorter and slightly faster code.
|
||||||
|
;MAX_SEQUENCE_LENGTH_256 = 1
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; if the sequence length 3 has its own offset table then the following
|
||||||
|
; line can be uncommented for in some situations slightly better
|
||||||
|
; compression at the cost of a larger decrunch table.
|
||||||
|
EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE = 1
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; optional progress UI
|
||||||
|
!IFNDEF SHOW_PROGRESS_DURING_DECRUNCH {
|
||||||
|
!set SHOW_PROGRESS_DURING_DECRUNCH = 0
|
||||||
|
}
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; zero page addresses used
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
zp_len_lo = $a7
|
||||||
|
zp_len_hi = $a8
|
||||||
|
|
||||||
|
zp_src_lo = $ae
|
||||||
|
zp_src_hi = zp_src_lo + 1
|
||||||
|
|
||||||
|
zp_bits_hi = $fc
|
||||||
|
|
||||||
|
zp_bitbuf = $fd
|
||||||
|
zp_dest_lo = zp_bitbuf + 1 ; dest addr lo
|
||||||
|
zp_dest_hi = zp_bitbuf + 2 ; dest addr hi
|
||||||
|
|
||||||
|
!IFDEF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE {
|
||||||
|
encoded_entries = 68
|
||||||
|
} ELSE {
|
||||||
|
encoded_entries = 52
|
||||||
|
}
|
||||||
|
|
||||||
|
tabl_bi = decrunch_table
|
||||||
|
tabl_lo = decrunch_table + encoded_entries
|
||||||
|
tabl_hi = decrunch_table + encoded_entries * 2
|
||||||
|
|
||||||
|
;; refill bits is always inlined
|
||||||
|
!MACRO mac_refill_bits {
|
||||||
|
pha
|
||||||
|
jsr get_crunched_byte
|
||||||
|
rol
|
||||||
|
sta zp_bitbuf
|
||||||
|
pla
|
||||||
|
}
|
||||||
|
|
||||||
|
!IFDEF INLINE_GET_BITS {
|
||||||
|
!MACRO mac_get_bits {
|
||||||
|
adc #$80 ; needs c=0, affects v
|
||||||
|
asl
|
||||||
|
bpl gb_skip
|
||||||
|
gb_next:
|
||||||
|
asl zp_bitbuf
|
||||||
|
bne gb_ok
|
||||||
|
mac_refill_bits
|
||||||
|
gb_ok:
|
||||||
|
rol
|
||||||
|
bmi gb_next
|
||||||
|
gb_skip:
|
||||||
|
bvc skip
|
||||||
|
gb_get_hi:
|
||||||
|
sec
|
||||||
|
sta zp_bits_hi
|
||||||
|
jsr get_crunched_byte
|
||||||
|
skip:
|
||||||
|
}
|
||||||
|
} ELSE {
|
||||||
|
!MACRO mac_get_bits {
|
||||||
|
jsr get_bits
|
||||||
|
}
|
||||||
|
get_bits:
|
||||||
|
adc #$80 ; needs c=0, affects v
|
||||||
|
asl
|
||||||
|
bpl gb_skip
|
||||||
|
gb_next:
|
||||||
|
asl zp_bitbuf
|
||||||
|
bne gb_ok
|
||||||
|
+mac_refill_bits
|
||||||
|
gb_ok:
|
||||||
|
rol
|
||||||
|
bmi gb_next
|
||||||
|
gb_skip:
|
||||||
|
bvs gb_get_hi
|
||||||
|
rts
|
||||||
|
gb_get_hi:
|
||||||
|
sec
|
||||||
|
sta zp_bits_hi
|
||||||
|
jmp get_crunched_byte
|
||||||
|
}
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; no code below this comment has to be modified in order to generate
|
||||||
|
; a working decruncher of this source file.
|
||||||
|
; However, you may want to relocate the tables last in the file to a
|
||||||
|
; more suitable address.
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; jsr this label to decrunch, it will in turn init the tables and
|
||||||
|
; call the decruncher
|
||||||
|
; no constraints on register content, however the
|
||||||
|
; decimal flag has to be #0 (it almost always is, otherwise do a cld)
|
||||||
|
decrunch:
|
||||||
|
|
||||||
|
!IF SHOW_PROGRESS_DURING_DECRUNCH = 1 {
|
||||||
|
ldx #(kExoProgressWidth+2)
|
||||||
|
lda #$DF
|
||||||
|
- sta $0528+(20-(kExoProgressWidth/2))-1, x
|
||||||
|
sta $05A8+(20-(kExoProgressWidth/2))-1, x
|
||||||
|
dex
|
||||||
|
bpl -
|
||||||
|
lda #$20
|
||||||
|
sta $05A8+(20-(kExoProgressWidth/2))-1
|
||||||
|
sta $05A8+(20-(kExoProgressWidth/2))+kExoProgressWidth+1
|
||||||
|
lda #$A8+(20-(kExoProgressWidth/2))
|
||||||
|
sta ExoProgressPtr+1
|
||||||
|
decrunch_no_reset_progress:
|
||||||
|
}
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; init zeropage, x and y regs. (12 bytes)
|
||||||
|
;
|
||||||
|
ldy #0
|
||||||
|
ldx #3
|
||||||
|
init_zp:
|
||||||
|
jsr get_crunched_byte
|
||||||
|
sta zp_bitbuf - 1,x
|
||||||
|
dex
|
||||||
|
bne init_zp
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; calculate tables (62 bytes) + get_bits macro
|
||||||
|
; x and y must be #0 when entering
|
||||||
|
;
|
||||||
|
clc
|
||||||
|
table_gen:
|
||||||
|
tax
|
||||||
|
tya
|
||||||
|
and #$0f
|
||||||
|
sta tabl_lo,y
|
||||||
|
beq shortcut ; start a new sequence
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
txa
|
||||||
|
adc tabl_lo - 1,y
|
||||||
|
sta tabl_lo,y
|
||||||
|
lda zp_len_hi
|
||||||
|
adc tabl_hi - 1,y
|
||||||
|
shortcut:
|
||||||
|
sta tabl_hi,y
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
lda #$01
|
||||||
|
sta <zp_len_hi
|
||||||
|
lda #$78 ; %01111000
|
||||||
|
+mac_get_bits
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
lsr
|
||||||
|
tax
|
||||||
|
beq rolled
|
||||||
|
php
|
||||||
|
rolle:
|
||||||
|
asl zp_len_hi
|
||||||
|
sec
|
||||||
|
ror
|
||||||
|
dex
|
||||||
|
bne rolle
|
||||||
|
plp
|
||||||
|
rolled:
|
||||||
|
ror
|
||||||
|
sta tabl_bi,y
|
||||||
|
bmi no_fixup_lohi
|
||||||
|
lda zp_len_hi
|
||||||
|
stx zp_len_hi
|
||||||
|
!BYTE $24
|
||||||
|
no_fixup_lohi:
|
||||||
|
txa
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
iny
|
||||||
|
cpy #encoded_entries
|
||||||
|
bne table_gen
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; prepare for main decruncher
|
||||||
|
ldy zp_dest_lo
|
||||||
|
stx zp_dest_lo
|
||||||
|
stx zp_bits_hi
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; copy one literal byte to destination (11(10) bytes)
|
||||||
|
;
|
||||||
|
!ifndef FORWARD_DECRUNCHING {
|
||||||
|
!set FORWARD_DECRUNCHING = 1
|
||||||
|
}
|
||||||
|
literal_start1:
|
||||||
|
!IF SHOW_PROGRESS_DURING_DECRUNCH = 1 {
|
||||||
|
dec ExoProgressCounter
|
||||||
|
bne +
|
||||||
|
lda #$20
|
||||||
|
ExoProgressPtr
|
||||||
|
sta $0500 ; SMC lo byte
|
||||||
|
inc ExoProgressPtr+1
|
||||||
|
+
|
||||||
|
}
|
||||||
|
!if FORWARD_DECRUNCHING = 0 {
|
||||||
|
tya
|
||||||
|
bne no_hi_decr
|
||||||
|
dec zp_dest_hi
|
||||||
|
no_hi_decr:
|
||||||
|
dey
|
||||||
|
jsr get_crunched_byte
|
||||||
|
sta (zp_dest_lo),y
|
||||||
|
} else {
|
||||||
|
jsr get_crunched_byte
|
||||||
|
sta (zp_dest_lo),y
|
||||||
|
iny
|
||||||
|
bne no_hi_incr
|
||||||
|
inc zp_dest_hi
|
||||||
|
no_hi_incr:
|
||||||
|
}
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; fetch sequence length index (15 bytes)
|
||||||
|
; x must be #0 when entering and contains the length index + 1
|
||||||
|
; when exiting or 0 for literal byte
|
||||||
|
next_round:
|
||||||
|
dex
|
||||||
|
lda zp_bitbuf
|
||||||
|
no_literal1:
|
||||||
|
asl
|
||||||
|
bne nofetch8
|
||||||
|
jsr get_crunched_byte
|
||||||
|
rol
|
||||||
|
nofetch8:
|
||||||
|
inx
|
||||||
|
bcc no_literal1
|
||||||
|
sta zp_bitbuf
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; check for literal byte (2 bytes)
|
||||||
|
;
|
||||||
|
beq literal_start1
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; check for decrunch done and literal sequences (4 bytes)
|
||||||
|
;
|
||||||
|
cpx #$11
|
||||||
|
!IFDEF INLINE_GET_BITS {
|
||||||
|
bcc skip_jmp
|
||||||
|
jmp exit_or_lit_seq
|
||||||
|
skip_jmp:
|
||||||
|
} ELSE {
|
||||||
|
bcs exit_or_lit_seq
|
||||||
|
}
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; calulate length of sequence (zp_len) (18(11) bytes) + get_bits macro
|
||||||
|
;
|
||||||
|
lda tabl_bi - 1,x
|
||||||
|
+mac_get_bits
|
||||||
|
adc tabl_lo - 1,x ; we have now calculated zp_len_lo
|
||||||
|
sta zp_len_lo
|
||||||
|
!IFNDEF MAX_SEQUENCE_LENGTH_256 {
|
||||||
|
lda zp_bits_hi
|
||||||
|
adc tabl_hi - 1,x ; c = 0 after this.
|
||||||
|
sta zp_len_hi
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; here we decide what offset table to use (27(26) bytes) + get_bits_nc macro
|
||||||
|
; z-flag reflects zp_len_hi here
|
||||||
|
;
|
||||||
|
ldx zp_len_lo
|
||||||
|
} ELSE {
|
||||||
|
tax
|
||||||
|
}
|
||||||
|
lda #$e1
|
||||||
|
!IFDEF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE {
|
||||||
|
cpx #$04
|
||||||
|
} ELSE {
|
||||||
|
cpx #$03
|
||||||
|
}
|
||||||
|
bcs gbnc2_next
|
||||||
|
lda tabl_bit - 1,x
|
||||||
|
gbnc2_next:
|
||||||
|
asl zp_bitbuf
|
||||||
|
bne gbnc2_ok
|
||||||
|
tax
|
||||||
|
jsr get_crunched_byte
|
||||||
|
rol
|
||||||
|
sta zp_bitbuf
|
||||||
|
txa
|
||||||
|
gbnc2_ok:
|
||||||
|
rol
|
||||||
|
bcs gbnc2_next
|
||||||
|
tax
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; calulate absolute offset (zp_src) (21(23) bytes) + get_bits macro
|
||||||
|
;
|
||||||
|
!IFNDEF MAX_SEQUENCE_LENGTH_256 {
|
||||||
|
lda #0
|
||||||
|
sta zp_bits_hi
|
||||||
|
}
|
||||||
|
lda tabl_bi,x
|
||||||
|
+mac_get_bits
|
||||||
|
!if FORWARD_DECRUNCHING = 0 {
|
||||||
|
adc tabl_lo,x
|
||||||
|
sta zp_src_lo
|
||||||
|
lda zp_bits_hi
|
||||||
|
adc tabl_hi,x
|
||||||
|
adc zp_dest_hi
|
||||||
|
} else {
|
||||||
|
clc
|
||||||
|
adc tabl_lo,x
|
||||||
|
eor #$ff
|
||||||
|
sta zp_src_lo
|
||||||
|
lda zp_dest_hi
|
||||||
|
bcc skip_dest_hi
|
||||||
|
sbc #1
|
||||||
|
clc
|
||||||
|
skip_dest_hi:
|
||||||
|
sbc zp_bits_hi
|
||||||
|
sbc tabl_hi,x
|
||||||
|
clc
|
||||||
|
}
|
||||||
|
sta zp_src_hi
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; prepare for copy loop (2 bytes)
|
||||||
|
;
|
||||||
|
pre_copy:
|
||||||
|
ldx zp_len_lo
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; main copy loop (30 bytes)
|
||||||
|
;
|
||||||
|
copy_next:
|
||||||
|
!if FORWARD_DECRUNCHING = 0 {
|
||||||
|
tya
|
||||||
|
bne copy_skip_hi
|
||||||
|
dec zp_dest_hi
|
||||||
|
dec zp_src_hi
|
||||||
|
copy_skip_hi:
|
||||||
|
dey
|
||||||
|
}
|
||||||
|
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
|
||||||
|
bcs get_literal_byte
|
||||||
|
}
|
||||||
|
lda (zp_src_lo),y
|
||||||
|
literal_byte_gotten:
|
||||||
|
sta (zp_dest_lo),y
|
||||||
|
!if FORWARD_DECRUNCHING = 1 {
|
||||||
|
iny
|
||||||
|
bne copy_skip_hi
|
||||||
|
inc zp_dest_hi
|
||||||
|
inc zp_src_hi
|
||||||
|
copy_skip_hi:
|
||||||
|
}
|
||||||
|
dex
|
||||||
|
bne copy_next
|
||||||
|
!IFNDEF MAX_SEQUENCE_LENGTH_256 {
|
||||||
|
lda zp_len_hi
|
||||||
|
!IFDEF INLINE_GET_BITS {
|
||||||
|
bne copy_next_hi
|
||||||
|
}
|
||||||
|
}
|
||||||
|
begin_stx:
|
||||||
|
stx zp_bits_hi
|
||||||
|
!IFNDEF INLINE_GET_BITS {
|
||||||
|
beq next_round
|
||||||
|
} ELSE {
|
||||||
|
jmp next_round
|
||||||
|
}
|
||||||
|
!IFNDEF MAX_SEQUENCE_LENGTH_256 {
|
||||||
|
copy_next_hi:
|
||||||
|
dec zp_len_hi
|
||||||
|
jmp copy_next
|
||||||
|
}
|
||||||
|
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
|
||||||
|
get_literal_byte:
|
||||||
|
jsr get_crunched_byte
|
||||||
|
bcs literal_byte_gotten
|
||||||
|
}
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; exit or literal sequence handling (16(12) bytes)
|
||||||
|
;
|
||||||
|
exit_or_lit_seq:
|
||||||
|
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
|
||||||
|
beq decr_exit
|
||||||
|
jsr get_crunched_byte
|
||||||
|
!IFNDEF MAX_SEQUENCE_LENGTH_256 {
|
||||||
|
sta zp_len_hi
|
||||||
|
}
|
||||||
|
jsr get_crunched_byte
|
||||||
|
tax
|
||||||
|
bcs copy_next
|
||||||
|
decr_exit:
|
||||||
|
}
|
||||||
|
rts
|
||||||
|
!IFDEF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE {
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; the static stable used for bits+offset for lengths 1, 2 and 3 (3 bytes)
|
||||||
|
; bits 2, 4, 4 and offsets 64, 48, 32 corresponding to
|
||||||
|
; %10010000, %11100011, %11100010
|
||||||
|
tabl_bit:
|
||||||
|
!BYTE $90, $e3, $e2
|
||||||
|
} ELSE {
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; the static stable used for bits+offset for lengths 1 and 2 (2 bytes)
|
||||||
|
; bits 2, 4 and offsets 48, 32 corresponding to %10001100, %11100010
|
||||||
|
tabl_bit:
|
||||||
|
!BYTE $8c, $e2
|
||||||
|
}
|
||||||
|
!IF SHOW_PROGRESS_DURING_DECRUNCH = 1 {
|
||||||
|
ExoProgressCounter
|
||||||
|
!byte $00
|
||||||
|
}
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; end of decruncher
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; this 156 (204) byte table area may be relocated. It may also be
|
||||||
|
; clobbered by other data between decrunches.
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
decrunch_table=$200;;:
|
||||||
|
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
;;.IFDEF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE
|
||||||
|
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
;;.ENDIF
|
||||||
|
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
; -------------------------------------------------------------------
|
||||||
|
; end of decruncher
|
||||||
|
; -------------------------------------------------------------------
|
|
@ -10,7 +10,7 @@
|
||||||
; - OpenFile
|
; - OpenFile
|
||||||
; - ReadFile
|
; - ReadFile
|
||||||
; - WriteFile
|
; - WriteFile
|
||||||
; - SetMarkTo0
|
; - SeekFile
|
||||||
; - FlushFile
|
; - FlushFile
|
||||||
; - CloseFile
|
; - CloseFile
|
||||||
; - Quit
|
; - Quit
|
||||||
|
@ -256,22 +256,26 @@ WriteFile
|
||||||
+ rts
|
+ rts
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; SetMarkTo0
|
; SeekFile
|
||||||
; set file position within an open file to the beginning of the file
|
; set file position within an open file
|
||||||
;
|
;
|
||||||
; in: A = file reference number
|
; in: A = file reference number
|
||||||
; out: if C set, save failed and A = error code
|
; X = seek offset (lo)
|
||||||
; if C clear, write succeeded and A = the same file reference
|
; Y = seek offset (hi)
|
||||||
|
; note: this routine can not seek beyond 65535 bytes even though
|
||||||
|
; ProDOS can do that
|
||||||
|
; out: if C set, seek failed and A = error code
|
||||||
|
; if C clear, seek succeeded and A = the same file reference
|
||||||
; number that was passed in
|
; number that was passed in
|
||||||
; Y clobbered
|
; Y clobbered
|
||||||
; X preserved
|
; X preserved
|
||||||
; other flags clobbered
|
; other flags clobbered
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
SetMarkTo0
|
SeekFile
|
||||||
sta mliparam+1 ; file reference number
|
sta mliparam+1 ; file reference number
|
||||||
|
stx mliparam+2
|
||||||
|
sty mliparam+3
|
||||||
lda #0
|
lda #0
|
||||||
sta mliparam+2
|
|
||||||
sta mliparam+3
|
|
||||||
sta mliparam+4
|
sta mliparam+4
|
||||||
+LDADDR CMD_SETMARK
|
+LDADDR CMD_SETMARK
|
||||||
bne mli ; always branches
|
bne mli ; always branches
|
||||||
|
|
|
@ -27,6 +27,9 @@ Start ; X = Mockingboard slot (from init)
|
||||||
jsr EnableAccelerator
|
jsr EnableAccelerator
|
||||||
jmp Quit
|
jmp Quit
|
||||||
|
|
||||||
|
FORWARD_DECRUNCHING = 1
|
||||||
|
SHOW_PROGRESS_DURING_DECRUNCH = 0
|
||||||
|
!source "src/exodecrunch.a"
|
||||||
!source "src/ui.strings.a"
|
!source "src/ui.strings.a"
|
||||||
!source "src/ui.title.a"
|
!source "src/ui.title.a"
|
||||||
!source "src/ui.main.menu.a"
|
!source "src/ui.main.menu.a"
|
||||||
|
@ -40,6 +43,8 @@ Start ; X = Mockingboard slot (from init)
|
||||||
!source "src/ui.message.a"
|
!source "src/ui.message.a"
|
||||||
!source "src/ui.common.a"
|
!source "src/ui.common.a"
|
||||||
!source "src/puzzle.a"
|
!source "src/puzzle.a"
|
||||||
|
data_index
|
||||||
|
!source "src/data.index.a"
|
||||||
!source "src/storage.a"
|
!source "src/storage.a"
|
||||||
!source "src/prefs.a"
|
!source "src/prefs.a"
|
||||||
!source "src/glue.sound.a"
|
!source "src/glue.sound.a"
|
||||||
|
@ -60,5 +65,6 @@ M_vi6 !bin "res/M.VI6"
|
||||||
M_ERROR !bin "res/M.ERROR"
|
M_ERROR !bin "res/M.ERROR"
|
||||||
!source "src/electric.duet.a"
|
!source "src/electric.duet.a"
|
||||||
!source "src/mockingduet.a"
|
!source "src/mockingduet.a"
|
||||||
|
compressed_data
|
||||||
}
|
}
|
||||||
LastMover
|
LastMover
|
||||||
|
|
|
@ -30,8 +30,6 @@ kPuzzleWidths ; width in letters of the puzzles in each w
|
||||||
!byte 4,5,6,7
|
!byte 4,5,6,7
|
||||||
!byte 4,5,6,7
|
!byte 4,5,6,7
|
||||||
|
|
||||||
progressRefNum ; [byte][private]
|
|
||||||
!byte $FF ; 0xFF means 'no progress file open'
|
|
||||||
checksum = $FB
|
checksum = $FB
|
||||||
packedvalue = $FC
|
packedvalue = $FC
|
||||||
bitcount = $FD
|
bitcount = $FD
|
||||||
|
@ -47,28 +45,63 @@ bitcount = $FD
|
||||||
; other registers/flags clobbered
|
; other registers/flags clobbered
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
MaybeLoadWorldFromDisk
|
MaybeLoadWorldFromDisk
|
||||||
clc
|
|
||||||
adc #$41
|
|
||||||
cmp WorldFileLoaded
|
cmp WorldFileLoaded
|
||||||
bne +
|
bne +
|
||||||
@success clc
|
@success clc
|
||||||
rts
|
rts
|
||||||
+ sta WorldFileLoaded
|
+ sta WorldFileLoaded
|
||||||
jsr LoadFile1Shot
|
jsr $ff58
|
||||||
!word @filename ; address of filename
|
jsr OpenFile
|
||||||
!word WORLDDATA ; load address
|
!word @filename
|
||||||
!word $2F00 ; maximum length
|
!word WORLDFILEBUFFER
|
||||||
!word WORLDFILEBUFFER ; address of ProDOS file buffer
|
|
||||||
bcs @failure
|
bcs @failure
|
||||||
|
sta @refnum
|
||||||
|
|
||||||
|
lda WorldFileLoaded
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
tax
|
||||||
|
lda data_index, x
|
||||||
|
ldy data_index+1, x
|
||||||
|
tax
|
||||||
|
lda @refnum
|
||||||
|
jsr SeekFile
|
||||||
|
|
||||||
|
lda WorldFileLoaded
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
tax
|
||||||
|
lda data_index+2, x
|
||||||
|
sta @readlen
|
||||||
|
lda data_index+3, x
|
||||||
|
sta @readlen+1
|
||||||
|
jsr ReadFile
|
||||||
|
@refnum !byte $FD ; SMC
|
||||||
|
!word compressed_data ; data address
|
||||||
|
@readlen !word $FDFD ; data length
|
||||||
|
|
||||||
|
php
|
||||||
|
lda @refnum
|
||||||
|
jsr CloseFile
|
||||||
|
plp
|
||||||
|
bcs @failure
|
||||||
|
|
||||||
|
lda #<compressed_data
|
||||||
|
sta get_crunched_byte+1
|
||||||
|
lda #>compressed_data
|
||||||
|
sta get_crunched_byte+2
|
||||||
|
jsr decrunch
|
||||||
jsr PreParseWorldData
|
jsr PreParseWorldData
|
||||||
cpx #100
|
cpx #100
|
||||||
beq @success
|
beq @success
|
||||||
@failure lda #$FF
|
@failure lda WorldFileLoaded
|
||||||
|
jsr CloseFile ; ignore error, if any
|
||||||
|
lda #$FF
|
||||||
sta WorldFileLoaded
|
sta WorldFileLoaded
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
@filename
|
@filename
|
||||||
!byte 1 ; length
|
!text 4,"DATA"
|
||||||
WorldFileLoaded
|
WorldFileLoaded
|
||||||
!byte $FF ; no file
|
!byte $FF ; no file
|
||||||
|
|
||||||
|
@ -124,25 +157,17 @@ PreParseWorldData
|
||||||
; see comments in MarkPuzzleCompleted for file format
|
; see comments in MarkPuzzleCompleted for file format
|
||||||
;
|
;
|
||||||
; in: none
|
; in: none
|
||||||
; out: C clear if file was read successfully, and
|
; out: C clear if file was read successfully
|
||||||
; progressRefNum contains ProDOS file reference number (file is left
|
; C set if error occurred
|
||||||
; open)
|
|
||||||
; C set if error occurred, and
|
|
||||||
; progressRefNum = 0xFF
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
LoadProgressFromDisk
|
LoadProgressFromDisk
|
||||||
jsr OpenFile
|
jsr LoadFile1Shot
|
||||||
!word @progressFile
|
!word progressFile
|
||||||
!word PROGRESSFILEBUFFER
|
|
||||||
bcs +
|
|
||||||
sta @refnum
|
|
||||||
sta progressRefNum
|
|
||||||
jsr ReadFile
|
|
||||||
@refnum !byte $FD ; SMC
|
|
||||||
!word PACKEDPROGRESS ; data address
|
!word PACKEDPROGRESS ; data address
|
||||||
!word $00C0 ; data length
|
!word $00C0 ; data length
|
||||||
+ rts
|
!word PROGRESSFILEBUFFER
|
||||||
@progressFile
|
rts
|
||||||
|
progressFile
|
||||||
!byte 8
|
!byte 8
|
||||||
!raw "PROGRESS"
|
!raw "PROGRESS"
|
||||||
|
|
||||||
|
@ -374,14 +399,13 @@ MarkPuzzleSkipped
|
||||||
eor checksum
|
eor checksum
|
||||||
iny
|
iny
|
||||||
sta ($FE), y
|
sta ($FE), y
|
||||||
lda progressRefNum
|
jsr SaveFile1Shot
|
||||||
jsr SetMarkTo0
|
!word progressFile
|
||||||
lda progressRefNum
|
!byte 4
|
||||||
jsr WriteFile
|
!word 0
|
||||||
!word PACKEDPROGRESS
|
!word PACKEDPROGRESS
|
||||||
!word $00C0
|
!word $00C0
|
||||||
lda progressRefNum
|
!word PROGRESSFILEBUFFER
|
||||||
jsr FlushFile
|
|
||||||
pla
|
pla
|
||||||
tax
|
tax
|
||||||
pla
|
pla
|
||||||
|
@ -412,3 +436,10 @@ FindPackedProgress
|
||||||
bcc +
|
bcc +
|
||||||
inc $FF
|
inc $FF
|
||||||
+ rts
|
+ rts
|
||||||
|
|
||||||
|
get_crunched_byte
|
||||||
|
lda compressed_data
|
||||||
|
inc get_crunched_byte+1
|
||||||
|
bne +
|
||||||
|
inc get_crunched_byte+2
|
||||||
|
+ rts
|
||||||
|
|
|
@ -13,7 +13,7 @@ sTitleLine3
|
||||||
!raw "LETTERS"
|
!raw "LETTERS"
|
||||||
sVersion
|
sVersion
|
||||||
!byte 4
|
!byte 4
|
||||||
!raw "V1.0"
|
!raw "V1.1"
|
||||||
sOneSpace
|
sOneSpace
|
||||||
!byte 1
|
!byte 1
|
||||||
!raw " "
|
!raw " "
|
||||||
|
@ -89,8 +89,8 @@ sWorldHelp
|
||||||
!byte 40
|
!byte 40
|
||||||
!raw "ARROWS TO SELECT, RETURN TO PLAY, OR ESC"
|
!raw "ARROWS TO SELECT, RETURN TO PLAY, OR ESC"
|
||||||
sAboutWritten
|
sAboutWritten
|
||||||
!byte 21
|
!byte 26
|
||||||
!raw "COPYRIGHT 2022 BY 4AM"
|
!raw "COPYRIGHT 2022-2024 BY 4AM"
|
||||||
sAboutTested
|
sAboutTested
|
||||||
!byte 21
|
!byte 21
|
||||||
!raw "PLAYTESTED BY OPTION8"
|
!raw "PLAYTESTED BY OPTION8"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user