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: 8
Joined: Wed May 05, 2021 3:04 am

How to not hard code sprites

Post by Copy_con^Z » Thu Jun 10, 2021 8:41 am

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: 168
Joined: Mon Oct 01, 2012 3:47 pm
Location: freemland (NTSC-U)
Contact:

Re: How to not hard code sprites

Post by freem » Thu Jun 10, 2021 12:20 pm

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: 12105
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: How to not hard code sprites

Post by tokumaru » Thu Jun 10, 2021 3:17 pm

I posted an example metasprite subroutine recently: viewtopic.php?f=10&t=23011&p=272984#p272984

Copy_con^Z
Posts: 8
Joined: Wed May 05, 2021 3:04 am

Re: How to not hard code sprites

Post by Copy_con^Z » Fri Jun 11, 2021 1:50 am

Thanks a lot!

It makes things a bit more clear to me.

Post Reply