From 56e9dd1200ccd863216d68e75240dadb3a7fabb2 Mon Sep 17 00:00:00 2001 From: EvanR Date: Sun, 28 Jun 2009 16:31:31 -0400 Subject: [PATCH] Added command line options and unicode. Changed audio init. The unicode is untested and prehaps incomplete. The audio is failing to play silence on intel HDA hardware. --- Makefile | 4 +++- backend.c | 46 ++++++++++++++++++++++++++++++++++------------ backend.h | 9 +++++++-- util.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- util.h | 10 +++++++++- 5 files changed, 106 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index a915322..f76e9d2 100644 --- a/Makefile +++ b/Makefile @@ -7,11 +7,13 @@ LIBS = -lSDL -lGL -lzzip $(PROJECT): $(OBJ) $(CC) -o $(PROJECT) $(LIBS) $(OBJ) + + game.o: game.h intro.h title.o: game.h backend.h title.h intro.o: game.h backend.h intro.h title.h util.o: util.h -main.o: game.h backend.h intro.h loader.h +main.o: game.h backend.h intro.h loader.h util.h backend.o: game.h backend.h util.h loader.h sound.h loader.o: loader.h util.h sound.o: sound.h diff --git a/backend.c b/backend.c index 4bc08d3..650f989 100644 --- a/backend.c +++ b/backend.c @@ -23,9 +23,8 @@ #include #include -#include "game.h" #include "backend.h" -#include "util.h" +#include "game.h" #include "loader.h" #include "sound.h" @@ -616,13 +615,11 @@ extern void process_audio(short lout[], short rout[], int len); void audio_callback(void *userdata, Uint8 *stream, int len){ Sint16* out = (Sint16*)stream; - process_audio(lout, rout, BUFFER_SIZE/2); + process_audio(lout, rout, BUFFER_SIZE); - int j = 0; - for(int i=0; i>2; + N = 2; + } + else if(((b[0]&0xf0)==0xe0) && + ((b[1]&0xc0)==0x80) && + ((b[2]&0xc0)==0x80) ){/*three byte sequence*/ + a[3] = ((b[1]&0x03)<<6)|(b[2]&0x3f); + a[2] = ((b[0]&0x0f)<<4)|((b[1]&0x3c)>>2); + N = 3; + } + else if(((b[0]&0xf8)==0xf0) && + ((b[1]&0xc0)==0x80) && + ((b[2]&0xc0)==0x80) && + ((b[3]&0xc0)==0x80) ){/*four byte sequence*/ + a[3] =((b[2]&0x03)<<6)|(b[3]&0x3f); + a[2] =((b[1]&0x0f)<<4)|((b[2]&0x3c)>>2); + a[1] =((b[0]&0x03)<<2)|((b[1]&0x30)>>4); + N = 4; + } + else { + a[3] = '?'; + N = 4;/*FIXME find next valid byte*/ + } + *u = (a[0]<<24) | (a[1]<<16) | (a[2]<<8) | a[3]; + return N; +} + diff --git a/util.h b/util.h index c629955..4d437b9 100644 --- a/util.h +++ b/util.h @@ -25,4 +25,12 @@ void fatal_error(const char* format, ...); void* xmalloc(size_t size); char* strxcpy(const char* str); void strmcat(char* dst, const char* src, size_t n); -void out_of_memory(const char*); \ No newline at end of file +void out_of_memory(const char*); + +//typedef struct { +// unsigned char b[4]; + // unsigned long n; +//} utf32; +typedef unsigned long utf32; + +int unicode_getc(char* str, utf32* u); -- 2.11.4.GIT