Homebrew Boot GBA + custom border?

  • Thread starter Thread starter Searinox
  • Start date Start date
  • Views Views 18,182
  • Replies Replies 49
I would settle for not using his border code, but there is no other example to rely on or I'd have gladly ripped it. Firmwares of other flashcarts, AFAIK are closed source. Do you know of any opensource FWs that boot GBA with frame? I'd look into them!
 
I think I've got it right... here's what I think is the right code but I can't for the life of me compile it due to library issues. I just don't get what commands like #include are supposed to point to. It doesn't have a .h extension and is nowhere to be found.

This is for the ARM9, ARM7 supposedly does nothing.
CODE#include
#include "bmp15.h"

void ResetVideo()
{
ÂÂÂÂÂÂÂÂ// turn off video
ÂÂÂÂÂÂÂÂvideoSetMode(0);
ÂÂÂÂÂÂÂÂvideoSetModeSub(0);
ÂÂÂÂÂÂÂÂ
ÂÂÂÂÂÂÂÂ// zero out video memory
ÂÂÂÂÂÂÂÂvramSetMainBanks(
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂVRAM_A_LCD,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂVRAM_B_LCD,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂVRAM_C_LCD,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂVRAM_D_LCD);
ÂÂÂÂÂÂÂÂu32* ptr = (u32*)0x6800000;
ÂÂÂÂÂÂÂÂwhile(ptr < (u32*)0x687FFFF)
ÂÂÂÂÂÂÂÂ{
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ*ptr++ = 0;
ÂÂÂÂÂÂÂÂ}
}

void BootGbaARM9()
{
ÂÂÂÂÂÂÂÂREG_IME = 0;
ÂÂÂÂÂÂÂÂResetVideo();
ÂÂÂÂÂÂÂÂgbaFrame();
ÂÂÂÂÂÂÂÂ// http://nocash.emubase.de/gbatek.htm#dsbackwardscompatiblegbamode
ÂÂÂÂÂÂÂÂREG_EXMEMCNT |= 0x8080;ÂÂÂÂ // ARM7 has access to GBA cart
ÂÂÂÂÂÂÂÂREG_POWERCNT = POWER_SWAP_LCDS | POWER_LCD | POWER_2D_A;
ÂÂÂÂÂÂÂÂREG_EXMEMCNT &= ~0x4000;ÂÂÂÂ// set Async Main Memory mode
ÂÂÂÂÂÂÂÂ// notify arm7
ÂÂÂÂÂÂÂÂIPC->mailData = 2;
ÂÂÂÂÂÂÂÂ// halt indefinitly, since irqs are disabled
ÂÂÂÂÂÂÂÂswiWaitForIRQ();
}

void gbaFrame(void)
{
ÂÂu16* frame=NULL;
ÂÂcBMP15 frameBMP=createBMP15FromFile("/gbaframe.bmp");
ÂÂif(frameBMP.valid()&&frameBMP.width()==SCREEN_WIDTH&&frameBMP.height()==SCREEN_HEIGHT)
ÂÂ{
ÂÂÂÂframe=(u16*)malloc(SCREEN_WIDTH*SCREEN_HEIGHT*2);
ÂÂÂÂmemcpy(frame,frameBMP.buffer(),SCREEN_WIDTH*SCREEN_HEIGHT*2); //tricky thing
ÂÂ}

ÂÂvideoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
ÂÂvideoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
ÂÂvramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, VRAM_C_SUB_BG_0x06200000, VRAM_D_LCD);

ÂÂ// for the main screen
ÂÂBG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_WRAP_OFF;
ÂÂBG3_XDX = 1
 
Yes .h files are obviously headers, usually included in ndslib. Sometimes instead of being encased in they're encased in "", signifying that they're in the same folder as the sourcecode. However... there's about two of these which have NO EXTENSION. I believe one is memory. #include I have no idea what these files point to. I was able to find one of them's counterpart, in the \nds folder, and with a .h extension. The other two I have no friggin clue where to find. They're not in the sourcecodes, not in the libnds, not on google, nowhere.

Okay, include was mapped to the other one is . I can't find string. Both are required by bmp15.h.
 
This post needs a re-edit...

So anyways. In the end I got the code to both compile and work... partially. It now boots GBA, but it doesn't apply a frame still. The framecode is in ARM9\main.cpp and provided here for anyone who has any ideas. This is the last thing I need to fix!
CODE#include
#include
#include
#include
#include
#include
#include
#include "bmp15.h"
#include "fifotool.h"

int main(void)
{
/*Init Video and Apply Frame*/

videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
ÂÂvideoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
ÂÂvramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, VRAM_C_SUB_BG_0x06200000, VRAM_D_LCD);

// for the main screen
ÂÂREG_BG3CNT = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_WRAP_OFF;
ÂÂREG_BG3PA = 1
 
Finally XenoFile 0.64 has slot2 gba with custom boader. snippet:
CODEÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂvideoSetMode(MODE_5_2D),videoSetModeSub(MODE_5_2D); //just kill it
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint screen=(userdata>>3)&1;

ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ//transfer image to BG_BMP_BASE(0) and BG_BMP_BASE(8). Firstly reset.
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂvramset(0x06000000,0x8000,256*192);
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂvramset(0x06020000,0x8000,256*192);

ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂFILE *f=fopen("/xenogba.b15","rb"); //tenuki(w
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif(f){
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂu16 z[256];
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂfread(z,2,3,f);
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂu16 width=read16(z),height=read16(z+1);
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂu32 size=filelength(fileno(f));

ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif(width>256||height>192||size!=width*height*2+6){fclose(f);slot2gba(screen);}

ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ{int l=0;for(;l
 
Xenon I was able to make the filesystem work! Now the frame is applying but it looks garbled! Your code is giving me a bunch of undefineds, please specify what libraries you are using.
 
Searinox said:
Xenon I was able to make the filesystem work! Now the frame is applying but it looks garbled! Your code is giving me a bunch of undefineds, please specify what libraries you are using.
libprism and original ARM7, which is also in mshl2tools
 
Xenon++ said:
Searinox said:
Xenon I was able to make the filesystem work! Now the frame is applying but it looks garbled! Your code is giving me a bunch of undefineds, please specify what libraries you are using.
libprism and original ARM7, which is also in mshl2tools
Pardon my wording... I meant which headers you are including, the #include.
tongue.gif
 
libprism.h

#include
#include

//all in one
#include
#include
#include
#include //validateTM, struct tm
#include //getDirEntFromDirIter, DIR_ITER
#include
#include //low level API

#include "include/minIni.h"
#include "include/dldi.h"
#include "../arm7/ipcz.h"

also please note read16/filelength/vramset/vramcpy/slot2gba are libprism special APIs.
 
Can't get them damn libs to install properly. If you don't mind, think you could help me compile it?

I have uploaded the source complete with your BMP memoryload. All it should need now is for you to include the relevant libraries and compile! IMPORTANT the name of the bmp being loaded is now "gbaframe.bmp". I saw a file referrence in the code "xenogba.b15" and changed it to that, I hope I got it right! You should be able to test it yourself since it boots any GBA game.

http://www.megaupload.com/?d=YVUWV3N9
 
Very sorry but your porting had kinda many mistake... At least .b15 and .bmp are different format.
I don't want GPLed portion so I don't use cBMP15. Well, I can use libnsbmp(which makesplash uses), but...

I'm afraid I cannot test the compiled NDS because I'm out. Later.

[edit] I admit libprism is hard to read because I want to maintain compatibility with devkitARM r23b...

Code:
void vramcpy(void* dst, const void* src, int len){ //use align2 macro then divide by 2
ÂÂÂÂu16* dst16 = (u16*)dst;
ÂÂÂÂu16* src16 = (u16*)src;
ÂÂÂÂfor(;len>0;len--)*dst16++=*src16++;
}

void vramset(void* dst, const u16 n, int len){ //use align2 macro then divide by 2
ÂÂÂÂu16* dst16 = (u16*)dst;
ÂÂÂÂfor(;len>0;len--)*dst16++=n;
}

int main(void)
{

/*Mount Filesystem*/

fatInitDefault();

/*Init Video and Apply Frame*/

videoSetMode(MODE_5_2D),videoSetModeSub(MODE_5_2D); //just kill it
vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, VRAM_C_SUB_BG_0x06200000, VRAM_D_LCD);

//transfer image to BG_BMP_BASE(0) and BG_BMP_BASE(8). Firstly reset.
vramset((u16*)0x06000000,0x8000,256*192);
vramset((u16*)0x06020000,0x8000,256*192);

ÂÂcBMP15 frameBMP=createBMP15FromFile("gbaframe.bmp");
ÂÂif(frameBMP.valid()&&frameBMP.width()==SCREEN_WIDTH&&frameBMP.height()==SCREEN_HEIGHT)
ÂÂ{
ÂÂÂÂ//DC_FlushRange(frameBMP.buffer(),SCREEN_WIDTH*SCREEN_HEIGHT*2);
ÂÂÂÂ//dmaCopy(frameBMP.buffer(),(void*)BG_BMP_RAM(0),SCREEN_WIDTH*SCREEN_HEIGHT*2);
ÂÂÂÂ//dmaCopy(frameBMP.buffer(),(void*)BG_BMP_RAM(8),SCREEN_WIDTH*SCREEN_HEIGHT*2);
vramcpy((u16*)0x06000000,frameBMP.buffer(),256*192);
vramcpy((u16*)0x06020000,frameBMP.buffer(),256*192);
ÂÂ}

/*Boot GBA*/

ÂÂsysSetBusOwners(BUS_OWNER_ARM7,BUS_OWNER_ARM7);
ÂÂif(PersonalData->gbaScreen)
ÂÂÂÂREG_POWERCNT=1;
ÂÂelse
ÂÂÂÂREG_POWERCNT=(POWER_SWAP_LCDS|1)&0xffff;
ÂÂfifoSendValue32(FIFO_USER_01,MENU_MSG_GBA);
ÂÂwhile(true) swiWaitForVBlank();


return 0;
}
 
Xenon what are your own results when you try to run that file in your DS? Because it gives me the EXACT same frame corruption as my old version of code did. If it's working properly, could you post the compiled .nds here?
 
It's okay if you can't help any further with cBMP15! I've downloaded your xenofile source and I'm looking at it now. If I was to use YOUR code for loading frames, would I have to use a different picture format than bmp? I've never heard of "b15" as a picture format before so I'm a bit confused. I would like with this program that people be able to put their own frames in, so I want to load a popular format like jpg png or bmp which people are familliar with.

And I do think that what is there is indeed intended to load BMP despite being small. This is because even though the frame looks corrupt, you can make out its parts - it's basically colorshifted and separated from the middle, so it's "trying" to load the pic.

IT IS FULLY FIXED NOW! IN FACT IT WAS NEVER BROKEN! ... THE THING WITH THIS FUNCTION IS IT REQUIRES 16BIT BMP PICTURES, AND SAVING AS SUCH MUST BE DONE IN PHOTOSHOP OR SOME OTHER PROGRAM THAT ALLOWS BITRATE CHANGE!

Finally this ordeal is over!

http://filetrip.net/f13144-Boot-GBA-and-apply-Frame-1-0.html
 
Searinox said:
IT IS FULLY FIXED NOW! IN FACT IT WAS NEVER BROKEN! ... THE THING WITH THIS FUNCTION IS IT REQUIRES 16BIT BMP PICTURES, AND SAVING AS SUCH MUST BE DONE IN PHOTOSHOP OR SOME OTHER PROGRAM THAT ALLOWS BITRATE CHANGE!
That's sorry, for libnsbmp doesn't have such limitation...
 
At least for the time being, I can't be bothered to include another lib. Perhaps I will come back to this program someday but for now I'm happy with it.
 
Good work Searinox, it's always best when you do it yourself (especially when it saves me from fighting with the NDS toolchain update again!)
biggrin.gif


The native format of the DS framebuffer is 15 bit (5bits per R/G/B) + alpha bit which is likely where the b15 'format' comes from.

BTW, bmp is one of the simplest image formats out there... no compression only scanlines in reverse, and depending on the color depth either raw bits per pixel or a indexed color table. My own implementation to decode 8bpp and 24bpp bmp for gbaldr can be found here (and includes support for odd photoshop scanlines) where you simply load the image to a buffer and pass it to decode.
 

Site & Scene News

Popular threads in this forum