Code: Select all
/*
* vshmain.c
* vshmain
*
* Created by Zachry Thayer on 9/28/09.
* Copyright 2009 A_Nub. All rights reserved.
*
*/
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspidstorage.h>
#include <pspdisplay.h>
PSP_MODULE_INFO("VSH", 0x0000, 1, 1);
PSP_HEAP_SIZE_KB(0x00010000);
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)
#define BUF_WIDTH (512)
#define PIXEL_SIZE (4)
#define FRAME_SIZE (BUF_WIDTH * SCR_HEIGHT * PIXEL_SIZE)
unsigned int *vramTop = (unsigned int*)0x04000000;
void clearScreen(unsigned int col){
int y = 0,x = 0;
for(y = 0; y < SCR_HEIGHT; y++)
for(x = 0; x < SCR_WIDTH; x++){
vramTop[x + y * BUF_WIDTH] = col;
}
}
void putRect(int X, int Y, int W, int H, unsigned int col){
int y = 0,x = 0;
for(y = Y; y < Y + H; y++)
for(x = X; x < X + W; x++){
putPixel(x,y,col);
}
}
void putPixel(int x, int y, unsigned int col){
if(x < 0 || x > SCR_WIDTH) return;
if(y < 0 || y > SCR_HEIGHT) return;
vramTop[x + y * BUF_WIDTH] = col;
}
SceUID main_thread_uid;
int main_thread(SceSize args, void *argp){
sceDisplaySetFrameBuf(vramTop, BUF_WIDTH, PSP_DISPLAY_PIXEL_FORMAT_8888, PSP_DISPLAY_SETBUF_IMMEDIATE);
sceDisplaySetMode(0, SCR_WIDTH, SCR_HEIGHT);
while(1){
clearScreen(0xff00ff00);
putRect(10,10,100,100,0xffff0000);
sceKernelDelayThread(1);
}
return 0;
}
int module_start(SceSize args, void *argp){
main_thread_uid = sceKernelCreateThread("VSH_MAIN",main_thread, 32, 0x00010000, 0x4000, NULL);
if(main_thread_uid >= 0)
sceKernelStartThread(main_thread_uid, 0, NULL);
return 0;
}
int module_stop(SceSize args, void *argp){
sceKernelTerminateDeleteThread(main_thread_uid);
return 0;
}