Wednesday, December 5, 2007

Fitz And Floyd Christmas China Retired

12) Discussion (text Debug)

I think we need a study on 'use of text debugging! Not all programmers want to use graphics, even at times there is not really needed and you can get something nice and cute even without using it. What we do is change the location in which to print and color the text of debugging! Ritenetelo a deepening of the first program "Hello World!", In the end it is always easy printing ...
remember that the "Hello World! print this written in a predetermined position using the predetermined color (white). From that source and use the same Makefile to compile.




To use these features we must add the library " pspdebug.h .



changed positions!

If you remember, we used the "pspDebugScreenPrintf (" Hello World! ")" To print text on the screen. And if we wanted to change the position of the writing?
Default is to put at the top left ...
Then we use the first function:



pspDebugScreenSetXY (int x, int y);



and set the value of x to move the text horizontally and vertically to move the y ( plus the value of x is higher and the message is moved to the right, plus the value of y is higher and the message is printed below, remember not to go too high or low otherwise die outside the visible screen ).
After setting the position, we use the classic function that this time the press in the position we have chosen:



pspDebugScreenPrintf ("Hello World!") ;





color the text!

Now let us have the color of the writing ...
For convenience we set a macro that transforms the color we give to the program in hexadecimal code (the same color coding that exists in the HTML). In short, we make sure that they can change color by increasing or decreasing value of the three primary colors on the PC (R G B, red ( Red), green (Green ), blue (Blue )).
Then in the code (before the function "main") write:


# define RGB (r, g, b) ((r) <<8)|((b)<<16))


pspDebugScreenSetTextColor (RGB (red, yellow, blue));


The values \u200b\u200bof "red", "yellow" and "blue" can range from 0 to 255. Remember that if all three values \u200b\u200bare set to 0 you will have the color black. If all 3 are set to 255 you will have the opposite, that is WHITE. Appropriately setting these three parameters can be obtained all the colors you want (staying in the 32-bit!) Now after setting the color we use the classic function to print, only this time we will print in color set:





pspDebugScreenPrintf ("Hello World!") ;



color the background of the text!



Now we color the text, but there is a 'latest gem to make a more colorful print! If you notice you can print in any color you want, but the background is always black! And if we want to color the background on which we print the text? In short, if you set the color black in writing, you see a bat! In fact the screen is black and white writing on black is not a smart thing, but if we want to write using the color black because we like? We can color the line under the word. What to do? I tell you!


First we must enable this option by writing:

pspDebugScreenEnableBackColor (1);





If we want to disable it, call it by passing the value 0 instead of 1.



After we set the color for that line (same argument as before to the colors):




pspDebugScreenSetBackColor ( RGB (red, yellow, blue)

)

Finally print the words:




pspDebugScreenPrintf ("Hello World!")
;






premise that these are just some of the prettiest that I seemed appropriate to report. In fact there are many to manage printing and debugging are all located in the library "
pspdebug.h
.

remind everyone that these three features can be used together! Just put them before printing the text!

I hope I was clear and helpful at all with this little time on her ' argument debug print ...

Difference Between Mexican And Regular Oregano

11) info function (Write to File)


The first function that will illustrate to write something on a file. We simply write letters numbers or symbols, that is what we can type keyboard.
This feature is in a library and then to use it we must include it in the source with the command:



# include pspiofilemgr.h
> < Going to order, we must have a file open to write something. First declare a variable " SceUID fd"
fd is a given name, a name you can put any work. To open a file we have to use a feature included in the same library:


SceUID sceIoOpen (const char * file, int flags, SceMode mode)


This function returns the value SceUID we open the file. It accepts 3 parameters:


const char * file , the full path of the file to open

  • int flags, the way in which to open the file ("
    O_RDONLY"
  • = read-only if we just read from that file or " O_WRONLY how it works but in doubt, do not ever go wrong by setting the value "0777". If I had to understand what good will post certainly 'more! If sceIoOpen report one 0, it means that the 'file open is not successful because of some error. to initialize fd So now, using this function, write this:
  • fd = sceIoOpen ("ms0: / file.txt",
O_RDONLY, 0777
)
Now fd "contains the 'address" file open and we can use this function with sceIoWrite that writes to a file.


This function returns an integer, the number of bytes written. As just one example ... byte corresponds to a symbol (including space), letter or number. Then the function is: int
sceIoWrite

(SceUID fd, const void * data, SceSize size); accepts 3 parameters: SceUID fd, fd is a variable called type SceUID. We say that this is stored the file open, to be able to do something. So before you call


sceIoWrite us ensure that they have opened a file and have created and initialized this variable. Obviously fd is a given name, then you can call whatever you want!




    const void * data, this pointer contains data to write. In our case we will write one or more characters. So you can call the function passed as an attribute letter or character string.
  • SceSize size, this is the size of what we write. I repeat that in the case of writing characters and strings, this value is equal to the number of characters including the space.
  • Finally, after writing our string we should close the file to save the whole. This we must do so with the function:
sceIoClose
(fd);
  • So we close the file and save it.
That's the theory. Now on to practice with a simple code that shows everything. Let's create a function that writes something on the file:



scrivo_su_file void (const char * file_path, const char * string) {


SceUID fd;


/ * are the I create the file does not exist (thanks to 'option PSP_O_CREAT

) * / fd =

sceIoOpen ( file_path

, PSP_O_WRONLY
sceIoWrite (fd, string, strlen (string));


sceIoClose (fd);}



To compile a source with this feature, you do not need any added to the Makefile , then you can use this very well:
TARGET = file1 OBJS = main.o CFLAGS =-O2-G0-Wall CXXFLAGS =
$ (CFLAGS)-fno-exceptions-fno- rtti
ASFLAGS = $ (CFLAGS)
EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = Input File Tutorial 1
PSPSDK = $ (shell / usr / local / pspdev / bin / psp-config - Pspsdk-path) include $
(PSPSDK) / lib / build.mak






You can test this function in your sources and how to best use it. There's nothing better than the 'direct experience ...




This tutorial is over, but to conclude that there is to say we can open the file in various ways. We have illustrated the simplest, which are read and write ...

Below is a list of all possible ways to open a file ("int flags") and I know I point out what they do:










PSP_O_RDONLY (Read Only)






PSP_O_WRONLY (WRITE ONLY)

PSP_O_RDWR (READ + WRITE)

PSP_O_NBLOCK


PSP_O_DIROPEN
  • PSP_O_APPEND (I open and write down the file)
  • PSP_O_CREAT (create files, or overwrite, and open it in WRITING)
  • PSP_O_TRUNC
  • PSP_O_EXCL
  • PSP_O_NOWAIT
  • I hope I was clear. For any errors or clarification is my email. I hope now that it has completed the basic "things" about the world of C programming on the PSP. From now introduce further information and / or explanations of the various libraries usable to do specific things.
  • Thanks to BigBoss, because I was inspired by his leadership to create this!

North Carolina Singlets

10) Info Functions (Introduction)

From now on, what I write is what I learned with 'experience thanks a friend who calls himself BigBoss. Up at first I merely translate and test something that was not mine. From now on I will describe the functions that can be embedded in your code. I will explain and comment on useful features as possible, without writing complete sources. So if you got this far you know more or less how to compose a source alone. I will help you only with the Makefile that contains the information to compile the code with new features. This file is something to be reckoned with ... watch out!
  • I hope I was clear ... BEGIN!