Created PSX Game template to use

This commit is contained in:
jaby 2022-08-21 21:00:00 +02:00
parent f7f43f50c6
commit 9ab4520b81
18 changed files with 108 additions and 563 deletions

View File

@ -1,141 +0,0 @@
{
"folders": [
{
"name": "JabyEngine",
"path": "."
},
{
"name": "PSYQ",
"path": "..\\..\\..\\PSYQ\\Converted\\Include"
},
{
"name": "NEXTGPU",
"path": "..\\..\\..\\..\\..\\PSX\\projects\\NEXTGPU"
},
{
"name": "CDPLAYER",
"path": "..\\..\\..\\..\\..\\PSX\\projects\\CDPLAYER"
}
],
"tasks": {
"version": "2.0.0",
"tasks": [
{
"label": "make",
"type": "shell",
"command": "wsl make ${input:target} BUILD=${input:build}",
"options": {
"cwd": "Library/Code"
},
"problemMatcher": []
},
{
"label": "finalize",
"type": "shell",
"command": "Finalize.bat ${input:finalize_tool} ${input:finalize} JabyEngine Library\\Code",
"options": {
"env": {
"PATH": "./Tools/;./Tools/psxcdgen/psxcdgen/target/release;../../Tools/;../../Tools/mkpsxiso;${env:PATH}"
}
},
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [],
},
{
"label": "nugget make",
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": ["make", "finalize"],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "jaby make",
"type": "shell",
"command": "wsl make ${input:target} BUILD=${input:build} USE_JABY_MAKE=true",
"options": {
"cwd": "Library/Code"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "jaby make & finalize",
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": ["jaby make", "finalize"],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"inputs": [
{
"id": "build",
"type": "pickString",
"description": "Build type to use",
"options": ["Debug", "Release"],
"default": "Release"
},
{
"id": "target",
"type": "pickString",
"description": "Target to build",
"options": ["", "rebuild", "fullclean", "clean"],
"default": ""
},
{
"id": "finalize",
"type": "pickString",
"description": "Mode for FinalizeCD",
"options": ["all", "calculate", "skip"],
"default": "all"
},
{
"id": "finalize_tool",
"type": "pickString",
"description": "Tool to use for Finalizing the CD",
"options": ["mkpsxiso.exe", "psxcdgen"],
"default": "mkpsxiso.exe"
},
{
"id": "target",
"type": "pickString",
"description": "Phony target",
"options": ["all", "clean"],
"default": "all"
},
{
"id": "build_profile",
"type": "pickString",
"description": "Build type to use",
"options": ["debug", "release"],
"default": "release"
},
],
},
"settings": {
"C_Cpp.default.name": "PSX",
"C_Cpp.default.includePath": [
"../../PSYQ/Converted/Include"
],
"C_Cpp.default.compilerPath": "",
"C_Cpp.default.cStandard": "c17",
"C_Cpp.default.cppStandard": "c++20",
"C_Cpp.default.compilerArgs": [
],
"C_Cpp.default.defines": [
],
"files.associations": {
"CDDADEMO.C": "cpp"
}
}
}

View File

@ -1,54 +0,0 @@
BINDIR ?= bin/
PCSX_REDUX ?= ../../../../GIT/pcsx-redux/src/mips
PSYQ_PATH ?= ../../../../PSYQ/Converted
TARGET = JabyEngine
TYPE = ps-exe
BUILD = Release
#OVERLAYSCRIPT ?= overlay.ld
#OVERLAYSECTION ?= .ovly0 .ovly1
rwildcard = $(wildcard $(addprefix $1/*.,$2)) $(foreach d,$(wildcard $1/*),$(call rwildcard,$d,$2))
#Source list
SRCS = $(call rwildcard, src, c cpp)
SRCS += $(PCSX_REDUX)/common/crt0/crt0.s
CPPFLAGS += -I$(PSYQ_PATH)/Include -D_WCHAR_T
LDFLAGS += -L$(PSYQ_PATH)/Lib
LDFLAGS += -Wl,--start-group
LDFLAGS += -lapi
LDFLAGS += -lc
LDFLAGS += -lc2
LDFLAGS += -lcard
LDFLAGS += -lcomb
LDFLAGS += -lds
LDFLAGS += -letc
LDFLAGS += -lgpu
LDFLAGS += -lgs
LDFLAGS += -lgte
LDFLAGS += -lgun
LDFLAGS += -lhmd
LDFLAGS += -lmath
LDFLAGS += -lmcrd
LDFLAGS += -lmcx
LDFLAGS += -lpad
LDFLAGS += -lpress
LDFLAGS += -lsio
LDFLAGS += -lsnd
LDFLAGS += -lspu
LDFLAGS += -ltap
LDFLAGS += -lcd
LDFLAGS += -Wl,--end-group
ifdef USE_JABY_MAKE
include Wrapper.mk
else
include $(PCSX_REDUX)/common.mk
endif
fullclean: clean
rm -fr iso/Info/* bin/GlobalLBATable.bin
rebuild: fullclean all

View File

@ -1,19 +0,0 @@
#this makefile translates from NUGGET make to JabyMake
ARTIFACT = JabyEngine
BUILD_DIR = bin
ifeq ($(BUILD),Release)
BUILD_PROFILE := release
else
BUILD_PROFILE := debug
endif
CCFLAGS_all := $(CPPFLAGS)
LIBS := $(LDFLAGS)
undefine CPPFLAGS
undefine LDFLAGS
undefine BUILD
#include the real make file
include ../Makefile

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<iso_project image_name="iso/JabyEngine.bin" cue_sheet="iso/JabyEngine.cue" no_xa="0">
<track type="data">
<identifiers
system = "PLAYSTATION"
application = "PLAYSTATION"
volume = "MYDISC"
volume_set = "MYDISC"
publisher = "JABY"
data_preparer = "MKPSXISO"
copyright = "COPYLEFT"
/>
<license file="../../PSYQ/psyq/cdgen/LCNSFILE/LICENSEE.DAT"/>
<directory_tree>
<file name="SYSTEM.CNF" type="data" source="Library/Code/iso/JabyEngine.cnf"/>
<file name="SCES_003.90" type="data" source="Library/Code/bin/PSX-release/JabyEngine.psexe"/>
<dir name="XB">
<file name="FOX.XA" type="xa" source="Ressource/fox.xa"/>
<file name="SHARK.XA" type="xa" source="Ressource/shark.xa"/>
<file name="FOXSHK.XA" type="xa" source="Ressource/fox_shark_sub.xa"/>
<file name="FXSHKT.XA" type="xa" source="Ressource/fox_shark_sub_vtx.xa"/>
</dir>
<dir name="XA">
<file name="FOX.XA" type="xa" source="Ressource/fox.xa"/>
<file name="SHARK.XA" type="xa" source="Ressource/shark.xa"/>
<file name="FOXSHK.XA" type="xa" source="Ressource/fox_shark_sub.xa"/>
<file name="FXSHKT.XA" type="xa" source="Ressource/fox_shark_sub_vtx.xa"/>
</dir>
<!--<dummy sectors="1024"/>-->
</directory_tree>
</track>
<track type="audio" source="D:\PSX\projects\NEXTGPU\data\Burg.wav"/>
<track type="audio" source="D:\PSX\projects\VS2019\JabyPhew\JabyPhew\Ressources\shark.wav"/>
</iso_project>

View File

@ -1,6 +0,0 @@
{
"Output":"Library/Code/bin/GlobalLBATable.bin",
"Input":"Library/Code/iso/Info/JabyEngine.lba",
"Order": [
]
}

View File

@ -1,94 +0,0 @@
#include "XAAudio.h"
#include <STDDEF.H>
#include <LIBSND.H>
namespace XAAudio
{
static constexpr int BigSectorSize = 2340;
static CdlCB oldCallback = nullptr;
static CdlLOC curLoc;
static int curChannel;
static u_char buffer[(sizeof(u_long)*8)];
static u_short getChannel(u_char *buffer)
{
const u_short currentChannel = *((unsigned short *)(buffer + 12) + 1);
return ((currentChannel&31744) >> 10);
}
static u_short getID(u_char *buffer)
{
return *(u_short*)(buffer + 12);
}
void cbready(int intr, u_char *result)
{
static const u_short VideoFrameID = 352;
if(intr == CdlDataReady)
{
CdGetSector((u_long*)buffer, 8);
const u_short ID = getID(buffer);
const u_short actChannel = getChannel(buffer);
if((ID == VideoFrameID) && (actChannel == curChannel))
{
CdControlF(CdlReadS, (u_char*)&curLoc);
}
}
}
void enable(bool doubleSpeed)
{
// setup the XA playback - adjust the speed as needed by your XA samples
u_char param[4];
param[0] = (((doubleSpeed) ? CdlModeSpeed : 0x0)|CdlModeRT|CdlModeSF|CdlModeSize1);
CdControlB(CdlSetmode, param, 0);
CdControlF(CdlPause, 0);
oldCallback = CdReadyCallback((CdlCB)cbready);
}
void disable()
{
// reset any callback that we replaced
CdControlF(CdlPause, 0);
CdReadyCallback(oldCallback);
// clear XA mode
u_char param = 0x0;
CdControlB(CdlSetmode, &param, 0);
}
void play(const CdlLOC &file, int channel)
{
CdlFILTER theFilter;
curLoc = file;
curChannel = channel;
// set the volume to max
SsSetSerialVol(SS_SERIAL_A, 127, 127);
// set up the XA filter
theFilter.file = 1;
theFilter.chan = channel;
CdControlF(CdlSetfilter, (u_char*)&theFilter);
// begin playing
CdControlF(CdlReadS, (u_char*)&file);
}
CdlLOC locate(const char* fileName)
{
CdlFILE file = {0};
CdSearchFile(&file, const_cast<char*>(fileName));
return file.pos;
}
}

View File

@ -1,16 +0,0 @@
#ifndef XAAUDIO_H
#define XAAUDIO_H
#include <STDDEF.H>
#include <LIBCD.H>
namespace XAAudio
{
void enable(bool doubleSpeed);
void disable();
void play(const CdlLOC &file, int channel);
CdlLOC locate(const char* fileName);
}
#endif // !XAAUDIO_H

View File

@ -1,74 +0,0 @@
#include "Audio/XAAudio.h"
#include "JabyEngine.h"
#include <types.h>
#include <libcd.h>
#include <libetc.h>
#include <libgte.h>
#include <libgpu.h>
#include <libsnd.h>
#include <stdio.h>
static CdlLOC TOC[100] = {0};
static void setup() {
ResetCallback();
//ResetGraph(0);
CdInit();
CdSetDebug(3);
SetVideoMode(MODE_PAL);
SsSetTickMode(SS_TICK50);
//SetDispMask(1);
}
static int fill_toc() {
u_char param[4] = {0};
param[0] = CdlModeRept|CdlModeDA; // report ON / CD-DA ON
CdControlB(CdlSetmode, param, 0);
return CdGetToc(TOC); // TOC
}
static void play_track(int track, int track_count) {
for(int n = 0; n < track_count; n++) {
const auto& cur_toc = TOC[n];
printf("Track %i.) starts at %x:%x:%x\n", n, cur_toc.minute, cur_toc.second, cur_toc.sector);
}
CdControlB(CdlSetloc, reinterpret_cast<u_char*>(&TOC[track]), 0); // seek to start of track "track"
CdControlB(CdlPlay, 0, 0); // play track
}
static void play_xa_track(const char* name, int channel) {
CdlFILE file;
if(CdSearchFile(&file, const_cast<char*>(name)) == nullptr)
{
printf("Couldn't locate file %s on disk!\n", name);
return;
}
XAAudio::enable(true);
XAAudio::play(file.pos, 1);
}
int main() {
setup();
const int track_count = fill_toc();
printf("Hello Planschi!\nI found %i tracks\n", track_count);
#ifdef USE_CDDA
//Play CDDA
play_track(2, track_count);
#else
//Play CDXA
play_xa_track("\\XA\\FXSHKT.XA;1", 0);
#endif
while(true);
return 0;
}

View File

@ -1,4 +0,0 @@
#ifndef JABYENGINE_H
#define JABYENGINE_H
#endif //!JABYENGINE_H

View File

@ -1,100 +0,0 @@
#Build architecture/variant string, possible values: x86, armv7le, etc...
PLATFORM ?= PSX
#Build profile, possible values: release, debug, profile, coverage
BUILD_DIR ?= build
BUILD_PROFILE ?= debug
CONFIG_NAME ?= $(PLATFORM)-$(BUILD_PROFILE)
OUTPUT_DIR = $(BUILD_DIR)/$(CONFIG_NAME)
TARGET = $(OUTPUT_DIR)/$(ARTIFACT)
#Compiler definitions
HAS_LINUX_MIPS_GCC = $(shell which mipsel-linux-gnu-gcc > /dev/null 2> /dev/null && echo true || echo false)
ifeq ($(HAS_LINUX_MIPS_GCC),true)
PREFIX ?= mipsel-linux-gnu
FORMAT ?= elf32-tradlittlemips
else
PREFIX ?= mipsel-none-elf
FORMAT ?= elf32-littlemips
endif
$(info We currently only support normal linker scripts)
LDSCRIPT ?= $(PCSX_REDUX)/ps-exe.ld
LDSCRIPT := $(addprefix $(PCSX_REDUX)/default.ld , -T$(LDSCRIPT))
CC = $(PREFIX)-gcc-10
CXX = $(PREFIX)-g++-10
LD = $(CXX)
#architecture flags
ARCHFLAGS = -march=mips1 -mabi=32 -EL -fno-pic -mno-shared -mno-abicalls -mfp32
ARCHFLAGS += -fno-stack-protector -nostdlib -ffreestanding
#Compiler flags for build profiles
CCFLAGS_release += -O3
CCFLAGS_debug += -O0
CXXFLAGS += -fno-exceptions -fno-rtti
USE_FUNCTION_SECTIONS ?= true
ifeq ($(USE_FUNCTION_SECTIONS),true)
CCFLAGS_all += -ffunction-sections
endif
CCFLAGS_all += -mno-gpopt -fomit-frame-pointer
CCFLAGS_all += -fno-builtin -fno-strict-aliasing -Wno-attributes
CCFLAGS_all += $(ARCHFLAGS)
CCFLAGS_all += $(CCFLAGS_$(BUILD_PROFILE))
#Linker flags
LDFLAGS_release += -Os
LDFLAGS_all += -Wl,-Map=$(TARGET).map -nostdlib -T$(LDSCRIPT) -static -Wl,--gc-sections -Wl,--build-id=none
LDFLAGS_all += $(ARCHFLAGS) -Wl,--oformat=$(FORMAT)
LDFLAGS_all += $(LDFLAGS_$(BUILD_PROFILE))
LIBS_all += $(LIBS_$(BUILD_PROFILE))
DEPS = -Wp,-MMD,$(@:%.o=%.d),-MT,$@
#Macro to expand files recursively: parameters $1 - directory, $2 - extension, i.e. cpp
rwildcard = $(wildcard $(addprefix $1/*.,$2)) $(foreach d,$(wildcard $1/*),$(call rwildcard,$d,$2))
#Object files list
OBJS = $(addprefix $(OUTPUT_DIR)/,$(addsuffix .o, $(subst ..,!super,$(basename $(SRCS)))))
#Compiling rule
$(OUTPUT_DIR)/%.o: %.c
@mkdir -p $(dir $@)
$(CC) -c $(DEPS) -o $@ $(CCFLAGS_all) $(CCFLAGS) $<
$(OUTPUT_DIR)/%.o: %.cpp
@mkdir -p $(dir $@)
$(CXX) -c $(DEPS) -o $@ $(CCFLAGS_all) $(CXXFLAGS) $<
.SECONDEXPANSION:
$(OUTPUT_DIR)/%.o: $$(subst !super,..,%.s)
@mkdir -p $(dir $@)
$(CC) $(ARCHFLAGS) -I$(PCSX_REDUX) -g -c -o $@ $<
#Linking rule
$(TARGET).elf: $(OBJS)
$(LD) -o $(TARGET).elf $(LDFLAGS_all) $(LDFLAGS) $(OBJS) $(LIBS_all) $(LIBS)
#Strips the psexe
$(TARGET).psexe: $(TARGET).elf
$(PREFIX)-objcopy $(addprefix -R , $(OVERLAYSECTION)) -O binary $< $@
#Rules section for default compilation and linking
all: $(TARGET).psexe
clean:
rm -fr $(OUTPUT_DIR)
rebuild:
$(MAKE) clean
$(MAKE) all
#Inclusion of dependencies (object files to source and includes)
-include $(OBJS:%.o=%.d)

Binary file not shown.

View File

@ -1,19 +0,0 @@
@echo off
if not exist "%4\iso\Info" mkdir %4\iso\Info
if not exist "iso" mkdir iso
if %2 == skip goto end
if not exist "%4/bin/GlobalLBATable.bin" echo Planschi > "%4%/bin/GlobalLBATable.bin"
echo "Calculate LBAs"
%1 -y -lba %4\iso\Info\%3.lba -lbahead %4\iso\Info\%3.h -noisogen %4\iso\%3ISODesc.xml *> nul
if exist "%4\iso\%3LBAFile.json" LBAHacker.exe %4\iso\%3LBAFile.json
if %2 == calculate goto end
rem this used to have "*> nul"
%1 -y %4\iso\%3ISODesc.xml
echo "Wrote ISO image"
:end

View File

@ -0,0 +1,63 @@
{
"folders": [
{
"path": ".",
"name": "#{ProjectName}"
}
],
"tasks": {
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "wsl make ${input:target} BUILD_PROFILE=${input:build profile} JABY_ENGINE_DIR=../${config:jaby_engine_path}",
"group": {
"kind": "build",
"isDefault": true
},
"options": {
"cwd": "application"
}
},
{
"label": "cdgen",
"type": "shell",
"command": "${config:jaby_engine_path}/bin/psxcdgen.exe iso/Config.xml",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "build & generate cd",
"type": "shell",
"dependsOn": ["build", "cdgen"],
"dependsOrder": "sequence",
"group": {
"kind": "build",
"isDefault": true
}
}
],
"inputs": [
{
"id": "build profile",
"type": "pickString",
"options": ["debug", "release"],
"default": "release",
"description": "the build profile for #{ProjectName}"
},
{
"id": "target",
"type": "pickString",
"options": ["all", "clean", "rebuild"],
"default": "all",
"description": "the build target"
}
]
},
"settings": {
"jaby_engine_path": "#{JabyEnginePath}",
}
}

View File

@ -0,0 +1,5 @@
*.bin
*.cue
*.d
*.o
**/bin

View File

@ -0,0 +1,18 @@
ARTIFACT = #{ProjectName}
BUILD_DIR = bin
PSCX_REDUX_DIR = $(JABY_ENGINE_DIR)/lib/pcsx-redux
include $(JABY_ENGINE_DIR)/lib/Wildcard.mk
SRCS = $(call rwildcard, src, c cpp)
LIBS = -L$(JABY_ENGINE_DIR)/lib/PSX-$(BUILD_PROFILE) -lJabyEngine
include $(JABY_ENGINE_DIR)/lib/Makefile
#Rules section for default compilation and linking
all: $(TARGET).psexe
clean:
rm -fr $(OUTPUT_DIR)
rm -fr ../iso/*.bin
rm -fr ../iso/*.cue

View File

@ -0,0 +1,3 @@
int main() {
return 0;
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<iso_project image_name="iso/#{ProjectName}.bin" cue_sheet="iso/#{ProjectName}.cue" no_xa="0">
<track type="data">
<identifiers
system = "PLAYSTATION"
application = "PLAYSTATION"
volume = "MYDISC"
volume_set = "MYDISC"
publisher = "JABY"
data_preparer = "MKPSXISO"
copyright = "COPYLEFT"
/>
<license file="D:/RetroGameDev/PSX/PSYQ/psyq/cdgen/LCNSFILE/LICENSEE.DAT"/>
<directory_tree>
<file name="SYSTEM.CNF" type="data" source="iso/System.cnf"/>
<file name="SCES_003.90" type="data" source="application/bin/PSX-release/#{ProjectName}.psexe"/>
</directory_tree>
</track>
</iso_project>