mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-06-08 00:29:35 +00:00
lovebyte: at size target
This commit is contained in:
parent
8621dbe235
commit
b2be06be8d
|
@ -1,6 +1,2 @@
|
||||||
optimize music code:
|
optimize music code:
|
||||||
+ depending on alignment can hard-code the high value for track0/track1
|
+ depending on alignment can hard-code the high value for track0/track1
|
||||||
+ check the frequencies, high freq might always be 0
|
|
||||||
|
|
||||||
optimize other:
|
|
||||||
+ can hardcode zx if only use it once?
|
|
||||||
|
|
|
@ -39,6 +39,20 @@ save = $2300
|
||||||
|
|
||||||
make_tables:
|
make_tables:
|
||||||
|
|
||||||
|
; print pre-calc string
|
||||||
|
|
||||||
|
ldx #0
|
||||||
|
write_string:
|
||||||
|
lda precalc_string,X
|
||||||
|
beq done_string
|
||||||
|
; ora #$80
|
||||||
|
sta $650,X
|
||||||
|
inx
|
||||||
|
bne write_string
|
||||||
|
done_string:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;====================================================
|
;====================================================
|
||||||
; sin1[i]=round(47.0+
|
; sin1[i]=round(47.0+
|
||||||
; 32.0*sin(i*(PI*2.0/256.0))+
|
; 32.0*sin(i*(PI*2.0/256.0))+
|
||||||
|
@ -107,6 +121,8 @@ make_tables:
|
||||||
|
|
||||||
make_sin_table:
|
make_sin_table:
|
||||||
|
|
||||||
|
dec $659
|
||||||
|
|
||||||
ldx #0
|
ldx #0
|
||||||
sin_loop:
|
sin_loop:
|
||||||
stx OURX
|
stx OURX
|
||||||
|
@ -220,3 +236,6 @@ three_input:
|
||||||
; ; 8*2*pi/256 = .196349541
|
; ; 8*2*pi/256 = .196349541
|
||||||
; .byte $7E,$49,$0F,$da,$a2
|
; .byte $7E,$49,$0F,$da,$a2
|
||||||
|
|
||||||
|
precalc_string:
|
||||||
|
.byte 'P'|$80,'R'|$80,'E'|$80,'C'|$80,'A'|$80,'L'|$80,'C'|$80,':'|$80,' '|$80,'4'
|
||||||
|
.byte ' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,' '|$80,'d'|$80,'S'|$80,'r'|$80,0
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
; 1135 -- initial
|
; 1135 -- initial
|
||||||
; 1000 -- compressed
|
; 1000 -- compressed
|
||||||
; 997 -- minor optimization
|
; 997 -- minor optimization
|
||||||
|
; 984 -- inline zx02 compress
|
||||||
|
; 988 -- fix fullscreen
|
||||||
|
|
||||||
.include "hardware.inc"
|
.include "hardware.inc"
|
||||||
.include "zp.inc"
|
.include "zp.inc"
|
||||||
|
@ -23,7 +25,7 @@ tracker_song = peasant_song
|
||||||
plasma_mask:
|
plasma_mask:
|
||||||
|
|
||||||
jsr HGR ; have table gen appear on hgr page1
|
jsr HGR ; have table gen appear on hgr page1
|
||||||
; bit FULLGR
|
|
||||||
|
|
||||||
|
|
||||||
;=================
|
;=================
|
||||||
|
@ -51,6 +53,7 @@ plasma_mask:
|
||||||
cli ; start music
|
cli ; start music
|
||||||
|
|
||||||
bit LORES ; set lo-res
|
bit LORES ; set lo-res
|
||||||
|
bit FULLGR
|
||||||
|
|
||||||
; ============================================================================
|
; ============================================================================
|
||||||
; init lores colors (inline)
|
; init lores colors (inline)
|
||||||
|
|
|
@ -2,18 +2,173 @@
|
||||||
|
|
||||||
.include "zp.inc"
|
.include "zp.inc"
|
||||||
|
|
||||||
; TODO: inline
|
plasma_new:
|
||||||
|
|
||||||
|
; inlined
|
||||||
|
|
||||||
|
; De-compressor for ZX02 files
|
||||||
|
; ----------------------------
|
||||||
|
;
|
||||||
|
; Decompress ZX02 data (6502 optimized format), optimized for speed and size
|
||||||
|
; 138 bytes code, 58.0 cycles/byte in test file.
|
||||||
|
;
|
||||||
|
; Compress with:
|
||||||
|
; zx02 input.bin output.zx0
|
||||||
|
;
|
||||||
|
; (c) 2022 DMSC
|
||||||
|
; Code under MIT license, see LICENSE file.
|
||||||
|
|
||||||
|
|
||||||
|
;ZP=$80
|
||||||
|
|
||||||
|
;offset = ZP+0
|
||||||
|
;ZX0_src = ZP+2
|
||||||
|
;ZX0_dst = ZP+4
|
||||||
|
;bitr = ZP+6
|
||||||
|
;pntr = ZP+7
|
||||||
|
|
||||||
|
; Initial values for offset, source, destination and bitr
|
||||||
|
;zx0_ini_block:
|
||||||
|
; .byte $00, $00, <comp_data, >comp_data, <out_addr, >out_addr, $80
|
||||||
|
|
||||||
|
;--------------------------------------------------
|
||||||
|
; Decompress ZX0 data (6502 optimized format)
|
||||||
|
|
||||||
|
zx02_full_decomp:
|
||||||
|
; ; Get initialization block
|
||||||
|
; ldy #7
|
||||||
|
;
|
||||||
|
;copy_init: lda zx0_ini_block-1, y
|
||||||
|
; sta offset-1, y
|
||||||
|
; dey
|
||||||
|
; bne copy_init
|
||||||
|
|
||||||
lda #<compressed_data
|
|
||||||
sta zx_src_l+1
|
|
||||||
lda #>compressed_data
|
|
||||||
sta zx_src_h+1
|
|
||||||
lda #$40
|
lda #$40
|
||||||
jsr zx02_full_decomp
|
sta ZX0_dst+1 ; page to output to in A
|
||||||
|
zx_src_l:
|
||||||
|
ldy #<compressed_data
|
||||||
|
sty ZX0_src
|
||||||
|
zx_src_h:
|
||||||
|
ldy #>compressed_data
|
||||||
|
sty ZX0_src+1
|
||||||
|
ldy #$80
|
||||||
|
sty bitr
|
||||||
|
ldy #0
|
||||||
|
sty offset
|
||||||
|
sty offset+1
|
||||||
|
sty ZX0_dst ; always on even page
|
||||||
|
|
||||||
|
; Decode literal: Ccopy next N bytes from compressed file
|
||||||
|
; Elias(length) byte[1] byte[2] ... byte[N]
|
||||||
|
decode_literal:
|
||||||
|
jsr get_elias
|
||||||
|
|
||||||
|
cop0: lda (ZX0_src), y
|
||||||
|
inc ZX0_src
|
||||||
|
bne plus1
|
||||||
|
inc ZX0_src+1
|
||||||
|
plus1: sta (ZX0_dst),y
|
||||||
|
inc ZX0_dst
|
||||||
|
bne plus2
|
||||||
|
inc ZX0_dst+1
|
||||||
|
plus2: dex
|
||||||
|
bne cop0
|
||||||
|
|
||||||
|
asl bitr
|
||||||
|
bcs dzx0s_new_offset
|
||||||
|
|
||||||
|
; Copy from last offset (repeat N bytes from last offset)
|
||||||
|
; Elias(length)
|
||||||
|
jsr get_elias
|
||||||
|
dzx0s_copy:
|
||||||
|
lda ZX0_dst
|
||||||
|
sbc offset ; C=0 from get_elias
|
||||||
|
sta pntr
|
||||||
|
lda ZX0_dst+1
|
||||||
|
sbc offset+1
|
||||||
|
sta pntr+1
|
||||||
|
|
||||||
|
cop1:
|
||||||
|
lda (pntr), y
|
||||||
|
inc pntr
|
||||||
|
bne plus3
|
||||||
|
inc pntr+1
|
||||||
|
plus3: sta (ZX0_dst),y
|
||||||
|
inc ZX0_dst
|
||||||
|
bne plus4
|
||||||
|
inc ZX0_dst+1
|
||||||
|
plus4: dex
|
||||||
|
bne cop1
|
||||||
|
|
||||||
|
asl bitr
|
||||||
|
bcc decode_literal
|
||||||
|
|
||||||
|
; Copy from new offset (repeat N bytes from new offset)
|
||||||
|
; Elias(MSB(offset)) LSB(offset) Elias(length-1)
|
||||||
|
dzx0s_new_offset:
|
||||||
|
; Read elias code for high part of offset
|
||||||
|
jsr get_elias
|
||||||
|
beq exit ; Read a 0, signals the end
|
||||||
|
; Decrease and divide by 2
|
||||||
|
dex
|
||||||
|
txa
|
||||||
|
lsr ; @
|
||||||
|
sta offset+1
|
||||||
|
|
||||||
|
; Get low part of offset, a literal 7 bits
|
||||||
|
lda (ZX0_src), y
|
||||||
|
inc ZX0_src
|
||||||
|
bne plus5
|
||||||
|
inc ZX0_src+1
|
||||||
|
plus5:
|
||||||
|
; Divide by 2
|
||||||
|
ror ; @
|
||||||
|
sta offset
|
||||||
|
|
||||||
|
; And get the copy length.
|
||||||
|
; Start elias reading with the bit already in carry:
|
||||||
|
ldx #1
|
||||||
|
jsr elias_skip1
|
||||||
|
|
||||||
|
inx
|
||||||
|
bcc dzx0s_copy
|
||||||
|
|
||||||
|
; Read an elias-gamma interlaced code.
|
||||||
|
; ------------------------------------
|
||||||
|
get_elias:
|
||||||
|
; Initialize return value to #1
|
||||||
|
ldx #1
|
||||||
|
bne elias_start
|
||||||
|
|
||||||
|
elias_get: ; Read next data bit to result
|
||||||
|
asl bitr
|
||||||
|
rol ; @
|
||||||
|
tax
|
||||||
|
|
||||||
|
elias_start:
|
||||||
|
; Get one bit
|
||||||
|
asl bitr
|
||||||
|
bne elias_skip1
|
||||||
|
|
||||||
|
; Read new bit from stream
|
||||||
|
lda (ZX0_src), y
|
||||||
|
inc ZX0_src
|
||||||
|
bne plus6
|
||||||
|
inc ZX0_src+1
|
||||||
|
plus6: ;sec ; not needed, C=1 guaranteed from last bit
|
||||||
|
rol ;@
|
||||||
|
sta bitr
|
||||||
|
|
||||||
|
elias_skip1:
|
||||||
|
txa
|
||||||
|
bcs elias_get
|
||||||
|
; Got ending bit, stop reading
|
||||||
|
|
||||||
|
rts
|
||||||
|
exit:
|
||||||
|
|
||||||
jmp $4000
|
jmp $4000
|
||||||
|
|
||||||
.include "zx02_optim.s"
|
|
||||||
|
|
||||||
compressed_data:
|
compressed_data:
|
||||||
.incbin "PLASMA_COMPRESS.zx02"
|
.incbin "PLASMA_COMPRESS.zx02"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user