Orkie
Super Duper Mega GP Mania
I've started writing an application which will run purely on the 940 in the end (I was bored ) and I used the main.c/code.c layout and Makefile from Dzz's demo tutorials, with my own loader using rlyeh's minimal library. I have found my way around the registers so far, but writing to the screen seems to be more difficult.
CODE
#include <stdint.h>
#define mem2addr(a) (a-0x2000000)
unsigned short *memregs16;
uint16_t *screen, *fb0, *fb1;
void fb_flip(uint32_t fb_addr)
{
memregs16[0x290E>>1] = (uint16_t)(fb_addr & 0xffff);
memregs16[0x2910>>1] = (uint16_t)(fb_addr >> 16);
fb_addr += 640;
memregs16[0x2912>>1] = (uint16_t)(fb_addr & 0xffff);
memregs16[0x2914>>1] = (uint16_t)(fb_addr >> 16);
}
void flip() {
if(screen == fb0) fb_flip((uint32_t) fb1);
else fb_flip((uint32_t) fb0);
}
void vsync(void) {
while(memregs16[0x1182>>1]&(1<<4)); // waiting for V-sync
}
void Do940Stuff()
{
// Set up registers
memregs16 = (unsigned short*)mem2addr(0xC0000000);
fb0 = (uint16_t*)mem2addr(0x03101000);
fb1 = (uint16_t*)mem2addr(0x03381000);
screen = fb0;
memregs16[0x28DA>>1] = 0x004AB; // 16bpp, only region 1 activated
memregs16[0x290C>>1] = 640; // in 16bpp mode, this means width = 320
unsigned int loop;
while(1) {
vsync();
for(loop = 76800; loop--; ) {
screen[loop] = 0xF800;
}
flip();
}
}
This in code.c finally displays something (took me ages to get anything on-screen) but it looks like pink static. It *should* fill the screen in a solid red colour. Any ideas what I can do to fix this?
Here is a binary so you can see the problem for yourself: http://x11.gp2x.de/tempfiles/940ldr.zip
Thanks
CODE
#include <stdint.h>
#define mem2addr(a) (a-0x2000000)
unsigned short *memregs16;
uint16_t *screen, *fb0, *fb1;
void fb_flip(uint32_t fb_addr)
{
memregs16[0x290E>>1] = (uint16_t)(fb_addr & 0xffff);
memregs16[0x2910>>1] = (uint16_t)(fb_addr >> 16);
fb_addr += 640;
memregs16[0x2912>>1] = (uint16_t)(fb_addr & 0xffff);
memregs16[0x2914>>1] = (uint16_t)(fb_addr >> 16);
}
void flip() {
if(screen == fb0) fb_flip((uint32_t) fb1);
else fb_flip((uint32_t) fb0);
}
void vsync(void) {
while(memregs16[0x1182>>1]&(1<<4)); // waiting for V-sync
}
void Do940Stuff()
{
// Set up registers
memregs16 = (unsigned short*)mem2addr(0xC0000000);
fb0 = (uint16_t*)mem2addr(0x03101000);
fb1 = (uint16_t*)mem2addr(0x03381000);
screen = fb0;
memregs16[0x28DA>>1] = 0x004AB; // 16bpp, only region 1 activated
memregs16[0x290C>>1] = 640; // in 16bpp mode, this means width = 320
unsigned int loop;
while(1) {
vsync();
for(loop = 76800; loop--; ) {
screen[loop] = 0xF800;
}
flip();
}
}
This in code.c finally displays something (took me ages to get anything on-screen) but it looks like pink static. It *should* fill the screen in a solid red colour. Any ideas what I can do to fix this?
Here is a binary so you can see the problem for yourself: http://x11.gp2x.de/tempfiles/940ldr.zip
Thanks