Compare commits

...

19 Commits

Author SHA1 Message Date
Ziemas 6d54fb3c8a
Merge d114ca8309 into 4aafab2fc9 2024-05-14 08:20:27 +03:00
OpenGOAL Bot 4aafab2fc9
CI: Periodic Controller Database Update (#3517)
Updating Controller Database

Co-authored-by: OpenGOALBot <OpenGOALBot@users.noreply.github.com>
2024-05-13 20:37:21 -04:00
ManDude ebbbedabc5
jak3: fix hud sprite crash + add entity debugger (#3516) 2024-05-13 04:09:25 +01:00
Ziemas d114ca8309 queue load single messages 2024-05-12 19:58:31 +02:00
Tyler Wilding d1ece445d4
Dependency graph work - Part 1 - Preliminary work (#3505)
Relates to #1353 

This adds no new functionality or overhead to the compiler, yet. This is
the preliminary work that has:
- added code to the compiler in several spots to flag when something is
used without being properly required/imported/whatever (disabled by
default)
- that was used to generate project wide file dependencies (some
circulars were manually fixed)
- then that graph underwent a transitive reduction and the result was
written to all `jak1` source files.

The next step will be making this actually produce and use a dependency
graph. Some of the reasons why I'm working on this:
- eliminates more `game.gp` boilerplate. This includes the `.gd` files
to some extent (`*-ag` files and `tpage` files will still need to be
handled) this is the point of the new `bundles` form. This should make
it even easier to add a new file into the source tree.
- a build order that is actually informed from something real and
compiler warnings that tell you when you are using something that won't
be available at build time.
- narrows the search space for doing LSP actions -- like searching for
references. Since it would be way too much work to store in the compiler
every location where every symbol/function/etc is used, I have to do
ad-hoc searches. By having a dependency graph i can significantly reduce
that search space.
- opens the doors for common shared code with a legitimate pattern.
Right now jak 2 shares code from the jak 1 folder. This is basically a
hack -- but by having an explicit require syntax, it would be possible
to reference arbitrary file paths, such as a `common` folder.

Some stats:
- Jak 1 has about 2500 edges between files, including transitives
- With transitives reduced at the source code level, each file seems to
have a modest amount of explicit requirements.

Known issues:
- Tracking the location for where `defmacro`s and virtual state
definitions were defined (and therefore the file) is still problematic.
Because those forms are in a macro environment, the reader does not
track them. I'm wondering if a workaround could be to search the
reader's text_db by not just the `goos::Object` but by the text
position. But for the purposes of finishing this work, I just statically
analyzed and searched the code with throwaway python code.
2024-05-12 12:37:59 -04:00
water111 e0b1d8c21e
Jak3 sky (#3514) 2024-05-12 09:36:50 -04:00
Ziemas 6628fc3600 pagemanager: mostly map out structs 2024-05-03 18:17:00 +02:00
Ziemas 78917bd96e wip 2024-05-02 13:24:58 +02:00
Ziemas b5b45b2c99 wip 2024-05-02 07:45:15 +02:00
Ziemas 1c034c97bf Add no-op Suspend/Resume intr 2024-05-02 06:48:56 +02:00
Ziemas fdb439e014 wip 2024-05-02 06:23:29 +02:00
Ziemas 3c73063940 iop: Support wating on message boxes 2024-05-02 06:20:37 +02:00
Ziemas 38fe4161d0 wip 2024-05-01 23:57:09 +02:00
Ziemas 541815f809 start all rpc threads 2024-05-01 23:57:09 +02:00
Ziemas 379622b70b set up fake iso system class 2024-05-01 23:57:09 +02:00
Ziemas 7661301b5f overlrd2: ctz 2024-05-01 23:57:09 +02:00
Ziemas bea9e6a1e3 wip 2024-05-01 23:57:09 +02:00
Ziemas 8c1948db68 overlrd2: angle lookup table 2024-05-01 03:56:56 +02:00
Ziemas 413e214d2c overlrd2: start 2024-05-01 03:56:56 +02:00
630 changed files with 10367 additions and 596 deletions

View File

@ -16,10 +16,6 @@
#include "common/log/log.h"
// clang-format on
// TODO - basically REPL to listen and inject commands into a running REPL
// - we will need a C++ side client as well which will let us communicate with the repl via for
// example, ImgUI
//
// TODO - The server also needs to eventually return the result of the evaluation
ReplServer::~ReplServer() {

View File

@ -28,8 +28,12 @@ struct MethodInfo {
std::string name;
TypeSpec type;
std::string defined_in_type;
// TODO - this might be redundant, but preventing an unknown breaking change, clean it up later
std::string type_name;
bool no_virtual = false;
// TODO - this is no longer used anymore...but was not removed from th4e struct?
bool overrides_parent = false;
// TODO - this is no longer used anymore...but was not removed from th4e struct?
bool only_overrides_docstring = false;
std::optional<std::string> docstring;
std::optional<std::string> overlay_name;

View File

@ -124,10 +124,12 @@ class TypeSpec {
ASSERT(m_arguments);
return m_arguments->at(idx);
}
TypeSpec& get_arg(int idx) {
ASSERT(m_arguments);
return m_arguments->at(idx);
}
const TypeSpec& last_arg() const {
ASSERT(m_arguments);
ASSERT(!m_arguments->empty());

View File

@ -548,6 +548,7 @@ MethodInfo TypeSystem::override_method(Type* type,
existing_info.name,
existing_info.type,
type->get_name(),
type->get_name(),
existing_info.no_virtual,
false,
true,
@ -607,6 +608,7 @@ MethodInfo TypeSystem::declare_method(Type* type,
method_name,
ts,
type->get_name(),
type->get_name(),
no_virtual,
true,
false,
@ -645,6 +647,7 @@ MethodInfo TypeSystem::declare_method(Type* type,
method_name,
ts,
type->get_name(),
type->get_name(),
no_virtual,
false,
false,
@ -678,8 +681,8 @@ MethodInfo TypeSystem::overlay_method(Type* type,
}
// use the existing ID.
return type->add_method({existing_info.id, method_name, ts, type->get_name(), false, true, false,
docstring, std::make_optional(method_overlay_name)});
return type->add_method({existing_info.id, method_name, ts, type->get_name(), type->get_name(),
false, true, false, docstring, std::make_optional(method_overlay_name)});
}
MethodInfo TypeSystem::define_method(const std::string& type_name,
@ -709,8 +712,10 @@ MethodInfo TypeSystem::define_method(Type* type,
// look up the method
MethodInfo existing_info;
bool got_existing = try_lookup_method(type, method_name, &existing_info);
if (got_existing) {
// The lookup will return a parents method, but the type should be equal
// to the type in question (it's a child)
existing_info.type_name = type->get_name();
// Update the docstring
existing_info.docstring = docstring;
int bad_arg_idx = -99;
@ -758,7 +763,7 @@ MethodInfo TypeSystem::add_new_method(Type* type,
return existing;
} else {
return type->add_new_method(
{0, "new", ts, type->get_name(), false, false, false, docstring, {}});
{0, "new", ts, type->get_name(), type->get_name(), false, false, false, docstring, {}});
}
}

View File

@ -58,10 +58,11 @@ EnumType* parse_defenum(const goos::Object& defenum,
auto& enum_name_obj = car(iter);
iter = cdr(iter);
// check for docstring
std::optional<std::string> maybe_docstring;
if (iter->is_pair() && car(iter).is_string()) {
// TODO - docstring - store and use docstring if coming from the compiler
if (symbol_metadata) {
symbol_metadata->docstring = str_util::trim_newline_indents(car(iter).as_string()->data);
maybe_docstring = str_util::trim_newline_indents(car(iter).as_string()->data);
symbol_metadata->docstring = maybe_docstring.value();
}
iter = cdr(iter);
}
@ -157,6 +158,7 @@ EnumType* parse_defenum(const goos::Object& defenum,
if (is_type("integer", base_type, ts)) {
auto parent = ts->get_type_of_type<ValueType>(base_type.base_type());
auto new_type = std::make_unique<EnumType>(parent, name, is_bitfield, entries);
new_type->m_metadata.docstring = maybe_docstring;
new_type->set_runtime_type(parent->get_runtime_name());
return dynamic_cast<EnumType*>(ts->add_type(name, std::move(new_type)));
} else {

View File

@ -36,6 +36,9 @@
#define ASSERT_NOT_REACHED_MSG(STR) \
(void)((private_assert_failed("not reached", __FILE__, __LINE__, __PRETTY_FUNCTION__, STR), 0))
#define ASSERT_EQ_IMM(EXPR, EXPECTED) \
ASSERT_MSG((EXPR) == (EXPECTED), fmt::format("result was {}, expected {}", (EXPR), (EXPECTED)))
#else
#define ASSERT(EX) ((void)0)

View File

@ -7,9 +7,6 @@
// A normal Trie does not allow for duplicate keys, however this one does
// It allows for insertion and removal
//
// Note, keys assume only basic ASCII, which is _fine_ as OpenGOAL itself has this
// limitation as well.
template <typename T>
class TrieWithDuplicates {
private:

View File

@ -3540,7 +3540,7 @@
(bucket2 2) ;; pc vis stuff
(bucket3 3) ;; blit?
(tex-lcom-sky-pre 4)
(bucket5 5) ;; sky
(sky 5) ;; sky
(bucket6 6) ;; ocean
(bucket7 7) ;; unknown new jak 3 texture upload, for all levels.
(hfrag 8) ;; hfrag
@ -4234,7 +4234,7 @@
(rn0)
(rn1)
(rn2)
(rn3)
(sky)
(rn4)
(rn5)
(hfrag)
@ -4468,6 +4468,8 @@
(deftype dma-gif (structure)
"Believed unused GIF header type."
((gif uint64 2 :offset-assert 0) ;; guessed by decompiler
(gif0 uint64 :overlay-at (-> gif 0) :score 1)
(gif1 uint64 :overlay-at (-> gif 1) :score 1)
(quad uint128 :offset-assert 0 :overlay-at gif)
)
:method-count-assert 9
@ -4479,6 +4481,8 @@
"The header for a DMA transfer that goes directly to GIF, containing DMA, VIF, GIF tags."
((dma-vif dma-packet :inline :offset-assert 0)
(gif uint64 2 :offset-assert 16) ;; guessed by decompiler
(gif0 uint64 :offset 16 :score -1)
(gif1 uint64 :offset 24 :score -1)
(quad uint128 2 :offset-assert 0 :overlay-at dma-vif) ;; guessed by decompiler
)
:method-count-assert 9
@ -5519,6 +5523,32 @@
:flag-assert #x900000010
)
; (deftype dma-gif-packet (structure)
; "The header for a DMA transfer that goes directly to GIF, containing DMA, VIF, GIF tags."
; ((dma-vif dma-packet :inline :offset-assert 0)
; ;;(gif uint64 2 :offset-assert 16) ;; guessed by decompiler
; (gif0 gif-tag64 :offset 16 :score 1)
; (gif1 gif-tag-regs :offset 24 :score 1)
; (quad uint128 2 :offset-assert 0 :overlay-at dma-vif) ;; guessed by decompiler
; )
; :method-count-assert 9
; :size-assert #x20
; :flag-assert #x900000020
; )
; (deftype dma-gif (structure)
; "Believed unused GIF header type."
; ((gif uint64 2 :offset-assert 0) ;; guessed by decompiler
; (gif0 gif-tag64 :overlay-at (-> gif 0) :score 1)
; (gif1 gif-tag-regs :overlay-at (-> gif 1) :score 1)
; (quad uint128 :offset-assert 0 :overlay-at gif)
; )
; :method-count-assert 9
; :size-assert #x10
; :flag-assert #x900000010
; )
(deftype gif-packet (basic)
"Unused type for building a dynamically sized gif packet."
((reg-count int32 :offset-assert 4)
@ -11484,7 +11514,7 @@
(blit-displays-work-method-17 (_type_ vector int float symbol) none) ;; 17
(blit-displays-work-method-18 () none) ;; 18
(blit-displays-work-method-19 (_type_) none) ;; 19 (called from main.gc)
(blit-displays-work-method-20 () none) ;; 20
(blit-displays-work-method-20 (_type_) none) ;; 20
(get-menu-mode (_type_) symbol) ;; 21
(get-screen-copied (_type_) symbol) ;; 22
(get-horizontal-flip-flag (_type_) symbol) ;; 23
@ -11715,33 +11745,33 @@
(init-sun-data! (_type_ int float float float) none) ;; 9
(init-orbit-settings! (_type_ int float float float float float float) none) ;; 10
(update-colors-for-time (_type_ float) none) ;; 11
(update-time-and-speed (_type_ float float) none) ;; 12
(sky-work-method-13 () none) ;; 13
(draw (_type_) none) ;; 14 ;; (update-matrix (_type_ matrix) none)
(sky-work-method-15 () none) ;; 15 ;; (update-template-colors (_type_) none)
(sky-work-method-16 () none) ;; 16 ;; (init-regs-for-large-polygon-draw (_type_) none)
(sky-work-method-17 () none) ;; 17 ;; (init-regs-for-sky-asm (_type_) none)
(sky-work-method-18 () none) ;; 18 ;; (cloud-vtx-light-update (_type_ vector vector cloud-lights vector vector) none)
(sky-work-method-19 () none) ;; 19 ;; (cloud-vtx-tex-update (_type_ vector vector vector cloud-lights) none)
(sky-work-method-20 () none) ;; 20 ;; (adjust-cloud-lighting (_type_) none)
(sky-work-method-21 () none) ;; 21 ;; (cloud-vtx1-to-sky (_type_ sky-vertex cloud-vertex) none)
(sky-work-method-22 () none) ;; 22 ;; (cloud-vtx2-to-sky (_type_ sky-vertex cloud-vertex) none)
(sky-work-method-23 () none) ;; 23 ;; (draw-clouds (_type_ dma-buffer) none)
(sky-work-method-24 () none) ;; 24 ;; (apply-haze-light (_type_ vector vector haze-lights) none)
(sky-work-method-25 () none) ;; 25 ;; (adjust-haze-lighting (_type_) none)
(sky-work-method-26 () none) ;; 26 ;; (haze-vtx-to-sky (_type_ sky-vertex sky-vertex haze-vertex) none)
(sky-work-method-27 () none) ;; 27 ;; (draw-haze (_type_ dma-buffer) none)
(sky-work-method-28 () none) ;; 28 ;; (sun-dma (_type_ dma-buffer) none)
(sky-work-method-29 () none) ;; 29 ;; (green-sun-dma (_type_ dma-buffer) none)
(sky-work-method-30 () none) ;; 30 ;; (moon-dma (_type_ dma-buffer) none)
(sky-work-method-31 () none) ;; 31 ;; (setup-stars (_type_ matrix sky-upload-data) none)
(sky-work-method-32 () none) ;; 32 ;; (stars-transform-asm (_type_) none)
(sky-work-method-33 () none) ;; 33 ;; (stars-dma (_type_ dma-buffer) none)
(sky-work-method-34 () none) ;; 34 ;; (draw-roof (_type_ dma-buffer) none)
(sky-work-method-35 () none) ;; 35 ;; (draw-base (_type_ dma-buffer) none)
(sky-work-method-36 () none) ;; 36 ;; (draw-fog (_type_ dma-buffer) none)
(sky-work-method-37 () none) ;; 37
(sky-work-method-38 () none) ;; 38
(update-time-and-speed "Update cloud sroll and sun/moon position for the time." (_type_ float float) none) ;; 12
(draw-erase (_type_ dma-buffer vector) none) ;; 13
(draw (_type_) none) ;; 14
(update-camera-matrix "Set the camera matrix (no perspective) for sky drawing." (_type_ matrix) none) ;; 15
(update-template-colors "Update work with sky/erase colors from time-of-day/level." (_type_) none) ;; 16
(init-regs-for-large-polygon-draw (_type_) none) ;; 17
(init-regs-for-sky-asm (_type_) none) ;; 18
(cloud-vtx-light-update (_type_ vector vector cloud-lights vector vector) none) ;; 19
(cloud-vtx-tex-update (_type_ vector vector vector cloud-lights) none) ;; 20
(adjust-cloud-lighting (_type_) none) ;; 21
(cloud-vtx1-to-sky (_type_ sky-vertex cloud-vertex) none) ;; 22
(cloud-vtx2-to-sky (_type_ sky-vertex cloud-vertex) none) ;; 23
(draw-clouds (_type_ dma-buffer) none) ;; 24
(apply-haze-light (_type_ vector vector haze-lights float) none) ;; 25
(adjust-haze-lighting (_type_) none) ;; 26
(haze-vtx-to-sky (_type_ sky-vertex sky-vertex haze-vertex) none) ;; 27
(draw-haze (_type_ dma-buffer) none) ;; 28
(sun-dma (_type_ dma-buffer) none) ;; 29
(green-sun-dma (_type_ dma-buffer) none) ;; 30
(moon-dma (_type_ dma-buffer) none) ;; 31
(day-star-dma (_type_ dma-buffer) none) ;; 32
(setup-stars (_type_ matrix sky-upload-data) none) ;; 33
(stars-transform-asm (_type_) none) ;; 34
(stars-dma (_type_ dma-buffer) none) ;; 35
(draw-roof (_type_ dma-buffer) none) ;; 36
(draw-base (_type_ dma-buffer) none) ;; 37
(draw-fog (_type_ dma-buffer) none) ;; 38
)
)
@ -28482,8 +28512,6 @@
(name symbol :offset-assert 8) ;; guessed by decompiler
(process process-drawable :offset-assert 12) ;; guessed by decompiler
(curve curve :inline :offset-assert 16)
(num-cverts int32 :offset 20)
(cverts uint32 :offset 16)
)
:method-count-assert 32
:size-assert #x24
@ -32458,13 +32486,13 @@
;; sky-tng ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (define-extern set-tex-offset function) ;; (function int int none)
(define-extern set-tex-offset (function int int none))
;; (define-extern draw-large-polygon function)
;; (define-extern clip-polygon-against-positive-hyperplane function)
;; (define-extern clip-polygon-against-negative-hyperplane function)
;; (define-extern render-sky-quad function) ;; (function (inline-array sky-vertex) dma-buffer none)
;; (define-extern render-sky-tri function) ;; (function (inline-array sky-vertex) dma-buffer none)
(define-extern close-sky-buffer (function dma-buffer none))
(define-extern render-sky-quad (function (inline-array sky-vertex) dma-buffer none))
(define-extern render-sky-tri (function (inline-array sky-vertex) dma-buffer none))
(define-extern close-sky-buffer "Close DMA buffer for large polygon drawing." (function dma-buffer none))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; load-state ;;

View File

@ -608,13 +608,14 @@
"draw-large-polygon",
"render-sky-quad",
"render-sky-tri",
"(method 16 sky-work)",
"(method 17 sky-work)",
"(method 18 sky-work)",
"(method 32 sky-work)",
"(method 33 sky-work)",
// "(method 28 sky-work)",
"(method 31 sky-work)",
"(method 34 sky-work)",
"(method 29 sky-work)",
"(method 30 sky-work)",
"(method 35 sky-work)",
"(method 11 collide-hash)",
"(method 12 collide-hash)",
"fill-bg-using-box-new",
@ -727,11 +728,9 @@
["lcit", 0, 0],
["pow", 0, 0],
["wasintro", 0, 0],
["wasintro-vis", 0, 0],
["lfacctyb", 0, 0],
["intpfall", 0, 0],
["lfaccity", 0, 0],
["lfacctyb-vis", 0, 0],
["ltowcity", 0, 0],
["powergd", 0, 0],
["lcitysml", 0, 0]

View File

@ -183,11 +183,11 @@
"DGO/RAILF.DGO",
"DGO/RAILX.DGO",
// // precursor
// "DGO/PRECA.DGO",
// "DGO/PRECB.DGO",
// "DGO/PRECC.DGO",
"DGO/PRECA.DGO",
"DGO/PRECB.DGO",
"DGO/PRECC.DGO",
// "DGO/PRECD.DGO",
// title/intro
// // title/intro
"DGO/WIN.DGO", // wasintro
"DGO/TITLE.DGO",
"DGO/INTTITLE.DGO",
@ -195,15 +195,15 @@
"DGO/IPF.DGO", // intro-palace-fall
"DGO/INTROCST.DGO",
// // outro
// "DGO/OUTCAST3.DGO",
// "DGO/OUTROCST.DGO",
"DGO/OUTCAST3.DGO",
"DGO/OUTROCST.DGO",
// // museum
// "DGO/MUSEUM.DGO",
// "DGO/MUSEUM2.DGO",
// "DGO/MUSEUM3.DGO",
// "DGO/MUSEUM3B.DGO",
// "DGO/MUSEUM4.DGO",
// "DGO/MUSEUM4B.DGO",
"DGO/MUSEUM.DGO",
"DGO/MUSEUM2.DGO",
"DGO/MUSEUM3.DGO",
"DGO/MUSEUM3B.DGO",
"DGO/MUSEUM4.DGO",
"DGO/MUSEUM4B.DGO",
// test
"DGO/HALFPIPE.DGO",
// borrow

View File

@ -575,6 +575,15 @@
["L23", "(inline-array sky-vertex)", 648],
["L21", "(inline-array sky-vertex)", 144]
],
"sky-tng": [
["L130", "vector"],
["L131", "uint64", true],
["L132", "uint64", true],
["L133", "uint64", true],
["L134", "uint64", true],
["L135", "uint64", true],
["L136", "uint64", true]
],
"mood-funcs": [
["L198", "uint64", true],
["L197", "uint64", true],

View File

@ -10845,5 +10845,35 @@
"(method 32 bt-vehicle)": [
["_stack_", 76, "float"],
["_stack_", 100, "float"]
],
"real-wang-texture-anim-func": [
[[3, 31], "v1", "mood-context"]
],
"(method 24 sky-work)": [
[256, "s4", "(pointer int32)"],
[261, "s4", "(pointer int32)"]
],
"(method 28 sky-work)": [
[143, "s4", "(pointer int32)"],
[148, "s4", "(pointer int32)"]
],
"(method 36 sky-work)": [
[81, "s5", "(pointer int32)"],
[86, "s5", "(pointer int32)"]
],
"(method 37 sky-work)": [
[67, "s5", "(pointer int32)"],
[72, "s5", "(pointer int32)"]
],
"(method 38 sky-work)": [
[[83, 179], "v1", "(inline-array qword)"]
],
"(method 14 sky-work)": [
[[80, 256], "s4", "sky-work"]
],
"(method 13 sky-work)": [
[65, "v1", "(pointer uint128)"],
[[70, 77], "a0", "vector4w"],
[[78, 84], "v1", "vector4w"]
]
}

View File

@ -28,25 +28,9 @@ namespace decompiler {
std::optional<ObjectFileRecord> get_bsp_file(const std::vector<ObjectFileRecord>& records,
const std::string& dgo_name) {
std::optional<ObjectFileRecord> result;
bool found = false;
for (auto& file : records) {
if (file.name.length() > 4 && file.name.substr(file.name.length() - 4) == "-vis") {
ASSERT(!found);
found = true;
result = file;
}
}
if (!result) {
if (str_util::ends_with(dgo_name, ".DGO") || str_util::ends_with(dgo_name, ".CGO")) {
auto expected_name = dgo_name.substr(0, dgo_name.length() - 4);
for (auto& c : expected_name) {
c = tolower(c);
}
if (!records.empty() && expected_name == records.back().name) {
return records.back();
}
}
if (str_util::ends_with(dgo_name, ".DGO")) {
// only DGOs are valid levels, and the last file is the bsp file
result = records.at(records.size() - 1);
}
return result;
}

View File

@ -253,6 +253,19 @@ set(RUNTIME_SOURCE
overlord/jak2/streamlfo.cpp
overlord/jak2/streamlist.cpp
overlord/jak2/vag.cpp
overlord/jak3/start.cpp
overlord/jak3/iso_api.cpp
overlord/jak3/iso_fake.cpp
overlord/jak3/iso_queue.cpp
overlord/jak3/iso.cpp
overlord/jak3/overlord.cpp
overlord/jak3/pagemanager.cpp
overlord/jak3/ramdisk.cpp
overlord/jak3/sbank.cpp
overlord/jak3/srpc.cpp
overlord/jak3/ssound.cpp
overlord/jak3/stream.cpp
overlord/jak3/vblank_handler.cpp
runtime.cpp
sce/deci2.cpp
sce/iop.cpp

View File

@ -1570,6 +1570,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
03000000a306000020f6000011010000,Saitek PS2700 Rumble,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,
05000000e804000000a000001b010000,Samsung EIGP20,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
03000000d81d00000e00000010010000,Savior,a:b0,b:b1,back:b8,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b11,righttrigger:b3,start:b9,x:b4,y:b5,platform:Linux,
03000000952e00004b43000011010000,Scuf Envision,a:b0,b:b1,x:b2,y:b3,dpleft:h0.8,dpright:h0.2,dpup:h0.1,dpdown:h0.4,leftx:a0,lefty:a1,leftstick:b8,rightx:a2,righty:a5,rightstick:b9,leftshoulder:b4,lefttrigger:a3,rightshoulder:b,righttrigger:a4,back:b6,start:b7,guide:b10,platform:Linux,
03000000a30c00002500000011010000,Sega Genesis Mini 3B Controller,a:b2,b:b1,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,righttrigger:b5,start:b9,platform:Linux,
03000000790000001100000011010000,Sega Saturn,a:b1,b:b2,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b7,rightshoulder:b5,righttrigger:b4,start:b9,x:b0,y:b3,platform:Linux,
03000000790000002201000011010000,Sega Saturn,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b6,righttrigger:b7,start:b9,x:b2,y:b3,platform:Linux,

View File

@ -40,8 +40,8 @@ struct RPC_Dgo_Cmd {
uint32_t buffer2;
uint32_t buffer_heap_top;
char name[16];
uint16_t cgo_id;
uint8_t pad[30];
uint32_t cgo_id;
uint8_t pad[28];
};
static_assert(sizeof(RPC_Dgo_Cmd) == 0x40);
} // namespace jak3

View File

@ -141,6 +141,7 @@ void OpenGLRenderer::init_bucket_renderers_jak3() {
// 4
init_bucket_renderer<TextureUploadHandler>("tex-lcom-sky-pre", BucketCategory::TEX,
BucketId::TEX_LCOM_SKY_PRE, texture_animator);
init_bucket_renderer<DirectRenderer>("sky", BucketCategory::OTHER, BucketId::SKY, 1024 * 8);
init_bucket_renderer<OceanMidAndFar>("ocean-mid-far", BucketCategory::OCEAN,
BucketId::OCEAN_MID_FAR);

View File

@ -417,6 +417,7 @@ enum class BucketId {
BUCKET_2 = 2,
BLIT_START = 3,
TEX_LCOM_SKY_PRE = 4,
SKY = 5,
OCEAN_MID_FAR = 6,
HFRAG = 8,

View File

@ -378,6 +378,9 @@ void Sprite3::render_2d_group1(DmaFollower& dma,
case GameVersion::Jak2:
ASSERT(run.vifcode1().immediate == SpriteProgMem::Sprites2dHud_Jak2);
break;
case GameVersion::Jak3:
ASSERT_EQ_IMM(run.vifcode1().immediate, (int)SpriteProgMem::Sprites2dHud_Jak3);
break;
default:
ASSERT_NOT_REACHED();
}

View File

@ -205,6 +205,7 @@ enum SpriteProgMem {
Sprites2dGrp0 = 3, // world space 2d sprites
Sprites2dHud_Jak1 = 109, // hud sprites
Sprites2dHud_Jak2 = 115,
Sprites2dHud_Jak3 = 143,
Sprites3d = 211 // 3d sprites
};
@ -241,4 +242,4 @@ struct SpriteGlowConsts {
math::Vector4f clamp_min;
math::Vector4f clamp_max;
};
static_assert(sizeof(SpriteGlowConsts) == 0x180);
static_assert(sizeof(SpriteGlowConsts) == 0x180);

File diff suppressed because it is too large Load Diff

View File

@ -365,6 +365,19 @@ namespace generic_translucent { extern void link(); }
namespace high_speed_reject { extern void link(); }
namespace mercneric_convert { extern void link(); }
namespace generic_merc_init_asm { extern void link(); }
namespace set_tex_offset { extern void link(); }
namespace draw_large_polygon { extern void link(); }
namespace render_sky_quad { extern void link(); }
namespace render_sky_tri { extern void link(); }
namespace method_17_sky_work { extern void link(); }
namespace method_18_sky_work { extern void link(); }
namespace method_29_sky_work { extern void link(); }
namespace method_30_sky_work { extern void link(); }
namespace method_31_sky_work { extern void link(); }
namespace method_34_sky_work { extern void link(); }
namespace method_35_sky_work { extern void link(); }
namespace method_32_sky_work { extern void link(); }
namespace set_sky_vf23_value { extern void link(); }
}
// clang-format on
@ -535,86 +548,90 @@ PerGameVersion<std::unordered_map<std::string, std::vector<void (*)()>>> gMips2C
jak2::shadow_scissor_top::link, jak2::shadow_scissor_edges::link,
jak2::shadow_calc_dual_verts::link, jak2::shadow_xform_verts::link}}},
/////////// JAK 3
{
{"lights",
{jak3::light_hash_get_bucket_index::link, jak3::add_light_sphere_to_light_group::link,
jak3::light_hash_count_items::link, jak3::light_hash_add_items::link}},
{"debug",
{jak3::debug_line_clip::link, jak3::init_boundary_regs::link,
jak3::draw_boundary_polygon::link, jak3::render_boundary_quad::link,
jak3::render_boundary_tri::link, jak3::set_sky_vf27::link}},
{"generic-effect",
{jak3::generic_light_proc::link, jak3::generic_envmap_proc::link,
jak3::generic_prepare_dma_double::link, jak3::generic_prepare_dma_single::link,
jak3::generic_warp_source_proc::link, jak3::generic_warp_dest_proc::link,
jak3::generic_warp_dest::link, jak3::generic_warp_envmap_dest::link,
jak3::generic_no_light_proc::link}},
{"font",
{jak3::method_9_font_work::link, jak3::draw_string_asm::link,
jak3::get_string_length::link}},
{"texture", {jak3::adgif_shader_texture_with_update::link}},
{"collide-func",
{jak3::moving_sphere_triangle_intersect::link, jak3::collide_do_primitives::link}},
{"prim", {jak3::method_9_prim_strip::link}},
{"joint", {jak3::cspace_parented_transformq_joint::link}},
{"foreground",
{jak3::foreground_check_longest_edge_asm::link, jak3::foreground_generic_merc::link,
jak3::foreground_merc::link, jak3::foreground_draw_hud::link}},
{"particle-curves", {jak3::live_func_curve::link, jak3::birth_func_curve::link}},
{"collide-hash",
{jak3::method_11_collide_hash::link, jak3::method_12_collide_hash::link,
jak3::fill_bg_using_box_new::link, jak3::fill_bg_using_line_sphere_new::link}},
{"collide-mesh",
{jak3::method_12_collide_mesh::link, jak3::method_14_collide_mesh::link,
jak3::method_15_collide_mesh::link, jak3::method_10_collide_shape_prim_mesh::link}},
{"collide-cache",
{jak3::method_10_collide_shape_prim_mesh::link,
jak3::method_10_collide_shape_prim_sphere::link,
jak3::method_10_collide_shape_prim_group::link,
jak3::method_11_collide_shape_prim_mesh::link,
jak3::method_11_collide_shape_prim_sphere::link,
jak3::method_11_collide_shape_prim_group::link, jak3::method_9_collide_cache_prim::link,
jak3::method_10_collide_cache_prim::link, jak3::method_17_collide_cache::link,
jak3::method_9_collide_puss_work::link, jak3::method_10_collide_puss_work::link}},
{"collide-edge-grab",
{jak3::method_10_collide_edge_hold_list::link, jak3::method_19_collide_edge_work::link,
jak3::method_9_edge_grab_info::link, jak3::method_17_collide_edge_work::link,
jak3::method_16_collide_edge_work::link, jak3::method_18_collide_edge_work::link}},
{"spatial-hash",
{jak3::method_18_grid_hash::link, jak3::method_19_grid_hash::link,
jak3::method_20_grid_hash::link, jak3::method_22_grid_hash::link,
jak3::method_28_sphere_hash::link, jak3::method_32_sphere_hash::link,
jak3::method_29_sphere_hash::link, jak3::method_30_sphere_hash::link,
jak3::method_31_sphere_hash::link, jak3::method_32_spatial_hash::link,
jak3::method_38_spatial_hash::link, jak3::method_35_spatial_hash::link,
jak3::method_36_spatial_hash::link, jak3::method_34_spatial_hash::link}},
{"sparticle-launcher",
{jak3::sparticle_motion_blur::link, jak3::sp_launch_particles_var::link,
jak3::particle_adgif::link, jak3::sp_init_fields::link}},
{"sparticle", {jak3::sp_process_block_2d::link, jak3::sp_process_block_3d::link}},
{"nav-engine",
{jak3::method_21_nav_engine::link, jak3::method_20_nav_engine::link,
jak3::method_18_nav_engine::link, jak3::method_17_nav_engine::link,
jak3::nav_state_patch_pointers::link, jak3::nav_dma_send_from_spr_no_flush::link,
jak3::nav_dma_send_to_spr_no_flush::link}},
{"nav-control", {jak3::method_39_nav_state::link}},
{"merc-blend-shape",
{jak3::blerc_execute::link, jak3::setup_blerc_chains_for_one_fragment::link}},
{"wvehicle-part", {jak3::sparticle_motion_blur_dirt::link}},
{"ripple",
{jak3::ripple_matrix_scale::link, jak3::ripple_apply_wave_table::link,
jak3::ripple_create_wave_table::link, jak3::ripple_execute_init::link}},
{"ocean-vu0",
{jak3::method_14_ocean::link, jak3::method_15_ocean::link, jak3::method_16_ocean::link}},
{"ocean",
{jak3::init_ocean_far_regs::link, jak3::draw_large_polygon_ocean::link,
jak3::render_ocean_quad::link}},
{"generic-merc",
{jak3::generic_merc_do_chain::link, jak3::generic_merc_execute_asm::link,
jak3::generic_merc_death::link, jak3::generic_merc_query::link,
jak3::generic_translucent::link, jak3::high_speed_reject::link,
jak3::mercneric_convert::link, jak3::generic_merc_init_asm::link}},
}};
{{"lights",
{jak3::light_hash_get_bucket_index::link, jak3::add_light_sphere_to_light_group::link,
jak3::light_hash_count_items::link, jak3::light_hash_add_items::link}},
{"debug",
{jak3::debug_line_clip::link, jak3::init_boundary_regs::link,
jak3::draw_boundary_polygon::link, jak3::render_boundary_quad::link,
jak3::render_boundary_tri::link, jak3::set_sky_vf27::link}},
{"generic-effect",
{jak3::generic_light_proc::link, jak3::generic_envmap_proc::link,
jak3::generic_prepare_dma_double::link, jak3::generic_prepare_dma_single::link,
jak3::generic_warp_source_proc::link, jak3::generic_warp_dest_proc::link,
jak3::generic_warp_dest::link, jak3::generic_warp_envmap_dest::link,
jak3::generic_no_light_proc::link}},
{"font",
{jak3::method_9_font_work::link, jak3::draw_string_asm::link, jak3::get_string_length::link}},
{"texture", {jak3::adgif_shader_texture_with_update::link}},
{"collide-func",
{jak3::moving_sphere_triangle_intersect::link, jak3::collide_do_primitives::link}},
{"prim", {jak3::method_9_prim_strip::link}},
{"joint", {jak3::cspace_parented_transformq_joint::link}},
{"foreground",
{jak3::foreground_check_longest_edge_asm::link, jak3::foreground_generic_merc::link,
jak3::foreground_merc::link, jak3::foreground_draw_hud::link}},
{"particle-curves", {jak3::live_func_curve::link, jak3::birth_func_curve::link}},
{"collide-hash",
{jak3::method_11_collide_hash::link, jak3::method_12_collide_hash::link,
jak3::fill_bg_using_box_new::link, jak3::fill_bg_using_line_sphere_new::link}},
{"collide-mesh",
{jak3::method_12_collide_mesh::link, jak3::method_14_collide_mesh::link,
jak3::method_15_collide_mesh::link, jak3::method_10_collide_shape_prim_mesh::link}},
{"collide-cache",
{jak3::method_10_collide_shape_prim_mesh::link,
jak3::method_10_collide_shape_prim_sphere::link,
jak3::method_10_collide_shape_prim_group::link,
jak3::method_11_collide_shape_prim_mesh::link,
jak3::method_11_collide_shape_prim_sphere::link,
jak3::method_11_collide_shape_prim_group::link, jak3::method_9_collide_cache_prim::link,
jak3::method_10_collide_cache_prim::link, jak3::method_17_collide_cache::link,
jak3::method_9_collide_puss_work::link, jak3::method_10_collide_puss_work::link}},
{"collide-edge-grab",
{jak3::method_10_collide_edge_hold_list::link, jak3::method_19_collide_edge_work::link,
jak3::method_9_edge_grab_info::link, jak3::method_17_collide_edge_work::link,
jak3::method_16_collide_edge_work::link, jak3::method_18_collide_edge_work::link}},
{"spatial-hash",
{jak3::method_18_grid_hash::link, jak3::method_19_grid_hash::link,
jak3::method_20_grid_hash::link, jak3::method_22_grid_hash::link,
jak3::method_28_sphere_hash::link, jak3::method_32_sphere_hash::link,
jak3::method_29_sphere_hash::link, jak3::method_30_sphere_hash::link,
jak3::method_31_sphere_hash::link, jak3::method_32_spatial_hash::link,
jak3::method_38_spatial_hash::link, jak3::method_35_spatial_hash::link,
jak3::method_36_spatial_hash::link, jak3::method_34_spatial_hash::link}},
{"sparticle-launcher",
{jak3::sparticle_motion_blur::link, jak3::sp_launch_particles_var::link,
jak3::particle_adgif::link, jak3::sp_init_fields::link}},
{"sparticle", {jak3::sp_process_block_2d::link, jak3::sp_process_block_3d::link}},
{"nav-engine",
{jak3::method_21_nav_engine::link, jak3::method_20_nav_engine::link,
jak3::method_18_nav_engine::link, jak3::method_17_nav_engine::link,
jak3::nav_state_patch_pointers::link, jak3::nav_dma_send_from_spr_no_flush::link,
jak3::nav_dma_send_to_spr_no_flush::link}},
{"nav-control", {jak3::method_39_nav_state::link}},
{"merc-blend-shape",
{jak3::blerc_execute::link, jak3::setup_blerc_chains_for_one_fragment::link}},
{"wvehicle-part", {jak3::sparticle_motion_blur_dirt::link}},
{"ripple",
{jak3::ripple_matrix_scale::link, jak3::ripple_apply_wave_table::link,
jak3::ripple_create_wave_table::link, jak3::ripple_execute_init::link}},
{"ocean-vu0",
{jak3::method_14_ocean::link, jak3::method_15_ocean::link, jak3::method_16_ocean::link}},
{"ocean",
{jak3::init_ocean_far_regs::link, jak3::draw_large_polygon_ocean::link,
jak3::render_ocean_quad::link}},
{"generic-merc",
{jak3::generic_merc_do_chain::link, jak3::generic_merc_execute_asm::link,
jak3::generic_merc_death::link, jak3::generic_merc_query::link,
jak3::generic_translucent::link, jak3::high_speed_reject::link,
jak3::mercneric_convert::link, jak3::generic_merc_init_asm::link}},
{"sky-tng",
{jak3::set_tex_offset::link, jak3::render_sky_quad::link, jak3::render_sky_tri::link,
jak3::method_17_sky_work::link, jak3::method_18_sky_work::link,
jak3::method_29_sky_work::link, jak3::method_30_sky_work::link,
jak3::method_31_sky_work::link, jak3::method_34_sky_work::link,
jak3::method_35_sky_work::link, jak3::method_32_sky_work::link,
jak3::set_sky_vf23_value::link, jak3::draw_large_polygon::link}}}};
void LinkedFunctionTable::reg(const std::string& name, u64 (*exec)(void*), u32 stack_size) {
const auto& it = m_executes.insert({name, {exec, Ptr<u8>()}});

View File

@ -69,6 +69,7 @@ int start_overlord(int, const char* const*) {
param.initPriority = 0x73;
param.stackSize = 0x1000;
param.option = 0;
strcpy(param.name, "Loader"); // added
SndPlayThread = thread_player;
auto thread_loader = CreateThread(&param);
if (thread_loader <= 0) {

View File

@ -0,0 +1,18 @@
#pragma once
#include "game/overlord/jak3/iso_structs.h"
#include "game/overlord/jak3/overlord.h"
namespace jak3 {
class CBaseFile {
public:
CBaseFile(const ISOFileDef*);
virtual EIsoStatus BeginRead(ISOBuffer*) = 0;
virtual EIsoStatus SyncRead() = 0;
virtual void Close() = 0;
/* unk return values */
virtual void Unk1() = 0;
virtual void Unk2() = 0;
};
} // namespace jak3

View File

@ -0,0 +1,24 @@
#pragma once
#include "game/overlord/jak3/basefile.h"
#include "game/overlord/jak3/iso_structs.h"
namespace jak3 {
class CBaseFileSystem {
public:
virtual int Init() = 0;
virtual void PollDrive() = 0;
virtual const ISOFileDef* Find(const char* name) = 0;
virtual const ISOFileDef* FindIN(const char* name) = 0;
virtual int GetLength(const ISOFileDef* def) = 0;
virtual CBaseFile* Open(const ISOFileDef* def, int offset, EFileComp mode) = 0;
virtual CBaseFile* OpenWad(const ISOFileDef* def, int offset) = 0;
virtual VagDirEntryJak3* FindVagFile(const char* name) = 0;
u8* CheckForPageBoundaryCrossing();
private:
ISOBuffer m_Buffer;
};
} // namespace jak3

366
game/overlord/jak3/iso.cpp Normal file
View File

@ -0,0 +1,366 @@
#include "iso.h"
#include <cstring>
#include "common/log/log.h"
#include "common/util/Assert.h"
#include "game/common/dgo_rpc_types.h"
#include "game/overlord/jak3/basefilesystem.h"
#include "game/overlord/jak3/iso_api.h"
#include "game/overlord/jak3/iso_fake.h"
#include "game/overlord/jak3/iso_queue.h"
#include "game/overlord/jak3/stream.h"
namespace jak3 {
using namespace iop;
CBaseFileSystem* g_pFileSystem;
int g_nISOThreadID;
int g_nDGOThreadID;
int g_nSTRThreadID;
int g_nPlayThreadID;
int g_nISOMbx;
VagDirJak3 g_VagDir;
char g_szCurrentMusicName[16];
char g_szTargetMusicName[16];
static int s_nISOInitFlag;
static ISO_LoadDGO s_LoadDGO;
static int s_nSyncMbx;
static MsgPacket s_MsgPacket_NotOnStackSync[2];
static RPC_Dgo_Cmd s_aISO_RPCBuf[1];
static int s_nDGOMbx;
static u32 DGOThread();
u32 ISOThread();
int NullCallback(ISO_Hdr* msg);
int CopyDataToEE(ISO_Hdr*);
int CopyDataToIOP(ISO_Hdr*);
int CopyDataTo989snd(ISO_Hdr*);
int CopyData(ISO_LoadSingle*, int);
/* COMPLETE */
void InitDriver() {
if (g_pFileSystem->Init() == 0) {
s_nISOInitFlag = 0;
}
SendMbx(s_nSyncMbx, &s_MsgPacket_NotOnStackSync[0]);
}
/* TODO unfinished */
static int LookMbx() {
MsgPacket* pkt;
int ret = PollMbx(&pkt, s_nSyncMbx);
if (ret != KE_MBOX_NOMSG) {
// FIXME
}
return ret != KE_MBOX_NOMSG;
}
/* COMPLETE */
static void WaitMbx(int mbx) {
MsgPacket* pkt;
ReceiveMbx(&pkt, mbx);
}
/* TODO unfinished */
int InitISOFS(const char* fs_mode, const char* loading_sceeen) {
const ISOFileDef* fd;
ThreadParam thp;
MbxParam mbx;
memset(&s_LoadDGO, 0, sizeof(s_LoadDGO));
/* TODO INIT s_LoadDgo fields */
s_nISOInitFlag = 1;
g_pFileSystem = &g_FakeISOCDFileSystem;
/* Lets not bother error checking the Create* calls */
mbx.attr = 0;
mbx.option = 0;
g_nISOMbx = CreateMbx(&mbx);
mbx.attr = 0;
mbx.option = 0;
s_nDGOMbx = CreateMbx(&mbx);
mbx.attr = 0;
mbx.option = 0;
s_nSyncMbx = CreateMbx(&mbx);
thp.attr = TH_C;
thp.entry = ISOThread;
thp.initPriority = 0x37;
thp.option = 0;
thp.stackSize = 0x1100;
g_nISOThreadID = CreateThread(&thp);
thp.attr = TH_C;
thp.entry = DGOThread;
thp.initPriority = 0x38;
thp.option = 0;
thp.stackSize = 0x900;
g_nDGOThreadID = CreateThread(&thp);
thp.attr = TH_C;
thp.entry = STRThread;
thp.initPriority = 0x39;
thp.option = 0;
thp.stackSize = 0x900;
g_nSTRThreadID = CreateThread(&thp);
thp.attr = TH_C;
thp.entry = PLAYThread;
thp.initPriority = 0x35;
thp.option = 0;
thp.stackSize = 0x900;
g_nPlayThreadID = CreateThread(&thp);
StartThread(g_nISOThreadID, 0);
StartThread(g_nDGOThreadID, 0);
StartThread(g_nSTRThreadID, 0);
StartThread(g_nPlayThreadID, 0);
WaitMbx(s_nSyncMbx);
/* Originally VAGDIR is only loaded for the CD filesystem
* Presumably there was different mechanism for fakeiso,
* but we need it regardless */
fd = FindIsoFile("VAGDIR.AYB");
LoadISOFileToIOP(fd, &g_VagDir, sizeof(g_VagDir));
/* Skip getting the loading screen thing? */
return s_nISOInitFlag;
}
const ISOFileDef* FindIsoFile(const char* name) {
return g_pFileSystem->Find(name);
}
u32 ISOThread() {
ISO_Msg* msg;
g_szCurrentMusicName[0] = '\0';
g_szTargetMusicName[0] = '\0';
InitBuffers();
// InitVagCmds();
InitDriver();
while (true) {
int res = PollMbx((MsgPacket**)&msg, g_nISOMbx);
if (res == KE_OK) {
msg->SetActive(false);
msg->SetUnk1(false);
msg->SetUnk2(false);
msg->file = nullptr;
msg->callback = NullCallback;
/* LoadSingle messages */
if (msg->msg_kind >= LOAD_TO_EE_CMD_ID && msg->msg_kind <= LOAD_TO_989SND) {
auto* ls = static_cast<ISO_LoadSingle*>(msg);
int pri = 0;
if (ls->unk40 == 2) {
pri = 2;
}
if (ls->unk40 == 10) {
pri = 4;
}
if (!QueueMessage(msg, pri)) {
break;
}
msg->file = nullptr;
if (msg->msg_kind == LOAD_TO_EE_OFFSET_CMD_ID) {
msg->file = g_pFileSystem->Open(ls->fd, ls->offset, EFileComp::MODE1);
} else if (msg->msg_kind == LOAD_TO_989SND) {
char name[16] = {0};
if (ls->filename) {
strncpy(name, ls->filename, 12);
name[8] = 0;
strcat(name, ".sbk");
auto fd = g_pFileSystem->Find(name);
if (fd) {
msg->file = g_pFileSystem->Open(ls->fd, -1, EFileComp::MODE1);
}
}
} else {
msg->file = g_pFileSystem->Open(ls->fd, -1, EFileComp::MODE1);
}
if (!msg->file) {
msg->m_nStatus = 8;
UnqueueMessage(msg);
ReturnMessage(msg);
break;
}
ls->unk44 = ls->address;
ls->unk48 = 0;
ls->length_to_copy = g_pFileSystem->GetLength(ls->fd);
if (msg->msg_kind == LOAD_TO_989SND) {
ls->length = ls->length_to_copy;
} else {
if (!ls->length_to_copy || ls->length < ls->length_to_copy) {
ls->length_to_copy = ls->length;
}
}
switch (msg->msg_kind) {
case LOAD_TO_EE_CMD_ID:
msg->callback = CopyDataToEE;
break;
case LOAD_TO_IOP_CMD_ID:
msg->callback = CopyDataToIOP;
break;
case LOAD_TO_EE_OFFSET_CMD_ID:
msg->callback = CopyDataToEE;
break;
case LOAD_TO_989SND:
msg->callback = CopyDataTo989snd;
break;
default:
ASSERT_NOT_REACHED();
}
msg->m_nStatus = 2;
msg->SetActive(true);
} else if (msg->msg_kind == 0xADEADBEE) {
ReturnMessage(msg);
ExitThread();
}
}
DelayThread(4000);
}
return 0;
}
static void ISO_LoadDGO(RPC_Dgo_Cmd* msg);
static void ISO_LoadNextDGO(RPC_Dgo_Cmd* msg);
static void ISO_CancelDGO(RPC_Dgo_Cmd* msg);
static void* RPC_DGO(u32 fno, void* data, int size) {
auto* msg = static_cast<RPC_Dgo_Cmd*>(data);
switch (fno) {
case 0:
ISO_LoadDGO(msg);
break;
case 1:
ISO_LoadNextDGO(msg);
break;
case 2:
ISO_CancelDGO(msg);
break;
default:
msg->result = 1;
break;
}
return data;
}
static u32 DGOThread() {
sceSifQueueData dq;
sceSifServeData serve;
CpuDisableIntr();
sceSifInitRpc(0);
sceSifSetRpcQueue(&dq, GetThreadId());
sceSifRegisterRpc(&serve, 0xfab3, RPC_DGO, s_aISO_RPCBuf, sizeof(s_aISO_RPCBuf), nullptr, nullptr,
&dq);
CpuEnableIntr();
sceSifRpcLoop(&dq);
return 0;
}
static void ISO_LoadDGO(RPC_Dgo_Cmd* msg) {
auto* def = g_pFileSystem->Find(msg->name);
if (def == nullptr) {
msg->result = 1;
return;
}
ASSERT_NOT_REACHED();
msg->buffer1 = msg->buffer_heap_top;
msg->result = 0;
}
static void ISO_LoadNextDGO(RPC_Dgo_Cmd* msg) {
ASSERT_NOT_REACHED();
}
static void ISO_CancelDGO(RPC_Dgo_Cmd* msg) {
ASSERT_NOT_REACHED();
}
/* COMPLETE */
const ISOFileDef* FindISOFile(char* name) {
return g_pFileSystem->Find(name);
}
/* COMPLETE */
s32 GetISOFileLength(const ISOFileDef* fd) {
return g_pFileSystem->GetLength(fd);
}
int CopyDataToEE(ISO_Hdr* msg) {
return CopyData((ISO_LoadSingle*)msg, 0);
}
int CopyDataToIOP(ISO_Hdr* msg) {
return CopyData((ISO_LoadSingle*)msg, 1);
}
int CopyDataTo989snd(ISO_Hdr* msg) {
return CopyData((ISO_LoadSingle*)msg, 2);
}
int CopyData(ISO_LoadSingle*, int) {
ASSERT_NOT_REACHED();
return 0;
}
int NullCallback(ISO_Hdr* msg) {
return 7;
}
void ISO_Hdr::SetActive(bool b) {
m_bActive = b;
}
void ISO_Hdr::SetUnk1(bool b) {
unk1 = b;
}
void ISO_Hdr::SetUnk2(bool b) {
unk2 = b;
}
void ISOBuffer::AdjustDataLength(int size) {
int state;
CpuSuspendIntr(&state);
decompressed_size -= size;
CpuResumeIntr(state);
}
void ISOBuffer::AdvanceCurrentData(int size) {
int state;
CpuSuspendIntr(&state);
decomp_buffer += size;
decompressed_size -= size;
CpuResumeIntr(state);
}
} // namespace jak3

59
game/overlord/jak3/iso.h Normal file
View File

@ -0,0 +1,59 @@
#pragma once
#include "game/overlord/jak3/basefile.h"
#include "game/sce/iop.h"
namespace jak3 {
constexpr int LOAD_TO_EE_CMD_ID = 0x100; // command to load file to ee
constexpr int LOAD_TO_IOP_CMD_ID = 0x101; // command to load to iop
constexpr int LOAD_TO_EE_OFFSET_CMD_ID = 0x102; // command to load file to ee with offset.
constexpr int LOAD_TO_989SND = 0x103;
constexpr int PAUSE_VAG_STREAM = 0x403; // Command to pause a vag stream
constexpr int CONTINUE_VAG_STREAM = 0x404; // Command to continue a vag stream
constexpr int SET_DIALOG_VOLUME = 0x406; // Command to set the volume of vag playback
extern int g_nISOMbx;
struct ISO_Hdr {
iop::MsgPacket m_Pkt;
int m_nStatus;
bool m_bActive;
bool unk1;
bool unk2;
void SetActive(bool b);
void SetUnk1(bool b);
void SetUnk2(bool b);
};
struct ISO_Msg : ISO_Hdr {
u32 msg_kind;
int mbx_to_reply;
int thread_id;
int (*callback)(ISO_Hdr*);
CBaseFile* file;
u32 priority;
};
struct ISO_LoadDGO : ISO_Msg {
ISOFileDef* fd;
};
struct ISO_LoadSingle : ISO_Msg {
const ISOFileDef* fd;
void* address;
u32 length;
u32 length_to_copy;
u32 offset;
char* filename;
u32 unk40;
void* unk44;
u32 unk48;
u32 unk4c;
};
int InitISOFS(const char* fs_mode, const char* loading_sceeen);
const ISOFileDef* FindIsoFile(const char* name);
} // namespace jak3

View File

@ -0,0 +1,31 @@
#include "iso_api.h"
#include "common/common_types.h"
#include "game/overlord/jak3/iso.h"
#include "game/overlord/jak3/iso_structs.h"
namespace jak3 {
using namespace iop;
u32 LoadISOFileToIOP(const ISOFileDef* file, void* addr, u32 length) {
ISO_LoadSingle msg;
msg.msg_kind = 0x101;
msg.mbx_to_reply = 0;
msg.thread_id = GetThreadId();
msg.fd = file;
msg.address = addr;
msg.length = length;
SendMbx(g_nISOMbx, &msg);
SleepThread();
u32 ret = 0;
if (msg.m_nStatus == 0) {
ret = msg.length_to_copy;
}
return ret;
}
} // namespace jak3

View File

@ -0,0 +1,12 @@
#ifndef ISO_API_H_
#define ISO_API_H_
#include "common/common_types.h"
#include "game/overlord/jak3/iso_structs.h"
namespace jak3 {
u32 LoadISOFileToIOP(const ISOFileDef* file, void* addr, u32 length);
}
#endif // ISO_API_H_

View File

@ -0,0 +1,36 @@
#include "iso_fake.h"
namespace jak3 {
CFakeISOCDFileSystem g_FakeISOCDFileSystem;
int CFakeISOCDFileSystem::Init() {
return 0;
}
void CFakeISOCDFileSystem::PollDrive() {}
const ISOFileDef* CFakeISOCDFileSystem::Find(const char* name) {
return nullptr;
}
const ISOFileDef* CFakeISOCDFileSystem::FindIN(const char* name) {
return nullptr;
}
int CFakeISOCDFileSystem::GetLength(const ISOFileDef* def) {
return 0;
}
CBaseFile* CFakeISOCDFileSystem::Open(const ISOFileDef* def, int offset, EFileComp mode) {
return nullptr;
}
CBaseFile* CFakeISOCDFileSystem::OpenWad(const ISOFileDef* def, int offset) {
return nullptr;
}
VagDirEntryJak3* CFakeISOCDFileSystem::FindVagFile(const char* name) {
return nullptr;
}
} // namespace jak3

View File

@ -0,0 +1,35 @@
#ifndef ISO_FAKE_H_
#define ISO_FAKE_H_
#include "basefile.h"
#include "basefilesystem.h"
#include "game/overlord/jak3/iso.h"
namespace jak3 {
class CFakeISOCDFileSystem : public CBaseFileSystem {
int Init() override;
void PollDrive() override;
const ISOFileDef* Find(const char* name) override;
const ISOFileDef* FindIN(const char* name) override;
int GetLength(const ISOFileDef* def) override;
CBaseFile* Open(const ISOFileDef* def, int offset, EFileComp mode) override;
CBaseFile* OpenWad(const ISOFileDef* def, int offset) override;
VagDirEntryJak3* FindVagFile(const char* name) override;
};
class CFakeISOCDFile : public CBaseFile {
EIsoStatus BeginRead(ISOBuffer*) override;
EIsoStatus SyncRead() override;
void Close() override;
/* unk return values */
void Unk1() override;
void Unk2() override;
};
extern CFakeISOCDFileSystem g_FakeISOCDFileSystem;
} // namespace jak3
#endif // ISO_FAKE_H_

View File

@ -0,0 +1,78 @@
#include "iso_queue.h"
#include "common/log/log.h"
#include "common/util/Assert.h"
#include "game/overlord/jak3/pagemanager.h"
#include "game/overlord/jak3/util.h"
#include "game/sce/iop.h"
namespace jak3 {
using namespace iop;
constexpr int N_VAG_CMDS = 6;
u32 g_auStreamSRAM[N_VAG_CMDS];
u32 g_auTrapSRAM[N_VAG_CMDS];
int g_nPriQueueSema;
int g_nISOSema;
PriStackEntry gPriStack[N_PRIORITIES];
CPageManager g_PageManager;
void InitBuffers() {
SemaParam semap;
semap.init_count = 1;
semap.max_count = 1;
semap.attr = 0;
semap.option = 0;
g_nPriQueueSema = CreateSema(&semap);
g_PageManager.Initialize();
semap.init_count = 1;
semap.max_count = 1;
semap.attr = SA_THPRI;
semap.option = 0;
g_nISOSema = CreateSema(&semap);
}
bool QueueMessage(ISO_Msg* msg, int priority) {
msg->m_nStatus = 2;
msg->priority = priority;
int level = priority == 5;
{
ScopedLock l(g_nPriQueueSema);
if (gPriStack[level].count != 8) {
gPriStack[level].entries[gPriStack[level].count] = msg;
gPriStack[level].count++;
return true;
}
}
msg->m_nStatus = 4;
ReturnMessage(msg);
return false;
}
void UnqueueMessage(ISO_Msg* msg) {}
void ReturnMessage(ISO_Msg* msg) {
if (msg->mbx_to_reply) {
SendMbx(msg->mbx_to_reply, msg);
} else if (msg->thread_id) {
WakeupThread(msg->thread_id);
} else {
// FreeVAGCommand(msg);
ASSERT_NOT_REACHED_MSG("unimplemented");
}
}
} // namespace jak3

View File

@ -0,0 +1,21 @@
#ifndef ISO_QUEUE_H_
#define ISO_QUEUE_H_
#include "game/overlord/jak3/iso.h"
namespace jak3 {
constexpr int N_PRIORITIES = 2;
constexpr int PRI_STACK_LENGTH = 8;
struct PriStackEntry {
ISO_Msg* entries[PRI_STACK_LENGTH];
int count;
};
void InitBuffers();
bool QueueMessage(ISO_Msg* msg, int priority);
void ReturnMessage(ISO_Msg* msg);
void UnqueueMessage(ISO_Msg* msg);
} // namespace jak3
#endif // ISO_QUEUE_H_

View File

@ -0,0 +1,50 @@
#pragma once
#include "common/common_types.h"
#include "game/overlord/jak3/pagemanager.h"
namespace jak3 {
/* TODO check values */
enum class EFileComp { MODE0, MODE1, KNOWN_NOT_BLZO };
struct ISOBuffer {
public:
void AdjustDataLength(int);
void AdvanceCurrentData(int);
void SetDataLength(int length) { m_nDataLength = length; }
int GetDataLength() { return m_nDataLength; }
private:
CPageManager::CPageList* m_pActivePages;
u8* decomp_buffer;
int decompressed_size;
int m_nDataLength;
};
struct VagDirEntryJak3 {
union {
u64 data;
struct {
u64 name : 42;
bool stereo : 1;
bool international : 1;
u8 param : 4;
u64 offset : 16;
};
};
};
static constexpr int MAX_VAGDIR_ENTRIES = 4096;
struct VagDirJak3 {
u32 id[2];
u32 version;
u32 count;
VagDirEntryJak3 entries[MAX_VAGDIR_ENTRIES];
};
struct VagDirEntry {};
struct ISOFileDef {};
} // namespace jak3

View File

@ -0,0 +1,30 @@
#include "overlord.h"
#include <cstdint>
#include <cstdio>
#include <cstring>
namespace jak3 {
extern int start_overlord(int, const char* const*);
void Panic() {
printf(
"IOP: *** Overlord panic at 0x%08lx (rel. address 0x%08lx)\n"
"IOP: *** Check mapfile to determine function name.\n"
"IOP: *** Thread halted.\n",
(intptr_t)__builtin_return_address(0),
(intptr_t)__builtin_return_address(0) - (intptr_t)start_overlord);
while (true)
;
}
char* strncpyz(char* dst, const char* src, size_t sz) {
if (sz) {
strncpy(dst, src, sz);
dst[sz - 1] = '\0';
}
return dst;
}
} // namespace jak3

View File

@ -0,0 +1,22 @@
#pragma once
#include <cstddef>
#include "common/common_types.h"
namespace jak3 {
struct Vec3 {
s32 x, y, z;
};
enum class EIsoStatus { Unk };
int start_overlord_wrapper(int argc, const char* const* argv, bool* signal);
void Panic();
char* strncpyz(char* dst, const char* src, size_t sz);
void InitSound();
int VBlank_Initialize();
} // namespace jak3

View File

@ -0,0 +1,191 @@
#include "pagemanager.h"
#include <cstring>
#include "common/util/Assert.h"
#include "game/sce/iop.h"
namespace jak3 {
using namespace iop;
static constexpr u32 PAGE_SIZE = 0x8010;
static constexpr u32 NUM_PAGES = 29;
CPageManager::CPage::CPage(u8* start, u8* end, int page_id) {
m_pNextPage = nullptr;
m_uPageBit = 1 << (page_id & 0x1f);
m_nPageState = 0;
m_pData = start;
m_pDataEnd = end;
m_nPageRefCount = 0;
m_nPageID = page_id;
m_nPageDmaRefCount = 0;
m_nAllocState = 0;
m_nPageState = 0;
}
int CPageManager::CPage::AddRef() {
int state, ret = -1;
CpuSuspendIntr(&state);
if (m_nAllocState == 1 && m_pPageList != nullptr) {
m_pPageList->m_nListRefCount++;
m_nPageRefCount++;
ret = m_nPageRefCount;
}
CpuResumeIntr(state);
return ret;
}
int CPageManager::CPage::ReleaseRef() {
int state, ret = -1;
CpuSuspendIntr(&state);
if (m_nAllocState == 1 && m_pPageList != nullptr) {
m_pPageList->m_nListRefCount--;
m_nPageRefCount--;
ret = m_nPageRefCount;
}
CpuResumeIntr(state);
return ret;
}
int CPageManager::CPage::AddDmaRef() {
int state, ret = -1;
CpuSuspendIntr(&state);
if (m_nAllocState == 1 && m_pPageList != nullptr) {
m_pPageList->m_nListDmaRefCount++;
m_nPageDmaRefCount++;
ret = m_nPageDmaRefCount;
}
CpuResumeIntr(state);
return ret;
}
int CPageManager::CPage::ReleaseDmaRef() {
int state, ret = -1;
CpuSuspendIntr(&state);
if (m_nAllocState == 1 && m_pPageList != nullptr) {
m_pPageList->m_nListDmaRefCount--;
m_nPageDmaRefCount--;
ret = m_nPageDmaRefCount;
}
CpuResumeIntr(state);
return ret;
}
void CPageManager::CPage::FromPagesCopy(u8* pInPageData, u8* pDest, int nNumBytes) {
int nInputPageLengthLeft;
CPage* page = this;
if (nNumBytes <= 0) {
return;
}
for (;;) {
nInputPageLengthLeft = (uintptr_t)page->m_pDataEnd + (1 - (uintptr_t)pInPageData);
if (nInputPageLengthLeft <= nNumBytes) {
break;
}
if (nNumBytes <= 0) {
nNumBytes -= nInputPageLengthLeft;
return;
}
ASSERT(m_pNextPage != nullptr);
page = page->m_pNextPage;
pInPageData = page->m_pData;
}
memcpy(pDest, pInPageData, nNumBytes);
}
CPageManager::CCache::CCache() {
m_paCache = nullptr;
m_uAllocatedPageMap = 0;
m_Unk = (1 << NUM_PAGES) - 1;
}
int CPageManager::CCache::Initialize() {
m_paCache = AllocSysMemory(0, PAGE_SIZE * NUM_PAGES, nullptr);
if (!m_paCache) {
return 1;
}
m_nNumFree = 29;
for (auto& pl : m_aPageLists) {
pl = {};
}
int page_idx = 0;
u8* page_start = (u8*)m_paCache;
for (auto& page : m_aPages) {
page = CPage(page_start, page_start + 0x7fff, page_idx);
page_start += PAGE_SIZE;
page_idx++;
}
return 0;
}
void CPageManager::Initialize() {
m_Cache.Initialize();
}
int CPageManager::TryFreePages(int nPages) {
return 0;
}
CPageManager::CPageList* CPageManager::AllocPageList(int nPages, char unk) {
CPageList* pList = nullptr;
CPage* apCollectedPages[29];
int nPageCount;
if (nPages <= 0) {
return nullptr;
}
if (m_Cache.m_nNumFree < nPages) {
if (nPages >= 29) {
return nullptr;
}
int nFreed = TryFreePages(nPages);
if (nFreed < nPages) {
return nullptr;
}
}
int nPageListID = std::countr_one(m_Cache.m_uAllocatedListMap);
if (nPages >= 29) {
return nullptr;
}
m_Cache.m_uAllocatedListMap |= 1u << nPageListID;
nPageCount = 0;
while (nPageCount < nPages) {
int nPageID = std::countr_one(m_Cache.m_uAllocatedPageMap);
}
}
} // namespace jak3

View File

@ -0,0 +1,104 @@
#pragma once
#include "common/common_types.h"
namespace jak3 {
class CPageManager {
public:
class CPageList;
enum class AllocState {
EPLAS_FREE,
EPLAS_ALLOCATED,
};
class CPage {
public:
CPage() = default;
CPage(u8*, u8*, int);
int AddRef();
int ReleaseRef();
int AddDmaRef();
int ReleaseDmaRef();
void FromPagesCopy(u8* pInPageData, u8* pDest, int nNumBytes);
u8* GetStart() const;
u8* GetEnd() const;
bool IsReferenced() { return m_nPageRefCount != 0 || m_nPageDmaRefCount != 0; }
bool IsFilled() const; // Exists as string in july version, not sure on impl
bool IsAllocated() const;
void SetPageInputState(int state); // enum
int GetPageCacheIndex() const;
CPage* GetNextPage() const;
CPage* GetPrevPage() const;
private:
CPage* m_pNextPage;
CPage* m_pPrevPage;
CPageList* m_pPageList;
int m_nPageRefCount;
int m_nPageDmaRefCount;
int m_nAllocState;
u32 m_nPageState; // 3: filled otherwise unk?
u8* m_pData;
u8* m_pDataEnd;
int m_nPageID;
u32 m_uPageBit;
};
class CPageList {
friend class CPage;
public:
int AddActivePages(int);
int CancelActivePages();
CPage* StepActivePage();
void GarbageCollect();
CPage* GetCurrentActivePage() const;
int GetNumRawPages() const;
int GetFirstRawPage() const;
int GetNumUnsteppedPages() const;
bool IsReferenced() { return m_nListRefCount != 0 || m_nListDmaRefCount != 0; }
int GetNumActivePages() const;
private:
CPage* m_pFirstPage;
CPage* m_pLastPage;
CPage* m_pFirstACtivePage;
CPage* m_pLastActivePage;
CPage* m_pCurrentActivePage;
int m_nNumPages;
int m_nNumActivePages;
int m_nNumUnsteppedPages;
int m_nListRefCount;
int m_nListDmaRefCount;
int m_nAllocState;
};
void Initialize();
CPageList* AllocPageListBytes(int nBytes, char unk);
CPageList* AllocPageList(int nPages, char unk);
CPageList* GrowPageList(CPageList* list, char nPages);
int FreePageList(CPageList* list);
int TryFreePages(int nUnk);
void GarbageCollect();
private:
class CCache {
public:
CCache();
int Initialize();
void* m_paCache;
CPageList m_aPageLists[29];
CPage m_aPages[29];
int m_nNumFree;
u32 m_uAllocatedPageMap;
u32 m_uAllocatedListMap;
int m_nEventFlag;
u32 m_Unk;
};
CCache m_Cache;
};
} // namespace jak3

View File

@ -0,0 +1,34 @@
#include "ramdisk.h"
#include "common/log/log.h"
#include "game/sce/iop.h"
namespace jak3 {
using namespace iop;
static u8 gRamDisk_RPCBUF[40];
static void* RPC_Ramdisk(u32 fno, void* data, int size) {
lg::error("RPC_RAMDISK UNIMPLEMENTED");
return nullptr;
}
void InitRamdisk() {}
u32 Thread_Server() {
sceSifQueueData dq;
sceSifServeData serve;
CpuDisableIntr();
sceSifInitRpc(0);
sceSifSetRpcQueue(&dq, GetThreadId());
sceSifRegisterRpc(&serve, 0xfab2, RPC_Ramdisk, gRamDisk_RPCBUF, sizeof(gRamDisk_RPCBUF), nullptr,
nullptr, &dq);
CpuEnableIntr();
sceSifRpcLoop(&dq);
return 0;
}
} // namespace jak3

View File

@ -0,0 +1,9 @@
#pragma once
#include "common/common_types.h"
namespace jak3 {
u32 Thread_Server();
}

View File

@ -0,0 +1,49 @@
#include "sbank.h"
#include "overlord.h"
namespace jak3 {
SoundBankInfo gCommonBank, gModeBank;
SoundBankInfo gLevelBanks[6];
SoundBankInfo* gBanks[8] = {
&gCommonBank, &gModeBank, &gLevelBanks[0], &gLevelBanks[1],
&gLevelBanks[2], &gLevelBanks[3], &gLevelBanks[4], &gLevelBanks[5],
};
void InitBanks() {
for (int i = 0; i < 8; i++) {
gBanks[i]->in_use = false;
gBanks[i]->unk = 0;
gBanks[i]->unk2 = 0;
gBanks[i]->index = i;
}
strncpyz(gBanks[0]->slot_name, "common", 16);
gBanks[0]->spu_size = 0xbbe40;
gBanks[0]->spu_loc = 0x1d1c0;
strncpyz(gBanks[1]->slot_name, "mode", 16);
gBanks[1]->spu_size = 0x25400;
gBanks[1]->spu_loc = 0xe0000;
strncpyz(gBanks[2]->slot_name, "level0", 16);
gBanks[2]->spu_size = 0x51400;
gBanks[2]->spu_loc = 0x105400;
strncpyz(gBanks[3]->slot_name, "level0h", 16);
gBanks[3]->spu_size = 0x28a00;
gBanks[3]->spu_loc = 0x12de00;
strncpyz(gBanks[4]->slot_name, "level1", 16);
gBanks[4]->spu_size = 0x51400;
gBanks[4]->spu_loc = 0x156800;
strncpyz(gBanks[5]->slot_name, "level1h", 16);
gBanks[5]->spu_size = 0x28a00;
gBanks[5]->spu_loc = 0x17f200;
strncpyz(gBanks[6]->slot_name, "level2", 16);
gBanks[6]->spu_size = 0x51400;
gBanks[6]->spu_loc = 0x1a7c00;
strncpyz(gBanks[7]->slot_name, "level2h", 16);
gBanks[7]->spu_size = 0x28a00;
gBanks[7]->spu_loc = 0x1d0600;
}
} // namespace jak3

View File

@ -0,0 +1,19 @@
#pragma once
#include "common/common_types.h"
namespace jak3 {
struct SoundBankInfo {
char bank_name[16];
char slot_name[16];
u32 spu_loc;
u32 spu_size;
u32 unk;
bool in_use;
u8 unk2;
u8 unk3;
u8 index;
u32 unk4;
};
void InitBanks();
} // namespace jak3

View File

@ -0,0 +1,56 @@
#include "srpc.h"
#include "common/log/log.h"
#include "game/sce/iop.h"
namespace jak3 {
using namespace iop;
constexpr int SRPC_MESSAGE_SIZE = 0x50;
constexpr int SRPC_MESSAGE_COUNT = 128;
static u8 s_anSRPC_PlayerBuf[SRPC_MESSAGE_SIZE * SRPC_MESSAGE_COUNT];
static u8 s_anSRPC_LoaderBuf[SRPC_MESSAGE_SIZE];
static void* RPC_Player(u32 fno, void* data, int size) {
lg::error("RPC_PLAYER UNIMPLEMENTED");
return nullptr;
}
static void* RPC_Loader(u32 fno, void* data, int size) {
lg::error("RPC_LOADER UNIMPLEMENTED");
return nullptr;
}
u32 Thread_Player() {
sceSifQueueData dq;
sceSifServeData serve;
CpuDisableIntr();
sceSifInitRpc(0);
sceSifSetRpcQueue(&dq, GetThreadId());
sceSifRegisterRpc(&serve, 0xfab0, RPC_Player, s_anSRPC_PlayerBuf, sizeof(s_anSRPC_PlayerBuf),
nullptr, nullptr, &dq);
CpuEnableIntr();
sceSifRpcLoop(&dq);
return 0;
}
u32 Thread_Loader() {
sceSifQueueData dq;
sceSifServeData serve;
CpuDisableIntr();
sceSifInitRpc(0);
sceSifSetRpcQueue(&dq, GetThreadId());
sceSifRegisterRpc(&serve, 0xfab1, RPC_Loader, s_anSRPC_LoaderBuf, sizeof(s_anSRPC_LoaderBuf),
nullptr, nullptr, &dq);
CpuEnableIntr();
sceSifRpcLoop(&dq);
return 0;
}
} // namespace jak3

10
game/overlord/jak3/srpc.h Normal file
View File

@ -0,0 +1,10 @@
#pragma once
#include "common/common_types.h"
namespace jak3 {
u32 Thread_Player();
u32 Thread_Loader();
} // namespace jak3

View File

@ -0,0 +1,115 @@
#include "overlord.h"
#include "common/common_types.h"
namespace jak3 {
static s16 angle_table[2056] = {
180, 0, 180, 0, 90, 90, 270, 270, 180, 0, 180, 0, 90, 90, 270, 270, 180, 0, 180, 0,
90, 90, 270, 270, 180, 0, 180, 0, 90, 90, 270, 270, 180, 0, 180, 0, 90, 90, 270, 270,
179, 1, 181, 359, 91, 89, 269, 271, 179, 1, 181, 359, 91, 89, 269, 271, 179, 1, 181, 359,
91, 89, 269, 271, 179, 1, 181, 359, 91, 89, 269, 271, 178, 2, 182, 358, 92, 88, 268, 272,
178, 2, 182, 358, 92, 88, 268, 272, 178, 2, 182, 358, 92, 88, 268, 272, 178, 2, 182, 358,
92, 88, 268, 272, 178, 2, 182, 358, 92, 88, 268, 272, 177, 3, 183, 357, 93, 87, 267, 273,
177, 3, 183, 357, 93, 87, 267, 273, 177, 3, 183, 357, 93, 87, 267, 273, 177, 3, 183, 357,
93, 87, 267, 273, 176, 4, 184, 356, 94, 86, 266, 274, 176, 4, 184, 356, 94, 86, 266, 274,
176, 4, 184, 356, 94, 86, 266, 274, 176, 4, 184, 356, 94, 86, 266, 274, 176, 4, 184, 356,
94, 86, 266, 274, 175, 5, 185, 355, 95, 85, 265, 275, 175, 5, 185, 355, 95, 85, 265, 275,
175, 5, 185, 355, 95, 85, 265, 275, 175, 5, 185, 355, 95, 85, 265, 275, 174, 6, 186, 354,
96, 84, 264, 276, 174, 6, 186, 354, 96, 84, 264, 276, 174, 6, 186, 354, 96, 84, 264, 276,
174, 6, 186, 354, 96, 84, 264, 276, 174, 6, 186, 354, 96, 84, 264, 276, 173, 7, 187, 353,
97, 83, 263, 277, 173, 7, 187, 353, 97, 83, 263, 277, 173, 7, 187, 353, 97, 83, 263, 277,
173, 7, 187, 353, 97, 83, 263, 277, 172, 8, 188, 352, 98, 82, 262, 278, 172, 8, 188, 352,
98, 82, 262, 278, 172, 8, 188, 352, 98, 82, 262, 278, 172, 8, 188, 352, 98, 82, 262, 278,
172, 8, 188, 352, 98, 82, 262, 278, 171, 9, 189, 351, 99, 81, 261, 279, 171, 9, 189, 351,
99, 81, 261, 279, 171, 9, 189, 351, 99, 81, 261, 279, 171, 9, 189, 351, 99, 81, 261, 279,
171, 9, 189, 351, 99, 81, 261, 279, 170, 10, 190, 350, 100, 80, 260, 280, 170, 10, 190, 350,
100, 80, 260, 280, 170, 10, 190, 350, 100, 80, 260, 280, 170, 10, 190, 350, 100, 80, 260, 280,
169, 11, 191, 349, 101, 79, 259, 281, 169, 11, 191, 349, 101, 79, 259, 281, 169, 11, 191, 349,
101, 79, 259, 281, 169, 11, 191, 349, 101, 79, 259, 281, 169, 11, 191, 349, 101, 79, 259, 281,
168, 12, 192, 348, 102, 78, 258, 282, 168, 12, 192, 348, 102, 78, 258, 282, 168, 12, 192, 348,
102, 78, 258, 282, 168, 12, 192, 348, 102, 78, 258, 282, 168, 12, 192, 348, 102, 78, 258, 282,
167, 13, 193, 347, 103, 77, 257, 283, 167, 13, 193, 347, 103, 77, 257, 283, 167, 13, 193, 347,
103, 77, 257, 283, 167, 13, 193, 347, 103, 77, 257, 283, 166, 14, 194, 346, 104, 76, 256, 284,
166, 14, 194, 346, 104, 76, 256, 284, 166, 14, 194, 346, 104, 76, 256, 284, 166, 14, 194, 346,
104, 76, 256, 284, 166, 14, 194, 346, 104, 76, 256, 284, 165, 15, 195, 345, 105, 75, 255, 285,
165, 15, 195, 345, 105, 75, 255, 285, 165, 15, 195, 345, 105, 75, 255, 285, 165, 15, 195, 345,
105, 75, 255, 285, 165, 15, 195, 345, 105, 75, 255, 285, 164, 16, 196, 344, 106, 74, 254, 286,
164, 16, 196, 344, 106, 74, 254, 286, 164, 16, 196, 344, 106, 74, 254, 286, 164, 16, 196, 344,
106, 74, 254, 286, 164, 16, 196, 344, 106, 74, 254, 286, 163, 17, 197, 343, 107, 73, 253, 287,
163, 17, 197, 343, 107, 73, 253, 287, 163, 17, 197, 343, 107, 73, 253, 287, 163, 17, 197, 343,
107, 73, 253, 287, 163, 17, 197, 343, 107, 73, 253, 287, 162, 18, 198, 342, 108, 72, 252, 288,
162, 18, 198, 342, 108, 72, 252, 288, 162, 18, 198, 342, 108, 72, 252, 288, 162, 18, 198, 342,
108, 72, 252, 288, 162, 18, 198, 342, 108, 72, 252, 288, 161, 19, 199, 341, 109, 71, 251, 289,
161, 19, 199, 341, 109, 71, 251, 289, 161, 19, 199, 341, 109, 71, 251, 289, 161, 19, 199, 341,
109, 71, 251, 289, 161, 19, 199, 341, 109, 71, 251, 289, 160, 20, 200, 340, 110, 70, 250, 290,
160, 20, 200, 340, 110, 70, 250, 290, 160, 20, 200, 340, 110, 70, 250, 290, 160, 20, 200, 340,
110, 70, 250, 290, 160, 20, 200, 340, 110, 70, 250, 290, 159, 21, 201, 339, 111, 69, 249, 291,
159, 21, 201, 339, 111, 69, 249, 291, 159, 21, 201, 339, 111, 69, 249, 291, 159, 21, 201, 339,
111, 69, 249, 291, 159, 21, 201, 339, 111, 69, 249, 291, 158, 22, 202, 338, 112, 68, 248, 292,
158, 22, 202, 338, 112, 68, 248, 292, 158, 22, 202, 338, 112, 68, 248, 292, 158, 22, 202, 338,
112, 68, 248, 292, 158, 22, 202, 338, 112, 68, 248, 292, 157, 23, 203, 337, 113, 67, 247, 293,
157, 23, 203, 337, 113, 67, 247, 293, 157, 23, 203, 337, 113, 67, 247, 293, 157, 23, 203, 337,
113, 67, 247, 293, 157, 23, 203, 337, 113, 67, 247, 293, 157, 23, 203, 337, 113, 67, 247, 293,
156, 24, 204, 336, 114, 66, 246, 294, 156, 24, 204, 336, 114, 66, 246, 294, 156, 24, 204, 336,
114, 66, 246, 294, 156, 24, 204, 336, 114, 66, 246, 294, 156, 24, 204, 336, 114, 66, 246, 294,
155, 25, 205, 335, 115, 65, 245, 295, 155, 25, 205, 335, 115, 65, 245, 295, 155, 25, 205, 335,
115, 65, 245, 295, 155, 25, 205, 335, 115, 65, 245, 295, 155, 25, 205, 335, 115, 65, 245, 295,
154, 26, 206, 334, 116, 64, 244, 296, 154, 26, 206, 334, 116, 64, 244, 296, 154, 26, 206, 334,
116, 64, 244, 296, 154, 26, 206, 334, 116, 64, 244, 296, 154, 26, 206, 334, 116, 64, 244, 296,
154, 26, 206, 334, 116, 64, 244, 296, 153, 27, 207, 333, 117, 63, 243, 297, 153, 27, 207, 333,
117, 63, 243, 297, 153, 27, 207, 333, 117, 63, 243, 297, 153, 27, 207, 333, 117, 63, 243, 297,
153, 27, 207, 333, 117, 63, 243, 297, 153, 27, 207, 333, 117, 63, 243, 297, 152, 28, 208, 332,
118, 62, 242, 298, 152, 28, 208, 332, 118, 62, 242, 298, 152, 28, 208, 332, 118, 62, 242, 298,
152, 28, 208, 332, 118, 62, 242, 298, 152, 28, 208, 332, 118, 62, 242, 298, 151, 29, 209, 331,
119, 61, 241, 299, 151, 29, 209, 331, 119, 61, 241, 299, 151, 29, 209, 331, 119, 61, 241, 299,
151, 29, 209, 331, 119, 61, 241, 299, 151, 29, 209, 331, 119, 61, 241, 299, 151, 29, 209, 331,
119, 61, 241, 299, 150, 30, 210, 330, 120, 60, 240, 300, 150, 30, 210, 330, 120, 60, 240, 300,
150, 30, 210, 330, 120, 60, 240, 300, 150, 30, 210, 330, 120, 60, 240, 300, 150, 30, 210, 330,
120, 60, 240, 300, 150, 30, 210, 330, 120, 60, 240, 300, 149, 31, 211, 329, 121, 59, 239, 301,
149, 31, 211, 329, 121, 59, 239, 301, 149, 31, 211, 329, 121, 59, 239, 301, 149, 31, 211, 329,
121, 59, 239, 301, 149, 31, 211, 329, 121, 59, 239, 301, 149, 31, 211, 329, 121, 59, 239, 301,
148, 32, 212, 328, 122, 58, 238, 302, 148, 32, 212, 328, 122, 58, 238, 302, 148, 32, 212, 328,
122, 58, 238, 302, 148, 32, 212, 328, 122, 58, 238, 302, 148, 32, 212, 328, 122, 58, 238, 302,
148, 32, 212, 328, 122, 58, 238, 302, 148, 32, 212, 328, 122, 58, 238, 302, 147, 33, 213, 327,
123, 57, 237, 303, 147, 33, 213, 327, 123, 57, 237, 303, 147, 33, 213, 327, 123, 57, 237, 303,
147, 33, 213, 327, 123, 57, 237, 303, 147, 33, 213, 327, 123, 57, 237, 303, 147, 33, 213, 327,
123, 57, 237, 303, 146, 34, 214, 326, 124, 56, 236, 304, 146, 34, 214, 326, 124, 56, 236, 304,
146, 34, 214, 326, 124, 56, 236, 304, 146, 34, 214, 326, 124, 56, 236, 304, 146, 34, 214, 326,
124, 56, 236, 304, 146, 34, 214, 326, 124, 56, 236, 304, 146, 34, 214, 326, 124, 56, 236, 304,
145, 35, 215, 325, 125, 55, 235, 305, 145, 35, 215, 325, 125, 55, 235, 305, 145, 35, 215, 325,
125, 55, 235, 305, 145, 35, 215, 325, 125, 55, 235, 305, 145, 35, 215, 325, 125, 55, 235, 305,
145, 35, 215, 325, 125, 55, 235, 305, 145, 35, 215, 325, 125, 55, 235, 305, 144, 36, 216, 324,
126, 54, 234, 306, 144, 36, 216, 324, 126, 54, 234, 306, 144, 36, 216, 324, 126, 54, 234, 306,
144, 36, 216, 324, 126, 54, 234, 306, 144, 36, 216, 324, 126, 54, 234, 306, 144, 36, 216, 324,
126, 54, 234, 306, 143, 37, 217, 323, 127, 53, 233, 307, 143, 37, 217, 323, 127, 53, 233, 307,
143, 37, 217, 323, 127, 53, 233, 307, 143, 37, 217, 323, 127, 53, 233, 307, 143, 37, 217, 323,
127, 53, 233, 307, 143, 37, 217, 323, 127, 53, 233, 307, 143, 37, 217, 323, 127, 53, 233, 307,
143, 37, 217, 323, 127, 53, 233, 307, 142, 38, 218, 322, 128, 52, 232, 308, 142, 38, 218, 322,
128, 52, 232, 308, 142, 38, 218, 322, 128, 52, 232, 308, 142, 38, 218, 322, 128, 52, 232, 308,
142, 38, 218, 322, 128, 52, 232, 308, 142, 38, 218, 322, 128, 52, 232, 308, 142, 38, 218, 322,
128, 52, 232, 308, 141, 39, 219, 321, 129, 51, 231, 309, 141, 39, 219, 321, 129, 51, 231, 309,
141, 39, 219, 321, 129, 51, 231, 309, 141, 39, 219, 321, 129, 51, 231, 309, 141, 39, 219, 321,
129, 51, 231, 309, 141, 39, 219, 321, 129, 51, 231, 309, 141, 39, 219, 321, 129, 51, 231, 309,
140, 40, 220, 320, 130, 50, 230, 310, 140, 40, 220, 320, 130, 50, 230, 310, 140, 40, 220, 320,
130, 50, 230, 310, 140, 40, 220, 320, 130, 50, 230, 310, 140, 40, 220, 320, 130, 50, 230, 310,
140, 40, 220, 320, 130, 50, 230, 310, 140, 40, 220, 320, 130, 50, 230, 310, 140, 40, 220, 320,
130, 50, 230, 310, 139, 41, 221, 319, 131, 49, 229, 311, 139, 41, 221, 319, 131, 49, 229, 311,
139, 41, 221, 319, 131, 49, 229, 311, 139, 41, 221, 319, 131, 49, 229, 311, 139, 41, 221, 319,
131, 49, 229, 311, 139, 41, 221, 319, 131, 49, 229, 311, 139, 41, 221, 319, 131, 49, 229, 311,
139, 41, 221, 319, 131, 49, 229, 311, 138, 42, 222, 318, 132, 48, 228, 312, 138, 42, 222, 318,
132, 48, 228, 312, 138, 42, 222, 318, 132, 48, 228, 312, 138, 42, 222, 318, 132, 48, 228, 312,
138, 42, 222, 318, 132, 48, 228, 312, 138, 42, 222, 318, 132, 48, 228, 312, 138, 42, 222, 318,
132, 48, 228, 312, 138, 42, 222, 318, 132, 48, 228, 312, 137, 43, 223, 317, 133, 47, 227, 313,
137, 43, 223, 317, 133, 47, 227, 313, 137, 43, 223, 317, 133, 47, 227, 313, 137, 43, 223, 317,
133, 47, 227, 313, 137, 43, 223, 317, 133, 47, 227, 313, 137, 43, 223, 317, 133, 47, 227, 313,
137, 43, 223, 317, 133, 47, 227, 313, 137, 43, 223, 317, 133, 47, 227, 313, 137, 43, 223, 317,
133, 47, 227, 313, 136, 44, 224, 316, 134, 46, 226, 314, 136, 44, 224, 316, 134, 46, 226, 314,
136, 44, 224, 316, 134, 46, 226, 314, 136, 44, 224, 316, 134, 46, 226, 314, 136, 44, 224, 316,
134, 46, 226, 314, 136, 44, 224, 316, 134, 46, 226, 314, 136, 44, 224, 316, 134, 46, 226, 314,
136, 44, 224, 316, 134, 46, 226, 314, 135, 45, 225, 315, 135, 45, 225, 315,
};
void InitSound() {}
} // namespace jak3

View File

@ -0,0 +1,39 @@
#pragma once
#include "common/common_types.h"
#include "game/overlord/jak3/overlord.h"
namespace jak3 {
struct Curve {
s32 p1;
s32 p2;
s32 p3;
s32 p4;
};
struct SoundPlayParams {
u16 mask;
s16 pitch_mod;
s16 bend;
s16 fo_min;
s16 fo_max;
s8 fo_curve;
s8 priority;
s32 volume;
Vec3 trans;
u8 group;
u8 reg[3];
};
struct SoundInfo {
char name[16];
s32 id;
u32 sound_handle;
s32 auto_volume;
s32 auto_time;
SoundPlayParams params;
};
} // namespace jak3

View File

@ -0,0 +1,124 @@
#include <cstdio>
#include <cstring>
#include "iso.h"
#include "overlord.h"
#include "ramdisk.h"
#include "sbank.h"
#include "game/overlord/jak3/srpc.h"
#include "game/sce/iop.h"
namespace jak3 {
using namespace iop;
int g_nServerThreadID;
int g_nPlayerThreadID;
int g_nLoaderThreadID;
int start_overlord(int argc, const char* const* argp) {
ThreadParam thp;
if (argc < 0) {
Panic();
}
if (sceSifCheckInit() == 0) {
sceSifInit();
}
sceSifInitRpc(0);
printf("======== overlrd2.irx startup ========\n");
// printf(" mem size: %lu\n", QueryMemSize());
// printf("total mem free: %lu\n", QueryTotalFreeMemSize());
// printf(" max mem free: %lu\n", QueryMaxFreeMemSize());
// printf(" used: %lu\n", QueryMemSize() - QueryTotalFreeMemSize());
// printf(" start() addr: 0x%08x\n", start_overlord);
//__do_global_ctors();
InitBanks();
InitSound();
VBlank_Initialize();
thp.attr = TH_C;
thp.option = 0;
thp.entry = Thread_Server;
thp.stackSize = 0x800;
thp.initPriority = 59;
g_nServerThreadID = CreateThread(&thp);
if (g_nServerThreadID < 0) {
Panic();
return 1;
}
thp.attr = TH_C;
thp.option = 0;
thp.entry = Thread_Player;
thp.stackSize = 0xb00;
thp.initPriority = 54;
g_nPlayerThreadID = CreateThread(&thp);
if (g_nPlayerThreadID < 0) {
Panic();
return 1;
}
thp.attr = TH_C;
thp.option = 0;
thp.entry = Thread_Loader;
thp.stackSize = 0x900;
thp.initPriority = 58;
g_nLoaderThreadID = CreateThread(&thp);
if (g_nPlayerThreadID < 0) {
Panic();
return 1;
}
// CDvdDriver::Initialize(&g_DvdDriver);
InitISOFS(argp[1], argp[2]);
StartThread(g_nServerThreadID, 0);
StartThread(g_nPlayerThreadID, 0);
StartThread(g_nLoaderThreadID, 0);
printf("======== overlrd2.irx post-startup ========\n");
// printf(" mem size: %lu\n", QueryMemSize());
// printf("total mem free: %lu\n", QueryTotalFreeMemSize());
// printf(" max mem free: %lu\n", QueryMaxFreeMemSize());
// printf(" used: %lu\n", QueryMemSize() - QueryTotalFreeMemSize());
return 0;
}
static s32 gargc;
static const char* const* gargv;
static bool* init_complete;
static u32 call_start() {
start_overlord(gargc, gargv);
*init_complete = true;
while (true) {
SleepThread();
}
return 0;
}
int start_overlord_wrapper(int argc, const char* const* argv, bool* signal) {
ThreadParam param = {};
gargc = argc;
gargv = argv;
init_complete = signal;
param.attr = TH_C;
param.initPriority = 0;
param.stackSize = 0x800;
param.option = 0;
strcpy(param.name, "start"); // added for debug
param.entry = call_start;
auto start_thread = CreateThread(&param);
StartThread(start_thread, 0);
return 0;
}
} // namespace jak3

View File

@ -0,0 +1,54 @@
#include "common/common_types.h"
#include "common/log/log.h"
#include "game/common/str_rpc_types.h"
#include "game/sce/iop.h"
namespace jak3 {
using namespace iop;
static RPC_Str_Cmd_Jak2 sRPCBuf[1];
static RPC_Str_Cmd_Jak2 sRPCBuf2[4];
static void* RPC_STR(unsigned int /*fno*/, void* _cmd, int /*y*/);
static void* RPC_PLAY(unsigned int /*fno*/, void* _cmd, int size);
u32 STRThread() {
sceSifQueueData dq;
sceSifServeData serve;
CpuDisableIntr();
sceSifInitRpc(0);
sceSifSetRpcQueue(&dq, GetThreadId());
sceSifRegisterRpc(&serve, 0xfab4, RPC_STR, sRPCBuf, sizeof(sRPCBuf), nullptr, nullptr, &dq);
CpuEnableIntr();
sceSifRpcLoop(&dq);
return 0;
}
u32 PLAYThread() {
sceSifQueueData dq;
sceSifServeData serve;
CpuDisableIntr();
sceSifInitRpc(0);
sceSifSetRpcQueue(&dq, GetThreadId());
sceSifRegisterRpc(&serve, 0xfab5, RPC_PLAY, sRPCBuf2, sizeof(sRPCBuf2), nullptr, nullptr, &dq);
CpuEnableIntr();
sceSifRpcLoop(&dq);
return 0;
}
static void* RPC_STR(unsigned int /*fno*/, void* _cmd, int /*y*/) {
lg::error("RPC_STR UNIMPLEMENTED");
return nullptr;
}
static void* RPC_PLAY(unsigned int /*fno*/, void* _cmd, int size) {
lg::error("RPC_PLAY UNIMPLEMENTED");
return nullptr;
}
} // namespace jak3

View File

@ -0,0 +1,11 @@
#ifndef STREAM_H_
#define STREAM_H_
#include "common/common_types.h"
namespace jak3 {
u32 STRThread();
u32 PLAYThread();
} // namespace jak3
#endif // STREAM_H_

View File

@ -0,0 +1,9 @@
#include "overlord.h"
namespace jak3 {
int VBlank_Initialize() {
return 0;
}
} // namespace jak3

View File

@ -4,6 +4,7 @@
*/
#include "common/common_types.h"
#ifdef OS_POSIX
#include <unistd.h>
@ -78,6 +79,7 @@
#include "game/overlord/jak2/stream.h"
#include "game/overlord/jak2/streamlist.h"
#include "game/overlord/jak2/vag.h"
#include "game/overlord/jak3/overlord.h"
#include "game/system/Deci2Server.h"
#include "game/system/iop_thread.h"
#include "sce/deci2.h"
@ -323,9 +325,11 @@ void iop_runner(SystemThreadInterface& iface, GameVersion version) {
jak1::start_overlord_wrapper(iop.overlord_argc, iop.overlord_argv, &complete);
break;
case GameVersion::Jak2:
case GameVersion::Jak3: // TODO: jak3 using jak2's overlord.
jak2::start_overlord_wrapper(iop.overlord_argc, iop.overlord_argv, &complete);
break;
case GameVersion::Jak3:
jak3::start_overlord_wrapper(iop.overlord_argc, iop.overlord_argv, &complete);
break;
default:
ASSERT_NOT_REACHED();
}

View File

@ -195,6 +195,10 @@ s32 SendMbx(s32 mbxid, void* sendmsg) {
return iop->kernel.SendMbx(mbxid, sendmsg);
}
s32 ReceiveMbx(MsgPacket** recvmsg, int mbxid) {
return iop->kernel.ReceiveMbx((void**)recvmsg, mbxid);
}
s32 PollMbx(MsgPacket** recvmsg, int mbxid) {
return iop->kernel.PollMbx((void**)recvmsg, mbxid);
}
@ -247,4 +251,14 @@ s32 RegisterVblankHandler(int edge, int priority, int (*handler)(void*), void* /
return iop->kernel.RegisterVblankHandler(handler);
}
s32 CpuSuspendIntr(int* old_state) {
(void)old_state;
return KE_OK;
}
s32 CpuResumeIntr(int old_state) {
(void)old_state;
return KE_OK;
}
} // namespace iop

View File

@ -30,6 +30,12 @@
#define SA_THFIFO 0
#define SA_THPRI 1
// Message box attributes
#define MBA_THFIFO 0x000
#define MBA_THPRI 0x001
#define MBA_MSFIFO 0x000
#define MBA_MSPRI 0x004
class IOP;
namespace iop {
@ -134,6 +140,7 @@ int sceCdDiskReady(int mode);
u32 sceSifSetDma(sceSifDmaData* sdd, int len);
s32 SendMbx(int mbxid, void* sendmsg);
s32 ReceiveMbx(MsgPacket** recvmsg, int mbxid);
s32 PollMbx(MsgPacket** recvmsg, int mbxid);
s32 PeekMbx(s32 mbx);
s32 CreateMbx(MbxParam* param);
@ -152,6 +159,9 @@ void FlushDcache();
u32 sceSifCheckInit();
void sceSifInit();
s32 CpuSuspendIntr(int* old_state);
s32 CpuResumeIntr(int old_state);
void LIBRARY_INIT();
void LIBRARY_register(::IOP* i);
void LIBRARY_kill();

View File

@ -103,6 +103,12 @@ void IOP_Kernel::iWakeupThread(s32 id) {
wakeup_queue.push(id);
}
s32 IOP_Kernel::CreateSema(s32 attr, s32 option, s32 init_count, s32 max_count) {
s32 id = semas.size();
semas.emplace_back((Semaphore::attribute)attr, option, init_count, max_count);
return id;
}
s32 IOP_Kernel::WaitSema(s32 id) {
auto& sema = semas.at(id);
if (sema.count > 0) {
@ -159,6 +165,81 @@ s32 IOP_Kernel::PollSema(s32 id) {
return KE_SEMA_ZERO;
}
/*!
* Create a message box
*/
s32 IOP_Kernel::CreateMbx() {
s32 id = mbxs.size();
mbxs.emplace_back();
return id;
}
s32 IOP_Kernel::ReceiveMbx(void** msg, s32 mbx) {
ASSERT(mbx < (s32)mbxs.size());
s32 gotSomething = mbxs[mbx].messages.empty() ? 0 : 1;
if (!gotSomething) {
/* Was empty, wait until there's messages */
mbxs[mbx].wait_list.push_back(_currentThread);
_currentThread->state = IopThread::State::Wait;
_currentThread->waitType = IopThread::Wait::MsgBox;
leaveThread();
}
ASSERT(mbxs[mbx].messages.empty() == false);
void* thing = mbxs[mbx].messages.front();
if (msg) {
*msg = thing;
}
mbxs[mbx].messages.pop();
return KE_OK;
}
/*!
* Set msg to thing if its there and pop it.
* Returns if it got something.
*/
s32 IOP_Kernel::PollMbx(void** msg, s32 mbx) {
ASSERT(mbx < (s32)mbxs.size());
s32 gotSomething = mbxs[mbx].messages.empty() ? 0 : 1;
if (gotSomething) {
void* thing = mbxs[mbx].messages.front();
if (msg) {
*msg = thing;
}
mbxs[mbx].messages.pop();
}
return gotSomething ? KE_OK : KE_MBOX_NOMSG;
}
s32 IOP_Kernel::PeekMbx(s32 mbx) {
return !mbxs[mbx].messages.empty();
}
/*!
* Push something into a mbx
*/
s32 IOP_Kernel::SendMbx(s32 mbx, void* value) {
ASSERT(mbx < (s32)mbxs.size());
mbxs[mbx].messages.push(value);
IopThread* to_run = nullptr;
if (!mbxs[mbx].wait_list.empty()) {
to_run = mbxs[mbx].wait_list.front();
mbxs[mbx].wait_list.pop_front();
to_run->waitType = IopThread::Wait::None;
to_run->state = IopThread::State::Ready;
}
return KE_OK;
}
/*!
* Return to kernel from a thread, not to be called from the kernel thread.
*/

View File

@ -57,6 +57,7 @@ struct IopThread {
None,
Semaphore,
Delay,
MsgBox,
};
IopThread(std::string n, void (*f)(), s32 ID, u32 priority)
@ -91,6 +92,11 @@ struct Semaphore {
std::list<IopThread*> wait_list;
};
struct MsgBox {
std::queue<void*> messages;
std::list<IopThread*> wait_list;
};
class IOP_Kernel {
public:
IOP_Kernel() {
@ -122,52 +128,13 @@ class IOP_Kernel {
return _currentThread->thID;
}
/*!
* Create a message box
*/
s32 CreateMbx() {
s32 id = mbxs.size();
mbxs.emplace_back();
return id;
}
/*!
* Set msg to thing if its there and pop it.
* Returns if it got something.
*/
s32 PollMbx(void** msg, s32 mbx) {
ASSERT(mbx < (s32)mbxs.size());
s32 gotSomething = mbxs[mbx].empty() ? 0 : 1;
if (gotSomething) {
void* thing = mbxs[mbx].front();
if (msg) {
*msg = thing;
}
mbxs[mbx].pop();
}
return gotSomething ? KE_OK : KE_MBOX_NOMSG;
}
s32 PeekMbx(s32 mbx) { return !mbxs[mbx].empty(); }
/*!
* Push something into a mbx
*/
s32 SendMbx(s32 mbx, void* value) {
ASSERT(mbx < (s32)mbxs.size());
mbxs[mbx].push(value);
return 0;
}
s32 CreateSema(s32 attr, s32 option, s32 init_count, s32 max_count) {
s32 id = semas.size();
semas.emplace_back((Semaphore::attribute)attr, option, init_count, max_count);
return id;
}
s32 CreateMbx();
s32 ReceiveMbx(void** msg, s32 mbx);
s32 PollMbx(void** msg, s32 mbx);
s32 PeekMbx(s32 mbx);
s32 SendMbx(s32 mbx, void* value);
s32 CreateSema(s32 attr, s32 option, s32 init_count, s32 max_count);
s32 WaitSema(s32 id);
s32 SignalSema(s32 id);
s32 PollSema(s32 id);
@ -205,7 +172,7 @@ class IOP_Kernel {
s32 _nextThID = 0;
IopThread* _currentThread = nullptr;
std::vector<IopThread> threads;
std::vector<std::queue<void*>> mbxs;
std::vector<MsgBox> mbxs;
std::vector<SifRecord> sif_records;
std::vector<Semaphore> semas;
std::queue<int> wakeup_queue;

View File

@ -34,6 +34,7 @@
"dma-buffer.o"
"dma-bucket.o"
"dma-disasm.o"
"pc-cheats.o" ;; added
"pckernel-h.o" ;; added
"pckernel-impl.o" ;; added
"pc-debug-common.o" ;; added

View File

@ -30,6 +30,7 @@
"dma-buffer.o"
"dma-bucket.o"
"dma-disasm.o"
"pc-cheats.o" ;; added
"pckernel-h.o" ;; added
"pckernel-impl.o" ;; added
"pc-debug-common.o" ;; added

View File

@ -1,5 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/draw/drawable-h.gc")
(require "kernel/gstate.gc")
;; name: aligner-h.gc
;; name in dgo: aligner-h

View File

@ -1,5 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/anim/aligner-h.gc")
(require "engine/common-obs/process-drawable.gc")
;; name: aligner.gc
;; name in dgo: aligner

View File

@ -1,5 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "GAME.CGO")
(require "engine/collide/collide-cache.gc")
(require "engine/common-obs/process-drawable.gc")
;; name: joint-exploder.gc
;; name in dgo: joint-exploder

View File

@ -1,5 +1,8 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "kernel-defs.gc")
;; name: joint-h.gc
;; name in dgo: joint-h

View File

@ -1,5 +1,16 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/geometry/geometry.gc")
(require "engine/game/main-h.gc")
(require "engine/debug/debug-h.gc")
(require "engine/math/transformq-h.gc")
(require "engine/math/vector.gc")
(require "engine/game/fact-h.gc")
(require "engine/anim/joint-h.gc")
(require "engine/anim/mspace-h.gc")
(require "engine/game/game-h.gc")
;; name: joint-mod-h.gc
;; name in dgo: joint-mod-h

View File

@ -1,5 +1,14 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/entity/res.gc")
(require "engine/gfx/background/subdivide-h.gc")
(require "engine/math/transformq.gc")
(require "engine/anim/joint-h.gc")
(require "engine/data/art-h.gc")
(require "engine/anim/mspace-h.gc")
(require "engine/game/game-h.gc")
;; name: joint.gc
;; name in dgo: joint

View File

@ -1,5 +1,8 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "kernel/gcommon.gc")
;; name: mspace-h.gc
;; name in dgo: mspace-h

View File

@ -1,5 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/gfx/hw/display.gc")
(require "engine/camera/camera.gc")
;; name: cam-combiner.gc
;; name in dgo: cam-combiner

View File

@ -1,5 +1,8 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "kernel-defs.gc")
;; name: cam-debug-h.gc
;; name in dgo: cam-debug-h

View File

@ -1,5 +1,14 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/collide/pat-h.gc")
(require "engine/anim/joint-mod-h.gc")
(require "engine/math/euler.gc")
(require "engine/geometry/bounding-box-h.gc")
(require "engine/debug/debug.gc")
(require "engine/collide/collide-mesh-h.gc")
(require "engine/camera/camera.gc")
;; name: cam-debug.gc
;; name in dgo: cam-debug

View File

@ -1,5 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/camera/camera-h.gc")
(require "engine/math/matrix-h.gc")
;; name: cam-interface-h.gc
;; name in dgo: cam-interface-h

View File

@ -1,5 +1,13 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/camera/cam-interface-h.gc")
(require "engine/math/quaternion.gc")
(require "kernel/gstate.gc")
(require "engine/gfx/math-camera-h.gc")
(require "engine/entity/entity-h.gc")
(require "engine/math/transformq-h.gc")
;; name: cam-interface.gc
;; name in dgo: cam-interface

View File

@ -1,5 +1,10 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/ps2/pad.gc")
(require "engine/geometry/vol-h.gc")
(require "engine/camera/camera.gc")
;; name: cam-layout.gc
;; name in dgo: cam-layout

View File

@ -1,5 +1,13 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/game/projectiles-h.gc")
(require "engine/physics/dynamics-h.gc")
(require "engine/gfx/mood/weather-part.gc")
(require "engine/anim/joint-mod-h.gc")
(require "engine/collide/collide-mesh-h.gc")
(require "engine/camera/camera.gc")
;; name: cam-master.gc
;; name in dgo: cam-master

View File

@ -1,5 +1,8 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/camera/cam-combiner.gc")
;; name: cam-start.gc
;; name in dgo: cam-start

View File

@ -1,5 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/camera/camera.gc")
(require "pc/pckernel-impl.gc")
;; name: cam-states-dbg.gc
;; name in dgo: cam-states-dbg

View File

@ -1,5 +1,14 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/camera/pov-camera-h.gc")
(require "engine/collide/collide-mesh-h.gc")
(require "engine/camera/camera.gc")
(require "engine/nav/navigate-h.gc")
(require "engine/collide/collide-cache-h.gc")
(require "engine/anim/joint-h.gc")
(require "engine/debug/debug.gc")
;; name: cam-states.gc
;; name in dgo: cam-states

View File

@ -1,5 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/math/matrix.gc")
(require "engine/util/smush-control-h.gc")
;; name: cam-update-h.gc
;; name in dgo: cam-update-h

View File

@ -1,5 +1,16 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/gfx/tie/tie-h.gc")
(require "engine/level/bsp-h.gc")
(require "engine/gfx/math-camera.gc")
(require "engine/load/decomp.gc")
(require "engine/gfx/shrub/shrubbery-h.gc")
(require "engine/physics/dynamics-h.gc")
(require "engine/math/vector.gc")
(require "engine/gfx/background/wind.gc")
(require "engine/math/quaternion.gc")
;; name: cam-update.gc
;; name in dgo: cam-update

View File

@ -1,5 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/math/vector-h.gc")
(require "engine/gfx/hw/display-h.gc")
;; name: camera-h.gc
;; name in dgo: camera-h

View File

@ -1,5 +1,17 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/engine/engines.gc")
(require "engine/entity/res.gc")
(require "engine/camera/cam-debug-h.gc")
(require "engine/geometry/geometry.gc")
(require "engine/game/main-h.gc")
(require "engine/util/smush-control-h.gc")
(require "engine/entity/entity-h.gc")
(require "engine/math/vector.gc")
(require "kernel/gstate.gc")
(require "engine/camera/cam-interface-h.gc")
;; name: camera.gc
;; name in dgo: camera

View File

@ -1,5 +1,8 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/game/game-h.gc")
;; name: pov-camera-h.gc
;; name in dgo: pov-camera-h

View File

@ -1,5 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/camera/pov-camera-h.gc")
(require "engine/common-obs/water.gc")
;; name: pov-camera.gc
;; name in dgo: pov-camera

View File

@ -1,5 +1,8 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "kernel-defs.gc")
;; name: collide-cache-h.gc
;; name in dgo: collide-cache-h

View File

@ -1,5 +1,17 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/gfx/background/subdivide.gc")
(require "engine/collide/collide-func.gc")
(require "examples/debug-collide.gc")
(require "engine/collide/collide-probe.gc")
(require "engine/geometry/bounding-box.gc")
(require "engine/collide/collide-mesh-h.gc")
(require "engine/collide/main-collide.gc")
(require "engine/common-obs/water-h.gc")
(require "engine/collide/collide-shape-h.gc")
(require "engine/debug/debug.gc")
;; name: collide-cache.gc
;; name in dgo: collide-cache

View File

@ -1,5 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/math/vector-h.gc")
(require "engine/geometry/bounding-box-h.gc")
;; name: collide-edge-grab-h.gc
;; name in dgo: collide-edge-grab-h

View File

@ -1,5 +1,14 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/collide/surface-h.gc")
(require "engine/collide/collide-edge-grab-h.gc")
(require "kernel/gstate.gc")
(require "engine/collide/collide-cache-h.gc")
(require "engine/target/target-h.gc")
(require "engine/collide/collide-shape-h.gc")
(require "engine/debug/debug.gc")
;; name: collide-edge-grab.gc
;; name in dgo: collide-edge-grab

View File

@ -1,5 +1,10 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/math/vector-h.gc")
(require "engine/draw/drawable-tree-h.gc")
(require "engine/draw/drawable-inline-array-h.gc")
;; name: collide-frag-h.gc
;; name in dgo: collide-frag-h

View File

@ -1,5 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/level/bsp.gc")
(require "engine/collide/collide-frag-h.gc")
;; name: collide-frag.gc
;; name in dgo: collide-frag

View File

@ -1,6 +1,6 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
;; name: collide-func-h.gc
;; name in dgo: collide-func-h
;; dgos: GAME, ENGINE

View File

@ -1,5 +1,9 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/math/vector.gc")
(require "kernel/gkernel-h.gc")
;; name: collide-func.gc
;; name in dgo: collide-func

View File

@ -1,6 +1,6 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
;; name: collide-h.gc
;; name in dgo: collide-h
;; dgos: GAME, ENGINE

View File

@ -1,5 +1,8 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "kernel-defs.gc")
;; name: collide-mesh-h.gc
;; name in dgo: collide-mesh-h

View File

@ -1,5 +1,10 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/collide/pat-h.gc")
(require "engine/debug/debug.gc")
(require "engine/collide/collide-mesh-h.gc")
;; name: collide-mesh.gc
;; name in dgo: collide-mesh

View File

@ -1,5 +1,13 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/level/level-h.gc")
(require "kernel/gkernel.gc")
(require "engine/collide/collide-cache-h.gc")
(require "engine/gfx/tie/tie-h.gc")
(require "engine/collide/collide-frag-h.gc")
(require "engine/draw/draw-node-h.gc")
;; name: collide-probe.gc
;; name in dgo: collide-probe

View File

@ -1,5 +1,13 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/collide/pat-h.gc")
(require "engine/math/quaternion.gc")
(require "kernel/gkernel-h.gc")
(require "engine/math/transformq-h.gc")
(require "engine/game/game-h.gc")
(require "engine/engine/connect.gc")
;; name: collide-shape-h.gc
;; name in dgo: collide-shape-h

View File

@ -1,5 +1,8 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/collide/collide-shape.gc")
;; name: collide-shape-rider.gc
;; name in dgo: collide-shape-rider

View File

@ -1,5 +1,17 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/camera/camera-h.gc")
(require "engine/geometry/cylinder.gc")
(require "engine/collide/collide-target-h.gc")
(require "engine/math/transformq.gc")
(require "engine/collide/collide-probe.gc")
(require "engine/collide/collide-mesh.gc")
(require "engine/collide/collide-edge-grab.gc")
(require "engine/gfx/sprite/sparticle/sparticle-launcher.gc")
(require "engine/gfx/background/subdivide-h.gc")
(require "engine/collide/collide-touch.gc")
;; name: collide-shape.gc
;; name in dgo: collide-shape

View File

@ -1,5 +1,8 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/collide/collide-shape-h.gc")
;; name: collide-target-h.gc
;; name in dgo: collide-target-h

View File

@ -1,5 +1,8 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "kernel-defs.gc")
;; name: collide-touch-h.gc
;; name in dgo: collide-touch-h

View File

@ -1,5 +1,12 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/collide/collide-touch-h.gc")
(require "kernel/gstate.gc")
(require "engine/target/target-h.gc")
(require "engine/collide/collide-shape-h.gc")
(require "engine/collide/collide-mesh-h.gc")
;; name: collide-touch.gc
;; name in dgo: collide-touch

View File

@ -1,5 +1,8 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "kernel-defs.gc")
;; name: collide.gc
;; name in dgo: collide

View File

@ -1,5 +1,12 @@
;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "engine/math/vector-h.gc")
(require "engine/gfx/tie/tie-h.gc")
(require "engine/ps2/vu1-macros.gc")
(require "engine/geometry/bounding-box-h.gc")
(require "engine/math/math.gc")
;; name: main-collide.gc
;; name in dgo: main-collide

Some files were not shown because too many files have changed in this diff Show More