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 > 120 Pixels in X Axis in Mode 4 ??

#53182 - Tomik - Tue Sep 06, 2005 5:02 pm

Hello, again my porblem...

I work in Mode 4 but I just can draw 120 Pixels, because it always draws 2 in a row. I got that example code from "Tank" (Programming for Beginners)
Thats what I have:
SetMode(MODE_4 | BG2_ENABLE );

Thanks, Thomas

#53196 - Quirky - Tue Sep 06, 2005 6:43 pm

You can only write 16 or 32 bit values to vram, but each pixel is described in 8 bits. The solution is to write 2 pixels at once. In practice you tend to read the current 2 pixels, change the one you want, then write both pixels back. This is what makes mode 4 such a slowy.

#53290 - Tomik - Wed Sep 07, 2005 8:20 am

Edit: Maybe I misunderstood. Is what you want me to say I have to draw my Pixel (GBA draws two) and then I have to override the second pixel again ..... and Flip then to screen ??
Is there no other way ??

Thomas

#53295 - Tomik - Wed Sep 07, 2005 9:17 am

..and if I use this
Code:
   for(y = 0; y < 160; y++)
   {
      for(x = 0; x < 120; x++)
      {
         PlotPixel(x,y,logoData[y*120+x]);      
      }
   }

it draws not only 160 Pixel, because I can see all 240 Pixels. What is happening there ??