How to not hard code sprites

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
Copy_con^Z
Posts: 10
Joined: Tue May 04, 2021 8:49 pm

How to not hard code sprites

Post by Copy_con^Z »

Currently I’m hard coding my sprites. I know, it’s a pretty bad practice, and I’ll soon need to rework a lot of code. So instead of procrastinating I think I’d better get to it as soon as possible. My problem is I don’t have a clue where to start. Or perhaps I do, but I just underestimate the amount of code needed (since I currently with hard coded sprites don’t need any variables or tables). Could someone please guide me in the right direction?
User avatar
freem
Posts: 176
Joined: Mon Oct 01, 2012 3:47 pm
Location: freemland (NTSC-U)
Contact:

Re: How to not hard code sprites

Post by freem »

The wiki has a pretty nice article on this:
http://wiki.nesdev.com/w/index.php/Don% ... _addresses

The short version: use a byte as an index into your shadow OAM, and have any sprite drawing routines use that index instead of hardcoded addresses.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: How to not hard code sprites

Post by tokumaru »

I posted an example metasprite subroutine recently: viewtopic.php?f=10&t=23011&p=272984#p272984
Copy_con^Z
Posts: 10
Joined: Tue May 04, 2021 8:49 pm

Re: How to not hard code sprites

Post by Copy_con^Z »

Thanks a lot!

It makes things a bit more clear to me.
Post Reply