flash · 349792
Still got audio probs (well, music)
Maybe HK has got some time to write a little C program to show me how you use IPC with libXM7?
Funny you mention it I'm working on a little demo now...
#define XM7_IPC (*((vu32*)0x027FF000 + 32))
.arm .align .text .global initMusic .global stopMusic #define XM7_MODULEMANAGER_TYPE_SIZE 0xCE8 #define XM7_MODULE_IPC IPC+0x20 #define XM7_STOP -1 #define XM7_MOD_NOT_LOADED 0 #define XM7_MOD_LOADED 1 initMusic: stmfd sp!, {r0-r1, lr} @ set r1 to module to play and call push {r1} ldr r0, =modLoaded ldr r1, [r0] ldr r2, =XM7_MOD_NOT_LOADED cmp r1, #XM7_MOD_LOADED streq r2, [r0] bne initMusicContinue bl stopMusic bl swiWaitForVBlank bl XM7_UnloadXMinitMusicContinue: pop {r1} ldr r0, =Module @ Pointer to module data bl XM7_LoadXM @ Load module bl DC_FlushAll @ Flush ldr r0, =XM7_MODULE_IPC @ Location in IPC for XM7 control ldr r1, =Module @ Send module data location str r1, [r0] ldmfd sp!, {r0-r1, pc} @ --------------------------------------- stopMusic: stmfd sp!, {r0-r1, lr} ldr r0, =XM7_MODULE_IPC @ Location in IPC for XM7 control ldr r1, =XM7_STOP @ Send stop command str r1, [r0] ldmfd sp!, {r0-r1, pc} @ --------------------------------------- .data .alignmodLoaded: .word 0 Module: .space XM7_MODULEMANAGER_TYPE_SIZE .pool .end
#define XM7_MODULE_IPC IPC+0x20 #define XM7_STOP -1 #define MUSIC_CHANNEL 0 #define SOUND_CHANNEL 1 #define FORCE_SOUND_CHANNEL 2 #define STOP_SOUND -1 #define NO_FREE_CHANNEL -1 #define FIND_FREE_CHANNEL 0x80 .arm .align .text .global main interruptHandlerVBlank: stmfd sp!, {r0-r8, lr} ldr r1, =XM7_MODULE_IPC ldr r0, [r1] cmp r0, #0 blgt XM7_PlayModule ldr r0, =XM7_MODULE_IPC ldr r1, [r0] mov r2, #0 cmp r1, #0 strgt r2, [r0] ldr r0, =XM7_MODULE_IPC ldr r1, [r0] cmp r1, #XM7_STOP bleq XM7_StopModule ldr r7, =IPC_SOUND_DATA(SOUND_CHANNEL) @ Get a pointer to the sound data in IPC ldr r8, =IPC_SOUND_LEN(SOUND_CHANNEL) @ Get a pointer to the sound data in IPC ldr r2, =IPC_SOUND_CHAN(SOUND_CHANNEL) @ Get a pointer to the sound data in IPC ldr r3, =IPC_SOUND_RATE(SOUND_CHANNEL) @ Get a pointer to the sound data in IPC ldr r4, =IPC_SOUND_VOL(SOUND_CHANNEL) @ Get a pointer to the sound data in IPC ldr r5, =IPC_SOUND_PAN(SOUND_CHANNEL) @ Get a pointer to the sound data in IPC ldr r6, =IPC_SOUND_FORMAT(SOUND_CHANNEL) @ Get a pointer to the sound data in IPC ldr r0, [r7] @ Read the value ldr r1, [r8] @ Read the value ldrb r2, [r2] @ Read the value ldr r3, [r3] @ Read the value ldrb r4, [r4] @ Read the value ldrb r5, [r5] @ Read the value ldrb r6, [r6] @ Read the value mov r8, #0 @ Value to reset cmp r0, #STOP_SOUND @ Stop Sound value? streq r8, [r7] @ Clear the data bleq stopSound @ Stop Sound cmp r0, #0 @ Is there data there? strgt r8, [r7] @ Clear the data blgt playSound @ If so lets play the sound ldmfd sp!, {r0-r8, pc} @ restore registers and return @ ------------------------------------
You get an error running the demo I posted in No$? Wierd I didn't get any errors at all.
interruptHandlerVBlank: stmfd sp!, {r0-r8, lr} ldr r1, =XM7_MODULE_IPC ldr r0, [r1] cmp r0, #0 @ --here-- blgt XM7_PlayModule @rest of code removed
ldr r2, #0strgt r2, [r1]
[...] I do have another idea though and that is to get all the xm's from MMLL and have them rotate through in the C++ demo and see if it's problem caused by the xm's themselves.
ldr r0, =Module @ <-- THIS LINE OF CODE WAS MISSING!!!bl XM7_UnloadXM
Music bug fixed!!! I can't believe how stupid this mistake was.. I didn't realise XM7_UnloadXM required a pointer to the module struct! So I was calling it without placing the module struct pointer in r0 first
DOH! It's amazing how much havok one line of code can cause. Sorry about putting you on a wild goose chase sverx although we did find some wierd FIFO bug along the way.
Great idea SF!!
Err did you notice I fixed the music bug? I even created a stripped back version of MMLL with just the music engine for testing. Only took me about 4 hours of work lol Thought you would be dancing around in excitement PS. I was thinking about splitting the music bug posts into their own thread whaddathink? I think they are quite pointless now. Hmm I don't think I even know how to do that come to think of it.
I still think it should be a separate release (MMG2H?), so that everybody can enjoy them even not completing the LL game. This way there will be also more memory Btw I still haven't had a chance too see anything new...