📄 guifuncs.c
字号:
/*Copyright (C) 1997-2007 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach )http://www.zsnes.comhttp://sourceforge.net/projects/zsneshttps://zsnes.bountysource.comThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseversion 2 as published by the Free Software Foundation.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/#ifdef __UNIXSDL__#include "gblhdr.h"#define fnamecmp strcmp#define fnamencmp strncmp#else#ifdef __WIN32__#include "../win/lib.h"#endif#ifdef __MSDOS__#include <fcntl.h>#include "../dos/lib.h"#endif#include <stdio.h>#include <stdlib.h>#include <string.h>#include <zlib.h>#define fnamencmp strncasecmp#define fnamecmp strcasecmp#endif#ifndef _MSC_VER#include <stdint.h>#include <dirent.h>#include <unistd.h>#endif#include "../zpath.h"#include "../md.h"#include "../cfg.h"#include "../input.h"#include "../asm_call.h"#include "../zloader.h"#ifndef S_ISDIR#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)#endif#define BIT(X) (1 << (X))extern unsigned char ComboHeader[23], ComboBlHeader[23], CombinDataGlob[3300];extern unsigned char ShowTimer, savecfgforce;extern unsigned int SnowTimer, NumSnow, NumComboGlob;extern unsigned char GUIFontData1[705], GUIFontData[705];enum vtype { UB, UW, UD, SB, SW, SD };unsigned int ConvertBinaryToInt(char data[]){ int x; int num = 0; for(x = 0;x<8;x++) { if(data[x] == '1') { num |= BIT(7-x); } } return(num);}void InsertFontChar(char data[], int pos){ GUIFontData1[pos] = ConvertBinaryToInt(data);}void LoadCustomFont(){ FILE *fp; char data[100]; int x = 0; fp = fopen_dir(ZCfgPath, "zfont.txt", "r"); if (fp) { while (fgets(data,100,fp) && strcmp(data,"EOF\n") && x < 705) { fgets(data,10,fp); //get first line InsertFontChar(data,x++); fgets(data,10,fp); //get second line InsertFontChar(data,x++); fgets(data,10,fp); //get third line InsertFontChar(data,x++); fgets(data,10,fp); //get fourth line InsertFontChar(data,x++); fgets(data,10,fp); //get fifth line InsertFontChar(data,x++); } } else { memcpy(GUIFontData1,GUIFontData,705); fp = fopen_dir(ZCfgPath, "zfont.txt", "w"); fputs("; empty space 0x00\n00000000\n00000000\n00000000\n00000000\n00000000\n",fp); fputs("; 0 0x01\n01110000\n10011000\n10101000\n11001000\n01110000\n",fp); fputs("; 1 0x02\n00100000\n01100000\n00100000\n00100000\n01110000\n",fp); fputs("; 2 0x03\n01110000\n10001000\n00110000\n01000000\n11111000\n",fp); fputs("; 3 0x04\n01110000\n10001000\n00110000\n10001000\n01110000\n",fp); fputs("; 4 0x05\n01010000\n10010000\n11111000\n00010000\n00010000\n",fp); fputs("; 5 0x06\n11111000\n10000000\n11110000\n00001000\n11110000\n",fp); fputs("; 6 0x07\n01110000\n10000000\n11110000\n10001000\n01110000\n",fp); fputs("; 7 0x08\n11111000\n00001000\n00010000\n00010000\n00010000\n",fp); fputs("; 8 0x09\n01110000\n10001000\n01110000\n10001000\n01110000\n",fp); fputs("; 9 0x0A\n01110000\n10001000\n01111000\n00001000\n01110000\n",fp); fputs("; A 0x0B\n01110000\n10001000\n11111000\n10001000\n10001000\n",fp); fputs("; B 0x0C\n11110000\n10001000\n11110000\n10001000\n11110000\n",fp); fputs("; C 0x0D\n01110000\n10001000\n10000000\n10001000\n01110000\n",fp); fputs("; D 0x0E\n11110000\n10001000\n10001000\n10001000\n11110000\n",fp); fputs("; E 0x0F\n11111000\n10000000\n11110000\n10000000\n11111000\n",fp); fputs("; F 0x10\n11111000\n10000000\n11110000\n10000000\n10000000\n",fp); fputs("; G 0x11\n01111000\n10000000\n10011000\n10001000\n01110000\n",fp); fputs("; H 0x12\n10001000\n10001000\n11111000\n10001000\n10001000\n",fp); fputs("; I 0x13\n11111000\n00100000\n00100000\n00100000\n11111000\n",fp); fputs("; J 0x14\n01111000\n00010000\n00010000\n10010000\n01100000\n",fp); fputs("; K 0x15\n10010000\n10100000\n11100000\n10010000\n10001000\n",fp); fputs("; L 0x16\n10000000\n10000000\n10000000\n10000000\n11111000\n",fp); fputs("; M 0x17\n11011000\n10101000\n10101000\n10101000\n10001000\n",fp); fputs("; N 0x18\n11001000\n10101000\n10101000\n10101000\n10011000\n",fp); fputs("; O 0x19\n01110000\n10001000\n10001000\n10001000\n01110000\n",fp); fputs("; P 0x1A\n11110000\n10001000\n11110000\n10000000\n10000000\n",fp); fputs("; Q 0x1B\n01110000\n10001000\n10101000\n10010000\n01101000\n",fp); fputs("; R 0x1C\n11110000\n10001000\n11110000\n10010000\n10001000\n",fp); fputs("; S 0x1D\n01111000\n10000000\n01110000\n00001000\n11110000\n",fp); fputs("; T 0x1E\n11111000\n00100000\n00100000\n00100000\n00100000\n",fp); fputs("; U 0x1F\n10001000\n10001000\n10001000\n10001000\n01110000\n",fp); fputs("; V 0x20\n10001000\n10001000\n01010000\n01010000\n00100000\n",fp); fputs("; W 0x21\n10001000\n10101000\n10101000\n10101000\n01010000\n",fp); fputs("; X 0x22\n10001000\n01010000\n00100000\n01010000\n10001000\n",fp); fputs("; Y 0x23\n10001000\n01010000\n00100000\n00100000\n00100000\n",fp); fputs("; Z 0x24\n11111000\n00010000\n00100000\n01000000\n11111000\n",fp); fputs("; - 0x25\n00000000\n00000000\n11111000\n00000000\n00000000\n",fp); fputs("; _ 0x26\n00000000\n00000000\n00000000\n00000000\n11111000\n",fp); fputs("; ~ 0x27\n01101000\n10010000\n00000000\n00000000\n00000000\n",fp); fputs("; . 0x28\n00000000\n00000000\n00000000\n00000000\n00100000\n",fp); fputs("; / 0x29\n00001000\n00010000\n00100000\n01000000\n10000000\n",fp); fputs("; < 0x2A\n00010000\n00100000\n01000000\n00100000\n00010000\n",fp); fputs("; > 0x2B\n01000000\n00100000\n00010000\n00100000\n01000000\n",fp); fputs("; [ 0x2C\n01110000\n01000000\n01000000\n01000000\n01110000\n",fp); fputs("; ] 0x2D\n01110000\n00010000\n00010000\n00010000\n01110000\n",fp); fputs("; : 0x2E\n00000000\n00100000\n00000000\n00100000\n00000000\n",fp); fputs("; & 0x2F\n01100000\n10011000\n01110000\n10011000\n01101000\n",fp); fputs("; arrow down 0x30\n00100000\n00100000\n10101000\n01110000\n00100000\n",fp); fputs("; # 0x31\n01010000\n11111000\n01010000\n11111000\n01010000\n",fp); fputs("; = 0x32\n00000000\n11111000\n00000000\n11111000\n00000000\n",fp); fputs("; \" 0x33\n01001000\n10010000\n00000000\n00000000\n00000000\n",fp); fputs("; \\ 0x34\n10000000\n01000000\n00100000\n00010000\n00001000\n",fp); fputs("; * 0x35\n10101000\n01110000\n11111000\n01110000\n10101000\n",fp); fputs("; ? 0x36\n01110000\n10001000\n00110000\n00000000\n00100000\n",fp); fputs("; % 0x37\n10001000\n00010000\n00100000\n01000000\n10001000\n",fp); fputs("; + 0x38\n00100000\n00100000\n11111000\n00100000\n00100000\n",fp); fputs("; , 0x39\n00000000\n00000000\n00000000\n00100000\n01000000\n",fp); fputs("; ( 0x3A\n00110000\n01000000\n01000000\n01000000\n00110000\n",fp); fputs("; ) 0x3B\n01100000\n00010000\n00010000\n00010000\n01100000\n",fp); fputs("; @ 0x3C\n01110000\n10011000\n10111000\n10000000\n01110000\n",fp); fputs("; \' 0x3D\n00100000\n01000000\n00000000\n00000000\n00000000\n",fp); fputs("; ! 0x3E\n00100000\n00100000\n00100000\n00000000\n00100000\n",fp); fputs("; $ 0x3F\n01111000\n10100000\n01110000\n00101000\n11110000\n",fp); fputs("; ; 0x40\n00000000\n00100000\n00000000\n00100000\n01000000\n",fp); fputs("; ` 0x41\n01000000\n00100000\n00000000\n00000000\n00000000\n",fp); fputs("; ^ 0x42\n00100000\n01010000\n00000000\n00000000\n00000000\n",fp); fputs("; { 0x43\n00110000\n01000000\n11000000\n01000000\n00110000\n",fp); fputs("; } 0x44\n01100000\n00010000\n00011000\n00010000\n01100000\n",fp); fputs("; up 0x45\n00100000\n00100000\n01110000\n01110000\n11111000\n",fp); fputs("; down 0x46\n11111000\n01110000\n01110000\n00100000\n00100000\n",fp); fputs("; left 0x47\n00001000\n00111000\n11111000\n00111000\n00001000\n",fp); fputs("; right 0x48\n10000000\n11100000\n11111000\n11100000\n10000000\n",fp); fputs("; arrow left 0x49\n00100000\n01100000\n11111000\n01100000\n00100000\n",fp); fputs("; .5 0x4A\n00111000\n00100000\n00110000\n00001000\n10110000\n",fp); fputs("; maximize (Win) 0x4B\n11111100\n10000100\n11111100\n00000000\n00000000\n",fp); fputs("; minimize (Win) 0x4C\n00000000\n11111100\n00000000\n00000000\n00000000\n",fp); fputs("; maximize (SDL) 0x4D\n11111000\n10001000\n10001000\n10001000\n11111000\n",fp); fputs("; shw fullstop 0x4E\n00000000\n00000000\n00100000\n01010000\n00100000\n",fp); fputs("; shw left bracket 0x4F\n01110000\n01000000\n01000000\n01000000\n00000000\n",fp); fputs("; shw right bracket 0x50\n00000000\n00010000\n00010000\n00010000\n01110000\n",fp); fputs("; shw comma 0x51\n00000000\n00000000\n00000000\n01000000\n00100000\n",fp); fputs("; shw mid-dot 0x52\n00000000\n00100000\n01110000\n00100000\n00000000\n",fp); fputs("; shw wo 0x53\n11111000\n00001000\n11110000\n00100000\n11000000\n",fp); fputs("; shw mini a 0x54\n00000000\n11111000\n01010000\n01100000\n01000000\n",fp); fputs("; shw mini i 0x55\n00000000\n00010000\n00100000\n11100000\n00100000\n",fp); fputs("; shw mini u 0x56\n00000000\n00100000\n11111000\n10001000\n00110000\n",fp); fputs("; shw mini e 0x57\n00000000\n00000000\n11111000\n00100000\n11111000\n",fp); fputs("; shw mini o 0x58\n00000000\n00010000\n11111000\n00110000\n11010000\n",fp); fputs("; shw mini ya 0x59\n00000000\n01000000\n11111000\n01010000\n01000000\n",fp); fputs("; shw mini yu 0x5A\n00000000\n00000000\n11110000\n00010000\n11111000\n",fp); fputs("; shw mini yo 0x5B\n00000000\n11111000\n00001000\n01111000\n11111000\n",fp); fputs("; shw mini tsu 0x5C\n00000000\n10101000\n10101000\n00010000\n01100000\n",fp); fputs("; shw prolong 0x5D\n00000000\n10000000\n01111000\n00000000\n00000000\n",fp); fputs("; shw a 0x5E\n11111000\n00101000\n00110000\n00100000\n11000000\n",fp); fputs("; shw i 0x5F\n00001000\n00110000\n11100000\n00100000\n00100000\n",fp); fputs("; shw u 0x60\n00100000\n11111000\n10001000\n00010000\n01100000\n",fp); fputs("; shw e 0x61\n11111000\n00100000\n00100000\n00100000\n11111000\n",fp); fputs("; shw o 0x62\n00010000\n11111000\n00110000\n01010000\n10010000\n",fp); fputs("; shw ka 0x63\n01000000\n11111000\n01001000\n01001000\n10011000\n",fp); fputs("; shw ki 0x64\n00100000\n11111000\n00100000\n11111000\n00100000\n",fp); fputs("; shw ku 0x65\n01000000\n01111000\n10001000\n00010000\n01100000\n",fp); fputs("; shw ke 0x66 ^^\n01000000\n01111000\n10010000\n00010000\n01100000\n",fp); fputs("; shw ko 0x67\n11111000\n00001000\n00001000\n00001000\n11111000\n",fp); fputs("; shw sa 0x68\n01010000\n11111000\n01010000\n00010000\n01100000\n",fp); fputs("; shw shi 0x69\n01000000\n10101000\n01001000\n00010000\n11100000\n",fp); fputs("; shw su 0x6A\n11111000\n00001000\n00010000\n00110000\n11001000\n",fp); fputs("; shw se 0x6B\n01000000\n11111000\n01010000\n01000000\n00111000\n",fp); fputs("; shw so 0x6C\n10001000\n01001000\n00001000\n00010000\n01100000\n",fp); fputs("; shw ta 0x6D\n01000000\n01111000\n11001000\n00110000\n01100000\n",fp); fputs("; shw chi 0x6E\n11111000\n00100000\n11111000\n00100000\n01000000\n",fp); fputs("; shw tsu 0x6F\n10101000\n10101000\n00001000\n00010000\n01100000\n",fp); fputs("; shw te 0x70\n11111000\n00000000\n11111000\n00100000\n11000000\n",fp); fputs("; shw to 0x71\n01000000\n01000000\n01100000\n01010000\n01000000\n",fp); fputs("; shw na 0x72\n00100000\n11111000\n00100000\n00100000\n01000000\n",fp); fputs("; shw ni 0x73\n11110000\n00000000\n00000000\n00000000\n11111000\n",fp); fputs("; shw nu 0x74\n11111000\n00001000\n00101000\n00010000\n01101000\n",fp); fputs("; shw ne 0x75\n00100000\n11111000\n00001000\n01110000\n10101000\n",fp); fputs("; shw no 0x76\n00001000\n00001000\n00001000\n00010000\n01100000\n",fp); fputs("; shw ha 0x77\n01010000\n01010000\n01010000\n10001000\n10001000\n",fp); fputs("; shw hi 0x78\n10000000\n10011000\n11100000\n10000000\n01111000\n",fp); fputs("; shw hu 0x79\n11111000\n00001000\n00001000\n00010000\n01100000\n",fp); fputs("; shw he 0x7A\n01000000\n10100000\n10010000\n00001000\n00000000\n",fp); fputs("; shw ho 0x7B\n00100000\n11111000\n01110000\n10101000\n00100000\n",fp); fputs("; shw ma 0x7C\n11111000\n00001000\n10010000\n01100000\n00100000\n",fp); fputs("; shw mi 0x7D\n11111000\n00000000\n11111000\n00000000\n11111000\n",fp); fputs("; shw mu 0x7E\n00100000\n01000000\n01000000\n10010000\n11111000\n",fp); fputs("; shw me 0x7F\n00001000\n01001000\n00110000\n00110000\n11001000\n",fp); fputs("; shw mo 0x80\n11111000\n00100000\n11111000\n00100000\n00111000\n",fp); fputs("; shw ya 0x81\n01000000\n11111100\n01001000\n00100000\n00100000\n",fp); fputs("; shw yu 0x82\n11110000\n00010000\n00010000\n00010000\n11111000\n",fp); fputs("; shw yo 0x83\n11111000\n00001000\n11111000\n00001000\n11111000\n",fp); fputs("; shw ra 0x84\n11111000\n00000000\n11111000\n00010000\n01100000\n",fp); fputs("; shw ri 0x85\n10001000\n10001000\n10001000\n00010000\n01100000\n",fp); fputs("; shw ru 0x86\n01100000\n01100000\n01101000\n01101000\n10110000\n",fp); fputs("; shw re 0x87\n10000000\n10000000\n10001000\n10001000\n11110000\n",fp); fputs("; shw ro 0x88\n11111000\n10001000\n10001000\n10001000\n11111000\n",fp); fputs("; shw wa 0x89\n11111000\n10001000\n00001000\n00010000\n01100000\n",fp); fputs("; shw n 0x8A\n10000000\n01001000\n00001000\n00010000\n11100000\n",fp); fputs("; shw voiced 0x8B\n10100000\n10100000\n00000000\n00000000\n00000000\n",fp); fputs("; shw halfvoiced 0x8C\n01000000\n10100000\n01000000\n00000000\n00000000\n",fp); fputs("EOF\n",fp); } fclose(fp);}static void CheckValueBounds(void *ptr, int min, int max, int val, enum vtype type){ switch (type) { case SB: if (((*(char*)ptr) > (char)max) || ((*(char*)ptr) < (char)min)) { *(char*)ptr = (char)val; } break; case UB: if (((*(unsigned char*)ptr) > (unsigned char)max) || ((*(unsigned char*)ptr) < (unsigned char)min)) { *(unsigned char*)ptr = (unsigned char)val; } break; case SW: if (((*(short*)ptr) > (short)max) || ((*(short*)ptr) < (short)min)) { *(short*)ptr = (short)val; } break; case UW: if (((*(unsigned short*)ptr) > (unsigned short)max) || ((*(unsigned short*)ptr) < (unsigned short)min)) { *(unsigned short*)ptr = (unsigned short)val; } break; default: case SD: if (((*(int*)ptr) > max) || ((*(int*)ptr) < min)) { *(int*)ptr = val; } break; case UD: if (((*(unsigned int*)ptr) > (unsigned int)max) || ((*(unsigned int*)ptr) < (unsigned int)min)) { *(unsigned int*)ptr = (unsigned int)val; } }}unsigned char CalcCfgChecksum(){ unsigned char *ptr = &GUIRAdd, i = 0; unsigned short chksum = 0; for (; i < 100 ; i++, ptr++) { chksum += *ptr; } chksum ^= 0xB2ED; // xor bx,1011001011101101b i = (chksum & 0x800) >> 8; chksum &= 0xF7FF; // and bh,0F7h if (chksum & 0x10) { chksum |= 0x800; } chksum &= 0xFFEF; // and bl,0EFh if (i) { chksum |= 0x10; } i = (chksum >> 8); return (((chksum & 0xFF) ^ i) | 0x80);}void GUIRestoreVars(){ int i; FILE *cfg_fp; psr_cfg_run(read_cfg_vars, ZCfgPath, ZCfgFile); psr_cfg_run(read_md_vars, ZCfgPath, "zmovie.cfg"); psr_cfg_run(read_input_vars, ZCfgPath, "zinput.cfg");#ifdef __MSDOS__ CheckValueBounds(&pl1contrl, 0, 16, 1, UB); CheckValueBounds(&pl1p209, 0, 1, 0, UB); CheckValueBounds(&pl2contrl, 0, 16, 0, UB); CheckValueBounds(&pl2p209, 0, 1, 0, UB); CheckValueBounds(&pl3contrl, 0, 16, 0, UB); CheckValueBounds(&pl3p209, 0, 1, 0, UB); CheckValueBounds(&pl4contrl, 0, 16, 0, UB); CheckValueBounds(&pl4p209, 0, 1, 0, UB); CheckValueBounds(&pl5contrl, 0, 16, 0, UB); CheckValueBounds(&pl5p209, 0, 1, 0, UB);#else CheckValueBounds(&pl1contrl, 0, 1, 1, UB); CheckValueBounds(&pl2contrl, 0, 1, 0, UB); CheckValueBounds(&pl3contrl, 0, 1, 0, UB); CheckValueBounds(&pl4contrl, 0, 1, 0, UB); CheckValueBounds(&pl5contrl, 0, 1, 0, UB);#endif#ifndef __MSDOS__ CheckValueBounds(&joy_sensitivity, 0, 32767, 16384, UW);#endif#ifdef __WIN32__ CheckValueBounds(&MouseSensitivity, 1, 255, 1, UB);#endif#ifdef __MSDOS__ CheckValueBounds(&SidewinderFix, 0, 1, 0, UB);#endif CheckValueBounds(&pl12s34, 0, 1, 0, UB); CheckValueBounds(&AllowUDLR, 0, 1, 0, UB); CheckValueBounds(&Turbo30hz, 0, 1, 1, UB); CheckValueBounds(&mouse1lh, 0, 1, 0, UB); CheckValueBounds(&mouse2lh, 0, 1, 0, UB); CheckValueBounds(&device1, 0, 1, 0, UB); CheckValueBounds(&device2, 0, 4, 0, UB); CheckValueBounds(&GUIComboGameSpec, 0, 1, 0, UB); CheckValueBounds(&GameSpecificInput, 0, 1, 0, UB); CheckValueBounds(&AllowMMX, 0, 1, 1, UB);#ifdef __WIN32__ CheckValueBounds(&PauseFocusChange, 0, 1, 0, UB); CheckValueBounds(&HighPriority, 0, 1, 0, UB);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -