From 7771f2d660faaa2aabdc528b4c51595b4df86f40 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 17 Jun 2022 01:25:26 -0400 Subject: [PATCH] compression_test: missed some files --- basic/appleiibot/Makefile | 8 +- basic/appleiibot/horiz_star.bas | 2 + compression/comparison/Makefile | 8 +- compression/comparison/exodecrunch.s.old | 452 +++++++++-------------- compression/comparison/hardware.inc | 8 +- 5 files changed, 185 insertions(+), 293 deletions(-) create mode 100644 basic/appleiibot/horiz_star.bas diff --git a/basic/appleiibot/Makefile b/basic/appleiibot/Makefile index 1c31978c..52ef7433 100644 --- a/basic/appleiibot/Makefile +++ b/basic/appleiibot/Makefile @@ -23,7 +23,7 @@ appleiibot.dsk: E2.BAS FLAME.BAS FLAME2.BAS HELLO \ FLAME_HGR.BAS RECT.BAS SNOWY.BAS EDGAR.BAS OOPS4.BAS OOPS3.BAS \ HORROR.BAS DIAMOND.BAS LEMM.BAS OOPS.BAS SPLIT.BAS PARTICLE.BAS \ PARTICLE_HGR.BAS DIAMOND_SCROLL.BAS RANDOM_SCROLL.BAS STAR_BOUNCE.BAS\ - OOZE.BAS + OOZE.BAS HORIZ_STAR.BAS # cp $(EMPTY_DISK)/empty.dsk appleiibot.dsk cp empty.dsk appleiibot.dsk $(DOS33) -y appleiibot.dsk BSAVE -a 0x0300 LOAD @@ -124,6 +124,7 @@ appleiibot.dsk: E2.BAS FLAME.BAS FLAME2.BAS HELLO \ $(DOS33) -y appleiibot.dsk SAVE A RANDOM_SCROLL.BAS $(DOS33) -y appleiibot.dsk SAVE A STAR_BOUNCE.BAS $(DOS33) -y appleiibot.dsk SAVE A OOZE.BAS + $(DOS33) -y appleiibot.dsk SAVE A HORIZ_STAR.BAS #### @@ -695,6 +696,11 @@ STAR_BOUNCE.BAS: star_bounce.bas OOZE.BAS: ooze.bas $(TOKENIZE) < ooze.bas > OOZE.BAS +#### + +HORIZ_STAR.BAS: horiz_star.bas + $(TOKENIZE) < horiz_star.bas > HORIZ_STAR.BAS + #### diff --git a/basic/appleiibot/horiz_star.bas b/basic/appleiibot/horiz_star.bas new file mode 100644 index 00000000..f1ec7310 --- /dev/null +++ b/basic/appleiibot/horiz_star.bas @@ -0,0 +1,2 @@ +1FORI=0TO135:POKE880+I,4*PEEK(2125+I)-204+(PEEK(2261+I/3)-35)/4^(I-INT(I/3)*3):NEXT +2&"/@q 0 +;.export decrunch + ; ------------------------------------------------------------------- -; To decrunch files crunched with the split feature (-E) you can't use the -; decrunch function. Instead you call the split_decrunch function. But you -; can only do this if the decrunch table contains the encoding used by the -; file you are decrunching. To generate the correct content for the decrunch -; table call set the get_crunched_byte function to point to the encoding data -; and then call the split_gentable function. +; Controls if the shared get_bits routines should be inlined or not. +;INLINE_GET_BITS=1 ; ------------------------------------------------------------------- -.export split_gentable -.export split_decrunch -.ENDIF +; 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 ; ------------------------------------------------------------------- ; zero page addresses used ; ------------------------------------------------------------------- -zp_len_lo = $9e -zp_len_hi = $9f +zp_len_lo = $a7 +zp_len_hi = $a8 zp_src_lo = $ae zp_src_hi = zp_src_lo + 1 -zp_bits_hi = $a7 -.IF DONT_REUSE_OFFSET = 0 -zp_ro_state = $a8 -.ENDIF +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 -.IF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE <> 0 +.ifdef EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE encoded_entries = 68 -.ELSE +.else encoded_entries = 52 -.ENDIF +.endif 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 +.macro mac_refill_bits pha jsr get_crunched_byte rol sta zp_bitbuf pla -.ENDMACRO +.endmacro -.MACRO mac_get_bits -.IF INLINE_GET_BITS <> 0 -.SCOPE +.ifdef INLINE_GET_BITS +.macro mac_get_bits adc #$80 ; needs c=0, affects v asl bpl gb_skip @@ -164,45 +120,13 @@ gb_get_hi: sta zp_bits_hi jsr get_crunched_byte skip: -.ENDSCOPE -.ELSE +.endmacro +.else +.macro mac_get_bits jsr get_bits -.ENDIF -.ENDMACRO +.endmacro +.endif -.MACRO mac_init_zp -.SCOPE -; ------------------------------------------------------------------- -; init zeropage and x reg. (8 bytes) -; -init_zp: - jsr get_crunched_byte - sta zp_bitbuf - 1,x - dex - bne init_zp -.ENDSCOPE -.ENDMACRO - -.IF INLINE_GET_BITS = 0 -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 -.ENDIF ; ------------------------------------------------------------------- ; no code below this comment has to be modified in order to generate ; a working decruncher of this source file. @@ -214,25 +138,22 @@ gb_get_hi: ; 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 cleared (it almost always is, otherwise do a cld) +; decimal flag has to be #0 (it almost always is, otherwise do a cld) decrunch: -.IF ENABLE_SPLIT_ENCODING <> 0 - ldx #3 - jsr internal_gentable - jmp normal_decrunch -split_gentable: - ldx #1 -internal_gentable: - jsr split_init_zp -.ELSE - ldx #3 - mac_init_zp -.ENDIF ; ------------------------------------------------------------------- -; calculate tables (64 bytes) + get_bits macro -; x must be #0 when entering +; 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 @@ -271,7 +192,7 @@ rolled: bmi no_fixup_lohi lda zp_len_hi stx zp_len_hi - .BYTE $24 + .byte $24 no_fixup_lohi: txa ; ------------------------------------------------------------------- @@ -279,57 +200,26 @@ no_fixup_lohi: cpy #encoded_entries bne table_gen ; ------------------------------------------------------------------- -.IF ENABLE_SPLIT_ENCODING <> 0 - rts -split_decrunch: - ldx #3 - jsr split_init_zp -; X reg must be 0 here - sec -normal_decrunch: -.ENDIF -; ------------------------------------------------------------------- ; prepare for main decruncher -.IF DONT_REUSE_OFFSET = 0 - ror zp_ro_state - sec -.ENDIF ldy zp_dest_lo stx zp_dest_lo stx zp_bits_hi ; ------------------------------------------------------------------- -; copy one literal byte to destination (11 bytes) +; copy one literal byte to destination (11(10) bytes) ; literal_start1: -.IF DECRUNCH_FORWARDS = 0 tya bne no_hi_decr dec zp_dest_hi -.IF DONT_REUSE_OFFSET = 0 - dec zp_src_hi -.ENDIF no_hi_decr: dey -.ENDIF jsr get_crunched_byte sta (zp_dest_lo),y -.IF DECRUNCH_FORWARDS <> 0 - iny - bne skip_hi_incr - inc zp_dest_hi -.IF DONT_REUSE_OFFSET = 0 - inc zp_src_hi -.ENDIF -skip_hi_incr: -.ENDIF ; ------------------------------------------------------------------- ; 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: -.IF DONT_REUSE_OFFSET = 0 - ror zp_ro_state -.ENDIF dex lda zp_bitbuf no_literal1: @@ -349,13 +239,13 @@ nofetch8: ; check for decrunch done and literal sequences (4 bytes) ; cpx #$11 -.IF INLINE_GET_BITS <> 0 +.ifdef INLINE_GET_BITS bcc skip_jmp jmp exit_or_lit_seq skip_jmp: -.ELSE +.else bcs exit_or_lit_seq -.ENDIF +.endif ; ------------------------------------------------------------------- ; calulate length of sequence (zp_len) (18(11) bytes) + get_bits macro ; @@ -363,7 +253,7 @@ skip_jmp: mac_get_bits adc tabl_lo - 1,x ; we have now calculated zp_len_lo sta zp_len_lo -.IF MAX_SEQUENCE_LENGTH_256 = 0 +.ifndef MAX_SEQUENCE_LENGTH_256 lda zp_bits_hi adc tabl_hi - 1,x ; c = 0 after this. sta zp_len_hi @@ -372,32 +262,15 @@ skip_jmp: ; z-flag reflects zp_len_hi here ; ldx zp_len_lo -.ELSE +.else tax -.ENDIF -.IF MAX_SEQUENCE_LENGTH_256 = 0 - lda #0 -.ENDIF -.IF DONT_REUSE_OFFSET = 0 -; ------------------------------------------------------------------- -; here we decide to reuse latest offset or not (13(15) bytes) -; - bit 0 +.ifdef EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE cpx #$04 -.ELSE +.else cpx #$03 -.ENDIF +.endif bcs gbnc2_next lda tabl_bit - 1,x gbnc2_next: @@ -413,163 +286,172 @@ gbnc2_ok: bcs gbnc2_next tax ; ------------------------------------------------------------------- -; calulate absolute offset (zp_src) (17 bytes) + get_bits macro +; calulate absolute offset (zp_src) (21(23) bytes) + get_bits macro ; +.ifndef MAX_SEQUENCE_LENGTH_256 + lda #0 + sta zp_bits_hi +.endif lda tabl_bi,x mac_get_bits -.IF DECRUNCH_FORWARDS = 0 adc tabl_lo,x sta zp_src_lo lda zp_bits_hi adc tabl_hi,x adc zp_dest_hi sta zp_src_hi -.ELSE - clc - adc tabl_lo,x - eor #$ff - sta zp_src_lo - lda zp_bits_hi - adc tabl_hi,x - eor #$ff - adc zp_dest_hi - sta zp_src_hi - clc -.ENDIF ; ------------------------------------------------------------------- ; prepare for copy loop (2 bytes) ; +pre_copy: ldx zp_len_lo ; ------------------------------------------------------------------- ; main copy loop (30 bytes) ; copy_next: -.IF DECRUNCH_FORWARDS = 0 tya bne copy_skip_hi dec zp_dest_hi dec zp_src_hi copy_skip_hi: dey -.ENDIF -.IF LITERAL_SEQUENCES_NOT_USED = 0 +.ifndef LITERAL_SEQUENCES_NOT_USED bcs get_literal_byte -.ENDIF +.endif lda (zp_src_lo),y literal_byte_gotten: sta (zp_dest_lo),y -.IF DECRUNCH_FORWARDS <> 0 - iny - bne copy_skip_hi - inc zp_dest_hi - inc zp_src_hi -copy_skip_hi: -.ENDIF dex bne copy_next -.IF MAX_SEQUENCE_LENGTH_256 = 0 +.ifndef MAX_SEQUENCE_LENGTH_256 lda zp_len_hi -.IF INLINE_GET_BITS <> 0 +.ifdef INLINE_GET_BITS bne copy_next_hi -.ENDIF -.ENDIF +.endif +.endif +begin_stx: stx zp_bits_hi -.IF INLINE_GET_BITS = 0 +.ifndef INLINE_GET_BITS beq next_round -.ELSE +.else jmp next_round -.ENDIF -.IF MAX_SEQUENCE_LENGTH_256 = 0 +.endif +.ifndef MAX_SEQUENCE_LENGTH_256 copy_next_hi: dec zp_len_hi jmp copy_next -.ENDIF -.IF DONT_REUSE_OFFSET = 0 -; ------------------------------------------------------------------- -; test for offset reuse (11 bytes) -; -test_reuse: - bvs no_reuse -.IF MAX_SEQUENCE_LENGTH_256 <> 0 - lda #$00 ; fetch one bit -.ENDIF - asl zp_bitbuf - bne gbnc1_ok - pha +.endif +.ifndef LITERAL_SEQUENCES_NOT_USED +get_literal_byte: jsr get_crunched_byte - rol - sta zp_bitbuf - pla -gbnc1_ok: - rol - beq no_reuse ; bit == 0 => C=0, no reuse - bne copy_next ; bit != 0 => C=0, reuse previous offset -.ENDIF + bcs literal_byte_gotten +.endif ; ------------------------------------------------------------------- ; exit or literal sequence handling (16(12) bytes) ; exit_or_lit_seq: -.IF LITERAL_SEQUENCES_NOT_USED = 0 +.ifndef LITERAL_SEQUENCES_NOT_USED beq decr_exit jsr get_crunched_byte -.IF MAX_SEQUENCE_LENGTH_256 = 0 +.ifndef MAX_SEQUENCE_LENGTH_256 sta zp_len_hi -.ENDIF +.endif jsr get_crunched_byte tax bcs copy_next decr_exit: -.ENDIF +.endif rts -.IF LITERAL_SEQUENCES_NOT_USED = 0 -get_literal_byte: - jsr get_crunched_byte - bcs literal_byte_gotten -.ENDIF -.IF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE <> 0 +.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 + .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 -.ENDIF - -.IF ENABLE_SPLIT_ENCODING <> 0 -split_init_zp: - mac_init_zp - rts -.ENDIF + .byte $8c, $e2 +.endif ; ------------------------------------------------------------------- ; end of decruncher ; ------------------------------------------------------------------- +.ifndef INLINE_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 +; fall through +.endif +get_crunched_byte: + lda _byte_lo + bne _byte_skip_hi + dec _byte_hi +_byte_skip_hi: + dec _byte_lo +_byte_lo = * + 1 +_byte_hi = * + 2 + lda $d1d1 ; needs to be set correctly before + ; decrunch_file is called. + rts + ; ------------------------------------------------------------------- ; this 156 (204) byte table area may be relocated. It may also be ; clobbered by other data between decrunches. ; ------------------------------------------------------------------- decrunch_table: - .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 -.IF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE <> 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 -.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 +;!warn "entry=",* + pla + tay + pla + tax + clc + pla + adc #$F8 + sta _byte_lo + pla + sta zp_bitbuf + pla + adc zp_bitbuf + sta _byte_hi + txa + pha + tya + pha + jmp decrunch + +;; .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 ; ------------------------------------------------------------------- diff --git a/compression/comparison/hardware.inc b/compression/comparison/hardware.inc index 122551dd..1d1810fa 100644 --- a/compression/comparison/hardware.inc +++ b/compression/comparison/hardware.inc @@ -4,8 +4,8 @@ KEYPRESS = $C000 KEYRESET = $C010 ;; SOFT SWITCHES -CLR80COL = $C000 ; PAGE0/PAGE1 normal -SET80COL = $C001 ; PAGE0/PAGE1 switches PAGE0 in Aux instead +CLR80COL = $C000 ; PAGE1/PAGE2 normal +SET80COL = $C001 ; PAGE1/PAGE2 switches PAGE1 in Aux instead EIGHTYCOLOFF = $C00C EIGHTYCOLON = $C00D VBLANK = $C019 ; IIe *not* RDVBL (VBL low), IIgs opposite @@ -20,8 +20,8 @@ SET_GR = $C050 SET_TEXT = $C051 FULLGR = $C052 TEXTGR = $C053 -PAGE0 = $C054 -PAGE1 = $C055 +PAGE1 = $C054 +PAGE2 = $C055 LORES = $C056 ; Enable LORES graphics HIRES = $C057 ; Enable HIRES graphics CLRAN1 = $C05A ; clear annunciator 1 (if IOUDIS off)