Skip to content

Commit

Permalink
examples: Add Maxmod + NitroFAT example
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioND committed Aug 1, 2023
1 parent 41b479b commit b88b00e
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/maxmod_nitrofat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nitrofat/soundbank.bin
25 changes: 25 additions & 0 deletions examples/maxmod_nitrofat/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: CC0-1.0
#
# SPDX-FileContributor: Antonio Niño Díaz, 2023

BLOCKSDS ?= /opt/blocksds/core

# User config

NAME := maxmod_nitrofat
GAME_TITLE := Maxmod NitroFAT example

# Source code paths

SOURCEDIRS := source
AUDIODIRS := audio
# When a directory is added to NITROFATDIR, the Makefile rules will save the
# soundbank to that directory instead of the build directory.
NITROFATDIR := nitrofat

# Libraries

LIBS := -lnds9 -lmm9
LIBDIRS := $(BLOCKSDS)/libs/maxmod

include ../../tests/Makefile.include
Binary file not shown.
Binary file added examples/maxmod_nitrofat/audio/parallax_80599.xm
Binary file not shown.
2 changes: 2 additions & 0 deletions examples/maxmod_nitrofat/nitrofat/placeholder.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This is here so that the NitroFAT filesystem isn't empty and the Makefile
creates the Maxmod soundbank here.
110 changes: 110 additions & 0 deletions examples/maxmod_nitrofat/source/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: Antonio Niño Díaz, 2023

#include <stdbool.h>
#include <stdio.h>

#include <filesystem.h>
#include <maxmod9.h>
#include <nds.h>

#include "soundbank.h"

// - lasse_haen_pyykit.xm
//
// XM module by Lasse. Obtained from the original libxm7 example by sverx
//
// - Parallax Glacier by Raina
//
// http://modarchive.org/index.php?request=view_by_moduleid&query=163194

int main(int argc, char **argv)
{
consoleDemoInit();

printf("maxmod NitroFAT example\n");
printf("=======================\n");
printf("\n");
printf("START: Return to loader\n");
printf("\n");
printf("\n");

// It isn't needed to call fatInitDefault() manually. If nitroFSInit detects
// that the ROM is running in a flashcard or from the DSi internal SD slot,
// it will call it internally.
bool init_ok = nitroFSInit(NULL);
if (!init_ok)
{
perror("nitroFSInit()");
while (1)
{
swiWaitForVBlank();
uint16_t keys = keysDown();
if (keys & KEY_START)
return 0;
}
}

printf("NitroFAT init ok!\n");
printf("\n");
printf("\n");

printf("X: haen pyykit by Lasse\n");
printf("Y: Parallax Glacier by Raina\n");
printf("\n");
printf("B: Stop song\n");
printf("\n");

mmInitDefault("nitro:/soundbank.bin");

mmLoad(MOD_PARALLAX_80599);
mmLoad(MOD_LASSE_HAEN_PYYKIT);

soundEnable();

bool playing = false;

while (1)
{
swiWaitForVBlank();

scanKeys();

uint16_t keys_down = keysDown();

if (keys_down & KEY_B)
{
if (playing)
{
mmStop();
playing = false;
}
}

if (keys_down & KEY_X)
{
if (playing)
mmStop();

mmStart(MOD_LASSE_HAEN_PYYKIT, MM_PLAY_LOOP);
playing = true;
}

if (keys_down & KEY_Y)
{
if (playing)
mmStop();

mmStart(MOD_PARALLAX_80599, MM_PLAY_LOOP);
playing = true;
}

if (keys_down & KEY_START)
break;
}

soundDisable();

return 0;
}

0 comments on commit b88b00e

Please sign in to comment.