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 > Graphics are chopped and reformed...whats wrong???!

#7442 - yaustar - Wed Jun 18, 2003 1:09 am

Following gba junkies chapter 3 to display an image without any changes to the code and using the programs that he is i get this

http://www31.brinkster.com/yaustar/1.bmp

instead of this

http://www31.brinkster.com/yaustar/2.bmp

Please help me.....
_________________
[Blog] [Portfolio]

#7444 - hnager - Wed Jun 18, 2003 2:45 am

hmmm, I can't ghet your bitmaps to display...I've been through that tutorial - if I remember it's pretty short. Post your source?

#7445 - yaustar - Wed Jun 18, 2003 3:12 am

Type the address in manually, its brinkster being a pain. The source is exactly the same as GBA Junkie's (i copied and pasted) All I have changd is the image data (.h) file


imagedisp.cpp
Code:

//////////////////////////////////////////////////////////////////////////
// File:    imagedisp.cpp                                           //
// Description: A program that displays an image on the GBA      //
// Author:   gbajunkie (with lots of code from dovoto)        //
// Date:    15th March 2002                                         //
//////////////////////////////////////////////////////////////////////////
#include "gba.h"        //GBA register definitions
#include "dispcnt.h"    //REG_DISPCNT register definitions
#include "junkie.h"   //holds the image information in an array

void PlotPixel(int x,int y, unsigned short int c)
{
   VideoBuffer[(y) * 120 + (x)] = (c);
}

int main()
{
   int loop;
   int x, y;

        SetMode(MODE_4 | BG2_ENABLE); //set mode 4 and enable background 2

   for(loop = 0; loop < 256; loop++)                 //256 entries allowed
      BGPaletteMem[loop] = junkiePalette[loop]; //load the palette into palette memory

   while(1)
   {
      for(y = 0; y < 240; y++)                  //screen height
      {
         for(x = 0; x < 160; x++)          //screen width
         {
            PlotPixel(x,y, junkieData[y*120+x]);   //load image data into
         }                  //memory pixel by pixel
      }
   }
}

_________________
[Blog] [Portfolio]

#7446 - yaustar - Wed Jun 18, 2003 3:16 am

and the image data
Code:

/**********************************************\
       junkie.h                               
          by dovotos pcx->gba program         
\*********************************************/
#define  junkie_WIDTH   240
#define  junkie_HEIGHT  160


const u16 junkieData[] = {
 //image data

const u16 junkiePalette[] = {
                    0x0000, 0x1800, 0x3000, 0x4C00, 0x6400, 0x7C00, 0x0006, 0x1806, 0x3006, 0x4C06,
                    0x6406, 0x7C06, 0x000C, 0x180C, 0x300C, 0x4C0C, 0x640C, 0x7C0C, 0x0013, 0x1813,
                    0x3013, 0x4C13, 0x6413, 0x7C13, 0x0019, 0x1819, 0x3019, 0x4C19, 0x6419, 0x7C19,
                    0x001F, 0x181F, 0x301F, 0x4C1F, 0x641F, 0x7C1F, 0x00C0, 0x18C0, 0x30C0, 0x4CC0,
                    0x64C0, 0x7CC0, 0x00C6, 0x18C6, 0x30C6, 0x4CC6, 0x64C6, 0x7CC6, 0x00CC, 0x18CC,
                    0x30CC, 0x4CCC, 0x64CC, 0x7CCC, 0x00D3, 0x18D3, 0x30D3, 0x4CD3, 0x64D3, 0x7CD3,
                    0x00D9, 0x18D9, 0x30D9, 0x4CD9, 0x64D9, 0x7CD9, 0x00DF, 0x18DF, 0x30DF, 0x4CDF,
                    0x64DF, 0x7CDF, 0x0180, 0x1980, 0x3180, 0x4D80, 0x6580, 0x7D80, 0x0186, 0x1986,
                    0x3186, 0x4D86, 0x6586, 0x7D86, 0x018C, 0x198C, 0x318C, 0x4D8C, 0x658C, 0x7D8C,
                    0x0193, 0x1993, 0x3193, 0x4D93, 0x6593, 0x7D93, 0x0199, 0x1999, 0x3199, 0x4D99,
                    0x6599, 0x7D99, 0x019F, 0x199F, 0x319F, 0x4D9F, 0x659F, 0x7D9F, 0x0260, 0x1A60,
                    0x3260, 0x4E60, 0x6660, 0x7E60, 0x0266, 0x1A66, 0x3266, 0x4E66, 0x6666, 0x7E66,
                    0x026C, 0x1A6C, 0x326C, 0x4E6C, 0x666C, 0x7E6C, 0x0273, 0x1A73, 0x3273, 0x4E73,
                    0x6673, 0x7E73, 0x0279, 0x1A79, 0x3279, 0x4E79, 0x6679, 0x7E79, 0x027F, 0x1A7F,
                    0x327F, 0x4E7F, 0x667F, 0x7E7F, 0x0320, 0x1B20, 0x3320, 0x4F20, 0x6720, 0x7F20,
                    0x0326, 0x1B26, 0x3326, 0x4F26, 0x6726, 0x7F26, 0x032C, 0x1B2C, 0x332C, 0x4F2C,
                    0x672C, 0x7F2C, 0x0333, 0x1B33, 0x3333, 0x4F33, 0x6733, 0x7F33, 0x0339, 0x1B39,
                    0x3339, 0x4F39, 0x6739, 0x7F39, 0x033F, 0x1B3F, 0x333F, 0x4F3F, 0x673F, 0x7F3F,
                    0x03E0, 0x1BE0, 0x33E0, 0x4FE0, 0x67E0, 0x7FE0, 0x03E6, 0x1BE6, 0x33E6, 0x4FE6,
                    0x67E6, 0x7FE6, 0x03EC, 0x1BEC, 0x33EC, 0x4FEC, 0x67EC, 0x7FEC, 0x03F3, 0x1BF3,
                    0x33F3, 0x4FF3, 0x67F3, 0x7FF3, 0x03F9, 0x1BF9, 0x33F9, 0x4FF9, 0x67F9, 0x7FF9,
                    0x03FF, 0x1BFF, 0x33FF, 0x4FFF, 0x67FF, 0x7FFF, 0x0000, 0x0000, 0x0000, 0x0000,
                    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
                    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
                    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
                    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,};

_________________
[Blog] [Portfolio]

#7447 - hnager - Wed Jun 18, 2003 3:19 am

What happens if you use the original gbajunkie image?

#7473 - niltsair - Wed Jun 18, 2003 2:18 pm

Try this instead :
Code:


    for(y = 0; y < 160; y++)                  //screen height
    {
        for(x = 0; x < [b]120[/b]; x++)              //screen width /2 (because 2 pixels are wirtten at a time)
        {
            PlotPixel(x,y, junkieData[y*120+x]);   //load image data into
        }                                                          //memory pixel by pixel
    }

    while(1)
    {
    }
}


You have to remember that video memory can only be wirtten in 16 or 32bits. A pixel in mode 4 takes 8bits. So everytime you write 1 pixel, you actually write 2 at a time. Thus you have 2time less to write.

The entry 0x4C00 in your junkiePalette[] actually represent 2 pixel, 0x00 and 0x4C.

#7513 - yaustar - Thu Jun 19, 2003 12:46 am

The original gba junkie image works fine....

however the new code doesn't, it's just left a black horizontal border at the bottom of the screen
_________________
[Blog] [Portfolio]

#7584 - djei-dot - Fri Jun 20, 2003 11:10 am

There is a difference between dovoto's pcx2gba and pcx2sprites programs. Maybe you're using the wrong one. (I think pcx2gba is used only in mode 3 (and 5?), pcx2sprites is used in every other modes). Make sure you are using pcx2sprites for your image conversions.

#7777 - yaustar - Tue Jun 24, 2003 3:41 pm

I think I am using pcx2sprites at the mo...

I use both to see if there is a difference later... thanks
_________________
[Blog] [Portfolio]

#7778 - djei-dot - Tue Jun 24, 2003 3:59 pm

I'm sorry. I've been watching the pcx2gba and pcx2sprite outputs this morning and I realized that I was wrong. pcx2sprite splits your image into sprites/tiles so it is only suitable for tile modes (0-2). pcx2gba is what you need for mode 4 (and no, it is not for mode 3, sorry about that too). There's another post about this in the Graphics forum, maybe you should have a look at it.

#7826 - yaustar - Thu Jun 26, 2003 12:52 am

thank you very much for that little bit of info :))
_________________
[Blog] [Portfolio]

#7885 - peebrain - Fri Jun 27, 2003 11:56 am

http://www.pbwhere.com

Go into the tools section and check out gbAmp... that tool makes it a lot clearer what you're converting and in what format. Not to mention it's made by me! yay! :-P.... It's a windows proggie, not a DOS one (but it does take command line args if you want it to).

~Sean
_________________
http://www.pbwhere.com