Using a map

SGDK only sub forum

Moderator: Stef

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Using a map

Post by oofwill » Tue Jan 22, 2013 8:53 pm

I'm trying to use a map generated by genitile.

I'm using two map. One for drawing foreground of level, the second for object to collect (ex gold pieces)

I'm able to read the map so i can draw my foreground.
Then, able too to place my gold pieces using the second map.

But while taking a gold piece, i want to write the map to delete the piece at this place, but it doesn't work :|

Maybe i'm not using the good method?

My code reading and placing the gold piece tile (working)

Code: Select all

VDP_setTileMap(BPLAN, TILE_ATTR(0,0,0,0)+(level1objets_map[i+j*40]+1), k, l);
My code, trying to delete one gold piece:

Code: Select all

level1objets_map[i+j*40]=0;
VDP_setTileMap(BPLAN, TILE_ATTR(0,0,0,0)+(level1objets_map[i+j*40]+1), k, l);
tile 0 is transparent. but level1objets_map[i+j*40]=0; don't seems to work...

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) » Tue Jan 22, 2013 9:14 pm

Are you trying to modify what is in ROM ?
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

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Tue Jan 22, 2013 9:20 pm

With your comment i begin to understand that what i'm trying to do is impossible. :lol:

So i suppose i can't modify a value in map because it's read directly from rom?

How can i do to have a plan of where my items are, and modify it when one item is taken?

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) » Tue Jan 22, 2013 11:29 pm

Perhaps generate a compact table into main RAM from the ROM map and do modifications there, and then compare the 2 and decide if an item is taken or not.
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

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Wed Jan 23, 2013 1:46 am

You'll need a copy of the level objects in ROM so that you always know their initial state when starting the level.

When you're playing the level, you'll need to make a copy of the level objects in RAM so that you can know what their state is.

When you restart the level, recopy the level object data from ROM to the copy in RAM.

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Wed Jan 23, 2013 5:47 pm

Thanks for advice, i've been thinking this night and this is the solve i found.

I'll create a table in wich i copy map of the objects, as you say.

Thanks again, it's always more easier to find response when problem is written on a board, and after a good night too :lol:

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Tue Jan 29, 2013 12:30 pm

Hi,

I'm now able to use a map correctly as you can see here

However, map is just 320*1728 pxls.

I've tried to test with a big map (792*1920pxl) and the problem is i can't compile project anymore:

Code: Select all

-------------- Build: default in Miracle_World_MD ---------------

Using makefile: C:\SGDK\makefile.gen
ld: address 0x1002bd2 of out/rom.out section .bss is not within region ram
make: *** [out/rom.out] Error 1
Process terminated with status 2 (0 minutes, 3 seconds)
0 errors, 0 warnings
 
I suppose map file is to big right? (size:47520 bytes)
if not, what means this message?

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Tue Jan 29, 2013 12:43 pm

you're right your array is too big to fit within ram.

nice project btw :D Alex kid in miracle is a great game (childhood memory :))

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Tue Jan 29, 2013 12:49 pm

Ok i see.

What is maximum size for it?
I will do it in several files :)

Yes, i really like Miracle World and want to play it sometimes, but don't want to plug in my master system :lol:

Don't sure i made the good choice beetwen plug my old system or reprogram the game :lol:

thanks :)

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Tue Jan 29, 2013 1:45 pm

If your map array is not declared as "const", then it'll be stored in ram. If your array is const, then it'll be stored in rom.

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Tue Jan 29, 2013 1:45 pm

if you count
320 pix = 40 tiles
1728 pix = 216 tiles

40*216 = 8640 tiles * 2 bytes (size of one map entry) = 17280 bytes
almost 1/4 of your memory for a array... + add the memory footprint of the SGDK...

you don't have to do such big array in memory , as in alex kidd , i think you can not go back

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Tue Jan 29, 2013 1:54 pm

Ok i see.

My map is declared as :

Code: Select all

* ---------------------------
.global level1_map
level1_map:
* ---------------------------
* size:47520 bytes

	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
	dc.w 0x0000
How can i declare it as "const"?

I use to write:

Code: Select all

extern u16 level1_map[];
But i if write "extern const level1_map[];", this won't work since sgdk tell me it's declared as int...

And pascal, you're right, no use to go back in alex kidd, but as i'm new in coding, i try to build a correct scroll engine, in all direction, wich will be usefull for another game :)

EDIT: if i write extern const u16 level1_map[];
map will be stored in rom and not ram?

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Tue Jan 29, 2013 2:10 pm

Oh right, you're working in assembly. I was talking about doing it in C. I don't know what the syntax is in assembly.

oofwill
Very interested
Posts: 173
Joined: Mon May 03, 2010 6:12 pm
Location: France - Niort

Post by oofwill » Tue Jan 29, 2013 2:14 pm

I'm using assembly only for map. i think i'm complicating things :lol:

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Tue Jan 29, 2013 2:45 pm

genitile can generate h file (btw good choice of tools :D)

Post Reply