NOOB ASM - How to load only one tile?

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
User avatar
POLYGAMe
Very interested
Posts: 144
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

NOOB ASM - How to load only one tile?

Post by POLYGAMe » Sun Jul 02, 2017 6:35 am

This is driving me nuts. I have been working away of Big Evil Corp's awesome slides but I'm stuck at how to display just one tile.

I have my 'H' character displaying on screen and all tiles are set to 0 so the following code fills the screen with H characters. All well and good but no matter what I try I can't work out how to set the H to tile index 1 and to set the map to show that tile in a particular place. The closest I have come is loading the tile into position 1536 (0600) in the tilemap and I don't even know why or how that happened. lol.

Here's the bit I have for displaying a screen of characters. Any hints or ideas on where to go from here?

Code: Select all

; Tell VDP we're about to write to VRAM
	SetVRAMWrite 0x0000
	move.l #CharacterH, a0 		; Store H character in address register 0 (a0)
	move.w #0x7, d0				; Loop counter = 8 longwords in tile (-1)
	CharLoop:					; Start of loop
		move.l (a0)+, vdp_data	; Write tile line, post increment address (like for loop)
	dbra d0, CharLoop			; Loop until finished

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

Re: NOOB ASM - How to load only one tile?

Post by TmEE co.(TM) » Sun Jul 02, 2017 6:40 am

Are you sure the SetVRAMwrite creates the correct command word for VDP ?
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

User avatar
POLYGAMe
Very interested
Posts: 144
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: NOOB ASM - How to load only one tile?

Post by POLYGAMe » Sun Jul 02, 2017 6:46 am

TmEE co.(TM) wrote:Are you sure the SetVRAMwrite creates the correct command word for VDP ?
LOL I have no idea. This is all very new to me. Apparently it does this:

Code: Select all

SetVRAMWrite: macro addr
	move.l  #(vdp_cmd_vram_write)|((\addr)&$3FFF)<<16|(\addr)>>14, vdp_control
    endm
^^^ That's from the VDP file from the Big Evil website.

EDIT: I'm beginning to think my brain isn't wired for this stuff and I should go back to the SGDK... had some decent progress there lol.

User avatar
Sik
Very interested
Posts: 592
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: NOOB ASM - How to load only one tile?

Post by Sik » Sun Jul 02, 2017 7:30 am

Multiply the tile ID by 0x20 (i.e. shift left by 5) to get its address in VRAM. In other words, tiles start at 0x0000, 0x0020, 0x0040, 0x0060... all the way up to 0xFFE0 (the last tile). Note that if you're loading consecutive tiles you don't need to set the address again after each one.

I'd suggest learning this even if you go back to SGDK since it's quite a fundamental part of the hardware and will help a lot when debugging. Knowing how graphics are stored in VRAM is considered a basic concept on the console =P
Sik is pronounced as "seek", not as "sick".

User avatar
POLYGAMe
Very interested
Posts: 144
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: NOOB ASM - How to load only one tile?

Post by POLYGAMe » Sun Jul 02, 2017 7:48 am

Sik wrote:Multiply the tile ID by 0x20 (i.e. shift left by 5) to get its address in VRAM. In other words, tiles start at 0x0000, 0x0020, 0x0040, 0x0060... all the way up to 0xFFE0 (the last tile). Note that if you're loading consecutive tiles you don't need to set the address again after each one.

I'd suggest learning this even if you go back to SGDK since it's quite a fundamental part of the hardware and will help a lot when debugging. Knowing how graphics are stored in VRAM is considered a basic concept on the console =P
Thanks for your reply :) Yeah I'll press on with it.

So how do I actually set my character to have tile ID1? And the map... I just want to set my character to tile ID1 then place that on that map in a certain position. I think I get how the tiles work it's just the actual setting the ID. I have no idea where that's happening. I know all tiles are set to 0 in my code as every one displays my character which means the character's tile ID must be 0 right? That's the bit I'm stuck on... how to specity the ID. Where is this done?

EDIT: Okay, I get it now. I managed to set the tile to ID1 :D Now I just need to work out how to set the map. I think I know what to do now. Thanks for your help!!!

ANOTER EDIT: I did it! Thanks so much for the help, everyone, teaching this old dog new tricks!

Cheers!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests