Skip to content

Commit

Permalink
New Plugin: FrameTime Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
illusion0001 committed Jul 5, 2023
1 parent 9e937a6 commit 478d390
Show file tree
Hide file tree
Showing 4 changed files with 391 additions and 3 deletions.
13 changes: 12 additions & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Plugins allows you to customize your games like never before!

While we make every effort to deliver high quality products, we do not guarantee that our products are free from defects. Our software is provided **as is** and you use the software at your own risk.

# Getting Started
# Quick Start

- Load [GoldHEN 2.3](https://github.com/GoldHEN/GoldHEN/releases/latest) or newer on your PS4.
- Enable option to load plugins in Plugins Menu.
Expand Down Expand Up @@ -94,6 +94,17 @@ Author(s):

Removes framerate limit for games using system function `sceVideoOutSetFlipRate`.

### FrameTime Logger

Plugin filename: `frame_logger.prx`

Author(s):
- [illusion](https://github.com/illusion0001)

- Log frametime statistics.
- Press `L3 + L1 + Triangle` to start capturing data.
- Press `L3 + R3 + L1 + R1 + Square` to stop plugin.

### GamePad helper Plugin

Plugin filename: `gamepad_helper.prx`
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,22 @@ jobs:
echo "llvm_path=$RUNNER_TOOL_CACHE/llvm" >> $GITHUB_ENV
echo "OO_PS4_TOOLCHAIN=$GITHUB_WORKSPACE/OpenOrbis/PS4Toolchain" >> $GITHUB_ENV
echo "commit_ver=1.$(git rev-list HEAD --count)" >> $GITHUB_ENV
echo "toolchain_url=https://github.com/illusion0001/OpenOrbis-PS4-Toolchain/releases/download/0.0.1.481/toolchain.tar.gz" >> $GITHUB_ENV
- name: Cache OpenOrbis Toolchain
id: cache-oosdk
uses: actions/cache@v3
with:
path: ${{ env.OO_PS4_TOOLCHAIN }}
key: ${{ runner.os }}-oosdk
key: ${{ runner.os }}-oosdk-${{ env.toolchain_url }}

# temporary release until 0.53 is released
- name: Download OpenOrbis Toolchain
if: steps.cache-oosdk.outputs.cache-hit != 'true'
run: curl -sL https://github.com/illusion0001/OpenOrbis-PS4-Toolchain/releases/download/0.0.1.416/toolchain.tar.gz | tar xz -C ./
run: curl -sL ${{ env.toolchain_url }} | tar xz -C ./

- name: Temporary Pad definition update
run: wget https://raw.githubusercontent.com/OpenOrbis/OpenOrbis-PS4-Toolchain/master/include/orbis/Pad.h -O $OO_PS4_TOOLCHAIN/include/orbis/Pad.h

- name: Cache LLVM and Clang (${{ env.llvm_ver }})
id: cache-llvm
Expand Down
99 changes: 99 additions & 0 deletions plugin_src/frame_logger/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Library metadata.

DEBUG_FLAGS = -D__FINAL__=1
LOG_TYPE = -D__USE_PRINTF__
BUILD_TYPE = _final

ifeq ($(DEBUG),1)
DEBUG_FLAGS = -D__FINAL__=0
BUILD_TYPE = _debug
endif

TYPE := $(BUILD_TYPE)
FINAL := $(DEBUG_FLAGS)
BUILD_FOLDER := $(shell pwd)/../../bin/plugins
OUTPUT_PRX := $(shell basename $(CURDIR))
TARGET := $(BUILD_FOLDER)/prx$(TYPE)/$(OUTPUT_PRX)
TARGET_ELF := $(BUILD_FOLDER)/elf$(TYPE)/$(OUTPUT_PRX)
TARGETSTUB := $(OUTPUT_PRX).so

# Libraries linked into the ELF.
LIBS := -lSceLibcInternal -lSceGnmDriver -lScePad -lGoldHEN_Hook -lkernel -lSceSysmodule -lSceSystemService -lSceUserService

EXTRAFLAGS := $(DEBUG_FLAGS) $(LOG_TYPE) -fcolor-diagnostics -Wall

# You likely won't need to touch anything below this point.
# Root vars
TOOLCHAIN := $(OO_PS4_TOOLCHAIN)
GH_SDK := $(GOLDHEN_SDK)
PROJDIR := ../$(shell basename $(CURDIR))/source
INTDIR := ../$(shell basename $(CURDIR))/build
INCLUDEDIR := ../$(shell basename $(CURDIR))/include
COMMON_DIR := ../../common

# Define objects to build
CFILES := $(wildcard $(PROJDIR)/*.c)
CPPFILES := $(wildcard $(PROJDIR)/*.cpp)
COMMONFILES := $(wildcard $(COMMONDIR)/*.cpp)
OBJS := $(patsubst $(PROJDIR)/%.c, $(INTDIR)/%.o, $(CFILES)) $(patsubst $(PROJDIR)/%.cpp, $(INTDIR)/%.o, $(CPPFILES)) $(patsubst $(COMMONDIR)/%.cpp, $(INTDIR)/%.o, $(COMMONFILES))
STUBOBJS := $(patsubst $(PROJDIR)/%.c, $(INTDIR)/%.o, $(CFILES)) $(patsubst $(PROJDIR)/%.cpp, $(INTDIR)/%.o.stub, $(CPPFILES)) $(patsubst $(COMMONDIR)/%.cpp, $(INTDIR)/%.o.stub, $(COMMONFILES))

# Define final C/C++ flags
CFLAGS := $(FINAL) --target=x86_64-pc-freebsd12-elf -fPIC -funwind-tables -c $(EXTRAFLAGS) -isysroot $(TOOLCHAIN) -isystem $(TOOLCHAIN)/include -I$(GH_SDK)/include -I$(INCLUDEDIR) -I$(COMMON_DIR) $(O_FLAG)
CXXFLAGS := $(CFLAGS) -isystem $(TOOLCHAIN)/$(INCLUDEDIR)/c++/v1
LDFLAGS := -m elf_x86_64 -pie --script $(TOOLCHAIN)/link.x -e _init --eh-frame-hdr -L$(TOOLCHAIN)/lib -L$(GH_SDK) $(LIBS)

# Create the intermediate directory incase it doesn't already exist.
_unused := $(shell mkdir -p $(INTDIR))

# Check for linux vs macOS and account for clang/ld path
UNAME_S := $(shell uname -s)

ifeq ($(UNAME_S),Linux)
CC := clang
CCX := clang++
LD := ld.lld
CDIR := linux
endif
ifeq ($(UNAME_S),Darwin)
CC := /usr/local/opt/llvm/bin/clang
CCX := /usr/local/opt/llvm/bin/clang++
LD := /usr/local/opt/llvm/bin/ld.lld
CDIR := macos
endif

$(TARGET): $(INTDIR) $(OBJS)
$(LD) $(GH_SDK)/build/crtprx.o $(INTDIR)/*.o -o $(TARGET_ELF).elf $(LDFLAGS)
$(TOOLCHAIN)/bin/$(CDIR)/create-fself -in=$(TARGET_ELF).elf -out=$(TARGET_ELF).oelf --lib=$(TARGET).prx --paid 0x3800000000000011

$(TARGETSTUB): $(INTDIR) $(STUBOBJS)
$(CC) $(INTDIR)/*.o.stub -o $(TARGETSTUB) -target x86_64-pc-linux-gnu -shared -fuse-ld=lld -ffreestanding -nostdlib -fno-builtin -L$(TOOLCHAIN)/lib $(LIBS)

$(INTDIR)/%.o: $(PROJDIR)/%.c
$(CC) $(CFLAGS) -o $@ $<

$(INTDIR)/%.o: $(PROJDIR)/%.cpp
$(CCX) $(CXXFLAGS) -o $@ $<

$(INTDIR)/%.o.stub: $(PROJDIR)/%.c
$(CC) -target x86_64-pc-linux-gnu -ffreestanding -nostdlib -fno-builtin -fPIC $(O_FLAG) -s -c -o $@ $<

$(INTDIR)/%.o.stub: $(PROJDIR)/%.cpp
$(CCX) -target x86_64-pc-linux-gnu -ffreestanding -nostdlib -fno-builtin -fPIC $(O_FLAG) -s -c -o $@ $<

build-info:
$(shell echo "#define GIT_COMMIT \"$(shell git rev-parse HEAD)\"" > $(COMMON_DIR)/git_ver.h)
$(shell echo "#define GIT_VER \"$(shell git branch --show-current)\"" >> $(COMMON_DIR)/git_ver.h)
$(shell echo "#define GIT_NUM $(shell git rev-list HEAD --count)" >> $(COMMON_DIR)/git_ver.h)
$(shell echo "#define BUILD_DATE \"$(shell date '+%b %d %Y @ %T')\"" >> $(COMMON_DIR)/git_ver.h)

plugin_common:
$(CC) $(CFLAGS) -o $(INTDIR)/plugin_common.o $(COMMON_DIR)/plugin_common.c

.PHONY: clean
.DEFAULT_GOAL := all

all: build-info plugin_common $(TARGET)

clean:
rm -rf $(TARGET) $(TARGETSTUB) $(INTDIR) $(OBJS)
Loading

0 comments on commit 478d390

Please sign in to comment.