summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-10-01 21:38:19 +0800
committerIru Cai <mytbk920423@gmail.com>2018-10-01 21:38:19 +0800
commit6736d6764ba2541eeaa48b45b002acadb20b9b05 (patch)
tree61a6814db04e2550379e1fbbfd5e4a419c682af9
parent63d7007905047e5f488e179a56d861dfaa17aa90 (diff)
downloadrich4-6736d6764ba2541eeaa48b45b002acadb20b9b05.tar.xz
mkf uses graph_st
-rw-r--r--csrc/mkf/graph_struct.c (renamed from csrc/graph_struct.c)0
-rw-r--r--csrc/mkf/graph_struct.h (renamed from csrc/graph_struct.h)0
-rw-r--r--csrc/mkf/mkf.c30
-rw-r--r--csrc/mkf/mkf.h10
4 files changed, 14 insertions, 26 deletions
diff --git a/csrc/graph_struct.c b/csrc/mkf/graph_struct.c
index 52aa207..52aa207 100644
--- a/csrc/graph_struct.c
+++ b/csrc/mkf/graph_struct.c
diff --git a/csrc/graph_struct.h b/csrc/mkf/graph_struct.h
index 4859508..4859508 100644
--- a/csrc/graph_struct.h
+++ b/csrc/mkf/graph_struct.h
diff --git a/csrc/mkf/mkf.c b/csrc/mkf/mkf.c
index 63e7e2d..9a7e5aa 100644
--- a/csrc/mkf/mkf.c
+++ b/csrc/mkf/mkf.c
@@ -72,28 +72,22 @@ void unload_mkf(int mkf_idx)
static void update_spr_smp_ptr(void *s)
{
struct spr_smp *sst = (struct spr_smp*)s;
- int lastsz;
+ size_t lastsz;
if (strcmp(sst->sig, "SPR") == 0) {
- lastsz = sst->chunk_tab[0].chunk_sz;
- sst->chunk_tab[0].chunk_sz = (int32_t)s + sst->start_offset + 0x200;
-
- for (int i = 1; i < sst->nchunk; i++) {
- int t = sst->chunk_tab[i].chunk_sz;
- sst->chunk_tab[i].chunk_sz = lastsz + sst->chunk_tab[i-1].chunk_sz;
- lastsz = t;
- }
+ lastsz = (size_t)(sst->chunk_tab[0].gdata);
+ sst->chunk_tab[0].gdata = (int16_t*)(s + sst->start_offset + 0x200);
+ } else if (strcmp(sst->sig, "SMP") == 0) {
+ lastsz = (size_t)(sst->chunk_tab[0].gdata);
+ sst->chunk_tab[0].gdata = (int16_t*)(s + sst->start_offset);
+ } else {
+ return;
}
- if (strcmp(sst->sig, "SMP") == 0) {
- lastsz = sst->chunk_tab[0].chunk_sz;
- sst->chunk_tab[0].chunk_sz = (int32_t)s + sst->start_offset;
-
- for (int i = 1; i < sst->nchunk; i++) {
- int t = sst->chunk_tab[i].chunk_sz;
- sst->chunk_tab[i].chunk_sz = lastsz + sst->chunk_tab[i-1].chunk_sz;
- lastsz = t;
- }
+ for (int i = 1; i < sst->nchunk; i++) {
+ size_t t = (size_t)(sst->chunk_tab[i].gdata);
+ sst->chunk_tab[i].gdata = (int16_t*)((void*)(sst->chunk_tab[i-1].gdata) + lastsz);
+ lastsz = t;
}
}
diff --git a/csrc/mkf/mkf.h b/csrc/mkf/mkf.h
index ef1fa38..f42d709 100644
--- a/csrc/mkf/mkf.h
+++ b/csrc/mkf/mkf.h
@@ -1,4 +1,5 @@
#include <stdint.h>
+#include "graph_struct.h"
int load_mkf(const char *fn);
void unload_mkf(int mkf_idx);
@@ -11,12 +12,5 @@ struct spr_smp
char sig[4]; /* "SPR" or "SMP" */
int32_t nchunk;
int32_t start_offset;
- int32_t t3, t4; /* unused? */
- struct {
- /* in the file, it's the chunk size,
- * after read_mkf(), it becomes the start address */
- int32_t chunk_sz;
- int32_t v2, v3; /* unused? */
- } chunk_tab[0];
+ struct graph_st chunk_tab[0];
};
-