I'm pretty new to NES development and tried creating my first dynamic object manager.
Each object contains of 16 byte (x,y,sprite_address_high,sprite_addres_low,sprite_count,update_address_high,update_address_low, <some object related variables > )
I built a generic update function that jumps to the update address defined in update_address_low and update_address_high for each object sitting in the buffer.
Whenever I want to instantiate a new object at runtime, I just add one to the buffer and it's update will be called automatically.
Here is my problem / question:
I'm using a variable that points to the current object in the buffer. It is increased automatically after update of the current object, pointing to the next object.
Whenever I want to change a value of an object, I need to access them like this:
Code: Select all
;game header / variable definitions OBJECT_BUFFER = $0100 ;SomeObjectUpdate ;Move object's X and Y position (X = first entry, Y = second entry) ldx current_buffer_index lda OBJECT_BUFFER,x adc #$01 sta OBJECT_BUFFER,x clc lda OBJECT_BUFFER+1,x adc #$01 sta OBJECT_BUFFER+1,x clc
Do you think it's a good idea? Will I get performance problems soon? Can it be optimized?