Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > CSDb Entries > Release id #198340 : Exomizer V3.1.0
2020-12-23 20:10
Jammer

Registered: Nov 2002
Posts: 1336
Release id #198340 : Exomizer V3.1.0

Has anyone got any reasonable kickass source of mem decruncher compatible with Exomizer 3.x? I've got only this and have to compress files with Exomizer 2.x compatibility mode:

//
// Copyright (c) 2002 - 2005 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. This subroutine has to preserve x and y register
// and must not modify the state of the carry flag.
// -------------------------------------------------------------------
// not needed for kickass... just defined it in client code as
// .var get_crunched_byte = get_crunched_byte_custom 
// where get_crunched_byte_custom is your routine
// -------------------------------------------------------------------
// .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.
// -------------------------------------------------------------------
// Not needed for kickass
// .export decrunch

// -------------------------------------------------------------------
// if literal sequences is not used (the data was crunched with the -c
// flag) then the following line can be uncommented for shorter code.
// #define LITERAL_SEQUENCES_NOT_USED

//.var get_crunched_byte = get_crunched_byte_custom 

// -------------------------------------------------------------------
// zero page addresses used
// -------------------------------------------------------------------
.var zp_len_lo = exomizerzp

.var zp_src_lo  = zp_len_lo + 1
.var zp_src_hi  = zp_src_lo + 1

.var zp_bits_hi = zp_src_hi + 1

.var zp_bitbuf  = zp_bits_hi + 1
.var zp_dest_lo = zp_bitbuf + 1	// dest addr lo
.var zp_dest_hi = zp_dest_lo + 1	// dest addr hi

.var tabl_bi = decrunch_table
.var tabl_lo = decrunch_table + 52
.var tabl_hi = decrunch_table + 104

// -------------------------------------------------------------------
// 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:
// -------------------------------------------------------------------
// 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 (50 bytes)
// x and y must be #0 when entering
//
nextone:
				inx
				tya
				and #$0f
				beq shortcut		// starta pĺ ny sekvens

				txa			// this clears reg a
				lsr 			// and sets the carry flag
				ldx tabl_bi-1,y
rolle:
				rol 
				rol zp_bits_hi
				dex
				bpl rolle		// c = 0 after this (rol zp_bits_hi)

				adc tabl_lo-1,y
				tax

				lda zp_bits_hi
				adc tabl_hi-1,y
shortcut:
				sta tabl_hi,y
				txa
				sta tabl_lo,y

				ldx #4
				jsr get_bits		// clears x-reg.
				sta tabl_bi,y
				iny
				cpy #52
				bne nextone
				ldy #0
				beq begin
// -------------------------------------------------------------------
// get bits (29 bytes)
//
// args:
//   x = number of bits to get
// returns:
//   a = #bits_lo
//   x = #0
//   c = 0
//   z = 1
//   zp_bits_hi = #bits_hi
// notes:
//   y is untouched
// -------------------------------------------------------------------
get_bits:
				lda #$00
				sta zp_bits_hi
				cpx #$01
				bcc bits_done
bits_next:
				lsr zp_bitbuf
				bne ok
				pha
literal_get_byte:
				jsr get_crunched_byte
				bcc literal_byte_gotten
				ror 
				sta zp_bitbuf
				pla
ok:
				rol 
				rol zp_bits_hi
				dex
				bne bits_next
bits_done:
				rts
// -------------------------------------------------------------------
// main copy loop (18(16) bytes)
//
copy_next_hi:
				dex
				dec zp_dest_hi
				dec zp_src_hi
copy_next:
				dey
#if !LITERAL_SEQUENCES_NOT_USED
				bcc literal_get_byte
#endif
				lda (zp_src_lo),y
literal_byte_gotten:
				sta (zp_dest_lo),y
copy_start:
				tya
				bne copy_next
begin:
				txa
				bne copy_next_hi
// -------------------------------------------------------------------
// decruncher entry point, needs calculated tables (21(13) bytes)
// x and y must be #0 when entering
//
#if !LITERAL_SEQUENCES_NOT_USED
				inx
				jsr get_bits
				tay
				bne literal_start1
#else
				dey
#endif
begin2:
				inx
				jsr bits_next
				lsr 
				iny
				bcc begin2
#if LITERAL_SEQUENCES_NOT_USED
				beq literal_start
#endif
				cpy #$11
#if !LITERAL_SEQUENCES_NOT_USED
				bcc sequence_start
				beq bits_done
// -------------------------------------------------------------------
// literal sequence handling (13(2) bytes)
//
				ldx #$10
				jsr get_bits
literal_start1:
				sta <zp_len_lo
				ldx <zp_bits_hi
				ldy #0
				bcc literal_start
sequence_start:
#else
				bcs bits_done
#endif
// -------------------------------------------------------------------
// calulate length of sequence (zp_len) (11 bytes)
//
				ldx tabl_bi - 1,y
				jsr get_bits
				adc tabl_lo - 1,y	// we have now calculated zp_len_lo
				sta zp_len_lo
// -------------------------------------------------------------------
// now do the hibyte of the sequence length calculation (6 bytes)
				lda zp_bits_hi
				adc tabl_hi - 1,y	// c = 0 after this.
				pha
// -------------------------------------------------------------------
// here we decide what offset table to use (20 bytes)
// x is 0 here
//
				bne nots123
				ldy zp_len_lo
				cpy #$04
				bcc size123
nots123:
				ldy #$03
size123:
				ldx tabl_bit - 1,y
				jsr get_bits
				adc tabl_off - 1,y	// c = 0 after this.
				tay			// 1 <= y <= 52 here
// -------------------------------------------------------------------
// Here we do the dest_lo -= len_lo subtraction to prepare zp_dest
// but we do it backwards:	a - b == (b - a - 1) ^ ~0 (C-syntax)
// (16(16) bytes)
				lda zp_len_lo
literal_start:			// literal enters here with y = 0, c = 1
				sbc zp_dest_lo
				bcc noborrow
				dec zp_dest_hi
noborrow:
				eor #$ff
				sta zp_dest_lo
				cpy #$01		// y < 1 then literal
#if !LITERAL_SEQUENCES_NOT_USED
				bcc pre_copy
#else
				bcc literal_get_byte
#endif
// -------------------------------------------------------------------
// calulate absolute offset (zp_src) (27 bytes)
//
				ldx tabl_bi,y
				jsr get_bits//
				adc tabl_lo,y
				bcc skipcarry
				inc zp_bits_hi
				clc
skipcarry:
				adc zp_dest_lo
				sta zp_src_lo
				lda zp_bits_hi
				adc tabl_hi,y
				adc zp_dest_hi
				sta zp_src_hi
// -------------------------------------------------------------------
// prepare for copy loop (8(6) bytes)
//
				pla
				tax
#if !LITERAL_SEQUENCES_NOT_USED
				sec
pre_copy:
				ldy <zp_len_lo
				jmp copy_start
#else
				ldy <zp_len_lo
				bcc copy_start
#endif

get_crunched_byte:
    lda srcptr
    bne !+
    dec srcptr + 1
!:
    dec srcptr
    lda srcptr:$ffff
    rts
	
// -------------------------------------------------------------------
// two small static tables (6(6) bytes)
//
tabl_bit:
				.byte 2,4,4
tabl_off:
				.byte 48,32,16
// -------------------------------------------------------------------
// end of decruncher
// -------------------------------------------------------------------

// -------------------------------------------------------------------
// this 156 byte table area may be relocated. It may also be clobbered
// by other data between decrunches.
// -------------------------------------------------------------------
decrunch_table:
				.fill 156,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,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
// -------------------------------------------------------------------
2020-12-23 20:26
Krill

Registered: Apr 2002
Posts: 2982
Not sure what constitutes Kickass compatibility (does it really require '.var' instead of '=' or old-style 'equ'?), but do the decrunchers in the archive not suit your needs, at least after some slight modification?
2020-12-23 21:57
Richard

Registered: Dec 2001
Posts: 621
I usually use the -P0 prefix at the end of the commandline for Exomizer V3. This level crunches memory in V2 compatibility mode. The Wrap.s code can decrunch that also. I used it many times on some of my multi-level game projects as I haven't spotted any V3 compatible level memory decrunch routines since the cruncher was released.
2020-12-23 22:03
iAN CooG

Registered: May 2002
Posts: 3204
It kinda defies the purpose using exo v3.x if you still make use of the old compression method, just use the old 2.x
2020-12-23 22:49
Krill

Registered: Apr 2002
Posts: 2982
Quoting Richard
I haven't spotted any V3 compatible level memory decrunch routines since the cruncher was released.
Has been released with Exo V3 itself, and Krill's Loader, Repository Version 184 uses it and supports Exo3.
2020-12-24 00:10
Jammer

Registered: Nov 2002
Posts: 1336
Quoting Richard
I usually use the -P0 prefix at the end of the commandline for Exomizer V3. This level crunches memory in V2 compatibility mode.

That's what I'm basically doing for 'mem' packed things but... what iAN Coog said in this case :/ Alas, sources included in Exomizer 3 turned out to be a little above my abilities to make it kickass :D I got the one above from Mojzesh/Arise and modified it only a little to suit my zp use better.
2020-12-24 01:32
Krill

Registered: Apr 2002
Posts: 2982
Quoting Jammer
Alas, sources included in Exomizer 3 turned out to be a little above my abilities to make it kickass :D
Well, old XY problem question. Do you really need to have library stuff in your preferred assembler's syntax? Could be good enough for now to just integrate one of the supported assemblers in your build toolchain to spit out decrunch.prg now and then that you can .incbin in your sources.

Pretty much what you'd do with SID tunes as well. Or loaders, for that matter. =)
2020-12-24 11:14
chatGPZ

Registered: Dec 2001
Posts: 11391
back to linking binary blobs? why not :)
2020-12-24 12:13
Krill

Registered: Apr 2002
Posts: 2982
Quoting Groepaz
back to linking binary blobs? why not :)
Less of a binary blob than linking any regular tune.prg. Would be part of the build toolchain, after all, with the small decruncher snippet just happening to be built by another assembler. Basically a pedestrian way of .o linkage otherwise done by object linkers. =)
2020-12-24 13:32
Jammer

Registered: Nov 2002
Posts: 1336
As I said, I needed to modify variables slightly. Not the most pleasant task with binary :D
2020-12-24 13:57
Krill

Registered: Apr 2002
Posts: 2982
Quoting Jammer
As I said, I needed to modify variables slightly. Not the most pleasant task with binary :D
You are perfectly capable of changing variables in the source, even if slightly different format than your preferred assembler's, no?
 
... 5 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
stephan-a
LDX#40
psych
Malmix/Fatzone
t0m3000/hf^boom!^ibx
cobbpg
MagerValp/G★P
Guests online: 122
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.6)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 Uncensored  (9.6)
7 The Demo Coder  (9.6)
8 Comaland 100%  (9.6)
9 What Is The Matrix 2  (9.6)
10 Unboxed  (9.6)
Top onefile Demos
1 Layers  (9.7)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 Dawnfall V1.1  (9.5)
6 Rainbow Connection  (9.5)
7 Morph  (9.5)
8 Libertongo  (9.5)
9 Onscreen 5k  (9.5)
10 It's More Fun to Com..  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Performers  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Original Suppliers
1 Derbyshire Ram  (9.7)
2 Fungus  (9.3)
3 Black Beard  (9.2)
4 Baracuda  (9.2)
5 hedning  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.054 sec.