The only thing I don't like about that code is that it is using a C style cast when you are using C++. Other then that, I don't see any problems with it.Zitat:
Zitat von xart
Printable View
The only thing I don't like about that code is that it is using a C style cast when you are using C++. Other then that, I don't see any problems with it.Zitat:
Zitat von xart
It makes code on Xcode more portable when switching from C to C++, as i may do a command line and use C for it.
Xcode auto switches from C to C++ based on the extension .c or .cpp and so I tend to keep my code C & C++ compatible and even use yes malloc in some cases, I love new & delete but then need to retype stuff for Xcode if using .c not .cpp
Xart, so how can I fix the endian issue?
im trying to compile zlib but it refuses to work. It says i dont have build.mak in the lib directory. Or something along them lines. Anyone have a solution ?
ok i have edited my cygwin.bat to try and get it to work but now it gives other errors. what's going on
did you not get that last e-mailZitat:
Zitat von Bronx
I now have a much improved version,
placed in the graphics class and moded this section of codeCode:littleEndian = 1;
littleEndian=(1 == *reinterpret_cast<char*>(&littleEndian))?1:0;
so that bit on the endCode:// New - Read the image, one line at a line (convert from little-endian to big-endian for PPC)
for (pass = 0; pass < number_passes; pass++) {
for (y = 0; y < (int)height; y++)
{
png_read_row(png_ptr, (u8*) line, png_bytep_NULL);
for (x = 0; x < (int)width; x++)
{
u32 color = *(line+x);
data[x + y * image->width] = (littleEndian==1)?color:(color>>24)|((color>>8)&0xFF00)|((color<<8)&0xFF0000)|(color<<24);
}
}
}
#inndef _PSP ......
removed
so has the ABGRToRGBA function
You haven't set your paths correctly.Zitat:
Zitat von eldiablov
Doh! The email was in my sspam folder >.<
Zitat:
Zitat von xart
Graphics C++ Class is getting to a stage were it can soon be hosted for downloading, I am hoping to do some liitle mods and vast improvments to the code as quick as possible and then will release it.
DAS support may or may not be ready when I release it.
DAS will allow you to safe guard any artwork that you don't whant others to easly take from your software.
please note that full protection is impossible, e.g
homebrew for PSP
But DAS will not make it easy.
It also will comes with Effect & Transition C++ Classes for doing stuff to loaded Pictures (PNG Images)
I am working on making it also fully compatible with graphics.h based code
This class requires SDL when compiling for Mac OS X, Linux or Tinker Toy platforms, woops ment Windows
mmm, Ok, I need a way to play Mp3's in a file browser, (using a file browser , press x on an mp3, it plays) Ill just use the File browser at the source depository at psp-programming.com, but does any body know how to use the mp3 function?
Just install libmad, go on www.psp-programming.com , and in the tutorials they have a good howto for playing mp3s
BlackShark - your askingvery specific questions which are actually very general.
All you'd do is (puesdo code):
Note, if you do not call MP3_Init, it will play the mp3 starting at the last time of the last one. AKA, say you listen to 1 mp3 for 20 seconds. If you stop, load a different one, and play it, it will play from 20 seconds.Code:if X is pressed then
if filebrowser[current_file].extension == "mp3" then
MP3_Init();
MP3_Load(filebrowser[current_file].path);
MP3_Play();
end
end
http://www.sendspace.com/file/w0e0s3
Those are the sorce files for my game,
I need help on making it work. Right now its just a menu,
TWO PROBLEMS WITH IT:
It used to compile, but now it wont,
and,
When the menu used to show up, the picture would freeze.
and, my compileing errors:
main.c: syntax error before ';' token.
main.c: syntax error before ';' token. (yes, twice)
MENU/MENU1.C: Syntax error before '}' token.
MENU/MENU2.C: Syntax error before '}' token.
MENU/MENU3.C: Syntax error before '}' token.
use spoilers to post your code , i dont go download it
one thing before I post my answer, I am not very good at C niether, but, should you be including your menu files like <MENU/Menu1.h> ? since these files are in your project folder wouldn't it be "MENU/Menu1.h" ? using "" instead of <>?
Well I made some fixes, but I didn't fix the above, so if that is whats wrong, dl this new zip and make those fixes to all of the <MENU/Menu#.h> in all of the files.
Zips are better than Rar's IMO :P
That doesnt really matter is you use "" or <>.Zitat:
Zitat von BlackShark
And yaustar helped me fix it, but now when I start the game, I (think) it freezes, so I cant go down on the menu.
Edit your right it doesnt
MrChaos - You have missing ';' at the end of 2 lines. Also, your missing 1 '}'. Finding and placing those in the correct places will fix your errors.
Those are the old sorce files, try looking at these:Zitat:
Zitat von SG57
http://www.sendspace.com/file/xltroj
Actually it does: http://en.wikipedia.org/wiki/Header_file
The reason why it appears to freeze is because your while loop looks like this:Zitat:
The syntax for including standard library and implementation-defined header files is:
User-defined header files are included with a slightly different syntax:Code:#include <name.h>
Code:#include "name.h"
This does SFA (sweet **** all) in terms of visuals. That's why it appears to freeze.Code:while (1)
{
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_DOWN)
{
if (MenuOption == 0)
{
MenuOption++;
}
sceDisplayWaitVblankStart();
}
if (pad.Buttons & PSP_CTRL_DOWN)
{
if (MenuOption == 1)
{
MenuOption++;
}
sceDisplayWaitVblankStart();
}
if (pad.Buttons & PSP_CTRL_DOWN)
{
if (MenuOption == 2)
{
MenuOption---;
}
sceDisplayWaitVblankStart();
}
if (pad.Buttons & PSP_CTRL_UP)
{
if (MenuOption == 0)
{
MenuOption+++;
}
sceDisplayWaitVblankStart();
}
if (pad.Buttons & PSP_CTRL_UP)
{
if (MenuOption == 1)
{
MenuOption--;
}
sceDisplayWaitVblankStart();
}
if (pad.Buttons & PSP_CTRL_UP)
{
if (MenuOption == 2)
{
MenuOption--;
}
sceDisplayWaitVblankStart();
}
}
So I fix by...?Zitat:
Zitat von yaustar
Zitat:
Zitat von MrChaos
my guess is to get rid of all of the
sceDisplayWaitVblankStart ();
and instead use the "oldpad" method.
Well, this still probably will work. But, try this....at least simplify your code and...fix it:Zitat:
Zitat von MrChaos
I don't know how to say this, but your menu code will not work the way you made it. You have to set up some variables, and then use those variables in your controls part. Let me give your a short explaination: look at my menu code. Read it, try to understand it, and if you need help, just PM me. Here is my menu code (btw, it has an mp3.....so make sure you have libmad):Code:while (1)
{
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons != lastpad.Buttons) {
lastpad = pad;
if (pad.Buttons & PSP_CTRL_DOWN)
{
if (MenuOption == 0)
{
MenuOption++;
}
if (MenuOption == 1)
{
MenuOption++;
}
if (MenuOption == 2)
{
MenuOption---;
}
}
if (pad.Buttons & PSP_CTRL_UP)
{
if (MenuOption == 0)
{
MenuOption+++;
}
if (MenuOption == 1)
{
MenuOption--;
}
if (MenuOption == 2)
{
MenuOption--;
}
}
}
Remember to make sure you have your callbacks in a seperate file named pspcallbacks.h. Make sure it is in "C:\CYGWIN\usr\local\pspd ev\psp\sdk\include". C being whatever hard drive you put CYGWIN. Anyways, here is my callback file:Code:#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include "graphics.h"
#include <pspdebug.h>
#include <pspaudio.h>
#include <pspaudiolib.h>
#include <psppower.h>
#include <pspcallbacks.h>
PSP_MODULE_INFO("SuperbatXS's Simple Menu", 0, 1, 1);
#include "mp3player.h"
#define RGB(r, g, b) ((r)|((g)<<8)|((b)<<16))
#define printf pspDebugScreenPrintf
//GLOBAL VARIABLES
int DifficultySetting = 1;
int main(void) {
scePowerSetClockFrequency(222, 222, 166);
SetupCallbacks();
initGraphics();
pspDebugScreenInit();
pspAudioInit();
SceCtrlData pad, lastpad;
sceCtrlReadBufferPositive(&lastpad, 1);
Image* Background;
Background = loadImage("./black.png");
Color EasyColor = RGB(0, 0, 0);
Color MediumColor = RGB(0, 0, 0);
Color HardColor = RGB(0, 0, 0);
int i;
MP3_Init(1);
MP3_Load("./../../MUSIC/test.mp3");
MP3_Play();
int OnStartGameMenu = 1;
int OnDifficultyMenu = 0;
extern int DifficultySetting;
while(1) {
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons != lastpad.Buttons) {
lastpad = pad;
if(pad.Buttons & PSP_CTRL_CROSS)
{
if (OnStartGameMenu == 1)
{
OnStartGameMenu = 0;
OnDifficultyMenu = 1;
DifficultySetting = 1;
}
else if (OnDifficultyMenu == 1)
{
//HERE'S WHERE WE WOULD START THE ACTUAL GAME
}
}
if(pad.Buttons & PSP_CTRL_CIRCLE)
{
if (OnDifficultyMenu == 1)
{
OnStartGameMenu = 1;
OnDifficultyMenu = 0;
}
}
if(pad.Buttons & PSP_CTRL_SQUARE) {
MP3_Pause();
for(i=0; i<10; i++) {
sceDisplayWaitVblankStart();
}
}
if (MP3_EndOfStream() == 1) {
MP3_Stop();
}
if(pad.Buttons & PSP_CTRL_TRIANGLE) {
sceKernelExitGame();
}
if(pad.Buttons & PSP_CTRL_UP)
{
if (OnDifficultyMenu == 1)
{
DifficultySetting--;
if (DifficultySetting < 1)
DifficultySetting = 1;
}
}
if(pad.Buttons & PSP_CTRL_DOWN)
{
if (OnDifficultyMenu == 1)
{
DifficultySetting++;
if (DifficultySetting > 3)
DifficultySetting = 3;
}
}
}
blitAlphaImageToScreen(0, 0 , 480, 272, Background, 0, 0);
if (OnStartGameMenu == 1)
{
printTextScreen(170, 140, "Start Game", RGB(191, 0, 0));
}
else if (OnDifficultyMenu == 1)
{
if (DifficultySetting == 1)
{
EasyColor = RGB(191, 0, 0);
MediumColor = RGB(0, 0, 0);
HardColor = RGB(0, 0, 0);
}
else if (DifficultySetting == 2)
{
EasyColor = RGB(0, 0, 0);
MediumColor = RGB(191, 0, 0);
HardColor = RGB(0, 0, 0);
}
else if (DifficultySetting == 3)
{
EasyColor = RGB(0, 0, 0);
MediumColor = RGB(0, 0, 0);
HardColor = RGB(191, 0, 0);
}
printTextScreen(170, 140, "Easy", EasyColor);
printTextScreen(170, 150, "Medium", MediumColor);
printTextScreen(170, 160, "Hard", HardColor);
}
sceDisplayWaitVblankStart();
flipScreen();
}
MP3_Stop();
MP3_FreeTune();
sceKernelSleepThread();
return 0;
}
Putting your callback in a separate file and including it in your program saves you time and space in your program. ;)Code:#include <malloc.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <stdio.h>
// Exit callback
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
// Callback thread
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
// Sets up the callback thread and returns its thread id
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
Neither of those solutions will 'fix' it, they still don't render anything in the loop. Keywords: Render and Loop.
Lol, yea. It's a completely different menu code. It's just a better menu code in my opinion. It's just some random stuff i put up there to give a general idea of what i learned about making menu's-simplicity.Zitat:
Zitat von yaustar
Im still learning in C. Keywords arnt helping me...Zitat:
Zitat von yaustar
A "how-to" would.
So did my "how-to" sort of help?Zitat:
Zitat von MrChaos
Not neccessarly, Im using pics for a menu..And no music for now either.Zitat:
Zitat von superbatxs
Oh. :( Well if you need help, i can help you. Right now i am making a shell in C, but the problem is that i don't know how to load .lua files in my shell. :(Zitat:
Zitat von MrChaos
Well whenever you can, I could appriecate some help.Zitat:
Zitat von superbatxs
(Good Luck on the Shell)
The while loop doesn't call anything to 'show'/blit/render/display any graphics/images/colours to the screen every frame/loop.Zitat:
Zitat von MrChaos
Oh I understand the problem now.Zitat:
Zitat von yaustar
Now to get to fixing it.
superbatxs, isnt that menu from insomniac's "How to make a full game tutorial".
I don't know who he is, but it is from psp-programming.com. I only showed that to show that i LEARNED the menu from psp-programming.com, and i wanted to show others the menu as well.Zitat:
Zitat von Moca
InsomniacPSP = Insomniac = Insomniac197 = Insert_Witty_NameZitat:
Zitat von superbatxs
Oh, well thanks for telling me.Zitat:
Zitat von Access_Denied
Maybe it would benefit him more if you linked to his tutorial where it explains each part thoroughly, than copy,paste and adapt to his variable names.
Anyways, quick question - qsort; is this a built in operator (like sizeof)?
Thank youZitat:
Zitat von SG57
This should be a simple question, how do you fade in and out of an image with C, can i do a method similar to Lua?
any clues?
No, it's a function of stdlibc to do a quicksort on an array of items.Zitat:
Zitat von SG57
hello back there,
could somehelp help me please: i've create an "theme" flasher and how can i add firwmare check, because sony added signature check for topmenu_plugin.rco at firmware 3.10 and i want to add topmenu flash option for my progam.. so how do I check wich firmware the user has?
(and would you please give an example of the code)
Greets Kwastie