Show 40 post(s) from this thread on one page
• 03-16-2007, 08:05 PM
yaustar
Quote:

Originally Posted by Mr305
I meant real HandHeld books that are written specifically dealing with PSP development not Generic C/C++!

If you were good enough at generic C/C++ then you wouldn't need a 'real' book for PSP programming since you will be looking at White papers most of the time. There is no "real HandHeld books that are written specifically dealing with PSP development". The knowledge comes from White papers, a solid knowledge of C++, software design, base concepts such as math and networking and most of all, experience.

Thinking in C++ is a great C++ free ebook covering advanced aspects of the language. Effective C++ is a must read for every C++ programmer.

Quote:

Will try that code...

Code:

```float m; m= (rand() % 9)/10;```
Wouldn't this work in the same way?
Other ?n, I 've been seeing many 'f' s at the end of number lately... looking at PSP Gu tutorials! What are they used for?
No it won't, it will attempt to divide an int by an int which results in another int before casting (with a warning) to a float.

ie:
Code:

```rand() returns 4 4 % 9 = 4 4 / 10 = 0 (works with whole numbers only) type cast 0 to a float = 0.0f Therefore m = 0.0f```
My code
Code:

```rand() returns 4 4 % 9 = 4 type cast 4 to a float = 4.0f 4.0f / 10.0f = 0.4f Therefore m = 0.4f```
The 'f' at the end means that this literal value is a float, without the f, it is a double.
Code:

```1.0f // float (usually 32 bit) 1.0 // double (usually 64 bit)```
• 03-16-2007, 09:11 PM
SG57
The reason why floats are prefered over doubles is because the PSP emulates doubles in software, where as floats are done in hardware, resulting in faster processing while using floats (although you lose precision using floats over doubles). (please correct me if imwrong :o)
• 03-16-2007, 10:54 PM
Grimfate126
and you really cant tell the difference in precision unless you're using angle functions (atan/atan2 etc.) even then, its not too major.
• 03-17-2007, 05:25 AM
hallo007
Quote:

Originally Posted by xart
Files taken from the installation of the Universal PNG for Mac OS X
libpng.zip

1st Add this folder to you Xcode project

2nd
Code:

```#include "libpng/png.h" #include "libpng/pngconf.h"```
3rd Add to Project... the file libpng.a (this is an alias file that points to libpng12.a file)

Now you should be able to use the LoadPNG code that you use for the PSP for Mac OS X make testing png functions easer.
-= Double Post =-

I would use
Code:

```/* time example */ #include <stdio.h> #include <time.h> int main () {   time_t seconds;   seconds = time (NULL);   printf ("%ld hours since January 1, 1970", seconds/3600);     return 0; }```
Cross platform, makes testing code easer as you don't need a PSP
readup on time.h and you should be able to produce emulator functions for functions like sceRtcGetCurrentClockLoca lTime

isnt psptime easier to use:s?
• 03-17-2007, 06:09 AM
xart
May look easer but you can easly get the same value using time function, it is not that hard and you can then test your software on a computer instead of a PSP that can slow you down, as you can fully debug on computer.

any functions that can be done with generic C/C++ should be avoided.

even the sceIo stuff, best to create emulator functions for these so you can compile on any platform for easy debuging.

You never reinvent the wheel, after all would you write your own libpng, no you use the one from the png.org place

So most of these sce functions to me is a joke, we don't need them and they are to me a complete waste of my time.
• 03-17-2007, 06:31 AM
Bronx
I wouldn't say they are a waste. GU is much faster SDL or OpenGL. And if we have all the functions of the real PSP SDK, we would be using them in an instant ;)
• 03-17-2007, 06:41 AM
xart
i agree, not all are a waste of time, only the ones that realy serve no real advantage, eg sceIoOpen, fopen works fine for me, much rafer stick with fopen

Gu stuff is good, pitty SDL didn't have them, but that can easly be put right as i do emulator functions for these in SDL to keep my code portable.

I still have to now replace some raphic function in my graphics class to use GU stuff, made functions compatible so they can be easly be replace once code was running on all platforms

To all, my graphics classs will be open source to all.
including the effects class that gose with it, and transitions class

And to Bronx
How did the PNG work on your Intel Mac, did it show the image correct.
• 03-17-2007, 07:05 AM
Bronx
Did you not get my email? Hmmmm.

Anyways, the colors were distorted because of the endian issue. :p
If I could see where you made the convert to the PPC little(?) endian that would be great!
• 03-17-2007, 07:23 AM
xart
I made the conversion change at the end of the LoadPNG private methos of the graphics class, in the graphics.cpp file, it is at the end of LoadPNG just remove it and should work fine.

I am looking for a way of identifying what Mac platform a program runs on so the code can convert if run on PPC or not if Intel
• 03-17-2007, 07:38 AM
yaustar
This is a huge stab in the dark here given I can't test it:
Code:

```int checkEndianess = 2; checkEndianess = checkEndianess >> 1; if( 1 == checkEndianess ) {     // intel } else {     // PPC }```
• 03-17-2007, 07:48 AM
Mr305
Quote:

Originally Posted by Bronx
Anyways, the colors were distorted because of the endian issue. :p
If I could see where you made the convert to the PPC little(?) endian that would be great!

Would mind elaborating on that issue.. I experienced it once, trying to use swizzle_fast function from ps2dev, but gave up?

I donno about colors but image was showing up as distorted!
• 03-17-2007, 07:54 AM
xart
that would give 1 on both platforms, one way is what apple says and I thought of strait away but is sort of a hack that I don't whant is write a u32 value to file, read it back to detect platform in run time

#ifndef _PSP
if ((fp = fopen(filename, "rb")) == NULL) return;
fseek(fp,offset,SEEK_SET) ;
#endif

now it works
• 03-17-2007, 08:18 AM
yaustar
Try this which is what I found off the net:
Code:

```int checkEndianness = 1; char * pCheckEndianness = static_cast<char*>(&checkEndianness); if( 1 == (*pCheckEndianness) ) {         // Intel (little endian) } else {         // PPC (big endian) }```
• 03-17-2007, 08:46 AM
Bronx
I can't find where you do the endian conversion. I pretty sure it's in here:
Code:

```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] =  color;         }       }   }```
But I'm not sure exactly...
• 03-17-2007, 08:57 AM
xart
Improved Code so it is smaller and still easy to understand

Code:

```int checkEndian = 1;    if( 1 == *(char *)&checkEndian )   {       // Intel (little endian)   }   else   {       // PPC (big endian)   }```
• 03-17-2007, 09:04 AM
yaustar
Quote:

Originally Posted by xart
Corrected Code

Code:

```  int checkEndianness = 1;   char * pCheckEndianness = (char*)(&checkEndianness);     if( 1 == (*pCheckEndianness) )   {       // Intel (little endian)   }   else   {       // PPC (big endian)   }```

Yep, static_cast doesn't work. my bad (noob mistake):
Code:

```int checkEndianness = 1;     char * pCheckEndianness = reinterpret_cast<char*>(&checkEndianness);     if ( 1 == (*pCheckEndianness) )     {         // Intel (little endian)     }     else     {         // PPC (big endian)     }```
Corrected C++ code.
• 03-17-2007, 11:09 AM
Raphael
Shouldn't you rather cast an array of two bytes to an short and check that for value? I know endianess check like that:
Code:

```unsigned char endian[2] = { 0xFF, 0x00 }; if (*(unsigned short*)endian==0xFF00) {     //big endian (mac, etc.) } else {   // little endian (intel, etc.) }```
• 03-17-2007, 11:17 AM
xart
This works fine.
So see no point to use any other way and this is also nice and easy to follow.

Code:

```int checkEndian = 1;    if( 1 == *(char *)&checkEndian )   {       // Intel (little endian)   }   else   {       // PPC (big endian)   }```
You could be at it all day with differant ways, but I think this version is nice looking and simple to understand what this code dose.
• 03-17-2007, 11:32 AM
eldiablov
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 :Argh:
• 03-17-2007, 11:58 AM
xart
A method of using fixed point math to convert rgb to y (grayscale)
Code:

`y=((red*77)+(green*150)+(blue*29))>>8;`
use this code in a loop and your image will not dim as 76 been changed to 77 when converted from 0.299f to 8-bit 76 (0.299f*256)=76.544

and *256 is the same as int << 8
so wee need to >> 8 that is the same as int / 256 when completed the rest of the calculation, logical shift is quicker than * or /

but depend on your code if you can logical shift, as some cases you can only * or / as too many logical shift look complicated, hard to read and end up being no quicker if too many are being used.

for building zlib

cd zlib
make
make install

try the zlib I used

and you need

• 03-17-2007, 12:16 PM
yaustar
Quote:

Originally Posted by xart
This works fine.
So see no point to use any other way and this is also nice and easy to follow.

Code:

```int checkEndian = 1;    if( 1 == *(char *)&checkEndian )   {       // Intel (little endian)   }   else   {       // PPC (big endian)   }```
You could be at it all day with differant ways, but I think this version is nice looking and simple to understand what this code dose.

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.
• 03-17-2007, 12:30 PM
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
• 03-17-2007, 12:33 PM
Bronx
Xart, so how can I fix the endian issue?
• 03-17-2007, 12:33 PM
eldiablov
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
• 03-17-2007, 12:38 PM
xart
Quote:

Originally Posted by Bronx
Xart, so how can I fix the endian issue?

did you not get that last e-mail

I now have a much improved version,

Code:

```littleEndian = 1;       littleEndian=(1 == *reinterpret_cast<char*>(&littleEndian))?1:0;```
placed in the graphics class and moded this section of code
Code:

```// 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);         }       }   }```
so that bit on the end

#inndef _PSP ......
removed

so has the ABGRToRGBA function
• 03-17-2007, 12:45 PM
Insert_Witty_Name
Quote:

Originally Posted by eldiablov
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 :Argh:

You haven't set your paths correctly.
• 03-17-2007, 12:52 PM
Bronx
Doh! The email was in my sspam folder >.<
Quote:

Originally Posted by xart
did you not get that last e-mail

I now have a much improved version,

Code:

```littleEndian = 1;       littleEndian=(1 == *reinterpret_cast<char*>(&littleEndian))?1:0;```
placed in the graphics class and moded this section of code
Code:

```// 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);         }       }   }```
so that bit on the end

#inndef _PSP ......
removed

so has the ABGRToRGBA function

• 03-17-2007, 06:05 PM
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
• 03-17-2007, 06:23 PM
BlackShark
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?
• 03-18-2007, 02:22 AM
Dream_Team
Just install libmad, go on www.psp-programming.com , and in the tutorials they have a good howto for playing mp3s
Show 40 post(s) from this thread on one page