diff -c --strip-trailing-cr onscripter-20111226_old/Makefile.iPhone onscripter-20111226_new/Makefile.iPhone *** onscripter-20111226_old/Makefile.iPhone Mon Dec 26 01:07:42 2011 --- onscripter-20111226_new/Makefile.iPhone Wed Dec 28 14:27:57 2011 *************** *** 3,9 **** # Makefile.iPhone - Makefile rules for iPhone & iPod touch # ! PREF = /usr/local/arm-apple-darwin INCS = `$(PREF)/bin/sdl-config --cflags` `$(PREF)/bin/freetype-config --cflags` #LIBS = `$(PREF)/bin/sdl-config --libs` -lSDL_ttf -lSDL_image -lSDL_mixer -lSDL -lmad -lvorbisidec -lfreetype -ljpeg -lpng -lbz2 -lz --- 3,9 ---- # Makefile.iPhone - Makefile rules for iPhone & iPod touch # ! PREF = /usr/local INCS = `$(PREF)/bin/sdl-config --cflags` `$(PREF)/bin/freetype-config --cflags` #LIBS = `$(PREF)/bin/sdl-config --libs` -lSDL_ttf -lSDL_image -lSDL_mixer -lSDL -lmad -lvorbisidec -lfreetype -ljpeg -lpng -lbz2 -lz *************** *** 15,25 **** $(PREF)/lib/libmad.a \ $(PREF)/lib/libvorbisidec.a \ $(PREF)/lib/libfreetype.a \ ! $(PREF)/lib/libjpeg.a \ $(PREF)/lib/libpng.a \ -lz -lbz2 ! DEFS = -DIPHONE -DMACOSX -DPDA_WIDTH=424 -DBPP16 -DMP3_MAD -DUSE_OGG_VORBIS -DINTEGER_OGG_VORBIS -DUTF8_CAPTION -DUTF8_FILESYSTEM EXESUFFIX = OBJSUFFIX = .o --- 15,29 ---- $(PREF)/lib/libmad.a \ $(PREF)/lib/libvorbisidec.a \ $(PREF)/lib/libfreetype.a \ ! $(PREF)/lib/libsmjpeg.a \ $(PREF)/lib/libpng.a \ + $(PREF)/lib/libsmpeg.a \ + -F/usr/local/iphone-sysroot/System/Library/Frameworks \ + -F/usr/local/iphone-sysroot/System/Library/PrivateFrameworks \ + -framework QuartzCore -framework Foundation -lstdc++ \ -lz -lbz2 ! DEFS = -DIPHONE -DMACOSX -DPDA_WIDTH=424 -DBPP16 -DMP3_MAD -DUSE_OGG_VORBIS -DINTEGER_OGG_VORBIS -DUTF8_CAPTION -DUTF8_FILESYSTEM -DUSE_SMJPEG EXESUFFIX = OBJSUFFIX = .o *************** *** 27,40 **** .SUFFIXES: .SUFFIXES: $(OBJSUFFIX) .cpp .h ! CC = arm-apple-darwin-g++ ! LD = arm-apple-darwin-g++ -o #CFLAGS = -g -Wall -Wpointer-arith -pipe -c $(INCS) $(DEFS) CFLAGS = -O3 -Wall -Wpointer-arith -pipe -c $(INCS) $(DEFS) RM = rm -f TARGET = onscripter$(EXESUFFIX) sardec$(EXESUFFIX) nsadec$(EXESUFFIX) sarconv$(EXESUFFIX) nsaconv$(EXESUFFIX) ! EXT_OBJS = include Makefile.onscripter --- 31,44 ---- .SUFFIXES: .SUFFIXES: $(OBJSUFFIX) .cpp .h ! CC = arm-apple-darwin9-g++ ! LD = arm-apple-darwin9-g++ -o #CFLAGS = -g -Wall -Wpointer-arith -pipe -c $(INCS) $(DEFS) CFLAGS = -O3 -Wall -Wpointer-arith -pipe -c $(INCS) $(DEFS) RM = rm -f TARGET = onscripter$(EXESUFFIX) sardec$(EXESUFFIX) nsadec$(EXESUFFIX) sarconv$(EXESUFFIX) nsaconv$(EXESUFFIX) ! EXT_OBJS = StreamChunkWrapper$(OBJSUFFIX) include Makefile.onscripter diff -c --strip-trailing-cr onscripter-20111226_old/ONScripter.cpp onscripter-20111226_new/ONScripter.cpp *** onscripter-20111226_old/ONScripter.cpp Mon Dec 26 01:07:42 2011 --- onscripter-20111226_new/ONScripter.cpp Thu Jan 5 22:05:55 2012 *************** *** 26,31 **** --- 26,32 ---- #include #endif + extern void initSJIS2UTF16(); extern "C" void waveCallback( int channel ); *************** *** 80,86 **** screen_bpp = 32; #endif ! #if defined(PDA_WIDTH) screen_ratio1 = PDA_WIDTH; screen_ratio2 = screen_width; screen_width = screen_width * screen_ratio1 / screen_ratio2; --- 81,95 ---- screen_bpp = 32; #endif ! #if defined(IPHONE) ! screen_ratio2 *= screen_width; ! char* width_str = SDL_getenv("WIDTH"); ! if(width_str){ ! screen_width = strtol(width_str, NULL, 0); ! screen_ratio1 *= screen_width; ! } ! ! #elif defined(PDA_WIDTH) screen_ratio1 = PDA_WIDTH; screen_ratio2 = screen_width; screen_width = screen_width * screen_ratio1 / screen_ratio2; *************** *** 104,109 **** --- 113,119 ---- screen_ratio2 = screen_width; screen_width = screen_width * screen_ratio1 / screen_ratio2; } + #endif screen_height = screen_width*script_h.screen_height/script_h.screen_width; *************** *** 415,421 **** loop_bgm_name[1] = NULL; int i; ! for (i=0 ; i #include #include + #include "StreamChunkWrapper.h" #define DEFAULT_VIDEO_SURFACE_FLAG (SDL_SWSURFACE) *************** *** 666,671 **** --- 667,673 ---- char *loop_bgm_name[2]; Mix_Chunk *wave_sample[ONS_MIX_CHANNELS+ONS_MIX_EXTRA_CHANNELS]; + unsigned char *wave_buffer[ONS_MIX_CHANNELS+ONS_MIX_EXTRA_CHANNELS]; char *midi_cmd; diff -c --strip-trailing-cr onscripter-20111226_old/ONScripter_sound.cpp onscripter-20111226_new/ONScripter_sound.cpp *** onscripter-20111226_old/ONScripter_sound.cpp Mon Dec 26 01:07:42 2011 --- onscripter-20111226_new/ONScripter_sound.cpp Wed Dec 28 14:27:57 2011 *************** *** 86,91 **** --- 86,100 ---- #include "AVIWrapper.h" #endif + #if defined(USE_SMJPEG) + #include + extern SDLKey transKey( SDLKey key ); + extern SDLKey transJoystickButton( Uint8 button ); + #include + #include + #endif + + #ifndef MP3_MAD #include extern "C" void mp3callback( void *userdata, Uint8 *stream, int len ) *************** *** 145,151 **** if (format & SOUND_CHUNK){ Mix_Chunk *chunk = Mix_LoadWAV_RW(SDL_RWFromMem(buffer, length), 1); if (playWave(chunk, format, loop_flag, channel) == 0){ ! delete[] buffer; return SOUND_CHUNK; } } --- 154,160 ---- if (format & SOUND_CHUNK){ Mix_Chunk *chunk = Mix_LoadWAV_RW(SDL_RWFromMem(buffer, length), 1); if (playWave(chunk, format, loop_flag, channel) == 0){ ! wave_buffer[channel] = buffer; return SOUND_CHUNK; } } *************** *** 209,214 **** --- 218,225 ---- Mix_Pause( channel ); if ( wave_sample[channel] ) Mix_FreeChunk( wave_sample[channel] ); wave_sample[channel] = chunk; + if ( wave_buffer[channel] ) delete [] wave_buffer[channel]; + wave_buffer[channel] = NULL; if (channel == 0) Mix_Volume( channel, voice_volume * MIX_MAX_VOLUME / 100 ); else if (channel == MIX_BGM_CHANNEL) Mix_Volume( channel, music_volume * MIX_MAX_VOLUME / 100 ); *************** *** 242,247 **** --- 253,322 ---- return 0; } + + #if defined(USE_SMJPEG) + void MakeFileName( char* mjpeg_filename, const char* archive_path, const char* filename ) + { + char *cur_p = NULL; + DIR *dp = NULL; + char mjpeg_subpath[256]; + size_t len = strlen(archive_path) + strlen(filename) + 1; + + memset( mjpeg_filename, 0, sizeof(mjpeg_filename) ); + memset( mjpeg_subpath, 0, sizeof(mjpeg_subpath) ); + sprintf(mjpeg_filename, "%s%s", archive_path, filename); + + CFStringRef unicodeStrRef = CFStringCreateWithBytes(nil, (const UInt8*)mjpeg_filename, len, + kCFStringEncodingShiftJIS, false); + if(unicodeStrRef) { + Boolean ret = CFStringGetCString(unicodeStrRef, mjpeg_subpath, len*2+1, kCFStringEncodingUTF8); + CFRelease(unicodeStrRef); + if (ret){ + strcpy(mjpeg_filename, mjpeg_subpath); + memset( mjpeg_subpath, 0, sizeof(mjpeg_subpath) ); + } + } + + len = strlen(archive_path); + if (len > 0) dp = opendir(archive_path); + else dp = opendir("."); + cur_p = mjpeg_filename+len; + while(1){ + if (dp == NULL) return; + + char *delim_p = NULL; + while(1){ + delim_p = strchr( cur_p, (char)DELIMITER ); + if (delim_p != cur_p) break; + cur_p++; + } + + if (delim_p) len = delim_p - cur_p; + else len = strlen(cur_p); + memcpy(mjpeg_subpath, cur_p, len); + mjpeg_subpath[len] = '\0'; + + struct dirent *entp; + while ( (entp = readdir(dp)) != NULL ){ + if ( !strcasecmp( mjpeg_subpath, entp->d_name ) ){ + memcpy(cur_p, entp->d_name, len); + break; + } + } + closedir( dp ); + + if (entp == NULL) return; + if (delim_p == NULL) break; + + memcpy(mjpeg_subpath, mjpeg_filename, delim_p-mjpeg_filename); + mjpeg_subpath[delim_p-mjpeg_filename]='\0'; + dp = opendir(mjpeg_subpath); + + cur_p = delim_p+1; + } + } + #endif /* USE_SMJPEG */ + int ONScripter::playMPEG(const char *filename, bool click_flag, bool loop_flag) { unsigned long length = script_h.cBR->getFileLength( filename ); *************** *** 256,261 **** --- 331,412 ---- #endif int ret = 0; + + #if defined(USE_SMJPEG) + if(screen_bpp>16) return ret; + + SMJPEG mjpeg_sample; + char mjpeg_filename[256]; + + MakeFileName( mjpeg_filename, archive_path, filename ); + // sprintf(mjpeg_filename, "%s%s", archive_path, filename); + if(SMJPEG_load(&mjpeg_sample, mjpeg_filename) == 0){ + if(mjpeg_sample.video.enabled){ + int target_x = 0; + int target_y = 0; + int vw = mjpeg_sample.video.width; + int vh = mjpeg_sample.video.height; + int sw = screen_surface->w; + int sh = screen_surface->h; + // too large. odd number. + if((vw>sw || vh>sh) || (vw%2==1 || vh%2==1)){ + SMJPEG_free( &mjpeg_sample ); + return 0; + } else if(vw*2 <= sw && vh*2<= sh){ + target_x = (sw - vw*2) / 2; + target_y = (sh - vh*2) / 2; + SMJPEG_double(&mjpeg_sample, 1); + } else { + target_x = (sw - vw) / 2; + target_y = (sh - vh) / 2; + SMJPEG_double(&mjpeg_sample, 0); + } + SMJPEG_target(&mjpeg_sample, NULL, target_x, target_y, screen_surface, SDL_UpdateRect); + } + if(mjpeg_sample.audio.enabled) + Mix_HookMusic(SMJPEG_feedaudio, &mjpeg_sample); + SMJPEG_start(&mjpeg_sample, 1); + bool done_flag = false; + while( !(done_flag & click_flag) && !mjpeg_sample.at_end ){ + SDL_Event event; + SMJPEG_advance( &mjpeg_sample, 1, 1 ); + while( SDL_PollEvent( &event ) ){ + switch (event.type){ + case SDL_JOYBUTTONUP: + event.key.type = SDL_KEYUP; + event.key.keysym.sym = transJoystickButton(event.jbutton.button); + if(event.key.keysym.sym == SDLK_UNKNOWN) + break; + case SDL_KEYUP: + event.key.keysym.sym = transKey(event.key.keysym.sym); + if ( + ((SDL_KeyboardEvent *)&event)->keysym.sym == SDLK_RETURN || + ((SDL_KeyboardEvent *)&event)->keysym.sym == SDLK_SPACE || + ((SDL_KeyboardEvent *)&event)->keysym.sym == SDLK_ESCAPE ) + done_flag = true; + break; + case SDL_QUIT: + ret = 1; + case SDL_MOUSEBUTTONDOWN: + done_flag = true; + break; + default: + break; + } + } + } + + SMJPEG_stop(&mjpeg_sample); + if(mjpeg_sample.audio.enabled) + Mix_HookMusic(NULL, NULL); + SMJPEG_free(&mjpeg_sample); + dirty_rect.fill(screen_width, screen_height); + flush( refreshMode() ); + + return ret; + } + #endif /* USE_SMJPEG */ + #ifndef MP3_MAD unsigned char *mpeg_buffer = new unsigned char[length]; script_h.cBR->getFile( filename, mpeg_buffer ); *************** *** 377,382 **** --- 528,537 ---- Mix_Pause( MIX_BGM_CHANNEL ); Mix_FreeChunk( wave_sample[MIX_BGM_CHANNEL] ); wave_sample[MIX_BGM_CHANNEL] = NULL; + if ( wave_buffer[MIX_BGM_CHANNEL] ){ + delete [] wave_buffer[MIX_BGM_CHANNEL]; + wave_buffer[MIX_BGM_CHANNEL] = NULL; + } } if ( music_info ){ *************** *** 415,420 **** --- 570,579 ---- Mix_Pause( ch ); Mix_FreeChunk( wave_sample[ch] ); wave_sample[ch] = NULL; + if( wave_buffer[ch] ){ + delete wave_buffer[ch]; + wave_buffer[ch] = NULL; + } } } Common subdirectories: onscripter-20111226_old/www and onscripter-20111226_new/www