summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-09-29 10:31:09 +0800
committerIru Cai <mytbk920423@gmail.com>2018-09-29 10:31:09 +0800
commitd73b9944848e8cd544564ecb0dd0ec96710237bb (patch)
tree12515455b04431dcfa0d1fb0b36e3dda33bab81a
parentd02dbcac9d53d84a8b0c8b5a46479dd87a37ae93 (diff)
downloadrich4-d73b9944848e8cd544564ecb0dd0ec96710237bb.tar.xz
name mkf_00455040 as mkf_decompress
Now it's a correct implementation, tested with dump_600
-rw-r--r--csrc/Makefile14
-rw-r--r--csrc/mkf.c6
-rw-r--r--csrc/mkf_00455040.c570
-rw-r--r--csrc/mkf_asm.asm88
-rw-r--r--csrc/mkf_decompress.c (renamed from csrc/mkf_asm_data.c)29
-rw-r--r--csrc/test/dump_600.c2
6 files changed, 20 insertions, 689 deletions
diff --git a/csrc/Makefile b/csrc/Makefile
index 2c842b7..c33b580 100644
--- a/csrc/Makefile
+++ b/csrc/Makefile
@@ -1,11 +1,5 @@
-CFLAGS=-m32 -g
+CFLAGS=-m32 -g -Wall
+MKFOBJ=mkf.o mkf_decompress.o
-mkf_asm.o: mkf_asm.asm
- nasm -f elf32 mkf_asm.asm
-
-mkf_asm_data.o: mkf_asm_data.c
-
-mkf.o: mkf.c
-
-libmkf.a: mkf.o mkf_asm.o mkf_asm_data.o
- ar r libmkf.a mkf.o mkf_asm.o mkf_asm_data.o
+libmkf.a: $(MKFOBJ)
+ ar r libmkf.a $(MKFOBJ)
diff --git a/csrc/mkf.c b/csrc/mkf.c
index e0e1375..63e7e2d 100644
--- a/csrc/mkf.c
+++ b/csrc/mkf.c
@@ -10,8 +10,7 @@
#define NULL_HND ((FILE*)(-1))
-/* mkf_00455040.c */
-void fcn_00455040(char *arg1, char *arg2);
+void mkf_decompress(void *arg1, void *arg2);
struct mkf
{
@@ -33,7 +32,6 @@ int load_mkf(const char *fn)
{
int i;
int32_t x;
- int sz;
if (mkf_stdata[0].handle == NULL_HND)
memset(mkf_stdata, 0, sizeof(mkf_stdata));
@@ -165,7 +163,7 @@ char * read_mkf(int mkf_idx, int a1, char *buf, int *bufsize)
} else {
void *tmpbuf = malloc(data[1]);
fread(tmpbuf, 1, data[1], hdl);
- fcn_00455040(buf, tmpbuf);
+ mkf_decompress(buf, tmpbuf);
free(tmpbuf);
}
if (data[3] != 0) {
diff --git a/csrc/mkf_00455040.c b/csrc/mkf_00455040.c
deleted file mode 100644
index 967c660..0000000
--- a/csrc/mkf_00455040.c
+++ /dev/null
@@ -1,570 +0,0 @@
-/*
- * Copyright (C) 2018 Iru Cai <mytbk920423@gmail.com>
- * SPDX-License-Identifier: GPL-3.0-or-later
- */
-
-#include <stdint.h>
-#include <string.h>
-
-void fcn_00455109(size_t ebx);
-void fcn_004551bb(uint16_t *esi, uint32_t *ecx, uint16_t*);
-void fcn_0045511b(size_t ebx);
-void fcn_004550cc();
-
-/* code used by read_mkf function */
-
-const uint8_t table_00483430[256] = {
- 0x3f, 0x0b, 0x17, 0x03, 0x2f, 0x0a, 0x16, 0x00, 0x2e, 0x09,
- 0x15, 0x02, 0x2d, 0x01, 0x08, 0x00, 0x3e, 0x07, 0x14, 0x03,
- 0x2c, 0x06, 0x13, 0x00, 0x2b, 0x05, 0x12, 0x02, 0x2a, 0x01,
- 0x04, 0x00, 0x3d, 0x0b, 0x11, 0x03, 0x29, 0x0a, 0x10, 0x00,
- 0x28, 0x09, 0x0f, 0x02, 0x27, 0x01, 0x08, 0x00, 0x3c, 0x07,
- 0x0e, 0x03, 0x26, 0x06, 0x0d, 0x00, 0x25, 0x05, 0x0c, 0x02,
- 0x24, 0x01, 0x04, 0x00, 0x3b, 0x0b, 0x17, 0x03, 0x23, 0x0a,
- 0x16, 0x00, 0x22, 0x09, 0x15, 0x02, 0x21, 0x01, 0x08, 0x00,
- 0x3a, 0x07, 0x14, 0x03, 0x20, 0x06, 0x13, 0x00, 0x1f, 0x05,
- 0x12, 0x02, 0x1e, 0x01, 0x04, 0x00, 0x39, 0x0b, 0x11, 0x03,
- 0x1d, 0x0a, 0x10, 0x00, 0x1c, 0x09, 0x0f, 0x02, 0x1b, 0x01,
- 0x08, 0x00, 0x38, 0x07, 0x0e, 0x03, 0x1a, 0x06, 0x0d, 0x00,
- 0x19, 0x05, 0x0c, 0x02, 0x18, 0x01, 0x04, 0x00, 0x37, 0x0b,
- 0x17, 0x03, 0x2f, 0x0a, 0x16, 0x00, 0x2e, 0x09, 0x15, 0x02,
- 0x2d, 0x01, 0x08, 0x00, 0x36, 0x07, 0x14, 0x03, 0x2c, 0x06,
- 0x13, 0x00, 0x2b, 0x05, 0x12, 0x02, 0x2a, 0x01, 0x04, 0x00,
- 0x35, 0x0b, 0x11, 0x03, 0x29, 0x0a, 0x10, 0x00, 0x28, 0x09,
- 0x0f, 0x02, 0x27, 0x01, 0x08, 0x00, 0x34, 0x07, 0x0e, 0x03,
- 0x26, 0x06, 0x0d, 0x00, 0x25, 0x05, 0x0c, 0x02, 0x24, 0x01,
- 0x04, 0x00, 0x33, 0x0b, 0x17, 0x03, 0x23, 0x0a, 0x16, 0x00,
- 0x22, 0x09, 0x15, 0x02, 0x21, 0x01, 0x08, 0x00, 0x32, 0x07,
- 0x14, 0x03, 0x20, 0x06, 0x13, 0x00, 0x1f, 0x05, 0x12, 0x02,
- 0x1e, 0x01, 0x04, 0x00, 0x31, 0x0b, 0x11, 0x03, 0x1d, 0x0a,
- 0x10, 0x00, 0x1c, 0x09, 0x0f, 0x02, 0x1b, 0x01, 0x08, 0x00,
- 0x30, 0x07, 0x0e, 0x03, 0x1a, 0x06, 0x0d, 0x00, 0x19, 0x05,
- 0x0c, 0x02, 0x18, 0x01, 0x04, 0x00
-};
-
-const uint8_t table_00483530[256] = {
- 0x08, 0x05, 0x06, 0x04, 0x07, 0x05, 0x06, 0x03, 0x07, 0x05,
- 0x06, 0x04, 0x07, 0x04, 0x05, 0x03, 0x08, 0x05, 0x06, 0x04,
- 0x07, 0x05, 0x06, 0x03, 0x07, 0x05, 0x06, 0x04, 0x07, 0x04,
- 0x05, 0x03, 0x08, 0x05, 0x06, 0x04, 0x07, 0x05, 0x06, 0x03,
- 0x07, 0x05, 0x06, 0x04, 0x07, 0x04, 0x05, 0x03, 0x08, 0x05,
- 0x06, 0x04, 0x07, 0x05, 0x06, 0x03, 0x07, 0x05, 0x06, 0x04,
- 0x07, 0x04, 0x05, 0x03, 0x08, 0x05, 0x06, 0x04, 0x07, 0x05,
- 0x06, 0x03, 0x07, 0x05, 0x06, 0x04, 0x07, 0x04, 0x05, 0x03,
- 0x08, 0x05, 0x06, 0x04, 0x07, 0x05, 0x06, 0x03, 0x07, 0x05,
- 0x06, 0x04, 0x07, 0x04, 0x05, 0x03, 0x08, 0x05, 0x06, 0x04,
- 0x07, 0x05, 0x06, 0x03, 0x07, 0x05, 0x06, 0x04, 0x07, 0x04,
- 0x05, 0x03, 0x08, 0x05, 0x06, 0x04, 0x07, 0x05, 0x06, 0x03,
- 0x07, 0x05, 0x06, 0x04, 0x07, 0x04, 0x05, 0x03, 0x08, 0x05,
- 0x06, 0x04, 0x07, 0x05, 0x06, 0x03, 0x07, 0x05, 0x06, 0x04,
- 0x07, 0x04, 0x05, 0x03, 0x08, 0x05, 0x06, 0x04, 0x07, 0x05,
- 0x06, 0x03, 0x07, 0x05, 0x06, 0x04, 0x07, 0x04, 0x05, 0x03,
- 0x08, 0x05, 0x06, 0x04, 0x07, 0x05, 0x06, 0x03, 0x07, 0x05,
- 0x06, 0x04, 0x07, 0x04, 0x05, 0x03, 0x08, 0x05, 0x06, 0x04,
- 0x07, 0x05, 0x06, 0x03, 0x07, 0x05, 0x06, 0x04, 0x07, 0x04,
- 0x05, 0x03, 0x08, 0x05, 0x06, 0x04, 0x07, 0x05, 0x06, 0x03,
- 0x07, 0x05, 0x06, 0x04, 0x07, 0x04, 0x05, 0x03, 0x08, 0x05,
- 0x06, 0x04, 0x07, 0x05, 0x06, 0x03, 0x07, 0x05, 0x06, 0x04,
- 0x07, 0x04, 0x05, 0x03, 0x08, 0x05, 0x06, 0x04, 0x07, 0x05,
- 0x06, 0x03, 0x07, 0x05, 0x06, 0x04, 0x07, 0x04, 0x05, 0x03,
- 0x08, 0x05, 0x06, 0x04, 0x07, 0x05, 0x06, 0x03, 0x07, 0x05,
- 0x06, 0x04, 0x07, 0x04, 0x05, 0x03
-};
-
-const uint16_t table_483630[642] = {
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
- 0x0001, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
- 0x0002, 0x0003, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
- 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
- 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
- 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
- 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
- 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
- 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
- 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
- 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
- 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
- 0x0004, 0x0005, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0009, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
- 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
- 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0011, 0x0020, 0x0020,
- 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0021,
- 0x0040, 0x0040, 0x0040, 0x0040, 0x0041, 0x0080, 0x0080, 0x00c1,
- 0x0141, 0xffff
-};
-
-const uint16_t table_483b34[641] = {
- 0x0502, 0x0504, 0x0506, 0x0508, 0x050a, 0x050c, 0x050e, 0x0510,
- 0x0512, 0x0514, 0x0516, 0x0518, 0x051a, 0x051c, 0x051e, 0x0520,
- 0x0522, 0x0524, 0x0526, 0x0528, 0x052a, 0x052c, 0x052e, 0x0530,
- 0x0532, 0x0534, 0x0536, 0x0538, 0x053a, 0x053c, 0x053e, 0x0540,
- 0x0542, 0x0544, 0x0546, 0x0548, 0x054a, 0x054c, 0x054e, 0x0550,
- 0x0552, 0x0554, 0x0556, 0x0558, 0x055a, 0x055c, 0x055e, 0x0560,
- 0x0562, 0x0564, 0x0566, 0x0568, 0x056a, 0x056c, 0x056e, 0x0570,
- 0x0572, 0x0574, 0x0576, 0x0578, 0x057a, 0x057c, 0x057e, 0x0580,
- 0x0582, 0x0584, 0x0586, 0x0588, 0x058a, 0x058c, 0x058e, 0x0590,
- 0x0592, 0x0594, 0x0596, 0x0598, 0x059a, 0x059c, 0x059e, 0x05a0,
- 0x05a2, 0x05a4, 0x05a6, 0x05a8, 0x05aa, 0x05ac, 0x05ae, 0x05b0,
- 0x05b2, 0x05b4, 0x05b6, 0x05b8, 0x05ba, 0x05bc, 0x05be, 0x05c0,
- 0x05c2, 0x05c4, 0x05c6, 0x05c8, 0x05ca, 0x05cc, 0x05ce, 0x05d0,
- 0x05d2, 0x05d4, 0x05d6, 0x05d8, 0x05da, 0x05dc, 0x05de, 0x05e0,
- 0x05e2, 0x05e4, 0x05e6, 0x05e8, 0x05ea, 0x05ec, 0x05ee, 0x05f0,
- 0x05f2, 0x05f4, 0x05f6, 0x05f8, 0x05fa, 0x05fc, 0x05fe, 0x0600,
- 0x0602, 0x0604, 0x0606, 0x0608, 0x060a, 0x060c, 0x060e, 0x0610,
- 0x0612, 0x0614, 0x0616, 0x0618, 0x061a, 0x061c, 0x061e, 0x0620,
- 0x0622, 0x0624, 0x0626, 0x0628, 0x062a, 0x062c, 0x062e, 0x0630,
- 0x0632, 0x0634, 0x0636, 0x0638, 0x063a, 0x063c, 0x063e, 0x0640,
- 0x0642, 0x0644, 0x0646, 0x0648, 0x064a, 0x064c, 0x064e, 0x0650,
- 0x0652, 0x0654, 0x0656, 0x0658, 0x065a, 0x065c, 0x065e, 0x0660,
- 0x0662, 0x0664, 0x0666, 0x0668, 0x066a, 0x066c, 0x066e, 0x0670,
- 0x0672, 0x0674, 0x0676, 0x0678, 0x067a, 0x067c, 0x067e, 0x0680,
- 0x0682, 0x0684, 0x0686, 0x0688, 0x068a, 0x068c, 0x068e, 0x0690,
- 0x0692, 0x0694, 0x0696, 0x0698, 0x069a, 0x069c, 0x069e, 0x06a0,
- 0x06a2, 0x06a4, 0x06a6, 0x06a8, 0x06aa, 0x06ac, 0x06ae, 0x06b0,
- 0x06b2, 0x06b4, 0x06b6, 0x06b8, 0x06ba, 0x06bc, 0x06be, 0x06c0,
- 0x06c2, 0x06c4, 0x06c6, 0x06c8, 0x06ca, 0x06cc, 0x06ce, 0x06d0,
- 0x06d2, 0x06d4, 0x06d6, 0x06d8, 0x06da, 0x06dc, 0x06de, 0x06e0,
- 0x06e2, 0x06e4, 0x06e6, 0x06e8, 0x06ea, 0x06ec, 0x06ee, 0x06f0,
- 0x06f2, 0x06f4, 0x06f6, 0x06f8, 0x06fa, 0x06fc, 0x06fe, 0x0700,
- 0x0702, 0x0704, 0x0706, 0x0708, 0x070a, 0x070c, 0x070e, 0x0710,
- 0x0712, 0x0714, 0x0716, 0x0718, 0x071a, 0x071c, 0x071e, 0x0720,
- 0x0722, 0x0724, 0x0726, 0x0728, 0x072a, 0x072c, 0x072e, 0x0730,
- 0x0732, 0x0734, 0x0736, 0x0738, 0x073a, 0x073c, 0x073e, 0x0740,
- 0x0742, 0x0744, 0x0746, 0x0748, 0x074a, 0x074c, 0x074e, 0x0750,
- 0x0752, 0x0754, 0x0756, 0x0758, 0x075a, 0x075c, 0x075e, 0x0760,
- 0x0762, 0x0764, 0x0766, 0x0768, 0x076a, 0x076c, 0x076e, 0x0770,
- 0x0772, 0x0774, 0x0776, 0x0778, 0x077a, 0x077c, 0x077e, 0x0780,
- 0x0782, 0x0000, 0x0004, 0x0008, 0x000c, 0x0010, 0x0014, 0x0018,
- 0x001c, 0x0020, 0x0024, 0x0028, 0x002c, 0x0030, 0x0034, 0x0038,
- 0x003c, 0x0040, 0x0044, 0x0048, 0x004c, 0x0050, 0x0054, 0x0058,
- 0x005c, 0x0060, 0x0064, 0x0068, 0x006c, 0x0070, 0x0074, 0x0078,
- 0x007c, 0x0080, 0x0084, 0x0088, 0x008c, 0x0090, 0x0094, 0x0098,
- 0x009c, 0x00a0, 0x00a4, 0x00a8, 0x00ac, 0x00b0, 0x00b4, 0x00b8,
- 0x00bc, 0x00c0, 0x00c4, 0x00c8, 0x00cc, 0x00d0, 0x00d4, 0x00d8,
- 0x00dc, 0x00e0, 0x00e4, 0x00e8, 0x00ec, 0x00f0, 0x00f4, 0x00f8,
- 0x00fc, 0x0100, 0x0104, 0x0108, 0x010c, 0x0110, 0x0114, 0x0118,
- 0x011c, 0x0120, 0x0124, 0x0128, 0x012c, 0x0130, 0x0134, 0x0138,
- 0x013c, 0x0140, 0x0144, 0x0148, 0x014c, 0x0150, 0x0154, 0x0158,
- 0x015c, 0x0160, 0x0164, 0x0168, 0x016c, 0x0170, 0x0174, 0x0178,
- 0x017c, 0x0180, 0x0184, 0x0188, 0x018c, 0x0190, 0x0194, 0x0198,
- 0x019c, 0x01a0, 0x01a4, 0x01a8, 0x01ac, 0x01b0, 0x01b4, 0x01b8,
- 0x01bc, 0x01c0, 0x01c4, 0x01c8, 0x01cc, 0x01d0, 0x01d4, 0x01d8,
- 0x01dc, 0x01e0, 0x01e4, 0x01e8, 0x01ec, 0x01f0, 0x01f4, 0x01f8,
- 0x01fc, 0x0200, 0x0204, 0x0208, 0x020c, 0x0210, 0x0214, 0x0218,
- 0x021c, 0x0220, 0x0224, 0x0228, 0x022c, 0x0230, 0x0234, 0x0238,
- 0x023c, 0x0240, 0x0244, 0x0248, 0x024c, 0x0250, 0x0254, 0x0258,
- 0x025c, 0x0260, 0x0264, 0x0268, 0x026c, 0x0270, 0x0274, 0x0278,
- 0x027c, 0x0280, 0x0284, 0x0288, 0x028c, 0x0290, 0x0294, 0x0298,
- 0x029c, 0x02a0, 0x02a4, 0x02a8, 0x02ac, 0x02b0, 0x02b4, 0x02b8,
- 0x02bc, 0x02c0, 0x02c4, 0x02c8, 0x02cc, 0x02d0, 0x02d4, 0x02d8,
- 0x02dc, 0x02e0, 0x02e4, 0x02e8, 0x02ec, 0x02f0, 0x02f4, 0x02f8,
- 0x02fc, 0x0300, 0x0304, 0x0308, 0x030c, 0x0310, 0x0314, 0x0318,
- 0x031c, 0x0320, 0x0324, 0x0328, 0x032c, 0x0330, 0x0334, 0x0338,
- 0x033c, 0x0340, 0x0344, 0x0348, 0x034c, 0x0350, 0x0354, 0x0358,
- 0x035c, 0x0360, 0x0364, 0x0368, 0x036c, 0x0370, 0x0374, 0x0378,
- 0x037c, 0x0380, 0x0384, 0x0388, 0x038c, 0x0390, 0x0394, 0x0398,
- 0x039c, 0x03a0, 0x03a4, 0x03a8, 0x03ac, 0x03b0, 0x03b4, 0x03b8,
- 0x03bc, 0x03c0, 0x03c4, 0x03c8, 0x03cc, 0x03d0, 0x03d4, 0x03d8,
- 0x03dc, 0x03e0, 0x03e4, 0x03e8, 0x03ec, 0x03f0, 0x03f4, 0x03f8,
- 0x03fc, 0x0400, 0x0404, 0x0408, 0x040c, 0x0410, 0x0414, 0x0418,
- 0x041c, 0x0420, 0x0424, 0x0428, 0x042c, 0x0430, 0x0434, 0x0438,
- 0x043c, 0x0440, 0x0444, 0x0448, 0x044c, 0x0450, 0x0454, 0x0458,
- 0x045c, 0x0460, 0x0464, 0x0468, 0x046c, 0x0470, 0x0474, 0x0478,
- 0x047c, 0x0480, 0x0484, 0x0488, 0x048c, 0x0490, 0x0494, 0x0498,
- 0x049c, 0x04a0, 0x04a4, 0x04a8, 0x04ac, 0x04b0, 0x04b4, 0x04b8,
- 0x04bc, 0x04c0, 0x04c4, 0x04c8, 0x04cc, 0x04d0, 0x04d4, 0x04d8,
- 0x04dc, 0x04e0, 0x04e4, 0x04e8, 0x04ec, 0x04f0, 0x04f4, 0x04f8,
- 0x04fc
-};
-
-const uint16_t table_484036[641] = {
- 0x0282, 0x0282, 0x0284, 0x0284, 0x0286, 0x0286, 0x0288, 0x0288,
- 0x028a, 0x028a, 0x028c, 0x028c, 0x028e, 0x028e, 0x0290, 0x0290,
- 0x0292, 0x0292, 0x0294, 0x0294, 0x0296, 0x0296, 0x0298, 0x0298,
- 0x029a, 0x029a, 0x029c, 0x029c, 0x029e, 0x029e, 0x02a0, 0x02a0,
- 0x02a2, 0x02a2, 0x02a4, 0x02a4, 0x02a6, 0x02a6, 0x02a8, 0x02a8,
- 0x02aa, 0x02aa, 0x02ac, 0x02ac, 0x02ae, 0x02ae, 0x02b0, 0x02b0,
- 0x02b2, 0x02b2, 0x02b4, 0x02b4, 0x02b6, 0x02b6, 0x02b8, 0x02b8,
- 0x02ba, 0x02ba, 0x02bc, 0x02bc, 0x02be, 0x02be, 0x02c0, 0x02c0,
- 0x02c2, 0x02c2, 0x02c4, 0x02c4, 0x02c6, 0x02c6, 0x02c8, 0x02c8,
- 0x02ca, 0x02ca, 0x02cc, 0x02cc, 0x02ce, 0x02ce, 0x02d0, 0x02d0,
- 0x02d2, 0x02d2, 0x02d4, 0x02d4, 0x02d6, 0x02d6, 0x02d8, 0x02d8,
- 0x02da, 0x02da, 0x02dc, 0x02dc, 0x02de, 0x02de, 0x02e0, 0x02e0,
- 0x02e2, 0x02e2, 0x02e4, 0x02e4, 0x02e6, 0x02e6, 0x02e8, 0x02e8,
- 0x02ea, 0x02ea, 0x02ec, 0x02ec, 0x02ee, 0x02ee, 0x02f0, 0x02f0,
- 0x02f2, 0x02f2, 0x02f4, 0x02f4, 0x02f6, 0x02f6, 0x02f8, 0x02f8,
- 0x02fa, 0x02fa, 0x02fc, 0x02fc, 0x02fe, 0x02fe, 0x0300, 0x0300,
- 0x0302, 0x0302, 0x0304, 0x0304, 0x0306, 0x0306, 0x0308, 0x0308,
- 0x030a, 0x030a, 0x030c, 0x030c, 0x030e, 0x030e, 0x0310, 0x0310,
- 0x0312, 0x0312, 0x0314, 0x0314, 0x0316, 0x0316, 0x0318, 0x0318,
- 0x031a, 0x031a, 0x031c, 0x031c, 0x031e, 0x031e, 0x0320, 0x0320,
- 0x0322, 0x0322, 0x0324, 0x0324, 0x0326, 0x0326, 0x0328, 0x0328,
- 0x032a, 0x032a, 0x032c, 0x032c, 0x032e, 0x032e, 0x0330, 0x0330,
- 0x0332, 0x0332, 0x0334, 0x0334, 0x0336, 0x0336, 0x0338, 0x0338,
- 0x033a, 0x033a, 0x033c, 0x033c, 0x033e, 0x033e, 0x0340, 0x0340,
- 0x0342, 0x0342, 0x0344, 0x0344, 0x0346, 0x0346, 0x0348, 0x0348,
- 0x034a, 0x034a, 0x034c, 0x034c, 0x034e, 0x034e, 0x0350, 0x0350,
- 0x0352, 0x0352, 0x0354, 0x0354, 0x0356, 0x0356, 0x0358, 0x0358,
- 0x035a, 0x035a, 0x035c, 0x035c, 0x035e, 0x035e, 0x0360, 0x0360,
- 0x0362, 0x0362, 0x0364, 0x0364, 0x0366, 0x0366, 0x0368, 0x0368,
- 0x036a, 0x036a, 0x036c, 0x036c, 0x036e, 0x036e, 0x0370, 0x0370,
- 0x0372, 0x0372, 0x0374, 0x0374, 0x0376, 0x0376, 0x0378, 0x0378,
- 0x037a, 0x037a, 0x037c, 0x037c, 0x037e, 0x037e, 0x0380, 0x0380,
- 0x0382, 0x0382, 0x0384, 0x0384, 0x0386, 0x0386, 0x0388, 0x0388,
- 0x038a, 0x038a, 0x038c, 0x038c, 0x038e, 0x038e, 0x0390, 0x0390,
- 0x0392, 0x0392, 0x0394, 0x0394, 0x0396, 0x0396, 0x0398, 0x0398,
- 0x039a, 0x039a, 0x039c, 0x039c, 0x039e, 0x039e, 0x03a0, 0x03a0,
- 0x03a2, 0x03a2, 0x03a4, 0x03a4, 0x03a6, 0x03a6, 0x03a8, 0x03a8,
- 0x03aa, 0x03aa, 0x03ac, 0x03ac, 0x03ae, 0x03ae, 0x03b0, 0x03b0,
- 0x03b2, 0x03b2, 0x03b4, 0x03b4, 0x03b6, 0x03b6, 0x03b8, 0x03b8,
- 0x03ba, 0x03ba, 0x03bc, 0x03bc, 0x03be, 0x03be, 0x03c0, 0x03c0,
- 0x03c2, 0x03c2, 0x03c4, 0x03c4, 0x03c6, 0x03c6, 0x03c8, 0x03c8,
- 0x03ca, 0x03ca, 0x03cc, 0x03cc, 0x03ce, 0x03ce, 0x03d0, 0x03d0,
- 0x03d2, 0x03d2, 0x03d4, 0x03d4, 0x03d6, 0x03d6, 0x03d8, 0x03d8,
- 0x03da, 0x03da, 0x03dc, 0x03dc, 0x03de, 0x03de, 0x03e0, 0x03e0,
- 0x03e2, 0x03e2, 0x03e4, 0x03e4, 0x03e6, 0x03e6, 0x03e8, 0x03e8,
- 0x03ea, 0x03ea, 0x03ec, 0x03ec, 0x03ee, 0x03ee, 0x03f0, 0x03f0,
- 0x03f2, 0x03f2, 0x03f4, 0x03f4, 0x03f6, 0x03f6, 0x03f8, 0x03f8,
- 0x03fa, 0x03fa, 0x03fc, 0x03fc, 0x03fe, 0x03fe, 0x0400, 0x0400,
- 0x0402, 0x0402, 0x0404, 0x0404, 0x0406, 0x0406, 0x0408, 0x0408,
- 0x040a, 0x040a, 0x040c, 0x040c, 0x040e, 0x040e, 0x0410, 0x0410,
- 0x0412, 0x0412, 0x0414, 0x0414, 0x0416, 0x0416, 0x0418, 0x0418,
- 0x041a, 0x041a, 0x041c, 0x041c, 0x041e, 0x041e, 0x0420, 0x0420,
- 0x0422, 0x0422, 0x0424, 0x0424, 0x0426, 0x0426, 0x0428, 0x0428,
- 0x042a, 0x042a, 0x042c, 0x042c, 0x042e, 0x042e, 0x0430, 0x0430,
- 0x0432, 0x0432, 0x0434, 0x0434, 0x0436, 0x0436, 0x0438, 0x0438,
- 0x043a, 0x043a, 0x043c, 0x043c, 0x043e, 0x043e, 0x0440, 0x0440,
- 0x0442, 0x0442, 0x0444, 0x0444, 0x0446, 0x0446, 0x0448, 0x0448,
- 0x044a, 0x044a, 0x044c, 0x044c, 0x044e, 0x044e, 0x0450, 0x0450,
- 0x0452, 0x0452, 0x0454, 0x0454, 0x0456, 0x0456, 0x0458, 0x0458,
- 0x045a, 0x045a, 0x045c, 0x045c, 0x045e, 0x045e, 0x0460, 0x0460,
- 0x0462, 0x0462, 0x0464, 0x0464, 0x0466, 0x0466, 0x0468, 0x0468,
- 0x046a, 0x046a, 0x046c, 0x046c, 0x046e, 0x046e, 0x0470, 0x0470,
- 0x0472, 0x0472, 0x0474, 0x0474, 0x0476, 0x0476, 0x0478, 0x0478,
- 0x047a, 0x047a, 0x047c, 0x047c, 0x047e, 0x047e, 0x0480, 0x0480,
- 0x0482, 0x0482, 0x0484, 0x0484, 0x0486, 0x0486, 0x0488, 0x0488,
- 0x048a, 0x048a, 0x048c, 0x048c, 0x048e, 0x048e, 0x0490, 0x0490,
- 0x0492, 0x0492, 0x0494, 0x0494, 0x0496, 0x0496, 0x0498, 0x0498,
- 0x049a, 0x049a, 0x049c, 0x049c, 0x049e, 0x049e, 0x04a0, 0x04a0,
- 0x04a2, 0x04a2, 0x04a4, 0x04a4, 0x04a6, 0x04a6, 0x04a8, 0x04a8,
- 0x04aa, 0x04aa, 0x04ac, 0x04ac, 0x04ae, 0x04ae, 0x04b0, 0x04b0,
- 0x04b2, 0x04b2, 0x04b4, 0x04b4, 0x04b6, 0x04b6, 0x04b8, 0x04b8,
- 0x04ba, 0x04ba, 0x04bc, 0x04bc, 0x04be, 0x04be, 0x04c0, 0x04c0,
- 0x04c2, 0x04c2, 0x04c4, 0x04c4, 0x04c6, 0x04c6, 0x04c8, 0x04c8,
- 0x04ca, 0x04ca, 0x04cc, 0x04cc, 0x04ce, 0x04ce, 0x04d0, 0x04d0,
- 0x04d2, 0x04d2, 0x04d4, 0x04d4, 0x04d6, 0x04d6, 0x04d8, 0x04d8,
- 0x04da, 0x04da, 0x04dc, 0x04dc, 0x04de, 0x04de, 0x04e0, 0x04e0,
- 0x04e2, 0x04e2, 0x04e4, 0x04e4, 0x04e6, 0x04e6, 0x04e8, 0x04e8,
- 0x04ea, 0x04ea, 0x04ec, 0x04ec, 0x04ee, 0x04ee, 0x04f0, 0x04f0,
- 0x04f2, 0x04f2, 0x04f4, 0x04f4, 0x04f6, 0x04f6, 0x04f8, 0x04f8,
- 0x04fa, 0x04fa, 0x04fc, 0x04fc, 0x04fe, 0x04fe, 0x0500, 0x0500,
- 0x0000
-};
-
-const uint16_t table_484538[322] = {
- 0x0000, 0x0002, 0x0004, 0x0006, 0x0008, 0x000a, 0x000c, 0x000e,
- 0x0010, 0x0012, 0x0014, 0x0016, 0x0018, 0x001a, 0x001c, 0x001e,
- 0x0020, 0x0022, 0x0024, 0x0026, 0x0028, 0x002a, 0x002c, 0x002e,
- 0x0030, 0x0032, 0x0034, 0x0036, 0x0038, 0x003a, 0x003c, 0x003e,
- 0x0040, 0x0042, 0x0044, 0x0046, 0x0048, 0x004a, 0x004c, 0x004e,
- 0x0050, 0x0052, 0x0054, 0x0056, 0x0058, 0x005a, 0x005c, 0x005e,
- 0x0060, 0x0062, 0x0064, 0x0066, 0x0068, 0x006a, 0x006c, 0x006e,
- 0x0070, 0x0072, 0x0074, 0x0076, 0x0078, 0x007a, 0x007c, 0x007e,
- 0x0080, 0x0082, 0x0084, 0x0086, 0x0088, 0x008a, 0x008c, 0x008e,
- 0x0090, 0x0092, 0x0094, 0x0096, 0x0098, 0x009a, 0x009c, 0x009e,
- 0x00a0, 0x00a2, 0x00a4, 0x00a6, 0x00a8, 0x00aa, 0x00ac, 0x00ae,
- 0x00b0, 0x00b2, 0x00b4, 0x00b6, 0x00b8, 0x00ba, 0x00bc, 0x00be,
- 0x00c0, 0x00c2, 0x00c4, 0x00c6, 0x00c8, 0x00ca, 0x00cc, 0x00ce,
- 0x00d0, 0x00d2, 0x00d4, 0x00d6, 0x00d8, 0x00da, 0x00dc, 0x00de,
- 0x00e0, 0x00e2, 0x00e4, 0x00e6, 0x00e8, 0x00ea, 0x00ec, 0x00ee,
- 0x00f0, 0x00f2, 0x00f4, 0x00f6, 0x00f8, 0x00fa, 0x00fc, 0x00fe,
- 0x0100, 0x0102, 0x0104, 0x0106, 0x0108, 0x010a, 0x010c, 0x010e,
- 0x0110, 0x0112, 0x0114, 0x0116, 0x0118, 0x011a, 0x011c, 0x011e,
- 0x0120, 0x0122, 0x0124, 0x0126, 0x0128, 0x012a, 0x012c, 0x012e,
- 0x0130, 0x0132, 0x0134, 0x0136, 0x0138, 0x013a, 0x013c, 0x013e,
- 0x0140, 0x0142, 0x0144, 0x0146, 0x0148, 0x014a, 0x014c, 0x014e,
- 0x0150, 0x0152, 0x0154, 0x0156, 0x0158, 0x015a, 0x015c, 0x015e,
- 0x0160, 0x0162, 0x0164, 0x0166, 0x0168, 0x016a, 0x016c, 0x016e,
- 0x0170, 0x0172, 0x0174, 0x0176, 0x0178, 0x017a, 0x017c, 0x017e,
- 0x0180, 0x0182, 0x0184, 0x0186, 0x0188, 0x018a, 0x018c, 0x018e,
- 0x0190, 0x0192, 0x0194, 0x0196, 0x0198, 0x019a, 0x019c, 0x019e,
- 0x01a0, 0x01a2, 0x01a4, 0x01a6, 0x01a8, 0x01aa, 0x01ac, 0x01ae,
- 0x01b0, 0x01b2, 0x01b4, 0x01b6, 0x01b8, 0x01ba, 0x01bc, 0x01be,
- 0x01c0, 0x01c2, 0x01c4, 0x01c6, 0x01c8, 0x01ca, 0x01cc, 0x01ce,
- 0x01d0, 0x01d2, 0x01d4, 0x01d6, 0x01d8, 0x01da, 0x01dc, 0x01de,
- 0x01e0, 0x01e2, 0x01e4, 0x01e6, 0x01e8, 0x01ea, 0x01ec, 0x01ee,
- 0x01f0, 0x01f2, 0x01f4, 0x01f6, 0x01f8, 0x01fa, 0x01fc, 0x01fe,
- 0x0200, 0x0202, 0x0204, 0x0206, 0x0208, 0x020a, 0x020c, 0x020e,
- 0x0210, 0x0212, 0x0214, 0x0216, 0x0218, 0x021a, 0x021c, 0x021e,
- 0x0220, 0x0222, 0x0224, 0x0226, 0x0228, 0x022a, 0x022c, 0x022e,
- 0x0230, 0x0232, 0x0234, 0x0236, 0x0238, 0x023a, 0x023c, 0x023e,
- 0x0240, 0x0242, 0x0244, 0x0246, 0x0248, 0x024a, 0x024c, 0x024e,
- 0x0250, 0x0252, 0x0254, 0x0256, 0x0258, 0x025a, 0x025c, 0x025e,
- 0x0260, 0x0262, 0x0264, 0x0266, 0x0268, 0x026a, 0x026c, 0x026e,
- 0x0270, 0x0272, 0x0274, 0x0276, 0x0278, 0x027a, 0x027c, 0x027e,
- 0x0280, 0x0000
-};
-
-struct {
- uint16_t tab1[642]; /* 0x4847bc, from 0x483630 */
- uint16_t tab2[641]; /* 0x484cc0, from 0x483b34 */
- uint16_t tab3[641]; /* 0x4851c2, from 0x484036 */
- uint16_t tab4[322]; /* 0x4856c4, from 0x484538 */
-} gtables; /* 0x4847bc */
-
-void fcn_00455040(char *arg1, char *arg2)
-{
- uint16_t bx;
- uint32_t eax, ecx;
-#if 0
- memcpy(&gtables, 0x483630, 4492);
-#else
- memcpy(gtables.tab1, table_483630, sizeof(table_483630));
- memcpy(gtables.tab2, table_483b34, sizeof(table_483b34));
- memcpy(gtables.tab3, table_484036, sizeof(table_484036));
- memcpy(gtables.tab4, table_484538, sizeof(table_484538));
-#endif
- ecx = 0; /* after a rep movsd */
- char *edi = arg1;
- char *esi = arg2;
-
- while (1) {
- fcn_004551bb(esi, &ecx, &bx); /* this function changes bx, ecx for return value */
- if ((bx & 0xff00) == 0) {
- *edi = bx & 0xff;
- edi++;
- continue;
- }
- eax = ecx;
- uint32_t old_ecx = ecx;/* push ecx */
- eax <<= 3;
- ecx &= 7;
- eax = *(int32_t*)(esi + eax);
- eax >>= ecx;
- size_t ebp = eax & 0xff;
- uint8_t cl = table_00483530[ebp];
- uint8_t dh = table_00483430[ebp];
- eax >>= cl;
- uint8_t dl = eax << 2;
- uint16_t dx = (((uint16_t)dh << 8) | dl) >> 2;
- cl += 6;
- eax = cl;
- /* pop ecx */
- ecx = old_ecx + eax;
- if (dx == 0xfff)
- return;
- old_ecx = ecx; /* backup ecx */
- bx -= 0xfd;
- char *old_esi = esi; /* push esi */
- esi = edi - 1 - dx;
- memcpy(edi, esi, bx); /* using rep movsb */
- edi += bx; /* by movsb */
- esi = old_esi; /* pop esi */
- ecx = old_ecx; /* restore ecx */
- }
-}
-
-/* unknown ABI */
-/*
-argument: esi, ecx
-changes ebx, ecx
-doesn't change edi
-*/
-void fcn_004551bb(uint16_t *esi, uint32_t *ecx, uint16_t *ret_bx)
-{
- uint16_t bx = 0x500;
-
- while (1) {
- /* 0x484cc0-0x4847bc = 0x504 */
- /* initial value: [0x483630+0x504+0x500] = 0x4fc */
- bx = gtables.tab2[bx / 2];
-
- if (bx >= 0x502)
- break;
-#if BT
- bool cf = bittest(esi, ecx); /* bt dword [esi], ecx */
-#else
- uint32_t _ecx = *ecx;
- uint16_t cf = esi[_ecx / 16] & (1 << (_ecx % 16));
-#endif
- (*ecx)++;
- if (cf) {
- bx += 2;
- }
- }
-
- bx -= 0x502;
- /* push ebx, ecx, edi */
- fcn_00455109(bx);
- /* pop edi, ecx, ebx */
- bx >>= 1;
- *ret_bx = bx;
-}
-
-/* unknown ABI */
-/* argument: ebx, changes eax, ebx, ecx, edi */
-void fcn_00455109(size_t ebx)
-{
- if (gtables.tab1[640] == 0x8000) {
- /* push ebx */
- fcn_004550cc();
- /* pop ebx */
- }
- fcn_0045511b(ebx);
-}
-
-/* unknown ABI */
-/* argument: ebx, changes eax,edi,ecx,ebx */
-void fcn_0045511b(size_t ebx)
-{
- uint16_t ax, cx, tmp;
- size_t edi;
- /* actually the high 16 bits of ebx is 0 */
- ebx = gtables.tab4[ebx / 2];
- do {
- gtables.tab1[ebx / 2]++;
- ax = gtables.tab1[ebx / 2];
- if (ax > gtables.tab1[ebx / 2 + 1]) {
- uint16_t *ptr = &gtables.tab1[ebx / 2 + 1];
- int ecx = 0x282;
- ax--;
- while (ecx-- && *ptr == ax)
- ptr ++;
-
- edi = (ptr - &gtables.tab1[2]) * sizeof(uint16_t);
-
- ax++;
-
- /* note that edi may equal to ebx,
- there's some trap to convert the swap to mov
- */
-#ifdef XCHG
- swap(gtables.tab1[edi / 2], ax);
- gtables.tab1[ebx / 2] = ax;
-#else
- if (edi != ebx) {
- gtables.tab1[ebx / 2] = gtables.tab1[edi / 2];
- gtables.tab1[edi / 2] = ax;
- }
-#endif
-
- ax = gtables.tab2[ebx / 2];
- cx = gtables.tab2[edi / 2];
-
- if (cx < 0x502) {
- gtables.tab3[ecx / 2] = ebx;
- gtables.tab3[ecx / 2 + 1] = ebx;
- } else {
- gtables.tab4[(ecx - 0x502) / 2] = ebx;
- }
-
-#if 0
- swap(ax, cx);
-#else
- tmp = ax;
- ax = cx;
- cx = tmp;
-#endif
-
- if (cx < 0x502) {
- gtables.tab3[ecx / 2] = edi;
- gtables.tab3[ecx / 2 + 1] = edi;
- } else {
- gtables.tab4[(ecx - 0x502) / 2] = edi;
- }
-
- gtables.tab2[ebx / 2] = ax;
- gtables.tab2[edi / 2] = cx;
- ebx = edi;
- }
-
- ebx = gtables.tab3[ebx / 2];
- } while (ebx != 0);
-
- return;
-}
-
-/* unknown ABI */
-/* no argument, changes ebx, ecx, edx, ebp */
-void fcn_004550cc()
-{
- uint16_t cx;
- size_t ebp = 0;
- int edx = 0x141;
- do {
- cx = gtables.tab4[ebp/2]; /* 0x4856c4 + 0x141 * 2 = 0x485946 */
- /* assert((cx % 2) == 0) */
- if (gtables.tab1[cx/2] & 1) {
- fcn_0045511b(ebp);
- }
- ebp += 2;
- edx--;
- } while(edx);
- for (size_t i = 0; i < 0x502; i += 2) {
- gtables.tab1[i/2] >>= 1;
- }
- return;
-}
-
diff --git a/csrc/mkf_asm.asm b/csrc/mkf_asm.asm
deleted file mode 100644
index 7a5d0b6..0000000
--- a/csrc/mkf_asm.asm
+++ /dev/null
@@ -1,88 +0,0 @@
-section .text
-global fcn_00455040
-extern table_483430
-extern table_483530
-extern data_483630
-extern gtables
-extern cfcn_45511b
-extern cfcn_004550cc
-extern cfcn_00455109
-extern cfcn_004551bb
-extern cfcn_00455040
-
-fcn_00455040:
-jmp cfcn_00455040
-push ebp
-mov ebp, esp
-push ebx
-push ecx
-push esi
-push edi
-sub esp, 8
-mov esi, data_483630
-mov edi, gtables
-mov ecx, 0x463 ; 1123
-rep movsd
-mov edi, dword [ebp + 8] ; [0x8:4]=-1 ; 8
-mov esi, dword [ebp + 0xc] ; [0xc:4]=-1 ; 12
-xor edx, edx
-
-L0:
-
-mov [esp+4], ebx
-mov [esp], ecx
-lea eax, [esp+4]
-push eax
-lea eax, [esp+4]
-push eax
-push esi
-call cfcn_004551bb
-add esp, 12
-mov ecx, [esp]
-mov ebx, [esp+4]
-
-or bh, bh
-jne L1
-mov byte [edi], bl
-inc edi
-jmp L0
-L1:
-mov eax, ecx
-push ecx
-shr eax, 3
-and ecx, 7
-mov eax, dword [esi + eax]
-shr eax, cl
-mov ebp, eax
-and ebp, 0xff
-mov cl, byte [ebp + table_483530]
-mov dh, byte [ebp + table_483430]
-shr eax, cl
-mov dl, al
-shl dl, 2
-shr dx, 2
-add cl, 6
-mov eax, ecx
-and eax, 0xff
-pop ecx
-add ecx, eax
-cmp dx, 0xfff
-je L2
-mov ebp, ecx
-sub ebx, 0xfd
-push esi
-lea esi, [edi - 1]
-sub esi, edx
-mov ecx, ebx
-rep movsb
-pop esi
-mov ecx, ebp
-jmp L0
-L2:
-add esp, 8
-pop edi
-pop esi
-pop ecx
-pop ebx
-pop ebp
-ret
diff --git a/csrc/mkf_asm_data.c b/csrc/mkf_decompress.c
index 555f861..ea9ac4f 100644
--- a/csrc/mkf_asm_data.c
+++ b/csrc/mkf_decompress.c
@@ -520,7 +520,7 @@ struct {
uint16_t tab4[322]; /* 0x4856c4, from 0x484538 */
} gtables; /* 0x4847bc */
-void cfcn_45511b(uint32_t ebx)
+static void cfcn_45511b(uint32_t ebx)
{
uint16_t ax, cx, tmp;
ebx = gtables.tab4[ebx / 2];
@@ -575,14 +575,13 @@ void cfcn_45511b(uint32_t ebx)
} while (ebx);
}
-void cfcn_004550cc()
+static void cfcn_004550cc()
{
uint16_t cx;
size_t ebp = 0;
int edx = 0x141;
do {
- cx = gtables.tab4[ebp/2]; /* 0x4856c4 + 0x141 * 2 = 0x485946 */
- /* assert((cx % 2) == 0) */
+ cx = gtables.tab4[ebp/2];
if (gtables.tab1[cx/2] & 1) {
cfcn_45511b(ebp);
}
@@ -595,7 +594,7 @@ void cfcn_004550cc()
return;
}
-void cfcn_00455109(uint32_t ebx)
+static void cfcn_00455109(uint32_t ebx)
{
if (gtables.tab1[640] == 0x8000) {
cfcn_004550cc();
@@ -603,7 +602,7 @@ void cfcn_00455109(uint32_t ebx)
cfcn_45511b(ebx);
}
-void cfcn_004551bb(uint16_t *esi, uint32_t *ecx, uint32_t *ebx)
+static void cfcn_004551bb(uint16_t *esi, uint32_t *ecx, uint32_t *ebx)
{
uint16_t bx = 0x500;
@@ -629,16 +628,15 @@ void cfcn_004551bb(uint16_t *esi, uint32_t *ecx, uint32_t *ebx)
*ebx = bx;
}
-void cfcn_00455040(void *arg1, void *arg2)
+void mkf_decompress(void *arg1, void *arg2)
{
uint32_t bx;
- uint32_t eax, ecx, edx;
+ uint32_t eax, ecx;
memcpy(&gtables, data_483630, sizeof(gtables));
- ecx = 0; /* after a rep movsd */
+ ecx = 0;
void *edi = arg1;
void *esi = arg2;
- edx = 0;
while (1) {
cfcn_004551bb(esi, &ecx, &bx);
@@ -648,7 +646,7 @@ void cfcn_00455040(void *arg1, void *arg2)
continue;
}
eax = ecx;
- uint32_t old_ecx = ecx;/* push ecx */
+ uint32_t old_ecx = ecx;
eax >>= 3;
ecx &= 7;
eax = *(uint32_t*)(esi + eax);
@@ -661,13 +659,12 @@ void cfcn_00455040(void *arg1, void *arg2)
uint16_t dx = (((uint16_t)dh << 8) | dl) >> 2;
cl += 6;
eax = cl;
- /* pop ecx */
ecx = old_ecx + eax;
if (dx == 0xfff)
return;
- old_ecx = ecx; /* backup ecx */
+ old_ecx = ecx;
bx -= 0xfd;
- void *old_esi = esi; /* push esi */
+ void *old_esi = esi;
esi = edi - 1 - dx;
/* the following is a little bit tricky,
@@ -685,7 +682,7 @@ void cfcn_00455040(void *arg1, void *arg2)
memmove(edi, esi, bx); /* using rep movsb */
edi += bx; /* by movsb */
#endif
- esi = old_esi; /* pop esi */
- ecx = old_ecx; /* restore ecx */
+ esi = old_esi;
+ ecx = old_ecx;
}
}
diff --git a/csrc/test/dump_600.c b/csrc/test/dump_600.c
index 99d224a..147de87 100644
--- a/csrc/test/dump_600.c
+++ b/csrc/test/dump_600.c
@@ -1,4 +1,4 @@
-/* gcc -m32 -I.. dump_600.c ../mkf.c ../mkf_00455040.c -o dump_600 */
+/* gcc -m32 -I.. dump_600.c ../libmkf.a -o dump_600 */
/* copy Data.mkf and run this, open loading.data with GIMP,
* data type is RGB565 little endian, size 165*256, it's a tortoise card! */