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
59
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
  • Xdqwerty @ Xdqwerty:
    @a_username_that_isnt_cool, could you change your username?
  • Xdqwerty @ Xdqwerty:
    i guess not...
  • Xdqwerty @ Xdqwerty:
    yawn
  • Xdqwerty @ Xdqwerty:
    anybody here?
  • P @ PKNate:
    nope
  • BakerMan @ BakerMan:
    fun fact: 7 years by lukas graham, supermassive black hole by muse, and megalomania all have the same bpm
  • BakerMan @ BakerMan:
    girls just wanna have fun and renai circulation also share the same tempo as the few i said before
  • Xdqwerty @ Xdqwerty:
    @BakerMan, megalomania the live a live song?
  • BakerMan @ BakerMan:
    wait no, megalovania*
  • BakerMan @ BakerMan:
    my bad
  • K3Nv2 @ K3Nv2:
    I don't forgive you
  • BigOnYa @ BigOnYa:
    The nerve of that guy, gosh.
  • K3Nv2 @ K3Nv2:
    Yeah expecting me to forgive gtfo
  • Psionic Roshambo @ Psionic Roshambo:
    But how could the Dr have known you didn't want to be circumcized?
  • K3Nv2 @ K3Nv2:
    He didn't you just wanted your dick to be fondled
    +1
  • K3Nv2 @ K3Nv2:
    Watching dune 2 it's eh
  • Psionic Roshambo @ Psionic Roshambo:
    Dune one sucked
  • Psionic Roshambo @ Psionic Roshambo:
    The original with Patrick Stewart was Great
  • K3Nv2 @ K3Nv2:
    A sexual psycopath that love pain where have I heard that before
  • BigOnYa @ BigOnYa:
    In your high school diary?
  • K3Nv2 @ K3Nv2:
    No but your wife let's me read her diary the word psychopath comes up more than sexual
    +1
  • K3Nv2 @ K3Nv2:
    Lol stremio hogging all of my tvs on board ram
    K3Nv2 @ K3Nv2: Lol stremio hogging all of my tvs on board ram