05 May 2024, 18:17 | #1 |
Registered User
Join Date: Feb 2022
Location: san fernando
Posts: 8
|
Centurion packer
Hello, good afternoon. I am trying to translate the centurion game. There are several compressed files supposedly in lzw. I have got a decompressor made in C, that works. But, the files need to be compressed again. Using the same algorithm would it be possible to make a compressor? thanks for the help. I will leave an example file and the code.
|
05 May 2024, 18:48 | #2 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,411
|
In a compressor/decompressor algorithm, the decompressor is the easy part. Writing the compressor is not easy and there are several possiblities to compute the dictionary, not just one. Did you write the decompressor yourself?
|
05 May 2024, 18:58 | #3 |
Registered User
Join Date: Feb 2022
Location: san fernando
Posts: 8
|
I didn't do it. I just looked it up. But I haven't found a compressor. Ok, thanks anyway.
|
05 May 2024, 19:04 | #4 |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,284
|
It shouldn't be too bad of such a simple encoding. You can probably adapt an existing encoder quite easily. If you you're not pressed for size, start out with just a really stupid one that encodes everything as literals.
|
05 May 2024, 19:11 | #5 |
Registered User
Join Date: Feb 2022
Location: san fernando
Posts: 8
|
mmm. thanks. i'll try a couple of things.
|
05 May 2024, 21:07 | #6 |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,284
|
Like this I mean (terrible code, but should decompress to the same thing):
Code:
#include <stdio.h> #include <stdlib.h> #include <stdint.h> uint8_t outbuf[1024*1024]; uint8_t* mode_ptr = &outbuf[0]; int mode_cnt = 0; size_t outbuf_pos = 1; int main(int argc, char* argv[]) { if (argc != 3) { fprintf(stderr, "Usage: %s in out\n", argv[0]); return 1; } FILE* in = fopen(argv[1], "rb"); if (!in) { fprintf(stderr, "Could not open %s\n", argv[1]); return -1; } uint8_t* data; uint32_t data_len; fseek(in, 0, SEEK_END); data_len = (uint32_t)ftell(in); fseek(in, 0, SEEK_SET); data = (uint8_t*)malloc(data_len); // Let's assume this works fread(data, data_len, 1, in); fclose(in); FILE* out = fopen(argv[2], "wb"); if (!out) { fprintf(stderr, "Could not create %s\n", argv[2]); return -1; } fputc((data_len>>24)&0xff, out); fputc((data_len>>16)&0xff, out); fputc((data_len>>8)&0xff, out); fputc((data_len>>0)&0xff, out); for (uint32_t i = 0; i < data_len; ++i) { if (mode_cnt == 8) { mode_cnt = 0; mode_ptr = &outbuf[outbuf_pos++]; } *mode_ptr = *mode_ptr << 1 | 1; ++mode_cnt; outbuf[outbuf_pos++] = data[i]; } fwrite(outbuf, outbuf_pos, 1, out); fclose(out); return 0; } |
05 May 2024, 22:04 | #7 |
Registered User
Join Date: Feb 2022
Location: san fernando
Posts: 8
|
Thank you very much. I'll try it right now. Anyway I've tested adding a fake header to the decompressed file and it seems to read it, although the texts don't match where they should be, but it reads it for sure.
Last edited by Darasco; 05 May 2024 at 22:56. |
05 May 2024, 22:15 | #8 |
Registered User
Join Date: Feb 2022
Location: san fernando
Posts: 8
|
It workssss!!!. there are no words to thank you
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Is there a better packer than arjm7? | leonard | Coders. Asm / Hardware | 70 | 04 January 2024 20:22 |
old soundeditors and pt-packer | Promax | request.Apps | 7 | 14 July 2010 13:21 |
Unofficial version of Centurion PL, needing WHDLoad support... | Shoonay | project.WHDLoad | 1 | 04 August 2008 23:15 |
req: Centurion Defender Of Rome Whdfied | AMIGAZ | request.Old Rare Games | 5 | 17 August 2006 00:33 |
Centurion - how to speak? | Shoonay | support.Games | 2 | 29 April 2005 21:22 |
|
|