Skip to content

Commit e04e01e

Browse files
committed
overlrd2: start
1 parent 9aa2913 commit e04e01e

File tree

13 files changed

+331
-0
lines changed

13 files changed

+331
-0
lines changed

game/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ set(RUNTIME_SOURCE
223223
overlord/jak2/streamlfo.cpp
224224
overlord/jak2/streamlist.cpp
225225
overlord/jak2/vag.cpp
226+
overlord/jak3/start.cpp
227+
overlord/jak3/overlord.cpp
228+
overlord/jak3/sbank.cpp
229+
overlord/jak3/ssound.cpp
230+
overlord/jak3/vblank_handler.cpp
226231
runtime.cpp
227232
sce/deci2.cpp
228233
sce/iop.cpp

game/overlord/jak3/basefile.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef BASEFILE_H_
2+
#define BASEFILE_H_
3+
4+
#include "game/overlord/jak3/iso_structs.h"
5+
#include "game/overlord/jak3/overlord.h"
6+
7+
namespace jak3 {
8+
class CBaseFile {
9+
public:
10+
CBaseFile(const ISOFileDef*);
11+
virtual EIsoStatus BeginRead(ISOBuffer*) = 0;
12+
virtual EIsoStatus SyncRead() = 0;
13+
virtual void Close() = 0;
14+
15+
/* unk return values */
16+
virtual void Unk1() = 0;
17+
virtual void Unk2() = 0;
18+
};
19+
} // namespace jak3
20+
21+
#endif // BASEFILE_H_
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef BASEFILESYSTEM_H_
2+
#define BASEFILESYSTEM_H_
3+
4+
#include "game/overlord/jak3/iso_structs.h"
5+
6+
namespace jak3 {
7+
class CBaseFileSystem {
8+
public:
9+
virtual void Init() = 0;
10+
virtual void PollDrive() = 0;
11+
virtual const ISOFileDef* Find(const char* name) = 0;
12+
virtual const ISOFileDef* FindIN(const char* name) = 0;
13+
virtual int GetLength(const ISOFileDef* def) = 0;
14+
virtual int Open(const ISOFileDef* def, int offset, EFileComp mode) = 0;
15+
virtual int OpenWad(const ISOFileDef* def, int offset) = 0;
16+
virtual VagDirEntryJak3* FindVagFile(const char* name) = 0;
17+
};
18+
} // namespace jak3
19+
20+
#endif // BASEFILESYSTEM_H_

game/overlord/jak3/iso_structs.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef ISO_STRUCTS_H_
2+
#define ISO_STRUCTS_H_
3+
4+
#include "common/common_types.h"
5+
6+
namespace jak3 {
7+
/* TODO check values */
8+
enum class EFileComp { MODE0, MODE1, KNOWN_NOT_BLZO };
9+
10+
struct VagDirEntryJak3 {
11+
union {
12+
u64 data;
13+
struct {
14+
u64 name : 42;
15+
bool stereo : 1;
16+
bool international : 1;
17+
u8 param : 4;
18+
u64 offset : 16;
19+
};
20+
};
21+
};
22+
23+
struct VagDirJak3 {
24+
u32 id[2];
25+
u32 version;
26+
u32 count;
27+
VagDirEntryJak3 entries[0];
28+
} dir;
29+
30+
struct VagDirEntry {};
31+
32+
struct ISOBuffer {};
33+
34+
struct ISOFileDef {};
35+
} // namespace jak3
36+
37+
#endif // ISO_STRUCTS_H_

game/overlord/jak3/overlord.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "overlord.h"
2+
3+
#include <cstdint>
4+
#include <cstdio>
5+
#include <cstring>
6+
7+
namespace jak3 {
8+
extern int start_overlord(int, const char* const*);
9+
10+
void Panic() {
11+
printf(
12+
"IOP: *** Overlord panic at 0x%08lx (rel. address 0x%08lx)\n"
13+
"IOP: *** Check mapfile to determine function name.\n"
14+
"IOP: *** Thread halted.\n",
15+
(intptr_t)__builtin_return_address(0),
16+
(intptr_t)__builtin_return_address(0) - (intptr_t)start_overlord);
17+
while (true)
18+
;
19+
}
20+
21+
char* strncpyz(char* dst, const char* src, size_t sz) {
22+
if (sz) {
23+
strncpy(dst, src, sz);
24+
dst[sz - 1] = '\0';
25+
}
26+
27+
return dst;
28+
}
29+
30+
} // namespace jak3

game/overlord/jak3/overlord.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef OVERLORD_H_
2+
#define OVERLORD_H_
3+
4+
#include <cstddef>
5+
6+
namespace jak3 {
7+
enum class EIsoStatus { Unk };
8+
9+
int start_overlord_wrapper(int argc, const char* const* argv, bool* signal);
10+
void Panic();
11+
char* strncpyz(char* dst, const char* src, size_t sz);
12+
13+
void InitSound();
14+
15+
int VBlank_Initialize();
16+
} // namespace jak3
17+
18+
#endif

game/overlord/jak3/pagemanager.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#ifndef PAGEMANAGER_H_
2+
#define PAGEMANAGER_H_
3+
4+
#include "common/common_types.h"
5+
6+
namespace jak3 {
7+
class CPageManager {
8+
public:
9+
class CPage {
10+
public:
11+
CPage(u8*, u8*, int);
12+
int AddRef();
13+
int ReleaseRef();
14+
int AddDmaRef();
15+
int ReleaseDmaRef();
16+
void FromPagesCopy(u8* pInPageData, u8* pDest, int nNumBytes);
17+
};
18+
19+
class CPageList {
20+
int AddActivePages(int);
21+
int CancelActivePages();
22+
CPage* StepActivePage();
23+
void GarbageCollect();
24+
};
25+
26+
void Initialize();
27+
CPageList* AllocPageListBytes(int nBytes, char unk);
28+
CPageList* AllocPageList(int nPages, char unk);
29+
CPageList* GrowPageList(CPageList* list, char nPages);
30+
int FreePageList(CPageList* list);
31+
int Unk(int nUnk);
32+
void GarbageCollect();
33+
34+
private:
35+
class CCache {
36+
public:
37+
int Initialize();
38+
};
39+
CCache m_Cache;
40+
};
41+
42+
} // namespace jak3
43+
44+
#endif // PAGEMANAGER_H_

game/overlord/jak3/ramdisk.cpp

Whitespace-only changes.

game/overlord/jak3/sbank.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include "sbank.h"
2+
3+
#include "overlord.h"
4+
5+
namespace jak3 {
6+
7+
SoundBankInfo gCommonBank, gModeBank;
8+
SoundBankInfo gLevelBanks[6];
9+
10+
SoundBankInfo* gBanks[8] = {
11+
&gCommonBank, &gModeBank, &gLevelBanks[0], &gLevelBanks[1],
12+
&gLevelBanks[2], &gLevelBanks[3], &gLevelBanks[4], &gLevelBanks[5],
13+
};
14+
15+
void InitBanks() {
16+
for (int i = 0; i < 8; i++) {
17+
gBanks[i]->in_use = false;
18+
gBanks[i]->unk = 0;
19+
gBanks[i]->unk2 = 0;
20+
gBanks[i]->index = i;
21+
}
22+
23+
strncpyz(gBanks[0]->slot_name, "common", 16);
24+
gBanks[0]->spu_size = 0xbbe40;
25+
gBanks[0]->spu_loc = 0x1d1c0;
26+
strncpyz(gBanks[1]->slot_name, "mode", 16);
27+
gBanks[1]->spu_size = 0x25400;
28+
gBanks[1]->spu_loc = 0xe0000;
29+
strncpyz(gBanks[2]->slot_name, "level0", 16);
30+
gBanks[2]->spu_size = 0x51400;
31+
gBanks[2]->spu_loc = 0x105400;
32+
strncpyz(gBanks[3]->slot_name, "level0h", 16);
33+
gBanks[3]->spu_size = 0x28a00;
34+
gBanks[3]->spu_loc = 0x12de00;
35+
strncpyz(gBanks[4]->slot_name, "level1", 16);
36+
gBanks[4]->spu_size = 0x51400;
37+
gBanks[4]->spu_loc = 0x156800;
38+
strncpyz(gBanks[5]->slot_name, "level1h", 16);
39+
gBanks[5]->spu_size = 0x28a00;
40+
gBanks[5]->spu_loc = 0x17f200;
41+
strncpyz(gBanks[6]->slot_name, "level2", 16);
42+
gBanks[6]->spu_size = 0x51400;
43+
gBanks[6]->spu_loc = 0x1a7c00;
44+
strncpyz(gBanks[7]->slot_name, "level2h", 16);
45+
gBanks[7]->spu_size = 0x28a00;
46+
gBanks[7]->spu_loc = 0x1d0600;
47+
}
48+
49+
} // namespace jak3

game/overlord/jak3/sbank.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#ifndef SBANK_H_
2+
#define SBANK_H_
3+
4+
#include "common/common_types.h"
5+
6+
namespace jak3 {
7+
struct SoundBankInfo {
8+
char bank_name[16];
9+
char slot_name[16];
10+
u32 spu_loc;
11+
u32 spu_size;
12+
u32 unk;
13+
bool in_use;
14+
u8 unk2;
15+
u8 unk3;
16+
u8 index;
17+
u32 unk4;
18+
};
19+
void InitBanks();
20+
} // namespace jak3
21+
22+
#endif // SBANK_H_

0 commit comments

Comments
 (0)