gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Mega-Newbie Needs help :)

#5692 - vb_recruit - Tue May 06, 2003 7:27 am

hey all, I am trying to compile a C++ prog into GBA format.
I can do C, but for some reason, whenever I try C++,and include
the iostream header, it gives some error:
Undefined reference to write and some Paths.

Here was the C++ file:

Code:

#include<iostream.h>

int main(void)
 {
   cout << "TEsT\n";
   
  return 0;
}


Any advice?

Thanks a lot,

-Chris

#5703 - niltsair - Tue May 06, 2003 2:20 pm

The Gba got no standard output.

You should try the turorials first (you can find some under the beginer forum faq, or under www.gbadeb.org ->Doc) this would help you a lot since GBA programming is very hardware oriented.

#5734 - vb_recruit - Wed May 07, 2003 7:54 am

Thanks a lot :)

-Chris

#6892 - hzx - Wed Jun 04, 2003 8:45 am

hello

i feel myself as a mega-newbie, because i totally stucked with a code. It wants to be a mode3 double buffer, in which you always draw into the background buffer and then copy it to VideoBuffer on VBlank. Here it is:

u16 *DrawBuffer = (u16 *)0x02000000;

// Backbuffer in EWRAM, because it is bigger than 32K

void Wkey() {
while ((*KEYS) & 1) {
};
}

// just for debugging purposes

void CopyDrawBuffer() {

REG_DMA3SAD = (u32)DrawBuffer;
REG_DMA3DAD = 0x06000000;
REG_DMA3CNT = 38400 | DMA_ENABLE;

}

// use DMA to copy the backbuffer to VideoBuffer

void DMAClearDrawBuffer() {

REG_DMA3SAD = 0x05000000;
REG_DMA3DAD = (u32)DrawBuffer;
REG_DMA3CNT = 38400 | DMA_ENABLE | DMA_SOURCE_FIXED;
}

// this one clears the backbuffer. Takes the zero value from the Palette[0]

void StupidClear() {

int i;
for (i = 0; i < 38400; i++) {
DrawBuffer[i] = 0;
}
}

// a debug clearscreen, filling background buffer with zeros

int main() {

int i;

SetMode(MODE_3 | BG2_ENABLE);

i = 1000; // for a little demonstration

while(1) {
DrawBuffer[i] = RGB16(31,31,31);
WaitForVSync();
CopyDrawBuffer();
Wkey();
i++;
DMAClearDrawBuffer();
// StupidClear();
}

So, when i run the code, the screen remains blank until the first keypress, which is strange, because the CopyDrawBuffer should display the white pixel in the 1000th position of VideoBuffer. After the first keypress, the code works as it is expected, BUT! only with the stupid clear routine - the DMA version clears the screen though, the program doesnt work at all. Maybe i am missing some oblivious, but i cannot see it. Somebody can help me?
_________________
.hzx

#6896 - djei-dot - Wed Jun 04, 2003 10:40 am

Mode 3 doesn't have a backbuffer. You have to use mode 4.

#6902 - hzx - Wed Jun 04, 2003 11:34 am

djei-dot wrote:
Mode 3 doesn't have a backbuffer. You have to use mode 4.


Well, true. That is why I defined the DrawBuffer array into the EWRAM. A software backbuffer. :)
_________________
.hzx