Skip to content

Commit

Permalink
Fixed issue with filesystem not working on cdrom
Browse files Browse the repository at this point in the history
Added gamma correction to model importer
  • Loading branch information
EPICGameGuy committed Nov 27, 2023
1 parent fa88088 commit 0047d11
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 97 deletions.
73 changes: 0 additions & 73 deletions .vscode/settings.json

This file was deleted.

Binary file modified assets/models/kettle.fbx
Binary file not shown.
2 changes: 1 addition & 1 deletion dependencies/egg-library/include/egg/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static constexpr const char* get_filesystem_prefix(Type in_filesystem_type = get
switch (in_filesystem_type)
{
case Type::cdrom:
return "cdrom0:";
return "cdrom0:\\";
case Type::host:
return "host0:";
case Type::rom:
Expand Down
17 changes: 3 additions & 14 deletions dependencies/egg-library/src/filesystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,10 @@ static std::string convert_filepath_to_systempath_impl(std::string_view path)
int index = filesystem_prefix_len;

int path_start = 0;
if constexpr (type != Type::host)
// iterate past the start of the path
while (path[path_start] == '\\' || path[path_start] == '/')
{
if (path[0] != '\\' && path[0] != '/')
{
out_path_chars[index] = get_filesystem_separator();
index++;
}
}
else
{
// iterate past the start of the path on host filesystem
while (path[path_start] == '\\' || path[path_start] == '/')
{
path_start++;
}
path_start++;
}

path = std::string_view(path.data() + path_start, path.end());
Expand Down
1 change: 1 addition & 0 deletions include/sound/sound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ namespace Sound
{
void init();
bool work_song();
void set_music_volume(int volume); // 0-100 volume
} // namespace Sound
9 changes: 5 additions & 4 deletions src/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static u32 frameCounter = 0;

void init()
{
Filesystem::set_filesystem_type(Filesystem::Type::host);
Filesystem::set_filesystem_type(Filesystem::Type::cdrom);

if (Filesystem::get_filesystem_type() != Filesystem::Type::host)
{
Expand Down Expand Up @@ -75,7 +75,7 @@ void init()
Stats::init();
Input::init();
//Filesystem::run_tests();
//Sound::init();
Sound::init();
GS::init();

printf("Graph mode (region): ");
Expand Down Expand Up @@ -135,12 +135,13 @@ void run()

if (Input::get_paddata() & PAD_SELECT)
{
exit(0);
return;
//exit(0);
//return;
}

if (Input::get_paddata() & PAD_START)
{
Sound::set_music_volume(50);
Stats::print_timer_stats();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/gs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static void init_renderer()

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
//glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
//glEnableClientState(GL_TEXTURE_COORD_ARRAY);


Expand Down
6 changes: 3 additions & 3 deletions src/renderer/mesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ void Mesh::compile()
check(num_lists <= 4096);
glNewList(list, GL_COMPILE);
{
//glEnable(GL_COLOR_MATERIAL);
//glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
//glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
//static float material_diff_amb[] = {0.5f, 0.5f, 0.5f, 0};
//glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, material_diff_amb);
Expand All @@ -87,7 +87,7 @@ void Mesh::compile()
if (mesh->colors.offset > 0)
{
printf("Mesh: %d has colors\n", list);
//glColorPointer(4, GL_FLOAT, 0, mesh->colors.get_ptr());
glColorPointer(4, GL_FLOAT, 0, mesh->colors.get_ptr());
}

int i = 0;
Expand Down
8 changes: 7 additions & 1 deletion src/sound/sound.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void init()
audsrv_adpcm_set_volume(i, MAX_VOLUME / 10);
}

audsrv_set_volume(50);
audsrv_set_volume(0);

{
audsrv_fmt_t format;
Expand Down Expand Up @@ -167,6 +167,12 @@ bool work_song()

return did_work;
}

void set_music_volume(int volume)
{
audsrv_set_volume(volume);
}

} // namespace Sound

static void audioThread()
Expand Down
6 changes: 6 additions & 0 deletions tools/ps2-mesh-converter/include/model_modifiers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#include <vector>
#include "types.hpp"

void apply_gamma_correction(std::vector<Mesh>& meshes);
3 changes: 3 additions & 0 deletions tools/ps2-mesh-converter/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "model_importer.hpp"
#include "model_exporter.hpp"
#include "model_modifiers.hpp"
#include <cxxopts.hpp>

#include "meshoptimizer.h"
Expand Down Expand Up @@ -128,6 +129,8 @@ static void process()

printf("Loaded %lu meshes from file\n", meshes.size());

apply_gamma_correction(meshes);

std::vector<MeshStrip> strips;
for (size_t i = 0; i < meshes.size(); ++i)
{
Expand Down
14 changes: 14 additions & 0 deletions tools/ps2-mesh-converter/src/model_modifiers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "model_modifiers.hpp"

void apply_gamma_correction(std::vector<Mesh>& meshes)
{
for (Mesh& mesh : meshes)
{
for (Vertex& vertex : mesh.vertices)
{
vertex.r = pow(vertex.r, 1.0 / 2.2);
vertex.g = pow(vertex.g, 1.0 / 2.2);
vertex.b = pow(vertex.b, 1.0 / 2.2);
}
}
}

0 comments on commit 0047d11

Please sign in to comment.