Homebrew Homebrew Development

AileenLumina

Python main, software engineer and API designer
Member
Joined
Sep 27, 2015
Messages
631
Trophies
0
Age
26
XP
614
Country
Germany
This is not what I meant. Post the source of what you are having trouble with, so we can help.
I deleted basically everything already to start over as it was 100% trash ^^

--------------------- MERGED ---------------------------

This is not what I meant. Post the source of what you are having trouble with, so we can help.
Can you at least try to say if all of this is possible and if I should better do something different/change the algorithm? :)
 

AileenLumina

Python main, software engineer and API designer
Member
Joined
Sep 27, 2015
Messages
631
Trophies
0
Age
26
XP
614
Country
Germany
I can only hope that you are really okay with that I will ask a lot of questions. ^^"

So I got these example from the libctru docs:
Code:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <inttypes.h>

#include <3ds.h>

Result http_download(httpcContext *context)//This error handling needs updated with proper text printing once ctrulib itself supports that.
{
Result ret=0;
u8* framebuf_top;
u32 statuscode=0;
u32 size=0, contentsize=0;
u8 *buf;

ret = httpcBeginRequest(context);
if(ret!=0)return ret;

ret = httpcGetResponseStatusCode(context, &statuscode, 0);
if(ret!=0)return ret;

if(statuscode!=200)return -2;

ret=httpcGetDownloadSizeState(context, NULL, &contentsize);
if(ret!=0)return ret;

printf("size: %"PRId32"\n",contentsize);
gfxFlushBuffers();

buf = (u8*)malloc(contentsize);
if(buf==NULL)return -1;
memset(buf, 0, contentsize);


ret = httpcDownloadData(context, buf, contentsize, NULL);
if(ret!=0)
{
free(buf);
return ret;
}

size = contentsize;
if(size>(240*400*3*2))size = 240*400*3*2;

framebuf_top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
memcpy(framebuf_top, buf, size);

gfxFlushBuffers();
gfxSwapBuffers();

framebuf_top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
memcpy(framebuf_top, buf, size);

gfxFlushBuffers();
gfxSwapBuffers();
gspWaitForVBlank();

free(buf);

return 0;
}

int main()
{
Result ret=0;
httpcContext context;

gfxInitDefault();
httpcInit();

consoleInit(GFX_BOTTOM,NULL);

//Change this to your own URL.
char *url = "http://devkitpro.org/misc/httpexample_rawimg.rgb";

printf("Downloading %s\n",url);
gfxFlushBuffers();

ret = httpcOpenContext(&context, url, 1);
printf("return from httpcOpenContext: %"PRId32"\n",ret);
gfxFlushBuffers();

if(ret==0)
{
ret=http_download(&context);
printf("return from http_download: %"PRId32"\n",ret);
gfxFlushBuffers();
httpcCloseContext(&context);
}

// Main loop
while (aptMainLoop())
{
gspWaitForVBlank();
hidScanInput();

// Your code goes here

u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu

// Flush and swap framebuffers
gfxFlushBuffers();
gfxSwapBuffers();
}

// Exit services
httpcExit();
gfxExit();
return 0;
}
Code:
///////////////////////////////////////
// SDMC example //
///////////////////////////////////////
//this example shows you how to load a binary image file from the SD card and display it on the lower screen
//for this to work you should copy test.bin to same folder as your .3dsx
//this file was generated with GIMP by saving a 240x320 image to raw RGB
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include <3ds.h>
#include "costable.h"

//this will contain the data read from SDMC
u8* buffer;

//3DS has VFPs so we could just use cos
//but we're old school so LUT4life
s32 pcCos(u16 v)
{
return costable[v&0x1FF];
}

void renderEffect()
{
static int cnt;
u8* bufAdr=gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);

int i, j;
for(i=1;i<400;i++)
{
for(j=1;j<240;j++)
{
u32 v=(j+i*240)*3;
bufAdr[v]=(pcCos(i+cnt)+4096)/32;
bufAdr[v+1]=(pcCos(j-256+cnt)+4096)/64;
bufAdr[v+2]=(pcCos(i+128-cnt)+4096)/32;
}
}

cnt++;
}

int main(int argc, char** argv)
{

gfxInitDefault(); //makes displaying to screen easier

FILE *file = fopen("test.bin","rb");
if (file == NULL) goto exit;

// seek to end of file
fseek(file,0,SEEK_END);

// file pointer tells us the size
off_t size = ftell(file);

// seek back to start
fseek(file,0,SEEK_SET);

//allocate a buffer
buffer=malloc(size);
if(!buffer)goto exit;

//read contents !
off_t bytesRead = fread(buffer,1,size,file);

//close the file because we like being nice and tidy
fclose(file);

if(size!=bytesRead)goto exit;

while(aptMainLoop())
{
//exit when user hits B
hidScanInput();
if(keysHeld()&KEY_B)break;

//render rainbow
renderEffect();

//copy buffer to lower screen (don't have to do it every frame)
memcpy(gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL), buffer, size);

//wait & swap
gfxSwapBuffersGpu();
gspWaitForEvent(GSPGPU_EVENT_VBlank0, false);
}

//cleanup and return
//returning from main() returns to hbmenu when run under ninjhax
exit:

//closing all services even more so
gfxExit();
return 0;
}
But yeah, I don't really know how to use all this. A simple example code that shows how to download a file using an URL and save it into a specific folder would be really helpful as I'm a beginner to C too XD
 

AileenLumina

Python main, software engineer and API designer
Member
Joined
Sep 27, 2015
Messages
631
Trophies
0
Age
26
XP
614
Country
Germany
@AidanLumina First you should learn about File IO using stdio.h, learn how to read, write, and parse files.
You need to know at least, fopen, fread, fwrite, fscanf, fclose, fseek.
Thanks, this helps! :) But I asked another question. Could you please try to answer it?
Can you at least try to say if all of this is possible and if I should better do something different/change the algorithm?
 

MasterFeizz

Well-Known Member
Member
Joined
Oct 15, 2015
Messages
1,098
Trophies
1
Age
29
XP
3,710
Country
United States
Thanks, this helps! :) But I asked another question. Could you please try to answer it?
It will work. You can't really make it any simple than that,and as long as the version numbers follow the same rule you won't have a problem.

Edit: You don't need to multiply by 1000 when checking the version numbers.
Just do something like
Code:
while(curVersion < onlineVersion)
{
    curVersion += 0.001;
    downloadVersion(curVersion);
}
 
Last edited by MasterFeizz,
  • Like
Reactions: AileenLumina

fafaffy

Well-Known Member
Member
Joined
Sep 1, 2012
Messages
345
Trophies
0
XP
717
Country
United States
Hey guys, looking to develop some simple homebrew apps (hopefully create more advanced ones in the future, got a couple of really awesome ideas) but I'm running into a slight issue.

First off, I'm trying to code and compile on Windows using Visual Studio Community 2015.
I read the tutorials, installed the proper libraries, and even made the provided homebrew apps compile perfectly. That said, my environment is proper as I'm able to make the .3dsx files.

However, my Visual Studio's Intellisense is going crazy. I have included the libraries as instructed on my Visual Studio project, and even visual studio itself can compile the homebrew, however intellisense is detecting nearly a thousand errors. Does anyone know how to fix this?

Image of error: http://i.imgur.com/Iw4v1Hx.png
Like I said, I can compile the homebrew (within Visual Studio) and included the required libraries.
 

MasterFeizz

Well-Known Member
Member
Joined
Oct 15, 2015
Messages
1,098
Trophies
1
Age
29
XP
3,710
Country
United States
Hey guys, looking to develop some simple homebrew apps (hopefully create more advanced ones in the future, got a couple of really awesome ideas) but I'm running into a slight issue.

First off, I'm trying to code and compile on Windows using Visual Studio Community 2015.
I read the tutorials, installed the proper libraries, and even made the provided homebrew apps compile perfectly. That said, my environment is proper as I'm able to make the .3dsx files.

However, my Visual Studio's Intellisense is going crazy. I have included the libraries as instructed on my Visual Studio project, and even visual studio itself can compile the homebrew, however intellisense is detecting nearly a thousand errors. Does anyone know how to fix this?

Image of error: http://i.imgur.com/Iw4v1Hx.png
Like I said, I can compile the homebrew (within Visual Studio) and included the required libraries.
To use Visual Studio you have to create a makefile project and not a regular project, and setup include paths so intellisense can find the included files.
 

fafaffy

Well-Known Member
Member
Joined
Sep 1, 2012
Messages
345
Trophies
0
XP
717
Country
United States
To use Visual Studio you have to create a makefile project and not a regular project, and setup include paths so intellisense can find the included files.
Is it just not following these directions? Genuinely asking.

When installing Visual Studio, make sure to install the Visual C++ packages!

1) File -> New -> Project From Existing Code...

2) In the dropdown, choose Visual C++ and click Next

3) Under Project file location, navigate to the folder with all sources. Enter a name for the project and click next.

4) Use external build system, Next

5) Build command line:

make

Clean command line:

make clean

Leave the rest blank. Click Finish.

6) Right click project (in the solution explorer) -> properties

7) Under VC++ directories -> General -> Include directories, add the devkitARM and ctrulib include directories (change if needed):

C:\devkitPro\devkitARM\include
C:\devkitPro\libctru\include

Make sure not to remove anything already in the box! You can add any other include folder that the project may need as well. In the end it'll read something like:

C:\devkitPro\devkitARM\include;C:\devkitPro\libctru\include;$(IncludePath)

Click OK

8) (Optional) Right click project -> Add -> Existing Item
Choose the Makefile and any other files you want to add, then click Add. This step isn't required, but allows you to edit the Makefile etc. from the editor.

Alternatively, you can use "Show All Files" under the "Project" menu (on the top) to display all files and folders as they are on the file system.

9) You can now build the project (Right click -> Build)
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,030
Country
United States
That's the issue, I did do these steps and I'm still getting the intellisense errors.
the intellisense settings need to be adjusted too - there are on the NMake tab for the project settings
Preprocessor Definitions: ARM11;_HAVE_STDC;_3DS
Include Search Path: C:\devkitPro\libctru\include;C:\devkitPro\devkitARM\arm-none-eabi\include;

you will also need to add your project include directories to the path as well. If you have added other defines in your makefile then add them to the Preprocessor Definitions too.
 

fafaffy

Well-Known Member
Member
Joined
Sep 1, 2012
Messages
345
Trophies
0
XP
717
Country
United States
the intellisense settings need to be adjusted too - there are on the NMake tab for the project settings
Preprocessor Definitions: ARM11;_HAVE_STDC;_3DS
Include Search Path: C:\devkitPro\libctru\include;C:\devkitPro\devkitARM\arm-none-eabi\include;

you will also need to add your project include directories to the path as well. If you have added other defines in your makefile then add them to the Preprocessor Definitions too.
Thanks, I tried this and here's my current configuration (I don't have any includes yet; simply trying to make the base template work. Also the makefile didn't specify any additional includes from what I saw):
2vGdRQf.png


FhsG4Pz.png

But I still get the 800-some odd errors: (as you can see, I can build successfully on the bottom, even with the errors)
IDDZ69z.png
 
Last edited by fafaffy,

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,030
Country
United States
Thanks, I tried this and here's my current configuration (I don't have any includes yet; simply trying to make the base template work. Also the makefile didn't specify any additional includes from what I saw):
2vGdRQf.png


FhsG4Pz.png

But I still get the 800-some odd errors: (as you can see, I can build successfully on the bottom, even with the errors)
IDDZ69z.png
on VC++ Directories - clear all fields except for Executable Directories - they are not used at all. they just confuse intellisense.
on NMake->Preprocessor definitions you should have the values I specified - having WIN32 defined doesn't make sense. remove WIN32 and everything after it
 

fafaffy

Well-Known Member
Member
Joined
Sep 1, 2012
Messages
345
Trophies
0
XP
717
Country
United States
on VC++ Directories - clear all fields except for Executable Directories - they are not used at all. they just confuse intellisense.
I have erased all fields except the includes directory (I'm assuming that's what you meant to say). However the errors still persist (but in case you did mean the Executable Directories, I have tried erasing everything except this, and erasing everything except Executable Directories and Include Directories).

on NMake->Preprocessor definitions you should have the values I specified - having WIN32 defined doesn't make sense. remove WIN32 and everything after it
I had tried this before posting but it didn't work, so I put it back in case it broke something else (logically I would think not since this is not a WIN32 program, but I'm not going to go out and assume).


Finally, thanks for trying to help. I really do appreciate it. I promise I'm at least a semi decent programmer, but haven't delved too far into C++ on visual studio (was always using code::blocks) or stuck with C#.
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,030
Country
United States
I have erased all fields except the includes directory (I'm assuming that's what you meant to say). However the errors still persist (but in case you did mean the Executable Directories, I have tried erasing everything except this, and erasing everything except Executable Directories and Include Directories).


I had tried this before posting but it didn't work, so I put it back in case it broke something else (logically I would think not since this is not a WIN32 program, but I'm not going to go out and assume).


Finally, thanks for trying to help. I really do appreciate it. I promise I'm at least a semi decent programmer, but haven't delved too far into C++ on visual studio (was always using code::blocks) or stuck with C#.
I meant what I said and I said what I meant. particularly the part where I said leaving these settings confuses intellisense. also, make sure that you are changing the settings for the correct project configuration - the default is Debug x86. sometimes the settings will open up for a different config.

edit: screenshots http://imgur.com/a/BGPJp
 
Last edited by elhobbs, , Reason: added screenshots
D

Deleted User

Guest
Random question... perhaps I am being dense, but why does 3ds.h use the deprecated stdint.h over cstdint?
 
D

Deleted User

Guest
Because ctrulib is a C project, not c++. stdint.h is a C99 header.

OH. Derp. Don't you go using your common sense on me!

EDIT: Since I don't use C very often, what advantages does C provide over C++ in this case? Is it just because it is lower-level code and needs less overhead?

EDIT 2: I don't mean to be dense, I'm just relatively new to development for embedded systems and/or kernel-level access.
 
Last edited by ,

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,030
Country
United States
OH. Derp. Don't you go using your common sense on me!

EDIT: Since I don't use C very often, what advantages does C provide over C++ in this case? Is it just because it is lower-level code and needs less overhead?

EDIT 2: I don't mean to be dense, I'm just relatively new to development for embedded systems and/or kernel-level access.
You can easily reference C libraries in C++. It is a bit more difficult to reference a C++ library from C. So the current solution is easy to use with both.
 
  • Like
Reactions: Deleted User

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    ZeroT21 @ ZeroT21: gn