Merge branch 'master' into d/pal-pass

This commit is contained in:
ManDude
2022-06-22 01:59:52 +01:00
132 changed files with 20835 additions and 10032 deletions
+52
View File
@@ -0,0 +1,52 @@
name: Bug Report
description: Create a bug report.
labels: ["bug"]
body:
- type: textarea
attributes:
label: Describe the Bug
description: A clear and concise description of what the bug is. You may post screenshots or videos of the bug here.
validations:
required: true
- type: textarea
attributes:
label: How To Reproduce
description: Steps to reproduce the behavior. You can also post a video of it here.
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: A clear and concise description of the expected behavior.
placeholder: When I do X, Y should happen.
validations:
required: true
- type: input
attributes:
label: Operating System
description: Windows version, Linux distribution, etc.
validations:
required: true
- type: dropdown
attributes:
label: OpenGOAL Version
options:
- Release
- Compiled from source
validations:
required: true
- type: dropdown
attributes:
label: Game Version
options:
- NTSC 1.0 (black label)
- NTSC Greatest Hits version (red label)
- PAL
- JP
validations:
required: true
@@ -0,0 +1,24 @@
name: Enhancement Request
description: Suggest an improvement for an existing feature.
labels: ["enhancement"]
body:
- type: textarea
attributes:
label: What feature is your idea related to?
description: A clear and concise description of what the problem is.
validations:
required: true
- type: textarea
attributes:
label: Describe the solution you'd like.
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: Additional context
description: Any other context or screenshots about the enhancement request here.
validations:
required: false
@@ -0,0 +1,24 @@
name: Feature Request
description: Suggest an idea for the game
labels: ["game"]
body:
- type: textarea
attributes:
label: Is your feature request related to a problem?
description: A clear and concise description of what the problem is.
validations:
required: true
- type: textarea
attributes:
label: Describe the solution you'd like.
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: Additional context
description: Add any other context or screenshots about the feature request here.
validations:
required: false
@@ -28,3 +28,4 @@ cp -r $SOURCE/decompiler/config $DEST/data/decompiler/
cp -r $SOURCE/goal_src $DEST/data
cp -r $SOURCE/game/assets $DEST/data/game/
cp -r $SOURCE/game/graphics/opengl_renderer/shaders $DEST/data/game/graphics/opengl_renderer
cp -r $SOURCE/custom_levels $DEST/data
@@ -24,3 +24,4 @@ cp -r $SOURCE/decompiler/config $DEST/data/decompiler/
cp -r $SOURCE/goal_src $DEST/data
cp -r $SOURCE/game/assets $DEST/data/game/
cp -r $SOURCE/game/graphics/opengl_renderer/shaders $DEST/data/game/graphics/opengl_renderer
cp -r $SOURCE/custom_levels $DEST/data
+4
View File
@@ -162,6 +162,10 @@ add_subdirectory(third-party/lzokay EXCLUDE_FROM_ALL)
# build format library
add_subdirectory(third-party/fmt EXCLUDE_FROM_ALL)
add_subdirectory(third-party/stb_image EXCLUDE_FROM_ALL)
add_subdirectory(third-party/tiny_gltf EXCLUDE_FROM_ALL)
# discord rich presence
include_directories(third-party/discord-rpc/include)
add_subdirectory(third-party/discord-rpc EXCLUDE_FROM_ALL)
+2 -2
View File
@@ -37,7 +37,7 @@ The original game had a few issues of varying severity - from progress softlocks
In the future yes! We intend to make it as easy as we can to make your own code or import graphics for the game.
### What is this menu? Why am I not dying sometimes?
This might be the result of the game beeing booted in debugging mode. The project is still in development and we rely on the game's built-in debug features (along with some we made ourselves) for testing and development. The final product will have this debug mode disabled. In the meantime, have fun with all the options! Keep in mind some don't work very well.
This might be the result of the game being booted in debugging mode. The project is still in development and we rely on the game's built-in debug features (along with some we made ourselves) for testing and development. The final product will have this debug mode disabled. In the meantime, have fun with all the options! Keep in mind some don't work very well.
### What are the minimum requirements?
These are not totally set in stone as the project is not complete. These are the minimum architecture requirements for the project:
@@ -49,7 +49,7 @@ These are not totally set in stone as the project is not complete. These are the
Probably yes, in the future!
### I'd like to contribute, but don't know where to start!
Great to hear! Any help is good help. If you haven't already, please read the project readme. It has information on what is done, what isn't done, what is being worked on, the project layout and how it all works. Then just join our development discord server and we can help you further.
Great to hear! Any help is good help. If you haven't already, please read the project readme. It has information on what is done, what isn't done, what is being worked on, the project layout and how it all works. Then just join our development Discord server and we can help you further.
### Will you also decompile other games that aren't Jak?
No.
+32 -7
View File
@@ -46,7 +46,7 @@ This project is to port Jak 1 (NTSC, "black label" version) to PC. Over 98% of t
- create tools to repack game assets into a format that our port uses.
Our objectives are:
- make the port a "native application" on x86-64, with high performance. It shouldn't emulated, interpreted, or transpiled.
- make the port a "native application" on x86-64, with high performance. It shouldn't be emulated, interpreted, or transpiled.
- Our GOAL compiler's performance should be around the same as unoptimized C.
- try to match things from the original game and development as possible. For example, the original GOAL compiler supported live modification of code while the game is running, so we do the same, even though it's not required for just porting the game.
- support modifications. It should be possible to make edits to the code without everything else breaking.
@@ -85,7 +85,7 @@ We don't save any assets from the game - you must bring your own copy of the gam
Install packages and init repository:
```sh
sudo apt install gcc make cmake build-essential g++ nasm clang-format libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev python
sudo apt install gcc make cmake build-essential g++ nasm clang-format libxrandr-dev libxinerama-dev libxcursor-dev libpulse-dev libxi-dev python
sudo sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin
```
@@ -118,10 +118,12 @@ cmake -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_EXE_LINKER_FLAGS="-fuse
Install packages and init repository:
```sh
sudo pacman -S gcc make cmake base-devel g++ nasm python
yay -S taskfile-git
sudo pacman -S cmake libpulse base-devel nasm python
yay -S go-task
```
For Arch only, replace `task` with `go-task` in the rest of the instructions.
Compile:
```sh
@@ -134,6 +136,28 @@ Run tests:
./test.sh
```
### Fedora
Install packages and init repository:
```sh
sudo dnf install cmake lld clang nasm libX11-devel libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel pulseaudio-libs-devel
sudo sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin
```
Compile with `clang`:
```sh
cmake -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -B build
cmake --build build -j$(nproc)
```
Run tests:
```sh
./test.sh
```
## Getting Started - Windows
### Required Software
@@ -293,7 +317,7 @@ The second component to the project is the decompiler. You must have a copy of t
Then run `decomp.sh` (Linux) or `decomp-jak1.bat` (Windows) to run the decompiler. The decompiler will extract assets to the `assets` folder. These assets will be used by the compiler when building the port, and you may want to turn asset extraction off after running it once. The decompiler will output code and other data intended to be inspected by humans in the `decompiler_out` folder. Stuff in this folder will not be used by the compiler.
The third is the game source code, written in OpenGOAL. This is located in `goal_src`. All GOAL and GOOS code should be in this folder. Right now most of this is placeholders or incomplete, but you can take a look at `kernel/gcommon.gc` or `goal-lib.gc` to see some in-progress source code.
The third is the game source code, written in OpenGOAL. This is located in `goal_src`. All GOAL and GOOS code should be in this folder.
The final component is the "runtime", located in `game`. This is the part of the game that's written in C++. In the port, that includes:
- The "C Kernel", which contains the GOAL linker and some low-level GOAL language features. GOAL has a completely custom dynamically linked object file format so in order to load the first GOAL code, you need a linker written in C++. Some low-level functions for memory allocation, communicating with the I/O Processor, symbol table, strings, and the type system are also implemented in C, as these are required for the linker. It also listens for incoming messages from the compiler and passes them to the running game. This also initializes the game, by initializing the PS2 hardware, allocating the GOAL heaps, loading the GOAL kernel off of the DVD, and executing the kernel dispatcher function. This is in the `game/kernel` folder. This should be as close as possible to the game, and all differences should be noted with a comment.
@@ -357,7 +381,7 @@ The final component is the "runtime", located in `game`. This is the part of the
- `listener`: The OpenGOAL listener, which connects the compiler to a running GOAL program for the interactive REPL.
- `make`: The OpenGOAL build system, builds both code and data files.
- `regalloc`: Register allocator.
- `iso_data`:
- `iso_data`: Location of the user-provided DVD contents of the game that the decompiler extracts game assets and code from.
- `out`: Outputs from the build process. Only the `iso` subfolder should contain assets used by the game.
- `iso`: Final outputs that are used by the game.
- `obj`: Object files generated by the compiler.
@@ -366,7 +390,8 @@ The final component is the "runtime", located in `game`. This is the part of the
- `test`: Unit tests (run on GitHub Actions).
- `third-party`: Third party libraries.
- CMake Code Coverage. For code coverage statistics on GitHub builds.
- `fmt`. String formatting library.
- `discord-rpc`: Discord Rich Presence library.
- `fmt`: String formatting library.
- `googletest`: Test framework.
- `inja`: templating library used for generating test code for compiler tests.
- `lzokay`: decompression code for Jak 2 and later DGOs.
+2 -2
View File
@@ -4,6 +4,7 @@ add_library(common
cross_sockets/XSocket.cpp
cross_sockets/XSocketServer.cpp
cross_sockets/XSocketClient.cpp
custom_data/pack_helpers.cpp
custom_data/TFrag3Data.cpp
deserialization/subtitles/subtitles.cpp
dma/dma.cpp
@@ -47,8 +48,7 @@ add_library(common
util/os.cpp
util/print_float.cpp
util/FontUtils.cpp
util/FrameLimiter.cpp
util/image_loading.cpp)
util/FrameLimiter.cpp)
target_link_libraries(common fmt lzokay replxx libzstd_static)
+66 -5
View File
@@ -1,3 +1,5 @@
#include <functional>
#include <algorithm>
#include "Tfrag3Data.h"
#include "common/util/Assert.h"
@@ -21,6 +23,7 @@ void StripDraw::serialize(Serializer& ser) {
ser.from_ptr(&mode);
ser.from_ptr(&tree_tex_id);
ser.from_pod_vector(&runs);
ser.from_pod_vector(&plain_indices);
ser.from_pod_vector(&vis_groups);
ser.from_ptr(&num_triangles);
}
@@ -64,6 +67,7 @@ void TfragTree::serialize(Serializer& ser) {
ser.from_pod_vector(&packed_vertices.cluster_origins);
ser.from_pod_vector(&colors);
bvh.serialize(ser);
ser.from_ptr(&use_strips);
}
void TieTree::unpack() {
@@ -78,7 +82,7 @@ void TieTree::unpack() {
vtx.x = proto_vtx.x;
vtx.y = proto_vtx.y;
vtx.z = proto_vtx.z;
vtx.q = 1.f;
vtx.q_unused = 1.f;
vtx.s = proto_vtx.s;
vtx.t = proto_vtx.t;
i++;
@@ -93,7 +97,7 @@ void TieTree::unpack() {
vtx.x = temp.x();
vtx.y = temp.y();
vtx.z = temp.z();
vtx.q = 1.f;
vtx.q_unused = 1.f;
vtx.s = proto_vtx.s;
vtx.t = proto_vtx.t;
i++;
@@ -103,6 +107,7 @@ void TieTree::unpack() {
for (auto& draw : static_draws) {
draw.unpacked.idx_of_first_idx_in_full_buffer = unpacked.indices.size();
ASSERT(draw.plain_indices.empty());
for (auto& run : draw.runs) {
for (u32 ri = 0; ri < run.length; ri++) {
unpacked.indices.push_back(run.vertex0 + ri);
@@ -152,7 +157,7 @@ void TfragTree::unpack() {
o.z = cz + in.zoff * rescale;
o.s = in.s / (1024.f);
o.t = in.t / (1024.f);
o.q = 1.f;
o.q_unused = 1.f;
o.color_index = in.color_index;
}
@@ -162,8 +167,12 @@ void TfragTree::unpack() {
for (u32 ri = 0; ri < run.length; ri++) {
unpacked.indices.push_back(run.vertex0 + ri);
}
unpacked.indices.push_back(UINT32_MAX);
if (use_strips) {
unpacked.indices.push_back(UINT32_MAX);
}
}
unpacked.indices.insert(unpacked.indices.end(), draw.plain_indices.begin(),
draw.plain_indices.end());
}
}
@@ -288,7 +297,8 @@ void MercModelGroup::serialize(Serializer& ser) {
void Level::serialize(Serializer& ser) {
ser.from_ptr(&version);
if (ser.is_loading() && version != TFRAG3_VERSION) {
ASSERT_MSG(false, fmt::format("version mismatch when loading tfrag3 data. Got {}, expected {}",
ASSERT_MSG(false, fmt::format("version mismatch when loading tfrag3 data. Got {}, expected {}, "
"did you forget to re-decompile?",
version, TFRAG3_VERSION));
}
@@ -359,6 +369,7 @@ std::array<int, MemoryUsageCategory::NUM_CATEGORIES> Level::get_memory_usage() c
for (const auto& tfrag_tree : tfrag_tree_geoms) {
for (const auto& draw : tfrag_tree.draws) {
result[TFRAG_INDEX] += draw.runs.size() * sizeof(StripDraw::VertexRun);
result[TFRAG_INDEX] += draw.plain_indices.size() * sizeof(u32);
result[TFRAG_VIS] += draw.vis_groups.size() * sizeof(StripDraw::VisGroup);
}
result[TFRAG_VERTS] +=
@@ -417,4 +428,54 @@ std::array<int, MemoryUsageCategory::NUM_CATEGORIES> Level::get_memory_usage() c
return result;
}
void print_memory_usage(const tfrag3::Level& lev, int uncompressed_data_size) {
int total_accounted = 0;
auto memory_use_by_category = lev.get_memory_usage();
std::vector<std::pair<std::string, int>> known_categories = {
{"texture", memory_use_by_category[tfrag3::MemoryUsageCategory::TEXTURE]},
{"tie-deinst-vis", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_DEINST_VIS]},
{"tie-deinst-idx", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_DEINST_INDEX]},
{"tie-inst-vis", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_INST_VIS]},
{"tie-inst-idx", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_INST_INDEX]},
{"tie-bvh", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_BVH]},
{"tie-verts", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_VERTS]},
{"tie-colors", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_TIME_OF_DAY]},
{"tie-wind-inst-info",
memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_WIND_INSTANCE_INFO]},
{"tie-cidx", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_CIDX]},
{"tie-mats", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_MATRICES]},
{"tie-grps", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_GRPS]},
{"tfrag-vis", memory_use_by_category[tfrag3::MemoryUsageCategory::TFRAG_VIS]},
{"tfrag-idx", memory_use_by_category[tfrag3::MemoryUsageCategory::TFRAG_INDEX]},
{"tfrag-vert", memory_use_by_category[tfrag3::MemoryUsageCategory::TFRAG_VERTS]},
{"tfrag-colors", memory_use_by_category[tfrag3::MemoryUsageCategory::TFRAG_TIME_OF_DAY]},
{"tfrag-cluster", memory_use_by_category[tfrag3::MemoryUsageCategory::TFRAG_CLUSTER]},
{"tfrag-bvh", memory_use_by_category[tfrag3::MemoryUsageCategory::TFRAG_BVH]},
{"shrub-colors", memory_use_by_category[tfrag3::MemoryUsageCategory::SHRUB_TIME_OF_DAY]},
{"shrub-vert", memory_use_by_category[tfrag3::MemoryUsageCategory::SHRUB_VERT]},
{"shrub-ind", memory_use_by_category[tfrag3::MemoryUsageCategory::SHRUB_IND]},
{"collision", memory_use_by_category[tfrag3::MemoryUsageCategory::COLLISION]},
{"merc-vert", memory_use_by_category[tfrag3::MemoryUsageCategory::MERC_VERT]},
{"merc-idx", memory_use_by_category[tfrag3::MemoryUsageCategory::MERC_INDEX]}};
for (auto& known : known_categories) {
total_accounted += known.second;
}
known_categories.push_back({"unknown", uncompressed_data_size - total_accounted});
std::sort(known_categories.begin(), known_categories.end(),
[](const auto& a, const auto& b) { return a.second > b.second; });
for (const auto& x : known_categories) {
fmt::print("{:30s} : {:6d} kB {:3.1f}%\n", x.first, x.second / 1024,
100.f * (float)x.second / uncompressed_data_size);
}
}
std::size_t PreloadedVertex::hash::operator()(const PreloadedVertex& v) const {
return std::hash<float>()(v.x) ^ std::hash<float>()(v.y) ^ std::hash<float>()(v.z) ^
std::hash<float>()(v.s) ^ std::hash<float>()(v.t) ^ std::hash<u16>()(v.color_index);
}
} // namespace tfrag3
+17 -3
View File
@@ -53,17 +53,26 @@ enum MemoryUsageCategory {
NUM_CATEGORIES
};
constexpr int TFRAG3_VERSION = 19;
constexpr int TFRAG3_VERSION = 20;
// These vertices should be uploaded to the GPU at load time and don't change
struct PreloadedVertex {
// the vertex position
float x, y, z;
// texture coordinates
float s, t, q;
float s, t, q_unused;
// color table index
u16 color_index;
u16 pad[3];
struct hash {
std::size_t operator()(const PreloadedVertex& x) const;
};
bool operator==(const PreloadedVertex& other) const {
return x == other.x && y == other.y && z == other.z && s == other.s && t == other.t &&
color_index == other.color_index;
}
};
static_assert(sizeof(PreloadedVertex) == 32, "PreloadedVertex size");
@@ -144,12 +153,14 @@ struct StripDraw {
u32 idx_of_first_idx_in_full_buffer = 0;
} unpacked;
// indices can be specified as lists of runs and plain indices.
// the runs are still drawn with indexed opengl calls, it just uses less space in the file.
struct VertexRun {
u32 vertex0;
u16 length;
};
std::vector<VertexRun> runs;
std::vector<u32> plain_indices;
// to do culling, the above vertex stream is grouped.
// by following the visgroups and checking the visibility, you can leave out invisible vertices.
@@ -260,6 +271,7 @@ struct TfragTree {
PackedTfragVertices packed_vertices;
std::vector<TimeOfDayColor> colors; // vertex colors (pre-interpolation)
BVH bvh; // the bvh for frustum culling
bool use_strips = true;
struct {
std::vector<PreloadedVertex> vertices; // mesh vertices
@@ -397,4 +409,6 @@ struct Level {
std::array<int, MemoryUsageCategory::NUM_CATEGORIES> get_memory_usage() const;
};
void print_memory_usage(const tfrag3::Level& lev, int uncompressed_data_size);
} // namespace tfrag3
+71
View File
@@ -0,0 +1,71 @@
#include "pack_helpers.h"
#include <map>
constexpr float kClusterSize = 4096 * 40; // 100 in-game meters
constexpr float kMasterOffset = 12000 * 4096;
std::pair<u64, u16> position_to_cluster_and_offset(float in) {
in += kMasterOffset;
if (in < 0) {
fmt::print("negative: {}\n", in);
}
ASSERT(in >= 0);
int cluster_cell = (in / kClusterSize);
float leftover = in - (cluster_cell * kClusterSize);
u16 offset = (leftover / kClusterSize) * float(UINT16_MAX);
float recovered = ((float)cluster_cell + ((float)offset / UINT16_MAX)) * kClusterSize;
float diff = std::fabs(recovered - in);
ASSERT(diff < 7);
ASSERT(cluster_cell >= 0);
ASSERT(cluster_cell < UINT16_MAX);
return {cluster_cell, offset};
}
void pack_tfrag_vertices(tfrag3::PackedTfragVertices* result,
const std::vector<tfrag3::PreloadedVertex>& vertices) {
u32 next_cluster_idx = 0;
std::map<u64, u32> clusters;
for (auto& vtx : vertices) {
auto x = position_to_cluster_and_offset(vtx.x);
auto y = position_to_cluster_and_offset(vtx.y);
auto z = position_to_cluster_and_offset(vtx.z);
u64 cluster_id = 0;
cluster_id |= x.first;
cluster_id |= (y.first << 16);
cluster_id |= (z.first << 32);
auto cluster_it = clusters.find(cluster_id);
u32 my_cluster_idx = 0;
if (cluster_it == clusters.end()) {
// first in cluster
clusters[cluster_id] = next_cluster_idx;
my_cluster_idx = next_cluster_idx;
next_cluster_idx++;
} else {
my_cluster_idx = cluster_it->second;
}
tfrag3::PackedTfragVertices::Vertex out_vtx;
out_vtx.xoff = x.second;
out_vtx.yoff = y.second;
out_vtx.zoff = z.second;
out_vtx.cluster_idx = my_cluster_idx;
// TODO check these
out_vtx.s = vtx.s * 1024;
out_vtx.t = vtx.t * 1024;
out_vtx.color_index = vtx.color_index;
result->vertices.push_back(out_vtx);
}
result->cluster_origins.resize(next_cluster_idx);
for (auto& cluster : clusters) {
auto& res = result->cluster_origins[cluster.second];
res.x() = (u16)cluster.first;
res.y() = (u16)(cluster.first >> 16);
res.z() = (u16)(cluster.first >> 32);
}
ASSERT(next_cluster_idx < UINT16_MAX);
}
+6
View File
@@ -0,0 +1,6 @@
#pragma once
#include "common/custom_data/Tfrag3Data.h"
void pack_tfrag_vertices(tfrag3::PackedTfragVertices* result,
const std::vector<tfrag3::PreloadedVertex>& vertices);
+72 -2
View File
@@ -89,6 +89,14 @@ class Vector {
return result;
}
Vector<T, Size> operator+(const T& other) const {
Vector<T, Size> result;
for (int i = 0; i < Size; i++) {
result[i] = m_data[i] + other;
}
return result;
}
Vector<T, Size>& operator+=(const Vector<T, Size>& other) {
for (int i = 0; i < Size; i++) {
m_data[i] += other[i];
@@ -103,6 +111,13 @@ class Vector {
return *this;
}
Vector<T, Size>& operator-=(const T& other) {
for (int i = 0; i < Size; i++) {
m_data[i] -= other;
}
return *this;
}
Vector<T, Size> elementwise_multiply(const Vector<T, Size>& other) const {
Vector<T, Size> result;
for (int i = 0; i < Size; i++) {
@@ -180,6 +195,18 @@ class Vector {
void normalize(const T& norm = T(1)) { *this = normalized(norm); }
void max_in_place(const Vector<T, Size>& other) {
for (int i = 0; i < Size; i++) {
m_data[i] = std::max(m_data[i], other[i]);
}
}
void min_in_place(const Vector<T, Size>& other) {
for (int i = 0; i < Size; i++) {
m_data[i] = std::min(m_data[i], other[i]);
}
}
std::string to_string_aligned() const {
std::string result = "[";
for (auto x : m_data) {
@@ -229,6 +256,8 @@ class Vector {
}
}
void set_zero() { fill(0); }
private:
T m_data[Size];
};
@@ -246,8 +275,24 @@ struct Matrix {
return result;
}
// const T& operator()(int r, int c) const { return m_data[c + r * Cols]; }
// T& operator()(int r, int c) { return m_data[r + c * Rows]; }
static Matrix identity() {
Matrix result;
for (int c = 0; c < Cols; c++) {
for (int r = 0; r < Rows; r++) {
result(r, c) = r == c ? T(1) : T(0);
}
}
return result;
}
void set_zero() {
for (auto& x : m_data) {
x = 0;
}
}
T& operator()(int r, int c) { return m_data[r + c * Rows]; }
const T& operator()(int r, int c) const { return m_data[r + c * Rows]; }
Vector<T, Rows> col(int c) const {
Vector<T, Rows> result;
@@ -274,6 +319,31 @@ struct Matrix {
return result;
}
template <int OtherCols>
Matrix<T, Rows, OtherCols> operator*(const Matrix<T, Cols, OtherCols>& y) const {
Matrix<T, Rows, OtherCols> result;
result.set_zero();
for (int rx = 0; rx < Rows; rx++) {
for (int cx = 0; cx < Cols; cx++) {
for (int yi = 0; yi < OtherCols; yi++) {
result(rx, yi) += operator()(rx, cx) * y(cx, yi);
}
}
}
return result;
}
Vector<T, Rows> operator*(const Vector<T, Cols>& y) const {
Vector<T, Rows> result;
result.set_zero();
for (int rx = 0; rx < Rows; rx++) {
for (int cx = 0; cx < Cols; cx++) {
result[rx] += operator()(rx, cx) * y[cx];
}
}
return result;
}
private:
T m_data[Rows * Cols];
};
+40
View File
@@ -0,0 +1,40 @@
#include "geometry.h"
namespace math {
Vector4f bsphere_of_triangle(const Vector3f* v) {
Vector4f bsphere;
auto& p1 = v[0];
auto& p2 = v[1];
auto& p3 = v[2];
float A = (p1 - p2).length();
float B = (p2 - p3).length();
float C = (p3 - p1).length();
const Vector3f *a = &p3, *b = &p1, *c = &p2;
if (B < C)
std::swap(B, C), std::swap(b, c);
if (A < B)
std::swap(A, B), std::swap(a, b);
float r;
math::Vector3f origin;
if ((B * B) + (C * C) <= (A * A)) {
r = A / 2.f;
origin = (*b + *c) / 2.f;
} else {
float cos_a = (B * B + C * C - A * A) / (B * C * 2);
r = A / (sqrt(1 - cos_a * cos_a) * 2.f);
Vector3f alpha = *a - *c, beta = *b - *c;
origin = (beta * alpha.dot(alpha) - alpha * beta.dot(beta)).cross(alpha.cross(beta)) /
(alpha.cross(beta).dot(alpha.cross(beta)) * 2.f) +
*c;
}
bsphere.x() = origin.x();
bsphere.y() = origin.y();
bsphere.z() = origin.z();
bsphere.w() = r;
return bsphere;
}
} // namespace math
+6
View File
@@ -44,4 +44,10 @@ RaySphereResult<T> ray_sphere_intersect(const Vector3<T>& ray_origin,
result.u[1] = minus_b - sqrt_val;
return result;
}
math::Vector4f bsphere_of_triangle(const Vector3f* vertices);
inline bool point_in_bsphere(const Vector4f& sphere, const Vector3f& pt) {
return (sphere.xyz() - pt).squared_length() <= (sphere.w() * sphere.w());
}
} // namespace math
-13
View File
@@ -1,13 +0,0 @@
// hides warnings
#ifdef __linux__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-qual"
#endif
#define STB_IMAGE_IMPLEMENTATION
#include "third-party/stb_image.h"
#ifdef __linux__
#pragma GCC diagnostic pop
#endif
-1
View File
@@ -1 +0,0 @@
#include "third-party/stb_image.h"
+36
View File
@@ -0,0 +1,36 @@
# Custom Levels
Disclaimer: custom levels are still in development and are missing most features.
The first three steps are already done for "test zone", so this can be used as a starting point.
# 1: File Setup
To create a custom level, copy the layout of `custom_levels/test-zone`. See `test-zone.jsonc` for information on how to name things. The `.gd` file also contains the level name.
# 2: Modify the engine
Modify `goal_src/engine/level/level-info.gc` to add level info for each custom level. There is level info for `test-zone` at the bottom that can be used as an example.
# 3: Modify the build system
Modify `goal_src/game.gp` and add a custom level target:
```lisp
(build-custom-level "test-zone")
;; the DGO file
(custom-level-cgo "TESTZONE.DGO" "test-zone/testzone.gd")
```
# 4: Export the GLTF file from blender.
For now, all meshes are displayed and treated as ground collision. This causes buggy collision because walls shouldn't use "floor" mode.
Blender will create a `.glb` file, which must have the name specified in the `.jsonc` file and should be located in `custom_level/your_level`
# 5: Rebuild the game
Any time the `.glb` file is changed, you must rebuild the game. Launch the compiler (`goalc`) and run `(mi)` to rebuild everything. It's recommended to leave the compiler open - it will remember files that haven't changed and skip rebuilding them.
# 6: Go to the custom level
Start the game in debug mode `gk`.
In the compiler window, run `(lt)` to connect to the game. You must run this again every time you restart the game. If this doesn't work, there could be a firewall issue and you must allow goalc/gk to use the network. They don't make any outside connections.
In the compiler window, run a command like `(bg-custom 'test-zone-vis)` to load and start at a custom level.
+15
View File
@@ -0,0 +1,15 @@
{
// The "in-game" name of the level. Should be lower case, with dashes (GOAL symbol name)
// the name of this file, and the folder this file is in must have the same name.
"long_name": "test-zone",
// The file name, should be upper case and 8 characters or less.
"iso_name": "TESTZONE",
// The nickname, should be exactly 3 characters
"nickname": "TSZ", // 3 char name, all uppercase
// Background mesh file.
// Must have vertex colors. Use the blender cycles renderer, bake, diffuse, uncheck color,
// and bake to vertex colors. For now, only the first vertex color group is used, so make sure you
// only have 1.
"gltf_file": "custom_levels/test-zone/test-zone2.glb"
}
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
;; DGO definition file for Awful Village level
;; We use the convention of having a longer DGO name for levels without precomputed visibility.
;; the actual file name still needs to be 8.3
("TSZ.DGO"
("static-screen.o" "static-screen")
("test-zone.go" "test-zone")
)
+5 -2
View File
@@ -83,6 +83,7 @@ target_link_libraries(decomp
lzokay
common
fmt
stb_image
)
add_executable(decompiler
@@ -92,7 +93,8 @@ target_link_libraries(decompiler
decomp
common
lzokay
fmt)
fmt
stb_image)
add_executable(extractor
@@ -103,4 +105,5 @@ target_link_libraries(extractor
common
lzokay
fmt
compiler)
compiler
stb_image)
+1 -1
View File
@@ -2,7 +2,7 @@
#include "third-party/fmt/core.h"
#include "common/util/Assert.h"
#include "third-party/stb_image.h"
#include "third-party/stb_image/stb_image.h"
#include <filesystem>
namespace decompiler {
@@ -53,51 +53,6 @@ bool is_valid_bsp(const decompiler::LinkedObjectFile& file) {
return true;
}
void print_memory_usage(const tfrag3::Level& lev, int uncompressed_data_size) {
int total_accounted = 0;
auto memory_use_by_category = lev.get_memory_usage();
std::vector<std::pair<std::string, int>> known_categories = {
{"texture", memory_use_by_category[tfrag3::MemoryUsageCategory::TEXTURE]},
{"tie-deinst-vis", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_DEINST_VIS]},
{"tie-deinst-idx", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_DEINST_INDEX]},
{"tie-inst-vis", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_INST_VIS]},
{"tie-inst-idx", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_INST_INDEX]},
{"tie-bvh", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_BVH]},
{"tie-verts", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_VERTS]},
{"tie-colors", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_TIME_OF_DAY]},
{"tie-wind-inst-info",
memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_WIND_INSTANCE_INFO]},
{"tie-cidx", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_CIDX]},
{"tie-mats", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_MATRICES]},
{"tie-grps", memory_use_by_category[tfrag3::MemoryUsageCategory::TIE_GRPS]},
{"tfrag-vis", memory_use_by_category[tfrag3::MemoryUsageCategory::TFRAG_VIS]},
{"tfrag-idx", memory_use_by_category[tfrag3::MemoryUsageCategory::TFRAG_INDEX]},
{"tfrag-vert", memory_use_by_category[tfrag3::MemoryUsageCategory::TFRAG_VERTS]},
{"tfrag-colors", memory_use_by_category[tfrag3::MemoryUsageCategory::TFRAG_TIME_OF_DAY]},
{"tfrag-cluster", memory_use_by_category[tfrag3::MemoryUsageCategory::TFRAG_CLUSTER]},
{"tfrag-bvh", memory_use_by_category[tfrag3::MemoryUsageCategory::TFRAG_BVH]},
{"shrub-colors", memory_use_by_category[tfrag3::MemoryUsageCategory::SHRUB_TIME_OF_DAY]},
{"shrub-vert", memory_use_by_category[tfrag3::MemoryUsageCategory::SHRUB_VERT]},
{"shrub-ind", memory_use_by_category[tfrag3::MemoryUsageCategory::SHRUB_IND]},
{"collision", memory_use_by_category[tfrag3::MemoryUsageCategory::COLLISION]},
{"merc-vert", memory_use_by_category[tfrag3::MemoryUsageCategory::MERC_VERT]},
{"merc-idx", memory_use_by_category[tfrag3::MemoryUsageCategory::MERC_INDEX]}};
for (auto& known : known_categories) {
total_accounted += known.second;
}
known_categories.push_back({"unknown", uncompressed_data_size - total_accounted});
std::sort(known_categories.begin(), known_categories.end(),
[](const auto& a, const auto& b) { return a.second > b.second; });
for (const auto& x : known_categories) {
fmt::print("{:30s} : {:6d} kB {:3.1f}%\n", x.first, x.second / 1024,
100.f * (float)x.second / uncompressed_data_size);
}
}
void add_all_textures_from_level(tfrag3::Level& lev,
const std::string& level_name,
const TextureDB& tex_db) {
+4 -82
View File
@@ -5,6 +5,7 @@
#include "common/util/FileUtil.h"
#include "common/dma/gs.h"
#include "common/util/Assert.h"
#include "common/custom_data/pack_helpers.h"
namespace decompiler {
namespace {
@@ -2056,9 +2057,9 @@ void make_tfrag3_data(std::map<u32, std::vector<GroupedDraw>>& draws,
vtx.z = vert.pre_cam_trans_pos.z();
vtx.s = vert.stq.x();
vtx.t = vert.stq.y();
vtx.q = vert.stq.z();
vtx.q_unused = vert.stq.z();
// if this is true, we can remove a divide in the shader
ASSERT(vtx.q == 1.f);
ASSERT(vtx.q_unused == 1.f);
vtx.color_index = vert.rgba / 4;
// ASSERT((vert.rgba >> 2) < 1024); spider cave has 2048?
ASSERT((vert.rgba & 3) == 0);
@@ -2137,85 +2138,6 @@ void merge_groups(std::vector<tfrag3::StripDraw::VisGroup>& grps) {
} // namespace
constexpr float kClusterSize = 4096 * 40; // 100 in-game meters
constexpr float kMasterOffset = 12000 * 4096;
std::pair<u64, u16> position_to_cluster_and_offset(float in) {
in += kMasterOffset;
if (in < 0) {
fmt::print("negative: {}\n", in);
}
ASSERT(in >= 0);
int cluster_cell = (in / kClusterSize);
float leftover = in - (cluster_cell * kClusterSize);
u16 offset = (leftover / kClusterSize) * float(UINT16_MAX);
float recovered = ((float)cluster_cell + ((float)offset / UINT16_MAX)) * kClusterSize;
float diff = std::fabs(recovered - in);
ASSERT(diff < 7);
ASSERT(cluster_cell >= 0);
ASSERT(cluster_cell < UINT16_MAX);
return {cluster_cell, offset};
}
void pack_vertices(tfrag3::PackedTfragVertices* result,
const std::vector<tfrag3::PreloadedVertex>& vertices) {
u32 next_cluster_idx = 0;
std::map<u64, u32> clusters;
for (auto& vtx : vertices) {
auto x = position_to_cluster_and_offset(vtx.x);
auto y = position_to_cluster_and_offset(vtx.y);
auto z = position_to_cluster_and_offset(vtx.z);
u64 cluster_id = 0;
cluster_id |= x.first;
cluster_id |= (y.first << 16);
cluster_id |= (z.first << 32);
auto cluster_it = clusters.find(cluster_id);
u32 my_cluster_idx = 0;
if (cluster_it == clusters.end()) {
// first in cluster
clusters[cluster_id] = next_cluster_idx;
my_cluster_idx = next_cluster_idx;
next_cluster_idx++;
} else {
my_cluster_idx = cluster_it->second;
}
tfrag3::PackedTfragVertices::Vertex out_vtx;
out_vtx.xoff = x.second;
out_vtx.yoff = y.second;
out_vtx.zoff = z.second;
out_vtx.cluster_idx = my_cluster_idx;
// TODO check these
out_vtx.s = vtx.s * 1024;
out_vtx.t = vtx.t * 1024;
out_vtx.color_index = vtx.color_index;
result->vertices.push_back(out_vtx);
}
result->cluster_origins.resize(next_cluster_idx);
for (auto& cluster : clusters) {
auto& res = result->cluster_origins[cluster.second];
res.x() = (u16)cluster.first;
res.y() = (u16)(cluster.first >> 16);
res.z() = (u16)(cluster.first >> 32);
}
/*
std::unordered_set<tfrag3::PackedTfragVertices::Vertex, tfrag3::PackedTfragVertices::Vertex::hash>
a;
for (auto& v : result->vertices) {
a.insert(v);
}
fmt::print("SIZE: {} vs {} {}\n", a.size(), result->vertices.size(),
(float)a.size() / result->vertices.size());
*/
ASSERT(next_cluster_idx < UINT16_MAX);
}
void extract_tfrag(const level_tools::DrawableTreeTfrag* tree,
const std::string& debug_name,
const std::vector<level_tools::TextureRemap>& map,
@@ -2282,7 +2204,7 @@ void extract_tfrag(const level_tools::DrawableTreeTfrag* tree,
std::vector<tfrag3::PreloadedVertex> vertices;
emulate_tfrags(geom, as_tfrag_array->tfragments, debug_name, map, out, this_tree, vertices,
tex_db, expected_missing_textures, dump_level);
pack_vertices(&this_tree.packed_vertices, vertices);
pack_tfrag_vertices(&this_tree.packed_vertices, vertices);
extract_time_of_day(tree, this_tree);
for (auto& draw : this_tree.draws) {
+1 -1
View File
@@ -157,7 +157,7 @@ add_subdirectory(sound)
# we build the runtime as a static library.
add_library(runtime STATIC ${RUNTIME_SOURCE} "../third-party/glad/src/glad.c")
target_link_libraries(runtime common fmt glfw imgui discord-rpc sound)
target_link_libraries(runtime common fmt glfw imgui discord-rpc sound stb_image)
if(WIN32)
target_link_libraries(runtime mman)
else()
+2 -2
View File
@@ -70,9 +70,9 @@ const char* time_of_day_str(float time) {
if (hour >= 0 && hour <= 9)
return "green-sun";
else if (hour >= 10 && hour <= 21)
else if (hour < 22)
return "day";
else if (hour >= 22 && hour <= 24)
else if (hour < 25)
return "evening";
else
return "";
@@ -78,6 +78,7 @@ void Tfrag3::update_load(const std::vector<tfrag3::TFragmentTreeKind>& tree_kind
tree_cache.vis = &tree.bvh;
tree_cache.index_data = tree.unpacked.indices.data();
tree_cache.tod_cache = swizzle_time_of_day(tree.colors);
tree_cache.draw_mode = tree.use_strips ? GL_TRIANGLE_STRIP : GL_TRIANGLES;
vis_temp_len = std::max(vis_temp_len, tree.bvh.vis_nodes.size());
glBindBuffer(GL_ARRAY_BUFFER, tree_cache.vertex_buffer);
// glBufferData(GL_ARRAY_BUFFER, verts * sizeof(tfrag3::PreloadedVertex),
@@ -240,11 +241,11 @@ void Tfrag3::render_tree(int geom,
prof.add_draw_call();
if (render_state->no_multidraw) {
glDrawElements(GL_TRIANGLE_STRIP, singledraw_indices.second, GL_UNSIGNED_INT,
glDrawElements(tree.draw_mode, singledraw_indices.second, GL_UNSIGNED_INT,
(void*)(singledraw_indices.first * sizeof(u32)));
} else {
glMultiDrawElements(GL_TRIANGLE_STRIP,
&m_cache.multidraw_count_buffer[multidraw_indices.first], GL_UNSIGNED_INT,
glMultiDrawElements(tree.draw_mode, &m_cache.multidraw_count_buffer[multidraw_indices.first],
GL_UNSIGNED_INT,
&m_cache.multidraw_index_offset_buffer[multidraw_indices.first],
multidraw_indices.second);
}
@@ -260,11 +261,11 @@ void Tfrag3::render_tree(int geom,
double_draw.aref_second);
glDepthMask(GL_FALSE);
if (render_state->no_multidraw) {
glDrawElements(GL_TRIANGLE_STRIP, singledraw_indices.second, GL_UNSIGNED_INT,
glDrawElements(tree.draw_mode, singledraw_indices.second, GL_UNSIGNED_INT,
(void*)(singledraw_indices.first * sizeof(u32)));
} else {
glMultiDrawElements(
GL_TRIANGLE_STRIP, &m_cache.multidraw_count_buffer[multidraw_indices.first],
tree.draw_mode, &m_cache.multidraw_count_buffer[multidraw_indices.first],
GL_UNSIGNED_INT, &m_cache.multidraw_index_offset_buffer[multidraw_indices.first],
multidraw_indices.second);
}
@@ -64,6 +64,7 @@ class Tfrag3 {
const tfrag3::BVH* vis = nullptr;
const u32* index_data = nullptr;
SwizzledTimeOfDay tod_cache;
u64 draw_mode = 0;
void reset_stats() {
rendered_this_frame = false;
@@ -83,6 +83,7 @@ class TfragLoadStage : public LoaderStage {
GLuint& tree_out = data.lev_data->tfrag_vertex_data[geo].emplace_back();
glGenBuffers(1, &tree_out);
glBindBuffer(GL_ARRAY_BUFFER, tree_out);
glBufferData(GL_ARRAY_BUFFER,
in_tree.unpacked.vertices.size() * sizeof(tfrag3::PreloadedVertex), nullptr,
GL_STATIC_DRAW);
@@ -97,34 +98,38 @@ class TfragLoadStage : public LoaderStage {
u32 unique_buffers = 0;
while (true) {
const auto& tree = data.lev_data->level->tfrag_trees[m_next_geo][m_next_tree];
u32 end_vert_in_tree = tree.unpacked.vertices.size();
// the number of vertices we'd need to finish the tree right now
size_t num_verts_left_in_tree = end_vert_in_tree - m_next_vert;
size_t start_vert_for_chunk;
size_t end_vert_for_chunk;
bool complete_tree;
if (num_verts_left_in_tree > CHUNK_SIZE) {
complete_tree = false;
// should only do partial
start_vert_for_chunk = m_next_vert;
end_vert_for_chunk = start_vert_for_chunk + CHUNK_SIZE;
m_next_vert += CHUNK_SIZE;
} else {
// should do all!
start_vert_for_chunk = m_next_vert;
end_vert_for_chunk = end_vert_in_tree;
if (data.lev_data->level->tfrag_trees[m_next_geo].empty()) {
complete_tree = true;
}
} else {
const auto& tree = data.lev_data->level->tfrag_trees[m_next_geo][m_next_tree];
u32 end_vert_in_tree = tree.unpacked.vertices.size();
// the number of vertices we'd need to finish the tree right now
size_t num_verts_left_in_tree = end_vert_in_tree - m_next_vert;
size_t start_vert_for_chunk;
size_t end_vert_for_chunk;
glBindBuffer(GL_ARRAY_BUFFER, data.lev_data->tfrag_vertex_data[m_next_geo][m_next_tree]);
u32 upload_size =
(end_vert_for_chunk - start_vert_for_chunk) * sizeof(tfrag3::PreloadedVertex);
glBufferSubData(GL_ARRAY_BUFFER, start_vert_for_chunk * sizeof(tfrag3::PreloadedVertex),
upload_size, tree.unpacked.vertices.data() + start_vert_for_chunk);
uploaded_bytes += upload_size;
if (num_verts_left_in_tree > CHUNK_SIZE) {
complete_tree = false;
// should only do partial
start_vert_for_chunk = m_next_vert;
end_vert_for_chunk = start_vert_for_chunk + CHUNK_SIZE;
m_next_vert += CHUNK_SIZE;
} else {
// should do all!
start_vert_for_chunk = m_next_vert;
end_vert_for_chunk = end_vert_in_tree;
complete_tree = true;
}
glBindBuffer(GL_ARRAY_BUFFER, data.lev_data->tfrag_vertex_data[m_next_geo][m_next_tree]);
u32 upload_size =
(end_vert_for_chunk - start_vert_for_chunk) * sizeof(tfrag3::PreloadedVertex);
glBufferSubData(GL_ARRAY_BUFFER, start_vert_for_chunk * sizeof(tfrag3::PreloadedVertex),
upload_size, tree.unpacked.vertices.data() + start_vert_for_chunk);
uploaded_bytes += upload_size;
}
if (complete_tree) {
unique_buffers++;
+22 -8
View File
@@ -21,7 +21,7 @@
#include "game/system/newpad.h"
#include "common/log/log.h"
#include "common/goal_constants.h"
#include "common/util/image_loading.h"
#include "third-party/stb_image/stb_image.h"
#include "game/runtime.h"
#include "common/util/Timer.h"
#include "game/graphics/opengl_renderer/debug_gui.h"
@@ -192,6 +192,13 @@ static std::shared_ptr<GfxDisplay> gl_make_display(int width,
g_gfx_data->debug_gui.m_vsync = false;
g_gfx_data->vsync_enabled = false;
glfwSwapInterval(false);
if (primary_monitor_video_mode->refreshRate > 100) {
BootVideoMode = VideoMode::FPS150;
g_gfx_data->debug_gui.target_fps = 150;
} else if (primary_monitor_video_mode->refreshRate > 60) {
BootVideoMode = VideoMode::FPS100;
g_gfx_data->debug_gui.target_fps = 100;
}
} else {
// enable vsync
g_gfx_data->debug_gui.framelimiter = false;
@@ -228,6 +235,11 @@ static std::shared_ptr<GfxDisplay> gl_make_display(int width,
// this does initialization for stuff like the font data
ImGui::CreateContext();
// Init ImGui settings
ImGuiIO& io = ImGui::GetIO();
io.IniFilename = file_util::get_file_path({"imgui.ini"}).c_str();
io.LogFilename = file_util::get_file_path({"imgui_log.txt"}).c_str();
// set up to get inputs for this window
ImGui_ImplGlfw_InitForOpenGL(window, true);
@@ -400,13 +412,15 @@ GfxDisplayMode GLDisplay::get_fullscreen() {
void GLDisplay::get_screen_size(int vmode_idx, s32* w_out, s32* h_out, s32* count_out) {
int count = 0;
auto vmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
auto vmodes = glfwGetVideoModes(glfwGetPrimaryMonitor(), &count);
if (vmode_idx >= 0) {
vmode = &vmodes[vmode_idx];
} else {
for (int i = 0; i < count; ++i) {
if (!vmode || vmode->height < vmodes[i].height) {
vmode = &vmodes[i];
if (get_fullscreen() == GfxDisplayMode::Fullscreen) {
auto vmodes = glfwGetVideoModes(glfwGetPrimaryMonitor(), &count);
if (vmode_idx >= 0) {
vmode = &vmodes[vmode_idx];
} else {
for (int i = 0; i < count; ++i) {
if (!vmode || vmode->height < vmodes[i].height) {
vmode = &vmodes[i];
}
}
}
}
+2
View File
@@ -32,6 +32,8 @@
using namespace ee;
VideoMode BootVideoMode;
// Level to load on boot
char DebugBootLevel[64];
+10
View File
@@ -30,6 +30,16 @@ enum class RuntimeExitStatus {
RESTART_IN_DEBUG = 3,
};
enum class VideoMode {
NTSC = 0,
PAL = 1,
FPS100 = 2,
FPS150 = 3,
};
// Video Mode that's set based on display refresh rate on boot
extern VideoMode BootVideoMode;
// Level to load on boot
extern char DebugBootLevel[64];
+1 -1
View File
@@ -2003,7 +2003,7 @@ s32 InitHeapAndSymbol() {
method_set_symbol->value = 0;
// set *boot-video-mode*
intern_from_c("*boot-video-mode*")->value = 0;
intern_from_c("*boot-video-mode*")->value = (u32)BootVideoMode;
lg::info("Initialized GOAL heap in {:.2} ms", heap_init_timer.getMs());
// load the kernel!
+4 -1
View File
@@ -1,6 +1,7 @@
#include "soundcommon.h"
#include <cstdio>
#include "common/util/Assert.h"
#include <string>
// TODO strcpy_toupper
// TODO atoi
@@ -16,7 +17,9 @@ void ReadBankSoundInfo(SoundBank* bank, SoundBank* unk, s32 unk2) {
void PrintBankInfo(SoundBank* bank) {
printf("Bank %s\n\n", bank->name);
for (u32 i = 0; i < bank->sound_count; i++) {
printf("%d : %16s : min %d max %d curve %d\n", i, bank->sound[i].name,
// Some characters use the full 16 characters (bonelurker-grunt) and dont have a null terminator
std::string name = std::string(bank->sound[i].name, 16);
printf("%d : %16s : min %d max %d curve %d\n", i, name.c_str(),
bank->sound[i].fallof_params & 0x3fff, (bank->sound[i].fallof_params >> 14) & 0x3fff,
bank->sound[i].fallof_params >> 28);
}
-2
View File
@@ -282,8 +282,6 @@ RuntimeExitStatus exec_runtime(int argc, char** argv) {
g_argv = argv;
g_main_thread_id = std::this_thread::get_id();
file_util::create_dir_if_needed("game_config/");
// parse opengoal arguments
bool enable_display = true;
for (int i = 1; i < argc; i++) {
+7 -49
View File
@@ -353,7 +353,7 @@
)
(defun update-snow ((arg0 target))
(let ((gp-0 (-> arg0 control trans)))
(let ((target-position (-> arg0 control trans)))
(let ((f0-0 (lerp-scale 0.0 1.0 (vector-length (-> arg0 control transv)) 2048.0 40960.0)))
(set! (-> *part-id-table* 34 init-specs 1 initial-valuef) (- 1.0 f0-0))
(set! (-> *part-id-table* 33 init-specs 1 initial-valuef) (* 4.0 f0-0))
@@ -361,22 +361,8 @@
(set! (-> *part-id-table* 33 init-specs 19 initial-valuef)
(+ 32768.0 (vector-y-angle (-> arg0 control transv)))
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 34)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 33)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 34) target-position)
(launch-particles (-> *part-id-table* 33) target-position)
)
0
(none)
@@ -464,22 +450,8 @@
(let ((gp-0 (new 'stack-no-clear 'vector)))
(sp-kill-particle arg0 arg1)
(set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 39)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 40)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :rate 1.0 (-> *part-id-table* 39) gp-0)
(launch-particles :system *sp-particle-system-3d* :rate 1.0 (-> *part-id-table* 40) gp-0)
)
)
(none)
@@ -512,22 +484,8 @@
(set! (-> *part-id-table* 38 init-specs 5 initial-valuef) f30-0)
(set! (-> *part-id-table* 38 init-specs 5 random-rangef) f30-0)
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 37)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 38)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 37) gp-0)
(launch-particles (-> *part-id-table* 38) gp-0)
)
)
0
+2
View File
@@ -384,6 +384,8 @@
(set! (-> v1-5 mesh) (-> obj mesh))
(set! (-> v1-5 inst) #f)
)
; (add-debug-sphere #t (bucket-id debug) (-> obj bsphere) (-> obj bsphere w) (new 'static 'rgba :g #x80 :a #x80))
; (format 0 "~f~%" (-> obj bsphere w))
(+! (-> arg1 num-items) 1)
)
(&+! obj 32)
+13
View File
@@ -83,6 +83,19 @@
(defmethod draw collide-fragment ((obj collide-fragment) (arg0 collide-fragment) (arg1 display-frame))
;; if we wanted to draw collide-fragment's we'd do it here.
; (when (< (-> obj bsphere w) (meters 22.))
; (format 0 "sp: ~m : ~D~%" (-> obj bsphere w) (-> obj mesh poly-count))
; (let ((mins (vector-copy! (new-stack-vector0) (-> obj bsphere)))
; (maxs (vector-copy! (new-stack-vector0) (-> obj bsphere))))
; (dotimes (i 3)
; (-! (-> mins data i) (-> obj bsphere w))
; (+! (-> maxs data i) (-> obj bsphere w))
; )
; (add-debug-box #t (bucket-id debug) mins maxs (new 'static 'rgba :r #x80 :a #x80)
; )
; ;(add-debug-sphere #t (bucket-id debug) (-> obj bsphere) (-> obj bsphere w) (new 'static 'rgba :r #x80 :a #x80))
; )
;; (add-debug-point #t (bucket-id debug) (-> obj bsphere))
(none)
)
+7 -2
View File
@@ -1335,7 +1335,12 @@
(+! (-> disp base-frame-counter) scaled-seconds)
(+! (-> disp part-frame-counter) scaled-seconds)
;; this counts actual frames, not seconds. Will count 2 frames if we lag
(+! (-> disp integral-frame-counter) (the int time-ratio))
;; When counting frames while running at > 60fps we need to scale it, but always count at least 1 frame
(+! (-> disp integral-frame-counter) (if (= (-> *setting-control* current video-mode) '150fps)
(max 1 (the int (* 0.4 time-ratio)))
(if (= (-> *setting-control* current video-mode) '100fps)
(max 1 (the int (* 0.6 time-ratio)))
(the int time-ratio))))
;; this counts actual frames, not doubling for lag. Will count 1 per frame drawn
(+! (-> disp actual-frame-counter) 1)
;; game counter will count seconds that we're not in a movie
@@ -1640,7 +1645,7 @@
;; need to call reset-graph with some magic number
;; also stash this parameter so that if things go really wrong and our DMA transfer
;; times out, we can reset-graph to the appropriate video mode
(if (= (-> *setting-control* current video-mode) 'ntsc)
(if (or (= (-> *setting-control* current video-mode) 'ntsc) (= (-> *setting-control* current video-mode) '150fps) (= (-> *setting-control* current video-mode) '100fps))
(set! *video-reset-parm* 2)
(set! *video-reset-parm* 3)
)
+134 -1
View File
@@ -148,4 +148,137 @@
(bit-10 10)
)
(define-extern process-entity-status! (function process entity-perm-status symbol int))
(define-extern process-entity-status! (function process entity-perm-status symbol int))
(defmacro ja-group (&key (chan 0))
"get the frame group for self. default channel is 0, the base channel. returns #f if no frame group."
`(if (> (-> self skel active-channels) ,chan)
(-> self skel root-channel ,chan frame-group))
)
(defmacro ja-group? (group &key (chan 0))
"is self in this frame group on this channel? default is channel 0, which is the base channel."
`(= (ja-group) ,group)
)
(defmacro ja (&key (chan 0)
&key (group! #f)
&key (num! #f)
&key (param0 #f)
&key (param1 #f)
&key (num-func #f)
&key (frame-num #f)
&key (frame-interp #f)
&key (dist #f)
&key (eval? #t)
)
"set various joint anim parameters for self and eval them.
you can use this for playing animations!
chan = the channel to modify. defaults to 0 (base channel). this is usually what you want.
group! = when not #f, set this as the new frame-group. defaults to #f
num! = set the frame playback function. this is what determines what frame an animation is at. funcs below.
#f = no func will be set, and there wont be a frame eval.
num-func = sets the num-func field for the channel. this lets you change the function with eval'ing.
param0 = 1st parameter for the playback function. ONLY USE THESE WITH num-func !!
param1 = 2nd parameter for the playback function. ONLY USE THESE WITH num-func !!
frame-num = set the frame-num field.
frame-interp = set the frame-interp field.
dist = set the dist field.
available num! functions:
- (+!) = advance anim.
- (-!) = reverse anim.
- (identity num) = play 'num' frame.
- (seek! target speed) = animate towards frame target at a speed.
speed is optional and defaults to 1.0 when not provided.
target is optional and defaults to the last frame of the animation.
if you want to set the speed, you therefore must also set the target.
target can be max (no quote), which is just the same as the default value.
- (loop! speed) = loop animation at a speed. default speed is 1.0 when not provided.
- (chan channel) = copy frame from another channel.
- min = the start of the animation.
- max = the end of the animation.
"
(let* ((num-args (if (pair? num!) (cdr num!) '()))
(num! (if (pair? num!) (car num!) num!))
(nf (cond
((or (eq? num! 'identity)
(eq? num! 'min)
(eq? num! 'max)
)
'num-func-identity)
((eq? num! 'none) 'num-func-none)
((eq? num! '+!) 'num-func-+!)
((eq? num! '-!) 'num-func--!)
((eq? num! 'seek!) 'num-func-seek!)
((eq? num! 'loop!) 'num-func-loop!)
((eq? num! 'blend-in!) 'num-func-blend-in!)
((eq? num! 'chan) 'num-func-chan)
))
(p0 (if param0 param0
(cond
((eq? num! 'chan) `(the float ,(car num-args)))
((eq? num! '+!) (if (null? num-args) 1.0 (car num-args)))
((eq? num! '-!) (if (null? num-args) 1.0 (car num-args)))
((eq? num! 'loop!) (if (null? num-args) 1.0 (if (eq? 'max (car num-args))
(if group!
`(the float (1- (-> (the art-joint-anim ,group!) data 0 length)))
`(the float (1- (-> ja-ch frame-group data 0 length)))
)
(car num-args))))
((eq? num! 'seek!) (if (or (null? num-args) (eq? (car num-args) 'max))
(if group!
`(the float (1- (-> (the art-joint-anim ,group!) data 0 length)))
`(the float (1- (-> ja-ch frame-group data 0 length)))
)
(car num-args)))
)))
(p1 (if param1 param1
(cond
((eq? num! 'seek!) (if (or (null? num-args) (null? (cdr num-args))) 1.0 (cadr num-args)))
)))
(frame-num (if (eq? 'max frame-num) (if group!
`(the float (1- (-> (the art-joint-anim ,group!) data 0 length)))
`(the float (1- (-> ja-ch frame-group data 0 length)))
)
frame-num))
(frame-group (if (or p0 p1 frame-num (not nf)) group! #f))
)
`(let ((ja-ch (-> self skel root-channel ,chan)))
,(if frame-interp `(set! (-> ja-ch frame-interp) ,frame-interp) `(none))
,(if dist `(set! (-> ja-ch dist) ,dist) `(none))
,(if frame-group `(set! (-> ja-ch frame-group) (the art-joint-anim ,frame-group)) `(none))
,(if p0 `(set! (-> ja-ch param 0) ,p0) `(none))
,(if p1 `(set! (-> ja-ch param 1) ,p1) `(none))
,(if num-func `(set! (-> ja-ch num-func) ,num-func) `(none))
,(if frame-num `(set! (-> ja-ch frame-num) ,frame-num) `(none))
,(if nf
`(,(if eval? 'joint-control-channel-group-eval! 'joint-control-channel-group!)
ja-ch (the art-joint-anim ,group!) ,nf)
`(none))
,(cond
((eq? num! 'min) `(set! (-> ja-ch frame-num) 0.0))
((eq? num! 'max) (if group!
`(set! (-> ja-ch frame-num) (the float (1- (-> (the art-joint-anim ,group!) data 0 length))))
`(set! (-> ja-ch frame-num) (the float (1- (-> ja-ch frame-group data 0 length))))
))
((eq? num! 'identity) `(set! (-> ja-ch frame-num) ,(car num-args)))
(#t `(none))
)
))
)
(defmacro ja-no-eval (&key (chan 0)
&key (group! #f)
&key (num! #f)
&key (param0 #f)
&key (param1 #f)
&key (num-func #f)
&key (frame-num #f)
&key (frame-interp #f)
&key (dist #f)
)
`(ja :eval? #f :chan ,chan :group! ,group! :num! ,num! :param0 ,param0 :param1 ,param1 :num-func ,num-func :frame-num ,frame-num :frame-interp ,frame-interp :dist ,dist)
)
-134
View File
@@ -694,18 +694,6 @@
)
)
(defmacro ja-group (&key (chan 0))
"get the frame group for self. default channel is 0, the base channel. returns #f if no frame group."
`(if (> (-> self skel active-channels) ,chan)
(-> self skel root-channel ,chan frame-group))
)
(defmacro ja-group? (group &key (chan 0))
"is self in this frame group on this channel? default is channel 0, which is the base channel."
`(= (ja-group) ,group)
)
(defbehavior ja-num-frames process-drawable ((arg0 int))
(+ (-> self skel root-channel arg0 frame-group data 0 length) -1)
)
@@ -881,128 +869,6 @@
)
)
(defmacro ja (&key (chan 0)
&key (group! #f)
&key (num! #f)
&key (param0 #f)
&key (param1 #f)
&key (num-func #f)
&key (frame-num #f)
&key (frame-interp #f)
&key (dist #f)
&key (eval? #t)
)
"set various joint anim parameters for self and eval them.
you can use this for playing animations!
chan = the channel to modify. defaults to 0 (base channel). this is usually what you want.
group! = when not #f, set this as the new frame-group. defaults to #f
num! = set the frame playback function. this is what determines what frame an animation is at. funcs below.
#f = no func will be set, and there wont be a frame eval.
num-func = sets the num-func field for the channel. this lets you change the function with eval'ing.
param0 = 1st parameter for the playback function. ONLY USE THESE WITH num-func !!
param1 = 2nd parameter for the playback function. ONLY USE THESE WITH num-func !!
frame-num = set the frame-num field.
frame-interp = set the frame-interp field.
dist = set the dist field.
available num! functions:
- (+!) = advance anim.
- (-!) = reverse anim.
- (identity num) = play 'num' frame.
- (seek! target speed) = animate towards frame target at a speed.
speed is optional and defaults to 1.0 when not provided.
target is optional and defaults to the last frame of the animation.
if you want to set the speed, you therefore must also set the target.
target can be max (no quote), which is just the same as the default value.
- (loop! speed) = loop animation at a speed. default speed is 1.0 when not provided.
- (chan channel) = copy frame from another channel.
- min = the start of the animation.
- max = the end of the animation.
"
(let* ((num-args (if (pair? num!) (cdr num!) '()))
(num! (if (pair? num!) (car num!) num!))
(nf (cond
((or (eq? num! 'identity)
(eq? num! 'min)
(eq? num! 'max)
)
'num-func-identity)
((eq? num! 'none) 'num-func-none)
((eq? num! '+!) 'num-func-+!)
((eq? num! '-!) 'num-func--!)
((eq? num! 'seek!) 'num-func-seek!)
((eq? num! 'loop!) 'num-func-loop!)
((eq? num! 'blend-in!) 'num-func-blend-in!)
((eq? num! 'chan) 'num-func-chan)
))
(p0 (if param0 param0
(cond
((eq? num! 'chan) `(the float ,(car num-args)))
((eq? num! '+!) (if (null? num-args) 1.0 (car num-args)))
((eq? num! '-!) (if (null? num-args) 1.0 (car num-args)))
((eq? num! 'loop!) (if (null? num-args) 1.0 (if (eq? 'max (car num-args))
(if group!
`(the float (1- (-> (the art-joint-anim ,group!) data 0 length)))
`(the float (1- (-> ja-ch frame-group data 0 length)))
)
(car num-args))))
((eq? num! 'seek!) (if (or (null? num-args) (eq? (car num-args) 'max))
(if group!
`(the float (1- (-> (the art-joint-anim ,group!) data 0 length)))
`(the float (1- (-> ja-ch frame-group data 0 length)))
)
(car num-args)))
)))
(p1 (if param1 param1
(cond
((eq? num! 'seek!) (if (or (null? num-args) (null? (cdr num-args))) 1.0 (cadr num-args)))
)))
(frame-num (if (eq? 'max frame-num) (if group!
`(the float (1- (-> (the art-joint-anim ,group!) data 0 length)))
`(the float (1- (-> ja-ch frame-group data 0 length)))
)
frame-num))
(frame-group (if (or p0 p1 frame-num (not nf)) group! #f))
)
`(let ((ja-ch (-> self skel root-channel ,chan)))
,(if frame-interp `(set! (-> ja-ch frame-interp) ,frame-interp) `(none))
,(if dist `(set! (-> ja-ch dist) ,dist) `(none))
,(if frame-group `(set! (-> ja-ch frame-group) (the art-joint-anim ,frame-group)) `(none))
,(if p0 `(set! (-> ja-ch param 0) ,p0) `(none))
,(if p1 `(set! (-> ja-ch param 1) ,p1) `(none))
,(if num-func `(set! (-> ja-ch num-func) ,num-func) `(none))
,(if frame-num `(set! (-> ja-ch frame-num) ,frame-num) `(none))
,(if nf
`(,(if eval? 'joint-control-channel-group-eval! 'joint-control-channel-group!)
ja-ch (the art-joint-anim ,group!) ,nf)
`(none))
,(cond
((eq? num! 'min) `(set! (-> ja-ch frame-num) 0.0))
((eq? num! 'max) (if group!
`(set! (-> ja-ch frame-num) (the float (1- (-> (the art-joint-anim ,group!) data 0 length))))
`(set! (-> ja-ch frame-num) (the float (1- (-> ja-ch frame-group data 0 length))))
))
((eq? num! 'identity) `(set! (-> ja-ch frame-num) ,(car num-args)))
(#t `(none))
)
))
)
(defmacro ja-no-eval (&key (chan 0)
&key (group! #f)
&key (num! #f)
&key (param0 #f)
&key (param1 #f)
&key (num-func #f)
&key (frame-num #f)
&key (frame-interp #f)
&key (dist #f)
)
`(ja :eval? #f :chan ,chan :group! ,group! :num! ,num! :param0 ,param0 :param1 ,param1 :num-func ,num-func :frame-num ,frame-num :frame-interp ,frame-interp :dist ,dist)
)
(defbehavior ja-eval process-drawable ()
(let ((gp-0 (-> self skel root-channel 0))
(s5-0 (-> self skel channel (-> self skel active-channels)))
+4 -8
View File
@@ -430,14 +430,10 @@
arg1
s5-0
)
(sp-launch-particles-var
*sp-particle-system-2d*
(the-as sparticle-launcher s3-0)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> obj process node-list data s5-0))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :rate 1.0
(the-as sparticle-launcher s3-0)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> obj process node-list data s5-0))
)
)
((= (-> (the-as basic s3-0) type) sparticle-launch-group)
(if *debug-effect-control*
+1 -8
View File
@@ -2364,14 +2364,7 @@
(dotimes (s4-1 3)
(quaternion-rotate-local-z! s5-0 s5-0 10922.667)
(quaternion-copy! *particle-quat* s5-0)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 2528)
gp-1
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 2528) gp-1)
)
)
)
+31 -129
View File
@@ -503,24 +503,10 @@
:init-specs ((sp-flt spt-fade-g 0.0))
)
(defun eco-blue-glow ((arg0 vector))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 255)
arg0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(defun eco-blue-glow ((origin vector))
(launch-particles (-> *part-id-table* 255) origin)
(if (rand-vu-percent? 0.5)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 257)
arg0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 257) origin)
)
0
(none)
@@ -555,14 +541,7 @@
)
(rand-vu-percent? 0.5)
)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 2391)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 2391) gp-0)
)
)
(let ((gp-1 (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data 70))))
@@ -576,14 +555,7 @@
)
(rand-vu-percent? 0.5)
)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 2391)
gp-1
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 2391) gp-1)
)
)
;; PAL patch here
@@ -657,29 +629,15 @@
(((pickup-type eco-yellow))
(change-sound! (-> self sound) (static-sound-name "yel-eco-jak"))
(let ((s4-0 (rand-vu-int-range 3 (+ (-> self node-list length) -1))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* (if (rand-vu-percent? 0.5)
269
270
)
)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data s4-0))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* (if (rand-vu-percent? 0.5) 269 270))
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data s4-0))
)
)
(dotimes (gp-4 2)
(let ((v1-111 (rand-vu-int-range 3 (+ (-> self node-list length) -1))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 271)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-111))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 271)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-111))
)
)
)
)
@@ -695,29 +653,15 @@
(update-transforms! (-> self control))
(change-sound! (-> self sound) (static-sound-name "red-eco-jak"))
(let ((s4-2 (rand-vu-int-range 3 (+ (-> self node-list length) -1))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* (if (rand-vu-percent? 0.5)
273
274
)
)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data s4-2))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* (if (rand-vu-percent? 0.5) 273 274))
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data s4-2))
)
)
(dotimes (gp-6 2)
(let ((v1-139 (rand-vu-int-range 3 (+ (-> self node-list length) -1))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 275)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-139))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 275)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-139))
)
)
)
)
@@ -736,77 +680,35 @@
(set! (-> *part-id-table* 259 init-specs 4 random-rangef) 16384.0)
)
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 259)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-150))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 259) (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-150))
)
)
(let ((gp-8 (rand-vu-int-range 3 (+ (-> self node-list length) -1))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* (if (rand-vu-percent? 0.5)
255
256
)
)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data gp-8))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* (if (rand-vu-percent? 0.5) 255 256))
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data gp-8))
)
(if (rand-vu-percent? 0.5)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 257)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data gp-8))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 257)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data gp-8))
)
)
)
(let ((v1-168 (rand-vu-int-range 3 (+ (-> self node-list length) -1))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 260)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-168))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 260)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-168))
)
)
(cpad-set-buzz! (-> *cpad-list* cpads 0) 0 1 (seconds 0.1))
)
(((pickup-type eco-green))
(change-sound! (-> self sound) (static-sound-name "green-eco-jak"))
(let ((s4-8 (rand-vu-int-range 3 (+ (-> self node-list length) -1))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* (if (rand-vu-percent? 0.5)
277
278
)
)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data s4-8))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* (if (rand-vu-percent? 0.5) 277 278))
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data s4-8)))
)
(dotimes (gp-11 2)
(let ((v1-188 (rand-vu-int-range 3 (+ (-> self node-list length) -1))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 279)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-188))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 279) (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-188)))
)
)
)
+14 -4
View File
@@ -445,10 +445,20 @@
(set! (-> gp-0 aspect-ratio) 'aspect4x3)
)
)
(if (zero? *boot-video-mode*)
(set! (-> gp-0 video-mode) 'ntsc)
(set! (-> gp-0 video-mode) 'pal)
)
(case *boot-video-mode*
((0)
(set! (-> gp-0 video-mode) 'ntsc)
)
((1)
(set! (-> gp-0 video-mode) 'pal)
)
((2)
(set! (-> gp-0 video-mode) '100fps)
)
((3)
(set! (-> gp-0 video-mode) '150fps)
)
)
(set! (-> s5-0 sfx-volume) (+ -1.0 (-> gp-0 sfx-volume)))
(set! (-> s5-0 music-volume) (+ -1.0 (-> gp-0 music-volume)))
(set! (-> s5-0 dialog-volume) (+ -1.0 (-> gp-0 dialog-volume)))
+24
View File
@@ -33,6 +33,30 @@
(set! (-> *math-camera* y-clip) 512.0)
(set! (-> *shadow-data* texoffset y) 128.5)
)
(('100fps)
(set! (-> *video-parms* screen-sy) 224)
(set! (-> *setting-control* default screenx) 0)
(set! (-> *setting-control* default screeny) 8)
(set! (-> *video-parms* screen-pages-high) 7)
(set! (-> *video-parms* relative-y-scale) 1.0)
(set! *ticks-per-frame* 5859)
(set! (-> *math-camera* isometric vector 1 y) 0.5)
(set! (-> *math-camera* y-pix) 112.0)
(set! (-> *math-camera* y-clip) 448.0)
(set! (-> *shadow-data* texoffset y) 112.5)
)
(('150fps)
(set! (-> *video-parms* screen-sy) 224)
(set! (-> *setting-control* default screenx) 0)
(set! (-> *setting-control* default screeny) 8)
(set! (-> *video-parms* screen-pages-high) 7)
(set! (-> *video-parms* relative-y-scale) 1.0)
(set! *ticks-per-frame* 3906)
(set! (-> *math-camera* isometric vector 1 y) 0.5)
(set! (-> *math-camera* y-pix) 112.0)
(set! (-> *math-camera* y-clip) 448.0)
(set! (-> *shadow-data* texoffset y) 112.5)
)
)
(set-time-ratios *display* (-> *display* time-ratio))
(set! (-> *video-parms* reset-video-mode) #t)
+13 -2
View File
@@ -832,7 +832,13 @@
(when (not (paused?))
(cond
((and (>= (-> s5-3 left lid) 0.0) (>= (-> s5-3 right lid) 0.0))
(set! (-> s5-3 random-time) (the-as uint 60))
(set! (-> s5-3 random-time) (the int (* (if (or (= (-> *setting-control* current video-mode) '150fps)
(= (-> *setting-control* current video-mode) '100fps))
(if (= (-> *setting-control* current video-mode) '150fps)
2.5
1.6667)
1.0)
(the-as uint 60))))
(set! (-> s5-3 blink) 0.0)
)
(else
@@ -841,7 +847,12 @@
(when (< v1-54 (the-as uint 10))
(set! (-> s5-3 blink) (-> *eye-work* blink-table v1-54))
(if (zero? v1-54)
(set! (-> s5-3 random-time) (the-as uint (the int (rand-vu-float-range 60.0 240.0))))
(set! (-> s5-3 random-time) (the-as uint (the int (* (if (or (= (-> *setting-control* current video-mode) '150fps)
(= (-> *setting-control* current video-mode) '100fps))
(if (= (-> *setting-control* current video-mode) '150fps)
2.5
1.6667)
1.0) (rand-vu-float-range 60.0 240.0)))))
)
)
)
+18 -1
View File
@@ -45,13 +45,30 @@
;; 6 "ticks" per frame * 50 fps = 300 ticks per second.
(set! (-> obj time-factor) 6.0)
)
(else
(('ntsc)
(set! (-> obj time-adjust-ratio) ratio)
(set! (-> obj seconds-per-frame) (* 0.016666668 ratio))
(set! (-> obj frames-per-second) (* 60.0 (/ 1.0 ratio)))
;; 5 "ticks" per frame * 60 fps = 300 ticks per second.
(set! (-> obj time-factor) 5.0)
)
(('100fps)
(set! (-> obj time-adjust-ratio) (* 0.6 ratio))
(set! (-> obj seconds-per-frame) (* 0.01 ratio))
(set! (-> obj frames-per-second) (* 100.0 (/ 1.0 ratio)))
;; 3 "ticks" per frame * 100 fps = 300 ticks per second.
(set! (-> obj time-factor) 3.0)
)
(('150fps)
(set! (-> obj time-adjust-ratio) (* 0.4 ratio))
(set! (-> obj seconds-per-frame) (* 0.006666667 ratio))
(set! (-> obj frames-per-second) (* 150.0 (/ 1.0 ratio)))
;; 2 "ticks" per frame * 150 fps = 300 ticks per second.
(set! (-> obj time-factor) 2.0)
)
(else
(format #t "Warning: Tried to set unsupported video-mode")
)
)
)
(-> obj time-ratio)
+1 -1
View File
@@ -747,4 +747,4 @@
)
0
(none)
)
)
+22 -6
View File
@@ -168,15 +168,31 @@
(sky-make-sun-data *sky-parms* 1 arg0)
(sky-make-moon-data *sky-parms* arg0)
(let ((v1-0 *sky-tng-data*))
(+! (-> v1-0 off-s-0) 16)
(+! (-> v1-0 off-t-0) 32)
(+! (-> v1-0 off-s-1) -21)
(+! (-> v1-0 off-t-1) 42)
(set! (-> v1-0 time) arg0)
(case (-> *setting-control* current video-mode)
(('150fps)
(+! (-> v1-0 off-s-0) 6.4)
(+! (-> v1-0 off-t-0) 12.8)
(+! (-> v1-0 off-s-1) -8.4)
(+! (-> v1-0 off-t-1) 16.8)
)
(('100fps)
(+! (-> v1-0 off-s-0) 9.6)
(+! (-> v1-0 off-t-0) 19.2)
(+! (-> v1-0 off-s-1) -12.6)
(+! (-> v1-0 off-t-1) 25.2)
)
(else
(+! (-> v1-0 off-s-0) 16)
(+! (-> v1-0 off-t-0) 32)
(+! (-> v1-0 off-s-1) -21)
(+! (-> v1-0 off-t-1) 42)
)
)
(set! (-> v1-0 time) arg0)
)
0
(none)
)
)
#|
(defun init-sky-regs ()
+6 -1
View File
@@ -1371,7 +1371,12 @@
(dotimes (page-idx 9)
(set! (-> level texture-page page-idx) #f)
)
(#when PC_PORT
(when (zero? id-array)
(format #t "ERROR: texture id array is 0, skipping texture login!~%")
(return #f)
)
)
(if (>= max-page-kind 0) ;; tfrag.
;; login the texture. If the texture isn't there, it will try to load it
;; and allocate with the given allocation function.
+8 -64
View File
@@ -48,14 +48,7 @@
(sp-kill-particle arg0 arg1)
(set-vector! s5-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
(sound-play "water-drop" :position (the-as symbol s5-0))
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 108)
s5-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system *sp-particle-system-3d* :rate 1.0 (-> *part-id-table* 108) s5-0)
)
)
0
@@ -728,42 +721,14 @@
(set! (-> *part-id-table* 118 init-specs 1 initial-valuef) (* 0.0000036621095 f28-0))
(set! (-> *part-id-table* 118 init-specs 2 initial-valuef) (* 0.1 f28-0))
(set! (-> *part-id-table* 118 init-specs 13 initial-valuef) 0.7111111)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 118)
s4-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 118) s4-0)
(set! (-> *part-id-table* 121 init-specs 1 initial-valuef) (* 0.000004150391 f28-0))
(set! (-> *part-id-table* 121 init-specs 18 initial-valuef) f30-1)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 121)
s4-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 121) s4-0)
(when (< f28-0 4096.0)
(set! (-> *part-id-table* 112 init-specs 4 random-rangef) (-> obj ripple-size))
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 112)
s4-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 115)
s4-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 112) s4-0)
(launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 115) s4-0)
)
)
)
@@ -786,23 +751,9 @@
(* 0.00012207031 (vector-xz-length (-> obj process root transv)))
)
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 110)
s4-1
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 110) s4-1)
(set! (-> *part-id-table* 111 init-specs 16 initial-valuef) (-> obj surface-height))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 111)
s4-1
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 111) s4-1)
)
)
(let ((f30-3 (- (+ (-> obj base-height) (-> obj ocean-offset) (-> obj bob-offset) (-> obj align-offset))
@@ -990,14 +941,7 @@
(set! (-> *part-id-table* 145 init-specs 8 initial-valuef) (* 0.05 (- (-> a2-15 x) (-> obj drip-old-pos x))))
(set! (-> *part-id-table* 145 init-specs 9 initial-valuef) (* 0.05 (- (-> a2-15 y) (-> obj drip-old-pos y))))
(set! (-> *part-id-table* 145 init-specs 10 initial-valuef) (* 0.05 (- (-> a2-15 z) (-> obj drip-old-pos z))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 145)
a2-15
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 145) a2-15)
)
(set! (-> obj drip-time) (-> *display* base-frame-counter))
(logclear! (-> obj flags) (water-flags wt15))
+2 -2
View File
@@ -21,9 +21,9 @@
(set! (-> arg0 wind-time) (+ (-> arg0 wind-time) 1))
(let* ((s4-0 (logand (-> arg0 wind-time) 63))
(f0-4 (rand-vu-float-range 0.0 100.0))
(v1-5 (/ (-> arg0 wind-time) (the-as uint 120)))
(v1-5 (/ (if (or (eq? (-> *setting-control* current video-mode) '150fps) (eq? (-> *setting-control* current video-mode) '100fps)) (the uint (min 1.0 (* (if (eq? (-> *setting-control* current video-mode) '150fps) 0.4 0.6) (-> arg0 wind-time)))) (-> arg0 wind-time)) (the-as uint 120)))
(f1-6 (* 0.008333334
(the float (mod (-> arg0 wind-time) (the-as uint 120)))
(the float (mod (if (or (eq? (-> *setting-control* current video-mode) '150fps) (eq? (-> *setting-control* current video-mode) '100fps)) (the uint (min 1.0 (* (if (eq? (-> *setting-control* current video-mode) '150fps) 0.4 0.6) (-> arg0 wind-time)))) (-> arg0 wind-time)) (the-as uint 120)))
)
)
(f2-4 (* 0.0625
+41
View File
@@ -1972,3 +1972,44 @@
;;;;;;;;; CUSTOM LEVELS
(define test-zone (new 'static 'level-load-info
:index 26
:name 'test-zone
:visname 'test-zone-vis ;; name + -vis
:nickname 'tsz ;; nickname
:packages '()
:sound-banks '()
:music-bank #f
:ambient-sounds '()
:mood '*default-mood*
:mood-func 'update-mood-default
:ocean #f
:sky #t
:continues '((new 'static 'continue-point
:name "test-zone-start"
:level 'test-zone
:trans (new 'static 'vector :x 0.0 :y (meters 10.) :z (meters 10.) :w 1.0)
:quat (new 'static 'quaternion :w 1.0)
:camera-trans (new 'static 'vector :x 0.0 :y 4096.0 :z 0.0 :w 1.0)
:camera-rot (new 'static 'array float 9 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0)
:load-commands '()
:vis-nick 'none
:lev0 'test-zone
:disp0 'display
:lev1 'village1
:disp1 'display
))
:tasks '()
:priority 100
:load-commands '()
:alt-load-commands '()
:bsp-mask #xffffffffffffffff
:bsphere (new 'static 'sphere :w 167772160000.0)
:bottom-height (meters -20)
:run-packages '()
:wait-for-load #t
)
)
(cons! *level-load-list* 'test-zone)
+137 -80
View File
@@ -93,13 +93,13 @@
"Draw a level!"
;; do the draw
(draw arg0 arg0 arg3)
(if (nonzero? *display-strip-lines*)
(debug-draw arg0 arg0 arg3)
)
(none)
)
(defmethod print level ((obj level))
"print a level."
@@ -115,7 +115,7 @@
(defmethod relocate bsp-header ((obj bsp-header) (dest-heap kheap) (name (pointer uint8)))
"Handle a bsp file load."
;; we expect that we'll have a loading-level set when we link/login a bsp-header
(let ((s5-0 (-> *level* loading-level)))
(if s5-0
@@ -175,7 +175,7 @@
(defmethod vis-clear level ((obj level))
"Clear the visibility info for when the level is loading."
;; clear vis-infos, so we can't try to look up a vis string.
(countdown (v1-0 8)
(nop!) ;; the usual.
@@ -194,11 +194,11 @@
(defmethod vis-load level ((obj level))
"Start the initial load of a VIS file to the IOP VIS buffer. After this is done, we can use
ramdisk-load to load chunks."
;; check to see if we have a buffer for loaded vis data.
;; check to see if we have a buffer for loaded vis data.
(when (zero? (-> obj vis-info (-> obj vis-self-index) ramdisk))
;; nope, we have no vis data buffer, we need to set it up.
;; first, we should see if the other level has loaded vis. if so, kill it.
(let ((vis (-> obj other vis-info (-> obj other vis-self-index))))
(when (and vis (nonzero? (-> vis ramdisk)))
@@ -207,7 +207,7 @@
0
)
)
;; set up a ramdisk rpc (fill command, actually load the file from DVD to IOP buffer)
(let ((visname (make-file-name (file-kind vis) (the-as string (-> obj nickname)) 0 #f))
(cmd (the-as ramdisk-rpc-fill (add-element *ramdisk-rpc*)))
@@ -222,7 +222,7 @@
(set! (-> obj vis-info (-> obj vis-self-index) ramdisk) s5-0)
)
)
;; return the ramdisk ID.
(-> obj vis-info (-> obj vis-self-index) ramdisk)
)
@@ -278,7 +278,7 @@
)
)
)
;; check for up to 6 neighbor level vis info. The last one is always left as null.
(dotimes (s5-1 6)
(let* ((s3-0 (+ s5-1 1))
@@ -425,7 +425,7 @@
(('alive)
(when (and *dproc* (= want-status 'active))
;; only if we want to do alive -> active
;; will set the level to be drawn.
(remove-by-param1 *background-draw-engine* (-> obj bsp))
(add-connection *background-draw-engine* *dproc* (the (function object object object object object) add-bsp-drawable) (-> obj bsp) obj #f)
@@ -539,10 +539,10 @@
;; set the level heap. level code logins called from linker may allocate here
(set! loading-level (-> obj heap))
;; relocate method of the bsp will look for this
(set! (-> *level* loading-level) obj)
;; clear out old stuff
(set! (-> *level* log-in-level-bsp) #f)
(set! (-> obj nickname) #f)
@@ -551,12 +551,12 @@
(set! (-> obj ambient) #f)
(set! (-> obj linking) #f)
(vis-clear obj)
(set! (-> obj status) 'loading)
;; incoming textures should use the level allocator
(set! (-> *texture-pool* allocate-func) texture-page-level-allocate)
;; build name
(if (= (-> obj load-name) (-> obj info visname))
(format (clear *temp-string*) "~S" (-> obj info nickname))
@@ -564,19 +564,19 @@
)
(set! (-> *temp-string* data 8) (the-as uint 0))
(format *temp-string* ".DGO")
;; reset temporary allocations on level heap
(set! (-> obj heap top) (-> obj heap top-base))
;; allocate DGO loading buffers
(let ((s4-0 (kmalloc (-> obj heap) (* 2 1024 1024) (kmalloc-flags align-64 top) "dgo-level-buf-2"))
(s5-2 (kmalloc (-> obj heap) (* 2 1024 1024) (kmalloc-flags align-64 top) "dgo-level-buf-2"))
)
(load-dbg " DGO buffers at #x~X #x~X~%" s4-0 s5-2)
;; we expect to load code first, remember where the heap is now.
(set! (-> obj code-memory-start) (-> obj heap current))
(format 0 "-----------> begin load ~A [~S]~%" (-> obj load-name) *temp-string*)
;; kick off the load!
(dgo-load-begin *temp-string* s5-2 s4-0 (the pointer (align64 (-> obj heap current))))
@@ -586,10 +586,10 @@
(defmethod login-begin level ((obj level))
"Start the login. This is spread over multiple frames."
;; done with load, reset the texture page allocator
(set! (-> *texture-pool* allocate-func) texture-page-default-allocate)
(cond
((-> obj bsp)
(set! (-> *level* log-in-level-bsp) (-> obj bsp))
@@ -605,7 +605,7 @@
)
)
)
;; set the login state machine at the beginning.
(set! (-> *login-state* state) -1)
(set! (-> *login-state* pos) (the-as uint 0))
@@ -633,16 +633,16 @@
(sv-16 prototype-bucket-tie)
(sv-32 int)
)
;; there is some logic for not doing the whole login all at once...
;; for now, we will somewhat ignore that.
(let ((level-drawable-trees (-> loaded-level bsp drawable-trees)))
;;(.mfc0 initial-timer Count)
(label cfg-1)
;;(.mfc0 current-timer Count)
;; this would quit the login function after some amount of time elapsed.
#|
(let ((elapsed-timer (- current-timer initial-timer)))
@@ -652,16 +652,16 @@
)
)
|#
(let ((current-login-pos (the-as int (-> level-login-state pos))))
;; Login state -1.
;; in this state, we log in drawables/art-groups that are in referenced in the bsp directly
;; the current-login-pos in the index of the drawable/art to login.
(when (= (-> level-login-state state) -1)
;;(load-dbg "login state -1~%")
;; login some drawables.
(when (< current-login-pos (-> level-drawable-trees length))
(let ((current-drawable (-> level-drawable-trees trees (the-as uint current-login-pos))))
@@ -699,7 +699,7 @@
(+! (-> level-login-state pos) 1)
(goto cfg-1)
)
;; this makes the art groups go at the end.
(let ((v1-39 (- (the-as uint current-login-pos) (the-as uint (-> level-drawable-trees length)))))
(when (< (the-as int v1-39) (-> loaded-level art-group art-group-array length))
@@ -713,14 +713,14 @@
(goto cfg-1)
)
)
;; if we got here, we're done with state -1!
(set! (-> level-login-state pos) (the-as uint 0))
(set! (-> level-login-state state) 0)
(goto cfg-1)
)
;; login state 0.
;; we log in children of the drawables from state -1.
(when (< (-> level-login-state state) (the-as int (-> level-login-state elts)))
@@ -755,7 +755,7 @@
(when (< current-login-pos (-> s1-2 length))
(set! sv-16 (-> s1-2 array-data (the-as uint current-login-pos)))
(set! sv-32 0)
(#when PC_PORT
;; if a TIE uses environment mapping, disable the fade out so it always renderers with
;; the generic renderer. In the port, we just make envmapped things always envmap.
@@ -763,7 +763,7 @@
(*! (-> sv-16 envmap-fade-far) 10000.)
)
)
(while (< sv-32 4)
(let ((a0-28 (-> sv-16 geometry sv-32)))
;;(load-dbg " login geom: ~A~%" a0-28)
@@ -810,8 +810,8 @@
)
(goto cfg-1)
)
(when (= (-> level-login-state state) (-> level-login-state elts))
(let ((v1-115 (-> loaded-level bsp)))
(cond
@@ -837,8 +837,7 @@
)
)
)
;; done!
(set! (-> loaded-level nickname) (-> loaded-level bsp nickname))
(if (nonzero? (-> loaded-level bsp nodes))
@@ -857,7 +856,7 @@
(set! (-> *subdivide-settings* close 3) f0-0)
(set! (-> *subdivide-settings* far 3) f1-0)
)
(load-dbg "init-vis~%")
(init-vis loaded-level)
(load-dbg "package load~%")
@@ -905,31 +904,31 @@
(case (-> obj status)
(('active 'alive)
(format 0 "----------- kill ~A (status ~A)~%" obj (-> obj status))
;; copy data from the level to the game-info storage. This will remember permanent level stuff, like
;; what you collected/completed.
(copy-perms-from-level! *game-info* obj)
(send-event *camera* 'level-deactivate (-> obj name))
(send-event *target* 'level-deactivate (-> obj name))
;; remove this BSP from the engine. This will stop us from being drawn.
(remove-by-param1 *background-draw-engine* (-> obj bsp))
;; track down all the entities and kill them
(deactivate-entities (-> obj bsp))
;; kill any remaining particles not associated with a part-tracker
(kill-all-particles-in-level obj)
;; clean up our level
(set! (-> obj inside-sphere?) #f)
(set! (-> obj inside-boxes?) #f)
(set! (-> obj meta-inside?) #f)
(set! (-> obj force-inside?) #f)
;; we're still loaded.
(set! (-> obj status) 'loaded)
(set! (-> obj all-visible?) 'loading)
;; clear vis buffers
(dotimes (v1-19 128)
@@ -955,10 +954,10 @@
(defmethod unload! level ((obj level))
"Unloads the level. This does not free the heap. The level will be made inactive and ready to be loaded some other time."
(deactivate obj)
(when (!= (-> obj status) 'inactive)
;; if we linked art group, unlink it.
(when (or (= (-> obj status) 'loaded)
(= (-> obj status) 'alive)
@@ -973,7 +972,7 @@
)
)
)
;; turn some things off
(set! (-> obj bsp) #f)
(set! (-> obj entity) #f)
@@ -981,7 +980,7 @@
(set! (-> obj status) 'inactive)
(set! (-> obj art-group string-array length) 0)
(set! (-> obj art-group art-group-array length) 0)
;; unload texture pages
(countdown (s5-1 (-> obj loaded-texture-page-count))
(dotimes (v1-27 32)
@@ -993,10 +992,10 @@
)
(set! (-> obj loaded-texture-page-count) 0)
(unlink-textures-in-heap! *texture-page-dir* (-> obj heap))
;; unload particle groups that were defined in the level data
(unlink-part-group-by-heap (-> obj heap))
;; if there are any in-progress art loads for this level, kill them.
(dotimes (s5-2 2)
(let ((v1-41 (-> *art-control* buffer s5-2 pending-load-file)))
@@ -1019,7 +1018,7 @@
(a0-29 (car s5-3))
)
(while (not (null? s5-3))
(case (rtype-of a0-29)
(case (rtype-of a0-29)
((symbol)
(unload (symbol->string (the-as symbol a0-29)))
)
@@ -1033,7 +1032,7 @@
)
(vis-clear obj)
;; reset the level heap!
(let ((v1-64 (-> obj heap)))
(set! (-> v1-64 current) (-> v1-64 base))
@@ -1057,14 +1056,14 @@
;; note : pc port added option to show every actor regardless
(with-pc (if (-> *pc-settings* force-actors?) (return #t)))
;; check the vis bits!
(let* (;; lwu v1, 388(a0)
(let* (;; lwu v1, 388(a0)
(vis-data (-> obj vis-bits))
;; sra a0, a1, 3
(byte-idx (sar arg0 3))
;; daddu v1, a0, v1
;; lb v1, 0(v1)
;; lb v1, 0(v1)
(vis-byte (-> (the (pointer int8) vis-data) byte-idx))
;; andi a0, a1, 7
(bit-idx (logand arg0 #b111))
@@ -1117,7 +1116,7 @@
(defmethod debug-print-splitbox level ((obj level) (arg0 vector) (arg1 string))
"Print the current splitbox, if we're in one."
(cond
((or (not (-> obj bsp)) (zero? (-> obj bsp boxes)) (zero? (-> obj bsp split-box-indices)))
((or (not (-> obj bsp)) (zero? (-> obj bsp boxes)) (zero? (-> obj bsp split-box-indices)))
;; do nothing!
)
(else
@@ -1431,6 +1430,11 @@
)
(defun bg ((level-name symbol))
"Begin game in a given level.
The level name can be the full name (village3), the nickname (vi3), or visname (village3-vis)
If the visname is used (and its a recognized level in level-info), it will use vis mode.
Otherwise, it will use the non-vis DGO name (like VILLAGE3.DGO) which will usually fail.
"
(set! *cheat-mode* (if *debug-segment*
'debug
#f
@@ -1496,6 +1500,62 @@
0
)
(defun bg-custom ((level-name symbol))
"Modified version of bg for the PC Port custom levels."
;; lookup info
(format 0 "(bg-custom ~A)%" level-name)
(let ((lev-info (lookup-level-info level-name)))
(when (= lev-info default-level)
(format 0 "Unable to (bg-custom ~A), the level was not found in *level-load-list*~%" level-name)
(return #f)
)
;; kill jak (rip)
(format 0 "doing stop~%")
(stop 'play)
;; enable visiblity. the custom level won't use it, but we want it on so other levels can be loaded.
(set! (-> *level* vis?) #t)
;; disable border and play mode to prevent loading levels
(set! (-> *level* border?) #f)
(set! (-> *setting-control* default border-mode) #f)
(set! (-> *level* play?) #f)
(format 0 "doing level load~%")
;; allocate level. This may start the loading process, but won't finish it.
(let ((lev (level-get-for-use *level* level-name 'active)))
(when (not lev)
(format 0 "Unable to load level, could not level-get-for-use~%")
(return #f)
)
(format 0 "about to start load loop, game will freeze and hopefully come back soon~%")
;; spin in a loop and load it. This will cause the game to freeze during the load,
;; but this is good enough for now.
(while (or (= (-> lev status) 'loading)
(= (-> lev status) 'loading-bt)
(= (-> lev status) 'login)
)
(load-continue lev)
)
(when (not (-> lev info continues))
(format 0 "level info has no continues, can't load it.~%")
)
(let ((cont (car (-> lev info continues))))
(start 'play (the continue-point cont))
)
(vis-load lev)
(set! (-> lev all-visible?) #f)
(set! (-> lev force-all-visible?) #t)
)
)
)
(defun play ((use-vis symbol) (init-game symbol))
"The entry point to the actual game! This allocates the level heaps, loads some data, sets some default parameters and sets the startup level."
@@ -1817,11 +1877,11 @@
)
)
)
;; load vis info.
;; The load-state's vis-nick is the level we want vis data for.
;; Note that we won't load vis until we are inside the level's boxes.
;; this will be the level that is currently being used.
(let ((s5-3 #f))
(dotimes (v1-121 (-> *level* length))
@@ -1833,7 +1893,7 @@
)
)
)
;; if we have the wrong vis
(when (and (!= s5-3 (-> obj vis-nick)) (-> *level* vis?))
;; and we want a vis
@@ -1859,23 +1919,23 @@
;; method 16 level-group (debug text stuff)
(defmethod level-update level-group ((obj level-group))
;; this does nothing...
(camera-pos)
(new 'static 'boxed-array :type symbol :length 0 :allocated-length 2)
;; compute the settings for this frame
(update *setting-control*)
;; run the art loading system
(update *art-control* #t)
(clear-rec *art-control*)
;; run level loading!
(dotimes (s5-0 2)
(load-continue (-> obj level s5-0))
)
;; compute inside for each level
(dotimes (s5-1 (-> obj length))
(let ((s4-0 (-> obj level s5-1)))
@@ -1889,10 +1949,9 @@
)
)
)
;; update load state machine (the level-border one)
(update! *load-state*)
;; checkpoint assignment
(dotimes (s5-2 (-> obj length))
(let ((s4-1 (-> obj level s5-2)))
@@ -1927,7 +1986,7 @@
)
)
)
;; determine vis info idx for each level
(dotimes (v1-67 (-> obj length))
(let ((a0-26 (-> obj level v1-67)))
@@ -1950,7 +2009,7 @@
)
)
)
;; display level vis info
(when *display-level-border*
(dotimes (s5-3 (-> obj length))
@@ -1978,7 +2037,7 @@
)
)
)
;; if we have vis for level A, but we aren't "in" it, display an error and
;; force us out of the other level. Ideally the boxes and the load boundary system
;; will be consistent and there is no way to set a vis to a level that we aren't in.
@@ -2002,7 +2061,6 @@
)
)
)
;; if we are outside of the boxes, we consider ourselves "outside of bsp"
;; if we are outside of both levels boxes, then we don't really know what to do
;; for vis, and we can display the classic "outside of bsp" error.
@@ -2041,7 +2099,7 @@
)
)
)
;; now, handle setting bit 31 (maybe single vis mode?)
(cond
;; special display self mode.
@@ -2074,7 +2132,6 @@
)
)
)
(when (or *display-level-border* *display-texture-download* *display-split-box-info*)
(when *display-level-border*
(format *stdcon* " want: ~A ~A/~A ~A ~A/~A~%"
@@ -2144,13 +2201,13 @@
)
)
)
;; tell PC port about our levels
(__pc-set-levels
(__pc-set-levels
(if (= (-> obj level0 status) 'inactive) "none" (symbol->string (-> obj level0 nickname)))
(if (= (-> obj level1 status) 'inactive) "none" (symbol->string (-> obj level1 nickname)))
)
0
)
+47 -67
View File
@@ -892,7 +892,7 @@
(set! sv-56 0)
(set! spool-sound (new-sound-id))
(backup-load-state-and-set-cmds *load-state* (-> arg0 command-list))
(set-setting! 'spooling (the-as symbol (process->ppointer self)) 0.0 0)
(set-setting! 'spooling (process->ppointer self) 0.0 0)
(logior! (-> self skel status) (janim-status inited drawn done))
(kill-current-level-hint '() '() 'die)
(level-hint-surpress!)
@@ -900,16 +900,9 @@
(when (or (handle->process (-> *art-control* spool-lock)) (!= *master-mode* 'game))
(cond
(arg1
(when (!= (if (> (-> self skel active-channels) 0)
(-> self skel root-channel 0 frame-group)
)
arg1
)
(when (!= (ja-group) arg1)
(ja-channel-push! 1 (seconds 0.05))
(let ((s2-0 (-> self skel root-channel 0)))
(joint-control-channel-group-eval! s2-0 arg1 num-func-identity)
(set! (-> s2-0 frame-num) 0.0)
)
(ja :group! arg1 :num! min)
)
)
(else
@@ -923,12 +916,9 @@
)
(spool-push *art-control* (-> arg0 name) spool-part self -9.0)
(suspend)
(when arg1
(let ((a0-17 (-> self skel root-channel 0)))
(set! (-> a0-17 param 0) 1.0)
(joint-control-channel-group-eval! a0-17 (the-as art-joint-anim #f) num-func-loop!)
(if arg1
(ja :num! (loop!))
)
)
)
)
(let ((v1-46 (process->ppointer self)))
@@ -936,7 +926,7 @@
(new 'static 'handle :process v1-46 :pid (-> (the-as process (-> v1-46 0)) pid))
)
)
(set! sv-48 (-> *display* base-frame-counter))
(set! sv-48 (the-as int (-> *display* base-frame-counter)))
(while (< spool-part (-> arg0 parts))
(spool-push *art-control* (-> arg0 name) spool-part self -20.0)
(update *art-control* #f)
@@ -944,16 +934,9 @@
(when (!= (file-status *art-control* (-> arg0 name) spool-part) 'active)
(cond
(arg1
(when (!= (if (> (-> self skel active-channels) 0)
(-> self skel root-channel 0 frame-group)
)
arg1
)
(when (!= (ja-group) arg1)
(ja-channel-set! 1)
(let ((s2-2 (-> self skel root-channel 0)))
(joint-control-channel-group-eval! s2-2 arg1 num-func-identity)
(set! (-> s2-2 frame-num) 0.0)
)
(ja :group! arg1 :num! min)
)
)
(else
@@ -967,12 +950,9 @@
(spool-push *art-control* (-> arg0 name) spool-part self -20.0)
(format #t "WARNING: ---------------------> loader stall on art ~S ~D~%" (-> arg0 name) spool-part)
(suspend)
(when arg1
(let ((a0-37 (-> self skel root-channel 0)))
(set! (-> a0-37 param 0) 1.0)
(joint-control-channel-group-eval! a0-37 (the-as art-joint-anim #f) num-func-loop!)
(if arg1
(ja :num! (loop!))
)
)
)
)
(spool-push *art-control* (-> arg0 name) spool-part self -20.0)
@@ -980,28 +960,39 @@
(cond
(s2-4
(ja-channel-set! 1)
(let ((a0-42 (-> self skel root-channel 0)))
(set! (-> a0-42 frame-group) s2-4)
(set! (-> a0-42 param 0) (the float (+ (-> s2-4 data 0 length) -1)))
(set! (-> a0-42 param 1) 1.0)
(set! (-> a0-42 frame-num) 0.0)
(joint-control-channel-group! a0-42 s2-4 num-func-seek!)
)
(ja-no-eval :group! s2-4 :num! (seek!) :frame-num 0.0)
(when (zero? spool-part)
(str-play-async (-> arg0 name) spool-sound)
(set! (-> *art-control* active-stream) (-> arg0 name))
)
(let* ((f30-0 (* 0.05859375 (-> s2-4 speed)))
;; When running at higher than 60fps, Jak's idle animations are spedup but no other animations appear to be
;; We couldn't figure out a simple way to detect these animations, so this is checking against the idle animation names
(let* ((f30-0 (* (if (and (or (= (-> *setting-control* current video-mode) '150fps) (= (-> *setting-control* current video-mode) '100fps))
(or (string= (-> arg0 name) "eichar-ambient-1")
(string= (-> arg0 name) "eichar-ambient-2")
(string= (-> arg0 name) "eichar-ambient-3")
(string= (-> arg0 name) "eichar-ambient-4")
(string= (-> arg0 name) "fishermans-boat-ride-to-village1-alt")
(string= (-> arg0 name) "fishermans-boat-ride-to-village1")
(string= (-> arg0 name) "fishermans-boat-ride-to-misty")
(string= (-> arg0 name) "gondola-ride-up")
(string= (-> arg0 name) "gondola-ride-down")
)
)
(if (= (-> *setting-control* current video-mode) '150fps) 0.4 0.6)
1.0
)
0.05859375 (-> s2-4 speed)))
(f28-0 (+ sv-24 (/ (the float (+ (-> s2-4 data 0 length) -1)) f30-0)))
)
(set! sv-72 (current-str-pos spool-sound))
(set! sv-40 (-> *display* base-frame-counter))
(set! sv-40 (the-as int (-> *display* base-frame-counter)))
(until (>= (the float v0-39) f28-0)
(if (= (-> self skel root-channel 0) (-> self skel channel))
(logior! (-> self skel status) (janim-status spool))
)
(if (or (arg3 self)
(and (<= sv-72 0) (>= (- (-> *display* base-frame-counter) sv-40) 1200))
(and (<= sv-72 0) (>= (- (-> *display* base-frame-counter) sv-40) (seconds 4)))
(and (< 300 sv-56) (<= sv-72 0))
)
(goto cfg-88)
@@ -1015,22 +1006,17 @@
(cond
((and (< sv-32 sv-72) (= (current-str-id) spool-sound))
(set! sv-56 (+ sv-56 (- (-> *display* base-frame-counter) (-> *display* old-base-frame-counter))))
(set! sv-40 (-> *display* base-frame-counter))
(set! sv-40 (the-as int (-> *display* base-frame-counter)))
)
(else
0
)
)
(set! sv-32 sv-72)
(set! sv-48 (-> *display* base-frame-counter))
(set! sv-48 (the-as int (-> *display* base-frame-counter)))
(suspend)
(let ((f0-14 (* (- (the float (current-str-pos spool-sound)) sv-24) f30-0))
(a0-69 (-> self skel root-channel 0))
)
(set! (-> a0-69 param 0) (the float (+ (-> a0-69 frame-group data 0 length) -1)))
(set! (-> a0-69 param 1) 1.0)
(set! (-> a0-69 frame-num) f0-14)
(joint-control-channel-group! a0-69 (the-as art-joint-anim #f) num-func-seek!)
(let ((f0-14 (* (- (the float (current-str-pos spool-sound)) sv-24) f30-0)))
(ja-no-eval :num! (seek!) :frame-num f0-14)
)
(set! v0-39 (current-str-pos spool-sound))
(set! sv-72 v0-39)
@@ -1055,34 +1041,28 @@
(defbehavior ja-abort-spooled-anim process-drawable ((arg0 spool-anim) (arg1 art-joint-anim) (arg2 int))
"Abort a spooled animation."
(restore-load-state-and-cleanup *load-state*)
(str-play-stop (-> arg0 name))
(set! (-> *art-control* active-stream) #f)
(logclear! (-> self skel status) (janim-status drawn done))
(if (zero? (logand (-> self skel status) (janim-status inited)))
(logclear! (-> self skel status) (janim-status inited))
)
(logclear! (-> self skel status) (janim-status inited))
)
(remove-setting! 'spooling)
(cond
((and arg1 (>= arg2 0))
(ja-channel-push! 1 (seconds 0.1))
(set! (-> self skel root-channel 0 frame-group) arg1)
(while (!= (-> self skel root-channel 0) (-> self skel channel))
(spool-push *art-control* (-> arg0 name) arg2 self -20.0)
(suspend)
;; TODO macro
(let ((a0-12 (-> self skel root-channel 0)))
(set! (-> a0-12 param 0) (the float (+ (-> a0-12 frame-group data 0 length) -1)))
(set! (-> a0-12 param 1) 1.0)
(joint-control-channel-group-eval! a0-12 (the-as art-joint-anim #f) num-func-seek!)
((and arg1 (>= arg2 0))
(ja-channel-push! 1 (seconds 0.1))
(set! (-> self skel root-channel 0 frame-group) arg1)
(while (!= (-> self skel root-channel 0) (-> self skel channel))
(spool-push *art-control* (-> arg0 name) arg2 self -20.0)
(suspend)
(ja :num! (seek!))
)
)
(else
(ja-channel-set! 0)
)
)
(else
(ja-channel-set! 0)
)
)
(set! (-> *art-control* spool-lock) (the-as handle #f))
0
)
+9 -40
View File
@@ -127,6 +127,12 @@
(new 'global 'sparticle-system 256 0 #t (-> *sprite-array-3d* vec-data) (-> *sprite-array-3d* adgif-data))
)
(defmacro launch-particles (&key (system *sp-particle-system-2d*) particle origin &key (launch-state (the-as sparticle-launch-state #f)) &key (launch-control (the-as sparticle-launch-control #f))
&key (rate (if (= (-> *setting-control* current video-mode) '150fps)
(if (= (-> *setting-control* current video-mode) '100fps) 0.6 0.4)
1.0)))
`(sp-launch-particles-var ,system ,particle ,origin ,launch-state ,launch-control ,rate)
)
;;;;;;;;;;;;;;;;;;;;
@@ -676,46 +682,9 @@
(none)
)
(defun set-particle-frame-time ((arg0 int))
(cond
((= arg0 5)
(set-vector!
*sp-frame-time*
0.00000000000000000000000000000000000001175495
5.0
1.0
1.0
)
)
((= arg0 6)
(set-vector!
*sp-frame-time*
0.000000000000000000000000000000000000011754952
6.0
1.2
1.2
)
)
((= arg0 10)
(set-vector!
*sp-frame-time*
0.000000000000000000000000000000000000011754958
10.0
2.0
2.0
)
)
((= arg0 12)
(set-vector!
*sp-frame-time*
0.00000000000000000000000000000000000001175496
12.0
2.4
2.4
)
)
)
0
(defun set-particle-frame-time ((scaled-seconds int))
"Adjusts particle frame time based on the frame-rate (scaled-seconds). Note: This used to be a case statement and has been rewritten as a more generic formula"
(set-vector! *sp-frame-time* (the-as float (logior #x800000 scaled-seconds)) (the float scaled-seconds) (* 0.2 scaled-seconds) (* 0.2 scaled-seconds))
(none)
)
+4 -2
View File
@@ -180,9 +180,11 @@
)
)
(let ((s5-2 (level-get *level* (-> arg0 level))))
(when s5-2
;; vis info check added for PC, don't bother waiting for vis if the level doesn't have it.
(when (and s5-2 (-> s5-2 vis-info 0))
(while (and (= (-> s5-2 all-visible?) 'loading) (-> *level* vis?))
(suspend)
(suspend)
)
)
)
+1 -8
View File
@@ -2172,14 +2172,7 @@
)
)
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2002)
a2-3
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
(the-as float 1.0)
)
(launch-particles (-> *part-id-table* 2002) a2-3)
)
(suspend)
0
+34 -9
View File
@@ -809,7 +809,12 @@
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max (/ (* (fmax 20480.0 (-> self control unknown-float01)) (-> *display* seconds-per-frame))
;; This controls the slow walk animation that occurs after landing from a jump. > 60fps was broken here so I think should not be tied to seconds-per-frame
;; unknown-float01 is the magnitude of xz velocity
(ja :num! (seek! max (/ (* (fmax 20480.0 (-> self control unknown-float01)) (if (or (= (-> *setting-control* current video-mode) '150fps)
(= (-> *setting-control* current video-mode) '100fps))
0.016666668
(-> *display* seconds-per-frame)))
(/ (-> *TARGET-bank* run-up-cycle-dist) (-> *TARGET-bank* run-cycle-length))
)
)
@@ -879,7 +884,11 @@
(set! f30-0 (seek
f30-0
(fmax 0.0 (fmin 1.0 (* 0.000048828126 (+ -16384.0 (-> self control unknown-float01)))))
(* 2.0 (-> *display* seconds-per-frame))
;; Jaks' walk animation felt sped up in > 60fps. I'm thinking it shouldn't be tied to seconds-per-frame but I'm not positive
(* 2.0 (if (or (= (-> *setting-control* current video-mode) '150fps)
(= (-> *setting-control* current video-mode) '100fps))
0.016666668
(-> *display* seconds-per-frame)))
)
)
(let ((v1-317 (-> self skel effect)))
@@ -2438,7 +2447,13 @@
(seek!
(-> self control dynam gravity-length)
(-> self control unknown-dynamics00 gravity-length)
(* 245760.0 (-> *display* seconds-per-frame))
(* 245760.0 (if (or (= (-> *setting-control* current video-mode) '150fps)
(= (-> *setting-control* current video-mode) '100fps)
)
0.016666668
(-> *display* seconds-per-frame)
)
)
)
)
(when (and (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.05))
@@ -2741,10 +2756,14 @@
(or (= v1-6 eichar-flop-down-loop-ja) (= v1-6 eichar-moving-flop-down-ja))
)
)
(when (and (or (< (target-move-dist (seconds 0.1)) 1638.4)
(and (logtest? (-> self control status) (cshape-moving-flags twall)) (< 0.7 (-> self control poly-angle)))
)
(zero? (logand (-> self control status) (cshape-moving-flags t-act)))
(when (and (or (< (target-move-dist (if (or (= (-> *setting-control* current video-mode) '150fps) (= (-> *setting-control* current video-mode) '150fps))
(if (= (-> *setting-control* current video-mode) '150ps) (seconds 0.04) (seconds 0.06))
(seconds 0.1)))
(if (or (= (-> *setting-control* current video-mode) '150fps) (= (-> *setting-control* current video-mode) '100fps)) (if (= (-> *setting-control* current video-mode) '150fps) 655.36 983.04) 1638.4)
)
(and (logtest? (-> self control status) (cshape-moving-flags twall)) (< 0.7 (-> self control poly-angle)))
)
(zero? (logand (-> self control status) (cshape-moving-flags t-act)))
(>= (-> self control unknown-uint20) (the-as uint 2))
)
(set! (-> self control unknown-dword36) (-> *display* base-frame-counter))
@@ -2766,9 +2785,15 @@
(lambda ((arg0 target)) (let ((f0-3 (seek
(-> arg0 control root-prim local-sphere w)
(the-as float 28672.0)
(* 286720.0 (-> *display* seconds-per-frame))
(* 286720.0 0 (if (or (= (-> *setting-control* current video-mode) '150fps)
(= (-> *setting-control* current video-mode) '100fps)
)
0.016666668
(-> *display* seconds-per-frame)
)
)
)
)
)
)
(set! (-> arg0 control root-prim local-sphere w) f0-3)
f0-3
+1 -1
View File
@@ -224,7 +224,7 @@
)
(case (get-aspect-ratio)
(('aspect4x3)
(set! (-> self sides-x-scale) 3.5)
(set! (-> self sides-x-scale) (if (= (-> *pc-settings* aspect-custom-x) 16) 5.0 3.5))
(set! (-> self sides-y-scale) 13.0)
(set! (-> self x-offset) 0)
0
+2 -2
View File
@@ -701,9 +701,9 @@
(let ((f0-1 (* (1/ METER_LENGTH) (the float (-> obj in-out-position)))))
(set! (-> obj particles 2 init-pos x) (the float (+ (-> obj right-x-offset) 409 (the int (* 301.5 f0-1)))))
(set! (-> obj particles 1 init-pos x) (the float (+ (-> obj left-x-offset) 59)))
(set! (-> obj left-side-x-scale) (meters (+ (/ 3.5 (-> obj sides-x-scale)) (* 10.0 f0-1))))
(set! (-> obj left-side-x-scale) (meters (+ (/ (if (= (-> *pc-settings* aspect-custom-x) 16) 5.0 3.5) (-> obj sides-x-scale)) (* 10.0 f0-1))))
(set! (-> obj left-side-y-scale) (meters (+ (-> obj sides-y-scale) (* 10.0 f0-1))))
(set! (-> obj right-side-x-scale) (meters (+ (/ 6.0 (-> obj sides-x-scale)) (* 4.0 f0-1))))
(set! (-> obj right-side-x-scale) (meters (+ (/ (if (= (-> *pc-settings* aspect-custom-x) 16) 8.5 6.0) (-> obj sides-x-scale)) (* 4.0 f0-1))))
(set! (-> obj right-side-y-scale) (meters (+ (-> obj sides-y-scale) (* 4.0 f0-1))))
)
(dotimes (s5-0 (-> obj nb-of-particles))
+3 -17
View File
@@ -102,23 +102,9 @@
)
(dotimes (i 10)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 37)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
(launch-particles (-> *part-id-table* 37) gp-0)
(launch-particles (-> *part-id-table* 38) gp-0)
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 38)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
)
)
)
0
@@ -368,4 +354,4 @@
(load-state-want-display-level *debug-load-level* #t)
)
)
)
)
+61
View File
@@ -0,0 +1,61 @@
;;-*-Lisp-*-
(in-package goal)
;; This script creates a simple process that draws text demonstrating
;; all of GOAL's color constants to the on-screen debug output.
;; Create somewhere for the handle to the process to live. See https://open-goal.github.io/docs/reference/process_and_state
;; as well as kernel/gstate.gc
(define *color-display-handle* (new 'static 'handle))
(set! *color-display-handle* (the handle #f))
(defun-debug start-display-text-colors ()
"Spawn an onscreen string displaying all possible colors"
(if (not (handle->process *color-display-handle*))
(let ((disp-proc
(process-spawn-function process :name 'display-proc
(lambda :behavior process ()
(stack-size-set! (-> self main-thread) 256)
(loop
;; These constants live in engine/gfx/font-h.gc
(format *stdcon* "~0k~%~%
~0L 0 default ~1L 1 white
~2L 2 gray ~3L 3 orange-red
~4L 4 bright-orange-red ~5L 5 bright-orange-red
~6L 6 bright-green ~7L 7 dark-blue
~8L 8 light-blue ~9L 9 dark-pink
~10L10 lighter-blue ~11L11 dark-light-blue
~12L12 dim-white ~13L13 dim-gray
~14L14 orange-red-2 ~15L15 yellow-green
~16L16 dark-green ~17L17 another-gray
~18L18 dark-dark-green ~19L19 flat-dark-purple
~20L20 flat-yellow ~21L21 blue-white
~22L22 pad-back ~23L23 pad-shine
~24L24 pad-square ~25L25 pad-circle
~26L26 pad-triangle ~27L27 pad-x
~28L28 lighter-lighter-blue ~29L29 yellow-orange
~30L30 yellow-green-2 ~31L31 another-light-blue
~32L32 light-yellow ~33L33 red-orange
~34L34 another-orange-red~0L~%
alternate names
~3L3 red ~4L4 red2 ~5L5 yellow ~6L6 green ~7L7 blue
~10L10 cyan ~33L33 red-reverse ~34L34 red-obverse~0L"
)
(suspend)
)
)
)
))
(set! *color-display-handle* (ppointer->handle disp-proc))
)
;; else
(format #t "Colors are already being displayed")
)
)
(defun-debug stop-display-text-colors ()
"Kill the example text color display"
(kill-by-name 'display-proc *active-pool*)
)
+28
View File
@@ -103,6 +103,17 @@
)
)
(defun custom-level-cgo (output-name desc-file-name)
"Add a CGO with the given output name (in out/iso) and input name (in custom_levels/)"
(let ((out-name (string-append "out/iso/" output-name)))
(defstep :in (string-append "custom_levels/" desc-file-name)
:tool 'dgo
:out `(,out-name)
)
(set! *all-cgos* (cons out-name *all-cgos*))
)
)
(defun cgo (output-name desc-file-name)
"Add a CGO with the given output name (in out/iso) and input name (in goal_src/dgos)"
(let ((out-name (string-append "out/iso/" output-name)))
@@ -147,6 +158,12 @@
)
)
(defmacro build-custom-level (name)
(let* ((path (string-append "custom_levels/" name "/" name ".jsonc")))
`(defstep :in ,path
:tool 'build-level
:out '(,(string-append "out/obj/" name ".go")))))
(defun get-iso-data-path ()
(if *use-iso-data-path*
(string-append *iso-data* "/")
@@ -1553,6 +1570,17 @@
"ndi-volumes-ag"
"title-vis")
;;;;;;;;;;;;;;;;;;;;;;;;;
;; Example Custom Level
;;;;;;;;;;;;;;;;;;;;;;;;;
;; Set up the build system to build the level geometry
;; this path is relative to the custom_levels/ folder
;; it should point to the .jsonc file that specifies the level.
(build-custom-level "test-zone")
;; the DGO file
(custom-level-cgo "TESTZONE.DGO" "test-zone/testzone.gd")
;;;;;;;;;;;;;;;;;;;;;
;; Game Engine Code
;;;;;;;;;;;;;;;;;;;;;
+2 -16
View File
@@ -93,24 +93,10 @@
(f0-0 (vector-vector-distance (-> self root trans) gp-0))
)
(if (or (< (-> gp-0 y) (-> self root trans y)) (< 122880.0 f0-0))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 666)
(-> self root trans)
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 666) (-> self root trans))
)
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 668)
(-> self root trans)
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 668) (-> self root trans))
)
(suspend)
)
+4 -32
View File
@@ -241,44 +241,16 @@
(defmethod particle-effect lurkerworm ((obj lurkerworm))
(let ((a2-0 (vector<-cspace! (new 'stack-no-clear 'vector) (-> obj node-list data 5))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 661)
a2-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 661) a2-0)
)
(let ((a2-1 (vector<-cspace! (new 'stack-no-clear 'vector) (-> obj node-list data 6))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 661)
a2-1
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 661) a2-1)
)
(let ((a2-2 (vector<-cspace! (new 'stack-no-clear 'vector) (-> obj node-list data 7))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 661)
a2-2
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 661) a2-2)
)
(let ((a2-3 (vector<-cspace! (new 'stack-no-clear 'vector) (-> obj node-list data 8))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 661)
a2-3
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 661) a2-3)
)
0
(none)
+2 -16
View File
@@ -63,22 +63,8 @@
(let ((gp-0 (new 'stack-no-clear 'vector)))
(sp-kill-particle arg0 arg1)
(set-vector! gp-0 (-> arg2 x) (-> arg2 y) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2882)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
(the-as float 1.0)
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2883)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
(the-as float 1.0)
)
(launch-particles :rate 1.0 (-> *part-id-table* 2882) gp-0)
(launch-particles :rate 1.0 (-> *part-id-table* 2883) gp-0)
)
)
(none)
+1 -8
View File
@@ -71,14 +71,7 @@
)
(dotimes (s2-2 12)
(vector-matrix*! s5-0 (-> self bar-array s2-2) gp-0)
(sp-launch-particles-var
s3-1
s4-1
s5-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system s3-1 s4-1 s5-0)
)
)
)
+1 -8
View File
@@ -887,14 +887,7 @@
(dotimes (s5-0 16)
(quaternion-rotate-local-z! gp-0 gp-0 2048.0)
(quaternion-copy! *particle-quat* gp-0)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 2541)
(-> self blast-pos)
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 2541) (-> self blast-pos))
)
)
(spawn (-> self part) (-> self blast-pos))
+4 -32
View File
@@ -188,22 +188,8 @@
(let ((gp-0 (new 'stack-no-clear 'vector)))
(sp-kill-particle arg0 arg1)
(set-vector! gp-0 (-> arg2 x) (-> arg2 y) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2904)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2905)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :rate 1.0 (-> *part-id-table* 2904) gp-0)
(launch-particles :rate 1.0 (-> *part-id-table* 2905) gp-0)
)
)
(none)
@@ -321,22 +307,8 @@
(let ((gp-0 (new 'stack-no-clear 'vector)))
(sp-kill-particle arg0 arg1)
(set-vector! gp-0 (-> arg2 x) (-> arg2 y) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2910)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2911)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :rate 1.0 (-> *part-id-table* 2910) gp-0)
(launch-particles :rate 1.0 (-> *part-id-table* 2911) gp-0)
)
)
(none)
@@ -352,22 +352,8 @@
(let ((gp-0 (new 'stack-no-clear 'vector)))
(sp-kill-particle arg0 arg1)
(set-vector! gp-0 (-> arg2 x) (-> arg2 y) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2933)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2934)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :rate 1.0 (-> *part-id-table* 2933) gp-0)
(launch-particles :rate 1.0 (-> *part-id-table* 2934) gp-0)
)
)
(none)
@@ -1041,22 +1027,8 @@
(let ((gp-0 (new 'stack-no-clear 'vector)))
(sp-kill-particle arg0 arg1)
(set-vector! gp-0 (-> arg2 x) (-> arg2 y) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2962)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2963)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :rate 1.0 (-> *part-id-table* 2962) gp-0)
(launch-particles :rate 1.0 (-> *part-id-table* 2963) gp-0)
)
)
(none)
+1 -8
View File
@@ -218,14 +218,7 @@
(ja-channel-push! 1 (seconds 0.15))
(ja-no-eval :group! darkvine-retreat-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 800)
(-> self root-override trans)
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 800) (-> self root-override trans))
(suspend)
(ja :num! (seek!))
)
+5 -40
View File
@@ -853,14 +853,7 @@
(set! (-> *part-id-table* 118 init-specs 1 initial-valuef) 0.05)
(set! (-> *part-id-table* 118 init-specs 2 initial-valuef) 0.0)
(set! (-> *part-id-table* 118 init-specs 13 initial-valuef) 0.35555556)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 118)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 118) gp-0)
)
0
(none)
@@ -1738,42 +1731,14 @@
(when (-> self training)
(let ((gp-0 (new-stack-vector0)))
(vector<-cspace! gp-0 (-> self node-list data 74))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2001)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 2001) gp-0)
(fisher-fish-water gp-0 (+ 32768.0 (vector-y-angle (-> self node-list data 75 bone transform vector 1))))
(vector<-cspace! gp-0 (-> self node-list data 77))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2001)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 2001) gp-0)
(fisher-fish-water gp-0 (+ 32768.0 (vector-y-angle (-> self node-list data 78 bone transform vector 1))))
(vector<-cspace! gp-0 (-> self node-list data 80))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 828)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2013)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 828) gp-0)
(launch-particles (-> *part-id-table* 2013) gp-0)
(fisher-fish-water gp-0 (+ 32768.0 (vector-y-angle (-> self node-list data 80 bone transform vector 1))))
)
)
+2 -16
View File
@@ -998,14 +998,7 @@
(when (periscope-has-power-input?)
(update! (-> self sound))
(if (logtest? (-> self draw status) (draw-status was-drawn))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 825)
(-> self reflector-trans)
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 825) (-> self reflector-trans))
)
)
0
@@ -1828,14 +1821,7 @@
(draw-power-beam gp-0 (-> self beam-end))
(update! (-> self sound))
(when (logtest? (-> self draw status) (draw-status was-drawn))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 825)
(-> self beam-end)
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 825) (-> self beam-end))
(when (and *target* (>= 24576.0 (vector-vector-distance (-> self root-override trans) (-> *target* control trans))))
(start-hint-timer (game-text-id jungle-mirrors-break-the-mirror-jak))
(level-hint-spawn
+2 -16
View File
@@ -483,22 +483,8 @@
(cond
((< gp-0 a0-1)
(when (sphere-in-view-frustum? (the-as sphere (-> self root-override root-prim prim-core)))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 704)
(the-as vector (-> self launch-pos))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 705)
(the-as vector (&-> self stack 112))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 704) (the-as vector (-> self launch-pos)))
(launch-particles (-> *part-id-table* 705) (the-as vector (&-> self stack 112)))
)
(when (-> self should-play-sound?)
(set! (-> self should-play-sound?) #f)
+2 -16
View File
@@ -293,22 +293,8 @@
(sound-play "water-drop")
)
(set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2231)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 2232)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :rate 1.0 (-> *part-id-table* 2231) gp-0)
(launch-particles :system *sp-particle-system-3d* :rate 1.0 (-> *part-id-table* 2232) gp-0)
)
)
(none)
+1 -8
View File
@@ -1394,14 +1394,7 @@
(defstate breakaway-about-to-fall (breakaway)
:code (behavior ()
(sound-play "falling-bones")
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 281)
(-> self root-override trans)
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 281) (-> self root-override trans))
(let ((gp-1 #f)
(s5-1 (-> *display* base-frame-counter))
)
+1 -8
View File
@@ -150,14 +150,7 @@
(defmethod dummy-51 muse ((obj muse))
(dotimes (s5-0 2)
(let ((v1-2 (rand-vu-int-range 3 (+ (-> obj node-list length) -1))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 271)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> obj node-list data v1-2))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 271) (vector<-cspace! (new 'stack-no-clear 'vector) (-> obj node-list data v1-2)))
)
)
0
+1 -8
View File
@@ -407,14 +407,7 @@
)
(when (>= (-> self control unknown-float01) 40960.0)
(set! (-> *part-id-table* 2225 init-specs 1 initial-valuef) 100.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2225)
(-> self control trans)
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 2225) (-> self control trans))
)
(target-land-effect)
(when (and (>= (-> self control ground-impact-vel) 61440.0) (zero? (-> self racer bounce)))
+23 -78
View File
@@ -650,14 +650,10 @@
(when (< 0.0 (-> *part-id-table* 2212 init-specs 11 initial-valuef))
(set! (-> *part-id-table* 2212 init-specs 14 initial-valuef) (the-as float gp-0))
(set! (-> *part-id-table* 2212 init-specs 3 initial-valuef) 15155.2)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 2212)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self manipy 0 node-list data 4))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system *sp-particle-system-3d*
(-> *part-id-table* 2212)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self manipy 0 node-list data 4))
)
)
)
(let ((gp-2 (vector-y-quaternion! (new 'stack-no-clear 'vector) (-> self control unknown-quaternion00))))
@@ -670,14 +666,10 @@
(when (< 0.0 (-> *part-id-table* 2212 init-specs 11 initial-valuef))
(set! (-> *part-id-table* 2212 init-specs 14 initial-valuef) (the-as float gp-2))
(set! (-> *part-id-table* 2212 init-specs 3 initial-valuef) 10240.0)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 2212)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self manipy 0 node-list data 10))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system *sp-particle-system-3d*
(-> *part-id-table* 2212)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self manipy 0 node-list data 10))
)
)
)
(when (and (racer-on-ground?) (< (-> self control unknown-float01) 90112.0))
@@ -696,22 +688,8 @@
(set! (-> *part-id-table* 2275 init-specs 19 initial-valuef) (+ 49152.0 f1-3))
(set! (-> *part-id-table* 2275 init-specs 1 initial-valuef) (* 0.0000036621095 f0-17))
(set! (-> *part-id-table* 2275 init-specs 2 initial-valuef) (* 0.1 f0-17))
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 2275)
s4-2
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 2276)
s4-2
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 2275) s4-2)
(launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 2276) s4-2)
)
)
(-> *part-id-table* 2208)
@@ -753,17 +731,10 @@
)
(set! (-> s5-2 y) (-> self control shadow-pos y))
(if (nonzero? a1-13)
(sp-launch-particles-var
(if gp-4
*sp-particle-system-3d*
*sp-particle-system-2d*
)
a1-13
s5-2
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system (if gp-4 *sp-particle-system-3d* *sp-particle-system-2d*)
a1-13
s5-2
)
)
)
(let* ((gp-5 #f)
@@ -790,17 +761,10 @@
)
(set! (-> a2-7 y) (-> self control shadow-pos y))
(if (nonzero? s5-3)
(sp-launch-particles-var
(if gp-5
*sp-particle-system-3d*
*sp-particle-system-2d*
)
(the-as sparticle-launcher s5-3)
a2-7
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system (if gp-5 *sp-particle-system-3d* *sp-particle-system-2d*)
(the-as sparticle-launcher s5-3)
a2-7
)
)
)
)
@@ -916,14 +880,9 @@
(when (!= (-> self racer boost-output) 0.0)
(dotimes (gp-7 8)
(let ((v1-258 (rand-vu-int-range 3 (+ (-> self node-list length) -1))))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2229)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-258))
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 2229)
(vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data v1-258))
)
)
)
(cpad-set-buzz! (-> *cpad-list* cpads 0) 0 1 (seconds 0.1))
@@ -948,14 +907,7 @@
)
)
)
(sp-launch-particles-var
*sp-particle-system-2d*
a1-54
gp-8
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles a1-54 gp-8)
)
(cpad-set-buzz! (-> *cpad-list* cpads 0) 0 51 (seconds 0.05))
(sound-play-by-name
@@ -986,14 +938,7 @@
)
)
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2227)
a2-28
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 2227) a2-28)
)
)
0
@@ -1157,14 +1157,7 @@
(let ((gp-0 (new 'stack-no-clear 'vector)))
(sp-kill-particle arg0 arg1)
(set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 1771)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :rate 1.0 (-> *part-id-table* 1771) gp-0)
)
)
(none)
@@ -1178,14 +1171,7 @@
(sound-play "land-grass")
)
(set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 1772)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :rate 1.0 (-> *part-id-table* 1772) gp-0)
)
)
(none)
+1 -8
View File
@@ -152,14 +152,7 @@
)
(set! (-> *part-id-table* 1717 init-specs 1 random-rangef) (* 0.000009494358 f30-0))
)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 1717)
arg0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 1717) arg0)
0
(none)
)
+1 -8
View File
@@ -571,14 +571,7 @@
(vector-matrix*! gp-0 gp-0 s4-0)
(vector-float*! gp-0 gp-0 (/ 1.0 (-> gp-0 w)))
(set! (-> *part-id-table* 2515 init-specs 13 initial-valuef) (+ 24576.0 (-> gp-0 y)))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 2515)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 2515) gp-0)
)
(none)
)
+1 -8
View File
@@ -80,14 +80,7 @@
)
(set! (-> gp-0 vertex-skip) 128)
(dotimes (s5-0 (-> gp-0 vertex-count))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 1736)
(-> gp-0 data s5-0)
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles (-> *part-id-table* 1736) (-> gp-0 data s5-0))
)
)
#f
+2 -16
View File
@@ -293,22 +293,8 @@
(sound-play "water-drop")
)
(set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 763)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 764)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :rate 1.0 (-> *part-id-table* 763) gp-0)
(launch-particles :system *sp-particle-system-3d* :rate 1.0 (-> *part-id-table* 764) gp-0)
)
)
(none)
+1 -8
View File
@@ -359,14 +359,7 @@
(sound-play "water-drop")
)
(set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 367)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :rate 1.0 (-> *part-id-table* 367) gp-0)
)
)
(none)
+1 -8
View File
@@ -688,14 +688,7 @@
(set! (-> *part-id-table* 2896 init-specs 19 initial-valuef) (+ 49152.0 arg1))
(set! (-> *part-id-table* 2896 init-specs 1 initial-valuef) (* 0.0000036621095 arg2))
(set! (-> *part-id-table* 2896 init-specs 2 initial-valuef) (* 0.1 arg2))
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 2896)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 2896) gp-0)
)
0
(none)
+2 -16
View File
@@ -1209,22 +1209,8 @@
(let ((gp-0 (new 'stack-no-clear 'vector)))
(sp-kill-particle arg0 arg1)
(set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 434)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
(the-as float 1.0)
)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 435)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
(the-as float 1.0)
)
(launch-particles :rate 1.0 (-> *part-id-table* 434) gp-0)
(launch-particles :system *sp-particle-system-3d* :rate 1.0 (-> *part-id-table* 435) gp-0)
)
)
(none)
+2 -16
View File
@@ -1613,22 +1613,8 @@
(sound-play "water-drop")
)
(set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 502)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
(the-as float 1.0)
)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 503)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
(the-as float 1.0)
)
(launch-particles :rate 1.0 (-> *part-id-table* 502) gp-0)
(launch-particles :system *sp-particle-system-3d* :rate 1.0 (-> *part-id-table* 503) gp-0)
)
)
(none)
@@ -687,14 +687,7 @@
(sound-play "water-drop")
)
(set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 1324)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :rate 1.0 (-> *part-id-table* 1324) gp-0)
)
)
(none)
+1 -8
View File
@@ -1030,14 +1030,7 @@
(let ((a2-1 (new 'static 'vector)))
(set! (-> a2-1 quad) (-> self root-override trans quad))
(set! (-> a2-1 y) 0.0)
(sp-launch-particles-var
*sp-particle-system-3d*
(-> *part-id-table* 2017)
a2-1
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(launch-particles :rate 1.0 (-> *part-id-table* 2017) a2-1)
)
)
(none)
+1 -8
View File
@@ -1856,14 +1856,7 @@
(sound-play "water-drop")
)
(set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 1207)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
(the-as float 1.0)
)
(launch-particles :rate 1.0 (-> *part-id-table* 1207) gp-0)
)
)
(none)
+20 -3
View File
@@ -104,13 +104,30 @@
(format *stdcon* "~%")
)
(dotimes (ii 2)
(format *stdcon* " ~3Lcpad ~D~0L~%" ii)
(format *stdcon* " ~0k~3Lcpad ~D~0L~%" ii)
(dotimes (j 8)
(dotimes (i 2)
(let (
(format *stdcon* " ")
(let* (
(btn-idx (+ i(* j 2)))
(btn-name (-> *pc-pad-button-names* btn-idx))
(keycode (pc-pad-get-mapped-button ii btn-idx))
)
(format *stdcon* " ~8L~S: ~0L~D " (-> *pc-pad-button-names* btn-idx) (pc-pad-get-mapped-button ii btn-idx))
(format *stdcon* "~8L~S: " btn-name)
;; longest button string is TRIANGLE, which is 8 characters in length
;; but only shows up in the left column. CIRCLE and SQUARE are longest in the right with 6
(dotimes (_ (-
(cond ((= i 0) 8) ((= i 1) 6))
(length btn-name)))
(format *stdcon* " ")
)
(format *stdcon* "~0L~D" keycode)
(when (< keycode 100)
(format *stdcon* " ")
(if (< keycode 10)
(format *stdcon* " ")
)
)
)
)
(format *stdcon* "~%")
+11 -1
View File
@@ -5,6 +5,16 @@ add_library(compiler
emitter/ObjectGenerator.cpp
emitter/Register.cpp
debugger/disassemble.cpp
build_level/build_level.cpp
build_level/collide_bvh.cpp
build_level/collide_drawable.cpp
build_level/collide_pack.cpp
build_level/color_quantization.cpp
build_level/FileInfo.cpp
build_level/gltf_mesh_extract.cpp
build_level/LevelFile.cpp
build_level/ResLump.cpp
build_level/Tfrag.cpp
compiler/Compiler.cpp
compiler/Env.cpp
compiler/Val.cpp
@@ -44,7 +54,7 @@ add_library(compiler
regalloc/Allocator_v2.cpp
)
target_link_libraries(compiler common Zydis)
target_link_libraries(compiler common Zydis tiny_gltf)
if (WIN32)
target_link_libraries(compiler mman)
+30
View File
@@ -0,0 +1,30 @@
#include "FileInfo.h"
#include "goalc/data_compiler/DataObjectGenerator.h"
#include "common/versions.h"
size_t FileInfo::add_to_object_file(DataObjectGenerator& gen) const {
gen.align_to_basic();
gen.add_type_tag("file-info");
size_t offset = gen.current_offset_bytes();
gen.add_type_tag(file_type);
gen.add_ref_to_string_in_pool(file_name);
gen.add_word(major_version);
gen.add_word(minor_version);
gen.add_ref_to_string_in_pool(maya_file_name);
gen.add_ref_to_string_in_pool(tool_debug);
gen.add_ref_to_string_in_pool(tool_debug);
return offset;
}
FileInfo make_file_info_for_level(const std::string& file_name) {
FileInfo info;
info.file_type = "bsp-header";
info.file_name = file_name;
info.major_version = versions::jak1::LEVEL_FILE_VERSION;
info.minor_version = 0;
info.maya_file_name = "Unknown";
info.tool_debug = "Created by OpenGOAL buildlevel";
info.mdb_file_name = "Unknown";
return info;
}
+28
View File
@@ -0,0 +1,28 @@
#pragma once
#include <string>
#include "common/common_types.h"
class DataObjectGenerator;
struct FileInfo {
// (file-type symbol :offset-assert 4)
std::string file_type;
// (file-name basic :offset-assert 8)
std::string file_name;
// (major-version uint32 :offset-assert 12)
u32 major_version = 0;
// (minor-version uint32 :offset-assert 16)
u32 minor_version = 0;
// (maya-file-name basic :offset-assert 20)
std::string maya_file_name;
// (tool-debug basic :offset-assert 24)
std::string tool_debug;
// (mdb-file-name basic :offset-assert 28)
std::string mdb_file_name;
size_t add_to_object_file(DataObjectGenerator& gen) const;
};
FileInfo make_file_info_for_level(const std::string& file_name);
+105
View File
@@ -0,0 +1,105 @@
#include "LevelFile.h"
#include "goalc/data_compiler/DataObjectGenerator.h"
size_t DrawableTreeArray::add_to_object_file(DataObjectGenerator& gen) const {
/*
(deftype drawable-tree-array (drawable-group)
((trees drawable-tree 1 :offset 32 :score 100))
:flag-assert #x1200000024
)
(deftype drawable-group (drawable)
((length int16 :offset 6)
(data drawable 1 :offset-assert 32)
)
(:methods
(new (symbol type int) _type_)
)
:flag-assert #x1200000024
)
*/
gen.align_to_basic();
gen.add_type_tag("drawable-tree-array");
size_t result = gen.current_offset_bytes();
int num_trees = 0;
num_trees += tfrags.size();
num_trees += collides.size();
gen.add_word(num_trees << 16);
gen.add_word(0);
gen.add_word(0);
gen.add_word(0);
gen.add_word(0);
gen.add_word(0);
gen.add_word(0);
// todo add trees...
if (num_trees == 0) {
gen.add_word(0); // the one at the end.
} else {
int tree_word = (int)gen.current_offset_bytes() / 4;
for (int i = 0; i < num_trees; i++) {
gen.add_word(0);
}
for (auto& tfrag : tfrags) {
// gen.set_word(tree_word++, tfrag.add_to_object_file(gen));
gen.link_word_to_byte(tree_word++, tfrag.add_to_object_file(gen));
}
for (auto& collide : collides) {
gen.link_word_to_byte(tree_word++, collide.add_to_object_file(gen));
}
}
return result;
}
std::vector<u8> LevelFile::save_object_file() const {
DataObjectGenerator gen;
gen.add_type_tag("bsp-header");
// add blank space for the bsp-header
while (gen.words() < 100) {
gen.add_word(0);
}
//(info file-info :offset 4)
auto file_info_slot = info.add_to_object_file(gen);
gen.link_word_to_byte(1, file_info_slot);
//(bsphere vector :inline :offset-assert 16)
//(all-visible-list (pointer uint16) :offset-assert 32)
//(visible-list-length int32 :offset-assert 36)
//(drawable-trees drawable-tree-array :offset-assert 40)
gen.link_word_to_byte(40 / 4, drawable_trees.add_to_object_file(gen));
//(pat pointer :offset-assert 44)
//(pat-length int32 :offset-assert 48)
//(texture-remap-table (pointer uint64) :offset-assert 52)
//(texture-remap-table-len int32 :offset-assert 56)
//(texture-ids (pointer texture-id) :offset-assert 60)
//(texture-page-count int32 :offset-assert 64)
//(unk-zero-0 basic :offset-assert 68)
//(name symbol :offset-assert 72)
gen.link_word_to_symbol(name, 72 / 4);
//(nickname symbol :offset-assert 76)
gen.link_word_to_symbol(nickname, 76 / 4);
//(vis-info level-vis-info 8 :offset-assert 80)
//(actors drawable-inline-array-actor :offset-assert 112)
//(cameras (array entity-camera) :offset-assert 116)
//(nodes (inline-array bsp-node) :offset-assert 120)
//(level level :offset-assert 124)
//(current-leaf-idx uint16 :offset-assert 128)
//(unk-data-2 uint16 9 :offset-assert 130)
//(boxes box8s-array :offset-assert 148)
//(current-bsp-back-flags uint32 :offset-assert 152)
//(ambients drawable-inline-array-ambient :offset-assert 156)
//(unk-data-4 float :offset-assert 160)
//(unk-data-5 float :offset-assert 164)
//(adgifs adgif-shader-array :offset-assert 168)
//(actor-birth-order (pointer uint32) :offset-assert 172)
//(split-box-indices (pointer uint16) :offset-assert 176)
//(unk-data-8 uint32 55 :offset-assert 180)
return gen.generate_v2();
}

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