├── AVIWrapper.cpp ├── AVIWrapper.h ├── AnimationInfo.cpp ├── AnimationInfo.h ├── BUGS ├── BaseReader.h ├── CHANGES ├── COPYING ├── DirPaths.cpp ├── DirPaths.h ├── DirectReader.cpp ├── DirectReader.h ├── DirtyRect.cpp ├── DirtyRect.h ├── FontInfo.cpp ├── FontInfo.h ├── INSTALL ├── Layer.cpp ├── Layer.h ├── MadWrapper.cpp ├── MadWrapper.h ├── Makefile.extlibs ├── Makefile.onscripter ├── Makefile.wii ├── NsaReader.cpp ├── NsaReader.h ├── ONScripterLabel.cpp ├── ONScripterLabel.h ├── ONScripterLabel_animation.cpp ├── ONScripterLabel_command.cpp ├── ONScripterLabel_effect.cpp ├── ONScripterLabel_event.cpp ├── ONScripterLabel_file.cpp ├── ONScripterLabel_file2.cpp ├── ONScripterLabel_image.cpp ├── ONScripterLabel_rmenu.cpp ├── ONScripterLabel_sound.cpp ├── ONScripterLabel_text.cpp ├── README ├── SDL_win32_main.c ├── SarReader.cpp ├── SarReader.h ├── ScriptHandler.cpp ├── ScriptHandler.h ├── ScriptParser.cpp ├── ScriptParser.h ├── ScriptParser_command.cpp ├── config.guess ├── config.sub ├── configure ├── graphics_altivec.cpp ├── graphics_altivec.h ├── graphics_common.h ├── graphics_mmx.cpp ├── graphics_mmx.h ├── graphics_sse2.cpp ├── graphics_sse2.h ├── install-sh ├── macosx ├── Info.plist ├── ONScripter.icns ├── ONScripter.xcodeproj │ └── project.pbxproj ├── ONScripter_Prefix.pch ├── SDL_config.h ├── ftconfig.h ├── ftmodule.h ├── jconfig.h └── ogg │ └── config_types.h ├── nscriptdecode.cpp ├── onscripter.cpp ├── onscripter.rc.in ├── osx_build.sh ├── resize_image.cpp ├── resize_image.h ├── sjis2utf16.cpp ├── test ├── 0.breakup.txt ├── 0.cascade.txt ├── 0.color.txt ├── 0.hana.txt ├── 0.jponly.txt ├── 0.oldmovie.txt ├── 0.snow.txt ├── 0.trvswave.txt ├── 0.txtbtn.txt ├── 0.whirl.txt ├── 00.txt ├── README ├── bgi.jpg ├── bgi0.jpg ├── bgi1.jpg ├── bgi2.jpg ├── chr.jpg ├── default.ttf ├── dust.bmp ├── kaede1.jpg ├── kaede2.jpg ├── kaede3.jpg ├── kimikage.jpg ├── msk.jpg ├── oldmovie.jpg ├── rain1.bmp ├── rain2.bmp ├── rain3.bmp ├── registry.txt ├── sakura1.bmp ├── sakura2.bmp ├── sakura3.bmp ├── snow1.bmp ├── snow2.bmp ├── snow3.bmp ├── snowa1.bmp ├── snowa2.bmp ├── snowa3.bmp └── tr_logo.jpg ├── version.h └── wii ├── FreeTypeGX.cpp ├── FreeTypeGX.h ├── audio.cpp ├── audio.h ├── filelist.h ├── fonts └── font.ttf ├── icon.png ├── images ├── bg_list_selection.png ├── bg_list_selection_entry.png ├── bg_options.png ├── bg_options_entry.png ├── button.png ├── button_large.png ├── button_large_over.png ├── button_over.png ├── dialogue_box.png ├── keyboard_key.png ├── keyboard_key_over.png ├── keyboard_largekey.png ├── keyboard_largekey_over.png ├── keyboard_mediumkey.png ├── keyboard_mediumkey_over.png ├── keyboard_textbox.png ├── player1_grab.png ├── player1_point.png ├── player2_grab.png ├── player2_point.png ├── player3_grab.png ├── player3_point.png ├── player4_grab.png ├── player4_point.png ├── scrollbar.png ├── scrollbar_arrowdown.png ├── scrollbar_arrowdown_over.png ├── scrollbar_arrowup.png ├── scrollbar_arrowup_over.png ├── scrollbar_box.png └── scrollbar_box_over.png ├── input.cpp ├── input.h ├── libwiigui ├── gui.h ├── gui_button.cpp ├── gui_element.cpp ├── gui_image.cpp ├── gui_imagedata.cpp ├── gui_keyboard.cpp ├── gui_listbox.cpp ├── gui_optionbrowser.cpp ├── gui_sound.cpp ├── gui_text.cpp ├── gui_trigger.cpp └── gui_window.cpp ├── mad_decoder ├── Buffer.cpp ├── buffer.h ├── mad_convert.cpp ├── mad_decode.cpp ├── mad_decode.h ├── mad_frame.cpp ├── mad_internal.h └── mad_stream.cpp ├── menu.cpp ├── menu.h ├── oggplayer.c ├── oggplayer.h ├── setting_parser.cpp ├── setting_parser.h ├── sounds ├── bg_music.ogg └── button_over.pcm ├── video.cpp └── video.h /AVIWrapper.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * AVIWrapper.h - avifile library wrapper class to play AVI video & audio stream 4 | * 5 | * Copyright (c) 2001-2004 Ogapee. All rights reserved. 6 | * 7 | * ogapee@aqua.dti2.ne.jp 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef __AVI_WRAPPER_H__ 25 | #define __AVI_WRAPPER_H__ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | class AVIWrapper 34 | { 35 | public: 36 | enum { AVI_STOP = 0, 37 | AVI_PLAYING = 1 38 | }; 39 | AVIWrapper(); 40 | ~AVIWrapper(); 41 | 42 | int init( char *filename, bool debug_flag ); 43 | int initAV( SDL_Surface *surface, bool audio_open_flag ); 44 | int play( bool click_flag ); 45 | 46 | void audioCallback( void *userdata, Uint8 *stream, int len ); 47 | int playVideo( void *userdata ); 48 | 49 | unsigned int getWidth(){ return width; }; 50 | unsigned int getHeight(){ return height; }; 51 | 52 | private: 53 | double getAudioTime(); 54 | int drawFrame( CImage *image ); 55 | 56 | SDL_Overlay *screen_overlay; 57 | SDL_Rect screen_rect; 58 | unsigned int width; 59 | unsigned int height; 60 | 61 | IAviReadFile *i_avi; 62 | IAviReadStream *v_stream; 63 | IAviReadStream *a_stream; 64 | int remaining_count; 65 | char *remaining_buffer; 66 | 67 | bool debug_flag; 68 | int status; 69 | SDL_Thread *thread_id; 70 | int64_t time_start; 71 | double frame_start; 72 | }; 73 | 74 | #endif // __AVI_WRAPPER_H__ 75 | -------------------------------------------------------------------------------- /AnimationInfo.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * AnimationInfo.h - General image storage class of ONScripter 4 | * 5 | * Copyright (c) 2001-2008 Ogapee. All rights reserved. 6 | * 7 | * ogapee@aqua.dti2.ne.jp 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef __ANIMATION_INFO_H__ 25 | #define __ANIMATION_INFO_H__ 26 | 27 | #include 28 | #include 29 | #include 30 | #include "BaseReader.h" 31 | 32 | #if defined (USE_X86_GFX) && !defined(MACOSX) 33 | #include 34 | #endif 35 | 36 | typedef unsigned char uchar3[3]; 37 | 38 | class AnimationInfo{ 39 | public: 40 | #ifdef BPP16 41 | typedef Uint16 ONSBuf; 42 | #else 43 | typedef Uint32 ONSBuf; 44 | #endif 45 | enum { TRANS_ALPHA = 1, 46 | TRANS_TOPLEFT = 2, 47 | TRANS_COPY = 3, 48 | TRANS_STRING = 4, 49 | TRANS_DIRECT = 5, 50 | TRANS_PALLET = 6, 51 | TRANS_TOPRIGHT = 7, 52 | TRANS_MASK = 8, 53 | #ifndef BPP16 54 | TRANS_LAYER = 9 55 | #endif 56 | }; 57 | 58 | bool is_copy; // allocated buffers should not be deleted from a copied instance 59 | 60 | /* Variables from TaggedInfo */ 61 | int trans_mode; 62 | uchar3 direct_color; 63 | int pallet_number; 64 | uchar3 color; 65 | SDL_Rect pos; // pose and size of the current cell 66 | 67 | int num_of_cells; 68 | int current_cell; 69 | int direction; 70 | int *duration_list; 71 | uchar3 *color_list; 72 | int loop_mode; 73 | bool is_animatable; 74 | bool is_single_line; 75 | bool is_tight_region; // valid under TRANS_STRING 76 | bool is_ruby_drawable; 77 | bool skip_whitespace; 78 | 79 | //Mion: for Layer effects 80 | int layer_no; 81 | 82 | //Mion: for special graphics routine handling 83 | enum{ 84 | CPUF_NONE = 0, 85 | CPUF_X86_MMX = 1, 86 | CPUF_X86_SSE = 2, 87 | CPUF_X86_SSE2 = 4, 88 | CPUF_PPC_ALTIVEC = 8, 89 | }; 90 | 91 | char *file_name; 92 | char *mask_file_name; 93 | 94 | /* Variables from AnimationInfo */ 95 | bool visible; 96 | bool abs_flag; 97 | bool affine_flag; 98 | int trans; 99 | char *image_name; 100 | SDL_Surface *image_surface; 101 | unsigned char *alpha_buf; 102 | /* Variables for extended sprite (lsp2, drawsp2, etc.) - Mion: ogapee2008 */ 103 | int scale_x, scale_y, rot; 104 | int mat[2][2], inv_mat[2][2]; 105 | int corner_xy[4][2]; 106 | SDL_Rect bounding_rect; 107 | 108 | enum { BLEND_NORMAL = 0, 109 | BLEND_ADD = 1, 110 | BLEND_SUB = 2 111 | }; 112 | int blending_mode; 113 | int cos_i, sin_i; 114 | 115 | int font_size_xy[2]; // used by prnum and lsp string 116 | int font_pitch; // used by lsp string 117 | int remaining_time; 118 | 119 | int param; // used by prnum and bar 120 | int max_param; // used by bar 121 | int max_width; // used by bar 122 | 123 | AnimationInfo(); 124 | AnimationInfo(const AnimationInfo &anim); 125 | ~AnimationInfo(); 126 | 127 | AnimationInfo& operator =(const AnimationInfo &anim); 128 | 129 | void reset(); 130 | 131 | void deleteImageName(); 132 | void setImageName( const char *name ); 133 | void deleteSurface(); 134 | void remove(); 135 | void removeTag(); 136 | 137 | bool proceedAnimation(); 138 | 139 | void setCell(int cell); 140 | static int doClipping( SDL_Rect *dst, SDL_Rect *clip, SDL_Rect *clipped=NULL ); 141 | void blendOnSurface( SDL_Surface *dst_surface, int dst_x, int dst_y, 142 | SDL_Rect &clip, int alpha=256 ); 143 | //Mion - ogapee2008 144 | void blendOnSurface2( SDL_Surface *dst_surface, int dst_x, int dst_y, 145 | SDL_Rect &clip, int alpha=256 ); 146 | void blendBySurface( SDL_Surface *surface, int dst_x, int dst_y, SDL_Color &color, 147 | SDL_Rect *clip, bool rotate_flag ); 148 | void calcAffineMatrix(); 149 | 150 | static SDL_Surface *allocSurface( int w, int h ); 151 | void allocImage( int w, int h ); 152 | void copySurface( SDL_Surface *surface, SDL_Rect *src_rect, SDL_Rect *dst_rect = NULL ); 153 | void fill( Uint8 r, Uint8 g, Uint8 b, Uint8 a ); 154 | void setupImage( SDL_Surface *surface, SDL_Surface *surface_m, bool has_alpha ); 155 | static void setCpufuncs(unsigned int func); 156 | static unsigned int getCpufuncs(); 157 | static void imageFilterMean(unsigned char *src1, unsigned char *src2, unsigned char *dst, int length); 158 | static void imageFilterAddTo(unsigned char *dst, unsigned char *src, int length); 159 | static void imageFilterSubFrom(unsigned char *dst, unsigned char *src, int length); 160 | static void imageFilterBlend(Uint32 *dst_buffer, Uint32 *src_buffer, Uint8 *alphap, int alpha, int length); 161 | }; 162 | 163 | #endif // __ANIMATION_INFO_H__ 164 | -------------------------------------------------------------------------------- /BUGS: -------------------------------------------------------------------------------- 1 | BUGS OR MISFEATURES 2 | 3 | * OS X: should look for missing files (eg font) inside bundles, even 4 | if the main game data is outside the bundle. 5 | 6 | FEATURES REQUESTED 7 | 8 | * Allow the specification of a "fallback" font to use for characters 9 | missing from the main font -- this would make mix-and-match Japanese 10 | and English easier. 11 | -------------------------------------------------------------------------------- /BaseReader.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * BaseReader.h - Base class of archive reader 4 | * 5 | * Copyright (c) 2001-2008 Ogapee. All rights reserved. 6 | * 7 | * ogapee@aqua.dti2.ne.jp 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef __BASE_READER_H__ 25 | #define __BASE_READER_H__ 26 | 27 | #include 28 | 29 | #ifndef SEEK_END 30 | #define SEEK_END 2 31 | #endif 32 | 33 | #ifdef WIN32 34 | #define DELIMITER '\\' 35 | #else 36 | #define DELIMITER '/' 37 | #endif 38 | 39 | struct BaseReader 40 | { 41 | enum { 42 | NO_COMPRESSION = 0, 43 | SPB_COMPRESSION = 1, 44 | LZSS_COMPRESSION = 2, 45 | NBZ_COMPRESSION = 4 46 | }; 47 | 48 | enum { 49 | ARCHIVE_TYPE_NONE = 0, 50 | ARCHIVE_TYPE_SAR = 1, 51 | ARCHIVE_TYPE_NSA = 2, 52 | ARCHIVE_TYPE_NS2 = 3, 53 | ARCHIVE_TYPE_NS3 = 4 54 | }; 55 | 56 | struct FileInfo{ 57 | char name[256]; 58 | int compression_type; 59 | size_t offset; 60 | size_t length; 61 | size_t original_length; 62 | }; 63 | 64 | struct ArchiveInfo{ 65 | struct ArchiveInfo *next; 66 | FILE *file_handle; 67 | char *file_name; 68 | struct FileInfo *fi_list; 69 | unsigned int num_of_files; 70 | unsigned long base_offset; 71 | 72 | ArchiveInfo(){ 73 | next = NULL; 74 | file_handle = NULL; 75 | file_name = NULL; 76 | fi_list = NULL; 77 | num_of_files = 0; 78 | } 79 | }; 80 | 81 | virtual ~BaseReader(){}; 82 | 83 | virtual int open( const char *name=NULL, int archive_type = ARCHIVE_TYPE_NONE ) = 0; 84 | virtual int close() = 0; 85 | 86 | virtual const char *getArchiveName() const = 0; 87 | virtual int getNumFiles() = 0; 88 | virtual void registerCompressionType( const char *ext, int type ) = 0; 89 | 90 | virtual struct FileInfo getFileByIndex( unsigned int index ) = 0; 91 | virtual size_t getFileLength( const char *file_name ) = 0; 92 | virtual size_t getFile( const char *file_name, unsigned char *buffer, int *location=NULL ) = 0; 93 | }; 94 | 95 | #endif // __BASE_READER_H__ 96 | -------------------------------------------------------------------------------- /DirPaths.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * DirPaths.cpp - contains multiple directory paths 4 | * 5 | * Added by Sonozaki Futago-tachi, Nov. 2007 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include "DirPaths.h" 23 | 24 | DirPaths::DirPaths() 25 | { 26 | num_paths = 0; 27 | paths = NULL; 28 | all_paths = NULL; 29 | } 30 | 31 | DirPaths::DirPaths( const char *new_paths ) 32 | { 33 | num_paths = 0; 34 | paths = NULL; 35 | all_paths = NULL; 36 | add(new_paths); 37 | } 38 | 39 | DirPaths::DirPaths( DirPaths& old_dp ) 40 | { 41 | num_paths = 0; 42 | paths = NULL; 43 | add(old_dp.get_all_paths()); 44 | } 45 | 46 | DirPaths::~DirPaths() 47 | { 48 | if (paths != NULL) { 49 | char **ptr = paths; 50 | for (int i=0; i 0) { 87 | // make a new "paths", copy over existing ones 88 | //printf("DirPaths::add(\"%s\")\n", new_paths); 89 | old_paths = paths; 90 | paths = new char*[num_paths + 1]; 91 | for (i=0; i num_paths) || (n < 0)) 148 | return NULL; 149 | else 150 | return paths[n]; 151 | } 152 | 153 | // Returns a delimited string containing all paths 154 | char* DirPaths::get_all_paths() 155 | { 156 | if ((all_paths == NULL) && (paths != NULL)) { 157 | // construct all_paths 158 | char *buf; 159 | int n, len = 0; 160 | for (n=0; n len) 189 | len = strlen(paths[i]); 190 | } 191 | return len; 192 | } 193 | -------------------------------------------------------------------------------- /DirPaths.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * DirPaths.h - contains multiple directory paths 4 | * 5 | * Added by Sonozaki Futago-tachi, Nov. 2007 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef __DIR_PATHS__ 23 | #define __DIR_PATHS__ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #if defined(WIN32) 30 | #define DELIMITER '\\' 31 | #define PATH_DELIMITER ';' 32 | #elif defined(WII) 33 | #define DELIMITER '/' 34 | #define PATH_DELIMITER ';' 35 | #else 36 | #define DELIMITER '/' 37 | #define PATH_DELIMITER ':' 38 | #endif 39 | 40 | 41 | class DirPaths 42 | { 43 | public: 44 | DirPaths(); 45 | DirPaths( const char *new_paths ); 46 | DirPaths( DirPaths& old_dp ); 47 | ~DirPaths(); 48 | 49 | void add( const char *new_paths ); 50 | char *get_path( int n ); 51 | char *get_all_paths(); 52 | int get_num_paths(); 53 | unsigned int max_path_len(); 54 | 55 | private: 56 | int num_paths; 57 | char **paths; 58 | char *all_paths; 59 | }; 60 | 61 | #endif // __DIR_PATHS__ 62 | -------------------------------------------------------------------------------- /DirectReader.h: -------------------------------------------------------------------------------- 1 | //$Id:$ -*- C++ -*- 2 | /* 3 | * DirectReader.h - Reader from independent files 4 | * 5 | * Copyright (c) 2001-2008 Ogapee. All rights reserved. 6 | * 7 | * ogapee@aqua.dti2.ne.jp 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef __DIRECT_READER_H__ 25 | #define __DIRECT_READER_H__ 26 | 27 | #include "BaseReader.h" 28 | #include "DirPaths.h" 29 | #include 30 | 31 | #define MAX_FILE_NAME_LENGTH 256 32 | 33 | class DirectReader : public BaseReader 34 | { 35 | public: 36 | DirectReader( DirPaths *path=NULL, const unsigned char *key_table=NULL ); 37 | ~DirectReader(); 38 | 39 | int open( const char *name=NULL, int archive_type = ARCHIVE_TYPE_NONE ); 40 | int close(); 41 | 42 | void setArchivePath( DirPaths *path ); 43 | const char *getArchiveName() const; 44 | int getNumFiles(); 45 | void registerCompressionType( const char *ext, int type ); 46 | 47 | struct FileInfo getFileByIndex( unsigned int index ); 48 | size_t getFileLength( const char *file_name ); 49 | size_t getFile( const char *file_name, unsigned char *buffer, int *location=NULL ); 50 | 51 | static void convertFromSJISToEUC( char *buf ); 52 | static void convertFromSJISToUTF8( char *dst_buf, char *src_buf, size_t src_len ); 53 | 54 | protected: 55 | char *file_full_path; 56 | char *file_sub_path; 57 | size_t file_path_len; 58 | char *capital_name; 59 | char *capital_name_tmp; 60 | 61 | DirPaths *archive_path; 62 | unsigned char key_table[256]; 63 | bool key_table_flag; 64 | int getbit_mask; 65 | size_t getbit_len, getbit_count; 66 | unsigned char *read_buf; 67 | unsigned char *decomp_buffer; 68 | size_t decomp_buffer_len; 69 | 70 | struct RegisteredCompressionType{ 71 | RegisteredCompressionType *next; 72 | char *ext; 73 | int type; 74 | RegisteredCompressionType(){ 75 | ext = NULL; 76 | next = NULL; 77 | }; 78 | RegisteredCompressionType( const char *ext, int type ){ 79 | this->ext = new char[ strlen(ext)+1 ]; 80 | for ( unsigned int i=0 ; iext[i] = ext[i]; 82 | if ( this->ext[i] >= 'a' && this->ext[i] <= 'z' ) 83 | this->ext[i] += 'A' - 'a'; 84 | } 85 | this->type = type; 86 | this->next = NULL; 87 | }; 88 | ~RegisteredCompressionType(){ 89 | if (ext) delete[] ext; 90 | }; 91 | } root_registered_compression_type, *last_registered_compression_type; 92 | 93 | FILE *fopen(const char *path, const char *mode); 94 | unsigned char readChar( FILE *fp ); 95 | unsigned short readShort( FILE *fp ); 96 | unsigned long readLong( FILE *fp ); 97 | void writeChar( FILE *fp, unsigned char ch ); 98 | void writeShort( FILE *fp, unsigned short ch ); 99 | void writeLong( FILE *fp, unsigned long ch ); 100 | size_t decodeNBZ( FILE *fp, size_t offset, unsigned char *buf ); 101 | size_t encodeNBZ( FILE *fp, size_t length, unsigned char *buf ); 102 | int getbit( FILE *fp, int n ); 103 | size_t decodeSPB( FILE *fp, size_t offset, unsigned char *buf ); 104 | size_t decodeLZSS( struct ArchiveInfo *ai, int no, unsigned char *buf ); 105 | int getRegisteredCompressionType( const char *file_name ); 106 | size_t getDecompressedFileLength( int type, FILE *fp, size_t offset ); 107 | 108 | private: 109 | FILE *getFileHandle( const char *file_name, int &compression_type, size_t *length ); 110 | }; 111 | 112 | #endif // __DIRECT_READER_H__ 113 | -------------------------------------------------------------------------------- /DirtyRect.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * DirtyRect.cpp - Invalid region on text_surface which should be updated 4 | * 5 | * Copyright (c) 2001-2004 Ogapee. All rights reserved. 6 | * 7 | * ogapee@aqua.dti2.ne.jp 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "DirtyRect.h" 25 | 26 | DirtyRect::DirtyRect() 27 | { 28 | area = 0; 29 | total_history = 10; 30 | num_history = 0; 31 | bounding_box.w = bounding_box.h = 0; 32 | history = new SDL_Rect[total_history]; 33 | }; 34 | 35 | DirtyRect::DirtyRect( const DirtyRect &d ) 36 | { 37 | area = d.area; 38 | total_history = d.total_history; 39 | num_history = d.num_history; 40 | bounding_box = d.bounding_box; 41 | history = new SDL_Rect[total_history]; 42 | 43 | for ( int i=0 ; i= 0 && 94 | history[min_hist].w * history[min_hist].h + src.w * src.h > min_is ){ 95 | area -= history[min_hist].w * history[min_hist].h; 96 | history[min_hist] = calcBoundingBox(src, history[min_hist]); 97 | area += history[min_hist].w * history[min_hist].h; 98 | return; 99 | } 100 | 101 | history[ num_history++ ] = src; 102 | area += src.w * src.h; 103 | 104 | if ( num_history == total_history ){ 105 | total_history += 10; 106 | SDL_Rect *tmp = history; 107 | history = new SDL_Rect[ total_history ]; 108 | for ( i=0 ; i src2.x ){ 126 | src1.w += src1.x - src2.x; 127 | src1.x = src2.x; 128 | } 129 | if ( src1.y > src2.y ){ 130 | src1.h += src1.y - src2.y; 131 | src1.y = src2.y; 132 | } 133 | if ( src1.x + src1.w < src2.x + src2.w ){ 134 | src1.w = src2.x + src2.w - src1.x; 135 | } 136 | if ( src1.y + src1.h < src2.y + src2.h ){ 137 | src1.h = src2.y + src2.h - src1.y; 138 | } 139 | 140 | return src1; 141 | } 142 | 143 | void DirtyRect::clear() 144 | { 145 | area = 0; 146 | num_history = 0; 147 | bounding_box.w = bounding_box.h = 0; 148 | } 149 | 150 | void DirtyRect::fill( int w, int h ) 151 | { 152 | area = w*h; 153 | bounding_box.x = bounding_box.y = 0; 154 | bounding_box.w = w; 155 | bounding_box.h = h; 156 | } 157 | -------------------------------------------------------------------------------- /DirtyRect.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * DirtyRect.h - Invalid region on text_surface which should be updated 4 | * 5 | * Copyright (c) 2001-2004 Ogapee. All rights reserved. 6 | * 7 | * ogapee@aqua.dti2.ne.jp 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef __DIRTY_RECT__ 25 | #define __DIRTY_RECT__ 26 | 27 | #include 28 | 29 | struct DirtyRect 30 | { 31 | DirtyRect(); 32 | DirtyRect( const DirtyRect &d ); 33 | DirtyRect& operator =( const DirtyRect &d ); 34 | ~DirtyRect(); 35 | 36 | void add( SDL_Rect src ); 37 | void clear(); 38 | void fill( int w, int h ); 39 | 40 | SDL_Rect calcBoundingBox( SDL_Rect src1, SDL_Rect &src2 ); 41 | 42 | int area; 43 | int total_history; 44 | int num_history; 45 | SDL_Rect bounding_box; 46 | SDL_Rect *history; 47 | }; 48 | 49 | #endif // __DIRTY_RECT__ 50 | -------------------------------------------------------------------------------- /FontInfo.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * FontInfo.cpp - Font information storage class of ONScripter 4 | * 5 | * Copyright (c) 2001-2007 Ogapee. All rights reserved. 6 | * 7 | * ogapee@aqua.dti2.ne.jp 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "FontInfo.h" 25 | #include 26 | #include 27 | 28 | static struct FontContainer{ 29 | FontContainer *next; 30 | int size; 31 | TTF_Font *font; 32 | 33 | FontContainer(){ 34 | size = 0; 35 | next = NULL; 36 | font = NULL; 37 | }; 38 | } root_font_container; 39 | 40 | Fontinfo::Fontinfo() 41 | { 42 | ttf_font = NULL; 43 | 44 | color[0] = color[1] = color[2] = 0xff; 45 | on_color[0] = on_color[1] = on_color[2] = 0xff; 46 | off_color[0] = off_color[1] = off_color[2] = 0xaa; 47 | nofile_color[0] = 0x55; 48 | nofile_color[1] = 0x55; 49 | nofile_color[2] = 0x99; 50 | 51 | reset(); 52 | } 53 | 54 | void Fontinfo::reset() 55 | { 56 | tateyoko_mode = YOKO_MODE; 57 | rubyon_flag = false; 58 | ruby_offset_xy[0] = ruby_offset_xy[1] = 0; 59 | clear(); 60 | 61 | is_bold = true; 62 | is_shadow = true; 63 | is_transparent = true; 64 | is_newline_accepted = false; 65 | } 66 | 67 | void *Fontinfo::openFont( char *font_file, int ratio1, int ratio2 ) 68 | { 69 | int font_size; 70 | if ( font_size_xy[0] < font_size_xy[1] ) 71 | font_size = font_size_xy[0]; 72 | else 73 | font_size = font_size_xy[1]; 74 | 75 | FontContainer *fc = &root_font_container; 76 | while( fc->next ){ 77 | if ( fc->next->size == font_size ) break; 78 | fc = fc->next; 79 | } 80 | if ( !fc->next ){ 81 | fc->next = new FontContainer(); 82 | fc->next->size = font_size; 83 | FILE *fp = fopen( font_file, "r" ); 84 | if ( fp == NULL ) return NULL; 85 | fclose( fp ); 86 | fc->next->font = TTF_OpenFont( font_file, font_size * ratio1 / ratio2 ); 87 | } 88 | 89 | ttf_font = (void*)fc->next->font; 90 | 91 | return fc->next->font; 92 | } 93 | 94 | void Fontinfo::setTateyokoMode( int tateyoko_mode ) 95 | { 96 | this->tateyoko_mode = tateyoko_mode; 97 | clear(); 98 | } 99 | 100 | int Fontinfo::getTateyokoMode() 101 | { 102 | return tateyoko_mode; 103 | } 104 | 105 | int Fontinfo::getRemainingLine() 106 | { 107 | if (tateyoko_mode == YOKO_MODE) 108 | return num_xy[1] - xy[1]/2; 109 | else 110 | return num_xy[1] - num_xy[0] + xy[0]/2 + 1; 111 | } 112 | 113 | int Fontinfo::x() 114 | { 115 | return xy[0]*pitch_xy[0]/2 + top_xy[0] + line_offset_xy[0] + ruby_offset_xy[0]; 116 | } 117 | 118 | int Fontinfo::y() 119 | { 120 | return xy[1]*pitch_xy[1]/2 + top_xy[1] + line_offset_xy[1] + ruby_offset_xy[1]; 121 | } 122 | 123 | void Fontinfo::setXY( int x, int y ) 124 | { 125 | if ( x != -1 ) xy[0] = x*2; 126 | if ( y != -1 ) xy[1] = y*2; 127 | } 128 | 129 | void Fontinfo::clear() 130 | { 131 | if (tateyoko_mode == YOKO_MODE) 132 | setXY(0, 0); 133 | else 134 | setXY(num_xy[0]-1, 0); 135 | line_offset_xy[0] = line_offset_xy[1] = 0; 136 | setRubyOnFlag(rubyon_flag); 137 | } 138 | 139 | void Fontinfo::newLine() 140 | { 141 | if (tateyoko_mode == YOKO_MODE){ 142 | xy[0] = 0; 143 | xy[1] += 2; 144 | } 145 | else{ 146 | xy[0] -= 2; 147 | xy[1] = 0; 148 | } 149 | line_offset_xy[0] = line_offset_xy[1] = 0; 150 | } 151 | 152 | void Fontinfo::setLineArea(int num) 153 | { 154 | num_xy[tateyoko_mode] = num; 155 | num_xy[1-tateyoko_mode] = 1; 156 | } 157 | 158 | bool Fontinfo::isEndOfLine(int margin) 159 | { 160 | int offset = 2 * line_offset_xy[tateyoko_mode] / pitch_xy[tateyoko_mode]; 161 | if (((2 * line_offset_xy[tateyoko_mode]) % pitch_xy[tateyoko_mode]) > 0) 162 | offset++; 163 | if (xy[tateyoko_mode] + offset + margin >= num_xy[tateyoko_mode]*2) 164 | return true; 165 | 166 | return false; 167 | } 168 | 169 | bool Fontinfo::isLineEmpty() 170 | { 171 | if (xy[tateyoko_mode] == 0) return true; 172 | 173 | return false; 174 | } 175 | 176 | void Fontinfo::advanceCharInHankaku(int offset) 177 | { 178 | xy[tateyoko_mode] += offset; 179 | } 180 | 181 | void Fontinfo::addLineOffset(int offset) 182 | { 183 | line_offset_xy[tateyoko_mode] += offset; 184 | } 185 | 186 | void Fontinfo::setRubyOnFlag(bool flag) 187 | { 188 | rubyon_flag = flag; 189 | ruby_offset_xy[0] = ruby_offset_xy[1] = 0; 190 | if (rubyon_flag && tateyoko_mode == TATE_MODE) 191 | ruby_offset_xy[0] = font_size_xy[0]-pitch_xy[0]; 192 | if (rubyon_flag && tateyoko_mode == YOKO_MODE) 193 | ruby_offset_xy[1] = pitch_xy[1] - font_size_xy[1]; 194 | } 195 | 196 | SDL_Rect Fontinfo::calcUpdatedArea(int start_xy[2], int ratio1, int ratio2) 197 | { 198 | SDL_Rect rect; 199 | 200 | if (tateyoko_mode == YOKO_MODE){ 201 | if (start_xy[1] == xy[1]){ 202 | rect.x = top_xy[0] + pitch_xy[0]*start_xy[0]/2; 203 | rect.w = pitch_xy[0]*(xy[0]-start_xy[0])/2+1; 204 | } 205 | else{ 206 | rect.x = top_xy[0]; 207 | rect.w = pitch_xy[0]*num_xy[0]; 208 | } 209 | rect.y = top_xy[1] + start_xy[1]*pitch_xy[1]/2; 210 | rect.h = pitch_xy[1]*(xy[1]-start_xy[1]+2)/2; 211 | } 212 | else{ 213 | rect.x = top_xy[0] + pitch_xy[0]*xy[0]/2; 214 | rect.w = pitch_xy[0]*(start_xy[0]-xy[0]+2)/2; 215 | if (start_xy[0] == xy[0]){ 216 | rect.y = top_xy[1] + pitch_xy[1]*start_xy[1]/2; 217 | rect.h = pitch_xy[1]*(xy[1]-start_xy[1])/2+1; 218 | } 219 | else{ 220 | rect.y = top_xy[1]; 221 | rect.h = pitch_xy[1]*num_xy[1]; 222 | } 223 | num_xy[0] = (xy[0]-start_xy[0])/2+1; 224 | } 225 | 226 | rect.x = rect.x * ratio1 / ratio2; 227 | rect.y = rect.y * ratio1 / ratio2; 228 | rect.w = rect.w * ratio1 / ratio2; 229 | rect.h = rect.h * ratio1 / ratio2; 230 | 231 | return rect; 232 | } 233 | 234 | void Fontinfo::addShadeArea(SDL_Rect &rect, int shade_distance[2]) 235 | { 236 | if (is_shadow){ 237 | if (shade_distance[0]>0) 238 | rect.w += shade_distance[0]; 239 | else{ 240 | rect.x += shade_distance[0]; 241 | rect.w -= shade_distance[0]; 242 | } 243 | if (shade_distance[1]>0) 244 | rect.h += shade_distance[1]; 245 | else{ 246 | rect.y += shade_distance[1]; 247 | rect.h -= shade_distance[1]; 248 | } 249 | } 250 | } 251 | 252 | int Fontinfo::initRuby(Fontinfo &body_info, int body_count, int ruby_count) 253 | { 254 | top_xy[0] = body_info.x(); 255 | top_xy[1] = body_info.y(); 256 | pitch_xy[0] = font_size_xy[0]; 257 | pitch_xy[1] = font_size_xy[1]; 258 | 259 | int margin=0; 260 | 261 | if (tateyoko_mode == YOKO_MODE){ 262 | top_xy[1] -= font_size_xy[1]; 263 | num_xy[0] = ruby_count; 264 | num_xy[1] = 1; 265 | } 266 | else{ 267 | top_xy[0] += body_info.font_size_xy[0]; 268 | num_xy[0] = 1; 269 | num_xy[1] = ruby_count; 270 | } 271 | 272 | if (ruby_count*font_size_xy[tateyoko_mode] >= body_count*body_info.pitch_xy[tateyoko_mode]){ 273 | margin = (ruby_count*font_size_xy[tateyoko_mode] - body_count*body_info.pitch_xy[tateyoko_mode] + 1)/2; 274 | } 275 | else{ 276 | int offset = 0; 277 | if (ruby_count > 0) 278 | offset = (body_count*body_info.pitch_xy[tateyoko_mode] - ruby_count*font_size_xy[tateyoko_mode]) / ruby_count; 279 | top_xy[tateyoko_mode] += (offset+1)/2; 280 | pitch_xy[tateyoko_mode] += offset; 281 | } 282 | //body_info.line_offset_xy[tateyoko_mode] += margin; 283 | 284 | clear(); 285 | 286 | return margin; 287 | } 288 | -------------------------------------------------------------------------------- /FontInfo.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * FontInfo.h - Font information storage class of ONScripter 4 | * 5 | * Copyright (c) 2001-2007 Ogapee. All rights reserved. 6 | * 7 | * ogapee@aqua.dti2.ne.jp 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef __FONT_INFO_H__ 25 | #define __FONT_INFO_H__ 26 | 27 | #include 28 | 29 | typedef unsigned char uchar3[3]; 30 | 31 | // OS X pollutes the main namespace with its own FontInfo type, so we 32 | // have to use something else. 33 | class Fontinfo { 34 | public: 35 | enum { YOKO_MODE = 0, 36 | TATE_MODE = 1 37 | }; 38 | void *ttf_font; 39 | uchar3 color; 40 | uchar3 on_color, off_color, nofile_color; 41 | int font_size_xy[2]; 42 | int top_xy[2]; // Top left origin 43 | int num_xy[2]; // Row and column of the text windows 44 | int xy[2]; // Current position 45 | int pitch_xy[2]; // Width and height of a character 46 | int wait_time; 47 | bool is_bold; 48 | bool is_shadow; 49 | bool is_transparent; 50 | bool is_newline_accepted; 51 | uchar3 window_color; 52 | 53 | int line_offset_xy[2]; // ruby offset for each line 54 | int ruby_offset_xy[2]; // ruby offset for the whole sentence 55 | bool rubyon_flag; 56 | int tateyoko_mode; 57 | 58 | Fontinfo(); 59 | void reset(); 60 | void *openFont( char *font_file, int ratio1, int ratio2 ); 61 | void setTateyokoMode( int tateyoko_mode ); 62 | int getTateyokoMode(); 63 | int getRemainingLine(); 64 | 65 | int x(); 66 | int y(); 67 | void setXY( int x=-1, int y=-1 ); 68 | void clear(); 69 | void newLine(); 70 | void setLineArea(int num); 71 | 72 | bool isEndOfLine(int margin=0); 73 | bool isLineEmpty(); 74 | void advanceCharInHankaku(int offest); 75 | void addLineOffset(int margin); 76 | void setRubyOnFlag(bool flag); 77 | 78 | SDL_Rect calcUpdatedArea(int start_xy[2], int ratio1, int ratio2 ); 79 | void addShadeArea(SDL_Rect &rect, int shade_distance[2] ); 80 | int initRuby(Fontinfo &body_info, int body_count, int ruby_count); 81 | }; 82 | 83 | #endif // __FONT_INFO_H__ 84 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | * TO BUILD ONSCRIPTER-EN FOR YOUR USE 2 | 3 | This is the usual 4 | 5 | ./configure 6 | make 7 | sudo make install 8 | 9 | 10 | This will use gcc by default; to use icc, start with 11 | CC=icc ./configure 12 | 13 | 14 | * DEALING WITH UNHELPFUL LIBRARIES 15 | 16 | Some system-provided libraries are not ideally configured for use with 17 | ONScripter-En. For example, some system-provided SDL libraries cause 18 | stuttering audio. You can usually fix this by using the internal 19 | library pack and configuring with something like 20 | 21 | ./configure --with-internal-sdl 22 | 23 | (use --help to get a list of the options you can use to selectively 24 | replace libraries with internal versions). 25 | 26 | 27 | * TO BUILD A RELATIVELY REDISTRIBUTABLE ONSCRIPTER-EN BINARY 28 | 29 | Configure with 30 | 31 | ./configure --with-internal-libs 32 | 33 | to statically link as many libraries as possible into the executable, 34 | which makes life better on systems with very primitive application 35 | installation methods, such as OS X and Windows. 36 | 37 | If you are compiling ONScripter-En for a system with modern package 38 | management - for example, if you are creating a binary package for a 39 | specific Linux distribution - then it may make more sense to omit the 40 | --with-internal-libs, compile a dynamically linked executable, and 41 | have your package depend on the regular platform-specific packages for 42 | SDL, Freetype, and all the other dependencies. However, you may still 43 | need to include some libraries internally to make everything work. 44 | 45 | 46 | * NOTES 47 | 48 | For Windows builds, use a MinGW toolchain in the MSYS environment. 49 | There is no Visual Studio option; it just isn't worth the pain. 50 | 51 | For Mac OS X there is an XCode project file in the "macosx" directory. 52 | It builds a Universal binary as an application bundle. 53 | Either build from within XCode, or use "xcodebuild" from a shell prompt. 54 | It is known to build with XCode 2.4.1 on Mac OS X 10.4. 55 | The game data can either be stored in the Contents/Resources within the 56 | bundle, or run ONScripter.app from within the game directory itself. 57 | -------------------------------------------------------------------------------- /Layer.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * Layer.h - Base class for effect layers 4 | * 5 | * Added by Mion (Sonozaki Futago-tachi) Sep 2008 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef __LAYER_H__ 23 | #define __LAYER_H__ 24 | 25 | #include "AnimationInfo.h" 26 | #include "BaseReader.h" 27 | 28 | struct Pt { int x; int y; int type; int cell; }; 29 | 30 | struct Layer 31 | { 32 | BaseReader *reader; 33 | AnimationInfo *sprite_info, *sprite; 34 | int width, height; 35 | 36 | virtual ~Layer(){}; 37 | 38 | void setSpriteInfo( AnimationInfo *sinfo, AnimationInfo *anim ){ 39 | sprite_info = sinfo; 40 | sprite = anim; 41 | }; 42 | virtual void update( ) = 0; 43 | virtual char* message( const char *message, int &ret_int ) = 0; 44 | virtual void refresh( SDL_Surface* surface, SDL_Rect &clip ) = 0; 45 | }; 46 | 47 | class OldMovieLayer : public Layer 48 | { 49 | public: 50 | OldMovieLayer( int w, int h ); 51 | ~OldMovieLayer(); 52 | void update(); 53 | char* message( const char *message, int &ret_int ); 54 | void refresh( SDL_Surface* surface, SDL_Rect &clip ); 55 | 56 | private: 57 | // message parameters 58 | int blur_level; 59 | int noise_level; 60 | int glow_level; 61 | int scratch_level; 62 | int dust_level; 63 | AnimationInfo *dust_sprite; 64 | AnimationInfo *dust; 65 | 66 | Pt *dust_pts; 67 | int rx, ry, // Offset of blur (second copy of background image) 68 | ns; // Current noise surface 69 | int gv, // Current glow level 70 | go; // Glow delta: flips between 1 and -1 to fade the glow in and out. 71 | bool initialized; 72 | 73 | void om_init(); 74 | //void BlendOnSurface(SDL_Surface* src, SDL_Surface* dst, SDL_Rect clip); 75 | }; 76 | 77 | #define N_FURU_ELEMENTS 3 78 | #define FURU_ELEMENT_BUFSIZE 512 // should be a power of 2 79 | #define FURU_AMP_TABLE_SIZE 256 // should also be power of 2, it helps 80 | const float fall_mult[N_FURU_ELEMENTS] = {0.9, 0.7, 0.6}; 81 | 82 | class FuruLayer : public Layer 83 | { 84 | public: 85 | FuruLayer( int w, int h, bool animated, BaseReader *br=NULL ); 86 | ~FuruLayer(); 87 | void update(); 88 | char* message( const char *message, int &ret_int ); 89 | void refresh( SDL_Surface* surface, SDL_Rect &clip ); 90 | 91 | private: 92 | bool tumbling; // true (hana) or false (snow) 93 | 94 | // message parameters 95 | int interval; // 1 ~ 10000; # frames between a new element release 96 | int fall_velocity; // 1 ~ screen_height; pix/frame 97 | int wind; // -screen_width/2 ~ screen_width/2; pix/frame 98 | int amplitude; // 0 ~ screen_width/2; pix/frame 99 | int freq; // 0 ~ 359; degree/frame 100 | int angle; 101 | bool paused, halted; 102 | 103 | struct OscPt { // point plus base oscillation angle 104 | Pt pt; 105 | int base_angle; 106 | }; 107 | struct Element { 108 | AnimationInfo *sprite; 109 | int *amp_table; 110 | // rolling buffer 111 | OscPt *points; 112 | int pstart, pend, frame_cnt, fall_speed; 113 | Element(){ 114 | sprite = NULL; 115 | amp_table = NULL; 116 | points = NULL; 117 | pstart = pend = frame_cnt = fall_speed = 0; 118 | }; 119 | ~Element(){ 120 | if (sprite) delete sprite; 121 | if (amp_table) delete[] amp_table; 122 | if (points) delete[] points; 123 | }; 124 | void init(){ 125 | if (!points) points = new OscPt[FURU_ELEMENT_BUFSIZE]; 126 | pstart = pend = frame_cnt = 0; 127 | }; 128 | void clear(){ 129 | if (sprite) delete sprite; 130 | sprite = NULL; 131 | if (amp_table) delete[] amp_table; 132 | amp_table = NULL; 133 | if (points) delete[] points; 134 | points = NULL; 135 | pstart = pend = frame_cnt = 0; 136 | }; 137 | void setSprite(AnimationInfo *anim){ 138 | if (sprite) delete sprite; 139 | sprite = anim; 140 | }; 141 | } elements[N_FURU_ELEMENTS]; 142 | int max_sp_w; 143 | 144 | bool initialized; 145 | 146 | void furu_init(); 147 | void validate_params(); 148 | void buildAmpTables(); 149 | }; 150 | 151 | #endif // __LAYER_H__ 152 | -------------------------------------------------------------------------------- /MadWrapper.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * MadWrapper.h - SMPEG compatible wrapper functions for MAD: Mpeg Audio Decoder 4 | * 5 | * Copyright (c) 2001-2004 Ogapee. All rights reserved. 6 | * 7 | * ogapee@aqua.dti2.ne.jp 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef __MAD_WRAPPER_H__ 25 | #define __MAD_WRAPPER_H__ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | typedef struct _MAD_WRAPPER MAD_WRAPPER; 33 | 34 | MAD_WRAPPER* MAD_WRAPPER_new( const char *file, void* info, int sdl_audio ); 35 | MAD_WRAPPER* MAD_WRAPPER_new_rwops( SDL_RWops *src, void* info, int sdl_audio ); 36 | int MAD_WRAPPER_playAudio( void *userdata, Uint8 *stream, int len ); 37 | void MAD_WRAPPER_stop( MAD_WRAPPER *mad ); 38 | void MAD_WRAPPER_play( MAD_WRAPPER *mad ); 39 | void MAD_WRAPPER_delete( MAD_WRAPPER *mad ); 40 | void MAD_WRAPPER_setvolume( MAD_WRAPPER *mad, int volume ); 41 | const char* MAD_WRAPPER_error( MAD_WRAPPER *mad ); 42 | 43 | #define SMPEG_new MAD_WRAPPER_new 44 | #define SMPEG_new_rwops MAD_WRAPPER_new_rwops 45 | #define SMPEG_playAudio MAD_WRAPPER_playAudio 46 | #define SMPEG_play MAD_WRAPPER_play 47 | #define SMPEG_stop MAD_WRAPPER_stop 48 | #define SMPEG_delete MAD_WRAPPER_delete 49 | #define SMPEG_setvolume MAD_WRAPPER_setvolume 50 | #define SMPEG MAD_WRAPPER 51 | #define SMPEG_error MAD_WRAPPER_error 52 | 53 | #endif // __MAD_WRAPPER_H__ 54 | 55 | -------------------------------------------------------------------------------- /Makefile.onscripter: -------------------------------------------------------------------------------- 1 | # -*- makefile-gmake -*- 2 | # 3 | # Makefile.onscripter - General makefile rules for ONScripter 4 | # 5 | 6 | TARGET_EXE ?= onscripter 7 | 8 | GUI_OBJS = ONScripterLabel$(OBJSUFFIX) \ 9 | ONScripterLabel_command$(OBJSUFFIX) \ 10 | ONScripterLabel_text$(OBJSUFFIX) \ 11 | ONScripterLabel_effect$(OBJSUFFIX) \ 12 | ONScripterLabel_event$(OBJSUFFIX) \ 13 | ONScripterLabel_rmenu$(OBJSUFFIX) \ 14 | ONScripterLabel_animation$(OBJSUFFIX) \ 15 | ONScripterLabel_sound$(OBJSUFFIX) \ 16 | ONScripterLabel_file$(OBJSUFFIX) \ 17 | ONScripterLabel_file2$(OBJSUFFIX) \ 18 | ONScripterLabel_image$(OBJSUFFIX) AnimationInfo$(OBJSUFFIX) \ 19 | FontInfo$(OBJSUFFIX) DirtyRect$(OBJSUFFIX) \ 20 | resize_image$(OBJSUFFIX) 21 | DECODER_OBJS = DirectReader$(OBJSUFFIX) SarReader$(OBJSUFFIX) \ 22 | NsaReader$(OBJSUFFIX) 23 | ONSCRIPTER_OBJS = onscripter$(OBJSUFFIX) $(DECODER_OBJS) \ 24 | ScriptHandler$(OBJSUFFIX) ScriptParser$(OBJSUFFIX) \ 25 | ScriptParser_command$(OBJSUFFIX) $(GUI_OBJS) \ 26 | sjis2utf16$(OBJSUFFIX) $(EXT_OBJS) \ 27 | DirPaths$(OBJSUFFIX) Layer$(OBJSUFFIX) 28 | PARSER_HEADER = $(EXTRADEPS) BaseReader.h SarReader.h NsaReader.h \ 29 | DirectReader.h ScriptHandler.h ScriptParser.h \ 30 | AnimationInfo.h FontInfo.h DirtyRect.h DirPaths.h Layer.h 31 | ONSCRIPTER_HEADER = ONScripterLabel.h $(PARSER_HEADER) 32 | 33 | ALL: $(TARGET) 34 | 35 | $(TARGET_EXE)$(EXESUFFIX): $(ONSCRIPTER_OBJS) 36 | $(CXX) -o $@ $(LDFLAGS) $(ONSCRIPTER_OBJS) $(LIBS) 37 | 38 | pclean: 39 | -$(RM) *$(OBJSUFFIX) $(CLEANUP) $(RCFILE) 40 | 41 | pdistclean: pclean 42 | -$(RM) $(TARGET_EXE)$(EXESUFFIX) onscripter-en$(EXESUFFIX) 43 | 44 | .cpp$(OBJSUFFIX): 45 | $(CXX) -c -o $@ $(OSCFLAGS) $(INCS) $(DEFS) $< 46 | 47 | Layer$(OBJSUFFIX): Layer.h AnimationInfo.h 48 | DirPaths$(OBJSUFFIX): DirPaths.h 49 | SarReader$(OBJSUFFIX): BaseReader.h SarReader.h 50 | NsaReader$(OBJSUFFIX): BaseReader.h SarReader.h NsaReader.h 51 | DirectReader$(OBJSUFFIX): BaseReader.h DirectReader.h 52 | ScriptHandler$(OBJSUFFIX): ScriptHandler.h 53 | ScriptParser$(OBJSUFFIX): $(PARSER_HEADER) 54 | ScriptParser_command$(OBJSUFFIX): $(PARSER_HEADER) 55 | 56 | onscripter$(OBJSUFFIX): $(ONSCRIPTER_HEADER) version.h 57 | ONScripterLabel$(OBJSUFFIX): $(ONSCRIPTER_HEADER) 58 | ONScripterLabel_command$(OBJSUFFIX): $(ONSCRIPTER_HEADER) version.h 59 | ONScripterLabel_text$(OBJSUFFIX): $(ONSCRIPTER_HEADER) 60 | ONScripterLabel_effect$(OBJSUFFIX): $(ONSCRIPTER_HEADER) 61 | ONScripterLabel_event$(OBJSUFFIX): $(ONSCRIPTER_HEADER) 62 | ONScripterLabel_rmenu$(OBJSUFFIX): $(ONSCRIPTER_HEADER) 63 | ONScripterLabel_animation$(OBJSUFFIX): $(ONSCRIPTER_HEADER) 64 | ONScripterLabel_sound$(OBJSUFFIX): $(ONSCRIPTER_HEADER) 65 | ONScripterLabel_file$(OBJSUFFIX): $(ONSCRIPTER_HEADER) 66 | ONScripterLabel_file2$(OBJSUFFIX): $(ONSCRIPTER_HEADER) 67 | ONScripterLabel_image$(OBJSUFFIX): $(ONSCRIPTER_HEADER) resize_image.h 68 | AnimationInfo$(OBJSUFFIX): AnimationInfo.h graphics_common.h 69 | FontInfo$(OBJSUFFIX): FontInfo.h 70 | DirtyRect$(OBJSUFFIX) : DirtyRect.h 71 | MadWrapper$(OBJSUFFIX): MadWrapper.h 72 | AVIWrapper$(OBJSUFFIX): AVIWrapper.h 73 | -------------------------------------------------------------------------------- /Makefile.wii: -------------------------------------------------------------------------------- 1 | # Makefile for ONScripter-WII 2 | #--------------------------------------------------------------------------------- 3 | # Clear the implicit built in rules 4 | #--------------------------------------------------------------------------------- 5 | .SUFFIXES: 6 | #--------------------------------------------------------------------------------- 7 | ifeq ($(strip $(DEVKITPPC)),) 8 | $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") 9 | endif 10 | 11 | include $(DEVKITPPC)/wii_rules 12 | 13 | #--------------------------------------------------------------------------------- 14 | # TARGET is the name of the output 15 | # BUILD is the directory where object files & intermediate files will be placed 16 | # SOURCES is a list of directories containing source code 17 | # INCLUDES is a list of directories containing extra header files 18 | # EXCLUDES is a list of files that should NOT be built 19 | #--------------------------------------------------------------------------------- 20 | TARGET := onscripter 21 | BUILD := build 22 | SOURCES := . wii wii/libwiigui wii/fonts wii/sounds wii/images wii/mad_decoder 23 | INCLUDES := . wii wii/mad_decoder 24 | EXCLUDES := AVIWrapper.cpp MadWrapper.cpp nscriptdecode.cpp SDL_win32_main.c 25 | 26 | #--------------------------------------------------------------------------------- 27 | # Option for xml generation 28 | #--------------------------------------------------------------------------------- 29 | NAME = ONScripter WII 30 | AUTHOR = Brian 31 | VERSION = v07.2009 32 | DATE = `date +%Y%m%d%H%M%S` 33 | SDESC = "Visual Novel Engine" 34 | LDESC = "ONscripter is an open source clone of the japanese visual novel engine NScripter\n\nOrginal Code: Ogapee\nOnscripter-En: Haeleth" 35 | 36 | #--------------------------------------------------------------------------------- 37 | # options for code generation 38 | #--------------------------------------------------------------------------------- 39 | DEFINES = -DWII -DPDA -DPDA_WIDTH=640 -DUSE_OGG_VORBIS -DENABLE_1BYTE_CHAR -DINSANI -DHAELETH 40 | CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) $(DEFINES) 41 | CXXFLAGS = -save-temps -Xassembler -aln=$@.lst $(CFLAGS) $(DEFINES) 42 | LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map 43 | 44 | #--------------------------------------------------------------------------------- 45 | # any extra libraries we wish to link with the project 46 | #--------------------------------------------------------------------------------- 47 | LIBS := -lSDL_image -ljpeg -lpngu -lpng12 -lmetaphrasis -lz -lSDL_mixer -lmad -lvorbisfile -lvorbis \ 48 | -logg -lsmpeg -lSDL -lSDL_ttf -lfreetype -lasnd -lfat -logc -lwiiuse -lbte -lbz2 -lmxml -lwiihid 49 | #--------------------------------------------------------------------------------- 50 | # list of directories containing libraries, this must be the top level containing 51 | # include and lib 52 | #--------------------------------------------------------------------------------- 53 | LIBDIRS := $(CURDIR) 54 | 55 | #--------------------------------------------------------------------------------- 56 | # no real need to edit anything past this point unless you need to add additional 57 | # rules for different file extensions 58 | #--------------------------------------------------------------------------------- 59 | ifneq ($(BUILD),$(notdir $(CURDIR))) 60 | #--------------------------------------------------------------------------------- 61 | 62 | export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET) 63 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) 64 | export DEPSDIR := $(CURDIR)/$(BUILD) 65 | 66 | #--------------------------------------------------------------------------------- 67 | # automatically build a list of object files for our project 68 | #--------------------------------------------------------------------------------- 69 | CFILES := $(foreach dir,$(SOURCES),$(filter-out $(EXCLUDES),$(notdir $(wildcard $(dir)/*.c)))) 70 | CPPFILES := $(foreach dir,$(SOURCES),$(filter-out $(EXCLUDES),$(notdir $(wildcard $(dir)/*.cpp)))) 71 | sFILES := $(foreach dir,$(SOURCES),$(filter-out $(EXCLUDES),$(notdir $(wildcard $(dir)/*.s)))) 72 | SFILES := $(foreach dir,$(SOURCES),$(filter-out $(EXCLUDES),$(notdir $(wildcard $(dir)/*.S)))) 73 | TTFFILES := $(foreach dir,$(SOURCES),$(filter-out $(EXCLUDES),$(notdir $(wildcard $(dir)/*.ttf)))) 74 | PNGFILES := $(foreach dir,$(SOURCES),$(filter-out $(EXCLUDES),$(notdir $(wildcard $(dir)/*.png)))) 75 | OGGFILES := $(foreach dir,$(SOURCES),$(filter-out $(EXCLUDES),$(notdir $(wildcard $(dir)/*.ogg)))) 76 | PCMFILES := $(foreach dir,$(SOURCES),$(filter-out $(EXCLUDES),$(notdir $(wildcard $(dir)/*.pcm)))) 77 | 78 | #--------------------------------------------------------------------------------- 79 | # use CXX for linking C++ projects, CC for standard C 80 | #--------------------------------------------------------------------------------- 81 | ifeq ($(strip $(CPPFILES)),) 82 | export LD := $(CC) 83 | else 84 | export LD := $(CXX) 85 | endif 86 | 87 | export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 88 | $(sFILES:.s=.o) $(SFILES:.S=.o) \ 89 | $(TTFFILES:.ttf=.ttf.o) $(PNGFILES:.png=.png.o) \ 90 | $(OGGFILES:.ogg=.ogg.o) $(PCMFILES:.pcm=.pcm.o) 91 | 92 | #--------------------------------------------------------------------------------- 93 | # build a list of include paths 94 | #--------------------------------------------------------------------------------- 95 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 96 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 97 | -I$(CURDIR)/$(BUILD) \ 98 | -I$(DEVKITPRO)/3rd/wii/include \ 99 | -I${DEVKITPRO}/3rd/wii/include/smpeg \ 100 | -I${DEVKITPRO}/3rd/wii/include/freetype \ 101 | -I${DEVKITPRO}/3rd/wii/include/SDL \ 102 | -I$(LIBOGC_INC)/mad \ 103 | -I$(LIBOGC_INC) 104 | 105 | #--------------------------------------------------------------------------------- 106 | # build a list of library paths 107 | #--------------------------------------------------------------------------------- 108 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 109 | -L$(DEVKITPRO)/3rd/wii/lib \ 110 | -L$(LIBOGC_LIB) 111 | 112 | export OUTPUT := $(CURDIR)/$(TARGET) 113 | .PHONY: $(BUILD) clean 114 | 115 | #--------------------------------------------------------------------------------- 116 | $(BUILD): 117 | @[ -d $@ ] || mkdir -p $@ 118 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.wii 119 | 120 | #--------------------------------------------------------------------------------- 121 | clean: 122 | @echo clean ... 123 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol 124 | @rm -fr apps onscripter-wii.tar.bz2 125 | 126 | #--------------------------------------------------------------------------------- 127 | run: 128 | wiiload $(OUTPUT).dol 129 | 130 | #--------------------------------------------------------------------------------- 131 | reload: 132 | wiiload -r $(OUTPUT).dol 133 | 134 | #--------------------------------------------------------------------------------- 135 | channel: $(OUTPUT).dol 136 | mkdir -p apps/onscripter/games/test 137 | cp onscripter.dol apps/onscripter/boot.dol 138 | cp README apps/onscripter 139 | cp -a test/* apps/onscripter/games/test 140 | cp wii/icon.png apps/onscripter 141 | echo "\n\n\t"$(NAME)"\n\t"$(AUTHOR)"\n\t"$(VERSION)"\n\t"$(DATE)"\n\t"$(SDESC)"\n\t\n"$(LDESC)"\n\t\n" > apps/onscripter/meta.xml; 142 | 143 | #--------------------------------------------------------------------------------- 144 | dist: channel 145 | tar -jcvf onscripter-wii.tar.bz2 apps 146 | 147 | #--------------------------------------------------------------------------------- 148 | else 149 | 150 | DEPENDS := $(OFILES:.o=.d) 151 | 152 | #--------------------------------------------------------------------------------- 153 | # main targets 154 | #--------------------------------------------------------------------------------- 155 | $(OUTPUT).dol: $(OUTPUT).elf 156 | $(OUTPUT).elf: $(OFILES) 157 | 158 | #--------------------------------------------------------------------------------- 159 | # This rule links in binary data with .ttf, .png, and .mp3 extensions 160 | #--------------------------------------------------------------------------------- 161 | %.ttf.o : %.ttf 162 | @echo $(notdir $<) 163 | $(bin2o) 164 | 165 | %.png.o : %.png 166 | @echo $(notdir $<) 167 | $(bin2o) 168 | 169 | %.ogg.o : %.ogg 170 | @echo $(notdir $<) 171 | $(bin2o) 172 | 173 | %.pcm.o : %.pcm 174 | @echo $(notdir $<) 175 | $(bin2o) 176 | 177 | -include $(DEPENDS) 178 | 179 | #--------------------------------------------------------------------------------- 180 | endif 181 | #--------------------------------------------------------------------------------- 182 | -------------------------------------------------------------------------------- /NsaReader.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * NsaReader.cpp - Reader from a NSA archive 4 | * 5 | * Copyright (c) 2001-2008 Ogapee. All rights reserved. 6 | * 7 | * ogapee@aqua.dti2.ne.jp 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "NsaReader.h" 25 | #include 26 | #include 27 | #define NSA_ARCHIVE_NAME "arc" 28 | #define NSA_ARCHIVE_NAME2 "arc%d" 29 | 30 | NsaReader::NsaReader( DirPaths *path, const unsigned char *key_table ) 31 | :SarReader( path, key_table ) 32 | { 33 | sar_flag = true; 34 | num_of_nsa_archives = 0; 35 | 36 | if (key_table) 37 | nsa_archive_ext = "___"; 38 | else 39 | nsa_archive_ext = "nsa"; 40 | } 41 | 42 | NsaReader::~NsaReader() 43 | { 44 | } 45 | 46 | int NsaReader::open( const char *nsa_path, int archive_type ) 47 | { 48 | int i,j,n; 49 | FILE *fp; 50 | char archive_name[256], archive_name2[256]; 51 | 52 | if ( !SarReader::open( "arc.sar" ) ) { 53 | sar_flag = true; 54 | } 55 | else { 56 | sar_flag = false; 57 | } 58 | 59 | if ( !nsa_path ) nsa_path = ""; 60 | 61 | 62 | i = j = -1; 63 | n = 0; 64 | while ((iget_num_paths())) { 65 | if (j < 0) { 66 | sprintf( archive_name, "%s%s.%s", nsa_path, NSA_ARCHIVE_NAME, nsa_archive_ext ); 67 | sprintf(archive_name2, "%s%s", archive_path->get_path(n), archive_name); 68 | } else { 69 | sprintf( archive_name2, NSA_ARCHIVE_NAME2, j+1 ); 70 | sprintf( archive_name, "%s%s.%s", nsa_path, archive_name2, nsa_archive_ext ); 71 | sprintf(archive_name2, "%s%s", archive_path->get_path(n), archive_name); 72 | } 73 | fp = std::fopen(archive_name2, "rb"); 74 | if (fp != NULL) { 75 | if (i < 0) { 76 | archive_info_nsa.file_handle = fp; 77 | archive_info_nsa.file_name = new char[strlen(archive_name2)+1]; 78 | strcpy(archive_info_nsa.file_name, archive_name2); 79 | readArchive( &archive_info_nsa, archive_type ); 80 | } else { 81 | archive_info2[i].file_handle = fp; 82 | archive_info2[i].file_name = new char[strlen(archive_name2)+1]; 83 | strcpy(archive_info2[i].file_name, archive_name2); 84 | readArchive( &archive_info2[i], archive_type ); 85 | } 86 | i++; 87 | j++; 88 | } else { 89 | j = -1; 90 | n++; 91 | } 92 | } 93 | 94 | if (i < 0) { 95 | // didn't find any (main) archive files 96 | fprintf( stderr, "can't open archive file %s\n", archive_name ); 97 | return -1; 98 | } else { 99 | num_of_nsa_archives = i+1; 100 | return 0; 101 | } 102 | } 103 | 104 | int NsaReader::openForConvert( const char *nsa_name, int archive_type ) 105 | { 106 | sar_flag = false; 107 | if ( ( archive_info_nsa.file_handle = ::fopen( nsa_name, "rb" ) ) == NULL ){ 108 | fprintf( stderr, "can't open file %s\n", nsa_name ); 109 | return -1; 110 | } 111 | 112 | readArchive( &archive_info_nsa, archive_type ); 113 | 114 | return 0; 115 | } 116 | 117 | int NsaReader::writeHeader( FILE *fp, int archive_type ) 118 | { 119 | ArchiveInfo *ai = &archive_info; 120 | return writeHeaderSub( ai, fp, archive_type ); 121 | } 122 | 123 | size_t NsaReader::putFile( FILE *fp, int no, size_t offset, size_t length, size_t original_length, int compression_type, bool modified_flag, unsigned char *buffer ) 124 | { 125 | ArchiveInfo *ai = &archive_info; 126 | return putFileSub( ai, fp, no, offset, length, original_length , compression_type, modified_flag, buffer ); 127 | } 128 | 129 | const char *NsaReader::getArchiveName() const 130 | { 131 | return "nsa"; 132 | } 133 | 134 | int NsaReader::getNumFiles(){ 135 | int i; 136 | int total = archive_info.num_of_files; // start with sar files, if any 137 | 138 | total += archive_info_nsa.num_of_files; // add in the arc.nsa files 139 | 140 | for ( i=0 ; inum_of_files ) return 0; 150 | 151 | if ( ai->fi_list[i].compression_type == NO_COMPRESSION ){ 152 | int type = getRegisteredCompressionType( file_name ); 153 | if ( type == NBZ_COMPRESSION || type == SPB_COMPRESSION ) 154 | return getDecompressedFileLength( type, ai->file_handle, ai->fi_list[i].offset ); 155 | } 156 | 157 | return ai->fi_list[i].original_length; 158 | } 159 | 160 | size_t NsaReader::getFileLength( const char *file_name ) 161 | { 162 | size_t ret; 163 | int i; 164 | 165 | // direct read 166 | if ( ( ret = DirectReader::getFileLength( file_name ) ) ) return ret; 167 | 168 | // nsa read 169 | if ( ( ret = getFileLengthSub( &archive_info_nsa, file_name )) ) return ret; 170 | 171 | // nsa? read 172 | for ( i=0 ; i) and to create a 75 | shell script in an appropriate place (e.g. /usr/local/bin/) 76 | that launches the onscripter executable with a suitable argument to 77 | -r. Since there is no convenient way to distribute binaries that will 78 | work even on multiple Linux distributions, let alone other Unix 79 | platforms, it is recommended that packages instead depend on the user 80 | supplying a separate ONScripter-En binary, either built from source or 81 | from an OS/distro-specific package. 82 | 83 | MacOS X is an exception to all this, as it's only Unix from the waist 84 | down. OS X applications are typically distributed as bundles, and 85 | ONScripter-En includes special code to make this possible for 86 | NScripter games. Simply place the files that would normally go in the 87 | game directory (script, data archives, default.ttf, etc) in 88 | $GAME.app/Contents/Resources, and everything should Just Work; you'll 89 | have a native-looking OS X game that can be drag-installed and deleted 90 | to uninstall. (Well, you'll have to fiddle with plists and add an 91 | icon and so on, but that's all standard OS X development stuff.) 92 | 93 | 94 | BUILD REQUIREMENTS 95 | 96 | ONScripter is based on SDL, and should run on any platform for which 97 | SDL is available. The original version has been successfully compiled 98 | on platforms as diverse as the Dreamcast, the PSP, and the iPod. 99 | 100 | ONScripter-En has slightly more strict requirements, however. Since 101 | ONScripter's original build system is extremely difficult to use 102 | (requiring the creation of a custom makefile for every minor platform 103 | variation), it has been replaced in this branch with a more 104 | conventional configure-build system; this depends on a POSIX-like 105 | environment with GNU make. The code has been tested primarily with 106 | the GNU C++ compiler; Intel C++ 10 has also been tried successfully. 107 | 108 | The primary test environment is GNU/Linux (x86_64), and the secondary 109 | test environment is MacOS X (i386). Assuming standard build tools are 110 | installed, the full-source distribution is likely to compile 111 | out-of-the-box or with only minimal changes on these and any other 112 | POSIX-conformant platform. You may need to tweak the final link line 113 | if using static libraries -- see the configure script for examples of 114 | incantations that work on FreeBSD, NetBSD, and Solaris. 115 | 116 | This distribution is also supported on Windows (primarily 32-bit 117 | versions). Building on Windows requires the MinGW distribution of 118 | g++, and the MSYS environment. Windows users unfamiliar with the GNU 119 | build environment might prefer to stick with the binary distribution, 120 | which should work everywhere (this is one thing Microsoft has got 121 | right!) 122 | 123 | Please see INSTALL in the source distribution for specific build 124 | instructions. 125 | 126 | 127 | LOCALISATION 128 | 129 | While ONScripter proper, and previous versions of ONScripter-En, 130 | require English or Japanese settings to be selected at compile-time, 131 | this version can be run in both English and Japanese modes. 132 | 133 | In Japanese mode, the built-in menus are in Japanese, numbers are 134 | printed using full-width characters, and line-breaking decisions are 135 | based on Japanese rules (breaks are allowed in the middle of words, 136 | but not before or after certain special characters). 137 | 138 | In English mode, the built-in menus are in English, numbers are 139 | printed using half-width characters, and line-breaking decisions are 140 | based on English rules (breaks are only allowed between words). 141 | 142 | You can select a mode within a script by using the commands 143 | language english 144 | and 145 | language japanese 146 | It is recommended that you just set the language once at startup, but 147 | you can switch between them during the game if you need to. (If you 148 | do, and your game uses the built-in menus, be sure to switch back to 149 | your primary language before any point at which the player can bring 150 | up a menu, or they will probably be very confused!) 151 | 152 | The default mode is determined by the name of the ONScripter binary 153 | (or bundle, on OS X). If it is something like "onscripter-en" or 154 | "ONScripter-En.exe", the default mode will be English; otherwise it 155 | will be Japanese. (This is intended to allow users to play existing 156 | games in an appropriate mode -- if releasing a game yourself, you 157 | should use an explicit language command instead of relying on this.) 158 | 159 | 160 | CONTACT INFORMATION 161 | 162 | The author of ONScripter itself is Ogapee, who can be reached by email 163 | at the address 164 | 165 | ogapee@aqua.dti2.ne.jp 166 | 167 | The maintainer of this branch (as of February 2008) is Haeleth, who 168 | can be reached by email at the address 169 | 170 | haeleth@haeleth.net 171 | 172 | Correspondence in English, or regarding issues related to this branch 173 | in particular, should be directed to this latter address in the first 174 | instance: it contains a large number of customisations that are 175 | nothing to do with Ogapee. 176 | 177 | 178 | LICENSE 179 | 180 | ONScripter and ONScripter-En are distributed under the terms of the 181 | GNU General Public License. See COPYING for details. 182 | -------------------------------------------------------------------------------- /SarReader.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * SarReader.cpp - Reader from a SAR archive 4 | * 5 | * Copyright (c) 2001-2008 Ogapee. All rights reserved. 6 | * 7 | * ogapee@aqua.dti2.ne.jp 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef __SAR_READER_H__ 25 | #define __SAR_READER_H__ 26 | 27 | #include "DirectReader.h" 28 | 29 | class SarReader : public DirectReader 30 | { 31 | public: 32 | SarReader( DirPaths *path=NULL, const unsigned char *key_table=NULL ); 33 | ~SarReader(); 34 | 35 | int open( const char *name=NULL, int archive_type = ARCHIVE_TYPE_SAR ); 36 | int close(); 37 | const char *getArchiveName() const; 38 | int getNumFiles(); 39 | 40 | size_t getFileLength( const char *file_name ); 41 | size_t getFile( const char *file_name, unsigned char *buf, int *location=NULL ); 42 | struct FileInfo getFileByIndex( unsigned int index ); 43 | 44 | int writeHeader( FILE *fp ); 45 | size_t putFile( FILE *fp, int no, size_t offset, size_t length, size_t original_length, bool modified_flag, unsigned char *buffer ); 46 | 47 | protected: 48 | struct ArchiveInfo archive_info; 49 | struct ArchiveInfo *root_archive_info, *last_archive_info; 50 | int num_of_sar_archives; 51 | 52 | int readArchive( ArchiveInfo *ai, int archive_type = ARCHIVE_TYPE_SAR ); 53 | int getIndexFromFile( ArchiveInfo *ai, const char *file_name ); 54 | size_t getFileSub( ArchiveInfo *ai, const char *file_name, unsigned char *buf ); 55 | 56 | int writeHeaderSub( ArchiveInfo *ai, FILE *fp, int archive_type = ARCHIVE_TYPE_SAR ); 57 | size_t putFileSub( ArchiveInfo *ai, FILE *fp, int no, size_t offset, size_t length, size_t original_length, int compression_type, bool modified_flag, unsigned char *buffer ); 58 | }; 59 | 60 | #endif // __SAR_READER_H__ 61 | -------------------------------------------------------------------------------- /ScriptHandler.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/ScriptHandler.cpp -------------------------------------------------------------------------------- /ScriptParser.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/ScriptParser.cpp -------------------------------------------------------------------------------- /ScriptParser.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/ScriptParser.h -------------------------------------------------------------------------------- /graphics_altivec.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * graphics_altivec.cpp - graphics routines using PPC Altivec cpu functionality 4 | * 5 | * Copyright (c) 2009 Mion. All rights reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | // Based upon routines provided by Roto 23 | 24 | #ifdef USE_PPC_GFX 25 | 26 | #include <altivec.h> 27 | #include <math.h> 28 | #ifndef M_PI 29 | #define M_PI 3.14159265358979323846 30 | #endif 31 | 32 | #include "graphics_common.h" 33 | 34 | 35 | void imageFilterMean_Altivec(unsigned char *src1, unsigned char *src2, unsigned char *dst, int length) 36 | { 37 | int n = length; 38 | 39 | // Compute first few values so we're on a 16-byte boundary in dst 40 | while( (((long)dst & 0xF) > 0) && (n > 0) ) { 41 | MEAN_PIXEL(); 42 | --n; ++dst; ++src1; ++src2; 43 | } 44 | 45 | // Do bulk of processing using Altivec (find the mean of 16 8-bit unsigned integers, with saturation) 46 | vector unsigned char rshft = vec_splat_u8(0x1); 47 | while(n >= 16) { 48 | vector unsigned char s1 = vec_ld(0,src1); 49 | s1 = vec_sr(s1, rshft); // shift right 1 50 | vector unsigned char s2 = vec_ld(0,src2); 51 | s2 = vec_sr(s2, rshft); // shift right 1 52 | vector unsigned char r = vec_adds(s1, s2); 53 | vec_st(r,0,dst); 54 | 55 | n -= 16; src1 += 16; src2 += 16; dst += 16; 56 | } 57 | 58 | // If any bytes are left over, deal with them individually 59 | ++n; 60 | BASIC_MEAN(); 61 | } 62 | 63 | 64 | void imageFilterAddTo_Altivec(unsigned char *dst, unsigned char *src, int length) 65 | { 66 | int n = length; 67 | 68 | // Compute first few values so we're on a 16-byte boundary in dst 69 | while( (((long)dst & 0xF) > 0) && (n > 0) ) { 70 | ADDTO_PIXEL(); 71 | --n; ++dst; ++src; 72 | } 73 | 74 | // Do bulk of processing using Altivec (add 16 8-bit unsigned integers, with saturation) 75 | while(n >= 16) { 76 | vector unsigned char s = vec_ld(0,src); 77 | vector unsigned char d = vec_ld(0,dst); 78 | vector unsigned char r = vec_adds(d, s); 79 | vec_st(r,0,dst); 80 | 81 | n -= 16; src += 16; dst += 16; 82 | } 83 | 84 | // If any bytes are left over, deal with them individually 85 | ++n; 86 | BASIC_ADDTO(); 87 | } 88 | 89 | 90 | void imageFilterSubFrom_Altivec(unsigned char *dst, unsigned char *src, int length) 91 | { 92 | int n = length; 93 | 94 | // Compute first few values so we're on a 16-byte boundary in dst 95 | while( (((long)dst & 0xF) > 0) && (n > 0) ) { 96 | SUBFROM_PIXEL(); 97 | --n; ++dst; ++src; 98 | } 99 | 100 | // Do bulk of processing using Altivec (sub 16 8-bit unsigned integers, with saturation) 101 | while(n >= 16) { 102 | vector unsigned char s = vec_ld(0,src); 103 | vector unsigned char d = vec_ld(0,dst); 104 | vector unsigned char r = vec_subs(d, s); 105 | vec_st(r,0,dst); 106 | 107 | n -= 16; src += 16; dst += 16; 108 | } 109 | 110 | // If any bytes are left over, deal with them individually 111 | ++n; 112 | BASIC_SUBFROM(); 113 | } 114 | 115 | #endif 116 | 117 | 118 | -------------------------------------------------------------------------------- /graphics_altivec.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * graphics_altivec.h - graphics routines using PPC Altivec cpu functionality 4 | * 5 | * Copyright (c) 2009 Mion. All rights reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifdef USE_PPC_GFX 23 | 24 | void imageFilterMean_Altivec(unsigned char *src1, unsigned char *src2, unsigned char *dst, int length); 25 | void imageFilterAddTo_Altivec(unsigned char *dst, unsigned char *src, int length); 26 | void imageFilterSubFrom_Altivec(unsigned char *dst, unsigned char *src, int length); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /graphics_common.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * graphics_mmx.h - graphics macros common to graphics_* & AnimationInfo 4 | * 5 | * Copyright (c) 2009 Mion. All rights reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | 23 | #ifdef BPP16 24 | #define BPP 16 25 | #define RMASK 0xf800 26 | #define GMASK 0x07e0 27 | #define BMASK 0x001f 28 | #define AMASK 0 29 | #else 30 | #define BPP 32 31 | // the mask is the same as the one used in TTF_RenderGlyph_Blended 32 | #define RMASK 0x00ff0000 33 | #define GMASK 0x0000ff00 34 | #define BMASK 0x000000ff 35 | #define AMASK 0xff000000 36 | #endif 37 | #define RGBMASK 0x00ffffff 38 | 39 | #ifdef BPP16 40 | #define SET_PIXEL(rgb, alpha) {\ 41 | *dst_buffer = (((rgb)&0xf80000) >> 8) | (((rgb)&0xfc00) >> 5) | (((rgb)&0xf8) >> 3);\ 42 | *alphap++ = (alpha);\ 43 | } 44 | 45 | #define BLEND_PIXEL(){\ 46 | Uint32 mask2 = (*alphap++ * alpha) >> 11;\ 47 | Uint32 s1 = (*src_buffer | *src_buffer << 16) & 0x07e0f81f;\ 48 | Uint32 d1 = (*dst_buffer | *dst_buffer << 16) & 0x07e0f81f;\ 49 | Uint32 mask1 = (d1 + ((s1-d1) * mask2 >> 5)) & 0x07e0f81f;\ 50 | *dst_buffer = mask1 | mask1 >> 16;\ 51 | } 52 | 53 | #else 54 | #define SET_PIXEL(rgb, alpha) {\ 55 | *dst_buffer = (rgb);\ 56 | *alphap = (alpha);\ 57 | alphap += 4;\ 58 | } 59 | 60 | #define BLEND_PIXEL(){\ 61 | Uint32 mask2 = (*alphap * alpha) >> 8;\ 62 | Uint32 mask1 = mask2 ^ 0xff;\ 63 | Uint32 mask_rb = (((*dst_buffer & 0xff00ff) * mask1 +\ 64 | (*src_buffer & 0xff00ff) * mask2) >> 8) & 0xff00ff;\ 65 | Uint32 mask_g = (((*dst_buffer & 0x00ff00) * mask1 +\ 66 | (*src_buffer & 0x00ff00) * mask2) >> 8) & 0x00ff00;\ 67 | *dst_buffer = mask_rb | mask_g;\ 68 | alphap += 4;\ 69 | } 70 | 71 | #define ADDBLEND_PIXEL(){\ 72 | Uint32 mask2 = (*alphap * alpha) >> 8;\ 73 | Uint32 mask_rb = (*dst_buffer & 0xff00ff) +\ 74 | ((((*src_buffer & 0xff00ff) * mask2) >> 8) & 0xff00ff);\ 75 | mask_rb |= ((mask_rb & 0xff000000) ? 0xff0000 : 0) |\ 76 | ((mask_rb & 0x0000ff00) ? 0x0000ff : 0);\ 77 | Uint32 mask_g = (*dst_buffer & 0x00ff00) +\ 78 | ((((*src_buffer & 0x00ff00) * mask2) >> 8) & 0x00ff00);\ 79 | mask_g |= ((mask_g & 0xff0000) ? 0xff00 : 0);\ 80 | *dst_buffer = (mask_rb & 0xff00ff) | (mask_g & 0x00ff00);\ 81 | alphap += 4;\ 82 | } 83 | 84 | #define SUBBLEND_PIXEL(){\ 85 | Uint32 mask2 = (*alphap * alpha) >> 8;\ 86 | Uint32 mask_r = (*dst_buffer & 0xff0000) -\ 87 | ((((*src_buffer & 0xff0000) * mask2) >> 8) & 0xff0000);\ 88 | mask_r &= ((mask_r & 0xff000000) ? 0 : 0xff0000);\ 89 | Uint32 mask_g = (*dst_buffer & 0x00ff00) -\ 90 | ((((*src_buffer & 0x00ff00) * mask2) >> 8) & 0x00ff00);\ 91 | mask_g &= ((mask_g & 0xffff0000) ? 0 : 0x00ff00);\ 92 | Uint32 mask_b = (*dst_buffer & 0x0000ff) -\ 93 | ((((*src_buffer & 0x0000ff) * mask2) >> 8) & 0x0000ff);\ 94 | mask_b &= ((mask_b & 0xffffff00) ? 0 : 0x0000ff);\ 95 | *dst_buffer = (mask_r & 0xff0000) | (mask_g & 0x00ff00) | (mask_b & 0x0000ff);\ 96 | alphap += 4;\ 97 | } 98 | 99 | #endif 100 | 101 | 102 | #define BASIC_BLEND(){\ 103 | while(--n > 0) { \ 104 | BLEND_PIXEL(); \ 105 | ++dst_buffer, ++src_buffer; \ 106 | } \ 107 | } 108 | 109 | #define BASIC_ADDBLEND(){\ 110 | while(--n > 0) { \ 111 | ADDBLEND_PIXEL(); \ 112 | ++dst_buffer, ++src_buffer; \ 113 | } \ 114 | } 115 | 116 | #define BASIC_SUBBLEND(){\ 117 | while(--n > 0) { \ 118 | SUBBLEND_PIXEL(); \ 119 | ++dst_buffer, ++src_buffer; \ 120 | } \ 121 | } 122 | 123 | 124 | #define MEAN_PIXEL(){\ 125 | int result = ((int)(*src1) + (int)(*src2)) / 2; \ 126 | (*dst) = result; \ 127 | } 128 | 129 | #define BASIC_MEAN(){\ 130 | while (--n > 0) { \ 131 | MEAN_PIXEL(); \ 132 | ++dst; ++src1; ++src2; \ 133 | } \ 134 | } 135 | 136 | #define ADDTO_PIXEL(){\ 137 | int result = (*dst) + (*src); \ 138 | (*dst) = (result < 255) ? result : 255; \ 139 | } 140 | 141 | #define BASIC_ADDTO(){\ 142 | while (--n > 0) { \ 143 | ADDTO_PIXEL(); \ 144 | ++dst, ++src; \ 145 | } \ 146 | } 147 | 148 | #define SUBFROM_PIXEL(){\ 149 | int result = (*dst) - (*src); \ 150 | (*dst) = (result > 0) ? result : 0; \ 151 | } 152 | 153 | #define BASIC_SUBFROM(){\ 154 | while(--n > 0) { \ 155 | SUBFROM_PIXEL(); \ 156 | ++dst, ++src; \ 157 | } \ 158 | } 159 | 160 | -------------------------------------------------------------------------------- /graphics_mmx.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * graphics_mmx.cpp - graphics routines using X86 MMX cpu functionality 4 | * 5 | * Copyright (c) 2009 Mion. All rights reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | // Based upon routines provided by Roto 23 | 24 | #ifdef USE_X86_GFX 25 | 26 | #include <mmintrin.h> 27 | #include <math.h> 28 | #ifndef M_PI 29 | #define M_PI 3.14159265358979323846 30 | #endif 31 | 32 | #include "graphics_common.h" 33 | 34 | 35 | void imageFilterMean_MMX(unsigned char *src1, unsigned char *src2, unsigned char *dst, int length) 36 | { 37 | int n = length; 38 | 39 | // Compute first few values so we're on a 8-byte boundary in dst 40 | while( (((long)dst & 0x7) > 0) && (n > 0) ) { 41 | MEAN_PIXEL(); 42 | --n; ++dst; ++src1; ++src2; 43 | } 44 | 45 | // Do bulk of processing using MMX (find the mean of 8 8-bit unsigned integers, with saturation) 46 | __m64 mask = _mm_set1_pi8(0x7F); 47 | while(n >= 8) { 48 | __m64 s1 = *((__m64*)src1); 49 | s1 = _mm_srli_pi16(s1, 1); 50 | s1 = _mm_and_si64(s1, mask); 51 | __m64 s2 = *((__m64*)src2); 52 | s2 = _mm_srli_pi16(s2, 1); 53 | s2 = _mm_and_si64(s2, mask); 54 | __m64* d = (__m64*)dst; 55 | *d = _mm_adds_pu8(s1, s2); 56 | 57 | n -= 8; src1 += 8; src2 += 8; dst += 8; 58 | } 59 | _mm_empty(); 60 | 61 | // If any bytes are left over, deal with them individually 62 | ++n; 63 | BASIC_MEAN(); 64 | } 65 | 66 | 67 | void imageFilterAddTo_MMX(unsigned char *dst, unsigned char *src, int length) 68 | { 69 | int n = length; 70 | 71 | // Compute first few values so we're on a 8-byte boundary in dst 72 | while( (((long)dst & 0x7) > 0) && (n > 0) ) { 73 | ADDTO_PIXEL(); 74 | --n; ++dst; ++src; 75 | } 76 | 77 | // Do bulk of processing using MMX (add 8 8-bit unsigned integers, with saturation) 78 | while(n >= 8) { 79 | __m64* s = (__m64*)src; 80 | __m64* d = (__m64*)dst; 81 | *d = _mm_adds_pu8(*d, *s); 82 | 83 | n -= 8; src += 8; dst += 8; 84 | } 85 | _mm_empty(); 86 | 87 | // If any bytes are left over, deal with them individually 88 | ++n; 89 | BASIC_ADDTO(); 90 | } 91 | 92 | 93 | void imageFilterSubFrom_MMX(unsigned char *dst, unsigned char *src, int length) 94 | { 95 | int n = length; 96 | 97 | // Compute first few values so we're on a 8-byte boundary in dst 98 | while( (((long)dst & 0x7) > 0) && (n > 0) ) { 99 | SUBFROM_PIXEL(); 100 | --n; ++dst; ++src; 101 | } 102 | 103 | // Do bulk of processing using MMX (sub 8 8-bit unsigned integers, with saturation) 104 | while(n >= 8) { 105 | __m64* s = (__m64*)src; 106 | __m64* d = (__m64*)dst; 107 | *d = _mm_subs_pu8(*d, *s); 108 | 109 | n -= 8; src += 8; dst += 8; 110 | } 111 | _mm_empty(); 112 | 113 | // If any bytes are left over, deal with them individually 114 | ++n; 115 | BASIC_SUBFROM(); 116 | } 117 | 118 | #endif 119 | 120 | 121 | -------------------------------------------------------------------------------- /graphics_mmx.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * graphics_mmx.h - graphics routines using MMX cpu functionality 4 | * 5 | * Copyright (c) 2009 Mion. All rights reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifdef USE_X86_GFX 23 | 24 | void imageFilterMean_MMX(unsigned char *src1, unsigned char *src2, unsigned char *dst, int length); 25 | void imageFilterAddTo_MMX(unsigned char *dst, unsigned char *src, int length); 26 | void imageFilterSubFrom_MMX(unsigned char *dst, unsigned char *src, int length); 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /graphics_sse2.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * graphics_sse2.cpp - graphics routines using X86 SSE2 cpu functionality 4 | * 5 | * Copyright (c) 2009 Mion. All rights reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | // Based upon routines provided by Roto 23 | 24 | #ifdef USE_X86_GFX 25 | 26 | #include <SDL.h> 27 | #include <emmintrin.h> 28 | #include <math.h> 29 | #ifndef M_PI 30 | #define M_PI 3.14159265358979323846 31 | #endif 32 | 33 | #include "graphics_common.h" 34 | 35 | 36 | void imageFilterMean_SSE2(unsigned char *src1, unsigned char *src2, unsigned char *dst, int length) 37 | { 38 | int n = length; 39 | 40 | // Compute first few values so we're on a 16-byte boundary in dst 41 | while( (((long)dst & 0xF) > 0) && (n > 0) ) { 42 | MEAN_PIXEL(); 43 | --n; ++dst; ++src1; ++src2; 44 | } 45 | 46 | // Do bulk of processing using SSE2 (find the mean of 16 8-bit unsigned integers, with saturation) 47 | __m128i mask = _mm_set1_epi8(0x7F); 48 | while(n >= 16) { 49 | __m128i s1 = _mm_loadu_si128((__m128i*)src1); 50 | s1 = _mm_srli_epi16(s1, 1); // shift right 1 51 | s1 = _mm_and_si128(s1, mask); // apply byte-mask 52 | __m128i s2 = _mm_loadu_si128((__m128i*)src2); 53 | s2 = _mm_srli_epi16(s2, 1); // shift right 1 54 | s2 = _mm_and_si128(s2, mask); // apply byte-mask 55 | __m128i r = _mm_adds_epu8(s1, s2); 56 | _mm_store_si128((__m128i*)dst, r); 57 | 58 | n -= 16; src1 += 16; src2 += 16; dst += 16; 59 | } 60 | 61 | // If any bytes are left over, deal with them individually 62 | ++n; 63 | BASIC_MEAN(); 64 | } 65 | 66 | 67 | void imageFilterAddTo_SSE2(unsigned char *dst, unsigned char *src, int length) 68 | { 69 | int n = length; 70 | 71 | // Compute first few values so we're on a 16-byte boundary in dst 72 | while( (((long)dst & 0xF) > 0) && (n > 0) ) { 73 | ADDTO_PIXEL(); 74 | --n; ++dst; ++src; 75 | } 76 | 77 | // Do bulk of processing using SSE2 (add 16 8-bit unsigned integers, with saturation) 78 | while(n >= 16) { 79 | __m128i s = _mm_loadu_si128((__m128i*)src); 80 | __m128i d = _mm_load_si128((__m128i*)dst); 81 | __m128i r = _mm_adds_epu8(s, d); 82 | _mm_store_si128((__m128i*)dst, r); 83 | 84 | n -= 16; src += 16; dst += 16; 85 | } 86 | 87 | // If any bytes are left over, deal with them individually 88 | ++n; 89 | BASIC_ADDTO(); 90 | } 91 | 92 | 93 | void imageFilterSubFrom_SSE2(unsigned char *dst, unsigned char *src, int length) 94 | { 95 | int n = length; 96 | 97 | // Compute first few values so we're on a 16-byte boundary in dst 98 | while( (((long)dst & 0xF) > 0) && (n > 0) ) { 99 | SUBFROM_PIXEL(); 100 | --n; ++dst; ++src; 101 | } 102 | 103 | // Do bulk of processing using SSE2 (sub 16 8-bit unsigned integers, with saturation) 104 | while(n >= 16) { 105 | __m128i s = _mm_loadu_si128((__m128i*)src); 106 | __m128i d = _mm_load_si128((__m128i*)dst); 107 | __m128i r = _mm_subs_epu8(d, s); 108 | _mm_store_si128((__m128i*)dst, r); 109 | 110 | n -= 16; src += 16; dst += 16; 111 | } 112 | 113 | // If any bytes are left over, deal with them individually 114 | ++n; 115 | BASIC_SUBFROM(); 116 | } 117 | 118 | void imageFilterBlend_SSE2(Uint32 *dst_buffer, Uint32 *src_buffer, Uint8 *alphap, int alpha, int length) 119 | { 120 | int n = length; 121 | 122 | // Compute first few values so we're on a 16-byte boundary in dst_buffer 123 | while( (((long)dst_buffer & 0xF) > 0) && (n > 0) ) { 124 | BLEND_PIXEL(); 125 | --n; ++dst_buffer; ++src_buffer; 126 | } 127 | 128 | // Do bulk of processing using SSE2 (process 4 32bit (BGRA) pixels) 129 | // create basic bitmasks 0x00FF00FF, 0x000000FF 130 | __m128i bmask2 = _mm_set1_epi32(0x00FF00FF); 131 | __m128i bmask = _mm_srli_epi32(bmask2, 16); 132 | while(n >= 4) { 133 | // alpha1 = ((src_argb >> 24) * alpha) >> 8 134 | __m128i a = _mm_set1_epi32(alpha); 135 | __m128i buf = _mm_loadu_si128((__m128i*)src_buffer); 136 | __m128i tmp = _mm_srli_epi32(buf, 24); 137 | a = _mm_mullo_epi16(a, tmp); 138 | a = _mm_srli_epi32(a, 8); 139 | // double-up alpha1 (0x000000vv -> 0x00vv00vv) 140 | tmp = _mm_slli_epi32(a, 16); 141 | a = _mm_or_si128(a, tmp); 142 | // rb = (src_argb & bmask2) * alpha1 143 | tmp = _mm_and_si128(buf, bmask2); 144 | __m128i rb = _mm_mullo_epi16(a, tmp); 145 | // g = ((src_argb >> 8) & bmask) * alpha1 146 | buf = _mm_srli_epi32(buf, 8); 147 | tmp = _mm_and_si128(buf, bmask); 148 | __m128i g = _mm_mullo_epi16(a, tmp); 149 | // alpha2 = alpha1 ^ bmask2 150 | a = _mm_xor_si128(a, bmask2); 151 | buf = _mm_load_si128((__m128i*)dst_buffer); 152 | // rb += (dst_argb & bmask2) * alpha2 153 | tmp = _mm_and_si128(buf, bmask2); 154 | tmp = _mm_mullo_epi16(a, tmp); 155 | rb = _mm_add_epi32(rb, tmp); 156 | // rb = (rb >> 8) & bmask2 157 | tmp = _mm_srli_epi32(rb, 8); 158 | rb = _mm_and_si128(tmp, bmask2); 159 | // g += ((dst_argb >> 8) & bmask) * alpha2 160 | buf = _mm_srli_epi32(buf, 8); 161 | tmp = _mm_and_si128(buf, bmask); 162 | tmp = _mm_mullo_epi16(a, tmp); 163 | g = _mm_add_epi32(g, tmp); 164 | // g = g & (bmask << 8) 165 | tmp =_mm_slli_epi32(bmask, 8); 166 | g = _mm_and_si128(g, tmp); 167 | // dst_argb = rb | g 168 | tmp = _mm_or_si128(rb, g); 169 | _mm_store_si128((__m128i*)dst_buffer, tmp); 170 | 171 | n -= 4; src_buffer += 4; dst_buffer += 4; alphap += 16; 172 | } 173 | 174 | // If any pixels are left over, deal with them individually 175 | ++n; 176 | BASIC_BLEND(); 177 | } 178 | 179 | #endif 180 | -------------------------------------------------------------------------------- /graphics_sse2.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * graphics_sse2.h - graphics routines using X86 SSE2 cpu functionality 4 | * 5 | * Copyright (c) 2009 Mion. All rights reserved. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifdef USE_X86_GFX 23 | 24 | void imageFilterMean_SSE2(unsigned char *src1, unsigned char *src2, unsigned char *dst, int length); 25 | void imageFilterAddTo_SSE2(unsigned char *dst, unsigned char *src, int length); 26 | void imageFilterSubFrom_SSE2(unsigned char *dst, unsigned char *src, int length); 27 | void imageFilterBlend_SSE2(Uint32 *dst, Uint32 *src, Uint8 *alphap, int alpha, int length); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # install - install a program, script, or datafile 4 | # This comes from X11R5 (mit/util/scripts/install.sh). 5 | # 6 | # Copyright 1991 by the Massachusetts Institute of Technology 7 | # 8 | # Permission to use, copy, modify, distribute, and sell this software and its 9 | # documentation for any purpose is hereby granted without fee, provided that 10 | # the above copyright notice appear in all copies and that both that 11 | # copyright notice and this permission notice appear in supporting 12 | # documentation, and that the name of M.I.T. not be used in advertising or 13 | # publicity pertaining to distribution of the software without specific, 14 | # written prior permission. M.I.T. makes no representations about the 15 | # suitability of this software for any purpose. It is provided "as is" 16 | # without express or implied warranty. 17 | # 18 | # Calling this script install-sh is preferred over install.sh, to prevent 19 | # `make' implicit rules from creating a file called install from it 20 | # when there is no Makefile. 21 | # 22 | # This script is compatible with the BSD install script, but was written 23 | # from scratch. It can only install one file at a time, a restriction 24 | # shared with many OS's install programs. 25 | 26 | 27 | # set DOITPROG to echo to test this script 28 | 29 | # Don't use :- since 4.3BSD and earlier shells don't like it. 30 | doit="${DOITPROG-}" 31 | 32 | 33 | # put in absolute paths if you don't have them in your path; or use env. vars. 34 | 35 | mvprog="${MVPROG-mv}" 36 | cpprog="${CPPROG-cp}" 37 | chmodprog="${CHMODPROG-chmod}" 38 | chownprog="${CHOWNPROG-chown}" 39 | chgrpprog="${CHGRPPROG-chgrp}" 40 | stripprog="${STRIPPROG-strip}" 41 | rmprog="${RMPROG-rm}" 42 | mkdirprog="${MKDIRPROG-mkdir}" 43 | 44 | transformbasename="" 45 | transform_arg="" 46 | instcmd="$mvprog" 47 | chmodcmd="$chmodprog 0755" 48 | chowncmd="" 49 | chgrpcmd="" 50 | stripcmd="" 51 | rmcmd="$rmprog -f" 52 | mvcmd="$mvprog" 53 | src="" 54 | dst="" 55 | dir_arg="" 56 | 57 | while [ x"$1" != x ]; do 58 | case $1 in 59 | -c) instcmd="$cpprog" 60 | shift 61 | continue;; 62 | 63 | -d) dir_arg=true 64 | shift 65 | continue;; 66 | 67 | -m) chmodcmd="$chmodprog $2" 68 | shift 69 | shift 70 | continue;; 71 | 72 | -o) chowncmd="$chownprog $2" 73 | shift 74 | shift 75 | continue;; 76 | 77 | -g) chgrpcmd="$chgrpprog $2" 78 | shift 79 | shift 80 | continue;; 81 | 82 | -s) stripcmd="$stripprog" 83 | shift 84 | continue;; 85 | 86 | -t=*) transformarg=`echo $1 | sed 's/-t=//'` 87 | shift 88 | continue;; 89 | 90 | -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 91 | shift 92 | continue;; 93 | 94 | *) if [ x"$src" = x ] 95 | then 96 | src=$1 97 | else 98 | # this colon is to work around a 386BSD /bin/sh bug 99 | : 100 | dst=$1 101 | fi 102 | shift 103 | continue;; 104 | esac 105 | done 106 | 107 | if [ x"$src" = x ] 108 | then 109 | echo "install: no input file specified" 110 | exit 1 111 | else 112 | true 113 | fi 114 | 115 | if [ x"$dir_arg" != x ]; then 116 | dst=$src 117 | src="" 118 | 119 | if [ -d $dst ]; then 120 | instcmd=: 121 | chmodcmd="" 122 | else 123 | instcmd=mkdir 124 | fi 125 | else 126 | 127 | # Waiting for this to be detected by the "$instcmd $src $dsttmp" command 128 | # might cause directories to be created, which would be especially bad 129 | # if $src (and thus $dsttmp) contains '*'. 130 | 131 | if [ -f $src -o -d $src ] 132 | then 133 | true 134 | else 135 | echo "install: $src does not exist" 136 | exit 1 137 | fi 138 | 139 | if [ x"$dst" = x ] 140 | then 141 | echo "install: no destination specified" 142 | exit 1 143 | else 144 | true 145 | fi 146 | 147 | # If destination is a directory, append the input filename; if your system 148 | # does not like double slashes in filenames, you may need to add some logic 149 | 150 | if [ -d $dst ] 151 | then 152 | dst="$dst"/`basename $src` 153 | else 154 | true 155 | fi 156 | fi 157 | 158 | ## this sed command emulates the dirname command 159 | dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 160 | 161 | # Make sure that the destination directory exists. 162 | # this part is taken from Noah Friedman's mkinstalldirs script 163 | 164 | # Skip lots of stat calls in the usual case. 165 | if [ ! -d "$dstdir" ]; then 166 | defaultIFS=' 167 | ' 168 | IFS="${IFS-${defaultIFS}}" 169 | 170 | oIFS="${IFS}" 171 | # Some sh's can't handle IFS=/ for some reason. 172 | IFS='%' 173 | set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` 174 | IFS="${oIFS}" 175 | 176 | pathcomp='' 177 | 178 | while [ $# -ne 0 ] ; do 179 | pathcomp="${pathcomp}${1}" 180 | shift 181 | 182 | if [ ! -d "${pathcomp}" ] ; 183 | then 184 | $mkdirprog "${pathcomp}" 185 | else 186 | true 187 | fi 188 | 189 | pathcomp="${pathcomp}/" 190 | done 191 | fi 192 | 193 | if [ x"$dir_arg" != x ] 194 | then 195 | $doit $instcmd $dst && 196 | 197 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && 198 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && 199 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && 200 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi 201 | else 202 | 203 | # If we're going to rename the final executable, determine the name now. 204 | 205 | if [ x"$transformarg" = x ] 206 | then 207 | dstfile=`basename $dst` 208 | else 209 | dstfile=`basename $dst $transformbasename | 210 | sed $transformarg`$transformbasename 211 | fi 212 | 213 | # don't allow the sed command to completely eliminate the filename 214 | 215 | if [ x"$dstfile" = x ] 216 | then 217 | dstfile=`basename $dst` 218 | else 219 | true 220 | fi 221 | 222 | # Make a temp file name in the proper directory. 223 | 224 | dsttmp=$dstdir/#inst.$$# 225 | 226 | # Move or copy the file name to the temp name 227 | 228 | $doit $instcmd $src $dsttmp && 229 | 230 | trap "rm -f ${dsttmp}" 0 && 231 | 232 | # and set any options; do chmod last to preserve setuid bits 233 | 234 | # If any of these fail, we abort the whole thing. If we want to 235 | # ignore errors from any of these, just make sure not to ignore 236 | # errors from the above "$doit $instcmd $src $dsttmp" command. 237 | 238 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && 239 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && 240 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && 241 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && 242 | 243 | # Now rename the file to the real destination. 244 | 245 | $doit $rmcmd -f $dstdir/$dstfile && 246 | $doit $mvcmd $dsttmp $dstdir/$dstfile 247 | 248 | fi && 249 | 250 | 251 | exit 0 252 | -------------------------------------------------------------------------------- /macosx/Info.plist: -------------------------------------------------------------------------------- 1 | #include "../version.h" 2 | <?xml version="1.0" encoding="UTF-8"?> 3 | <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 4 | <plist version="1.0"> 5 | <dict> 6 | <key>CFBundleDevelopmentRegion</key> 7 | <string>English</string> 8 | <key>CFBundleExecutable</key> 9 | <string>${EXECUTABLE_NAME}</string> 10 | <key>CFBundleIconFile</key> 11 | <string>ONScripter.icns</string> 12 | <key>CFBundleIdentifier</key> 13 | <string>net.haeleth.ONScripter-En</string> 14 | <key>CFBundleInfoDictionaryVersion</key> 15 | <string>6.0</string> 16 | <key>CFBundleName</key> 17 | <string>${PRODUCT_NAME}</string> 18 | <key>CFBundlePackageType</key> 19 | <string>APPL</string> 20 | <key>CFBundleSignature</key> 21 | <string>????</string> 22 | <key>CFBundleVersion</key> 23 | <string>1.0</string> 24 | <key>CFBundleGetInfoString</key> 25 | <string>ONScripter-En, (c) 2001-2008 Ogapee, insani, haeleth</string> 26 | <key>CFBundleShortVersionString</key> 27 | <string>VER_NUMBER</string> 28 | <key>LSMinimumSystemVersion</key> 29 | <string>10.3</string> 30 | <key>NSMainNibFile</key> 31 | <string>SDLMain</string> 32 | <key>NSPrincipalClass</key> 33 | <string>NSApplication</string> 34 | </dict> 35 | </plist> 36 | -------------------------------------------------------------------------------- /macosx/ONScripter.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/macosx/ONScripter.icns -------------------------------------------------------------------------------- /macosx/ONScripter_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'ONScripter' target in the 'ONScripter' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import <Cocoa/Cocoa.h> 7 | #endif 8 | -------------------------------------------------------------------------------- /macosx/SDL_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2006 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | 22 | Hand-edited for ONScripter Xcode-project 23 | 24 | */ 25 | #ifndef _SDL_config_macosx_h 26 | #define _SDL_config_macosx_h 27 | 28 | #include "SDL_platform.h" 29 | 30 | /* This is a set of defines to configure the SDL features */ 31 | 32 | #define SDL_HAS_64BIT_TYPE 1 33 | 34 | /* Useful headers */ 35 | /* If we specified an SDK or have a post-PowerPC chip, then alloca.h exists. */ 36 | #if ( (MAC_OS_X_VERSION_MIN_REQUIRED >= 1030) || (!defined(__POWERPC__)) ) 37 | #define HAVE_ALLOCA_H 1 38 | #endif 39 | #define HAVE_SYS_TYPES_H 1 40 | #define HAVE_STDIO_H 1 41 | #define STDC_HEADERS 1 42 | #define HAVE_STRING_H 1 43 | #define HAVE_INTTYPES_H 1 44 | #define HAVE_STDINT_H 1 45 | #define HAVE_CTYPE_H 1 46 | #define HAVE_MATH_H 1 47 | #define HAVE_SIGNAL_H 1 48 | 49 | /* C library functions */ 50 | #define HAVE_MALLOC 1 51 | #define HAVE_CALLOC 1 52 | #define HAVE_REALLOC 1 53 | #define HAVE_FREE 1 54 | #define HAVE_ALLOCA 1 55 | #define HAVE_GETENV 1 56 | #define HAVE_PUTENV 1 57 | #define HAVE_UNSETENV 1 58 | #define HAVE_QSORT 1 59 | #define HAVE_ABS 1 60 | #define HAVE_BCOPY 1 61 | #define HAVE_MEMSET 1 62 | #define HAVE_MEMCPY 1 63 | #define HAVE_MEMMOVE 1 64 | #define HAVE_MEMCMP 1 65 | #define HAVE_STRLEN 1 66 | #define HAVE_STRLCPY 1 67 | #define HAVE_STRLCAT 1 68 | #define HAVE_STRDUP 1 69 | #define HAVE_STRCHR 1 70 | #define HAVE_STRRCHR 1 71 | #define HAVE_STRSTR 1 72 | #define HAVE_STRTOL 1 73 | #define HAVE_STRTOUL 1 74 | #define HAVE_STRTOLL 1 75 | #define HAVE_STRTOULL 1 76 | #define HAVE_STRTOD 1 77 | #define HAVE_ATOI 1 78 | #define HAVE_ATOF 1 79 | #define HAVE_STRCMP 1 80 | #define HAVE_STRNCMP 1 81 | #define HAVE_STRCASECMP 1 82 | #define HAVE_STRNCASECMP 1 83 | #define HAVE_SSCANF 1 84 | #define HAVE_SNPRINTF 1 85 | #define HAVE_VSNPRINTF 1 86 | #define HAVE_SIGACTION 1 87 | #define HAVE_SETJMP 1 88 | #define HAVE_NANOSLEEP 1 89 | 90 | #define SDL_AUDIO_DRIVER_COREAUDIO 1 91 | #define SDL_CDROM_MACOSX 1 92 | #define SDL_JOYSTICK_IOKIT 1 93 | 94 | #ifdef __ppc__ 95 | /* For Mac OS X 10.2 compatibility */ 96 | #define SDL_LOADSO_DLCOMPAT 1 97 | #else 98 | #define SDL_LOADSO_DLOPEN 1 99 | #endif 100 | 101 | #define SDL_THREAD_PTHREAD 1 102 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 103 | #define SDL_TIMER_UNIX 1 104 | #define SDL_VIDEO_DRIVER_QUARTZ 1 105 | #define SDL_VIDEO_OPENGL 1 106 | #define SDL_ASSEMBLY_ROUTINES 1 107 | #ifdef __ppc__ 108 | #define SDL_ALTIVEC_BLITTERS 1 109 | #endif 110 | 111 | #endif /* _SDL_config_macosx_h */ 112 | -------------------------------------------------------------------------------- /macosx/ftmodule.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file. */ 2 | FT_USE_MODULE(tt_driver_class) 3 | FT_USE_MODULE(t1_driver_class) 4 | FT_USE_MODULE(cff_driver_class) 5 | FT_USE_MODULE(t1cid_driver_class) 6 | FT_USE_MODULE(sfnt_module_class) 7 | FT_USE_MODULE(autofit_module_class) 8 | FT_USE_MODULE(pshinter_module_class) 9 | FT_USE_MODULE(ft_smooth_renderer_class) 10 | FT_USE_MODULE(ft_smooth_lcd_renderer_class) 11 | FT_USE_MODULE(ft_smooth_lcdv_renderer_class) 12 | FT_USE_MODULE(psaux_module_class) 13 | FT_USE_MODULE(psnames_module_class) 14 | /* EOF */ 15 | -------------------------------------------------------------------------------- /macosx/jconfig.h: -------------------------------------------------------------------------------- 1 | /* jconfig.h. Generated automatically by configure. */ 2 | /* jconfig.cfg --- source file edited by configure script */ 3 | /* see jconfig.doc for explanations */ 4 | 5 | #define HAVE_PROTOTYPES 6 | #define HAVE_UNSIGNED_CHAR 7 | #define HAVE_UNSIGNED_SHORT 8 | #undef void 9 | #undef const 10 | #undef CHAR_IS_UNSIGNED 11 | #define HAVE_STDDEF_H 12 | #ifndef HAVE_STDLIB_H 13 | #define HAVE_STDLIB_H 14 | #endif 15 | #undef NEED_BSD_STRINGS 16 | #undef NEED_SYS_TYPES_H 17 | #undef NEED_FAR_POINTERS 18 | #undef NEED_SHORT_EXTERNAL_NAMES 19 | /* Define this if you get warnings about undefined structures. */ 20 | #undef INCOMPLETE_TYPES_BROKEN 21 | 22 | #ifdef JPEG_INTERNALS 23 | 24 | #undef RIGHT_SHIFT_IS_UNSIGNED 25 | #define INLINE __inline__ 26 | /* These are for configuring the JPEG memory manager. */ 27 | #undef DEFAULT_MAX_MEM 28 | #undef NO_MKTEMP 29 | 30 | #endif /* JPEG_INTERNALS */ 31 | 32 | #ifdef JPEG_CJPEG_DJPEG 33 | 34 | #define BMP_SUPPORTED /* BMP image file format */ 35 | #define GIF_SUPPORTED /* GIF image file format */ 36 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ 37 | #undef RLE_SUPPORTED /* Utah RLE image file format */ 38 | #define TARGA_SUPPORTED /* Targa image file format */ 39 | 40 | #undef TWO_FILE_COMMANDLINE 41 | #undef NEED_SIGNAL_CATCHER 42 | #undef DONT_USE_B_MODE 43 | 44 | /* Define this if you want percent-done progress reports from cjpeg/djpeg. */ 45 | #undef PROGRESS_REPORT 46 | 47 | #endif /* JPEG_CJPEG_DJPEG */ 48 | -------------------------------------------------------------------------------- /macosx/ogg/config_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_TYPES_H__ 2 | #define __CONFIG_TYPES_H__ 3 | 4 | /* these are filled in by configure */ 5 | typedef int16_t ogg_int16_t; 6 | typedef uint16_t ogg_uint16_t; 7 | typedef int32_t ogg_int32_t; 8 | typedef uint32_t ogg_uint32_t; 9 | typedef int64_t ogg_int64_t; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /nscriptdecode.cpp: -------------------------------------------------------------------------------- 1 | #include<stdio.h> 2 | main(){int ch; while ((ch = getchar()) != EOF) putchar(ch ^ 0x84);} 3 | 4 | -------------------------------------------------------------------------------- /onscripter.rc.in: -------------------------------------------------------------------------------- 1 | 1 VERSIONINFO 2 | FILEVERSION @Y@, @M@, @D@, 0 3 | PRODUCTVERSION @Y@, @M@, @D@, 0 4 | FILEFLAGS 32 5 | FILEOS 4 6 | FILETYPE 1 7 | { 8 | BLOCK "StringFileInfo" { 9 | BLOCK "080904b0" { 10 | VALUE "FileDescription", "ONScripter-En" 11 | VALUE "OriginalFilename", "onscripter-en.exe" 12 | VALUE "CompanyName", "Ogapee/Haeleth" 13 | VALUE "FileVersion", "@Y@-@M@-@D@" 14 | VALUE "LegalCopyright", "Copyright 1998-2007 Studio O.G.A. Portions copyright 2005-2006 insani, 2006-@Y@ Haeleth." 15 | VALUE "ProductName", "ONScripter-En" 16 | VALUE "ProductVersion", "@Y@-@M@-@D@" 17 | } 18 | } 19 | BLOCK "VarFileInfo" { 20 | VALUE "Translation", 0x0809, 0x04B0 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /osx_build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # A noddy script to automate production of universal binaries on OS X. 4 | 5 | make distclean &>/dev/null 6 | 7 | export EXTRALDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.3.9.sdk -Wl,-framework,OpenGL" 8 | export CCARGS="-arch ppc -isysroot /Developer/SDKs/MacOSX10.3.9.sdk" 9 | export CC="gcc $CCARGS" 10 | export CXX="g++ $CCARGS" 11 | export SDLOTHERCONFIG="--build=powerpc-apple-darwin7.9.0" 12 | export OTHERCONFIG="--build=powerpc-apple-darwin7.9.0 --disable-sdltest" 13 | ./configure --with-internal-libs 14 | make || exit 15 | mv onscripter onscripter.ppc 16 | make distclean &>/dev/null 17 | 18 | export EXTRALDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -Wl,-framework,OpenGL" 19 | export CCARGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk" 20 | export CC="gcc $CCARGS" 21 | export CXX="g++ $CCARGS" 22 | export SDLOTHERCONFIG="--build=i386-apple-darwin8.11.1" 23 | export OTHERCONFIG="--build=i386-apple-darwin8.11.1 --disable-sdltest" 24 | ./configure --with-internal-libs 25 | make || exit 26 | mv onscripter onscripter.intel 27 | 28 | lipo -create \ 29 | -arch ppc onscripter.ppc \ 30 | -arch i386 onscripter.intel \ 31 | -output onscripter 32 | 33 | cp onscripter onscripter-en -------------------------------------------------------------------------------- /resize_image.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * resize_image.h - resize image using smoothing and resampling 4 | * 5 | * Copyright (c) 2001-2004 Ogapee. All rights reserved. 6 | * 7 | * ogapee@aqua.dti2.ne.jp 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | void resizeImage( unsigned char *dst_buffer, int dst_width, int dst_height, int dst_total_width, 25 | unsigned char *src_buffer, int src_width, int src_height, int src_total_width, 26 | int byte_per_pixel, unsigned char *tmp_buffer, int tmp_total_width, bool palette_flag ); 27 | -------------------------------------------------------------------------------- /test/0.breakup.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/0.breakup.txt -------------------------------------------------------------------------------- /test/0.cascade.txt: -------------------------------------------------------------------------------- 1 | 2 | ; A test for the "cascade.dll" effect. 3 | 4 | *define 5 | game 6 | 7 | *start 8 | 9 | bg "bgi1.jpg",99,5000,"cascade.dll/ux" 10 | bg "bgi1.jpg",99,3000,"cascade.dll/uo" 11 | bg "bgi1.jpg",99,2000,"cascade.dll/di" 12 | bg "bgi0.jpg",99,4000,"cascade.dll/dx" 13 | bg "bgi0.jpg",99,2000,"cascade.dll/do" 14 | bg "bgi0.jpg",99,1000,"cascade.dll/ui" 15 | bg "bgi1.jpg",99,3000,"cascade.dll/lx" 16 | bg "bgi1.jpg",99,3000,"cascade.dll/lo" 17 | bg "bgi1.jpg",99,2000,"cascade.dll/ri" 18 | bg "bgi0.jpg",99,2000,"cascade.dll/rx" 19 | bg "bgi0.jpg",99,2000,"cascade.dll/ro" 20 | bg "bgi0.jpg",99,1000,"cascade.dll/li" 21 | 22 | click 23 | end -------------------------------------------------------------------------------- /test/0.color.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/0.color.txt -------------------------------------------------------------------------------- /test/0.hana.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/0.hana.txt -------------------------------------------------------------------------------- /test/0.jponly.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/0.jponly.txt -------------------------------------------------------------------------------- /test/0.oldmovie.txt: -------------------------------------------------------------------------------- 1 | *define 2 | setlayer 0,100,"oldmovie.dll/0" 3 | windoweffect 10,800 4 | 5 | game 6 | 7 | *start 8 | 9 | setwindow 30,380,30,5,20,20,-1,1,0,1,1,#CCDDCC,20,370,620,460 10 | 11 | bg "oldmovie.jpg",1 12 | 13 | lsph 10,":l/16,0,3;dust.bmp",0,0 14 | lsp 2,"*0" 15 | 16 | layermessage 0,"s|2,12,10,200,160,10" 17 | 18 | !sd 19 | `This is an old movie.@ 20 | `Well, maybe not.\ 21 | `End of film... 22 | 23 | delay 1000 24 | 25 | textclear 26 | csp 2 27 | 28 | bg black,10,2000 29 | 30 | 31 | end -------------------------------------------------------------------------------- /test/0.snow.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/0.snow.txt -------------------------------------------------------------------------------- /test/0.trvswave.txt: -------------------------------------------------------------------------------- 1 | *define 2 | game 3 | *start 4 | 5 | click 6 | 7 | lsp 2,":c;tr_logo.jpg",140,100 8 | 9 | print 99,1500,"trvswave.dll/h" 10 | 11 | bg white,0 12 | lsp 2,":c;kimikage.jpg",160,176 13 | 14 | delay 1500 15 | print 99,3000,"trvswave.dll/h" 16 | 17 | bg black,0 18 | csp 2 19 | 20 | delay 2000 21 | print 99,1000,"trvswave.dll/h" 22 | 23 | end -------------------------------------------------------------------------------- /test/0.txtbtn.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/0.txtbtn.txt -------------------------------------------------------------------------------- /test/0.whirl.txt: -------------------------------------------------------------------------------- 1 | *define 2 | game 3 | 4 | *start 5 | 6 | lsp 0,":c;tr_logo.jpg",140,100 7 | print 99,2500,"whirl.dll/r" 8 | repaint 9 | delay 1000 10 | 11 | csp 0 12 | 13 | bg ":c;bgi1.jpg",99,3000,"whirl.dll/l" 14 | repaint 15 | delay 1000 16 | 17 | lsp 0,":c;kimikage.jpg",160,176 18 | bg white,99,4000,"whirl.dll/r" 19 | repaint 20 | delay 1000 21 | 22 | csp 0 23 | bg black,99,1500,"whirl.dll/l" 24 | end -------------------------------------------------------------------------------- /test/00.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/00.txt -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | This is a very basic set of tests. Absolutely no pretence is made at 2 | significant coverage, as a simple glance at the code will prove. They 3 | merely test things that are/were broken in either Ponscripter or 4 | ONScripter-En. 5 | 6 | If you wish to try them, note that you will need to supply a 7 | default.ttf yourself. It needs to be a monospaced Japanese font. 8 | 9 | Each test prints two lines: an "NScr" line showing the result given by 10 | an up-to-date NScripter, and a "Test" line showing what the 11 | interpreter you're using displays. If the two are different, you may 12 | have a bug. (Some tests then print another line, which you can 13 | ignore.) 14 | 15 | Some differences of behaviour are expected. In particular, 16 | ONScripter-En and Ponscripter will display a lot of numbers with 17 | regular ASCII numerals where NScripter uses double-width characters. 18 | This is not exactly a bug (it's by design; building ONScripter-En 19 | without FORCE_1BYTE_CHAR defined will give the NScripter behaviour). 20 | However, builds that display this behaviour will not be 100% 21 | compatible with some Japanese games. 22 | 23 | Other differences, like the kinsoku behaviour in test 4, are arguably 24 | bugs in NScripter that are fixed in ONScripter, though the test on the 25 | second page explains _why_ NScripter does that... 26 | -------------------------------------------------------------------------------- /test/bgi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/bgi.jpg -------------------------------------------------------------------------------- /test/bgi0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/bgi0.jpg -------------------------------------------------------------------------------- /test/bgi1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/bgi1.jpg -------------------------------------------------------------------------------- /test/bgi2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/bgi2.jpg -------------------------------------------------------------------------------- /test/chr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/chr.jpg -------------------------------------------------------------------------------- /test/default.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/default.ttf -------------------------------------------------------------------------------- /test/dust.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/dust.bmp -------------------------------------------------------------------------------- /test/kaede1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/kaede1.jpg -------------------------------------------------------------------------------- /test/kaede2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/kaede2.jpg -------------------------------------------------------------------------------- /test/kaede3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/kaede3.jpg -------------------------------------------------------------------------------- /test/kimikage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/kimikage.jpg -------------------------------------------------------------------------------- /test/msk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/msk.jpg -------------------------------------------------------------------------------- /test/oldmovie.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/oldmovie.jpg -------------------------------------------------------------------------------- /test/rain1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/rain1.bmp -------------------------------------------------------------------------------- /test/rain2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/rain2.bmp -------------------------------------------------------------------------------- /test/rain3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/rain3.bmp -------------------------------------------------------------------------------- /test/registry.txt: -------------------------------------------------------------------------------- 1 | [nscripter\interpreter\test] 2 | "IsThisONScripter" = "yes" 3 | -------------------------------------------------------------------------------- /test/sakura1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/sakura1.bmp -------------------------------------------------------------------------------- /test/sakura2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/sakura2.bmp -------------------------------------------------------------------------------- /test/sakura3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/sakura3.bmp -------------------------------------------------------------------------------- /test/snow1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/snow1.bmp -------------------------------------------------------------------------------- /test/snow2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/snow2.bmp -------------------------------------------------------------------------------- /test/snow3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/snow3.bmp -------------------------------------------------------------------------------- /test/snowa1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/snowa1.bmp -------------------------------------------------------------------------------- /test/snowa2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/snowa2.bmp -------------------------------------------------------------------------------- /test/snowa3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/snowa3.bmp -------------------------------------------------------------------------------- /test/tr_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/test/tr_logo.jpg -------------------------------------------------------------------------------- /version.h: -------------------------------------------------------------------------------- 1 | #define xstr(s) str(s) 2 | #define str(s) #s 3 | 4 | #define VER_NUMBER 20090712-en 5 | #define ONS_VERSION xstr(VER_NUMBER) 6 | #define NSC_VERSION 292 7 | -------------------------------------------------------------------------------- /wii/audio.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui Template 3 | * Tantric 2009 4 | * 5 | * audio.cpp 6 | * Audio support 7 | ***************************************************************************/ 8 | 9 | #include <gccore.h> 10 | #include <ogcsys.h> 11 | #include <asndlib.h> 12 | 13 | /**************************************************************************** 14 | * InitAudio 15 | * 16 | * Initializes the Wii's audio subsystem 17 | ***************************************************************************/ 18 | void InitAudio() 19 | { 20 | AUDIO_Init(NULL); 21 | ASND_Init(); 22 | ASND_Pause(0); 23 | } 24 | 25 | /**************************************************************************** 26 | * ShutdownAudio 27 | * 28 | * Shuts down audio subsystem. Useful to avoid unpleasant sounds if a 29 | * crash occurs during shutdown. 30 | ***************************************************************************/ 31 | void ShutdownAudio() 32 | { 33 | ASND_Pause(1); 34 | ASND_End(); 35 | } 36 | -------------------------------------------------------------------------------- /wii/audio.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui Template 3 | * Tantric 2009 4 | * 5 | * audio.h 6 | * Audio support 7 | ***************************************************************************/ 8 | 9 | #ifndef _AUDIO_H_ 10 | #define _AUDIO_H_ 11 | 12 | void InitAudio(); 13 | void ShutdownAudio(); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /wii/filelist.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui Template 3 | * Tantric 2009 4 | * 5 | * imagelist.h 6 | * Contains a list of all of the files in the images, fonts, sounds folders 7 | ***************************************************************************/ 8 | 9 | #ifndef _FILELIST_H_ 10 | #define _FILELIST_H_ 11 | 12 | #include <gccore.h> 13 | 14 | extern const u8 font_ttf[]; 15 | extern const u32 font_ttf_size; 16 | 17 | extern const u8 bg_music_ogg[]; 18 | extern const u32 bg_music_ogg_size; 19 | 20 | extern const u8 button_over_pcm[]; 21 | extern const u32 button_over_pcm_size; 22 | 23 | extern const u8 button_png[]; 24 | extern const u32 button_png_size; 25 | 26 | extern const u8 button_over_png[]; 27 | extern const u32 button_over_png_size; 28 | 29 | extern const u8 button_large_png[]; 30 | extern const u32 button_large_png_size; 31 | 32 | extern const u8 button_large_over_png[]; 33 | extern const u32 button_large_over_png_size; 34 | 35 | extern const u8 dialogue_box_png[]; 36 | extern const u32 dialogue_box_png_size; 37 | 38 | extern const u8 bg_options_png[]; 39 | extern const u32 bg_options_png_size; 40 | 41 | extern const u8 bg_options_entry_png[]; 42 | extern const u32 bg_options_entry_png_size; 43 | 44 | extern const u8 bg_list_selection_png[]; 45 | extern const u32 bg_list_selection_png_size; 46 | 47 | extern const u8 bg_list_selection_entry_png[]; 48 | extern const u32 bg_list_selection_entry_png_size; 49 | 50 | extern const u8 scrollbar_png[]; 51 | extern const u32 scrollbar_png_size; 52 | 53 | extern const u8 scrollbar_arrowup_png[]; 54 | extern const u32 scrollbar_arrowup_png_size; 55 | 56 | extern const u8 scrollbar_arrowup_over_png[]; 57 | extern const u32 scrollbar_arrowup_over_png_size; 58 | 59 | extern const u8 scrollbar_arrowdown_png[]; 60 | extern const u32 scrollbar_arrowdown_png_size; 61 | 62 | extern const u8 scrollbar_arrowdown_over_png[]; 63 | extern const u32 scrollbar_arrowdown_over_png_size; 64 | 65 | extern const u8 scrollbar_box_png[]; 66 | extern const u32 scrollbar_box_png_size; 67 | 68 | extern const u8 scrollbar_box_over_png[]; 69 | extern const u32 scrollbar_box_over_png_size; 70 | 71 | extern const u8 keyboard_textbox_png[]; 72 | extern const u32 keyboard_textbox_png_size; 73 | 74 | extern const u8 keyboard_key_png[]; 75 | extern const u32 keyboard_key_png_size; 76 | 77 | extern const u8 keyboard_key_over_png[]; 78 | extern const u32 keyboard_key_over_png_size; 79 | 80 | extern const u8 keyboard_mediumkey_png[]; 81 | extern const u32 keyboard_mediumkey_png_size; 82 | 83 | extern const u8 keyboard_mediumkey_over_png[]; 84 | extern const u32 keyboard_mediumkey_over_png_size; 85 | 86 | extern const u8 keyboard_largekey_png[]; 87 | extern const u32 keyboard_largekey_png_size; 88 | 89 | extern const u8 keyboard_largekey_over_png[]; 90 | extern const u32 keyboard_largekey_over_png_size; 91 | 92 | extern const u8 player1_point_png[]; 93 | extern const u32 player1_point_png_size; 94 | 95 | extern const u8 player2_point_png[]; 96 | extern const u32 player2_point_png_size; 97 | 98 | extern const u8 player3_point_png[]; 99 | extern const u32 player3_point_png_size; 100 | 101 | extern const u8 player4_point_png[]; 102 | extern const u32 player4_point_png_size; 103 | 104 | extern const u8 player1_grab_png[]; 105 | extern const u32 player1_grab_png_size; 106 | 107 | extern const u8 player2_grab_png[]; 108 | extern const u32 player2_grab_png_size; 109 | 110 | extern const u8 player3_grab_png[]; 111 | extern const u32 player3_grab_png_size; 112 | 113 | extern const u8 player4_grab_png[]; 114 | extern const u32 player4_grab_png_size; 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /wii/fonts/font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/fonts/font.ttf -------------------------------------------------------------------------------- /wii/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/icon.png -------------------------------------------------------------------------------- /wii/images/bg_list_selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/bg_list_selection.png -------------------------------------------------------------------------------- /wii/images/bg_list_selection_entry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/bg_list_selection_entry.png -------------------------------------------------------------------------------- /wii/images/bg_options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/bg_options.png -------------------------------------------------------------------------------- /wii/images/bg_options_entry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/bg_options_entry.png -------------------------------------------------------------------------------- /wii/images/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/button.png -------------------------------------------------------------------------------- /wii/images/button_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/button_large.png -------------------------------------------------------------------------------- /wii/images/button_large_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/button_large_over.png -------------------------------------------------------------------------------- /wii/images/button_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/button_over.png -------------------------------------------------------------------------------- /wii/images/dialogue_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/dialogue_box.png -------------------------------------------------------------------------------- /wii/images/keyboard_key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/keyboard_key.png -------------------------------------------------------------------------------- /wii/images/keyboard_key_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/keyboard_key_over.png -------------------------------------------------------------------------------- /wii/images/keyboard_largekey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/keyboard_largekey.png -------------------------------------------------------------------------------- /wii/images/keyboard_largekey_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/keyboard_largekey_over.png -------------------------------------------------------------------------------- /wii/images/keyboard_mediumkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/keyboard_mediumkey.png -------------------------------------------------------------------------------- /wii/images/keyboard_mediumkey_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/keyboard_mediumkey_over.png -------------------------------------------------------------------------------- /wii/images/keyboard_textbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/keyboard_textbox.png -------------------------------------------------------------------------------- /wii/images/player1_grab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/player1_grab.png -------------------------------------------------------------------------------- /wii/images/player1_point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/player1_point.png -------------------------------------------------------------------------------- /wii/images/player2_grab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/player2_grab.png -------------------------------------------------------------------------------- /wii/images/player2_point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/player2_point.png -------------------------------------------------------------------------------- /wii/images/player3_grab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/player3_grab.png -------------------------------------------------------------------------------- /wii/images/player3_point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/player3_point.png -------------------------------------------------------------------------------- /wii/images/player4_grab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/player4_grab.png -------------------------------------------------------------------------------- /wii/images/player4_point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/player4_point.png -------------------------------------------------------------------------------- /wii/images/scrollbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/scrollbar.png -------------------------------------------------------------------------------- /wii/images/scrollbar_arrowdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/scrollbar_arrowdown.png -------------------------------------------------------------------------------- /wii/images/scrollbar_arrowdown_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/scrollbar_arrowdown_over.png -------------------------------------------------------------------------------- /wii/images/scrollbar_arrowup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/scrollbar_arrowup.png -------------------------------------------------------------------------------- /wii/images/scrollbar_arrowup_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/scrollbar_arrowup_over.png -------------------------------------------------------------------------------- /wii/images/scrollbar_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/scrollbar_box.png -------------------------------------------------------------------------------- /wii/images/scrollbar_box_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/images/scrollbar_box_over.png -------------------------------------------------------------------------------- /wii/input.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui Template 3 | * Tantric 2009 4 | * 5 | * input.cpp 6 | * Wii/GameCube controller management 7 | ***************************************************************************/ 8 | 9 | #include <gccore.h> 10 | #include <stdio.h> 11 | #include <stdlib.h> 12 | #include <string.h> 13 | #include <math.h> 14 | #include <ogcsys.h> 15 | #include <unistd.h> 16 | #include <wiiuse/wpad.h> 17 | 18 | #include "menu.h" 19 | #include "video.h" 20 | #include "input.h" 21 | #include "libwiigui/gui.h" 22 | 23 | int rumbleRequest[4] = {0,0,0,0}; 24 | GuiTrigger userInput[4]; 25 | static int rumbleCount[4] = {0,0,0,0}; 26 | 27 | /**************************************************************************** 28 | * ShutoffRumble 29 | ***************************************************************************/ 30 | 31 | void ShutoffRumble() 32 | { 33 | for(int i=0;i<4;i++) 34 | { 35 | WPAD_Rumble(i, 0); 36 | rumbleCount[i] = 0; 37 | } 38 | } 39 | 40 | /**************************************************************************** 41 | * DoRumble 42 | ***************************************************************************/ 43 | 44 | void DoRumble(int i) 45 | { 46 | if(rumbleRequest[i] && rumbleCount[i] < 3) 47 | { 48 | WPAD_Rumble(i, 1); // rumble on 49 | rumbleCount[i]++; 50 | } 51 | else if(rumbleRequest[i]) 52 | { 53 | rumbleCount[i] = 12; 54 | rumbleRequest[i] = 0; 55 | } 56 | else 57 | { 58 | if(rumbleCount[i]) 59 | rumbleCount[i]--; 60 | WPAD_Rumble(i, 0); // rumble off 61 | } 62 | } 63 | 64 | /**************************************************************************** 65 | * WPAD_Stick 66 | * 67 | * Get X/Y value from Wii Joystick (classic, nunchuk) input 68 | ***************************************************************************/ 69 | 70 | s8 WPAD_Stick(u8 chan, u8 right, int axis) 71 | { 72 | float mag = 0.0; 73 | float ang = 0.0; 74 | WPADData *data = WPAD_Data(chan); 75 | 76 | switch (data->exp.type) 77 | { 78 | case WPAD_EXP_NUNCHUK: 79 | case WPAD_EXP_GUITARHERO3: 80 | if (right == 0) 81 | { 82 | mag = data->exp.nunchuk.js.mag; 83 | ang = data->exp.nunchuk.js.ang; 84 | } 85 | break; 86 | 87 | case WPAD_EXP_CLASSIC: 88 | if (right == 0) 89 | { 90 | mag = data->exp.classic.ljs.mag; 91 | ang = data->exp.classic.ljs.ang; 92 | } 93 | else 94 | { 95 | mag = data->exp.classic.rjs.mag; 96 | ang = data->exp.classic.rjs.ang; 97 | } 98 | break; 99 | 100 | default: 101 | break; 102 | } 103 | 104 | /* calculate x/y value (angle need to be converted into radian) */ 105 | if (mag > 1.0) mag = 1.0; 106 | else if (mag < -1.0) mag = -1.0; 107 | double val; 108 | 109 | if(axis == 0) // x-axis 110 | val = mag * sin((PI * ang)/180.0f); 111 | else // y-axis 112 | val = mag * cos((PI * ang)/180.0f); 113 | 114 | return (s8)(val * 128.0f); 115 | } 116 | -------------------------------------------------------------------------------- /wii/input.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui Template 3 | * Tantric 2009 4 | * 5 | * input.h 6 | * Wii/GameCube controller management 7 | ***************************************************************************/ 8 | 9 | #ifndef _INPUT_H_ 10 | #define _INPUT_H_ 11 | 12 | #include <gccore.h> 13 | #include <wiiuse/wpad.h> 14 | 15 | #define PI 3.14159265f 16 | #define PADCAL 50 17 | 18 | enum 19 | { 20 | TRIGGER_SIMPLE, 21 | TRIGGER_BUTTON_ONLY, 22 | TRIGGER_BUTTON_ONLY_IN_FOCUS 23 | }; 24 | 25 | typedef struct _paddata { 26 | u16 btns_d; 27 | u16 btns_u; 28 | u16 btns_h; 29 | s8 stickX; 30 | s8 stickY; 31 | s8 substickX; 32 | s8 substickY; 33 | u8 triggerL; 34 | u8 triggerR; 35 | } PADData; 36 | 37 | class GuiTrigger 38 | { 39 | public: 40 | GuiTrigger(); 41 | ~GuiTrigger(); 42 | void SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns); 43 | void SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns); 44 | void SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns); 45 | s8 WPAD_Stick(u8 right, int axis); 46 | bool Left(); 47 | bool Right(); 48 | bool Up(); 49 | bool Down(); 50 | 51 | u8 type; 52 | s32 chan; 53 | WPADData wpad; 54 | PADData pad; 55 | }; 56 | 57 | extern GuiTrigger userInput[4]; 58 | extern int rumbleRequest[4]; 59 | 60 | void ShutoffRumble(); 61 | void DoRumble(int i); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /wii/libwiigui/gui_button.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui 3 | * Tantric 2009 4 | * 5 | * gui_button.cpp 6 | * GUI class definitions 7 | ***************************************************************************/ 8 | 9 | #include "gui.h" 10 | /** 11 | * Constructor for the GuiButton class. 12 | */ 13 | 14 | GuiButton::GuiButton(int w, int h) 15 | { 16 | width = w; 17 | height = h; 18 | image = NULL; 19 | imageOver = NULL; 20 | icon = NULL; 21 | iconOver = NULL; 22 | 23 | for(int i=0; i < 3; i++) 24 | { 25 | label[i] = NULL; 26 | labelOver[i] = NULL; 27 | } 28 | 29 | soundOver = NULL; 30 | soundClick = NULL; 31 | selectable = true; 32 | clickable = true; 33 | } 34 | 35 | /** 36 | * Destructor for the GuiButton class. 37 | */ 38 | GuiButton::~GuiButton() 39 | { 40 | } 41 | 42 | void GuiButton::SetImage(GuiImage* img) 43 | { 44 | image = img; 45 | 46 | if(img) 47 | img->SetParent(this); 48 | } 49 | void GuiButton::SetImageOver(GuiImage* img) 50 | { 51 | imageOver = img; 52 | 53 | if(img) 54 | img->SetParent(this); 55 | } 56 | void GuiButton::SetIcon(GuiImage* img) 57 | { 58 | icon = img; 59 | 60 | if(img) 61 | img->SetParent(this); 62 | } 63 | void GuiButton::SetIconOver(GuiImage* img) 64 | { 65 | iconOver = img; 66 | 67 | if(img) 68 | img->SetParent(this); 69 | } 70 | void GuiButton::SetLabel(GuiText* txt) 71 | { 72 | label[0] = txt; 73 | 74 | if(txt) 75 | txt->SetParent(this); 76 | } 77 | void GuiButton::SetLabelOver(GuiText* txt) 78 | { 79 | labelOver[0] = txt; 80 | 81 | if(txt) 82 | txt->SetParent(this); 83 | } 84 | void GuiButton::SetLabel(GuiText* txt, int n) 85 | { 86 | label[n] = txt; 87 | 88 | if(txt) 89 | txt->SetParent(this); 90 | } 91 | void GuiButton::SetLabelOver(GuiText* txt, int n) 92 | { 93 | labelOver[n] = txt; 94 | 95 | if(txt) 96 | txt->SetParent(this); 97 | } 98 | void GuiButton::SetSoundOver(GuiSound * snd) 99 | { 100 | soundOver = snd; 101 | } 102 | void GuiButton::SetSoundClick(GuiSound * snd) 103 | { 104 | soundClick = snd; 105 | } 106 | 107 | /** 108 | * Draw the button on screen 109 | */ 110 | void GuiButton::Draw() 111 | { 112 | if(!this->IsVisible()) 113 | return; 114 | 115 | // draw image 116 | if(state == STATE_SELECTED && imageOver) 117 | imageOver->Draw(); 118 | else if(image) 119 | image->Draw(); 120 | // draw icon 121 | if(state == STATE_SELECTED && iconOver) 122 | iconOver->Draw(); 123 | else if(icon) 124 | icon->Draw(); 125 | // draw text 126 | for(int i=0; i<3; i++) 127 | { 128 | if(state == STATE_SELECTED && labelOver[i]) 129 | labelOver[i]->Draw(); 130 | else if(label[i]) 131 | label[i]->Draw(); 132 | } 133 | 134 | this->UpdateEffects(); 135 | } 136 | 137 | void GuiButton::Update(GuiTrigger * t) 138 | { 139 | if(state == STATE_CLICKED || state == STATE_DISABLED || !t) 140 | return; 141 | else if(parentElement && parentElement->GetState() == STATE_DISABLED) 142 | return; 143 | 144 | #ifdef HW_RVL 145 | // cursor 146 | if(t->wpad.ir.valid) 147 | { 148 | if(this->IsInside(t->wpad.ir.x, t->wpad.ir.y)) 149 | { 150 | if(state == STATE_DEFAULT) // we weren't on the button before! 151 | { 152 | state = STATE_SELECTED; 153 | 154 | if(this->Rumble()) 155 | rumbleRequest[t->chan] = 1; 156 | 157 | if(soundOver) 158 | soundOver->Play(); 159 | 160 | if(effectsOver && !effects) 161 | { 162 | // initiate effects 163 | effects = effectsOver; 164 | effectAmount = effectAmountOver; 165 | effectTarget = effectTargetOver; 166 | } 167 | } 168 | } 169 | else 170 | { 171 | if(state == STATE_SELECTED) 172 | state = STATE_DEFAULT; 173 | 174 | if(effectTarget == effectTargetOver && effectAmount == effectAmountOver) 175 | { 176 | // initiate effects (in reverse) 177 | effects = effectsOver; 178 | effectAmount = -effectAmountOver; 179 | effectTarget = 100; 180 | } 181 | } 182 | } 183 | #endif 184 | 185 | // button triggers 186 | if(this->IsClickable()) 187 | { 188 | for(int i=0; i<2; i++) 189 | { 190 | if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan)) 191 | { 192 | // higher 16 bits only (wiimote) 193 | s32 wm_btns = t->wpad.btns_d << 16; 194 | s32 wm_btns_trig = trigger[i]->wpad.btns_d << 16; 195 | 196 | // lower 16 bits only (classic controller) 197 | s32 cc_btns = t->wpad.btns_d >> 16; 198 | s32 cc_btns_trig = trigger[i]->wpad.btns_d >> 16; 199 | 200 | if( 201 | (t->wpad.btns_d > 0 && 202 | wm_btns == wm_btns_trig || 203 | (cc_btns == cc_btns_trig && t->wpad.exp.type == EXP_CLASSIC)) || 204 | (t->pad.btns_d == trigger[i]->pad.btns_d && t->pad.btns_d > 0)) 205 | { 206 | if(state == STATE_SELECTED) 207 | { 208 | state = STATE_CLICKED; 209 | 210 | if(soundClick) 211 | soundClick->Play(); 212 | } 213 | else if(trigger[i]->type == TRIGGER_BUTTON_ONLY) 214 | { 215 | state = STATE_CLICKED; 216 | } 217 | else if(trigger[i]->type == TRIGGER_BUTTON_ONLY_IN_FOCUS && 218 | parentElement->IsFocused()) 219 | { 220 | state = STATE_CLICKED; 221 | } 222 | } 223 | } 224 | } 225 | } 226 | 227 | if(updateCB) 228 | updateCB(this); 229 | } 230 | -------------------------------------------------------------------------------- /wii/libwiigui/gui_image.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui 3 | * Tantric 2009 4 | * 5 | * gui_image.cpp 6 | * GUI class definitions 7 | ***************************************************************************/ 8 | 9 | #include "gui.h" 10 | /** 11 | * Constructor for the GuiImage class. 12 | */ 13 | 14 | GuiImage::GuiImage(GuiImageData * img) 15 | { 16 | image = img->GetImage(); 17 | width = img->GetWidth(); 18 | height = img->GetHeight(); 19 | imageangle = 0; 20 | tile = -1; 21 | stripe = 0; 22 | imgType = IMAGE_DATA; 23 | } 24 | 25 | GuiImage::GuiImage(u8 * img, int w, int h) 26 | { 27 | image = img; 28 | width = w; 29 | height = h; 30 | imageangle = 0; 31 | tile = -1; 32 | stripe = 0; 33 | imgType = IMAGE_TEXTURE; 34 | } 35 | 36 | GuiImage::GuiImage(int w, int h, GXColor c) 37 | { 38 | image = (u8 *)memalign (32, w * h * 4); 39 | width = w; 40 | height = h; 41 | imageangle = 0; 42 | tile = -1; 43 | stripe = 0; 44 | imgType = IMAGE_COLOR; 45 | 46 | if(!image) 47 | return; 48 | 49 | int x, y; 50 | 51 | for(y=0; y < h; y++) 52 | { 53 | for(x=0; x < w; x++) 54 | { 55 | this->SetPixel(x, y, c); 56 | } 57 | } 58 | int len = w*h*4; 59 | if(len%32) len += (32-len%32); 60 | DCFlushRange(image, len); 61 | } 62 | 63 | /** 64 | * Destructor for the GuiImage class. 65 | */ 66 | GuiImage::~GuiImage() 67 | { 68 | if(imgType == IMAGE_COLOR && image) 69 | free(image); 70 | } 71 | 72 | u8 * GuiImage::GetImage() 73 | { 74 | return image; 75 | } 76 | 77 | void GuiImage::SetImage(GuiImageData * img) 78 | { 79 | image = img->GetImage(); 80 | width = img->GetWidth(); 81 | height = img->GetHeight(); 82 | imgType = IMAGE_DATA; 83 | } 84 | 85 | void GuiImage::SetImage(u8 * img, int w, int h) 86 | { 87 | image = img; 88 | width = w; 89 | height = h; 90 | imgType = IMAGE_TEXTURE; 91 | } 92 | 93 | void GuiImage::SetAngle(float a) 94 | { 95 | imageangle = a; 96 | } 97 | 98 | void GuiImage::SetTile(int t) 99 | { 100 | tile = t; 101 | } 102 | 103 | GXColor GuiImage::GetPixel(int x, int y) 104 | { 105 | if(!image || this->GetWidth() <= 0 || x < 0 || y < 0) 106 | return (GXColor){0, 0, 0, 0}; 107 | 108 | u32 offset = (((y >> 2)<<4)*this->GetWidth()) + ((x >> 2)<<6) + (((y%4 << 2) + x%4 ) << 1); 109 | GXColor color; 110 | color.a = *(image+offset); 111 | color.r = *(image+offset+1); 112 | color.g = *(image+offset+32); 113 | color.b = *(image+offset+33); 114 | return color; 115 | } 116 | 117 | void GuiImage::SetPixel(int x, int y, GXColor color) 118 | { 119 | if(!image || this->GetWidth() <= 0 || x < 0 || y < 0) 120 | return; 121 | 122 | u32 offset = (((y >> 2)<<4)*this->GetWidth()) + ((x >> 2)<<6) + (((y%4 << 2) + x%4 ) << 1); 123 | *(image+offset) = color.a; 124 | *(image+offset+1) = color.r; 125 | *(image+offset+32) = color.g; 126 | *(image+offset+33) = color.b; 127 | } 128 | 129 | void GuiImage::SetStripe(int s) 130 | { 131 | stripe = s; 132 | } 133 | 134 | void GuiImage::ColorStripe(int shift) 135 | { 136 | int x, y; 137 | GXColor color; 138 | int alt = 0; 139 | 140 | for(y=0; y < this->GetHeight(); y++) 141 | { 142 | if(y % 3 == 0) 143 | alt ^= 1; 144 | 145 | for(x=0; x < this->GetWidth(); x++) 146 | { 147 | color = GetPixel(x, y); 148 | 149 | if(alt) 150 | { 151 | if(color.r < 255-shift) 152 | color.r += shift; 153 | else 154 | color.r = 255; 155 | if(color.g < 255-shift) 156 | color.g += shift; 157 | else 158 | color.g = 255; 159 | if(color.b < 255-shift) 160 | color.b += shift; 161 | else 162 | color.b = 255; 163 | 164 | color.a = 255; 165 | } 166 | else 167 | { 168 | if(color.r > shift) 169 | color.r -= shift; 170 | else 171 | color.r = 0; 172 | if(color.g > shift) 173 | color.g -= shift; 174 | else 175 | color.g = 0; 176 | if(color.b > shift) 177 | color.b -= shift; 178 | else 179 | color.b = 0; 180 | 181 | color.a = 255; 182 | } 183 | SetPixel(x, y, color); 184 | } 185 | } 186 | } 187 | 188 | /** 189 | * Draw the button on screen 190 | */ 191 | void GuiImage::Draw() 192 | { 193 | if(!image || !this->IsVisible() || tile == 0) 194 | return; 195 | 196 | float currScale = this->GetScale(); 197 | int currLeft = this->GetLeft(); 198 | 199 | if(tile > 0) 200 | { 201 | for(int i=0; i<tile; i++) 202 | Menu_DrawImg(currLeft+width*i, this->GetTop(), width, height, image, imageangle, currScale, currScale, this->GetAlpha()); 203 | } 204 | else 205 | { 206 | // temporary (maybe), used to correct offset for scaled images 207 | if(scale != 1) 208 | currLeft = currLeft - width/2 + (width*scale)/2; 209 | 210 | Menu_DrawImg(currLeft, this->GetTop(), width, height, image, imageangle, currScale, currScale, this->GetAlpha()); 211 | } 212 | 213 | if(stripe > 0) 214 | for(int y=0; y < this->GetHeight(); y+=6) 215 | Menu_DrawRectangle(currLeft,this->GetTop()+y,this->GetWidth(),3,(GXColor){0, 0, 0, stripe},1); 216 | 217 | this->UpdateEffects(); 218 | } 219 | -------------------------------------------------------------------------------- /wii/libwiigui/gui_imagedata.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui 3 | * Tantric 2009 4 | * 5 | * gui_imagedata.cpp 6 | * GUI class definitions 7 | ***************************************************************************/ 8 | 9 | #include "gui.h" 10 | 11 | /** 12 | * Constructor for the GuiImageData class. 13 | */ 14 | GuiImageData::GuiImageData(const u8 * img) 15 | { 16 | data = NULL; 17 | width = 0; 18 | height = 0; 19 | 20 | if(img) 21 | { 22 | PNGUPROP imgProp; 23 | IMGCTX ctx = PNGU_SelectImageFromBuffer(img); 24 | 25 | if(!ctx) 26 | return; 27 | 28 | int res = PNGU_GetImageProperties(ctx, &imgProp); 29 | 30 | if(res == PNGU_OK) 31 | { 32 | int len = imgProp.imgWidth * imgProp.imgHeight * 4; 33 | if(len%32) len += (32-len%32); 34 | data = (u8 *)memalign (32, len); 35 | 36 | if(data) 37 | { 38 | res = PNGU_DecodeTo4x4RGBA8 (ctx, imgProp.imgWidth, imgProp.imgHeight, data, 255); 39 | 40 | if(res == PNGU_OK) 41 | { 42 | width = imgProp.imgWidth; 43 | height = imgProp.imgHeight; 44 | DCFlushRange(data, len); 45 | } 46 | else 47 | { 48 | free(data); 49 | data = NULL; 50 | } 51 | } 52 | } 53 | PNGU_ReleaseImageContext (ctx); 54 | } 55 | } 56 | 57 | /** 58 | * Destructor for the GuiImageData class. 59 | */ 60 | GuiImageData::~GuiImageData() 61 | { 62 | if(data) 63 | { 64 | free(data); 65 | data = NULL; 66 | } 67 | } 68 | 69 | u8 * GuiImageData::GetImage() 70 | { 71 | return data; 72 | } 73 | 74 | int GuiImageData::GetWidth() 75 | { 76 | return width; 77 | } 78 | 79 | int GuiImageData::GetHeight() 80 | { 81 | return height; 82 | } 83 | -------------------------------------------------------------------------------- /wii/libwiigui/gui_sound.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui 3 | * Tantric 2009 4 | * 5 | * gui_sound.cpp 6 | * GUI class definitions 7 | ***************************************************************************/ 8 | 9 | #include "gui.h" 10 | 11 | /** 12 | * Constructor for the GuiSound class. 13 | */ 14 | GuiSound::GuiSound(const u8 * snd, s32 len, int t) 15 | { 16 | sound = snd; 17 | length = len; 18 | type = t; 19 | voice = -1; 20 | volume = 100; 21 | loop = false; 22 | } 23 | 24 | /** 25 | * Destructor for the GuiSound class. 26 | */ 27 | GuiSound::~GuiSound() 28 | { 29 | if(type == SOUND_OGG) 30 | StopOgg(); 31 | } 32 | 33 | void GuiSound::Play() 34 | { 35 | int vol; 36 | 37 | switch(type) 38 | { 39 | case SOUND_PCM: 40 | vol = 255*(volume/100.0); 41 | voice = ASND_GetFirstUnusedVoice(); 42 | if(voice >= 0) 43 | ASND_SetVoice(voice, VOICE_STEREO_16BIT, 48000, 0, 44 | (u8 *)sound, length, vol, vol, NULL); 45 | break; 46 | 47 | case SOUND_OGG: 48 | voice = 0; 49 | /* 50 | if(loop) 51 | PlayOgg(mem_open((char *)sound, length), 0, OGG_INFINITE_TIME); 52 | else 53 | PlayOgg(mem_open((char *)sound, length), 0, OGG_ONE_TIME); 54 | SetVolumeOgg(255*(volume/100.0)); 55 | */ 56 | break; 57 | } 58 | } 59 | 60 | void GuiSound::Stop() 61 | { 62 | if(voice < 0) 63 | return; 64 | 65 | switch(type) 66 | { 67 | case SOUND_PCM: 68 | ASND_StopVoice(voice); 69 | break; 70 | 71 | case SOUND_OGG: 72 | StopOgg(); 73 | break; 74 | } 75 | } 76 | 77 | void GuiSound::Pause() 78 | { 79 | if(voice < 0) 80 | return; 81 | 82 | switch(type) 83 | { 84 | case SOUND_PCM: 85 | ASND_PauseVoice(voice, 1); 86 | break; 87 | 88 | case SOUND_OGG: 89 | PauseOgg(1); 90 | break; 91 | } 92 | } 93 | 94 | void GuiSound::Resume() 95 | { 96 | if(voice < 0) 97 | return; 98 | 99 | switch(type) 100 | { 101 | case SOUND_PCM: 102 | ASND_PauseVoice(voice, 0); 103 | break; 104 | 105 | case SOUND_OGG: 106 | PauseOgg(0); 107 | break; 108 | } 109 | } 110 | 111 | bool GuiSound::IsPlaying() 112 | { 113 | if(ASND_StatusVoice(voice) == SND_WORKING || ASND_StatusVoice(voice) == SND_WAITING) 114 | return true; 115 | else 116 | return false; 117 | } 118 | 119 | void GuiSound::SetVolume(int vol) 120 | { 121 | volume = vol; 122 | 123 | if(voice < 0) 124 | return; 125 | 126 | int newvol = 255*(volume/100.0); 127 | 128 | switch(type) 129 | { 130 | case SOUND_PCM: 131 | ASND_ChangeVolumeVoice(voice, newvol, newvol); 132 | break; 133 | 134 | case SOUND_OGG: 135 | SetVolumeOgg(255*(volume/100.0)); 136 | break; 137 | } 138 | } 139 | 140 | void GuiSound::SetLoop(bool l) 141 | { 142 | loop = l; 143 | } 144 | -------------------------------------------------------------------------------- /wii/libwiigui/gui_text.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui 3 | * Tantric 2009 4 | * 5 | * gui_text.cpp 6 | * GUI class definitions 7 | ***************************************************************************/ 8 | 9 | #include "gui.h" 10 | 11 | static int currentSize = 0; 12 | static int presetSize = 0; 13 | static int presetMaxWidth = 0; 14 | static int presetAlignmentHor = 0; 15 | static int presetAlignmentVert = 0; 16 | static u16 presetStyle = 0; 17 | static GXColor presetColor = (GXColor){255, 255, 255, 255}; 18 | 19 | /** 20 | * Constructor for the GuiText class. 21 | */ 22 | GuiText::GuiText(const char * t, int s, GXColor c) 23 | { 24 | text = NULL; 25 | size = s; 26 | color = c; 27 | alpha = c.a; 28 | style = FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE; 29 | maxWidth = 0; 30 | 31 | alignmentHor = ALIGN_CENTRE; 32 | alignmentVert = ALIGN_MIDDLE; 33 | 34 | if(t) 35 | text = fontSystem->charToWideChar((char *)t); 36 | } 37 | 38 | /** 39 | * Constructor for the GuiText class, uses presets 40 | */ 41 | GuiText::GuiText(const char * t) 42 | { 43 | text = NULL; 44 | size = presetSize; 45 | color = presetColor; 46 | alpha = presetColor.a; 47 | style = presetStyle; 48 | maxWidth = presetMaxWidth; 49 | 50 | alignmentHor = presetAlignmentHor; 51 | alignmentVert = presetAlignmentVert; 52 | 53 | if(t) 54 | text = fontSystem->charToWideChar((char *)t); 55 | } 56 | 57 | /** 58 | * Destructor for the GuiText class. 59 | */ 60 | GuiText::~GuiText() 61 | { 62 | if(text) 63 | { 64 | delete text; 65 | text = NULL; 66 | } 67 | } 68 | 69 | void GuiText::SetText(const char * t) 70 | { 71 | if(text) 72 | delete text; 73 | 74 | text = NULL; 75 | 76 | if(t) 77 | text = fontSystem->charToWideChar((char *)t); 78 | } 79 | 80 | void GuiText::SetPresets(int sz, GXColor c, int w, u16 s, int h, int v) 81 | { 82 | presetSize = sz; 83 | presetColor = c; 84 | presetStyle = s; 85 | presetMaxWidth = w; 86 | presetAlignmentHor = h; 87 | presetAlignmentVert = v; 88 | } 89 | 90 | void GuiText::SetFontSize(int s) 91 | { 92 | size = s; 93 | } 94 | 95 | void GuiText::SetMaxWidth(int w) 96 | { 97 | maxWidth = w; 98 | } 99 | 100 | void GuiText::SetColor(GXColor c) 101 | { 102 | color = c; 103 | alpha = c.a; 104 | } 105 | 106 | void GuiText::SetStyle(u16 s) 107 | { 108 | style = s; 109 | } 110 | 111 | void GuiText::SetAlignment(int hor, int vert) 112 | { 113 | style = 0; 114 | 115 | switch(hor) 116 | { 117 | case ALIGN_LEFT: 118 | style |= FTGX_JUSTIFY_LEFT; 119 | break; 120 | case ALIGN_RIGHT: 121 | style |= FTGX_JUSTIFY_RIGHT; 122 | break; 123 | default: 124 | style |= FTGX_JUSTIFY_CENTER; 125 | break; 126 | } 127 | switch(vert) 128 | { 129 | case ALIGN_TOP: 130 | style |= FTGX_ALIGN_TOP; 131 | break; 132 | case ALIGN_BOTTOM: 133 | style |= FTGX_ALIGN_BOTTOM; 134 | break; 135 | default: 136 | style |= FTGX_ALIGN_MIDDLE; 137 | break; 138 | } 139 | 140 | alignmentHor = hor; 141 | alignmentVert = vert; 142 | } 143 | 144 | /** 145 | * Draw the text on screen 146 | */ 147 | void GuiText::Draw() 148 | { 149 | if(!text) 150 | return; 151 | 152 | if(!this->IsVisible()) 153 | return; 154 | 155 | GXColor c = color; 156 | c.a = this->GetAlpha(); 157 | 158 | int newSize = size*this->GetScale(); 159 | 160 | if(newSize != currentSize) 161 | { 162 | fontSystem->changeSize(newSize); 163 | currentSize = newSize; 164 | } 165 | 166 | int voffset = 0; 167 | 168 | if(alignmentVert == ALIGN_MIDDLE) 169 | voffset = -newSize/2 + 2; 170 | 171 | if(maxWidth > 0) // text wrapping 172 | { 173 | int lineheight = newSize + 6; 174 | int strlen = wcslen(text); 175 | int i = 0; 176 | int ch = 0; 177 | int linenum = 0; 178 | int lastSpace = -1; 179 | int lastSpaceIndex = -1; 180 | wchar_t * tmptext[20]; 181 | 182 | while(ch < strlen) 183 | { 184 | if(i == 0) 185 | tmptext[linenum] = new wchar_t[strlen + 1]; 186 | 187 | tmptext[linenum][i] = text[ch]; 188 | tmptext[linenum][i+1] = 0; 189 | 190 | if(text[ch] == ' ' || ch == strlen-1) 191 | { 192 | if(fontSystem->getWidth(tmptext[linenum]) >= maxWidth) 193 | { 194 | if(lastSpace >= 0) 195 | { 196 | tmptext[linenum][lastSpaceIndex] = 0; // discard space, and everything after 197 | ch = lastSpace; // go backwards to the last space 198 | lastSpace = -1; // we have used this space 199 | lastSpaceIndex = -1; 200 | } 201 | linenum++; 202 | i = -1; 203 | } 204 | else if(ch == strlen-1) 205 | { 206 | linenum++; 207 | } 208 | } 209 | if(text[ch] == ' ' && i >= 0) 210 | { 211 | lastSpace = ch; 212 | lastSpaceIndex = i; 213 | } 214 | ch++; 215 | i++; 216 | } 217 | 218 | if(alignmentVert == ALIGN_MIDDLE) 219 | voffset = voffset - (lineheight*linenum)/2 + lineheight/2; 220 | 221 | for(i=0; i < linenum; i++) 222 | { 223 | fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, tmptext[i], c, style); 224 | delete tmptext[i]; 225 | } 226 | } 227 | else 228 | { 229 | fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset, text, c, style); 230 | } 231 | this->UpdateEffects(); 232 | } 233 | -------------------------------------------------------------------------------- /wii/libwiigui/gui_trigger.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui 3 | * Tantric 2009 4 | * 5 | * gui_trigger.cpp 6 | * GUI class definitions 7 | ***************************************************************************/ 8 | 9 | #include "gui.h" 10 | 11 | static int scrollDelay = 0; 12 | 13 | /** 14 | * Constructor for the GuiTrigger class. 15 | */ 16 | GuiTrigger::GuiTrigger() 17 | { 18 | chan = -1; 19 | memset(&wpad, 0, sizeof(WPADData)); 20 | memset(&pad, 0, sizeof(PADData)); 21 | } 22 | 23 | /** 24 | * Destructor for the GuiTrigger class. 25 | */ 26 | GuiTrigger::~GuiTrigger() 27 | { 28 | } 29 | 30 | /** 31 | * Sets a simple trigger. Requires: 32 | * - Element is selected 33 | * - Trigger button is pressed 34 | */ 35 | void GuiTrigger::SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns) 36 | { 37 | type = TRIGGER_SIMPLE; 38 | chan = ch; 39 | wpad.btns_d = wiibtns; 40 | pad.btns_d = gcbtns; 41 | } 42 | 43 | /** 44 | * Sets a button trigger. Requires: 45 | * - Trigger button is pressed 46 | */ 47 | void GuiTrigger::SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns) 48 | { 49 | type = TRIGGER_BUTTON_ONLY; 50 | chan = ch; 51 | wpad.btns_d = wiibtns; 52 | pad.btns_d = gcbtns; 53 | } 54 | 55 | /** 56 | * Sets a button trigger. Requires: 57 | * - Trigger button is pressed 58 | * - Parent window is in focus 59 | */ 60 | void GuiTrigger::SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns) 61 | { 62 | type = TRIGGER_BUTTON_ONLY_IN_FOCUS; 63 | chan = ch; 64 | wpad.btns_d = wiibtns; 65 | pad.btns_d = gcbtns; 66 | } 67 | 68 | /**************************************************************************** 69 | * WPAD_Stick 70 | * 71 | * Get X/Y value from Wii Joystick (classic, nunchuk) input 72 | ***************************************************************************/ 73 | 74 | s8 GuiTrigger::WPAD_Stick(u8 right, int axis) 75 | { 76 | #ifdef HW_RVL 77 | 78 | float mag = 0.0; 79 | float ang = 0.0; 80 | 81 | switch (wpad.exp.type) 82 | { 83 | case WPAD_EXP_NUNCHUK: 84 | case WPAD_EXP_GUITARHERO3: 85 | if (right == 0) 86 | { 87 | mag = wpad.exp.nunchuk.js.mag; 88 | ang = wpad.exp.nunchuk.js.ang; 89 | } 90 | break; 91 | 92 | case WPAD_EXP_CLASSIC: 93 | if (right == 0) 94 | { 95 | mag = wpad.exp.classic.ljs.mag; 96 | ang = wpad.exp.classic.ljs.ang; 97 | } 98 | else 99 | { 100 | mag = wpad.exp.classic.rjs.mag; 101 | ang = wpad.exp.classic.rjs.ang; 102 | } 103 | break; 104 | 105 | default: 106 | break; 107 | } 108 | 109 | /* calculate x/y value (angle need to be converted into radian) */ 110 | if (mag > 1.0) mag = 1.0; 111 | else if (mag < -1.0) mag = -1.0; 112 | double val; 113 | 114 | if(axis == 0) // x-axis 115 | val = mag * sin((PI * ang)/180.0f); 116 | else // y-axis 117 | val = mag * cos((PI * ang)/180.0f); 118 | 119 | return (s8)(val * 128.0f); 120 | 121 | #else 122 | return 0; 123 | #endif 124 | } 125 | 126 | bool GuiTrigger::Left() 127 | { 128 | u32 wiibtn = WPAD_BUTTON_LEFT; 129 | 130 | if((wpad.btns_d | wpad.btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT) 131 | || (pad.btns_d | pad.btns_h) & PAD_BUTTON_LEFT 132 | || pad.stickX < -PADCAL 133 | || WPAD_Stick(0,0) < -PADCAL) 134 | { 135 | if(wpad.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_LEFT) 136 | || pad.btns_d & PAD_BUTTON_LEFT) 137 | { 138 | scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay. 139 | return true; 140 | } 141 | else if(scrollDelay == 0) 142 | { 143 | scrollDelay = SCROLL_LOOP_DELAY; 144 | return true; 145 | } 146 | else 147 | { 148 | scrollDelay--; 149 | } 150 | } 151 | return false; 152 | } 153 | 154 | bool GuiTrigger::Right() 155 | { 156 | u32 wiibtn = WPAD_BUTTON_RIGHT; 157 | 158 | if((wpad.btns_d | wpad.btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT) 159 | || (pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT 160 | || pad.stickX > PADCAL 161 | || WPAD_Stick(0,0) > PADCAL) 162 | { 163 | if(wpad.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT) 164 | || pad.btns_d & PAD_BUTTON_RIGHT) 165 | { 166 | scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay. 167 | return true; 168 | } 169 | else if(scrollDelay == 0) 170 | { 171 | scrollDelay = SCROLL_LOOP_DELAY; 172 | return true; 173 | } 174 | else 175 | { 176 | scrollDelay--; 177 | } 178 | } 179 | return false; 180 | } 181 | 182 | bool GuiTrigger::Up() 183 | { 184 | u32 wiibtn = WPAD_BUTTON_UP; 185 | 186 | if((wpad.btns_d | wpad.btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_UP) 187 | || (pad.btns_d | pad.btns_h) & PAD_BUTTON_UP 188 | || pad.stickY > PADCAL 189 | || WPAD_Stick(0,1) > PADCAL) 190 | { 191 | if(wpad.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_UP) 192 | || pad.btns_d & PAD_BUTTON_UP) 193 | { 194 | scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay. 195 | return true; 196 | } 197 | else if(scrollDelay == 0) 198 | { 199 | scrollDelay = SCROLL_LOOP_DELAY; 200 | return true; 201 | } 202 | else 203 | { 204 | scrollDelay--; 205 | } 206 | } 207 | return false; 208 | } 209 | 210 | bool GuiTrigger::Down() 211 | { 212 | u32 wiibtn = WPAD_BUTTON_DOWN; 213 | 214 | if((wpad.btns_d | wpad.btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN) 215 | || (pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN 216 | || pad.stickY < -PADCAL 217 | || WPAD_Stick(0,1) < -PADCAL) 218 | { 219 | if(wpad.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN) 220 | || pad.btns_d & PAD_BUTTON_DOWN) 221 | { 222 | scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay. 223 | return true; 224 | } 225 | else if(scrollDelay == 0) 226 | { 227 | scrollDelay = SCROLL_LOOP_DELAY; 228 | return true; 229 | } 230 | else 231 | { 232 | scrollDelay--; 233 | } 234 | } 235 | return false; 236 | } 237 | -------------------------------------------------------------------------------- /wii/mad_decoder/Buffer.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | Buffer.c - A C-style buffer object 3 | ------------------- 4 | begin : Thu Jun 19 2003 5 | copyright : (C) 2003 by Tyler Montbriand 6 | email : tsm@accesscomm.ca 7 | ***************************************************************************/ 8 | 9 | /*************************************************************************** 10 | * * 11 | * This program is free software; you can redistribute it and/or modify * 12 | * it under the terms of the GNU General Public License as published by * 13 | * the Free Software Foundation; either version 2 of the License, or * 14 | * (at your option) any later version. * 15 | * * 16 | ***************************************************************************/ 17 | #include "buffer.h" 18 | #include <stdlib.h> 19 | #include <string.h> 20 | #include <SDL/SDL_rwops.h> 21 | 22 | void Buffer_Clear(Buffer *buf) 23 | { 24 | if(buf!=NULL) buf->pos=0; 25 | } 26 | 27 | size_t Buffer_KeepOnly(Buffer *buf, size_t pos, size_t len) 28 | { 29 | size_t lastpos; 30 | if(buf==NULL) return(-1); 31 | 32 | lastpos=pos+len; 33 | 34 | if(len<0) 35 | { 36 | pos+=len; 37 | len=-len; 38 | } 39 | 40 | if(lastpos>buf->pos) return(-1); /* out of bounds */ 41 | else if(pos<0) return(-1); /* out of bounds */ 42 | 43 | memmove(buf->data,buf->data+pos,len); 44 | buf->pos=len; 45 | return(0); 46 | } 47 | 48 | 49 | size_t Buffer_ReadFromRW(Buffer *buf,SDL_RWops *rw) 50 | { 51 | size_t space; 52 | size_t bytes_read; 53 | if(rw==NULL) return(-1); 54 | 55 | space=Buffer_Space(buf); 56 | if(space<=0) return(-1); 57 | 58 | bytes_read=SDL_RWread(rw,buf->data + buf->pos,1,space); 59 | if(bytes_read<=0) return(-1); 60 | 61 | else 62 | { 63 | buf->pos+=bytes_read; 64 | return(bytes_read); 65 | } 66 | } 67 | 68 | size_t Buffer_Space(Buffer *buf) 69 | { 70 | if(buf==NULL) return(-1); 71 | else return(buf->size-buf->pos); 72 | } 73 | 74 | size_t Buffer_Write(Buffer *buf,void *data,size_t bytes) 75 | { 76 | size_t space; 77 | if((data==NULL)||(bytes<=0)) return(-1); 78 | 79 | space=Buffer_Space(buf); 80 | 81 | if(space<=0) return(-1); 82 | if(space>bytes) space=bytes; 83 | 84 | memcpy(buf->data+buf->pos,data,space); 85 | buf->pos+=space; 86 | 87 | return(space); 88 | } 89 | 90 | Buffer * Buffer_Create(size_t size) 91 | { 92 | Buffer *buf=(Buffer *)malloc(sizeof(Buffer)); 93 | if(buf==NULL) return(NULL); 94 | 95 | buf->data=(char*)malloc(size); 96 | if(buf->data==NULL) 97 | { 98 | free(buf); 99 | return(NULL); 100 | } 101 | buf->size=size; 102 | buf->pos=0; 103 | return(buf); 104 | } 105 | 106 | void Buffer_Free(Buffer *buf) 107 | { 108 | if(buf!=NULL) 109 | { 110 | if(buf->data!=NULL) free(buf->data); 111 | free(buf); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /wii/mad_decoder/buffer.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | buffer.h - description 3 | ------------------- 4 | begin : Thu Jun 19 2003 5 | copyright : (C) 2003 by Tyler Montbriand 6 | email : tsm@accesscomm.ca 7 | ***************************************************************************/ 8 | 9 | /*************************************************************************** 10 | * * 11 | * This program is free software; you can redistribute it and/or modify * 12 | * it under the terms of the GNU General Public License as published by * 13 | * the Free Software Foundation; either version 2 of the License, or * 14 | * (at your option) any later version. * 15 | * * 16 | ***************************************************************************/ 17 | 18 | #ifndef __BUFFER_H__ 19 | #define __BUFFER_H__ 20 | 21 | #include <stdio.h> 22 | #include <SDL/SDL_types.h> 23 | #include <SDL/SDL_rwops.h> 24 | #include <SDL/begin_code.h> 25 | 26 | typedef struct Buffer 27 | { 28 | char *data; 29 | size_t size; 30 | size_t pos; 31 | } Buffer; 32 | 33 | 34 | DECLSPEC Buffer *SDLCALL Buffer_Create(size_t); 35 | DECLSPEC size_t SDLCALL Buffer_Write(Buffer *,void *,size_t); 36 | DECLSPEC void SDLCALL Buffer_Clear(Buffer *); 37 | DECLSPEC size_t SDLCALL Buffer_KeepOnly(Buffer *, size_t pos, size_t len); 38 | DECLSPEC size_t SDLCALL Buffer_Space(Buffer *); 39 | DECLSPEC void SDLCALL Buffer_Free(Buffer *); 40 | DECLSPEC size_t SDLCALL Buffer_ReadFromRW(Buffer *buf,SDL_RWops *rw); 41 | 42 | #include <SDL/close_code.h> 43 | 44 | #endif/*__BUFFER_H__*/ 45 | -------------------------------------------------------------------------------- /wii/mad_decoder/mad_convert.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | mad_convert.c - description 3 | ------------------- 4 | begin : Fri Jun 20 2003 5 | copyright : (C) 2003 by Tyler Montbriand 6 | email : tsm@accesscomm.ca 7 | ***************************************************************************/ 8 | 9 | /*************************************************************************** 10 | * * 11 | * This program is free software; you can redistribute it and/or modify * 12 | * it under the terms of the GNU General Public License as published by * 13 | * the Free Software Foundation; either version 2 of the License, or * 14 | * (at your option) any later version. * 15 | * * 16 | ***************************************************************************/ 17 | #include "mad_decode.h" 18 | #include "mad_internal.h" 19 | 20 | static unsigned short MadFixedToUshort(mad_fixed_t Fixed); 21 | 22 | MAD_phase_t MAD_Convert(MAD_decoder *dec, Sint16 *buffer, int *startpos, 23 | int size_in,int channels) 24 | { 25 | int pos=(*startpos)/2; 26 | int sample; 27 | int size=size_in/2; 28 | 29 | if((dec==NULL)||(buffer==NULL)||(startpos==NULL)) return(MAD_PHASE_DONE); 30 | if((channels<1)||(channels>2)) return(MAD_PHASE_DONE); 31 | if(size<=0) 32 | { 33 | fprintf(stderr,"MAD_Convert - 0 size given\n"); 34 | return(MAD_PHASE_DONE); 35 | } 36 | 37 | sample=dec->FrameSamplesUsed; 38 | 39 | if(channels==1) 40 | { 41 | if(MAD_NCHANNELS(&dec->Frame.header)==2) 42 | { 43 | while((pos<size)&&(sample<dec->Synth.pcm.length)) 44 | { 45 | int val=MadFixedToUshort(dec->Synth.pcm.samples[0][sample]); 46 | val+=MadFixedToUshort(dec->Synth.pcm.samples[1][sample]); 47 | val=val>>1; 48 | buffer[pos]=val; 49 | 50 | pos++; 51 | sample++; 52 | } 53 | } 54 | else 55 | { 56 | while((pos<size)&&(sample<dec->Synth.pcm.length)) 57 | { 58 | buffer[pos]=MadFixedToUshort(dec->Synth.pcm.samples[0][sample]); 59 | pos++; 60 | sample++; 61 | } 62 | } 63 | } 64 | else /* Stereo output */ 65 | { 66 | if(MAD_NCHANNELS(&dec->Frame.header)==2) 67 | { 68 | while((pos<size)&&(sample<dec->Synth.pcm.length)) 69 | { 70 | buffer[pos]=MadFixedToUshort(dec->Synth.pcm.samples[0][sample]); 71 | buffer[pos+1]=MadFixedToUshort(dec->Synth.pcm.samples[1][sample]); 72 | pos+=2; 73 | sample++; 74 | } 75 | } 76 | else 77 | { 78 | while((pos<size)&&(sample<dec->Synth.pcm.length)) 79 | { 80 | buffer[pos]=MadFixedToUshort(dec->Synth.pcm.samples[0][sample]); 81 | buffer[pos+1]=buffer[pos]; 82 | pos+=2; 83 | sample++; 84 | } 85 | } 86 | } 87 | 88 | 89 | (*startpos)=pos*2; 90 | 91 | if(sample==dec->Synth.pcm.length) 92 | { 93 | dec->FrameSamplesUsed=0; 94 | return(MAD_PHASE_FRAME); 95 | } 96 | else 97 | { 98 | dec->FrameSamplesUsed=sample; 99 | return(MAD_PHASE_CONVERT); 100 | } 101 | } 102 | 103 | 104 | /**************************************************************************** 105 | * Converts a sample from mad's fixed point number format to an unsigned * 106 | * short (16 bits). * 107 | ****************************************************************************/ 108 | static unsigned short MadFixedToUshort(mad_fixed_t Fixed) 109 | { 110 | /* A fixed point number is formed of the following bit pattern: 111 | * 112 | * SWWWFFFFFFFFFFFFFFFFFFFFFFFFFFFF 113 | * MSB LSB 114 | * S ==> Sign (0 is positive, 1 is negative) 115 | * W ==> Whole part bits 116 | * F ==> Fractional part bits 117 | * 118 | * This pattern contains MAD_F_FRACBITS fractional bits, one 119 | * should alway use this macro when working on the bits of a fixed 120 | * point number. It is not guaranteed to be constant over the 121 | * different platforms supported by libmad. 122 | * 123 | * The unsigned short value is formed by the least significant 124 | * whole part bit, followed by the 15 most significant fractional 125 | * part bits. Warning: this is a quick and dirty way to compute 126 | * the 16-bit number, madplay includes much better algorithms. 127 | */ 128 | Fixed=Fixed>>(MAD_F_FRACBITS-15); 129 | return((unsigned short)Fixed); 130 | } 131 | -------------------------------------------------------------------------------- /wii/mad_decoder/mad_decode.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | mad_decode.c 3 | A non-braindead implementation of an MP3 decoder using libmad, 4 | with SDL_RWops support. 5 | ------------------- 6 | begin : Fri Jun 20 2003 7 | copyright : (C) 2003 by Tyler Montbriand 8 | email : tsm@accesscomm.ca 9 | ***************************************************************************/ 10 | 11 | /*************************************************************************** 12 | * * 13 | * This program is free software; you can redistribute it and/or modify * 14 | * it under the terms of the GNU General Public License as published by * 15 | * the Free Software Foundation; either version 2 of the License, or * 16 | * (at your option) any later version. * 17 | * * 18 | ***************************************************************************/ 19 | 20 | #include <stdlib.h> 21 | #include <string.h> 22 | #include <SDL.h> 23 | #include "mad_decode.h" 24 | #include "mad_internal.h" 25 | 26 | /* Strings to correspond to MAD_phase_t values. */ 27 | const char *PhaseNames[]={"MAD_PHASE_STREAM","MAD_PHASE_FRAME", 28 | "MAD_PHASE_CONVERT","MAD_PHASE_DONE",NULL}; 29 | 30 | 31 | /* Sets dec->Phase, and prints a warning message if 32 | setting dec->Phase to MAD_PHASE_DONE. */ 33 | static void SetPhase(MAD_decoder *dec, MAD_phase_t phase); 34 | 35 | void MAD_play( MAD_decoder *dec ) 36 | { 37 | dec->Playing = true; 38 | } 39 | 40 | void MAD_stop( MAD_decoder *dec ) 41 | { 42 | dec->Playing = false; 43 | } 44 | 45 | bool MAD_playing( MAD_decoder *dec ) 46 | { 47 | return dec->Playing; 48 | } 49 | 50 | void MAD_setvolume( MAD_decoder *dec, int volume ) 51 | { 52 | if ( (volume >= 0) && (volume <= 100) ) { 53 | dec->Volume = (volume * SDL_MIX_MAXVOLUME) / 100; 54 | } 55 | } 56 | 57 | int MAD_Decode(MAD_decoder *dec, Uint8 *buffer, size_t size,int channels) 58 | { 59 | int bytes=0; /* Number of bytes of audio output decoded */ 60 | Uint8 *output; 61 | /* Sanity checking */ 62 | if((dec==NULL)||(buffer==NULL)||(size<=0)) return(-1); 63 | 64 | if ( !dec->Playing ) return -1; 65 | 66 | output = (Uint8 *)malloc(size); 67 | 68 | while(bytes<size) /* Loop until 'size' bytes decoded, or error */ 69 | switch(dec->Phase) 70 | { 71 | case MAD_PHASE_STREAM: /* Reading raw data from file */ 72 | SetPhase(dec,MAD_PushStream(dec)); 73 | break; 74 | 75 | case MAD_PHASE_FRAME: /* Reading frames from raw data */ 76 | SetPhase(dec,MAD_GetFrame(dec)); 77 | break; 78 | 79 | case MAD_PHASE_CONVERT: /* Converting frames to 16-bit PCM data */ 80 | SetPhase(dec,MAD_Convert(dec,(Sint16 *)output,&bytes,size,channels)); 81 | break; 82 | 83 | case MAD_PHASE_DONE: /* Out of data, or fatal error */ 84 | return(-1); 85 | 86 | default: /* Should't happen */ 87 | fprintf(stderr,"Unknown phase %d\n",dec->Phase); 88 | fprintf(stderr,"Email me at tsm@accesscomm.ca and tell me how you did this\n"); 89 | abort(); 90 | break; 91 | } 92 | 93 | if (bytes < size) 94 | memset(output + bytes, 0, size - bytes); 95 | 96 | SDL_MixAudio( buffer, output, size, dec->Volume ); 97 | free(output); 98 | 99 | return bytes; 100 | } 101 | 102 | void MAD_Free(MAD_decoder *decoder) 103 | { 104 | if(decoder==NULL) return; 105 | 106 | /* Deinitialize MAD */ 107 | mad_synth_finish(&(decoder->Synth)); 108 | mad_frame_finish(&(decoder->Frame)); 109 | mad_stream_finish(&(decoder->Stream)); 110 | 111 | if(decoder->buf!=NULL) Buffer_Free(decoder->buf); 112 | 113 | if((decoder->FreeRW)&&(decoder->Source!=NULL)) 114 | SDL_FreeRW(decoder->Source); 115 | 116 | free(decoder); 117 | } 118 | 119 | MAD_decoder *MAD_CreateDecoder(const char *fname, size_t bufsize) 120 | { 121 | SDL_RWops *source=SDL_RWFromFile(fname,"rb"); 122 | 123 | if(source==NULL) 124 | { 125 | return(NULL); 126 | } 127 | else 128 | { 129 | return(MAD_CreateDecoder_RW(source,bufsize,1)); 130 | } 131 | } 132 | 133 | MAD_decoder *MAD_CreateDecoder_RW(SDL_RWops *rwIn, size_t buffersize, int freerw) 134 | { 135 | MAD_decoder *decoder=NULL; 136 | 137 | if(rwIn==NULL) return(NULL); 138 | 139 | decoder=(MAD_decoder *)malloc(sizeof(MAD_decoder)); 140 | if(decoder==NULL) return(NULL); 141 | 142 | memset(decoder,0,sizeof(MAD_decoder)); 143 | 144 | decoder->buf=Buffer_Create(buffersize); 145 | if(decoder->buf==NULL) 146 | { 147 | free(decoder); 148 | return(NULL); 149 | } 150 | decoder->Phase=MAD_PHASE_STREAM; 151 | decoder->Source=rwIn; 152 | decoder->FreeRW=freerw; 153 | decoder->FrameCount=0; 154 | decoder->Playing = 0; 155 | decoder->Volume = 75; 156 | 157 | /* Initialize MAD */ 158 | mad_stream_init(&(decoder->Stream)); 159 | mad_frame_init(&(decoder->Frame)); 160 | mad_synth_init(&(decoder->Synth)); 161 | mad_timer_reset((&decoder->Timer)); 162 | 163 | return(decoder); 164 | } 165 | 166 | static void SetPhase(MAD_decoder *dec, MAD_phase_t phase) 167 | { 168 | if(phase==MAD_PHASE_DONE) 169 | { 170 | fprintf(stderr,"Going from %s to %s\n", 171 | PhaseNames[dec->Phase],PhaseNames[phase]); 172 | } 173 | 174 | dec->Phase=phase; 175 | } 176 | -------------------------------------------------------------------------------- /wii/mad_decoder/mad_decode.h: -------------------------------------------------------------------------------- 1 | #ifndef __MAD_DECODE_H__ 2 | #define __MAD_DECODE_H__ 3 | 4 | #include "mad.h" 5 | #include "buffer.h" 6 | 7 | #include <SDL/begin_code.h> 8 | 9 | struct MAD_decoder; 10 | 11 | DECLSPEC void SDLCALL MAD_play(struct MAD_decoder *dec ); 12 | DECLSPEC void SDLCALL MAD_stop(struct MAD_decoder *dec ); 13 | DECLSPEC bool SDLCALL MAD_playing(struct MAD_decoder *dec ); 14 | DECLSPEC void SDLCALL MAD_setvolume(struct MAD_decoder *dec, int volume ); 15 | DECLSPEC int SDLCALL MAD_Decode(struct MAD_decoder *decoder, Uint8 *buffer, size_t bytes, int channels); 16 | DECLSPEC void SDLCALL MAD_Free(struct MAD_decoder *decoder); 17 | 18 | /* Convenience function, create a MAD decoder from filename */ 19 | DECLSPEC struct MAD_decoder * SDLCALL MAD_CreateDecoder(const char *fname, size_t bufsize); 20 | /* Create a MAD decoder from a SDL_RWops stream */ 21 | DECLSPEC struct MAD_decoder * SDLCALL MAD_CreateDecoder_RW(SDL_RWops *rwIn, size_t buffersize, int freerw); 22 | 23 | #include <SDL/close_code.h> 24 | 25 | #endif/*__MAD_DECODE_H__*/ 26 | -------------------------------------------------------------------------------- /wii/mad_decoder/mad_frame.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | mad_frame.c - description 3 | ------------------- 4 | begin : Fri Jun 20 2003 5 | copyright : (C) 2003 by Tyler Montbriand 6 | email : tsm@accesscomm.ca 7 | ***************************************************************************/ 8 | 9 | /*************************************************************************** 10 | * * 11 | * This program is free software; you can redistribute it and/or modify * 12 | * it under the terms of the GNU General Public License as published by * 13 | * the Free Software Foundation; either version 2 of the License, or * 14 | * (at your option) any later version. * 15 | * * 16 | ***************************************************************************/ 17 | #include "mad_decode.h" 18 | #include "mad_internal.h" 19 | 20 | MAD_phase_t MAD_GetFrame(MAD_decoder *dec) 21 | { 22 | if(dec==NULL) return(MAD_PHASE_ERROR); 23 | 24 | if(mad_frame_decode(&dec->Frame,&dec->Stream)) /* Error? */ 25 | { 26 | if(MAD_RECOVERABLE(dec->Stream.error)) 27 | { 28 | fprintf(stderr,"Error in stream, proceeding to next frame\n"); 29 | return(MAD_PHASE_FRAME); 30 | } 31 | else if(dec->Stream.error==MAD_ERROR_BUFLEN) 32 | { 33 | return(MAD_PHASE_STREAM); 34 | } 35 | else 36 | { 37 | fprintf(stderr,"Irrecoverable error\n"); 38 | return(MAD_PHASE_DONE); 39 | } 40 | } 41 | else /* Valid frame */ 42 | { 43 | dec->FrameCount++; /* Increment frame count */ 44 | /* Keep track of timing */ 45 | mad_timer_add(&dec->Timer,dec->Frame.header.duration); 46 | /* Convert the frame to sound data */ 47 | mad_synth_frame(&dec->Synth,&dec->Frame); 48 | dec->FrameSamplesUsed=0; /* Set to start of frame */ 49 | 50 | return(MAD_PHASE_CONVERT); /* Lets go next phase */ 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /wii/mad_decoder/mad_internal.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | mad_internal.h - description 3 | ------------------- 4 | begin : Fri Jun 20 2003 5 | copyright : (C) 2003 by Tyler Montbriand 6 | email : tsm@accesscomm.ca 7 | ***************************************************************************/ 8 | 9 | /*************************************************************************** 10 | * * 11 | * This program is free software; you can redistribute it and/or modify * 12 | * it under the terms of the GNU General Public License as published by * 13 | * the Free Software Foundation; either version 2 of the License, or * 14 | * (at your option) any later version. * 15 | * * 16 | ***************************************************************************/ 17 | #ifndef __MAD_INTERNAL_H__ 18 | #define __MAD_INTERNAL_H__ 19 | 20 | extern const char *PhaseNames[]; 21 | 22 | typedef enum MAD_phase_t 23 | { 24 | MAD_PHASE_ERROR=-1, 25 | MAD_PHASE_STREAM=0, 26 | MAD_PHASE_FRAME, 27 | MAD_PHASE_CONVERT, 28 | MAD_PHASE_DONE 29 | } MAD_phase_t; 30 | 31 | typedef struct MAD_decoder 32 | { 33 | struct mad_stream Stream; 34 | struct mad_frame Frame; 35 | struct mad_synth Synth; 36 | mad_timer_t Timer; 37 | enum MAD_phase_t Phase; 38 | int FrameCount; 39 | 40 | SDL_RWops *Source; 41 | int Volume; 42 | bool Playing; 43 | int FreeRW; 44 | Buffer *buf; 45 | int FrameSamplesUsed; 46 | } MAD_decoder; 47 | 48 | 49 | extern MAD_phase_t MAD_PushStream(MAD_decoder *dec); 50 | extern MAD_phase_t MAD_GetFrame(MAD_decoder *dec); 51 | extern MAD_phase_t MAD_Convert(MAD_decoder *dec, Sint16 *buffer, 52 | int *startpos, int size, int channels); 53 | 54 | #endif/*__MAD_INTERNAL_H__*/ 55 | -------------------------------------------------------------------------------- /wii/mad_decoder/mad_stream.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | mad_stream.c - description 3 | ------------------- 4 | begin : Fri Jun 20 2003 5 | copyright : (C) 2003 by Tyler Montbriand 6 | email : tsm@accesscomm.ca 7 | ***************************************************************************/ 8 | 9 | /*************************************************************************** 10 | * * 11 | * This program is free software; you can redistribute it and/or modify * 12 | * it under the terms of the GNU General Public License as published by * 13 | * the Free Software Foundation; either version 2 of the License, or * 14 | * (at your option) any later version. * 15 | * * 16 | ***************************************************************************/ 17 | #include <stdlib.h> 18 | #include "mad_decode.h" 19 | #include "mad_internal.h" 20 | 21 | static int MAD_GetInputData(MAD_decoder *decoder); 22 | 23 | MAD_phase_t MAD_PushStream(MAD_decoder *dec) 24 | { 25 | if(dec==NULL) return(MAD_PHASE_DONE); 26 | 27 | /* Stream needs more data */ 28 | if(dec->Stream.buffer==NULL || dec->Stream.error==MAD_ERROR_BUFLEN) 29 | { 30 | 31 | if(dec->Stream.next_frame==NULL) /* All-new data */ 32 | { 33 | Buffer_Clear(dec->buf); 34 | 35 | if(MAD_GetInputData(dec)<0) 36 | if(MAD_GetInputData(dec)<0) 37 | { 38 | fprintf(stderr,"MAD_PushStream - Input error\n"); 39 | return(MAD_PHASE_DONE); 40 | } 41 | } 42 | else /* Little bit left in buffer */ 43 | { 44 | int Remaining=dec->Stream.bufend-dec->Stream.next_frame; 45 | if(Buffer_KeepOnly(dec->buf,dec->buf->pos-Remaining,Remaining)<0) 46 | { 47 | abort(); 48 | } 49 | 50 | if(MAD_GetInputData(dec)<0) 51 | if(MAD_GetInputData(dec)<0) 52 | { 53 | fprintf(stderr,"MAD_PushStream - Input error\n"); 54 | return(MAD_PHASE_DONE); 55 | } 56 | } 57 | 58 | mad_stream_buffer(&dec->Stream, (const u8*)dec->buf->data,dec->buf->pos); 59 | } 60 | 61 | return(MAD_PHASE_FRAME); 62 | } 63 | 64 | static int MAD_GetInputData(MAD_decoder *decoder) 65 | { 66 | if(decoder==NULL) 67 | return(-1); 68 | else 69 | return(Buffer_ReadFromRW(decoder->buf,decoder->Source)); 70 | } 71 | -------------------------------------------------------------------------------- /wii/menu.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui Template 3 | * Tantric 2009 4 | * 5 | * menu.h 6 | * Menu flow routines - handles all menu logic 7 | ***************************************************************************/ 8 | 9 | #ifndef _MENU_H_ 10 | #define _MENU_H_ 11 | 12 | #include <ogcsys.h> 13 | #include "ONScripterLabel.h" 14 | 15 | int MainMenu(ONScripterLabel *ons); 16 | 17 | enum 18 | { 19 | JAPANESE, 20 | ENGLISH, 21 | }; 22 | 23 | enum 24 | { 25 | MENU_EXIT = -1, 26 | MENU_NONE, 27 | MENU_GAME_SEL, 28 | MENU_GAME_ADD, 29 | MENU_GAME_LAUNCH, 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /wii/oggplayer.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/oggplayer.c -------------------------------------------------------------------------------- /wii/oggplayer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/oggplayer.h -------------------------------------------------------------------------------- /wii/setting_parser.cpp: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * setting_parser.cpp -- parses list of installed games on WII 4 | * 5 | * Copyright (c) 2009 Brian. All rights reserved. 6 | * 7 | * brijohn@gmail.com 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "setting_parser.h" 25 | 26 | struct xml_settings_s { 27 | mxml_node_t *root; 28 | mxml_index_t *index; 29 | }; 30 | 31 | xml_settings_t *open_settings() 32 | { 33 | FILE *fd; 34 | xml_settings_t *s; 35 | s = (struct xml_settings_s *)malloc(sizeof(struct xml_settings_s)); 36 | if (s == NULL) 37 | return NULL; 38 | 39 | memset(s, 0, sizeof(struct xml_settings_s)); 40 | 41 | fd = fopen("/apps/onscripter/games.xml", "r"); 42 | if (fd == NULL) { 43 | printf("Error : %d\n", errno); 44 | s->root = mxmlLoadString(NULL, "<settings></settings>", MXML_TEXT_CALLBACK); 45 | } else { 46 | s->root = mxmlLoadFile(NULL, fd, MXML_TEXT_CALLBACK); 47 | } 48 | s->index = mxmlIndexNew(s->root, "game", "id"); 49 | 50 | fclose(fd); 51 | 52 | return s; 53 | } 54 | 55 | int save_settings(xml_settings_t *s) 56 | { 57 | FILE *fd; 58 | int ret = -1; 59 | 60 | fd = fopen("/apps/onscripter/games.xml", "w"); 61 | if (fd == NULL) { 62 | printf("Error : %d\n", errno); 63 | return ret; 64 | } 65 | 66 | ret = mxmlSaveFile(s->root, fd, MXML_NO_CALLBACK); 67 | fclose(fd); 68 | return ret; 69 | } 70 | 71 | void add_game(xml_settings_t *s, char* id, char* title, int mode, char *root, char *save, char *font) 72 | { 73 | mxml_node_t *pRoot, *pSave, *pFont; 74 | mxml_node_t *game = mxmlNewElement(NULL, "game"); 75 | mxmlElementSetAttr(game, "id", id); 76 | mxmlElementSetAttr(game, "title", title); 77 | if (mode) { 78 | mxmlNewElement(game, "english"); 79 | } 80 | if (strcmp(root, "")) { 81 | pRoot = mxmlNewElement(game, "root"); 82 | mxmlElementSetAttr(pRoot, "path", root); 83 | } 84 | if (strcmp(save, "")) { 85 | pSave = mxmlNewElement(game, "save"); 86 | mxmlElementSetAttr(pSave, "path", save); 87 | } 88 | if (strcmp(font, "")) { 89 | pFont = mxmlNewElement(game, "font"); 90 | mxmlElementSetAttr(pFont, "file", font); 91 | } 92 | mxmlAdd(s->root, MXML_ADD_AFTER, NULL, game); 93 | mxmlIndexDelete(s->index); 94 | s->index = mxmlIndexNew(s->root, "game", "id"); 95 | } 96 | 97 | void delete_game(xml_settings_t *s, mxml_node_t *game) 98 | { 99 | mxmlDelete(game); 100 | mxmlIndexDelete(s->index); 101 | s->index = mxmlIndexNew(s->root, "game", "id"); 102 | } 103 | 104 | mxml_node_t *find_first_game(xml_settings_t *s) 105 | { 106 | mxmlIndexReset(s->index); 107 | return mxmlIndexEnum(s->index); 108 | } 109 | 110 | mxml_node_t *find_next_game(xml_settings_t *s) 111 | { 112 | return mxmlIndexEnum(s->index); 113 | } 114 | 115 | mxml_node_t *get_game_by_index(xml_settings_t *s, int index) 116 | { 117 | if (index < 0 || index > (s->index->num_nodes - 1)) 118 | return NULL; 119 | return s->index->nodes[index]; 120 | } 121 | 122 | int get_game_count(xml_settings_t *s) 123 | { 124 | return s->index->num_nodes; 125 | } 126 | 127 | const char *get_title(mxml_node_t *game) 128 | { 129 | return mxmlElementGetAttr(game, "title"); 130 | } 131 | 132 | const char *get_id(mxml_node_t *game) 133 | { 134 | return mxmlElementGetAttr(game, "id"); 135 | } 136 | 137 | const char *get_root_path(mxml_node_t *game) 138 | { 139 | mxml_node_t *node; 140 | node = mxmlFindElement(game, game, "root", "path", NULL, MXML_DESCEND_FIRST); 141 | if (node == NULL) 142 | return NULL; 143 | 144 | return mxmlElementGetAttr(node, "path"); 145 | } 146 | 147 | const char *get_save_path(mxml_node_t *game) 148 | { 149 | mxml_node_t *node; 150 | node = mxmlFindElement(game, game, "save", "path", NULL, MXML_DESCEND_FIRST); 151 | if (node == NULL) 152 | return NULL; 153 | 154 | return mxmlElementGetAttr(node, "path"); 155 | } 156 | 157 | const char *get_font(mxml_node_t *game) 158 | { 159 | mxml_node_t *node; 160 | node = mxmlFindElement(game, game, "font", "file", NULL, MXML_DESCEND_FIRST); 161 | if (node == NULL) 162 | return NULL; 163 | 164 | return mxmlElementGetAttr(node, "file"); 165 | } 166 | 167 | const char *get_registry(mxml_node_t *game) 168 | { 169 | mxml_node_t *node; 170 | node = mxmlFindElement(game, game, "registry", "file", NULL, MXML_DESCEND_FIRST); 171 | if (node == NULL) 172 | return NULL; 173 | 174 | return mxmlElementGetAttr(node, "file"); 175 | } 176 | 177 | int use_english_mode(mxml_node_t *game) 178 | { 179 | if(mxmlFindElement(game, game, "english", NULL, NULL, MXML_DESCEND_FIRST)) 180 | return 1; 181 | return 0; 182 | } 183 | 184 | void close_settings(xml_settings_t *s) 185 | { 186 | mxmlIndexDelete(s->index); 187 | mxmlDelete(s->root); 188 | free(s); 189 | } 190 | 191 | 192 | -------------------------------------------------------------------------------- /wii/setting_parser.h: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * 3 | * setting_parser.h -- parses list of installed games on WII 4 | * 5 | * Copyright (c) 2009 Brian. All rights reserved. 6 | * 7 | * brijohn@gmail.com 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef _SETTING_PARSER_H 25 | #define _SETTING_PARSER_H 26 | 27 | #include <mxml.h> 28 | 29 | typedef struct xml_settings_s xml_settings_t; 30 | 31 | xml_settings_t *open_settings(); 32 | void close_settings(xml_settings_t *s); 33 | int save_settings(xml_settings_t *s); 34 | 35 | void add_game(xml_settings_t *s, char *id, char *title, int mode, char *root, char *save, char *font); 36 | void delete_game(xml_settings_t *s, mxml_node_t *game); 37 | 38 | mxml_node_t *find_first_game(xml_settings_t *s); 39 | mxml_node_t *find_next_game(xml_settings_t *s); 40 | mxml_node_t *get_game_by_index(xml_settings_t *s, int index); 41 | int get_game_count(xml_settings_t *s); 42 | const char *get_title(mxml_node_t *game); 43 | const char *get_id(mxml_node_t *game); 44 | const char *get_root_path(mxml_node_t *game); 45 | const char *get_save_path(mxml_node_t *game); 46 | const char *get_font(mxml_node_t *game); 47 | const char *get_registry(mxml_node_t *game); 48 | int use_english_mode(mxml_node_t *game); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /wii/sounds/bg_music.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/sounds/bg_music.ogg -------------------------------------------------------------------------------- /wii/sounds/button_over.pcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brijohn/onscripter-wii/3dd360ba7efc4ff9f1a1dca37f5e22e629dfdc6b/wii/sounds/button_over.pcm -------------------------------------------------------------------------------- /wii/video.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui Template 3 | * Tantric 2009 4 | * 5 | * video.h 6 | * Video routines 7 | ***************************************************************************/ 8 | 9 | #ifndef _VIDEO_H_ 10 | #define _VIDEO_H_ 11 | 12 | #include <ogcsys.h> 13 | #include <ogc/conf.h> 14 | 15 | void InitVideo (); 16 | void StopGX(); 17 | void ResetVideo_Menu(); 18 | void Menu_Render(); 19 | void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[], f32 degrees, f32 scaleX, f32 scaleY, u8 alphaF ); 20 | void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled); 21 | 22 | extern int screenheight; 23 | extern int screenwidth; 24 | 25 | #endif 26 | --------------------------------------------------------------------------------