newbie's questions

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Shiru
Very interested
Posts: 786
Joined: Sat Apr 07, 2007 3:11 am
Location: Russia, Moscow
Contact:

Post by Shiru » Tue Aug 25, 2009 9:44 pm

Well, 16-bit word is only four digits in hex (0xffff max).

You need just tile_number+(palette_number<<13), where palette_number is 0..3.

Jaklub
Interested
Posts: 41
Joined: Mon Aug 24, 2009 1:36 pm

Post by Jaklub » Tue Aug 25, 2009 10:01 pm

I think it doesn't work.

Tried two options:

Code: Select all

VDP_setTile(APLAN, 130+(1<<13), 3, 10);
and

Code: Select all

VDP_setTile(APLAN, 130+(0<<13), 3, 10);
I think I'll just try to move on XGCC (too much trouble with that gendev). Thanks for all your help.

Shiru
Very interested
Posts: 786
Joined: Sat Apr 07, 2007 3:11 am
Location: Russia, Moscow
Contact:

Post by Shiru » Tue Aug 25, 2009 10:11 pm

Move to XGCC will make no sense at all. You can simply use compiler from Stef's devkit without using his libs (as I do, that's why I can say anything certain how to solve your problem).

What exactly does not work? Do you see the tile with wrong palette or don't see anything at all? If second, do you sure that you really have something in tile 130 (which is 131th in memory)?

Jaklub
Interested
Posts: 41
Joined: Mon Aug 24, 2009 1:36 pm

Post by Jaklub » Tue Aug 25, 2009 10:15 pm

I'm sure the tile is 130, I displayed it before with wrong palette.

The tile is whole black, even when I attempt to display it on palette 0 this method.

Shiru
Very interested
Posts: 786
Joined: Sat Apr 07, 2007 3:11 am
Location: Russia, Moscow
Contact:

Post by Shiru » Tue Aug 25, 2009 10:38 pm

I've spent few minutes to learning Stef's API, and here is working code:

Code: Select all

#include "genesis.h"

const unsigned short palette0[16]={
0x0000,0x000f,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
};

const unsigned short palette1[16]={
0x0000,0x00f0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
};

const unsigned int tile[8]={
0x11111111,
0x10000001,
0x10100101,
0x10000001,
0x10100101,
0x10111101,
0x10000001,
0x11111111
};

int main()
{
    VDP_init();
 
    VDP_loadTileTo(tile,0,1,0);
    VDP_setPalette(0,palette0);
    VDP_setPalette(1,palette1);
    VDP_setTile(APLAN,0<<13,0,0);
    VDP_setTile(APLAN,1<<13,1,0);
    
    return 0;
}
Shows same tile with different palettes. I don't know why you have problem with this, probably error or typo somewhere in your code, as it usually happens with mysterious problems.

TascoDLX
Very interested
Posts: 262
Joined: Tue Feb 06, 2007 8:18 pm

Post by TascoDLX » Tue Aug 25, 2009 10:40 pm

Did you mean to try this?

Code: Select all

VDP_setTile(APLAN, 0x130+(1<<13), 3, 10);
Or are you sure it's 130, not 0x130?

Jaklub
Interested
Posts: 41
Joined: Mon Aug 24, 2009 1:36 pm

Post by Jaklub » Wed Aug 26, 2009 8:34 am

Thanks, it works now with this code:

Code: Select all

VDP_setTile(APLAN, 1<<13^130, 3, 10);

mic_
Very interested
Posts: 265
Joined: Tue Aug 12, 2008 12:26 pm
Location: Sweden
Contact:

Post by mic_ » Wed Aug 26, 2009 8:59 am

Code: Select all

VDP_setTile(APLAN, 1<<13^130, 3, 10);
Just a tip even though it works in this case: Avoid using the XOR operator (^) unless XOR is really what you mean. If you want to set one or more bits regardless of their previous value, use the OR operator (|).

Jaklub
Interested
Posts: 41
Joined: Mon Aug 24, 2009 1:36 pm

Post by Jaklub » Wed Aug 26, 2009 9:33 am

Thanks for tip, also works.

Graz
Very interested
Posts: 81
Joined: Thu Aug 23, 2007 12:36 am
Location: Orlando, FL

Post by Graz » Wed Aug 26, 2009 11:29 am

That's really strange.

Code: Select all

VDP_setTile(APLAN, 1<<13^130, 3, 10);
Should be exactly the same as

Code: Select all

VDP_setTile(APLAN, 130+(1<<13), 3, 10);
The same is true of operator |. Are you sure something else wasn't out of place?

Jaklub
Interested
Posts: 41
Joined: Mon Aug 24, 2009 1:36 pm

Post by Jaklub » Thu Aug 27, 2009 10:27 pm

I got another problem, this time about music. :oops:

I have a bin from MSV Tracker (exported with Export MSV0). When I try to convert it to c/h format with converter from bin folder (using bintocs16.bat) and play it in app, a noise can be heard for about second. When I try to play music from particle example, it is played correctly. Except changing the name of played music, I apply no changes in code.

What program should I use to make bin compatibile with this converter?

Thanks in advance.

plee
Very interested
Posts: 66
Joined: Wed Nov 29, 2006 11:32 am
Location: Houston, Texas

Post by plee » Fri Aug 28, 2009 12:35 am

You could just modify the original routine by adding a palette parameter for future use.

void VDP_setTilePal(u16 plan, u16 tile, u16 x, u16 y, u16 pal)
{
volatile u32 *plctrl;
volatile u16 *pwdata;
u32 addr;

addr = plan + (2 * (x + (VDP_getPlanWidth() * y)));

/* point to vdp port */
plctrl = (u32 *) GFX_CTRL_PORT;
pwdata = (u16 *) GFX_DATA_PORT;

*plctrl = GFX_WRITE_VRAM_ADDR(addr);
*pwdata = tile | (pal << 13);
}

Shiru
Very interested
Posts: 786
Joined: Sat Apr 07, 2007 3:11 am
Location: Russia, Moscow
Contact:

Post by Shiru » Fri Aug 28, 2009 12:57 am

Jaklub wrote:What program should I use to make bin compatibile with this converter?
Why you think problem is with bin2c converter? It is probably problem with MVS output, too old/new version or something.

Jaklub
Interested
Posts: 41
Joined: Mon Aug 24, 2009 1:36 pm

Post by Jaklub » Fri Aug 28, 2009 8:46 am

Plee: Thanks, but I fixed this problem some days ago.
Why you think problem is with bin2c converter?
I think the problem is in bin, not converter. That's what I wrote.
It is probably problem with MVS output, too old/new version or something.
What should I do to change the version of MVS output then? Or what tracker do you recommend?

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Fri Aug 28, 2009 9:30 am

There is Shiru's TFM Music Maker, which is muuuuch more featured than MVStracker is. TFM replay routine lacks support for PCM and PSG though.
There is also my sound engine and tools, but they're not meant for public right now since things aren't in good shape...
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Post Reply