Are there any tutorials for creating an object system?

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
User avatar
SpencerKR
Posts: 19
Joined: Tue Aug 18, 2020 12:54 pm

Are there any tutorials for creating an object system?

Post by SpencerKR » Tue Aug 18, 2020 1:03 pm

Hello. As my very first babby NES project advances out of the "move a single metasprite on the screen" phase, I'm attempting to go through and refactor my hard-coded subroutines.

While I'm familiar enough with object oriented programming in High Level languages like C# and LISP, I'm struggling to bring those ideas into assembly. So far it's been a string of headaches over trying to remember which addressing mode to use and just yuck. And before I give myself too many more migraines, I would love to check out any examples or tutorials on object systems in assembly.

My overall goal is to have a system which calls update code for all my objects once per NMI, handles their movement, their animations, their logic, everything.

What I have right now is a few subroutines that do that, but only for a specific sprite. Any documentation out there?

For reference, my long long term goal is to make a point and click adventure.
Last edited by SpencerKR on Tue Aug 18, 2020 2:41 pm, edited 1 time in total.

lidnariq
Posts: 9655
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Are there any tutorials for creating an object system?

Post by lidnariq » Tue Aug 18, 2020 1:30 pm

Why not either write an implementation of lisp or use this one?

User avatar
SpencerKR
Posts: 19
Joined: Tue Aug 18, 2020 12:54 pm

Re: Are there any tutorials for creating an object system?

Post by SpencerKR » Tue Aug 18, 2020 2:35 pm

Reasons not to use Lisp are firstly that for my own gratification I want to write mostly assembly for this project but more to the point, to make a 6502 game engine in Lisp, I'd still have to know how to create an object system for the 6502, even if the compiler doesn't have to run on the 6502 processor, so even if I change my mind I still need the same information as before :)

I mean... I guess I could write a whole NES game in the functional style? But even something like that will eventually approximate an object system with structs and loops

User avatar
Quietust
Posts: 1596
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Are there any tutorials for creating an object system?

Post by Quietust » Tue Aug 18, 2020 2:59 pm

Whatever your objects are, they're all going to need to keep track of certain properties - size, position, velocity, various state flags, what they look like, what they do during each frame, what they do when you interact with them, and what they do when they interact with other objects. Some of those values could be numbers, some could be raw pointers (e.g. to code), and some could be indexes into globally-defined arrays of pointers (e.g. to structures filled with sprite tiles and relative offsets for various animation frames). You could define an array of structures, each one containing the state for each object, or you could define one array for each object property so you don't have to mess with indirect addressing (in fact, this is what the NES version of the SCUMM engine does).

You also don't have to define everything as a single object type - for example, SCUMM has "Objects" (used for all of the things you can interact with in each room), and it also has "Actors" (for all of the characters that walk around, talk, and do other things), and even things like Verbs are dynamically configurable (e.g. some verbs are disabled under certain circumstances). Each object type has different properties, and they typically wouldn't be interchangeable so you don't necessarily need to mess with things like subclasses and inheritance (which could have significant amounts of overhead in 6502 assembly).

This is by no means meant to be a comprehensive list, but it should at least get you pointed in the right direction.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
SpencerKR
Posts: 19
Joined: Tue Aug 18, 2020 12:54 pm

Re: Are there any tutorials for creating an object system?

Post by SpencerKR » Tue Aug 18, 2020 3:16 pm

Thanks! That's a darn good outline

Post Reply