Mlib V0.2 Sources Availabe..


mr.spiv

Certified Guru
Joined
Jan 19, 2003
Messages
462
mlib v0.2 - a tiny alternative module player & SFX library for GP32 is now available for download. No bells and whistles, no any SDK dependency, fast, etc.. (and hopefully not too bugged). Check http://www.deadcoderssociety.org for the archive.
 
Arr.. just noticed that the player.c file had mixer code selection forced to "C-version". So if you want to have asm mixer etc you need to edit the "ifdefs" in the file a bit. sowwy :blink:
 
Is it any faster than CHN's one ? smile.gif

I havent success to made a correct compilation with my GCC 3.4.1 ... I dont know why, but when I'll success , i'll made a little bench sure.
Today I think with ASM mixer this lib will be faster than CHN's.

JYCET
 
JyCet posted on Apr 11 2005 at 10:24 AM said:
Is it any faster than CHN's one ? smile.gif

I havent success to made a correct compilation with my GCC 3.4.1 ... I dont know why, but when I'll success , i'll made a little bench sure.
Today I think with ASM mixer this lib will be faster than CHN's.

JYCET

What's the problem? I know that Makefiles might have "issues" on Winblow$ systems e.g.
I seem to use PWD environment variable, which should contain a full path to your current
working directoty. Or is it something else? :blink:
 
Last edited by a moderator:
Sanosuke posted on Apr 11 2005 at 06:40 AM said:
It strongly interests me ^_^ I'll try to compile my shoot using this mod lib (I use ADS) =)

Is it any faster than CHN's one ? :)

if you convert all those inline ASM chuncks to ADS convention, please send those to me also :p
 
Last edited by a moderator:
Ok this is my makefile:

Code:
PROG_NAME = spivmod
LONG_PROG_NAME = Spiv Mod lib
OBJS = gpmain.o gpstart.o asmfuncs.o
AUTHOR = JyCet 2K5
ICON = icone.bmp

SDK_INCLUDE_DIR = C:/devkitARM_r8/include
SDK_LIB_DIR = C:/devkitARM_r8/arm-elf/lib
SDK_LIBS = -lgpfont -lgpstdlib -lgpos -lgpgraphic -lgpstdio -lgpsound -lgpmem
OTHER_LIBS = 


CC = arm-elf-gcc
AS = arm-elf-as

INCDIRS = -Ic:/devkitARM_r8/include -I$(SDK_INCLUDE_DIR)

CPPFLAGS = $(INCDIRS) -DLITTLE_ENDIAN -DGP32 -mcpu=arm9tdmi -mtune=arm9tdmi -fexpensive-optimizations -mapcs -O3 -mstructure-size-boundary=8 -mno-thumb-interwork -fno-builtin -fno-common -fno-exceptions -finline-functions -fomit-frame-pointer -fshort-enums -ffast-math -fshort-double

LDBASEFLAGS = -L$(SDK_LIB_DIR) -specs=gp32_gpsdk.specs $(SDK_LIBS) $(OTHER_LIBS)


CFLAGS =  $(CPPFLAGS) 
LDFLAGS = $(STRIP) $(LDBASEFLAGS)

TARGET	= $(PROG_NAME).fxe

all:	$(TARGET)

cleanobjs:
	del /F $(OBJS)

cleanbin:
	del /F $(PROG_NAME).fxe $(PROG_NAME).gxb $(PROG_NAME).elf

clean:	cleanobjs cleanbin

# Dependency rules

$(TARGET): $(PROG_NAME).gxb
#	b2fxec -t "$(LONG_PROG_NAME)" -a "$(AUTHOR)" -b "$(ICON)" $? $@
	b2fxec -t "$(LONG_PROG_NAME)" -a "$(AUTHOR)" $? $@
	del /f $(OBJS)
	del /f $(PROG_NAME).elf

$(PROG_NAME).gxb: $(PROG_NAME).elf
	arm-elf-objcopy -O binary $? $@
	
$(PROG_NAME).elf: $(OBJS)
	$(CC) $? $(LIBDIRS) $(LDFLAGS) -o $@

i've put your 6 files:
gp32.h (i'm not sure if it's necesary or not)
player.c - main player code & mixer (portable)
player.h - structures etc
sound.c - GP32 specific direct hardware level DMA sound buffer
sound.h - structures etc for the above
asmfuncs.s - optional context switch code for "out of IRQ mixing"
in the same directory as my gpmain.c

this is the gpmain.c:
Code:
#include "player.h"
#include "sound.h"
#include "gp32.h"

#include "gpdef.h"
#include "gpstdlib.h"
#include "gpgraphic.h"
#include "gpstdio.h"
#include "gpmain.h"

#include "mod.h"

GPDRAWSURFACE gpDraw[2];

void setCPUSpeed( long mclk, int fac, int div) {
	asm volatile(""
  "mov	r0,%0  	\n"
  "mov	r1,%1  	\n"
  "mov	r2,%2  	\n"
  "stmdb	sp!,{r0,r1,r2,lr}	\n"
  "mov	r0,sp  	\n"
  "swi	#0x0d  	\n"
  "add	sp,sp,#12  \n"
  "ldmia	sp!,{lr}"
  : 
  : "r"(mclk),"r"(fac),"r"(div)
  : "r0","r1","r2");
}

void mmuChange( unsigned char *s, unsigned char *e, int flg ) {
	asm volatile(""
  "mov	r0,%0  	\n"
  "mov	r1,%1  	\n"
  "mov	r2,%2  	\n"
  "stmdb	sp!,{lr}  \n"
  "swi	#0x02  	\n"
  "ldmia	sp!,{lr}"
  : 
  : "r"(s),"r"(e),"r"(flg)
  : "r0","r1","r2");
}

void installIRQ( int num, void (*irq)(void) ) {
	asm volatile(""
  "stmdb	sp!,{lr}  \n"
  "mov	r0,%0  	\n"
  "mov	r1,%1  	\n"
  "swi	#0x09  	\n"
  "ldmia	sp!,{lr}"
  : 
  : "r"(num),"r"(irq)
  : "r0","r1");
}

void removeIRQ( int num ) {
	asm volatile(""
  "stmdb	sp!,{lr}  \n"
  "mov	r0,%0  	\n"
  "swi	#0x0a  	\n"
  "ldmia	sp!,{lr}"
  :
  : "r"(num)
  : "r0");
}

void ARMDisableInterrupt( void ) {
	asm volatile(""
  "mrs	r0,CPSR  	\n"
  "orr	r0,r0,#192  \n"
  "msr	CPSR_fsxc,r0	\n"
  :
  :
  : "r0");
}

void ARMEnableInterrupt( void ) {
	asm volatile(""
  "mrs	r0,CPSR  	\n"
  "bic	r0,r0,#128  \n"
  "msr	CPSR_fsxc,r0	\n"
  :
  :
  : "r0");
}

//void waitLine( int line ) {
//	while ((rLCDCON1 >> 18) != line);
//}

//
//
//
////////////////////////////////////////////////////////////////////
//
//
//
// A simple main program to demonstrate playing a sound.
//
//
////////////////////////////////////////////////////////////////////

void *mymalloc( int size ) {
	// This SHOULD! be done with malloc() and then
	// fixing caches properly.. but I was lazy
	//
	// Make sure that the memory this function returns has no
	// caches or writeback enabled. Otherwise you will get unwanted
	// side effects - at least on GP32.
	return (void *)(0x0C7B4000+16*240);
}

void myfree( void *p ) {
	// Free the allocted memory..
}

void myinstallirq( int i, void (*f)(void), struct soundBufParams *p ) {
	installIRQ(i,f);
}

void myremoveirq( int i ) {
	removeIRQ(i);
}

void GpMain(void *arg)
{
	GpGraphicModeSet(8,NULL);
	GpLcdSurfaceGet(&gpDraw[0], 0);
	GpLcdSurfaceGet(&gpDraw[1], 1);
	GpSurfaceSet(&gpDraw[0]);
	
	//GpClockSpeedChange (40000000, 0x48013, 1);
	//GpClockSpeedChange (59250000, 0x47022, 1);
	setCPUSpeed (66000000, 0x3a012, 0);
	ARMEnableInterrupt();
	
	struct module mod;
	struct soundBufParams sbuf;
	struct FXinfo fx;
	
	initSoundBuffer(16000,66000000,&sbuf,myinstallirq,myremoveirq,mymalloc,myfree,mt_musicFastSwitch,&mod);
	
	mt_init(mod0,&sbuf,&mod);
	mt_masterVolume(&mod,31);
	
	for(;;)
	{

	}
}

/* END OF FILE */

when i compile i've the 3 *.o files but i've these message:
Code:
>make
arm-elf-gcc -Ic:/devkitARM_r8/include -IC:/devkitARM_r8/include -DLITTLE_ENDIAN -DGP32 -mcpu=arm9tdmi -mtune=arm9tdmi -fexpensive-optimizations -mapcs -O3 -mstructure-size-boundary=8 -mno-thumb-interwork -fno-builtin -fno-common -fno-exceptions -finline-functions -fomit-frame-pointer -fshort-enums -ffast-math -fshort-double  -Ic:/devkitARM_r8/include -IC:/devkitARM_r8/include -DLITTLE_ENDIAN -DGP32 -mcpu=arm9tdmi -mtune=arm9tdmi -fexpensive-optimizations -mapcs -O3 -mstructure-size-boundary=8 -mno-thumb-interwork -fno-builtin -fno-common -fno-exceptions -finline-functions -fomit-frame-pointer -fshort-enums -ffast-math -fshort-double  -c -o gpmain.o gpmain.c
arm-elf-gcc -Ic:/devkitARM_r8/include -IC:/devkitARM_r8/include -DLITTLE_ENDIAN -DGP32 -mcpu=arm9tdmi -mtune=arm9tdmi -fexpensive-optimizations -mapcs -O3 -mstructure-size-boundary=8 -mno-thumb-interwork -fno-builtin -fno-common -fno-exceptions -finline-functions -fomit-frame-pointer -fshort-enums -ffast-math -fshort-double  -Ic:/devkitARM_r8/include -IC:/devkitARM_r8/include -DLITTLE_ENDIAN -DGP32 -mcpu=arm9tdmi -mtune=arm9tdmi -fexpensive-optimizations -mapcs -O3 -mstructure-size-boundary=8 -mno-thumb-interwork -fno-builtin -fno-common -fno-exceptions -finline-functions -fomit-frame-pointer -fshort-enums -ffast-math -fshort-double  -c -o gpstart.o gpstart.c
arm-elf-as   -o asmfuncs.o asmfuncs.s
arm-elf-gcc gpmain.o gpstart.o asmfuncs.o   -LC:/devkitARM_r8/arm-elf/lib -specs=gp32_gpsdk.specs -lgpfont -lgpstdlib -lgpos -lgpgraphic -lgpstdio -lgpsound -lgpmem  -o spivmod.elf
C:/devkitARM_r8/arm-elf/lib\libgpstdlib.a(asm_gpstdlib.o)(.text+0x14): In function `ARMDisableInterrupt':
: multiple definition of `ARMDisableInterrupt'
gpmain.o(.text+0x98): first defined here
C:/devkitARM_r8/arm-elf/lib\libgpstdlib.a(asm_gpstdlib.o)(.text+0x2c): In function `ARMEnableInterrupt':
: multiple definition of `ARMEnableInterrupt'
gpmain.o(.text+0xa8): first defined here
gpmain.o(.text+0x1c0): In function `GpMain':
: undefined reference to `initSoundBuffer'
gpmain.o(.text+0x1d0): In function `GpMain':
: undefined reference to `mt_init'
gpmain.o(.text+0x1dc): In function `GpMain':
: undefined reference to `mt_masterVolume'
asmfuncs.o(.text+0x88): In function `mt_musicFastSwitch':
: undefined reference to `mt_music'
collect2: ld returned 1 exit status
make: *** [spivmod.elf] Error 1
>Exit code: 2

sorry for this flood :)
 
JyCet posted on Apr 11 2005 at 09:40 PM said:
Well thank to Mr Spiv on IRC to help me :)
Now it work !!!

Here my example (source,lib,makefile,fxe,gxb are included)
spiv_mod_example.zip

See you
JYCET

Jycet also pointed out that at least effect 6xx bugs.. gonna fix it :blink:
 
Last edited by a moderator:
Back
Top