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 6, 2023
1 parent 9e937a6 commit e47575e
Show file tree
Hide file tree
Showing 4 changed files with 375 additions and 28 deletions.
14 changes: 13 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,18 @@ 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.
- Logs data to `/data/frame_logger/`.

### GamePad helper Plugin

Plugin filename: `gamepad_helper.prx`
Expand Down
41 changes: 14 additions & 27 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,10 @@ 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 "commit_hash=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV
- name: Cache OpenOrbis Toolchain
id: cache-oosdk
uses: actions/cache@v3
with:
path: ${{ env.OO_PS4_TOOLCHAIN }}
key: ${{ runner.os }}-oosdk

# 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 https://github.com/illusion0001/OpenOrbis-PS4-Toolchain/releases/latest/download/toolchain.tar.gz | tar xz -C ./

- name: Cache LLVM and Clang (${{ env.llvm_ver }})
id: cache-llvm
Expand Down Expand Up @@ -92,38 +84,36 @@ jobs:
- name: Build (Debug)
run: make DEBUG=1

- name: Push module artifact (Release prx)
- name: Upload modules (Release prx)
uses: actions/upload-artifact@v3
with:
name: goldplugins_${{ env.commit_ver }}_prx_final
path: bin/plugins/prx_final/*
name: goldplugins_${{ env.commit_ver }}-${{ env.commit_hash }}_prx_final
path: bin/plugins/prx_final/*.prx
if-no-files-found: error

- name: Push module artifact (Release elf)
- name: Upload modules (Release elf symbols)
uses: actions/upload-artifact@v3
with:
name: goldplugins_${{ env.commit_ver }}_elf_final
path: bin/plugins/elf_final/*.elf
if-no-files-found: error

- name: Push module artifact (Debug prx)
- name: Upload modules (Debug prx)
uses: actions/upload-artifact@v3
with:
name: goldplugins_${{ env.commit_ver }}_prx_debug
path: bin/plugins/prx_debug/*
name: goldplugins_${{ env.commit_ver }}-${{ env.commit_hash }}_prx_debug
path: bin/plugins/prx_debug/*.prx
if-no-files-found: error

- name: Push module artifact (Debug elf)
- name: Upload modules (Debug elf symbols)
uses: actions/upload-artifact@v3
with:
name: goldplugins_${{ env.commit_ver }}_elf_debug
name: goldplugins_${{ env.commit_ver }}-${{ env.commit_hash }}_elf_debug
path: bin/plugins/elf_debug/*.elf
if-no-files-found: error

- name: Prepare Release
if: |
github.event_name == 'workflow_dispatch' &&
github.repository == 'GoldHEN/GoldHEN_Plugins_Repository'
if: github.event_name == 'workflow_dispatch'
run: |
# Excluding non user related plugins from release
BUILD=plugins
Expand All @@ -150,8 +140,7 @@ jobs:
cat $BUILD/$BUILD_MD5
cat $BUILD/$BUILD_SHA256
# Create zip
commit_hash=$(echo ${GITHUB_SHA} | cut -c1-8)
ZIP_NAME=GoldPlugins-${{ env.commit_ver }}-$commit_hash
ZIP_NAME=GoldPlugins-${{ env.commit_ver }}-${{ env.commit_hash }}
CFG=plugins.ini
echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV
echo "; Note: lines starting with semicolon are for comments." > $CFG
Expand Down Expand Up @@ -180,9 +169,7 @@ jobs:
echo "</details>" >> hash.md
- name: Create Release
if: |
github.event_name == 'workflow_dispatch' &&
github.repository == 'GoldHEN/GoldHEN_Plugins_Repository'
if: github.event_name == 'workflow_dispatch'
working-directory: bin/plugins
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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 e47575e

Please sign in to comment.