Add music tracker and music options for the menu and other places in the game. The previous issue #3 notes are incorporated here for reference, this issue supersedes the old one.
Update 2: Pedro Pimienta recommends Vortex Tracker, and that's included in Z88DK out of the box, so I guess it should be the initial option.
Unfortunately Vortex 2 does not allow sound effects mixed with music. Arkos and WYZ do.
Update 3: Arkos can import Vortex files and export Arkos, so this should be way to go: integrate Arkos in RAGE1, music can be created with Vortex and imported by Arkos.
Update 4: proof-of-concept working, ready to integrate.
Update 5: in-game music working, playback issues pending, see below.
Use cases:
Music playing during the menu, while the user selects the controller to use, redefine keys, etc.
Music playing during the game
Sound effects being played during the game
C Functions needed:
Init music player - tracker_init()
Set active music track - tracker_select_song
Start playing - tracker_start
Stop playing - tracker_stop
Periodic play callback - tracker_do_periodic_tasks
Play sound effect - tracker_play_fx
Design notes:
Since player code and music data can be big, and it's used only in 128K mode, everything player related must be stored under banked/128.
All C functions mentioned above must thus be defined as banked functions
All music tracks and effects data should be stored in the same memory bank as the code
Music periodic task must be called with interrupts disabled (in the case of Arkos2)
tracker_init called before callong menú functions
during selection menú, tracker_select_song and tracker_start can be called. Also tracker_do_periodic_tasks must be run 50 times per second
when menú function exits, music_stop is called
when Game starts, Game sound track is selected with tracker_select_song, tracker_start is called and on the main Game loop tracker_do_periodic_tasks is called only once per frame
when player dies, music stops, music player is reset and music is restarted again when new life is on stage.
when Game over, music is stopped
music song can be switched to another one when entering different screens. FLOW rules Will be used for this
[x] Develop new C functions and API - Conditional on ZX_TARGET=128
[x] Add DATAGEN directives in GAME_CONFIG for selecting a music player for 128K mode (first: Arkos) and adding music tracks (binary files that are included as data in the same code bank), and effect tracks (same)
[x] Create new test game with demo music track
[x] Evaluate running tracker periodic task from interrupt handler. When run from the main game loop, if the game gets slow, the music is trashed. If it was run from ISR, this would not happen. Careful with bank switching in ISR context! - Update: tracker music playback is done now in ISR!
[x] Add Arkos sound effects support
[x] Add DATAGEN support for sound effects bank
[x] Add DATAGEN support for sound effects selection
[x] General reorganization of beeper sound effects code, conditional compilation, etc.
[x] Add FLOW action for playing a tracker sound fx
[x] FLOW check that always returns true (need to always do something, e.g. switching song when entering a screen) - _NOTNEEDED
[x] FLOW action to select a music song. Optimize for the case where the song is the current one and do nothing if so.
[x] FLOW action to stop music
[x] FLOW action to start music
[x] Test music playback from menu
[x] Add functions to start and stop at beginning and end of game
Add music tracker and music options for the menu and other places in the game. The previous issue #3 notes are incorporated here for reference, this issue supersedes the old one.
Update: seems ArkosTracker is the way to go?
Update 2: Pedro Pimienta recommends Vortex Tracker, and that's included in Z88DK out of the box, so I guess it should be the initial option.
Unfortunately Vortex 2 does not allow sound effects mixed with music. Arkos and WYZ do.
Update 3: Arkos can import Vortex files and export Arkos, so this should be way to go: integrate Arkos in RAGE1, music can be created with Vortex and imported by Arkos.
Update 4: proof-of-concept working, ready to integrate.
Update 5: in-game music working, playback issues pending, see below.
Use cases:
C Functions needed:
tracker_init()
tracker_select_song
tracker_start
tracker_stop
tracker_do_periodic_tasks
tracker_play_fx
Design notes:
banked/128
.Tasks: