It is currently Wed Dec 12, 2018 12:59 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Fri Aug 10, 2012 3:06 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20865
Location: NE Indiana, USA (NTSC)
The solution that 3gengames gave works, and I use it in my own games. But it'll run into flicker problems once you start doing raster effects, such as scrolling with a still status bar.


Top
 Profile  
 
PostPosted: Sat Aug 11, 2012 9:02 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11011
Location: Rio de Janeiro - Brazil
That is indeed the most straightforward way to make use of NMIs, but like tepples said, it might screw up raster effects (i.e. mid-screen changes to the scroll, palettes, etc.) in case your frame logic takes longer than the time of a NES frame (in most games that happens only when lots of objects are active at the same time). If you are sure your frame calculations will never take too long to finish (usually the case of most puzzle games and games with little variation in the number of on-screen objects), that NMI solution is safe to use.


Top
 Profile  
 
PostPosted: Sat Aug 11, 2012 3:38 pm 
Offline
User avatar

Joined: Sun Jan 02, 2011 11:50 am
Posts: 522
This isn't hard to change is it? You could have the NMI routine take care of screen updates and split screen and exit and return to the selected engine with the same basic structure. I'm actually working on this right now. This may be a bit much for the OP (not really that complex) but I use something like this:

Code:
main_jump_vector:     .res 3 ; 3 bytes for jmp (lo)(hi)

.proc reset

  standard_init     ;video + sound is off
   
  set_new_engine_state state_titlescreen     ; initial gamecode pointer
   
  set_PPU_CTRL CR_NMI,1     ; Turn on NMI before MainLoop, never turn it off (video still off)
   
  Mainloop:

   : bit NMIhit      ; Wait for a 
   bpl :-         ; NMI to occur
   clrflag NMIhit    ; before proceeding
      
   jsr main_jump_vector
      
 jmp Mainloop ;}
   
   
.endproc

; -----------------------------------------------

.proc   state_titlescreen
   [do stuff, then:]
   set_new_engine_state state_readyscreen
   rts
.endproc

.proc   state_readyscreen
   [do stuff, then:]
   set_new_engine_state state_gameplay
   rts
.endproc


.proc   state_gameplay
   [do stuff, then:]   
   set_new_engine_state state_gameover   
   rts
.endproc



.proc   state_gameover
        [do stuff, then:]   
   set_new_engine_state state_titlescreen
   rts
.endproc

;----------------------


.macro set_new_engine_state engine_state
   
   lda #_RTS_
   sta main_jump_vector
   lda #<(engine_state)
   sta main_jump_vector+1
   lda #>(engine_state)
   sta main_jump_vector+2
   lda #_JMP_
   sta main_jump_vector
   
.endmacro


I am working on it now, but I have decided that every engine should expect rendering to be off when started and should turn it off before changing to a new state - but no changes are made directly - nothing happens to the PPU side of the NES until NMI - it updates all changes based on flags marking data that is ready.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group