Join Us and become a Member for a Verified Badge to access private areas with the latest PS4 PKGs.
Status
Not open for further replies.

PSXHAX

Staff Member
Verified
Moderator
Following his recent announcement of PS4 code execution, PlayStation 4 developer CTurt shared a video demo on YouTube of PS4 Pong homebrew being wirelessly controlled by the Nintendo DS with details below.

Download: PS4-Pong-master.zip / PS4-Pong GIT

From the video caption: The game's core is native code, but the renderer is an HTML5 canvas since we can't use the video out library, and it is controlled wirelessly using a Nintendo DS since we can't use the official controller library. This proves that some basic homebrew is possible, using some drastic workarounds for the limitations that are present.

Some recent Tweets from CTurt:
  • Made a quick PS4 Pong homebrew game! Couldn't use the official controller, so I used a DS: youtu.be/aNqKyuTDbjE
  • Found a hacky way to render graphics in native code, using HTML5 canvas: https://github.com/CTurt/PS4-***/blob/master/examples/canvas/source/main.c
  • Probably not useful for actual development though.
PS4 Native Canvas Rendering
Code:
#include "ps4.h"

unsigned int *framebuffer = NULL;

void getFramebuffer(void) {
	struct memoryRegionInfo info;
	struct otherMemoryRegionInfo otherInfo;
	
	void *m = NULL;
	
	int i;
	for(i = 0; i < 16; i++) {
		// Find base of next mapping
		getOtherMemoryInfo(m, 1, &otherInfo);
		
		// Get more info about this mapping
		getMemoryInfo(otherInfo.base, &info);
		
		// Search mappings 14 and 15 if they are readable
		if((i == 14 || i == 15) && (info.flags & PROT_CPU_READ)) {
			framebuffer = info.base;
			
			// Search for the colour we filled the framebuffer with
			while(framebuffer < (unsigned int *)info.end) {
				if(
					framebuffer[0] == 0xffc2c2c2 &&
					framebuffer[1] == 0xffc2c2c2
				) break;
				
				framebuffer++;
			}
		}
		
		m = info.end;
	}
}

void *canvasRenderer(void *arg) {
	getFramebuffer();
	
	unsigned int colour = RED;
	
	while(1) {
		int x, y;
		for(x = 0; x < 160; x++) {
			for(y = 0; y < 144 + 16; y++) {
				framebuffer[x + y * 144] = colour;
				
				colour = ((colour + 1) & 0x00ffffff) | (0xff << 24);
			}
		}
	}
	
	return NULL;
}

int _main(void) {
	// Init and resolve libraries
	initPthread();
	
	
	// Create our canvas rendering thread
	ScePthread thread;
	scePthreadCreate(&thread, NULL, canvasRenderer, NULL, "canvasRenderer");
	
	
	// Let this thread get back to updating the JS engine
	return 0;
}
PS4-Pong

A native pong game on the PS4, rendered in an HTML5 canvas, and controlled wirelessly with a DS.
 
Status
Not open for further replies.
Back
Top