PAlib Help

Discussion in 'NDS - ROM Hacking and Translations' started by ThomasWii, Mar 15, 2008.

Mar 15, 2008

PAlib Help by ThomasWii at 11:58 AM (1,954 Views / 0 Likes) 11 replies

  1. ThomasWii
    OP

    Member ThomasWii Member

    Joined:
    Mar 8, 2008
    Messages:
    34
    Location:
    England
    Country:
    United Kingdom
    Hi, just to let you know I'm new and dint know much, I have a problem with this code, I'm trying to make it so when i type "hi" into the palib keyboard, it Say's hello. I put in what it might be, build successful and when i run it, it dose not work! Here's the code CODE#include

    char text[200];


    int main()
    {
    ÂÂÂÂPA_Init();
    ÂÂÂÂPA_InitVBL();

    ÂÂÂÂPA_InitText(1, 0);
    ÂÂÂÂPA_InitKeyboard(2);
    ÂÂÂÂPA_KeyboardIn(20, 95);
    ÂÂÂÂs32 nletter = 0;
    ÂÂÂÂchar letter = 0;

    ÂÂÂÂwhile (1)
    ÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂletter = PA_CheckKeyboard();
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂif (letter > 31) {
    ÂÂÂÂÂÂÂÂÂÂÂÂtext[nletter] = letter;
    ÂÂÂÂÂÂÂÂÂÂÂÂnletter++;
    ÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂelse if(letter == PA_TAB){
    ÂÂÂÂÂÂÂÂÂÂÂÂu8 i;
    ÂÂÂÂÂÂÂÂÂÂÂÂfor (i = 0; i < 4; i++){
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂtext[nletter] = ' ';
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂnletter++;
    ÂÂÂÂÂÂÂÂÂÂÂÂ}
    ÂÂÂÂ
    ÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂelse if ((letter == PA_BACKSPACE)&&nletter) {
    ÂÂÂÂÂÂÂÂÂÂÂÂnletter--;
    ÂÂÂÂÂÂÂÂÂÂÂÂtext[nletter] = ' ';
    ÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂelse if (letter == '\n'){
    ÂÂÂÂÂÂÂÂÂÂÂÂif(text=="hi"){
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂPA_OutputSimpleText(1,1,10,"Hello!");
    ÂÂÂÂÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂPA_OutputText(1, 1, 1,"Text: %s",text);

    ÂÂÂÂÂÂÂÂPA_WaitForVBL();
    ÂÂÂÂ}
    ÂÂÂÂ
    ÂÂÂÂreturn 0;
    }

    Any help will be appreciated!

    Thanks in advance
    Thomas
     
  2. ThomasWii
    OP

    Member ThomasWii Member

    Joined:
    Mar 8, 2008
    Messages:
    34
    Location:
    England
    Country:
    United Kingdom
    Bump Come on guys i need help.

    Edit: And the palib website is down.
     
  3. ICEM4N

    Newcomer ICEM4N Newbie

    Joined:
    Feb 29, 2008
    Messages:
    4
    Country:
    if(text=="hi"){

    "text" isn't a String, is a vector (or array) of chars, You can not compare vectors or chars with strings.

    You may do

    if(text[0]=="h" && text[1]=="i") {


    But i thought PALib has a function like PA_CompareText or something similar.
     
  4. The Keeganator

    Newcomer The Keeganator Member

    Joined:
    Jul 4, 2007
    Messages:
    42
    Country:
    Australia
    Wrong. When you compile your code, it will do that for you.

    And ThomasWii, can you specify what actually happens when you load the game.
     
  5. ThomasWii
    OP

    Member ThomasWii Member

    Joined:
    Mar 8, 2008
    Messages:
    34
    Location:
    England
    Country:
    United Kingdom
    I run the game, and at the top it says "Text: " then i put in hi so it becomes "Text: hi" then press enter, and dose nothing.

    Thanks in advance.
    Thomas
     
  6. ThomasWii
    OP

    Member ThomasWii Member

    Joined:
    Mar 8, 2008
    Messages:
    34
    Location:
    England
    Country:
    United Kingdom
    bump, any more help?
     
  7. crazyshiza

    Member crazyshiza GBAtemp Regular

    Joined:
    Oct 18, 2006
    Messages:
    108
    Country:
    Why not post this at the PALib forums?
     
  8. Costello

    Administrator Costello Headmaster

    Joined:
    Oct 24, 2002
    Messages:
    12,030
  9. ThomasWii
    OP

    Member ThomasWii Member

    Joined:
    Mar 8, 2008
    Messages:
    34
    Location:
    England
    Country:
    United Kingdom
    palib site is down
     
  10. john_rampton1

    Newcomer john_rampton1 Newbie

    Joined:
    Oct 4, 2007
    Messages:
    2
    Country:
    United States
    change
    Code:
    if(text=="hi")
    to
    Code:
    if (strcmp(text,"hi")==0)
    that should fix it
     
  11. snakerdlk

    Newcomer snakerdlk Newbie

    Joined:
    Mar 13, 2008
    Messages:
    3
    Country:
    Brazil
    dont believe just one person here knows the strcmp function

    well...
    better would be to

    CODE#include

    at the top of the code

    and to use

    Code:
    if(!strcmp(text, "hi"))
    its more elegant and it should theoretically run faster...
     
  12. ThomasWii
    OP

    Member ThomasWii Member

    Joined:
    Mar 8, 2008
    Messages:
    34
    Location:
    England
    Country:
    United Kingdom
    after all this time i found out the main point why it was not coming up,
    Code:
    PA_OutputSimpleText(0,1,10,"Hello!");
    should have been
    Code:
    PA_OutputSimpleText(1,1,10,"Hello!");
    Thanks for all your help, got it fixed now [​IMG]
     

Share This Page