Homebrew Beginner needing help

Discussion in 'NDS - Emulation and Homebrew' started by Jamstruth, Sep 27, 2009.

Sep 27, 2009
  1. Jamstruth
    OP

    Member Jamstruth Secondary Feline Anthropomorph

    Joined:
    Apr 23, 2009
    Messages:
    3,456
    Location:
    North East Scotland
    Country:
    United Kingdom
    Trying to learn how to code some simple applications for the DS (never used C++ or whatever language it is so a complete beginner) and have been following this simple tutorial here but am having a small bit of trouble.

    I have devkitarm etc. installed with programmers notepad and have written this code
    CODE// Video Start code

    videosetmode (mode_FB0);

    vramsetbankA(vram_a_lcd);

    // Shape Size variables

    static int shape_width = 10;
    static int shape+height = 10;

    //Drawing Shape Code
    void draw_shape(int x, int y, uint16* buffer, uint16 color)
    {
    buffer += y * screen_width + x;
    for (int i = 0; i < shape_height; ++i) {
    uint16* line = buffer + (screen_width * i);
    for(int j = 0; j < shape_width; ++j) {
    *line++ = color;
    }
    }
    }

    Which I believe is correct and will draw a simple square (although I have just realised there is no color code in there, can anyone tell me where to put it?) but I can't figure out how to compile and test this file in an emulator. It is saved as a...well windows just says "file" and has no "makefile" beside it to let me compile the bugger...help please?
     
  2. monkat

    Banned monkat I'd like to see you TRY to ban me. (Should I try?.

    Joined:
    May 21, 2009
    Messages:
    2,268
    Location:
    Virginia
    Country:
    United States
    Well yes I can help you!
    *----Gets Hopes Up----*

    Switch to using MicroLuaDS - it's much easier on beginners...
    but seriously, (even though the above was serious...), your first programming experience probably shouldn't be on the DS (or any gaming system for that matter)!
    Take baby steps! Every programmer had to go through hello world in their terminal - so do you!
    But glad to see another programmer amongst us [​IMG]
     
  3. Jamstruth
    OP

    Member Jamstruth Secondary Feline Anthropomorph

    Joined:
    Apr 23, 2009
    Messages:
    3,456
    Location:
    North East Scotland
    Country:
    United Kingdom
    Meh, I've done very simple programming in COMAL at school which is admittedly a lot less complex than C or even BASIC, will take some of the more complicated text files off my school account (could even lift the whole of COMAL onto my memory stick)

    MicroLUA DS does look a bit more simple than the coding I just wrote (and cannot compile). Can I safely assume that MicroLUA comes with a compiler for me to use? Also is PAlib any simpler than libDS (I think that's what I'm using, can't quite remember)
     
  4. DanTheManMS

    Member DanTheManMS aka Ricochet Otter

    Joined:
    Jun 2, 2007
    Messages:
    4,325
    Location:
    Georgia
    Country:
    United States
    Your best bet when starting a new project is to copy and paste the "Hello, World" example project entirely, which will include a makefile, and work based off the copy you made. This will ensure you have everything you need to compile.

    However, you've got a few slight flaws in your program. First off, yes you have a function to draw a rectangle, but you never call it. You have no "main" function, so there's no starting place for execution. The main function should start a while loop that never terminates, since a DS program never ends unless the power is cut. In this while loop, you should wait for vblank, then call your rectangle drawing function.

    Really just look into the Hello, World example to get a better idea of what I'm talking about. That one uses the text console, which you don't really need at this point, but you'll get the idea.
     

Share This Page