1. jimmyj

    jimmyj Official founder of altariaism. Copyright jimmyj
    Member

    Joined:
    May 26, 2017
    Messages:
    1,480
    Country:
    United Kingdom
    Do i need the sd sdk for the ds option to appear in visual studio?
     
  2. iProgramInCpp

    iProgramInCpp Newbie
    Newcomer

    Joined:
    Jun 29, 2018
    Messages:
    1
    Country:
    Japan
    Welp, I managed to get this far without Nightfox Lib. The program is pretty inefficient, but it allows graphics generation to some degree.
    Code:
    /*---------------------------------------------------------------------------------
    
        Simple console print demo which prints to bottom screen
        and also has a frame buffer for the top screen to which
        you can draw stuff
        -- iProgramMC - Graphics Engine
        -- dovoto - Console bottom screen print
    
    ---------------------------------------------------------------------------------*/
    #include <nds.h>
    #include <stdio.h>
    #include "drunkenlog2o.h" //include the face image
    #include "drunkenlogo.h" //include the face image
    
    
    PrintConsole bottomScreen;
    
    const char TileSize = 8; //8px wide
    
    short question_image[256];
    
    unsigned short rng;
    
    short sky_colour = 0xEEEF;
    
    uint32 global_timer = 0;
    
    char ticks = 0;
    
    unsigned short rng_function(unsigned short input){
        if(input == 0x560A) input=0;
        unsigned short S0 = (unsigned char)input<<8;
        S0 = S0 ^ input;
        input = ((S0 & 0xFF) << 8) | ((S0 & 0xFF00) >> 8);
        S0 = ((unsigned char)S0 << 1) ^ input;
        short S1 = (S0 >> 1) ^ 0xFF80;
        if((S0 & 1) == 0){
            if(S1 == 0xAA55){input = 0;}else{input=S1 ^ 0x1FF4;}
        }else{
            input = S1 ^ 0x1FF4;
        }
        return (unsigned short)input;
    }
    
    void rng_update() {
        rng = rng_function(global_timer);
    }
    
    void make_top_screen() {consoleSelect(&bottomScreen);}
    void make_btm_screen() {consoleSelect(&bottomScreen);}
    void clear_screen();
    void printchar(char x, char y, char c) { printf("\x1b[%d;%dH%c", y, x, c); }
    
    short screenbuffer_maindisplay[49152];
    short screen_width = 256;
    short screen_height = 192;
    
    void update_frame(){
        dmaCopy(&screenbuffer_maindisplay, BG_GFX, 49152*2);
    }
    
    void clear_screenbuffer(short colour){
        for(int x = 0; x < 49152; x+=1){
            screenbuffer_maindisplay[x] = colour;
        }
    }
    
    void draw_image(short* image, int w, int h, int dx, int dy){
        for(int y = 0; y < h; y++){
            for(int x = 0; x < w; x++){
                screenbuffer_maindisplay[(dy+y)*screen_width+(x+dx)] = image[y*w+x];
            }
        }
    }
    
    //---------------------------------------------------------------------------------
    int main(void) {
    //---------------------------------------------------------------------------------
        touchPosition touch;
    
     
     
        videoSetMode(MODE_5_2D);
        videoSetModeSub(MODE_0_2D);
    
        vramSetBankA(VRAM_A_MAIN_BG);
        vramSetBankC(VRAM_C_SUB_BG);
        decompress(drunkenlogoBitmap, &question_image,  LZ77);
    
        bgInit(2, BgType_Bmp16, BgSize_B16_256x256, 0,0);
     
        //consoleInit(&topScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, true, true);
        consoleInit(&bottomScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
    
        make_btm_screen();
        iprintf("\n\n\tGraphics Engine\n\tCoded by iProgramMC\n\tMore modern-like\n\tDo whatever you want!");
     
        clear_screenbuffer(0xEEEE);
    
        while(1) {
            clear_screenbuffer(sky_colour);
        
            global_timer++;
    
            if(global_timer % 60 == 30){
    
                //decompress(drunkenlogoBitmap, &screenbuffer_maindisplay,  LZ77);
            }
            if(global_timer % 1 == 0){
                rng = rng_function(8762);
                rng_update();
                iprintf("\x1b[0;0H%d", rng);
                draw_image(question_image, 16, 16, rng%(256-16), rng%(192-16));
            }
            update_frame();
            swiWaitForVBlank();
        }
    
        return 0;
    }
    
    
    
    

    The program within the spoiler renders a question block image to the top screen at a random position and enables console output on the bottom screen.

    I based off the 16bit_color_bmp and print_both_screens devkitPro examples, and used the Makefile from the 16bit_color_bmp image.

    Here's a built version if you want to try the example out:
    http(semicolon)//www(dot)mediafire(dot)com/file/ppzdzwwdiwqzxcm/DSGameEngine(dot)nds

    Used the question mark block bitmap from NSMB.

    And I didn't use VS! Used make to build.

    Beware of seizures though!
     
    Last edited: Jun 30, 2018
  3. mbj222

    mbj222 Newbie
    Newcomer

    Joined:
    Sep 28, 2018
    Messages:
    1
    Country:
    Italy
    Does anyone have the Drunken Coders' Wizard? Their site is closed.
     
    Sledgehogg likes this.
  4. MrMcTiller

    MrMcTiller GBATemp's Tiller
    Member

    Joined:
    Mar 7, 2017
    Messages:
    1,129
    Country:
    United States
    So... @Foxi4 , is all of this still relevant? Or are there more up-to-date tools? Also, where do we get the Drunken Coders wizard.
     
  5. jurassicplayer

    jurassicplayer Completionist Themer
    Member

    Joined:
    Mar 7, 2009
    Messages:
    4,427
    Country:
    United States
    Drunken Coders template is just a template for an old version of VS. You don't necessarily need it...especially if you aren't going to use VS anyways.
    Otherwise most of the rest is just common programming logic.
     
    MrMcTiller likes this.
  6. MrMcTiller

    MrMcTiller GBATemp's Tiller
    Member

    Joined:
    Mar 7, 2017
    Messages:
    1,129
    Country:
    United States
    So, when you install devkitPro's thing you get a code editor right?

    — Posts automatically merged - Please don't double post! —

    Programmer's Notepad right?
     
  7. jurassicplayer

    jurassicplayer Completionist Themer
    Member

    Joined:
    Mar 7, 2009
    Messages:
    4,427
    Country:
    United States
    No. Code editor can be whatever you want. If you wanted to, you could even use notepad...as awful as that would be. The only preferable thing would be to pick something that integrates well with C/C++.
     
    MrMcTiller likes this.
  8. MrMcTiller

    MrMcTiller GBATemp's Tiller
    Member

    Joined:
    Mar 7, 2017
    Messages:
    1,129
    Country:
    United States
    Oh, wait. I have Notepad++ that works right? After editing the code in Notepad++, I just use devkitPro's tools to compile it right?
     
  9. jurassicplayer

    jurassicplayer Completionist Themer
    Member

    Joined:
    Mar 7, 2009
    Messages:
    4,427
    Country:
    United States
    Notepad++ is fine. As for compiling, it's something like that, I guess.
     
    MrMcTiller likes this.
  10. Foxi4

    OP Foxi4 On the hunt...
    Supervisor

    Joined:
    Sep 13, 2009
    Messages:
    25,810
    Country:
    Poland
    All of this is perfectly relevant, however I'd download the PDF instead of relying on the posts because the code blocks got mangled when GBATemp transitioned to Xenforo and I never really fixed them. Other than that you should be able to compile functional DS software based on these tips.
     
  11. MrMcTiller

    MrMcTiller GBATemp's Tiller
    Member

    Joined:
    Mar 7, 2017
    Messages:
    1,129
    Country:
    United States
    The PDF doesn't seem to be complete.
     
  12. Foxi4

    OP Foxi4 On the hunt...
    Supervisor

    Joined:
    Sep 13, 2009
    Messages:
    25,810
    Country:
    Poland
    Whoops, you're right! Welp, you'll have to go through some debug. :P Usually it's just the spacing that got messed up, if you encounter any problems, post here! The general principles are still fine.
     
    MrMcTiller likes this.
  13. MrMcTiller

    MrMcTiller GBATemp's Tiller
    Member

    Joined:
    Mar 7, 2017
    Messages:
    1,129
    Country:
    United States
  14. Foxi4

    OP Foxi4 On the hunt...
    Supervisor

    Joined:
    Sep 13, 2009
    Messages:
    25,810
    Country:
    Poland
    Any particular reason why you're starting with DS and not 3DS or Switch? It's a bit of an older platform. Good for training, but don't pick up bad habits - don't get overly reliant on libraries.
     
    MrMcTiller likes this.
  15. MrMcTiller

    MrMcTiller GBATemp's Tiller
    Member

    Joined:
    Mar 7, 2017
    Messages:
    1,129
    Country:
    United States
    I want to start with 3ds homebrew... but I don't have a 3ds. I have a DS Lite and I am getting a flashcart.
     
  16. Foxi4

    OP Foxi4 On the hunt...
    Supervisor

    Joined:
    Sep 13, 2009
    Messages:
    25,810
    Country:
    Poland
    That's fair! Don't worry about the hardware, for now you can debug in an emulator, it's pretty convenient.
     
    MrMcTiller likes this.
  17. MrMcTiller

    MrMcTiller GBATemp's Tiller
    Member

    Joined:
    Mar 7, 2017
    Messages:
    1,129
    Country:
    United States
    You see, the thing is... I don't really have my own computer. I use a school windows PC, and I don't have admin privileges. I think I can still use devkitpro if I install it in %appdata%, but I am not 100% for sure. That said, I can't install Citra emulator or anything like that.


    EDIT: And, yes I know devkitPro is the organization name.
     
  18. MrMcTiller

    MrMcTiller GBATemp's Tiller
    Member

    Joined:
    Mar 7, 2017
    Messages:
    1,129
    Country:
    United States
    @Foxi4 , I am having a REALLY hard time getting the devkitpro's tools to work. I can open msys, but when I try to make something, it says I need to set environment variables.... but I don't have admin. Can you try to install this stuff without using admin please? (In order for me to even run the updater, I had to make a batch with this in it:

    cmd /min /C "set __COMPAT_LAYER=RUNASINVOKER && start "" "%1""
     
  19. Foxi4

    OP Foxi4 On the hunt...
    Supervisor

    Joined:
    Sep 13, 2009
    Messages:
    25,810
    Country:
    Poland
    There's no way to install devkitPro without access to an Admin account that I know of, correct compilation requires adding some PATHS to the OS which you won't be able to do without administrative privileges.
     
    MrMcTiller likes this.
  20. sonicvssilver22

    sonicvssilver22 You're myself, I'm yourself
    Member

    Joined:
    Aug 12, 2010
    Messages:
    145
    Country:
    United States
    Thanks for the guide! I'm currently taking a class in C# for college and I figure I'll use this as practice when the semester ends so I don't get rusty. Very interesting indeed! I'm not interested in developing anything but I think it would be fun to tinker around a bit.
     
Draft saved Draft deleted
Loading...

Hide similar threads Similar threads with keywords - Programming, Newbies,