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 > Display Problems (possibly with subpixel font)

#55865 - GrenadeJumper - Mon Oct 03, 2005 3:48 pm

Hi All,

I'm using the framebuffer mode to create a simple interface on the touchscreen (Img 1: [Images not permitted - Click here to view it]). This is done by creating shapes and layering them (e.g. make big blue shape, then make smaller black shape on-top of that, then smaller blue shape on top of that).

Then i use the subpixel font over everything to add text. But it just won't work! (Img 2: [Images not permitted - Click here to view it] (Mockup)).

Here's an extract from my code:

Code:
void drawText()
{
    touchPosition touchXY = touchReadXY();

    char text1[14] = "Touch x =    "; // touchXY.px
    char text2[14] = "Touch y =    "; // touchXY.py

    int num1 = touchXY.px;
    char buf1[10];
    int num2 = touchXY.px;
    char buf2[10];

    itoa(num1, buf1, 20);
    itoa(num2, buf2, 20);

    subPixelPutString(0, 0, text1);
    subPixelPutString(0, 9, text2);
    subPixelPutString(30, 0, buf1);
    subPixelPutString(30, 9, buf2);
    subPixelPutString(116, 16, "1.");
    subPixelPutString(116, 46, "2.");
    subPixelPutString(116, 76, "3.");
    subPixelPutString(116, 106, "4.");
    subPixelPutString(116, 136, "5.");
    subPixelPutString(116, 166, "6.");
}

void draw_buttons(int sel)
{
  uint16 newy = 10;
  int counter = 1;
  char buf2[4];

  itoa(sel, buf2, 20);

  subPixelPutString(0, 18, buf2);

  while(newy < 170)
  {
    draw_customshape(110, newy, 90, 20, VRAM_A, RGB15(3,3,15));
    draw_customshape(113, newy+3, 84, 14, VRAM_A, RGB15(0,0,0));
    draw_customshape(114, newy+4, 10, 12, VRAM_A, RGB15(3,3,15));
    draw_customshape(125, newy+4, 71, 12, VRAM_A, RGB15(3,3,15));
    if(counter == sel)
    {
      draw_customshape(210, newy, 30, 20, VRAM_A, RGB15(1,1,8));
      draw_customshape(211, newy+1, 29, 19, VRAM_A, RGB15(6,6,25));
      draw_customshape(211, newy+1, 28, 18, VRAM_A, RGB15(3,3,15));
      draw_customshape(213, newy+3, 24, 14, VRAM_A, RGB15(31,31,31));
    }
    else
    {
      draw_customshape(210, newy, 30, 20, VRAM_A, RGB15(6,6,25));
      draw_customshape(211, newy+1, 29, 19, VRAM_A, RGB15(1,1,8));
      draw_customshape(211, newy+1, 28, 18, VRAM_A, RGB15(3,3,15));
      draw_customshape(213, newy+3, 24, 14, VRAM_A, RGB15(0,0,0));
    }
    draw_customshape(214, newy+4, 22, 12, VRAM_A, RGB15(3,3,15));

    newy += 30;
    counter++;
  }
  drawText();
}


The really annoying thing is, it doesn't matter where the "1." print line goes! It can be first, last, or in the middle, and it won't show up!

Once again, I hope it's something rediculously silly...
_________________
H/W: European NTR-001 - natrium42 PassMe v1.4 - Extreme Flash Advance 256Mb
S/W: EFA-Linker 2.5 - PA_Lib - Programmer's Notepad 2

#55952 - GrenadeJumper - Tue Oct 04, 2005 9:02 pm

shameless bump
please help!
_________________
H/W: European NTR-001 - natrium42 PassMe v1.4 - Extreme Flash Advance 256Mb
S/W: EFA-Linker 2.5 - PA_Lib - Programmer's Notepad 2

#57709 - GrenadeJumper - Mon Oct 17, 2005 9:25 pm

GrenadeJumper wrote:
shameless bump
please help!

ditto
_________________
H/W: European NTR-001 - natrium42 PassMe v1.4 - Extreme Flash Advance 256Mb
S/W: EFA-Linker 2.5 - PA_Lib - Programmer's Notepad 2

#57910 - LOst? - Wed Oct 19, 2005 5:53 am

We can't help you when you leave parts of the source code out... like the function call subPixelPutString.

I guess the problem is within this function.
_________________
Exceptions are fun

#58049 - GrenadeJumper - Thu Oct 20, 2005 1:41 pm

I didnt include that function because its not my code... It's part of the SubPixelFont project found in this thread.

But here you go:
Code:
// This PrintChar function is specific to the FrameBuffer mode
void subPixelPrintChar(char c)
{
  if (subPixelCury<187)
    {
      uint8 y = c>>4;
      for (uint8 i = 0; i<8; i++)
   for (uint8 j = 0; j<3; j++)
     {
       // indexes for the vram and the font table
       uint16 vramPosition = (subPixelCurx+j)+(subPixelCury+i)*256;
       uint16 fontTablePosition = 48*(i+(y<<3))+j+(c-(y<<4))*3;

       // curPal is not required for a Bitmap mode
           VRAM_A[vramPosition]=listPal[mode][listFont[curFont][fontTablePosition]];
     }

      subPixelCurx+=3;
      if (subPixelCurx>253) {subPixelCurx=0; subPixelCury+=8;}
    }
}

void subPixelPrintf(const char* s)
{
  uint16 i = 0;
  while (s[i]!=0) {subPixelPrintChar(s[i]);i++;}
}

void subPixelPutString(int x, int y, char* s)
{
  subPixelCurx = x; subPixelCury = y;
  subPixelPrintf(s);
}

_________________
H/W: European NTR-001 - natrium42 PassMe v1.4 - Extreme Flash Advance 256Mb
S/W: EFA-Linker 2.5 - PA_Lib - Programmer's Notepad 2