Fix module loading
[ps4-sdk.git] / examples / canvas / source / main.c
blob7df09022e2ab7006b0be14498a5af43f6d73fa50
1 #include "ps4.h"
3 unsigned int *framebuffer = NULL;
5 void getFramebuffer(void) {
6 struct memoryRegionInfo info;
7 struct otherMemoryRegionInfo otherInfo;
9 void *m = NULL;
11 int i;
12 for(i = 0; i < 16; i++) {
13 // Find base of next mapping
14 getOtherMemoryInfo(m, 1, &otherInfo);
16 // Get more info about this mapping
17 getMemoryInfo(otherInfo.base, &info);
19 // Search mappings 14 and 15 if they are readable
20 if((i == 14 || i == 15) && (info.flags & PROT_CPU_READ)) {
21 framebuffer = info.base;
23 // Search for the colour we filled the framebuffer with
24 while(framebuffer < (unsigned int *)info.end) {
25 if(
26 framebuffer[0] == 0xffc2c2c2 &&
27 framebuffer[1] == 0xffc2c2c2
28 ) break;
30 framebuffer++;
34 m = info.end;
38 void *canvasRenderer(void *arg) {
39 getFramebuffer();
41 unsigned int colour = RED;
43 while(1) {
44 int x, y;
45 for(x = 0; x < 160; x++) {
46 for(y = 0; y < 144 + 16; y++) {
47 framebuffer[x + y * 144] = colour;
49 colour = ((colour + 1) & 0x00ffffff) | (0xff << 24);
54 return NULL;
57 int _main(void) {
58 // Init and resolve libraries
59 initKernel();
61 initPthread();
64 // Create our canvas rendering thread
65 ScePthread thread;
66 scePthreadCreate(&thread, NULL, canvasRenderer, NULL, "canvasRenderer");
69 // Let this thread get back to updating the JS engine
70 return 0;