Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fuckit
Browse files Browse the repository at this point in the history
# Conflicts:
#	.gitignore
#	src/core/cdrom.h
#	src/core/luaiso.cc
#	src/gui/gui.cc
#	src/gui/widgets/isobrowser.cc
  • Loading branch information
nicolasnoble committed Oct 8, 2023
2 parents 2d3b863 + 755ec00 commit dad7cd9
Show file tree
Hide file tree
Showing 172 changed files with 12,046 additions and 802 deletions.
9 changes: 9 additions & 0 deletions .github/scripts/create-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ PlistBuddy ${APPROOT}/Contents/Info.plist -c "add CFBundleIconFile string AppIco
PlistBuddy ${APPROOT}/Contents/Info.plist -c "add NSHighResolutionCapable bool true"
PlistBuddy ${APPROOT}/Contents/version.plist -c "add ProjectName string ${APP}"

PlistBuddy ${APPROOT}/Contents/Info.plist -c "add CFBundleExecutable string ${APP}"
PlistBuddy ${APPROOT}/Contents/Info.plist -c "add CFBundleDevelopmentRegion string en"
PlistBuddy ${APPROOT}/Contents/Info.plist -c "add CFBundleInfoDictionaryVersion string 6.0"
PlistBuddy ${APPROOT}/Contents/Info.plist -c "add CFBundleName string ${APP}"
PlistBuddy ${APPROOT}/Contents/Info.plist -c "add CFBundlePackageType string APPL"
PlistBuddy ${APPROOT}/Contents/Info.plist -c "add NSHumanReadableCopyright string Copyright PCSX-Redux Authors"

PlistBuddy ${APPROOT}/Contents/Info.plist -c "add LSMinimumSystemVersion string 10.15"

# Install dylib dependencies in ./Contents/Frameworks.
# Update the dyld load commands for these.
dylibbundler -od -b -x ${APPROOT}/Contents/MacOS/${APP} -d ${APPROOT}/Contents/Frameworks/ -p @rpath
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/linux-asan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Linux CI asan

on:
push:
branches:
- main
pull_request:

jobs:
asan:
runs-on: ubuntu-latest
container:
image: ghcr.io/grumpycoders/pcsx-redux-build:latest
env:
TEST_RESULTS: /tmp/test-results
BUILD: asan
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
set-safe-directory: true
- uses: n1hility/cancel-previous-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- run: |
make -j 2 all pcsx-redux-tests
make -C src/mips/openbios -j 2 BUILD=Release
cp src/mips/openbios/openbios.bin .
make -C src/mips/openbios clean
make -C src/mips/tests -j 2 PCSX_TESTS=true BUILD=Release
cp ./openbios.bin src/mips/openbios/
- name: Test
run: |
xvfb-run ./pcsx-redux-tests
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ fb.bat
*.idb

# Runtime files in ./resources
16-to-24.frag
16-to-24.lua
16-to-24.vert
offscreen.frag
offscreen.lua
offscreen.vert
Expand Down Expand Up @@ -110,3 +113,6 @@ comport.txt

# Various editors' backup files
*.bak

# NVIDIA Nsight
GPUCache
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
url = https://github.com/luvit/luv.git
[submodule "third_party/freetype"]
path = third_party/freetype
url = https://gitlab.freedesktop.org/freetype/freetype.git
url = https://github.com/freetype/freetype.git
[submodule "third_party/stb"]
path = third_party/stb
url = https://github.com/nothings/stb.git
Expand Down Expand Up @@ -85,3 +85,6 @@
[submodule "third_party/nanosvg"]
path = third_party/nanosvg
url = https://github.com/grumpycoders/nanosvg
[submodule "third_party/luafilesystem"]
path = third_party/luafilesystem
url = https://github.com/lunarmodules/luafilesystem.git
20 changes: 10 additions & 10 deletions AppImageBuilder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ AppDir:
- amd64
allow_unauthenticated: true
sources:
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ kinetic main restricted
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ kinetic-updates main restricted
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ kinetic universe
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ kinetic-updates universe
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ kinetic multiverse
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ kinetic-updates multiverse
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ kinetic-backports main
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ lunar main restricted
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ lunar-updates main restricted
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ lunar universe
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ lunar-updates universe
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ lunar multiverse
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ lunar-updates multiverse
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ lunar-backports main
restricted universe multiverse
- sourceline: deb http://security.ubuntu.com/ubuntu kinetic-security main restricted
- sourceline: deb http://security.ubuntu.com/ubuntu kinetic-security universe
- sourceline: deb http://security.ubuntu.com/ubuntu kinetic-security multiverse
- sourceline: deb http://security.ubuntu.com/ubuntu lunar-security main restricted
- sourceline: deb http://security.ubuntu.com/ubuntu lunar-security universe
- sourceline: deb http://security.ubuntu.com/ubuntu lunar-security multiverse
include:
- libbz2-1.0:amd64
- libcom-err2:amd64
Expand Down
4 changes: 3 additions & 1 deletion LICENSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ find a link to the vendored version itself.
- [FreeType](https://gitlab.freedesktop.org/freetype/freetype.git)
- [gl3w](https://github.com/skaslev/gl3w) ([vendored](https://github.com/grumpycoders/pcsx-redux/tree/main/third_party/gl3w/GL))
- [glfw](https://www.glfw.org)
- [luajit-opencl](https://github.com/malkia/luajit-opencl) ([vendored](https://github.com/grumpycoders/pcsx-redux/tree/main/third_party/glffi))
- [googletest](https://github.com/google/googletest)
- [GoogleTestAdapter](https://github.com/csoltenborn/GoogleTestAdapter) ([vendored](https://github.com/grumpycoders/pcsx-redux/tree/main/third_party/GoogleTestAdapter))
- [http-parser](https://github.com/nodejs/http-parser)
Expand All @@ -41,8 +40,11 @@ find a link to the vendored version itself.
- [json](https://github.com/nlohmann/json) ([vendored](https://github.com/grumpycoders/pcsx-redux/blob/main/third_party/json.hpp))
- [libcester](https://github.com/exoticlibraries/libcester)
- [libuv](https://github.com/libuv/libuv)
- [LPeg](http://www.inf.puc-rio.br/~roberto/lpeg/)
- [lua-protobuf](https://github.com/starwing/lua-protobuf) ([vendored](https://github.com/grumpycoders/pcsx-redux/tree/main/third_party/lua-protobuf))
- [luafilesystem](https://github.com/lunarmodules/luafilesystem)
- [LuaJIT](https://github.com/LuaJIT/LuaJIT) ([vendored](https://github.com/grumpycoders/LuaJIT/tree/vendored-clib-virtual))
- [luajit-opencl](https://github.com/malkia/luajit-opencl) ([vendored](https://github.com/grumpycoders/pcsx-redux/tree/main/third_party/glffi))
- [luv](https://github.com/luvit/luv)
- [magic_enum](https://github.com/Neargye/magic_enum)
- [md4c](https://github.com/mity/md4c)
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ else
HAS_SUBMODULES = true
endif

CXXFLAGS += -std=c++2a
CXXFLAGS += -std=c++2b
CPPFLAGS += `pkg-config --cflags $(PACKAGES)`
CPPFLAGS += -I.
CPPFLAGS += -Isrc
Expand Down Expand Up @@ -58,6 +58,7 @@ else
endif
CPPFLAGS_asan += -O1 -fsanitize=address -fno-omit-frame-pointer
CPPFLAGS_ubsan += -O1 -fsanitize=undefined -fno-omit-frame-pointer
CPPFLAGS_lto += -O3 -flto=auto -fno-fat-lto-objects -flto-partition=one
CPPFLAGS_ReleaseWithTracy += -O3 -DTRACY_ENABLE

ifeq ($(CC_IS_CLANG),true)
Expand Down Expand Up @@ -93,6 +94,7 @@ else
endif
LDFLAGS_asan += -fsanitize=address
LDFLAGS_ubsan += -fsanitize=undefined
LDFLAGS_lto += -O3 -flto=auto -flto-partition=one

CPPFLAGS += $(CPPFLAGS_$(BUILD)) -pthread
LDFLAGS += $(LDFLAGS_$(BUILD)) -pthread
Expand Down Expand Up @@ -126,7 +128,9 @@ SRCS += third_party/imgui/misc/freetype/imgui_freetype.cpp
SRCS += third_party/imgui_lua_bindings/imgui_lua_bindings.cpp
SRCS += third_party/imgui_md/imgui_md.cpp
SRCS += third_party/imgui_memory_editor/imgui_memory_editor.cpp
SRCS += $(wildcard third_party/lpeg/*.c)
SRCS += third_party/lua-protobuf/pb.c
SRCS += third_party/luafilesystem/src/lfs.c
SRCS += third_party/luv/src/luv.c
SRCS += third_party/md4c/src/md4c.c
SRCS += third_party/multipart-parser-c/multipart_parser.c
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
|Linux build|[![Linux CI](https://github.com/grumpycoders/pcsx-redux/workflows/Linux%20CI/badge.svg?branch=main)](https://github.com/grumpycoders/pcsx-redux/actions?query=workflow%3A%22Linux+CI%22+branch%3Amain)|[Linux Intel 64-bits (AppImage)](https://install.appcenter.ms/orgs/grumpycoders/apps/pcsx-redux-linux64/distribution_groups/public)|
|MacOS build|[![MacOS CI](https://github.com/grumpycoders/pcsx-redux/workflows/macOS%20CI/badge.svg?branch=main)](https://github.com/grumpycoders/pcsx-redux/actions?query=workflow%3A%22macOS+CI%22+branch%3Amain)|[MacOS](https://install.appcenter.ms/orgs/grumpycoders/apps/pcsx-redux-macos/distribution_groups/public)|

To discuss this emulator specifically, please join our Discord server: [![Discord](https://img.shields.io/discord/567975889879695361)](https://discord.gg/KG5uCqw)
To discuss this emulator specifically, please join our Discord server:

To discuss PlayStation 1 development, hacking, and reverse engineering in general, please join the PSX.Dev Discord server: [![Discord](https://img.shields.io/discord/642647820683444236)](https://discord.gg/QByKPpH)
[![Discord](https://discord.com/api/guilds/567975889879695361/widget.png?style=banner2)](https://discord.gg/KG5uCqw)

To discuss PlayStation 1 development, hacking, and reverse engineering in general, please join the PSX.Dev Discord server:

[![Discord](https://discord.com/api/guilds/642647820683444236/widget.png?style=banner2)](https://discord.gg/QByKPpH)

# PCSX-Redux

Expand Down Expand Up @@ -72,7 +76,7 @@ powershell -c "& { iwr -UseBasicParsing https://bit.ly/mips-ps1 | iex }"
Then, open a new command prompt, and type the following:

```
mips install 13.1.0
mips install 13.2.0
```

To manually install this script, you can download it from [here](https://bit.ly/mips-ps1), and then install it with the following command:
Expand All @@ -83,8 +87,10 @@ powershell -ExecutionPolicy Unrestricted -File mips.ps1 self-install C:\path\to\

You can leave the installation path blank to install the script in the Application Data folder.

Once the toolchain is installed, you can compile OpenBIOS using `make -C src/mips/openbios`.

### Linux
Run `./dockermake.sh`. You need [docker](https://en.wikipedia.org/wiki/Docker_(software)) for this to work. You will also need a few libraries on your system for this to work. Check the [Dockerfile](https://github.com/grumpycoders/pcsx-redux/blob/main/tools/build/Dockerfile#L22) for a list of library packages to install. Alternatively, if you do not want to use Docker, you can also simply install the dependencies listed below and run `make`.
Run `./dockermake.sh appimage`. You need [docker](https://en.wikipedia.org/wiki/Docker_(software)) for this to work. This will create an [AppImage](https://appimage.org/) file, called `PCSX-Redux-HEAD-x86_64.AppImage`, which a self-hosted binary containing all of its required dependencies. Alternatively, if you do not want to use Docker, you can also simply install the dependencies listed below and run `make`.

#### GNU/Linux Dependencies

Expand Down
45 changes: 31 additions & 14 deletions src/cdrom/cdriso-cue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,31 @@ bool PCSX::CDRIso::parsecue(const char *isofileString) {
}
file->opaque = fi;
file->destroy = [](CueFile *file) {
UvFile *fi = reinterpret_cast<UvFile *>(file->opaque);
File *fi = reinterpret_cast<File *>(file->opaque);
fi->close();
delete fi;
file->opaque = nullptr;
};
file->close = [](CueFile *file, CueScheduler *scheduler, void (*cb)(CueFile *, CueScheduler *)) {
UvFile *fi = reinterpret_cast<UvFile *>(file->opaque);
File *fi = reinterpret_cast<File *>(file->opaque);
fi->close();
File_schedule_close(file, scheduler, cb);
};
file->size = [](CueFile *file, CueScheduler *scheduler, int compressed,
void (*cb)(CueFile *, CueScheduler *, uint64_t)) {
UvFile *fi = reinterpret_cast<UvFile *>(file->opaque);
if (compressed) {
FFmpegAudioFile *cfi = new FFmpegAudioFile(fi, FFmpegAudioFile::CHANNELS_STEREO,
FFmpegAudioFile::ENDIANNESS_LITTLE, 44100);
File *fi = reinterpret_cast<File *>(file->opaque);
if (compressed && dynamic_cast<UvFile *>(fi)) {
FFmpegAudioFile *cfi =
new FFmpegAudioFile(fi, FFmpegAudioFile::Channels::Stereo, FFmpegAudioFile::Endianness::Little,
FFmpegAudioFile::SampleFormat::S16, 44100);
file->opaque = cfi;
File_schedule_size(file, scheduler, cfi->size(), cb);
} else {
File_schedule_size(file, scheduler, fi->size(), cb);
fi = cfi;
}
File_schedule_size(file, scheduler, fi->size(), cb);
};
file->read = [](CueFile *file, CueScheduler *scheduler, uint32_t amount, uint64_t cursor, uint8_t *buffer,
void (*cb)(CueFile *, CueScheduler *, int error, uint32_t amount, uint8_t *buffer)) {
UvFile *fi = reinterpret_cast<UvFile *>(file->opaque);
File *fi = reinterpret_cast<File *>(file->opaque);
if (cursor >= fi->size()) {
File_schedule_read(file, scheduler, 0, 0, nullptr, cb);
} else {
Expand Down Expand Up @@ -135,21 +136,31 @@ bool PCSX::CDRIso::parsecue(const char *isofileString) {
Context *context = reinterpret_cast<Context *>(scheduler->opaque);
if (error) {
context->failed = true;
g_system->log(LogClass::CDROM_IO, "Error parsing Cue File: %s", error);
PCSX::g_system->printf("Error parsing Cue File: %s", error);
}
});

Scheduler_run(&scheduler);
CueParser_destroy(&parser);
CueParser_close(&parser, &scheduler, [](CueParser *parser, CueScheduler *scheduler, const char *error) {
Context *context = reinterpret_cast<Context *>(scheduler->opaque);
if (error) {
context->failed = true;
PCSX::g_system->printf("Error closing cue parser: %s", error);
}
CueParser_destroy(parser);
});
Scheduler_run(&scheduler);

File_schedule_close(&cue, &scheduler, [](CueFile *file, CueScheduler *scheduler) { file->destroy(file); });
if (context.failed) {
for (unsigned i = 1; i <= disc.trackCount; i++) {
CueTrack *track = &disc.tracks[i];
if (track->file) {
if (track->file->references == 1) {
File_schedule_close(track->file, &scheduler,
[](CueFile *file, CueScheduler *scheduler) { file->destroy(file); });
File_schedule_close(track->file, &scheduler, [](CueFile *file, CueScheduler *scheduler) {
file->destroy(file);
free(file);
});
} else {
track->file->references--;
}
Expand All @@ -172,6 +183,12 @@ bool PCSX::CDRIso::parsecue(const char *isofileString) {
m_ti[i].start = IEC60908b::MSF(track->indices[1] + 150);
m_ti[i].pregap = IEC60908b::MSF(track->indices[1] - track->indices[0]);
m_ti[i].length = IEC60908b::MSF(track->size);
if (track->file->references == 1) {
free(track->file);
} else {
track->file->references--;
}
track->file = nullptr;
}

m_numtracks = disc.trackCount;
Expand Down
5 changes: 2 additions & 3 deletions src/cdrom/cdriso-sbi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
#include "cdrom/cdriso.h"

bool PCSX::CDRIso::LoadSBI(const char *filename) {
IO<File> sbihandle;
IO<File> sbihandle(new UvFile(filename));
char buffer[16];

sbihandle.setFile(new UvFile(filename));
if (sbihandle->failed()) return false;
if (g_emulator->settings.get<Emulator::SettingFullCaching>()) {
sbihandle.asA<UvFile>()->startCaching();
}
if (sbihandle->failed()) return false;

// init
sbicount = 0;
Expand Down
15 changes: 5 additions & 10 deletions src/cdrom/cdriso.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,20 +257,15 @@ void PCSX::CDRIso::printTracks() {
}
}

// This function is invoked by the front-end when opening an ISO
// file for playback
bool PCSX::CDRIso::open(void) {
// is it already open?
if (m_cdHandle) return true;

m_cdHandle.setFile(new UvFile(m_isoPath));
if (g_emulator->settings.get<Emulator::SettingFullCaching>()) {
m_cdHandle.asA<UvFile>()->startCaching();
}
bool PCSX::CDRIso::open(IO<File> isoFile) {
m_cdHandle = isoFile;
if (m_cdHandle->failed()) {
m_cdHandle.reset();
return false;
}
if (g_emulator->settings.get<Emulator::SettingFullCaching>() && m_cdHandle.isA<UvFile>()) {
m_cdHandle.asA<UvFile>()->startCaching();
}

PCSX::g_system->printf(_("Loaded CD Image: %s"), m_isoPath.string());

Expand Down
12 changes: 8 additions & 4 deletions src/cdrom/cdriso.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ namespace PCSX {

class CDRIso {
public:
CDRIso();
CDRIso(const std::filesystem::path& path) : CDRIso() {
m_isoPath = path;
open();
open(new UvFile(m_isoPath));
}
CDRIso(IO<File> isoFile) : CDRIso() {
m_isoPath = isoFile->filename();
open(isoFile);
}
~CDRIso() {
close();
Expand Down Expand Up @@ -68,7 +71,8 @@ class CDRIso {
bool CheckSBI(const uint8_t* time);

private:
bool open();
CDRIso();
bool open(IO<File> isoFile);
void close();

std::filesystem::path m_isoPath;
Expand Down Expand Up @@ -139,7 +143,7 @@ class CDRIso {
IEC60908b::MSF start;
IEC60908b::MSF length;
IO<File> handle = nullptr; // for multi-track images CDDA
enum cddatype_t { NONE = 0, BIN = 1, CCDDA = 2 } cddatype = NONE; // BIN, WAV, MP3, APE
enum CDDAType { NONE = 0, BIN = 1, CCDDA = 2 } cddatype = NONE; // BIN, WAV, MP3, APE
uint32_t start_offset = 0; // byte offset from start of above file
};

Expand Down
3 changes: 2 additions & 1 deletion src/cdrom/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@ ssize_t PCSX::CDRIsoFile::read(void* buffer_, size_t size) {
while (toCopy != 0) {
if (m_cachedLBA != lba) {
m_cachedLBA = lba;
auto res = m_iso->readSectors(lba++, m_cachedSector, 1);
auto res = m_iso->readSectors(lba, m_cachedSector, 1);
if (res != 1) return -1;
}
size_t blocSize = std::min(toCopy, c_sectorSizes[modeIndex] - sectorOffset);
memcpy(buffer + actualSize, m_cachedSector + c_sectorOffsets[modeIndex] + sectorOffset, blocSize);
lba++;
sectorOffset = 0;
actualSize += blocSize;
toCopy -= blocSize;
Expand Down
Loading

0 comments on commit dad7cd9

Please sign in to comment.