Browse files

0.2.1

  • Loading branch information...
1 parent bbd5bf2 commit 9d58bf3585d924b2dec38481db4224fefc7b67af @wargio committed Oct 20, 2012
View
0 NoRSX_Example/COPYING.TXT 100755 → 100644
File mode changed.
View
0 NoRSX_Example/ICON0.PNG 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0 NoRSX_Example/Makefile 100755 → 100644
File mode changed.
View
0 NoRSX_Example/README.md 100755 → 100644
File mode changed.
View
0 NoRSX_Example/data/NoRSX_Image.png 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0 NoRSX_Example/data/Sans.ttf 100755 → 100644
File mode changed.
View
0 NoRSX_Example/pkgfiles/null 100755 → 100644
File mode changed.
View
82 NoRSX_Example/source/main.cpp 100755 → 100644
@@ -24,15 +24,18 @@
#include <time.h>
-//msgType MSG_OK = (msgType)(MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON);
+msgType MSG_OK = (msgType)(MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON);
s32 main(s32 argc, const char* argv[])
{
padInfo padinfo;
padData paddata;
-
ioPadInit(7);
+ int Bx=0;
+ int By=0;
+
+
pngData png;
NoRSX *GFX = new NoRSX(RESOLUTION_1920x1080); //set defined screen resolution You can change it to:
@@ -41,6 +44,7 @@ s32 main(s32 argc, const char* argv[])
Background BG(GFX);
Object OBJ(GFX);
Bitmap BMap(GFX);
+ MsgDialog Msg(GFX);
NoRSX_Bitmap Precalculated_Layer;
@@ -54,15 +58,15 @@ s32 main(s32 argc, const char* argv[])
IMG.LoadPNG_Buf(NoRSX_Image_png,NoRSX_Image_png_size, &png);
u32 imgX =(GFX->width/2)-(png.width/2), imgY = (GFX->height/2)-(png.height/2);
- BG.GradientBitmap(0xb4e83a,COLOR_RED,&Precalculated_Layer); //a green hex color (you can use hex colors insted of COLOR_XXXXXXX)
+ BG.MonoBitmap(0xb4e83a,&Precalculated_Layer); //a green hex color (you can use hex colors insted of COLOR_XXXXXXX)
- IMG.DrawIMGtoBitmap(imgX,imgY,&png,&Precalculated_Layer);
+// IMG.DrawIMGtoBitmap(imgX,imgY,&png,&Precalculated_Layer);
OBJ.CircleToBitmap(500,500,50,COLOR_YELLOW,&Precalculated_Layer);
F1.PrintfToBitmap(150,200,&Precalculated_Layer,COLOR_RED,"Screen %d x %d",GFX->width,GFX->height);
- F1.PrintfToBitmap(150,250,&Precalculated_Layer,COLOR_BLUE, 35,"Press X to exit!");
+ F1.PrintfToBitmap(150,250,&Precalculated_Layer,COLOR_BLUE, 35,"Press X to exit! (Start to skip Message Dialogs and exit)");
F2.PrintfToBitmap(150,300,&Precalculated_Layer,COLOR_GREEN,60,"FreeType2 with TTF support :)");
F3.PrintfToBitmap(150,500,&Precalculated_Layer,"Written by deroad");
@@ -79,18 +83,84 @@ s32 main(s32 argc, const char* argv[])
if(paddata.BTN_CROSS){
GFX->AppExit();
}
+ if(paddata.BTN_START){
+ GFX->AppExit();
+ goto end;
+ }
}
-
BMap.DrawBitmap(&Precalculated_Layer);
+ IMG.DrawIMG(imgX,imgY,&png);
F1.Printf(150,100,COLOR_RED,60,"FPS %f", fps);
GFX->Flip();
frame ++;
}
+ GFX->AppStart();
+ while(GFX->GetAppStatus()){
+ static time_t starttime = 0;
+ double fps = 0;
+ if (starttime == 0) starttime = time (NULL);
+ else fps = frame / difftime (time (NULL), starttime);
+ ioPadGetInfo(&padinfo);
+ if(padinfo.status[0]){
+ ioPadGetData(0, &paddata);
+ if(paddata.BTN_CROSS){
+ GFX->AppExit();
+ }
+ }
+ BG.Mono(0xb4e83a);
+ F1.Printf(150,100,COLOR_RED,60,"FPS %f", fps);
+
+ GFX->Flip();
+ frame ++;
+ }
+
+
//You need to clean the Bitmap before exit
BMap.ClearBitmap(&Precalculated_Layer);
+ Msg.TimerErrorDialog(0xdeadbeef, 5000.f);
+
+ Msg.TimerDialog(MSG_OK, "Timer Dialog!", 5000.f);
+ Msg.TimerErrorDialog(0xdeadbeef, 5000.f);
+
+
+ GFX->AppStart();
+ frame = 0;
+ Msg.SingleProgressBarDialog("Single progress bar!!", "Deroad Bar text");
+ while(GFX->GetAppStatus() && Bx<100){
+ Msg.ProgressBarDialogFlip();
+ frame ++;
+ if(frame%55==0){
+ Msg.SingleProgressBarDialogIncrease(10);
+ Bx+=10;
+ }
+ }
+ Msg.ProgressBarDialogAbort();
+
+
+ GFX->AppStart();
+ Msg.DoubleProgressBarDialog("Double progress bar!!", "Deroad Bar1 text", "Deroad Bar2 text");
+ Bx=0;
+ By=0;
+ while(GFX->GetAppStatus() && By<=100){
+ Msg.ProgressBarDialogFlip();
+ frame ++;
+ if(frame%55==0){
+ Bx+=10;
+ Msg.DoubleProgressBarDialogIncreaseFirstBar(10);
+ }
+
+ if(Bx>100){
+ Bx=0;
+ Msg.DoubleProgressBarDialogResetFirstBar();
+ Msg.DoubleProgressBarDialogIncreaseSecondBar(20);
+ By+=20;
+ }
+ }
+ Msg.ProgressBarDialogAbort();
+end:
GFX->NoRSX_Exit();
ioPadEnd();
return 0;
View
10 README.md
@@ -12,6 +12,16 @@ Authors
Changelog:
----------
+ - 0.2.1 -
+ Added new Message Dialog functions:
+ Single Progress Bar.
+ Double Progress Bar
+ Dialog with timer.
+ Error Dialog with timer.
+ Performance Patches for:
+ bitmap rendering.
+ image rendering.
+ Implemented print function. now is a class.
- 0.2.0 -
Text rendering improved with performance test
Fixed XMB Flip. Now is much more better.
View
18 libNoRSX/Animation.cpp
@@ -1,3 +1,21 @@
+/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ This program was created by Grazioli Giovanni Dante <wargio@libero.it>.
+
+*/
+
#include "Animation.h"
#include <stdio.h>
#include <stdint.h>
View
6 libNoRSX/Background.cpp
@@ -34,22 +34,22 @@ Background::Background(Minimum *g){
}
void Background::Mono(u32 Color){
- s32 size = G->buffers[G->currentBuffer].height * G->buffers[G->currentBuffer].width;
+ s32 size = G->height * G->width;
for(s32 i = 0; i < size; i++) {
G->buffers[G->currentBuffer].ptr[i] = Color;
}
}
void Background::MonoBitmap(u32 Color, NoRSX_Bitmap *a){
- s32 size = G->buffers[G->currentBuffer].height * G->buffers[G->currentBuffer].width;
+ s32 size = G->height * G->width;
for(s32 i = 0; i < size; i++) {
a->bitmap[i] = Color;
}
}
void Background::Gradient(u32 Color1, u32 Color2){ //G->buffers[G->currentBuffer].ptr[i]
- s32 size = G->buffers[G->currentBuffer].height * G->buffers[G->currentBuffer].width;
+ s32 size = G->height * G->width;
u8 Color_Red = R(Color2);
u8 Color_Blue = B(Color2);
u8 Color_Green = G(Color2);
View
14 libNoRSX/Bitmap.cpp
@@ -1,4 +1,3 @@
-
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,6 +17,7 @@
#include <NoRSX/Bitmap.h>
#include <NoRSX/NoRSXutil.h>
+
void Bitmap::GenerateBitmap(NoRSX_Bitmap *a){
a->bitmap = new uint32_t[G->width * G->height];
a->height = G->height;
@@ -44,25 +44,23 @@ void Bitmap::ClearBitmap(NoRSX_Bitmap *a){
void Bitmap::RegenBitmap(NoRSX_Bitmap *a){
if(a->load==1){
free(a->bitmap);
- a->bitmap = new uint32_t[(sizeof(u32) * G->width * G->height)];
+ a->bitmap = new uint32_t[(G->width * G->height)];
}else{
- a->bitmap = new uint32_t[(sizeof(u32) * G->width * G->height)];
+ a->bitmap = new uint32_t[(G->width * G->height)];
a->load = 1;
}
}
void Bitmap::DrawBitmap(NoRSX_Bitmap *a){
if(a->load==1){
- s32 size = G->buffers[G->currentBuffer].height * G->buffers[G->currentBuffer].width;
- for(s32 i = 0; i < size; i++) {
- G->buffers[G->currentBuffer].ptr[i] = a->bitmap[i];
- }
+ s32 size = G->height * G->width * sizeof(u32);
+ memcpy(G->buffers[G->currentBuffer].ptr,a->bitmap,size);
}
}
void Bitmap::DrawCustomBitmap(uint32_t start_width, uint32_t start_height, uint32_t end_width, uint32_t end_height, NoRSX_Bitmap *a){
if(a->load==1){
- s32 size = G->buffers[G->currentBuffer].height * G->buffers[G->currentBuffer].width;
+ s32 size = G->height * G->width;
u32 pos = start_height*a->width+start_width;
for(s32 i = 0; i < size; i++) {
G->buffers[G->currentBuffer].ptr[i] = a->bitmap[pos+i];
View
18 libNoRSX/EventHandler.cpp
@@ -1,3 +1,21 @@
+/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ This program was created by Grazioli Giovanni Dante <wargio@libero.it>.
+
+*/
+
#include <NoRSX/EventHandler.h>
int EventHandler::app_status, EventHandler::xmb_status;
View
18 libNoRSX/Font.cpp
@@ -1,3 +1,21 @@
+/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ This program was created by Grazioli Giovanni Dante <wargio@libero.it>.
+
+*/
+
#include <NoRSX/Font.h>
#define COLOR_TO_ARGB(alpha, red, green, blue) (((alpha) << 24) | ((red) << 16) | ((green) << 8) | (blue))
View
156 libNoRSX/Image.cpp
@@ -1,3 +1,21 @@
+/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ This program was created by Grazioli Giovanni Dante <wargio@libero.it>.
+
+*/
+
#include <NoRSX/Image.h>
void Image::LoadPNG(const char* filename, pngData *png){
@@ -21,22 +39,21 @@ void Image::DrawIMG(int x, int y, pngData *png1){
if(png1->bmp_out){
u32 *scr = (u32 *)G->buffers[G->currentBuffer].ptr;
u32 *png = (u32 *)(void *)png1->bmp_out;
- unsigned int n, m;
- scr += y*G->buffers[G->currentBuffer].width+x;
+ scr += y*G->width+x;
u32 height = png1->height;
- if((y+height) >= (u32)G->buffers[G->currentBuffer].height)
- height = G->buffers[G->currentBuffer].height;
+ if((y+height) >= (u32)G->height)
+ height = G->height;
u32 width = png1->width;
- if((x+width) >= (u32)G->buffers[G->currentBuffer].width)
- width = G->buffers[G->currentBuffer].width;
+ if((x+width) >= (u32)G->width)
+ width = G->width;
- for(n=0;n < (u32)height;n++){
- for(m=0;m < (u32)width;m++)
- scr[m]=png[m];
+ while(height>0){
+ memcpy(scr,png,width*sizeof(u32));
png+=png1->pitch>>2;
- scr+=G->buffers[G->currentBuffer].width;
+ scr+=G->width;
+ height--;
}
}
}
@@ -45,22 +62,21 @@ void Image::DrawIMG(int x, int y, jpgData *jpg1){
if(jpg1->bmp_out){
u32 *scr = (u32 *)G->buffers[G->currentBuffer].ptr;
u32 *jpg = (u32 *)(void *)jpg1->bmp_out;
- unsigned int n, m;
- scr += y*G->buffers[G->currentBuffer].width+x;
+ scr += y*G->width+x;
u32 height = jpg1->height;
- if((y+height) >= (u32)G->buffers[G->currentBuffer].height)
- height = G->buffers[G->currentBuffer].height;
+ if((y+height) >= (u32)G->height)
+ height = G->height;
u32 width = jpg1->width;
- if((x+width) >= (u32)G->buffers[G->currentBuffer].width)
- width = G->buffers[G->currentBuffer].width;
+ if((x+width) >= (u32)G->width)
+ width = G->width;
- for(n=0;n < (u32)height;n++){
- for(m=0;m < (u32)width;m++)
- scr[m]=jpg[m];
+ while(height>0){
+ memcpy(scr,jpg,width*sizeof(u32));
jpg+=jpg1->pitch>>2;
- scr+=G->buffers[G->currentBuffer].width;
+ scr+=G->width;
+ height--;
}
}
}
@@ -69,18 +85,18 @@ void Image::AlphaDrawIMG(int x, int y, pngData *png1){
if(png1->bmp_out){
u32 *scr = (u32 *)G->buffers[G->currentBuffer].ptr;
u32 *png = (u32 *)(void *)png1->bmp_out;
- unsigned int n, m;
+ unsigned int m;
- scr += y*G->buffers[G->currentBuffer].width+x;
+ scr += y*G->width+x;
u32 height = png1->height;
- if((y+height) >= (u32)G->buffers[G->currentBuffer].height)
- height = G->buffers[G->currentBuffer].height;
+ if((y+height) >= (u32)G->height)
+ height = G->height;
u32 width = png1->width;
- if((x+width) >= (u32)G->buffers[G->currentBuffer].width)
- width = G->buffers[G->currentBuffer].width;
+ if((x+width) >= (u32)G->width)
+ width = G->width;
- for(n=0;n < (u32)height;n++){
+ while(height>0){
for(m=0;m < (u32)width;m++){
unsigned int a = png[m] >> 24; // alpha
u32 OxFF_A = 0xff - a;
@@ -90,25 +106,9 @@ void Image::AlphaDrawIMG(int x, int y, pngData *png1){
(OxFF_A))) & 0x00ff0000)) >> 8);
}
png+=png1->pitch>>2;
- scr+=G->buffers[G->currentBuffer].width;
+ scr+=G->width;
+ height--;
}
-/*
- scr += y*G->buffers[G->currentBuffer].width+x;
- for(n=0;n<png1->height;n++){
- if((y+n)>=G->buffers[G->currentBuffer].height) break;
- for(m=0;m<png1->width;m++){
- if((x+m)>=G->buffers[G->currentBuffer].width) break;
- unsigned int a = png[m] >> 24; // alpha
- u32 OxFF_A = 0xff - a;
- if (0 != a)
- scr[m] = (png[m] & 0xff000000) | ( (((((png[m] & 0x00ff00ff) * a) + ((scr[m] & 0x00ff00ff) *
- (OxFF_A))) & 0xff00ff00) | ((((png[m] & 0x0000ff00) * a) + ((scr[m] & 0x0000ff00) *
- (OxFF_A))) & 0x00ff0000)) >> 8);
- }
- png+=png1->pitch>>2;
- scr+=G->buffers[G->currentBuffer].width;
- }
-*/
}
}
@@ -118,16 +118,16 @@ void Image::DrawPartialImage(int x, int y, unsigned int s_width, unsigned int s_
u32 *png = (u32 *)(void *)png1->bmp_out;
unsigned int n, m;
- scr += y*G->buffers[G->currentBuffer].width+x;
+ scr += y*G->width+x;
if(s_height>0) for(unsigned int i=0;i<s_height;i++) png+=png1->pitch>>2;
for(n=s_height;n<e_height+s_height;n++){
- if((y+n)>=(u32)G->buffers[G->currentBuffer].height) break;
+ if((y+n)>=(u32)G->height) break;
for(m=s_width;m<e_width+s_width;m++){
- if((x+m)>=(u32)G->buffers[G->currentBuffer].width) break;
+ if((x+m)>=(u32)G->width) break;
if(png[m]!=bg) scr[m-s_width]=color;
}
png+=png1->pitch>>2;
- scr+=G->buffers[G->currentBuffer].width;
+ scr+=G->width;
}
}
}
@@ -138,16 +138,16 @@ void Image::DrawPartialImage(int x, int y, unsigned int s_width, unsigned int s_
u32 *jpg = (u32 *)(void *)jpg1->bmp_out;
unsigned int n, m;
- scr += y*G->buffers[G->currentBuffer].width+x;
+ scr += y*G->width+x;
if(s_height>0) for(unsigned int i=0;i<s_height;i++) jpg+=jpg1->pitch>>2;
for(n=s_height;n<e_height+s_height;n++){
- if((y+n)>=(u32)G->buffers[G->currentBuffer].height) break;
+ if((y+n)>=(u32)G->height) break;
for(m=s_width;m<e_width+s_width;m++){
- if((x+m)>=(u32)G->buffers[G->currentBuffer].width) break;
+ if((x+m)>=(u32)G->width) break;
if(jpg[m]!=bg) scr[m-s_width]=color;
}
jpg+=jpg1->pitch>>2;
- scr+=G->buffers[G->currentBuffer].width;
+ scr+=G->width;
}
}
}
@@ -156,22 +156,21 @@ void Image::DrawIMGtoBitmap(int x, int y, pngData *png1, NoRSX_Bitmap *a){
if(png1->bmp_out){
u32 *scr = (u32 *)a->bitmap;
u32 *png = (u32 *)(void *)png1->bmp_out;
- unsigned int n, m;
- scr += y*G->buffers[G->currentBuffer].width+x;
+ scr += y*G->width+x;
u32 height = png1->height;
- if((y+height) >= (u32)G->buffers[G->currentBuffer].height)
- height = G->buffers[G->currentBuffer].height;
+ if((y+height) >= (u32)G->height)
+ height = G->height;
u32 width = png1->width;
- if((x+width) >= (u32)G->buffers[G->currentBuffer].width)
- width = G->buffers[G->currentBuffer].width;
+ if((x+width) >= (u32)G->width)
+ width = G->width;
- for(n=0;n < (u32)height;n++){
- for(m=0;m < (u32)width;m++)
- scr[m]=png[m];
+ while(height>0){
+ memcpy(scr,png,width*sizeof(u32));
png+=png1->pitch>>2;
- scr+=G->buffers[G->currentBuffer].width;
+ scr+=G->width;
+ height--;
}
}
}
@@ -181,22 +180,21 @@ void Image::DrawIMGtoBitmap(int x, int y, jpgData *jpg1, NoRSX_Bitmap *a){
if(jpg1->bmp_out){
u32 *scr = (u32 *)a->bitmap;
u32 *jpg = (u32 *)(void *)jpg1->bmp_out;
- unsigned int n, m;
- scr += y*G->buffers[G->currentBuffer].width+x;
+ scr += y*G->width+x;
u32 height = jpg1->height;
- if((y+height) >= (u32)G->buffers[G->currentBuffer].height)
- height = G->buffers[G->currentBuffer].height;
+ if((y+height) >= (u32)G->height)
+ height = G->height;
u32 width = jpg1->width;
- if((x+width) >= (u32)G->buffers[G->currentBuffer].width)
- width = G->buffers[G->currentBuffer].width;
+ if((x+width) >= (u32)G->width)
+ width = G->width;
- for(n=0;n < (u32)height;n++){
- for(m=0;m < (u32)width;m++)
- scr[m]=jpg[m];
+ while(height>0){
+ memcpy(scr,jpg,width*sizeof(u32));
jpg+=jpg1->pitch>>2;
- scr+=G->buffers[G->currentBuffer].width;
+ scr+=G->width;
+ height--;
}
}
}
@@ -208,14 +206,14 @@ void Image::AlphaDrawIMGtoBitmap(int x, int y, pngData *png1, NoRSX_Bitmap *a){
u32 *png= (u32 *)(void *)png1->bmp_out;
unsigned int n, m;
- scr += y*G->buffers[G->currentBuffer].width+x;
+ scr += y*G->width+x;
u32 height = png1->height;
- if((y+height) >= (u32)G->buffers[G->currentBuffer].height)
- height = G->buffers[G->currentBuffer].height;
+ if((y+height) >= (u32)G->height)
+ height = G->height;
u32 width = png1->width;
- if((x+width) >= (u32)G->buffers[G->currentBuffer].width)
- width = G->buffers[G->currentBuffer].width;
+ if((x+width) >= (u32)G->width)
+ width = G->width;
for(n=0;n < (u32)height;n++){
for(m=0;m < (u32)width;m++){
@@ -227,7 +225,7 @@ void Image::AlphaDrawIMGtoBitmap(int x, int y, pngData *png1, NoRSX_Bitmap *a){
(OxFF_A))) & 0x00ff0000)) >> 8);
}
png+=png1->pitch>>2;
- scr+=G->buffers[G->currentBuffer].width;
+ scr+=G->width;
}
}
}
View
18 libNoRSX/Min.cpp
@@ -1,3 +1,21 @@
+/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ This program was created by Grazioli Giovanni Dante <wargio@libero.it>.
+
+*/
+
#include <NoRSX/Min.h>
View
134 libNoRSX/Msg.cpp
@@ -1,7 +1,26 @@
+/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ This program was created by Grazioli Giovanni Dante <wargio@libero.it>.
+
+*/
+
#include <NoRSX/Msg.h>
static vs32 dialog_action = 0;
+static int i=0;
static void dialog_handler(msgButton button, void *usrdata){
dialog_action = button;
@@ -21,23 +40,128 @@ MsgDialog::~MsgDialog(){
sysUtilUnregisterCallback(SYSUTIL_EVENT_SLOT1);
}
+int MsgDialog::GetResponse(vs32 button){
+ if(dialog_action == button){
+ return 1;
+ }
+ return -1;
+}
+
void MsgDialog::Dialog(msgType md, const char *message){
msgDialogOpen2(md, message, dialog_handler, NULL, NULL);
+ i=0;
+ dialog_action = 0;
+ while(dialog_action == 0){
+ sysUtilCheckCallback();
+ flip(G->context, i);
+ waitFlip();
+ i = !i;
+ }
+ msgDialogAbort();
+}
+
+
+void MsgDialog::ErrorDialog(u32 errorCode){
+ msgDialogOpenErrorCode(errorCode,dialog_handler, NULL, NULL);
+
dialog_action = 0;
while(dialog_action == 0){
sysUtilCheckCallback();
- flip(G->context, 1);
+ flip(G->context, i);
+ waitFlip();
+ i = !i;
}
msgDialogAbort();
}
-int MsgDialog::GetResponse(vs32 button){
- if(dialog_action == button){
- return 1;
+void MsgDialog::TimerDialog(msgType md, const char *message, u32 Milliseconds){
+ msgDialogOpen2(md, message, dialog_handler, NULL, NULL);
+ msgDialogClose(Milliseconds);
+ i=0;
+ dialog_action = 0;
+ while(dialog_action == 0){
+ sysUtilCheckCallback();
+ flip(G->context, i);
+ waitFlip();
+ i = !i;
}
- return -1;
+
+ msgDialogAbort();
+}
+
+void MsgDialog::TimerErrorDialog(u32 errorCode, u32 Milliseconds){
+ msgDialogOpenErrorCode(errorCode,dialog_handler, NULL, NULL);
+ msgDialogClose(Milliseconds);
+ i=0;
+ dialog_action = 0;
+ while(dialog_action == 0){
+ sysUtilCheckCallback();
+ flip(G->context, i);
+ waitFlip();
+ i = !i;
+ }
+
+ msgDialogAbort();
+}
+
+void MsgDialog::SingleProgressBarDialog(const char *dialog_message, const char* bar_message){
+ msgDialogOpen2((msgType)(MSG_DIALOG_SINGLE_PROGRESSBAR | MSG_DIALOG_DISABLE_CANCEL_ON), dialog_message, dialog_handler, NULL, NULL);
+ msgDialogProgressBarSetMsg(MSG_PROGRESSBAR_INDEX0,bar_message);
+ msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX0);
+ msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX0,0);
+ i=0;
+}
+
+
+void MsgDialog::SingleProgressBarDialogIncrease(u32 percent){
+ msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX0,percent);
+}
+
+void MsgDialog::DoubleProgressBarDialog(const char *dialog_message, const char* bar1_message, const char* bar2_message){
+ msgDialogOpen2((msgType)(MSG_DIALOG_DOUBLE_PROGRESSBAR | MSG_DIALOG_DISABLE_CANCEL_ON), dialog_message, dialog_handler, NULL, NULL);
+ msgDialogProgressBarSetMsg(MSG_PROGRESSBAR_INDEX0,bar1_message);
+ msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX0);
+ msgDialogProgressBarSetMsg(MSG_PROGRESSBAR_INDEX1,bar2_message);
+ msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX1);
+ msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX0,0);
+ msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX1,0);
+ i=0;
+}
+
+void MsgDialog::SingleProgressBarDialogChangeMessage(const char* bar_message){
+ msgDialogProgressBarSetMsg(MSG_PROGRESSBAR_INDEX0,bar_message);
+}
+
+void MsgDialog::DoubleProgressBarDialogChangeMessageFirstBar(const char* bar_message){
+ msgDialogProgressBarSetMsg(MSG_PROGRESSBAR_INDEX0,bar_message);
+}
+
+void MsgDialog::DoubleProgressBarDialogChangeMessageSecondBar(const char* bar_message){
+ msgDialogProgressBarSetMsg(MSG_PROGRESSBAR_INDEX1,bar_message);
+}
+
+void MsgDialog::DoubleProgressBarDialogIncreaseFirstBar(u32 percent){
+ msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX0,percent);
}
+void MsgDialog::DoubleProgressBarDialogResetFirstBar(){
+ msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX0);
+}
+
+void MsgDialog::DoubleProgressBarDialogIncreaseSecondBar(u32 percent){
+ msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX1,percent);
+}
+
+void MsgDialog::ProgressBarDialogFlip(){
+ sysUtilCheckCallback();
+ flip(G->context, i);
+ waitFlip();
+ i = !i;
+}
+
+void MsgDialog::ProgressBarDialogAbort(){
+ msgDialogAbort();
+}
View
18 libNoRSX/NoRSX.cpp
@@ -1,6 +1,22 @@
-#include <NoRSX.h>
+/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ This program was created by Grazioli Giovanni Dante <wargio@libero.it>.
+*/
+#include <NoRSX.h>
static int already_done=0;
NoRSX::NoRSX() : EventHandler(){
View
5 libNoRSX/NoRSX/Min.h
@@ -17,11 +17,12 @@
#ifndef __NORSX_MIN_H__
#define __NORSX_MIN_H__
-#include <rsx/rsx.h>
#include <NoRSX/NoRSXutil.h>
#include <ppu-types.h>
-#include <io/pad.h>
#include <ppu_intrinsics.h>
+#include <cstring>
+
+
class Minimum{
public:
u16 width;
View
21 libNoRSX/NoRSX/Msg.h
@@ -27,8 +27,27 @@ class MsgDialog{
MsgDialog(Minimum *g);
~MsgDialog();
- void Dialog(msgType md, const char *message);
int GetResponse(vs32 button);
+ void Dialog(msgType md, const char *message);
+
+ void ErrorDialog(u32 errorCode);
+ void TimerDialog(msgType md, const char *message, u32 Milliseconds);
+ void TimerErrorDialog(u32 errorCode, u32 Milliseconds);
+
+ void SingleProgressBarDialog(const char *dialog_message, const char* bar_message);
+ void SingleProgressBarDialogIncrease(u32 percent);
+ void SingleProgressBarDialogChangeMessage(const char* bar_message);
+
+ void DoubleProgressBarDialog(const char *dialog_message, const char* bar1_message, const char* bar2_message);
+ void DoubleProgressBarDialogChangeMessageFirstBar(const char* bar_message);
+ void DoubleProgressBarDialogChangeMessageSecondBar(const char* bar_message);
+ void DoubleProgressBarDialogIncreaseFirstBar(u32 percent);
+ void DoubleProgressBarDialogResetFirstBar();
+ void DoubleProgressBarDialogIncreaseSecondBar(u32 percent);
+
+ void ProgressBarDialogFlip(); /*This is needed for both progress bar type*/
+ void ProgressBarDialogAbort(); /*This is needed for both progress bar type*/
+
protected:
Minimum *G;
};
View
15 libNoRSX/NoRSX/Printf.h
@@ -18,6 +18,8 @@
#ifndef __NORSX_PRINTF__
#define __NORSX_PRINTF__
+#include <fstream>
+
/*
*
* This will allow to write a debug message into a file
@@ -27,8 +29,13 @@
*
*/
-int init_print(const char* filename);
-int print(const char *a, ...);
-void end_print();
-
+class Printf{
+public:
+ Printf(const char* filename);
+ ~Printf();
+ int printf(const char *a, ...);
+protected:
+ std::fstream f;
+ int can_print;
+};
#endif
View
32 libNoRSX/Printf.cpp
@@ -1,31 +1,47 @@
+/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ This program was created by Grazioli Giovanni Dante <wargio@libero.it>.
+
+*/
+
+
#include <stdio.h>
#include <fstream>
#include <NoRSX/Printf.h>
#include <stdarg.h>
using namespace std;
-static fstream f;
-static int can_print = -1;
-int init_print(const char* filename){
+Printf::Printf(const char* filename){
f.open(filename,ios::out);
if(f.fail())
- return -1;
+ can_print =-1;
else
can_print = 0;
- return 1;
}
-int print(const char *a, ...){
+int Printf::printf(const char *a, ...){
char text[1024];
va_list va;
va_start(va, a);
vsnprintf(text, sizeof text, a, va);
- if(can_print==0)
+ if(can_print>0)
f << text;
return 1;
}
-void end_print(){
+Printf::~Printf(){
if(can_print==0)
f.close();
}

0 comments on commit 9d58bf3

Please sign in to comment.