Simple C/C++ Q

Discussion in 'NDS - ROM Hacking and Translations' started by .::5pYd3r::., Aug 14, 2007.

  1. .::5pYd3r::.
    OP

    .::5pYd3r::. Viva La Pizza

    Member
    2
    Jun 2, 2007
    The GREAT Southern Land :D
    What did i do wrong in this code, i'm trying to make an app that when u press the A button it changes the colour of the top screen to a random colour
    CODE// PALib Template Application

    // Includes
    #include    // Include for PA_Lib
    u8 Colour1 = 31;
    u8 Colour2 = 31;
    u8 Colour3 = 31;
    u32 max = 31;

    int main()
    {
    ÂÂÂÂint i;

    ÂÂÂÂconsoleDemoInit();

    ÂÂÂÂvideoSetMode(MODE_FB0);

    ÂÂÂÂvramSetBankA(VRAM_A_LCD);

    ÂÂÂÂprintf("WELCOME TO SpYdEr's first DS app\n");

    ÂÂÂÂprintf("Press A to change colour of the top screen\n");

    ÂÂÂÂif (Pad.Newpress.Anykey)

    Âu32 Colour1 = PA_RandMax(max);
    ÂÂÂÂ
    ÂÂÂÂfor(i = 0; i < 256 * 192; i++)
    ÂVRAM_A = RGB15(Colour1,Colour2,Colour3);

    ÂÂÂÂreturn 0;
    }
     
  2. OrGoN3

    OrGoN3 GBAtemp Addict

    Member
    6
    Apr 23, 2007
    United States
    I've never programmed for the DS, so I'm not sure, but I see one thing odd about the program. You define a global u8 Colour1 = 31;. But then later on you set u32 Colour1 = PA_RandMax(max);. So now you have to variables with different types? I assume those are types (u8, u32), which is an illegal operation in C++.
     
  3. test84

    test84 GBAtemp's last ninja 2.

    Member
    3
    Sep 8, 2006
    Iran
    Iran, Tehran.
    would you tell us the error code or the malfunction too?
    it will be easier to debug that way.
     
  4. .::5pYd3r::.
    OP

    .::5pYd3r::. Viva La Pizza

    Member
    2
    Jun 2, 2007
    The GREAT Southern Land :D
    yeah i changed it but it still doesn't work [​IMG] , it looks like when i do Colour1 = PA_RandMax(31); it doesn't change the variable
     
  5. .::5pYd3r::.
    OP

    .::5pYd3r::. Viva La Pizza

    Member
    2
    Jun 2, 2007
    The GREAT Southern Land :D
    ok well the malfunction is that when i run it and push a button it doesn't change colour
     
  6. .::5pYd3r::.
    OP

    .::5pYd3r::. Viva La Pizza

    Member
    2
    Jun 2, 2007
    The GREAT Southern Land :D
    sorry for the triple post but here is the updated code and it still doesn't work
    CODE// PALib Template Application

    // Includes
    #include    // Include for PA_Lib
    u8 Colour1 = 31;
    u8 Colour2 = 31;
    u8 Colour3 = 31;

    int main()
    {
    ÂÂÂÂint i;

    ÂÂÂÂconsoleDemoInit();

    ÂÂÂÂvideoSetMode(MODE_FB0);

    ÂÂÂÂvramSetBankA(VRAM_A_LCD);

    ÂÂÂÂprintf("WELCOME TO SpYdEr's first DS app\n");

    ÂÂÂÂprintf("Press A to change colour of the top screen\n");

    ÂÂÂÂif(Pad.Newpress.Anykey)
    ÂÂÂÂ{ÂÂÂÂ
    ÂColour1 = PA_RandMax(31);
    ÂColour2 = PA_RandMax(31);
    ÂColour3 = PA_RandMax(31);
    ÂÂÂÂ}
    ÂÂÂÂfor(i = 0; i < 256 * 192; i++)
    ÂVRAM_A = RGB15(Colour1,Colour2,Colour3);

    ÂÂÂÂreturn 0;
    }
     
  7. BassAceGold

    BassAceGold Testicles

    Member
    4
    Aug 14, 2006
    Canada
    If your using palib, why don't you use some of its functions?
    CODE// PALib Template Application

    // Includes
    #include    // Include for PA_Lib
    u8 Colour1 = 31;
    u8 Colour2 = 31;
    u8 Colour3 = 31;

    int main()
    {

    PA_Init(); Â Â// Initializes PA_Lib
    PA_InitVBL();
    PA_InitRand();
    PA_Init16bitBg (1,3);
    int x;
    int y;

    printf("WELCOME TO SpYdEr's first DS app\n");


    printf("Press A to change colour of the top screen\n");

    while(1){

    if(Pad.Newpress.Anykey)
    {
    Colour1 = PA_RandMax(31);
    Colour2 = PA_RandMax(31);
    Colour3 = PA_RandMax(31);
    }
    for(x=0;x
     
  8. .::5pYd3r::.
    OP

    .::5pYd3r::. Viva La Pizza

    Member
    2
    Jun 2, 2007
    The GREAT Southern Land :D
    Thank You So much BassAceGold it works the only thing is that i don't know half of the stuff you put in and the text doesn't show on screen anymore but i can probably fix that by using PA_OutputSimpleText instead of printf
     
  9. BassAceGold

    BassAceGold Testicles

    Member
    4
    Aug 14, 2006
    Canada
    Yeah i forgot to change the text stuff (its 2 am now [​IMG]) and if you need information on what i did you can find it in the palib documentation Here. Tutorials can also be found Here if you need more info.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice