It is currently Sun Dec 10, 2017 5:06 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat Jul 16, 2016 11:16 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1864
Location: DIGDUG
Usually, when I load a level/room, I either...
1.load the room # to x or y, and index to an array of that item...1 byte per room, per array.

Or,
2.load the address of the start the room's data to a pointer, and indirect index (y) to the data.

But, I was going to...let's say, double the maximum possible enemies per room, but only use the extra enemies rarely... Like 10% or less. I feel like this is a huge waste of ROM space, to have an array of 90% zeroes.

What would be a better approach?

If each enemy uses 16 bytes of data (ROM), per 100 rooms, that could be 1500 wasted bytes of ROM space.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sat Jul 16, 2016 11:26 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 596
That'd be a dynamic setup, instead of a single array.

Code:
const struct enemy things[num_rooms][max_enemies];

->

static const struct enemy room0[3];
static const struct enemy room1[32];
const struct enemy * const things[num_rooms] = {
  room0,
  room1,
};


Top
 Profile  
 
PostPosted: Sat Jul 16, 2016 6:56 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1864
Location: DIGDUG
I think I'm just going to have a pointer to each room data set, and terminate each set with FF, so that it doesn't try to load extra enemies in each room.

Any other suggestions?

(Yes, I changed my avatar).

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Jul 17, 2016 1:40 am 
Offline
User avatar

Joined: Fri Feb 27, 2009 2:35 pm
Posts: 215
Location: Fort Wayne, Indiana
dougeff wrote:
pointer to each room data set, and terminate each set with FF

Super Mario Bros, Super Mario Bros 3 and Super Mario World do this.

Seems like the best method to me, really.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group