From dbff026c936039e23fe95320e05044cbd38ebfac Mon Sep 17 00:00:00 2001 From: "fabio.olimpieri" Date: Sun, 8 Apr 2012 09:16:42 +0000 Subject: [PATCH] Added ASND sound, centered menus, added other save directories --- Makefile | 14 +++---- src/cargador.c | 13 +++++- src/characters.c | 4 +- src/computer.c | 12 ++++-- src/emulator.c | 28 +++++++++---- src/menus.c | 94 ++++++++++++++++++++++---------------------- src/menus.h | 2 +- src/sound.c | 61 +++++++++++++++++++++++++++- src/sound.h | 5 ++- src/z80free/Makefile | 2 +- 10 files changed, 161 insertions(+), 74 deletions(-) diff --git a/Makefile b/Makefile index 2e9cf98..4cfaa03 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ INCLUDES := # options for code generation #--------------------------------------------------------------------------------- -CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) -Wno-pointer-sign -DDEBUG +CFLAGS = -g -O2 -Wall -Wno-unused-but-set-variable $(MACHDEP) $(INCLUDE) -Wno-pointer-sign -DDEBUG CXXFLAGS = $(CFLAGS) LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map @@ -33,7 +33,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -lSDL_mixer -lsmpeg -lvorbisidec -lSDL_image -lpng -ljpeg -lz -lSDL -lSDL_gfx -lfreetype -lfat -lwiiuse -lbte -logc -lm -lwiikeyboard +LIBS := -lasnd -lSDL_mixer -lsmpeg -lvorbisidec -lSDL_image -lpng -ljpeg -lz -lSDL -lSDL_gfx -lfreetype -lfat -lwiiuse -lbte -logc -lm -lwiikeyboard #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing @@ -114,15 +114,15 @@ dist: $(BUILD) mkdir -p $@/apps/fbzx-wii mkdir -p $@/fbzx-wii/fbzx mkdir -p $@/fbzx-wii/spectrum-roms - mkdir -p $@/fbzx-wii/applications + mkdir -p $@/fbzx-wii/tapes + mkdir -p $@/fbzx-wii/snapshots + mkdir -p $@/fbzx-wii/microdrives mkdir -p $@/fbzx-wii/pixmaps - mkdir -p $@/fbzx-wii/doc/fbzx + mkdir -p $@/apps/fbzx-wii/doc cp fbzx.dol $@/apps/fbzx-wii/boot.dol cp spectrum-roms/* $@/fbzx-wii/spectrum-roms cp keymap.bmp $@/fbzx-wii/fbzx - cp fbzx.desktop $@/fbzx-wii/applications - cp fbzx.svg $@/fbzx-wii/pixmaps - cp AMSTRAD CAPABILITIES COPYING FAQ README README.TZX VERSIONS $@/fbzx-wii/doc/fbzx/ + cp AMSTRAD CAPABILITIES COPYING FAQ README README.TZX VERSIONS $@/apps/fbzx-wii/doc cd $@ && tar -czf ../fbzx-wii-bin.tar.gz * #--------------------------------------------------------------------------------- diff --git a/src/cargador.c b/src/cargador.c index d479566..a762d1f 100644 --- a/src/cargador.c +++ b/src/cargador.c @@ -24,6 +24,15 @@ #include #include +#ifdef DEBUG +extern FILE *fdebug; +#define printf(...) fprintf(fdebug,__VA_ARGS__) +#else + #ifdef GEKKO + #define printf(...) + #endif +#endif + void uncompress_z80(FILE *fichero,int length,unsigned char *memo) { unsigned char byte_loaded,EDfound,counter; @@ -87,7 +96,9 @@ int save_z80(char *filename) { fprintf(fichero,"%c%c%c%c%c%c",procesador.Rm.br.A,procesador.Rm.br.F,procesador.Rm.br.C,procesador.Rm.br.B,procesador.Rm.br.L,procesador.Rm.br.H); // AF, BC and HL if(ordenador.mode128k==0) // 48K - fprintf(fichero,"%c%c",(byte)(procesador.PC&0x0FF),(byte)((procesador.PC>>8)&0xFF)); // PC + fprintf(fichero,"%c%c",(byte)(procesador.PC&0x0FF),(byte)((procesador.PC>>8)&0xFF)); // PC + //Endian? + //fprintf(fichero,"%c%c",(byte)(procesador.PC&0x0FF),(byte)((procesador.PC<<8)&0xFF)); // PC else fprintf(fichero,"%c%c",0,0); // 128K diff --git a/src/characters.c b/src/characters.c index 99f59fb..29d9e7f 100644 --- a/src/characters.c +++ b/src/characters.c @@ -37,10 +37,10 @@ void printchar(unsigned char *memo, unsigned char carac, int x, int y, unsigned lugar2=lugar; for (bucle2=0;bucle2 < 16;bucle2++) { if ((characters[carac-32][pos]) & bit_rot) - paint_one_pixel (colors + (int) (color), lugar2); + paint_one_pixel ((unsigned char *) (colors + (int) (color)), lugar2); //*((unsigned int *)lugar2)=*(colors+(int)(color-16)); else if ((ordenador.text_mini==0)||((bucle1%2==0)&&(bucle2%2==0))) - paint_one_pixel (colors + (int) (back), lugar2); + paint_one_pixel ((unsigned char *)(colors + (int) (back)), lugar2); //*((unsigned int *)lugar2)=*(colors+(int)(back-16)); if ((ordenador.text_mini==0)||(bucle2%2==1)) { lugar2+=ordenador.bpp; diff --git a/src/computer.c b/src/computer.c index f7e5d8e..0c85b44 100644 --- a/src/computer.c +++ b/src/computer.c @@ -33,7 +33,11 @@ #ifdef DEBUG extern FILE *fdebug; -#define printf(...) fprintf(fdebug,__VA_ARGS__); fflush (fdebug) +#define printf(...) fprintf(fdebug,__VA_ARGS__) +#else + #ifdef GEKKO + #define printf(...) + #endif #endif /* Returns the bus value when reading a port without a periferial */ @@ -581,12 +585,12 @@ inline void show_screen (int tstados) { } if (ordenador.osd_time) - print_string (ordenador.screenbuffer,ordenador.osd_text, -1,460, 12, 0,ordenador.screen_width); + print_string (ordenador.screenbuffer,ordenador.osd_text, -1,450, 12, 0,ordenador.screen_width); else { if (ordenador.zaurus_mini==0) - print_string (ordenador.screenbuffer," ",-1, 460, 12, 0,ordenador.screen_width); + print_string (ordenador.screenbuffer," ",-1, 450, 12, 0,ordenador.screen_width); else - print_string (ordenador.screenbuffer," ",-1, 460, 12, 0,ordenador.screen_width); + print_string (ordenador.screenbuffer," ",-1, 450, 12, 0,ordenador.screen_width); } } diff --git a/src/emulator.c b/src/emulator.c index 5c4bd3f..db8b4ec 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "characters.h" #include "menus.h" #include @@ -42,7 +43,11 @@ #ifdef DEBUG FILE *fdebug; -#define printf(...) fprintf(fdebug,__VA_ARGS__); fflush (fdebug) +#define printf(...) fprintf(fdebug,__VA_ARGS__) +#else + #ifdef GEKKO + #define printf(...) + #endif #endif char debug_var=1; @@ -293,7 +298,9 @@ void init_screen(int resx,int resy,int depth,int fullscreen,int dblbuffer,int hw value=0; for(bucle2=0;bucle21)) - sprintf(nombre_final,"%s/%s.%s",path_snaps,nombre,extension); // name + longitud=strlen(path); + if((path[longitud-1]!='/')&&(longitud>1)) + sprintf(nombre_final,"%s/%s.%s",path,nombre,extension); // name else - sprintf(nombre_final,"%s%s.%s",path_snaps,nombre,extension); + sprintf(nombre_final,"%s%s.%s",path,nombre,extension); return (retorno); } @@ -1462,7 +1462,7 @@ void save_z80file() { print_string(videomem,path_snaps,0,152,12,0,ancho); - retorno=ask_filename(nombre2,84,"z80"); + retorno=ask_filename(nombre2,84,"z80", path_snaps); clean_screen(); @@ -1827,7 +1827,7 @@ void keyboard_menu() { for (bucle1=0;bucle1<344;bucle1++) for(bucle2=0;bucle2<640;bucle2++) { retval=fscanf(fichero,"%c",&valor); - paint_one_pixel(colors+valor,buffer); + paint_one_pixel((unsigned char *)(colors+valor),buffer); buffer+=ordenador.bpp; } } else { @@ -1836,7 +1836,7 @@ void keyboard_menu() { buffer2=buffer; for(bucle2=0;bucle2<640;bucle2++) { retval=fscanf(fichero,"%c",&valor); - paint_one_pixel(colors+valor,buffer); + paint_one_pixel((unsigned char *)(colors+valor),buffer); buffer+=(480*ordenador.bpp); } buffer=buffer2-ordenador.bpp; diff --git a/src/menus.h b/src/menus.h index 99c4d31..9fd52f4 100644 --- a/src/menus.h +++ b/src/menus.h @@ -45,7 +45,7 @@ void create_mdrfile(); void microdrive_menu(); void keyboard_menu(); void load_scrfile(); -int ask_filename(char *nombre,int y_coord,char *extension); +int ask_filename(char *nombre,int y_coord,char *extension, char *path); void create_scrfile(); void do_poke(); int ask_value(int *final_value,int y_coord,int max_value); diff --git a/src/sound.c b/src/sound.c index f49a3de..e9c6d30 100644 --- a/src/sound.c +++ b/src/sound.c @@ -33,7 +33,11 @@ char tabla[1024]; #ifdef DEBUG extern FILE *fdebug; -#define printf(...) fprintf(fdebug,__VA_ARGS__); fflush (fdebug) +#define printf(...) fprintf(fdebug,__VA_ARGS__) +#else + #ifdef GEKKO + #define printf(...) + #endif #endif /*#include @@ -60,6 +64,10 @@ snd_pcm_t * _soundDevice; pa_simple *pulse_s; #endif +#ifdef GEKKO +#include +#endif + enum e_soundtype sound_type; int sound_init() { @@ -112,6 +120,19 @@ int sound_init() { } break; #endif +#ifdef GEKKO + case SOUND_ASND: + printf("Trying ASND sound\n"); + if(0==sound_init_asnd()) { + sound_type=SOUND_ASND; + return 0; + } else { + printf("Failed\n"); + return -1; + } + break; +#endif + default: break; } @@ -140,9 +161,32 @@ int sound_init() { } #endif +#ifdef GEKKO + printf("Trying ASND sound\n"); + if(0==sound_init_asnd()) { + sound_type=SOUND_ASND; + return 0; + } +#endif return -1; } +#ifdef GEKKO +int sound_init_asnd() { + + ASND_Init(); + ASND_Pause(0); + ordenador.sign=0; + ordenador.format=0; + ordenador.channels=1; + ordenador.freq=48000; + ordenador.buffer_len=4096; + + return 0; + +} +#endif + #ifdef D_SOUND_PULSE int sound_init_pulse() { @@ -443,6 +487,15 @@ void sound_play() { return; break; #endif +#ifdef GEKKO + case SOUND_ASND: // ASND + retval=ASND_SetVoice(1,VOICE_MONO_8BIT,48000,0,ordenador.current_buffer,ordenador.buffer_len, + ordenador.volume, ordenador.volume, NULL); + while (ASND_StatusVoice(1) == SND_WORKING){}; + return; + break; +#endif + default: break; } @@ -470,6 +523,12 @@ void sound_close() { pa_simple_free(pulse_s); break; #endif +#ifdef GEKKO + case SOUND_ASND: + ASND_End(); + break; +#endif + default: break; } diff --git a/src/sound.h b/src/sound.h index 43dbf4c..7d8d96c 100644 --- a/src/sound.h +++ b/src/sound.h @@ -20,7 +20,7 @@ #ifndef SOUND_H #define SOUND_H -enum e_soundtype {SOUND_NO, SOUND_OSS, SOUND_ALSA, SOUND_PULSEAUDIO, SOUND_AUTOMATIC}; +enum e_soundtype {SOUND_NO, SOUND_OSS, SOUND_ALSA, SOUND_PULSEAUDIO, SOUND_AUTOMATIC, SOUND_ASND}; extern enum e_soundtype sound_type; @@ -33,7 +33,8 @@ extern volatile unsigned char *sdl_sound_buffer; int sound_init_oss(); int sound_init_alsa(); int sound_init_pulse(); +int sound_init_asnd(); -void sdlcallback(void *userdata, Uint8 *stream, int len); +//void sdlcallback(void *userdata, Uint8 *stream, int len); #endif diff --git a/src/z80free/Makefile b/src/z80free/Makefile index ef36b09..f88e84f 100644 --- a/src/z80free/Makefile +++ b/src/z80free/Makefile @@ -29,7 +29,7 @@ CFLAGS = -g -O1 -Wall $(MACHDEP) $(INCLUDE) CXXFLAGS = $(CFLAGS) LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -#-fpack-struct + #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #---------------------------------------------------------------------------------