[jak2] ckernel: implement loado and load_and_link (#3005)

This commit is contained in:
Hat Kid 2023-09-18 12:21:18 +02:00 committed by GitHub
parent 049a8057a8
commit cbbbd661d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 24 deletions

View file

@ -4,6 +4,8 @@
#include <cstdio>
#include <cstring>
#include "fileio.h"
#include "common/common_types.h"
#include "common/global_profiler/GlobalProfiler.h"
#include "common/goal_constants.h"
@ -13,10 +15,8 @@
#include "game/kernel/common/fileio.h"
#include "game/kernel/common/kdsnetm.h"
#include "game/kernel/common/klink.h"
#include "game/kernel/common/kmalloc.h"
#include "game/kernel/common/kmemcard.h"
#include "game/kernel/common/kprint.h"
#include "game/kernel/common/kscheme.h"
#include "game/kernel/jak2/kdgo.h"
#include "game/kernel/jak2/klink.h"
#include "game/kernel/jak2/klisten.h"
@ -1799,11 +1799,20 @@ u64 loadc(const char* /*file_name*/, kheapinfo* /*heap*/, u32 /*flags*/) {
return 0;
}
u64 loado(u32 file_name_in, u32 /*heap_in*/) {
// ASSERT(false);
// NOTE: copied from jak 1
u64 loado(u32 file_name_in, u32 heap_in) {
char loadName[272];
Ptr<String> file_name(file_name_in);
Ptr<kheapinfo> heap(heap_in);
printf("****** CALL TO loado(%s) ******\n", file_name->data());
return s7.offset;
kstrcpy(loadName, MakeFileName(DATA_FILE_TYPE, file_name->data(), 0));
s32 returnValue = load_and_link(file_name->data(), loadName, heap.c(), LINK_FLAG_PRINT_LOGIN);
if (returnValue < 0) {
return s7.offset;
} else {
return returnValue;
}
}
/*!
@ -1814,11 +1823,14 @@ u64 unload(u32 name) {
return 0;
}
s64 load_and_link(const char* /*filename*/,
char* /*decode_name*/,
kheapinfo* /*heap*/,
u32 /*flags*/) {
ASSERT(false);
return 0;
// NOTE: copied from jak 1
s64 load_and_link(const char* filename, char* decode_name, kheapinfo* heap, u32 flags) {
(void)filename;
s32 sz;
auto rv = FileLoad(decode_name, make_ptr(heap), Ptr<u8>(0), KMALLOC_ALIGN_64, &sz);
if (((s32)rv.offset) > -1) {
return (s32)link_and_exec(rv, decode_name, sz, make_ptr(heap), flags, false).offset;
}
return (s32)rv.offset;
}
} // namespace jak2

View file

@ -3,6 +3,7 @@
#include "game/kernel/common/Ptr.h"
#include "game/kernel/common/Symbol4.h"
#include "game/kernel/common/kmalloc.h"
#include "game/kernel/common/kscheme.h"
namespace jak2 {
@ -56,6 +57,7 @@ u64 load(u32 file_name_in, u32 heap_in);
u64 loadb(u32 file_name_in, u32 heap_in, u32 param3);
u64 loado(u32 file_name_in, u32 heap_in);
u64 unload(u32 name);
s64 load_and_link(const char* filename, char* decode_name, kheapinfo* heap, u32 flags);
u64 call_method_of_type(u32 arg, Ptr<Type> type, u32 method_id);
u64 call_goal_function_by_name(const char* name);
u64 alloc_heap_memory(u32 heap, u32 size);

View file

@ -151,19 +151,21 @@ NOTE: this is a special type in three ways:
(format *file-temp-string* "map~D/~S-mp" MAP_FILE_VERSION arg1)
)
((= arg0 (file-kind art-group))
(format
*file-temp-string*
"art-group~D/~S-ag"
(cond
((> arg2 0)
arg2
)
(else
ART_GROUP_FILE_VERSION
)
)
arg1
)
;; og:preserve-this removed art-group prefix
; (format
; *file-temp-string*
; "art-group~D/~S-ag"
; (cond
; ((> arg2 0)
; arg2
; )
; (else
; ART_GROUP_FILE_VERSION
; )
; )
; arg1
; )
(format *file-temp-string* "~S-ag" arg1)
)
)
*file-temp-string*