refactor animation-during-decompression using IFDEFs to shave some bytes

This commit is contained in:
4am 2021-04-19 10:28:08 -04:00
parent 46b2019ba1
commit 3beb4c8b3d
4 changed files with 18 additions and 12 deletions

View File

@ -1,8 +1,10 @@
; This source code is altered and is not the original version found on ; This source code is altered and is not the original version found on
; the Exomizer homepage. ; the Exomizer homepage.
; It contains modifications made by qkumba to depack a packed file ; It contains modifications made by qkumba to depack a packed file
; optionally crunched forward. ; optionally crunched forward, and additional modifications by 4am
; for an optional progress UI.
;
; Original copyright statement follows:
; ;
; Copyright (c) 2002 - 2018 Magnus Lind. ; Copyright (c) 2002 - 2018 Magnus Lind.
; ;
@ -62,9 +64,13 @@
; compression at the cost of a larger decrunch table. ; compression at the cost of a larger decrunch table.
EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE = 1 EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE = 1
; ------------------------------------------------------------------- ; -------------------------------------------------------------------
; optional progress UI
!IFNDEF SHOW_PROGRESS_DURING_DECRUNCH {
SHOW_PROGRESS_DURING_DECRUNCH = 0
}
; -------------------------------------------------------------------
; zero page addresses used ; zero page addresses used
; ------------------------------------------------------------------- ; -------------------------------------------------------------------
zp_show_progress_ui = $a6
zp_len_lo = $a7 zp_len_lo = $a7
zp_len_hi = $a8 zp_len_hi = $a8
@ -153,13 +159,10 @@ gb_get_hi:
; decimal flag has to be #0 (it almost always is, otherwise do a cld) ; decimal flag has to be #0 (it almost always is, otherwise do a cld)
decrunch: decrunch:
!IF SHOW_PROGRESS_DURING_DECRUNCH = 1 {
; ------------------------------------------------------------------- ; -------------------------------------------------------------------
; show initial on-screen progress UI ; show initial on-screen progress UI
; ;
ror
sta zp_show_progress_ui
bit zp_show_progress_ui
bpl done_init_progress_loop
ldy #7 ldy #7
init_progress_loop: init_progress_loop:
lda progress_char,y lda progress_char,y
@ -167,6 +170,7 @@ init_progress_loop:
dey dey
bpl init_progress_loop bpl init_progress_loop
done_init_progress_loop: done_init_progress_loop:
}
; ------------------------------------------------------------------- ; -------------------------------------------------------------------
; init zeropage, x and y regs. (12 bytes) ; init zeropage, x and y regs. (12 bytes)
; ;
@ -244,9 +248,8 @@ no_hi_decr:
jsr get_crunched_byte jsr get_crunched_byte
sta (zp_dest_lo),y sta (zp_dest_lo),y
!IF SHOW_PROGRESS_DURING_DECRUNCH = 1 {
; periodically update on-screen progress UI ; periodically update on-screen progress UI
bit zp_show_progress_ui
bpl dont_update_progress_ui
dec progress_counter dec progress_counter
bne dont_update_progress_ui bne dont_update_progress_ui
tya tya
@ -264,6 +267,7 @@ no_hi_decr:
pla pla
tay tay
dont_update_progress_ui: dont_update_progress_ui:
}
} else { } else {
literal_start1: literal_start1:
jsr get_crunched_byte jsr get_crunched_byte
@ -458,6 +462,7 @@ tabl_bit:
tabl_bit: tabl_bit:
!BYTE $8c, $e2 !BYTE $8c, $e2
} }
!IF SHOW_PROGRESS_DURING_DECRUNCH = 1 {
progress_index: progress_index:
!BYTE $00 !BYTE $00
progress_counter: progress_counter:
@ -480,6 +485,7 @@ show_one_progress_char:
progress_STA: progress_STA:
sta $FFFF sta $FFFF
rts rts
}
; ------------------------------------------------------------------- ; -------------------------------------------------------------------
; end of decruncher ; end of decruncher
; ------------------------------------------------------------------- ; -------------------------------------------------------------------

View File

@ -748,7 +748,6 @@ _applyToT00
sta _byte_hi sta _byte_hi
lda #<AnalyzeT00 lda #<AnalyzeT00
sta _byte_lo sta _byte_lo
clc ; don't show progress UI during decrunch
jsr decrunch jsr decrunch
jsr $2000 jsr $2000
_applyToAll _applyToAll

View File

@ -241,7 +241,6 @@ CopyUniversalAnywhere
sta _byte_hi sta _byte_hi
lda #<universalrwts lda #<universalrwts
sta _byte_lo sta _byte_lo
clc ; don't show progress UI during decrunch
jsr decrunch jsr decrunch
sty jCallRWTS+1 sty jCallRWTS+1
lda #$BD lda #$BD

View File

@ -17,7 +17,6 @@ good_mem
jsr $FE93 ; IN#0 jsr $FE93 ; IN#0
jsr $FB2F ; TEXT jsr $FB2F ; TEXT
jsr $FC58 ; HOME jsr $FC58 ; HOME
sec ; show progress UI during decrunch
jsr decrunch jsr decrunch
sty $fe ;;zp_dest_lo sty $fe ;;zp_dest_lo
@ -44,6 +43,9 @@ OneTimeSetup
!source "apidefs.a" !source "apidefs.a"
!source "strings/enid.a" !source "strings/enid.a"
!source "initscan.a" !source "initscan.a"
SHOW_PROGRESS_DURING_DECRUNCH = 1 ; activates optional UI code in exodecrunch
!source "exodecrunch.s" !source "exodecrunch.s"
get_crunched_byte get_crunched_byte