├── README.md ├── documents ├── cheats format.txt ├── cheats_jp.txt ├── directory.txt ├── readme.txt └── thanks.txt └── source ├── Makefile ├── SDK ├── include │ ├── kubridge.h │ ├── pspinit.h │ ├── psploadcore.h │ ├── psploadexec_kernel.h │ ├── pspmodulemgr.h │ ├── pspmodulemgr_kernel.h │ ├── pspsysmem.h │ ├── pspsysmem_kernel.h │ ├── pspusbdevice.h │ ├── systemctrl.h │ ├── systemctrl_se.h │ └── vshctrl.h ├── lib │ ├── 1 │ ├── libpspinit.a │ ├── libpspkdebug.a │ ├── libpspkubridge.a │ ├── libpsploadexec_kernel.a │ ├── libpspmodulemgr_kernel.a │ ├── libpspmodulemgr_user.a │ ├── libpspsysmem_kernel.a │ ├── libpspsysmem_user.a │ ├── libpspsystemctrl_kernel.a │ ├── libpspsystemctrl_user.a │ ├── libpspumd_kernel.a │ ├── libpspusbdevice.a │ ├── libpspusbdevice_driver.a │ └── libpspvshctrl.a └── readme.txt ├── copyright ├── prx ├── exceptionHandler │ ├── README.txt │ ├── prx │ │ ├── exception_asm.S │ │ ├── exports.exp │ │ ├── main.c │ │ └── makefile │ ├── test │ │ ├── main.c │ │ └── makefile │ └── utility │ │ ├── exception.c │ │ └── exception.h └── ku_bridge │ ├── Makefile │ ├── ku_bridge.exp │ ├── ku_bridge.h │ ├── main.c │ └── sceCtrl_driver.S ├── res └── ICON0.png └── src ├── ch_print.c ├── ch_print.h ├── cheats.c ├── cheats.h ├── common.h ├── cpu.c ├── cpu.h ├── exception.c ├── exception.h ├── gbkfont.c ├── gui.c ├── gui.h ├── input.c ├── input.h ├── ku_bridge.S ├── ku_bridge.h ├── libpower ├── libpsppower.a └── psppower.h ├── main.c ├── main.h ├── memory.c ├── memory.h ├── message.c ├── message.h ├── mh_print.c ├── mh_print.h ├── mips_emit.h ├── mips_stub.S ├── png.c ├── png.h ├── shinonomefont.c ├── sound.c ├── sound.h ├── text ├── a_pad_menu_t.h ├── cheat_menu_t.h ├── main_menu_t.h ├── message_ansi.h ├── option_menu_t.h ├── pad_menu_t.h └── state_menu_t.h ├── video.c ├── video.h ├── volume_icon.c ├── zip.c ├── zip.h └── zlib ├── README ├── adler32.c ├── compress.c ├── crc32.c ├── crc32.h ├── deflate.c ├── deflate.h ├── gzclose.c ├── gzguts.h ├── gzlib.c ├── gzread.c ├── gzwrite.c ├── infback.c ├── inffast.c ├── inffast.h ├── inffixed.h ├── inflate.c ├── inflate.h ├── inftrees.c ├── inftrees.h ├── trees.c ├── trees.h ├── uncompr.c ├── zconf.h ├── zlib.h ├── zutil.c └── zutil.h /README.md: -------------------------------------------------------------------------------- 1 | # TempGBA4PSP-Single-game 2 | 3 | Fork of TempGBA4PSP 4 | 5 | ## What is this? 6 | This emulator is a modified a version of TempGBA4PSP that allows to launch roms straight from the PSP Menu! It works by having a multiple instances of this emulator, each one for each game. 7 | 8 | ## Usage 9 | - Download this emulator from the [releases tab](https://github.com/GrabowskiDev/TempGBA4PSP-Single-game/releases) 10 | - Put you GBA game in roms folder, and name it `game.gba` (It needs to be unzipped) 11 | - (Note: If you're importing save file or config, put them in respective folders and also name them `game`) 12 | - Optional: Change the icon and background picture of the PBOOT.PBP to mach the game (You can use [PSP Brew](https://www.brewology.com/downloads/download.php?id=5487&mcid=1) for this but there are also other programs) 13 | - The Main Icon can be 144x80 for rectangle sized image, or 80x80 for square GBA icons (and probably anything between 80-144x80 would work) 14 | - The Background image should be 480x272 (at least that's what has been working for me) 15 | - The Background music must be in .AT3 (You can use [this converter](https://www.modconsoles.fr/club-articles.html/pc/at9at3-converter-v23-r36/)) 16 | - Keep in mind that the size of .AT3 combined with the size of .PMF (Animated icon) can't exceed 500KB. You may need to crop the sound. 17 | 18 | - Drag your TempGBA folder onto your PSP memory card (into PSP/GAME folder) 19 | - Enjoy your game! 20 | 21 | ### Development 22 | This project was build using older SDK, specifically [This one](https://github.com/PSP-Archive/ARK-4/tree/main/contrib/PC/PSPSDK) on Ubuntu 22.04LTS 23 | 24 | If you find any bugs or problems, feel free to address them or write me a message. 25 | -------------------------------------------------------------------------------- /documents/cheats format.txt: -------------------------------------------------------------------------------- 1 | code_format: 2 | 3 | gameshark_v1 4 | gameshark_v2 5 | gameshark_v3 6 | PAR_v1 7 | PAR_v2 8 | PAR_v3 9 | direct_v1 10 | direct_v2 11 | direct_v3 12 | 13 | gameshark_v1=gameshark_v2=PAR_v1=PAR_v2,gameshark_v3=PAR_v3,direct_v1=direct_v2 14 | 15 | direct_v1/v2: 16 | no encrypte gameshark_v1/v2/PAR_v1/v2 17 | 18 | direct_v3: 19 | no encrypte gameshark_v3/PAR_v3 20 | 21 | 22 | EX. 23 | direct_v1 money max 24 | 22000454 05F5E0FF 25 | 26 | direct_v2 money max 27 | 22000454 05F5E0FF 28 | ----------------- 29 | direct_v3 money max 30 | 04200454 05F5E0FF 31 | 32 | # money max 33 | 04200454 05F5E0FF 34 | 35 | 36 | code_name: 37 | when emlutor language select japanese,cheat file charset use SHIFT-JIS,other ANSI. 38 | SJIS:12 全角文字、24半角文字 39 | ANSI:24 characters 40 | -------------------------------------------------------------------------------- /documents/cheats_jp.txt: -------------------------------------------------------------------------------- 1 | UnOfficial gpSP kai 2 | -- gameplaySP Gameboy Advance emulator for Playstation Portable -- 3 | 4 | CHEAT CODE 5 | 6 | dir.cfgで指定したフォルダに、[ROM名].chtで保存する 7 | 文字コードはUTF-8Nを使用すること 8 | 9 | 以下の書式にて、30個まで登録可能 10 | 11 | code_format code_name 12 | aaaaaaaa dddddddd 13 | aaaaaaaa dddddddd 14 | ... 15 | 16 | code_format 17 | 以下の9種類を指定可能 18 | gameshark_v1 19 | gameshark_v2 20 | gameshark_v3 21 | PAR_v1 22 | PAR_v2 23 | PAR_v3 24 | direct_v1 25 | direct_v2 26 | direct_v3 27 | 28 | 注意 29 | ・gameshark_v1=gameshark_v2=PAR_v1=PAR_v2,gameshark_v3=PAR_v3,direct_v1=direct_v2で、実質4種類 30 | ・direct_v1/v2はgameshark_v1/v2/PAR_v1/v2、direct_v2はgameshark_v3/PAR_v3の非暗号化コード 31 | 32 | code_name 33 | 半角文字で16文字まで設定可能 34 | 35 | 注意 36 | 全角文字はUTF-8Nでは3byteなので、現在(3.2 test 8.6まで)5文字しか登録されない 37 | test8.7以降で拡張予定 38 | 39 | aaaaaaaa dddddddd 40 | チートコード 41 | 255個まで連続で設定可能 42 | 43 | コード詳細 44 | 以下は全て暗号化前の状態 45 | 46 | gameshark_v1/v2/PAR_v1/v2/direct_v1/v2 47 | 48 | 0aaaaaaa 000000xx 49 | アドレスaaaaaaaに1byteデータxxを書込 50 | 51 | 1aaaaaaa 0000xxxx 52 | アドレスaaaaaaaに2byteデータxxxxを書込 53 | 54 | 2aaaaaaa xxxxxxxx 55 | アドレスaaaaaaaに4byteデータxxxxxxxxを書込 56 | 57 | 3000cccc xxxxxxxx 58 | aaaaaaaa bbbbbbbb 59 | ... 60 | 4byteデータxxxxxxxxを(cccc-1)行分のアドレスに書き込む 61 | アドレスデータが奇数個の場合、cccccccc 00000000の用に0でパディングする 62 | ex. 63 | 30000003 FFFFFFFF 64 | 20000000 20000001 65 | 20000002 00000000 66 | 67 | 60aaaaaa y000xxxx 68 | ROMアドレス8000000h+aaaaaa*2byteデータxxxxを書込 69 | [8000000h+aaaaaa*2]=xxxx 70 | yの詳細は不明 71 | 72 | 注意 73 | 実機では書換個数に制限があるがgpSPでは無い 74 | オンメモリの場合のみ書換えが行われる 75 | (旧型は16MB以下、新型は32MB以下) 76 | 77 | 8a1aaaaa 000000xx 78 | 8a2aaaaa 0000xxxx 79 | 8a4aaaaa xxxxxxxx 80 | PAR/GSのボタンが押されたときに、アドレスa0aaaaaにそれぞれ1/2/4byteの書込を行う 81 | 82 | 注意 83 | 現在未対応 84 | 85 | 80F00000 0000xxxx 86 | PAR/GSのボタンが押されたときに、スローモーションを行う 87 | 速度をxxxxで指示、最高速0000 -> 最低速ffff 88 | 89 | 注意 90 | 現在未対応 91 | 92 | Daaaaaaa 0000xxxx 93 | Daaaaaaa 0010xxxx 94 | Daaaaaaa 0020xxxx 95 | Daaaaaaa 0030xxxx 96 | アドレスaaaaaの内容を2byteデータxxxxと比較し、偽の場合は次のコードをスキップする 97 | 条件は上から順に、[a]=x,[a]!=x,[a]<=x,[a]>=x 98 | 99 | 注意 100 | 現在[a]=x以外は未対応 101 | 102 | E0zzxxxx 0aaaaaaa 103 | E0zzxxxx 1aaaaaaa 104 | E0zzxxxx 2aaaaaaa 105 | E0zzxxxx 3aaaaaaa 106 | アドレスaaaaaの内容を2byteデータxxxxと比較し、偽の場合はzzで指示するコードをスキップする 107 | 条件は上から順に、[a]=x,[a]!=x,[a]<=x,[a]>=x 108 | 109 | 注意 110 | 現在[a]=x以外は未対応 111 | 112 | Faaaaaaa 00000x0y 113 | xxxxxxxx 001DC0DE 114 | 通称マスターコード、実機ではチートを有効にするのに必要 115 | gpSPでは必要としない 116 | 117 | DEADFACE 0000xxxx 118 | 暗号化に使用されるシードを変更する 119 | 120 | 注意 121 | 現在未対応 122 | 123 | 124 | gameshark_v3/PAR_v3/direct_v3 125 | 126 | 00aaaaaa 0000xxyy 127 | アドレスa0aaaaa~アドレスa0aaaaa+xxxxxxに1byteデータyyを書込 128 | 129 | 02aaaaaa xxxxyyyy 130 | アドレスa0aaaaa~アドレスa0aaaaa+xxxx*2に2byteデータyyyyを書込 131 | 132 | 04aaaaaa yyyyyyyy 133 | アドレスa0aaaaaに4byteデータyyyyyyyyを書込 134 | 135 | 40aaaaaa xxxxxxyy 136 | a0aaaaaの内容にxxxxxxを加えたアドレスに1byteデータyyを書込 137 | 138 | 42aaaaaa xxxxyyyy 139 | a0aaaaaの内容にxxxx*2を加えたアドレスに2byteデータyyyyを書込 140 | 141 | 44aaaaaa yyyyyyyy 142 | a0aaaaaの内容のアドレスに4byteデータyyyyyyyyを書込 143 | 144 | 80aaaaaa 000000yy 145 | アドレスa0aaaaaの内容に1byteデータyyを加算 146 | 147 | 82aaaaaa 0000yyyy 148 | アドレスa0aaaaaの内容に2byteデータyyyyを加算 149 | 150 | 84aaaaaa yyyyyyyy 151 | アドレスa0aaaaaの内容に4byteデータyyyyyyyyを加算 152 | 153 | C6aaaaaa 0000yyyy 154 | I/Oレジスタ4aaaaaに2byteデータyyyyを書込 155 | C7aaaaaa yyyyyyyy 156 | I/Oレジスタ4aaaaaに4byteデータyyyyyyyyを書込 157 | 158 | IFコードや00000000で始まるコードは未対応 159 | 160 | C4aaaaaa 0000yyyy 161 | xxxxxxxx 001DC0DE 162 | 通称マスターコード、実機ではチートを有効にするのに必要 163 | gpSPでは必要としない 164 | 165 | DEADFACE 0000xxxx 166 | 暗号化に使用されるシードを変更する 167 | 168 | 注意 169 | 現在未対応 170 | -------------------------------------------------------------------------------- /documents/directory.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/documents/directory.txt -------------------------------------------------------------------------------- /documents/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/documents/readme.txt -------------------------------------------------------------------------------- /documents/thanks.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/documents/thanks.txt -------------------------------------------------------------------------------- /source/Makefile: -------------------------------------------------------------------------------- 1 | # -x assembler-with-cpp 2 | # gpSP makefile 3 | # Gilead Kutnick - Exophase 4 | 5 | 6 | # Global definitions 7 | 8 | PSPSDK = ${shell psp-config --pspsdk-path} 9 | PREFIX = ${shell psp-config --psp-prefix} 10 | 11 | BUILD_PRX = 1 12 | ENCRYPT = 1 13 | 14 | PSP_FW_VERSION = 371 15 | PSP_LARGE_MEMORY = 1 16 | 17 | PSP_EBOOT_ICON = res/ICON0.png 18 | PSP_EBOOT_TITLE = TempGBA mod 19 | 20 | EXTRA_TARGETS = EBOOT.PBP 21 | 22 | COMMON_FILE = \ 23 | common.h \ 24 | cpu.h memory.h video.h input.h sound.h main.h message.h mh_print.h gui.h zip.h png.h \ 25 | ku_bridge.h exception.h ch_print.h 26 | 27 | MAINOBJS = \ 28 | cpu.o memory.o video.o input.o sound.o main.o message.o mh_print.o gui.o zip.o png.o \ 29 | mips_stub.o \ 30 | ku_bridge.o exception.o cheats.o ch_print.o 31 | 32 | OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o 33 | OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o 34 | 35 | OBJS = $(MAINOBJS) $(OBJZ) $(OBJG) 36 | 37 | TARGET = TempGBA 38 | 39 | VPATH = src src/zlib 40 | 41 | CFLAGS = \ 42 | -O2 -G0 \ 43 | -march=allegrex -mfp32 -mgp32 -mlong32 -mabi=eabi \ 44 | -fomit-frame-pointer -fstrict-aliasing \ 45 | -falign-functions=32 -falign-loops -falign-labels -falign-jumps \ 46 | -Wall -Wundef -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Wsign-compare -Werror \ 47 | -DZLIB_CONST 48 | 49 | ASFLAGS = ${CFLAGS} 50 | 51 | INCDIR = SDK/include src src/zlib src/libpower 52 | LIBDIR = SDK/lib 53 | 54 | LIBS = src/libpower/libpsppower.a -lpspgu -lpsprtc -lpspaudio -lpspkubridge 55 | 56 | include ${PSPSDK}/lib/build.mak 57 | 58 | -------------------------------------------------------------------------------- /source/SDK/include/kubridge.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/include/kubridge.h -------------------------------------------------------------------------------- /source/SDK/include/pspinit.h: -------------------------------------------------------------------------------- 1 | #ifndef __PSPINIT_H__ 2 | 3 | #define __PSPINIT_H__ 4 | 5 | enum PSPBootFrom 6 | { 7 | PSP_BOOT_FLASH = 0, /* ? */ 8 | PSP_BOOT_DISC = 0x20, 9 | PSP_BOOT_MS = 0x40, 10 | }; 11 | 12 | enum PSPInitApitype 13 | { 14 | PSP_INIT_APITYPE_DISC = 0x120, 15 | PSP_INIT_APITYPE_DISC_UPDATER = 0x121, 16 | PSP_INIT_APITYPE_MS1 = 0x140, 17 | PSP_INIT_APITYPE_MS2 = 0x141, 18 | PSP_INIT_APITYPE_MS3 = 0x142, 19 | PSP_INIT_APITYPE_MS4 = 0x143, 20 | PSP_INIT_APITYPE_MS5 = 0x144, 21 | PSP_INIT_APITYPE_VSH1 = 0x210, /* ExitGame */ 22 | PSP_INIT_APITYPE_VSH2 = 0x220, /* ExitVSH */ 23 | }; 24 | 25 | enum PSPKeyConfig 26 | { 27 | PSP_INIT_KEYCONFIG_VSH = 0x100, 28 | PSP_INIT_KEYCONFIG_GAME = 0x200, 29 | PSP_INIT_KEYCONFIG_POPS = 0x300, 30 | }; 31 | 32 | /** 33 | * Gets the api type 34 | * 35 | * @returns the api type in which the system has booted 36 | */ 37 | int sceKernelInitApitype(); 38 | 39 | /** 40 | * Gets the filename of the executable to be launched after all modules of the api. 41 | * 42 | * @returns filename of executable or NULL if no executable found. 43 | */ 44 | char *sceKernelInitFileName(); 45 | 46 | /** 47 | * 48 | * Gets the device in which the application was launched. 49 | * 50 | * @returns the device code, one of PSPBootFrom values. 51 | */ 52 | int sceKernelBootFrom(); 53 | 54 | /** 55 | * Get the key configuration in which the system has booted. 56 | * 57 | * @returns the key configuration code, one of PSPKeyConfig values 58 | */ 59 | int InitForKernel_7233B5BC(); 60 | 61 | #define sceKernelInitKeyConfig InitForKernel_7233B5BC 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /source/SDK/include/psploadcore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PSP Software Development Kit - http://www.pspdev.org 3 | * ----------------------------------------------------------------------- 4 | * Licensed under the BSD license, see LICENSE in PSPSDK root for details. 5 | * 6 | * psploadcore.h - Interface to LoadCoreForKernel. 7 | * 8 | * Copyright (c) 2005 Marcus R. Brown 9 | * Copyright (c) 2005 James Forshaw 10 | * Copyright (c) 2005 John Kelley 11 | * 12 | * $Id: psploadcore.h 1095 2005-09-27 21:02:16Z jim $ 13 | */ 14 | 15 | #ifndef PSPLOADCORE_H 16 | #define PSPLOADCORE_H 17 | 18 | #include 19 | 20 | /** @defgroup LoadCore Interface to the LoadCoreForKernel library. 21 | */ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** @addtogroup LoadCore Interface to the LoadCoreForKernel library. */ 28 | /*@{*/ 29 | 30 | /** Describes a module. This structure could change in future firmware revisions. */ 31 | typedef struct SceModule { 32 | struct SceModule *next; 33 | unsigned short attribute; 34 | unsigned char version[2]; 35 | char modname[27]; 36 | char terminal; 37 | unsigned int unknown1; 38 | unsigned int unknown2; 39 | SceUID modid; 40 | unsigned int unknown3[4]; 41 | void * ent_top; 42 | unsigned int ent_size; 43 | void * stub_top; 44 | unsigned int stub_size; 45 | unsigned int unknown4[4]; 46 | unsigned int entry_addr; 47 | unsigned int gp_value; 48 | unsigned int text_addr; 49 | unsigned int text_size; 50 | unsigned int data_size; 51 | unsigned int bss_size; 52 | unsigned int nsegment; 53 | unsigned int segmentaddr[4]; 54 | unsigned int segmentsize[4]; 55 | } SceModule; 56 | 57 | // For 1.50+ 58 | 59 | typedef struct SceModule2 60 | { 61 | struct SceModule *next; // 0 62 | u16 attribute; // 4 63 | u8 version[2]; // 6 64 | char modname[27]; // 8 65 | char terminal; // 0x23 66 | char mod_state; // 0x24 67 | char unk1; // 0x25 68 | char unk2[2]; // 0x26 69 | u32 unk3; // 0x28 70 | SceUID modid; // 0x2C 71 | u32 unk4; // 0x30 72 | SceUID mem_id; // 0x34 73 | u32 mpid_text; // 0x38 74 | u32 mpid_data; // 0x3C 75 | void * ent_top; // 0x40 76 | unsigned int ent_size; // 0x44 77 | void * stub_top; // 0x48 78 | u32 stub_size; // 0x4C 79 | u32 entry_addr_; // 0x50 80 | u32 unk5[4]; // 0x54 81 | u32 entry_addr; // 0x64 82 | u32 gp_value; // 0x68 83 | u32 text_addr; // 0x6C 84 | u32 text_size; // 0x70 85 | u32 data_size; // 0x74 86 | u32 bss_size; // 0x78 87 | u32 nsegment; // 0x7C 88 | u32 segmentaddr[4]; // 0x80 89 | u32 segmentsize[4]; // 0x90 90 | } SceModule2; 91 | 92 | /** Defines a library and its exported functions and variables. Use the len 93 | member to determine the real size of the table (size = len * 4). */ 94 | typedef struct SceLibraryEntryTable { 95 | /**The library's name. */ 96 | const char * libname; 97 | /** Library version. */ 98 | unsigned char version[2]; 99 | /** Library attributes. */ 100 | unsigned short attribute; 101 | /** Length of this entry table in 32-bit WORDs. */ 102 | unsigned char len; 103 | /** The number of variables exported by the library. */ 104 | unsigned char vstubcount; 105 | /** The number of functions exported by the library. */ 106 | unsigned short stubcount; 107 | /** Pointer to the entry table; an array of NIDs followed by 108 | pointers to functions and variables. */ 109 | void * entrytable; 110 | } SceLibraryEntryTable; 111 | 112 | /** Specifies a library and a set of imports from that library. Use the len 113 | member to determine the real size of the table (size = len * 4). */ 114 | typedef struct SceLibraryStubTable { 115 | /* The name of the library we're importing from. */ 116 | const char * libname; 117 | /** Minimum required version of the library we want to import. */ 118 | unsigned char version[2]; 119 | /* Import attributes. */ 120 | unsigned short attribute; 121 | /** Length of this stub table in 32-bit WORDs. */ 122 | unsigned char len; 123 | /** The number of variables imported from the library. */ 124 | unsigned char vstubcount; 125 | /** The number of functions imported from the library. */ 126 | unsigned short stubcount; 127 | /** Pointer to an array of NIDs. */ 128 | unsigned int * nidtable; 129 | /** Pointer to the imported function stubs. */ 130 | void * stubtable; 131 | /** Pointer to the imported variable stubs. */ 132 | void * vstubtable; 133 | } SceLibraryStubTable; 134 | 135 | 136 | /** 137 | * Find a module by it's name. 138 | * 139 | * @param modname - The name of the module. 140 | * 141 | * @returns Pointer to the ::SceModule structure if found, otherwise NULL. 142 | */ 143 | //SceModule * sceKernelFindModuleByName(const char *modname); 144 | SceModule2 *sceKernelFindModuleByName(const char *modname); 145 | 146 | /** 147 | * Find a module from an address. 148 | * 149 | * @param addr - Address somewhere within the module. 150 | * 151 | * @returns Pointer to the ::SceModule structure if found, otherwise NULL. 152 | */ 153 | //SceModule * sceKernelFindModuleByAddress(unsigned int addr); 154 | SceModule2 *sceKernelFindModuleByAddress(unsigned int addr); 155 | 156 | /** 157 | * Find a module by it's UID. 158 | * 159 | * @param modid - The UID of the module. 160 | * 161 | * @returns Pointer to the ::SceModule structure if found, otherwise NULL. 162 | */ 163 | //SceModule * sceKernelFindModuleByUID(SceUID modid); 164 | SceModule2 *sceKernelFindModuleByUID(SceUID modid); 165 | 166 | 167 | /** 168 | * Return the count of loaded modules. 169 | * 170 | * @returns The count of loaded modules. 171 | */ 172 | int sceKernelModuleCount(void); 173 | 174 | /** 175 | * Invalidate the CPU's instruction cache. 176 | */ 177 | void sceKernelIcacheClearAll(void); 178 | 179 | /*@}*/ 180 | 181 | #ifdef __cplusplus 182 | } 183 | #endif 184 | 185 | #endif /* PSPLOADCORE_H */ 186 | -------------------------------------------------------------------------------- /source/SDK/include/psploadexec_kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File for the kernel exports of LoadExec 3 | */ 4 | 5 | #ifndef __LOADEXEC_KERNEL__ 6 | #define __LOADEXEC_KERNEL__ 7 | 8 | #include 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /** Structure for LoadExecVSH* functions */ 15 | struct SceKernelLoadExecVSHParam { 16 | /** Size of the structure in bytes */ 17 | SceSize size; 18 | /** Size of the arguments string */ 19 | SceSize args; 20 | /** Pointer to the arguments strings */ 21 | void * argp; 22 | /** The key, usually "game", "updater" or "vsh" */ 23 | const char * key; 24 | /** The size of the vshmain arguments */ 25 | u32 vshmain_args_size; 26 | /** vshmain arguments that will be passed to vshmain after the program has exited */ 27 | void *vshmain_args; 28 | /** "/kd/pspbtcnf_game.txt" or "/kd/pspbtcnf.txt" if not supplied (max. 256 chars) */ 29 | char *configfile; 30 | /** An unknown string (max. 256 chars) probably used in 2nd stage of loadexec */ 31 | u32 unk4; 32 | /** unknown flag default value = 0x10000 */ 33 | u32 unk5; 34 | }; 35 | 36 | /** 37 | * Executes a new executable from a buffer. 38 | * 39 | * @param bufsize - Size in bytes of the buffer pointed by buf. 40 | * @param buf - Pointer to a buffer containing the module to execute. 41 | * @param param - Pointer to a ::SceKernelLoadExecParam structure, or NULL. 42 | * 43 | * @returns < 0 on some errors. 44 | */ 45 | int sceKernelLoadExecBufferPlain(SceSize bufsize, void *buf, struct SceKernelLoadExecParam *param); 46 | 47 | /** 48 | * Restart the vsh. 49 | * 50 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL 51 | * 52 | * @returns < 0 on some errors. 53 | * 54 | * @note - when called in game mode it will have the same effect that sceKernelExitGame 55 | * 56 | */ 57 | int sceKernelExitVSHVSH(struct SceKernelLoadExecVSHParam *param); 58 | 59 | /** 60 | * Restart the vsh (to be used by a kernel module) 61 | * 62 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL 63 | * 64 | * @returns < 0 on some errors. 65 | * 66 | * @note - when called in game mode it will have the same effect that sceKernelExitGame 67 | * @note2: available since firmware 2.00. 68 | */ 69 | int sceKernelExitVSHKernel(struct SceKernelLoadExecVSHParam *param); 70 | 71 | /** 72 | * Executes a new executable from a disc. 73 | * It is the function used by the firmware to execute the EBOOT.BIN from a disc. 74 | * 75 | * @param file - The file to execute. 76 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 77 | * 78 | * @returns < 0 on some errors. 79 | */ 80 | int sceKernelLoadExecVSHDisc(const char *file, struct SceKernelLoadExecVSHParam *param); 81 | 82 | /** 83 | * Executes a new executable from a disc. 84 | * It is the function used by the firmware to execute an updater from a disc. 85 | * 86 | * @param file - The file to execute. 87 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 88 | * 89 | * @returns < 0 on some errors. 90 | */ 91 | int sceKernelLoadExecVSHDiscUpdater(const char *file, struct SceKernelLoadExecVSHParam *param); 92 | 93 | /** 94 | * Executes a new executable from a memory stick. 95 | * It is the function used by the firmware to execute an updater from a memory stick. 96 | * 97 | * @param file - The file to execute. 98 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 99 | * 100 | * @returns < 0 on some errors. 101 | */ 102 | int sceKernelLoadExecVSHMs1(const char *file, struct SceKernelLoadExecVSHParam *param); 103 | 104 | /** 105 | * Executes a new executable from a memory stick. 106 | * It is the function used by the firmware to execute games (and homebrew :P) from a memory stick. 107 | * 108 | * @param file - The file to execute. 109 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 110 | * 111 | * @returns < 0 on some errors. 112 | */ 113 | int sceKernelLoadExecVSHMs2(const char *file, struct SceKernelLoadExecVSHParam *param); 114 | 115 | /** 116 | * Executes a new executable from a memory stick. 117 | * It is the function used by the firmware to execute ... ? 118 | * 119 | * @param file - The file to execute. 120 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 121 | * 122 | * @returns < 0 on some errors. 123 | */ 124 | int sceKernelLoadExecVSHMs3(const char *file, struct SceKernelLoadExecVSHParam *param); 125 | 126 | /*** 127 | * Executes a new executable from a memory stick. 128 | * It is the function used by the firmware to execute psx games 129 | * 130 | * @param file - The file to execute. 131 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 132 | * 133 | * @returns < 0 on some errors. 134 | * @note - Available since firmware 3.00 135 | */ 136 | int sceKernelLoadExecVSHMs4(const char *file, struct SceKernelLoadExecVSHParam *param); 137 | 138 | #ifdef __cplusplus 139 | } 140 | #endif 141 | 142 | #endif 143 | -------------------------------------------------------------------------------- /source/SDK/include/pspmodulemgr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PSP Software Development Kit - http://www.pspdev.org 3 | * ----------------------------------------------------------------------- 4 | * Licensed under the BSD license, see LICENSE in PSPSDK root for details. 5 | * 6 | * pspmodulemgr.h - Prototypes to manage modules. 7 | * 8 | * Copyright (c) 2005 Marcus R. Brown 9 | * Copyright (c) 2005 James Forshaw 10 | * Copyright (c) 2005 John Kelley 11 | * 12 | * $Id: pspmodulemgr.h 1148 2005-10-12 19:08:27Z tyranid $ 13 | */ 14 | 15 | /* Note: Some of the structures, types, and definitions in this file were 16 | extrapolated from symbolic debugging information found in the Japanese 17 | version of Puzzle Bobble. */ 18 | 19 | #ifndef __MODLOAD_H__ 20 | #define __MODLOAD_H__ 21 | 22 | #include 23 | 24 | /** @defgroup ModuleMgr Module Manager Library 25 | * This module contains the imports for the kernel's module management routines. 26 | */ 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | /** @addtogroup ModuleMgr Module Manager Library */ 33 | /*@{*/ 34 | 35 | #define PSP_MEMORY_PARTITION_KERNEL 1 36 | #define PSP_MEMORY_PARTITION_USER 2 37 | 38 | typedef struct SceKernelLMOption { 39 | SceSize size; 40 | SceUID mpidtext; 41 | SceUID mpiddata; 42 | unsigned int flags; 43 | char position; 44 | char access; 45 | char creserved[2]; 46 | } SceKernelLMOption; 47 | 48 | typedef struct SceKernelSMOption { 49 | SceSize size; 50 | SceUID mpidstack; 51 | SceSize stacksize; 52 | int priority; 53 | unsigned int attribute; 54 | } SceKernelSMOption; 55 | 56 | 57 | /** 58 | * Load a module. 59 | * @note This function restricts where it can load from (such as from flash0) 60 | * unless you call it in kernel mode. It also must be called from a thread. 61 | * 62 | * @param path - The path to the module to load. 63 | * @param flags - Unused, always 0 . 64 | * @param option - Pointer to a mod_param_t structure. Can be NULL. 65 | * 66 | * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes. 67 | */ 68 | SceUID sceKernelLoadModule(const char *path, int flags, SceKernelLMOption *option); 69 | 70 | /** 71 | * Load a module from MS. 72 | * @note This function restricts what it can load, e.g. it wont load plain executables. 73 | * 74 | * @param path - The path to the module to load. 75 | * @param flags - Unused, set to 0. 76 | * @param option - Pointer to a mod_param_t structure. Can be NULL. 77 | * 78 | * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes. 79 | */ 80 | SceUID sceKernelLoadModuleMs(const char *path, int flags, SceKernelLMOption *option); 81 | 82 | /** 83 | * Load a module from the given file UID. 84 | * 85 | * @param fid - The module's file UID. 86 | * @param flags - Unused, always 0. 87 | * @param option - Pointer to an optional ::SceKernelLMOption structure. 88 | * 89 | * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes. 90 | */ 91 | SceUID sceKernelLoadModuleByID(SceUID fid, int flags, SceKernelLMOption *option); 92 | 93 | /** 94 | * Load a module from a buffer using the USB/WLAN API. 95 | * 96 | * Can only be called from kernel mode, or from a thread that has attributes of 0xa0000000. 97 | * 98 | * @param bufsize - Size (in bytes) of the buffer pointed to by buf. 99 | * @param buf - Pointer to a buffer containing the module to load. The buffer must reside at an 100 | * address that is a multiple to 64 bytes. 101 | * @param flags - Unused, always 0. 102 | * @param option - Pointer to an optional ::SceKernelLMOption structure. 103 | * 104 | * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes. 105 | */ 106 | SceUID sceKernelLoadModuleBufferUsbWlan(SceSize bufsize, void *buf, int flags, SceKernelLMOption *option); 107 | 108 | /** 109 | * Start a loaded module. 110 | * 111 | * @param modid - The ID of the module returned from LoadModule. 112 | * @param argsize - Length of the args. 113 | * @param argp - A pointer to the arguments to the module. 114 | * @param status - Returns the status of the start. 115 | * @param option - Pointer to an optional ::SceKernelSMOption structure. 116 | * 117 | * @return ??? on success, otherwise one of ::PspKernelErrorCodes. 118 | */ 119 | int sceKernelStartModule(SceUID modid, SceSize argsize, void *argp, int *status, SceKernelSMOption *option); 120 | 121 | /** 122 | * Stop a running module. 123 | * 124 | * @param modid - The UID of the module to stop. 125 | * @param argsize - The length of the arguments pointed to by argp. 126 | * @param argp - Pointer to arguments to pass to the module's module_stop() routine. 127 | * @param status - Return value of the module's module_stop() routine. 128 | * @param option - Pointer to an optional ::SceKernelSMOption structure. 129 | * 130 | * @returns ??? on success, otherwise one of ::PspKernelErrorCodes. 131 | */ 132 | int sceKernelStopModule(SceUID modid, SceSize argsize, void *argp, int *status, SceKernelSMOption *option); 133 | 134 | /** 135 | * Unload a stopped module. 136 | * 137 | * @param modid - The UID of the module to unload. 138 | * 139 | * @returns ??? on success, otherwise one of ::PspKernelErrorCodes. 140 | */ 141 | int sceKernelUnloadModule(SceUID modid); 142 | 143 | /** 144 | * Stop and unload the current module. 145 | * 146 | * @param unknown - Unknown (I've seen 1 passed). 147 | * @param argsize - Size (in bytes) of the arguments that will be passed to module_stop(). 148 | * @param argp - Pointer to arguments that will be passed to module_stop(). 149 | * 150 | * @return ??? on success, otherwise one of ::PspKernelErrorCodes. 151 | */ 152 | int sceKernelSelfStopUnloadModule(int unknown, SceSize argsize, void *argp); 153 | 154 | /** 155 | * Stop and unload the current module. 156 | * 157 | * @param argsize - Size (in bytes) of the arguments that will be passed to module_stop(). 158 | * @param argp - Poitner to arguments that will be passed to module_stop(). 159 | * @param status - Return value from module_stop(). 160 | * @param option - Pointer to an optional ::SceKernelSMOption structure. 161 | * 162 | * @returns ??? on success, otherwise one of ::PspKernelErrorCodes. 163 | */ 164 | int sceKernelStopUnloadSelfModule(SceSize argsize, void *argp, int *status, SceKernelSMOption *option); 165 | 166 | 167 | typedef struct SceKernelModuleInfo { 168 | SceSize size; 169 | char nsegment; 170 | char reserved[3]; 171 | int segmentaddr[4]; 172 | int segmentsize[4]; 173 | unsigned int entry_addr; 174 | unsigned int gp_value; 175 | unsigned int text_addr; 176 | unsigned int text_size; 177 | unsigned int data_size; 178 | unsigned int bss_size; 179 | /* The following is only available in the v1.5 firmware and above, 180 | but as sceKernelQueryModuleInfo is broken in v1.0 is doesn't matter ;) */ 181 | unsigned short attribute; 182 | unsigned char version[2]; 183 | char name[28]; 184 | } SceKernelModuleInfo; 185 | 186 | /** 187 | * Query the information about a loaded module from its UID. 188 | * @note This fails on v1.0 firmware (and even it worked has a limited structure) 189 | * so if you want to be compatible with both 1.5 and 1.0 (and you are running in 190 | * kernel mode) then call this function first then ::pspSdkQueryModuleInfoV1 191 | * if it fails, or make separate v1 and v1.5+ builds. 192 | * 193 | * @param modid - The UID of the loaded module. 194 | * @param info - Pointer to a ::SceKernelModuleInfo structure. 195 | * 196 | * @return 0 on success, otherwise one of ::PspKernelErrorCodes. 197 | */ 198 | int sceKernelQueryModuleInfo(SceUID modid, SceKernelModuleInfo *info); 199 | 200 | /** 201 | * Get a list of module IDs. NOTE: This is only available on 1.5 firmware 202 | * and above. For V1 use ::pspSdkGetModuleIdList. 203 | * 204 | * @param readbuf - Buffer to store the module list. 205 | * @param readbufsize - Number of elements in the readbuffer. 206 | * @param idcount - Returns the number of module ids 207 | * 208 | * @return >= 0 on success 209 | */ 210 | int sceKernelGetModuleIdList(SceUID *readbuf, int readbufsize, int *idcount); 211 | 212 | /** 213 | * Load a module protected by DRM... 214 | * 215 | * @param path - The path to the module to load. 216 | * @param flags - Unused, always 0 . 217 | * @param option - Pointer to a mod_param_t structure. Can be NULL. 218 | * 219 | * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes. 220 | */ 221 | SceUID ModuleMgrForUser_FEF27DC1(const char *path, int flags, SceKernelLMOption *option); 222 | 223 | #define sceKernelLoadModuleDNAS ModuleMgrForUser_FEF27DC1 224 | 225 | /** 226 | * Stop and unload the current module with the specified exit status code 227 | * 228 | * @param exitcode - The exitcode for the module 229 | * @param argsize - Size (in bytes) of the arguments that will be passed to module_stop(). 230 | * @param argp - Poitner to arguments that will be passed to module_stop(). 231 | * @param status - Return value from module_stop(). 232 | * @param option - Pointer to an optional ::SceKernelSMOption structure. 233 | * 234 | * @returns ??? on success, otherwise one of ::PspKernelErrorCodes. 235 | */ 236 | int ModuleMgrForUser_8F2DF740(int exitcode, SceSize argsize, void *argp, int *status, SceKernelSMOption *option); 237 | 238 | #define sceKernelStopUnloadSelfModuleWithStatus ModuleMgrForUser_8F2DF740 239 | 240 | /*@}*/ 241 | 242 | #ifdef __cplusplus 243 | } 244 | #endif 245 | 246 | #endif 247 | -------------------------------------------------------------------------------- /source/SDK/include/pspmodulemgr_kernel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/include/pspmodulemgr_kernel.h -------------------------------------------------------------------------------- /source/SDK/include/pspsysmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PSP Software Development Kit - http://www.pspdev.org 3 | * ----------------------------------------------------------------------- 4 | * Licensed under the BSD license, see LICENSE in PSPSDK root for details. 5 | * 6 | * pspsysmem.h - Interface to the system memory manager. 7 | * 8 | * Copyright (c) 2005 Marcus R. Brown 9 | * 10 | * $Id: pspsysmem.h 1961 2006-07-04 04:14:56Z jim $ 11 | */ 12 | 13 | /* Note: Some of the structures, types, and definitions in this file were 14 | extrapolated from symbolic debugging information found in the Japanese 15 | version of Puzzle Bobble. */ 16 | 17 | #ifndef PSPSYSMEM_H 18 | #define PSPSYSMEM_H 19 | 20 | #include 21 | 22 | /** @defgroup SysMem System Memory Manager 23 | * This module contains routines to manage heaps of memory. 24 | */ 25 | 26 | /** @addtogroup SysMem System Memory Manager */ 27 | /*@{*/ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /** Specifies the type of allocation used for memory blocks. */ 34 | enum PspSysMemBlockTypes { 35 | /** Allocate from the lowest available address. */ 36 | PSP_SMEM_Low = 0, 37 | /** Allocate from the highest available address. */ 38 | PSP_SMEM_High, 39 | /** Allocate from the specified address. */ 40 | PSP_SMEM_Addr 41 | }; 42 | 43 | typedef int SceKernelSysMemAlloc_t; 44 | 45 | /** 46 | * Allocate a memory block from a memory partition. 47 | * 48 | * @param partitionid - The UID of the partition to allocate from. 49 | * @param name - Name assigned to the new block. 50 | * @param type - Specifies how the block is allocated within the partition. One of ::PspSysMemBlockTypes. 51 | * @param size - Size of the memory block, in bytes. 52 | * @param addr - If type is PSP_SMEM_Addr, then addr specifies the lowest address allocate the block from. 53 | * 54 | * @returns The UID of the new block, or if less than 0 an error. 55 | */ 56 | SceUID sceKernelAllocPartitionMemory(SceUID partitionid, const char *name, int type, SceSize size, void *addr); 57 | 58 | /** 59 | * Free a memory block allocated with ::sceKernelAllocPartitionMemory. 60 | * 61 | * @param blockid - UID of the block to free. 62 | * 63 | * @returns ? on success, less than 0 on error. 64 | */ 65 | int sceKernelFreePartitionMemory(SceUID blockid); 66 | 67 | /** 68 | * Get the address of a memory block. 69 | * 70 | * @param blockid - UID of the memory block. 71 | * 72 | * @returns The lowest address belonging to the memory block. 73 | */ 74 | void * sceKernelGetBlockHeadAddr(SceUID blockid); 75 | 76 | /** 77 | * Get the total amount of free memory. 78 | * 79 | * @returns The total amount of free memory, in bytes. 80 | */ 81 | SceSize sceKernelTotalFreeMemSize(void); 82 | 83 | /** 84 | * Get the size of the largest free memory block. 85 | * 86 | * @returns The size of the largest free memory block, in bytes. 87 | */ 88 | SceSize sceKernelMaxFreeMemSize(void); 89 | 90 | /** 91 | * Get the firmware version. 92 | * 93 | * @returns The firmware version. 94 | * 0x01000300 on v1.00 unit, 95 | * 0x01050001 on v1.50 unit, 96 | * 0x01050100 on v1.51 unit, 97 | * 0x01050200 on v1.52 unit, 98 | * 0x02000010 on v2.00/v2.01 unit, 99 | * 0x02050010 on v2.50 unit, 100 | * 0x02060010 on v2.60 unit, 101 | * 0x02070010 on v2.70 unit, 102 | * 0x02070110 on v2.71 unit. 103 | */ 104 | int sceKernelDevkitVersion(void); 105 | 106 | /** 107 | * 108 | * Set the SDK version of the current application. 109 | * All licensed games seem to set this value in the crt0 110 | * 111 | * @param sdkversion - The sdkversion to set (e.g.: 0x02070110 in applicationc compiled for firmware 2.71) 112 | * 113 | * @returns 0 114 | */ 115 | int sceKernelSetCompiledSdkVersion(int sdkversion); 116 | 117 | /** 118 | * 119 | * Get the SDK version of the current application, previously set with sceKernelSetCompiledSdkVersion 120 | * 121 | * @returns The sdk version 122 | */ 123 | int sceKernelGetCompiledSdkVersion(void); 124 | 125 | /** 126 | * 127 | * Set the compiler version of the current application. 128 | * All licensed games seem to set this value in the crt0 129 | * 130 | * @param version - The compiler version to set 131 | * 132 | * @returns 0 133 | */ 134 | int sceKernelSetCompilerVersion(int version); 135 | 136 | /** 137 | * 138 | * Get the compiler version of the current application, previously set with sceKernelSetCompilerVersion 139 | * 140 | * @returns The compiler version 141 | */ 142 | int sceKernelGetCompilerVersion(void); 143 | 144 | 145 | #ifdef __cplusplus 146 | } 147 | #endif 148 | 149 | /*@}*/ 150 | 151 | #endif /* PSPSYSMEM_H */ 152 | -------------------------------------------------------------------------------- /source/SDK/include/pspsysmem_kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PSP Software Development Kit - http://www.pspdev.org 3 | * ----------------------------------------------------------------------- 4 | * Licensed under the BSD license, see LICENSE in PSPSDK root for details. 5 | * 6 | * pspsysmem_kernel.h - Interface to the system memory manager (kernel). 7 | * 8 | * Copyright (c) 2005 James F. 9 | * 10 | * $Id: pspsysmem.h 1095 2005-09-27 21:02:16Z jim $ 11 | */ 12 | 13 | /* Note: Some of the structures, types, and definitions in this file were 14 | extrapolated from symbolic debugging information found in the Japanese 15 | version of Puzzle Bobble. */ 16 | 17 | #ifndef PSPSYSMEMKERNEL_H 18 | #define PSPSYSMEMKERNEL_H 19 | 20 | #include 21 | #include 22 | 23 | /** @defgroup SysMemKern System Memory Manager Kernel 24 | * This module contains routines to manage heaps of memory. 25 | */ 26 | 27 | /** @addtogroup SysMemKern System Memory Manager Kernel */ 28 | /*@{*/ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | typedef struct _PspSysmemPartitionInfo 35 | { 36 | SceSize size; 37 | unsigned int startaddr; 38 | unsigned int memsize; 39 | unsigned int attr; 40 | } PspSysmemPartitionInfo; 41 | 42 | enum PspModel 43 | { 44 | PSP_MODEL_STANDARD = 0, 45 | PSP_MODEL_SLIM_AND_LITE = 1 46 | }; 47 | 48 | /** 49 | * Query the parition information 50 | * 51 | * @param pid - The partition id 52 | * @param info - Pointer to the ::PspSysmemPartitionInfo structure 53 | * 54 | * @returns 0 on success. 55 | */ 56 | int sceKernelQueryMemoryPartitionInfo(int pid, PspSysmemPartitionInfo *info); 57 | 58 | /** 59 | * Get the total amount of free memory. 60 | * 61 | * @param pid - The partition id 62 | * 63 | * @returns The total amount of free memory, in bytes. 64 | */ 65 | SceSize sceKernelPartitionTotalFreeMemSize(int pid); 66 | 67 | /** 68 | * Get the size of the largest free memory block. 69 | * 70 | * @param pid - The partition id 71 | * 72 | * @returns The size of the largest free memory block, in bytes. 73 | */ 74 | SceSize sceKernelPartitionMaxFreeMemSize(int pid); 75 | 76 | /** 77 | * Get the kernel to dump the internal memory table to Kprintf 78 | */ 79 | void sceKernelSysMemDump(void); 80 | 81 | /** 82 | * Dump the list of memory blocks 83 | */ 84 | void sceKernelSysMemDumpBlock(void); 85 | 86 | /** 87 | * Dump the tail blocks 88 | */ 89 | void sceKernelSysMemDumpTail(void); 90 | 91 | /** 92 | * Set the protection of a block of ddr memory 93 | * 94 | * @param addr - Address to set protection on 95 | * @param size - Size of block 96 | * @param prot - Protection bitmask 97 | * 98 | * @return < 0 on error 99 | */ 100 | int sceKernelSetDdrMemoryProtection(void *addr, int size, int prot); 101 | 102 | /** 103 | * Create a heap. 104 | * 105 | * @param partitionid - The UID of the partition where allocate the heap. 106 | * @param size - The size in bytes of the heap. 107 | * @param unk - Unknown, probably some flag or type, pass 1. 108 | * @param name - Name assigned to the new heap. 109 | * 110 | * @returns The UID of the new heap, or if less than 0 an error. 111 | */ 112 | SceUID sceKernelCreateHeap(SceUID partitionid, SceSize size, int unk, const char *name); 113 | 114 | /** 115 | * Allocate a memory block from a heap. 116 | * 117 | * @param heapid - The UID of the heap to allocate from. 118 | * @param size - The number of bytes to allocate. 119 | * 120 | * @returns The address of the allocated memory block, or NULL on error. 121 | */ 122 | void *sceKernelAllocHeapMemory(SceUID heapid, SceSize size); 123 | 124 | /** 125 | * Free a memory block allocated from a heap. 126 | * 127 | * @param heapid - The UID of the heap where block belongs. 128 | * @param block - The block of memory to free from the heap. 129 | * 130 | * @returns 0 on success, < 0 on error. 131 | */ 132 | int sceKernelFreeHeapMemory(SceUID heapid, void *block); 133 | 134 | /** 135 | * Delete a heap. 136 | * 137 | * @param heapid - The UID of the heap to delete. 138 | * 139 | * @returns 0 on success, < 0 on error. 140 | */ 141 | int sceKernelDeleteHeap(SceUID heapid); 142 | 143 | /** 144 | * Get the amount of free size of a heap, in bytes. 145 | * 146 | * @param heapid - The UID of the heap 147 | * 148 | * @returns the free size of the heap, in bytes. < 0 on error. 149 | */ 150 | SceSize sceKernelHeapTotalFreeSize(SceUID heapid); 151 | 152 | /** Structure of a UID control block */ 153 | struct _uidControlBlock { 154 | struct _uidControlBlock *parent; 155 | struct _uidControlBlock *nextChild; 156 | struct _uidControlBlock *type; //(0x8) 157 | u32 UID; //(0xC) 158 | char *name; //(0x10) 159 | unsigned char unk; 160 | unsigned char size; // Size in words 161 | short attribute; 162 | struct _uidControlBlock *nextEntry; 163 | } __attribute__((packed)); 164 | typedef struct _uidControlBlock uidControlBlock; 165 | 166 | /** 167 | * Get a UID control block 168 | * 169 | * @param uid - The UID to find 170 | * @param block - Pointer to hold the pointer to the block 171 | * 172 | * @return 0 on success 173 | */ 174 | int sceKernelGetUIDcontrolBlock(SceUID uid, uidControlBlock** block); 175 | 176 | /** 177 | * Get a UID control block on a particular type 178 | * 179 | * @param uid - The UID to find 180 | * @param type - Pointer to the type UID block 181 | * @param block - Pointer to hold the pointer to the block 182 | * 183 | * @return 0 on success 184 | */ 185 | int sceKernelGetUIDcontrolBlockWithType(SceUID uid, uidControlBlock* type, uidControlBlock** block); 186 | 187 | /** 188 | * Get the root of the UID tree (1.5+ only) 189 | * 190 | * @return Pointer to the UID tree root 191 | */ 192 | uidControlBlock* SysMemForKernel_536AD5E1(void); 193 | 194 | /** 195 | * Delete a UID 196 | * 197 | * @param uid - The UID to delete 198 | * 199 | * @return 0 on success 200 | */ 201 | int sceKernelDeleteUID(SceUID uid); 202 | 203 | /** 204 | * Gets the model of the PSP. 205 | * 206 | * @returns one of PspModel values. 207 | */ 208 | int sceKernelGetModel(void); 209 | 210 | #ifdef __cplusplus 211 | } 212 | #endif 213 | 214 | /*@}*/ 215 | 216 | #endif /* PSPSYSMEMKERNEL_H */ 217 | -------------------------------------------------------------------------------- /source/SDK/include/pspusbdevice.h: -------------------------------------------------------------------------------- 1 | #ifndef __PSPUSBDEVICE_H__ 2 | #define __PSPUSBDEVICE_H__ 3 | 4 | /** 5 | * This functions require flash0:/kd/usbdevice.prx to be loaded/started first. 6 | 7 | * Link with pspusbdevice for user mode access or with pspusbdevice_driver for kernel access 8 | */ 9 | 10 | #define PSP_USBDEVICE_FLASH0 0 11 | #define PSP_USBDEVICE_FLASH1 1 12 | #define PSP_USBDEVICE_FLASH2 2 13 | #define PSP_USBDEVICE_FLASH3 3 14 | #define PSP_USBDEVICE_UMD9660 4 15 | 16 | #define UNASSIGN_MASK_FLASH0 1 17 | #define UNASSIGN_MASK_FLASH1 2 18 | #define UNASSIGN_MASK_FLASH2 3 19 | #define UNASSIGN_MASK_FLASH3 4 20 | 21 | /** 22 | * Sets the usb device. Call this function when you are about to do the sceUsbStart and sceUsbActivate stuff 23 | * 24 | * @param device - The usb device, one of listed above. 25 | * @param ronly - If non-zero indicates read only access. This parameters is ignored for PSP_USBDEVICE_UMD9660 26 | * @param unassign_mask - It unassigns automatically the flashes indicated by the mask. 27 | * The flashes will be reassigned automatically after calling pspUsbDeviceFinishDevice 28 | * 29 | * Set this param to 0 if you don't need it (vshctrl doesn't use it). 30 | * 31 | * @returns 0 on success, < 0 on error. 32 | */ 33 | int pspUsbDeviceSetDevice(u32 device, int ronly, int unassign_mask); 34 | 35 | /** 36 | * Finishes the usb device. Call this function after stoping usbstor driver 37 | * 38 | * @returns 0 in success, < 0 on error 39 | */ 40 | int pspUsbDeviceFinishDevice(); 41 | 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /source/SDK/include/systemctrl.h: -------------------------------------------------------------------------------- 1 | #ifndef __SCTRLLIBRARY_H__ 2 | #define __SCTRLLIBRARY_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | enum BootLoadFlags 11 | { 12 | BOOTLOAD_VSH = 1, 13 | BOOTLOAD_GAME = 2, 14 | BOOTLOAD_UPDATER = 4, 15 | BOOTLOAD_POPS = 8, 16 | BOOTLOAD_UMDEMU = 64, /* for original NP9660 */ 17 | }; 18 | 19 | /** 20 | * Restart the vsh. 21 | * 22 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL 23 | * 24 | * @returns < 0 on some errors. 25 | * 26 | */ 27 | int sctrlKernelExitVSH(struct SceKernelLoadExecVSHParam *param); 28 | 29 | /** 30 | * Executes a new executable from a disc. 31 | * It is the function used by the firmware to execute the EBOOT.BIN from a disc. 32 | * 33 | * @param file - The file to execute. 34 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 35 | * 36 | * @returns < 0 on some errors. 37 | */ 38 | int sctrlKernelLoadExecVSHDisc(const char *file, struct SceKernelLoadExecVSHParam *param); 39 | 40 | /** 41 | * Executes a new executable from a disc. 42 | * It is the function used by the firmware to execute an updater from a disc. 43 | * 44 | * @param file - The file to execute. 45 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 46 | * 47 | * @returns < 0 on some errors. 48 | */ 49 | int sctrlKernelLoadExecVSHDiscUpdater(const char *file, struct SceKernelLoadExecVSHParam *param); 50 | 51 | /** 52 | * Executes a new executable from a memory stick. 53 | * It is the function used by the firmware to execute an updater from a memory stick. 54 | * 55 | * @param file - The file to execute. 56 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 57 | * 58 | * @returns < 0 on some errors. 59 | */ 60 | int sctrlKernelLoadExecVSHMs1(const char *file, struct SceKernelLoadExecVSHParam *param); 61 | 62 | /** 63 | * Executes a new executable from a memory stick. 64 | * It is the function used by the firmware to execute games (and homebrew :P) from a memory stick. 65 | * 66 | * @param file - The file to execute. 67 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 68 | * 69 | * @returns < 0 on some errors. 70 | */ 71 | int sctrlKernelLoadExecVSHMs2(const char *file, struct SceKernelLoadExecVSHParam *param); 72 | 73 | /** 74 | * Executes a new executable from a memory stick. 75 | * It is the function used by the firmware to execute ... ? 76 | * 77 | * @param file - The file to execute. 78 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 79 | * 80 | * @returns < 0 on some errors. 81 | */ 82 | int sctrlKernelLoadExecVSHMs3(const char *file, struct SceKernelLoadExecVSHParam *param); 83 | 84 | /** 85 | * Executes a new executable from a memory stick. 86 | * It is the function used by the firmware to execute psx games 87 | * 88 | * @param file - The file to execute. 89 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 90 | * 91 | * @returns < 0 on some errors. 92 | */ 93 | int sctrlKernelLoadExecVSHMs4(const char *file, struct SceKernelLoadExecVSHParam *param); 94 | 95 | 96 | /** 97 | * Executes a new executable with the specified apitype 98 | * 99 | * @param apitype - The apitype 100 | * @param file - The file to execute. 101 | * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. 102 | * 103 | * @returns < 0 on some errors. 104 | */ 105 | int sctrlKernelLoadExecVSHWithApitype(int apitype, const char *file, struct SceKernelLoadExecVSHParam *param); 106 | 107 | /** 108 | * Sets the api type 109 | * 110 | * @param apitype - The apitype to set 111 | * @returns the previous apitype 112 | * 113 | * @Note - this will modify also the value of sceKernelBootFrom, since the value of 114 | * bootfrom is calculated from the apitype 115 | */ 116 | int sctrlKernelSetInitApitype(int apitype); 117 | 118 | /** 119 | * Sets the filename of the launched executable. 120 | * 121 | * @param filename - The filename to set 122 | * @returns 0 on success 123 | */ 124 | int sctrlKernelSetInitFileName(char *filename); 125 | 126 | /** 127 | * Sets the init key config 128 | * 129 | * @param key - The key code 130 | * @returns the previous key config 131 | */ 132 | int sctrlKernelSetInitKeyConfig(int key); 133 | 134 | /** 135 | * Sets the user level of the current thread 136 | * 137 | * @param level - The user level 138 | * @return the previous user level on success 139 | */ 140 | int sctrlKernelSetUserLevel(int level); 141 | 142 | /** 143 | * Sets the devkit version 144 | * 145 | * @param version - The devkit version to set 146 | * @return the previous devkit version 147 | * 148 | */ 149 | int sctrlKernelSetDevkitVersion(int version); 150 | 151 | /** 152 | * Checks if we are in SE. 153 | * 154 | * @returns 1 if we are in SE-C or later, 0 if we are in HEN-D or later, 155 | * and < 0 (a kernel error code) in any other case 156 | */ 157 | int sctrlHENIsSE(); 158 | 159 | /** 160 | * Checks if we are in Devhook. 161 | * 162 | * @returns 1 if we are in SE-C/HEN-D for devhook or later, 0 if we are in normal SE-C/HEN-D or later, 163 | * and < 0 (a kernel error code) in any other case 164 | */ 165 | int sctrlHENIsDevhook(); 166 | 167 | /** 168 | * Gets the HEN version 169 | * 170 | * @returns - The HEN version 171 | * 172 | * HEN D / SE-C : 0x00000400 173 | */ 174 | int sctrlHENGetVersion(); 175 | 176 | /** 177 | * Finds a driver 178 | * 179 | * @param drvname - The name of the driver (without ":" or numbers) 180 | * 181 | * @returns the driver if found, NULL otherwise 182 | * 183 | */ 184 | PspIoDrv *sctrlHENFindDriver(char *drvname); 185 | 186 | /** 187 | * Finds a function. 188 | * 189 | * @param szMod - The module where to search the function 190 | * @param szLib - The library name 191 | * @param nid - The nid of the function 192 | * 193 | * @returns - The function address or 0 if not found 194 | * 195 | */ 196 | u32 sctrlHENFindFunction(const char* szMod, const char* szLib, u32 nid); 197 | 198 | #define FindProc sctrlHENFindFunction 199 | 200 | typedef int (* STMOD_HANDLER)(SceModule2 *); 201 | 202 | /** 203 | * Sets a function to be called just before module_start of a module is gonna be called (useful for patching purposes) 204 | * 205 | * @param handler - The function, that will receive the module structure before the module is started. 206 | * 207 | * @returns - The previous set function (NULL if none); 208 | * @Note: because only one handler function is handled by HEN, you should 209 | * call the previous function in your code. 210 | * 211 | * @Example: 212 | * 213 | * STMOD_HANDLER previous = NULL; 214 | * 215 | * int OnModuleStart(SceModule2 *mod); 216 | * 217 | * void somepointofmycode() 218 | * { 219 | * previous = sctrlHENSetStartModuleHandler(OnModuleStart); 220 | * } 221 | * 222 | * int OnModuleStart(SceModule2 *mod) 223 | * { 224 | * if (strcmp(mod->modname, "vsh_module") == 0) 225 | * { 226 | * // Do something with vsh module here 227 | * } 228 | * 229 | * if (!previous) 230 | * return 0; 231 | * 232 | * // Call previous handler 233 | * 234 | * return previous(mod); 235 | * } 236 | * 237 | * @Note2: The above example should be compiled with the flag -fno-pic 238 | * in order to avoid problems with gp register that may lead to a crash. 239 | * 240 | */ 241 | STMOD_HANDLER sctrlHENSetStartModuleHandler(STMOD_HANDLER handler); 242 | 243 | /** 244 | * Sets the partition 2 and 8 memory for next loadexec. 245 | * 246 | * @param p2 - The size in MB for the user partition. Must be > 0 247 | * @param p8 - The size in MB for partition 8. Can be 0. 248 | * 249 | * @returns 0 on success, < 0 on error. 250 | * This function is only available in the slim. The function will fail 251 | * if p2+p8 > 52 or p2 == 0 252 | */ 253 | int sctrlHENSetMemory(u32 p2, u32 p8); 254 | 255 | /** 256 | * Loads a module on next reboot. Only kernel mode. 257 | * 258 | * @param module_after - The path of the module which is loaded after the module to be loaded. 259 | The module passed to this function will be loaded just before that module. 260 | * @param buf - The buffer containing the module - Don't deallocate this one. It has to reside in kernel memory. 261 | * @param size - The size of the module 262 | * @param flags - The modes in which the module should be loaded, one of BootLoadFlags 263 | * 264 | * @Example: 265 | * sctrlHENLoadModuleOnReboot("/kd/usersystemlib.prx", module_buffer, module_size, BOOTLOAD_GAME | BOOTLOAD_POPS | BOOTLOAD_UMDEMU); 266 | * 267 | * This will load the module contained in module_buffer just before /kd/usersystemlib.prx in the next reboot, if the mode of next reboot is game, pops or umdemu 268 | * 269 | * @Remarks: Don't use too early modules in first param like "/kd/init.prx" or "/kd/systemctrl.prx", or your module may not load properly 270 | * Only one module will be loaded on reboot with this function. 271 | * If this function is called many times, only the last one will be considered. 272 | * By making a module to load itself using this function, and calling 273 | * sctrlHENLoadModuleOnReboot on module_start, a prx can cause itself to be resident in the modes choosen by flags. 274 | * If all flags are selected, the module will stay resident until a psp shutdown, or until sctrlHENLoadModuleOnReboot is not called. 275 | */ 276 | 277 | void sctrlHENLoadModuleOnReboot(char *module_after, void *buf, int size, int flags); 278 | 279 | /** Changes a syscall to another function 280 | * 281 | * @param addr - the address of the original function 282 | * @param newaddr - the address of the new function 283 | */ 284 | void sctrlHENPatchSyscall(u32 addr, void *newaddr); 285 | 286 | #endif 287 | 288 | 289 | 290 | -------------------------------------------------------------------------------- /source/SDK/include/systemctrl_se.h: -------------------------------------------------------------------------------- 1 | #ifndef __SCTRLLIBRARY_SE_H__ 2 | #define __SCTRLLIBRARY_SE_H__ 3 | 4 | /** 5 | * These functions are only available in SE-C and later, 6 | * and they are not in HEN 7 | */ 8 | 9 | enum 10 | { 11 | FAKE_REGION_DISABLED = 0, 12 | FAKE_REGION_JAPAN = 1, 13 | FAKE_REGION_AMERICA = 2, 14 | FAKE_REGION_EUROPE = 3, 15 | FAKE_REGION_KOREA = 4, /* do not use, may cause brick on restore default settings */ 16 | FAKE_REGION_UNK = 5, 17 | FAKE_REGION_UNK2 = 6, 18 | FAKE_REGION_AUSTRALIA = 7, 19 | FAKE_REGION_HONGKONG = 8, /* do not use, may cause brick on restore default settings */ 20 | FAKE_REGION_TAIWAN = 9, /* do not use, may cause brick on restore default settings */ 21 | FAKE_REGION_RUSSIA = 10, 22 | FAKE_REGION_CHINA = 11, /* do not use, may cause brick on restore default settings */ 23 | }; 24 | 25 | 26 | enum SEUmdModes 27 | { 28 | MODE_UMD = 0, 29 | MODE_OE_LEGACY = 1, 30 | MODE_MARCH33 = 2, 31 | MODE_NP9660 = 3, 32 | }; 33 | 34 | typedef struct 35 | { 36 | int magic; /* 0x47434553 */ 37 | int hidecorrupt; 38 | int skiplogo; 39 | int umdactivatedplaincheck; 40 | int gamekernel150; 41 | int executebootbin; 42 | int startupprog; 43 | int umdmode; 44 | int useisofsonumdinserted; 45 | int vshcpuspeed; 46 | int vshbusspeed; 47 | int umdisocpuspeed; 48 | int umdisobusspeed; 49 | int fakeregion; 50 | int freeumdregion; 51 | int hardresetHB; 52 | int usbdevice; 53 | int novshmenu; 54 | int usbcharge; 55 | int notusedaxupd; 56 | int reserved[2]; 57 | } SEConfig; 58 | 59 | 60 | /** 61 | * Gets the SE/OE version 62 | * 63 | * @returns the SE version 64 | * 65 | * 3.03 OE-A: 0x00000500 66 | */ 67 | int sctrlSEGetVersion(); 68 | 69 | /** 70 | * Gets the SE configuration. 71 | * Avoid using this function, it may corrupt your program. 72 | * Use sctrlSEGetCongiEx function instead. 73 | * 74 | * @param config - pointer to a SEConfig structure that receives the SE configuration 75 | * @returns 0 on success 76 | */ 77 | int sctrlSEGetConfig(SEConfig *config); 78 | 79 | /** 80 | * Gets the SE configuration 81 | * 82 | * @param config - pointer to a SEConfig structure that receives the SE configuration 83 | * @param size - The size of the structure 84 | * @returns 0 on success 85 | */ 86 | int sctrlSEGetConfigEx(SEConfig *config, int size); 87 | 88 | /** 89 | * Sets the SE configuration 90 | * This function can corrupt the configuration in flash, use 91 | * sctrlSESetConfigEx instead. 92 | * 93 | * @param config - pointer to a SEConfig structure that has the SE configuration to set 94 | * @returns 0 on success 95 | */ 96 | int sctrlSESetConfig(SEConfig *config); 97 | 98 | /** 99 | * Sets the SE configuration 100 | * 101 | * @param config - pointer to a SEConfig structure that has the SE configuration to set 102 | * @param size - the size of the structure 103 | * @returns 0 on success 104 | */ 105 | int sctrlSESetConfigEx(SEConfig *config, int size); 106 | 107 | /** 108 | * Initiates the emulation of a disc from an ISO9660/CSO file. 109 | * 110 | * @param file - The path of the 111 | * @param noumd - Wether use noumd or not 112 | * @param isofs - Wether use the custom SE isofs driver or not 113 | * 114 | * @returns 0 on success 115 | * 116 | * @Note - When setting noumd to 1, isofs should also be set to 1, 117 | * otherwise the umd would be still required. 118 | * 119 | * @Note 2 - The function doesn't check if the file is valid or even if it exists 120 | * and it may return success on those cases 121 | * 122 | * @Note 3 - This function is not available in SE for devhook 123 | * @Example: 124 | * 125 | * SEConfig config; 126 | * 127 | * sctrlSEGetConfig(&config); 128 | * 129 | * if (config.usenoumd) 130 | * { 131 | * sctrlSEMountUmdFromFile("ms0:/ISO/mydisc.iso", 1, 1); 132 | * } 133 | * else 134 | * { 135 | * sctrlSEMountUmdFromFile("ms0:/ISO/mydisc.iso", 0, config.useisofsonumdinserted); 136 | * } 137 | */ 138 | int sctrlSEMountUmdFromFile(char *file, int noumd, int isofs); 139 | 140 | /** 141 | * Umounts an iso. 142 | * 143 | * @returns 0 on success 144 | */ 145 | int sctrlSEUmountUmd(void); 146 | 147 | /** 148 | * Forces the umd disc out state 149 | * 150 | * @param out - non-zero for disc out, 0 otherwise 151 | * 152 | */ 153 | void sctrlSESetDiscOut(int out); 154 | 155 | /** 156 | * Sets the disctype. 157 | * 158 | * @param type - the disctype (0x10=game, 0x20=video, 0x40=audio) 159 | */ 160 | void sctrlSESetDiscType(int type); 161 | 162 | /** 163 | * Sets the current umd file (kernel only) 164 | */ 165 | char *sctrlSEGetUmdFile(); 166 | 167 | /** 168 | * Gets the current umd file (kernel only) 169 | */ 170 | char *sctrlSEGetUmdFile(); 171 | 172 | /** 173 | * Sets the current umd file (kernel only) 174 | * 175 | * @param file - The umd file 176 | */ 177 | void sctrlSESetUmdFile(char *file); 178 | 179 | /** 180 | * Sets the boot config file for next reboot (kernel only) 181 | * 182 | * @param index - The index identifying the file (0 -> normal bootconf, 1 -> march33 driver bootconf, 2 -> np9660 bootcnf) 183 | */ 184 | void sctrlSESetBootConfFileIndex(int index); 185 | 186 | #endif 187 | -------------------------------------------------------------------------------- /source/SDK/include/vshctrl.h: -------------------------------------------------------------------------------- 1 | #ifndef __VSHCTRL_H__ 2 | #define __VSHCTRL_H__ 3 | 4 | /** 5 | * This api is for vsh menu. (flash0:/vsh/module/satelite.prx) 6 | * 7 | * The vsh menu is an user mode module, and because of this, these functions are 8 | * only available to user mode. 9 | */ 10 | 11 | /** 12 | * Registers the vsh menu. 13 | * When HOME is pressed, vshctrl will load the satelite module. 14 | * In module_start, call this function to register the vsh menu. 15 | * 16 | * @param ctrl - The function that will be executed each time 17 | * the system calls ReadBufferPositive. Despite satelite.prx being 18 | * an user module, this function will be executed in kernel mode. 19 | * 20 | * @returns 0 on success, < 0 on error. 21 | */ 22 | int vctrlVSHRegisterVshMenu(int (* ctrl)(SceCtrlData *, int)); 23 | 24 | /** 25 | * Exits the vsh menu. 26 | * vshmenu module must call this module after destroying vsh menu display and 27 | * freeing resources. 28 | * 29 | * vshmenu module doesn't need to stop-unload itself, as that is vshctrl job. 30 | * 31 | * @param conf - Indicates the new config. vshctrl will update the internal 32 | * vshctrl and systemctrl variables with the new configuration given by this param. 33 | * However is job of satelite.prx to save those settings to the configuration file. 34 | * using sctrlSESetConfig. 35 | * 36 | * @param videoiso - Indicates the videoiso to mount, or NULL if none. 37 | * @param disctype - The disctype of the videoiso (0x20=video, 0x40=audio) 38 | * 39 | * @returns 0 on success, < 0 on error. 40 | */ 41 | int vctrlVSHExitVSHMenu(SEConfig *conf, char *videoiso, int disctype); 42 | 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /source/SDK/lib/1: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /source/SDK/lib/libpspinit.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpspinit.a -------------------------------------------------------------------------------- /source/SDK/lib/libpspkdebug.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpspkdebug.a -------------------------------------------------------------------------------- /source/SDK/lib/libpspkubridge.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpspkubridge.a -------------------------------------------------------------------------------- /source/SDK/lib/libpsploadexec_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpsploadexec_kernel.a -------------------------------------------------------------------------------- /source/SDK/lib/libpspmodulemgr_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpspmodulemgr_kernel.a -------------------------------------------------------------------------------- /source/SDK/lib/libpspmodulemgr_user.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpspmodulemgr_user.a -------------------------------------------------------------------------------- /source/SDK/lib/libpspsysmem_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpspsysmem_kernel.a -------------------------------------------------------------------------------- /source/SDK/lib/libpspsysmem_user.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpspsysmem_user.a -------------------------------------------------------------------------------- /source/SDK/lib/libpspsystemctrl_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpspsystemctrl_kernel.a -------------------------------------------------------------------------------- /source/SDK/lib/libpspsystemctrl_user.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpspsystemctrl_user.a -------------------------------------------------------------------------------- /source/SDK/lib/libpspumd_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpspumd_kernel.a -------------------------------------------------------------------------------- /source/SDK/lib/libpspusbdevice.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpspusbdevice.a -------------------------------------------------------------------------------- /source/SDK/lib/libpspusbdevice_driver.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpspusbdevice_driver.a -------------------------------------------------------------------------------- /source/SDK/lib/libpspvshctrl.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/SDK/lib/libpspvshctrl.a -------------------------------------------------------------------------------- /source/SDK/readme.txt: -------------------------------------------------------------------------------- 1 | SDK for 4.01 M33 2 | 3 | This update adds the function sctrlHENLoadModuleOnReboot which may be used for programs that 4 | need to have reboot control (e.g. shells). 5 | 6 | A sample is included in samples/bootload. 7 | 8 | Copy EBOOT.PBP and rdriver.prx to /PSP/GAME4XX/bootload (the sample will not work in other path). 9 | The sample demonstrates how to load homebrew, isos, and psx games, while still having the control 10 | of returning to your application. 11 | 12 | ----- 13 | 14 | psp-packer, this tool is to compress prx's and pbp's. This is only for 3.xx and 4.xx kernel. 15 | What the tool can compress and its compatibility: 16 | 17 | kernel prx: yes, compatible with 3.71 M33-3 and higher 18 | PBP user: yes, compatible with 3.71 M33-1 or 3 (i don't remember) and higher 19 | PBP kernel and PBP vsh: no 20 | user prx: yes, compatible with 4.01 M33 and higher 21 | vsh prx: no. 22 | 23 | The usage of the tool is very simple: 24 | 25 | psp-packer myprx.prx -> it will compress myprx.prx in place 26 | psp-packer myprx.prx myprx_packed.prx -> it will compress myprx.prx into myprx_packed.prx 27 | 28 | If you want the prx to have a sce_header, add the "-s" switch before the other parameters. 29 | 30 | Note: pbps need to have 0x200 flags. If the user pbp has not those flags, the program will ask 31 | to convert it, this shouldn't cause any problem to the program. 32 | 33 | Windows binary is included. In linux x86, just type make and alternativelly make install. 34 | It won't work on big endian systems. 35 | -------------------------------------------------------------------------------- /source/copyright: -------------------------------------------------------------------------------- 1 | TempGBA 2 | 3 | Copyright (C) 2013 GBAtemp users Nebuleon, Normmatt and BassAceGold 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License as 7 | published by the Free Software Foundation; either version 2 of 8 | the License, or (at your option) any later version. 9 | 10 | This program 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 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | - - - Based on - - - 20 | 21 | gpSP (c) 2006 Exophase , 22 | improved by gpsp Kai unofficial (c) 2007 takka . 23 | 24 | This program is free software; you can redistribute it and/or 25 | modify it under the terms of the GNU General Public License as 26 | published by the Free Software Foundation; either version 2 of 27 | the License, or (at your option) any later version. 28 | 29 | This program is distributed in the hope that it will be useful, 30 | but WITHOUT ANY WARRANTY; without even the implied warranty of 31 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32 | General Public License for more details. 33 | 34 | You should have received a copy of the GNU General Public License 35 | along with this program; if not, write to the Free Software 36 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 37 | 38 | - - - Linking with - - - 39 | 40 | DSTwo Software Development Kit (SDK) 41 | 42 | Modifications (c) 2013 GBAtemp user BassAceGold 43 | 44 | Copyright information is in the source files. 45 | 46 | - - - Using icons - - - 47 | 48 | Game Boy Advance icon from the Gaming Icons Pack by deviantART user deleket. 49 | 50 | Some rights reserved. This work is licensed under a Creative Commons 51 | Attribution-Noncommercial-No Derivative Works 3.0 License. 52 | 53 | See it here: http://deleket.deviantart.com/art/Gaming-Icons-Pack-42723812 54 | 55 | The full text of the license is found here: 56 | http://creativecommons.org/licenses/by-nc-nd/3.0/ 57 | 58 | ---- 59 | 60 | sbutto.svg, smaini.svg, smnsel.svg, smsel.svg, smsgfr.svg, snmaini.svg, 61 | stitle.svg, subsela.svg: 62 | 63 | Created by GBAtemp user Nebuleon. 64 | 65 | Some rights reserved. This work is licensed under a Creative Commons 66 | Attribution-ShareAlike 3.0 license. 67 | 68 | The full text of the license is found here: 69 | http://creativecommons.org/licenses/by-sa/3.0/ 70 | 71 | ---- 72 | 73 | applications-system.svg, media-flash.svg, system-log-out.svg: 74 | 75 | Created by artists for the Tango Icon Project. 76 | 77 | This work is in the public domain. 78 | 79 | ---- 80 | 81 | key.svg, manage.svg, slide-audio.svg: 82 | 83 | Part of the RRZE Icon Set, (c) 2010 Regional Computing Centre of Erlangen 84 | (RRZE). 85 | 86 | Get it here: http://rrze-icon-set.berlios.de/download.html 87 | 88 | Some rights reserved. This work is licensed under a Creative Commons 89 | Attribution-ShareAlike 3.0 license. 90 | 91 | The full text of the license is found here: 92 | http://creativecommons.org/licenses/by-sa/3.0/ -------------------------------------------------------------------------------- /source/prx/exceptionHandler/README.txt: -------------------------------------------------------------------------------- 1 | Exception Handler for Kernel 3.71 2 | --------------------------------- 3 | All credits goes to crazyc (for the prx code) and SamuraiX (sample usage code) 4 | 5 | What is it? 6 | ----------- 7 | exception.prx is a prx that handle exception and can be used 8 | to show usefull information abuot a crash. 9 | 10 | 11 | How to build: 12 | ------------- 13 | To build exception.prx 14 | 15 | $cd prx 16 | $make 17 | 18 | To build the test program: 19 | $cd test 20 | $make 21 | 22 | 23 | How to use it: 24 | -------------- 25 | Include utility/exception.h in your main.c and init the handler with: 26 | 27 | initExceptionHandler(); 28 | 29 | Copy exception.prx in the same directory your EBOOT is. 30 | 31 | Please check the test program. ;) 32 | -------------------------------------------------------------------------------- /source/prx/exceptionHandler/prx/exception_asm.S: -------------------------------------------------------------------------------- 1 | #include "as_reg_compat.h" 2 | .set noreorder 3 | .set noat 4 | 5 | #define BadVAddr $8 // Address for the most recent address-related exception 6 | #define Status $12 // Processor status and control 7 | #define Cause $13 // Cause of last general exception 8 | #define EPC $14 // Program counter at last exception 9 | #define PRId $15 // Processor identification and revision 10 | 11 | #define FSR $31 12 | #define FIR $0 13 | 14 | #define REG_GPR_0 (6*4) 15 | #define REG_GPR_1 (REG_GPR_0 + 4) 16 | #define REG_GPR_2 (REG_GPR_1 + 4) 17 | #define REG_GPR_3 (REG_GPR_2 + 4) 18 | #define REG_GPR_4 (REG_GPR_3 + 4) 19 | #define REG_GPR_5 (REG_GPR_4 + 4) 20 | #define REG_GPR_6 (REG_GPR_5 + 4) 21 | #define REG_GPR_7 (REG_GPR_6 + 4) 22 | #define REG_GPR_8 (REG_GPR_7 + 4) 23 | #define REG_GPR_9 (REG_GPR_8 + 4) 24 | #define REG_GPR_10 (REG_GPR_9 + 4) 25 | #define REG_GPR_11 (REG_GPR_10 + 4) 26 | #define REG_GPR_12 (REG_GPR_11 + 4) 27 | #define REG_GPR_13 (REG_GPR_12 + 4) 28 | #define REG_GPR_14 (REG_GPR_13 + 4) 29 | #define REG_GPR_15 (REG_GPR_14 + 4) 30 | #define REG_GPR_16 (REG_GPR_15 + 4) 31 | #define REG_GPR_17 (REG_GPR_16 + 4) 32 | #define REG_GPR_18 (REG_GPR_17 + 4) 33 | #define REG_GPR_19 (REG_GPR_18 + 4) 34 | #define REG_GPR_20 (REG_GPR_19 + 4) 35 | #define REG_GPR_21 (REG_GPR_20 + 4) 36 | #define REG_GPR_22 (REG_GPR_21 + 4) 37 | #define REG_GPR_23 (REG_GPR_22 + 4) 38 | #define REG_GPR_24 (REG_GPR_23 + 4) 39 | #define REG_GPR_25 (REG_GPR_24 + 4) 40 | #define REG_GPR_26 (REG_GPR_25 + 4) 41 | #define REG_GPR_27 (REG_GPR_26 + 4) 42 | #define REG_GPR_28 (REG_GPR_27 + 4) 43 | #define REG_GPR_29 (REG_GPR_28 + 4) 44 | #define REG_GPR_30 (REG_GPR_29 + 4) 45 | #define REG_GPR_31 (REG_GPR_30 + 4) 46 | 47 | #define REG_STATUS (REG_GPR_31 + 4) 48 | #define REG_LO (REG_STATUS + 4) 49 | #define REG_HI (REG_LO + 4) 50 | #define REG_BADVADDR (REG_HI + 4) 51 | #define REG_CAUSE (REG_BADVADDR + 4) 52 | #define REG_EPC (REG_CAUSE + 4) 53 | 54 | #define REG_FPR_0 (REG_EPC + 4) 55 | #define REG_FPR_1 (REG_FPR_0 + 4) 56 | #define REG_FPR_2 (REG_FPR_1 + 4) 57 | #define REG_FPR_3 (REG_FPR_2 + 4) 58 | #define REG_FPR_4 (REG_FPR_3 + 4) 59 | #define REG_FPR_5 (REG_FPR_4 + 4) 60 | #define REG_FPR_6 (REG_FPR_5 + 4) 61 | #define REG_FPR_7 (REG_FPR_6 + 4) 62 | #define REG_FPR_8 (REG_FPR_7 + 4) 63 | #define REG_FPR_9 (REG_FPR_8 + 4) 64 | #define REG_FPR_10 (REG_FPR_9 + 4) 65 | #define REG_FPR_11 (REG_FPR_10 + 4) 66 | #define REG_FPR_12 (REG_FPR_11 + 4) 67 | #define REG_FPR_13 (REG_FPR_12 + 4) 68 | #define REG_FPR_14 (REG_FPR_13 + 4) 69 | #define REG_FPR_15 (REG_FPR_14 + 4) 70 | #define REG_FPR_16 (REG_FPR_15 + 4) 71 | #define REG_FPR_17 (REG_FPR_16 + 4) 72 | #define REG_FPR_18 (REG_FPR_17 + 4) 73 | #define REG_FPR_19 (REG_FPR_18 + 4) 74 | #define REG_FPR_20 (REG_FPR_19 + 4) 75 | #define REG_FPR_21 (REG_FPR_20 + 4) 76 | #define REG_FPR_22 (REG_FPR_21 + 4) 77 | #define REG_FPR_23 (REG_FPR_22 + 4) 78 | #define REG_FPR_24 (REG_FPR_23 + 4) 79 | #define REG_FPR_25 (REG_FPR_24 + 4) 80 | #define REG_FPR_26 (REG_FPR_25 + 4) 81 | #define REG_FPR_27 (REG_FPR_26 + 4) 82 | #define REG_FPR_28 (REG_FPR_27 + 4) 83 | #define REG_FPR_29 (REG_FPR_28 + 4) 84 | #define REG_FPR_30 (REG_FPR_29 + 4) 85 | #define REG_FPR_31 (REG_FPR_30 + 4) 86 | 87 | #define REG_FSR (REG_FPR_31 + 4) 88 | #define REG_FIR (REG_FSR + 4) 89 | #define REG_FP (REG_FIR + 4) 90 | 91 | .extern exception_regs 92 | .extern curr_handler 93 | 94 | .global _pspDebugExceptionHandler 95 | .ent _pspDebugExceptionHandler 96 | _pspDebugExceptionHandler: 97 | nop 98 | nop 99 | 100 | lw $v0, exception_regs 101 | sw $0, REG_GPR_0($v0) 102 | sw $1, REG_GPR_1($v0) 103 | 104 | cfc0 $1, $4 # Get original v0 105 | sw $1, REG_GPR_2($v0) 106 | cfc0 $1, $5 # Get original v1 107 | sw $1, REG_GPR_3($v0) 108 | sw $4, REG_GPR_4($v0) 109 | sw $5, REG_GPR_5($v0) 110 | sw $6, REG_GPR_6($v0) 111 | sw $7, REG_GPR_7($v0) 112 | sw $8, REG_GPR_8($v0) 113 | sw $9, REG_GPR_9($v0) 114 | sw $10, REG_GPR_10($v0) 115 | sw $11, REG_GPR_11($v0) 116 | sw $12, REG_GPR_12($v0) 117 | sw $13, REG_GPR_13($v0) 118 | sw $14, REG_GPR_14($v0) 119 | sw $15, REG_GPR_15($v0) 120 | sw $16, REG_GPR_16($v0) 121 | sw $17, REG_GPR_17($v0) 122 | sw $18, REG_GPR_18($v0) 123 | sw $19, REG_GPR_19($v0) 124 | sw $20, REG_GPR_20($v0) 125 | sw $21, REG_GPR_21($v0) 126 | sw $22, REG_GPR_22($v0) 127 | sw $23, REG_GPR_23($v0) 128 | sw $24, REG_GPR_24($v0) 129 | sw $25, REG_GPR_25($v0) 130 | sw $26, REG_GPR_26($v0) 131 | sw $27, REG_GPR_27($v0) 132 | sw $28, REG_GPR_28($v0) 133 | sw $29, REG_GPR_29($v0) 134 | sw $30, REG_GPR_30($v0) 135 | sw $31, REG_GPR_31($v0) 136 | 137 | mflo $v1 138 | sw $v1, REG_LO($v0) 139 | mfhi $v1 140 | sw $v1, REG_HI($v0) 141 | mfc0 $v1, BadVAddr 142 | sw $v1, REG_BADVADDR($v0) 143 | mfc0 $v1, Cause 144 | sw $v1, REG_CAUSE($v0) 145 | mfc0 $v1, EPC 146 | sw $v1, REG_EPC($v0) 147 | mfc0 $v1, Status 148 | sw $v1, REG_STATUS($v0) 149 | 150 | # Check if cop1 is enable and skip if not 151 | lui $a0, 0x2000 152 | and $a0, $a0, $v1 153 | beq $a0, $0, 1f 154 | nop 155 | 156 | swc1 $0, REG_FPR_0($v0) 157 | swc1 $1, REG_FPR_1($v0) 158 | swc1 $2, REG_FPR_2($v0) 159 | swc1 $3, REG_FPR_3($v0) 160 | swc1 $4, REG_FPR_4($v0) 161 | swc1 $5, REG_FPR_5($v0) 162 | swc1 $6, REG_FPR_6($v0) 163 | swc1 $7, REG_FPR_7($v0) 164 | swc1 $8, REG_FPR_8($v0) 165 | swc1 $9, REG_FPR_9($v0) 166 | swc1 $10, REG_FPR_10($v0) 167 | swc1 $11, REG_FPR_11($v0) 168 | swc1 $12, REG_FPR_12($v0) 169 | swc1 $13, REG_FPR_13($v0) 170 | swc1 $14, REG_FPR_14($v0) 171 | swc1 $15, REG_FPR_15($v0) 172 | swc1 $16, REG_FPR_16($v0) 173 | swc1 $17, REG_FPR_17($v0) 174 | swc1 $18, REG_FPR_18($v0) 175 | swc1 $19, REG_FPR_19($v0) 176 | swc1 $20, REG_FPR_20($v0) 177 | swc1 $21, REG_FPR_21($v0) 178 | swc1 $22, REG_FPR_22($v0) 179 | swc1 $23, REG_FPR_23($v0) 180 | swc1 $24, REG_FPR_24($v0) 181 | swc1 $25, REG_FPR_25($v0) 182 | swc1 $26, REG_FPR_26($v0) 183 | swc1 $27, REG_FPR_27($v0) 184 | swc1 $28, REG_FPR_28($v0) 185 | swc1 $29, REG_FPR_29($v0) 186 | swc1 $30, REG_FPR_30($v0) 187 | swc1 $31, REG_FPR_31($v0) 188 | 189 | cfc1 $t0, FSR 190 | sw $t0, REG_FSR($v0) 191 | cfc1 $t0, FIR 192 | sw $t0, REG_FIR($v0) 193 | ctc1 $0, FSR # Clear any cause flags 194 | 195 | # Jump target for ignore cop1 196 | 1: 197 | 198 | sw $sp, REG_FP($v0) 199 | move $a0, $v0 200 | 201 | lw $2, curr_handler 202 | mtc0 $2, $14 203 | nop 204 | nop 205 | eret 206 | nop 207 | nop 208 | 209 | .end _pspDebugExceptionHandler 210 | 211 | #include "pspimport.s" 212 | 213 | IMPORT_START "ExceptionManagerForKernel",0x00010011 214 | IMPORT_FUNC "ExceptionManagerForKernel",0x565C0B0E,sceKernelRegisterDefaultExceptionHandler371 215 | -------------------------------------------------------------------------------- /source/prx/exceptionHandler/prx/exports.exp: -------------------------------------------------------------------------------- 1 | PSP_BEGIN_EXPORTS 2 | PSP_EXPORT_START(syslib, 0, 0x8000) 3 | PSP_EXPORT_FUNC_HASH(module_start) 4 | PSP_EXPORT_VAR_HASH(module_info) 5 | PSP_EXPORT_END 6 | 7 | PSP_END_EXPORTS 8 | -------------------------------------------------------------------------------- /source/prx/exceptionHandler/prx/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | PSP_MODULE_INFO("exception", 0x1007, 1, 1); // better not unload 6 | 7 | PspDebugErrorHandler curr_handler; 8 | PspDebugRegBlock *exception_regs; 9 | 10 | void _pspDebugExceptionHandler(void); 11 | int sceKernelRegisterDefaultExceptionHandler(void *func); 12 | int sceKernelRegisterDefaultExceptionHandler371(void *func); 13 | 14 | int module_start(SceSize args, void *argp) 15 | { 16 | if(args != 8) return -1; 17 | curr_handler = (PspDebugErrorHandler)((int *)argp)[0]; 18 | exception_regs = (PspDebugRegBlock *)((int *)argp)[1]; 19 | if(!curr_handler || !exception_regs) return -1; 20 | 21 | if(sceKernelDevkitVersion() < 0x03070110) 22 | return sceKernelRegisterDefaultExceptionHandler((void *)_pspDebugExceptionHandler); 23 | else 24 | return sceKernelRegisterDefaultExceptionHandler371((void *)_pspDebugExceptionHandler); 25 | } 26 | -------------------------------------------------------------------------------- /source/prx/exceptionHandler/prx/makefile: -------------------------------------------------------------------------------- 1 | TARGET = exception 2 | OBJS = main.o exception_asm.o 3 | 4 | # Define to build this as a prx (instead of a static elf) 5 | BUILD_PRX=1 6 | # Define the name of our custom exports (minus the .exp extension) 7 | PRX_EXPORTS=exports.exp 8 | 9 | USE_KERNEL_LIBC = 1 10 | USE_KERNEL_LIBS = 1 11 | 12 | INCDIR = 13 | CFLAGS = -Os -G0 -Wall -nostartfiles -march=allegrex -mfp32 -mgp32 -mlong32 -mabi=eabi 14 | CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti 15 | ASFLAGS = $(CFLAGS) 16 | 17 | LIBDIR = 18 | 19 | PSPSDK=$(shell psp-config --pspsdk-path) 20 | include $(PSPSDK)/lib/build.mak 21 | -------------------------------------------------------------------------------- /source/prx/exceptionHandler/test/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "../utility/exception.h" 7 | PSP_MODULE_INFO("Exception Handler Test", 0, 1, 0); 8 | PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER); 9 | //PSP_HEAP_SIZE_KB(22000); 10 | 11 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 12 | // Globals: 13 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 14 | int runningFlag = 1; 15 | 16 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 17 | // Callbacks: 18 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 19 | /* Exit callback */ 20 | int exit_callback(int arg1, int arg2, void *common) { 21 | runningFlag = 0; 22 | return 0; 23 | } 24 | 25 | /* Callback thread */ 26 | int CallbackThread(SceSize args, void *argp) { 27 | int cbid; 28 | cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); 29 | sceKernelRegisterExitCallback(cbid); 30 | sceKernelSleepThreadCB(); 31 | return 0; 32 | } 33 | 34 | /* Sets up the callback thread and returns its thread id */ 35 | int SetupCallbacks(void) { 36 | int thid = 0; 37 | thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0); 38 | if(thid >= 0) 39 | sceKernelStartThread(thid, 0, 0); 40 | return thid; 41 | } 42 | 43 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 44 | // Main: 45 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 46 | int main(){ 47 | pspDebugScreenInit(); 48 | SetupCallbacks(); 49 | 50 | pspDebugScreenPrintf("Expcetion Handler Test\n"); 51 | 52 | initExceptionHandler(); 53 | 54 | pspDebugScreenPrintf("Press X for a breakpoint\n"); 55 | pspDebugScreenPrintf("Press O for a bus error\n"); 56 | 57 | SceCtrlData pad; 58 | while(runningFlag){ 59 | sceCtrlReadBufferPositive(&pad, 1); 60 | if (pad.Buttons & PSP_CTRL_CROSS){ 61 | /* Cause a break exception */ 62 | asm( 63 | "break\r\n" 64 | ); 65 | }else if (pad.Buttons & PSP_CTRL_CIRCLE){ 66 | /* Cause a bus error */ 67 | _sw(0, 0); 68 | } 69 | } 70 | sceKernelExitGame(); 71 | return 0; 72 | 73 | } 74 | -------------------------------------------------------------------------------- /source/prx/exceptionHandler/test/makefile: -------------------------------------------------------------------------------- 1 | TARGET = exception_handler_test 2 | OBJS = ../utility/exception.o main.o 3 | 4 | #To build for custom firmware: 5 | BUILD_PRX = 1 6 | 7 | #CFLAGS = -O3 -G0 -Wall 8 | CFLAGS = -O3 -frename-registers -G0 -Wall 9 | CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti 10 | ASFLAGS = $(CFLAGS) 11 | LIBDIR = 12 | 13 | LIBS = 14 | LDFLAGS = 15 | EXTRA_TARGETS = EBOOT.PBP 16 | PSP_EBOOT_TITLE = Exception Handler Test 17 | #PSP_EBOOT_ICON = ICON0.PNG 18 | PSPSDK=$(shell psp-config --pspsdk-path) 19 | include $(PSPSDK)/lib/build.mak 20 | -------------------------------------------------------------------------------- /source/prx/exceptionHandler/utility/exception.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | PspDebugRegBlock exception_regs; 9 | 10 | extern SceModule module_info; 11 | extern int _ftext; 12 | 13 | static const char *codeTxt[32] = 14 | { 15 | "Interrupt", "TLB modification", "TLB load/inst fetch", "TLB store", 16 | "Address load/inst fetch", "Address store", "Bus error (instr)", 17 | "Bus error (data)", "Syscall", "Breakpoint", "Reserved instruction", 18 | "Coprocessor unusable", "Arithmetic overflow", "Unknown 14", 19 | "Unknown 15", "Unknown 16", "Unknown 17", "Unknown 18", "Unknown 19", 20 | "Unknown 20", "Unknown 21", "Unknown 22", "Unknown 23", "Unknown 24", 21 | "Unknown 25", "Unknown 26", "Unknown 27", "Unknown 28", "Unknown 29", 22 | "Unknown 31" 23 | }; 24 | 25 | static const unsigned char regName[32][5] = 26 | { 27 | "zr", "at", "v0", "v1", "a0", "a1", "a2", "a3", 28 | "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", 29 | "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", 30 | "t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra" 31 | }; 32 | 33 | void ExceptionHandler(PspDebugRegBlock * regs) 34 | { 35 | int i; 36 | SceCtrlData pad; 37 | 38 | pspDebugScreenInit(); 39 | pspDebugScreenSetBackColor(0x00FF0000); 40 | pspDebugScreenSetTextColor(0xFFFFFFFF); 41 | pspDebugScreenClear(); 42 | pspDebugScreenPrintf("Your PSP has just crashed!\n"); 43 | pspDebugScreenPrintf("Exception details:\n\n"); 44 | 45 | pspDebugScreenPrintf("Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]); 46 | pspDebugScreenPrintf("EPC - %08X / %s.text + %08X\n", (int)regs->epc, module_info.modname, (unsigned int)(regs->epc-(int)&_ftext)); 47 | pspDebugScreenPrintf("Cause - %08X\n", (int)regs->cause); 48 | pspDebugScreenPrintf("Status - %08X\n", (int)regs->status); 49 | pspDebugScreenPrintf("BadVAddr - %08X\n", (int)regs->badvaddr); 50 | for(i=0; i<32; i+=4) pspDebugScreenPrintf("%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], (int)regs->r[i], regName[i+1], (int)regs->r[i+1], regName[i+2], (int)regs->r[i+2], regName[i+3], (int)regs->r[i+3]); 51 | 52 | sceKernelDelayThread(1000000); 53 | pspDebugScreenPrintf("\n\nPress X to dump information on file exception.log and quit"); 54 | pspDebugScreenPrintf("\nPress O to quit"); 55 | 56 | for (;;){ 57 | sceCtrlReadBufferPositive(&pad, 1); 58 | if (pad.Buttons & PSP_CTRL_CROSS){ 59 | FILE *log = fopen("exception.log", "w"); 60 | if (log != NULL){ 61 | char testo[512]; 62 | sprintf(testo, "Exception details:\n\n"); 63 | fwrite(testo, 1, strlen(testo), log); 64 | sprintf(testo, "Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]); 65 | fwrite(testo, 1, strlen(testo), log); 66 | sprintf(testo, "EPC - %08X / %s.text + %08X\n", (int)regs->epc, module_info.modname, (unsigned int)(regs->epc-(int)&_ftext)); 67 | fwrite(testo, 1, strlen(testo), log); 68 | sprintf(testo, "Cause - %08X\n", (int)regs->cause); 69 | fwrite(testo, 1, strlen(testo), log); 70 | sprintf(testo, "Status - %08X\n", (int)regs->status); 71 | fwrite(testo, 1, strlen(testo), log); 72 | sprintf(testo, "BadVAddr - %08X\n", (int)regs->badvaddr); 73 | fwrite(testo, 1, strlen(testo), log); 74 | for(i=0; i<32; i+=4){ 75 | sprintf(testo, "%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], (int)regs->r[i], regName[i+1], (int)regs->r[i+1], regName[i+2], (int)regs->r[i+2], regName[i+3], (int)regs->r[i+3]); 76 | fwrite(testo, 1, strlen(testo), log); 77 | } 78 | fclose(log); 79 | } 80 | break; 81 | }else if (pad.Buttons & PSP_CTRL_CIRCLE){ 82 | break; 83 | } 84 | sceKernelDelayThread(100000); 85 | } 86 | sceKernelExitGame(); 87 | } 88 | 89 | void initExceptionHandler() 90 | { 91 | SceKernelLMOption option; 92 | int args[2], fd, modid; 93 | 94 | memset(&option, 0, sizeof(option)); 95 | option.size = sizeof(option); 96 | option.mpidtext = PSP_MEMORY_PARTITION_KERNEL; 97 | option.mpiddata = PSP_MEMORY_PARTITION_KERNEL; 98 | option.position = 0; 99 | option.access = 1; 100 | 101 | if((modid = sceKernelLoadModule("exception.prx", 0, &option)) >= 0) 102 | { 103 | args[0] = (int)ExceptionHandler; 104 | args[1] = (int)&exception_regs; 105 | sceKernelStartModule(modid, 8, args, &fd, NULL); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /source/prx/exceptionHandler/utility/exception.h: -------------------------------------------------------------------------------- 1 | void initExceptionHandler(); 2 | 3 | 4 | -------------------------------------------------------------------------------- /source/prx/ku_bridge/Makefile: -------------------------------------------------------------------------------- 1 | TARGET = ku_bridge 2 | OBJS = main.o sceCtrl_driver.o 3 | 4 | INCDIR = 5 | CFLAGS = -O2 -G0 -Wall -march=allegrex -mfp32 -mgp32 -mlong32 -mabi=eabi 6 | CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti 7 | ASFLAGS = $(CFLAGS) 8 | 9 | BUILD_PRX = 1 10 | PRX_EXPORTS = $(TARGET).exp 11 | 12 | PSP_FW_VERSION=150 13 | 14 | USE_KERNEL_LIBC=1 15 | USE_KERNEL_LIBS=1 16 | 17 | LIBDIR = 18 | LDFLAGS = -mno-crt0 -nostartfiles 19 | LIBS = 20 | 21 | PSPSDK=$(shell psp-config --pspsdk-path) 22 | include $(PSPSDK)/lib/build.mak 23 | 24 | all: 25 | psp-build-exports -s $(PRX_EXPORTS) 26 | @cp $(TARGET).prx ../ 27 | @cp $(TARGET).S ../ 28 | @cp $(TARGET).h ../ 29 | @rm -f $(TARGET).prx 30 | @rm -f $(TARGET).S 31 | @rm -f *.o 32 | @rm -f *.elf 33 | 34 | -------------------------------------------------------------------------------- /source/prx/ku_bridge/ku_bridge.exp: -------------------------------------------------------------------------------- 1 | # Define the exports for the prx 2 | PSP_BEGIN_EXPORTS 3 | 4 | # These four lines are mandatory (although you can add other functions like module_stop) 5 | # syslib is a psynonym for the single mandatory export. 6 | PSP_EXPORT_START(syslib, 0, 0x8000) 7 | PSP_EXPORT_FUNC_HASH(module_start) 8 | PSP_EXPORT_VAR_HASH(module_info) 9 | PSP_EXPORT_END 10 | 11 | PSP_EXPORT_START(ku_bridge, 0, 0x4001) 12 | PSP_EXPORT_FUNC(init_ku_bridge) 13 | PSP_EXPORT_FUNC(kuImposeGetParam) 14 | PSP_EXPORT_FUNC(kuImposeSetParam) 15 | PSP_EXPORT_FUNC(kuCtrlSetSamplingCycle) 16 | PSP_EXPORT_FUNC(kuCtrlSetSamplingMode) 17 | PSP_EXPORT_FUNC(kuCtrlPeekBufferPositive) 18 | PSP_EXPORT_FUNC(kuCtrlReadBufferPositive) 19 | PSP_EXPORT_END 20 | 21 | PSP_END_EXPORTS 22 | -------------------------------------------------------------------------------- /source/prx/ku_bridge/ku_bridge.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | 3 | ku_bridge.prx 4 | 5 | ******************************************************************************/ 6 | 7 | #ifndef KU_BRIDGE_PRX_H 8 | #define KU_BRIDGE_PRX_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void init_ku_bridge(int devkit_version); 15 | 16 | int kuImposeGetParam(SceImposeParam param); 17 | int kuImposeSetParam(SceImposeParam param, int value); 18 | 19 | int kuCtrlSetSamplingCycle(int cycle); 20 | int kuCtrlSetSamplingMode(int mode); 21 | 22 | int kuCtrlPeekBufferPositive(SceCtrlData *pad_data, int count); 23 | int kuCtrlReadBufferPositive(SceCtrlData *pad_data, int count); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /* KU_BRIDGE_PRX_H */ 30 | -------------------------------------------------------------------------------- /source/prx/ku_bridge/main.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | 3 | ku_bridge.prx 4 | 5 | ******************************************************************************/ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | PSP_MODULE_INFO("ku_bridge", PSP_MODULE_KERNEL, 1, 1); 13 | PSP_MAIN_THREAD_ATTR(0); 14 | 15 | 16 | /****************************************************************************** 17 | prototypes 18 | ******************************************************************************/ 19 | 20 | int sceCtrlSetSamplingCycle371(int cycle); 21 | int sceCtrlSetSamplingMode371(int mode); 22 | 23 | int sceCtrlReadBufferPositive371(SceCtrlData *pad_data, int count); 24 | int sceCtrlPeekBufferPositive371(SceCtrlData *pad_data, int count); 25 | 26 | 27 | /****************************************************************************** 28 | local variables 29 | ******************************************************************************/ 30 | 31 | static int (*__sceCtrlPeekBufferPositive)(SceCtrlData *pad_data, int count); 32 | static int (*__sceCtrlReadBufferPositive)(SceCtrlData *pad_data, int count); 33 | 34 | static int (*__sceCtrlSetSamplingCycle)(int cycle); 35 | static int (*__sceCtrlSetSamplingMode)(int mode); 36 | 37 | /****************************************************************************** 38 | functions 39 | ******************************************************************************/ 40 | 41 | int kuImposeGetParam(SceImposeParam param) 42 | { 43 | int k1 = pspSdkSetK1(0); 44 | int ret = sceImposeGetParam(param); 45 | pspSdkSetK1(k1); 46 | return ret; 47 | } 48 | 49 | int kuImposeSetParam(SceImposeParam param, int value) 50 | { 51 | int k1 = pspSdkSetK1(0); 52 | int ret = sceImposeSetParam(param, value); 53 | pspSdkSetK1(k1); 54 | return ret; 55 | } 56 | 57 | 58 | int kuCtrlSetSamplingCycle(int cycle) 59 | { 60 | if (__sceCtrlSetSamplingCycle) 61 | { 62 | int k1 = pspSdkSetK1(0); 63 | int ret = (*__sceCtrlSetSamplingCycle)(cycle); 64 | pspSdkSetK1(k1); 65 | return ret; 66 | } 67 | 68 | return -1; 69 | } 70 | 71 | int kuCtrlSetSamplingMode(int mode) 72 | { 73 | if (__sceCtrlSetSamplingMode) 74 | { 75 | int k1 = pspSdkSetK1(0); 76 | int ret = (*__sceCtrlSetSamplingMode)(mode); 77 | pspSdkSetK1(k1); 78 | return ret; 79 | } 80 | 81 | return -1; 82 | } 83 | 84 | 85 | int kuCtrlPeekBufferPositive(SceCtrlData *pad_data, int count) 86 | { 87 | if (__sceCtrlPeekBufferPositive) 88 | { 89 | int k1 = pspSdkSetK1(0); 90 | int ret = (*__sceCtrlPeekBufferPositive)(pad_data, count); 91 | pspSdkSetK1(k1); 92 | return ret; 93 | } 94 | 95 | return -1; 96 | } 97 | 98 | int kuCtrlReadBufferPositive(SceCtrlData *pad_data, int count) 99 | { 100 | if (__sceCtrlReadBufferPositive) 101 | { 102 | int k1 = pspSdkSetK1(0); 103 | int ret = (*__sceCtrlReadBufferPositive)(pad_data, count); 104 | pspSdkSetK1(k1); 105 | return ret; 106 | } 107 | 108 | return -1; 109 | } 110 | 111 | 112 | void init_ku_bridge(int devkit_version) 113 | { 114 | if (devkit_version < 0x03070110) 115 | { 116 | __sceCtrlSetSamplingCycle = sceCtrlSetSamplingCycle; 117 | __sceCtrlSetSamplingMode = sceCtrlSetSamplingMode; 118 | 119 | __sceCtrlPeekBufferPositive = sceCtrlPeekBufferPositive; 120 | __sceCtrlReadBufferPositive = sceCtrlReadBufferPositive; 121 | } 122 | else 123 | { 124 | __sceCtrlSetSamplingCycle = sceCtrlSetSamplingCycle371; 125 | __sceCtrlSetSamplingMode = sceCtrlSetSamplingMode371; 126 | 127 | __sceCtrlPeekBufferPositive = sceCtrlPeekBufferPositive371; 128 | __sceCtrlReadBufferPositive = sceCtrlReadBufferPositive371; 129 | } 130 | } 131 | 132 | 133 | int module_start(SceSize args, void *argp) 134 | { 135 | __sceCtrlSetSamplingCycle = NULL; 136 | __sceCtrlSetSamplingMode = NULL; 137 | 138 | __sceCtrlPeekBufferPositive = NULL; 139 | __sceCtrlReadBufferPositive = NULL; 140 | 141 | return 0; 142 | } 143 | 144 | int module_stop(void) 145 | { 146 | return 0; 147 | } 148 | 149 | 150 | -------------------------------------------------------------------------------- /source/prx/ku_bridge/sceCtrl_driver.S: -------------------------------------------------------------------------------- 1 | .set noreorder 2 | 3 | # include "pspimport.s" 4 | 5 | IMPORT_START "sceCtrl_driver", 0x00010000 6 | 7 | IMPORT_FUNC "sceCtrl_driver", 0x6D74BF08, sceCtrlSetSamplingCycle371 8 | IMPORT_FUNC "sceCtrl_driver", 0x6A2774F3, sceCtrlSetSamplingCycle 9 | 10 | IMPORT_FUNC "sceCtrl_driver", 0x28E71A16, sceCtrlSetSamplingMode371 11 | IMPORT_FUNC "sceCtrl_driver", 0x1F4011E6, sceCtrlSetSamplingMode 12 | 13 | IMPORT_FUNC "sceCtrl_driver", 0x454455AC, sceCtrlReadBufferPositive371 14 | IMPORT_FUNC "sceCtrl_driver", 0x1F803938, sceCtrlReadBufferPositive 15 | 16 | IMPORT_FUNC "sceCtrl_driver", 0xC4AAD55F, sceCtrlPeekBufferPositive371 17 | IMPORT_FUNC "sceCtrl_driver", 0x3A622550, sceCtrlReekBufferPositive 18 | 19 | -------------------------------------------------------------------------------- /source/res/ICON0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/res/ICON0.png -------------------------------------------------------------------------------- /source/src/ch_print.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/src/ch_print.c -------------------------------------------------------------------------------- /source/src/ch_print.h: -------------------------------------------------------------------------------- 1 | #define FONTWIDTH (6) 2 | #define FONTHEIGHT (12) 3 | 4 | #define BG_NO_FILL (-1) 5 | 6 | 7 | #define FONT_BATTERY0_GBK "\x13\x16\x17" // empty 8 | #define FONT_BATTERY1_GBK "\x13\x15\x12" 9 | #define FONT_BATTERY2_GBK "\x13\x14\x12" 10 | #define FONT_BATTERY3_GBK "\x10\x11\x12" // full 11 | #define FONT_GBA_ICON_GBK "\x18\xA1\x4C" 12 | #define FONT_PSP_ICON_GBK "\x19\xA1\x4D" 13 | #define FONT_MSC_ICON_GBK "\x1A\xA1\x4E" 14 | #define FONT_OPT_ICON_GBK "\x1B\xA1\x4F" 15 | #define FONT_PAD_ICON_GBK "\x1C\xA1\x50" 16 | 17 | #define FONT_KEY_ICON_GBK "\xA1\x40" 18 | #define FONT_R_TRIGGER_GBK "\xA1\x41" 19 | #define FONT_L_TRIGGER_GBK "\xA1\x42" 20 | #define FONT_CURSOR_RIGHT_GBK "\xA1\x43" 21 | #define FONT_CURSOR_LEFT_GBK "\xA1\x44" 22 | #define FONT_CURSOR_UP_GBK "\xA1\x45" 23 | #define FONT_CURSOR_DOWN_GBK "\xA1\x46" 24 | #define FONT_CURSOR_RIGHT_FILL_GBK "\xA1\x47" 25 | #define FONT_CURSOR_LEFT_FILL_GBK "\xA1\x48" 26 | #define FONT_CURSOR_UP_FILL_GBK "\xA1\x49" 27 | #define FONT_CURSOR_DOWN_FILL_GBK "\xA1\x4A" 28 | #define FONT_UP_DIRECTORY_GBK "\xA1\x4B" 29 | 30 | #define FONT_ARROW_UP_GBK "\xA1\xFC" 31 | #define FONT_ARROW_DOWN_GBK "\xA1\xFD" 32 | #define FONT_ARROW_LEFT_GBK "\xA1\xFB" 33 | #define FONT_ARROW_RIGHT_GBK "\xA1\xFA" 34 | #define FONT_CIRCLE_GBK "\xA1\xF0" 35 | #define FONT_CROSS_GBK "\xA1\xC1" 36 | #define FONT_SQUARE_GBK "\xA1\xF5" 37 | #define FONT_TRIANGLE_GBK "\xA1\xF7" 38 | 39 | void ch_print(const char *str, u16 x, u16 y, u16 col, s16 bg_col, u16 *base_vram, u16 bufferwidth); 40 | 41 | -------------------------------------------------------------------------------- /source/src/cheats.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/src/cheats.h -------------------------------------------------------------------------------- /source/src/common.h: -------------------------------------------------------------------------------- 1 | /* unofficial gameplaySP kai 2 | * 3 | * Copyright (C) 2006 Exophase 4 | * Copyright (C) 2007 takka 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef COMMON_H 22 | #define COMMON_H 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #define MAX_PATH (512) 45 | #define MAX_FILE (256) 46 | 47 | #define ALIGN_PSPDATA __attribute__((aligned(16))) 48 | #define ALIGN_DATA __attribute__((aligned(4))) 49 | #define MEM_ALIGN (4) 50 | 51 | #define ROR(dest, value, shift) \ 52 | dest = __builtin_allegrex_rotr(value, shift) \ 53 | 54 | #define LIMIT_MAX(input, maxout) \ 55 | __builtin_allegrex_min(input, maxout) \ 56 | 57 | #define LIMIT_MIN(input, minout) \ 58 | __builtin_allegrex_max(input, minout) \ 59 | 60 | 61 | #define PSP_FILE_OPEN_READ "r" 62 | #define PSP_FILE_OPEN_WRITE "w" 63 | 64 | #define FILE_OPEN(filename_tag, filename, mode) \ 65 | filename_tag = psp_fopen(filename, PSP_FILE_OPEN_##mode) \ 66 | 67 | #define FILE_CHECK_VALID(filename_tag) \ 68 | ((filename_tag) >= 0) \ 69 | 70 | #define FILE_CLOSE(filename_tag) \ 71 | psp_fclose(filename_tag) \ 72 | 73 | #define FILE_READ(filename_tag, buffer, size) \ 74 | sceIoRead(filename_tag, buffer, size) \ 75 | 76 | #define FILE_WRITE(filename_tag, buffer, size) \ 77 | sceIoWrite(filename_tag, buffer, size) \ 78 | 79 | // type = FILE_OPEN_READ / FILE_OPEN_WRITE 80 | #define FILE_SEEK(filename_tag, offset, type) \ 81 | sceIoLseek(filename_tag, offset, PSP_##type) \ 82 | 83 | #define FILE_WRITE_MEM(filename_tag, buffer, size) \ 84 | { \ 85 | memcpy(write_mem_ptr, buffer, size); \ 86 | write_mem_ptr += (size); \ 87 | } \ 88 | 89 | // These must be variables, not constants. 90 | 91 | #define FILE_READ_VARIABLE(filename_tag, variable) \ 92 | FILE_READ(filename_tag, &variable, sizeof(variable)) \ 93 | 94 | #define FILE_WRITE_VARIABLE(filename_tag, variable) \ 95 | FILE_WRITE(filename_tag, &variable, sizeof(variable)) \ 96 | 97 | #define FILE_WRITE_MEM_VARIABLE(filename_tag, variable) \ 98 | FILE_WRITE_MEM(filename_tag, &variable, sizeof(variable)) \ 99 | 100 | // These must be statically declared arrays (ie, global or on the stack, 101 | // not dynamically allocated on the heap) 102 | 103 | #define FILE_READ_ARRAY(filename_tag, array) \ 104 | FILE_READ(filename_tag, array, sizeof(array)) \ 105 | 106 | #define FILE_WRITE_ARRAY(filename_tag, array) \ 107 | FILE_WRITE(filename_tag, array, sizeof(array)) \ 108 | 109 | #define FILE_WRITE_MEM_ARRAY(filename_tag, array) \ 110 | FILE_WRITE_MEM(filename_tag, array, sizeof(array)) \ 111 | 112 | 113 | typedef u32 FIXED08_24; 114 | 115 | #define FLOAT_TO_FP08_24(value) \ 116 | (FIXED08_24)((value) * 16777216.0) \ 117 | 118 | #define FP08_24_TO_FLOAT(value) \ 119 | (float)((value) / 16777216.0) \ 120 | 121 | #define U32_TO_FP08_24(value) \ 122 | ((value) << 24) \ 123 | 124 | #define FP08_24_TO_U32(value) \ 125 | ((value) >> 24) \ 126 | 127 | #define FP08_24_FRACTIONAL_PART(value) \ 128 | ((value) & 0x00FFFFFF) \ 129 | 130 | 131 | #define FIXED_DIV(numerator, denominator, bits) \ 132 | (((numerator * (1 << bits)) + (denominator / 2)) / denominator) \ 133 | 134 | 135 | #define ADDRESS8(base, offset) \ 136 | *((u8 *)((u8 *)(base) + (offset))) \ 137 | 138 | #define ADDRESS16(base, offset) \ 139 | *((u16 *)((u8 *)(base) + (offset))) \ 140 | 141 | #define ADDRESS32(base, offset) \ 142 | *((u32 *)((u8 *)(base) + (offset))) \ 143 | 144 | 145 | #include "zlib/zlib.h" 146 | #include "libpower/psppower.h" 147 | 148 | #include "zip.h" 149 | #include "png.h" 150 | 151 | #include "message.h" 152 | 153 | #include "cheats.h" 154 | 155 | #include "mh_print.h" 156 | #include "ch_print.h" 157 | #include "gui.h" 158 | 159 | #include "cpu.h" 160 | #include "memory.h" 161 | #include "video.h" 162 | #include "input.h" 163 | #include "sound.h" 164 | #include "main.h" 165 | 166 | #include "ku_bridge.h" 167 | #include "exception.h" 168 | 169 | #endif /* COMMON_H */ 170 | -------------------------------------------------------------------------------- /source/src/cpu.h: -------------------------------------------------------------------------------- 1 | /* unofficial gameplaySP kai 2 | * 3 | * Copyright (C) 2006 Exophase 4 | * Copyright (C) 2007 takka 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef CPU_H 22 | #define CPU_H 23 | 24 | // System mode and user mode are represented as the same here 25 | 26 | typedef enum 27 | { 28 | MODE_USER, 29 | MODE_IRQ, 30 | MODE_FIQ, 31 | MODE_SUPERVISOR, 32 | MODE_ABORT, 33 | MODE_UNDEFINED, 34 | MODE_INVALID 35 | } CPU_MODE_TYPE; 36 | 37 | typedef enum 38 | { 39 | CPU_ALERT_NONE = 0, 40 | CPU_ALERT_SMC = 1, // bit0 - SMC 41 | CPU_ALERT_IRQ = 2, // bit1 - IRQ 42 | CPU_ALERT_SMC_IRQ = 3, 43 | CPU_ALERT_HALT = 4, // bit2 - HALT 44 | CPU_ALERT_TIMER = 8, // bit3 - timer counter change. 45 | CPU_ALERT_DMA = 16 // bit4 - DMA transfers 46 | } CPU_ALERT_TYPE; 47 | 48 | typedef enum 49 | { 50 | CPU_ACTIVE, 51 | CPU_HALT, 52 | CPU_STOP 53 | } CPU_HALT_TYPE; 54 | 55 | typedef enum 56 | { 57 | IRQ_NONE = 0x0000, 58 | IRQ_VBLANK = 0x0001, 59 | IRQ_HBLANK = 0x0002, 60 | IRQ_VCOUNT = 0x0004, 61 | IRQ_TIMER0 = 0x0008, 62 | IRQ_TIMER1 = 0x0010, 63 | IRQ_TIMER2 = 0x0020, 64 | IRQ_TIMER3 = 0x0040, 65 | IRQ_SERIAL = 0x0080, 66 | IRQ_DMA0 = 0x0100, 67 | IRQ_DMA1 = 0x0200, 68 | IRQ_DMA2 = 0x0400, 69 | IRQ_DMA3 = 0x0800, 70 | IRQ_KEYPAD = 0x1000, 71 | IRQ_GAMEPAK = 0x2000, 72 | } IRQ_TYPE; 73 | 74 | typedef enum 75 | { 76 | REG_SP = 13, 77 | REG_LR = 14, 78 | REG_PC = 15, 79 | REG_N_FLAG = 16, 80 | REG_Z_FLAG = 17, 81 | REG_C_FLAG = 18, 82 | REG_V_FLAG = 19, 83 | REG_CPSR = 20, 84 | REG_SAVE = 21, 85 | REG_SAVE2 = 22, 86 | REG_SAVE3 = 23, 87 | 88 | CPU_MODE = 29, 89 | CPU_HALT_STATE = 30, 90 | CHANGED_PC_STATUS = 31, 91 | 92 | EXECUTE_CYCLES = 60, 93 | 94 | CPU_DMA_HACK = 61, 95 | CPU_DMA_LAST = 62, 96 | 97 | REG_TMP = 63 98 | 99 | } EXT_REG_NUMBERS; 100 | 101 | typedef enum 102 | { 103 | TRANSLATION_REGION_READONLY, 104 | TRANSLATION_REGION_WRITABLE 105 | } TRANSLATION_REGION_TYPE; 106 | 107 | #define TRANSLATION_REGION_COUNT 2 108 | 109 | typedef enum { 110 | METADATA_AREA_BIOS, 111 | METADATA_AREA_EWRAM, 112 | METADATA_AREA_IWRAM, 113 | METADATA_AREA_VRAM, 114 | METADATA_AREA_ROM 115 | } METADATA_AREA_TYPE; 116 | 117 | #define METADATA_AREA_COUNT 5 118 | 119 | typedef enum { 120 | /* Both caches are being thoroughly flushed during initialisation. */ 121 | FLUSH_REASON_INITIALIZING, 122 | /* The read-only code cache is being cleared after a new ROM has been 123 | * loaded. */ 124 | FLUSH_REASON_LOADING_ROM, 125 | /* The writable code cache is being cleared in response to the read-only one 126 | * being flushed. The recompiler will have patched the branch addresses 127 | * towards the read-only area, and they have become invalid. */ 128 | FLUSH_REASON_NATIVE_BRANCHING, 129 | /* One of the caches is being flushed because it's full of code. */ 130 | FLUSH_REASON_FULL_CACHE 131 | } CACHE_FLUSH_REASON_TYPE; 132 | 133 | #define CACHE_FLUSH_REASON_COUNT 4 134 | 135 | typedef enum { 136 | /* All metadata areas are being thoroughly cleared during initialisation. */ 137 | CLEAR_REASON_INITIALIZING, 138 | /* All metadata areas are being cleared after a new ROM has been loaded. */ 139 | CLEAR_REASON_LOADING_ROM, 140 | /* Writable metadata areas are being cleared in response to a read-only 141 | * code cache being flushed. The recompiler will have patched the branch 142 | * addresses towards the read-only area, and they have become invalid. */ 143 | CLEAR_REASON_NATIVE_BRANCHING, 144 | /* All read-only metadata areas or all writable metadata areas are being 145 | * cleared due to its code cache being full of code. (If that cache 146 | * is for the read-only area, the writable one will follow suit.) */ 147 | CLEAR_REASON_FULL_CACHE, 148 | /* One metadata area is being cleared before assigning a tag in it because 149 | * the tag that would be assigned to the code exceeds MAX_TAG. */ 150 | CLEAR_REASON_LAST_TAG, 151 | /* Writable metadata areas are being flushed because a saved state has been 152 | * loaded. */ 153 | CLEAR_REASON_LOADING_STATE 154 | } METADATA_CLEAR_REASON_TYPE; 155 | 156 | #define METADATA_CLEAR_REASON_COUNT 6 157 | 158 | 159 | void set_cpu_mode(CPU_MODE_TYPE new_mode); 160 | 161 | u32 execute_load_u8(u32 address); 162 | u32 execute_load_u16(u32 address); 163 | u32 execute_load_u32(u32 address); 164 | u32 execute_load_s8(u32 address); 165 | u32 execute_load_s16(u32 address); 166 | void execute_store_u8(u32 address, u32 source); 167 | void execute_store_u16(u32 address, u32 source); 168 | void execute_store_u32(u32 address, u32 source); 169 | void execute_arm_translate(u32 cycles); 170 | 171 | void invalidate_all_cache(void); 172 | void invalidate_icache_region(u8 *addr, u32 length); 173 | 174 | u8 *block_lookup_address_arm(u32 pc); 175 | u8 *block_lookup_address_thumb(u32 pc); 176 | u8 *block_lookup_address_dual(u32 pc); 177 | 178 | 179 | #define MAX_IDLE_LOOPS 8 180 | 181 | extern s32 idle_loop_targets; 182 | extern u32 idle_loop_target_pc[MAX_IDLE_LOOPS]; 183 | 184 | extern u32 iwram_stack_optimize; 185 | 186 | void partial_clear_metadata(u32 offset, u8 region); 187 | void flush_translation_cache(TRANSLATION_REGION_TYPE translation_region, CACHE_FLUSH_REASON_TYPE flush_reason); 188 | void clear_metadata_area(METADATA_AREA_TYPE metadata_area, METADATA_CLEAR_REASON_TYPE clear_reason); 189 | void dump_translation_cache(void); 190 | 191 | extern u32 reg[64]; 192 | 193 | extern u32 reg_mode[7][7]; 194 | extern u32 spsr[7]; 195 | 196 | void init_cpu(void); 197 | 198 | void cpu_write_mem_savestate(SceUID savestate_file); 199 | void cpu_read_savestate(SceUID savestate_file); 200 | 201 | 202 | #define ARM_IRQ_STATE ((reg[REG_CPSR] & 0x80) == 0) 203 | 204 | #endif /* CPU_H */ 205 | -------------------------------------------------------------------------------- /source/src/exception.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | PspDebugRegBlock exception_regs; 4 | 5 | extern SceModule module_info; 6 | extern int _ftext; 7 | 8 | static const char *codeTxt[32] = 9 | { 10 | "Interrupt", "TLB modification", "TLB load/inst fetch", "TLB store", 11 | "Address load/inst fetch", "Address store", "Bus error (instr)", 12 | "Bus error (data)", "Syscall", "Breakpoint", "Reserved instruction", 13 | "Coprocessor unusable", "Arithmetic overflow", "Unknown 14", 14 | "Unknown 15", "Unknown 16", "Unknown 17", "Unknown 18", "Unknown 19", 15 | "Unknown 20", "Unknown 21", "Unknown 22", "Unknown 23", "Unknown 24", 16 | "Unknown 25", "Unknown 26", "Unknown 27", "Unknown 28", "Unknown 29", 17 | "Unknown 31" 18 | }; 19 | 20 | static const unsigned char regName[32][5] = 21 | { 22 | "zr", "at", "v0", "v1", "a0", "a1", "a2", "a3", 23 | "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", 24 | "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", 25 | "t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra" 26 | }; 27 | 28 | void ExceptionHandler(PspDebugRegBlock *regs) 29 | { 30 | int i; 31 | SceCtrlData pad; 32 | 33 | pspDebugScreenInit(); 34 | pspDebugScreenSetBackColor(0x00FF0000); 35 | pspDebugScreenSetTextColor(0xFFFFFFFF); 36 | pspDebugScreenClear(); 37 | 38 | pspDebugScreenPrintf("Your PSP has just crashed!\n\n"); 39 | 40 | pspDebugScreenPrintf("Exception details:\n\n"); 41 | pspDebugScreenPrintf("Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]); 42 | pspDebugScreenPrintf("EPC - %08X / %s.text + %08X\n", (int)regs->epc, module_info.modname, (unsigned int)(regs->epc-(int)&_ftext)); 43 | pspDebugScreenPrintf("Cause - %08X\n", (int)regs->cause); 44 | pspDebugScreenPrintf("Status - %08X\n", (int)regs->status); 45 | pspDebugScreenPrintf("BadVAddr - %08X\n\n", (int)regs->badvaddr); 46 | for (i=0; i<32; i+=4) pspDebugScreenPrintf("%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], (int)regs->r[i], regName[i+1], (int)regs->r[i+1], regName[i+2], (int)regs->r[i+2], regName[i+3], (int)regs->r[i+3]); 47 | 48 | sceKernelDelayThread(1000000); 49 | pspDebugScreenPrintf("\n\nPress X to dump information on file exception.log and quit"); 50 | pspDebugScreenPrintf("\nPress O to quit"); 51 | 52 | for (;;) { 53 | sceCtrlReadBufferPositive(&pad, 1); 54 | if (pad.Buttons & PSP_CTRL_CROSS) { 55 | char filename[MAX_FILE]; 56 | sprintf(filename, "%sexception.log", main_path); 57 | FILE *log = fopen(filename, "w"); 58 | if (log != NULL) { 59 | char testo[512]; 60 | sprintf(testo, "Exception details:\n\n"); 61 | fwrite(testo, 1, strlen(testo), log); 62 | sprintf(testo, "Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]); 63 | fwrite(testo, 1, strlen(testo), log); 64 | sprintf(testo, "EPC - %08X / %s.text + %08X\n", (int)regs->epc, module_info.modname, (unsigned int)(regs->epc-(int)&_ftext)); 65 | fwrite(testo, 1, strlen(testo), log); 66 | sprintf(testo, "Cause - %08X\n", (int)regs->cause); 67 | fwrite(testo, 1, strlen(testo), log); 68 | sprintf(testo, "Status - %08X\n", (int)regs->status); 69 | fwrite(testo, 1, strlen(testo), log); 70 | sprintf(testo, "BadVAddr - %08X\n\n", (int)regs->badvaddr); 71 | fwrite(testo, 1, strlen(testo), log); 72 | for (i=0; i<32; i+=4) { 73 | sprintf(testo, "%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], (int)regs->r[i], regName[i+1], (int)regs->r[i+1], regName[i+2], (int)regs->r[i+2], regName[i+3], (int)regs->r[i+3]); 74 | fwrite(testo, 1, strlen(testo), log); 75 | } 76 | fclose(log); 77 | } 78 | break; 79 | } else if (pad.Buttons & PSP_CTRL_CIRCLE) { 80 | break; 81 | } 82 | sceKernelDelayThread(100000); 83 | } 84 | scePowerUnlock(0); 85 | sceKernelExitGame(); 86 | } 87 | 88 | void initExceptionHandler(void) 89 | { 90 | SceKernelLMOption option = { 0 }; 91 | int args[2], fd, modid; 92 | 93 | option.size = sizeof(option); 94 | option.mpidtext = PSP_MEMORY_PARTITION_KERNEL; 95 | option.mpiddata = PSP_MEMORY_PARTITION_KERNEL; 96 | option.position = 0; 97 | option.access = 1; 98 | 99 | if ((modid = kuKernelLoadModule("exception.prx", 0, &option)) >= 0) 100 | { 101 | args[0] = (int)ExceptionHandler; 102 | args[1] = (int)&exception_regs; 103 | sceKernelStartModule(modid, 8, args, &fd, NULL); 104 | } 105 | } 106 | 107 | -------------------------------------------------------------------------------- /source/src/exception.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | 5 | void initExceptionHandler(void); 6 | void ExceptionHandler(PspDebugRegBlock *regs); 7 | 8 | #ifdef __cplusplus 9 | } 10 | #endif 11 | 12 | -------------------------------------------------------------------------------- /source/src/gui.h: -------------------------------------------------------------------------------- 1 | /* unofficial gameplaySP kai 2 | * 3 | * Copyright (C) 2006 Exophase 4 | * Copyright (C) 2007 takka 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef GUI_H 22 | #define GUI_H 23 | 24 | 25 | extern char dir_roms[MAX_PATH]; 26 | extern char dir_save[MAX_PATH]; 27 | extern char dir_state[MAX_PATH]; 28 | extern char dir_cfg[MAX_PATH]; 29 | extern char dir_snap[MAX_PATH]; 30 | extern char dir_cheat[MAX_PATH]; 31 | 32 | s32 load_file(const char **wildcards, char *result, char *default_dir_name); 33 | 34 | s32 load_game_config_file(void); 35 | s32 load_config_file(void); 36 | s32 save_config_file(void); 37 | 38 | s32 load_dir_cfg(char *file_name); 39 | 40 | u32 menu(void); 41 | 42 | void action_loadstate(void); 43 | void action_savestate(void); 44 | 45 | 46 | #endif /* GUI_H */ 47 | -------------------------------------------------------------------------------- /source/src/input.h: -------------------------------------------------------------------------------- 1 | /* unofficial gameplaySP kai 2 | * 3 | * Copyright (C) 2006 Exophase 4 | * Copyright (C) 2007 takka 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef INPUT_H 22 | #define INPUT_H 23 | 24 | typedef enum 25 | { 26 | BUTTON_L = 0x200, 27 | BUTTON_R = 0x100, 28 | BUTTON_DOWN = 0x80, 29 | BUTTON_UP = 0x40, 30 | BUTTON_LEFT = 0x20, 31 | BUTTON_RIGHT = 0x10, 32 | BUTTON_START = 0x08, 33 | BUTTON_SELECT = 0x04, 34 | BUTTON_B = 0x02, 35 | BUTTON_A = 0x01, 36 | BUTTON_NONE = 0x00 37 | } INPUT_BUTTONS_TYPE; 38 | 39 | typedef enum 40 | { 41 | BUTTON_ID_UP, 42 | BUTTON_ID_DOWN, 43 | BUTTON_ID_LEFT, 44 | BUTTON_ID_RIGHT, 45 | BUTTON_ID_A, 46 | BUTTON_ID_B, 47 | BUTTON_ID_L, 48 | BUTTON_ID_R, 49 | BUTTON_ID_START, 50 | BUTTON_ID_SELECT, 51 | BUTTON_ID_MENU, 52 | BUTTON_ID_FASTFORWARD, 53 | BUTTON_ID_LOADSTATE, 54 | BUTTON_ID_SAVESTATE, 55 | BUTTON_ID_RAPIDFIRE_A, 56 | BUTTON_ID_RAPIDFIRE_B, 57 | BUTTON_ID_RAPIDFIRE_L, 58 | BUTTON_ID_RAPIDFIRE_R, 59 | BUTTON_ID_FPS, 60 | BUTTON_ID_NONE 61 | } INPUT_BUTTONS_ID_TYPE; 62 | 63 | typedef enum 64 | { 65 | CURSOR_RTRIGGER, 66 | CURSOR_LTRIGGER, 67 | CURSOR_UP, 68 | CURSOR_DOWN, 69 | CURSOR_LEFT, 70 | CURSOR_RIGHT, 71 | CURSOR_SELECT, 72 | CURSOR_BACK, 73 | CURSOR_EXIT, 74 | CURSOR_DEFAULT, 75 | CURSOR_NONE 76 | } GUI_ACTION_TYPE; 77 | 78 | 79 | extern u32 gamepad_config_map[16]; 80 | 81 | extern u32 enable_tilt_sensor; 82 | extern u32 tilt_sensorX; 83 | extern u32 tilt_sensorY; 84 | 85 | void init_input(void); 86 | void init_input_kernel(void); 87 | 88 | u32 update_input(void); 89 | 90 | u32 get_pad_input(u32 mask); 91 | 92 | GUI_ACTION_TYPE get_gui_input(void); 93 | GUI_ACTION_TYPE get_gui_input_fs_hold(u32 button_id); 94 | 95 | void input_write_mem_savestate(SceUID savestate_file); 96 | void input_read_savestate(SceUID savestate_file); 97 | 98 | 99 | #endif /* INPUT_H */ 100 | -------------------------------------------------------------------------------- /source/src/ku_bridge.S: -------------------------------------------------------------------------------- 1 | .set noreorder 2 | 3 | #include "pspstub.s" 4 | 5 | STUB_START "ku_bridge",0x40090000,0x00070005 6 | STUB_FUNC 0xBBB01C12,init_ku_bridge 7 | STUB_FUNC 0x13475607,kuImposeGetParam 8 | STUB_FUNC 0xB9D58B81,kuImposeSetParam 9 | STUB_FUNC 0x0CCE70FC,kuCtrlSetSamplingCycle 10 | STUB_FUNC 0x83E3C13E,kuCtrlSetSamplingMode 11 | STUB_FUNC 0x983E0EA4,kuCtrlPeekBufferPositive 12 | STUB_FUNC 0x20D2A21C,kuCtrlReadBufferPositive 13 | STUB_END 14 | -------------------------------------------------------------------------------- /source/src/ku_bridge.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | 3 | ku_bridge.prx 4 | 5 | ******************************************************************************/ 6 | 7 | #ifndef KU_BRIDGE_PRX_H 8 | #define KU_BRIDGE_PRX_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void init_ku_bridge(int devkit_version); 15 | 16 | int kuImposeGetParam(SceImposeParam param); 17 | int kuImposeSetParam(SceImposeParam param, int value); 18 | 19 | int kuCtrlSetSamplingCycle(int cycle); 20 | int kuCtrlSetSamplingMode(int mode); 21 | 22 | int kuCtrlPeekBufferPositive(SceCtrlData *pad_data, int count); 23 | int kuCtrlReadBufferPositive(SceCtrlData *pad_data, int count); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /* KU_BRIDGE_PRX_H */ 30 | -------------------------------------------------------------------------------- /source/src/libpower/libpsppower.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/src/libpower/libpsppower.a -------------------------------------------------------------------------------- /source/src/main.h: -------------------------------------------------------------------------------- 1 | /* unofficial gameplaySP kai 2 | * 3 | * Copyright (C) 2006 Exophase 4 | * Copyright (C) 2007 takka 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef MAIN_H 22 | #define MAIN_H 23 | 24 | 25 | // video scale type 26 | #define SCALED_NONE 0 27 | #define SCALED_X15_GU 1 28 | #define SCALED_X15_SW 2 29 | #define SCALED_USER 3 30 | 31 | // video filter type 32 | #define FILTER_NEAREST 0 33 | #define FILTER_BILINEAR 1 34 | 35 | // frameskip type 36 | #define FRAMESKIP_AUTO 0 37 | #define FRAMESKIP_MANUAL 1 38 | #define FRAMESKIP_NONE 2 39 | 40 | // psp cpu clock frequency 41 | #define PSP_CLOCK_222 0 42 | #define PSP_CLOCK_266 1 43 | #define PSP_CLOCK_300 2 44 | #define PSP_CLOCK_333 3 45 | 46 | #define CONFIRMATION_NONE 0 47 | #define CONFIRMATION_CONT 1 48 | #define CONFIRMATION_QUIT 2 49 | 50 | 51 | extern u32 option_screen_scale; 52 | extern u32 option_screen_mag; 53 | extern u32 option_screen_filter; 54 | extern u32 option_sound_volume; 55 | extern u32 option_stack_optimize; 56 | extern u32 option_boot_mode; 57 | extern u32 option_update_backup; 58 | extern u32 option_screen_capture_format; 59 | extern u32 option_enable_analog; 60 | extern u32 option_analog_sensitivity; 61 | extern u32 option_language; 62 | extern u32 option_button_swap; 63 | 64 | extern u32 option_frameskip_type; 65 | extern u32 option_frameskip_value; 66 | extern u32 option_clock_speed; 67 | 68 | extern char main_path[MAX_PATH]; 69 | 70 | extern int date_format; 71 | extern u32 enable_home_menu; 72 | 73 | extern u32 sleep_flag; 74 | 75 | extern u32 synchronize_flag; 76 | extern u32 psp_fps_debug; 77 | 78 | extern u32 real_frame_count; 79 | extern u32 virtual_frame_count; 80 | 81 | void direct_sound_timer_select(u32 value); 82 | 83 | void timer_control_low(u8 timer_number, u32 value); 84 | CPU_ALERT_TYPE timer_control_high(u8 timer_number, u32 value); 85 | 86 | extern u32 dma_cycle_count; 87 | 88 | u32 update_gba(void); 89 | 90 | void reset_gba(void); 91 | void quit(void); 92 | 93 | void error_msg(const char *text, u8 confirm); 94 | void change_ext(char *src, char *buffer, const char *extension); 95 | 96 | u64 ticker(void); 97 | u32 file_length(char *filename); 98 | 99 | int set_cpu_clock(u32 psp_clock); 100 | 101 | SceUID psp_fopen(const char *filename, const char *mode); 102 | void psp_fclose(SceUID filename_tag); 103 | 104 | void *safe_malloc(size_t size); 105 | 106 | void main_write_mem_savestate(SceUID savestate_file); 107 | void main_read_savestate(SceUID savestate_file); 108 | 109 | 110 | #endif /* MAIN_H */ 111 | -------------------------------------------------------------------------------- /source/src/memory.h: -------------------------------------------------------------------------------- 1 | /* unofficial gameplaySP kai 2 | * 3 | * Copyright (C) 2006 Exophase 4 | * Copyright (C) 2007 takka 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef MEMORY_H 22 | #define MEMORY_H 23 | 24 | 25 | typedef enum 26 | { 27 | DMA_START_IMMEDIATELY, 28 | DMA_START_VBLANK, 29 | DMA_START_HBLANK, 30 | DMA_START_SPECIAL, 31 | DMA_INACTIVE 32 | } DMA_START_TYPE; 33 | 34 | typedef enum 35 | { 36 | DMA_16BIT, 37 | DMA_32BIT 38 | } DMA_LENGTH_TYPE; 39 | 40 | typedef enum 41 | { 42 | DMA_NO_REPEAT, 43 | DMA_REPEAT 44 | } DMA_REPEAT_TYPE; 45 | 46 | typedef enum 47 | { 48 | DMA_INCREMENT, 49 | DMA_DECREMENT, 50 | DMA_FIXED, 51 | DMA_RELOAD 52 | } DMA_INCREMENT_TYPE; 53 | 54 | typedef enum 55 | { 56 | DMA_NO_IRQ, 57 | DMA_TRIGGER_IRQ 58 | } DMA_IRQ_TYPE; 59 | 60 | typedef enum 61 | { 62 | DMA_DIRECT_SOUND_A, 63 | DMA_DIRECT_SOUND_B, 64 | DMA_NO_DIRECT_SOUND 65 | } DMA_DS_TYPE; 66 | 67 | typedef struct 68 | { 69 | u32 dma_channel; 70 | u32 source_address; 71 | u32 dest_address; 72 | u32 length; 73 | DMA_REPEAT_TYPE repeat_type; 74 | DMA_DS_TYPE direct_sound_channel; 75 | DMA_INCREMENT_TYPE source_direction; 76 | DMA_INCREMENT_TYPE dest_direction; 77 | DMA_LENGTH_TYPE length_type; 78 | DMA_START_TYPE start_type; 79 | DMA_IRQ_TYPE irq; 80 | } DmaTransferType; 81 | 82 | typedef enum 83 | { 84 | REG_DISPCNT = 0x000, 85 | REG_DISPSTAT = 0x004 / 2, 86 | REG_VCOUNT = 0x006 / 2, 87 | REG_BG0CNT = 0x008 / 2, 88 | REG_BG1CNT = 0x00A / 2, 89 | REG_BG2CNT = 0x00C / 2, 90 | REG_BG3CNT = 0x00E / 2, 91 | REG_BG0HOFS = 0x010 / 2, 92 | REG_BG0VOFS = 0x012 / 2, 93 | REG_BG1HOFS = 0x014 / 2, 94 | REG_BG1VOFS = 0x016 / 2, 95 | REG_BG2HOFS = 0x018 / 2, 96 | REG_BG2VOFS = 0x01A / 2, 97 | REG_BG3HOFS = 0x01C / 2, 98 | REG_BG3VOFS = 0x01E / 2, 99 | REG_BG2PA = 0x020 / 2, 100 | REG_BG2PB = 0x022 / 2, 101 | REG_BG2PC = 0x024 / 2, 102 | REG_BG2PD = 0x026 / 2, 103 | REG_BG2X_L = 0x028 / 2, 104 | REG_BG2X_H = 0x02A / 2, 105 | REG_BG2Y_L = 0x02C / 2, 106 | REG_BG2Y_H = 0x02E / 2, 107 | REG_BG3PA = 0x030 / 2, 108 | REG_BG3PB = 0x032 / 2, 109 | REG_BG3PC = 0x034 / 2, 110 | REG_BG3PD = 0x036 / 2, 111 | REG_BG3X_L = 0x038 / 2, 112 | REG_BG3X_H = 0x03A / 2, 113 | REG_BG3Y_L = 0x03C / 2, 114 | REG_BG3Y_H = 0x03E / 2, 115 | REG_WIN0H = 0x040 / 2, 116 | REG_WIN1H = 0x042 / 2, 117 | REG_WIN0V = 0x044 / 2, 118 | REG_WIN1V = 0x046 / 2, 119 | REG_WININ = 0x048 / 2, 120 | REG_WINOUT = 0x04A / 2, 121 | REG_BLDCNT = 0x050 / 2, 122 | REG_BLDALPHA = 0x052 / 2, 123 | REG_BLDY = 0x054 / 2, 124 | REG_SOUNDCNT_X = 0x084 / 2, 125 | REG_SOUNDBIAS = 0x088 / 2, 126 | REG_TM0D = 0x100 / 2, 127 | REG_TM0CNT = 0x102 / 2, 128 | REG_TM1D = 0x104 / 2, 129 | REG_TM1CNT = 0x106 / 2, 130 | REG_TM2D = 0x108 / 2, 131 | REG_TM2CNT = 0x10A / 2, 132 | REG_TM3D = 0x10C / 2, 133 | REG_TM3CNT = 0x10E / 2, 134 | REG_SIOCNT = 0x128 / 2, 135 | REG_P1 = 0x130 / 2, 136 | REG_P1CNT = 0x132 / 2, 137 | REG_RCNT = 0x134 / 2, 138 | REG_IE = 0x200 / 2, 139 | REG_IF = 0x202 / 2, 140 | REG_WAITCNT = 0x204 / 2, 141 | REG_IME = 0x208 / 2, 142 | REG_HALTCNT = 0x300 / 2 143 | } HARDWARE_REGISTER; 144 | 145 | 146 | extern char gamepak_filename[MAX_FILE]; 147 | extern char gamepak_filename_raw[MAX_FILE]; 148 | 149 | extern SceUID gamepak_file_large; 150 | extern u8 *gamepak_rom; 151 | extern u32 gamepak_ram_buffer_size; 152 | 153 | extern u32 oam_update; 154 | 155 | extern DmaTransferType dma[4]; 156 | 157 | 158 | struct BiosData 159 | { 160 | // These need to be consecutive because separated areas break Lufia games. 161 | // Somehow, some code is accessing the metadata's first half as if it were 162 | // a "second half" of the BIOS, and having all-zeroes in that area breaks 163 | // everything. Also do not reorder the members, because the assembly files 164 | // expect "bios" to mean "bios.rom". 165 | u8 rom [0x4000]; 166 | u16 metadata[0x4000]; 167 | }; 168 | 169 | extern u16 palette_ram [ 0x200]; 170 | extern u16 oam_ram [ 0x200]; 171 | extern u16 io_registers [ 0x400]; 172 | extern u8 ewram [0x40000]; 173 | extern u8 iwram [ 0x8000]; 174 | extern u8 vram [0x18000]; 175 | struct BiosData bios; 176 | 177 | extern u16 ewram_metadata[0x40000]; 178 | extern u16 iwram_metadata[ 0x8000]; 179 | extern u16 vram_metadata [0x18000]; 180 | 181 | extern u32 bios_read_protect; 182 | 183 | extern u32 iwram_control; 184 | 185 | extern u32 obj_address; 186 | 187 | extern u8 memory_waitstate_n[2][16]; 188 | extern u8 memory_waitstate_s[2][16]; 189 | extern u8 fetch_waitstate_n[2][16]; 190 | extern u8 fetch_waitstate_s[2][16]; 191 | 192 | extern u8 *memory_map_read[8 * 1024]; 193 | extern u8 *memory_map_write[8 * 1024]; 194 | 195 | // extern char backup_id[16]; 196 | 197 | 198 | u8 read_memory8(u32 address); 199 | u32 read_memory16(u32 address); 200 | s16 read_memory16_signed(u32 address); 201 | u32 read_memory32(u32 address); 202 | 203 | u8 read_open_memory8(u32 address); 204 | u16 read_open_memory16(u32 address); 205 | u32 read_open_memory32(u32 address); 206 | 207 | CPU_ALERT_TYPE write_memory8(u32 address, u8 value); 208 | CPU_ALERT_TYPE write_memory16(u32 address, u16 value); 209 | CPU_ALERT_TYPE write_memory32(u32 address, u32 value); 210 | 211 | CPU_ALERT_TYPE write_io_register8(u32 address, u32 value); 212 | CPU_ALERT_TYPE write_io_register16(u32 address, u32 value); 213 | CPU_ALERT_TYPE write_io_register32(u32 address, u32 value); 214 | 215 | CPU_ALERT_TYPE dma_transfer(DmaTransferType *dma); 216 | 217 | u8 *load_gamepak_page(u32 physical_index); 218 | 219 | s32 load_bios(char *name); 220 | s32 load_gamepak(char *name); 221 | s32 load_backup(char *name); 222 | 223 | u32 read_eeprom(void); 224 | u32 read_backup(u32 address); 225 | 226 | CPU_ALERT_TYPE write_eeprom(u32 address, u32 value); 227 | CPU_ALERT_TYPE write_backup(u32 address, u32 value); 228 | CPU_ALERT_TYPE write_rtc(u32 address, u32 value); 229 | 230 | s32 parse_config_line(char *current_line, char *current_variable, char *current_value); 231 | 232 | void init_memory(void); 233 | void init_gamepak_buffer(void); 234 | 235 | void memory_term(void); 236 | 237 | void update_backup(void); 238 | void update_backup_immediately(void); 239 | 240 | extern u8 *write_mem_ptr; 241 | 242 | void load_state(char *savestate_filename); 243 | void save_state(char *savestate_filename, u16 *screen_capture); 244 | 245 | 246 | #define pIO_REG(offset) *(io_registers + (offset)) 247 | 248 | #define GBA_IME_STATE (pIO_REG(REG_IME) != 0) 249 | 250 | #define pMEMORY_WS16N(resion) *(memory_waitstate_n[0] + (resion)) 251 | #define pMEMORY_WS16S(resion) *(memory_waitstate_s[0] + (resion)) 252 | #define pMEMORY_WS32N(resion) *(memory_waitstate_n[1] + (resion)) 253 | #define pMEMORY_WS32S(resion) *(memory_waitstate_s[1] + (resion)) 254 | #define pFETCH_WS16N(resion) *(fetch_waitstate_n[0] + (resion)) 255 | #define pFETCH_WS16S(resion) *(fetch_waitstate_s[0] + (resion)) 256 | #define pFETCH_WS32N(resion) *(fetch_waitstate_n[1] + (resion)) 257 | #define pFETCH_WS32S(resion) *(fetch_waitstate_s[1] + (resion)) 258 | 259 | #endif /* MEMORY_H */ 260 | -------------------------------------------------------------------------------- /source/src/message.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/src/message.c -------------------------------------------------------------------------------- /source/src/message.h: -------------------------------------------------------------------------------- 1 | /* unofficial gameplaySP kai 2 | * 3 | * Copyright (C) 2006 Exophase 4 | * Copyright (C) 2007 takka 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef MESSAGE_H 22 | #define MESSAGE_H 23 | 24 | #define MSG message[option_language] 25 | 26 | enum MESSAGE_ITEM 27 | { 28 | MSG_TURBO, 29 | MSG_CHARGE, 30 | MSG_BUFFER, 31 | 32 | MSG_BROWSER_HELP, 33 | 34 | MSG_MENU_DATE_FMT_0, 35 | MSG_MENU_DATE_FMT_1, 36 | 37 | MSG_MAIN_MENU_TITLE, 38 | 39 | MSG_MAIN_MENU_0, 40 | MSG_MAIN_MENU_1, 41 | MSG_MAIN_MENU_2, 42 | MSG_MAIN_MENU_3, 43 | MSG_MAIN_MENU_4, 44 | MSG_MAIN_MENU_5, 45 | MSG_MAIN_MENU_6, 46 | MSG_MAIN_MENU_CHEAT, 47 | MSG_MAIN_MENU_7, 48 | MSG_MAIN_MENU_8, 49 | MSG_MAIN_MENU_9, 50 | MSG_MAIN_MENU_10, 51 | MSG_MAIN_MENU_11, 52 | 53 | MSG_MAIN_MENU_HELP_0, 54 | MSG_MAIN_MENU_HELP_1, 55 | MSG_MAIN_MENU_HELP_2, 56 | MSG_MAIN_MENU_HELP_3, 57 | MSG_MAIN_MENU_HELP_4, 58 | MSG_MAIN_MENU_HELP_5, 59 | MSG_MAIN_MENU_HELP_6, 60 | MSG_MAIN_MENU_HELP_CHEAT, 61 | MSG_MAIN_MENU_HELP_7, 62 | MSG_MAIN_MENU_HELP_8, 63 | MSG_MAIN_MENU_HELP_9, 64 | MSG_MAIN_MENU_HELP_10, 65 | MSG_MAIN_MENU_HELP_11, 66 | 67 | MSG_OPTION_MENU_TITLE, 68 | 69 | MSG_OPTION_MENU_0, 70 | MSG_OPTION_MENU_1, 71 | MSG_OPTION_MENU_2, 72 | MSG_OPTION_MENU_SHOW_FPS, 73 | MSG_OPTION_MENU_3, 74 | MSG_OPTION_MENU_4, 75 | MSG_OPTION_MENU_5, 76 | MSG_OPTION_MENU_6, 77 | MSG_OPTION_MENU_7, 78 | MSG_OPTION_MENU_8, 79 | MSG_OPTION_MENU_9, 80 | MSG_OPTION_MENU_10, 81 | MSG_OPTION_MENU_DEFAULT, 82 | MSG_OPTION_MENU_11, 83 | 84 | MSG_OPTION_MENU_HELP_0, 85 | MSG_OPTION_MENU_HELP_1, 86 | MSG_OPTION_MENU_HELP_2, 87 | MSG_OPTION_MENU_HELP_SHOW_FPS, 88 | MSG_OPTION_MENU_HELP_3, 89 | MSG_OPTION_MENU_HELP_4, 90 | MSG_OPTION_MENU_HELP_5, 91 | MSG_OPTION_MENU_HELP_6, 92 | MSG_OPTION_MENU_HELP_7, 93 | MSG_OPTION_MENU_HELP_8, 94 | MSG_OPTION_MENU_HELP_9, 95 | MSG_OPTION_MENU_HELP_10, 96 | MSG_OPTION_MENU_HELP_DEFAULT, 97 | MSG_OPTION_MENU_HELP_11, 98 | 99 | MSG_STATE_MENU_DATE_FMT_0, 100 | MSG_STATE_MENU_DATE_FMT_1, 101 | MSG_STATE_MENU_DATE_NONE_0, 102 | MSG_STATE_MENU_DATE_NONE_1, 103 | 104 | MSG_STATE_MENU_STATE_NONE, 105 | 106 | MSG_STATE_MENU_TITLE, 107 | 108 | MSG_STATE_MENU_0, 109 | MSG_STATE_MENU_1, 110 | MSG_STATE_MENU_2, 111 | 112 | MSG_STATE_MENU_HELP_0, 113 | MSG_STATE_MENU_HELP_1, 114 | MSG_STATE_MENU_HELP_2, 115 | 116 | MSG_PAD_MENU_TITLE, 117 | 118 | MSG_PAD_MENU_0, 119 | MSG_PAD_MENU_1, 120 | MSG_PAD_MENU_2, 121 | MSG_PAD_MENU_3, 122 | MSG_PAD_MENU_4, 123 | MSG_PAD_MENU_5, 124 | MSG_PAD_MENU_6, 125 | MSG_PAD_MENU_7, 126 | MSG_PAD_MENU_8, 127 | MSG_PAD_MENU_9, 128 | MSG_PAD_MENU_10, 129 | MSG_PAD_MENU_11, 130 | MSG_PAD_MENU_12, 131 | 132 | MSG_PAD_MENU_HELP_0, 133 | MSG_PAD_MENU_HELP_1, 134 | 135 | MSG_PAD_MENU_CFG_0, 136 | MSG_PAD_MENU_CFG_1, 137 | MSG_PAD_MENU_CFG_2, 138 | MSG_PAD_MENU_CFG_3, 139 | MSG_PAD_MENU_CFG_4, 140 | MSG_PAD_MENU_CFG_5, 141 | MSG_PAD_MENU_CFG_6, 142 | MSG_PAD_MENU_CFG_7, 143 | MSG_PAD_MENU_CFG_8, 144 | MSG_PAD_MENU_CFG_9, 145 | MSG_PAD_MENU_CFG_10, 146 | MSG_PAD_MENU_CFG_11, 147 | MSG_PAD_MENU_CFG_12, 148 | MSG_PAD_MENU_CFG_13, 149 | MSG_PAD_MENU_CFG_14, 150 | MSG_PAD_MENU_CFG_15, 151 | MSG_PAD_MENU_CFG_16, 152 | MSG_PAD_MENU_CFG_17, 153 | MSG_PAD_MENU_CFG_18, 154 | MSG_PAD_MENU_CFG_19, 155 | 156 | MSG_A_PAD_MENU_TITLE, 157 | 158 | MSG_A_PAD_MENU_0, 159 | MSG_A_PAD_MENU_1, 160 | MSG_A_PAD_MENU_2, 161 | MSG_A_PAD_MENU_3, 162 | MSG_A_PAD_MENU_4, 163 | MSG_A_PAD_MENU_5, 164 | MSG_A_PAD_MENU_6, 165 | 166 | MSG_A_PAD_MENU_HELP_0, 167 | MSG_A_PAD_MENU_HELP_1, 168 | MSG_A_PAD_MENU_HELP_2, 169 | 170 | MSG_CHEAT_MENU_TITLE, 171 | 172 | MSG_CHEAT_MENU_NON_LOAD, 173 | MSG_CHEAT_MENU_0, 174 | MSG_CHEAT_MENU_1, 175 | MSG_CHEAT_MENU_2, 176 | MSG_CHEAT_MENU_3, 177 | 178 | MSG_CHEAT_MENU_HELP_0, 179 | MSG_CHEAT_MENU_HELP_1, 180 | MSG_CHEAT_MENU_HELP_2, 181 | MSG_CHEAT_MENU_HELP_3, 182 | 183 | MSG_NON_LOAD_GAME, 184 | 185 | MSG_DAYW_0, 186 | MSG_DAYW_1, 187 | MSG_DAYW_2, 188 | MSG_DAYW_3, 189 | MSG_DAYW_4, 190 | MSG_DAYW_5, 191 | MSG_DAYW_6, 192 | 193 | MSG_YES, 194 | MSG_NO, 195 | 196 | MSG_ON, 197 | MSG_OFF, 198 | 199 | MSG_ENABLED, 200 | MSG_DISABLED, 201 | 202 | MSG_AUTO, 203 | MSG_MANUAL, 204 | 205 | MSG_EXITONLY, 206 | 207 | MSG_LOAD, 208 | MSG_SAVE, 209 | 210 | MSG_SCN_SCALED_NONE, 211 | MSG_SCN_SCALED_X15_GU, 212 | MSG_SCN_SCALED_X15_SW, 213 | MSG_SCN_SCALED_USER, 214 | 215 | MSG_LANG_JAPANESE, 216 | MSG_LANG_ENGLISH, 217 | MSG_LANG_CHS, 218 | MSG_LANG_CHT, 219 | 220 | MSG_SS_DATE_FMT_0, 221 | MSG_SS_DATE_FMT_1, 222 | 223 | MSG_ERR_SET_DIR_0, 224 | MSG_ERR_SET_DIR_1, 225 | MSG_ERR_SET_DIR_2, 226 | 227 | MSG_ERR_SS_PNG_0, 228 | MSG_ERR_SS_PNG_1, 229 | 230 | MSG_LOADING_ROM, 231 | MSG_SEARCHING_BACKUP_ID, 232 | 233 | MSG_GBA_SLEEP_MODE, 234 | 235 | MSG_ERR_LOAD_DIR_INI, 236 | 237 | MSG_ERR_BIOS_NONE, 238 | 239 | MSG_ERR_LOAD_GAMEPACK, 240 | MSG_ERR_OPEN_GAMEPACK, 241 | 242 | MSG_ERR_START_CALLBACK_THREAD, 243 | 244 | MSG_ERR_RESERVE_AUDIO_CHANNEL, 245 | MSG_ERR_START_SOUND_THREAD, 246 | 247 | MSG_ERR_MALLOC, 248 | 249 | MSG_ERR_CONT, 250 | MSG_ERR_QUIT, 251 | 252 | MSG_BLANK, 253 | 254 | MSG_END 255 | }; 256 | 257 | extern const char *message[4][MSG_END]; 258 | 259 | #endif /* MESSAGE_H */ 260 | -------------------------------------------------------------------------------- /source/src/mh_print.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/src/mh_print.c -------------------------------------------------------------------------------- /source/src/mh_print.h: -------------------------------------------------------------------------------- 1 | #define FONTWIDTH (6) 2 | #define FONTHEIGHT (12) 3 | 4 | #define BG_NO_FILL (-1) 5 | 6 | 7 | #define FONT_BATTERY0 "\xF3\xF6\xF7" // empty 8 | #define FONT_BATTERY1 "\xF3\xF5\xF2" 9 | #define FONT_BATTERY2 "\xF3\xF4\xF2" 10 | #define FONT_BATTERY3 "\xF0\xF1\xF2" // full 11 | #define FONT_GBA_ICON "\xF8\x87\xAC" 12 | #define FONT_PSP_ICON "\xF9\x87\xAD" 13 | #define FONT_MSC_ICON "\xFA\x87\xAE" 14 | 15 | #define FONT_KEY_ICON "\x87\xA0" 16 | #define FONT_R_TRIGGER "\x87\xA1" 17 | #define FONT_L_TRIGGER "\x87\xA2" 18 | #define FONT_CURSOR_RIGHT "\x87\xA3" 19 | #define FONT_CURSOR_LEFT "\x87\xA4" 20 | #define FONT_CURSOR_UP "\x87\xA5" 21 | #define FONT_CURSOR_DOWN "\x87\xA6" 22 | #define FONT_CURSOR_RIGHT_FILL "\x87\xA7" 23 | #define FONT_CURSOR_LEFT_FILL "\x87\xA8" 24 | #define FONT_CURSOR_UP_FILL "\x87\xA9" 25 | #define FONT_CURSOR_DOWN_FILL "\x87\xAA" 26 | #define FONT_UP_DIRECTORY "\x87\xAB" 27 | 28 | 29 | void mh_print(const char *str, u16 x, u16 y, u16 col, s16 bg_col, u16 *base_vram, u16 bufferwidth); 30 | 31 | -------------------------------------------------------------------------------- /source/src/png.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/src/png.c -------------------------------------------------------------------------------- /source/src/png.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | 3 | png.c 4 | 5 | PSP PNG format image I/O functions. (based on M.A.M.E. PNG functions) 6 | 7 | ***************************************************************************/ 8 | 9 | #ifndef PSP_PNG_H 10 | #define PSP_PNG_H 11 | 12 | int save_png(const char *path, u16 *screen_image); 13 | 14 | #endif /* PSP_PNG_H */ 15 | -------------------------------------------------------------------------------- /source/src/sound.h: -------------------------------------------------------------------------------- 1 | /* unofficial gameplaySP kai 2 | * 3 | * Copyright (C) 2006 Exophase 4 | * Copyright (C) 2007 takka 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef SOUND_H 22 | #define SOUND_H 23 | 24 | 25 | #define SOUND_SAMPLES (800) 26 | #define SOUND_FREQUENCY (48000) 27 | 28 | // #define SOUND_SAMPLES (736) 29 | // #define SOUND_FREQUENCY (44100) 30 | 31 | extern u32 sound_pause; 32 | 33 | extern u32 gbc_sound_update; 34 | void update_gbc_sound(u32 cpu_ticks); 35 | 36 | void sound_timer(FIXED08_24 frequency_step, u8 channel); 37 | void adjust_direct_sound_buffer(u8 channel, u32 cpu_ticks); 38 | 39 | void sound_timer_queue(u8 channel); 40 | 41 | void gbc_sound_tone_control_low(u8 channel, u32 value); 42 | void gbc_sound_tone_control_high(u8 channel, u32 value); 43 | 44 | void gbc_sound_tone_control_sweep(u32 value); 45 | 46 | void gbc_sound_wave_control(u32 value); 47 | void gbc_sound_tone_control_low_wave(u32 value); 48 | void gbc_sound_tone_control_high_wave(u32 value); 49 | void gbc_sound_wave_pattern_ram16(u32 address, u32 value); 50 | 51 | void gbc_sound_noise_control(u32 value); 52 | 53 | void sound_control_low(u32 value); 54 | void sound_control_high(u32 value); 55 | void sound_control_x(u32 value); 56 | 57 | 58 | void init_sound(void); 59 | void reset_sound(void); 60 | void sound_term(void); 61 | 62 | void set_sound_volume(void); 63 | int psp_sound_frequency(u16 sample_count, u16 freq); 64 | 65 | void synchronize_sound(void); 66 | 67 | void sound_write_mem_savestate(SceUID savestate_file); 68 | void sound_read_savestate(SceUID savestate_file); 69 | 70 | 71 | #endif /* SOUND_H */ 72 | -------------------------------------------------------------------------------- /source/src/text/a_pad_menu_t.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/src/text/a_pad_menu_t.h -------------------------------------------------------------------------------- /source/src/text/cheat_menu_t.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/src/text/cheat_menu_t.h -------------------------------------------------------------------------------- /source/src/text/main_menu_t.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/src/text/main_menu_t.h -------------------------------------------------------------------------------- /source/src/text/option_menu_t.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/src/text/option_menu_t.h -------------------------------------------------------------------------------- /source/src/text/pad_menu_t.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/src/text/pad_menu_t.h -------------------------------------------------------------------------------- /source/src/text/state_menu_t.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/src/text/state_menu_t.h -------------------------------------------------------------------------------- /source/src/video.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GrabowskiDev/TempGBA4PSP-Single-game/f7fa8f74b9f9cee20752a25f00c45d137e444c82/source/src/video.c -------------------------------------------------------------------------------- /source/src/video.h: -------------------------------------------------------------------------------- 1 | /* unofficial gameplaySP kai 2 | * 3 | * Copyright (C) 2006 Exophase 4 | * Copyright (C) 2007 takka 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef VIDEO_H 22 | #define VIDEO_H 23 | 24 | 25 | #define GBA_SCREEN_WIDTH (240) 26 | #define GBA_SCREEN_HEIGHT (160) 27 | #define GBA_LINE_SIZE (256) 28 | #define GBA_SCREEN_SIZE (GBA_SCREEN_WIDTH * GBA_SCREEN_HEIGHT * 2) 29 | 30 | #define PSP_SCREEN_WIDTH (480) 31 | #define PSP_SCREEN_HEIGHT (272) 32 | #define PSP_LINE_SIZE (512) 33 | #define PSP_FRAME_SIZE (PSP_LINE_SIZE * PSP_SCREEN_HEIGHT * 2) 34 | 35 | 36 | #define COLOR15(red, green, blue) (((blue) << 10) | ((green) << 5) | (red)) 37 | 38 | #define COLOR15_WHITE COLOR15(31, 31, 31) 39 | #define COLOR15_BLACK COLOR15( 0, 0, 0) 40 | #define COLOR15_RED COLOR15(31, 5, 5) 41 | #define COLOR15_GREEN COLOR15( 5, 31, 5) 42 | #define COLOR15_BLUE COLOR15( 5, 5, 31) 43 | #define COLOR15_YELLOW COLOR15(31, 31, 5) 44 | #define COLOR15_PURPLE COLOR15(31, 5, 31) 45 | #define COLOR15_CYAN COLOR15( 5, 31, 31) 46 | 47 | #define COL15_GET_R5(col15) ((col15) & 0x1F) 48 | #define COL15_GET_G5(col15) (((col15) >> 5) & 0x1F) 49 | #define COL15_GET_B5(col15) (((col15) >>10) & 0x1F) 50 | 51 | #define COL15_GET_R8(col15) ((((col15) << 3) & 0xF8) | (((col15) >> 2) & 0x07)) 52 | #define COL15_GET_G8(col15) ((((col15) >> 2) & 0xF8) | (((col15) >> 7) & 0x07)) 53 | #define COL15_GET_B8(col15) ((((col15) >> 7) & 0xF8) | (((col15) >> 12) & 0x07)) 54 | 55 | #define COLOR32(red, green, blue) (((blue) << 16) | ((green) << 8) | (red) | 0xFF000000) 56 | 57 | #define COLOR32_WHITE COLOR32(255, 255, 255) 58 | #define COLOR32_BLACK COLOR32( 0, 0, 0) 59 | 60 | #define COL32_GET_R8(col32) ((col32) & 0xFF) 61 | #define COL32_GET_G8(col32) (((col32) >> 8) & 0xFF) 62 | #define COL32_GET_B8(col32) (((col32) >> 16) & 0xFF) 63 | 64 | #define COLOR15_TO_32(col15) COLOR32(COL15_GET_R8(col15), COL15_GET_G8(col15), COL15_GET_B8(col15)) 65 | 66 | #define X_POS_CENTER (-1) 67 | 68 | 69 | void update_scanline(void); 70 | void (*update_screen)(void); 71 | 72 | void flip_screen(u32 vsync); 73 | 74 | void video_resolution_large(void); 75 | void video_resolution_small(void); 76 | 77 | void init_video(int devkit_version); 78 | void video_term(void); 79 | 80 | void print_string(const char *str, s16 x, u16 y, u16 fg_color, s16 bg_color); 81 | void print_string_ext(const char *str, s16 x, u16 y, u16 fg_color, s16 bg_color, void *_dest_ptr, u16 pitch); 82 | 83 | void print_string_gbk(const char *str, s16 x, u16 y, u16 fg_color, s16 bg_color); 84 | void print_string_ext_gbk(const char *str, s16 x, u16 y, u16 fg_color, s16 bg_color, void *_dest_ptr, u16 pitch); 85 | 86 | void clear_screen(u32 color); 87 | void clear_texture(u16 color); 88 | 89 | void blit_to_screen(u16 *src, u16 w, u16 h, u16 dest_x, u16 dest_y); 90 | u16 *copy_screen(void); 91 | 92 | extern s32 affine_reference_x[2]; 93 | extern s32 affine_reference_y[2]; 94 | 95 | typedef void (*tile_render_function)(u32 layer_number, u32 start, u32 end, void *dest_ptr); 96 | typedef void (*bitmap_render_function)(u32 start, u32 end, void *dest_ptr); 97 | 98 | typedef struct 99 | { 100 | tile_render_function normal_render_base; 101 | tile_render_function normal_render_transparent; 102 | tile_render_function alpha_render_base; 103 | tile_render_function alpha_render_transparent; 104 | tile_render_function color16_render_base; 105 | tile_render_function color16_render_transparent; 106 | tile_render_function color32_render_base; 107 | tile_render_function color32_render_transparent; 108 | } TileLayerRenderStruct; 109 | 110 | typedef struct 111 | { 112 | bitmap_render_function normal_render; 113 | } BitmapLayerRenderStruct; 114 | 115 | 116 | void draw_box_line(u16 x1, u16 y1, u16 x2, u16 y2, u16 color); 117 | void draw_box_fill(u16 x1, u16 y1, u16 x2, u16 y2, u16 color); 118 | void draw_box_alpha(u16 x1, u16 y1, u16 x2, u16 y2, u32 color); 119 | 120 | void draw_hline(u16 sx, u16 ex, u16 y, u16 color); 121 | void draw_vline(u16 x, u16 sy, u16 ey, u16 color); 122 | 123 | int (*__draw_volume_status)(int draw); 124 | int draw_volume_status(int draw); 125 | int draw_volume_status_null(int draw); 126 | 127 | void video_write_mem_savestate(SceUID savestate_file); 128 | void video_read_savestate(SceUID savestate_file); 129 | 130 | 131 | #endif /* VIDEO_H */ 132 | -------------------------------------------------------------------------------- /source/src/zip.c: -------------------------------------------------------------------------------- 1 | /* unofficial gameplaySP kai 2 | * 3 | * Copyright (C) 2006 Exophase 4 | * Copyright (C) 2006 SiberianSTAR 5 | * Copyright (C) 2007 takka 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License as 9 | * published by the Free Software Foundation; either version 2 of 10 | * the License, or (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 GNU 15 | * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include "common.h" 23 | 24 | 25 | #define ZIP_BUFFER_SIZE (128 * 1024) 26 | 27 | struct SZIPFileDataDescriptor 28 | { 29 | s32 CRC32; 30 | s32 CompressedSize; 31 | s32 UncompressedSize; 32 | } __attribute__((packed)); 33 | 34 | struct SZIPFileHeader 35 | { 36 | char Sig[4]; 37 | s16 VersionToExtract; 38 | s16 GeneralBitFlag; 39 | s16 CompressionMethod; 40 | s16 LastModFileTime; 41 | s16 LastModFileDate; 42 | struct SZIPFileDataDescriptor DataDescriptor; 43 | s16 FilenameLength; 44 | s16 ExtraFieldLength; 45 | } __attribute__((packed)); 46 | 47 | void draw_progress(u32 output_size, u32 total_size); 48 | 49 | 50 | s32 load_file_zip(char *filename) 51 | { 52 | SceUID fd; 53 | struct SZIPFileHeader data; 54 | char tmp[MAX_FILE]; 55 | s32 retval = -1; 56 | u8 *buffer = NULL; 57 | u8 *cbuffer = NULL; 58 | char *ext; 59 | 60 | FILE_OPEN(fd, filename, READ); 61 | 62 | if (!FILE_CHECK_VALID(fd)) 63 | return -1; 64 | 65 | FILE_READ(fd, &data, sizeof(struct SZIPFileHeader)); 66 | 67 | if ((data.Sig[0] != 0x50) || (data.Sig[1] != 0x4B) || (data.Sig[2] != 0x03) || (data.Sig[3] != 0x04)) 68 | { 69 | goto outcode; 70 | } 71 | 72 | FILE_READ(fd, tmp, data.FilenameLength); 73 | tmp[data.FilenameLength] = 0; // end string 74 | 75 | if (data.ExtraFieldLength != 0) 76 | { 77 | FILE_SEEK(fd, data.ExtraFieldLength, SEEK_CUR); 78 | } 79 | 80 | if ((data.GeneralBitFlag & 0x0008) != 0) 81 | { 82 | FILE_READ(fd, &data.DataDescriptor, sizeof(struct SZIPFileDataDescriptor)); 83 | } 84 | 85 | // file is too big 86 | if ((u32)data.DataDescriptor.UncompressedSize > gamepak_ram_buffer_size) 87 | { 88 | retval = -2; 89 | goto outcode; 90 | } 91 | 92 | ext = strrchr(tmp, '.') + 1; 93 | 94 | if ((strcasecmp(ext, "bin") == 0) || (strcasecmp(ext, "gba") == 0) || (strcasecmp(ext, "agb") == 0)) 95 | { 96 | buffer = gamepak_rom; 97 | 98 | // ok, found 99 | switch (data.CompressionMethod) 100 | { 101 | case 0: // Z_NO_COMPRESSION 102 | retval = (u32)data.DataDescriptor.UncompressedSize; 103 | FILE_READ(fd, buffer, retval); 104 | break; 105 | 106 | case 8: // Z_DEFLATED 107 | { 108 | z_stream stream; 109 | s32 err; 110 | 111 | if ((cbuffer = (u8 *)malloc(ZIP_BUFFER_SIZE)) == NULL) 112 | break; 113 | memset(cbuffer, 0, ZIP_BUFFER_SIZE); 114 | 115 | stream.next_in = (Bytef*)cbuffer; 116 | stream.avail_in = (u32)ZIP_BUFFER_SIZE; 117 | stream.next_out = (Bytef*)buffer; 118 | stream.avail_out = data.DataDescriptor.UncompressedSize; 119 | stream.zalloc = (alloc_func)Z_NULL; 120 | stream.zfree = (free_func)Z_NULL; 121 | stream.opaque = (voidpf)Z_NULL; 122 | 123 | err = inflateInit2(&stream, -MAX_WBITS); 124 | 125 | FILE_READ(fd, cbuffer, ZIP_BUFFER_SIZE); 126 | 127 | if (err == Z_OK) 128 | { 129 | retval = (u32)data.DataDescriptor.UncompressedSize; 130 | 131 | while (err != Z_STREAM_END) 132 | { 133 | err = inflate(&stream, Z_SYNC_FLUSH); 134 | 135 | if (err == Z_BUF_ERROR) 136 | { 137 | stream.avail_in = ZIP_BUFFER_SIZE; 138 | stream.next_in = (Bytef*)cbuffer; 139 | 140 | FILE_READ(fd, cbuffer, ZIP_BUFFER_SIZE); 141 | } 142 | 143 | draw_progress((u32)stream.total_out, (u32)retval); 144 | flip_screen(0); 145 | } 146 | 147 | err = Z_OK; 148 | inflateEnd(&stream); 149 | } 150 | 151 | free(cbuffer); 152 | break; 153 | } 154 | } 155 | } 156 | 157 | outcode: 158 | FILE_CLOSE(fd); 159 | 160 | return retval; 161 | } 162 | 163 | void draw_progress(u32 output_size, u32 total_size) 164 | { 165 | draw_box_line(140 - 4, 140 - 4, 340 + 4, 165 + 4, COLOR15_WHITE); 166 | draw_box_line(140 - 3, 140 - 3, 340 + 3, 165 + 3, COLOR15_WHITE); 167 | draw_box_fill(140, 140, 140 + ((u64)output_size * 200 / total_size), 165, COLOR15_WHITE); 168 | } 169 | 170 | -------------------------------------------------------------------------------- /source/src/zip.h: -------------------------------------------------------------------------------- 1 | /* unofficial gameplaySP kai 2 | * 3 | * Copyright (C) 2006 Exophase 4 | * Copyright (C) 2007 takka 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef ZIP_H 22 | #define ZIP_H 23 | 24 | 25 | s32 load_file_zip(char *filename); 26 | 27 | 28 | #endif /* ZIP_H */ 29 | -------------------------------------------------------------------------------- /source/src/zlib/README: -------------------------------------------------------------------------------- 1 | ZLIB DATA COMPRESSION LIBRARY 2 | 3 | zlib 1.2.8 is a general purpose data compression library. All the code is 4 | thread safe. The data format used by the zlib library is described by RFCs 5 | (Request for Comments) 1950 to 1952 in the files 6 | http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and 7 | rfc1952 (gzip format). 8 | 9 | All functions of the compression library are documented in the file zlib.h 10 | (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example 11 | of the library is given in the file test/example.c which also tests that 12 | the library is working correctly. Another example is given in the file 13 | test/minigzip.c. The compression library itself is composed of all source 14 | files in the root directory. 15 | 16 | To compile all files and run the test program, follow the instructions given at 17 | the top of Makefile.in. In short "./configure; make test", and if that goes 18 | well, "make install" should work for most flavors of Unix. For Windows, use 19 | one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use 20 | make_vms.com. 21 | 22 | Questions about zlib should be sent to , or to Gilles Vollant 23 | for the Windows DLL version. The zlib home page is 24 | http://zlib.net/ . Before reporting a problem, please check this site to 25 | verify that you have the latest version of zlib; otherwise get the latest 26 | version and check whether the problem still exists or not. 27 | 28 | PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. 29 | 30 | Mark Nelson wrote an article about zlib for the Jan. 1997 31 | issue of Dr. Dobb's Journal; a copy of the article is available at 32 | http://marknelson.us/1997/01/01/zlib-engine/ . 33 | 34 | The changes made in version 1.2.8 are documented in the file ChangeLog. 35 | 36 | Unsupported third party contributions are provided in directory contrib/ . 37 | 38 | zlib is available in Java using the java.util.zip package, documented at 39 | http://java.sun.com/developer/technicalArticles/Programming/compression/ . 40 | 41 | A Perl interface to zlib written by Paul Marquess is available 42 | at CPAN (Comprehensive Perl Archive Network) sites, including 43 | http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . 44 | 45 | A Python interface to zlib written by A.M. Kuchling is 46 | available in Python 1.5 and later versions, see 47 | http://docs.python.org/library/zlib.html . 48 | 49 | zlib is built into tcl: http://wiki.tcl.tk/4610 . 50 | 51 | An experimental package to read and write files in .zip format, written on top 52 | of zlib by Gilles Vollant , is available in the 53 | contrib/minizip directory of zlib. 54 | 55 | 56 | Notes for some targets: 57 | 58 | - For Windows DLL versions, please see win32/DLL_FAQ.txt 59 | 60 | - For 64-bit Irix, deflate.c must be compiled without any optimization. With 61 | -O, one libpng test fails. The test works in 32 bit mode (with the -n32 62 | compiler flag). The compiler bug has been reported to SGI. 63 | 64 | - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works 65 | when compiled with cc. 66 | 67 | - On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is 68 | necessary to get gzprintf working correctly. This is done by configure. 69 | 70 | - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with 71 | other compilers. Use "make test" to check your compiler. 72 | 73 | - gzdopen is not supported on RISCOS or BEOS. 74 | 75 | - For PalmOs, see http://palmzlib.sourceforge.net/ 76 | 77 | 78 | Acknowledgments: 79 | 80 | The deflate format used by zlib was defined by Phil Katz. The deflate and 81 | zlib specifications were written by L. Peter Deutsch. Thanks to all the 82 | people who reported problems and suggested various improvements in zlib; they 83 | are too numerous to cite here. 84 | 85 | Copyright notice: 86 | 87 | (C) 1995-2013 Jean-loup Gailly and Mark Adler 88 | 89 | This software is provided 'as-is', without any express or implied 90 | warranty. In no event will the authors be held liable for any damages 91 | arising from the use of this software. 92 | 93 | Permission is granted to anyone to use this software for any purpose, 94 | including commercial applications, and to alter it and redistribute it 95 | freely, subject to the following restrictions: 96 | 97 | 1. The origin of this software must not be misrepresented; you must not 98 | claim that you wrote the original software. If you use this software 99 | in a product, an acknowledgment in the product documentation would be 100 | appreciated but is not required. 101 | 2. Altered source versions must be plainly marked as such, and must not be 102 | misrepresented as being the original software. 103 | 3. This notice may not be removed or altered from any source distribution. 104 | 105 | Jean-loup Gailly Mark Adler 106 | jloup@gzip.org madler@alumni.caltech.edu 107 | 108 | If you use the zlib library in a product, we would appreciate *not* receiving 109 | lengthy legal documents to sign. The sources are provided for free but without 110 | warranty of any kind. The library has been entirely written by Jean-loup 111 | Gailly and Mark Adler; it does not include third-party code. 112 | 113 | If you redistribute modified sources, we would appreciate that you include in 114 | the file ChangeLog history information documenting your changes. Please read 115 | the FAQ for more information on the distribution of modified source versions. 116 | -------------------------------------------------------------------------------- /source/src/zlib/adler32.c: -------------------------------------------------------------------------------- 1 | /* adler32.c -- compute the Adler-32 checksum of a data stream 2 | * Copyright (C) 1995-2011 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #include "zutil.h" 9 | 10 | #define local static 11 | 12 | local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); 13 | 14 | #define BASE 65521 /* largest prime smaller than 65536 */ 15 | #define NMAX 5552 16 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 17 | 18 | #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} 19 | #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); 20 | #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); 21 | #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); 22 | #define DO16(buf) DO8(buf,0); DO8(buf,8); 23 | 24 | /* use NO_DIVIDE if your processor does not do division in hardware -- 25 | try it both ways to see which is faster */ 26 | #ifdef NO_DIVIDE 27 | /* note that this assumes BASE is 65521, where 65536 % 65521 == 15 28 | (thank you to John Reiser for pointing this out) */ 29 | # define CHOP(a) \ 30 | do { \ 31 | unsigned long tmp = a >> 16; \ 32 | a &= 0xffffUL; \ 33 | a += (tmp << 4) - tmp; \ 34 | } while (0) 35 | # define MOD28(a) \ 36 | do { \ 37 | CHOP(a); \ 38 | if (a >= BASE) a -= BASE; \ 39 | } while (0) 40 | # define MOD(a) \ 41 | do { \ 42 | CHOP(a); \ 43 | MOD28(a); \ 44 | } while (0) 45 | # define MOD63(a) \ 46 | do { /* this assumes a is not negative */ \ 47 | z_off64_t tmp = a >> 32; \ 48 | a &= 0xffffffffL; \ 49 | a += (tmp << 8) - (tmp << 5) + tmp; \ 50 | tmp = a >> 16; \ 51 | a &= 0xffffL; \ 52 | a += (tmp << 4) - tmp; \ 53 | tmp = a >> 16; \ 54 | a &= 0xffffL; \ 55 | a += (tmp << 4) - tmp; \ 56 | if (a >= BASE) a -= BASE; \ 57 | } while (0) 58 | #else 59 | # define MOD(a) a %= BASE 60 | # define MOD28(a) a %= BASE 61 | # define MOD63(a) a %= BASE 62 | #endif 63 | 64 | /* ========================================================================= */ 65 | uLong ZEXPORT adler32(adler, buf, len) 66 | uLong adler; 67 | const Bytef *buf; 68 | uInt len; 69 | { 70 | unsigned long sum2; 71 | unsigned n; 72 | 73 | /* split Adler-32 into component sums */ 74 | sum2 = (adler >> 16) & 0xffff; 75 | adler &= 0xffff; 76 | 77 | /* in case user likes doing a byte at a time, keep it fast */ 78 | if (len == 1) { 79 | adler += buf[0]; 80 | if (adler >= BASE) 81 | adler -= BASE; 82 | sum2 += adler; 83 | if (sum2 >= BASE) 84 | sum2 -= BASE; 85 | return adler | (sum2 << 16); 86 | } 87 | 88 | /* initial Adler-32 value (deferred check for len == 1 speed) */ 89 | if (buf == Z_NULL) 90 | return 1L; 91 | 92 | /* in case short lengths are provided, keep it somewhat fast */ 93 | if (len < 16) { 94 | while (len--) { 95 | adler += *buf++; 96 | sum2 += adler; 97 | } 98 | if (adler >= BASE) 99 | adler -= BASE; 100 | MOD28(sum2); /* only added so many BASE's */ 101 | return adler | (sum2 << 16); 102 | } 103 | 104 | /* do length NMAX blocks -- requires just one modulo operation */ 105 | while (len >= NMAX) { 106 | len -= NMAX; 107 | n = NMAX / 16; /* NMAX is divisible by 16 */ 108 | do { 109 | DO16(buf); /* 16 sums unrolled */ 110 | buf += 16; 111 | } while (--n); 112 | MOD(adler); 113 | MOD(sum2); 114 | } 115 | 116 | /* do remaining bytes (less than NMAX, still just one modulo) */ 117 | if (len) { /* avoid modulos if none remaining */ 118 | while (len >= 16) { 119 | len -= 16; 120 | DO16(buf); 121 | buf += 16; 122 | } 123 | while (len--) { 124 | adler += *buf++; 125 | sum2 += adler; 126 | } 127 | MOD(adler); 128 | MOD(sum2); 129 | } 130 | 131 | /* return recombined sums */ 132 | return adler | (sum2 << 16); 133 | } 134 | 135 | /* ========================================================================= */ 136 | local uLong adler32_combine_(adler1, adler2, len2) 137 | uLong adler1; 138 | uLong adler2; 139 | z_off64_t len2; 140 | { 141 | unsigned long sum1; 142 | unsigned long sum2; 143 | unsigned rem; 144 | 145 | /* for negative len, return invalid adler32 as a clue for debugging */ 146 | if (len2 < 0) 147 | return 0xffffffffUL; 148 | 149 | /* the derivation of this formula is left as an exercise for the reader */ 150 | MOD63(len2); /* assumes len2 >= 0 */ 151 | rem = (unsigned)len2; 152 | sum1 = adler1 & 0xffff; 153 | sum2 = rem * sum1; 154 | MOD(sum2); 155 | sum1 += (adler2 & 0xffff) + BASE - 1; 156 | sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; 157 | if (sum1 >= BASE) sum1 -= BASE; 158 | if (sum1 >= BASE) sum1 -= BASE; 159 | if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1); 160 | if (sum2 >= BASE) sum2 -= BASE; 161 | return sum1 | (sum2 << 16); 162 | } 163 | 164 | /* ========================================================================= */ 165 | uLong ZEXPORT adler32_combine(adler1, adler2, len2) 166 | uLong adler1; 167 | uLong adler2; 168 | z_off_t len2; 169 | { 170 | return adler32_combine_(adler1, adler2, len2); 171 | } 172 | 173 | uLong ZEXPORT adler32_combine64(adler1, adler2, len2) 174 | uLong adler1; 175 | uLong adler2; 176 | z_off64_t len2; 177 | { 178 | return adler32_combine_(adler1, adler2, len2); 179 | } 180 | -------------------------------------------------------------------------------- /source/src/zlib/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 23 | Bytef *dest; 24 | uLongf *destLen; 25 | const Bytef *source; 26 | uLong sourceLen; 27 | int level; 28 | { 29 | z_stream stream; 30 | int err; 31 | 32 | stream.next_in = (z_const Bytef *)source; 33 | stream.avail_in = (uInt)sourceLen; 34 | #ifdef MAXSEG_64K 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | #endif 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | stream.opaque = (voidpf)0; 45 | 46 | err = deflateInit(&stream, level); 47 | if (err != Z_OK) return err; 48 | 49 | err = deflate(&stream, Z_FINISH); 50 | if (err != Z_STREAM_END) { 51 | deflateEnd(&stream); 52 | return err == Z_OK ? Z_BUF_ERROR : err; 53 | } 54 | *destLen = stream.total_out; 55 | 56 | err = deflateEnd(&stream); 57 | return err; 58 | } 59 | 60 | /* =========================================================================== 61 | */ 62 | int ZEXPORT compress (dest, destLen, source, sourceLen) 63 | Bytef *dest; 64 | uLongf *destLen; 65 | const Bytef *source; 66 | uLong sourceLen; 67 | { 68 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 69 | } 70 | 71 | /* =========================================================================== 72 | If the default memLevel or windowBits for deflateInit() is changed, then 73 | this function needs to be updated. 74 | */ 75 | uLong ZEXPORT compressBound (sourceLen) 76 | uLong sourceLen; 77 | { 78 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 79 | (sourceLen >> 25) + 13; 80 | } 81 | -------------------------------------------------------------------------------- /source/src/zlib/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /source/src/zlib/gzguts.h: -------------------------------------------------------------------------------- 1 | /* gzguts.h -- zlib internal header definitions for gz* operations 2 | * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #ifdef _LARGEFILE64_SOURCE 7 | # ifndef _LARGEFILE_SOURCE 8 | # define _LARGEFILE_SOURCE 1 9 | # endif 10 | # ifdef _FILE_OFFSET_BITS 11 | # undef _FILE_OFFSET_BITS 12 | # endif 13 | #endif 14 | 15 | #ifdef HAVE_HIDDEN 16 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 17 | #else 18 | # define ZLIB_INTERNAL 19 | #endif 20 | 21 | #include 22 | #include "zlib.h" 23 | #ifdef STDC 24 | # include 25 | # include 26 | # include 27 | #endif 28 | #include 29 | 30 | #ifdef _WIN32 31 | # include 32 | #endif 33 | 34 | #if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) 35 | # include 36 | #endif 37 | 38 | #ifdef WINAPI_FAMILY 39 | # define open _open 40 | # define read _read 41 | # define write _write 42 | # define close _close 43 | #endif 44 | 45 | #ifdef NO_DEFLATE /* for compatibility with old definition */ 46 | # define NO_GZCOMPRESS 47 | #endif 48 | 49 | #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) 50 | # ifndef HAVE_VSNPRINTF 51 | # define HAVE_VSNPRINTF 52 | # endif 53 | #endif 54 | 55 | #if defined(__CYGWIN__) 56 | # ifndef HAVE_VSNPRINTF 57 | # define HAVE_VSNPRINTF 58 | # endif 59 | #endif 60 | 61 | #if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410) 62 | # ifndef HAVE_VSNPRINTF 63 | # define HAVE_VSNPRINTF 64 | # endif 65 | #endif 66 | 67 | #ifndef HAVE_VSNPRINTF 68 | # ifdef MSDOS 69 | /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), 70 | but for now we just assume it doesn't. */ 71 | # define NO_vsnprintf 72 | # endif 73 | # ifdef __TURBOC__ 74 | # define NO_vsnprintf 75 | # endif 76 | # ifdef WIN32 77 | /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ 78 | # if !defined(vsnprintf) && !defined(NO_vsnprintf) 79 | # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) 80 | # define vsnprintf _vsnprintf 81 | # endif 82 | # endif 83 | # endif 84 | # ifdef __SASC 85 | # define NO_vsnprintf 86 | # endif 87 | # ifdef VMS 88 | # define NO_vsnprintf 89 | # endif 90 | # ifdef __OS400__ 91 | # define NO_vsnprintf 92 | # endif 93 | # ifdef __MVS__ 94 | # define NO_vsnprintf 95 | # endif 96 | #endif 97 | 98 | /* unlike snprintf (which is required in C99, yet still not supported by 99 | Microsoft more than a decade later!), _snprintf does not guarantee null 100 | termination of the result -- however this is only used in gzlib.c where 101 | the result is assured to fit in the space provided */ 102 | #ifdef _MSC_VER 103 | # define snprintf _snprintf 104 | #endif 105 | 106 | #ifndef local 107 | # define local static 108 | #endif 109 | /* compile with -Dlocal if your debugger can't find static symbols */ 110 | 111 | /* gz* functions always use library allocation functions */ 112 | #ifndef STDC 113 | extern voidp malloc OF((uInt size)); 114 | extern void free OF((voidpf ptr)); 115 | #endif 116 | 117 | /* get errno and strerror definition */ 118 | #if defined UNDER_CE 119 | # include 120 | # define zstrerror() gz_strwinerror((DWORD)GetLastError()) 121 | #else 122 | # ifndef NO_STRERROR 123 | # include 124 | # define zstrerror() strerror(errno) 125 | # else 126 | # define zstrerror() "stdio error (consult errno)" 127 | # endif 128 | #endif 129 | 130 | /* provide prototypes for these when building zlib without LFS */ 131 | #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 132 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); 133 | ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); 134 | ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); 135 | ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); 136 | #endif 137 | 138 | /* default memLevel */ 139 | #if MAX_MEM_LEVEL >= 8 140 | # define DEF_MEM_LEVEL 8 141 | #else 142 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL 143 | #endif 144 | 145 | /* default i/o buffer size -- double this for output when reading (this and 146 | twice this must be able to fit in an unsigned type) */ 147 | #define GZBUFSIZE 8192 148 | 149 | /* gzip modes, also provide a little integrity check on the passed structure */ 150 | #define GZ_NONE 0 151 | #define GZ_READ 7247 152 | #define GZ_WRITE 31153 153 | #define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ 154 | 155 | /* values for gz_state how */ 156 | #define LOOK 0 /* look for a gzip header */ 157 | #define COPY 1 /* copy input directly */ 158 | #define GZIP 2 /* decompress a gzip stream */ 159 | 160 | /* internal gzip file state data structure */ 161 | typedef struct { 162 | /* exposed contents for gzgetc() macro */ 163 | struct gzFile_s x; /* "x" for exposed */ 164 | /* x.have: number of bytes available at x.next */ 165 | /* x.next: next output data to deliver or write */ 166 | /* x.pos: current position in uncompressed data */ 167 | /* used for both reading and writing */ 168 | int mode; /* see gzip modes above */ 169 | int fd; /* file descriptor */ 170 | char *path; /* path or fd for error messages */ 171 | unsigned size; /* buffer size, zero if not allocated yet */ 172 | unsigned want; /* requested buffer size, default is GZBUFSIZE */ 173 | unsigned char *in; /* input buffer */ 174 | unsigned char *out; /* output buffer (double-sized when reading) */ 175 | int direct; /* 0 if processing gzip, 1 if transparent */ 176 | /* just for reading */ 177 | int how; /* 0: get header, 1: copy, 2: decompress */ 178 | z_off64_t start; /* where the gzip data started, for rewinding */ 179 | int eof; /* true if end of input file reached */ 180 | int past; /* true if read requested past end */ 181 | /* just for writing */ 182 | int level; /* compression level */ 183 | int strategy; /* compression strategy */ 184 | /* seek request */ 185 | z_off64_t skip; /* amount to skip (already rewound if backwards) */ 186 | int seek; /* true if seek request pending */ 187 | /* error information */ 188 | int err; /* error code */ 189 | char *msg; /* error message */ 190 | /* zlib inflate or deflate stream */ 191 | z_stream strm; /* stream structure in-place (not a pointer) */ 192 | } gz_state; 193 | typedef gz_state FAR *gz_statep; 194 | 195 | /* shared functions */ 196 | void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); 197 | #if defined UNDER_CE 198 | char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); 199 | #endif 200 | 201 | /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t 202 | value -- needed when comparing unsigned to z_off64_t, which is signed 203 | (possible z_off64_t types off_t, off64_t, and long are all signed) */ 204 | #ifdef INT_MAX 205 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) 206 | #else 207 | unsigned ZLIB_INTERNAL gz_intmax OF((void)); 208 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) 209 | #endif 210 | -------------------------------------------------------------------------------- /source/src/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /source/src/zlib/inffixed.h: -------------------------------------------------------------------------------- 1 | /* inffixed.h -- table for decoding fixed codes 2 | * Generated automatically by makefixed(). 3 | */ 4 | 5 | /* WARNING: this file should *not* be used by applications. 6 | It is part of the implementation of this library and is 7 | subject to change. Applications should only use zlib.h. 8 | */ 9 | 10 | static const code lenfix[512] = { 11 | {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, 12 | {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, 13 | {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, 14 | {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, 15 | {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, 16 | {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, 17 | {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, 18 | {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, 19 | {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, 20 | {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, 21 | {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, 22 | {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, 23 | {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, 24 | {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, 25 | {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, 26 | {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, 27 | {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, 28 | {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, 29 | {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, 30 | {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, 31 | {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, 32 | {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, 33 | {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, 34 | {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, 35 | {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, 36 | {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, 37 | {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, 38 | {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, 39 | {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, 40 | {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, 41 | {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, 42 | {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, 43 | {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, 44 | {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, 45 | {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, 46 | {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, 47 | {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, 48 | {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, 49 | {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, 50 | {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, 51 | {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, 52 | {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, 53 | {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, 54 | {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, 55 | {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, 56 | {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, 57 | {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, 58 | {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, 59 | {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, 60 | {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, 61 | {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, 62 | {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, 63 | {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, 64 | {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, 65 | {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, 66 | {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, 67 | {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, 68 | {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, 69 | {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, 70 | {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, 71 | {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, 72 | {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, 73 | {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, 74 | {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, 75 | {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, 76 | {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, 77 | {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, 78 | {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, 79 | {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, 80 | {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, 81 | {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, 82 | {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, 83 | {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, 84 | {0,9,255} 85 | }; 86 | 87 | static const code distfix[32] = { 88 | {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, 89 | {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, 90 | {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, 91 | {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, 92 | {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, 93 | {22,5,193},{64,5,0} 94 | }; 95 | -------------------------------------------------------------------------------- /source/src/zlib/inflate.h: -------------------------------------------------------------------------------- 1 | /* inflate.h -- internal inflate state definition 2 | * Copyright (C) 1995-2009 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* define NO_GZIP when compiling if you want to disable gzip header and 12 | trailer decoding by inflate(). NO_GZIP would be used to avoid linking in 13 | the crc code when it is not needed. For shared libraries, gzip decoding 14 | should be left enabled. */ 15 | #ifndef NO_GZIP 16 | # define GUNZIP 17 | #endif 18 | 19 | /* Possible inflate modes between inflate() calls */ 20 | typedef enum { 21 | HEAD, /* i: waiting for magic header */ 22 | FLAGS, /* i: waiting for method and flags (gzip) */ 23 | TIME, /* i: waiting for modification time (gzip) */ 24 | OS, /* i: waiting for extra flags and operating system (gzip) */ 25 | EXLEN, /* i: waiting for extra length (gzip) */ 26 | EXTRA, /* i: waiting for extra bytes (gzip) */ 27 | NAME, /* i: waiting for end of file name (gzip) */ 28 | COMMENT, /* i: waiting for end of comment (gzip) */ 29 | HCRC, /* i: waiting for header crc (gzip) */ 30 | DICTID, /* i: waiting for dictionary check value */ 31 | DICT, /* waiting for inflateSetDictionary() call */ 32 | TYPE, /* i: waiting for type bits, including last-flag bit */ 33 | TYPEDO, /* i: same, but skip check to exit inflate on new block */ 34 | STORED, /* i: waiting for stored size (length and complement) */ 35 | COPY_, /* i/o: same as COPY below, but only first time in */ 36 | COPY, /* i/o: waiting for input or output to copy stored block */ 37 | TABLE, /* i: waiting for dynamic block table lengths */ 38 | LENLENS, /* i: waiting for code length code lengths */ 39 | CODELENS, /* i: waiting for length/lit and distance code lengths */ 40 | LEN_, /* i: same as LEN below, but only first time in */ 41 | LEN, /* i: waiting for length/lit/eob code */ 42 | LENEXT, /* i: waiting for length extra bits */ 43 | DIST, /* i: waiting for distance code */ 44 | DISTEXT, /* i: waiting for distance extra bits */ 45 | MATCH, /* o: waiting for output space to copy string */ 46 | LIT, /* o: waiting for output space to write literal */ 47 | CHECK, /* i: waiting for 32-bit check value */ 48 | LENGTH, /* i: waiting for 32-bit length (gzip) */ 49 | DONE, /* finished check, done -- remain here until reset */ 50 | BAD, /* got a data error -- remain here until reset */ 51 | MEM, /* got an inflate() memory error -- remain here until reset */ 52 | SYNC /* looking for synchronization bytes to restart inflate() */ 53 | } inflate_mode; 54 | 55 | /* 56 | State transitions between above modes - 57 | 58 | (most modes can go to BAD or MEM on error -- not shown for clarity) 59 | 60 | Process header: 61 | HEAD -> (gzip) or (zlib) or (raw) 62 | (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> 63 | HCRC -> TYPE 64 | (zlib) -> DICTID or TYPE 65 | DICTID -> DICT -> TYPE 66 | (raw) -> TYPEDO 67 | Read deflate blocks: 68 | TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK 69 | STORED -> COPY_ -> COPY -> TYPE 70 | TABLE -> LENLENS -> CODELENS -> LEN_ 71 | LEN_ -> LEN 72 | Read deflate codes in fixed or dynamic block: 73 | LEN -> LENEXT or LIT or TYPE 74 | LENEXT -> DIST -> DISTEXT -> MATCH -> LEN 75 | LIT -> LEN 76 | Process trailer: 77 | CHECK -> LENGTH -> DONE 78 | */ 79 | 80 | /* state maintained between inflate() calls. Approximately 10K bytes. */ 81 | struct inflate_state { 82 | inflate_mode mode; /* current inflate mode */ 83 | int last; /* true if processing last block */ 84 | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ 85 | int havedict; /* true if dictionary provided */ 86 | int flags; /* gzip header method and flags (0 if zlib) */ 87 | unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ 88 | unsigned long check; /* protected copy of check value */ 89 | unsigned long total; /* protected copy of output count */ 90 | gz_headerp head; /* where to save gzip header information */ 91 | /* sliding window */ 92 | unsigned wbits; /* log base 2 of requested window size */ 93 | unsigned wsize; /* window size or zero if not using window */ 94 | unsigned whave; /* valid bytes in the window */ 95 | unsigned wnext; /* window write index */ 96 | unsigned char FAR *window; /* allocated sliding window, if needed */ 97 | /* bit accumulator */ 98 | unsigned long hold; /* input bit accumulator */ 99 | unsigned bits; /* number of bits in "in" */ 100 | /* for string and stored block copying */ 101 | unsigned length; /* literal or length of data to copy */ 102 | unsigned offset; /* distance back to copy string from */ 103 | /* for table and code decoding */ 104 | unsigned extra; /* extra bits needed */ 105 | /* fixed and dynamic code tables */ 106 | code const FAR *lencode; /* starting table for length/literal codes */ 107 | code const FAR *distcode; /* starting table for distance codes */ 108 | unsigned lenbits; /* index bits for lencode */ 109 | unsigned distbits; /* index bits for distcode */ 110 | /* dynamic table building */ 111 | unsigned ncode; /* number of code length code lengths */ 112 | unsigned nlen; /* number of length code lengths */ 113 | unsigned ndist; /* number of distance code lengths */ 114 | unsigned have; /* number of code lengths in lens[] */ 115 | code FAR *next; /* next available space in codes[] */ 116 | unsigned short lens[320]; /* temporary storage for code lengths */ 117 | unsigned short work[288]; /* work area for code table building */ 118 | code codes[ENOUGH]; /* space for code tables */ 119 | int sane; /* if false, allow invalid distance too far */ 120 | int back; /* bits back of last unprocessed length/lit */ 121 | unsigned was; /* initial length of match */ 122 | }; 123 | -------------------------------------------------------------------------------- /source/src/zlib/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /source/src/zlib/trees.h: -------------------------------------------------------------------------------- 1 | /* header created automatically with -DGEN_TREES_H */ 2 | 3 | local const ct_data static_ltree[L_CODES+2] = { 4 | {{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, 5 | {{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, 6 | {{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, 7 | {{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, 8 | {{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, 9 | {{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, 10 | {{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, 11 | {{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, 12 | {{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, 13 | {{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, 14 | {{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, 15 | {{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, 16 | {{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, 17 | {{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, 18 | {{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, 19 | {{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, 20 | {{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, 21 | {{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, 22 | {{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, 23 | {{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, 24 | {{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, 25 | {{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, 26 | {{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, 27 | {{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, 28 | {{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, 29 | {{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, 30 | {{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, 31 | {{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, 32 | {{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, 33 | {{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, 34 | {{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, 35 | {{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, 36 | {{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, 37 | {{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, 38 | {{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, 39 | {{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, 40 | {{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, 41 | {{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, 42 | {{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, 43 | {{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, 44 | {{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, 45 | {{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, 46 | {{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, 47 | {{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, 48 | {{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, 49 | {{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, 50 | {{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, 51 | {{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, 52 | {{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, 53 | {{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, 54 | {{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, 55 | {{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, 56 | {{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, 57 | {{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, 58 | {{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, 59 | {{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, 60 | {{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, 61 | {{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} 62 | }; 63 | 64 | local const ct_data static_dtree[D_CODES] = { 65 | {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, 66 | {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, 67 | {{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, 68 | {{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, 69 | {{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, 70 | {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} 71 | }; 72 | 73 | const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { 74 | 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 75 | 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 76 | 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 77 | 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 78 | 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 79 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 80 | 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 81 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 82 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 83 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 84 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 85 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 86 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 87 | 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 88 | 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 89 | 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 90 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 91 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 92 | 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 93 | 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 94 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 95 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 96 | 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 97 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 98 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 99 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 100 | }; 101 | 102 | const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { 103 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 104 | 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 105 | 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 106 | 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 107 | 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 108 | 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 109 | 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 110 | 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 111 | 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 112 | 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 113 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 114 | 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 115 | 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 116 | }; 117 | 118 | local const int base_length[LENGTH_CODES] = { 119 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 120 | 64, 80, 96, 112, 128, 160, 192, 224, 0 121 | }; 122 | 123 | local const int base_dist[D_CODES] = { 124 | 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 125 | 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 126 | 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 127 | }; 128 | 129 | -------------------------------------------------------------------------------- /source/src/zlib/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | 20 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 21 | enough memory, Z_BUF_ERROR if there was not enough room in the output 22 | buffer, or Z_DATA_ERROR if the input data was corrupted. 23 | */ 24 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 25 | Bytef *dest; 26 | uLongf *destLen; 27 | const Bytef *source; 28 | uLong sourceLen; 29 | { 30 | z_stream stream; 31 | int err; 32 | 33 | stream.next_in = (z_const Bytef *)source; 34 | stream.avail_in = (uInt)sourceLen; 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | 45 | err = inflateInit(&stream); 46 | if (err != Z_OK) return err; 47 | 48 | err = inflate(&stream, Z_FINISH); 49 | if (err != Z_STREAM_END) { 50 | inflateEnd(&stream); 51 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 52 | return Z_DATA_ERROR; 53 | return err; 54 | } 55 | *destLen = stream.total_out; 56 | 57 | err = inflateEnd(&stream); 58 | return err; 59 | } 60 | -------------------------------------------------------------------------------- /source/src/zlib/zutil.c: -------------------------------------------------------------------------------- 1 | /* zutil.c -- target dependent utility functions for the compression library 2 | * Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #include "zutil.h" 9 | #ifndef Z_SOLO 10 | # include "gzguts.h" 11 | #endif 12 | 13 | #ifndef NO_DUMMY_DECL 14 | struct internal_state {int dummy;}; /* for buggy compilers */ 15 | #endif 16 | 17 | z_const char * const z_errmsg[10] = { 18 | "need dictionary", /* Z_NEED_DICT 2 */ 19 | "stream end", /* Z_STREAM_END 1 */ 20 | "", /* Z_OK 0 */ 21 | "file error", /* Z_ERRNO (-1) */ 22 | "stream error", /* Z_STREAM_ERROR (-2) */ 23 | "data error", /* Z_DATA_ERROR (-3) */ 24 | "insufficient memory", /* Z_MEM_ERROR (-4) */ 25 | "buffer error", /* Z_BUF_ERROR (-5) */ 26 | "incompatible version",/* Z_VERSION_ERROR (-6) */ 27 | ""}; 28 | 29 | 30 | const char * ZEXPORT zlibVersion() 31 | { 32 | return ZLIB_VERSION; 33 | } 34 | 35 | uLong ZEXPORT zlibCompileFlags() 36 | { 37 | uLong flags; 38 | 39 | flags = 0; 40 | switch ((int)(sizeof(uInt))) { 41 | case 2: break; 42 | case 4: flags += 1; break; 43 | case 8: flags += 2; break; 44 | default: flags += 3; 45 | } 46 | switch ((int)(sizeof(uLong))) { 47 | case 2: break; 48 | case 4: flags += 1 << 2; break; 49 | case 8: flags += 2 << 2; break; 50 | default: flags += 3 << 2; 51 | } 52 | switch ((int)(sizeof(voidpf))) { 53 | case 2: break; 54 | case 4: flags += 1 << 4; break; 55 | case 8: flags += 2 << 4; break; 56 | default: flags += 3 << 4; 57 | } 58 | switch ((int)(sizeof(z_off_t))) { 59 | case 2: break; 60 | case 4: flags += 1 << 6; break; 61 | case 8: flags += 2 << 6; break; 62 | default: flags += 3 << 6; 63 | } 64 | #ifdef DEBUG 65 | flags += 1 << 8; 66 | #endif 67 | #if defined(ASMV) || defined(ASMINF) 68 | flags += 1 << 9; 69 | #endif 70 | #ifdef ZLIB_WINAPI 71 | flags += 1 << 10; 72 | #endif 73 | #ifdef BUILDFIXED 74 | flags += 1 << 12; 75 | #endif 76 | #ifdef DYNAMIC_CRC_TABLE 77 | flags += 1 << 13; 78 | #endif 79 | #ifdef NO_GZCOMPRESS 80 | flags += 1L << 16; 81 | #endif 82 | #ifdef NO_GZIP 83 | flags += 1L << 17; 84 | #endif 85 | #ifdef PKZIP_BUG_WORKAROUND 86 | flags += 1L << 20; 87 | #endif 88 | #ifdef FASTEST 89 | flags += 1L << 21; 90 | #endif 91 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) 92 | # ifdef NO_vsnprintf 93 | flags += 1L << 25; 94 | # ifdef HAS_vsprintf_void 95 | flags += 1L << 26; 96 | # endif 97 | # else 98 | # ifdef HAS_vsnprintf_void 99 | flags += 1L << 26; 100 | # endif 101 | # endif 102 | #else 103 | flags += 1L << 24; 104 | # ifdef NO_snprintf 105 | flags += 1L << 25; 106 | # ifdef HAS_sprintf_void 107 | flags += 1L << 26; 108 | # endif 109 | # else 110 | # ifdef HAS_snprintf_void 111 | flags += 1L << 26; 112 | # endif 113 | # endif 114 | #endif 115 | return flags; 116 | } 117 | 118 | #ifdef DEBUG 119 | 120 | # ifndef verbose 121 | # define verbose 0 122 | # endif 123 | int ZLIB_INTERNAL z_verbose = verbose; 124 | 125 | void ZLIB_INTERNAL z_error (m) 126 | char *m; 127 | { 128 | fprintf(stderr, "%s\n", m); 129 | exit(1); 130 | } 131 | #endif 132 | 133 | /* exported to allow conversion of error code to string for compress() and 134 | * uncompress() 135 | */ 136 | const char * ZEXPORT zError(err) 137 | int err; 138 | { 139 | return ERR_MSG(err); 140 | } 141 | 142 | #if defined(_WIN32_WCE) 143 | /* The Microsoft C Run-Time Library for Windows CE doesn't have 144 | * errno. We define it as a global variable to simplify porting. 145 | * Its value is always 0 and should not be used. 146 | */ 147 | int errno = 0; 148 | #endif 149 | 150 | #ifndef HAVE_MEMCPY 151 | 152 | void ZLIB_INTERNAL zmemcpy(dest, source, len) 153 | Bytef* dest; 154 | const Bytef* source; 155 | uInt len; 156 | { 157 | if (len == 0) return; 158 | do { 159 | *dest++ = *source++; /* ??? to be unrolled */ 160 | } while (--len != 0); 161 | } 162 | 163 | int ZLIB_INTERNAL zmemcmp(s1, s2, len) 164 | const Bytef* s1; 165 | const Bytef* s2; 166 | uInt len; 167 | { 168 | uInt j; 169 | 170 | for (j = 0; j < len; j++) { 171 | if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; 172 | } 173 | return 0; 174 | } 175 | 176 | void ZLIB_INTERNAL zmemzero(dest, len) 177 | Bytef* dest; 178 | uInt len; 179 | { 180 | if (len == 0) return; 181 | do { 182 | *dest++ = 0; /* ??? to be unrolled */ 183 | } while (--len != 0); 184 | } 185 | #endif 186 | 187 | #ifndef Z_SOLO 188 | 189 | #ifdef SYS16BIT 190 | 191 | #ifdef __TURBOC__ 192 | /* Turbo C in 16-bit mode */ 193 | 194 | # define MY_ZCALLOC 195 | 196 | /* Turbo C malloc() does not allow dynamic allocation of 64K bytes 197 | * and farmalloc(64K) returns a pointer with an offset of 8, so we 198 | * must fix the pointer. Warning: the pointer must be put back to its 199 | * original form in order to free it, use zcfree(). 200 | */ 201 | 202 | #define MAX_PTR 10 203 | /* 10*64K = 640K */ 204 | 205 | local int next_ptr = 0; 206 | 207 | typedef struct ptr_table_s { 208 | voidpf org_ptr; 209 | voidpf new_ptr; 210 | } ptr_table; 211 | 212 | local ptr_table table[MAX_PTR]; 213 | /* This table is used to remember the original form of pointers 214 | * to large buffers (64K). Such pointers are normalized with a zero offset. 215 | * Since MSDOS is not a preemptive multitasking OS, this table is not 216 | * protected from concurrent access. This hack doesn't work anyway on 217 | * a protected system like OS/2. Use Microsoft C instead. 218 | */ 219 | 220 | voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) 221 | { 222 | voidpf buf = opaque; /* just to make some compilers happy */ 223 | ulg bsize = (ulg)items*size; 224 | 225 | /* If we allocate less than 65520 bytes, we assume that farmalloc 226 | * will return a usable pointer which doesn't have to be normalized. 227 | */ 228 | if (bsize < 65520L) { 229 | buf = farmalloc(bsize); 230 | if (*(ush*)&buf != 0) return buf; 231 | } else { 232 | buf = farmalloc(bsize + 16L); 233 | } 234 | if (buf == NULL || next_ptr >= MAX_PTR) return NULL; 235 | table[next_ptr].org_ptr = buf; 236 | 237 | /* Normalize the pointer to seg:0 */ 238 | *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; 239 | *(ush*)&buf = 0; 240 | table[next_ptr++].new_ptr = buf; 241 | return buf; 242 | } 243 | 244 | void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) 245 | { 246 | int n; 247 | if (*(ush*)&ptr != 0) { /* object < 64K */ 248 | farfree(ptr); 249 | return; 250 | } 251 | /* Find the original pointer */ 252 | for (n = 0; n < next_ptr; n++) { 253 | if (ptr != table[n].new_ptr) continue; 254 | 255 | farfree(table[n].org_ptr); 256 | while (++n < next_ptr) { 257 | table[n-1] = table[n]; 258 | } 259 | next_ptr--; 260 | return; 261 | } 262 | ptr = opaque; /* just to make some compilers happy */ 263 | Assert(0, "zcfree: ptr not found"); 264 | } 265 | 266 | #endif /* __TURBOC__ */ 267 | 268 | 269 | #ifdef M_I86 270 | /* Microsoft C in 16-bit mode */ 271 | 272 | # define MY_ZCALLOC 273 | 274 | #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) 275 | # define _halloc halloc 276 | # define _hfree hfree 277 | #endif 278 | 279 | voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) 280 | { 281 | if (opaque) opaque = 0; /* to make compiler happy */ 282 | return _halloc((long)items, size); 283 | } 284 | 285 | void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) 286 | { 287 | if (opaque) opaque = 0; /* to make compiler happy */ 288 | _hfree(ptr); 289 | } 290 | 291 | #endif /* M_I86 */ 292 | 293 | #endif /* SYS16BIT */ 294 | 295 | 296 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ 297 | 298 | #ifndef STDC 299 | extern voidp malloc OF((uInt size)); 300 | extern voidp calloc OF((uInt items, uInt size)); 301 | extern void free OF((voidpf ptr)); 302 | #endif 303 | 304 | voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) 305 | voidpf opaque; 306 | unsigned items; 307 | unsigned size; 308 | { 309 | if (opaque) items += size - size; /* make compiler happy */ 310 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : 311 | (voidpf)calloc(items, size); 312 | } 313 | 314 | void ZLIB_INTERNAL zcfree (opaque, ptr) 315 | voidpf opaque; 316 | voidpf ptr; 317 | { 318 | free(ptr); 319 | if (opaque) return; /* make compiler happy */ 320 | } 321 | 322 | #endif /* MY_ZCALLOC */ 323 | 324 | #endif /* !Z_SOLO */ 325 | -------------------------------------------------------------------------------- /source/src/zlib/zutil.h: -------------------------------------------------------------------------------- 1 | /* zutil.h -- internal interface and configuration of the compression library 2 | * Copyright (C) 1995-2013 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* @(#) $Id$ */ 12 | 13 | #ifndef ZUTIL_H 14 | #define ZUTIL_H 15 | 16 | #ifdef HAVE_HIDDEN 17 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 18 | #else 19 | # define ZLIB_INTERNAL 20 | #endif 21 | 22 | #include "zlib.h" 23 | 24 | #if defined(STDC) && !defined(Z_SOLO) 25 | # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) 26 | # include 27 | # endif 28 | # include 29 | # include 30 | #endif 31 | 32 | #ifdef Z_SOLO 33 | typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ 34 | #endif 35 | 36 | #ifndef local 37 | # define local static 38 | #endif 39 | /* compile with -Dlocal if your debugger can't find static symbols */ 40 | 41 | typedef unsigned char uch; 42 | typedef uch FAR uchf; 43 | typedef unsigned short ush; 44 | typedef ush FAR ushf; 45 | typedef unsigned long ulg; 46 | 47 | extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ 48 | /* (size given to avoid silly warnings with Visual C++) */ 49 | 50 | #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] 51 | 52 | #define ERR_RETURN(strm,err) \ 53 | return (strm->msg = ERR_MSG(err), (err)) 54 | /* To be used only when the state is known to be valid */ 55 | 56 | /* common constants */ 57 | 58 | #ifndef DEF_WBITS 59 | # define DEF_WBITS MAX_WBITS 60 | #endif 61 | /* default windowBits for decompression. MAX_WBITS is for compression only */ 62 | 63 | #if MAX_MEM_LEVEL >= 8 64 | # define DEF_MEM_LEVEL 8 65 | #else 66 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL 67 | #endif 68 | /* default memLevel */ 69 | 70 | #define STORED_BLOCK 0 71 | #define STATIC_TREES 1 72 | #define DYN_TREES 2 73 | /* The three kinds of block type */ 74 | 75 | #define MIN_MATCH 3 76 | #define MAX_MATCH 258 77 | /* The minimum and maximum match lengths */ 78 | 79 | #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ 80 | 81 | /* target dependencies */ 82 | 83 | #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) 84 | # define OS_CODE 0x00 85 | # ifndef Z_SOLO 86 | # if defined(__TURBOC__) || defined(__BORLANDC__) 87 | # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) 88 | /* Allow compilation with ANSI keywords only enabled */ 89 | void _Cdecl farfree( void *block ); 90 | void *_Cdecl farmalloc( unsigned long nbytes ); 91 | # else 92 | # include 93 | # endif 94 | # else /* MSC or DJGPP */ 95 | # include 96 | # endif 97 | # endif 98 | #endif 99 | 100 | #ifdef AMIGA 101 | # define OS_CODE 0x01 102 | #endif 103 | 104 | #if defined(VAXC) || defined(VMS) 105 | # define OS_CODE 0x02 106 | # define F_OPEN(name, mode) \ 107 | fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") 108 | #endif 109 | 110 | #if defined(ATARI) || defined(atarist) 111 | # define OS_CODE 0x05 112 | #endif 113 | 114 | #ifdef OS2 115 | # define OS_CODE 0x06 116 | # if defined(M_I86) && !defined(Z_SOLO) 117 | # include 118 | # endif 119 | #endif 120 | 121 | #if defined(MACOS) || defined(TARGET_OS_MAC) 122 | # define OS_CODE 0x07 123 | # ifndef Z_SOLO 124 | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os 125 | # include /* for fdopen */ 126 | # else 127 | # ifndef fdopen 128 | # define fdopen(fd,mode) NULL /* No fdopen() */ 129 | # endif 130 | # endif 131 | # endif 132 | #endif 133 | 134 | #ifdef TOPS20 135 | # define OS_CODE 0x0a 136 | #endif 137 | 138 | #ifdef WIN32 139 | # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ 140 | # define OS_CODE 0x0b 141 | # endif 142 | #endif 143 | 144 | #ifdef __50SERIES /* Prime/PRIMOS */ 145 | # define OS_CODE 0x0f 146 | #endif 147 | 148 | #if defined(_BEOS_) || defined(RISCOS) 149 | # define fdopen(fd,mode) NULL /* No fdopen() */ 150 | #endif 151 | 152 | #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX 153 | # if defined(_WIN32_WCE) 154 | # define fdopen(fd,mode) NULL /* No fdopen() */ 155 | # ifndef _PTRDIFF_T_DEFINED 156 | typedef int ptrdiff_t; 157 | # define _PTRDIFF_T_DEFINED 158 | # endif 159 | # else 160 | # define fdopen(fd,type) _fdopen(fd,type) 161 | # endif 162 | #endif 163 | 164 | #if defined(__BORLANDC__) && !defined(MSDOS) 165 | #pragma warn -8004 166 | #pragma warn -8008 167 | #pragma warn -8066 168 | #endif 169 | 170 | /* provide prototypes for these when building zlib without LFS */ 171 | #if !defined(_WIN32) && \ 172 | (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) 173 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); 174 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); 175 | #endif 176 | 177 | /* common defaults */ 178 | 179 | #ifndef OS_CODE 180 | # define OS_CODE 0x03 /* assume Unix */ 181 | #endif 182 | 183 | #ifndef F_OPEN 184 | # define F_OPEN(name, mode) fopen((name), (mode)) 185 | #endif 186 | 187 | /* functions */ 188 | 189 | #if defined(pyr) || defined(Z_SOLO) 190 | # define NO_MEMCPY 191 | #endif 192 | #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) 193 | /* Use our own functions for small and medium model with MSC <= 5.0. 194 | * You may have to use the same strategy for Borland C (untested). 195 | * The __SC__ check is for Symantec. 196 | */ 197 | # define NO_MEMCPY 198 | #endif 199 | #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) 200 | # define HAVE_MEMCPY 201 | #endif 202 | #ifdef HAVE_MEMCPY 203 | # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ 204 | # define zmemcpy _fmemcpy 205 | # define zmemcmp _fmemcmp 206 | # define zmemzero(dest, len) _fmemset(dest, 0, len) 207 | # else 208 | # define zmemcpy memcpy 209 | # define zmemcmp memcmp 210 | # define zmemzero(dest, len) memset(dest, 0, len) 211 | # endif 212 | #else 213 | void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); 214 | int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); 215 | void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); 216 | #endif 217 | 218 | /* Diagnostic functions */ 219 | #ifdef DEBUG 220 | # include 221 | extern int ZLIB_INTERNAL z_verbose; 222 | extern void ZLIB_INTERNAL z_error OF((char *m)); 223 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} 224 | # define Trace(x) {if (z_verbose>=0) fprintf x ;} 225 | # define Tracev(x) {if (z_verbose>0) fprintf x ;} 226 | # define Tracevv(x) {if (z_verbose>1) fprintf x ;} 227 | # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} 228 | # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} 229 | #else 230 | # define Assert(cond,msg) 231 | # define Trace(x) 232 | # define Tracev(x) 233 | # define Tracevv(x) 234 | # define Tracec(c,x) 235 | # define Tracecv(c,x) 236 | #endif 237 | 238 | #ifndef Z_SOLO 239 | voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, 240 | unsigned size)); 241 | void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); 242 | #endif 243 | 244 | #define ZALLOC(strm, items, size) \ 245 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) 246 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) 247 | #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} 248 | 249 | /* Reverse the bytes in a 32-bit value */ 250 | #define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ 251 | (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) 252 | 253 | #endif /* ZUTIL_H */ 254 | --------------------------------------------------------------------------------