Skip to content

Commit 5976d57

Browse files
committed
ready to have a lot of fun
1 parent 8fed8a2 commit 5976d57

12 files changed

Lines changed: 911 additions & 0 deletions

File tree

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.exe
2+
*.elf
3+
*.self
4+
*.pkg
5+
*.o
6+
*.a
7+
*.d
8+
.DS_Store
9+
._*

eboot_plugin/Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ifndef Ps4Sdk
2+
ifdef ps4sdk
3+
Ps4Sdk := $(ps4sdk)
4+
endif
5+
ifdef PS4SDK
6+
Ps4Sdk := $(PS4SDK)
7+
endif
8+
ifndef Ps4Sdk
9+
$(error Neither PS4SDK, Ps4Sdk nor ps4sdk set)
10+
endif
11+
endif
12+
13+
keepelf = True
14+
target ?= ps4_elf
15+
16+
#need to add this flags
17+
#-Wl,-T script.ld
18+
19+
###################################
20+
21+
Libraries := -lorbis2d -lorbisPad -lSceVideoOut_stub -lSceSystemService_stub -lSceUserService_stub -lSceGnmDriver_stub -lScePad_stub
22+
23+
include $(Ps4Sdk)/make/ps4sdk.mk
24+

eboot_plugin/script.ld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SECTIONS
2+
{
3+
. = 0x10000;
4+
.text : { *(.text) }
5+
. = 0x8000000;
6+
.data : { *(.data) }
7+
.bss : { *(.bss) }
8+
}

eboot_plugin/source/eboot_plugin.c

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
#include <kernel.h>
5+
#include <systemservice.h>
6+
#include <logdebug.h>
7+
#include <orbis2d.h>
8+
#include <orbisPad.h>
9+
10+
int x=1280/2;
11+
int y=720/2;
12+
int w=1280/64;
13+
int h=1280/64;
14+
int step=10;
15+
16+
17+
int64_t flipArg=0;
18+
int R,G,B;
19+
uint32_t color=0x80ff0000;
20+
int flag=1;
21+
22+
Orbis2dConfig *conf;
23+
24+
void updateController()
25+
{
26+
int ret;
27+
ret=orbisPadUpdate();
28+
if(ret==0)
29+
{
30+
31+
if(orbisPadGetButton(SCE_PAD_BUTTON_UP))
32+
{
33+
if(y-step>=0)
34+
{
35+
y=y-step;
36+
}
37+
else
38+
{
39+
y=0;
40+
}
41+
}
42+
if(orbisPadGetButton(SCE_PAD_BUTTON_DOWN))
43+
{
44+
if(y+step<conf->height-1)
45+
{
46+
y=y+step;
47+
}
48+
else
49+
{
50+
y=conf->height-1-step;
51+
}
52+
}
53+
if(orbisPadGetButton(SCE_PAD_BUTTON_RIGHT))
54+
{
55+
if(x+step<conf->width-1)
56+
{
57+
x=x+step;
58+
}
59+
else
60+
{
61+
x=conf->width-1-step;
62+
}
63+
}
64+
if(orbisPadGetButton(SCE_PAD_BUTTON_LEFT))
65+
{
66+
if(x-step>=0)
67+
{
68+
x=x-step;
69+
}
70+
else
71+
{
72+
x=0;
73+
}
74+
}
75+
if(orbisPadGetButton(SCE_PAD_BUTTON_TRIANGLE))
76+
{
77+
sys_log("Triangle pressed exit\n");
78+
79+
flag=0;
80+
81+
}
82+
if(orbisPadGetButton(SCE_PAD_BUTTON_CIRCLE))
83+
{
84+
sys_log("Circle pressed reset position and color red\n");
85+
x=1280/2;
86+
y=720/2;
87+
color=0x80ff0000;
88+
}
89+
if(orbisPadGetButton(SCE_PAD_BUTTON_CROSS))
90+
{
91+
sys_log("Cross pressed rand color\n");
92+
R=rand()%256;
93+
G=rand()%256;
94+
B=rand()%256;
95+
color=0x80000000|R<<16|G<<8|B;
96+
97+
}
98+
if(orbisPadGetButton(SCE_PAD_BUTTON_SQUARE))
99+
{
100+
sys_log("Square pressed\n");
101+
102+
}
103+
104+
}
105+
}
106+
int main(uint64_t stackbase, uint64_t othervalue)
107+
{
108+
int ret;
109+
110+
111+
//hide playroom splash
112+
sceSystemServiceHideSplashScreen();
113+
//init pad
114+
ret=orbisPadInit();
115+
116+
if(ret==1)
117+
{
118+
119+
ret=orbis2dInit();
120+
121+
if(ret==1)
122+
{
123+
conf=orbis2dGetConf();
124+
while(flag)
125+
{
126+
//capture pad data and populate positions
127+
// X random color
128+
// O reset to center position and red color
129+
// /\ to exit
130+
// dpad move rectangle
131+
updateController();
132+
133+
134+
//wait for current display buffer
135+
orbis2dStartDrawing();
136+
137+
// clear with background (default white) to the current display buffer
138+
orbis2dClearBuffer();
139+
140+
//default red is here press X to random color
141+
orbis2dDrawRectColor(x,w,y,h,color);
142+
143+
//flush and flip
144+
orbis2dFinishDrawing(flipArg);
145+
146+
//swap buffers
147+
orbis2dSwapBuffers();
148+
flipArg++;
149+
}
150+
151+
orbis2dFinish();
152+
orbisPadFinish();
153+
}
154+
155+
}
156+
157+
158+
159+
160+
exit(0);
161+
162+
return 0;
163+
}

liborbis2d/Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
ifndef Ps4Sdk
2+
ifdef ps4sdk
3+
Ps4Sdk := $(ps4sdk)
4+
endif
5+
ifdef PS4SDK
6+
Ps4Sdk := $(PS4SDK)
7+
endif
8+
ifndef Ps4Sdk
9+
$(error Neither PS4SDK, Ps4Sdk nor ps4sdk set)
10+
endif
11+
endif
12+
13+
target := ps4_lib
14+
OutPath := lib
15+
TargetFile := liborbis2d
16+
AllTarget = $(OutPath)/$(TargetFile).a
17+
18+
include $(Ps4Sdk)/make/ps4sdk.mk
19+
20+
21+
$(OutPath)/$(TargetFile).a: $(ObjectFiles)
22+
$(dirp)
23+
$(archive)
24+
25+
install:
26+
@cp $(OutPath)/$(TargetFile).a $(Ps4Sdk)/lib
27+
@cp include/orbis2d.h $(Ps4Sdk)/include
28+
@cp include/logdebug.h $(Ps4Sdk)/include
29+
@echo "Installed!"

liborbis2d/include/logdebug.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <stdint.h>
2+
3+
4+
uint64_t syscall2(uint64_t i_rdi, ...);
5+
#define sys_log(args...) {\
6+
char logbuf[400];\
7+
snprintf(logbuf, 400, args);\
8+
syscall2(308, 2, logbuf); \
9+
}
10+
__asm__("syscall2: \n\
11+
push %r10\n\
12+
push %r11\n\
13+
mov $0x93a4FFFF8, %r11\n\
14+
mov (%r11), %r11\n\
15+
mov %rcx, %r10\n\
16+
mov $0, %rax;\n\
17+
call *%r11\n\
18+
pop %r11\n\
19+
pop %r10\n\
20+
ret");
21+
22+

liborbis2d/include/orbis2d.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include <stdint.h>
2+
3+
#include <types/kernel.h>
4+
#include <types/videoout.h>
5+
6+
7+
#define ORBIS2D_DISPLAY_BUFFER_NUM 2
8+
#define ORBIS2D_FLIP_RATE 0 // 0 none 1 30fps 2 20fps
9+
#define ORBIS2D_FLIP_MODE SCE_VIDEO_OUT_FLIP_MODE_VSYNC
10+
11+
12+
#define ATTR_WIDTH 1280
13+
#define ATTR_HEIGHT 720
14+
15+
16+
17+
18+
typedef struct Orbis2dConfig
19+
{
20+
uint32_t bgColor;
21+
uint64_t videoMemStackAddr;
22+
uint32_t videoMemStackSize;
23+
uint64_t videoMemStackTopAddr;
24+
uint64_t videoMemStackBaseAddr;
25+
off_t videoMemOffset;
26+
int width;
27+
int pitch;
28+
int height;
29+
int pixelFormat;
30+
int bytesPerPixel;
31+
int tilingMode;
32+
void *surfaceAddr[ORBIS2D_DISPLAY_BUFFER_NUM];
33+
int64_t flipArgLog[ORBIS2D_DISPLAY_BUFFER_NUM];
34+
int flipMode;
35+
int flipRate;
36+
SceKernelEqueue flipQueue;
37+
int videoHandle;
38+
int currentBuffer;
39+
int orbis2d_initialized;
40+
41+
}Orbis2dConfig;
42+
43+
int orbis2dInit();
44+
void orbis2dFinish();
45+
int orbis2dInitWithConf(Orbis2dConfig *conf);
46+
int orbis2dSetConf(Orbis2dConfig *conf);
47+
int orbis2dCreateConf();
48+
Orbis2dConfig *orbis2dGetConf();
49+
void orbis2dSwapBuffers();
50+
void orbis2dClearBuffer();
51+
void orbis2dDrawRectColor(int x, int w, int y, int h, uint32_t color);
52+
void orbis2dWritePixelColor(int x, int y, uint32_t pixelColor);
53+
void orbis2dStartDrawing();
54+
void orbis2dFinishDrawing(int64_t flipArg);

0 commit comments

Comments
 (0)