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 > 120x160 in Mode 4

#51984 - Tomik - Thu Aug 25, 2005 9:07 am

Hello,
I work right now in Mode 4, but this means display in x axis only 120 pixels.
which mode do i have to choose, when i dont want to change the background and displaying 240pixel in x axis ?

where can i find mode explaination?

Thanks, Thomas

#51987 - Fatnickc - Thu Aug 25, 2005 10:15 am

Huh?
Mode 4 support 240 on the x axis, you know?

#51992 - headspin - Thu Aug 25, 2005 10:56 am

http://www.cs.rit.edu/~tjh8300/CowBite/CowBiteSpec.htm#Mode%200
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#53301 - Tomik - Wed Sep 07, 2005 10:01 am

if I write
plotpixel(50,50,0x0000)
there are two pixels (50 and 51) in x Axis display !! so i can only use 120 pixels !!

right or wrong ??

#53379 - APL - Thu Sep 08, 2005 1:53 am

0x0000 is 16bits worth of zeros. Mode 4 is an 8bit mode.

I don't think there's an 8bit way to set plot a pixel, so you've got to plot them two at a time.

I'll bet you'd get diferent results with this line : plotpixel(50,50,0x00FF)
_________________
-Andy L
http://www.depthchasers.com

#53465 - Cearn - Thu Sep 08, 2005 4:42 pm

Of course you can plot single pixels in mode 4. It just takes a little masking, that's all. Of course, it won't exactly be the fastest thing in the world.
Code:
u16 *vid_page= (u16*)0x06000000; // point to the frame buffer that you want

static inline void m4_plot(int x, int y, u8 clrid)
{
    u16 *dst= &vid_page[(y*240+x)>>1];
    if(x&1)
        *dst= (*dst& 0xFF) | (clrid<<8);
    else
        *dst= (*dst&~0xFF) | clrid;
}

Another option is to use double buffering: put a frame buffer in ewram (or even iwram, it *might* just fit without problems) and copy that VRAM. Not exactly speedy either, but at least you can circumvent the 16bit rule that way.