Skip to content

Commit 8cc3aa2

Browse files
authored
Merge pull request #1906 from nicolasnoble/authoring
Adding CD authoring tool.
2 parents 3b8f0a0 + 928e64b commit 8cc3aa2

36 files changed

+935
-213
lines changed

.github/filter-support/Makefile-filtered

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ SRCS += $(wildcard third_party/cueparser/*.c)
8585
SRCS += $(wildcard third_party/iec-60908b/*.c)
8686
SRCS += third_party/ucl/src/n2e_99.c third_party/ucl/src/alloc.c
8787

88-
TOOLS = exe2elf exe2iso ps1-packer psyq-obj-parser
88+
TOOLS = authoring exe2elf exe2iso modconv ps1-packer psyq-obj-parser
8989

9090
##############################################################################
9191

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ deps/
3939
objs/
4040
bins/
4141
/pcsx-redux
42+
/authoring
4243
/exe2elf
4344
/exe2iso
4445
/modconv

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ ifeq ($(CROSS),arm64)
165165
CPPFLAGS += -DVIXL_INCLUDE_TARGET_AARCH64 -DVIXL_CODE_BUFFER_MMAP
166166
CPPFLAGS += -Ithird_party/vixl/src -Ithird_party/vixl/src/aarch64
167167
endif
168-
SUPPORT_SRCS := src/support/file.cc src/support/mem4g.cc src/support/zfile.cc
169-
SUPPORT_SRCS += src/supportpsx/adpcm.cc src/supportpsx/binloader.cc src/supportpsx/ps1-packer.cc
168+
SUPPORT_SRCS := src/support/container-file.cc src/support/file.cc src/support/mem4g.cc src/support/zfile.cc
169+
SUPPORT_SRCS += src/supportpsx/adpcm.cc src/supportpsx/binloader.cc src/supportpsx/iec-60908b.cc src/supportpsx/iso9660-builder.cc src/supportpsx/ps1-packer.cc
170170
SUPPORT_SRCS += third_party/fmt/src/os.cc third_party/fmt/src/format.cc
171171
SUPPORT_SRCS += third_party/ucl/src/n2e_99.c third_party/ucl/src/alloc.c
172172
SUPPORT_SRCS += $(wildcard third_party/iec-60908b/*.c)
173173
LIBS := third_party/luajit/src/libluajit.a
174174

175-
TOOLS = exe2elf exe2iso modconv ps1-packer psyq-obj-parser
175+
TOOLS = authoring exe2elf exe2iso modconv ps1-packer psyq-obj-parser
176176

177177
##############################################################################
178178

azure-pipelines-cli.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ steps:
6262
Contents: |
6363
vsprojects/x64/ReleaseCLI/pcsx-redux.exe
6464
vsprojects/x64/ReleaseCLI/crashpad_handler.exe
65+
vsprojects/x64/ReleaseCLI/authoring.exe
6566
vsprojects/x64/ReleaseCLI/exe2elf.exe
6667
vsprojects/x64/ReleaseCLI/exe2iso.exe
6768
vsprojects/x64/ReleaseCLI/modconv.exe
@@ -82,6 +83,7 @@ steps:
8283
testAssemblyVer2: |
8384
**\*.exe
8485
!**\crashpad_handler.exe
86+
!**\authoring.exe
8587
!**\exe2elf.exe
8688
!**\exe2iso.exe
8789
!**\modconv.exe

azure-pipelines.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ steps:
7070
vsprojects/x64/ReleaseWithClangCL/pcsx-redux.main
7171
vsprojects/x64/ReleaseWithClangCL/pcsx-redux.exe
7272
vsprojects/x64/ReleaseWithClangCL/crashpad_handler.exe
73+
vsprojects/x64/ReleaseWithClangCL/authoring.exe
7374
vsprojects/x64/ReleaseWithClangCL/exe2elf.exe
7475
vsprojects/x64/ReleaseWithClangCL/exe2iso.exe
7576
vsprojects/x64/ReleaseWithClangCL/modconv.exe
@@ -90,6 +91,7 @@ steps:
9091
testAssemblyVer2: |
9192
**\*.exe
9293
!**\crashpad_handler.exe
94+
!**\authoring.exe
9395
!**\exe2elf.exe
9496
!**\exe2iso.exe
9597
!**\modconv.exe

src/cdrom/common.h

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/cdrom/file.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
#include "cdrom/cdriso.h"
2525
#include "iec-60908b/edcecc.h"
2626

27-
PCSX::CDRIsoFile::CDRIsoFile(std::shared_ptr<CDRIso> iso, uint32_t lba, int32_t size, SectorMode mode)
27+
PCSX::CDRIsoFile::CDRIsoFile(std::shared_ptr<CDRIso> iso, uint32_t lba, int32_t size, IEC60908b::SectorMode mode)
2828
: File(RW_SEEKABLE), m_iso(iso), m_lba(lba) {
2929
uint8_t* sector = m_cachedSector;
3030
if (iso->failed()) {
3131
m_failed = true;
3232
return;
3333
}
34-
if (mode == SectorMode::GUESS) {
35-
mode = SectorMode::RAW;
34+
if (mode == IEC60908b::SectorMode::GUESS) {
35+
mode = IEC60908b::SectorMode::RAW;
3636
do {
3737
m_cachedLBA = lba;
3838
iso->readSectors(lba, sector, 1);
@@ -48,7 +48,7 @@ PCSX::CDRIsoFile::CDRIsoFile(std::shared_ptr<CDRIso> iso, uint32_t lba, int32_t
4848
}
4949
switch (sector[15]) {
5050
case 1:
51-
mode = SectorMode::M1;
51+
mode = IEC60908b::SectorMode::M1;
5252
break;
5353
case 2: {
5454
uint8_t* subheaders = sector + 16;
@@ -57,9 +57,9 @@ PCSX::CDRIsoFile::CDRIsoFile(std::shared_ptr<CDRIso> iso, uint32_t lba, int32_t
5757
break;
5858
}
5959
if (subheaders[2] & 32) {
60-
mode = SectorMode::M2_FORM2;
60+
mode = IEC60908b::SectorMode::M2_FORM2;
6161
} else {
62-
mode = SectorMode::M2_FORM1;
62+
mode = IEC60908b::SectorMode::M2_FORM1;
6363
}
6464
break;
6565
}
@@ -74,7 +74,7 @@ PCSX::CDRIsoFile::CDRIsoFile(std::shared_ptr<CDRIso> iso, uint32_t lba, int32_t
7474
return;
7575
}
7676

77-
if ((mode != SectorMode::M2_FORM1) && (mode != SectorMode::M2_FORM2)) {
77+
if ((mode != IEC60908b::SectorMode::M2_FORM1) && (mode != IEC60908b::SectorMode::M2_FORM2)) {
7878
// can't detect file size on non-mode2 sectors
7979
m_failed = true;
8080
return;
@@ -200,8 +200,8 @@ ssize_t PCSX::CDRIsoFile::write(const void* buffer_, size_t size) {
200200
size_t blocSize = std::min(toCopy, c_sectorSizes[modeIndex] - sectorOffset);
201201
memcpy(patched + c_sectorOffsets[modeIndex] + sectorOffset, buffer + actualSize, blocSize);
202202
switch (m_mode) {
203-
case SectorMode::M2_FORM1:
204-
case SectorMode::M2_FORM2:
203+
case IEC60908b::SectorMode::M2_FORM1:
204+
case IEC60908b::SectorMode::M2_FORM2:
205205
compute_edcecc(patched);
206206
break;
207207
}

src/cdrom/file.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#include <memory>
2525
#include <string_view>
2626

27-
#include "cdrom/common.h"
2827
#include "support/file.h"
28+
#include "supportpsx/iec-60908b.h"
2929

3030
namespace PCSX {
3131

@@ -37,7 +37,8 @@ class CDRIsoFile : public File {
3737

3838
static constexpr uint32_t c_sectorSizes[] = {2352, 2352, 2048, 2336, 2048, 2324};
3939
static constexpr size_t c_sectorOffsets[] = {0, 0, 16, 16, 24, 24};
40-
CDRIsoFile(std::shared_ptr<CDRIso> iso, uint32_t lba, int32_t size = -1, SectorMode = SectorMode::GUESS);
40+
CDRIsoFile(std::shared_ptr<CDRIso> iso, uint32_t lba, int32_t size = -1,
41+
IEC60908b::SectorMode = IEC60908b::SectorMode::GUESS);
4142
virtual bool failed() final override { return m_failed; }
4243
virtual ssize_t rSeek(ssize_t pos, int wheel) override;
4344
virtual ssize_t rTell() override { return m_ptrR; }
@@ -54,7 +55,7 @@ class CDRIsoFile : public File {
5455
int32_t m_cachedLBA = -1;
5556
uint32_t m_lba;
5657
uint32_t m_size;
57-
SectorMode m_mode;
58+
IEC60908b::SectorMode m_mode;
5859
size_t m_ptrR = 0;
5960
size_t m_ptrW = 0;
6061

src/cdrom/iso9660-builder.h

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/cdrom/iso9660-reader.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include "cdrom/iso9660-reader.h"
2121

2222
#include "cdrom/file.h"
23-
#include "cdrom/iso9660-lowlevel.h"
2423
#include "support/strings-helpers.h"
24+
#include "supportpsx/iso9660-lowlevel.h"
2525

2626
PCSX::ISO9660Reader::ISO9660Reader(std::shared_ptr<CDRIso> iso) : m_iso(iso) {
2727
unsigned pvdSector = 16;

src/cdrom/iso9660-reader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <vector>
2525

2626
#include "cdrom/file.h"
27-
#include "cdrom/iso9660-lowlevel.h"
27+
#include "supportpsx/iso9660-lowlevel.h"
2828

2929
namespace PCSX {
3030

src/core/luaiso.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424
#include "cdrom/cdriso.h"
2525
#include "cdrom/file.h"
26-
#include "cdrom/iso9660-builder.h"
2726
#include "cdrom/iso9660-reader.h"
2827
#include "core/cdrom.h"
2928
#include "lua/luafile.h"
3029
#include "lua/luawrapper.h"
30+
#include "supportpsx/iso9660-builder.h"
3131

3232
namespace {
3333

@@ -53,7 +53,7 @@ bool isReaderFailed(PCSX::ISO9660Reader* reader) { return reader->failed(); }
5353
PCSX::LuaFFI::LuaFile* readerOpen(PCSX::ISO9660Reader* reader, const char* path) {
5454
return new PCSX::LuaFFI::LuaFile(reader->open(path));
5555
}
56-
PCSX::LuaFFI::LuaFile* fileisoOpen(LuaIso* wrapper, uint32_t lba, uint32_t size, PCSX::SectorMode mode) {
56+
PCSX::LuaFFI::LuaFile* fileisoOpen(LuaIso* wrapper, uint32_t lba, uint32_t size, PCSX::IEC60908b::SectorMode mode) {
5757
return new PCSX::LuaFFI::LuaFile(new PCSX::CDRIsoFile(wrapper->iso, lba, size, mode));
5858
}
5959

@@ -64,7 +64,7 @@ void deleteIsoBuilder(PCSX::ISO9660Builder* builder) { delete builder; }
6464
void isoBuilderWriteLicense(PCSX::ISO9660Builder* builder, PCSX::LuaFFI::LuaFile* licenseWrapper) {
6565
builder->writeLicense(licenseWrapper->file);
6666
}
67-
void isoBuilderWriteSector(PCSX::ISO9660Builder* builder, const uint8_t* sectorData, PCSX::SectorMode mode) {
67+
void isoBuilderWriteSector(PCSX::ISO9660Builder* builder, const uint8_t* sectorData, PCSX::IEC60908b::SectorMode mode) {
6868
builder->writeSector(sectorData, mode);
6969
}
7070
void isoBuilderClose(PCSX::ISO9660Builder* builder) { builder->close(); }

src/core/web-server.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "GL/gl3w.h"
3232
#include "cdrom/cdriso.h"
3333
#include "cdrom/file.h"
34-
#include "cdrom/iso9660-builder.h"
3534
#include "cdrom/iso9660-reader.h"
3635
#include "core/cdrom.h"
3736
#include "core/gpu.h"
@@ -44,6 +43,7 @@
4443
#include "support/file.h"
4544
#include "support/hashtable.h"
4645
#include "support/strings-helpers.h"
46+
#include "supportpsx/iso9660-builder.h"
4747
#include "uriparser/Uri.h"
4848

4949
namespace {
@@ -463,7 +463,7 @@ class CDExecutor : public PCSX::WebExecutor {
463463
auto filename = vars.find("filename");
464464
auto sector = vars.find("sector");
465465
auto modeStr = vars.find("mode");
466-
PCSX::SectorMode mode = PCSX::SectorMode::GUESS;
466+
PCSX::IEC60908b::SectorMode mode = PCSX::IEC60908b::SectorMode::GUESS;
467467
if ((filename == vars.end()) && (sector == vars.end())) {
468468
client->write("HTTP/1.1 400 Bad Request\r\n\r\n");
469469
return true;
@@ -473,7 +473,7 @@ class CDExecutor : public PCSX::WebExecutor {
473473
return true;
474474
}
475475
if (modeStr != vars.end()) {
476-
auto modeCast = magic_enum::enum_cast<PCSX::SectorMode>(modeStr->second.value_or(""));
476+
auto modeCast = magic_enum::enum_cast<PCSX::IEC60908b::SectorMode>(modeStr->second.value_or(""));
477477
if (modeCast.has_value()) {
478478
mode = modeCast.value();
479479
} else {

src/mips/common/util/util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ void storeUnaligned(uint8_t *ptr, T value) {
5454

5555
#endif
5656

57+
#ifdef __mips__
5758
static __inline__ uint32_t load32Unaligned(const void *in, int pos) {
5859
const uint8_t *buffer = (const uint8_t *)in;
5960
uint32_t r;
6061
__builtin_memcpy(&r, buffer + pos, sizeof(uint32_t));
6162
return r;
6263
}
64+
#endif

src/mips/psyqo-paths/src/archive-manager.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ void psyqo::paths::ArchiveManager::setupInitQueue(eastl::string_view archiveName
4545
}
4646
m_queueInitFilename.then(parser.scheduleGetDirentry(archiveName, &m_archiveDirentry))
4747
.then([this](auto task) {
48-
m_index.resize(2048 / sizeof(IndexEntry));
4948
m_request.LBA = m_archiveDirentry.LBA;
50-
m_request.count = 1;
51-
m_request.buffer = m_index.data();
5249
task->resolve();
5350
})
5451
.then(m_queue.schedule());
@@ -62,6 +59,7 @@ void psyqo::paths::ArchiveManager::setupInitQueue(uint32_t LBA, CDRom& device, e
6259
m_initCallback = eastl::move(callback);
6360
m_request.LBA = LBA;
6461
m_request.count = 1;
62+
m_index.resize(2048 / sizeof(IndexEntry));
6563
m_request.buffer = m_index.data();
6664
m_queue.startWith(device.scheduleReadRequest(&m_request))
6765
.then([this](auto task) {
@@ -70,8 +68,9 @@ void psyqo::paths::ArchiveManager::setupInitQueue(uint32_t LBA, CDRom& device, e
7068
task->reject();
7169
return;
7270
}
73-
m_index.resize(getIndexSectorCount() * 2048 / sizeof(IndexEntry));
74-
m_request.count = getIndexSectorCount();
71+
auto indexSectorCount = getIndexSectorCount();
72+
m_index.resize(indexSectorCount * 2048 / sizeof(IndexEntry));
73+
m_request.count = indexSectorCount;
7574
m_request.buffer = m_index.data();
7675
task->resolve();
7776
})

src/support/binstruct.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,17 @@ struct CString {
149149
static constexpr char const typeName[] = "CString";
150150
typedef std::string_view type;
151151
operator type() const { return {value, S}; }
152-
CString<S> operator=(const type &v) {
152+
CString &operator=(const type &v) {
153153
memcpy(value, v.data(), S);
154154
return *this;
155155
}
156-
void set(const type &v) {
156+
void set(const type &v, char padding = 0) {
157157
value[S] = 0;
158-
memcpy(value, v.data(), S);
158+
auto toCopy = std::min(S, v.size());
159+
memcpy(value, v.data(), toCopy);
160+
if (toCopy < S) {
161+
memset(value + toCopy, padding, S - toCopy);
162+
}
159163
}
160164
void serialize(IO<File> f) const { f->write(value, S); }
161165
void deserialize(IO<File> f) {

0 commit comments

Comments
 (0)