Files

83 lines
2.3 KiB
C

// Minimal MSXgl ROM that plays a single PSG VGM generated by the
// msx-music-generator (Claude -> MML -> VGM) pipeline, looping forever.
//─────────────────────────────────────────────────────────────────────────────
#include "msxgl.h"
#include "psg.h"
#include "vgm/vgm_player.h"
#if (VGM_USE_SCC)
#include "scc.h"
#endif
#if (VGM_USE_MSXMUSIC)
#include "msx-music.h"
#endif
#if (VGM_USE_MSXAUDIO)
#include "msx-audio.h"
#endif
// Our generated music: const unsigned char g_MyVGM[]
#include "mytest_vgm.h"
// Library's logo characters
#define MSX_GL "\x02\x03\x04\x05"
// Font
#include "font/font_mgl_sample8.h"
//-----------------------------------------------------------------------------
// Program entry point
void main()
{
// Initialize screen
VDP_SetMode(VDP_MODE_SCREEN1);
VDP_SetColor2(COLOR_BLACK, COLOR_WHITE);
VDP_ClearVRAM();
VDP_EnableVBlank(TRUE);
// The VGM player can drive these chips too; init them if compiled in.
#if (VGM_USE_SCC)
SCC_Initialize();
#endif
#if (VGM_USE_MSXMUSIC)
MSXMusic_Initialize();
#endif
#if (VGM_USE_MSXAUDIO)
MSXAudio_Initialize();
#endif
// Text
Print_SetTextFont(g_Font_MGL_Sample8, 1);
Print_DrawText(MSX_GL " MY VGM TEST");
Print_DrawLineH(0, 1, 32);
// Start our music (loop = TRUE), then report what the header decoded to.
bool ok = VGM_Play(g_MyVGM, TRUE);
Print_SetPosition(0, 3);
Print_DrawFormat("Header: %s\n", ok ? "OK" : "INVALID");
Print_DrawFormat("Version: %1x.%1x%1x\n",
(u8)(g_VGM_Header->Version >> 8) & 0xF,
(u8)(g_VGM_Header->Version >> 4) & 0xF,
(u8)(g_VGM_Header->Version) & 0xF);
Print_DrawFormat("PSG: %c\n", VGM_ContainsPSG() ? '\x0C' : '\x0B');
Print_DrawFormat("MSX-Mus: %c\n", VGM_ContainsMSXMusic() ? '\x0C' : '\x0B');
Print_DrawFormat("Size: %i bytes\n", (u16)sizeof(g_MyVGM));
Print_SetPosition(0, 9);
Print_DrawText("Playing, looping...");
// Main loop: advance the player once per frame (60 Hz).
u8 anim = 0;
while (1)
{
Halt(); // wait for VBlank
VGM_Decode(); // decode/play one frame of VGM
#if (PSG_ACCESS == PSG_INDIRECT)
PSG_Apply();
#endif
// Little spinner so we can see the frame loop is alive.
Print_SetPosition(31, 0);
Print_DrawChar("|/-\\"[(anim++ >> 3) & 3]);
}
}