MADRV MusicAdvanceDriver ver 0.05 by Moonlight. ·Purpose ・ Features (for song data creators) ・ Features (for developers) ・ Disadvantages ・ About pitch resolution ・ Differences from X68k version (common part) ・ Differences from the X68k version (GB compatible sound source section) -Differences from the X68k version (PCM8 compatible sound source section) ・ How to create a GBA ROM file with song data ・ How to incorporate in your own software ・ Driver specifications ・ List of valid commands (GB compatible sound source) ・ Invalid command list (GB compatible sound source) ・ List of valid commands (PCM8 compatible sound source) ・ List of invalid commands (PCM8 compatible sound source) ·Purpose There is no free sound driver for Gameboy Advance! If you don't have it, let's make it ・ Features (for song data creators) MXDRV backward compatible and easy to use with familiar MML. You can use old (or worse, dead) mature MML compilers like note.x and mxc.com. Even if you don't have a development environment, you can create a GBAROM file containing songs with an MML compiler. Full control of GBA sound source with PSG 3ch + Noise 1ch + PCM 8ch configuration. You can also edit the PCM for SOUND3 while checking the sound with the attached tone color editor (gb3pcmedit.exe). Player for PogoShell2. ・ Features (for developers) I think it's very easy because you can do while (1); after calling the initialization function by passing the data pointer. See simplesdk / minisdk. Since it is freeware, you can install it in your own games. You can also install it in software that involves money (such as doujin software) without permission. It is OK even if you modify the internal code or create your own format. ・ Disadvantages FM sound source cannot be used because it is not an X68k emulator. The PCM composition section is heavy. I think the sequence part is quite heavy. Please optimize each one if necessary. If define code_Enable * in madrv.c is set to False, the corresponding function will be turned off and it will be a little lighter. Be sure to check "Differences from the X68k version" because the sound source itself to play is completely different. ・ About pitch resolution There are 2048 levels of A / B / C channels. The higher the pitch, the lower the accuracy. Resolution can be gained by lowering the octave with double sample PCM on C channel. The D channel has no concept of pitch. The PCM channel has a fixed pitch. ・ Differences from X68k version (common part) y command: Address 10 corresponds to NR10 and address 43 corresponds to NR43. Write the sweep of A channel into NR10 and the division ratio frequency setting of D channel into NR43. Please do not write to any other addresses as it will be expanded in the future. S / W / MA / MH / $ FO command: Ignored. ・ Differences from the X68k version (GB compatible sound source section) v command: There are 15 levels of A / B / D channels. Since the C channel has 5 levels of volume resolution, the following is supported. v0 = 0% v1 = 25% v2 = 25% v3 = 25% v4 = 50% v5 = 50% v6 = 50% v7 = 50% v8 = 75% v9 = 75% v10 = 75% v11 = 75% v12 = 100% v13 = 100% v14 = 100% v15 = 100% @v command: Simply 1/8 and v command is processed, but volume increase / decrease is processed by @v. F command: The duty ratio will be changed for A / B channels. @ 0 (00): 12.5% ​​(100000001000000010000000) @ 1 (01): 25% (110000001100000011000000) @ 2 (10): 50% (111100001111000011110000). @ 3 (11): 75% (111111001111110011111100). Ignored on C / D channels. @command: For A / B / D channels, this is the envelope change. Actually, it affects Bit0-3 of NR12 / NR22 / NR42 register. 0 No envelope 1 decay 1/64 second 2 decay 2/64 seconds ... 7 decay 7/64 seconds A parameter of +8 will increase the envelope. But I feel like it's not working ... The C channel reads the corresponding 4bit 64step PCM from the gb3pcm file. MP command: The operation (condition) is different from the X68k version, but you should be able to go with the same feeling. All EFGH channels are ignored. -Differences from the X68k version (PCM8 compatible sound source section) v command: Only amplification is possible in 8 steps. v8 = x1 v9 = x2 v10 = x4 v11 = x8 v12 = x16 v13 = x32 v14 = x64 v15 = x128 Do not set v7 or lower. @v command: Simply 1/8 and v command is processed, but volume increase / decrease is processed by @v. F command: Currently, only 15625Hz fixed pitch PCM can be played. If you want to specify it, set F4. F0 one shot (same as F4) F1 loop F2 One-shot pitch variable F3 loop pitch variable F4 one shot (same as F0) In the variable pitch PCM mode, the note 0 PCM of the specified bank is used. The standard note is o4a. Example: P F2 @ 3o4cdefgab Tone No. 3 Note 0 is pronounced at different pitches of -5, -4, -3, -2, -1,0, + 1. ・ How to create a GBA ROM file with song data 1. Create an MDX / PDX file. The compiler is the same as MXDRV, so OK. 2. If you also use gb3pcm, make it with gb3pcmedit.exe. 3. Create an MDA file with mdx2mda.exe. 4. Attach .mda to mda.bin with DOS copy command. that's all. Please refer to make_gba.bat for how to combine with mda.bin. ・ How to incorporate in your own software 1. Include madrv.h / pcmstream.h. 2. Link madrv.o / pcmstream.o / OPM2GBATable.o when making. Regeneration procedure. Initialize pcmstream. sndbuf_StartPCM (); Specify the pointer of song data. madrv_LoadMDA2 (u8 * buf); The first 4 bytes are the magic ID, which is "MDA2". Please specify the pointer including the magic ID. Initialize the driver internal information. madrv_MDARegisterInit (); madrv_GBRegisterInit (); Being in Vsync interrupt processing. Call sndbuf_Vsync_Handler () ;. If sndbuf_Vsync_Handler () returns True, call madrv_Vsync_Handler () ;. Being in DMA1 interrupt processing. Call sndbuf_DMA1_Handler () ;. There is no termination process. The song can be changed at any time if it is not in the interrupt process. Call madrv_Load * (u8 * buf); and madrv_ * RegisterInit () ;. For safety, it is recommended to stop the interrupt before operating. ・ Driver specifications Channel configuration: PSG 3ch + Noise 1ch + PCM 8ch total 12 channels Sequence part: Full MXDRV compatible (if there is no bug) ・ List of valid commands (GB compatible sound source) rest Note on Note off 0xff tempo 0xfe OPM register write 0xfd Tone switch 0xfc bread pot 0xfb volume 0xfa volume down 0xf9 Volume up 0xf8 gate time 0xf7 Thailand (key off disabled) 0xf6 Repeat start 0xf5 Repeat end 0xf4 repeat escape 0xf3 detune 0xf2 portamento 0xf1 Channel data end 0xf0 key-on delay 0xec Phase LFO 0xed PCM mode (change duty ratio) 0xe9 LFO Delay 0xe8 Extended PCM8 Mode ・ Invalid command list (GB compatible sound source) 0xef Sync signal transmission 0xee Sync signal wait 0xeb Volume LFO 0xea OPM LFO 0xe7 Fade out start 0xe6 extended command ・ List of valid commands (PCM8 compatible sound source) rest Note on Note off 0xff tempo 0xfe OPM register write 0xfd (@) PCM bank switch 0xfb volume 0xfa volume down 0xf9 Volume up 0xf8 gate time 0xf7 Thailand (key off disabled) 0xf6 Repeat start 0xf5 Repeat end 0xf4 repeat escape 0xf1 Channel data end 0xf0 key-on delay 0xed PCM mode 0xe8 Extended PCM8 Mode ・ List of invalid commands (PCM8 compatible sound source) 0xfc bread pot 0xf3 detune 0xf2 portamento 0xef Sync signal transmission 0xee Sync signal wait 0xec Phase LFO 0xeb Volume LFO 0xea OPM LFO 0xe9 LFO Delay 0xe7 Fade out start 0xe6 extended command