Some newbie programming questions...

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Shanoul
Posts: 2
Joined: Mon Oct 17, 2005 12:26 am

Some newbie programming questions...

Post by Shanoul »

Hi guys... Just wandering on the forum... I'm a newbie here, and had a little programming experience in C++...
I now started to code somethin' for the psp but cannot get too far...
I installed the cygwin + dev c++ solution and the psp toolchain.
Ok, now i developed a little "star demo" where stars (i.e. random yellow pixels, but i feel poetic today) appear. When I push a key (i.e. X) it puts on pause mode (that is loops lookin for the right key to be pressed) and waits. Then it continues.
I took my infos from various sources downloaded from the net, and trying to understand somethin about the psp hardware.
I plan to release the little demo when it will be enough clear to me to add documentation to it and to make it understandable for all the ppl (or ehm... myself included)
Some questions so...

Please note that i took everything to work from demos, in particular a file called pg.h and pg.c (i.e. primitive graphic, think it is from pspsdk)

1- I had problems accessing the memcpy function... the truth is that i do not exactly remember how it does work. What i mean is this
<save the vram in the screen>
put the "PAUSE MODE" window on screen
<when the right key pressed, load the previous saved screen>
I did it using a cycle but it is not fast and quite ugly for a programmer to see in the code, so I looked for the memcpy function. Here's the prototype of the builtin funct, as far as i can remember it :
memcpy(void*, const void*, size_t)
ok so... I get the VRAM address with a pointer like this :

unsigned short* vram = (unsigned short*) pgGetVramAddr(0,0);

would like to make a memcpy on an allocated buffer. But it gives me errors on compatible types when i try to do it, doing a buf[VRAM_SIZE] or a *buf gives the same result

2- how to allocate dynamic memory? MK_FP does work? malloc and calloc?

3- how to use video ram swapping screens? I wanted to use the screenfilp function but cannot make it work properly...
First I set a screen with pgScreenFrame(1, 1);
then i want to write lines on a "swap page" and then copy it on the main VRAM. Anyone can help?

4- Are there any functions to change the palette like old codes for DOS demos? (I did something in the past with fractals and so on, but now I'm quite rusty, VB at work makes mind lazy!!!!)

Ok for now i think it is enough, thanks for the kindness and good day/night to you all.
Dario
Shanoul
Posts: 2
Joined: Mon Oct 17, 2005 12:26 am

Post by Shanoul »

No help at all? :(
Am I using the right tools or should I direct myself to other premade libraries?
I would not like to use LUA language, just to program the psp itself...
starman2049
Posts: 75
Joined: Mon Sep 19, 2005 5:41 am

Post by starman2049 »

I would start with the basic cube sample in the sdk at

samples\gu\cube

Complile it, make sure it runs then you can build from there. There are other samples too, but at the level you are at you should be able to have lots of fun just with that for now...

To answer some of your questions, malloc() works on the psp, and the cube example from above shows how to "flip pages"

Hope that helps...
weak
Posts: 114
Joined: Thu Jan 13, 2005 8:31 pm
Location: Vienna, Austria

Post by weak »

unsigned short* vram = (unsigned short*) pgGetVramAddr(0,0);
looks like something from nem's pre sdk code.

make sure to get the latest version of the toolchain and the sdk via svn. hint: wiki

then just take a look at the samples. you'll find nice libraries for gfx stuff aswell as standard c libs.
Post Reply