Page 1 of 1

Problem with tiles

Posted: Tue Aug 19, 2008 6:48 pm
by M-374 LX
What can cause this problem with tiles?

Image

I think that the problem is with the positions of the tiles.

Posted: Tue Aug 19, 2008 7:24 pm
by Shiru
Nobody can answer what is wrong if you do not explain what you do and what you try to get. More information - more chances for answer.

Posted: Tue Aug 19, 2008 7:36 pm
by M-374 LX
Shiru wrote:Nobody can answer what is wrong if you do not explain what you do and what you try to get. More information - more chances for answer.
Do you see the image?
There are some black parts where should be green.
And some green parts where should de yellow.

Posted: Tue Aug 19, 2008 7:40 pm
by Christuserloeser
I think he sees the image, but it is just ...well, an image. How on earth would anyone know what it is supposed to look like ?


- What are you working on btw ? (I am always curious about new homebrew :))

Posted: Tue Aug 19, 2008 7:46 pm
by M-374 LX
I think that the problem is with the positions of the tiles.
What are you working on btw ?
Nothing interesting.
I am just testing.

Posted: Wed Aug 20, 2008 1:20 am
by devzone
Without explaining what it is that you are doing nobody will be able to answer what is wrong

Posting the source code that generates the tiles would help greatly

Posted: Wed Aug 20, 2008 4:17 pm
by M-374 LX
As I said, I think that the problem is with the positions.

This is the full source:

Code: Select all

#include "genesis.h"

void init_gfx();
void load_tiles();
void show_tiles();
void set_colors();

unsigned int Pal[128] = {
	0x0000,0x00EE,0x0E0E,0x000E,0x0EE0,0x00E0,0x0E00,0x0888,
	0x0CCC,0x0088,0x0808,0x0008,0x0880,0x0080,0x0800,0x0EEE,	
	};

unsigned long Tiles[32] = {
	0		  , 0		  , 0		  , 0		  , 0		  , 0		  , 0		  , 0		  , 
	0xDD5D5D55, 0x55D5DD5D, 0xD5DD55D5, 0x55555D5D, 0x55D5D555, 0xD55555D5, 0x5D5D5555, 0x5D55D55D, 
	0x55D51191, 0x5D5D1911, 0xD5551919, 0x5DD59119, 0x55559191, 0xD5DD1111, 0x5D5D9119, 0xD5551911, 
	0x91111911, 0x99111191, 0x11191191, 0x19919119, 0x91111111, 0x11191911, 0x99111111, 0x11191199, 
	} ;

unsigned short Map[48] = {1,1,1,1,2,3,3,3,3,1,1,1,1,1,2,3,3,3,3,3,3,
			3,3,3,3,3,1,1,1,1,1,1,1,1,1,2,3,3,3,3,3,3,3,3,3,3,3,3};

void main()
{
    init_gfx();

    load_tiles();

    set_colors();

    show_tiles();

    while (1)
    {
        asm("nop");
    }
}

void init_gfx()
{
    register uint *pw;

    pw = (uint *) GFXCNTL;

    *pw = 0x8016;   
    *pw = 0x8174;   
    *pw = 0x8230;   
    *pw = 0x8338;   
    *pw = 0x8407;   
    *pw = 0x857e;
    *pw = 0x8600;
    *pw = 0x8700;
    *pw = 0x8801;
    *pw = 0x8901;
    *pw = 0x8a01;
    *pw = 0x8b00;
    *pw = 0x8c08;
    *pw = 0x8d08;
    *pw = 0x8f02;
    *pw = 0x9000;
    *pw = 0x9100;
    *pw = 0x92ff;
}

void load_tiles()
{
    register ulong *pl;
    register uint i;

    pl = (ulong *) GFXCNTL;
    *pl = GFX_WRITE_ADDR(0);

    pl = (ulong *) GFXDATA;

	*pl=0;
	for (i = 0; i < 8*4; i++)
        *pl=Tiles[i];
}

void set_colors()
{
    register ulong *pl;
    register uint *pw;
	uint i;

    pl = (ulong *) GFXCNTL;
    *pl = GFX_COLOR_WRITE_ADDR(0);

    pw = (uint *) GFXDATA;
    
	for (i=0; i<16; i++)
		*pw=Pal[i];
}

void show_tiles()
{
    register ulong *pl;
    register uint *pw;
    register uint i;

    pl = (ulong *) GFXCNTL;
    *pl = GFX_WRITE_ADDR(0xC000);

    pw = (uint *) GFXDATA;

    for (i = 0; i < 48; i++)
        *pw = 0x8000 + Map[i];
}

Edit: I posted a different image, which is easier to understand.