i have spent today thinking about an engine i was writing for a game i was making a few months back. after a while i started wondering about others possible effective ways that other nes developers might use. so, what methods do you all use for games engines?
the method i have used divides the game up in to... uhh.. states.
each state has its own NMI, MGL (main-game-loop), and INIT subs. a subroutine called change_state will lookup the address for the NMI and MGL and copy it to RAM, then it will jump to the address given to INIT to setup all options (timer, controller options, inital background, data loading,etc) for that state. different flags can be set by the three state subs, such as different timer options, to rest for a vblank, check for zapper hit, update sprites, scrolling, etc.
the basic engine flow is similar to this
Reset:
_normal nes startup stuff
_clear ram
_change_to_state 0
main game loop:
_if(zapper) then check zapper hit
_jump to state's MGL
NMI:
_if(timer) then do timer stuff
_get joypad input
_jump to state's NMI
_if(sprite update) update sprites
_if(scroll) set scroll
_rti
the method i have used divides the game up in to... uhh.. states.
each state has its own NMI, MGL (main-game-loop), and INIT subs. a subroutine called change_state will lookup the address for the NMI and MGL and copy it to RAM, then it will jump to the address given to INIT to setup all options (timer, controller options, inital background, data loading,etc) for that state. different flags can be set by the three state subs, such as different timer options, to rest for a vblank, check for zapper hit, update sprites, scrolling, etc.
the basic engine flow is similar to this
Reset:
_normal nes startup stuff
_clear ram
_change_to_state 0
main game loop:
_if(zapper) then check zapper hit
_jump to state's MGL
NMI:
_if(timer) then do timer stuff
_get joypad input
_jump to state's NMI
_if(sprite update) update sprites
_if(scroll) set scroll
_rti