Code for a App I Can't Compile

Domslayer342

New Member
OP
Newbie
Joined
Apr 1, 2024
Messages
2
Trophies
0
Age
25
XP
10
Country
United States
Anyone want to try this code it might be bad but its a app to make the LED light do a lot more like change colors with the volume slider, flash and dim with the screen brightness ,flash when a game cart is inserted, flash when a app is launched, etc. If a real app dev is interested could try to look into it and finish for me I would appreciate it.




#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <3ds.h>
#include <citro2d.h>
#include <citro3d.h>
#include "guibase.h"
#include "guitheme.h"

#define PATCH_PATH "sdmc:/3ds/light_patch.bin"
#define PATCH_FILE "light_patch.bin"
#define PATCH_SIZE 0x1000

// Global variables
static bool isPatched = false;
static u8 patchData[PATCH_SIZE];

// Function prototypes
static int patchDevice(u8* patchData, size_t patchSize);
static int unpatchDevice(void);

// GUI callbacks
static void onPatchButton(uiButton* button, void* data);
static void onUnpatchButton(uiButton* button, void* data);

// Patch the device with the provided code
static int patchDevice(u8* patchData, size_t patchSize) {
// Open the patch file
FILE* patchFile = fopen(PATCH_FILE, "wb");
if (!patchFile) return -1;

// Write the patch data to the file
if (fwrite(patchData, patchSize, 1, patchFile) != 1) {
fclose(patchFile);
return -1;
}

fclose(patchFile);

// Write the patch file to the device
int ret = 0;
FILE* fp = fopen(PATCH_PATH, "wb");
if (fp) {
ret = fwrite(patchData, patchSize, 1, fp);
fclose(fp);
}

// Set the patch flag
isPatched = true;

return ret;
}

// Unpatch the device
static int unpatchDevice(void) {
// Remove the patch file
if (remove(PATCH_PATH) != 0) return -1;

// Clear the patch flag
isPatched = false;

return 0;
}

// Callback for the Patch button
static void onPatchButton(uiButton* button, void* data) {
// Read the patch data from the file
FILE* patchFile = fopen(PATCH_FILE, "rb");
if (!patchFile) {
printf("Error: Could not open patch file.\n");
return;
}

size_t patchSize = fread(patchData, 1, PATCH_SIZE, patchFile);
fclose(patchFile);

// Patch the device
if (patchDevice(patchData, patchSize) < 0) {
printf("Error: Failed to patch the device.\n");
} else {
printf("Success: Device patched.\n");
}
}

// Callback for the Unpatch button
static void onUnpatchButton(uiButton* button, void* data) {
// Unpatch the device
if (unpatchDevice() < 0) {
printf("Error: Failed to unpatch the device.\n");
} else {
printf("Success: Device unpatched.\n");
}
}

// Initialize the GUI
static int guiInit(void) {
// Initialize the Newlib GUI library
guiInit();

// Initialize the GUI theme
guiThemeInit();

// Set the GUI background color
C3D_FVB barrier;
C3D_FVUnmap(&barrier, GFX_TOP);
C3D_FVColor3f(1.0f, 1.0f, 1.0f);
C3D_FVFill(&barrier, 0.0f, 0.0f, 1.0f, 1.0f);
C3D_FVMap(&barrier, GFX_TOP);

// Create the GUI buttons
uiButton* patchButton = uiButton
Post automatically merged:

I'm not a big app maker but I can code but if its broke i couldn't test it my pc is dumb and won't compile or build.
 
  • Haha
Reactions: SylverReZ

AsadSolos

Member
Newcomer
Joined
Oct 3, 2022
Messages
5
Trophies
0
Location
Here
XP
58
Country
United States
Anyone want to try this code it might be bad but its a app to make the LED light do a lot more like change colors with the volume slider, flash and dim with the screen brightness ,flash when a game cart is inserted, flash when a app is launched, etc. If a real app dev is interested could try to look into it and finish for me I would appreciate it.




#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <3ds.h>
#include <citro2d.h>
#include <citro3d.h>
#include "guibase.h"
#include "guitheme.h"

#define PATCH_PATH "sdmc:/3ds/light_patch.bin"
#define PATCH_FILE "light_patch.bin"
#define PATCH_SIZE 0x1000

// Global variables
static bool isPatched = false;
static u8 patchData[PATCH_SIZE];

// Function prototypes
static int patchDevice(u8* patchData, size_t patchSize);
static int unpatchDevice(void);

// GUI callbacks
static void onPatchButton(uiButton* button, void* data);
static void onUnpatchButton(uiButton* button, void* data);

// Patch the device with the provided code
static int patchDevice(u8* patchData, size_t patchSize) {
// Open the patch file
FILE* patchFile = fopen(PATCH_FILE, "wb");
if (!patchFile) return -1;

// Write the patch data to the file
if (fwrite(patchData, patchSize, 1, patchFile) != 1) {
fclose(patchFile);
return -1;
}

fclose(patchFile);

// Write the patch file to the device
int ret = 0;
FILE* fp = fopen(PATCH_PATH, "wb");
if (fp) {
ret = fwrite(patchData, patchSize, 1, fp);
fclose(fp);
}

// Set the patch flag
isPatched = true;

return ret;
}

// Unpatch the device
static int unpatchDevice(void) {
// Remove the patch file
if (remove(PATCH_PATH) != 0) return -1;

// Clear the patch flag
isPatched = false;

return 0;
}

// Callback for the Patch button
static void onPatchButton(uiButton* button, void* data) {
// Read the patch data from the file
FILE* patchFile = fopen(PATCH_FILE, "rb");
if (!patchFile) {
printf("Error: Could not open patch file.\n");
return;
}

size_t patchSize = fread(patchData, 1, PATCH_SIZE, patchFile);
fclose(patchFile);

// Patch the device
if (patchDevice(patchData, patchSize) < 0) {
printf("Error: Failed to patch the device.\n");
} else {
printf("Success: Device patched.\n");
}
}

// Callback for the Unpatch button
static void onUnpatchButton(uiButton* button, void* data) {
// Unpatch the device
if (unpatchDevice() < 0) {
printf("Error: Failed to unpatch the device.\n");
} else {
printf("Success: Device unpatched.\n");
}
}

// Initialize the GUI
static int guiInit(void) {
// Initialize the Newlib GUI library
guiInit();

// Initialize the GUI theme
guiThemeInit();

// Set the GUI background color
C3D_FVB barrier;
C3D_FVUnmap(&barrier, GFX_TOP);
C3D_FVColor3f(1.0f, 1.0f, 1.0f);
C3D_FVFill(&barrier, 0.0f, 0.0f, 1.0f, 1.0f);
C3D_FVMap(&barrier, GFX_TOP);

// Create the GUI buttons
uiButton* patchButton = uiButton
Post automatically merged:

I'm not a big app maker but I can code but if its broke i couldn't test it my pc is dumb and won't compile or build.
Your code seems fine. I tried compiling it myself but I don't have guibase.h and guitheme.h. Could you please send those files over? The file locations should be in your main.d file if you've attempted to build but had some sort of error. I can send you a zip file over google drive of a basic template for how your folders that contain your code should be structured. Idk might help out. Also make sure you've cd'd into the folder where your program is stored. Also, if you had an error please send that as well. Hope that helps a little! :D
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • BigOnYa
  • BakerMan
    I rather enjoy a life of taking it easy. I haven't reached that life yet though.
  • K3Nv2 @ K3Nv2:
    He put it down when the 3ds came out
  • SylverReZ @ SylverReZ:
    @K3Nv2, RIP Felix does great videos on the PS3 yellow-light-of-death.
  • Jayro @ Jayro:
    Eventhough the New 3DS XL is more powerful, I still feel like the DS Lite was a more polished system. It's a real shame that it never got an XL variant keeping the GBA slot. You'd have to go on AliExpress and buy an ML shell to give a DS phat the unofficial "DS Lite" treatment, and that's the best we'll ever get I'm afraid.
    +1
  • Jayro @ Jayro:
    The phat model had amazingly loud speakers tho.
    +1
  • SylverReZ @ SylverReZ:
    @Jayro, I don't see whats so special about the DS ML, its just a DS lite in a phat shell. At least the phat model had louder speakers, whereas the lite has a much better screen.
    +1
  • SylverReZ @ SylverReZ:
    They probably said "Hey, why not we combine the two together and make a 'new' DS to sell".
  • Veho @ Veho:
    It's a DS Lite in a slightly bigger DS Lite shell.
    +1
  • Veho @ Veho:
    It's not a Nintendo / iQue official product, it's a 3rd party custom.
    +1
  • Veho @ Veho:
    Nothing special about it other than it's more comfortable than the Lite
    for people with beefy hands.
    +1
  • Jayro @ Jayro:
    I have yaoi anime hands, very lorge but slender.
  • Jayro @ Jayro:
    I'm Slenderman.
  • Veho @ Veho:
    I have hands.
  • BakerMan @ BakerMan:
    imagine not having hands, cringe
    +1
  • AncientBoi @ AncientBoi:
    ESPECIALLY for things I do to myself :sad:.. :tpi::rofl2: Or others :shy::blush::evil:
    +1
  • The Real Jdbye @ The Real Jdbye:
    @SylverReZ if you could find a v5 DS ML you would have the best of both worlds since the v5 units had the same backlight brightness levels as the DS Lite unlockable with flashme
  • The Real Jdbye @ The Real Jdbye:
    but that's a long shot
  • The Real Jdbye @ The Real Jdbye:
    i think only the red mario kart edition phat was v5
  • BigOnYa @ BigOnYa:
    A woman with no arms and no legs was sitting on a beach. A man comes along and the woman says, "I've never been hugged before." So the man feels bad and hugs her. She says "Well i've also never been kissed before." So he gives her a kiss on the cheek. She says "Well I've also never been fucked before." So the man picks her up, and throws her in the ocean and says "Now you're fucked."
    +1
  • BakerMan @ BakerMan:
    lmao
  • BakerMan @ BakerMan:
    anyways, we need to re-normalize physical media

    if i didn't want my games to be permanent, then i'd rent them
  • BigOnYa @ BigOnYa:
    Agreed, that why I try to buy all my games on disc, Xbox anyways.
    BigOnYa @ BigOnYa: Agreed, that why I try to buy all my games on disc, Xbox anyways.