Page 1 of 3
newbie's questions
Posted: Mon Aug 24, 2009 10:28 pm
by Jaklub
Hi guys. I want to program a rom for Sega Genesis/Mega Drive. I attempted BasiEgaXorz, but I think it is not enough (it lacks of comfortable way to use many files for one project).
I've downloaded enviroment from here:
http://gens.consolemul.com/download/tem ... sDev04.zip I tried to install XGCC before, but I failed.
I managed to compile a simple hello-worldish app.
But how do I code tiles to display? Is there any simple way to do it? I've searched in include directory, but I don't have any idea what should I do with VDP_loadTileTo command (where should I take tile data from).
Or should I move to te XGCC? But I don't know how to install it.
Please help, I've searched, but failed to get helpful info.
ps. correct me if I'm wrong somewhere.
Posted: Tue Aug 25, 2009 6:55 am
by bastien
hi,
if you wan read the french language , i have write a tutorial on my website for use Gendev:
here is the link:
http://sega4ever.power-heberg.com/artic ... g=fr&pg=17
Posted: Tue Aug 25, 2009 11:15 am
by Jaklub
Thank you for your help, but i've got another problem.
How can i change the palette to display from 0 to other ones? I tried to figure out, but i didn't find the answer.
Posted: Tue Aug 25, 2009 11:47 am
by bastien
Jaklub wrote:Thank you for your help, but i've got another problem.
How can i change the palette to display from 0 to other ones? I tried to figure out, but i didn't find the answer.
here is the text fonction in Gendev , and "Hello World" the text
VDP_drawText(APLAN,"Hello World", 0x0000, 10, 10);
-0x0000 : is the palette number 0
0x2000 for the number 1
0x4000 for the number 2
0x6000 for the number 3
for exemple if you want to write "hello world " in red with the palette number 2 , the right code is:
Code: Select all
#include "genesis.h"
int main()
{
VDP_init();
VDP_setPaletteColor(2, 15, 0x00F);
VDP_drawText(APLAN,"Hello World", 0x4000, 10, 10);
}
Posted: Tue Aug 25, 2009 11:59 am
by Jaklub
But what should I do to apply this to tiles and sprites? (change palette to draw, not one of palette colours, to be exact)
Posted: Tue Aug 25, 2009 12:24 pm
by bastien
Jaklub wrote:But what should I do to apply this to tiles and sprites? (change palette to draw, not one of palette colours, to be exact)
i explain everything of this in my tuto:
just read this:
http://sega4ever.power-heberg.com/artic ... g=fr&pg=36
Posted: Tue Aug 25, 2009 1:10 pm
by Jaklub
Sorry, but I'm talking about code - I've succeed in importing palettes and tiles into the program, but I can't change which palette tile to display should use (it's 0 by default, and I want to set it to another one).
but maybe I'm missing something ;p
Posted: Tue Aug 25, 2009 2:39 pm
by bastien
with Genitile you can convert a picture in BMP format in two ASM file.
one for the tiles and the second for the pal.
look the exemple in my tuto i try with this picture :
i have converted with genitile so i have got 2 files in *.S
after you need to add these in the two files :
after this step for add the *.s files in your source code you must write this:
Code: Select all
extern u32 Zelda_tiles[];
extern u16 Zelda_pal[];
and for load the bitmap pal in the pal0 for exemple :
after this you must load the bitmap tiles in the genesis Vram , for exemple write this :
Code: Select all
VDP_DoVRamDMA( (u32) Zelda_tiles, 0, 76800);
0 for start to add tiles in the beginning of the vram
76800 is the bytes in my picture in the files zelda_tiles :
and finally for display the picture use this :
Code: Select all
VDP_fillTileRectInc(0xc000, 0x0000,0,0,320/8,248/8);
0x0000 number pal
0 ( axe of X)
0 ( axe of Y)
320 is the height of the bitmap
248 is the width
so my complete code is :
Code: Select all
#include "genesis.h"
extern u32 Zelda_tiles[];
extern u16 Zelda_pal[];
int main()
{
VDP_init();
// Ecran Titre
VDP_setPalette(0, Zelda_pal);
VDP_DoVRamDMA( (u32) Zelda_tiles, 0, 76800);
VDP_fillTileRectInc(0xc000, 0x0000,0,0,320/8,248/8);
VDP_updateSprites();
}
and here is the result with kmods:
excuse me for my bad english

Posted: Tue Aug 25, 2009 3:09 pm
by Jaklub
That's nice you translated the tutorial.
but how do I change palette when using this function:
Code: Select all
VDP_setTile(u16 plan, u16 tile, u16 x, u16 y);
is it impossible?
anyway, thanks for help.
Posted: Tue Aug 25, 2009 3:21 pm
by Shiru
Every tile in tilemap (not in tileset) is linked to one of four palettes (defined by bits D14,D13).
Posted: Tue Aug 25, 2009 3:33 pm
by bastien
first convert your image BMP with genitile
and after you can choose the pallette :
with this:
VDP_setPalette(0, Zelda_pal);
for load the zelda palette in this palette number 0:
VDP_setPalette(1, Zelda_pal);
for load the zelda palette in this palette number 1:
please if you can read the french language , read this:
http://sega4ever.power-heberg.com/artic ... g=fr&pg=28
Posted: Tue Aug 25, 2009 4:12 pm
by Jaklub
I've got the tiles and palette in h files. Instead of VDP_fillTileRectInc command I use VDP_setTile (which at least I think I understand). But, the tiles display always in 0 palette and that's the problem - I want to display some tiles in palette 1 instead.
Every tile in tilemap (not in tileset) is linked to one of four palettes (defined by bits D14,D13).
linked? I know a single displayed tile can't have more than 1 palette, but can you explain this?
Posted: Tue Aug 25, 2009 4:35 pm
by mic_
linked? I know a single displayed tile can't have more than 1 palette, but can you explain this?
He means that for each 16-bit value you write to the name table, bits 13 and 14 specify which palette to use for the tile at that position.
Posted: Tue Aug 25, 2009 4:37 pm
by Shiru
Jaklub wrote:linked? I know a single displayed tile can't have more than 1 palette, but can you explain this?
I don't speak english well, so this may be wrong word. Single tile can have any of 4 palettes. The tile defined by single word (16-bit number), which contains the tile number itself, and some flags, including the palette number. As I can see from Stef's libs sourcecode, you can pass tile number with flags to VDP_setTile directly. Read 'Name Tables' section of
this document.
Posted: Tue Aug 25, 2009 9:22 pm
by Jaklub
I've read the 'Name Tables' section (and priority one) and I wrote this.
Code: Select all
VDP_setTile(APLAN, 0xF0100130<<11, 3, 10);
I'm trying to draw a sprite 130 with palette 1, but even when I change it to "0xF0000130<<11" or remove "<<11" it's not working - tile is black. I tried "0xF010000000000130" and "0xF000000000000130" before (with and without "<<11"), but no effects.
I really have no idea what am I doing wrong, please help me. I think I understood "The pattern name is the upper 11 bits" wrong. ;p