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.

DS development > libhax (to many bugs)

#162702 - hacker013 - Tue Sep 09, 2008 8:20 pm

Hey everybody,

I'm busy with a new program but i've written a basic library for it so i could use that in other programs but that library has so many bugs that it won't compile.

bugs:
multiple defination.
not yet working fifo (can't test it because library won't compile)
memory bugs (pointers and stuff)

Can anybody help me to fix it. You get credit for it, and i release the library as libhax (version 0.3). I haven't released 0.2 also because it had to many bugs, please can anybody help me with this??

Download xsystem.zip

ltr,

Hacker013
_________________
Website / Blog

Let the nds be with you.

#162703 - gauauu - Tue Sep 09, 2008 8:39 pm

This is your libhax that we're talking about, right, which won't compile?

You've been working on it for awhile...have you been compiling or testing as you go to make sure that blocks of code work (or at least compile)? Maybe I'm misunderstanding your post, but it sounds as if you typed it all, then at the end hit compile, and it's not compiling. While one of us could go through and try to fix your bugs (I don't have time to do that, but maybe someone else does), you could learn more from the process of finding and fixing them yourself.

First: Make your cycle of writing code/compiling/testing smaller, so that instead of having a zillion bugs to fix, you only have a few. When they are fixed, add new code. It's MUCH more manageable that way.

Second: Your multiple definition issue is occurring because you have definitions in your header files. For example, in hax_font.h:
Code:

char *fontline[4] = {    "abcdefghijklmnopqrstuvwxyz",
                  "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
                  "0123456789=!\"?$%&/()<>,.-+",
                  "*~#;:_|@??\{[]}??| " } ;


Whenever you try to include this, is tries to redefine it. Instead, put the declaration in your header, and move the definition to hax_font.c.

hax_font.h:
Code:

char * fontline[]; // or extern char * fontline[];


hax_font.c:
Code:

char *fontline[4] = {    "abcdefghijklmnopqrstuvwxyz",
                  "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
                  "0123456789=!\"?$%&/()<>,.-+",
                  "*~#;:_|@??\{[]}??| " } ;


Third: About the memory bugs and fifo....get your code compiling, and mostly working first. Then feel free to come back with specific questions to help solve those problems ;-)

#162714 - hacker013 - Wed Sep 10, 2008 3:31 pm

Thank you for the tips, i try it again:D

Edit can anyone look at the screen and font code because it is al scruded up.
_________________
Website / Blog

Let the nds be with you.

#162816 - hacker013 - Sat Sep 13, 2008 2:33 pm

anybody??
_________________
Website / Blog

Let the nds be with you.

#162818 - Maxxie - Sat Sep 13, 2008 3:52 pm

MightyMax's:
Code:

char *fontline[4] = {    "abcdefghijklmnopqrstuvwxyz",
                  "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
                  "0123456789=!\"?$%&/()<>,.-+",
                  "*~#;:_|@??\{[]}??| " } ;

void intern_GFX_printCharCol(int x, int y,char ch,unsigned short col,unsigned short bg) {
   /* copy 8x13 pixels from char location */
   /* search location of char */
   int i,q ;
   char *loc_ch ;
   int px = -1,py = -1 ;
   for (i=0;i<4;i++) {
      loc_ch = fontline[i] ;
      q = 0 ;
      while (*loc_ch) {
         if (*loc_ch == ch) {
            px = q*8 ;
            py = i*13 ;
         } ;
         loc_ch++ ;
         q++ ;
      } ;
   } ;
   unsigned short *font = (unsigned short *)0x06020000 ;
   unsigned short *screen = (unsigned short *)0x06000000 ;
   if ((px<0) || (py < 0)) {
      return ;
   } ;
   if (bg & 0x8000) {
      for (i=0;i<13;i++) {
         for (q=0;q<8;q++) {
            if (font[q+px + (i+py)*256] & ~0x8000) {
               screen[q+x + (i+y)*256] = col ;
            } else {
               screen[q+x + (i+y)*256] = bg ;
            } ;
         } ;
      } ;
   } else {
      for (i=0;i<13;i++) {
         for (q=0;q<8;q++) {
            if (font[q+px + (i+py)*256] & ~0x8000) {
               screen[q+x + (i+y)*256] = col ;
            } else {
               // only set background if color was charcolor
               if (screen[q+x + (i+y)*256] == col) screen[q+x + (i+y)*256] = bg | 0x8000;
            } ;
         } ;
      } ;
   }
} ;


Your's
Code:

char *fontline[4] = {    "abcdefghijklmnopqrstuvwxyz",
                  "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
                  "0123456789=!\"?$%&/()<>,.-+",
                  "*~#;:_|@??\{[]}??| " } ;

Code:

void hax_draw_charcol(bool scr, int x, int y,char ch,unsigned short col,unsigned short bg) {
   /* copy 8x13 pixels from char location */
   /* search location of char */
   int i,q ;
   char *loc_ch ;
   int px = -1,py = -1 ;
   for (i=0;i<4;i++) {
      loc_ch = fontline[i] ;
      q = 0 ;
      while (*loc_ch) {
         if (*loc_ch == ch) {
            px = q*8 ;
            py = i*13 ;
         } ;
         loc_ch++ ;
         q++ ;
      } ;
   } ;
   unsigned short *font = (unsigned short *)0x06028000 ;
   unsigned short *screen;
   if (scr==0) {
      screen = (unsigned short *)0x06008000 ;
   } else {
      screen = (unsigned short *)0x06208000 ;
   }
   if ((px<0) || (py < 0)) {
      return ;
   } ;
   if (bg & 0x8000) {
      for (i=0;i<13;i++) {
         for (q=0;q<8;q++) {
            if (font[q+px + (i+py)*256] & ~0x8000) {
               screen[q+x + (i+y)*256] = col ;
            } else {
               screen[q+x + (i+y)*256] = bg ;
            } ;
         } ;
      } ;
   } else {
      for (i=0;i<13;i++) {
         for (q=0;q<8;q++) {
            if (font[q+px + (i+py)*256] & ~0x8000) {
               screen[q+x + (i+y)*256] = col ;
            } else {
               // only set background if color was charcolor
               if (screen[q+x + (i+y)*256] == col) screen[q+x + (i+y)*256] = bg | 0x8000;
            } ;
         } ;
      } ;
   }
} ;


At least add a line which credits the original author if you take it.
_________________
Trying to bring more detail into understanding the wireless hardware

#162821 - Kyoufu Kawa - Sat Sep 13, 2008 4:56 pm

Right down to unnecessary semicolons... ouch.

#162825 - hacker013 - Sat Sep 13, 2008 6:41 pm

@Maxxie

Ok, if added the credits for MightyMax, are you now happy?
_________________
Website / Blog

Let the nds be with you.