SGDK usage, need help understanding some parts

SGDK only sub forum

Moderator: Stef

Post Reply
Helghast
Interested
Posts: 29
Joined: Sat May 25, 2013 8:53 pm
Location: Amsterdam, Netherlands
Contact:

SGDK usage, need help understanding some parts

Post by Helghast » Sat May 25, 2013 9:20 pm

Hi guys,

I've been starting into development for Megadrive lately, and have been reading loads of documents and articles to get to grips with how this beast works.
I am getting at a point, where I have questions, but nowhere to ask, so I figured people here might be able to point me into the right directions.

I am having issues trying to understand how palette data and VRAM data combine and work together.

I have 2 images which I want to display, which I both am loading into VRAM using VDP_loadTileData (I have converted my images using GenRes), and am loading the palette data into different pallete's each.

I think I'm right by saying all image data (tiles) get loaded into 1 big "image" on VRAM.

Now when I display these images, how can I define the alpha channel for each image (or tell one not to use alpha at all), or is alpha only reserved for Sprites?

I tried to load tile data and sprites together before (I had no issue displaying them separately), but they seem to get corrupted when I attempt this. How do I load a certain Tile from VRAM?
I see some examples (for instance the sonic animation) do spritename>>8, now my programming skills don't go far enough to know what that exactly does, I believe it's bitshifting, but can someone explain easily what this does behind the scenes?


I am sorry for all the amount of questions in 1 post, I'm just trying to learn and experiment with this, no doubt I'll be posting more stuff later (probably even to get it to run on actual hardware, and yes, I'm aware of the elements required for that).

I hope someone here will take some time to help me, I am also available on twitter and Skype (tw: @rawrDennis, sk: kak-hoofd)

kind regards,
Dennis

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) » Sun May 26, 2013 3:34 am

The VDP takes tile data from VRAM according to the tilemap and sprite list. SPrite list and tilemap both contain 2 bits that determine which of the 4 palettes this tile will use. Each tile is 8x8 block that can have 16 values per pixel. Value of zero is always transparency.
Image is generated on the fly, line by line, there is never a full composited image stored anywhere.
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

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Mon May 27, 2013 1:41 am

Use this DOC:
https://code.google.com/p/genplus-gx/so ... p.txt?r=31
This is MORE than enough, as I think.

Transparent color = index 0 in each palette of CRAM.
You can imagine process like this:
1) Fill background with backdrop color.
2) Draw Plane A over it
3) Draw Plane B over it
4) Draw sprites
(not taking into account the priority flags)
Plane draws according to Plane Map. Plane Map is array (table) of word in VRAM. word in Plane map = tile_index + flags. Flags like: priority, horizontal flip, vertical flip, palette. Location of array selected by specific register in VDP. VRAM = just RAM in VDP, so there can be word values.

Tile size 32 byte. Tiles aligned by 32 byte. Tiles displayed by indexes. So it's normal to bitshift by 5.
Palette id location: 13,14 bits in Plane Map word. So it's normal to bitshift palette id by 13. Or bitshift by 5 and write high byte.

Code: Select all

C++ | M68k| description 
>>  | asr | arithmetic shift right
<<  | asl | arithmetic shift left
|   | or  | bitwise or
&   | and | bitwise and
^   | eor | bitwise xor
~   | not | bitwise not
You can see VDP Ram in some emulators, such as my modification of gens rerecording 11b (for Windows):
http://elektropage.ru/load/0-0-0-1-20
Tools -> VDP Ram
You can see boxes of sprites, if you turn on: Graphics->Layers->Sprites->Sprites Boxing
Emulation quality less than in MESS or RetroArch... But, I have good (for me) Debug! :)
Image

Nemesis
Very interested
Posts: 791
Joined: Wed Nov 07, 2007 1:09 am
Location: Sydney, Australia

Post by Nemesis » Mon May 27, 2013 9:24 am

If your system is up to the task, you can also use my emulator "Exodus" for debugging. It'll give you realtime views into the VRAM and CRAM so you can see what's going on, and it has a bunch of other debug features such as sprite boxing, display regions, layer removal, sprite debugging, etc.

Helghast
Interested
Posts: 29
Joined: Sat May 25, 2013 8:53 pm
Location: Amsterdam, Netherlands
Contact:

Post by Helghast » Tue May 28, 2013 4:39 pm

Hey guys, I think I am grasping all this so far!
Having difficulties getting to load multiple images now though.
Trying to load 2 background images (as BITMAP), but this seems to go horribly wrong.

cant figure out how the index Works. I load one image tiles into memory, and displaying is all fine. Loading the second one seems to graphically explode, is there a flag which calculates how many tiles have been loaded, and appends after that?
or is there a magic way I need to do that myself?

Also, what tools do you use to create a palette? Paint always outputs the same pallette It seems :/

Regards, D.

Helghast
Interested
Posts: 29
Joined: Sat May 25, 2013 8:53 pm
Location: Amsterdam, Netherlands
Contact:

Post by Helghast » Tue May 28, 2013 4:41 pm

Nemesis wrote:If your system is up to the task, you can also use my emulator "Exodus" for debugging. It'll give you realtime views into the VRAM and CRAM so you can see what's going on, and it has a bunch of other debug features such as sprite boxing, display regions, layer removal, sprite debugging, etc.
was using Gens Kmod, with which I managed to do all that too (helped me understand very well!)

Thanks!

Post Reply