#70982 - Red XIII - Thu Feb 09, 2006 9:26 pm
So...I'm only experimenting,but what's wrong with this code?
Code: |
#include <PA9.h>
int main()
{
int i = 0;
PA_Init();
PA_InitVBL();
PA_InitText(0,2);
while (!Stylus.Held)
{
PA_OutputSimpleText(0, 6,10, "Touch the screen...");
while (i < 120)
{
PA_WaitForVBL();
i++;
}
PA_OutputSimpleText(0, 4, 12, "...to see something...");
i=0;
while (i < 120)
{
PA_WaitForVBL();
i++;
}
PA_OutputSimpleText(0, 7, 14, "...really good!!");
PA_WaitForVBL();
}
PA_InitText(1,2);
PA_OutputSimpleText(1,1,1,"This is supposed to be the really good thing");
while(1)
{}
return 0;
} |
I can't get it to show the "This is supposed to be the really good thing" message at the upper screen,unless I erase the 2 PA_WaitForVBL(); inside both 2" delays. I'm trying stuff but nothing good comes out.Anyone?
Last edited by Red XIII on Sat Feb 11, 2006 12:36 am; edited 2 times in total
#71021 - SeanMon - Fri Feb 10, 2006 12:58 am
Can you see any text?
(BTW, you should move the int i=0; into main() because you aren't using it anywhere else. This has no effect on the text.)
_________________
null
#71113 - Red XIII - Fri Feb 10, 2006 12:34 pm
int i=0; moved into main.
What I see with the above code,are the 3 lines with 2" delay each,but the touch screen doesn't respond.
And what I see if I delete the 2 PA_WaitForVBL(); inside both 2" delays,is that the touch screen works,but of course the delays don't work (the 3 lines on the lower screen show up all together)
I know the code is very silly,but I'm learning,mind that! :D
P.S. Hmm, geocities won't let me upload my .nds files...?
#71126 - tepples - Fri Feb 10, 2006 2:56 pm
Red XIII wrote: |
P.S. Hmm, geocities won't let me upload my .nds
files...? |
Free hosting only allows a few file types. Use .zip for any other file type.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#71132 - SeanMon - Fri Feb 10, 2006 4:01 pm
I'm not sure how PA_lib works, but it seems that the touch-screen will only detect once about every 4 secs, so if your stylus isn't down then, it won't display the last text.
Try holding the stylus on the screen for 5 seconds and see if the last string displays.
#71133 - SeanMon - Fri Feb 10, 2006 4:04 pm
tepples(or any admin): shouldn't this topic be moved to DS Development?
_________________
null
#71180 - tepples - Fri Feb 10, 2006 9:04 pm
The admins appear to have left it wide open as to whether "Beginners" means "GBA Beginners" or "GBA/DS Beginners". Have them clarify it, and I'll move topics.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#71209 - Red XIII - Sat Feb 11, 2006 12:35 am
Indeed, SeanMon, you're almost right. With the code at the top of the page(edited),the 3 lines appear correctly,and finally the "This is supposed to be the really good thing" message appears,but only if I hold the stylus for about 1 second.
Strange,ain't?
#71612 - psycorpse - Mon Feb 13, 2006 7:23 pm
Red XIII wrote: |
So...I'm only experimenting,but what's wrong with this code?
Code: | #include <PA9.h>
int main()
{
int i = 0;
PA_Init();
PA_InitVBL();
PA_InitText(0,2);
while (!Stylus.Held)
{
PA_OutputSimpleText(0, 6,10, "Touch the screen...");
while (i < 120)
{
PA_WaitForVBL();
i++;
}
PA_OutputSimpleText(0, 4, 12, "...to see something...");
i=0;
while (i < 120)
{
PA_WaitForVBL();
i++;
}
PA_OutputSimpleText(0, 7, 14, "...really good!!");
PA_WaitForVBL();
}
PA_InitText(1,2);
PA_OutputSimpleText(1,1,1,"This is supposed to be the really good thing");
while(1)
{}
return 0;
} | I can't get it to show the "This is supposed to be the really good thing" message at the upper screen,unless I erase the 2 PA_WaitForVBL(); inside both 2" delays. I'm trying stuff but nothing good comes out.Anyone? |
Dont you need another PA_WaitForVBL(); after the PA_OutputSimpleText();? I am not 100% sure that this is correct but it seems that you have it after the others and those seem to work. Just my 2 cents/
#71687 - SeanMon - Tue Feb 14, 2006 12:35 am
Here's a fixed up version (untested, I haven't ever used PA_Lib!)
Code: |
#include <PA9.h>
int main()
{
int i = 0;
bool touched=false;
PA_Init();
PA_InitVBL();
PA_InitText(0,2);
PA_OutputSimpleText(0, 6,10, "Touch the screen...");
while(i < 120)
{ if(Stylus.Held)
touched=true;
PA_WaitForVBL();
i++;
}
PA_OutputSimpleText(0, 4, 12, "...to see something...");
i=0;
while(i < 120)
{ if(Stylus.Held)
touched=true;
PA_WaitForVBL();
i++;
}
PA_OutputSimpleText(0, 7, 14, "...really good!!");
while(!touched)
{ if(Stylus.Held)
touched=true;
PA_WaitForVBL();
}
PA_InitText(1,2);
PA_OutputSimpleText(1,1,1,"This is supposed to be the really good thing");
while(1)
{}
return 0;
}
|
I'm not sure if you want to wait until after you have output the first three strings to check for touchscreen input, but tell me if it works.
#71799 - Red XIII - Tue Feb 14, 2006 4:18 pm
Yup,this works alright.
It would be better if it could wait for the output of the first three strings before it checks for touchscreen input,but I'll figure it out myself,hopefully.
What do you use if you don't use PA_Lib? Does a 3rd library exist,except the official one and the PA_Lib? Or maybe you mean you are not in in DS yet,still coding for GBA?
Man,DS developing is the best thing ever.
#71874 - SeanMon - Wed Feb 15, 2006 1:24 am
Comment out the Code: |
if(Stylus.Held) touched=true; |
inside the two while(i<120) loops to wait until the first three strings have been output.
Red XIII wrote: |
What do you use if you don't use PA_Lib? Does a 3rd library exist, except the official one and the PA_Lib? |
I use libnds, on which PA_lib is based (I think, unless it is based on the older ndslib). This isn't the same as the official library (which is illegal to use and/or distribute without a license from Nintendo).
PA_lib hides much of the ugly direct-hardware access which libnds requires you to use. It allows you to get straight to the programming. But I have enjoyed the challenge of using libnds so for.