Skip to content

Commit

Permalink
fix psu - psv conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
bucanero committed Jan 28, 2024
1 parent 5f5a2d9 commit aa37225
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 3 additions & 1 deletion source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
#include "spu_soundmodule_bin.h"
#include <soundlib/spu_soundlib.h>
#include <libxmp-lite/xmp.h>
#include "haiku_s3m.h"

#define SAMPLING_FREQ 48000 /* 48khz. */
#define AUDIO_SAMPLES SAMPLING_FREQ * 2 /* audio buffer to decode (for 48000 samples x 0.5 seconds and 16 bit stereo as reference) */

extern const uint8_t haiku_s3m[];
extern const uint32_t haiku_s3m_size;

static short *background_music[2] = {NULL, NULL};
static xmp_context xmp = NULL;

Expand Down
18 changes: 9 additions & 9 deletions source/psv_ps2.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const uint8_t cbsKey[256] = {
};

int psv_resign(const char *src_psv);
void write_psvheader(FILE *fp, uint32_t type);
void write_psv_header(FILE *fp, uint32_t type);
void get_psv_filename(char* psvName, const char* path, const char* dirName);

static void printMAXHeader(const maxHeader_t *header)
Expand Down Expand Up @@ -231,7 +231,7 @@ int ps2_max2psv(const char *save, const char* psv_path)
memcpy(&ps2md.modified, &fmtime, sizeof(sceMcStDateTime));
memcpy(ps2md.filename, dirName, sizeof(ps2md.filename));

write_psvheader(psv, 2);
write_psv_header(psv, 2);

LOG("\nSave contents:\n");

Expand Down Expand Up @@ -340,13 +340,13 @@ int ps2_psu2psv(const char *save, const char* psv_path)

ps2h.numberOfFiles = ES32(numFiles);

ps2md.attribute = entry.mode;
ps2md.attribute = ((uint32_t)entry.mode << 16);
ps2md.numberOfFilesInDir = entry.length;
memcpy(&ps2md.created, &entry.created, sizeof(sceMcStDateTime));
memcpy(&ps2md.modified, &entry.modified, sizeof(sceMcStDateTime));
memcpy(ps2md.filename, entry.name, sizeof(ps2md.filename));

write_psvheader(psvFile, 2);
write_psv_header(psvFile, 2);

// Skip "." and ".."
fseek(psuFile, sizeof(ps2_McFsEntry)*2, SEEK_CUR);
Expand Down Expand Up @@ -387,7 +387,7 @@ int ps2_psu2psv(const char *save, const char* psv_path)
{
fread(&entry, 1, sizeof(ps2_McFsEntry), psuFile);

ps2fi[i].attribute = entry.mode;
ps2fi[i].attribute = ((uint32_t)entry.mode << 16);
ps2fi[i].positionInFile = ES32(dataPos);
ps2fi[i].filesize = entry.length;
memcpy(&ps2fi[i].created, &entry.created, sizeof(sceMcStDateTime));
Expand Down Expand Up @@ -533,7 +533,7 @@ int ps2_cbs2psv(const char *save, const char *psv_path)
memcpy(&ps2md.modified, &header->modified, sizeof(sceMcStDateTime));
memcpy(ps2md.filename, header->name, sizeof(ps2md.filename));

write_psvheader(dstFile, 2);
write_psv_header(dstFile, 2);

LOG("Save contents:\n");

Expand Down Expand Up @@ -675,7 +675,7 @@ int ps2_xps2psv(const char *save, const char *psv_path)
memcpy(&ps2md.modified, &entry.modified, sizeof(sceMcStDateTime));
memcpy(ps2md.filename, entry.name, sizeof(ps2md.filename));

write_psvheader(psvFile, 2);
write_psv_header(psvFile, 2);

// Find the icon.sys (need to know the icons names)
for(i = 0; i < numFiles; i++)
Expand Down Expand Up @@ -784,7 +784,7 @@ int ps2_psv2psu(const char *save, const char* psu_path)
memcpy(&entry.created, &ps2md.created, sizeof(sceMcStDateTime));
memcpy(&entry.modified, &ps2md.modified, sizeof(sceMcStDateTime));
memcpy(entry.name, ps2md.filename, sizeof(entry.name));
entry.mode = ps2md.attribute;
entry.mode = (ps2md.attribute >> 16);
entry.length = ps2md.numberOfFilesInDir;
fwrite(&entry, sizeof(entry), 1, psuFile);

Expand All @@ -809,7 +809,7 @@ int ps2_psv2psu(const char *save, const char* psu_path)
memcpy(&entry.created, &ps2fi.created, sizeof(sceMcStDateTime));
memcpy(&entry.modified, &ps2fi.modified, sizeof(sceMcStDateTime));
memcpy(entry.name, ps2fi.filename, sizeof(entry.name));
entry.mode = ps2fi.attribute;
entry.mode = (ps2fi.attribute >> 16);
entry.length = ps2fi.filesize;
fwrite(&entry, sizeof(entry), 1, psuFile);

Expand Down
6 changes: 3 additions & 3 deletions source/psv_resign.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void get_psv_filename(char* psvName, const char* path, const char* dirName)
strcat(psvName, ".PSV");
}

void write_psvheader(FILE *fp, uint32_t type)
void write_psv_header(FILE *fp, uint32_t type)
{
psv_header_t ph;

Expand Down Expand Up @@ -232,7 +232,7 @@ int ps1_mcs2psv(const char* mcsfile, const char* psv_path)
return 0;
}

write_psvheader(pf, 1);
write_psv_header(pf, 1);

memset(&ps1h, 0, sizeof(ps1_header_t));
ps1h.saveSize = ES32(sz - 0x80);
Expand Down Expand Up @@ -328,7 +328,7 @@ int ps1_psx2psv(const char* psxfile, const char* psv_path)
return 0;
}

write_psvheader(pf, 1);
write_psv_header(pf, 1);

memset(&ps1h, 0, sizeof(ps1_header_t));
ps1h.saveSize = ES32(sz - 0x36);
Expand Down

0 comments on commit aa37225

Please sign in to comment.