Homebrew Homebrew Development

  • Thread starter Thread starter aliak11
  • Start date Start date
  • Views Views 1,474,949
  • Replies Replies 6,048
  • Likes Likes 54
I really don't like SP3 way to handle the taskbar. I still prefer not running the (hypothetically fixed in SP3) emulator.
Sorry if it sounds a weird reason for you, but I have working methods and don't like newer windows one.

Maybe I can try it in VMWare.
 
OK; so I've successfully made a program that lets you use your 3DS as a wireless controller for Windows. It's like a much more basic version of Win2DS.

On the PC side, to simulate a key press I'm just using:

Code:
void simulateKeyNewpress(unsigned int key) {
    INPUT ip;
    ip.type = INPUT_KEYBOARD;
    ip.ki.wScan = mapVirtualKey(key);
    ip.ki.time = 0;
    ip.ki.dwExtraInfo = 0;
    ip.ki.wVk = 0;
    ip.ki.dwFlags = KEYEVENTF_SCANCODE;
    SendInput(1, &ip, sizeof(INPUT));
}

void simulateKeyRelease(unsigned int key) {
    INPUT ip;
    ip.type = INPUT_KEYBOARD;
    ip.ki.wScan = mapVirtualKey(key);
    ip.ki.time = 0;
    ip.ki.dwExtraInfo = 0;
    ip.ki.wVk = 0;
    ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
    SendInput(1, &ip, sizeof(INPUT));
}

Which sends a real keypress, as if you were to press it on your keyboard.

I'm wondering if anyone knows how I should deal with the circle pad. How do I simulate it like a joystick in Windows?

I found a nearly identical question here. But don't really understand, the answer is a bit vague.
 
  • Like
Reactions: st4rk and Idaho
Hi guys, so pretty much I am trying to figure out how to make it so when I press the R trigger or L trigger, it changes the colour of the text that I print called "colour" which changes colour depending on which number it's on. I am a super noob, and I am trying to use my sub-basic knowledge in Java to do this, so any help will be greatly appreciated. I am using https://gbatemp.net/threads/textstuff-for-homebrew-development-library.374887/ for the text. Also, if anyone could explain how to use the "o" as a cursor, that would be greatly appreciated. (for example, you hover over a certain area, it doesn't draw until you hold the "A" button, which then it print's "o"s over anywhere that the "o" has been) Hopefully that makes sense... there is also a video to elaborate. Only the first part of the video show's what I mean by a cursor, and the second part where it draws all over the second screen(due to some sort of glitch? lol) is what I am trying to accomplish.​


Code:
#include <3ds.h>
#include "memory.h"
 
 
int main()
{
    // Initialize services
    srvInit();
    aptInit();
    hidInit(NULL);
    gfxInit();
    //gfxSet3D(true); // uncomment if using stereoscopic 3D
    int x = 50;
    int y = 50;
    int R, G, B;
    int numColour = 1;
 
    char* a = "o";
 
    // Main loop
    while (aptMainLoop())
    {
        gspWaitForVBlank();
        hidScanInput();
   
   
        // Your code goes here
 
        u32 kDown = hidKeysDown();
        u32 kHeld = hidKeysHeld();
        if (kDown & KEY_START) break; // break in order to return to hbmenu
 
        // Example rendering code that displays some text
        // Please note that the 3DS screens are sideways (thus 240x400 and 240x320)
        u8* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
        memset(fb, 0, 240*400*3);
   
   
        if (kHeld & KEY_DUP){
            y++;
            //y++;
            //y++;
        }
        if (kHeld & KEY_DDOWN){
            y--;
            //y--;
            //y--;
        }
        if (kHeld & KEY_DRIGHT){
            x++;
            //x++;
            //x++;
        }
        if (kHeld & KEY_DLEFT){
            x--;
            //x--;
            //x--;
        }
        /*========numColour: 0 = White, 1 = Red, 2 = Blue, 3 = Green, 4 = Yellow======== +1*/
        if (kDown & KEY_R){ //Colours rotate right
            numColour++;
            if ((numColour = 6)){
                numColour = 1;
            }
        }
        if (kDown & KEY_L){ //Colours rotate left
            numColour--;
            if ((numColour = 0)){
                numColour = 5;
            }
        }
        if((numColour = 1)){ //White
            R = 255;
            G = 255;
            B = 255;
            paint_word(fb, "colour",/*x*/0,/*y*/230, R, G, B);
        }
        else if((numColour = 2)){ //Red
            R = 255;
            G = 0;
            B = 0;
            paint_word(fb, "colour",/*x*/0,/*y*/230, R, G, B);
        }
        else if((numColour = 3)){ //Blue
            R = 0;
            G = 0;
            B = 255;
            paint_word(fb, "colour",/*x*/0,/*y*/230, R, G, B);
        }
        else if((numColour = 4)){ //Green
            R = 0;
            G = 204;
            B = 0;
            paint_word(fb, "colour",/*x*/0,/*y*/230, R, G, B);
        }
        else if((numColour = 5)){ //Yellow
            R = 255;
            G = 255;
            B = 0;
            paint_word(fb, "colour",/*x*/0,/*y*/230, R, G, B);
        }
        paint_word(fb, a, x, y, 255, 255, 255);
        // Flush and swap framebuffers
        gfxFlushBuffers();
        gfxSwapBuffers();
    }
 
    // Exit services
    gfxExit();
    hidExit();
    aptExit();
    srvExit();
    return 0;
}
 
Hi guys, so pretty much I am trying to figure out how to make it so when I press the R trigger or L trigger, it changes the colour of the text that I print called "colour" which changes colour depending on which number it's on. I am a super noob, and I am trying to use my sub-basic knowledge in Java to do this, so any help will be greatly appreciated. I am using https://gbatemp.net/threads/textstuff-for-homebrew-development-library.374887/ for the text. Also, if anyone could explain how to use the "o" as a cursor, that would be greatly appreciated. (for example, you hover over a certain area, it doesn't draw until you hold the "A" button, which then it print's "o"s over anywhere that the "o" has been) Hopefully that makes sense... there is also a video to elaborate. Only the first part of the video show's what I mean by a cursor, and the second part where it draws all over the second screen(due to some sort of glitch? lol) is what I am trying to accomplish.


Code:
#include <3ds.h>
#include "memory.h"
 
 
int main()
{
    // Initialize services
    srvInit();
    aptInit();
    hidInit(NULL);
    gfxInit();
    //gfxSet3D(true); // uncomment if using stereoscopic 3D
    int x = 50;
    int y = 50;
    int R, G, B;
    int numColour = 1;
 
    char* a = "o";
 
    // Main loop
    while (aptMainLoop())
    {
        gspWaitForVBlank();
        hidScanInput();
 
 
        // Your code goes here
 
        u32 kDown = hidKeysDown();
        u32 kHeld = hidKeysHeld();
        if (kDown & KEY_START) break; // break in order to return to hbmenu
 
        // Example rendering code that displays some text
        // Please note that the 3DS screens are sideways (thus 240x400 and 240x320)
        u8* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
        memset(fb, 0, 240*400*3);
 
 
        if (kHeld & KEY_DUP){
            y++;
            //y++;
            //y++;
        }
        if (kHeld & KEY_DDOWN){
            y--;
            //y--;
            //y--;
        }
        if (kHeld & KEY_DRIGHT){
            x++;
            //x++;
            //x++;
        }
        if (kHeld & KEY_DLEFT){
            x--;
            //x--;
            //x--;
        }
        /*========numColour: 0 = White, 1 = Red, 2 = Blue, 3 = Green, 4 = Yellow======== +1*/
        if (kDown & KEY_R){ //Colours rotate right
            numColour++;
            if ((numColour = 6)){
                numColour = 1;
            }
        }
        if (kDown & KEY_L){ //Colours rotate left
            numColour--;
            if ((numColour = 0)){
                numColour = 5;
            }
        }
        if((numColour = 1)){ //White
            R = 255;
            G = 255;
            B = 255;
            paint_word(fb, "colour",/*x*/0,/*y*/230, R, G, B);
        }
        else if((numColour = 2)){ //Red
            R = 255;
            G = 0;
            B = 0;
            paint_word(fb, "colour",/*x*/0,/*y*/230, R, G, B);
        }
        else if((numColour = 3)){ //Blue
            R = 0;
            G = 0;
            B = 255;
            paint_word(fb, "colour",/*x*/0,/*y*/230, R, G, B);
        }
        else if((numColour = 4)){ //Green
            R = 0;
            G = 204;
            B = 0;
            paint_word(fb, "colour",/*x*/0,/*y*/230, R, G, B);
        }
        else if((numColour = 5)){ //Yellow
            R = 255;
            G = 255;
            B = 0;
            paint_word(fb, "colour",/*x*/0,/*y*/230, R, G, B);
        }
        paint_word(fb, a, x, y, 255, 255, 255);
        // Flush and swap framebuffers
        gfxFlushBuffers();
        gfxSwapBuffers();
    }
 
    // Exit services
    gfxExit();
    hidExit();
    aptExit();
    srvExit();
    return 0;
}



Here's your problem:
Code:
if((numColour = 1))
This assigns numColor to 1, it doesn't compare it. To compare it you need to use ==, ie if((numColour == 1)).
 
Hi guys, so pretty much I am trying to figure out how to make it so when I press the R trigger or L trigger, it changes the colour of the text that I print called "colour" which changes colour depending on which number it's on. I am a super noob, and I am trying to use my sub-basic knowledge in Java to do this, so any help will be greatly appreciated. I am using https://gbatemp.net/threads/textstuff-for-homebrew-development-library.374887/ for the text. Also, if anyone could explain how to use the "o" as a cursor, that would be greatly appreciated. (for example, you hover over a certain area, it doesn't draw until you hold the "A" button, which then it print's "o"s over anywhere that the "o" has been) Hopefully that makes sense... there is also a video to elaborate. Only the first part of the video show's what I mean by a cursor, and the second part where it draws all over the second screen(due to some sort of glitch? lol) is what I am trying to accomplish.

i got text to show up last night, the text kinda looks thick compared to the text in ftopny tho.
anyone see anything i'm doing wrong?
edit: also would be nice to add colors.

Code:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <3ds.h>
#include "text.h"
 
int drawFrameTop(){
    //display text
    gfxDrawText(GFX_TOP, GFX_LEFT, NULL, "top screen text", 120, 100);
    return 0;}
 
int drawFrameBottom(){
    //display text
    gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, "bottom screen text", 120, 100);
    return 0;}
 
int main(){
    // Initialize services
    srvInit();    aptInit();    hidInit(NULL);    gfxInit();
    gfxSet3D(true); // uncomment if using stereoscopic 3D
   
    // Main loop
    while (aptMainLoop()){
        hidScanInput();    u32 kDown = hidKeysDown();
        if(kDown & KEY_START)break; // break in order to return to hbmenu
   
        drawFrameTop();    drawFrameBottom();
   
        // Flush and swap framebuffers
        gfxFlushBuffers();    gfxSwapBuffers();    gspWaitForVBlank();
        }
 
    // Exit services
    gfxExit();    hidExit();    aptExit();    srvExit();
    return 0;
}
 
i got text to show up last night, the text kinda looks thick compared to the text in ftopny tho.
anyone see anything i'm doing wrong?
edit: also would be nice to add colors.

Code:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <3ds.h>
#include "text.h"
 
int drawFrameTop(){
    //display text
    gfxDrawText(GFX_TOP, GFX_LEFT, NULL, "top screen text", 120, 100);
    return 0;}
 
int drawFrameBottom(){
    //display text
    gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, "bottom screen text", 120, 100);
    return 0;}
 
int main(){
    // Initialize services
    srvInit();    aptInit();    hidInit(NULL);    gfxInit();
    gfxSet3D(true); // uncomment if using stereoscopic 3D
 
    // Main loop
    while (aptMainLoop()){
        hidScanInput();    u32 kDown = hidKeysDown();
        if(kDown & KEY_START)break; // break in order to return to hbmenu
 
        drawFrameTop();    drawFrameBottom();
 
        // Flush and swap framebuffers
        gfxFlushBuffers();    gfxSwapBuffers();    gspWaitForVBlank();
        }
 
    // Exit services
    gfxExit();    hidExit();    aptExit();    srvExit();
    return 0;
}

You need to clear the screens between frames, otherwise the alpha values (or whatever it is) will stack up on top of eachother and make it look thicker.
 
  • Like
Reactions: T3GZdev
how do i do that lol.

Do a for loop and write 0's to the entire top and bottom screen before you render to it. I believe some homebrew demos (including my own pong game) have some examples which you could look at. Although it's horribly inefficient how most things have it at the moment, but there's not much you can do about that without either doing it via ASM (which is plausible) or DMA (I don't think this is documented and/or even exists).
 
OK; so I've successfully made a program that lets you use your 3DS as a wireless controller for Windows. It's like a much more basic version of Win2DS.

On the PC side, to simulate a key press I'm just using:

Code:
void simulateKeyNewpress(unsigned int key) {
    INPUT ip;
    ip.type = INPUT_KEYBOARD;
    ip.ki.wScan = mapVirtualKey(key);
    ip.ki.time = 0;
    ip.ki.dwExtraInfo = 0;
    ip.ki.wVk = 0;
    ip.ki.dwFlags = KEYEVENTF_SCANCODE;
    SendInput(1, &ip, sizeof(INPUT));
}
 
void simulateKeyRelease(unsigned int key) {
    INPUT ip;
    ip.type = INPUT_KEYBOARD;
    ip.ki.wScan = mapVirtualKey(key);
    ip.ki.time = 0;
    ip.ki.dwExtraInfo = 0;
    ip.ki.wVk = 0;
    ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
    SendInput(1, &ip, sizeof(INPUT));
}

Which sends a real keypress, as if you were to press it on your keyboard.

I'm wondering if anyone knows how I should deal with the circle pad. How do I simulate it like a joystick in Windows?

I found a nearly identical question here. But don't really understand, the answer is a bit vague.

I'd normally say to get the partial acceleration values vs the digital ones, but I'm not sure if you can grab those with ctrulib at the moment since it only returns a 1 or 0 bit. So maybe implement it as a joystick for now and then if something comes up later you can implement it properly, or just make each direction it's own button.
 
Do a for loop and write 0's to the entire top and bottom screen before you render to it. I believe some homebrew demos (including my own pong game) have some examples which you could look at. Although it's horribly inefficient how most things have it at the moment, but there's not much you can do about that without either doing it via ASM (which is plausible) or DMA (I don't think this is documented and/or even exists).

thanks i fixed it by doing this.

Code:
int drawFrameTop(){   
    u8* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
        memset(fb, 0, 240*400*3);
       
        //display text
    gfxDrawText(GFX_TOP, GFX_LEFT, NULL, "top screen text", 120, 100);
    return 0;}
   
int drawFrameBottom(){
    u8* fb2 = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
        memset(fb2, 0, 240*320*3);
   
    //display text
    gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, "bottom screen text", 120, 100);
    return 0;}
 
Do a for loop and write 0's to the entire top and bottom screen before you render to it. I believe some homebrew demos (including my own pong game) have some examples which you could look at. Although it's horribly inefficient how most things have it at the moment, but there's not much you can do about that without either doing it via ASM (which is plausible) or DMA (I don't think this is documented and/or even exists).

wait you made Nitro Engine for DS? o.O
 
Er, no. I've done a few ROM hacks for Fire Red and I'm working on a full disassembly of the game, but no, I've never really touched DS homebrew. In fact, I never even had a DS flash cartridge, so 3DS homebrew is pretty neat for me.

lol thoght you were this guy. http://antoniond.drunkencoders.com/pong3ds.html.
i actually started doing pokemon fire red mods as well before doing ds/dsi homebrew.
 
has anyone gotten console text to show? like print, printf, sprint?
it seems there's no native text output system in the 3DS, or none we've heard of.
All homebrews displaying text currently do so using a bitmap font (they print each character as a 8x8 sprite, for example)
 
So recently I made a very very simple homebrew which is pretty much etch a sketch, that makes use of some sort of error because I didn't make a framebuffer for the bottom screen(I assume?) so that it draws lines with the letter that you move around with the dpad. I was wondering how I would go about drawing lines with this but without that error, so that I am able to draw on the top screen so that 3D is possible with the drawings :D. Here is some code, but from what I can tell everytime you move your cursor, it will follow it, is there someway, to literally PAINT it onto the screen and make it so it doesn't move.
Code:
if (kHeld & KEY_A){
            while(loop = true){
                int xDraw = x; //x is where the cursor is on the x-axis
                int yDraw = y; //y is where the cursor is on the y-axis
                paint_word(fb, "o", xDraw, yDraw, 255, 255, 255);
            }
        }
Here's an example of what I mean:
HXxEGck.png

Any help will be greatly be appreciated, also if what I was asking makes literally no sense, let me know.
I can show my entire source if that will help, just let me know. By the way I am using https://gbatemp.net/threads/textstuff-for-homebrew-development-library.374887/#post-5188904 for drawing the text.
 
  • Like
Reactions: Celice
is there a way (I mean already done by someone else's project) to fill portion of the screen with color based on 4 coordinates? making rectangles, but not with "pixel + height + width", more like 4 unaligned pixels.
Should I need to use the 3D engine with vertex? (it's only creating forms with triangles, not rectangles?)

Or do I need to coded it myself? maybe a scanline parser and filling matching pixels?

I didn't start anything yet, just reading and getting info on what I could do.
I never developed anything with 3D models, I would prefer to start with 2D.
 

Site & Scene News

Popular threads in this forum