├── .gitignore ├── .gitmodules ├── AUTHORS ├── COPYING ├── Makefile ├── Makefile.libretro ├── NEWS ├── README.md ├── frontend ├── Cheat.h ├── cspace.c ├── cspace.h ├── cspace_arm.S ├── cspace_neon.S ├── libretro.c ├── libretro.h ├── main.c ├── main.h ├── pl_gun_ts.c ├── pl_gun_ts.h ├── plat.h ├── plugin.c ├── plugin.h └── plugin_lib.h ├── include ├── arm_features.h ├── config.h ├── pcnt.h └── psemu_plugin_defs.h ├── jni ├── Android.mk └── Application.mk ├── libpcsxcore ├── cdriso.c ├── cdriso.h ├── cdrom.c ├── cdrom.h ├── cheat.c ├── cheat.h ├── coff.h ├── debug.c ├── debug.h ├── decode_xa.c ├── decode_xa.h ├── disr3000a.c ├── gpu.h ├── gte.c ├── gte.h ├── ix86 │ ├── iGte.h │ ├── iR3000A.c │ ├── ix86.c │ └── ix86.h ├── ix86_64 │ ├── README │ ├── iGte.h │ ├── iR3000A-64.c │ ├── ix86-64.c │ ├── ix86-64.h │ ├── ix86_3dnow.c │ ├── ix86_cpudetect.c │ ├── ix86_fpu.c │ ├── ix86_mmx.c │ └── ix86_sse.c ├── mdec.c ├── mdec.h ├── memmap.h ├── memmap_win32.c ├── misc.c ├── misc.h ├── new_dynarec │ ├── assem_arm.c │ ├── assem_arm.h │ ├── emu_if.c │ ├── emu_if.h │ ├── fpu.c │ ├── fpu.h │ ├── gte.c │ ├── gte.h │ ├── gte_arm.S │ ├── gte_arm.h │ ├── gte_divider.c │ ├── gte_divider.h │ ├── gte_neon.S │ ├── gte_neon.h │ ├── gte_nf.c │ ├── linkage_arm.S │ ├── linkage_offsets.h │ ├── new_dynarec.c │ ├── new_dynarec.h │ ├── pcsxmem.c │ ├── pcsxmem.h │ └── pcsxmem_inline.c ├── plugins.c ├── plugins.h ├── ppc │ ├── pGte.h │ ├── pR3000A.c │ ├── pasm.s │ ├── ppc.c │ ├── ppc.h │ ├── ppc_mnemonics.h │ ├── reguse.c │ └── reguse.h ├── ppf.c ├── ppf.h ├── psxbios.c ├── psxbios.h ├── psxcommon.c ├── psxcommon.h ├── psxcounters.c ├── psxcounters.h ├── psxdma.c ├── psxdma.h ├── psxhle.c ├── psxhle.h ├── psxhw.c ├── psxhw.h ├── psxinterpreter.c ├── psxmem.c ├── psxmem.h ├── psxmem_map.h ├── r3000a.c ├── r3000a.h ├── retro_inline.h ├── retro_miscellaneous.h ├── sio.c ├── sio.h ├── sjisfont.h ├── socket.c ├── socket.h ├── spu.c ├── spu.h └── system.h ├── makefile_ ├── plugins ├── cdrcimg │ ├── cdrcimg.c │ └── cdrcimg.h ├── dfinput │ ├── externals.h │ ├── guncon.c │ ├── main.c │ ├── main.h │ └── pad.c ├── dfsound │ ├── adsr.c │ ├── adsr.h │ ├── arm_utils.S │ ├── dma.c │ ├── dma.h │ ├── externals.h │ ├── freeze.c │ ├── gauss_i.h │ ├── out.c │ ├── out.h │ ├── psemuxa.h │ ├── registers.c │ ├── registers.h │ ├── reverb.c │ ├── spu.c │ ├── spu.h │ ├── spu_config.h │ ├── stdafx.h │ ├── xa.c │ └── xa.h └── gpu_neon │ ├── gpu.h │ ├── psx_gpu │ ├── common.h │ ├── gte_accuracy.c │ ├── gte_accuracy.h │ ├── psx_gpu.c │ ├── psx_gpu.h │ ├── psx_gpu_arm_neon.S │ ├── psx_gpu_c.h │ ├── psx_gpu_parse.c │ └── vector_ops.h │ ├── psx_gpu_if.c │ └── vout_pl.c ├── readme.txt └── tools ├── Makefile ├── gas-preprocessor.pl └── psxcimg.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.a 3 | *.so 4 | tags 5 | cscope.out 6 | pandora 7 | pcsx.map 8 | config.mak 9 | config.log 10 | frontend/revision.h 11 | tools 12 | .pcsx/ 13 | obj/ 14 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libpicofe"] 2 | path = frontend/libpicofe 3 | url = git://notaz.gp2x.de/~notaz/libpicofe.git 4 | [submodule "warm"] 5 | path = frontend/warm 6 | url = git://notaz.gp2x.de/~notaz/warm.git 7 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | (C) 1999-2003 PCSX Team 2 | (c) 1998 Vision Thing 3 | Linuzappz 4 | Shadow 5 | Pete Bernett 6 | NoComp 7 | Nik3d 8 | Akumax 9 | 10 | (C) 2005-2009 PCSX-df Team 11 | (c) Ryan Schultz 12 | (c) Andrew Burton 13 | (c) Stephen Chao 14 | (c) Marcus Comstedt 15 | Stefan Sikora 16 | 17 | (C) 2009-2011 PCSX-Reloaded Team 18 | edgbla (Root counters, various core/plugin fixes) 19 | shalma (GTE Divider, many core improvements, sound plugin fixes) 20 | Firnis (GTE code from PCSX-Revolution Project) 21 | Gabriele Gorla (MDEC decoder) 22 | Peter Collingbourne (Various core/psxbios fixes) 23 | Dario, NeToU, siveritas (Various bugfixes) 24 | Wei Mingzhi (Maintainer, input plugin, iso/cheat support, misc stuff) 25 | 26 | ARM NEON GPU plugin: 27 | (C) 2011-2012 Exophase 28 | (C) 2011-2012 notaz 29 | 30 | PCSX4ALL GPU plugin: 31 | (C) 2010 PCSX4ALL Team 32 | (C) 2010 Unai 33 | Franxis 34 | Chui 35 | 36 | GLES plugin (psx4m project): 37 | (C) 1999-2009 by Pete Bernert 38 | EQ 39 | Olli Hinkka 40 | Proger 41 | Pickle 42 | 43 | P.E.Op.S. GPU plugin: 44 | (C) Pete Bernert and the P.E.Op.S. team 45 | 46 | P.E.Op.S. SPU plugin: 47 | (C) Pete Bernert and the P.E.Op.S. team 48 | (C) SPU2-X, gigaherz, Pcsx2 Development Team 49 | shalma 50 | notaz 51 | 52 | MIPS->ARM recompiler: 53 | (C) 2009-2011 Ari64 54 | 55 | integration, optimization and frontend: 56 | (C) 2010-2012 notaz 57 | 58 | Special thanks to Mednafen author, shalma/gretar and Rokas for 59 | various help and ideas while developing this emulator. 60 | 61 | some implementation ideas (and maybe code?) likely originated from 62 | MAME/smf/pSXauthor and were integrated by various people to PCSX. 63 | 64 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.libretro 2 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | PCSX-Reloaded: Bringing clarity, joy, and a nice GUI to PCSX. 2 | 3 | You should remove your old ~/.pcsx directory before using PCSX-Reloaded, to 4 | avoid any possible compatibility issues, such as missing folders. Remember 5 | that memcards and savestates are kept there, so be sure to copy them out first! 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PCSX-ReARMed - yet another PCSX fork 2 | ==================================== 3 | 4 | [![Build Status](https://travis-ci.org/notaz/pcsx_rearmed.svg?branch=master)](https://travis-ci.org/notaz/pcsx_rearmed) 5 | 6 | *see [readme.txt](readme.txt) for more complete documentation* 7 | 8 | PCSX ReARMed is yet another PCSX fork based on the PCSX-Reloaded project, 9 | which itself contains code from PCSX, PCSX-df and PCSX-Revolution. This 10 | version is ARM architecture oriented and features MIPS->ARM recompiler by 11 | Ari64, NEON GTE code and more performance improvements. It was created for 12 | Pandora handheld, but should be usable on other devices after some code 13 | adjustments (N900, GPH Wiz/Caanoo, PlayBook versions are also available). 14 | 15 | PCSX ReARMed features ARM NEON GPU by Exophase, that in many cases produces 16 | pixel perfect graphics at very high performance. There is also Una-i's GPU 17 | plugin from PCSX4ALL project, and traditional P.E.Op.S. one. 18 | 19 | 20 | PCSX-Reloaded 21 | ============= 22 | 23 | PCSX-Reloaded is a forked version of the dead PCSX emulator, with a nicer 24 | interface and several improvements to stability and functionality. 25 | 26 | PCSX-Reloaded uses the PSEMU plugin interface to provide most functionality; 27 | without them, you will not be able to use it to play games. PCSX-Reloaded 28 | provides a number of plugins to provide basic functionality out of the box. 29 | 30 | PCSX-Reloaded has a very capable Internal HLE BIOS that can run many games 31 | without problems. It is recommended that you use it. However, if you own a 32 | real PlayStation, you may be able to use your own BIOS image. PCSX-Reloaded 33 | will find it in ~/.pcsx/bios/ or /usr/share/psemu/bios/ if you place it there. 34 | This can improve compatibility, especially with certain games and with the 35 | use of memory cards. 36 | 37 | See the doc/ folder in the source, or /usr/share/doc/pcsx/ on Debian systems, 38 | for more detailed information on PCSX-Reloaded. A UNIX manpage is also 39 | available. 40 | -------------------------------------------------------------------------------- /frontend/Cheat.h: -------------------------------------------------------------------------------- 1 | /* dummy */ 2 | -------------------------------------------------------------------------------- /frontend/cspace.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Gražvydas "notaz" Ignotas, 2011,2012 3 | * 4 | * This work is licensed under the terms of any of these licenses 5 | * (at your option): 6 | * - GNU GPL, version 2 or later. 7 | * - GNU LGPL, version 2.1 or later. 8 | * See the COPYING file in the top-level directory. 9 | */ 10 | 11 | #include "cspace.h" 12 | 13 | /* 14 | * note: these are intended for testing and should be avoided 15 | * in favor of NEON version or platform-specific conversion 16 | */ 17 | 18 | #ifndef __arm__ 19 | 20 | void bgr555_to_rgb565(void *dst_, const void *src_, int bytes) 21 | { 22 | const unsigned int *src = src_; 23 | unsigned int *dst = dst_; 24 | unsigned int p; 25 | int x; 26 | 27 | for (x = 0; x < bytes / 4; x++) { 28 | p = src[x]; 29 | p = ((p & 0x7c007c00) >> 10) | ((p & 0x03e003e0) << 1) 30 | | ((p & 0x001f001f) << 11); 31 | dst[x] = p; 32 | } 33 | } 34 | 35 | #endif 36 | 37 | #ifndef __ARM_NEON__ 38 | 39 | void bgr888_to_rgb565(void *dst_, const void *src_, int bytes) 40 | { 41 | const unsigned char *src = src_; 42 | unsigned int *dst = dst_; 43 | unsigned int r1, g1, b1, r2, g2, b2; 44 | 45 | for (; bytes >= 6; bytes -= 6, src += 6, dst++) { 46 | r1 = src[0] & 0xf8; 47 | g1 = src[1] & 0xfc; 48 | b1 = src[2] & 0xf8; 49 | r2 = src[3] & 0xf8; 50 | g2 = src[4] & 0xfc; 51 | b2 = src[5] & 0xf8; 52 | *dst = (r2 << 24) | (g2 << 19) | (b2 << 13) | 53 | (r1 << 8) | (g1 << 3) | (b1 >> 3); 54 | } 55 | } 56 | 57 | // TODO? 58 | void rgb888_to_rgb565(void *dst, const void *src, int bytes) {} 59 | void bgr888_to_rgb888(void *dst, const void *src, int bytes) {} 60 | 61 | #endif // __ARM_NEON__ 62 | 63 | /* YUV stuff */ 64 | static int yuv_ry[32], yuv_gy[32], yuv_by[32]; 65 | static unsigned char yuv_u[32 * 2], yuv_v[32 * 2]; 66 | 67 | void bgr_to_uyvy_init(void) 68 | { 69 | int i, v; 70 | 71 | /* init yuv converter: 72 | y0 = (int)((0.299f * r0) + (0.587f * g0) + (0.114f * b0)); 73 | y1 = (int)((0.299f * r1) + (0.587f * g1) + (0.114f * b1)); 74 | u = (int)(8 * 0.565f * (b0 - y0)) + 128; 75 | v = (int)(8 * 0.713f * (r0 - y0)) + 128; 76 | */ 77 | for (i = 0; i < 32; i++) { 78 | yuv_ry[i] = (int)(0.299f * i * 65536.0f + 0.5f); 79 | yuv_gy[i] = (int)(0.587f * i * 65536.0f + 0.5f); 80 | yuv_by[i] = (int)(0.114f * i * 65536.0f + 0.5f); 81 | } 82 | for (i = -32; i < 32; i++) { 83 | v = (int)(8 * 0.565f * i) + 128; 84 | if (v < 0) 85 | v = 0; 86 | if (v > 255) 87 | v = 255; 88 | yuv_u[i + 32] = v; 89 | v = (int)(8 * 0.713f * i) + 128; 90 | if (v < 0) 91 | v = 0; 92 | if (v > 255) 93 | v = 255; 94 | yuv_v[i + 32] = v; 95 | } 96 | } 97 | 98 | void rgb565_to_uyvy(void *d, const void *s, int pixels) 99 | { 100 | unsigned int *dst = d; 101 | const unsigned short *src = s; 102 | const unsigned char *yu = yuv_u + 32; 103 | const unsigned char *yv = yuv_v + 32; 104 | int r0, g0, b0, r1, g1, b1; 105 | int y0, y1, u, v; 106 | 107 | for (; pixels > 0; src += 2, dst++, pixels -= 2) 108 | { 109 | r0 = (src[0] >> 11) & 0x1f; 110 | g0 = (src[0] >> 6) & 0x1f; 111 | b0 = src[0] & 0x1f; 112 | r1 = (src[1] >> 11) & 0x1f; 113 | g1 = (src[1] >> 6) & 0x1f; 114 | b1 = src[1] & 0x1f; 115 | y0 = (yuv_ry[r0] + yuv_gy[g0] + yuv_by[b0]) >> 16; 116 | y1 = (yuv_ry[r1] + yuv_gy[g1] + yuv_by[b1]) >> 16; 117 | u = yu[b0 - y0]; 118 | v = yv[r0 - y0]; 119 | // valid Y range seems to be 16..235 120 | y0 = 16 + 219 * y0 / 31; 121 | y1 = 16 + 219 * y1 / 31; 122 | 123 | *dst = (y1 << 24) | (v << 16) | (y0 << 8) | u; 124 | } 125 | } 126 | 127 | void bgr555_to_uyvy(void *d, const void *s, int pixels) 128 | { 129 | unsigned int *dst = d; 130 | const unsigned short *src = s; 131 | const unsigned char *yu = yuv_u + 32; 132 | const unsigned char *yv = yuv_v + 32; 133 | int r0, g0, b0, r1, g1, b1; 134 | int y0, y1, u, v; 135 | 136 | for (; pixels > 0; src += 2, dst++, pixels -= 2) 137 | { 138 | b0 = (src[0] >> 10) & 0x1f; 139 | g0 = (src[0] >> 5) & 0x1f; 140 | r0 = src[0] & 0x1f; 141 | b1 = (src[1] >> 10) & 0x1f; 142 | g1 = (src[1] >> 5) & 0x1f; 143 | r1 = src[1] & 0x1f; 144 | y0 = (yuv_ry[r0] + yuv_gy[g0] + yuv_by[b0]) >> 16; 145 | y1 = (yuv_ry[r1] + yuv_gy[g1] + yuv_by[b1]) >> 16; 146 | u = yu[b0 - y0]; 147 | v = yv[r0 - y0]; 148 | y0 = 16 + 219 * y0 / 31; 149 | y1 = 16 + 219 * y1 / 31; 150 | 151 | *dst = (y1 << 24) | (v << 16) | (y0 << 8) | u; 152 | } 153 | } 154 | 155 | void bgr888_to_uyvy(void *d, const void *s, int pixels) 156 | { 157 | unsigned int *dst = d; 158 | const unsigned char *src8 = s; 159 | const unsigned char *yu = yuv_u + 32; 160 | const unsigned char *yv = yuv_v + 32; 161 | int r0, g0, b0, r1, g1, b1; 162 | int y0, y1, u, v; 163 | 164 | for (; pixels > 0; src8 += 3*2, dst++, pixels -= 2) 165 | { 166 | r0 = src8[0], g0 = src8[1], b0 = src8[2]; 167 | r1 = src8[3], g1 = src8[4], b1 = src8[5]; 168 | y0 = (r0 * 19595 + g0 * 38470 + b0 * 7471) >> 16; 169 | y1 = (r1 * 19595 + g1 * 38470 + b1 * 7471) >> 16; 170 | u = yu[(b0 - y0) / 8]; 171 | v = yv[(r0 - y0) / 8]; 172 | y0 = 16 + 219 * y0 / 255; 173 | y1 = 16 + 219 * y1 / 255; 174 | 175 | *dst = (y1 << 24) | (v << 16) | (y0 << 8) | u; 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /frontend/cspace.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" 3 | { 4 | #endif 5 | 6 | void bgr555_to_rgb565(void *dst, const void *src, int bytes); 7 | void bgr888_to_rgb888(void *dst, const void *src, int bytes); 8 | void bgr888_to_rgb565(void *dst, const void *src, int bytes); 9 | void rgb888_to_rgb565(void *dst, const void *src, int bytes); 10 | 11 | void bgr555_to_rgb565_b(void *dst, const void *src, int bytes, 12 | int brightness2k); // 0-0x0800 13 | 14 | void bgr_to_uyvy_init(void); 15 | void rgb565_to_uyvy(void *d, const void *s, int pixels); 16 | void bgr555_to_uyvy(void *d, const void *s, int pixels); 17 | void bgr888_to_uyvy(void *d, const void *s, int pixels); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /frontend/cspace_arm.S: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Gražvydas "notaz" Ignotas, 2013 3 | * 4 | * This work is licensed under the terms of GNU GPL version 2 or later. 5 | * See the COPYING file in the top-level directory. 6 | */ 7 | 8 | #include "arm_features.h" 9 | 10 | .text 11 | .align 2 12 | 13 | @ lr=0x001f001f 14 | @ trashes r11, r12 15 | .macro bgr555_to_rgb565_one rn 16 | and r11, lr, \rn 17 | and r12, lr, \rn, lsr #5 18 | and \rn, lr, \rn, lsr #10 19 | orr r12, r11, lsl #5 20 | orr \rn, r12, lsl #6 21 | .endm 22 | 23 | .macro pld_ reg offs=#0 24 | #ifdef HAVE_ARMV6 25 | pld [\reg, \offs] 26 | #endif 27 | .endm 28 | 29 | FUNCTION(bgr555_to_rgb565): @ void *dst, const void *src, int bytes 30 | pld_ r1 31 | push {r4-r11,lr} 32 | mov lr, #0x001f 33 | subs r2, #4*8 34 | orr lr, lr, lsl #16 35 | blt 1f 36 | 37 | 0: 38 | ldmia r1!, {r3-r10} 39 | subs r2, #4*8 40 | bgr555_to_rgb565_one r3 41 | 42 | pld_ r1, #32*2 43 | bgr555_to_rgb565_one r4 44 | bgr555_to_rgb565_one r5 45 | bgr555_to_rgb565_one r6 46 | bgr555_to_rgb565_one r7 47 | bgr555_to_rgb565_one r8 48 | bgr555_to_rgb565_one r9 49 | bgr555_to_rgb565_one r10 50 | stmia r0!, {r3-r10} 51 | bge 0b 52 | 53 | 1: 54 | adds r2, #4*8 55 | popeq {r4-r11,pc} 56 | 57 | 2: 58 | ldr r3, [r1], #4 59 | subs r2, #4 60 | bgr555_to_rgb565_one r3 61 | str r3, [r0], #4 62 | bgt 2b 63 | 64 | pop {r4-r11,pc} 65 | -------------------------------------------------------------------------------- /frontend/main.h: -------------------------------------------------------------------------------- 1 | /* Pcsx - Pc Psx Emulator 2 | * Copyright (C) 1999-2002 Pcsx Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef __FRONTEND_MAIN_H__ 20 | #define __FRONTEND_MAIN_H__ 21 | 22 | #include "config.h" 23 | 24 | #define DEFAULT_MEM_CARD_1 "/.pcsx/memcards/card1.mcd" 25 | #define DEFAULT_MEM_CARD_2 "/.pcsx/memcards/card2.mcd" 26 | #define MEMCARD_DIR "/.pcsx/memcards/" 27 | #define PLUGINS_DIR "/.pcsx/plugins/" 28 | #define PLUGINS_CFG_DIR "/.pcsx/plugins/cfg/" 29 | #define PCSX_DOT_DIR "/.pcsx/" 30 | #define STATES_DIR "/.pcsx/sstates/" 31 | #define CHEATS_DIR "/.pcsx/cheats/" 32 | #define PATCHES_DIR "/.pcsx/patches/" 33 | #define BIOS_DIR "/bios/" 34 | 35 | extern char cfgfile_basename[MAXPATHLEN]; 36 | 37 | extern int state_slot; 38 | 39 | /* emu_core_preinit - must be the very first call 40 | * emu_core_init - to be called after platform-specific setup */ 41 | int emu_core_preinit(void); 42 | int emu_core_init(void); 43 | 44 | void emu_core_ask_exit(void); 45 | 46 | void emu_set_default_config(void); 47 | void emu_on_new_cd(int show_hud_msg); 48 | 49 | int get_state_filename(char *buf, int size, int i); 50 | 51 | void set_cd_image(const char *fname); 52 | 53 | extern unsigned long gpuDisp; 54 | extern int ready_to_go, g_emu_want_quit, g_emu_resetting; 55 | 56 | extern char hud_msg[64]; 57 | extern int hud_new_msg; 58 | 59 | enum sched_action { 60 | SACTION_NONE, 61 | SACTION_ENTER_MENU, 62 | SACTION_LOAD_STATE, 63 | SACTION_SAVE_STATE, 64 | SACTION_NEXT_SSLOT, 65 | SACTION_PREV_SSLOT, 66 | SACTION_TOGGLE_FSKIP, 67 | SACTION_SWITCH_DISPMODE, 68 | SACTION_FAST_FORWARD, 69 | SACTION_SCREENSHOT, 70 | SACTION_VOLUME_UP, // 10 71 | SACTION_VOLUME_DOWN, 72 | SACTION_MINIMIZE, 73 | SACTION_TOGGLE_FPS, 74 | SACTION_TOGGLE_FULLSCREEN, 75 | SACTION_GUN_TRIGGER = 16, 76 | SACTION_GUN_A, 77 | SACTION_GUN_B, 78 | SACTION_GUN_TRIGGER2, 79 | }; 80 | 81 | #define SACTION_GUN_MASK (0x0f << SACTION_GUN_TRIGGER) 82 | 83 | static inline void emu_set_action(enum sched_action action_) 84 | { 85 | extern enum sched_action emu_action, emu_action_old; 86 | extern int stop; 87 | 88 | if (action_ == SACTION_NONE) 89 | emu_action_old = 0; 90 | else if (action_ != emu_action_old) 91 | stop = 1; 92 | emu_action = action_; 93 | } 94 | 95 | #endif /* __FRONTEND_MAIN_H__ */ 96 | -------------------------------------------------------------------------------- /frontend/pl_gun_ts.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Gražvydas "notaz" Ignotas, 2011 3 | * 4 | * This work is licensed under the terms of any of these licenses 5 | * (at your option): 6 | * - GNU GPL, version 2 or later. 7 | * - GNU LGPL, version 2.1 or later. 8 | * See the COPYING file in the top-level directory. 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "plugin_lib.h" 16 | #include "pl_gun_ts.h" 17 | #include "menu.h" 18 | #include "../plugins/dfinput/externals.h" 19 | #include "../plugins/dfinput/main.h" 20 | 21 | static int gun_x, gun_y, gun_in; 22 | static int ts_multiplier_x, ts_multiplier_y, ts_offs_x, ts_offs_y; 23 | static int (*pts_read)(struct tsdev *dev, struct ts_sample *sample, int nr); 24 | static int (*pts_fd)(struct tsdev *dev); 25 | 26 | #define limit(v, min, max) \ 27 | if (v < min) v = min; \ 28 | else if (v > max) v = max 29 | 30 | int pl_gun_ts_update_raw(struct tsdev *ts, int *x, int *y, int *p) 31 | { 32 | struct ts_sample sample; 33 | int sx = 0, sy = 0, sp = 0, updated = 0; 34 | 35 | if (ts != NULL) { 36 | while (pts_read(ts, &sample, 1) > 0) { 37 | sx = sample.x; 38 | sy = sample.y; 39 | sp = sample.pressure; 40 | updated = 1; 41 | } 42 | 43 | if (updated) { 44 | gun_x = (sx - ts_offs_x) * ts_multiplier_x >> 10; 45 | gun_y = (sy - ts_offs_y) * ts_multiplier_y >> 10; 46 | limit(gun_x, 0, 1023); 47 | limit(gun_y, 0, 1023); 48 | if (sp && !(g_opts & OPT_TSGUN_NOTRIGGER)) 49 | gun_in |= GUNIN_TRIGGER; 50 | else 51 | gun_in &= ~GUNIN_TRIGGER; 52 | } 53 | } 54 | 55 | if (updated) { 56 | if (x) *x = sx; 57 | if (y) *y = sy; 58 | if (p) *p = sp; 59 | return 1; 60 | } 61 | 62 | return 0; 63 | } 64 | 65 | /* returns x, y in range 0..1023 (normalized to visible layer) */ 66 | void pl_gun_ts_update(struct tsdev *ts, int *x, int *y, int *in) 67 | { 68 | pl_gun_ts_update_raw(ts, NULL, NULL, NULL); 69 | 70 | *x = gun_x; 71 | *y = gun_y; 72 | *in = gun_in | in_state_gun; 73 | } 74 | 75 | void pl_set_gun_rect(int x, int y, int w, int h) 76 | { 77 | ts_offs_x = x; 78 | ts_offs_y = y; 79 | ts_multiplier_x = (1<<20) / w; 80 | ts_multiplier_y = (1<<20) / h; 81 | } 82 | 83 | int pl_gun_ts_get_fd(struct tsdev *ts) 84 | { 85 | if (ts != NULL && pts_fd != NULL) 86 | return pts_fd(ts); 87 | 88 | return -1; 89 | } 90 | 91 | struct tsdev *pl_gun_ts_init(void) 92 | { 93 | struct tsdev *(*pts_open)(const char *dev_name, int nonblock) = NULL; 94 | int (*pts_config)(struct tsdev *) = NULL; 95 | int (*pts_close)(struct tsdev *) = NULL; 96 | const char *tsdevname; 97 | struct tsdev *ts; 98 | void *ltsh; 99 | 100 | tsdevname = getenv("TSLIB_TSDEVICE"); 101 | if (tsdevname == NULL) 102 | tsdevname = "/dev/input/touchscreen0"; 103 | 104 | // avoid hard dep on tslib 105 | ltsh = dlopen("/usr/lib/libts-1.0.so.0", RTLD_NOW|RTLD_GLOBAL); 106 | if (ltsh == NULL) 107 | ltsh = dlopen("/usr/lib/libts-0.0.so.0", RTLD_NOW|RTLD_GLOBAL); 108 | if (ltsh == NULL) 109 | ltsh = dlopen("/lib/libts-0.0.so.0", RTLD_NOW|RTLD_GLOBAL); 110 | if (ltsh == NULL) { 111 | fprintf(stderr, "%s\n", dlerror()); 112 | goto fail; 113 | } 114 | 115 | pts_open = dlsym(ltsh, "ts_open"); 116 | pts_config = dlsym(ltsh, "ts_config"); 117 | pts_read = dlsym(ltsh, "ts_read"); 118 | pts_fd = dlsym(ltsh, "ts_fd"); 119 | pts_close = dlsym(ltsh, "ts_close"); 120 | if (pts_open == NULL || pts_config == NULL || pts_read == NULL 121 | || pts_fd == NULL || pts_close == NULL) { 122 | fprintf(stderr, "%s\n", dlerror()); 123 | goto fail_dlsym; 124 | } 125 | 126 | ts = pts_open(tsdevname, 1); 127 | if (ts == NULL){ 128 | printf("Failed pts_open, check permission on %s\n", tsdevname); 129 | goto fail_open; 130 | } 131 | if (pts_config(ts) != 0){ 132 | printf("Failed pts_config\n"); 133 | goto fail_config; 134 | } 135 | 136 | // FIXME: we should be able to get this somewhere 137 | // the problem is this doesn't always match resolution due to different display modes 138 | #ifdef __ARM_ARCH_7A__ 139 | pl_set_gun_rect(0, 0, 800, 480); 140 | #else 141 | pl_set_gun_rect(0, 0, 320, 240); 142 | #endif 143 | printf("Touchscreen configured, device=%s\n", tsdevname); 144 | return ts; 145 | 146 | fail_config: 147 | pts_close(ts); 148 | fail_open: 149 | fail_dlsym: 150 | dlclose(ltsh); 151 | ltsh = NULL; 152 | fail: 153 | fprintf(stderr, "Could not open touchscreen\n"); 154 | return NULL; 155 | } 156 | 157 | -------------------------------------------------------------------------------- /frontend/pl_gun_ts.h: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_TSLIB 2 | 3 | struct tsdev; 4 | 5 | struct tsdev *pl_gun_ts_init(void); 6 | void pl_gun_ts_update(struct tsdev *ts, int *x, int *y, int *in); 7 | void pl_set_gun_rect(int x, int y, int w, int h); 8 | 9 | int pl_gun_ts_update_raw(struct tsdev *ts, int *x, int *y, int *p); 10 | int pl_gun_ts_get_fd(struct tsdev *ts); 11 | 12 | #else 13 | 14 | #define pl_gun_ts_init() NULL 15 | #define pl_gun_ts_update(...) do {} while (0) 16 | #define pl_set_gun_rect(...) do {} while (0) 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /frontend/plat.h: -------------------------------------------------------------------------------- 1 | void plat_init(void); 2 | void plat_finish(void); 3 | void plat_minimize(void); 4 | void *plat_prepare_screenshot(int *w, int *h, int *bpp); 5 | 6 | // indirectly called from GPU plugin 7 | void plat_gvideo_open(int is_pal); 8 | void *plat_gvideo_set_mode(int *w, int *h, int *bpp); 9 | void *plat_gvideo_flip(void); 10 | void plat_gvideo_close(void); 11 | -------------------------------------------------------------------------------- /frontend/plugin.h: -------------------------------------------------------------------------------- 1 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) 2 | 3 | #define PLUGIN_DL_BASE 0xfbad0000 4 | 5 | enum builtint_plugins_e { 6 | PLUGIN_GPU, 7 | PLUGIN_SPU, 8 | PLUGIN_CDR, 9 | PLUGIN_PAD, 10 | PLUGIN_CDRCIMG, 11 | }; 12 | 13 | void *plugin_link(enum builtint_plugins_e id, const char *sym); 14 | void plugin_call_rearmed_cbs(void); 15 | -------------------------------------------------------------------------------- /frontend/plugin_lib.h: -------------------------------------------------------------------------------- 1 | 2 | enum { 3 | DKEY_SELECT = 0, 4 | DKEY_L3, 5 | DKEY_R3, 6 | DKEY_START, 7 | DKEY_UP, 8 | DKEY_RIGHT, 9 | DKEY_DOWN, 10 | DKEY_LEFT, 11 | DKEY_L2, 12 | DKEY_R2, 13 | DKEY_L1, 14 | DKEY_R1, 15 | DKEY_TRIANGLE, 16 | DKEY_CIRCLE, 17 | DKEY_CROSS, 18 | DKEY_SQUARE, 19 | }; 20 | extern int in_type1, in_type2; 21 | extern int in_keystate, in_state_gun, in_a1[2], in_a2[2], in_a3[2], in_a4[2]; 22 | extern int in_adev[2], in_adev_axis[2][2]; 23 | extern int in_adev_is_nublike[2]; 24 | extern int in_enable_vibration; 25 | 26 | extern void *pl_vout_buf; 27 | 28 | extern int g_layer_x, g_layer_y; 29 | extern int g_layer_w, g_layer_h; 30 | 31 | void pl_start_watchdog(void); 32 | void *pl_prepare_screenshot(int *w, int *h, int *bpp); 33 | void pl_init(void); 34 | void pl_switch_dispmode(void); 35 | 36 | void pl_timing_prepare(int is_pal); 37 | void pl_frame_limit(void); 38 | 39 | struct rearmed_cbs { 40 | void (*pl_get_layer_pos)(int *x, int *y, int *w, int *h); 41 | int (*pl_vout_open)(void); 42 | void (*pl_vout_set_mode)(int w, int h, int raw_w, int raw_h, int bpp); 43 | void (*pl_vout_flip)(const void *vram, int stride, int bgr24, 44 | int w, int h); 45 | void (*pl_vout_close)(void); 46 | void *(*mmap)(unsigned int size); 47 | void (*munmap)(void *ptr, unsigned int size); 48 | // only used by some frontends 49 | void (*pl_vout_set_raw_vram)(void *vram); 50 | void (*pl_set_gpu_caps)(int caps); 51 | // some stats, for display by some plugins 52 | int flips_per_sec, cpu_usage; 53 | float vsps_cur; // currect vsync/s 54 | // these are for gles plugin 55 | unsigned int screen_w, screen_h; 56 | void *gles_display, *gles_surface; 57 | // gpu options 58 | int frameskip; 59 | int fskip_advice; 60 | unsigned int *gpu_frame_count; 61 | unsigned int *gpu_hcnt; 62 | unsigned int flip_cnt; // increment manually if not using pl_vout_flip 63 | unsigned int only_16bpp; // platform is 16bpp-only 64 | struct { 65 | int allow_interlace; // 0 off, 1 on, 2 guess 66 | int enhancement_enable; 67 | int enhancement_no_main; 68 | } gpu_neon; 69 | struct { 70 | int iUseDither; 71 | int dwActFixes; 72 | float fFrameRateHz; 73 | int dwFrameRateTicks; 74 | } gpu_peops; 75 | struct { 76 | int abe_hack; 77 | int no_light, no_blend; 78 | int lineskip; 79 | } gpu_unai; 80 | struct { 81 | int dwActFixes; 82 | int bDrawDither, iFilterType, iFrameTexType; 83 | int iUseMask, bOpaquePass, bAdvancedBlend, bUseFastMdec; 84 | int iVRamSize, iTexGarbageCollection; 85 | } gpu_peopsgl; 86 | // misc 87 | int gpu_caps; 88 | }; 89 | 90 | extern struct rearmed_cbs pl_rearmed_cbs; 91 | 92 | enum gpu_plugin_caps { 93 | GPU_CAP_OWNS_DISPLAY = (1 << 0), 94 | GPU_CAP_SUPPORTS_2X = (1 << 1), 95 | }; 96 | 97 | // platform hooks 98 | extern void (*pl_plat_clear)(void); 99 | extern void (*pl_plat_blit)(int doffs, const void *src, 100 | int w, int h, int sstride, int bgr24); 101 | extern void (*pl_plat_hud_print)(int x, int y, const char *str, int bpp); 102 | 103 | #ifndef ARRAY_SIZE 104 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) 105 | #endif 106 | -------------------------------------------------------------------------------- /include/arm_features.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARM_FEATURES_H__ 2 | #define __ARM_FEATURES_H__ 3 | 4 | #if defined(__ARM_ARCH_8A__) 5 | 6 | #define HAVE_ARMV8 7 | #define HAVE_ARMV7 8 | #define HAVE_ARMV6 9 | #define HAVE_ARMV5 10 | 11 | #elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \ 12 | || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \ 13 | || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7S__) 14 | 15 | #define HAVE_ARMV7 16 | #define HAVE_ARMV6 17 | #define HAVE_ARMV5 18 | 19 | #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ 20 | || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \ 21 | || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \ 22 | || defined(__ARM_ARCH_6M__) 23 | 24 | #define HAVE_ARMV6 25 | #define HAVE_ARMV5 26 | 27 | #elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5E__) \ 28 | || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__) 29 | 30 | #define HAVE_ARMV5 31 | 32 | #endif 33 | 34 | /* no need for HAVE_NEON - GCC defines __ARM_NEON__ consistently */ 35 | 36 | /* global function/external symbol */ 37 | #ifndef __MACH__ 38 | #define ESYM(name) name 39 | 40 | #define FUNCTION(name) \ 41 | .globl name; \ 42 | .type name, %function; \ 43 | name 44 | 45 | #define EXTRA_UNSAVED_REGS 46 | 47 | #else 48 | #define ESYM(name) _##name 49 | 50 | #define FUNCTION(name) \ 51 | .globl ESYM(name); \ 52 | name: \ 53 | ESYM(name) 54 | 55 | // r7 is preserved, but add it for EABI alignment.. 56 | #define EXTRA_UNSAVED_REGS r7, r9, 57 | 58 | #endif 59 | 60 | #endif /* __ARM_FEATURES_H__ */ 61 | -------------------------------------------------------------------------------- /include/config.h: -------------------------------------------------------------------------------- 1 | #define MAXPATHLEN 256 2 | #define PACKAGE_VERSION "1.9" 3 | -------------------------------------------------------------------------------- /include/pcnt.h: -------------------------------------------------------------------------------- 1 | 2 | enum pcounters { 3 | PCNT_ALL, 4 | PCNT_GPU, 5 | PCNT_SPU, 6 | PCNT_BLIT, 7 | PCNT_GTE, 8 | PCNT_TEST, 9 | PCNT_CNT 10 | }; 11 | 12 | #ifdef PCNT 13 | 14 | #if defined(__ARM_ARCH_7A__) || defined(ARM1176) 15 | #define PCNT_DIV 1000 16 | #else 17 | #include 18 | #define PCNT_DIV 1 19 | #endif 20 | 21 | static const char *pcnt_names[PCNT_CNT] = { "", "gpu", "spu", "blit", "gte", "test" }; 22 | 23 | #define PCNT_FRAMES 10 24 | 25 | extern unsigned int pcounters[PCNT_CNT]; 26 | extern unsigned int pcounter_starts[PCNT_CNT]; 27 | 28 | #define pcnt_start(id) \ 29 | pcounter_starts[id] = pcnt_get() 30 | 31 | #define pcnt_end(id) \ 32 | pcounters[id] += pcnt_get() - pcounter_starts[id] 33 | 34 | void pcnt_hook_plugins(void); 35 | 36 | static inline void pcnt_print(float fps) 37 | { 38 | static int print_counter; 39 | unsigned int total, rem; 40 | int i; 41 | 42 | for (i = 0; i < PCNT_CNT; i++) 43 | pcounters[i] /= PCNT_DIV * PCNT_FRAMES; 44 | 45 | rem = total = pcounters[PCNT_ALL]; 46 | for (i = 1; i < PCNT_CNT; i++) 47 | rem -= pcounters[i]; 48 | if (!total) 49 | total++; 50 | 51 | if (--print_counter < 0) { 52 | printf(" "); 53 | for (i = 1; i < PCNT_CNT; i++) 54 | printf("%5s ", pcnt_names[i]); 55 | printf("%5s\n", "rem"); 56 | print_counter = 30; 57 | } 58 | 59 | printf("%4.1f ", fps); 60 | #if 0 61 | static float pcounters_all[PCNT_CNT+1]; 62 | static int pcounter_samples; 63 | pcounter_samples++; 64 | 65 | for (i = 1; i < PCNT_CNT; i++) { 66 | pcounters_all[i] += pcounters[i]; 67 | printf("%5.0f ", pcounters_all[i] / pcounter_samples); 68 | } 69 | pcounters_all[i] += rem; 70 | printf("%5.0f\n", pcounters_all[i] / pcounter_samples); 71 | #else 72 | for (i = 1; i < PCNT_CNT; i++) 73 | printf("%5u ", pcounters[i]); 74 | printf("%5u (", rem); 75 | for (i = 1; i < PCNT_CNT; i++) 76 | printf("%2u ", pcounters[i] * 100 / total); 77 | printf("%2u) %u\n", rem * 100 / total, total); 78 | #endif 79 | memset(pcounters, 0, sizeof(pcounters)); 80 | } 81 | 82 | static inline unsigned int pcnt_get(void) 83 | { 84 | unsigned int val; 85 | #ifdef __ARM_ARCH_7A__ 86 | __asm__ volatile("mrc p15, 0, %0, c9, c13, 0" 87 | : "=r"(val)); 88 | #elif defined(ARM1176) 89 | __asm__ volatile("mrc p15, 0, %0, c15, c12, 1" 90 | : "=r"(val)); 91 | #else 92 | // all slow on ARM :( 93 | //struct timespec tv; 94 | //clock_gettime(CLOCK_MONOTONIC_RAW, &tv); 95 | //val = tv.tv_sec * 1000000000 + tv.tv_nsec; 96 | struct timeval tv; 97 | gettimeofday(&tv, NULL); 98 | val = tv.tv_sec * 1000000 + tv.tv_usec; 99 | #endif 100 | return val; 101 | } 102 | 103 | static inline void pcnt_init(void) 104 | { 105 | #ifdef __ARM_ARCH_7A__ 106 | int v; 107 | asm volatile("mrc p15, 0, %0, c9, c12, 0" : "=r"(v)); 108 | v |= 5; // master enable, ccnt reset 109 | v &= ~8; // ccnt divider 0 110 | asm volatile("mcr p15, 0, %0, c9, c12, 0" :: "r"(v)); 111 | // enable cycle counter 112 | asm volatile("mcr p15, 0, %0, c9, c12, 1" :: "r"(1<<31)); 113 | #elif defined(ARM1176) 114 | int v; 115 | asm volatile("mrc p15, 0, %0, c15, c12, 0" : "=r"(v)); 116 | v |= 5; // master enable, ccnt reset 117 | v &= ~8; // ccnt divider 0 118 | asm volatile("mcr p15, 0, %0, c15, c12, 0" :: "r"(v)); 119 | #endif 120 | } 121 | 122 | void pcnt_gte_start(int op); 123 | void pcnt_gte_end(int op); 124 | 125 | #else 126 | 127 | #define pcnt_start(id) 128 | #define pcnt_end(id) 129 | #define pcnt_hook_plugins() 130 | #define pcnt_print(fps) 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | APP_DIR := ../../src 6 | 7 | ifneq ($(TARGET_ARCH_ABI),armeabi-v7a) 8 | NO_NEON_BUILD := 1 9 | else 10 | NO_NEON_BUILD := $(NO_NEON) 11 | endif 12 | 13 | ifeq ($(NO_NEON_BUILD)$(TARGET_ARCH_ABI),1armeabi-v7a) 14 | LOCAL_MODULE := retro-noneon 15 | else 16 | LOCAL_MODULE := retro 17 | endif 18 | 19 | ifeq ($(TARGET_ARCH),arm) 20 | LOCAL_ARM_MODE := arm 21 | 22 | LOCAL_CFLAGS += -DANDROID_ARM 23 | 24 | LOCAL_SRC_FILES += ../libpcsxcore/new_dynarec/gte_arm.S 25 | 26 | # dynarec 27 | LOCAL_SRC_FILES += ../libpcsxcore/new_dynarec/new_dynarec.c ../libpcsxcore/new_dynarec/linkage_arm.S ../libpcsxcore/new_dynarec/emu_if.c ../libpcsxcore/new_dynarec/pcsxmem.c 28 | 29 | # spu 30 | LOCAL_SRC_FILES += ../plugins/dfsound/arm_utils.S 31 | 32 | # misc 33 | 34 | ifeq ($(NO_NEON_BUILD),1) 35 | # gpu 36 | LOCAL_CFLAGS += -DREARMED 37 | LOCAL_SRC_FILES += ../plugins/gpu_unai/gpulib_if.cpp ../plugins/gpu_unai/gpu_arm.s 38 | LOCAL_SRC_FILES += ../frontend/cspace_arm.S 39 | else 40 | LOCAL_ARM_NEON := true 41 | LOCAL_CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP 42 | LOCAL_SRC_FILES += ../libpcsxcore/new_dynarec/gte_neon.S ../frontend/cspace_neon.S 43 | 44 | # gpu 45 | LOCAL_SRC_FILES += ../plugins/gpu_neon/psx_gpu_if.c ../plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S 46 | endif 47 | LOCAL_SRC_FILES += ../libpcsxcore/new_dynarec/gte.c ../libpcsxcore/new_dynarec/gte_nf.c ../libpcsxcore/new_dynarec/gte_divider.c 48 | endif 49 | 50 | ifeq ($(TARGET_ARCH),x86) 51 | LOCAL_CFLAGS += -DANDROID_X86 52 | endif 53 | 54 | ifeq ($(TARGET_ARCH),mips) 55 | LOCAL_CFLAGS += -DANDROID_MIPS -D__mips__ -D__MIPSEL__ 56 | endif 57 | 58 | ifneq ($(TARGET_ARCH),arm) 59 | # gpu 60 | LOCAL_CFLAGS += -DREARMED 61 | LOCAL_SRC_FILES += ../plugins/gpu_unai/gpulib_if.cpp 62 | endif 63 | 64 | $(shell cd "$(LOCAL_PATH)" && ((git describe || echo) | sed -e 's/.*/#define REV "\0"/' > ../frontend/revision.h_)) 65 | $(shell cd "$(LOCAL_PATH)" && (diff -q ../frontend/revision.h_ ../frontend/revision.h > /dev/null 2>&1 || cp ../frontend/revision.h_ ../frontend/revision.h)) 66 | $(shell cd "$(LOCAL_PATH)" && (rm ../frontend/revision.h_)) 67 | 68 | LOCAL_SRC_FILES += ../libpcsxcore/cdriso.c ../libpcsxcore/cdrom.c ../libpcsxcore/cheat.c ../libpcsxcore/debug.c \ 69 | ../libpcsxcore/decode_xa.c ../libpcsxcore/disr3000a.c ../libpcsxcore/mdec.c \ 70 | ../libpcsxcore/misc.c ../libpcsxcore/plugins.c ../libpcsxcore/ppf.c ../libpcsxcore/psxbios.c \ 71 | ../libpcsxcore/psxcommon.c ../libpcsxcore/psxcounters.c ../libpcsxcore/psxdma.c ../libpcsxcore/psxhle.c \ 72 | ../libpcsxcore/psxhw.c ../libpcsxcore/psxinterpreter.c ../libpcsxcore/psxmem.c ../libpcsxcore/r3000a.c \ 73 | ../libpcsxcore/sio.c ../libpcsxcore/socket.c ../libpcsxcore/spu.c 74 | 75 | # spu 76 | LOCAL_SRC_FILES += ../plugins/dfsound/dma.c ../plugins/dfsound/freeze.c \ 77 | ../plugins/dfsound/registers.c ../plugins/dfsound/spu.c \ 78 | ../plugins/dfsound/out.c 79 | 80 | # builtin gpu 81 | LOCAL_SRC_FILES += ../plugins/gpulib/gpu.c ../plugins/gpulib/vout_pl.c 82 | 83 | # cdrcimg 84 | LOCAL_SRC_FILES += ../plugins/cdrcimg/cdrcimg.c 85 | 86 | # dfinput 87 | LOCAL_SRC_FILES += ../plugins/dfinput/main.c ../plugins/dfinput/pad.c ../plugins/dfinput/guncon.c 88 | 89 | # misc 90 | LOCAL_SRC_FILES += ../frontend/main.c ../frontend/plugin.c ../frontend/cspace.c 91 | 92 | # libretro 93 | LOCAL_SRC_FILES += ../frontend/libretro.c 94 | 95 | LOCAL_CFLAGS += -O3 -ffast-math -funroll-loops -DNDEBUG -D_FILE_OFFSET_BITS=64 -DHAVE_LIBRETRO -DNO_FRONTEND -DFRONTEND_SUPPORTS_RGB565 96 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include 97 | LOCAL_LDLIBS := -lz -llog 98 | 99 | include $(BUILD_SHARED_LIBRARY) 100 | -------------------------------------------------------------------------------- /jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := armeabi armeabi-v7a 2 | -------------------------------------------------------------------------------- /libpcsxcore/cdriso.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 PCSX-df Team * 3 | * Copyright (C) 2009 Wei Mingzhi * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify * 6 | * it under the terms of the GNU General Public License as published by * 7 | * the Free Software Foundation; either version 2 of the License, or * 8 | * (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 * 13 | * GNU 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 * 17 | * Free Software Foundation, Inc., * 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 19 | ***************************************************************************/ 20 | 21 | #ifndef CDRISO_H 22 | #define CDRISO_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | void cdrIsoInit(void); 29 | int cdrIsoActive(void); 30 | 31 | extern unsigned int cdrIsoMultidiskCount; 32 | extern unsigned int cdrIsoMultidiskSelect; 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | #endif 38 | -------------------------------------------------------------------------------- /libpcsxcore/cdrom.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __CDROM_H__ 21 | #define __CDROM_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "psxcommon.h" 28 | #include "decode_xa.h" 29 | #include "r3000a.h" 30 | #include "plugins.h" 31 | #include "psxmem.h" 32 | #include "psxhw.h" 33 | 34 | #define btoi(b) ((b) / 16 * 10 + (b) % 16) /* BCD to u_char */ 35 | #define itob(i) ((i) / 10 * 16 + (i) % 10) /* u_char to BCD */ 36 | 37 | #define MSF2SECT(m, s, f) (((m) * 60 + (s) - 2) * 75 + (f)) 38 | 39 | #define CD_FRAMESIZE_RAW 2352 40 | #define DATA_SIZE (CD_FRAMESIZE_RAW - 12) 41 | 42 | #define SUB_FRAMESIZE 96 43 | 44 | typedef struct { 45 | unsigned char OCUP; 46 | unsigned char Reg1Mode; 47 | unsigned char Reg2; 48 | unsigned char CmdProcess; 49 | unsigned char Ctrl; 50 | unsigned char Stat; 51 | 52 | unsigned char StatP; 53 | 54 | unsigned char Transfer[DATA_SIZE]; 55 | struct { 56 | unsigned char Track; 57 | unsigned char Index; 58 | unsigned char Relative[3]; 59 | unsigned char Absolute[3]; 60 | } subq; 61 | unsigned char TrackChanged; 62 | unsigned char pad1[3]; 63 | unsigned int freeze_ver; 64 | 65 | unsigned char Prev[4]; 66 | unsigned char Param[8]; 67 | unsigned char Result[16]; 68 | 69 | unsigned char ParamC; 70 | unsigned char ParamP; 71 | unsigned char ResultC; 72 | unsigned char ResultP; 73 | unsigned char ResultReady; 74 | unsigned char Cmd; 75 | unsigned char Readed; 76 | unsigned char SetlocPending; 77 | u32 Reading; 78 | 79 | unsigned char ResultTN[6]; 80 | unsigned char ResultTD[4]; 81 | unsigned char SetSectorPlay[4]; 82 | unsigned char SetSectorEnd[4]; 83 | unsigned char SetSector[4]; 84 | unsigned char Track; 85 | boolean Play, Muted; 86 | int CurTrack; 87 | int Mode, File, Channel; 88 | int Reset; 89 | int RErr; 90 | int FirstSector; 91 | 92 | xa_decode_t Xa; 93 | 94 | int Init; 95 | 96 | u16 Irq; 97 | u8 IrqRepeated; 98 | u32 eCycle; 99 | 100 | u8 Seeked; 101 | 102 | u8 DriveState; 103 | u8 FastForward; 104 | u8 FastBackward; 105 | u8 pad; 106 | 107 | u8 AttenuatorLeftToLeft, AttenuatorLeftToRight; 108 | u8 AttenuatorRightToRight, AttenuatorRightToLeft; 109 | u8 AttenuatorLeftToLeftT, AttenuatorLeftToRightT; 110 | u8 AttenuatorRightToRightT, AttenuatorRightToLeftT; 111 | } cdrStruct; 112 | 113 | extern cdrStruct cdr; 114 | 115 | void cdrReset(); 116 | void cdrAttenuate(s16 *buf, int samples, int stereo); 117 | 118 | void cdrInterrupt(); 119 | void cdrReadInterrupt(); 120 | void cdrRepplayInterrupt(); 121 | void cdrLidSeekInterrupt(); 122 | void cdrPlayInterrupt(); 123 | void cdrDmaInterrupt(); 124 | void LidInterrupt(); 125 | unsigned char cdrRead0(void); 126 | unsigned char cdrRead1(void); 127 | unsigned char cdrRead2(void); 128 | unsigned char cdrRead3(void); 129 | void cdrWrite0(unsigned char rt); 130 | void cdrWrite1(unsigned char rt); 131 | void cdrWrite2(unsigned char rt); 132 | void cdrWrite3(unsigned char rt); 133 | int cdrFreeze(void *f, int Mode); 134 | 135 | #ifdef __cplusplus 136 | } 137 | #endif 138 | #endif 139 | -------------------------------------------------------------------------------- /libpcsxcore/cheat.h: -------------------------------------------------------------------------------- 1 | /* Cheat Support for PCSX-Reloaded 2 | * Copyright (C) 2009, Wei Mingzhi . 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef CHEAT_H 20 | #define CHEAT_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | typedef struct { 27 | uint32_t Addr; 28 | uint16_t Val; 29 | uint16_t OldVal; 30 | } CheatCode; 31 | 32 | typedef struct { 33 | char *Descr; 34 | int First; // index of the first cheat code 35 | int n; // number of cheat codes for this cheat 36 | int Enabled; 37 | int WasEnabled; 38 | } Cheat; 39 | 40 | void ClearAllCheats(); 41 | 42 | void LoadCheats(const char *filename); 43 | void SaveCheats(const char *filename); 44 | 45 | void ApplyCheats(); 46 | 47 | int AddCheat(const char *descr, char *code); 48 | void RemoveCheat(int index); 49 | int EditCheat(int index, const char *descr, char *code); 50 | 51 | void FreeCheatSearchResults(); 52 | void FreeCheatSearchMem(); 53 | void CheatSearchBackupMemory(); 54 | 55 | void CheatSearchEqual8(u8 val); 56 | void CheatSearchEqual16(u16 val); 57 | void CheatSearchEqual32(u32 val); 58 | void CheatSearchNotEqual8(u8 val); 59 | void CheatSearchNotEqual16(u16 val); 60 | void CheatSearchNotEqual32(u32 val); 61 | void CheatSearchRange8(u8 min, u8 max); 62 | void CheatSearchRange16(u16 min, u16 max); 63 | void CheatSearchRange32(u32 min, u32 max); 64 | void CheatSearchIncreasedBy8(u8 val); 65 | void CheatSearchIncreasedBy16(u16 val); 66 | void CheatSearchIncreasedBy32(u32 val); 67 | void CheatSearchDecreasedBy8(u8 val); 68 | void CheatSearchDecreasedBy16(u16 val); 69 | void CheatSearchDecreasedBy32(u32 val); 70 | void CheatSearchIncreased8(); 71 | void CheatSearchIncreased16(); 72 | void CheatSearchIncreased32(); 73 | void CheatSearchDecreased8(); 74 | void CheatSearchDecreased16(); 75 | void CheatSearchDecreased32(); 76 | void CheatSearchDifferent8(); 77 | void CheatSearchDifferent16(); 78 | void CheatSearchDifferent32(); 79 | void CheatSearchNoChange8(); 80 | void CheatSearchNoChange16(); 81 | void CheatSearchNoChange32(); 82 | 83 | extern Cheat *Cheats; 84 | extern CheatCode *CheatCodes; 85 | extern int NumCheats; 86 | extern int NumCodes; 87 | 88 | extern s8 *prevM; 89 | extern u32 *SearchResults; 90 | extern int NumSearchResults; 91 | 92 | extern int NumCheatsAllocated; 93 | extern int NumCodesAllocated; 94 | 95 | #define PREVM(mem) (&prevM[mem]) 96 | #define PrevMu8(mem) (*(u8 *)PREVM(mem)) 97 | #define PrevMu16(mem) (SWAP16(*(u16 *)PREVM(mem))) 98 | #define PrevMu32(mem) (SWAP32(*(u32 *)PREVM(mem))) 99 | 100 | // cheat types 101 | #define CHEAT_CONST8 0x30 /* 8-bit Constant Write */ 102 | #define CHEAT_CONST16 0x80 /* 16-bit Constant Write */ 103 | #define CHEAT_INC16 0x10 /* 16-bit Increment */ 104 | #define CHEAT_DEC16 0x11 /* 16-bit Decrement */ 105 | #define CHEAT_INC8 0x20 /* 8-bit Increment */ 106 | #define CHEAT_DEC8 0x21 /* 8-bit Decrement */ 107 | #define CHEAT_SLIDE 0x50 /* Slide Codes */ 108 | #define CHEAT_MEMCPY 0xC2 /* Memory Copy */ 109 | 110 | #define CHEAT_EQU8 0xE0 /* 8-bit Equal To */ 111 | #define CHEAT_NOTEQU8 0xE1 /* 8-bit Not Equal To */ 112 | #define CHEAT_LESSTHAN8 0xE2 /* 8-bit Less Than */ 113 | #define CHEAT_GREATERTHAN8 0xE3 /* 8-bit Greater Than */ 114 | #define CHEAT_EQU16 0xD0 /* 16-bit Equal To */ 115 | #define CHEAT_NOTEQU16 0xD1 /* 16-bit Not Equal To */ 116 | #define CHEAT_LESSTHAN16 0xD2 /* 16-bit Less Than */ 117 | #define CHEAT_GREATERTHAN16 0xD3 /* 16-bit Greater Than */ 118 | 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | #endif 123 | -------------------------------------------------------------------------------- /libpcsxcore/coff.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __COFF_H__ 21 | #define __COFF_H__ 22 | 23 | /********************** FILE HEADER **********************/ 24 | 25 | struct external_filehdr { 26 | unsigned short f_magic; /* magic number */ 27 | unsigned short f_nscns; /* number of sections */ 28 | unsigned int f_timdat; /* time & date stamp */ 29 | unsigned int f_symptr; /* file pointer to symtab */ 30 | unsigned int f_nsyms; /* number of symtab entries */ 31 | unsigned short f_opthdr; /* sizeof(optional hdr) */ 32 | unsigned short f_flags; /* flags */ 33 | }; 34 | 35 | #define FILHDR struct external_filehdr 36 | #define FILHSZ sizeof(FILHDR) 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libpcsxcore/debug.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __DEBUG_H__ 21 | #define __DEBUG_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | enum breakpoint_types { 28 | E, R1, R2, R4, W1, W2, W4 29 | }; 30 | 31 | void StartDebugger(); 32 | void StopDebugger(); 33 | 34 | void DebugVSync(); 35 | void ProcessDebug(); 36 | 37 | void DebugCheckBP(u32 address, enum breakpoint_types type); 38 | 39 | void PauseDebugger(); 40 | void ResumeDebugger(); 41 | 42 | extern char *disRNameCP0[]; 43 | 44 | char* disR3000AF(u32 code, u32 pc); 45 | 46 | /* 47 | * Specficies which logs should be activated. 48 | */ 49 | 50 | //#define LOG_STDOUT 51 | 52 | //#define PAD_LOG __Log 53 | //#define GTE_LOG __Log 54 | //#define CDR_LOG __Log("%8.8lx %8.8lx: ", psxRegs.pc, psxRegs.cycle); __Log 55 | 56 | //#define PSXHW_LOG __Log("%8.8lx %8.8lx: ", psxRegs.pc, psxRegs.cycle); __Log 57 | //#define PSXBIOS_LOG __Log("%8.8lx %8.8lx: ", psxRegs.pc, psxRegs.cycle); __Log 58 | //#define PSXDMA_LOG __Log 59 | //#define PSXMEM_LOG __Log("%8.8lx %8.8lx: ", psxRegs.pc, psxRegs.cycle); __Log 60 | //#define PSXCPU_LOG __Log 61 | 62 | //#define CDRCMD_DEBUG 63 | 64 | #if defined (PSXCPU_LOG) || defined(PSXDMA_LOG) || defined(CDR_LOG) || defined(PSXHW_LOG) || \ 65 | defined(PSXBIOS_LOG) || defined(PSXMEM_LOG) || defined(GTE_LOG) || defined(PAD_LOG) 66 | #define EMU_LOG __Log 67 | #endif 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | #endif 73 | -------------------------------------------------------------------------------- /libpcsxcore/decode_xa.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __DECODE_XA_H__ 21 | #define __DECODE_XA_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "psxcommon.h" 28 | 29 | typedef struct { 30 | s32 y0, y1; 31 | } ADPCM_Decode_t; 32 | 33 | typedef struct { 34 | int freq; 35 | int nbits; 36 | int stereo; 37 | int nsamples; 38 | ADPCM_Decode_t left, right; 39 | short pcm[16384]; 40 | } xa_decode_t; 41 | 42 | s32 xa_decode_sector( xa_decode_t *xdp, 43 | unsigned char *sectorp, 44 | int is_first_sector ); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif 50 | -------------------------------------------------------------------------------- /libpcsxcore/gpu.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * q: Why bother with GPU stuff in a plugin-based emu core? 4 | * a: mostly because of busy bits, we have all the needed timing info 5 | * that GPU plugin doesn't. 6 | */ 7 | 8 | #define PSXGPU_LCF (1<<31) 9 | #define PSXGPU_nBUSY (1<<26) 10 | #define PSXGPU_ILACE (1<<22) 11 | #define PSXGPU_DHEIGHT (1<<19) 12 | 13 | // both must be set for interlace to work 14 | #define PSXGPU_ILACE_BITS (PSXGPU_ILACE | PSXGPU_DHEIGHT) 15 | 16 | #define HW_GPU_STATUS psxHu32ref(0x1814) 17 | 18 | // TODO: handle com too 19 | #define PSXGPU_TIMING_BITS (PSXGPU_LCF | PSXGPU_nBUSY) 20 | 21 | #define gpuSyncPluginSR() { \ 22 | HW_GPU_STATUS &= PSXGPU_TIMING_BITS; \ 23 | HW_GPU_STATUS |= GPU_readStatus() & ~PSXGPU_TIMING_BITS; \ 24 | } 25 | -------------------------------------------------------------------------------- /libpcsxcore/gte.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __GTE_H__ 21 | #define __GTE_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "psxcommon.h" 28 | #include "r3000a.h" 29 | 30 | void gteMFC2(); 31 | void gteCFC2(); 32 | void gteMTC2(); 33 | void gteCTC2(); 34 | void gteLWC2(); 35 | void gteSWC2(); 36 | 37 | void gteRTPS(); 38 | void gteNCLIP(); 39 | void gteOP(); 40 | void gteDPCS(); 41 | void gteINTPL(); 42 | void gteMVMVA(); 43 | void gteNCDS(); 44 | void gteCDP(); 45 | void gteNCDT(); 46 | void gteNCCS(); 47 | void gteCC(); 48 | void gteNCS(); 49 | void gteNCT(); 50 | void gteSQR(); 51 | void gteDCPL(); 52 | void gteDPCT(); 53 | void gteAVSZ3(); 54 | void gteAVSZ4(); 55 | void gteRTPT(); 56 | void gteGPF(); 57 | void gteGPL(); 58 | void gteNCCT(); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #endif 64 | -------------------------------------------------------------------------------- /libpcsxcore/ix86/iGte.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __IGTE_H__ 21 | #define __IGTE_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "../r3000a.h" 28 | #include "../psxmem.h" 29 | 30 | #define CP2_FUNC(f) \ 31 | void gte##f(); \ 32 | static void rec##f() { \ 33 | iFlushRegs(); \ 34 | MOV32ItoM((u32)&psxRegs.code, (u32)psxRegs.code); \ 35 | CALLFunc ((u32)gte##f); \ 36 | /* branch = 2; */\ 37 | } 38 | 39 | CP2_FUNC(MFC2); 40 | CP2_FUNC(MTC2); 41 | CP2_FUNC(CFC2); 42 | CP2_FUNC(CTC2); 43 | CP2_FUNC(LWC2); 44 | CP2_FUNC(SWC2); 45 | CP2_FUNC(RTPS); 46 | CP2_FUNC(OP); 47 | CP2_FUNC(NCLIP); 48 | CP2_FUNC(DPCS); 49 | CP2_FUNC(INTPL); 50 | CP2_FUNC(MVMVA); 51 | CP2_FUNC(NCDS); 52 | CP2_FUNC(NCDT); 53 | CP2_FUNC(CDP); 54 | CP2_FUNC(NCCS); 55 | CP2_FUNC(CC); 56 | CP2_FUNC(NCS); 57 | CP2_FUNC(NCT); 58 | CP2_FUNC(SQR); 59 | CP2_FUNC(DCPL); 60 | CP2_FUNC(DPCT); 61 | CP2_FUNC(AVSZ3); 62 | CP2_FUNC(AVSZ4); 63 | CP2_FUNC(RTPT); 64 | CP2_FUNC(GPF); 65 | CP2_FUNC(GPL); 66 | CP2_FUNC(NCCT); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | #endif 72 | -------------------------------------------------------------------------------- /libpcsxcore/ix86_64/README: -------------------------------------------------------------------------------- 1 | This is the AMD64 dynamic recompiler. 2 | Made from opcodes from PCSX2 0.9.3 and the x86 recompiler modified to fit. ie. currently no AMD64/SSE specific code advantages. 3 | -------------------------------------------------------------------------------- /libpcsxcore/ix86_64/iGte.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __IGTE_H__ 21 | #define __IGTE_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "../r3000a.h" 28 | #include "../psxmem.h" 29 | 30 | #define CP2_FUNC(f) \ 31 | void gte##f(); \ 32 | static void rec##f() { \ 33 | iFlushRegs(); \ 34 | MOV32ItoM((uptr)&psxRegs.code, (u32)psxRegs.code); \ 35 | CALLFunc((uptr)gte##f); \ 36 | /* branch = 2; */\ 37 | } 38 | 39 | CP2_FUNC(MFC2); 40 | CP2_FUNC(MTC2); 41 | CP2_FUNC(CFC2); 42 | CP2_FUNC(CTC2); 43 | CP2_FUNC(LWC2); 44 | CP2_FUNC(SWC2); 45 | CP2_FUNC(RTPS); 46 | CP2_FUNC(OP); 47 | CP2_FUNC(NCLIP); 48 | CP2_FUNC(DPCS); 49 | CP2_FUNC(INTPL); 50 | CP2_FUNC(MVMVA); 51 | CP2_FUNC(NCDS); 52 | CP2_FUNC(NCDT); 53 | CP2_FUNC(CDP); 54 | CP2_FUNC(NCCS); 55 | CP2_FUNC(CC); 56 | CP2_FUNC(NCS); 57 | CP2_FUNC(NCT); 58 | CP2_FUNC(SQR); 59 | CP2_FUNC(DCPL); 60 | CP2_FUNC(DPCT); 61 | CP2_FUNC(AVSZ3); 62 | CP2_FUNC(AVSZ4); 63 | CP2_FUNC(RTPT); 64 | CP2_FUNC(GPF); 65 | CP2_FUNC(GPL); 66 | CP2_FUNC(NCCT); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | #endif 72 | -------------------------------------------------------------------------------- /libpcsxcore/ix86_64/ix86_3dnow.c: -------------------------------------------------------------------------------- 1 | // stop compiling if NORECBUILD build (only for Visual Studio) 2 | #if !(defined(_MSC_VER) && defined(PCSX2_NORECBUILD)) 3 | 4 | #include "ix86-64.h" 5 | 6 | /**********************/ 7 | /* 3DNOW instructions */ 8 | /**********************/ 9 | 10 | /* femms */ 11 | void FEMMS( void ) 12 | { 13 | write16( 0x0E0F ); 14 | } 15 | 16 | void PFCMPEQMtoR( x86IntRegType to, uptr from ) 17 | { 18 | MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1); 19 | write8( 0xB0 ); 20 | } 21 | 22 | void PFCMPGTMtoR( x86IntRegType to, uptr from ) 23 | { 24 | MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1); 25 | write8( 0xA0 ); 26 | } 27 | 28 | void PFCMPGEMtoR( x86IntRegType to, uptr from ) 29 | { 30 | MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1); 31 | write8( 0x90 ); 32 | } 33 | 34 | void PFADDMtoR( x86IntRegType to, uptr from ) 35 | { 36 | MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1); 37 | write8( 0x9E ); 38 | } 39 | 40 | void PFADDRtoR( x86IntRegType to, x86IntRegType from ) 41 | { 42 | RexRB(0, to, from); 43 | write16( 0x0F0F ); 44 | ModRM( 3, to, from ); 45 | write8( 0x9E ); 46 | } 47 | 48 | void PFSUBMtoR( x86IntRegType to, uptr from ) 49 | { 50 | MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1); 51 | write8( 0x9A ); 52 | } 53 | 54 | void PFSUBRtoR( x86IntRegType to, x86IntRegType from ) 55 | { 56 | RexRB(0, to, from); 57 | write16( 0x0F0F ); 58 | ModRM( 3, to, from ); 59 | write8( 0x9A ); 60 | } 61 | 62 | void PFMULMtoR( x86IntRegType to, uptr from ) 63 | { 64 | MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1); 65 | write8( 0xB4 ); 66 | } 67 | 68 | void PFMULRtoR( x86IntRegType to, x86IntRegType from ) 69 | { 70 | RexRB(0, to, from); 71 | write16( 0x0F0F ); 72 | ModRM( 3, to, from ); 73 | write8( 0xB4 ); 74 | } 75 | 76 | void PFRCPMtoR( x86IntRegType to, uptr from ) 77 | { 78 | MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1); 79 | write8( 0x96 ); 80 | } 81 | 82 | void PFRCPRtoR( x86IntRegType to, x86IntRegType from ) 83 | { 84 | RexRB(0, to, from); 85 | write16( 0x0F0F ); 86 | ModRM( 3, to, from ); 87 | write8( 0x96 ); 88 | } 89 | 90 | void PFRCPIT1RtoR( x86IntRegType to, x86IntRegType from ) 91 | { 92 | RexRB(0, to, from); 93 | write16( 0x0F0F ); 94 | ModRM( 3, to, from ); 95 | write8( 0xA6 ); 96 | } 97 | 98 | void PFRCPIT2RtoR( x86IntRegType to, x86IntRegType from ) 99 | { 100 | RexRB(0, to, from); 101 | write16( 0x0F0F ); 102 | ModRM( 3, to, from ); 103 | write8( 0xB6 ); 104 | } 105 | 106 | void PFRSQRTRtoR( x86IntRegType to, x86IntRegType from ) 107 | { 108 | RexRB(0, to, from); 109 | write16( 0x0F0F ); 110 | ModRM( 3, to, from ); 111 | write8( 0x97 ); 112 | } 113 | 114 | void PFRSQIT1RtoR( x86IntRegType to, x86IntRegType from ) 115 | { 116 | RexRB(0, to, from); 117 | write16( 0x0F0F ); 118 | ModRM( 3, to, from ); 119 | write8( 0xA7 ); 120 | } 121 | 122 | void PF2IDMtoR( x86IntRegType to, uptr from ) 123 | { 124 | MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1); 125 | write8( 0x1D ); 126 | } 127 | 128 | void PF2IDRtoR( x86IntRegType to, x86IntRegType from ) 129 | { 130 | RexRB(0, to, from); 131 | write16( 0x0F0F ); 132 | ModRM( 3, to, from ); 133 | write8( 0x1D ); 134 | } 135 | 136 | void PI2FDMtoR( x86IntRegType to, uptr from ) 137 | { 138 | MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1); 139 | write8( 0x0D ); 140 | } 141 | 142 | void PI2FDRtoR( x86IntRegType to, x86IntRegType from ) 143 | { 144 | RexRB(0, to, from); 145 | write16( 0x0F0F ); 146 | ModRM( 3, to, from ); 147 | write8( 0x0D ); 148 | } 149 | 150 | void PFMAXMtoR( x86IntRegType to, uptr from ) 151 | { 152 | MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1); 153 | write8( 0xA4 ); 154 | } 155 | 156 | void PFMAXRtoR( x86IntRegType to, x86IntRegType from ) 157 | { 158 | RexRB(0, to, from); 159 | write16( 0x0F0F ); 160 | ModRM( 3, to, from ); 161 | write8( 0xA4 ); 162 | } 163 | 164 | void PFMINMtoR( x86IntRegType to, uptr from ) 165 | { 166 | MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1); 167 | write8( 0x94 ); 168 | } 169 | 170 | void PFMINRtoR( x86IntRegType to, x86IntRegType from ) 171 | { 172 | RexRB(0, to, from); 173 | write16( 0x0F0F ); 174 | ModRM( 3, to, from ); 175 | write8( 0x94 ); 176 | } 177 | 178 | #endif 179 | -------------------------------------------------------------------------------- /libpcsxcore/ix86_64/ix86_fpu.c: -------------------------------------------------------------------------------- 1 | // stop compiling if NORECBUILD build (only for Visual Studio) 2 | 3 | #ifdef __x86_64__ 4 | 5 | #if !(defined(_MSC_VER) && defined(PCSX2_NORECBUILD)) 6 | 7 | #include 8 | #include 9 | #include "ix86-64.h" 10 | 11 | /********************/ 12 | /* FPU instructions */ 13 | /********************/ 14 | 15 | /* fild m32 to fpu reg stack */ 16 | void FILD32( uptr from ) 17 | { 18 | MEMADDR_OP(0, VAROP1(0xDB), false, 0, from, 0); 19 | } 20 | 21 | /* fistp m32 from fpu reg stack */ 22 | void FISTP32( uptr from ) 23 | { 24 | MEMADDR_OP(0, VAROP1(0xDB), false, 3, from, 0); 25 | } 26 | 27 | /* fld m32 to fpu reg stack */ 28 | void FLD32( uptr from ) 29 | { 30 | MEMADDR_OP(0, VAROP1(0xD9), false, 0, from, 0); 31 | } 32 | 33 | // fld st(i) 34 | void FLD(int st) { write16(0xc0d9+(st<<8)); } 35 | 36 | void FLD1() { write16(0xe8d9); } 37 | void FLDL2E() { write16(0xead9); } 38 | 39 | /* fst m32 from fpu reg stack */ 40 | void FST32( uptr to ) 41 | { 42 | MEMADDR_OP(0, VAROP1(0xD9), false, 2, to, 0); 43 | } 44 | 45 | /* fstp m32 from fpu reg stack */ 46 | void FSTP32( uptr to ) 47 | { 48 | MEMADDR_OP(0, VAROP1(0xD9), false, 3, to, 0); 49 | } 50 | 51 | // fstp st(i) 52 | void FSTP(int st) { write16(0xd8dd+(st<<8)); } 53 | 54 | /* fldcw fpu control word from m16 */ 55 | void FLDCW( uptr from ) 56 | { 57 | MEMADDR_OP(0, VAROP1(0xD9), false, 5, from, 0); 58 | } 59 | 60 | /* fnstcw fpu control word to m16 */ 61 | void FNSTCW( uptr to ) 62 | { 63 | MEMADDR_OP(0, VAROP1(0xD9), false, 7, to, 0); 64 | } 65 | 66 | void FNSTSWtoAX( void ) 67 | { 68 | write16( 0xE0DF ); 69 | } 70 | 71 | void FXAM() 72 | { 73 | write16(0xe5d9); 74 | } 75 | 76 | void FDECSTP() { write16(0xf6d9); } 77 | void FRNDINT() { write16(0xfcd9); } 78 | void FXCH(int st) { write16(0xc8d9+(st<<8)); } 79 | void F2XM1() { write16(0xf0d9); } 80 | void FSCALE() { write16(0xfdd9); } 81 | 82 | /* fadd ST(src) to fpu reg stack ST(0) */ 83 | void FADD32Rto0( x86IntRegType src ) 84 | { 85 | write8( 0xD8 ); 86 | write8( 0xC0 + src ); 87 | } 88 | 89 | /* fadd ST(0) to fpu reg stack ST(src) */ 90 | void FADD320toR( x86IntRegType src ) 91 | { 92 | write8( 0xDC ); 93 | write8( 0xC0 + src ); 94 | } 95 | 96 | /* fsub ST(src) to fpu reg stack ST(0) */ 97 | void FSUB32Rto0( x86IntRegType src ) 98 | { 99 | write8( 0xD8 ); 100 | write8( 0xE0 + src ); 101 | } 102 | 103 | /* fsub ST(0) to fpu reg stack ST(src) */ 104 | void FSUB320toR( x86IntRegType src ) 105 | { 106 | write8( 0xDC ); 107 | write8( 0xE8 + src ); 108 | } 109 | 110 | /* fsubp -> substract ST(0) from ST(1), store in ST(1) and POP stack */ 111 | void FSUBP( void ) 112 | { 113 | write8( 0xDE ); 114 | write8( 0xE9 ); 115 | } 116 | 117 | /* fmul ST(src) to fpu reg stack ST(0) */ 118 | void FMUL32Rto0( x86IntRegType src ) 119 | { 120 | write8( 0xD8 ); 121 | write8( 0xC8 + src ); 122 | } 123 | 124 | /* fmul ST(0) to fpu reg stack ST(src) */ 125 | void FMUL320toR( x86IntRegType src ) 126 | { 127 | write8( 0xDC ); 128 | write8( 0xC8 + src ); 129 | } 130 | 131 | /* fdiv ST(src) to fpu reg stack ST(0) */ 132 | void FDIV32Rto0( x86IntRegType src ) 133 | { 134 | write8( 0xD8 ); 135 | write8( 0xF0 + src ); 136 | } 137 | 138 | /* fdiv ST(0) to fpu reg stack ST(src) */ 139 | void FDIV320toR( x86IntRegType src ) 140 | { 141 | write8( 0xDC ); 142 | write8( 0xF8 + src ); 143 | } 144 | 145 | void FDIV320toRP( x86IntRegType src ) 146 | { 147 | write8( 0xDE ); 148 | write8( 0xF8 + src ); 149 | } 150 | 151 | /* fadd m32 to fpu reg stack */ 152 | void FADD32( uptr from ) 153 | { 154 | MEMADDR_OP(0, VAROP1(0xD8), false, 0, from, 0); 155 | } 156 | 157 | /* fsub m32 to fpu reg stack */ 158 | void FSUB32( uptr from ) 159 | { 160 | MEMADDR_OP(0, VAROP1(0xD8), false, 4, from, 0); 161 | } 162 | 163 | /* fmul m32 to fpu reg stack */ 164 | void FMUL32( uptr from ) 165 | { 166 | MEMADDR_OP(0, VAROP1(0xD8), false, 1, from, 0); 167 | } 168 | 169 | /* fdiv m32 to fpu reg stack */ 170 | void FDIV32( uptr from ) 171 | { 172 | MEMADDR_OP(0, VAROP1(0xD8), false, 6, from, 0); 173 | } 174 | 175 | /* fabs fpu reg stack */ 176 | void FABS( void ) 177 | { 178 | write16( 0xE1D9 ); 179 | } 180 | 181 | /* fsqrt fpu reg stack */ 182 | void FSQRT( void ) 183 | { 184 | write16( 0xFAD9 ); 185 | } 186 | 187 | void FPATAN(void) { write16(0xf3d9); } 188 | void FSIN(void) { write16(0xfed9); } 189 | 190 | /* fchs fpu reg stack */ 191 | void FCHS( void ) 192 | { 193 | write16( 0xE0D9 ); 194 | } 195 | 196 | /* fcomi st, st(i) */ 197 | void FCOMI( x86IntRegType src ) 198 | { 199 | write8( 0xDB ); 200 | write8( 0xF0 + src ); 201 | } 202 | 203 | /* fcomip st, st(i) */ 204 | void FCOMIP( x86IntRegType src ) 205 | { 206 | write8( 0xDF ); 207 | write8( 0xF0 + src ); 208 | } 209 | 210 | /* fucomi st, st(i) */ 211 | void FUCOMI( x86IntRegType src ) 212 | { 213 | write8( 0xDB ); 214 | write8( 0xE8 + src ); 215 | } 216 | 217 | /* fucomip st, st(i) */ 218 | void FUCOMIP( x86IntRegType src ) 219 | { 220 | write8( 0xDF ); 221 | write8( 0xE8 + src ); 222 | } 223 | 224 | /* fcom m32 to fpu reg stack */ 225 | void FCOM32( uptr from ) 226 | { 227 | MEMADDR_OP(0, VAROP1(0xD8), false, 2, from, 0); 228 | } 229 | 230 | /* fcomp m32 to fpu reg stack */ 231 | void FCOMP32( uptr from ) 232 | { 233 | MEMADDR_OP(0, VAROP1(0xD8), false, 3, from, 0); 234 | } 235 | 236 | #define FCMOV32( low, high ) \ 237 | { \ 238 | write8( low ); \ 239 | write8( high + from ); \ 240 | } 241 | 242 | void FCMOVB32( x86IntRegType from ) { FCMOV32( 0xDA, 0xC0 ); } 243 | void FCMOVE32( x86IntRegType from ) { FCMOV32( 0xDA, 0xC8 ); } 244 | void FCMOVBE32( x86IntRegType from ) { FCMOV32( 0xDA, 0xD0 ); } 245 | void FCMOVU32( x86IntRegType from ) { FCMOV32( 0xDA, 0xD8 ); } 246 | void FCMOVNB32( x86IntRegType from ) { FCMOV32( 0xDB, 0xC0 ); } 247 | void FCMOVNE32( x86IntRegType from ) { FCMOV32( 0xDB, 0xC8 ); } 248 | void FCMOVNBE32( x86IntRegType from ) { FCMOV32( 0xDB, 0xD0 ); } 249 | void FCMOVNU32( x86IntRegType from ) { FCMOV32( 0xDB, 0xD8 ); } 250 | 251 | #endif 252 | 253 | #endif 254 | -------------------------------------------------------------------------------- /libpcsxcore/mdec.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __MDEC_H__ 21 | #define __MDEC_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "psxcommon.h" 28 | #include "r3000a.h" 29 | #include "psxhw.h" 30 | #include "psxdma.h" 31 | 32 | void mdecInit(); 33 | void mdecWrite0(u32 data); 34 | void mdecWrite1(u32 data); 35 | u32 mdecRead0(); 36 | u32 mdecRead1(); 37 | void psxDma0(u32 madr, u32 bcr, u32 chcr); 38 | void psxDma1(u32 madr, u32 bcr, u32 chcr); 39 | void mdec0Interrupt(); 40 | void mdec1Interrupt(); 41 | int mdecFreeze(void *f, int Mode); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | #endif 47 | -------------------------------------------------------------------------------- /libpcsxcore/memmap.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEMMAP_H 2 | #define _MEMMAP_H 3 | 4 | #ifdef _WIN32 5 | 6 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 7 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 8 | #endif 9 | 10 | /* All the headers include this file. */ 11 | #ifndef _MSC_VER 12 | #include <_mingw.h> 13 | #endif 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #define PROT_NONE 0 22 | #define PROT_READ 1 23 | #define PROT_WRITE 2 24 | #define PROT_EXEC 4 25 | 26 | #define MAP_FILE 0 27 | #define MAP_SHARED 1 28 | #define MAP_PRIVATE 2 29 | #define MAP_TYPE 0xf 30 | #define MAP_FIXED 0x10 31 | #define MAP_ANONYMOUS 0x20 32 | #define MAP_ANON MAP_ANONYMOUS 33 | 34 | #define MAP_FAILED ((void *)-1) 35 | 36 | /* Flags for msync. */ 37 | #define MS_ASYNC 1 38 | #define MS_SYNC 2 39 | #define MS_INVALIDATE 4 40 | 41 | void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off); 42 | int munmap(void *addr, size_t len); 43 | int mprotect(void *addr, size_t len, int prot); 44 | int msync(void *addr, size_t len, int flags); 45 | int mlock(const void *addr, size_t len); 46 | int munlock(const void *addr, size_t len); 47 | 48 | #ifdef __cplusplus 49 | }; 50 | #endif 51 | 52 | #else 53 | #include 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /libpcsxcore/memmap_win32.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "memmap.h" 6 | 7 | #ifndef FILE_MAP_EXECUTE 8 | #define FILE_MAP_EXECUTE 0x0020 9 | #endif /* FILE_MAP_EXECUTE */ 10 | 11 | static int __map_mman_error(const DWORD err, const int deferr) 12 | { 13 | if (err == 0) 14 | return 0; 15 | /* TODO: implement */ 16 | return err; 17 | } 18 | 19 | static DWORD __map_mmap_prot_page(const int prot) 20 | { 21 | DWORD protect = 0; 22 | 23 | if (prot == PROT_NONE) 24 | return 0; 25 | 26 | if ((prot & PROT_EXEC) != 0) 27 | protect = ((prot & PROT_WRITE) != 0) ? 28 | PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ; 29 | else 30 | protect = ((prot & PROT_WRITE) != 0) ? 31 | PAGE_READWRITE : PAGE_READONLY; 32 | 33 | return protect; 34 | } 35 | 36 | static DWORD __map_mmap_prot_file(const int prot) 37 | { 38 | DWORD desiredAccess = 0; 39 | 40 | if (prot == PROT_NONE) 41 | return 0; 42 | 43 | if ((prot & PROT_READ) != 0) 44 | desiredAccess |= FILE_MAP_READ; 45 | if ((prot & PROT_WRITE) != 0) 46 | desiredAccess |= FILE_MAP_WRITE; 47 | if ((prot & PROT_EXEC) != 0) 48 | desiredAccess |= FILE_MAP_EXECUTE; 49 | 50 | return desiredAccess; 51 | } 52 | 53 | void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off) 54 | { 55 | HANDLE fm, h; 56 | 57 | void * map = MAP_FAILED; 58 | 59 | #ifdef _MSC_VER 60 | #pragma warning(push) 61 | #pragma warning(disable: 4293) 62 | #endif 63 | 64 | const DWORD dwFileOffsetLow = (sizeof(off_t) <= sizeof(DWORD)) ? 65 | (DWORD)off : (DWORD)(off & 0xFFFFFFFFL); 66 | const DWORD dwFileOffsetHigh = (sizeof(off_t) <= sizeof(DWORD)) ? 67 | (DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL); 68 | const DWORD protect = __map_mmap_prot_page(prot); 69 | const DWORD desiredAccess = __map_mmap_prot_file(prot); 70 | 71 | const off_t maxSize = off + (off_t)len; 72 | 73 | const DWORD dwMaxSizeLow = (sizeof(off_t) <= sizeof(DWORD)) ? 74 | (DWORD)maxSize : (DWORD)(maxSize & 0xFFFFFFFFL); 75 | const DWORD dwMaxSizeHigh = (sizeof(off_t) <= sizeof(DWORD)) ? 76 | (DWORD)0 : (DWORD)((maxSize >> 32) & 0xFFFFFFFFL); 77 | 78 | #ifdef _MSC_VER 79 | #pragma warning(pop) 80 | #endif 81 | 82 | errno = 0; 83 | 84 | if (len == 0 85 | /* Unsupported flag combinations */ 86 | || (flags & MAP_FIXED) != 0 87 | /* Usupported protection combinations */ 88 | || prot == PROT_EXEC) 89 | { 90 | errno = EINVAL; 91 | return MAP_FAILED; 92 | } 93 | 94 | h = ((flags & MAP_ANONYMOUS) == 0) ? 95 | (HANDLE)_get_osfhandle(fildes) : INVALID_HANDLE_VALUE; 96 | 97 | if ((flags & MAP_ANONYMOUS) == 0 && h == INVALID_HANDLE_VALUE) 98 | { 99 | errno = EBADF; 100 | return MAP_FAILED; 101 | } 102 | 103 | fm = CreateFileMapping(h, NULL, protect, dwMaxSizeHigh, dwMaxSizeLow, NULL); 104 | 105 | if (!fm) 106 | goto error; 107 | 108 | map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len); 109 | 110 | CloseHandle(fm); 111 | 112 | if (!map) 113 | goto error; 114 | 115 | return map; 116 | error: 117 | errno = __map_mman_error(GetLastError(), EPERM); 118 | return MAP_FAILED; 119 | } 120 | 121 | int munmap(void *addr, size_t len) 122 | { 123 | if (UnmapViewOfFile(addr)) 124 | return 0; 125 | 126 | errno = __map_mman_error(GetLastError(), EPERM); 127 | 128 | return -1; 129 | } 130 | 131 | int mprotect(void *addr, size_t len, int prot) 132 | { 133 | DWORD newProtect = __map_mmap_prot_page(prot); 134 | DWORD oldProtect = 0; 135 | 136 | if (VirtualProtect(addr, len, newProtect, &oldProtect)) 137 | return 0; 138 | 139 | errno = __map_mman_error(GetLastError(), EPERM); 140 | 141 | return -1; 142 | } 143 | 144 | int msync(void *addr, size_t len, int flags) 145 | { 146 | if (FlushViewOfFile(addr, len)) 147 | return 0; 148 | 149 | errno = __map_mman_error(GetLastError(), EPERM); 150 | 151 | return -1; 152 | } 153 | 154 | int mlock(const void *addr, size_t len) 155 | { 156 | if (VirtualLock((LPVOID)addr, len)) 157 | return 0; 158 | 159 | errno = __map_mman_error(GetLastError(), EPERM); 160 | 161 | return -1; 162 | } 163 | 164 | int munlock(const void *addr, size_t len) 165 | { 166 | if (VirtualUnlock((LPVOID)addr, len)) 167 | return 0; 168 | 169 | errno = __map_mman_error(GetLastError(), EPERM); 170 | 171 | return -1; 172 | } 173 | 174 | -------------------------------------------------------------------------------- /libpcsxcore/misc.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __MISC_H__ 21 | #define __MISC_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "psxcommon.h" 28 | #include "coff.h" 29 | #include "plugins.h" 30 | #include "r3000a.h" 31 | #include "psxmem.h" 32 | 33 | #undef s_addr 34 | 35 | typedef struct { 36 | unsigned char id[8]; 37 | u32 text; 38 | u32 data; 39 | u32 pc0; 40 | u32 gp0; 41 | u32 t_addr; 42 | u32 t_size; 43 | u32 d_addr; 44 | u32 d_size; 45 | u32 b_addr; 46 | u32 b_size; 47 | u32 s_addr; 48 | u32 s_size; 49 | u32 SavedSP; 50 | u32 SavedFP; 51 | u32 SavedGP; 52 | u32 SavedRA; 53 | u32 SavedS0; 54 | } EXE_HEADER; 55 | 56 | extern char CdromId[10]; 57 | extern char CdromLabel[33]; 58 | 59 | int LoadCdrom(); 60 | int LoadCdromFile(const char *filename, EXE_HEADER *head); 61 | int CheckCdrom(); 62 | int Load(const char *ExePath); 63 | 64 | int SaveState(const char *file); 65 | int LoadState(const char *file); 66 | 67 | int SendPcsxInfo(); 68 | int RecvPcsxInfo(); 69 | 70 | void trim(char *str); 71 | u16 calcCrc(u8 *d, int len); 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | #endif 77 | -------------------------------------------------------------------------------- /libpcsxcore/new_dynarec/assem_arm.h: -------------------------------------------------------------------------------- 1 | #define HOST_REGS 13 2 | #define HOST_CCREG 10 3 | #define HOST_BTREG 8 4 | #define EXCLUDE_REG 11 5 | 6 | #define HOST_IMM8 1 7 | #define HAVE_CMOV_IMM 1 8 | #define CORTEX_A8_BRANCH_PREDICTION_HACK 1 9 | #define USE_MINI_HT 1 10 | //#define REG_PREFETCH 1 11 | #define HAVE_CONDITIONAL_CALL 1 12 | #define DISABLE_TLB 1 13 | //#define MUPEN64 14 | #define FORCE32 1 15 | #define DISABLE_COP1 1 16 | #define PCSX 1 17 | #define RAM_SIZE 0x200000 18 | 19 | #ifndef __ARM_ARCH_7A__ 20 | //#undef CORTEX_A8_BRANCH_PREDICTION_HACK 21 | //#undef USE_MINI_HT 22 | #endif 23 | 24 | #ifndef BASE_ADDR_FIXED 25 | #define BASE_ADDR_FIXED 0 26 | #endif 27 | 28 | #ifdef FORCE32 29 | #define REG_SHIFT 2 30 | #else 31 | #define REG_SHIFT 3 32 | #endif 33 | 34 | /* ARM calling convention: 35 | r0-r3, r12: caller-save 36 | r4-r11: callee-save */ 37 | 38 | #define ARG1_REG 0 39 | #define ARG2_REG 1 40 | #define ARG3_REG 2 41 | #define ARG4_REG 3 42 | 43 | /* GCC register naming convention: 44 | r10 = sl (base) 45 | r11 = fp (frame pointer) 46 | r12 = ip (scratch) 47 | r13 = sp (stack pointer) 48 | r14 = lr (link register) 49 | r15 = pc (program counter) */ 50 | 51 | #define FP 11 52 | #define LR 14 53 | #define HOST_TEMPREG 14 54 | 55 | // Note: FP is set to &dynarec_local when executing generated code. 56 | // Thus the local variables are actually global and not on the stack. 57 | 58 | extern char *invc_ptr; 59 | 60 | #define TARGET_SIZE_2 24 // 2^24 = 16 megabytes 61 | 62 | // Code generator target address 63 | #if BASE_ADDR_FIXED 64 | // "round" address helpful for debug 65 | #define BASE_ADDR 0x1000000 66 | #else 67 | extern char translation_cache[1 << TARGET_SIZE_2]; 68 | #define BASE_ADDR (u_int)translation_cache 69 | #endif 70 | -------------------------------------------------------------------------------- /libpcsxcore/new_dynarec/emu_if.h: -------------------------------------------------------------------------------- 1 | #include "new_dynarec.h" 2 | #include "../r3000a.h" 3 | 4 | extern char invalid_code[0x100000]; 5 | 6 | /* weird stuff */ 7 | #define EAX 0 8 | #define ECX 1 9 | 10 | /* same as psxRegs */ 11 | extern int reg[]; 12 | 13 | /* same as psxRegs.GPR.n.* */ 14 | extern int hi, lo; 15 | 16 | /* same as psxRegs.CP0.n.* */ 17 | extern int reg_cop0[]; 18 | #define Status psxRegs.CP0.n.Status 19 | #define Cause psxRegs.CP0.n.Cause 20 | #define EPC psxRegs.CP0.n.EPC 21 | #define BadVAddr psxRegs.CP0.n.BadVAddr 22 | #define Context psxRegs.CP0.n.Context 23 | #define EntryHi psxRegs.CP0.n.EntryHi 24 | #define Count psxRegs.cycle // psxRegs.CP0.n.Count 25 | 26 | /* COP2/GTE */ 27 | enum gte_opcodes { 28 | GTE_RTPS = 0x01, 29 | GTE_NCLIP = 0x06, 30 | GTE_OP = 0x0c, 31 | GTE_DPCS = 0x10, 32 | GTE_INTPL = 0x11, 33 | GTE_MVMVA = 0x12, 34 | GTE_NCDS = 0x13, 35 | GTE_CDP = 0x14, 36 | GTE_NCDT = 0x16, 37 | GTE_NCCS = 0x1b, 38 | GTE_CC = 0x1c, 39 | GTE_NCS = 0x1e, 40 | GTE_NCT = 0x20, 41 | GTE_SQR = 0x28, 42 | GTE_DCPL = 0x29, 43 | GTE_DPCT = 0x2a, 44 | GTE_AVSZ3 = 0x2d, 45 | GTE_AVSZ4 = 0x2e, 46 | GTE_RTPT = 0x30, 47 | GTE_GPF = 0x3d, 48 | GTE_GPL = 0x3e, 49 | GTE_NCCT = 0x3f, 50 | }; 51 | 52 | extern int reg_cop2d[], reg_cop2c[]; 53 | extern void *gte_handlers[64]; 54 | extern void *gte_handlers_nf[64]; 55 | extern const char *gte_regnames[64]; 56 | extern const char gte_cycletab[64]; 57 | extern const uint64_t gte_reg_reads[64]; 58 | extern const uint64_t gte_reg_writes[64]; 59 | 60 | /* dummy */ 61 | extern int FCR0, FCR31; 62 | 63 | /* mem */ 64 | extern void *mem_rtab; 65 | extern void *mem_wtab; 66 | 67 | void jump_handler_read8(u32 addr, u32 *table, u32 cycles); 68 | void jump_handler_read16(u32 addr, u32 *table, u32 cycles); 69 | void jump_handler_read32(u32 addr, u32 *table, u32 cycles); 70 | void jump_handler_write8(u32 addr, u32 data, u32 cycles, u32 *table); 71 | void jump_handler_write16(u32 addr, u32 data, u32 cycles, u32 *table); 72 | void jump_handler_write32(u32 addr, u32 data, u32 cycles, u32 *table); 73 | void jump_handler_write_h(u32 addr, u32 data, u32 cycles, void *handler); 74 | void jump_handle_swl(u32 addr, u32 data, u32 cycles); 75 | void jump_handle_swr(u32 addr, u32 data, u32 cycles); 76 | void rcnt0_read_count_m0(u32 addr, u32, u32 cycles); 77 | void rcnt0_read_count_m1(u32 addr, u32, u32 cycles); 78 | void rcnt1_read_count_m0(u32 addr, u32, u32 cycles); 79 | void rcnt1_read_count_m1(u32 addr, u32, u32 cycles); 80 | void rcnt2_read_count_m0(u32 addr, u32, u32 cycles); 81 | void rcnt2_read_count_m1(u32 addr, u32, u32 cycles); 82 | 83 | extern unsigned int address; 84 | extern void *psxH_ptr; 85 | extern void *zeromem_ptr; 86 | extern void *scratch_buf_ptr; 87 | 88 | // same as invalid_code, just a region for ram write checks (inclusive) 89 | extern u32 inv_code_start, inv_code_end; 90 | 91 | /* cycles/irqs */ 92 | extern unsigned int next_interupt; 93 | extern int pending_exception; 94 | 95 | /* called by drc */ 96 | void pcsx_mtc0(u32 reg, u32 val); 97 | void pcsx_mtc0_ds(u32 reg, u32 val); 98 | 99 | /* misc */ 100 | extern void (*psxHLEt[])(); 101 | 102 | extern void SysPrintf(const char *fmt, ...); 103 | 104 | #ifdef RAM_FIXED 105 | #define rdram ((u_int)0x80000000) 106 | #else 107 | #define rdram ((u_int)psxM) 108 | #endif 109 | -------------------------------------------------------------------------------- /libpcsxcore/new_dynarec/fpu.h: -------------------------------------------------------------------------------- 1 | void cvt_s_w(int *source,float *dest); 2 | void cvt_d_w(int *source,double *dest); 3 | void cvt_s_l(long long *source,float *dest); 4 | void cvt_d_l(long long *source,double *dest); 5 | void cvt_w_s(float *source,int *dest); 6 | void cvt_w_d(double *source,int *dest); 7 | void cvt_l_s(float *source,long long *dest); 8 | void cvt_l_d(double *source,long long *dest); 9 | void cvt_d_s(float *source,double *dest); 10 | void cvt_s_d(double *source,float *dest); 11 | void round_l_s(float *source,long long *dest); 12 | void round_w_s(float *source,int *dest); 13 | void trunc_l_s(float *source,long long *dest); 14 | void trunc_w_s(float *source,int *dest); 15 | void ceil_l_s(float *source,long long *dest); 16 | void ceil_w_s(float *source,int *dest); 17 | void floor_l_s(float *source,long long *dest); 18 | void floor_w_s(float *source,int *dest); 19 | void round_l_d(double *source,long long *dest); 20 | void round_w_d(double *source,int *dest); 21 | void trunc_l_d(double *source,long long *dest); 22 | void trunc_w_d(double *source,int *dest); 23 | void ceil_l_d(double *source,long long *dest); 24 | void ceil_w_d(double *source,int *dest); 25 | void floor_l_d(double *source,long long *dest); 26 | void floor_w_d(double *source,int *dest); 27 | void c_f_s(); 28 | void c_un_s(float *source,float *target); 29 | void c_eq_s(float *source,float *target); 30 | void c_ueq_s(float *source,float *target); 31 | void c_olt_s(float *source,float *target); 32 | void c_ult_s(float *source,float *target); 33 | void c_ole_s(float *source,float *target); 34 | void c_ule_s(float *source,float *target); 35 | void c_sf_s(float *source,float *target); 36 | void c_ngle_s(float *source,float *target); 37 | void c_seq_s(float *source,float *target); 38 | void c_ngl_s(float *source,float *target); 39 | void c_lt_s(float *source,float *target); 40 | void c_nge_s(float *source,float *target); 41 | void c_le_s(float *source,float *target); 42 | void c_ngt_s(float *source,float *target); 43 | void c_f_d(); 44 | void c_un_d(double *source,double *target); 45 | void c_eq_d(double *source,double *target); 46 | void c_ueq_d(double *source,double *target); 47 | void c_olt_d(double *source,double *target); 48 | void c_ult_d(double *source,double *target); 49 | void c_ole_d(double *source,double *target); 50 | void c_ule_d(double *source,double *target); 51 | void c_sf_d(double *source,double *target); 52 | void c_ngle_d(double *source,double *target); 53 | void c_seq_d(double *source,double *target); 54 | void c_ngl_d(double *source,double *target); 55 | void c_lt_d(double *source,double *target); 56 | void c_nge_d(double *source,double *target); 57 | void c_le_d(double *source,double *target); 58 | void c_ngt_d(double *source,double *target); 59 | void add_s(float *source1,float *source2,float *target); 60 | void sub_s(float *source1,float *source2,float *target); 61 | void mul_s(float *source1,float *source2,float *target); 62 | void div_s(float *source1,float *source2,float *target); 63 | void sqrt_s(float *source,float *target); 64 | void abs_s(float *source,float *target); 65 | void mov_s(float *source,float *target); 66 | void neg_s(float *source,float *target); 67 | void add_d(double *source1,double *source2,double *target); 68 | void sub_d(double *source1,double *source2,double *target); 69 | void mul_d(double *source1,double *source2,double *target); 70 | void div_d(double *source1,double *source2,double *target); 71 | void sqrt_d(double *source,double *target); 72 | void abs_d(double *source,double *target); 73 | void mov_d(double *source,double *target); 74 | void neg_d(double *source,double *target); 75 | -------------------------------------------------------------------------------- /libpcsxcore/new_dynarec/gte.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * PCSX-Revolution - PlayStation Emulator for Nintendo Wii * 3 | * Copyright (C) 2009-2010 PCSX-Revolution Dev Team * 4 | * * 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (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 * 14 | * GNU 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 * 18 | * Free Software Foundation, Inc., * 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 20 | ***************************************************************************/ 21 | 22 | #ifdef FLAGLESS 23 | 24 | #define gteRTPS gteRTPS_nf 25 | #define gteOP gteOP_nf 26 | #define gteNCLIP gteNCLIP_nf 27 | #define gteDPCS gteDPCS_nf 28 | #define gteINTPL gteINTPL_nf 29 | #define gteMVMVA gteMVMVA_nf 30 | #define gteNCDS gteNCDS_nf 31 | #define gteNCDT gteNCDT_nf 32 | #define gteCDP gteCDP_nf 33 | #define gteNCCS gteNCCS_nf 34 | #define gteCC gteCC_nf 35 | #define gteNCS gteNCS_nf 36 | #define gteNCT gteNCT_nf 37 | #define gteSQR gteSQR_nf 38 | #define gteDCPL gteDCPL_nf 39 | #define gteDPCT gteDPCT_nf 40 | #define gteAVSZ3 gteAVSZ3_nf 41 | #define gteAVSZ4 gteAVSZ4_nf 42 | #define gteRTPT gteRTPT_nf 43 | #define gteGPF gteGPF_nf 44 | #define gteGPL gteGPL_nf 45 | #define gteNCCT gteNCCT_nf 46 | 47 | #define gteGPL_part_noshift gteGPL_part_noshift_nf 48 | #define gteGPL_part_shift gteGPL_part_shift_nf 49 | #define gteDPCS_part_noshift gteDPCS_part_noshift_nf 50 | #define gteDPCS_part_shift gteDPCS_part_shift_nf 51 | #define gteINTPL_part_noshift gteINTPL_part_noshift_nf 52 | #define gteINTPL_part_shift gteINTPL_part_shift_nf 53 | #define gteMACtoRGB gteMACtoRGB_nf 54 | 55 | #undef __GTE_H__ 56 | #endif 57 | 58 | #ifndef __GTE_H__ 59 | #define __GTE_H__ 60 | 61 | #ifdef __cplusplus 62 | extern "C" { 63 | #endif 64 | 65 | #include "../psxcommon.h" 66 | #include "../r3000a.h" 67 | 68 | struct psxCP2Regs; 69 | 70 | void gteMFC2(); 71 | void gteCFC2(); 72 | void gteMTC2(); 73 | void gteCTC2(); 74 | void gteLWC2(); 75 | void gteSWC2(); 76 | 77 | void gteRTPS(struct psxCP2Regs *regs); 78 | void gteOP(struct psxCP2Regs *regs); 79 | void gteNCLIP(struct psxCP2Regs *regs); 80 | void gteDPCS(struct psxCP2Regs *regs); 81 | void gteINTPL(struct psxCP2Regs *regs); 82 | void gteMVMVA(struct psxCP2Regs *regs); 83 | void gteNCDS(struct psxCP2Regs *regs); 84 | void gteNCDT(struct psxCP2Regs *regs); 85 | void gteCDP(struct psxCP2Regs *regs); 86 | void gteNCCS(struct psxCP2Regs *regs); 87 | void gteCC(struct psxCP2Regs *regs); 88 | void gteNCS(struct psxCP2Regs *regs); 89 | void gteNCT(struct psxCP2Regs *regs); 90 | void gteSQR(struct psxCP2Regs *regs); 91 | void gteDCPL(struct psxCP2Regs *regs); 92 | void gteDPCT(struct psxCP2Regs *regs); 93 | void gteAVSZ3(struct psxCP2Regs *regs); 94 | void gteAVSZ4(struct psxCP2Regs *regs); 95 | void gteRTPT(struct psxCP2Regs *regs); 96 | void gteGPF(struct psxCP2Regs *regs); 97 | void gteGPL(struct psxCP2Regs *regs); 98 | void gteNCCT(struct psxCP2Regs *regs); 99 | 100 | void gteSQR_part_noshift(struct psxCP2Regs *regs); 101 | void gteSQR_part_shift(struct psxCP2Regs *regs); 102 | void gteOP_part_noshift(struct psxCP2Regs *regs); 103 | void gteOP_part_shift(struct psxCP2Regs *regs); 104 | void gteDCPL_part(struct psxCP2Regs *regs); 105 | void gteGPF_part_noshift(struct psxCP2Regs *regs); 106 | void gteGPF_part_shift(struct psxCP2Regs *regs); 107 | 108 | void gteGPL_part_noshift(struct psxCP2Regs *regs); 109 | void gteGPL_part_shift(struct psxCP2Regs *regs); 110 | void gteDPCS_part_noshift(struct psxCP2Regs *regs); 111 | void gteDPCS_part_shift(struct psxCP2Regs *regs); 112 | void gteINTPL_part_noshift(struct psxCP2Regs *regs); 113 | void gteINTPL_part_shift(struct psxCP2Regs *regs); 114 | void gteMACtoRGB(struct psxCP2Regs *regs); 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | #endif 120 | -------------------------------------------------------------------------------- /libpcsxcore/new_dynarec/gte_arm.h: -------------------------------------------------------------------------------- 1 | void gteRTPS_nf_arm(void *cp2_regs, int opcode); 2 | void gteRTPT_nf_arm(void *cp2_regs, int opcode); 3 | void gteNCLIP_arm(void *cp2_regs, int opcode); 4 | 5 | // decomposed ops, nonstd calling convention 6 | void gteMVMVA_part_arm(void *cp2_regs, int is_shift12); 7 | void gteMVMVA_part_nf_arm(void *cp2_regs, int is_shift12); 8 | void gteMVMVA_part_cv3sh12_arm(void *cp2_regs); 9 | 10 | void gteMACtoIR_lm0(void *cp2_regs); 11 | void gteMACtoIR_lm1(void *cp2_regs); 12 | void gteMACtoIR_lm0_nf(void *cp2_regs); 13 | void gteMACtoIR_lm1_nf(void *cp2_regs); 14 | -------------------------------------------------------------------------------- /libpcsxcore/new_dynarec/gte_divider.h: -------------------------------------------------------------------------------- 1 | u32 DIVIDE(s16 n, u16 d); 2 | -------------------------------------------------------------------------------- /libpcsxcore/new_dynarec/gte_neon.h: -------------------------------------------------------------------------------- 1 | void gteRTPS_neon(void *cp2_regs, int opcode); 2 | void gteRTPT_neon(void *cp2_regs, int opcode); 3 | 4 | // decomposed ops, nonstd calling convention 5 | void gteMVMVA_part_neon(void *cp2_regs, int opcode); 6 | 7 | // after NEON call only, does not do gteIR 8 | void gteMACtoIR_flags_neon(void *cp2_regs, int lm); 9 | -------------------------------------------------------------------------------- /libpcsxcore/new_dynarec/gte_nf.c: -------------------------------------------------------------------------------- 1 | #define FLAGLESS 2 | #include "gte.c" 3 | -------------------------------------------------------------------------------- /libpcsxcore/new_dynarec/linkage_offsets.h: -------------------------------------------------------------------------------- 1 | 2 | #define LO_next_interupt 64 3 | #define LO_cycle_count (LO_next_interupt + 4) 4 | #define LO_last_count (LO_cycle_count + 4) 5 | #define LO_pending_exception (LO_last_count + 4) 6 | #define LO_stop (LO_pending_exception + 4) 7 | #define LO_invc_ptr (LO_stop + 4) 8 | #define LO_address (LO_invc_ptr + 4) 9 | #define LO_psxRegs (LO_address + 4) 10 | #define LO_reg (LO_psxRegs) 11 | #define LO_lo (LO_reg + 128) 12 | #define LO_hi (LO_lo + 4) 13 | #define LO_reg_cop0 (LO_hi + 4) 14 | #define LO_reg_cop2d (LO_reg_cop0 + 128) 15 | #define LO_reg_cop2c (LO_reg_cop2d + 128) 16 | #define LO_PC (LO_reg_cop2c + 128) 17 | #define LO_pcaddr (LO_PC) 18 | #define LO_code (LO_PC + 4) 19 | #define LO_cycle (LO_code + 4) 20 | #define LO_interrupt (LO_cycle + 4) 21 | #define LO_intCycle (LO_interrupt + 4) 22 | #define LO_psxRegs_end (LO_intCycle + 256) 23 | #define LO_rcnts (LO_psxRegs_end) 24 | #define LO_rcnts_end (LO_rcnts + 7*4*4) 25 | #define LO_mem_rtab (LO_rcnts_end) 26 | #define LO_mem_wtab (LO_mem_rtab + 4) 27 | #define LO_psxH_ptr (LO_mem_wtab + 4) 28 | #define LO_zeromem_ptr (LO_psxH_ptr + 4) 29 | #define LO_inv_code_start (LO_zeromem_ptr + 4) 30 | #define LO_inv_code_end (LO_inv_code_start + 4) 31 | #define LO_branch_target (LO_inv_code_end + 4) 32 | #define LO_scratch_buf_ptr (LO_branch_target + 4) 33 | #define LO_align0 (LO_scratch_buf_ptr + 4) 34 | #define LO_mini_ht (LO_align0 + 12) 35 | #define LO_restore_candidate (LO_mini_ht + 256) 36 | #define LO_dynarec_local_size (LO_restore_candidate + 512) 37 | 38 | #define LO_FCR0 (LO_align0) 39 | #define LO_FCR31 (LO_align0) 40 | 41 | #define LO_cop2_to_scratch_buf (LO_scratch_buf_ptr - LO_reg_cop2d) 42 | -------------------------------------------------------------------------------- /libpcsxcore/new_dynarec/new_dynarec.h: -------------------------------------------------------------------------------- 1 | #define NEW_DYNAREC 1 2 | 3 | extern int pcaddr; 4 | extern int pending_exception; 5 | extern int stop; 6 | extern int new_dynarec_did_compile; 7 | extern int cycle_multiplier; // 100 for 1.0 8 | 9 | #define NDHACK_NO_SMC_CHECK (1<<0) 10 | #define NDHACK_GTE_UNNEEDED (1<<1) 11 | #define NDHACK_GTE_NO_FLAGS (1<<2) 12 | extern int new_dynarec_hacks; 13 | 14 | void new_dynarec_init(); 15 | void new_dynarec_cleanup(); 16 | void new_dynarec_clear_full(); 17 | void new_dyna_start(); 18 | int new_dynarec_save_blocks(void *save, int size); 19 | void new_dynarec_load_blocks(const void *save, int size); 20 | 21 | void invalidate_all_pages(); 22 | void invalidate_block(unsigned int block); 23 | -------------------------------------------------------------------------------- /libpcsxcore/new_dynarec/pcsxmem.h: -------------------------------------------------------------------------------- 1 | 2 | extern u8 zero_mem[0x1000]; 3 | 4 | void new_dyna_pcsx_mem_init(void); 5 | void new_dyna_pcsx_mem_reset(void); 6 | void new_dyna_pcsx_mem_load_state(void); 7 | void new_dyna_pcsx_mem_shutdown(void); 8 | 9 | int pcsxmem_is_handler_dynamic(unsigned int addr); 10 | -------------------------------------------------------------------------------- /libpcsxcore/new_dynarec/pcsxmem_inline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Gražvydas "notaz" Ignotas, 2011 3 | * 4 | * This work is licensed under the terms of GNU GPL version 2 or later. 5 | * See the COPYING file in the top-level directory. 6 | */ 7 | 8 | #ifndef DRC_DBG 9 | 10 | static int pcsx_direct_read(int type, u_int addr, int cc_adj, int cc, int rs, int rt) 11 | { 12 | if ((addr & 0xfffff000) == 0x1f801000) { 13 | u_int t; 14 | switch (addr & 0xffff) { 15 | case 0x1120: // rcnt2 count 16 | if (rt < 0) goto dont_care; 17 | if (cc < 0) return 0; 18 | emit_readword((int)&rcnts[2].mode, HOST_TEMPREG); 19 | emit_readword((int)&rcnts[2].cycleStart, rt); 20 | emit_testimm(HOST_TEMPREG, 0x200); 21 | emit_readword((int)&last_count, HOST_TEMPREG); 22 | emit_sub(HOST_TEMPREG, rt, HOST_TEMPREG); 23 | emit_add(HOST_TEMPREG, cc, HOST_TEMPREG); 24 | if (cc_adj) 25 | emit_addimm(HOST_TEMPREG, cc_adj, rt); 26 | emit_shrne_imm(rt, 3, rt); 27 | mov_loadtype_adj(type!=LOADW_STUB?type:LOADH_STUB, rt, rt); 28 | goto hit; 29 | case 0x1104: 30 | case 0x1114: 31 | case 0x1124: // rcnt mode 32 | if (rt < 0) return 0; 33 | t = (addr >> 4) & 3; 34 | emit_readword((int)&rcnts[t].mode, rt); 35 | emit_andimm(rt, ~0x1800, HOST_TEMPREG); 36 | emit_writeword(HOST_TEMPREG, (int)&rcnts[t].mode); 37 | mov_loadtype_adj(type, rt, rt); 38 | goto hit; 39 | } 40 | } 41 | else { 42 | if (rt < 0) 43 | goto dont_care; 44 | } 45 | 46 | return 0; 47 | 48 | hit: 49 | assem_debug("pcsx_direct_read %08x end\n", addr); 50 | return 1; 51 | 52 | dont_care: 53 | assem_debug("pcsx_direct_read %08x dummy\n", addr); 54 | return 1; 55 | } 56 | 57 | #else 58 | 59 | static int pcsx_direct_read(int type, u_int addr, int cc_adj, int cc, int rs, int rt) 60 | { 61 | return 0; 62 | } 63 | 64 | #endif 65 | 66 | // vim:shiftwidth=2:expandtab 67 | -------------------------------------------------------------------------------- /libpcsxcore/ppc/pGte.h: -------------------------------------------------------------------------------- 1 | /* Pcsx - Pc Psx Emulator 2 | * Copyright (C) 1999-2003 Pcsx Team 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef PGET_H 20 | #define PGET_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | int psxCP2time[64] = { 27 | 2, 16 , 1 , 1, 1, 1 , 8, 1, // 00 28 | 1 , 1 , 1 , 1, 6 , 1 , 1 , 1, // 08 29 | 8 , 8, 8, 19, 13 , 1 , 44 , 1, // 10 30 | 1 , 1 , 1 , 17, 11 , 1 , 14 , 1, // 18 31 | 30 , 1 , 1 , 1, 1, 1 , 1 , 1, // 20 32 | 5 , 8 , 17 , 1, 1, 5, 6, 1, // 28 33 | 23 , 1 , 1 , 1, 1, 1 , 1 , 1, // 30 34 | 1 , 1 , 1 , 1, 1, 6 , 5 , 39 // 38 35 | }; 36 | 37 | #define CP2_FUNC(f) \ 38 | void gte##f(); \ 39 | static void rec##f() { \ 40 | if (pc < cop2readypc) idlecyclecount += (cop2readypc - pc)>>2; \ 41 | iFlushRegs(0); \ 42 | LIW(0, (u32)psxRegs.code); \ 43 | STW(0, OFFSET(&psxRegs, &psxRegs.code), GetHWRegSpecial(PSXREGS)); \ 44 | FlushAllHWReg(); \ 45 | CALLFunc ((u32)gte##f); \ 46 | cop2readypc = pc + psxCP2time[_fFunct_(psxRegs.code)]<<2; \ 47 | } 48 | 49 | CP2_FUNC(MFC2); 50 | CP2_FUNC(MTC2); 51 | CP2_FUNC(CFC2); 52 | CP2_FUNC(CTC2); 53 | CP2_FUNC(LWC2); 54 | CP2_FUNC(SWC2); 55 | CP2_FUNC(RTPS); 56 | CP2_FUNC(OP); 57 | CP2_FUNC(NCLIP); 58 | CP2_FUNC(DPCS); 59 | CP2_FUNC(INTPL); 60 | CP2_FUNC(MVMVA); 61 | CP2_FUNC(NCDS); 62 | CP2_FUNC(NCDT); 63 | CP2_FUNC(CDP); 64 | CP2_FUNC(NCCS); 65 | CP2_FUNC(CC); 66 | CP2_FUNC(NCS); 67 | CP2_FUNC(NCT); 68 | CP2_FUNC(SQR); 69 | CP2_FUNC(DCPL); 70 | CP2_FUNC(DPCT); 71 | CP2_FUNC(AVSZ3); 72 | CP2_FUNC(AVSZ4); 73 | CP2_FUNC(RTPT); 74 | CP2_FUNC(GPF); 75 | CP2_FUNC(GPL); 76 | CP2_FUNC(NCCT); 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | #endif 82 | -------------------------------------------------------------------------------- /libpcsxcore/ppc/pasm.s: -------------------------------------------------------------------------------- 1 | 2 | #if defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__) || defined (__powerpc64__) || defined (__POWERPC__) 3 | 4 | #if defined (ELF) || defined (__linux__) 5 | #define C(label) label 6 | #else 7 | #define C(label) _##label 8 | #endif 9 | 10 | #define OLD_REGISTER_OFFSET (19*4) 11 | #define SP_SIZE (OLD_REGISTER_OFFSET+4+8) 12 | 13 | /*asm void recRun(register void (*func)(), register u32 hw1, register u32 hw2)*/ 14 | .text 15 | .align 4 16 | .globl C(recRun) 17 | C(recRun): 18 | /* prologue code */ 19 | mflr r0 20 | stmw r13, -(32-13)*4(r1) 21 | stw r0, 4(r1) 22 | stwu r1, -((32-13)*4+8)(r1) 23 | 24 | /* execute code */ 25 | mtctr r3 26 | mr r31, r4 27 | mr r30, r5 28 | bctrl 29 | /* 30 | } 31 | asm void returnPC() 32 | {*/ 33 | .text 34 | .align 4 35 | .globl C(returnPC) 36 | C(returnPC): 37 | // end code 38 | lwz r0, (32-13)*4+8+4(r1) 39 | addi r1, r1, (32-13)*4+8 40 | mtlr r0 41 | lmw r13, -(32-13)*4(r1) 42 | blr 43 | //}*/ 44 | 45 | // Memory functions that only works with a linear memory 46 | 47 | .text 48 | .align 4 49 | .globl C(dynMemRead8) 50 | C(dynMemRead8): 51 | // assumes that memory pointer is in r30 52 | addis r2,r3,-0x1f80 53 | srwi. r4,r2,16 54 | bne+ .norm8 55 | cmplwi r2,0x1000 56 | blt- .norm8 57 | b C(psxHwRead8) 58 | .norm8: 59 | clrlwi r5,r3,3 60 | lbzx r3,r5,r30 61 | blr 62 | 63 | .text 64 | .align 4 65 | .globl C(dynMemRead16) 66 | C(dynMemRead16): 67 | // assumes that memory pointer is in r30 68 | addis r2,r3,-0x1f80 69 | srwi. r4,r2,16 70 | bne+ .norm16 71 | cmplwi r2,0x1000 72 | blt- .norm16 73 | b C(psxHwRead16) 74 | .norm16: 75 | clrlwi r5,r3,3 76 | lhbrx r3,r5,r30 77 | blr 78 | 79 | .text 80 | .align 4 81 | .globl C(dynMemRead32) 82 | C(dynMemRead32): 83 | // assumes that memory pointer is in r30 84 | addis r2,r3,-0x1f80 85 | srwi. r4,r2,16 86 | bne+ .norm32 87 | cmplwi r2,0x1000 88 | blt- .norm32 89 | b C(psxHwRead32) 90 | .norm32: 91 | clrlwi r5,r3,3 92 | lwbrx r3,r5,r30 93 | blr 94 | 95 | /* 96 | N P Z 97 | 0 0 0 X 98 | - 0 0 1 X 99 | 1 0 0 X 100 | 1 0 1 X 101 | 102 | P | (!N & Z) 103 | P | !(N | !Z) 104 | */ 105 | 106 | .text 107 | .align 4 108 | .globl C(dynMemWrite32) 109 | C(dynMemWrite32): 110 | // assumes that memory pointer is in r30 111 | addis r2,r3,-0x1f80 112 | srwi. r5,r2,16 113 | bne+ .normw32 114 | cmplwi r2,0x1000 115 | blt .normw32 116 | b C(psxHwWrite32) 117 | .normw32: 118 | mtcrf 0xFF, r3 119 | clrlwi r5,r3,3 120 | crandc 0, 2, 0 121 | cror 2, 1, 0 122 | bne+ .okw32 123 | // write test 124 | li r2,0x0130 125 | addis r2,r2,0xfffe 126 | cmplw r3,r2 127 | bnelr 128 | .okw32: 129 | stwbrx r4,r5,r30 130 | blr 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /libpcsxcore/ppc/ppc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ix86 core v0.5.1 3 | * Authors: linuzappz 4 | * alexey silinov 5 | */ 6 | 7 | #if defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__) || defined (__powerpc64__) || defined (__POWERPC__) 8 | 9 | #include 10 | #include 11 | 12 | #include "ppc.h" 13 | 14 | // General Purpose hardware registers 15 | int cpuHWRegisters[NUM_HW_REGISTERS] = { 16 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 17 | 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 18 | }; 19 | 20 | u32 *ppcPtr; 21 | 22 | void ppcInit() { 23 | } 24 | void ppcSetPtr(u32 *ptr) { 25 | ppcPtr = ptr; 26 | } 27 | void ppcAlign(int bytes) { 28 | // forward align 29 | ppcPtr = (u32*)(((u32)ppcPtr + bytes) & ~(bytes - 1)); 30 | } 31 | 32 | void ppcShutdown() { 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libpcsxcore/ppc/ppc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ppc definitions v0.5.1 3 | * Authors: linuzappz 4 | * alexey silinov 5 | */ 6 | 7 | #ifndef __PPC_H__ 8 | #define __PPC_H__ 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | // include basic types 15 | #include "../psxcommon.h" 16 | #include "ppc_mnemonics.h" 17 | 18 | #define NUM_HW_REGISTERS 29 19 | 20 | /* general defines */ 21 | #define write8(val) *(u8 *)ppcPtr = val; ppcPtr++; 22 | #define write16(val) *(u16*)ppcPtr = val; ppcPtr+=2; 23 | #define write32(val) *(u32*)ppcPtr = val; ppcPtr+=4; 24 | #define write64(val) *(u64*)ppcPtr = val; ppcPtr+=8; 25 | 26 | #define CALLFunc(FUNC) \ 27 | { \ 28 | u32 _func = (FUNC); \ 29 | ReleaseArgs(); \ 30 | if ((_func & 0x1fffffc) == _func) { \ 31 | BLA(_func); \ 32 | } else { \ 33 | LIW(0, _func); \ 34 | MTCTR(0); \ 35 | BCTRL(); \ 36 | } \ 37 | } 38 | 39 | extern int cpuHWRegisters[NUM_HW_REGISTERS]; 40 | 41 | extern u32 *ppcPtr; 42 | extern u8 *j8Ptr[32]; 43 | extern u32 *j32Ptr[32]; 44 | 45 | void ppcInit(); 46 | void ppcSetPtr(u32 *ptr); 47 | void ppcShutdown(); 48 | 49 | void ppcAlign(int bytes); 50 | void returnPC(); 51 | void recRun(void (*func)(), u32 hw1, u32 hw2); 52 | u8 dynMemRead8(u32 mem); 53 | u16 dynMemRead16(u32 mem); 54 | u32 dynMemRead32(u32 mem); 55 | void dynMemWrite32(u32 mem, u32 val); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | #endif 61 | -------------------------------------------------------------------------------- /libpcsxcore/ppc/reguse.h: -------------------------------------------------------------------------------- 1 | #ifndef __REGUSE_H__ 2 | #define __REGUSE_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | // include basic types 9 | #include "../psxcommon.h" 10 | 11 | #define REGUSE_NONE 0x0000 12 | #define REGUSE_UNKNOWN 0x0001 13 | 14 | //sub functions 15 | #define REGUSE_SPECIAL 0x0002 16 | #define REGUSE_REGIMM 0x0004 17 | #define REGUSE_COP0 0x0006 18 | #define REGUSE_COP2 0x0008 19 | #define REGUSE_BASIC 0x000a 20 | #define REGUSE_SUBMASK 0x000e /* sub function mask */ 21 | 22 | #define REGUSE_ACC 0x0010 /* accumulator */ 23 | #define REGUSE_LOGIC 0x0020 /* logic operations */ 24 | #define REGUSE_MULT 0x0030 /* multiplier */ 25 | #define REGUSE_JUMP 0x0040 /* jump to dest */ 26 | #define REGUSE_JUMPR 0x0050 /* jump to reg */ 27 | #define REGUSE_BRANCH 0x0060 /* branch */ 28 | #define REGUSE_MEM_R 0x0070 /* read from memory */ 29 | #define REGUSE_MEM_W 0x0080 /* write to memory */ 30 | #define REGUSE_MEM 0x0090 /* read and write to memory */ 31 | #define REGUSE_SYS 0x00a0 /* syscall */ 32 | #define REGUSE_GTE 0x00b0 /* gte operation */ 33 | #define REGUSE_SUB 0x00f0 /* sub usage */ 34 | #define REGUSE_TYPEM 0x00f0 /* type mask */ 35 | 36 | 37 | #define REGUSE_RS_R 0x0100 38 | #define REGUSE_RS_W 0x0200 39 | #define REGUSE_RS (REGUSE_RS_R | REGUSE_RS_W) 40 | #define REGUSE_RT_R 0x0400 41 | #define REGUSE_RT_W 0x0800 42 | #define REGUSE_RT (REGUSE_RT_R | REGUSE_RT_W) 43 | #define REGUSE_RD_R 0x1000 44 | #define REGUSE_RD_W 0x2000 45 | #define REGUSE_RD (REGUSE_RD_R | REGUSE_RD_W) 46 | 47 | #define REGUSE_R31_W 0x4000 /* writes to link register (r31) */ 48 | #define REGUSE_PC 0x8000 /* reads pc */ 49 | 50 | #define REGUSE_LO_R 0x10000 51 | #define REGUSE_LO_W 0x20000 52 | #define REGUSE_LO (REGUSE_LO_R | REGUSE_LO_W) 53 | #define REGUSE_HI_R 0x40000 54 | #define REGUSE_HI_W 0x80000 55 | #define REGUSE_HI (REGUSE_HI_R | REGUSE_HI_W) 56 | 57 | #define REGUSE_COP0_RD_R 0x100000 58 | #define REGUSE_COP0_RD_W 0x200000 59 | #define REGUSE_COP0_RD (REGUSE_COP0_RD_R | REGUSE_COP0_RD_W) 60 | #define REGUSE_COP0_STATUS 0x400000 61 | #define REGUSE_EXCEPTION 0x800000 62 | 63 | #define REGUSE_COP2_RT_R 0x1000000 64 | #define REGUSE_COP2_RT_W 0x2000000 65 | #define REGUSE_COP2_RT (REGUSE_COP2_RT_R | REGUSE_COP2_RT_W) 66 | #define REGUSE_COP2_RD_R 0x4000000 67 | #define REGUSE_COP2_RD_W 0x8000000 68 | #define REGUSE_COP2_RD (REGUSE_COP2_RD_R | REGUSE_COP2_RD_W) 69 | 70 | 71 | // specific register use 72 | #define REGUSE_READ 1 73 | #define REGUSE_WRITE 2 74 | #define REGUSE_RW 3 75 | 76 | int useOfPsxReg(u32 code, int use, int psxreg) __attribute__ ((__pure__));; 77 | int nextPsxRegUse(u32 pc, int psxreg) __attribute__ ((__pure__));; 78 | int isPsxRegUsed(u32 pc, int psxreg) __attribute__ ((__pure__));; 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | #endif 84 | -------------------------------------------------------------------------------- /libpcsxcore/ppf.h: -------------------------------------------------------------------------------- 1 | /* PPF Patch Support for PCSX-Reloaded 2 | * Copyright (c) 2009, Wei Mingzhi . 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef __PPF_H__ 20 | #define __PPF_H__ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | void BuildPPFCache(); 27 | void FreePPFCache(); 28 | void CheckPPFCache(unsigned char *pB, unsigned char m, unsigned char s, unsigned char f); 29 | 30 | int LoadSBI(const char *fname, int sector_count); 31 | void UnloadSBI(void); 32 | 33 | extern unsigned char *sbi_sectors; 34 | 35 | #include "cdrom.h" 36 | 37 | static inline int CheckSBI(const u8 *t) 38 | { 39 | int s; 40 | if (sbi_sectors == NULL) 41 | return 0; 42 | 43 | s = MSF2SECT(t[0], t[1], t[2]); 44 | return (sbi_sectors[s >> 3] >> (s & 7)) & 1; 45 | } 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | #endif 51 | -------------------------------------------------------------------------------- /libpcsxcore/psxbios.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __PSXBIOS_H__ 21 | #define __PSXBIOS_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "psxcommon.h" 28 | #include "r3000a.h" 29 | #include "psxmem.h" 30 | #include "misc.h" 31 | #include "sio.h" 32 | 33 | extern char *biosA0n[256]; 34 | extern char *biosB0n[256]; 35 | extern char *biosC0n[256]; 36 | 37 | void psxBiosInit(); 38 | void psxBiosShutdown(); 39 | void psxBiosException(); 40 | void psxBiosFreeze(int Mode); 41 | 42 | extern void (*biosA0[256])(); 43 | extern void (*biosB0[256])(); 44 | extern void (*biosC0[256])(); 45 | 46 | extern boolean hleSoftCall; 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | #endif 52 | -------------------------------------------------------------------------------- /libpcsxcore/psxcommon.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | #include "psxcommon.h" 21 | #include "r3000a.h" 22 | #include "psxbios.h" 23 | 24 | #include "cheat.h" 25 | #include "ppf.h" 26 | 27 | PcsxConfig Config; 28 | boolean NetOpened = FALSE; 29 | 30 | int Log = 0; 31 | FILE *emuLog = NULL; 32 | 33 | int EmuInit() { 34 | return psxInit(); 35 | } 36 | 37 | void EmuReset() { 38 | FreeCheatSearchResults(); 39 | FreeCheatSearchMem(); 40 | 41 | psxReset(); 42 | } 43 | 44 | void EmuShutdown() { 45 | ClearAllCheats(); 46 | FreeCheatSearchResults(); 47 | FreeCheatSearchMem(); 48 | 49 | FreePPFCache(); 50 | 51 | psxShutdown(); 52 | } 53 | 54 | void EmuUpdate() { 55 | // Do not allow hotkeys inside a softcall from HLE BIOS 56 | if (!Config.HLE || !hleSoftCall) 57 | SysUpdate(); 58 | 59 | ApplyCheats(); 60 | 61 | // reamed hack 62 | { 63 | extern void pl_frame_limit(void); 64 | pl_frame_limit(); 65 | } 66 | } 67 | 68 | void __Log(char *fmt, ...) { 69 | va_list list; 70 | #ifdef LOG_STDOUT 71 | char tmp[1024]; 72 | #endif 73 | 74 | va_start(list, fmt); 75 | #ifndef LOG_STDOUT 76 | vfprintf(emuLog, fmt, list); 77 | #else 78 | vsprintf(tmp, fmt, list); 79 | SysPrintf(tmp); 80 | #endif 81 | va_end(list); 82 | } 83 | -------------------------------------------------------------------------------- /libpcsxcore/psxcommon.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | /* 21 | * This file contains common definitions and includes for all parts of the 22 | * emulator core. 23 | */ 24 | 25 | #ifndef __PSXCOMMON_H__ 26 | #define __PSXCOMMON_H__ 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | #include "config.h" 33 | 34 | // System includes 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | // Define types 47 | typedef int8_t s8; 48 | typedef int16_t s16; 49 | typedef int32_t s32; 50 | typedef int64_t s64; 51 | typedef intptr_t sptr; 52 | 53 | typedef uint8_t u8; 54 | typedef uint16_t u16; 55 | typedef uint32_t u32; 56 | typedef uint64_t u64; 57 | typedef uintptr_t uptr; 58 | 59 | typedef uint8_t boolean; 60 | 61 | #ifndef TRUE 62 | #define TRUE 1 63 | #endif 64 | 65 | #ifndef FALSE 66 | #define FALSE 0 67 | #endif 68 | 69 | // Local includes 70 | #include "system.h" 71 | 72 | #ifndef _WIN32 73 | #define strnicmp strncasecmp 74 | #endif 75 | #define __inline inline 76 | 77 | // Enables NLS/internationalization if active 78 | #ifdef ENABLE_NLS 79 | 80 | #include 81 | 82 | #undef _ 83 | #define _(String) gettext(String) 84 | #ifdef gettext_noop 85 | # define N_(String) gettext_noop (String) 86 | #else 87 | # define N_(String) (String) 88 | #endif 89 | 90 | #else 91 | 92 | #define _(msgid) msgid 93 | #define N_(msgid) msgid 94 | 95 | #endif 96 | 97 | extern FILE *emuLog; 98 | extern int Log; 99 | 100 | void __Log(char *fmt, ...); 101 | 102 | typedef struct { 103 | char Gpu[MAXPATHLEN]; 104 | char Spu[MAXPATHLEN]; 105 | char Cdr[MAXPATHLEN]; 106 | char Pad1[MAXPATHLEN]; 107 | char Pad2[MAXPATHLEN]; 108 | char Net[MAXPATHLEN]; 109 | char Sio1[MAXPATHLEN]; 110 | char Mcd1[MAXPATHLEN]; 111 | char Mcd2[MAXPATHLEN]; 112 | char Bios[MAXPATHLEN]; 113 | char BiosDir[MAXPATHLEN]; 114 | char PluginsDir[MAXPATHLEN]; 115 | char PatchesDir[MAXPATHLEN]; 116 | boolean Xa; 117 | boolean Sio; 118 | boolean Mdec; 119 | boolean PsxAuto; 120 | boolean Cdda; 121 | boolean HLE; 122 | boolean Debug; 123 | boolean PsxOut; 124 | boolean SpuIrq; 125 | boolean RCntFix; 126 | boolean UseNet; 127 | boolean VSyncWA; 128 | boolean Widescreen; 129 | u8 Cpu; // CPU_DYNAREC or CPU_INTERPRETER 130 | u8 PsxType; // PSX_TYPE_NTSC or PSX_TYPE_PAL 131 | #ifdef _WIN32 132 | char Lang[256]; 133 | #endif 134 | } PcsxConfig; 135 | 136 | extern PcsxConfig Config; 137 | extern boolean NetOpened; 138 | 139 | struct PcsxSaveFuncs { 140 | void *(*open)(const char *name, const char *mode); 141 | int (*read)(void *file, void *buf, u32 len); 142 | int (*write)(void *file, const void *buf, u32 len); 143 | long (*seek)(void *file, long offs, int whence); 144 | void (*close)(void *file); 145 | }; 146 | extern struct PcsxSaveFuncs SaveFuncs; 147 | 148 | #define gzfreeze(ptr, size) { \ 149 | if (Mode == 1) SaveFuncs.write(f, ptr, size); \ 150 | if (Mode == 0) SaveFuncs.read(f, ptr, size); \ 151 | } 152 | 153 | // Make the timing events trigger faster as we are currently assuming everything 154 | // takes one cycle, which is not the case on real hardware. 155 | // FIXME: Count the proper cycle and get rid of this 156 | #define BIAS 2 157 | #define PSXCLK 33868800 /* 33.8688 MHz */ 158 | 159 | enum { 160 | PSX_TYPE_NTSC = 0, 161 | PSX_TYPE_PAL 162 | }; // PSX Types 163 | 164 | enum { 165 | CPU_DYNAREC = 0, 166 | CPU_INTERPRETER 167 | }; // CPU Types 168 | 169 | int EmuInit(); 170 | void EmuReset(); 171 | void EmuShutdown(); 172 | void EmuUpdate(); 173 | 174 | #ifdef __cplusplus 175 | } 176 | #endif 177 | #endif 178 | -------------------------------------------------------------------------------- /libpcsxcore/psxcounters.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2010 by Blade_Arma * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __PSXCOUNTERS_H__ 21 | #define __PSXCOUNTERS_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "psxcommon.h" 28 | #include "r3000a.h" 29 | #include "psxmem.h" 30 | #include "plugins.h" 31 | 32 | extern u32 psxNextCounter, psxNextsCounter; 33 | 34 | extern u32 hSyncCount, frame_counter; 35 | 36 | typedef struct Rcnt 37 | { 38 | u16 mode, target; 39 | u32 rate, irq, counterState, irqState; 40 | u32 cycle, cycleStart; 41 | } Rcnt; 42 | extern Rcnt rcnts[]; 43 | 44 | void psxRcntInit(); 45 | void psxRcntUpdate(); 46 | 47 | void psxRcntWcount(u32 index, u32 value); 48 | void psxRcntWmode(u32 index, u32 value); 49 | void psxRcntWtarget(u32 index, u32 value); 50 | 51 | u32 psxRcntRcount(u32 index); 52 | u32 psxRcntRmode(u32 index); 53 | u32 psxRcntRtarget(u32 index); 54 | 55 | s32 psxRcntFreeze(void *f, s32 Mode); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | #endif 61 | -------------------------------------------------------------------------------- /libpcsxcore/psxdma.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __PSXDMA_H__ 21 | #define __PSXDMA_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "psxcommon.h" 28 | #include "r3000a.h" 29 | #include "psxhw.h" 30 | #include "psxmem.h" 31 | 32 | #define GPUDMA_INT(eCycle) { \ 33 | psxRegs.interrupt |= (1 << PSXINT_GPUDMA); \ 34 | psxRegs.intCycle[PSXINT_GPUDMA].cycle = eCycle; \ 35 | psxRegs.intCycle[PSXINT_GPUDMA].sCycle = psxRegs.cycle; \ 36 | new_dyna_set_event(PSXINT_GPUDMA, eCycle); \ 37 | } 38 | 39 | #define SPUDMA_INT(eCycle) { \ 40 | psxRegs.interrupt |= (1 << PSXINT_SPUDMA); \ 41 | psxRegs.intCycle[PSXINT_SPUDMA].cycle = eCycle; \ 42 | psxRegs.intCycle[PSXINT_SPUDMA].sCycle = psxRegs.cycle; \ 43 | new_dyna_set_event(PSXINT_SPUDMA, eCycle); \ 44 | } 45 | 46 | #define MDECOUTDMA_INT(eCycle) { \ 47 | psxRegs.interrupt |= (1 << PSXINT_MDECOUTDMA); \ 48 | psxRegs.intCycle[PSXINT_MDECOUTDMA].cycle = eCycle; \ 49 | psxRegs.intCycle[PSXINT_MDECOUTDMA].sCycle = psxRegs.cycle; \ 50 | new_dyna_set_event(PSXINT_MDECOUTDMA, eCycle); \ 51 | } 52 | 53 | #define MDECINDMA_INT(eCycle) { \ 54 | psxRegs.interrupt |= (1 << PSXINT_MDECINDMA); \ 55 | psxRegs.intCycle[PSXINT_MDECINDMA].cycle = eCycle; \ 56 | psxRegs.intCycle[PSXINT_MDECINDMA].sCycle = psxRegs.cycle; \ 57 | new_dyna_set_event(PSXINT_MDECINDMA, eCycle); \ 58 | } 59 | 60 | #define GPUOTCDMA_INT(eCycle) { \ 61 | psxRegs.interrupt |= (1 << PSXINT_GPUOTCDMA); \ 62 | psxRegs.intCycle[PSXINT_GPUOTCDMA].cycle = eCycle; \ 63 | psxRegs.intCycle[PSXINT_GPUOTCDMA].sCycle = psxRegs.cycle; \ 64 | new_dyna_set_event(PSXINT_GPUOTCDMA, eCycle); \ 65 | } 66 | 67 | #define CDRDMA_INT(eCycle) { \ 68 | psxRegs.interrupt |= (1 << PSXINT_CDRDMA); \ 69 | psxRegs.intCycle[PSXINT_CDRDMA].cycle = eCycle; \ 70 | psxRegs.intCycle[PSXINT_CDRDMA].sCycle = psxRegs.cycle; \ 71 | new_dyna_set_event(PSXINT_CDRDMA, eCycle); \ 72 | } 73 | 74 | void psxDma2(u32 madr, u32 bcr, u32 chcr); 75 | void psxDma3(u32 madr, u32 bcr, u32 chcr); 76 | void psxDma4(u32 madr, u32 bcr, u32 chcr); 77 | void psxDma6(u32 madr, u32 bcr, u32 chcr); 78 | void gpuInterrupt(); 79 | void spuInterrupt(); 80 | void gpuotcInterrupt(); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | #endif 86 | -------------------------------------------------------------------------------- /libpcsxcore/psxhle.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | /* 21 | * Internal PSX HLE functions. 22 | */ 23 | 24 | #include "psxhle.h" 25 | 26 | static void hleDummy() { 27 | psxRegs.pc = psxRegs.GPR.n.ra; 28 | 29 | psxBranchTest(); 30 | } 31 | 32 | static void hleA0() { 33 | u32 call = psxRegs.GPR.n.t1 & 0xff; 34 | 35 | if (biosA0[call]) biosA0[call](); 36 | 37 | psxBranchTest(); 38 | } 39 | 40 | static void hleB0() { 41 | u32 call = psxRegs.GPR.n.t1 & 0xff; 42 | 43 | if (biosB0[call]) biosB0[call](); 44 | 45 | psxBranchTest(); 46 | } 47 | 48 | static void hleC0() { 49 | u32 call = psxRegs.GPR.n.t1 & 0xff; 50 | 51 | if (biosC0[call]) biosC0[call](); 52 | 53 | psxBranchTest(); 54 | } 55 | 56 | static void hleBootstrap() { // 0xbfc00000 57 | SysPrintf("hleBootstrap\n"); 58 | CheckCdrom(); 59 | LoadCdrom(); 60 | SysPrintf("CdromLabel: \"%s\": PC = %8.8lx (SP = %8.8lx)\n", CdromLabel, psxRegs.pc, psxRegs.GPR.n.sp); 61 | } 62 | 63 | typedef struct { 64 | u32 _pc0; 65 | u32 gp0; 66 | u32 t_addr; 67 | u32 t_size; 68 | u32 d_addr; 69 | u32 d_size; 70 | u32 b_addr; 71 | u32 b_size; 72 | u32 S_addr; 73 | u32 s_size; 74 | u32 _sp,_fp,_gp,ret,base; 75 | } EXEC; 76 | 77 | static void hleExecRet() { 78 | EXEC *header = (EXEC*)PSXM(psxRegs.GPR.n.s0); 79 | 80 | SysPrintf("ExecRet %x: %x\n", psxRegs.GPR.n.s0, header->ret); 81 | 82 | psxRegs.GPR.n.ra = header->ret; 83 | psxRegs.GPR.n.sp = header->_sp; 84 | psxRegs.GPR.n.s8 = header->_fp; 85 | psxRegs.GPR.n.gp = header->_gp; 86 | psxRegs.GPR.n.s0 = header->base; 87 | 88 | psxRegs.GPR.n.v0 = 1; 89 | psxRegs.pc = psxRegs.GPR.n.ra; 90 | } 91 | 92 | void (*psxHLEt[256])() = { 93 | hleDummy, hleA0, hleB0, hleC0, 94 | hleBootstrap, hleExecRet, 95 | hleDummy, hleDummy 96 | }; 97 | -------------------------------------------------------------------------------- /libpcsxcore/psxhle.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __PSXHLE_H__ 21 | #define __PSXHLE_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "psxcommon.h" 28 | #include "r3000a.h" 29 | #include "plugins.h" 30 | 31 | extern void (*psxHLEt[256])(); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | #endif 37 | -------------------------------------------------------------------------------- /libpcsxcore/psxhw.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team * 3 | * * 4 | * This program is free software; you can redistribute it and/or modify * 5 | * it under the terms of the GNU General Public License as published by * 6 | * the Free Software Foundation; either version 2 of the License, or * 7 | * (at your option) any later version. * 8 | * * 9 | * This program is distributed in the hope that it will be useful, * 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 | * GNU General Public License for more details. * 13 | * * 14 | * You should have received a copy of the GNU General Public License * 15 | * along with this program; if not, write to the * 16 | * Free Software Foundation, Inc., * 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * 18 | ***************************************************************************/ 19 | 20 | #ifndef __PSXHW_H__ 21 | #define __PSXHW_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "psxcommon.h" 28 | #include "r3000a.h" 29 | #include "psxmem.h" 30 | #include "sio.h" 31 | #include "psxcounters.h" 32 | 33 | #define HW_DMA0_MADR (psxHu32ref(0x1080)) // MDEC in DMA 34 | #define HW_DMA0_BCR (psxHu32ref(0x1084)) 35 | #define HW_DMA0_CHCR (psxHu32ref(0x1088)) 36 | 37 | #define HW_DMA1_MADR (psxHu32ref(0x1090)) // MDEC out DMA 38 | #define HW_DMA1_BCR (psxHu32ref(0x1094)) 39 | #define HW_DMA1_CHCR (psxHu32ref(0x1098)) 40 | 41 | #define HW_DMA2_MADR (psxHu32ref(0x10a0)) // GPU DMA 42 | #define HW_DMA2_BCR (psxHu32ref(0x10a4)) 43 | #define HW_DMA2_CHCR (psxHu32ref(0x10a8)) 44 | 45 | #define HW_DMA3_MADR (psxHu32ref(0x10b0)) // CDROM DMA 46 | #define HW_DMA3_BCR (psxHu32ref(0x10b4)) 47 | #define HW_DMA3_CHCR (psxHu32ref(0x10b8)) 48 | 49 | #define HW_DMA4_MADR (psxHu32ref(0x10c0)) // SPU DMA 50 | #define HW_DMA4_BCR (psxHu32ref(0x10c4)) 51 | #define HW_DMA4_CHCR (psxHu32ref(0x10c8)) 52 | 53 | #define HW_DMA6_MADR (psxHu32ref(0x10e0)) // GPU DMA (OT) 54 | #define HW_DMA6_BCR (psxHu32ref(0x10e4)) 55 | #define HW_DMA6_CHCR (psxHu32ref(0x10e8)) 56 | 57 | #define HW_DMA_PCR (psxHu32ref(0x10f0)) 58 | #define HW_DMA_ICR (psxHu32ref(0x10f4)) 59 | 60 | #define HW_DMA_ICR_BUS_ERROR (1<<15) 61 | #define HW_DMA_ICR_GLOBAL_ENABLE (1<<23) 62 | #define HW_DMA_ICR_IRQ_SENT (1<<31) 63 | 64 | #define DMA_INTERRUPT(n) { \ 65 | u32 icr = SWAPu32(HW_DMA_ICR); \ 66 | if (icr & (1 << (16 + n))) { \ 67 | icr |= 1 << (24 + n); \ 68 | if (icr & HW_DMA_ICR_GLOBAL_ENABLE && !(icr & HW_DMA_ICR_IRQ_SENT)) { \ 69 | psxHu32ref(0x1070) |= SWAP32(8); \ 70 | icr |= HW_DMA_ICR_IRQ_SENT; \ 71 | } \ 72 | HW_DMA_ICR = SWAP32(icr); \ 73 | } \ 74 | } 75 | 76 | void psxHwReset(); 77 | u8 psxHwRead8(u32 add); 78 | u16 psxHwRead16(u32 add); 79 | u32 psxHwRead32(u32 add); 80 | void psxHwWrite8(u32 add, u8 value); 81 | void psxHwWrite16(u32 add, u16 value); 82 | void psxHwWrite32(u32 add, u32 value); 83 | int psxHwFreeze(void *f, int Mode); 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | #endif 89 | -------------------------------------------------------------------------------- /libpcsxcore/psxmem_map.h: -------------------------------------------------------------------------------- 1 | #ifndef __PSXMEM_MAP_H__ 2 | #define __PSXMEM_MAP_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | enum psxMapTag { 9 | MAP_TAG_OTHER = 0, 10 | MAP_TAG_RAM, 11 | MAP_TAG_VRAM, 12 | MAP_TAG_LUTS, 13 | }; 14 | 15 | extern void *(*psxMapHook)(unsigned long addr, size_t size, int is_fixed, 16 | enum psxMapTag tag); 17 | extern void (*psxUnmapHook)(void *ptr, size_t size, enum psxMapTag tag); 18 | 19 | void *psxMap(unsigned long addr, size_t size, int is_fixed, 20 | enum psxMapTag tag); 21 | void psxUnmap(void *ptr, size_t size, enum psxMapTag tag); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | #endif 27 | -------------------------------------------------------------------------------- /libpcsxcore/retro_inline.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2015 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_inline.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_INLINE_H 24 | #define __LIBRETRO_SDK_INLINE_H 25 | 26 | #ifndef INLINE 27 | 28 | #if !defined(__cplusplus) && defined(_WIN32) 29 | #define INLINE _inline 30 | #elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L 31 | #define INLINE inline 32 | #elif defined(__GNUC__) 33 | #define INLINE __inline__ 34 | #else 35 | #define INLINE 36 | #endif 37 | 38 | #endif 39 | #endif 40 | -------------------------------------------------------------------------------- /libpcsxcore/retro_miscellaneous.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2015 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_miscellaneous.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __RARCH_MISCELLANEOUS_H 24 | #define __RARCH_MISCELLANEOUS_H 25 | 26 | #include 27 | 28 | #if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) 29 | #include 30 | #elif defined(XENON) 31 | #include