|
| 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 | +} |
0 commit comments