mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-06-28 03:13:13 -04:00
Take7 (#17)
This commit is contained in:
+8
-6
@@ -39,6 +39,7 @@
|
||||
#include <debug.h>
|
||||
#include "crash_screen.h"
|
||||
#include "buffers/gfx_output_buffer.h"
|
||||
#include <bridge/gfxdebuggerbridge.h>
|
||||
|
||||
// Declarations (not in this file)
|
||||
void func_80091B78(void);
|
||||
@@ -301,7 +302,9 @@ void create_gfx_task_structure(void) {
|
||||
func_8008C214();
|
||||
// gGfxSPTask->task.t.yield_data_ptr = (u64 *) &gGfxSPTaskYieldBuffer;
|
||||
// gGfxSPTask->task.t.yield_data_size = OS_YIELD_DATA_SIZE;
|
||||
|
||||
if (GfxDebuggerIsDebuggingRequested()) {
|
||||
GfxDebuggerDebugDisplayList(gGfxPool->gfxPool);
|
||||
}
|
||||
Graphics_PushFrame(gGfxPool->gfxPool);
|
||||
}
|
||||
|
||||
@@ -1174,11 +1177,6 @@ void update_gamestate(void) {
|
||||
}
|
||||
|
||||
void thread5_game_loop(void) {
|
||||
|
||||
// if (GfxDebuggerIsDebugging()) {
|
||||
// Graphics_PushFrame(gGfxPool->gfxPool);
|
||||
// return;
|
||||
// }
|
||||
setup_game_memory();
|
||||
osCreateMesgQueue(&gGfxVblankQueue, gGfxMesgBuf, 1);
|
||||
osCreateMesgQueue(&gGameVblankQueue, &gGameMesgBuf, 1);
|
||||
@@ -1204,6 +1202,10 @@ void thread5_game_loop(void) {
|
||||
void thread5_iteration(void){
|
||||
// func_800CB2C4();
|
||||
|
||||
if (GfxDebuggerIsDebugging()) {
|
||||
Graphics_PushFrame(gGfxPool->gfxPool);
|
||||
return;
|
||||
}
|
||||
// Update the gamestate if it has changed (racing, menus, credits, etc.).
|
||||
if (gGamestateNext != gGamestate) {
|
||||
gGamestate = gGamestateNext;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "resource/importers/TrackSectionsFactory.h"
|
||||
#include "resource/importers/TrackWaypointFactory.h"
|
||||
#include "resource/importers/ActorSpawnDataFactory.h"
|
||||
#include "resource/importers/ArrayFactory.h"
|
||||
#include <Fast3D/Fast3dWindow.h>
|
||||
|
||||
#include <Fast3D/gfx_pc.h>
|
||||
@@ -66,6 +67,7 @@ GameEngine::GameEngine() {
|
||||
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryDisplayListV0>(), RESOURCE_FORMAT_BINARY, "DisplayList", static_cast<uint32_t>(LUS::ResourceType::DisplayList), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryMatrixV0>(), RESOURCE_FORMAT_BINARY, "Matrix", static_cast<uint32_t>(LUS::ResourceType::Matrix), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryBlobV0>(), RESOURCE_FORMAT_BINARY, "Blob", static_cast<uint32_t>(LUS::ResourceType::Blob), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<MK64::ResourceFactoryBinaryArrayV0>(), RESOURCE_FORMAT_BINARY, "Array", static_cast<uint32_t>(MK64::ResourceType::MK_Array), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<MK64::ResourceFactoryBinaryKartAIV0>(), RESOURCE_FORMAT_BINARY, "KartAI", static_cast<uint32_t>(MK64::ResourceType::KartAI), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<MK64::ResourceFactoryBinaryCourseVtxV0>(), RESOURCE_FORMAT_BINARY, "CourseVtx", static_cast<uint32_t>(MK64::ResourceType::CourseVertex), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<MK64::ResourceFactoryBinaryTrackSectionsV0>(), RESOURCE_FORMAT_BINARY, "TrackSections", static_cast<uint32_t>(MK64::ResourceType::TrackSection), 0);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "Engine.h"
|
||||
#include "DisplayList.h"
|
||||
#include "resource/type/ResourceType.h"
|
||||
#include "resource/type/Array.h"
|
||||
|
||||
extern "C" int GameEngine_OTRSigCheck(const char* data);
|
||||
|
||||
@@ -33,13 +35,12 @@ extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) {
|
||||
const auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(data);
|
||||
const auto type = static_cast<LUS::ResourceType>(res->GetInitData()->Type);
|
||||
|
||||
switch(type) {
|
||||
case LUS::ResourceType::DisplayList:
|
||||
if (res->GetInitData()->Type == static_cast<uint32_t>(LUS::ResourceType::DisplayList)) {
|
||||
texAddr = reinterpret_cast<uintptr_t>(&std::static_pointer_cast<LUS::DisplayList>(res)->Instructions[0]);
|
||||
break;
|
||||
default:
|
||||
} else if (res->GetInitData()->Type == static_cast<uint32_t>(MK64::ResourceType::MK_Array)) {
|
||||
texAddr = reinterpret_cast<uintptr_t>(std::static_pointer_cast<MK64::Array>(res)->Vertices.data());
|
||||
} else {
|
||||
texAddr = reinterpret_cast<uintptr_t>(res->GetRawPointer());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace MK64 {
|
||||
data.pos[0] = reader->ReadInt16();
|
||||
data.pos[1] = reader->ReadInt16();
|
||||
data.pos[2] = reader->ReadInt16();
|
||||
data.signedSomeId = reader->ReadUByte();
|
||||
data.signedSomeId = reader->ReadInt16();
|
||||
|
||||
section->ActorSpawnDataList.push_back(data);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "ArrayFactory.h"
|
||||
#include "../type/Array.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "graphic/Fast3D/lus_gbi.h"
|
||||
|
||||
namespace MK64 {
|
||||
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryArrayV0::ReadResource(std::shared_ptr<Ship::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto array = std::make_shared<Array>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
|
||||
|
||||
array->ArrayType = (ArrayResourceType)reader->ReadUInt32();
|
||||
array->ArrayCount = reader->ReadUInt32();
|
||||
|
||||
for (uint32_t i = 0; i < array->ArrayCount; i++) {
|
||||
if (array->ArrayType == ArrayResourceType::Vertex) {
|
||||
// OTRTODO: Implement Vertex arrays as just a vertex resource.
|
||||
F3DVtx data;
|
||||
data.v.ob[0] = reader->ReadInt16();
|
||||
data.v.ob[1] = reader->ReadInt16();
|
||||
data.v.ob[2] = reader->ReadInt16();
|
||||
data.v.flag = reader->ReadUInt16();
|
||||
data.v.tc[0] = reader->ReadInt16();
|
||||
data.v.tc[1] = reader->ReadInt16();
|
||||
data.v.cn[0] = reader->ReadUByte();
|
||||
data.v.cn[1] = reader->ReadUByte();
|
||||
data.v.cn[2] = reader->ReadUByte();
|
||||
data.v.cn[3] = reader->ReadUByte();
|
||||
array->Vertices.push_back(data);
|
||||
} else {
|
||||
array->ArrayScalarType = (ScalarType)reader->ReadUInt32();
|
||||
|
||||
int iter = 1;
|
||||
|
||||
if (array->ArrayType == ArrayResourceType::Vector) {
|
||||
iter = reader->ReadUInt32();
|
||||
}
|
||||
|
||||
for (int k = 0; k < iter; k++) {
|
||||
ScalarData data;
|
||||
|
||||
switch (array->ArrayScalarType) {
|
||||
case ScalarType::ZSCALAR_S16:
|
||||
data.s16 = reader->ReadInt16();
|
||||
break;
|
||||
case ScalarType::ZSCALAR_U16:
|
||||
data.u16 = reader->ReadUInt16();
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("ARRAY FACTORY TYPE NOT IMPLEMENTED");
|
||||
break;
|
||||
}
|
||||
|
||||
array->Scalars.push_back(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
} // namespace LUS
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource/Resource.h"
|
||||
#include "resource/ResourceFactoryBinary.h"
|
||||
|
||||
namespace MK64 {
|
||||
class ResourceFactoryBinaryArrayV0 : public Ship::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
|
||||
};
|
||||
} // namespace LUS
|
||||
@@ -86,6 +86,11 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinaryGenericArrayV0::ReadResour
|
||||
std::copy_n(reinterpret_cast<uint8_t*>(&vec), sizeof(Vec3i), std::back_inserter(arr->mData));
|
||||
break;
|
||||
}
|
||||
case ArrayType::Vec3iu: {
|
||||
Vec3i vec(reader->ReadUInt32(), reader->ReadUInt32(), reader->ReadUInt32());
|
||||
std::copy_n(reinterpret_cast<uint8_t*>(&vec), sizeof(Vec3iu), std::back_inserter(arr->mData));
|
||||
break;
|
||||
}
|
||||
case ArrayType::Vec4f: {
|
||||
Vec4f vec(reader->ReadFloat(), reader->ReadFloat(), reader->ReadFloat(), reader->ReadFloat());
|
||||
std::copy_n(reinterpret_cast<uint8_t*>(&vec), sizeof(Vec4f), std::back_inserter(arr->mData));
|
||||
@@ -96,6 +101,9 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinaryGenericArrayV0::ReadResour
|
||||
std::copy_n(reinterpret_cast<uint8_t*>(&vec), sizeof(Vec4s), std::back_inserter(arr->mData));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw std::runtime_error("UNIMPLEMENTED GENERICARRAY TYPE");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "Array.h"
|
||||
#include "graphic/Fast3D/lus_gbi.h"
|
||||
namespace MK64 {
|
||||
Array::Array() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {
|
||||
}
|
||||
|
||||
void* Array::GetPointer() {
|
||||
void* dataPointer = nullptr;
|
||||
switch (ArrayType) {
|
||||
case ArrayResourceType::Vertex:
|
||||
dataPointer = Vertices.data();
|
||||
break;
|
||||
case ArrayResourceType::Scalar:
|
||||
default:
|
||||
dataPointer = Scalars.data();
|
||||
break;
|
||||
}
|
||||
|
||||
return dataPointer;
|
||||
}
|
||||
|
||||
size_t Array::GetPointerSize() {
|
||||
size_t typeSize = 0;
|
||||
switch (ArrayType) {
|
||||
case ArrayResourceType::Vertex:
|
||||
typeSize = sizeof(F3DVtx);
|
||||
break;
|
||||
case ArrayResourceType::Scalar:
|
||||
default:
|
||||
switch (ArrayScalarType) {
|
||||
case ScalarType::ZSCALAR_S16:
|
||||
typeSize = sizeof(int16_t);
|
||||
break;
|
||||
case ScalarType::ZSCALAR_U16:
|
||||
typeSize = sizeof(uint16_t);
|
||||
break;
|
||||
default:
|
||||
// OTRTODO: IMPLEMENT OTHER TYPES!
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ArrayCount * typeSize;
|
||||
}
|
||||
} // namespace LUS
|
||||
@@ -0,0 +1,85 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource/Resource.h"
|
||||
|
||||
union F3DVtx;
|
||||
namespace MK64 {
|
||||
typedef union ScalarData {
|
||||
uint8_t u8;
|
||||
int8_t s8;
|
||||
uint16_t u16;
|
||||
int16_t s16;
|
||||
uint32_t u32;
|
||||
int32_t s32;
|
||||
uint64_t u64;
|
||||
int64_t s64;
|
||||
float f32;
|
||||
double f64;
|
||||
} ScalarData;
|
||||
|
||||
enum class ScalarType {
|
||||
ZSCALAR_NONE,
|
||||
ZSCALAR_S8,
|
||||
ZSCALAR_U8,
|
||||
ZSCALAR_X8,
|
||||
ZSCALAR_S16,
|
||||
ZSCALAR_U16,
|
||||
ZSCALAR_X16,
|
||||
ZSCALAR_S32,
|
||||
ZSCALAR_U32,
|
||||
ZSCALAR_X32,
|
||||
ZSCALAR_S64,
|
||||
ZSCALAR_U64,
|
||||
ZSCALAR_X64,
|
||||
ZSCALAR_F32,
|
||||
ZSCALAR_F64
|
||||
};
|
||||
|
||||
// OTRTODO: Replace this with something that can be shared between the exporter and importer...
|
||||
enum class ArrayResourceType {
|
||||
Error,
|
||||
Animation,
|
||||
Array,
|
||||
AltHeader,
|
||||
Background,
|
||||
Blob,
|
||||
CollisionHeader,
|
||||
Cutscene,
|
||||
DisplayList,
|
||||
Limb,
|
||||
LimbTable,
|
||||
Mtx,
|
||||
Path,
|
||||
PlayerAnimationData,
|
||||
Room,
|
||||
RoomCommand,
|
||||
Scalar,
|
||||
Scene,
|
||||
Skeleton,
|
||||
String,
|
||||
Symbol,
|
||||
Texture,
|
||||
TextureAnimation,
|
||||
TextureAnimationParams,
|
||||
Vector,
|
||||
Vertex,
|
||||
Audio
|
||||
};
|
||||
|
||||
class Array : public Ship::Resource<void> {
|
||||
public:
|
||||
using Resource::Resource;
|
||||
|
||||
Array();
|
||||
|
||||
void* GetPointer() override;
|
||||
size_t GetPointerSize() override;
|
||||
|
||||
ArrayResourceType ArrayType;
|
||||
ScalarType ArrayScalarType;
|
||||
size_t ArrayCount;
|
||||
// OTRTODO: Should be a vector of resource pointers...
|
||||
std::vector<ScalarData> Scalars;
|
||||
std::vector<F3DVtx> Vertices;
|
||||
};
|
||||
} // namespace LUS
|
||||
@@ -26,6 +26,11 @@ struct Vec3i {
|
||||
Vec3i(int32_t x, int32_t y, int32_t z) : x(x), y(y), z(z) {}
|
||||
};
|
||||
|
||||
struct Vec3iu {
|
||||
uint32_t x, y, z;
|
||||
Vec3iu(uint32_t x, uint32_t y, uint32_t z) : x(x), y(y), z(z) {}
|
||||
};
|
||||
|
||||
struct Vec4f {
|
||||
float x, y, z, w;
|
||||
Vec4f(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {}
|
||||
@@ -37,7 +42,7 @@ struct Vec4s {
|
||||
};
|
||||
|
||||
enum class ArrayType {
|
||||
u8, s8, u16, s16, u32, s32, u64, f32, f64, Vec2f, Vec3f, Vec3s, Vec3i, Vec4f, Vec4s,
|
||||
u8, s8, u16, s16, u32, s32, u64, f32, f64, Vec2f, Vec3f, Vec3s, Vec3i, Vec3iu, Vec4f, Vec4s,
|
||||
};
|
||||
|
||||
class GenericArray : public Ship::Resource<uint8_t> {
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace SF64 {
|
||||
|
||||
namespace MK64 {
|
||||
enum class ResourceType {
|
||||
MK_Array = 0x4F415252, // OARR
|
||||
CourseVertex = 0x43565458, // CVTX
|
||||
TrackSection = 0x5343544E, // SCTN
|
||||
Waypoints = 0x57505453, // WPTS
|
||||
|
||||
@@ -314,8 +314,7 @@ void DrawSettingsMenu(){
|
||||
Ship::WindowBackend runningWindowBackend = Ship::Context::GetInstance()->GetWindow()->GetWindowBackend();
|
||||
Ship::WindowBackend configWindowBackend;
|
||||
int configWindowBackendId = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1);
|
||||
if (configWindowBackendId != -1
|
||||
&& configWindowBackendId < static_cast<int>(Ship::WindowBackend::WINDOW_BACKEND_COUNT)) {
|
||||
if (Ship::Context::GetInstance()->GetWindow()->IsAvailableWindowBackend(configWindowBackendId)) {
|
||||
configWindowBackend = static_cast<Ship::WindowBackend>(configWindowBackendId);
|
||||
} else {
|
||||
configWindowBackend = runningWindowBackend;
|
||||
|
||||
+10
-10
@@ -1028,16 +1028,16 @@ void spawn_course_actors(void) {
|
||||
struct ActorSpawnData *a_d_course_mario_raceway_piranha_plant_spawns = (struct ActorSpawnData *) LOAD_ASSET(d_course_mario_raceway_piranha_plant_spawns);
|
||||
struct ActorSpawnData *a_d_course_mario_raceway_item_box_spawns = (struct ActorSpawnData *) LOAD_ASSET(d_course_mario_raceway_item_box_spawns);
|
||||
|
||||
//spawn_foliage(a_d_course_mario_raceway_tree_spawns);
|
||||
//spawn_piranha_plants(a_d_course_mario_raceway_piranha_plant_spawns);
|
||||
//spawn_all_item_boxes(a_d_course_mario_raceway_item_box_spawns);
|
||||
// vec3f_set(position, 150.0f, 40.0f, -1300.0f);
|
||||
// position[0] *= gCourseDirection;
|
||||
// add_actor_to_empty_slot(position, rotation, velocity, ACTOR_MARIO_SIGN);
|
||||
// vec3f_set(position, 2520.0f, 0.0f, 1240.0f);
|
||||
// position[0] *= gCourseDirection;
|
||||
// actor = &gActorList[add_actor_to_empty_slot(position, rotation, velocity, ACTOR_MARIO_SIGN)];
|
||||
// actor->flags |= 0x4000;
|
||||
spawn_foliage(a_d_course_mario_raceway_tree_spawns);
|
||||
spawn_piranha_plants(a_d_course_mario_raceway_piranha_plant_spawns);
|
||||
spawn_all_item_boxes(a_d_course_mario_raceway_item_box_spawns);
|
||||
vec3f_set(position, 150.0f, 40.0f, -1300.0f);
|
||||
position[0] *= gCourseDirection;
|
||||
add_actor_to_empty_slot(position, rotation, velocity, ACTOR_MARIO_SIGN);
|
||||
vec3f_set(position, 2520.0f, 0.0f, 1240.0f);
|
||||
position[0] *= gCourseDirection;
|
||||
actor = &gActorList[add_actor_to_empty_slot(position, rotation, velocity, ACTOR_MARIO_SIGN)];
|
||||
actor->flags |= 0x4000;
|
||||
break;
|
||||
case COURSE_CHOCO_MOUNTAIN:
|
||||
spawn_all_item_boxes(d_course_choco_mountain_item_box_spawns);
|
||||
|
||||
@@ -227,7 +227,7 @@ void load_texture_block_i8_nomirror(u8 *texture, s32 width, s32 height) {
|
||||
void func_80044924(u8 *texture, s32 width, s32 height) {
|
||||
// This macro ought to be equivalent to the block of macros below but it doesn't match
|
||||
// See comment above the `gDPLoadBlock` macro
|
||||
gDPLoadTextureBlock_4b(gDisplayListHead++, texture, G_IM_FMT_I, width, height, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
|
||||
//gDPLoadTextureBlock_4b(gDisplayListHead++, texture, G_IM_FMT_I, width, height, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
|
||||
|
||||
// gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, texture);
|
||||
// gDPSetTile(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, G_TX_RENDERTILE, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOLOD);
|
||||
|
||||
Reference in New Issue
Block a user