User:Zzo38/Hardware NSF: Difference between revisions

From NESdev Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 5: Line 5:
Memory from $4018-$403F would be filled by a 40-byte ROM used for an interrupt routine. Writing to this memory is used to switch between main routine and program/data from .NSF file in the $8000-$FFFF space. (Famicom Disk System uses some of these addresses but NSF only uses the audio registers, not these ones.)
Memory from $4018-$403F would be filled by a 40-byte ROM used for an interrupt routine. Writing to this memory is used to switch between main routine and program/data from .NSF file in the $8000-$FFFF space. (Famicom Disk System uses some of these addresses but NSF only uses the audio registers, not these ones.)


When the main routine is enabled, $8000 is RAM (used to store the current song number) and $8001-$FFFF is ROM. (Note: This might not be best idea. It could use $8000-$BFFF as mirrors of the single byte of RAM stored there, instead.)
When the main routine is enabled, $8000-$BFFF is a single byte of RAM (used to store the current song number; mirrored) and $C000-$FFFF is ROM (also mirrored; not much ROM is needed).


The hardware generate IRQ at the rate specified in the NSF header. When IRQ is called, the IRQ vector should be read as $4018 whenever it is checked.
The hardware generate IRQ at the rate specified in the NSF header. When IRQ is called, the IRQ vector should be read as $4018 whenever it is checked.
Line 23: Line 23:
** If LEFT is pushed:
** If LEFT is pushed:
*** Decrement current song number. If it is zero it wraps around.
*** Decrement current song number. If it is zero it wraps around.
*** Wait for button is not pushed.
** If RIGHT is pushed:
** If RIGHT is pushed:
*** Increment current song number. If it is too high it wraps to zero.
*** Increment current song number. If it is too high it wraps to zero.
*** Wait for button is not pushed.
** If START is pushed:
** If START is pushed:
*** Initialize the sound registers by writing $00 to $4000-$4013, $0F to $4015.
*** Initialize the sound registers by writing $00 to $4000-$4013, $0F to $4015.

Revision as of 21:06, 27 August 2012

These are some of my ideas for hardware NSF.

Hardware

Memory from $4018-$403F would be filled by a 40-byte ROM used for an interrupt routine. Writing to this memory is used to switch between main routine and program/data from .NSF file in the $8000-$FFFF space. (Famicom Disk System uses some of these addresses but NSF only uses the audio registers, not these ones.)

When the main routine is enabled, $8000-$BFFF is a single byte of RAM (used to store the current song number; mirrored) and $C000-$FFFF is ROM (also mirrored; not much ROM is needed).

The hardware generate IRQ at the rate specified in the NSF header. When IRQ is called, the IRQ vector should be read as $4018 whenever it is checked.

Another thing the hardware will do is convert the audio to digital and whenever the name tables are being accessed, make the pattern tables read as a waveform view of the music being played.

Main Routine

  • Disable IRQ.
  • Wait for PPU.
  • Write the starting song number to $8000.
  • Set up palette.
  • Fill up the nametable with the title and so on from the NSF header, and with the current and maximum song number, and indicate the music is stopped.
  • Enable background.
  • Loop:
    • Update the display of the current song number.
    • If LEFT is pushed:
      • Decrement current song number. If it is zero it wraps around.
      • Wait for button is not pushed.
    • If RIGHT is pushed:
      • Increment current song number. If it is too high it wraps to zero.
      • Wait for button is not pushed.
    • If START is pushed:
      • Initialize the sound registers by writing $00 to $4000-$4013, $0F to $4015.
      • Initialize the frame counter to 4-step mode ($40 to $4017).
      • Write initial bank values to $5FF6-$5FFF.
      • Update display to indicate song is playing.
      • Load value at memory $8000 into the accumulator.
      • Load zero into the X register.
      • Jump to the start routine.
  • Stop routine:
    • Disable interrupts.
    • Turn off all audio.
    • Reset the stack pointer.
    • Update display to indicate song is stopped.
    • Go to main loop checking which button is pushed.

Interrupt Routine

  • Check if the A button is pushed.
  • If the A button is pushed:
    • Enable main routine ROM.
    • Jump to the stop routine.
  • Call the play subroutine.
  • Reset the stack pointer.
  • Enable interrupts.
  • Run an idle loop doing nothing.
  • Start routine:
    • Disable main routine ROM.
    • Call the init subroutine.
    • Enable interrupts.
    • Run an idle loop doing nothing.