mirror of
https://github.com/perfect-dark-pc-port/perfect_dark.git
synced 2026-10-23 15:52:41 +02:00
portx64: pd-extract setups: a few bug fixes and changed how lists are copied
- moved ptrmarkers out of ext_file_bg to common - function to get ailist length
This commit is contained in:
1 parent
844d6c7ec8
commit
373f08ca3e
4 files changed
+58
-36
No files matched your search
@@ -0,0 +1,33 @@
|
||||
#include "common.h"
|
||||
#include "system.h"
|
||||
|
||||
struct ptrmarker m_PtrMarkers[2048];
|
||||
int m_NumPtrMarkers;
|
||||
|
||||
void add_marker(u32 ptr_src, uintptr_t ptr_host)
|
||||
{
|
||||
if (m_NumPtrMarkers >= ARRAYCOUNT(m_PtrMarkers)) {
|
||||
sysLogPrintf(LOG_ERROR, "[BG] Marker limit exceeded");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
m_PtrMarkers[m_NumPtrMarkers].ptr_src = ptr_src;
|
||||
m_PtrMarkers[m_NumPtrMarkers].ptr_host = ptr_host;
|
||||
m_NumPtrMarkers++;
|
||||
}
|
||||
|
||||
struct ptrmarker* find_marker(uintptr_t ptr_src)
|
||||
{
|
||||
for (int i = 0; i < m_NumPtrMarkers; i++) {
|
||||
if (m_PtrMarkers[i].ptr_src == ptr_src) {
|
||||
return &m_PtrMarkers[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void reset_markers()
|
||||
{
|
||||
m_NumPtrMarkers = 0;
|
||||
}
|
||||
@@ -77,4 +77,13 @@ void gbi_convert_vtx(uint8_t* dst, uint32_t dstpos, int count);
|
||||
void gbi_gdl_rewrite_addrs(uint8_t* dst, uint32_t offset);
|
||||
void gbi_add_tex_addr(uint32_t src_offset, uint32_t dst_offset);
|
||||
|
||||
struct ptrmarker {
|
||||
u32 ptr_src;
|
||||
uintptr_t ptr_host;
|
||||
};
|
||||
|
||||
void add_marker(u32 ptr_src, uintptr_t ptr_host);
|
||||
struct ptrmarker* find_marker(uintptr_t ptr_src);
|
||||
void reset_markers();
|
||||
|
||||
#endif
|
||||
@@ -6,44 +6,8 @@
|
||||
#include "system.h"
|
||||
#include "platform.h"
|
||||
|
||||
struct ptrmarker {
|
||||
u32 ptr_src;
|
||||
uintptr_t ptr_host;
|
||||
};
|
||||
|
||||
|
||||
struct ptrmarker m_PtrMarkers[2048];
|
||||
int m_NumPtrMarkers;
|
||||
int m_SizeGDLs;
|
||||
|
||||
static void add_marker(u32 ptr_src, uintptr_t ptr_host)
|
||||
{
|
||||
if (m_NumPtrMarkers >= ARRAYCOUNT(m_PtrMarkers)) {
|
||||
sysLogPrintf(LOG_ERROR, "[BG] Marker limit exceeded");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
m_PtrMarkers[m_NumPtrMarkers].ptr_src = ptr_src;
|
||||
m_PtrMarkers[m_NumPtrMarkers].ptr_host = ptr_host;
|
||||
m_NumPtrMarkers++;
|
||||
}
|
||||
|
||||
static struct ptrmarker* find_marker(uintptr_t ptr_src)
|
||||
{
|
||||
for (int i = 0; i < m_NumPtrMarkers; i++) {
|
||||
if (m_PtrMarkers[i].ptr_src == ptr_src) {
|
||||
return &m_PtrMarkers[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void reset_markers()
|
||||
{
|
||||
m_NumPtrMarkers = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 4 bytes decompressed size of primary data
|
||||
* 4 bytes compressed size of section 1 in its entirety
|
||||
|
||||
@@ -814,3 +814,19 @@ u32 chraiGetCommandLength(u8 *ailist, u32 aioffset)
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// used by ext_setup
|
||||
u32 chraiGetAilistLength(u8* list)
|
||||
{
|
||||
if (!list) return 0;
|
||||
|
||||
u8* cmd = list;
|
||||
|
||||
while (true) {
|
||||
u8 type = cmd[1];
|
||||
cmd += chraiGetCommandLength(cmd, 0);
|
||||
if (type == AICMD_END) break;
|
||||
}
|
||||
|
||||
return (u32)(cmd - list);
|
||||
}
|
||||
Reference in new issue
Block a user