Problem
sfx_play(byte sound, byte channel) is declared in NESLib but has no 6502 implementation in BuiltInSubroutines.cs. The crypto sample has 6 sfx_play calls that are commented out as a workaround.
// These are all commented out because sfx_play has no implementation:
// sfx_play(3, 2); // pickup sound
// sfx_play(4, 2); // level complete
// sfx_play(5, 3); // attack sound
// sfx_play(1, 0); // damage taken
// sfx_play(2, 3); // enemy killed
// sfx_play(0, 0); // item placed
What's Needed
A 6502 implementation of sfx_play that plays sound effects through the NES APU. This is typically provided by a sound engine like FamiTone2 or Pently.
cc65/neslib implementation
In the original cc65 neslib, sfx_play is part of the FamiTone2 sound engine. It:
- Takes a sound effect index in A and channel (0-3) in X
- Loads the sound effect data pointer from a table
- Starts playback on the specified APU channel
- The NMI handler calls
sfx_update each frame to advance the sound
References
Implementation Options
- Port FamiTone2's sfx routines to
BuiltInSubroutines.cs -- most compatible with existing neslib samples
- Stub implementation -- play a simple beep on the specified channel (minimal but functional)
- No-op -- emit an RTS stub so the transpiler doesn't crash but no sound plays
Context
The crypto sample (PR #211) has 6 sound effects for gameplay feedback. Without sfx_play, the game is silent.
Problem
sfx_play(byte sound, byte channel)is declared in NESLib but has no 6502 implementation inBuiltInSubroutines.cs. The crypto sample has 6 sfx_play calls that are commented out as a workaround.What's Needed
A 6502 implementation of
sfx_playthat plays sound effects through the NES APU. This is typically provided by a sound engine like FamiTone2 or Pently.cc65/neslib implementation
In the original cc65 neslib,
sfx_playis part of the FamiTone2 sound engine. It:sfx_updateeach frame to advance the soundReferences
Implementation Options
BuiltInSubroutines.cs-- most compatible with existing neslib samplesContext
The crypto sample (PR #211) has 6 sound effects for gameplay feedback. Without
sfx_play, the game is silent.