├── .github └── workflows │ └── main.yml ├── LICENSE ├── Makefile ├── Makefile.gc ├── Makefile.wii ├── README.txt ├── buildtools ├── libfreetype.a └── libfreetype.la ├── compile_gc.cmd ├── compile_wii.cmd ├── fonts ├── jp.ttf ├── ko.ttf └── zh.ttf ├── hbc ├── icon.png └── meta.xml └── source ├── audio.cpp ├── audio.h ├── button_mapping.c ├── button_mapping.h ├── cheatmgr.cpp ├── filebrowser.cpp ├── filebrowser.h ├── filelist.h ├── fileop.cpp ├── fileop.h ├── filter.cpp ├── filter.h ├── fonts └── font.ttf ├── freeze.cpp ├── freeze.h ├── gcunzip.cpp ├── gcunzip.h ├── gui ├── gui.h ├── gui_button.cpp ├── gui_element.cpp ├── gui_filebrowser.cpp ├── gui_image.cpp ├── gui_imagedata.cpp ├── gui_keyboard.cpp ├── gui_optionbrowser.cpp ├── gui_savebrowser.cpp ├── gui_sound.cpp ├── gui_text.cpp ├── gui_trigger.cpp └── gui_window.cpp ├── images ├── battery.png ├── battery_bar.png ├── battery_red.png ├── bg_bottom.png ├── bg_game_selection.png ├── bg_game_selection_entry.png ├── bg_options.png ├── bg_options_entry.png ├── bg_preview.png ├── bg_top.png ├── button.png ├── button_arrow_down.png ├── button_arrow_down_over.png ├── button_arrow_left.png ├── button_arrow_left_over.png ├── button_arrow_right.png ├── button_arrow_right_over.png ├── button_arrow_up.png ├── button_arrow_up_over.png ├── button_gamesave.png ├── button_gamesave_blank.png ├── button_gamesave_over.png ├── button_large.png ├── button_large_over.png ├── button_long.png ├── button_long_over.png ├── button_over.png ├── button_prompt.png ├── button_prompt_over.png ├── button_short.png ├── button_short_over.png ├── button_small.png ├── button_small_over.png ├── credits_box.png ├── dialogue_box.png ├── icon_dvd.png ├── icon_folder.png ├── icon_game_cheats.png ├── icon_game_controllers.png ├── icon_game_delete.png ├── icon_game_load.png ├── icon_game_reset.png ├── icon_game_save.png ├── icon_game_screenshot.png ├── icon_game_settings.png ├── icon_home.png ├── icon_sd.png ├── icon_settings.png ├── icon_settings_audio.png ├── icon_settings_classic.png ├── icon_settings_credits.png ├── icon_settings_drc.png ├── icon_settings_emulation.png ├── icon_settings_fastforward.png ├── icon_settings_file.png ├── icon_settings_gamecube.png ├── icon_settings_hacks.png ├── icon_settings_justifier.png ├── icon_settings_mappings.png ├── icon_settings_menu.png ├── icon_settings_mouse.png ├── icon_settings_nunchuk.png ├── icon_settings_snescontroller.png ├── icon_settings_superscope.png ├── icon_settings_video.png ├── icon_settings_wiimote.png ├── icon_settings_wiiupro.png ├── icon_usb.png ├── keyboard_key.png ├── keyboard_key_over.png ├── keyboard_largekey.png ├── keyboard_largekey_over.png ├── keyboard_mediumkey.png ├── keyboard_mediumkey_over.png ├── keyboard_textbox.png ├── logo.png ├── logo_over.png ├── player1_point.png ├── player2_point.png ├── player3_point.png ├── player4_point.png ├── progressbar.png ├── progressbar_empty.png ├── progressbar_outline.png ├── screen_position.png ├── scrollbar.png ├── scrollbar_arrowdown.png ├── scrollbar_arrowdown_over.png ├── scrollbar_arrowup.png ├── scrollbar_arrowup_over.png ├── scrollbar_box.png ├── scrollbar_box_over.png └── throbber.png ├── input.cpp ├── input.h ├── lang ├── de.lang ├── en.lang ├── es.lang ├── fr.lang ├── it.lang ├── jp.lang ├── ko.lang ├── nl.lang ├── pt.lang ├── pt_br.lang ├── tr.lang └── zh.lang ├── mem2.cpp ├── mem2.h ├── menu.cpp ├── menu.h ├── preferences.cpp ├── preferences.h ├── s9xsupport.cpp ├── snes9x ├── 65c816.h ├── apu │ ├── SNES_SPC.cpp │ ├── SNES_SPC.h │ ├── SNES_SPC_misc.cpp │ ├── SNES_SPC_state.cpp │ ├── SPC_CPU.h │ ├── SPC_DSP.cpp │ ├── SPC_DSP.h │ ├── SPC_Filter.cpp │ ├── SPC_Filter.h │ ├── apu.cpp │ ├── apu.h │ ├── blargg_common.h │ ├── blargg_config.h │ ├── blargg_endian.h │ ├── blargg_source.h │ ├── license.txt │ └── resampler.h ├── bml.cpp ├── bml.h ├── bsx.cpp ├── bsx.h ├── c4.cpp ├── c4.h ├── c4emu.cpp ├── cheats.cpp ├── cheats.h ├── cheats2.cpp ├── clip.cpp ├── controls.cpp ├── controls.h ├── cpu.cpp ├── cpuaddr.h ├── cpuexec.cpp ├── cpuexec.h ├── cpumacro.h ├── cpuops.cpp ├── cpuops.h ├── crosshairs.cpp ├── crosshairs.h ├── display.h ├── dma.cpp ├── dma.h ├── dsp.cpp ├── dsp.h ├── dsp1.cpp ├── dsp2.cpp ├── dsp3.cpp ├── dsp4.cpp ├── font.h ├── fxemu.cpp ├── fxemu.h ├── fxinst.cpp ├── fxinst.h ├── getset.h ├── gfx.cpp ├── gfx.h ├── globals.cpp ├── language.h ├── memmap.cpp ├── memmap.h ├── messages.h ├── missing.h ├── movie.cpp ├── movie.h ├── msu1.cpp ├── msu1.h ├── obc1.cpp ├── obc1.h ├── pixform.h ├── port.h ├── ppu.cpp ├── ppu.h ├── sa1.cpp ├── sa1.h ├── sa1cpu.cpp ├── sar.h ├── screenshot.cpp ├── screenshot.h ├── sdd1.cpp ├── sdd1.h ├── sdd1emu.cpp ├── sdd1emu.h ├── seta.cpp ├── seta.h ├── seta010.cpp ├── seta011.cpp ├── seta018.cpp ├── sha256.cpp ├── sha256.h ├── snapshot.cpp ├── snapshot.h ├── snes9x.h ├── spc7110.cpp ├── spc7110.h ├── spc7110dec.cpp ├── spc7110dec.h ├── spc7110emu.cpp ├── spc7110emu.h ├── srtc.cpp ├── srtc.h ├── srtcemu.cpp ├── srtcemu.h ├── stream.cpp ├── stream.h ├── tile.cpp ├── tile.h ├── tileimpl-h2x1.cpp ├── tileimpl-n1x1.cpp ├── tileimpl-n2x1.cpp └── tileimpl.h ├── snes9xtx.cpp ├── snes9xtx.h ├── sounds ├── button_click.pcm ├── button_over.pcm └── enter.ogg ├── sram.cpp ├── sram.h ├── utils ├── FreeTypeGX.cpp ├── FreeTypeGX.h ├── gettext.cpp ├── gettext.h ├── mayflash.c ├── mayflash.h ├── oggplayer.c ├── oggplayer.h ├── pngu.c ├── pngu.h ├── sicksaxis.c ├── sicksaxis.h ├── sz │ ├── 7zAlloc.c │ ├── 7zAlloc.h │ ├── 7zBuffer.c │ ├── 7zBuffer.h │ ├── 7zCrc.c │ ├── 7zCrc.h │ ├── 7zDecode.c │ ├── 7zDecode.h │ ├── 7zExtract.c │ ├── 7zExtract.h │ ├── 7zHeader.c │ ├── 7zHeader.h │ ├── 7zIn.c │ ├── 7zIn.h │ ├── 7zItem.c │ ├── 7zItem.h │ ├── 7zMethodID.c │ ├── 7zMethodID.h │ ├── 7zTypes.h │ ├── LzmaDecode.c │ ├── LzmaDecode.h │ └── LzmaTypes.h ├── vm │ ├── asm.h │ ├── dsihandler.s │ ├── vm.c │ └── vm.h ├── wiidrc.c ├── wiidrc.h ├── xbox360.c └── xbox360.h ├── video.cpp ├── video.h ├── vmalloc.cpp └── vmalloc.h /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Snes9x TX Build 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | name: Build Snes9x TX 8 | runs-on: ubuntu-20.04 9 | strategy: 10 | matrix: 11 | image: ["Wii", "GameCube"] 12 | container: devkitpro/devkitppc:latest 13 | 14 | steps: 15 | - uses: actions/checkout@v1 16 | with: 17 | submodules: true 18 | 19 | - name: Build Wii 20 | if: ${{ matrix.image == 'Wii' }} 21 | run: | 22 | make -f Makefile.wii -j2 23 | 24 | - name: Copy Wii artifact 25 | if: ${{ matrix.image == 'Wii' }} 26 | run: | 27 | mkdir -p dist/Snes9xTX/apps/snes9xtx 28 | mkdir -p dist/Snes9xTX/snes9xtx/roms 29 | mkdir dist/Snes9xTX/snes9xtx/cheats 30 | mkdir dist/Snes9xTX/snes9xtx/saves 31 | touch dist/Snes9xTX/snes9xtx/roms/romsdir 32 | touch dist/Snes9xTX/snes9xtx/cheats/cheatsdir 33 | touch dist/Snes9xTX/snes9xtx/saves/savesdir 34 | cp hbc/* dist/Snes9xTX/apps/snes9xtx/ 35 | cp executables/snes9xtx-wii.dol dist/Snes9xTX/apps/snes9xtx/boot.dol 36 | 37 | - name: Upload Wii artifacts 38 | uses: actions/upload-artifact@v3.1.0 39 | if: ${{ matrix.image == 'Wii' }} 40 | with: 41 | name: Snes9xTX 42 | path: | 43 | dist/Snes9xTX/ 44 | 45 | - name: Build GameCube 46 | if: ${{ matrix.image == 'GameCube' }} 47 | run: | 48 | make -f Makefile.gc -j2 49 | 50 | - name: Copy GameCube artifact 51 | if: ${{ matrix.image == 'GameCube' }} 52 | run: | 53 | mkdir -p dist/Snes9xTX-GameCube 54 | cp executables/snes9xtx-gc.dol dist/Snes9xTX-GameCube/ 55 | 56 | - name: Upload GameCube artifact 57 | uses: actions/upload-artifact@v3.1.0 58 | if: ${{ matrix.image == 'GameCube' }} 59 | with: 60 | name: Snes9xTX-GameCube 61 | path: | 62 | dist/Snes9xTX-GameCube/ 63 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY = all wii gc wii-clean gc-clean wii-run gc-run 2 | 3 | all: wii gc 4 | 5 | run: wii-run 6 | 7 | clean: wii-clean gc-clean 8 | 9 | wii: 10 | $(MAKE) -f Makefile.wii 11 | 12 | wii-clean: 13 | $(MAKE) -f Makefile.wii clean 14 | 15 | wii-run: wii 16 | $(MAKE) -f Makefile.wii run 17 | 18 | gc: 19 | $(MAKE) -f Makefile.gc 20 | 21 | gc-clean: 22 | $(MAKE) -f Makefile.gc clean 23 | 24 | gc-run: gc 25 | $(MAKE) -f Makefile.gc run 26 | -------------------------------------------------------------------------------- /buildtools/libfreetype.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/buildtools/libfreetype.a -------------------------------------------------------------------------------- /buildtools/libfreetype.la: -------------------------------------------------------------------------------- 1 | # libfreetype.la - a libtool library file 2 | # Generated by ltmain.sh (GNU libtool) 2.2.6b 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # The name that we can dlopen(3). 8 | dlname='' 9 | 10 | # Names of this library. 11 | library_names='' 12 | 13 | # The name of the static archive. 14 | old_library='libfreetype.a' 15 | 16 | # Linker flags that can not go in dependency_libs. 17 | inherited_linker_flags='' 18 | 19 | # Libraries that this one depends upon. 20 | dependency_libs=' -L$DEVKITPRO/ppc/lib -lz' 21 | 22 | # Names of additional weak libraries provided by this library 23 | weak_library_names='' 24 | 25 | # Version information for libfreetype. 26 | current=12 27 | age=6 28 | revision=0 29 | 30 | # Is this an already installed library? 31 | installed=yes 32 | 33 | # Should we warn about portability when linking against -modules? 34 | shouldnotlink=no 35 | 36 | # Files to dlopen/dlpreopen 37 | dlopen='' 38 | dlpreopen='' 39 | 40 | # Directory that this library needs to be installed in: 41 | libdir='$DEVKITPRO/portlibs/ppc/lib' 42 | -------------------------------------------------------------------------------- /compile_gc.cmd: -------------------------------------------------------------------------------- 1 | make -f Makefile.gc 2 | pause -------------------------------------------------------------------------------- /compile_wii.cmd: -------------------------------------------------------------------------------- 1 | make -f Makefile.wii 2 | pause -------------------------------------------------------------------------------- /fonts/jp.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/fonts/jp.ttf -------------------------------------------------------------------------------- /fonts/ko.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/fonts/ko.ttf -------------------------------------------------------------------------------- /fonts/zh.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/fonts/zh.ttf -------------------------------------------------------------------------------- /hbc/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/hbc/icon.png -------------------------------------------------------------------------------- /hbc/meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Snes9x TX 4 | Tanooki 5 | 1.1.3 6 | 20230115 7 | Super Nintendo Emulator 8 | Snes9x TX is a fork of Snes9x GX on Wii. 9 | 10 | 11 | -------------------------------------------------------------------------------- /source/audio.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * Tantric 2008-2022 5 | * 6 | * audio.h 7 | * 8 | * Audio driver 9 | * Audio is fixed to 32Khz/16bit/Stereo 10 | ***************************************************************************/ 11 | 12 | void InitAudio (); 13 | void AudioStart (); 14 | void SwitchAudioMode(int mode); 15 | void ShutdownAudio(); 16 | -------------------------------------------------------------------------------- /source/button_mapping.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * michniewski August 2008 5 | * Tantric 2008-2022 6 | * 7 | * button_mapping.c 8 | * 9 | * Controller button mapping 10 | ***************************************************************************/ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "utils/wiidrc.h" 21 | #include "button_mapping.h" 22 | 23 | /**************************************************************************** 24 | * Controller Button Descriptions: 25 | * used for identifying which buttons have been pressed when configuring 26 | * and for displaying the name of said button 27 | ***************************************************************************/ 28 | 29 | CtrlrMap ctrlr_def[6] = { 30 | // GameCube controller btn def 31 | { 32 | CTRLR_GCPAD, 33 | 13, 34 | { 35 | {PAD_BUTTON_DOWN, "DOWN"}, 36 | {PAD_BUTTON_UP, "UP"}, 37 | {PAD_BUTTON_LEFT, "LEFT"}, 38 | {PAD_BUTTON_RIGHT, "RIGHT"}, 39 | {PAD_BUTTON_A, "A"}, 40 | {PAD_BUTTON_B, "B"}, 41 | {PAD_BUTTON_X, "X"}, 42 | {PAD_BUTTON_Y, "Y"}, 43 | {PAD_BUTTON_MENU, "START"}, 44 | {PAD_BUTTON_START, "START"}, 45 | {PAD_TRIGGER_L, "L"}, 46 | {PAD_TRIGGER_R, "R"}, 47 | {PAD_TRIGGER_Z, "Z"}, 48 | {0, ""}, 49 | {0, ""} 50 | } 51 | }, 52 | // Wiimote btn def 53 | { 54 | CTRLR_WIIMOTE, 55 | 11, 56 | { 57 | {WPAD_BUTTON_DOWN, "DOWN"}, 58 | {WPAD_BUTTON_UP, "UP"}, 59 | {WPAD_BUTTON_LEFT, "LEFT"}, 60 | {WPAD_BUTTON_RIGHT, "RIGHT"}, 61 | {WPAD_BUTTON_A, "A"}, 62 | {WPAD_BUTTON_B, "B"}, 63 | {WPAD_BUTTON_1, "1"}, 64 | {WPAD_BUTTON_2, "2"}, 65 | {WPAD_BUTTON_PLUS, "PLUS"}, 66 | {WPAD_BUTTON_MINUS, "MINUS"}, 67 | {WPAD_BUTTON_HOME, "HOME"}, 68 | {0, ""}, 69 | {0, ""}, 70 | {0, ""}, 71 | {0, ""} 72 | } 73 | }, 74 | // Nunchuk btn def 75 | { 76 | CTRLR_NUNCHUK, 77 | 13, 78 | { 79 | {WPAD_BUTTON_DOWN, "DOWN"}, 80 | {WPAD_BUTTON_UP, "UP"}, 81 | {WPAD_BUTTON_LEFT, "LEFT"}, 82 | {WPAD_BUTTON_RIGHT, "RIGHT"}, 83 | {WPAD_BUTTON_A, "A"}, 84 | {WPAD_BUTTON_B, "B"}, 85 | {WPAD_BUTTON_1, "1"}, 86 | {WPAD_BUTTON_2, "2"}, 87 | {WPAD_BUTTON_PLUS, "PLUS"}, 88 | {WPAD_BUTTON_MINUS, "MINUS"}, 89 | {WPAD_BUTTON_HOME, "HOME"}, 90 | {WPAD_NUNCHUK_BUTTON_Z, "Z"}, 91 | {WPAD_NUNCHUK_BUTTON_C, "C"}, 92 | {0, ""}, 93 | {0, ""} 94 | } 95 | }, 96 | // Classic controller btn def 97 | { 98 | CTRLR_CLASSIC, 99 | 15, 100 | { 101 | {WPAD_CLASSIC_BUTTON_DOWN, "DOWN"}, 102 | {WPAD_CLASSIC_BUTTON_UP, "UP"}, 103 | {WPAD_CLASSIC_BUTTON_LEFT, "LEFT"}, 104 | {WPAD_CLASSIC_BUTTON_RIGHT, "RIGHT"}, 105 | {WPAD_CLASSIC_BUTTON_A, "A"}, 106 | {WPAD_CLASSIC_BUTTON_B, "B"}, 107 | {WPAD_CLASSIC_BUTTON_X, "X"}, 108 | {WPAD_CLASSIC_BUTTON_Y, "Y"}, 109 | {WPAD_CLASSIC_BUTTON_PLUS, "PLUS"}, 110 | {WPAD_CLASSIC_BUTTON_MINUS, "MINUS"}, 111 | {WPAD_CLASSIC_BUTTON_HOME, "HOME"}, 112 | {WPAD_CLASSIC_BUTTON_FULL_L, "L"}, 113 | {WPAD_CLASSIC_BUTTON_FULL_R, "R"}, 114 | {WPAD_CLASSIC_BUTTON_ZL, "ZL"}, 115 | {WPAD_CLASSIC_BUTTON_ZR, "ZR"} 116 | } 117 | }, 118 | // Wii U Pro controller btn def 119 | { 120 | CTRLR_WUPC, 121 | 15, 122 | { 123 | {WPAD_CLASSIC_BUTTON_DOWN, "DOWN"}, 124 | {WPAD_CLASSIC_BUTTON_UP, "UP"}, 125 | {WPAD_CLASSIC_BUTTON_LEFT, "LEFT"}, 126 | {WPAD_CLASSIC_BUTTON_RIGHT, "RIGHT"}, 127 | {WPAD_CLASSIC_BUTTON_A, "A"}, 128 | {WPAD_CLASSIC_BUTTON_B, "B"}, 129 | {WPAD_CLASSIC_BUTTON_X, "X"}, 130 | {WPAD_CLASSIC_BUTTON_Y, "Y"}, 131 | {WPAD_CLASSIC_BUTTON_PLUS, "PLUS"}, 132 | {WPAD_CLASSIC_BUTTON_MINUS, "MINUS"}, 133 | {WPAD_CLASSIC_BUTTON_HOME, "HOME"}, 134 | {WPAD_CLASSIC_BUTTON_FULL_L, "L"}, 135 | {WPAD_CLASSIC_BUTTON_FULL_R, "R"}, 136 | {WPAD_CLASSIC_BUTTON_ZL, "ZL"}, 137 | {WPAD_CLASSIC_BUTTON_ZR, "ZR"} 138 | } 139 | }, 140 | // Wii U Gamepad btn def 141 | { 142 | CTRLR_WIIDRC, 143 | 15, 144 | { 145 | {WIIDRC_BUTTON_DOWN, "DOWN"}, 146 | {WIIDRC_BUTTON_UP, "UP"}, 147 | {WIIDRC_BUTTON_LEFT, "LEFT"}, 148 | {WIIDRC_BUTTON_RIGHT, "RIGHT"}, 149 | {WIIDRC_BUTTON_A, "A"}, 150 | {WIIDRC_BUTTON_B, "B"}, 151 | {WIIDRC_BUTTON_X, "X"}, 152 | {WIIDRC_BUTTON_Y, "Y"}, 153 | {WIIDRC_BUTTON_PLUS, "PLUS"}, 154 | {WIIDRC_BUTTON_MINUS, "MINUS"}, 155 | {WIIDRC_BUTTON_HOME, "HOME"}, 156 | {WIIDRC_BUTTON_L, "L"}, 157 | {WIIDRC_BUTTON_R, "R"}, 158 | {WIIDRC_BUTTON_ZL, "ZL"}, 159 | {WIIDRC_BUTTON_ZR, "ZR"} 160 | } 161 | } 162 | }; 163 | -------------------------------------------------------------------------------- /source/button_mapping.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * michniewski August 2008 5 | * Tantric 2008-2022 6 | * 7 | * button_mapping.h 8 | * 9 | * Controller button mapping 10 | ***************************************************************************/ 11 | 12 | #ifndef BTN_MAP_H 13 | #define BTN_MAP_H 14 | 15 | enum { 16 | CTRLR_NONE = -1, 17 | CTRLR_GCPAD, 18 | CTRLR_WIIMOTE, 19 | CTRLR_NUNCHUK, 20 | CTRLR_CLASSIC, 21 | CTRLR_WUPC, 22 | CTRLR_WIIDRC 23 | }; 24 | 25 | const char ctrlrName[6][32] = 26 | { "GameCube Controller", "Wiimote", "Nunchuk + Wiimote", "Classic Controller", "Wii U Pro Controller", "Wii U Gamepad" }; 27 | 28 | typedef struct _btn_map { 29 | u32 btn; // button 'id' 30 | char* name; // button name 31 | } BtnMap; 32 | 33 | typedef struct _ctrlr_map { 34 | u16 type; // controller type 35 | int num_btns; // number of buttons on the controller 36 | BtnMap map[15]; // controller button map 37 | } CtrlrMap; 38 | 39 | extern CtrlrMap ctrlr_def[6]; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /source/cheatmgr.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * Tantric 2008-2022 5 | * 6 | * cheatmgr.cpp 7 | * 8 | * Cheat handling 9 | ***************************************************************************/ 10 | 11 | #include "snes9x/port.h" 12 | #include "snes9x/cheats.h" 13 | #include "snes9x/bml.h" 14 | 15 | #include "snes9xtx.h" 16 | #include "fileop.h" 17 | #include "filebrowser.h" 18 | 19 | #define MAX_CHEATS 150 20 | 21 | extern SCheatData Cheat; 22 | 23 | /**************************************************************************** 24 | * LoadCheatFile 25 | * 26 | * Loads cheat file from save buffer 27 | * Custom version of S9xLoadCheatFile() 28 | ***************************************************************************/ 29 | static bool LoadCheatFile (int length) 30 | { 31 | uint8 data [28]; 32 | int offset = 0; 33 | 34 | while (offset < length) { 35 | if(Cheat.g.size() >= MAX_CHEATS || (length - offset) < 28) 36 | break; 37 | 38 | memcpy (data, savebuffer+offset, 28); 39 | offset += 28; 40 | 41 | SCheat c; 42 | char name[21]; 43 | char cheat[10]; 44 | c.byte = data[1]; 45 | c.address = data[2] | (data[3] << 8) | (data[4] << 16); 46 | memcpy (name, &data[8], 20); 47 | name[20] = 0; 48 | 49 | snprintf (cheat, 10, "%x=%x", c.address, c.byte); 50 | S9xAddCheatGroup (name, cheat); 51 | } 52 | return true; 53 | } 54 | 55 | 56 | void ToggleCheat(uint32 num) { 57 | if(Cheat.g[num].enabled) { 58 | S9xDisableCheatGroup(num); 59 | } 60 | else { 61 | S9xEnableCheatGroup(num); 62 | } 63 | 64 | for(int i=0; i < Cheat.g.size(); i++) { 65 | if(Cheat.g[i].enabled) { 66 | Cheat.enabled = TRUE; 67 | return; 68 | } 69 | } 70 | Cheat.enabled = FALSE; 71 | } 72 | 73 | /**************************************************************************** 74 | * SetupCheats 75 | * 76 | * Erases any prexisting cheats, loads cheats from a cheat file 77 | * Called when a ROM is first loaded 78 | ***************************************************************************/ 79 | void 80 | WiiSetupCheats() 81 | { 82 | char filepath[1024]; 83 | int offset = 0; 84 | 85 | if(!MakeFilePath(filepath, FILE_CHEAT)) 86 | return; 87 | 88 | AllocSaveBuffer(); 89 | 90 | offset = LoadFile(filepath, SILENT); 91 | 92 | // load cheat file if present 93 | if(offset > 0) 94 | { 95 | bml_node bml; 96 | if (!bml.parse_file(filepath)) 97 | { 98 | LoadCheatFile (offset); 99 | } 100 | 101 | bml_node *n = bml.find_subnode("cheat"); 102 | if (n) 103 | { 104 | S9xLoadCheatsFromBMLNode (&bml); 105 | } 106 | 107 | if (!n) 108 | { 109 | LoadCheatFile (offset); 110 | } 111 | } 112 | 113 | 114 | FreeSaveBuffer (); 115 | } 116 | -------------------------------------------------------------------------------- /source/filebrowser.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * Tantric 2008-2022 5 | * 6 | * filebrowser.h 7 | * 8 | * Generic file routines - reading, writing, browsing 9 | ****************************************************************************/ 10 | 11 | #ifndef _FILEBROWSER_H_ 12 | #define _FILEBROWSER_H_ 13 | 14 | #include 15 | #include 16 | #include "snes9xtx.h" 17 | 18 | #define MAXJOLIET 255 19 | #ifdef HW_DOL 20 | #define MAX_BROWSER_SIZE 1000 21 | #else 22 | #define MAX_BROWSER_SIZE 5000 23 | #endif 24 | 25 | typedef struct 26 | { 27 | char dir[MAXPATHLEN + 1]; // directory path of browserList 28 | int numEntries; // # of entries in browserList 29 | int selIndex; // currently selected index of browserList 30 | int pageIndex; // starting index of browserList page display 31 | int size; // # of entries browerList has space allocated to store 32 | } BROWSERINFO; 33 | 34 | typedef struct 35 | { 36 | size_t length; // file length 37 | int isdir; // 0 - file, 1 - directory 38 | char filename[MAXJOLIET + 1]; // full filename 39 | char displayname[MAXJOLIET + 1]; // name for browser display 40 | int filenum; // file # (for 7z support) 41 | int icon; // icon to display 42 | } BROWSERENTRY; 43 | 44 | extern BROWSERINFO browser; 45 | extern BROWSERENTRY * browserList; 46 | 47 | enum 48 | { 49 | ICON_NONE, 50 | ICON_FOLDER, 51 | ICON_SD, 52 | ICON_USB, 53 | ICON_DVD, 54 | }; 55 | 56 | extern unsigned long SNESROMSize; 57 | extern bool loadingFile; 58 | extern char szname[MAXPATHLEN]; 59 | extern bool inSz; 60 | 61 | bool MakeFilePath(char filepath[], int type, char * filename = NULL, int filenum = -2); 62 | int UpdateDirName(); 63 | int OpenGameList(); 64 | int autoLoadMethod(); 65 | int autoSaveMethod(bool silent); 66 | int FileSortCallback(const void *f1, const void *f2); 67 | void StripExt(char* returnstring, char * inputstring); 68 | bool IsSz(); 69 | void ResetBrowser(); 70 | bool AddBrowserEntry(); 71 | bool IsDeviceRoot(char * path); 72 | int BrowserLoadSz(); 73 | int BrowserChangeFolder(); 74 | int BrowserLoadFile(); 75 | bool AutoloadGame(char* filepath, char* filename); 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /source/fileop.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * Tantric 2008-2022 5 | * 6 | * fileop.h 7 | * 8 | * File operations 9 | ****************************************************************************/ 10 | 11 | #ifndef _FILEOP_H_ 12 | #define _FILEOP_H_ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #ifdef HW_RVL 19 | #define SAVEBUFFERSIZE (1024 * 1024 * 2) // leave room for IPS/UPS files and large images 20 | #else 21 | #define SAVEBUFFERSIZE (1024 * 1024 * 1) 22 | #endif 23 | 24 | void InitDeviceThread(); 25 | void ResumeDeviceThread(); 26 | void HaltDeviceThread(); 27 | void HaltParseThread(); 28 | void MountAllFAT(); 29 | void UnmountAllFAT(); 30 | bool FindDevice(char * filepath, int * device); 31 | char * StripDevice(char * path); 32 | bool ChangeInterface(int device, bool silent); 33 | bool ChangeInterface(char * filepath, bool silent); 34 | void CreateAppPath(char * origpath); 35 | void FindAndSelectLastLoadedFile(); 36 | int ParseDirectory(bool waitParse = false, bool filter = true); 37 | bool CreateDirectory(char * path); 38 | void AllocSaveBuffer(); 39 | void FreeSaveBuffer(); 40 | size_t LoadFile(char * rbuffer, char *filepath, size_t length, size_t buffersize, bool silent); 41 | size_t LoadFile(char * filepath, bool silent); 42 | size_t LoadSzFile(char * filepath, unsigned char * rbuffer); 43 | size_t LoadFont(char *filepath); 44 | void LoadBgMusic(); 45 | size_t SaveFile(char * buffer, char *filepath, size_t datasize, bool silent); 46 | size_t SaveFile(char * filepath, size_t datasize, bool silent); 47 | 48 | extern unsigned char *savebuffer; 49 | extern u8 *ext_font_ttf; 50 | extern FILE * file; 51 | extern bool unmountRequired[]; 52 | extern bool isMounted[]; 53 | extern int selectLoadedFile; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /source/filter.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * Michniewski 2008 5 | * Tanooki 2019-2023 6 | * 7 | * Scale2x filter 8 | * (c) Copyright 2001 Andrea Mazzoleni (amadvance@gmail.com) 9 | * 10 | * Adapted from AdvanceMAME 11 | * Video Filter Code (scale2x) 12 | * http://www.scale2x.it/ 13 | * 14 | * filter.cpp 15 | * 16 | * Video filtering 17 | ****************************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "filter.h" 28 | #include "video.h" 29 | #include "menu.h" 30 | #include "snes9xtx.h" 31 | #include "snes9x/memmap.h" 32 | 33 | #define Mask_2 0x07E0 // 00000 111111 00000 34 | #define Mask13 0xF81F // 11111 000000 11111 35 | 36 | TFilterMethod FilterMethod; 37 | 38 | template void RenderTVMode (uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); 39 | template void RenderScale2X (uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); 40 | 41 | const char* GetFilterName (RenderFilter filterID) 42 | { 43 | switch(filterID) 44 | { 45 | default: return "Unknown"; 46 | case FILTER_NONE: return "None"; 47 | case FILTER_TVMODE: return "TV Mode"; 48 | case FILTER_SCALE2X: return "Scale2x"; 49 | } 50 | } 51 | 52 | // Return pointer to appropriate function 53 | static TFilterMethod FilterToMethod (RenderFilter filterID) 54 | { 55 | switch(filterID) 56 | { 57 | case FILTER_TVMODE: return RenderTVMode; 58 | case FILTER_SCALE2X: return RenderScale2X; 59 | default: return 0; 60 | } 61 | } 62 | 63 | int GetFilterScale(RenderFilter filterID) 64 | { 65 | switch(filterID) 66 | { 67 | case FILTER_NONE: 68 | return 1; 69 | default: 70 | case FILTER_TVMODE: 71 | case FILTER_SCALE2X: 72 | return 2; 73 | } 74 | } 75 | 76 | void SelectFilterMethod () 77 | { 78 | FilterMethod = FilterToMethod((RenderFilter)GCSettings.VideoFilter); 79 | } 80 | 81 | template 82 | void RenderTVMode (uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) 83 | { 84 | unsigned int nextlineSrc = srcPitch / sizeof(uint16); 85 | uint16 *p = (uint16 *)srcPtr; 86 | 87 | unsigned int nextlineDst = dstPitch / sizeof(uint16); 88 | uint16 *q = (uint16 *)dstPtr; 89 | 90 | while(height--) { 91 | for (int i = 0, j = 0; i < width; ++i, j += 2) { 92 | uint16 p1 = *(p + i); 93 | uint32 pi; 94 | 95 | pi = (((p1 & Mask_2) * 6) >> 3) & Mask_2; 96 | pi |= (((p1 & Mask13) * 6) >> 3) & Mask13; 97 | 98 | *(q + j) = p1; 99 | *(q + j + 1) = p1; 100 | *(q + j + nextlineDst) = (uint16)pi; 101 | *(q + j + nextlineDst + 1) = (uint16)pi; 102 | } 103 | p += nextlineSrc; 104 | q += nextlineDst << 1; 105 | } 106 | } 107 | 108 | template 109 | void RenderScale2X (uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) 110 | { 111 | unsigned int nextlineSrc = srcPitch / sizeof(uint16); 112 | uint16 *p = (uint16 *)srcPtr; 113 | 114 | unsigned int nextlineDst = dstPitch / sizeof(uint16); 115 | uint16 *q = (uint16 *)dstPtr; 116 | 117 | while (height--) { 118 | for (int i = 0; i < width; ++i) { 119 | uint16 B = *(p + i - nextlineSrc); 120 | uint16 D = *(p + i - 1); 121 | uint16 E = *(p + i); 122 | uint16 F = *(p + i + 1); 123 | uint16 H = *(p + i + nextlineSrc); 124 | 125 | *(q + (i << 1)) = D == B && B != F && D != H ? D : E; 126 | *(q + (i << 1) + 1) = B == F && B != D && F != H ? F : E; 127 | *(q + (i << 1) + nextlineDst) = D == H && D != B && H != F ? D : E; 128 | *(q + (i << 1) + nextlineDst + 1) = H == F && D != H && B != F ? F : E; 129 | } 130 | p += nextlineSrc; 131 | q += nextlineDst << 1; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /source/filter.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * Michniewski 2008 5 | * Tanooki 2019-2023 6 | * 7 | * filter.h 8 | * 9 | * Video filtering 10 | ****************************************************************************/ 11 | 12 | #ifndef _FILTER_H_ 13 | #define _FILTER_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "snes9x/snes9x.h" 24 | 25 | enum RenderFilter{ 26 | FILTER_NONE = 0, 27 | 28 | FILTER_TVMODE, 29 | FILTER_SCALE2X, 30 | 31 | NUM_FILTERS 32 | }; 33 | 34 | #define EXT_WIDTH (MAX_SNES_WIDTH + 4) 35 | #define EXT_PITCH (EXT_WIDTH * 2) 36 | #define EXT_HEIGHT (MAX_SNES_HEIGHT + 4) 37 | // Offset into buffer to allow a two pixel border around the whole rendered 38 | // SNES image. This is a speed up hack to allow some of the image processing 39 | // routines to access black pixel data outside the normal bounds of the buffer. 40 | #define EXT_OFFSET (EXT_PITCH * 2 + 2 * 2) 41 | 42 | typedef void (*TFilterMethod)(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); 43 | 44 | extern TFilterMethod FilterMethod; 45 | 46 | extern unsigned char * filtermem; 47 | 48 | void SelectFilterMethod (); 49 | const char* GetFilterName (RenderFilter filterID); 50 | int GetFilterScale(RenderFilter filterID); 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /source/fonts/font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/fonts/font.ttf -------------------------------------------------------------------------------- /source/freeze.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * softdev July 2006 5 | * crunchy2 May 2007-July 2007 6 | * Michniewski 2008 7 | * Tantric 2008-2022 8 | * 9 | * freeze.cpp 10 | ***************************************************************************/ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "snes9xtx.h" 17 | #include "fileop.h" 18 | #include "filebrowser.h" 19 | #include "menu.h" 20 | #include "video.h" 21 | #include "utils/pngu.h" 22 | 23 | #include "snes9x/snes9x.h" 24 | #include "snes9x/port.h" 25 | #include "snes9x/memmap.h" 26 | #include "snes9x/snapshot.h" 27 | #include "snes9x/language.h" 28 | 29 | bool8 S9xOpenSnapshotFile(const char *filepath, bool8 readonly, STREAM *file) 30 | { 31 | return FALSE; 32 | } 33 | 34 | void S9xCloseSnapshotFile(STREAM s) 35 | { 36 | 37 | } 38 | 39 | /**************************************************************************** 40 | * SaveSnapshot 41 | ***************************************************************************/ 42 | int 43 | SaveSnapshot (char * filepath, bool silent) 44 | { 45 | int device; 46 | 47 | if(!FindDevice(filepath, &device)) 48 | return 0; 49 | 50 | // save screenshot 51 | if(gameScreenPngSize > 0) 52 | { 53 | char screenpath[1024]; 54 | strcpy(screenpath, filepath); 55 | screenpath[strlen(screenpath)-4] = 0; 56 | strcat(screenpath, ".png"); 57 | SaveFile((char *)gameScreenPng, screenpath, gameScreenPngSize, silent); 58 | } 59 | 60 | STREAM fp = OPEN_STREAM(filepath, "wb"); 61 | 62 | if(!fp) 63 | { 64 | if(!silent) 65 | ErrorPrompt("Save failed!"); 66 | return 0; 67 | } 68 | 69 | S9xFreezeToStream(fp); 70 | CLOSE_STREAM(fp); 71 | 72 | if(!silent) 73 | InfoPrompt("Save successful"); 74 | return 1; 75 | } 76 | 77 | int 78 | SaveSnapshotAuto (bool silent) 79 | { 80 | char filepath[1024]; 81 | 82 | if(!MakeFilePath(filepath, FILE_SNAPSHOT, Memory.ROMFilename, 0)) 83 | return false; 84 | 85 | return SaveSnapshot(filepath, silent); 86 | } 87 | 88 | /**************************************************************************** 89 | * LoadSnapshot 90 | ***************************************************************************/ 91 | int 92 | LoadSnapshot (char * filepath, bool silent) 93 | { 94 | int device; 95 | 96 | if(!FindDevice(filepath, &device)) 97 | return 0; 98 | 99 | STREAM fp = OPEN_STREAM(filepath, "rb"); 100 | 101 | if(!fp) 102 | { 103 | if(!silent) 104 | ErrorPrompt("Unable to open state!"); 105 | return 0; 106 | } 107 | 108 | int result = S9xUnfreezeFromStream(fp); 109 | CLOSE_STREAM(fp); 110 | 111 | if (result == SUCCESS) 112 | return 1; 113 | 114 | switch (result) 115 | { 116 | case WRONG_FORMAT: 117 | ErrorPrompt(SAVE_ERR_WRONG_FORMAT); 118 | break; 119 | 120 | case WRONG_VERSION: 121 | ErrorPrompt(SAVE_ERR_WRONG_VERSION); 122 | break; 123 | 124 | case SNAPSHOT_INCONSISTENT: 125 | ErrorPrompt(MOVIE_ERR_SNAPSHOT_INCONSISTENT); 126 | break; 127 | } 128 | return 0; 129 | } 130 | 131 | int 132 | LoadSnapshotAuto (bool silent) 133 | { 134 | char filepath[1024]; 135 | 136 | if(!MakeFilePath(filepath, FILE_SNAPSHOT, Memory.ROMFilename, 0)) 137 | return false; 138 | 139 | return LoadSnapshot(filepath, silent); 140 | } 141 | 142 | /**************************************************************************** 143 | * SavePreview 144 | ***************************************************************************/ 145 | int SavePreviewImg (char * filepath, bool silent) 146 | { 147 | int device; 148 | 149 | if(!FindDevice(filepath, &device)) 150 | return 0; 151 | 152 | // save screenshot 153 | if(gameScreenPngSize > 0) 154 | { 155 | char screenpath[1024]; 156 | strcpy(screenpath, filepath); 157 | screenpath[strlen(screenpath)] = 0; 158 | strcat(screenpath, ".png"); 159 | SaveFile((char *)gameScreenPng, screenpath, gameScreenPngSize, silent); 160 | } 161 | return 1; 162 | } 163 | -------------------------------------------------------------------------------- /source/freeze.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * softdev July 2006 5 | * crunchy2 May 2007-July 2007 6 | * Michniewski 2008 7 | * Tantric 2008-2022 8 | * 9 | * freeze.h 10 | ***************************************************************************/ 11 | 12 | #ifndef _FREEZE_H_ 13 | #define _FREEZE_H_ 14 | 15 | int SaveSnapshot (char * filepath, bool silent); 16 | int SaveSnapshotAuto (bool silent); 17 | int LoadSnapshot (char * filepath, bool silent); 18 | int LoadSnapshotAuto (bool silent); 19 | int SavePreviewImg (char * filepath, bool silent); 20 | #endif 21 | -------------------------------------------------------------------------------- /source/gcunzip.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * softdev July 2006 5 | * Michniewski 2008 6 | * Tantric 2008-2022 7 | * 8 | * gcunzip.h 9 | * 10 | * File unzip routines 11 | ****************************************************************************/ 12 | #ifndef _GCUNZIP_H_ 13 | #define _GCUNZIP_H_ 14 | 15 | int IsZipFile (char *buffer); 16 | char * GetFirstZipFilename(); 17 | size_t UnZipBuffer (unsigned char *outbuffer, size_t buffersize); 18 | int SzParse(char * filepath); 19 | size_t SzExtractFile(int i, unsigned char *buffer); 20 | void SzClose(); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /source/gui/gui_imagedata.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui 3 | * 4 | * Tantric 2009 5 | * 6 | * gui_imagedata.cpp 7 | * 8 | * GUI class definitions 9 | ***************************************************************************/ 10 | 11 | #include "gui.h" 12 | 13 | /** 14 | * Constructor for the GuiImageData class. 15 | */ 16 | GuiImageData::GuiImageData(const u8 * i, int maxw, int maxh) 17 | { 18 | data = NULL; 19 | width = 0; 20 | height = 0; 21 | 22 | if(i) 23 | data = DecodePNG(i, &width, &height, data, maxw, maxh); 24 | } 25 | 26 | /** 27 | * Destructor for the GuiImageData class. 28 | */ 29 | GuiImageData::~GuiImageData() 30 | { 31 | if(data) 32 | { 33 | free(data); 34 | data = NULL; 35 | } 36 | } 37 | 38 | u8 * GuiImageData::GetImage() 39 | { 40 | return data; 41 | } 42 | 43 | int GuiImageData::GetWidth() 44 | { 45 | return width; 46 | } 47 | 48 | int GuiImageData::GetHeight() 49 | { 50 | return height; 51 | } 52 | -------------------------------------------------------------------------------- /source/gui/gui_sound.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * libwiigui 3 | * 4 | * Tantric 2009 5 | * 6 | * gui_sound.cpp 7 | * 8 | * GUI class definitions 9 | ***************************************************************************/ 10 | 11 | #include "gui.h" 12 | 13 | /** 14 | * Constructor for the GuiSound class. 15 | */ 16 | GuiSound::GuiSound(const u8 * s, s32 l, int t) 17 | { 18 | sound = s; 19 | length = l; 20 | type = t; 21 | voice = -1; 22 | volume = 100; 23 | loop = false; 24 | } 25 | 26 | /** 27 | * Destructor for the GuiSound class. 28 | */ 29 | GuiSound::~GuiSound() 30 | { 31 | #ifndef NO_SOUND 32 | if(type == SOUND_OGG) 33 | StopOgg(); 34 | #endif 35 | } 36 | 37 | void GuiSound::Play() 38 | { 39 | #ifndef NO_SOUND 40 | int vol; 41 | 42 | switch(type) 43 | { 44 | case SOUND_PCM: 45 | vol = 0.0255f*(volume*GCSettings.SFXVolume); 46 | voice = ASND_GetFirstUnusedVoice(); 47 | if(voice >= 0) 48 | ASND_SetVoice(voice, VOICE_STEREO_16BIT, 48000, 0, 49 | (u8 *)sound, length, vol, vol, NULL); 50 | break; 51 | 52 | case SOUND_OGG: 53 | voice = 0; 54 | if(loop) 55 | PlayOgg((char *)sound, length, 0, OGG_INFINITE_TIME); 56 | else 57 | PlayOgg((char *)sound, length, 0, OGG_ONE_TIME); 58 | SetVolumeOgg(2.55f*(volume)); 59 | break; 60 | } 61 | #endif 62 | } 63 | 64 | void GuiSound::Stop() 65 | { 66 | #ifndef NO_SOUND 67 | if(voice < 0) 68 | return; 69 | 70 | switch(type) 71 | { 72 | case SOUND_PCM: 73 | ASND_StopVoice(voice); 74 | break; 75 | 76 | case SOUND_OGG: 77 | StopOgg(); 78 | break; 79 | } 80 | #endif 81 | } 82 | 83 | void GuiSound::Pause() 84 | { 85 | #ifndef NO_SOUND 86 | if(voice < 0) 87 | return; 88 | 89 | switch(type) 90 | { 91 | case SOUND_PCM: 92 | ASND_PauseVoice(voice, 1); 93 | break; 94 | 95 | case SOUND_OGG: 96 | PauseOgg(1); 97 | break; 98 | } 99 | #endif 100 | } 101 | 102 | void GuiSound::Resume() 103 | { 104 | #ifndef NO_SOUND 105 | if(voice < 0) 106 | return; 107 | 108 | switch(type) 109 | { 110 | case SOUND_PCM: 111 | ASND_PauseVoice(voice, 0); 112 | break; 113 | 114 | case SOUND_OGG: 115 | PauseOgg(0); 116 | break; 117 | } 118 | #endif 119 | } 120 | 121 | bool GuiSound::IsPlaying() 122 | { 123 | if(ASND_StatusVoice(voice) == SND_WORKING || ASND_StatusVoice(voice) == SND_WAITING) 124 | return true; 125 | else 126 | return false; 127 | } 128 | 129 | void GuiSound::SetVolume(int vol) 130 | { 131 | #ifndef NO_SOUND 132 | volume = vol; 133 | 134 | if(voice < 0) 135 | return; 136 | 137 | int newvol = 0.0255f*(volume*GCSettings.SFXVolume); 138 | 139 | switch(type) 140 | { 141 | case SOUND_PCM: 142 | ASND_ChangeVolumeVoice(voice, newvol, newvol); 143 | break; 144 | 145 | case SOUND_OGG: 146 | SetVolumeOgg(2.55f*(volume)); 147 | break; 148 | } 149 | #endif 150 | } 151 | 152 | void GuiSound::SetLoop(bool l) 153 | { 154 | loop = l; 155 | } 156 | -------------------------------------------------------------------------------- /source/images/battery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/battery.png -------------------------------------------------------------------------------- /source/images/battery_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/battery_bar.png -------------------------------------------------------------------------------- /source/images/battery_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/battery_red.png -------------------------------------------------------------------------------- /source/images/bg_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/bg_bottom.png -------------------------------------------------------------------------------- /source/images/bg_game_selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/bg_game_selection.png -------------------------------------------------------------------------------- /source/images/bg_game_selection_entry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/bg_game_selection_entry.png -------------------------------------------------------------------------------- /source/images/bg_options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/bg_options.png -------------------------------------------------------------------------------- /source/images/bg_options_entry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/bg_options_entry.png -------------------------------------------------------------------------------- /source/images/bg_preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/bg_preview.png -------------------------------------------------------------------------------- /source/images/bg_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/bg_top.png -------------------------------------------------------------------------------- /source/images/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button.png -------------------------------------------------------------------------------- /source/images/button_arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_arrow_down.png -------------------------------------------------------------------------------- /source/images/button_arrow_down_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_arrow_down_over.png -------------------------------------------------------------------------------- /source/images/button_arrow_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_arrow_left.png -------------------------------------------------------------------------------- /source/images/button_arrow_left_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_arrow_left_over.png -------------------------------------------------------------------------------- /source/images/button_arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_arrow_right.png -------------------------------------------------------------------------------- /source/images/button_arrow_right_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_arrow_right_over.png -------------------------------------------------------------------------------- /source/images/button_arrow_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_arrow_up.png -------------------------------------------------------------------------------- /source/images/button_arrow_up_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_arrow_up_over.png -------------------------------------------------------------------------------- /source/images/button_gamesave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_gamesave.png -------------------------------------------------------------------------------- /source/images/button_gamesave_blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_gamesave_blank.png -------------------------------------------------------------------------------- /source/images/button_gamesave_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_gamesave_over.png -------------------------------------------------------------------------------- /source/images/button_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_large.png -------------------------------------------------------------------------------- /source/images/button_large_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_large_over.png -------------------------------------------------------------------------------- /source/images/button_long.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_long.png -------------------------------------------------------------------------------- /source/images/button_long_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_long_over.png -------------------------------------------------------------------------------- /source/images/button_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_over.png -------------------------------------------------------------------------------- /source/images/button_prompt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_prompt.png -------------------------------------------------------------------------------- /source/images/button_prompt_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_prompt_over.png -------------------------------------------------------------------------------- /source/images/button_short.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_short.png -------------------------------------------------------------------------------- /source/images/button_short_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_short_over.png -------------------------------------------------------------------------------- /source/images/button_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_small.png -------------------------------------------------------------------------------- /source/images/button_small_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/button_small_over.png -------------------------------------------------------------------------------- /source/images/credits_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/credits_box.png -------------------------------------------------------------------------------- /source/images/dialogue_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/dialogue_box.png -------------------------------------------------------------------------------- /source/images/icon_dvd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_dvd.png -------------------------------------------------------------------------------- /source/images/icon_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_folder.png -------------------------------------------------------------------------------- /source/images/icon_game_cheats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_game_cheats.png -------------------------------------------------------------------------------- /source/images/icon_game_controllers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_game_controllers.png -------------------------------------------------------------------------------- /source/images/icon_game_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_game_delete.png -------------------------------------------------------------------------------- /source/images/icon_game_load.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_game_load.png -------------------------------------------------------------------------------- /source/images/icon_game_reset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_game_reset.png -------------------------------------------------------------------------------- /source/images/icon_game_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_game_save.png -------------------------------------------------------------------------------- /source/images/icon_game_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_game_screenshot.png -------------------------------------------------------------------------------- /source/images/icon_game_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_game_settings.png -------------------------------------------------------------------------------- /source/images/icon_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_home.png -------------------------------------------------------------------------------- /source/images/icon_sd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_sd.png -------------------------------------------------------------------------------- /source/images/icon_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings.png -------------------------------------------------------------------------------- /source/images/icon_settings_audio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_audio.png -------------------------------------------------------------------------------- /source/images/icon_settings_classic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_classic.png -------------------------------------------------------------------------------- /source/images/icon_settings_credits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_credits.png -------------------------------------------------------------------------------- /source/images/icon_settings_drc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_drc.png -------------------------------------------------------------------------------- /source/images/icon_settings_emulation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_emulation.png -------------------------------------------------------------------------------- /source/images/icon_settings_fastforward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_fastforward.png -------------------------------------------------------------------------------- /source/images/icon_settings_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_file.png -------------------------------------------------------------------------------- /source/images/icon_settings_gamecube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_gamecube.png -------------------------------------------------------------------------------- /source/images/icon_settings_hacks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_hacks.png -------------------------------------------------------------------------------- /source/images/icon_settings_justifier.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_justifier.png -------------------------------------------------------------------------------- /source/images/icon_settings_mappings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_mappings.png -------------------------------------------------------------------------------- /source/images/icon_settings_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_menu.png -------------------------------------------------------------------------------- /source/images/icon_settings_mouse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_mouse.png -------------------------------------------------------------------------------- /source/images/icon_settings_nunchuk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_nunchuk.png -------------------------------------------------------------------------------- /source/images/icon_settings_snescontroller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_snescontroller.png -------------------------------------------------------------------------------- /source/images/icon_settings_superscope.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_superscope.png -------------------------------------------------------------------------------- /source/images/icon_settings_video.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_video.png -------------------------------------------------------------------------------- /source/images/icon_settings_wiimote.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_wiimote.png -------------------------------------------------------------------------------- /source/images/icon_settings_wiiupro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_settings_wiiupro.png -------------------------------------------------------------------------------- /source/images/icon_usb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/icon_usb.png -------------------------------------------------------------------------------- /source/images/keyboard_key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/keyboard_key.png -------------------------------------------------------------------------------- /source/images/keyboard_key_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/keyboard_key_over.png -------------------------------------------------------------------------------- /source/images/keyboard_largekey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/keyboard_largekey.png -------------------------------------------------------------------------------- /source/images/keyboard_largekey_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/keyboard_largekey_over.png -------------------------------------------------------------------------------- /source/images/keyboard_mediumkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/keyboard_mediumkey.png -------------------------------------------------------------------------------- /source/images/keyboard_mediumkey_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/keyboard_mediumkey_over.png -------------------------------------------------------------------------------- /source/images/keyboard_textbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/keyboard_textbox.png -------------------------------------------------------------------------------- /source/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/logo.png -------------------------------------------------------------------------------- /source/images/logo_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/logo_over.png -------------------------------------------------------------------------------- /source/images/player1_point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/player1_point.png -------------------------------------------------------------------------------- /source/images/player2_point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/player2_point.png -------------------------------------------------------------------------------- /source/images/player3_point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/player3_point.png -------------------------------------------------------------------------------- /source/images/player4_point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/player4_point.png -------------------------------------------------------------------------------- /source/images/progressbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/progressbar.png -------------------------------------------------------------------------------- /source/images/progressbar_empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/progressbar_empty.png -------------------------------------------------------------------------------- /source/images/progressbar_outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/progressbar_outline.png -------------------------------------------------------------------------------- /source/images/screen_position.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/screen_position.png -------------------------------------------------------------------------------- /source/images/scrollbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/scrollbar.png -------------------------------------------------------------------------------- /source/images/scrollbar_arrowdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/scrollbar_arrowdown.png -------------------------------------------------------------------------------- /source/images/scrollbar_arrowdown_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/scrollbar_arrowdown_over.png -------------------------------------------------------------------------------- /source/images/scrollbar_arrowup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/scrollbar_arrowup.png -------------------------------------------------------------------------------- /source/images/scrollbar_arrowup_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/scrollbar_arrowup_over.png -------------------------------------------------------------------------------- /source/images/scrollbar_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/scrollbar_box.png -------------------------------------------------------------------------------- /source/images/scrollbar_box_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/scrollbar_box_over.png -------------------------------------------------------------------------------- /source/images/throbber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/images/throbber.png -------------------------------------------------------------------------------- /source/input.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * softdev July 2006 5 | * crunchy2 May-June 2007 6 | * Michniewski 2008 7 | * Tantric 2008-2022 8 | * 9 | * input.h 10 | * 11 | * Controller management 12 | ***************************************************************************/ 13 | 14 | #ifndef _INPUT_H_ 15 | #define _INPUT_H_ 16 | 17 | #include 18 | #include 19 | #include "utils/wiidrc.h" 20 | 21 | #define PI 3.14159265f 22 | #define PADCAL 50 23 | #define WIIDRCCAL 20 24 | #define MAXJP 12 // # of mappable controller buttons 25 | 26 | extern u32 btnmap[4][6][12]; 27 | extern int playerMapping[4]; 28 | 29 | void ResetControls(int cc = -1, int wc = -1); 30 | void ReportButtons (); 31 | void SetControllers (); 32 | void SetDefaultButtonMap (); 33 | bool MenuRequested(); 34 | void SetupPads(); 35 | void UpdatePads(); 36 | #ifdef HW_RVL 37 | char* GetUSBControllerInfo(); 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /source/lang/en.lang: -------------------------------------------------------------------------------- 1 | msgid " " 2 | msgstr "" 3 | -------------------------------------------------------------------------------- /source/lang/nl.lang: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/lang/nl.lang -------------------------------------------------------------------------------- /source/mem2.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * Tantric 2010-2022 5 | * 6 | * mem2.cpp 7 | * 8 | * MEM2 memory allocator 9 | ***************************************************************************/ 10 | 11 | #ifdef HW_RVL 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | static heap_cntrl mem2_heap; 19 | 20 | u32 InitMem2Manager () 21 | { 22 | int size = (20*1024*1024); 23 | u32 level; 24 | _CPU_ISR_Disable(level); 25 | size &= ~0x1f; // round down, because otherwise we may exceed the area 26 | void *mem2_heap_ptr = (void *)((u32)SYS_GetArena2Hi()-size); 27 | SYS_SetArena2Hi(mem2_heap_ptr); 28 | _CPU_ISR_Restore(level); 29 | size = __lwp_heap_init(&mem2_heap, mem2_heap_ptr, size, 32); 30 | return size; 31 | } 32 | 33 | void* mem2_malloc(u32 size) 34 | { 35 | return __lwp_heap_allocate(&mem2_heap, size); 36 | } 37 | 38 | bool mem2_free(void *ptr) 39 | { 40 | return __lwp_heap_free(&mem2_heap, ptr); 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /source/mem2.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * Tantric 2010-2022 5 | * 6 | * mem2.h 7 | * 8 | * MEM2 memory allocator 9 | ***************************************************************************/ 10 | 11 | #ifdef HW_RVL 12 | 13 | #ifndef _MEM2MANAGER_H_ 14 | #define _MEM2MANAGER_H_ 15 | 16 | u32 InitMem2Manager (); 17 | void* mem2_malloc(u32 size); 18 | bool mem2_free(void *ptr); 19 | 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /source/menu.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * Tantric 2008-2022 5 | * Tanooki 2019-2023 6 | * 7 | * menu.h 8 | * 9 | * Menu flow routines - handles all menu logic 10 | ***************************************************************************/ 11 | 12 | #ifndef _MENU_H_ 13 | #define _MENU_H_ 14 | 15 | #include 16 | 17 | void InitGUIThreads(); 18 | void MainMenu (int menuitem); 19 | void ErrorPrompt(const char * msg); 20 | int ErrorPromptRetry(const char * msg); 21 | void InfoPrompt(const char * msg); 22 | void ShowAction (const char *msg); 23 | void CancelAction(); 24 | void ShowProgress (const char *msg, int done, int total); 25 | void ChangeLanguage(); 26 | 27 | extern u8 * bg_music; 28 | extern u32 bg_music_size; 29 | 30 | enum 31 | { 32 | MENU_EXIT = -1, 33 | MENU_NONE, 34 | MENU_SETTINGS, 35 | MENU_SETTINGS_FILE, 36 | MENU_SETTINGS_MENU, 37 | MENU_SETTINGS_EMULATION, 38 | MENU_GAMESELECTION, 39 | MENU_GAME, 40 | MENU_GAME_SAVE, 41 | MENU_GAME_LOAD, 42 | MENU_GAME_DELETE, 43 | MENU_GAMESETTINGS, 44 | MENU_GAMESETTINGS_MAPPINGS, 45 | MENU_GAMESETTINGS_MAPPINGS_CTRL, 46 | MENU_GAMESETTINGS_MAPPINGS_FASTFORWARD, 47 | MENU_GAMESETTINGS_MAPPINGS_MAP, 48 | MENU_GAMESETTINGS_VIDEO, 49 | MENU_GAMESETTINGS_AUDIO, 50 | MENU_GAMESETTINGS_CHEATS, 51 | MENU_GAMESETTINGS_HACKS 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /source/preferences.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * Tantric 2008-2022 5 | * Tanooki 2019-2023 6 | * 7 | * preferences.h 8 | * 9 | * Preferences save/load to XML file 10 | ***************************************************************************/ 11 | 12 | void FixInvalidSettings(); 13 | void DefaultSettings(); 14 | bool SavePrefs (bool silent); 15 | bool LoadPrefs (); 16 | -------------------------------------------------------------------------------- /source/snes9x/65c816.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _65C816_H_ 8 | #define _65C816_H_ 9 | 10 | #define Carry 1 11 | #define Zero 2 12 | #define IRQ 4 13 | #define Decimal 8 14 | #define IndexFlag 16 15 | #define MemoryFlag 32 16 | #define Overflow 64 17 | #define Negative 128 18 | #define Emulation 256 19 | 20 | #define SetCarry() (ICPU._Carry = 1) 21 | #define ClearCarry() (ICPU._Carry = 0) 22 | #define SetZero() (ICPU._Zero = 0) 23 | #define ClearZero() (ICPU._Zero = 1) 24 | #define SetIRQ() (Registers.PL |= IRQ) 25 | #define ClearIRQ() (Registers.PL &= ~IRQ) 26 | #define SetDecimal() (Registers.PL |= Decimal) 27 | #define ClearDecimal() (Registers.PL &= ~Decimal) 28 | #define SetIndex() (Registers.PL |= IndexFlag) 29 | #define ClearIndex() (Registers.PL &= ~IndexFlag) 30 | #define SetMemory() (Registers.PL |= MemoryFlag) 31 | #define ClearMemory() (Registers.PL &= ~MemoryFlag) 32 | #define SetOverflow() (ICPU._Overflow = 1) 33 | #define ClearOverflow() (ICPU._Overflow = 0) 34 | #define SetNegative() (ICPU._Negative = 0x80) 35 | #define ClearNegative() (ICPU._Negative = 0) 36 | 37 | #define CheckCarry() (ICPU._Carry) 38 | #define CheckZero() (ICPU._Zero == 0) 39 | #define CheckIRQ() (Registers.PL & IRQ) 40 | #define CheckDecimal() (Registers.PL & Decimal) 41 | #define CheckIndex() (Registers.PL & IndexFlag) 42 | #define CheckMemory() (Registers.PL & MemoryFlag) 43 | #define CheckOverflow() (ICPU._Overflow) 44 | #define CheckNegative() (ICPU._Negative & 0x80) 45 | #define CheckEmulation() (Registers.P.W & Emulation) 46 | 47 | #define SetFlags(f) (Registers.P.W |= (f)) 48 | #define ClearFlags(f) (Registers.P.W &= ~(f)) 49 | #define CheckFlag(f) (Registers.PL & (f)) 50 | 51 | typedef union 52 | { 53 | #ifdef LSB_FIRST 54 | struct { uint8 l, h; } B; 55 | #else 56 | struct { uint8 h, l; } B; 57 | #endif 58 | uint16 W; 59 | } pair; 60 | 61 | typedef union 62 | { 63 | #ifdef LSB_FIRST 64 | struct { uint8 xPCl, xPCh, xPB, z; } B; 65 | struct { uint16 xPC, d; } W; 66 | #else 67 | struct { uint8 z, xPB, xPCh, xPCl; } B; 68 | struct { uint16 d, xPC; } W; 69 | #endif 70 | uint32 xPBPC; 71 | } PC_t; 72 | 73 | struct SRegisters 74 | { 75 | uint8 DB; 76 | pair P; 77 | pair A; 78 | pair D; 79 | pair S; 80 | pair X; 81 | pair Y; 82 | PC_t PC; 83 | }; 84 | 85 | #define AL A.B.l 86 | #define AH A.B.h 87 | #define XL X.B.l 88 | #define XH X.B.h 89 | #define YL Y.B.l 90 | #define YH Y.B.h 91 | #define SL S.B.l 92 | #define SH S.B.h 93 | #define DL D.B.l 94 | #define DH D.B.h 95 | #define PL P.B.l 96 | #define PH P.B.h 97 | #define PBPC PC.xPBPC 98 | #define PCw PC.W.xPC 99 | #define PCh PC.B.xPCh 100 | #define PCl PC.B.xPCl 101 | #define PB PC.B.xPB 102 | 103 | extern struct SRegisters Registers; 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /source/snes9x/apu/SNES_SPC_state.cpp: -------------------------------------------------------------------------------- 1 | // SPC emulation state save/load: copy_state(), save_spc() 2 | // Separate file to avoid linking in unless needed 3 | 4 | // snes_spc 0.9.0. http://www.slack.net/‾ant/ 5 | 6 | #include "SNES_SPC.h" 7 | 8 | #if !SPC_NO_COPY_STATE_FUNCS 9 | 10 | #include 11 | 12 | /* Copyright (C) 2004-2007 Shay Green. This module is free software; you 13 | can redistribute it and/or modify it under the terms of the GNU Lesser 14 | General Public License as published by the Free Software Foundation; either 15 | version 2.1 of the License, or (at your option) any later version. This 16 | module is distributed in the hope that it will be useful, but WITHOUT ANY 17 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 19 | details. You should have received a copy of the GNU Lesser General Public 20 | License along with this module; if not, write to the Free Software Foundation, 21 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #include 24 | #include "blargg_source.h" 25 | 26 | #define RAM (m.ram.ram) 27 | #define REGS (m.smp_regs [0]) 28 | #define REGS_IN (m.smp_regs [1]) 29 | 30 | void SNES_SPC::save_regs( uint8_t out [reg_count] ) 31 | { 32 | // Use current timer counter values 33 | for ( int i = 0; i < timer_count; i++ ) 34 | out [r_t0out + i] = m.timers [i].counter; 35 | 36 | // Last written values 37 | memcpy( out, REGS, r_t0out ); 38 | } 39 | 40 | void SNES_SPC::init_header( void* spc_out ) 41 | { 42 | spc_file_t* const spc = (spc_file_t*) spc_out; 43 | 44 | spc->has_id666 = 26; // has none 45 | spc->version = 30; 46 | memcpy( spc, signature, sizeof spc->signature ); 47 | memset( spc->text, 0, sizeof spc->text ); 48 | } 49 | 50 | void SNES_SPC::save_spc( void* spc_out ) 51 | { 52 | spc_file_t* const spc = (spc_file_t*) spc_out; 53 | 54 | // CPU 55 | spc->pcl = (uint8_t) (m.cpu_regs.pc >> 0); 56 | spc->pch = (uint8_t) (m.cpu_regs.pc >> 8); 57 | spc->a = m.cpu_regs.a; 58 | spc->x = m.cpu_regs.x; 59 | spc->y = m.cpu_regs.y; 60 | spc->psw = m.cpu_regs.psw; 61 | spc->sp = m.cpu_regs.sp; 62 | 63 | // RAM, ROM 64 | memcpy( spc->ram, RAM, sizeof spc->ram ); 65 | if ( m.rom_enabled ) 66 | memcpy( spc->ram + rom_addr, m.hi_ram, sizeof m.hi_ram ); 67 | memset( spc->unused, 0, sizeof spc->unused ); 68 | memcpy( spc->ipl_rom, m.rom, sizeof spc->ipl_rom ); 69 | 70 | // SMP registers 71 | save_regs( &spc->ram [0xF0] ); 72 | int i; 73 | for ( i = 0; i < port_count; i++ ) 74 | spc->ram [0xF0 + r_cpuio0 + i] = REGS_IN [r_cpuio0 + i]; 75 | 76 | // DSP registers 77 | for ( i = 0; i < SPC_DSP::register_count; i++ ) 78 | spc->dsp [i] = dsp.read( i ); 79 | } 80 | 81 | #undef IF_0_THEN_256 82 | #define IF_0_THEN_256( n ) ((uint8_t) ((n) - 1) + 1) 83 | void SNES_SPC::copy_state( unsigned char** io, copy_func_t copy ) 84 | { 85 | SPC_State_Copier copier( io, copy ); 86 | 87 | // Make state data more readable by putting 64K RAM, 16 SMP registers, 88 | // then DSP (with its 128 registers) first 89 | 90 | // RAM 91 | enable_rom( 0 ); // will get re-enabled if necessary in regs_loaded() below 92 | copier.copy( RAM, 0x10000 ); 93 | 94 | { 95 | // SMP registers 96 | uint8_t regs [reg_count]; 97 | uint8_t regs_in [reg_count]; 98 | 99 | memcpy( regs, REGS, reg_count ); 100 | memcpy( regs_in, REGS_IN, reg_count ); 101 | 102 | copier.copy( regs, sizeof regs ); 103 | copier.copy( regs_in, sizeof regs_in ); 104 | 105 | memcpy( REGS, regs, reg_count); 106 | memcpy( REGS_IN, regs_in, reg_count ); 107 | 108 | enable_rom( REGS [r_control] & 0x80 ); 109 | } 110 | 111 | // CPU registers 112 | SPC_COPY( uint16_t, m.cpu_regs.pc ); 113 | SPC_COPY( uint8_t, m.cpu_regs.a ); 114 | SPC_COPY( uint8_t, m.cpu_regs.x ); 115 | SPC_COPY( uint8_t, m.cpu_regs.y ); 116 | SPC_COPY( uint8_t, m.cpu_regs.psw ); 117 | SPC_COPY( uint8_t, m.cpu_regs.sp ); 118 | copier.extra(); 119 | 120 | SPC_COPY( int16_t, m.spc_time ); 121 | SPC_COPY( int16_t, m.dsp_time ); 122 | 123 | // DSP 124 | dsp.copy_state( io, copy ); 125 | 126 | // Timers 127 | for ( int i = 0; i < timer_count; i++ ) 128 | { 129 | Timer* t = &m.timers [i]; 130 | t->period = IF_0_THEN_256( REGS [r_t0target + i] ); 131 | t->enabled = REGS [r_control] >> i & 1; 132 | SPC_COPY( int16_t, t->next_time ); 133 | SPC_COPY( uint8_t, t->divider ); 134 | SPC_COPY( uint8_t, t->counter ); 135 | copier.extra(); 136 | } 137 | 138 | set_tempo( m.tempo ); 139 | 140 | copier.extra(); 141 | } 142 | #endif 143 | -------------------------------------------------------------------------------- /source/snes9x/apu/SPC_Filter.cpp: -------------------------------------------------------------------------------- 1 | // snes_spc 0.9.0. http://www.slack.net/~ant/ 2 | 3 | #include "SPC_Filter.h" 4 | 5 | #include 6 | 7 | /* Copyright (C) 2007 Shay Green. This module is free software; you 8 | can redistribute it and/or modify it under the terms of the GNU Lesser 9 | General Public License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. This 11 | module is distributed in the hope that it will be useful, but WITHOUT ANY 12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 14 | details. You should have received a copy of the GNU Lesser General Public 15 | License along with this module; if not, write to the Free Software Foundation, 16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ 17 | 18 | #include "blargg_source.h" 19 | 20 | void SPC_Filter::clear() { memset( ch, 0, sizeof ch ); } 21 | 22 | SPC_Filter::SPC_Filter() 23 | { 24 | gain = gain_unit; 25 | bass = bass_norm; 26 | clear(); 27 | } 28 | 29 | void SPC_Filter::run( short* io, int count ) 30 | { 31 | require( (count & 1) == 0 ); // must be even 32 | 33 | int const gain = this->gain; 34 | int const bass = this->bass; 35 | chan_t* c = &ch [2]; 36 | do 37 | { 38 | // cache in registers 39 | int sum = (--c)->sum; 40 | int pp1 = c->pp1; 41 | int p1 = c->p1; 42 | 43 | for ( int i = 0; i < count; i += 2 ) 44 | { 45 | // Low-pass filter (two point FIR with coeffs 0.25, 0.75) 46 | int f = io [i] + p1; 47 | p1 = io [i] * 3; 48 | 49 | // High-pass filter ("leaky integrator") 50 | int delta = f - pp1; 51 | pp1 = f; 52 | int s = sum >> (gain_bits + 2); 53 | sum += (delta * gain) - (sum >> bass); 54 | 55 | // Clamp to 16 bits 56 | if ( (short) s != s ) 57 | s = (s >> 31) ^ 0x7FFF; 58 | 59 | io [i] = (short) s; 60 | } 61 | 62 | c->p1 = p1; 63 | c->pp1 = pp1; 64 | c->sum = sum; 65 | ++io; 66 | } 67 | while ( c != ch ); 68 | } 69 | -------------------------------------------------------------------------------- /source/snes9x/apu/SPC_Filter.h: -------------------------------------------------------------------------------- 1 | // Simple low-pass and high-pass filter to better match sound output of a SNES 2 | 3 | // snes_spc 0.9.0 4 | #ifndef SPC_FILTER_H 5 | #define SPC_FILTER_H 6 | 7 | #include "blargg_common.h" 8 | 9 | struct SPC_Filter { 10 | public: 11 | 12 | // Filters count samples of stereo sound in place. Count must be a multiple of 2. 13 | typedef short sample_t; 14 | void run( sample_t* io, int count ); 15 | 16 | // Optional features 17 | 18 | // Clears filter to silence 19 | void clear(); 20 | 21 | // Sets gain (volume), where gain_unit is normal. Gains greater than gain_unit 22 | // are fine, since output is clamped to 16-bit sample range. 23 | enum { gain_unit = 0x100 }; 24 | void set_gain( int gain ); 25 | 26 | // Sets amount of bass (logarithmic scale) 27 | enum { bass_none = 0 }; 28 | enum { bass_norm = 8 }; // normal amount 29 | enum { bass_max = 31 }; 30 | void set_bass( int bass ); 31 | 32 | public: 33 | SPC_Filter(); 34 | BLARGG_DISABLE_NOTHROW 35 | private: 36 | enum { gain_bits = 8 }; 37 | int gain; 38 | int bass; 39 | struct chan_t { int p1, pp1, sum; }; 40 | chan_t ch [2]; 41 | }; 42 | 43 | inline void SPC_Filter::set_gain( int g ) { gain = g; } 44 | 45 | inline void SPC_Filter::set_bass( int b ) { bass = b; } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /source/snes9x/apu/apu.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _APU_H_ 8 | #define _APU_H_ 9 | 10 | #include "../snes9x.h" 11 | #include "SNES_SPC.h" 12 | 13 | typedef void (*apu_callback) (void *); 14 | 15 | #define SPC_SAVE_STATE_BLOCK_SIZE (SNES_SPC::state_size + 8) 16 | 17 | bool8 S9xInitAPU (void); 18 | void S9xDeinitAPU (void); 19 | void S9xResetAPU (void); 20 | void S9xSoftResetAPU (void); 21 | uint8 S9xAPUReadPort (int); 22 | void S9xAPUWritePort (int, uint8); 23 | void S9xAPUExecute (void); 24 | void S9xAPUEndScanline (void); 25 | void S9xAPUSetReferenceTime (int32); 26 | void S9xAPUTimingSetSpeedup (int); 27 | void S9xAPUAllowTimeOverflow (bool); 28 | void S9xAPULoadState (uint8 *); 29 | void S9xAPUSaveState (uint8 *); 30 | void S9xDumpSPCSnapshot (void); 31 | bool8 S9xSPCDump (const char *); 32 | 33 | bool8 S9xInitSound (int, int); 34 | bool8 S9xOpenSoundDevice (void); 35 | 36 | bool8 S9xSyncSound (void); 37 | int S9xGetSampleCount (void); 38 | void S9xSetSoundControl (uint8); 39 | void S9xSetSoundMute (bool8); 40 | void S9xLandSamples (void); 41 | void S9xFinalizeSamples (void); 42 | void S9xClearSamples (void); 43 | bool8 S9xMixSamples (uint8 *, int); 44 | void S9xSetSamplesAvailableCallback (apu_callback, void *); 45 | void S9xUpdateDynamicRate (double rate); 46 | 47 | extern SNES_SPC *spc_core; 48 | 49 | #define DSP_INTERPOLATION_NONE 0 50 | #define DSP_INTERPOLATION_LINEAR 1 51 | #define DSP_INTERPOLATION_GAUSSIAN 2 52 | #define DSP_INTERPOLATION_CUBIC 3 53 | #define DSP_INTERPOLATION_SINC 4 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /source/snes9x/apu/blargg_config.h: -------------------------------------------------------------------------------- 1 | // snes_spc 0.9.0 user configuration file. Don't replace when updating library. 2 | 3 | // snes_spc 0.9.0 4 | #ifndef BLARGG_CONFIG_H 5 | #define BLARGG_CONFIG_H 6 | 7 | // Uncomment to disable debugging checks 8 | //#define NDEBUG 1 9 | 10 | // Uncomment to enable platform-specific (and possibly non-portable) optimizations 11 | //#define BLARGG_NONPORTABLE 1 12 | 13 | // Uncomment if automatic byte-order determination doesn't work 14 | //#define BLARGG_BIG_ENDIAN 1 15 | 16 | // Uncomment if you get errors in the bool section of blargg_common.h 17 | //#define BLARGG_COMPILER_HAS_BOOL 1 18 | 19 | // Use standard config.h if present 20 | #ifdef HAVE_CONFIG_H 21 | #include "config.h" 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /source/snes9x/apu/blargg_source.h: -------------------------------------------------------------------------------- 1 | /* Included at the beginning of library source files, after all other #include lines. 2 | Sets up helpful macros and services used in my source code. They don't need 3 | module an annoying module prefix on their names since they are defined after 4 | all other #include lines. */ 5 | 6 | // snes_spc 0.9.0 7 | #ifndef BLARGG_SOURCE_H 8 | #define BLARGG_SOURCE_H 9 | 10 | // If debugging is enabled, abort program if expr is false. Meant for checking 11 | // internal state and consistency. A failed assertion indicates a bug in the module. 12 | // void assert( bool expr ); 13 | #include 14 | 15 | // If debugging is enabled and expr is false, abort program. Meant for checking 16 | // caller-supplied parameters and operations that are outside the control of the 17 | // module. A failed requirement indicates a bug outside the module. 18 | // void require( bool expr ); 19 | #undef require 20 | #define require( expr ) assert( expr ) 21 | 22 | // Like printf() except output goes to debug log file. Might be defined to do 23 | // nothing (not even evaluate its arguments). 24 | // void dprintf( const char* format, ... ); 25 | static inline void blargg_dprintf_( const char*, ... ) { } 26 | #undef dprintf 27 | #define dprintf (1) ? (void) 0 : blargg_dprintf_ 28 | 29 | // If enabled, evaluate expr and if false, make debug log entry with source file 30 | // and line. Meant for finding situations that should be examined further, but that 31 | // don't indicate a problem. In all cases, execution continues normally. 32 | #undef check 33 | #define check( expr ) ((void) 0) 34 | 35 | // If expr yields error string, return it from current function, otherwise continue. 36 | #undef RETURN_ERR 37 | #define RETURN_ERR( expr ) do { \ 38 | blargg_err_t blargg_return_err_ = (expr); \ 39 | if ( blargg_return_err_ ) return blargg_return_err_; \ 40 | } while ( 0 ) 41 | 42 | // If ptr is 0, return out of memory error string. 43 | #undef CHECK_ALLOC 44 | #define CHECK_ALLOC( ptr ) do { if ( (ptr) == 0 ) return "Out of memory"; } while ( 0 ) 45 | 46 | // Avoid any macros which evaluate their arguments multiple times 47 | #undef min 48 | #undef max 49 | 50 | #define DEF_MIN_MAX( type ) \ 51 | static inline type min( type x, type y ) { if ( x < y ) return x; return y; }\ 52 | static inline type max( type x, type y ) { if ( y < x ) return x; return y; } 53 | 54 | DEF_MIN_MAX( int ) 55 | DEF_MIN_MAX( unsigned ) 56 | DEF_MIN_MAX( long ) 57 | DEF_MIN_MAX( unsigned long ) 58 | DEF_MIN_MAX( float ) 59 | DEF_MIN_MAX( double ) 60 | 61 | #undef DEF_MIN_MAX 62 | 63 | /* 64 | // using const references generates crappy code, and I am currenly only using these 65 | // for built-in types, so they take arguments by value 66 | 67 | // TODO: remove 68 | inline int min( int x, int y ) 69 | template 70 | inline T min( T x, T y ) 71 | { 72 | if ( x < y ) 73 | return x; 74 | return y; 75 | } 76 | 77 | template 78 | inline T max( T x, T y ) 79 | { 80 | if ( x < y ) 81 | return y; 82 | return x; 83 | } 84 | */ 85 | 86 | // TODO: good idea? bad idea? 87 | #undef byte 88 | #define byte byte_ 89 | typedef unsigned char byte; 90 | 91 | // deprecated 92 | #define BLARGG_CHECK_ALLOC CHECK_ALLOC 93 | #define BLARGG_RETURN_ERR RETURN_ERR 94 | 95 | // BLARGG_SOURCE_BEGIN: If defined, #included, allowing redefition of dprintf and check 96 | #ifdef BLARGG_SOURCE_BEGIN 97 | #include BLARGG_SOURCE_BEGIN 98 | #endif 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /source/snes9x/bml.h: -------------------------------------------------------------------------------- 1 | #ifndef __BML_H 2 | #define __BML_H 3 | #include 4 | #include 5 | #include 6 | 7 | struct bml_node 8 | { 9 | enum node_type { 10 | CHILD, 11 | ATTRIBUTE 12 | }; 13 | 14 | bml_node(); 15 | bool parse_file(std::string filename); 16 | void parse(std::ifstream &fd); 17 | bml_node *find_subnode(std::string name); 18 | void print(); 19 | 20 | std::string name; 21 | std::string data; 22 | int depth; 23 | std::vector child; 24 | node_type type; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /source/snes9x/bsx.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _BSX_H_ 8 | #define _BSX_H_ 9 | 10 | #include 11 | 12 | struct SBSX 13 | { 14 | bool8 dirty; // Changed register values 15 | bool8 dirty2; // Changed register values 16 | bool8 bootup; // Start in bios mapping 17 | bool8 flash_enable; // Flash state 18 | bool8 write_enable; // ROM write protection 19 | bool8 read_enable; // Allow card vendor reading 20 | uint32 flash_command; // Flash command 21 | uint32 old_write; // Previous flash write address 22 | uint32 new_write; // Current flash write address 23 | uint8 out_index; 24 | uint8 output[32]; 25 | uint8 PPU[32]; 26 | uint8 MMC[16]; 27 | uint8 prevMMC[16]; 28 | uint8 test2192[32]; 29 | 30 | bool flash_csr; 31 | bool flash_gsr; 32 | bool flash_bsr; 33 | bool flash_cmd_done; 34 | 35 | std::ifstream sat_stream1; 36 | std::ifstream sat_stream2; 37 | 38 | bool sat_pf_latch1_enable, sat_dt_latch1_enable; 39 | bool sat_pf_latch2_enable, sat_dt_latch2_enable; 40 | 41 | bool sat_stream1_loaded, sat_stream2_loaded; 42 | bool sat_stream1_first, sat_stream2_first; 43 | uint8 sat_stream1_count, sat_stream2_count; 44 | uint16 sat_stream1_queue, sat_stream2_queue; 45 | }; 46 | 47 | extern struct SBSX BSX; 48 | 49 | uint8 S9xGetBSX (uint32); 50 | void S9xSetBSX (uint8, uint32); 51 | uint8 S9xGetBSXPPU (uint16); 52 | void S9xSetBSXPPU (uint8, uint16); 53 | uint8 * S9xGetBasePointerBSX (uint32); 54 | void S9xInitBSX (void); 55 | void S9xResetBSX (void); 56 | void S9xBSXPostLoadState (void); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /source/snes9x/c4.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #include 8 | #include "snes9x.h" 9 | #include "memmap.h" 10 | 11 | #define C4_PI 3.14159265 12 | 13 | int16 C4WFXVal; 14 | int16 C4WFYVal; 15 | int16 C4WFZVal; 16 | int16 C4WFX2Val; 17 | int16 C4WFY2Val; 18 | int16 C4WFDist; 19 | int16 C4WFScale; 20 | int16 C41FXVal; 21 | int16 C41FYVal; 22 | int16 C41FAngleRes; 23 | int16 C41FDist; 24 | int16 C41FDistVal; 25 | 26 | static double tanval; 27 | static double c4x, c4y, c4z; 28 | static double c4x2, c4y2, c4z2; 29 | 30 | 31 | void C4TransfWireFrame (void) 32 | { 33 | c4x = (double) C4WFXVal; 34 | c4y = (double) C4WFYVal; 35 | c4z = (double) C4WFZVal - 0x95; 36 | 37 | // Rotate X 38 | tanval = -(double) C4WFX2Val * C4_PI * 2 / 128; 39 | c4y2 = c4y * cos(tanval) - c4z * sin(tanval); 40 | c4z2 = c4y * sin(tanval) + c4z * cos(tanval); 41 | 42 | // Rotate Y 43 | tanval = -(double) C4WFY2Val * C4_PI * 2 / 128; 44 | c4x2 = c4x * cos(tanval) + c4z2 * sin(tanval); 45 | c4z = c4x * -sin(tanval) + c4z2 * cos(tanval); 46 | 47 | // Rotate Z 48 | tanval = -(double) C4WFDist * C4_PI * 2 / 128; 49 | c4x = c4x2 * cos(tanval) - c4y2 * sin(tanval); 50 | c4y = c4x2 * sin(tanval) + c4y2 * cos(tanval); 51 | 52 | // Scale 53 | C4WFXVal = (int16) (c4x * (double) C4WFScale / (0x90 * (c4z + 0x95)) * 0x95); 54 | C4WFYVal = (int16) (c4y * (double) C4WFScale / (0x90 * (c4z + 0x95)) * 0x95); 55 | } 56 | 57 | void C4TransfWireFrame2 (void) 58 | { 59 | c4x = (double) C4WFXVal; 60 | c4y = (double) C4WFYVal; 61 | c4z = (double) C4WFZVal; 62 | 63 | // Rotate X 64 | tanval = -(double) C4WFX2Val * C4_PI * 2 / 128; 65 | c4y2 = c4y * cos(tanval) - c4z * sin(tanval); 66 | c4z2 = c4y * sin(tanval) + c4z * cos(tanval); 67 | 68 | // Rotate Y 69 | tanval = -(double) C4WFY2Val * C4_PI * 2 / 128; 70 | c4x2 = c4x * cos(tanval) + c4z2 * sin(tanval); 71 | c4z = c4x * -sin(tanval) + c4z2 * cos(tanval); 72 | 73 | // Rotate Z 74 | tanval = -(double) C4WFDist * C4_PI * 2 / 128; 75 | c4x = c4x2 * cos(tanval) - c4y2 * sin(tanval); 76 | c4y = c4x2 * sin(tanval) + c4y2 * cos(tanval); 77 | 78 | // Scale 79 | C4WFXVal = (int16) (c4x * (double) C4WFScale / 0x100); 80 | C4WFYVal = (int16) (c4y * (double) C4WFScale / 0x100); 81 | } 82 | 83 | void C4CalcWireFrame (void) 84 | { 85 | C4WFXVal = C4WFX2Val - C4WFXVal; 86 | C4WFYVal = C4WFY2Val - C4WFYVal; 87 | 88 | if (abs(C4WFXVal) > abs(C4WFYVal)) 89 | { 90 | C4WFDist = abs(C4WFXVal) + 1; 91 | C4WFYVal = (int16) (256 * (double) C4WFYVal / abs(C4WFXVal)); 92 | if (C4WFXVal < 0) 93 | C4WFXVal = -256; 94 | else 95 | C4WFXVal = 256; 96 | } 97 | else 98 | { 99 | if (C4WFYVal != 0) 100 | { 101 | C4WFDist = abs(C4WFYVal) + 1; 102 | C4WFXVal = (int16) (256 * (double) C4WFXVal / abs(C4WFYVal)); 103 | if (C4WFYVal < 0) 104 | C4WFYVal = -256; 105 | else 106 | C4WFYVal = 256; 107 | } 108 | else 109 | C4WFDist = 0; 110 | } 111 | } 112 | 113 | void C4Op1F (void) 114 | { 115 | if (C41FXVal == 0) 116 | { 117 | if (C41FYVal > 0) 118 | C41FAngleRes = 0x80; 119 | else 120 | C41FAngleRes = 0x180; 121 | } 122 | else 123 | { 124 | tanval = (double) C41FYVal / C41FXVal; 125 | C41FAngleRes = (int16) (atan(tanval) / (C4_PI * 2) * 512); 126 | if (C41FXVal< 0) 127 | C41FAngleRes += 0x100; 128 | C41FAngleRes &= 0x1FF; 129 | } 130 | } 131 | 132 | void C4Op15 (void) 133 | { 134 | tanval = sqrt((double) C41FYVal * C41FYVal + (double) C41FXVal * C41FXVal); 135 | C41FDist = (int16) tanval; 136 | } 137 | 138 | void C4Op0D (void) 139 | { 140 | tanval = sqrt((double) C41FYVal * C41FYVal + (double) C41FXVal * C41FXVal); 141 | tanval = C41FDistVal / tanval; 142 | C41FYVal = (int16) (C41FYVal * tanval * 0.99); 143 | C41FXVal = (int16) (C41FXVal * tanval * 0.98); 144 | } 145 | 146 | uint8 * S9xGetBasePointerC4 (uint16 Address) 147 | { 148 | if (Address >= 0x7f40 && Address <= 0x7f5e) 149 | return (NULL); 150 | return (Memory.C4RAM - 0x6000); 151 | } 152 | 153 | uint8 * S9xGetMemPointerC4 (uint16 Address) 154 | { 155 | if (Address >= 0x7f40 && Address <= 0x7f5e) 156 | return (NULL); 157 | return (Memory.C4RAM - 0x6000 + (Address & 0xffff)); 158 | } 159 | -------------------------------------------------------------------------------- /source/snes9x/c4.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _C4_H_ 8 | #define _C4_H_ 9 | 10 | extern int16 C4WFXVal; 11 | extern int16 C4WFYVal; 12 | extern int16 C4WFZVal; 13 | extern int16 C4WFX2Val; 14 | extern int16 C4WFY2Val; 15 | extern int16 C4WFDist; 16 | extern int16 C4WFScale; 17 | extern int16 C41FXVal; 18 | extern int16 C41FYVal; 19 | extern int16 C41FAngleRes; 20 | extern int16 C41FDist; 21 | extern int16 C41FDistVal; 22 | 23 | void C4TransfWireFrame (void); 24 | void C4TransfWireFrame2 (void); 25 | void C4CalcWireFrame (void); 26 | void C4Op0D (void); 27 | void C4Op15 (void); 28 | void C4Op1F (void); 29 | void S9xInitC4 (void); 30 | void S9xSetC4 (uint8, uint16); 31 | uint8 S9xGetC4 (uint16); 32 | uint8 * S9xGetBasePointerC4 (uint16); 33 | uint8 * S9xGetMemPointerC4 (uint16); 34 | 35 | static inline uint8 * C4GetMemPointer (uint32 Address) 36 | { 37 | return (Memory.ROM + ((Address & 0xff0000) >> 1) + (Address & 0x7fff)); 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /source/snes9x/cheats.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _CHEATS_H_ 8 | #define _CHEATS_H_ 9 | 10 | #include "port.h" 11 | #include "bml.h" 12 | #include 13 | 14 | struct SCheat 15 | { 16 | uint32 address; 17 | uint8 byte; 18 | uint8 saved_byte; 19 | bool8 conditional; 20 | bool8 cond_true; 21 | uint8 cond_byte; 22 | bool8 enabled; 23 | }; 24 | 25 | struct SCheatGroup 26 | { 27 | char *name; 28 | bool8 enabled; 29 | std::vector c; 30 | }; 31 | 32 | struct SCheatData 33 | { 34 | std::vector g; 35 | bool8 enabled; 36 | uint8 CWRAM[0x20000]; 37 | uint8 CSRAM[0x80000]; 38 | uint8 CIRAM[0x2000]; 39 | uint8 *RAM; 40 | uint8 *FillRAM; 41 | uint8 *SRAM; 42 | uint32 ALL_BITS[0x32000 >> 5]; 43 | uint8 CWatchRAM[0x32000]; 44 | }; 45 | 46 | struct Watch 47 | { 48 | bool on; 49 | int size; 50 | int format; 51 | uint32 address; 52 | char buf[12]; 53 | char desc[32]; 54 | }; 55 | 56 | typedef enum 57 | { 58 | S9X_LESS_THAN, 59 | S9X_GREATER_THAN, 60 | S9X_LESS_THAN_OR_EQUAL, 61 | S9X_GREATER_THAN_OR_EQUAL, 62 | S9X_EQUAL, 63 | S9X_NOT_EQUAL 64 | } S9xCheatComparisonType; 65 | 66 | typedef enum 67 | { 68 | S9X_8_BITS, 69 | S9X_16_BITS, 70 | S9X_24_BITS, 71 | S9X_32_BITS 72 | } S9xCheatDataSize; 73 | 74 | extern SCheatData Cheat; 75 | extern Watch watches[16]; 76 | 77 | int S9xAddCheatGroup (const char *name, const char *cheat); 78 | int S9xModifyCheatGroup (uint32 index, const char *name, const char *cheat); 79 | void S9xEnableCheatGroup (uint32 index); 80 | void S9xDisableCheatGroup (uint32 index); 81 | void S9xDeleteCheats (void); 82 | char *S9xCheatGroupToText (uint32 index); 83 | void S9xDeleteCheatGroup (uint32 index); 84 | bool8 S9xLoadCheatFile (const char *filename); 85 | bool8 S9xSaveCheatFile (const char *filename); 86 | void S9xUpdateCheatsInMemory (void); 87 | int S9xImportCheatsFromDatabase(const char *filename); 88 | void S9xCheatsDisable (void); 89 | void S9xCheatsEnable (void); 90 | char *S9xCheatValidate (const char *cheat); 91 | 92 | void S9xInitCheatData (void); 93 | void S9xInitWatchedAddress (void); 94 | void S9xStartCheatSearch (SCheatData *); 95 | void S9xSearchForChange (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, bool8, bool8); 96 | void S9xSearchForValue (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, uint32, bool8, bool8); 97 | void S9xSearchForAddress (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, uint32, bool8); 98 | void S9xOutputCheatSearchResults (SCheatData *); 99 | void S9xLoadCheatsFromBMLNode (bml_node *); 100 | 101 | const char * S9xGameGenieToRaw (const char *, uint32 &, uint8 &); 102 | const char * S9xProActionReplayToRaw (const char *, uint32 &, uint8 &); 103 | const char * S9xGoldFingerToRaw (const char *, uint32 &, bool8 &, uint8 &, uint8 bytes[3]); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /source/snes9x/cpu.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #include "snes9x.h" 8 | #include "memmap.h" 9 | #include "dma.h" 10 | #include "apu/apu.h" 11 | #include "fxemu.h" 12 | #include "sdd1.h" 13 | #include "srtc.h" 14 | #include "snapshot.h" 15 | #include "cheats.h" 16 | #ifdef DEBUGGER 17 | #include "debug.h" 18 | #endif 19 | 20 | static void S9xResetCPU (void); 21 | static void S9xSoftResetCPU (void); 22 | 23 | 24 | static void S9xResetCPU (void) 25 | { 26 | S9xSoftResetCPU(); 27 | Registers.SL = 0xff; 28 | Registers.P.W = 0; 29 | Registers.A.W = 0; 30 | Registers.X.W = 0; 31 | Registers.Y.W = 0; 32 | SetFlags(MemoryFlag | IndexFlag | IRQ | Emulation); 33 | ClearFlags(Decimal); 34 | } 35 | 36 | static void S9xSoftResetCPU (void) 37 | { 38 | CPU.Cycles = 182; // Or 188. This is the cycle count just after the jump to the Reset Vector. 39 | CPU.PrevCycles = CPU.Cycles; 40 | CPU.V_Counter = 0; 41 | CPU.Flags = CPU.Flags & (DEBUG_MODE_FLAG | TRACE_FLAG); 42 | CPU.PCBase = NULL; 43 | CPU.NMIPending = FALSE; 44 | CPU.IRQLine = FALSE; 45 | CPU.IRQTransition = FALSE; 46 | CPU.IRQExternal = FALSE; 47 | CPU.MemSpeed = SLOW_ONE_CYCLE; 48 | CPU.MemSpeedx2 = SLOW_ONE_CYCLE * 2; 49 | CPU.FastROMSpeed = SLOW_ONE_CYCLE; 50 | CPU.InDMA = FALSE; 51 | CPU.InHDMA = FALSE; 52 | CPU.InDMAorHDMA = FALSE; 53 | CPU.InWRAMDMAorHDMA = FALSE; 54 | CPU.HDMARanInDMA = 0; 55 | CPU.CurrentDMAorHDMAChannel = -1; 56 | CPU.WhichEvent = HC_RENDER_EVENT; 57 | CPU.NextEvent = Timings.RenderPos; 58 | CPU.WaitingForInterrupt = FALSE; 59 | CPU.AutoSaveTimer = 0; 60 | CPU.SRAMModified = FALSE; 61 | 62 | Registers.PBPC = 0; 63 | Registers.PB = 0; 64 | Registers.PCw = S9xGetWord(0xfffc); 65 | OpenBus = Registers.PCh; 66 | Registers.D.W = 0; 67 | Registers.DB = 0; 68 | Registers.SH = 1; 69 | Registers.SL -= 3; 70 | Registers.XH = 0; 71 | Registers.YH = 0; 72 | 73 | ICPU.ShiftedPB = 0; 74 | ICPU.ShiftedDB = 0; 75 | SetFlags(MemoryFlag | IndexFlag | IRQ | Emulation); 76 | ClearFlags(Decimal); 77 | 78 | Timings.InterlaceField = FALSE; 79 | Timings.H_Max = Timings.H_Max_Master; 80 | Timings.V_Max = Timings.V_Max_Master; 81 | Timings.NMITriggerPos = 0xffff; 82 | Timings.NextIRQTimer = 0x0fffffff; 83 | Timings.IRQFlagChanging = IRQ_NONE; 84 | 85 | if (Model->_5A22 == 2) 86 | Timings.WRAMRefreshPos = SNES_WRAM_REFRESH_HC_v2; 87 | else 88 | Timings.WRAMRefreshPos = SNES_WRAM_REFRESH_HC_v1; 89 | 90 | S9xSetPCBase(Registers.PBPC); 91 | 92 | ICPU.S9xOpcodes = S9xOpcodesE1; 93 | ICPU.S9xOpLengths = S9xOpLengthsM1X1; 94 | 95 | S9xUnpackStatus(); 96 | } 97 | 98 | void S9xReset (void) 99 | { 100 | S9xResetSaveTimer(FALSE); 101 | 102 | memset(Memory.RAM, 0x55, 0x20000); 103 | memset(Memory.VRAM, 0x00, 0x10000); 104 | memset(Memory.FillRAM, 0, 0x8000); 105 | 106 | S9xResetBSX(); 107 | S9xResetCPU(); 108 | S9xResetPPU(); 109 | S9xResetDMA(); 110 | S9xResetAPU(); 111 | S9xResetMSU(); 112 | 113 | if (Settings.DSP) 114 | S9xResetDSP(); 115 | if (Settings.SuperFX) 116 | S9xResetSuperFX(); 117 | if (Settings.SA1) 118 | S9xSA1Init(); 119 | if (Settings.SDD1) 120 | S9xResetSDD1(); 121 | if (Settings.SPC7110) 122 | S9xResetSPC7110(); 123 | if (Settings.C4) 124 | S9xInitC4(); 125 | if (Settings.OBC1) 126 | S9xResetOBC1(); 127 | if (Settings.SRTC) 128 | S9xResetSRTC(); 129 | if (Settings.MSU1) 130 | S9xMSU1Init(); 131 | 132 | S9xInitCheatData(); 133 | } 134 | 135 | void S9xSoftReset (void) 136 | { 137 | S9xResetSaveTimer(FALSE); 138 | 139 | memset(Memory.FillRAM, 0, 0x8000); 140 | 141 | if (Settings.BS) 142 | S9xResetBSX(); 143 | 144 | S9xSoftResetCPU(); 145 | S9xSoftResetPPU(); 146 | S9xResetDMA(); 147 | S9xSoftResetAPU(); 148 | S9xResetMSU(); 149 | 150 | if (Settings.DSP) 151 | S9xResetDSP(); 152 | if (Settings.SuperFX) 153 | S9xResetSuperFX(); 154 | if (Settings.SA1) 155 | S9xSA1Init(); 156 | if (Settings.SDD1) 157 | S9xResetSDD1(); 158 | if (Settings.SPC7110) 159 | S9xResetSPC7110(); 160 | if (Settings.C4) 161 | S9xInitC4(); 162 | if (Settings.OBC1) 163 | S9xResetOBC1(); 164 | if (Settings.SRTC) 165 | S9xResetSRTC(); 166 | if (Settings.MSU1) 167 | S9xMSU1Init(); 168 | 169 | S9xInitCheatData(); 170 | } 171 | -------------------------------------------------------------------------------- /source/snes9x/cpuexec.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _CPUEXEC_H_ 8 | #define _CPUEXEC_H_ 9 | 10 | #include "ppu.h" 11 | #ifdef DEBUGGER 12 | #include "debug.h" 13 | #endif 14 | 15 | struct SOpcodes 16 | { 17 | void (*S9xOpcode) (void); 18 | }; 19 | 20 | struct SICPU 21 | { 22 | struct SOpcodes *S9xOpcodes; 23 | uint8 *S9xOpLengths; 24 | uint8 _Carry; 25 | uint8 _Zero; 26 | uint8 _Negative; 27 | uint8 _Overflow; 28 | uint32 ShiftedPB; 29 | uint32 ShiftedDB; 30 | uint32 Frame; 31 | uint32 FrameAdvanceCount; 32 | }; 33 | 34 | extern struct SICPU ICPU; 35 | 36 | extern struct SOpcodes S9xOpcodesE1[256]; 37 | extern struct SOpcodes S9xOpcodesM1X1[256]; 38 | extern struct SOpcodes S9xOpcodesM1X0[256]; 39 | extern struct SOpcodes S9xOpcodesM0X1[256]; 40 | extern struct SOpcodes S9xOpcodesM0X0[256]; 41 | extern struct SOpcodes S9xOpcodesSlow[256]; 42 | extern uint8 S9xOpLengthsM1X1[256]; 43 | extern uint8 S9xOpLengthsM1X0[256]; 44 | extern uint8 S9xOpLengthsM0X1[256]; 45 | extern uint8 S9xOpLengthsM0X0[256]; 46 | 47 | void S9xMainLoop (void); 48 | void S9xReset (void); 49 | void S9xSoftReset (void); 50 | void S9xDoHEventProcessing (void); 51 | 52 | static inline void S9xUnpackStatus (void) 53 | { 54 | ICPU._Zero = (Registers.PL & Zero) == 0; 55 | ICPU._Negative = (Registers.PL & Negative); 56 | ICPU._Carry = (Registers.PL & Carry); 57 | ICPU._Overflow = (Registers.PL & Overflow) >> 6; 58 | } 59 | 60 | static inline void S9xPackStatus (void) 61 | { 62 | Registers.PL &= ~(Zero | Negative | Carry | Overflow); 63 | Registers.PL |= ICPU._Carry | ((ICPU._Zero == 0) << 1) | (ICPU._Negative & 0x80) | (ICPU._Overflow << 6); 64 | } 65 | 66 | static inline void S9xFixCycles (void) 67 | { 68 | if (CheckEmulation()) 69 | { 70 | ICPU.S9xOpcodes = S9xOpcodesE1; 71 | ICPU.S9xOpLengths = S9xOpLengthsM1X1; 72 | } 73 | else 74 | if (CheckMemory()) 75 | { 76 | if (CheckIndex()) 77 | { 78 | ICPU.S9xOpcodes = S9xOpcodesM1X1; 79 | ICPU.S9xOpLengths = S9xOpLengthsM1X1; 80 | } 81 | else 82 | { 83 | ICPU.S9xOpcodes = S9xOpcodesM1X0; 84 | ICPU.S9xOpLengths = S9xOpLengthsM1X0; 85 | } 86 | } 87 | else 88 | { 89 | if (CheckIndex()) 90 | { 91 | ICPU.S9xOpcodes = S9xOpcodesM0X1; 92 | ICPU.S9xOpLengths = S9xOpLengthsM0X1; 93 | } 94 | else 95 | { 96 | ICPU.S9xOpcodes = S9xOpcodesM0X0; 97 | ICPU.S9xOpLengths = S9xOpLengthsM0X0; 98 | } 99 | } 100 | } 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /source/snes9x/cpuops.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | 8 | #ifndef _CPUOPS_H_ 9 | #define _CPUOPS_H_ 10 | 11 | void S9xOpcode_NMI (void); 12 | void S9xOpcode_IRQ (void); 13 | 14 | #ifndef SA1_OPCODES 15 | #define CHECK_FOR_IRQ() {} // if (CPU.IRQLine) S9xOpcode_IRQ(); } 16 | #else 17 | #define CHECK_FOR_IRQ() {} 18 | #endif 19 | #endif 20 | -------------------------------------------------------------------------------- /source/snes9x/crosshairs.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _CROSSHAIRS_H_ 8 | #define _CROSSHAIRS_H_ 9 | 10 | // Read in the specified crosshair file, replacing whatever data might be in that slot. 11 | // Available slots are 1-31. 12 | // The input file must be a PNG or a text file. 13 | // PNG: 15x15 pixels, palettized, with 3 colors (white, black, and transparent). 14 | // text: 15 lines of 16 characters (counting the \n), consisting of ' ', '#', or '.'. 15 | 16 | bool S9xLoadCrosshairFile (int idx, const char *filename); 17 | 18 | // Return the specified crosshair. Woo-hoo. 19 | // char * to a 225-byte string, with '#' marking foreground, '.' marking background, 20 | // and anything else transparent. 21 | 22 | const char * S9xGetCrosshair (int idx); 23 | 24 | // In controls.cpp. Sets the crosshair for the specified device. Defaults are: 25 | // cross fgcolor bgcolor 26 | // Mouse 1: 1 White Black 27 | // Mouse 2: 1 Purple White 28 | // Superscope: 2 White Black 29 | // Justifier 1: 4 Blue Black 30 | // Justifier 2: 4 MagicPink Black 31 | // Macs Rifle: 2 White Black 32 | // 33 | // Available colors are: Trans, Black, 25Grey, 50Grey, 75Grey, White, Red, Orange, 34 | // Yellow, Green, Cyan, Sky, Blue, Violet, MagicPink, and Purple. 35 | // You may also prefix a 't' (e.g. tBlue) for a 50%-transparent version. 36 | // Use idx = -1 or fg/bg = NULL to keep the current setting. 37 | 38 | enum crosscontrols 39 | { 40 | X_MOUSE1, 41 | X_MOUSE2, 42 | X_SUPERSCOPE, 43 | X_JUSTIFIER1, 44 | X_JUSTIFIER2, 45 | X_MACSRIFLE 46 | }; 47 | 48 | void S9xSetControllerCrosshair (enum crosscontrols ctl, int8 idx, const char *fg, const char *bg); 49 | void S9xGetControllerCrosshair (enum crosscontrols ctl, int8 *idx, const char **fg, const char **bg); 50 | 51 | // In gfx.cpp, much like S9xDisplayChar() except it takes the parameters 52 | // listed and looks up GFX.Screen. 53 | // The 'crosshair' arg is a 15x15 image, with '#' meaning fgcolor, 54 | // '.' meaning bgcolor, and anything else meaning transparent. 55 | // Color values should be (RGB): 56 | // 0 = transparent 4 = 23 23 23 8 = 31 31 0 12 = 0 0 31 57 | // 1 = 0 0 0 5 = 31 31 31 9 = 0 31 0 13 = 23 0 31 58 | // 2 = 8 8 8 6 = 31 0 0 10 = 0 31 31 14 = 31 0 31 59 | // 3 = 16 16 16 7 = 31 16 0 11 = 0 23 31 15 = 31 0 16 60 | // 16-31 are 50% transparent versions of 0-15. 61 | 62 | void S9xDrawCrosshair (const char *crosshair, uint8 fgcolor, uint8 bgcolor, int16 x, int16 y); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /source/snes9x/display.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _DISPLAY_H_ 8 | #define _DISPLAY_H_ 9 | 10 | #include "snes9x.h" 11 | 12 | enum s9x_getdirtype 13 | { 14 | DEFAULT_DIR = 0, 15 | HOME_DIR, 16 | ROMFILENAME_DIR, 17 | ROM_DIR, 18 | SRAM_DIR, 19 | SNAPSHOT_DIR, 20 | SCREENSHOT_DIR, 21 | SPC_DIR, 22 | CHEAT_DIR, 23 | PATCH_DIR, 24 | BIOS_DIR, 25 | LOG_DIR, 26 | SAT_DIR, 27 | LAST_DIR 28 | }; 29 | 30 | void S9xUsage (void); 31 | char * S9xParseArgs (char **, int); 32 | void S9xParseArgsForCheats (char **, int); 33 | void S9xLoadConfigFiles (char **, int); 34 | void S9xSetInfoString (const char *); 35 | 36 | // Routines the port has to implement even if it doesn't use them 37 | 38 | void S9xPutImage (int, int); 39 | void S9xInitDisplay (int, char **); 40 | void S9xDeinitDisplay (void); 41 | void S9xTextMode (void); 42 | void S9xGraphicsMode (void); 43 | void S9xToggleSoundChannel (int); 44 | bool8 S9xOpenSnapshotFile (const char *, bool8, STREAM *); 45 | void S9xCloseSnapshotFile (STREAM); 46 | const char * S9xStringInput (const char *); 47 | const char * S9xGetDirectory (enum s9x_getdirtype); 48 | const char * S9xGetFilename (const char *, enum s9x_getdirtype); 49 | const char * S9xGetFilenameInc (const char *, enum s9x_getdirtype); 50 | const char * S9xBasename (const char *); 51 | 52 | // Routines the port has to implement if it uses command-line 53 | 54 | void S9xExtraUsage (void); 55 | void S9xParseArg (char **, int &, int); 56 | 57 | // Routines the port may implement as needed 58 | 59 | void S9xExtraDisplayUsage (void); 60 | void S9xParseDisplayArg (char **, int &, int); 61 | void S9xSetTitle (const char *); 62 | void S9xInitInputDevices (void); 63 | void S9xProcessEvents (bool8); 64 | const char * S9xSelectFilename (const char *, const char *, const char *, const char *); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /source/snes9x/dma.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _DMA_H_ 8 | #define _DMA_H_ 9 | 10 | struct SDMA 11 | { 12 | bool8 ReverseTransfer; 13 | bool8 HDMAIndirectAddressing; 14 | bool8 UnusedBit43x0; 15 | bool8 AAddressFixed; 16 | bool8 AAddressDecrement; 17 | uint8 TransferMode; 18 | uint8 BAddress; 19 | uint16 AAddress; 20 | uint8 ABank; 21 | uint16 DMACount_Or_HDMAIndirectAddress; 22 | uint8 IndirectBank; 23 | uint16 Address; 24 | uint8 Repeat; 25 | uint8 LineCount; 26 | uint8 UnknownByte; 27 | uint8 DoTransfer; 28 | }; 29 | 30 | #define TransferBytes DMACount_Or_HDMAIndirectAddress 31 | #define IndirectAddress DMACount_Or_HDMAIndirectAddress 32 | 33 | extern struct SDMA DMA[8]; 34 | 35 | bool8 S9xDoDMA (uint8); 36 | void S9xStartHDMA (void); 37 | uint8 S9xDoHDMA (uint8); 38 | void S9xResetDMA (void); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /source/snes9x/dsp.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #include "snes9x.h" 8 | #include "memmap.h" 9 | #ifdef DEBUGGER 10 | #include "missing.h" 11 | #endif 12 | 13 | uint8 (*GetDSP) (uint16) = NULL; 14 | void (*SetDSP) (uint8, uint16) = NULL; 15 | 16 | 17 | void S9xResetDSP (void) 18 | { 19 | memset(&DSP1, 0, sizeof(DSP1)); 20 | DSP1.waiting4command = TRUE; 21 | DSP1.first_parameter = TRUE; 22 | 23 | memset(&DSP2, 0, sizeof(DSP2)); 24 | DSP2.waiting4command = TRUE; 25 | 26 | memset(&DSP3, 0, sizeof(DSP3)); 27 | DSP3_Reset(); 28 | 29 | memset(&DSP4, 0, sizeof(DSP4)); 30 | DSP4.waiting4command = TRUE; 31 | } 32 | 33 | uint8 S9xGetDSP (uint16 address) 34 | { 35 | #ifdef DEBUGGER 36 | if (Settings.TraceDSP) 37 | { 38 | sprintf(String, "DSP read: 0x%04X", address); 39 | S9xMessage(S9X_TRACE, S9X_TRACE_DSP1, String); 40 | } 41 | #endif 42 | 43 | return ((*GetDSP)(address)); 44 | } 45 | 46 | void S9xSetDSP (uint8 byte, uint16 address) 47 | { 48 | #ifdef DEBUGGER 49 | missing.unknowndsp_write = address; 50 | if (Settings.TraceDSP) 51 | { 52 | sprintf(String, "DSP write: 0x%04X=0x%02X", address, byte); 53 | S9xMessage(S9X_TRACE, S9X_TRACE_DSP1, String); 54 | } 55 | #endif 56 | 57 | (*SetDSP)(byte, address); 58 | } 59 | -------------------------------------------------------------------------------- /source/snes9x/fxemu.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _FXEMU_H_ 8 | #define _FXEMU_H_ 9 | 10 | #define FX_BREAKPOINT (-1) 11 | #define FX_ERROR_ILLEGAL_ADDRESS (-2) 12 | 13 | // The FxInfo_s structure, the link between the FxEmulator and the Snes Emulator 14 | struct FxInfo_s 15 | { 16 | uint32 vFlags; 17 | uint8 *pvRegisters; // 768 bytes located in the memory at address 0x3000 18 | uint32 nRamBanks; // Number of 64kb-banks in GSU-RAM/BackupRAM (banks 0x70-0x73) 19 | uint8 *pvRam; // Pointer to GSU-RAM 20 | uint32 nRomBanks; // Number of 32kb-banks in Cart-ROM 21 | uint8 *pvRom; // Pointer to Cart-ROM 22 | uint32 speedPerLine; 23 | bool8 oneLineDone; 24 | }; 25 | 26 | extern struct FxInfo_s SuperFX; 27 | 28 | void S9xInitSuperFX (void); 29 | void S9xResetSuperFX (void); 30 | void S9xSuperFXExec (void); 31 | void S9xSetSuperFX (uint8, uint16); 32 | uint8 S9xGetSuperFX (uint16); 33 | void fx_flushCache (void); 34 | void fx_computeScreenPointers (void); 35 | uint32 fx_run (uint32); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /source/snes9x/language.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _LANGUAGE_H_ 8 | #define _LANGUAGE_H_ 9 | 10 | // Movie Messages 11 | #define MOVIE_ERR_SNAPSHOT_WRONG_MOVIE "Snapshot not from this movie" 12 | #define MOVIE_ERR_SNAPSHOT_NOT_MOVIE "Not a movie snapshot" 13 | #define MOVIE_INFO_REPLAY "Movie replay" 14 | #define MOVIE_INFO_RECORD "Movie record" 15 | #define MOVIE_INFO_RERECORD "Movie re-record" 16 | #define MOVIE_INFO_REWIND "Movie rewind" 17 | #define MOVIE_INFO_STOP "Movie stop" 18 | #define MOVIE_INFO_END "Movie end" 19 | #define MOVIE_INFO_SNAPSHOT "Movie snapshot" 20 | #define MOVIE_ERR_SNAPSHOT_INCONSISTENT "Snapshot inconsistent with movie" 21 | 22 | // Snapshot Messages 23 | #define SAVE_INFO_SNAPSHOT "Saved" 24 | #define SAVE_INFO_LOAD "Loaded" 25 | #define SAVE_INFO_OOPS "Auto-saving 'oops' snapshot" 26 | #define SAVE_ERR_WRONG_FORMAT "File not in Snes9x snapshot format" 27 | #define SAVE_ERR_WRONG_VERSION "Incompatible snapshot version" 28 | #define SAVE_ERR_ROM_NOT_FOUND "ROM image \"%s\" for snapshot not found" 29 | #define SAVE_ERR_SAVE_NOT_FOUND "Snapshot %s does not exist" 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /source/snes9x/messages.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _MESSAGES_H_ 8 | #define _MESSAGES_H_ 9 | 10 | // Types of message sent to S9xMessage() 11 | enum 12 | { 13 | S9X_TRACE, 14 | S9X_DEBUG, 15 | S9X_WARNING, 16 | S9X_INFO, 17 | S9X_ERROR, 18 | S9X_FATAL_ERROR 19 | }; 20 | 21 | // Individual message numbers 22 | enum 23 | { 24 | S9X_NO_INFO, 25 | S9X_ROM_INFO, 26 | S9X_HEADERS_INFO, 27 | S9X_CONFIG_INFO, 28 | S9X_ROM_CONFUSING_FORMAT_INFO, 29 | S9X_ROM_INTERLEAVED_INFO, 30 | S9X_SOUND_DEVICE_OPEN_FAILED, 31 | S9X_APU_STOPPED, 32 | S9X_USAGE, 33 | S9X_GAME_GENIE_CODE_ERROR, 34 | S9X_ACTION_REPLY_CODE_ERROR, 35 | S9X_GOLD_FINGER_CODE_ERROR, 36 | S9X_DEBUG_OUTPUT, 37 | S9X_DMA_TRACE, 38 | S9X_HDMA_TRACE, 39 | S9X_WRONG_FORMAT, 40 | S9X_WRONG_VERSION, 41 | S9X_ROM_NOT_FOUND, 42 | S9X_FREEZE_FILE_NOT_FOUND, 43 | S9X_PPU_TRACE, 44 | S9X_TRACE_DSP1, 45 | S9X_FREEZE_ROM_NAME, 46 | S9X_HEADER_WARNING, 47 | S9X_NETPLAY_NOT_SERVER, 48 | S9X_FREEZE_FILE_INFO, 49 | S9X_TURBO_MODE, 50 | S9X_SOUND_NOT_BUILT, 51 | S9X_MOVIE_INFO, 52 | S9X_WRONG_MOVIE_SNAPSHOT, 53 | S9X_NOT_A_MOVIE_SNAPSHOT, 54 | S9X_SNAPSHOT_INCONSISTENT, 55 | S9X_AVI_INFO, 56 | S9X_PRESSED_KEYS_INFO 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /source/snes9x/missing.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifdef DEBUGGER 8 | 9 | #ifndef _MISSING_H_ 10 | #define _MISSING_H_ 11 | 12 | struct MissingHDMA 13 | { 14 | uint8 used; 15 | uint8 bbus_address; 16 | uint8 abus_bank; 17 | uint16 abus_address; 18 | uint8 indirect_address; 19 | uint8 force_table_address_write; 20 | uint8 force_table_address_read; 21 | uint8 line_count_write; 22 | uint8 line_count_read; 23 | }; 24 | 25 | struct Missing 26 | { 27 | struct MissingHDMA hdma[8]; 28 | uint8 emulate6502; 29 | uint8 decimal_mode; 30 | uint8 mv_8bit_index; 31 | uint8 mv_8bit_acc; 32 | uint8 interlace; 33 | uint8 lines_239; 34 | uint8 pseudo_512; 35 | uint8 modes[8]; 36 | uint8 mode7_fx; 37 | uint8 mode7_flip; 38 | uint8 mode7_bgmode; 39 | uint8 direct; 40 | uint8 matrix_multiply; 41 | uint8 oam_read; 42 | uint8 vram_read; 43 | uint8 cgram_read; 44 | uint8 wram_read; 45 | uint8 dma_read; 46 | uint8 vram_inc; 47 | uint8 vram_full_graphic_inc; 48 | uint8 virq; 49 | uint8 hirq; 50 | uint16 virq_pos; 51 | uint16 hirq_pos; 52 | uint8 h_v_latch; 53 | uint8 h_counter_read; 54 | uint8 v_counter_read; 55 | uint8 fast_rom; 56 | uint8 window1[6]; 57 | uint8 window2[6]; 58 | uint8 sprite_priority_rotation; 59 | uint8 subscreen; 60 | uint8 subscreen_add; 61 | uint8 subscreen_sub; 62 | uint8 fixed_colour_add; 63 | uint8 fixed_colour_sub; 64 | uint8 mosaic; 65 | uint8 sprite_double_height; 66 | uint8 dma_channels; 67 | uint8 dma_this_frame; 68 | uint8 oam_address_read; 69 | uint8 bg_offset_read; 70 | uint8 matrix_read; 71 | uint8 hdma_channels; 72 | uint8 hdma_this_frame; 73 | uint16 unknownppu_read; 74 | uint16 unknownppu_write; 75 | uint16 unknowncpu_read; 76 | uint16 unknowncpu_write; 77 | uint16 unknowndsp_read; 78 | uint16 unknowndsp_write; 79 | }; 80 | 81 | extern struct Missing missing; 82 | 83 | #endif 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /source/snes9x/movie.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _MOVIE_H_ 8 | #define _MOVIE_H_ 9 | 10 | #define MOVIE_OPT_FROM_SNAPSHOT 0 11 | #define MOVIE_OPT_FROM_RESET (1 << 0) 12 | #define MOVIE_OPT_PAL (1 << 1) 13 | #define MOVIE_OPT_NOSAVEDATA (1 << 2) 14 | #define MOVIE_SYNC_DATA_EXISTS 0x01 15 | #define MOVIE_SYNC_OBSOLETE 0x02 16 | #define MOVIE_SYNC_VOLUMEENVX 0x08 17 | #define MOVIE_SYNC_FAKEMUTE 0x10 18 | #define MOVIE_SYNC_HASROMINFO 0x40 19 | #define MOVIE_SYNC_NOCPUSHUTDOWN 0x80 20 | #define MOVIE_MAX_METADATA 512 21 | 22 | #define CONTROLLER_DATA_SIZE 2 23 | #define MOUSE_DATA_SIZE 5 24 | #define SCOPE_DATA_SIZE 6 25 | #define JUSTIFIER_DATA_SIZE 11 26 | 27 | struct MovieInfo 28 | { 29 | time_t TimeCreated; 30 | uint32 Version; 31 | uint32 LengthFrames; 32 | uint32 LengthSamples; 33 | uint32 RerecordCount; 34 | uint8 Opts; 35 | uint8 ControllersMask; 36 | uint8 SyncFlags; 37 | bool8 ReadOnly; 38 | uint8 PortType[2]; 39 | wchar_t Metadata[MOVIE_MAX_METADATA]; 40 | uint32 ROMCRC32; 41 | char ROMName[23]; 42 | }; 43 | 44 | // methods used by the user-interface code 45 | int S9xMovieOpen (const char *, bool8); 46 | int S9xMovieCreate (const char *, uint8, uint8, const wchar_t *, int); 47 | int S9xMovieGetInfo (const char *, struct MovieInfo *); 48 | void S9xMovieStop (bool8); 49 | void S9xMovieToggleRecState (void); 50 | void S9xMovieToggleFrameDisplay (void); 51 | 52 | // methods used by the emulation 53 | void S9xMovieInit (void); 54 | void S9xMovieShutdown (void); 55 | void S9xMovieUpdate (bool a = true); 56 | void S9xMovieUpdateOnReset (void); 57 | void S9xUpdateFrameCounter (int o = 0); 58 | void S9xMovieFreeze (uint8 **, uint32 *); 59 | int S9xMovieUnfreeze (uint8 *, uint32); 60 | 61 | // accessor functions 62 | bool8 S9xMovieActive (void); 63 | bool8 S9xMoviePlaying (void); 64 | bool8 S9xMovieRecording (void); 65 | bool8 S9xMovieReadOnly (void); 66 | uint8 S9xMovieControllers (void); 67 | uint32 S9xMovieGetId (void); 68 | uint32 S9xMovieGetLength (void); 69 | uint32 S9xMovieGetFrameCounter (void); 70 | 71 | uint16 MovieGetJoypad (int); 72 | void MovieSetJoypad (int, uint16); 73 | bool MovieGetMouse (int, uint8 d[MOUSE_DATA_SIZE]); 74 | void MovieSetMouse (int, uint8 d[MOUSE_DATA_SIZE], bool); 75 | bool MovieGetScope (int, uint8 d[SCOPE_DATA_SIZE]); 76 | void MovieSetScope (int, uint8 d[SCOPE_DATA_SIZE]); 77 | bool MovieGetJustifier (int, uint8 d[JUSTIFIER_DATA_SIZE]); 78 | void MovieSetJustifier (int, uint8 d[JUSTIFIER_DATA_SIZE]); 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /source/snes9x/msu1.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _MSU1_H_ 8 | #define _MSU1_H_ 9 | #include "snes9x.h" 10 | 11 | #define MSU1_REVISION 0x02 12 | 13 | struct SMSU1 14 | { 15 | uint8 MSU1_STATUS; 16 | uint32 MSU1_DATA_SEEK; 17 | uint32 MSU1_DATA_POS; 18 | uint16 MSU1_TRACK_SEEK; 19 | uint16 MSU1_CURRENT_TRACK; 20 | uint32 MSU1_RESUME_TRACK; 21 | uint8 MSU1_VOLUME; 22 | uint8 MSU1_CONTROL; 23 | uint32 MSU1_AUDIO_POS; 24 | uint32 MSU1_RESUME_POS; 25 | }; 26 | 27 | enum SMSU1_FLAG { 28 | Revision = 0x07, // bitmask, not the actual version number 29 | AudioError = 0x08, 30 | AudioPlaying = 0x10, 31 | AudioRepeating = 0x20, 32 | AudioBusy = 0x40, 33 | DataBusy = 0x80 34 | }; 35 | 36 | enum SMSU1_CMD { 37 | Play = 0x01, 38 | Repeat = 0x02, 39 | Resume = 0x04 40 | }; 41 | 42 | extern struct SMSU1 MSU1; 43 | 44 | void S9xResetMSU(void); 45 | void S9xMSU1Init(void); 46 | void S9xMSU1DeInit(void); 47 | bool S9xMSU1ROMExists(void); 48 | STREAM S9xMSU1OpenFile(const char *msu_ext, bool skip_unpacked = FALSE); 49 | void S9xMSU1Init(void); 50 | void S9xMSU1Generate(size_t sample_count); 51 | uint8 S9xMSU1ReadPort(uint8 port); 52 | void S9xMSU1WritePort(uint8 port, uint8 byte); 53 | size_t S9xMSU1Samples(void); 54 | void S9xMSU1SetOutput(int16 *out, size_t size); 55 | void S9xMSU1PostLoadState(void); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /source/snes9x/obc1.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #include "snes9x.h" 8 | #include "memmap.h" 9 | 10 | 11 | uint8 S9xGetOBC1 (uint16 Address) 12 | { 13 | switch (Address) 14 | { 15 | case 0x7ff0: 16 | return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2)]); 17 | 18 | case 0x7ff1: 19 | return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 1]); 20 | 21 | case 0x7ff2: 22 | return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 2]); 23 | 24 | case 0x7ff3: 25 | return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 3]); 26 | 27 | case 0x7ff4: 28 | return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address >> 2) + 0x200]); 29 | } 30 | 31 | return (Memory.OBC1RAM[Address - 0x6000]); 32 | } 33 | 34 | void S9xSetOBC1 (uint8 Byte, uint16 Address) 35 | { 36 | switch (Address) 37 | { 38 | case 0x7ff0: 39 | Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2)] = Byte; 40 | break; 41 | 42 | case 0x7ff1: 43 | Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 1] = Byte; 44 | break; 45 | 46 | case 0x7ff2: 47 | Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 2] = Byte; 48 | break; 49 | 50 | case 0x7ff3: 51 | Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 3] = Byte; 52 | break; 53 | 54 | case 0x7ff4: 55 | { 56 | uint8 Temp; 57 | Temp = Memory.OBC1RAM[OBC1.basePtr + (OBC1.address >> 2) + 0x200]; 58 | Temp = (Temp & ~(3 << OBC1.shift)) | ((Byte & 3) << OBC1.shift); 59 | Memory.OBC1RAM[OBC1.basePtr + (OBC1.address >> 2) + 0x200] = Temp; 60 | break; 61 | } 62 | 63 | case 0x7ff5: 64 | if (Byte & 1) 65 | OBC1.basePtr = 0x1800; 66 | else 67 | OBC1.basePtr = 0x1c00; 68 | break; 69 | 70 | case 0x7ff6: 71 | OBC1.address = Byte & 0x7f; 72 | OBC1.shift = (Byte & 3) << 1; 73 | break; 74 | } 75 | 76 | Memory.OBC1RAM[Address - 0x6000] = Byte; 77 | } 78 | 79 | void S9xResetOBC1 (void) 80 | { 81 | for (int i = 0; i <= 0x1fff; i++) 82 | Memory.OBC1RAM[i] = 0xff; 83 | 84 | if (Memory.OBC1RAM[0x1ff5] & 1) 85 | OBC1.basePtr = 0x1800; 86 | else 87 | OBC1.basePtr = 0x1c00; 88 | 89 | OBC1.address = Memory.OBC1RAM[0x1ff6] & 0x7f; 90 | OBC1.shift = (Memory.OBC1RAM[0x1ff6] & 3) << 1; 91 | } 92 | 93 | uint8 * S9xGetBasePointerOBC1 (uint16 Address) 94 | { 95 | if (Address >= 0x7ff0 && Address <= 0x7ff6) 96 | return (NULL); 97 | return (Memory.OBC1RAM - 0x6000); 98 | } 99 | 100 | uint8 * S9xGetMemPointerOBC1 (uint16 Address) 101 | { 102 | if (Address >= 0x7ff0 && Address <= 0x7ff6) 103 | return (NULL); 104 | return (Memory.OBC1RAM + Address - 0x6000); 105 | } 106 | -------------------------------------------------------------------------------- /source/snes9x/obc1.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _OBC1_H_ 8 | #define _OBC1_H_ 9 | 10 | struct SOBC1 11 | { 12 | uint16 address; 13 | uint16 basePtr; 14 | uint16 shift; 15 | }; 16 | 17 | extern struct SOBC1 OBC1; 18 | 19 | void S9xSetOBC1 (uint8, uint16); 20 | uint8 S9xGetOBC1 (uint16); 21 | void S9xResetOBC1 (void); 22 | uint8 * S9xGetBasePointerOBC1 (uint16); 23 | uint8 * S9xGetMemPointerOBC1 (uint16); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /source/snes9x/sa1.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _SA1_H_ 8 | #define _SA1_H_ 9 | 10 | struct SSA1Registers 11 | { 12 | uint8 DB; 13 | pair P; 14 | pair A; 15 | pair D; 16 | pair S; 17 | pair X; 18 | pair Y; 19 | PC_t PC; 20 | }; 21 | 22 | struct SSA1 23 | { 24 | struct SOpcodes *S9xOpcodes; 25 | uint8 *S9xOpLengths; 26 | uint8 _Carry; 27 | uint8 _Zero; 28 | uint8 _Negative; 29 | uint8 _Overflow; 30 | uint32 ShiftedPB; 31 | uint32 ShiftedDB; 32 | 33 | uint32 Flags; 34 | int32 Cycles; 35 | int32 PrevCycles; 36 | uint8 *PCBase; 37 | bool8 WaitingForInterrupt; 38 | 39 | uint8 *Map[MEMMAP_NUM_BLOCKS]; 40 | uint8 *WriteMap[MEMMAP_NUM_BLOCKS]; 41 | uint8 *BWRAM; 42 | 43 | bool8 in_char_dma; 44 | bool8 TimerIRQLastState; 45 | uint16 HTimerIRQPos; 46 | uint16 VTimerIRQPos; 47 | int16 HCounter; 48 | int16 VCounter; 49 | int16 PrevHCounter; 50 | int32 MemSpeed; 51 | int32 MemSpeedx2; 52 | int32 arithmetic_op; 53 | uint16 op1; 54 | uint16 op2; 55 | uint64 sum; 56 | bool8 overflow; 57 | uint8 VirtualBitmapFormat; 58 | uint8 variable_bit_pos; 59 | }; 60 | 61 | #define SA1CheckCarry() (SA1._Carry) 62 | #define SA1CheckZero() (SA1._Zero == 0) 63 | #define SA1CheckIRQ() (SA1Registers.PL & IRQ) 64 | #define SA1CheckDecimal() (SA1Registers.PL & Decimal) 65 | #define SA1CheckIndex() (SA1Registers.PL & IndexFlag) 66 | #define SA1CheckMemory() (SA1Registers.PL & MemoryFlag) 67 | #define SA1CheckOverflow() (SA1._Overflow) 68 | #define SA1CheckNegative() (SA1._Negative & 0x80) 69 | #define SA1CheckEmulation() (SA1Registers.P.W & Emulation) 70 | 71 | #define SA1SetFlags(f) (SA1Registers.P.W |= (f)) 72 | #define SA1ClearFlags(f) (SA1Registers.P.W &= ~(f)) 73 | #define SA1CheckFlag(f) (SA1Registers.PL & (f)) 74 | 75 | extern struct SSA1Registers SA1Registers; 76 | extern struct SSA1 SA1; 77 | extern uint8 SA1OpenBus; 78 | extern struct SOpcodes S9xSA1OpcodesM1X1[256]; 79 | extern struct SOpcodes S9xSA1OpcodesM1X0[256]; 80 | extern struct SOpcodes S9xSA1OpcodesM0X1[256]; 81 | extern struct SOpcodes S9xSA1OpcodesM0X0[256]; 82 | extern uint8 S9xOpLengthsM1X1[256]; 83 | extern uint8 S9xOpLengthsM1X0[256]; 84 | extern uint8 S9xOpLengthsM0X1[256]; 85 | extern uint8 S9xOpLengthsM0X0[256]; 86 | 87 | uint8 S9xSA1GetByte (uint32); 88 | void S9xSA1SetByte (uint8, uint32); 89 | uint16 S9xSA1GetWord (uint32, enum s9xwrap_t w = WRAP_NONE); 90 | void S9xSA1SetWord (uint16, uint32, enum s9xwrap_t w = WRAP_NONE, enum s9xwriteorder_t o = WRITE_01); 91 | void S9xSA1SetPCBase (uint32); 92 | uint8 S9xGetSA1 (uint32); 93 | void S9xSetSA1 (uint8, uint32); 94 | void S9xSA1Init (void); 95 | void S9xSA1MainLoop (void); 96 | void S9xSA1PostLoadState (void); 97 | 98 | static inline void S9xSA1UnpackStatus (void) 99 | { 100 | SA1._Zero = (SA1Registers.PL & Zero) == 0; 101 | SA1._Negative = (SA1Registers.PL & Negative); 102 | SA1._Carry = (SA1Registers.PL & Carry); 103 | SA1._Overflow = (SA1Registers.PL & Overflow) >> 6; 104 | } 105 | 106 | static inline void S9xSA1PackStatus (void) 107 | { 108 | SA1Registers.PL &= ~(Zero | Negative | Carry | Overflow); 109 | SA1Registers.PL |= SA1._Carry | ((SA1._Zero == 0) << 1) | (SA1._Negative & 0x80) | (SA1._Overflow << 6); 110 | } 111 | 112 | static inline void S9xSA1FixCycles (void) 113 | { 114 | if (SA1CheckEmulation()) 115 | { 116 | SA1.S9xOpcodes = S9xSA1OpcodesM1X1; 117 | SA1.S9xOpLengths = S9xOpLengthsM1X1; 118 | } 119 | else 120 | if (SA1CheckMemory()) 121 | { 122 | if (SA1CheckIndex()) 123 | { 124 | SA1.S9xOpcodes = S9xSA1OpcodesM1X1; 125 | SA1.S9xOpLengths = S9xOpLengthsM1X1; 126 | } 127 | else 128 | { 129 | SA1.S9xOpcodes = S9xSA1OpcodesM1X0; 130 | SA1.S9xOpLengths = S9xOpLengthsM1X0; 131 | } 132 | } 133 | else 134 | { 135 | if (SA1CheckIndex()) 136 | { 137 | SA1.S9xOpcodes = S9xSA1OpcodesM0X1; 138 | SA1.S9xOpLengths = S9xOpLengthsM0X1; 139 | } 140 | else 141 | { 142 | SA1.S9xOpcodes = S9xSA1OpcodesM0X0; 143 | SA1.S9xOpLengths = S9xOpLengthsM0X0; 144 | } 145 | } 146 | } 147 | 148 | #endif 149 | -------------------------------------------------------------------------------- /source/snes9x/sar.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _SAR_H_ 8 | #define _SAR_H_ 9 | 10 | #ifdef RIGHTSHIFT_IS_SAR 11 | #define SAR(b, n) ((b) >> (n)) 12 | #else 13 | 14 | static inline int8 SAR (const int8 b, const int n) 15 | { 16 | #ifndef RIGHTSHIFT_int8_IS_SAR 17 | if (b < 0) 18 | return ((b >> n) | (-1 << (8 - n))); 19 | #endif 20 | return (b >> n); 21 | } 22 | 23 | static inline int16 SAR (const int16 b, const int n) 24 | { 25 | #ifndef RIGHTSHIFT_int16_IS_SAR 26 | if (b < 0) 27 | return ((b >> n) | (-1 << (16 - n))); 28 | #endif 29 | return (b >> n); 30 | } 31 | 32 | static inline int32 SAR (const int32 b, const int n) 33 | { 34 | #ifndef RIGHTSHIFT_int32_IS_SAR 35 | if (b < 0) 36 | return ((b >> n) | (-1 << (32 - n))); 37 | #endif 38 | return (b >> n); 39 | } 40 | 41 | static inline int64 SAR (const int64 b, const int n) 42 | { 43 | #ifndef RIGHTSHIFT_int64_IS_SAR 44 | if (b < 0) 45 | return ((b >> n) | (-1 << (64 - n))); 46 | #endif 47 | return (b >> n); 48 | } 49 | 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /source/snes9x/screenshot.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifdef HAVE_LIBPNG 8 | #include 9 | #endif 10 | #include "snes9x.h" 11 | #include "memmap.h" 12 | #include "display.h" 13 | #include "screenshot.h" 14 | 15 | 16 | bool8 S9xDoScreenshot (int width, int height) 17 | { 18 | Settings.TakeScreenshot = FALSE; 19 | 20 | #ifdef HAVE_LIBPNG 21 | FILE *fp; 22 | png_structp png_ptr; 23 | png_infop info_ptr; 24 | png_color_8 sig_bit; 25 | int imgwidth, imgheight; 26 | const char *fname; 27 | 28 | fname = S9xGetFilenameInc(".png", SCREENSHOT_DIR); 29 | 30 | fp = fopen(fname, "wb"); 31 | if (!fp) 32 | { 33 | S9xMessage(S9X_ERROR, 0, "Failed to take screenshot."); 34 | return (FALSE); 35 | } 36 | 37 | png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 38 | if (!png_ptr) 39 | { 40 | fclose(fp); 41 | remove(fname); 42 | S9xMessage(S9X_ERROR, 0, "Failed to take screenshot."); 43 | return (FALSE); 44 | } 45 | 46 | info_ptr = png_create_info_struct(png_ptr); 47 | if (!info_ptr) 48 | { 49 | png_destroy_write_struct(&png_ptr, (png_infopp) NULL); 50 | fclose(fp); 51 | remove(fname); 52 | S9xMessage(S9X_ERROR, 0, "Failed to take screenshot."); 53 | return (FALSE); 54 | } 55 | 56 | if (setjmp(png_jmpbuf(png_ptr))) 57 | { 58 | png_destroy_write_struct(&png_ptr, &info_ptr); 59 | fclose(fp); 60 | remove(fname); 61 | S9xMessage(S9X_ERROR, 0, "Failed to take screenshot."); 62 | return (FALSE); 63 | } 64 | 65 | imgwidth = width; 66 | imgheight = height; 67 | 68 | if (Settings.StretchScreenshots == 1) 69 | { 70 | if (width > SNES_WIDTH && height <= SNES_HEIGHT_EXTENDED) 71 | imgheight = height << 1; 72 | } 73 | else 74 | if (Settings.StretchScreenshots == 2) 75 | { 76 | if (width <= SNES_WIDTH) 77 | imgwidth = width << 1; 78 | if (height <= SNES_HEIGHT_EXTENDED) 79 | imgheight = height << 1; 80 | } 81 | 82 | png_init_io(png_ptr, fp); 83 | 84 | png_set_IHDR(png_ptr, info_ptr, imgwidth, imgheight, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 85 | 86 | sig_bit.red = 5; 87 | sig_bit.green = 5; 88 | sig_bit.blue = 5; 89 | png_set_sBIT(png_ptr, info_ptr, &sig_bit); 90 | png_set_shift(png_ptr, &sig_bit); 91 | 92 | png_write_info(png_ptr, info_ptr); 93 | 94 | png_set_packing(png_ptr); 95 | 96 | png_byte *row_pointer = new png_byte[png_get_rowbytes(png_ptr, info_ptr)]; 97 | uint16 *screen = GFX.Screen; 98 | 99 | for (int y = 0; y < height; y++, screen += GFX.RealPPL) 100 | { 101 | png_byte *rowpix = row_pointer; 102 | 103 | for (int x = 0; x < width; x++) 104 | { 105 | uint32 r, g, b; 106 | 107 | DECOMPOSE_PIXEL(screen[x], r, g, b); 108 | 109 | *(rowpix++) = r; 110 | *(rowpix++) = g; 111 | *(rowpix++) = b; 112 | 113 | if (imgwidth != width) 114 | { 115 | *(rowpix++) = r; 116 | *(rowpix++) = g; 117 | *(rowpix++) = b; 118 | } 119 | } 120 | 121 | png_write_row(png_ptr, row_pointer); 122 | if (imgheight != height) 123 | png_write_row(png_ptr, row_pointer); 124 | } 125 | 126 | delete [] row_pointer; 127 | 128 | png_write_end(png_ptr, info_ptr); 129 | png_destroy_write_struct(&png_ptr, &info_ptr); 130 | 131 | fclose(fp); 132 | 133 | fprintf(stderr, "%s saved.\n", fname); 134 | 135 | const char *base = S9xBasename(fname); 136 | sprintf(String, "Saved screenshot %s", base); 137 | S9xMessage(S9X_INFO, 0, String); 138 | 139 | return (TRUE); 140 | #else 141 | fprintf(stderr, "Screenshot support not available (libpng was not found at build time).\n"); 142 | return (FALSE); 143 | #endif 144 | } 145 | -------------------------------------------------------------------------------- /source/snes9x/screenshot.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _SCREENSHOT_H_ 8 | #define _SCREENSHOT_H_ 9 | 10 | bool8 S9xDoScreenshot (int, int); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /source/snes9x/sdd1.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #include "snes9x.h" 8 | #include "memmap.h" 9 | #include "sdd1.h" 10 | #include "display.h" 11 | 12 | 13 | void S9xSetSDD1MemoryMap (uint32 bank, uint32 value) 14 | { 15 | bank = 0xc00 + bank * 0x100; 16 | value = value * 1024 * 1024; 17 | 18 | for (int c = 0; c < 0x100; c += 16) 19 | { 20 | uint8 *block = &Memory.ROM[value + (c << 12)]; 21 | for (int i = c; i < c + 16; i++) 22 | Memory.Map[i + bank] = block; 23 | } 24 | } 25 | 26 | void S9xResetSDD1 (void) 27 | { 28 | memset(&Memory.FillRAM[0x4800], 0, 4); 29 | for (int i = 0; i < 4; i++) 30 | { 31 | Memory.FillRAM[0x4804 + i] = i; 32 | S9xSetSDD1MemoryMap(i, i); 33 | } 34 | } 35 | 36 | void S9xSDD1PostLoadState (void) 37 | { 38 | for (int i = 0; i < 4; i++) 39 | S9xSetSDD1MemoryMap(i, Memory.FillRAM[0x4804 + i]); 40 | } 41 | -------------------------------------------------------------------------------- /source/snes9x/sdd1.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _SDD1_H_ 8 | #define _SDD1_H_ 9 | 10 | void S9xSetSDD1MemoryMap (uint32, uint32); 11 | void S9xResetSDD1 (void); 12 | void S9xSDD1PostLoadState (void); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /source/snes9x/sdd1emu.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _SDD1EMU_H_ 8 | #define _SDD1EMU_H_ 9 | 10 | void SDD1_decompress (uint8 *, uint8 *, int); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /source/snes9x/seta.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #include "snes9x.h" 8 | #include "seta.h" 9 | 10 | uint8 (*GetSETA) (uint32) = &S9xGetST010; 11 | void (*SetSETA) (uint32, uint8) = &S9xSetST010; 12 | 13 | 14 | uint8 S9xGetSetaDSP (uint32 Address) 15 | { 16 | return (GetSETA(Address)); 17 | } 18 | 19 | void S9xSetSetaDSP (uint8 Byte, uint32 Address) 20 | { 21 | SetSETA (Address, Byte); 22 | } 23 | -------------------------------------------------------------------------------- /source/snes9x/seta.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _SETA_H_ 8 | #define _SETA_H_ 9 | 10 | #define ST_010 0x01 11 | #define ST_011 0x02 12 | #define ST_018 0x03 13 | 14 | struct SST010 15 | { 16 | uint8 input_params[16]; 17 | uint8 output_params[16]; 18 | uint8 op_reg; 19 | uint8 execute; 20 | bool8 control_enable; 21 | }; 22 | 23 | struct SST011 24 | { 25 | bool8 waiting4command; 26 | uint8 status; 27 | uint8 command; 28 | uint32 in_count; 29 | uint32 in_index; 30 | uint32 out_count; 31 | uint32 out_index; 32 | uint8 parameters[512]; 33 | uint8 output[512]; 34 | }; 35 | 36 | struct SST018 37 | { 38 | bool8 waiting4command; 39 | uint8 status; 40 | uint8 part_command; 41 | uint8 pass; 42 | uint32 command; 43 | uint32 in_count; 44 | uint32 in_index; 45 | uint32 out_count; 46 | uint32 out_index; 47 | uint8 parameters[512]; 48 | uint8 output[512]; 49 | }; 50 | 51 | extern struct SST010 ST010; 52 | extern struct SST011 ST011; 53 | extern struct SST018 ST018; 54 | 55 | uint8 S9xGetST010 (uint32); 56 | void S9xSetST010 (uint32, uint8); 57 | uint8 S9xGetST011 (uint32); 58 | void S9xSetST011 (uint32, uint8); 59 | uint8 S9xGetST018 (uint32); 60 | void S9xSetST018 (uint8, uint32); 61 | uint8 S9xGetSetaDSP (uint32); 62 | void S9xSetSetaDSP (uint8, uint32); 63 | 64 | extern uint8 (*GetSETA) (uint32); 65 | extern void (*SetSETA) (uint32, uint8); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /source/snes9x/seta011.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #include "snes9x.h" 8 | #include "memmap.h" 9 | #include "seta.h" 10 | 11 | static uint8 board[9][9]; // shougi playboard 12 | static int line = 0; // line counter 13 | 14 | 15 | uint8 S9xGetST011 (uint32 Address) 16 | { 17 | uint8 t; 18 | uint16 address = (uint16) Address & 0xFFFF; 19 | 20 | line++; 21 | 22 | // status check 23 | if (address == 0x01) 24 | t = 0xFF; 25 | else 26 | t = Memory.SRAM[address]; // read directly from s-ram 27 | 28 | #ifdef DEBUGGER 29 | if (address < 0x150) 30 | printf("ST011 R: %06X %02X\n", Address, t); 31 | #endif 32 | 33 | return (t); 34 | } 35 | 36 | void S9xSetST011 (uint32 Address, uint8 Byte) 37 | { 38 | static bool reset = false; 39 | uint16 address = (uint16) Address & 0xFFFF; 40 | 41 | line++; 42 | 43 | if (!reset) 44 | { 45 | // bootup values 46 | ST011.waiting4command = true; 47 | reset = true; 48 | } 49 | 50 | #ifdef DEBUGGER 51 | if (address < 0x150) 52 | printf("ST011 W: %06X %02X\n", Address, Byte); 53 | #endif 54 | 55 | Memory.SRAM[address] = Byte; 56 | 57 | // op commands/data goes through this address 58 | if (address == 0x00) 59 | { 60 | // check for new commands 61 | if (ST011.waiting4command) 62 | { 63 | ST011.waiting4command = false; 64 | ST011.command = Byte; 65 | ST011.in_index = 0; 66 | ST011.out_index = 0; 67 | 68 | switch (ST011.command) 69 | { 70 | case 0x01: ST011.in_count = 12 * 10 + 8; break; 71 | case 0x02: ST011.in_count = 4; break; 72 | case 0x04: ST011.in_count = 0; break; 73 | case 0x05: ST011.in_count = 0; break; 74 | case 0x06: ST011.in_count = 0; break; 75 | case 0x07: ST011.in_count = 0; break; 76 | case 0x0E: ST011.in_count = 0; break; 77 | default: ST011.waiting4command = true; break; 78 | } 79 | } 80 | else 81 | { 82 | ST011.parameters[ST011.in_index] = Byte; 83 | ST011.in_index++; 84 | } 85 | } 86 | 87 | if (ST011.in_count == ST011.in_index) 88 | { 89 | // actually execute the command 90 | ST011.waiting4command = true; 91 | ST011.out_index = 0; 92 | 93 | switch (ST011.command) 94 | { 95 | // unknown: download playboard 96 | case 0x01: 97 | // 9x9 board data: top to bottom, left to right 98 | // Values represent piece types and ownership 99 | for (int lcv = 0; lcv < 9; lcv++) 100 | memcpy(board[lcv], ST011.parameters + lcv * 10, 9 * 1); 101 | break; 102 | 103 | // unknown 104 | case 0x02: 105 | break; 106 | 107 | // unknown 108 | case 0x04: 109 | // outputs 110 | Memory.SRAM[0x12C] = 0x00; 111 | //Memory.SRAM[0x12D] = 0x00; 112 | Memory.SRAM[0x12E] = 0x00; 113 | break; 114 | 115 | // unknown 116 | case 0x05: 117 | // outputs 118 | Memory.SRAM[0x12C] = 0x00; 119 | //Memory.SRAM[0x12D] = 0x00; 120 | Memory.SRAM[0x12E] = 0x00; 121 | break; 122 | 123 | // unknown 124 | case 0x06: 125 | break; 126 | 127 | case 0x07: 128 | break; 129 | 130 | // unknown 131 | case 0x0E: 132 | // outputs 133 | Memory.SRAM[0x12C] = 0x00; 134 | Memory.SRAM[0x12D] = 0x00; 135 | break; 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /source/snes9x/sha256.h: -------------------------------------------------------------------------------- 1 | #ifndef __SHA256_H 2 | #define __SHA256_H 3 | 4 | void sha256sum (unsigned char *data, unsigned int length, unsigned char *hash); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /source/snes9x/snapshot.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _SNAPSHOT_H_ 8 | #define _SNAPSHOT_H_ 9 | 10 | #include "snes9x.h" 11 | 12 | #define SNAPSHOT_MAGIC "#!s9xsnp" 13 | #define SNAPSHOT_VERSION_IRQ 7 14 | #define SNAPSHOT_VERSION_BAPU 8 15 | #define SNAPSHOT_VERSION_IRQ_2018 11 // irq changes were introduced earlier, since this we store NextIRQTimer directly 16 | #define SNAPSHOT_VERSION 11 17 | 18 | #define SUCCESS 1 19 | #define WRONG_FORMAT (-1) 20 | #define WRONG_VERSION (-2) 21 | #define FILE_NOT_FOUND (-3) 22 | #define WRONG_MOVIE_SNAPSHOT (-4) 23 | #define NOT_A_MOVIE_SNAPSHOT (-5) 24 | #define SNAPSHOT_INCONSISTENT (-6) 25 | 26 | void S9xResetSaveTimer (bool8); 27 | bool8 S9xFreezeGame (const char *); 28 | uint32 S9xFreezeSize (void); 29 | bool8 S9xFreezeGameMem (uint8 *,uint32); 30 | bool8 S9xUnfreezeGame (const char *); 31 | int S9xUnfreezeGameMem (const uint8 *,uint32); 32 | void S9xFreezeToStream (STREAM); 33 | int S9xUnfreezeFromStream (STREAM); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /source/snes9x/spc7110.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _SPC7110_H_ 8 | #define _SPC7110_H_ 9 | 10 | #define SPC7110_DECOMP_BUFFER_SIZE 64 11 | 12 | // for snapshot only 13 | struct SSPC7110Snapshot 14 | { 15 | uint8 r4801; 16 | uint8 r4802; 17 | uint8 r4803; 18 | uint8 r4804; 19 | uint8 r4805; 20 | uint8 r4806; 21 | uint8 r4807; 22 | uint8 r4808; 23 | uint8 r4809; 24 | uint8 r480a; 25 | uint8 r480b; 26 | uint8 r480c; 27 | 28 | uint8 r4811; 29 | uint8 r4812; 30 | uint8 r4813; 31 | uint8 r4814; 32 | uint8 r4815; 33 | uint8 r4816; 34 | uint8 r4817; 35 | uint8 r4818; 36 | 37 | uint8 r481x; 38 | 39 | bool8 r4814_latch; // bool 40 | bool8 r4815_latch; // bool 41 | 42 | uint8 r4820; 43 | uint8 r4821; 44 | uint8 r4822; 45 | uint8 r4823; 46 | uint8 r4824; 47 | uint8 r4825; 48 | uint8 r4826; 49 | uint8 r4827; 50 | uint8 r4828; 51 | uint8 r4829; 52 | uint8 r482a; 53 | uint8 r482b; 54 | uint8 r482c; 55 | uint8 r482d; 56 | uint8 r482e; 57 | uint8 r482f; 58 | 59 | uint8 r4830; 60 | uint8 r4831; 61 | uint8 r4832; 62 | uint8 r4833; 63 | uint8 r4834; 64 | 65 | uint32 dx_offset; // unsigned 66 | uint32 ex_offset; // unsigned 67 | uint32 fx_offset; // unsigned 68 | 69 | uint8 r4840; 70 | uint8 r4841; 71 | uint8 r4842; 72 | 73 | int32 rtc_state; // enum RTC_State 74 | int32 rtc_mode; // enum RTC_Mode 75 | uint32 rtc_index; // unsigned 76 | 77 | uint32 decomp_mode; // unsigned 78 | uint32 decomp_offset; // unsigned 79 | 80 | uint8 decomp_buffer[SPC7110_DECOMP_BUFFER_SIZE]; 81 | 82 | uint32 decomp_buffer_rdoffset; // unsigned 83 | uint32 decomp_buffer_wroffset; // unsigned 84 | uint32 decomp_buffer_length; // unsigned 85 | 86 | struct ContextState 87 | { 88 | uint8 index; 89 | uint8 invert; 90 | } context[32]; 91 | }; 92 | 93 | extern struct SSPC7110Snapshot s7snap; 94 | 95 | void S9xInitSPC7110 (void); 96 | void S9xResetSPC7110 (void); 97 | void S9xSPC7110PreSaveState (void); 98 | void S9xSPC7110PostLoadState (int); 99 | void S9xSetSPC7110 (uint8, uint16); 100 | uint8 S9xGetSPC7110 (uint16); 101 | uint8 S9xGetSPC7110Byte (uint32); 102 | uint8 * S9xGetBasePointerSPC7110 (uint32); 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /source/snes9x/spc7110dec.h: -------------------------------------------------------------------------------- 1 | /***** 2 | * SPC7110 emulator - version 0.03 (2008-08-10) 3 | * Copyright (c) 2008, byuu and neviksti 4 | * 5 | * Permission to use, copy, modify, and/or distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * The software is provided "as is" and the author disclaims all warranties 10 | * with regard to this software including all implied warranties of 11 | * merchantibility and fitness, in no event shall the author be liable for 12 | * any special, direct, indirect, or consequential damages or any damages 13 | * whatsoever resulting from loss of use, data or profits, whether in an 14 | * action of contract, negligence or other tortious action, arising out of 15 | * or in connection with the use or performance of this software. 16 | *****/ 17 | 18 | 19 | #ifndef _SPC7110DEC_H_ 20 | #define _SPC7110DEC_H_ 21 | 22 | class SPC7110Decomp { 23 | public: 24 | uint8 read(); 25 | void init(unsigned mode, unsigned offset, unsigned index); 26 | void reset(); 27 | 28 | SPC7110Decomp(); 29 | ~SPC7110Decomp(); 30 | 31 | unsigned decomp_mode; 32 | unsigned decomp_offset; 33 | 34 | //read() will spool chunks half the size of decomp_buffer_size 35 | enum { decomp_buffer_size = SPC7110_DECOMP_BUFFER_SIZE }; //must be >= 64, and must be a power of two 36 | uint8 *decomp_buffer; 37 | unsigned decomp_buffer_rdoffset; 38 | unsigned decomp_buffer_wroffset; 39 | unsigned decomp_buffer_length; 40 | 41 | void write(uint8 data); 42 | uint8 dataread(); 43 | 44 | void mode0(bool init); 45 | void mode1(bool init); 46 | void mode2(bool init); 47 | 48 | static const uint8 evolution_table[53][4]; 49 | static const uint8 mode2_context_table[32][2]; 50 | 51 | struct ContextState { 52 | uint8 index; 53 | uint8 invert; 54 | } context[32]; 55 | 56 | uint8 probability(unsigned n); 57 | uint8 next_lps(unsigned n); 58 | uint8 next_mps(unsigned n); 59 | bool toggle_invert(unsigned n); 60 | 61 | unsigned morton16[2][256]; 62 | unsigned morton32[4][256]; 63 | unsigned morton_2x8(unsigned data); 64 | unsigned morton_4x8(unsigned data); 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /source/snes9x/spc7110emu.h: -------------------------------------------------------------------------------- 1 | /***** 2 | * SPC7110 emulator - version 0.03 (2008-08-10) 3 | * Copyright (c) 2008, byuu and neviksti 4 | * 5 | * Permission to use, copy, modify, and/or distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * The software is provided "as is" and the author disclaims all warranties 10 | * with regard to this software including all implied warranties of 11 | * merchantibility and fitness, in no event shall the author be liable for 12 | * any special, direct, indirect, or consequential damages or any damages 13 | * whatsoever resulting from loss of use, data or profits, whether in an 14 | * action of contract, negligence or other tortious action, arising out of 15 | * or in connection with the use or performance of this software. 16 | *****/ 17 | 18 | 19 | #ifndef _SPC7110EMU_H_ 20 | #define _SPC7110EMU_H_ 21 | 22 | #include "spc7110dec.h" 23 | 24 | class SPC7110 { 25 | public: 26 | void init(); 27 | void enable(); 28 | void power(); 29 | void reset(); 30 | 31 | unsigned datarom_addr(unsigned addr); 32 | 33 | unsigned data_pointer(); 34 | unsigned data_adjust(); 35 | unsigned data_increment(); 36 | void set_data_pointer(unsigned addr); 37 | void set_data_adjust(unsigned addr); 38 | 39 | void update_time(int offset = 0); 40 | time_t create_time(); 41 | 42 | uint8 mmio_read (unsigned addr); 43 | void mmio_write(unsigned addr, uint8 data); 44 | 45 | uint8 read (unsigned addr); 46 | void write(unsigned addr, uint8 data); 47 | 48 | //spc7110decomp 49 | void decomp_init(); 50 | uint8 decomp_read(); 51 | 52 | SPC7110(); 53 | 54 | //================== 55 | //decompression unit 56 | //================== 57 | uint8 r4801; //compression table low 58 | uint8 r4802; //compression table high 59 | uint8 r4803; //compression table bank 60 | uint8 r4804; //compression table index 61 | uint8 r4805; //decompression buffer index low 62 | uint8 r4806; //decompression buffer index high 63 | uint8 r4807; //??? 64 | uint8 r4808; //??? 65 | uint8 r4809; //compression length low 66 | uint8 r480a; //compression length high 67 | uint8 r480b; //decompression control register 68 | uint8 r480c; //decompression status 69 | 70 | SPC7110Decomp decomp; 71 | 72 | //============== 73 | //data port unit 74 | //============== 75 | uint8 r4811; //data pointer low 76 | uint8 r4812; //data pointer high 77 | uint8 r4813; //data pointer bank 78 | uint8 r4814; //data adjust low 79 | uint8 r4815; //data adjust high 80 | uint8 r4816; //data increment low 81 | uint8 r4817; //data increment high 82 | uint8 r4818; //data port control register 83 | 84 | uint8 r481x; 85 | 86 | bool r4814_latch; 87 | bool r4815_latch; 88 | 89 | //========= 90 | //math unit 91 | //========= 92 | uint8 r4820; //16-bit multiplicand B0, 32-bit dividend B0 93 | uint8 r4821; //16-bit multiplicand B1, 32-bit dividend B1 94 | uint8 r4822; //32-bit dividend B2 95 | uint8 r4823; //32-bit dividend B3 96 | uint8 r4824; //16-bit multiplier B0 97 | uint8 r4825; //16-bit multiplier B1 98 | uint8 r4826; //16-bit divisor B0 99 | uint8 r4827; //16-bit divisor B1 100 | uint8 r4828; //32-bit product B0, 32-bit quotient B0 101 | uint8 r4829; //32-bit product B1, 32-bit quotient B1 102 | uint8 r482a; //32-bit product B2, 32-bit quotient B2 103 | uint8 r482b; //32-bit product B3, 32-bit quotient B3 104 | uint8 r482c; //16-bit remainder B0 105 | uint8 r482d; //16-bit remainder B1 106 | uint8 r482e; //math control register 107 | uint8 r482f; //math status 108 | 109 | //=================== 110 | //memory mapping unit 111 | //=================== 112 | uint8 r4830; //SRAM write enable 113 | uint8 r4831; //$[d0-df]:[0000-ffff] mapping 114 | uint8 r4832; //$[e0-ef]:[0000-ffff] mapping 115 | uint8 r4833; //$[f0-ff]:[0000-ffff] mapping 116 | uint8 r4834; //??? 117 | 118 | unsigned dx_offset; 119 | unsigned ex_offset; 120 | unsigned fx_offset; 121 | 122 | //==================== 123 | //real-time clock unit 124 | //==================== 125 | uint8 r4840; //RTC latch 126 | uint8 r4841; //RTC index/data port 127 | uint8 r4842; //RTC status 128 | 129 | enum RTC_State { RTCS_Inactive, RTCS_ModeSelect, RTCS_IndexSelect, RTCS_Write } rtc_state; 130 | enum RTC_Mode { RTCM_Linear = 0x03, RTCM_Indexed = 0x0c } rtc_mode; 131 | unsigned rtc_index; 132 | 133 | static const unsigned months[12]; 134 | }; 135 | 136 | #endif 137 | -------------------------------------------------------------------------------- /source/snes9x/srtc.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | /***** 8 | * S-RTC emulation code 9 | * Copyright (c) byuu 10 | *****/ 11 | 12 | 13 | #include 14 | 15 | #include "snes9x.h" 16 | #include "memmap.h" 17 | #include "srtc.h" 18 | #include "display.h" 19 | 20 | #define memory_cartrtc_read(a) RTCData.reg[(a)] 21 | #define memory_cartrtc_write(a, b) { RTCData.reg[(a)] = (b); } 22 | #define cpu_regs_mdr OpenBus 23 | 24 | static inline unsigned max (unsigned a, unsigned b) 25 | { 26 | return ((a > b) ? a : b); 27 | } 28 | 29 | static inline unsigned min (unsigned a, unsigned b) 30 | { 31 | return ((a < b) ? a : b); 32 | } 33 | 34 | #define _SRTCEMU_CPP_ 35 | 36 | #include "srtcemu.h" 37 | #include "srtcemu.cpp" 38 | 39 | static SRTC srtcemu; 40 | 41 | 42 | void S9xInitSRTC (void) 43 | { 44 | srtcemu.power(); 45 | memset(RTCData.reg, 0, 20); 46 | } 47 | 48 | void S9xResetSRTC (void) 49 | { 50 | srtcemu.reset(); 51 | } 52 | 53 | void S9xSetSRTC (uint8 data, uint16 address) 54 | { 55 | srtcemu.mmio_write(address, data); 56 | } 57 | 58 | uint8 S9xGetSRTC (uint16 address) 59 | { 60 | return (srtcemu.mmio_read(address)); 61 | } 62 | 63 | void S9xSRTCPreSaveState (void) 64 | { 65 | srtcsnap.rtc_mode = (int32) srtcemu.rtc_mode; 66 | srtcsnap.rtc_index = (int32) srtcemu.rtc_index; 67 | } 68 | 69 | void S9xSRTCPostLoadState (int) 70 | { 71 | srtcemu.rtc_mode = (SRTC::RTC_Mode) srtcsnap.rtc_mode; 72 | srtcemu.rtc_index = (signed) srtcsnap.rtc_index; 73 | 74 | srtcemu.update_time(); 75 | } 76 | -------------------------------------------------------------------------------- /source/snes9x/srtc.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _SRTC_H_ 8 | #define _SRTC_H_ 9 | 10 | struct SRTCData 11 | { 12 | uint8 reg[20]; 13 | }; 14 | 15 | // for snapshot only 16 | struct SSRTCSnapshot 17 | { 18 | int32 rtc_mode; // enum RTC_Mode 19 | int32 rtc_index; // signed 20 | }; 21 | 22 | extern struct SRTCData RTCData; 23 | extern struct SSRTCSnapshot srtcsnap; 24 | 25 | void S9xInitSRTC (void); 26 | void S9xResetSRTC (void); 27 | void S9xSRTCPreSaveState (void); 28 | void S9xSRTCPostLoadState (int); 29 | void S9xSetSRTC (uint8, uint16); 30 | uint8 S9xGetSRTC (uint16); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /source/snes9x/srtcemu.h: -------------------------------------------------------------------------------- 1 | /***** 2 | * S-RTC emulation code 3 | * Copyright (c) byuu 4 | *****/ 5 | 6 | 7 | #ifndef _SRTCEMU_H_ 8 | #define _SRTCEMU_H_ 9 | 10 | class SRTC { 11 | public: 12 | void update_time(); 13 | unsigned weekday(unsigned year, unsigned month, unsigned day); 14 | 15 | void init(); 16 | void enable(); 17 | void power(); 18 | void reset(); 19 | 20 | uint8 mmio_read (unsigned addr); 21 | void mmio_write(unsigned addr, uint8 data); 22 | 23 | SRTC(); 24 | 25 | static const unsigned months[12]; 26 | enum RTC_Mode { RTCM_Ready, RTCM_Command, RTCM_Read, RTCM_Write } rtc_mode; 27 | signed rtc_index; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /source/snes9x/stream.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _STREAM_H_ 8 | #define _STREAM_H_ 9 | 10 | #include 11 | 12 | class Stream 13 | { 14 | public: 15 | Stream (void); 16 | virtual ~Stream (void); 17 | virtual int get_char (void) = 0; 18 | virtual char * gets (char *, size_t) = 0; 19 | virtual char * getline (void); // free() when done 20 | virtual std::string getline (bool &); 21 | virtual size_t read (void *, size_t) = 0; 22 | virtual size_t write (void *, size_t) = 0; 23 | virtual size_t pos (void) = 0; 24 | virtual size_t size (void) = 0; 25 | virtual int revert (uint8 origin, int32 offset) = 0; 26 | virtual void closeStream() = 0; 27 | 28 | protected: 29 | size_t pos_from_origin_offset(uint8 origin, int32 offset); 30 | }; 31 | 32 | class fStream : public Stream 33 | { 34 | public: 35 | fStream (FSTREAM); 36 | virtual ~fStream (void); 37 | virtual int get_char (void); 38 | virtual char * gets (char *, size_t); 39 | virtual size_t read (void *, size_t); 40 | virtual size_t write (void *, size_t); 41 | virtual size_t pos (void); 42 | virtual size_t size (void); 43 | virtual int revert (uint8 origin, int32 offset); 44 | virtual void closeStream(); 45 | 46 | private: 47 | FSTREAM fp; 48 | }; 49 | 50 | #ifdef UNZIP_SUPPORT 51 | # ifdef SYSTEM_ZIP 52 | # include 53 | # else 54 | # include "unzip.h" 55 | # endif 56 | 57 | #define unz_BUFFSIZ 1024 58 | 59 | class unzStream : public Stream 60 | { 61 | public: 62 | unzStream (unzFile &); 63 | virtual ~unzStream (void); 64 | virtual int get_char (void); 65 | virtual char * gets (char *, size_t); 66 | virtual size_t read (void *, size_t); 67 | virtual size_t write (void *, size_t); 68 | virtual size_t pos (void); 69 | virtual size_t size (void); 70 | virtual int revert (uint8 origin, int32 offset); 71 | virtual void closeStream(); 72 | 73 | private: 74 | void fill_buffer(); 75 | size_t buffer_remaining(); 76 | 77 | unzFile file; 78 | char buffer[unz_BUFFSIZ]; 79 | size_t pos_in_buf; 80 | size_t buf_pos_in_unzipped; 81 | size_t bytes_in_buf; 82 | unz_file_pos unz_file_start_pos; 83 | }; 84 | 85 | #endif 86 | 87 | class memStream : public Stream 88 | { 89 | public: 90 | memStream (uint8 *,size_t); 91 | memStream (const uint8 *,size_t); 92 | virtual ~memStream (void); 93 | virtual int get_char (void); 94 | virtual char * gets (char *, size_t); 95 | virtual size_t read (void *, size_t); 96 | virtual size_t write (void *, size_t); 97 | virtual size_t pos (void); 98 | virtual size_t size (void); 99 | virtual int revert (uint8 origin, int32 offset); 100 | virtual void closeStream(); 101 | 102 | private: 103 | uint8 *mem; 104 | size_t msize; 105 | size_t remaining; 106 | uint8 *head; 107 | bool readonly; 108 | }; 109 | 110 | /* dummy stream that always reads 0 and writes nowhere 111 | but counts bytes written 112 | */ 113 | class nulStream : public Stream 114 | { 115 | public: 116 | nulStream (void); 117 | virtual ~nulStream (void); 118 | virtual int get_char (void); 119 | virtual char * gets (char *, size_t); 120 | virtual size_t read (void *, size_t); 121 | virtual size_t write (void *, size_t); 122 | virtual size_t pos (void); 123 | virtual size_t size (void); 124 | virtual int revert (uint8 origin, int32 offset); 125 | virtual void closeStream(); 126 | 127 | private: 128 | size_t bytes_written; 129 | }; 130 | 131 | Stream *openStreamFromFSTREAM(const char* filename, const char* mode); 132 | Stream *reopenStreamFromFd(int fd, const char* mode); 133 | 134 | 135 | #endif 136 | -------------------------------------------------------------------------------- /source/snes9x/tile.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #ifndef _TILE_H_ 8 | #define _TILE_H_ 9 | 10 | void S9xInitTileRenderer (void); 11 | void S9xSelectTileRenderers (int, bool8, bool8); 12 | void S9xSelectTileConverter (int, bool8, bool8, bool8); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /source/snes9x/tileimpl-h2x1.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #define _TILEIMPL_CPP_ 8 | #include "tileimpl.h" 9 | 10 | namespace TileImpl { 11 | 12 | template 13 | void HiresBase::Draw(int N, int M, uint32 Offset, uint32 OffsetInLine, uint8 Pix, uint8 Z1, uint8 Z2) 14 | { 15 | if (Z1 > GFX.DB[Offset + 2 * N] && (M)) 16 | { 17 | GFX.S[Offset + 2 * N + 1] = MATH::Calc(GFX.ScreenColors[Pix], GFX.SubScreen[Offset + 2 * N], GFX.SubZBuffer[Offset + 2 * N]); 18 | if ((OffsetInLine + 2 * N ) != (SNES_WIDTH - 1) << 1) 19 | GFX.S[Offset + 2 * N + 2] = MATH::Calc((GFX.ClipColors ? 0 : GFX.SubScreen[Offset + 2 * N + 2]), GFX.RealScreenColors[Pix], GFX.SubZBuffer[Offset + 2 * N]); 20 | if ((OffsetInLine + 2 * N) == 0 || (OffsetInLine + 2 * N) == GFX.RealPPL) 21 | GFX.S[Offset + 2 * N] = MATH::Calc((GFX.ClipColors ? 0 : GFX.SubScreen[Offset + 2 * N]), GFX.RealScreenColors[Pix], GFX.SubZBuffer[Offset + 2 * N]); 22 | GFX.DB[Offset + 2 * N] = GFX.DB[Offset + 2 * N + 1] = Z2; 23 | } 24 | } 25 | 26 | 27 | // hires double width 28 | template struct Renderers; 29 | template struct Renderers; 30 | template struct Renderers; 31 | template struct Renderers; 32 | template struct Renderers; 33 | template struct Renderers; 34 | template struct Renderers; 35 | template struct Renderers; 36 | 37 | // hires double width interlace 38 | template struct Renderers; 39 | template struct Renderers; 40 | template struct Renderers; 41 | //template struct Renderers; 42 | //template struct Renderers; 43 | //template struct Renderers; 44 | //template struct Renderers; 45 | //template struct Renderers; 46 | 47 | } // namespace TileImpl 48 | -------------------------------------------------------------------------------- /source/snes9x/tileimpl-n1x1.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #define _TILEIMPL_CPP_ 8 | #include "tileimpl.h" 9 | 10 | namespace TileImpl { 11 | 12 | template 13 | void Normal1x1Base::Draw(int N, int M, uint32 Offset, uint32 OffsetInLine, uint8 Pix, uint8 Z1, uint8 Z2) 14 | { 15 | (void) OffsetInLine; 16 | if (Z1 > GFX.DB[Offset + N] && (M)) 17 | { 18 | GFX.S[Offset + N] = MATH::Calc(GFX.ScreenColors[Pix], GFX.SubScreen[Offset + N], GFX.SubZBuffer[Offset + N]); 19 | GFX.DB[Offset + N] = Z2; 20 | } 21 | } 22 | 23 | 24 | // normal width 25 | template struct Renderers; 26 | template struct Renderers; 27 | template struct Renderers; 28 | template struct Renderers; 29 | template struct Renderers; 30 | template struct Renderers; 31 | template struct Renderers; 32 | template struct Renderers; 33 | 34 | } // namespace TileImpl 35 | -------------------------------------------------------------------------------- /source/snes9x/tileimpl-n2x1.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************\ 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | This file is licensed under the Snes9x License. 4 | For further information, consult the LICENSE file in the root directory. 5 | \*****************************************************************************/ 6 | 7 | #define _TILEIMPL_CPP_ 8 | #include "tileimpl.h" 9 | 10 | namespace TileImpl { 11 | 12 | template 13 | void Normal2x1Base::Draw(int N, int M, uint32 Offset, uint32 OffsetInLine, uint8 Pix, uint8 Z1, uint8 Z2) 14 | { 15 | (void) OffsetInLine; 16 | if (Z1 > GFX.DB[Offset + 2 * N] && (M)) 17 | { 18 | GFX.S[Offset + 2 * N] = GFX.S[Offset + 2 * N + 1] = MATH::Calc(GFX.ScreenColors[Pix], GFX.SubScreen[Offset + 2 * N], GFX.SubZBuffer[Offset + 2 * N]); 19 | GFX.DB[Offset + 2 * N] = GFX.DB[Offset + 2 * N + 1] = Z2; 20 | } 21 | } 22 | 23 | 24 | // normal double width 25 | template struct Renderers; 26 | template struct Renderers; 27 | template struct Renderers; 28 | template struct Renderers; 29 | template struct Renderers; 30 | template struct Renderers; 31 | template struct Renderers; 32 | template struct Renderers; 33 | 34 | // normal double width interlace 35 | template struct Renderers; 36 | template struct Renderers; 37 | template struct Renderers; 38 | //template struct Renderers; 39 | //template struct Renderers; 40 | //template struct Renderers; 41 | //template struct Renderers; 42 | //template struct Renderers; 43 | 44 | } // namespace TileImpl 45 | -------------------------------------------------------------------------------- /source/sounds/button_click.pcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/sounds/button_click.pcm -------------------------------------------------------------------------------- /source/sounds/button_over.pcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/sounds/button_over.pcm -------------------------------------------------------------------------------- /source/sounds/enter.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/sounds/enter.ogg -------------------------------------------------------------------------------- /source/sram.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * crunchy2 April 2007-July 2007 5 | * Michniewski 2008 6 | * Tantric 2008-2022 7 | * 8 | * sram.cpp 9 | * 10 | * SRAM save/load/import/export handling 11 | ***************************************************************************/ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "snes9xtx.h" 19 | #include "menu.h" 20 | #include "fileop.h" 21 | #include "filebrowser.h" 22 | #include "input.h" 23 | #include "snes9x/snes9x.h" 24 | #include "snes9x/memmap.h" 25 | #include "snes9x/srtc.h" 26 | 27 | bool HiROM; 28 | bool LoROM; 29 | 30 | /**************************************************************************** 31 | * Load SRAM 32 | ***************************************************************************/ 33 | bool 34 | LoadSRAM (char * filepath, bool silent) 35 | { 36 | int len = 0; 37 | int device; 38 | bool result = false; 39 | 40 | if(!FindDevice(filepath, &device)) 41 | return 0; 42 | 43 | Memory.ClearSRAM(); 44 | 45 | int size = Memory.SRAMSize ? (1 << (Memory.SRAMSize + 3)) * 128 : 0; 46 | 47 | if (LoROM) 48 | size = size < 0x70000 ? size : 0x70000; 49 | else if (HiROM) 50 | size = size < 0x40000 ? size : 0x40000; 51 | 52 | if (size) 53 | { 54 | len = LoadFile((char *)Memory.SRAM, filepath, 0, size, silent); 55 | 56 | if (len > 0) 57 | { 58 | if (len - size == 512) 59 | memmove(Memory.SRAM, Memory.SRAM + 512, size); 60 | 61 | if (Settings.SRTC || Settings.SPC7110RTC) 62 | { 63 | int pathlen = strlen(filepath); 64 | filepath[pathlen-3] = 'r'; 65 | filepath[pathlen-2] = 't'; 66 | filepath[pathlen-1] = 'c'; 67 | LoadFile((char *)RTCData.reg, filepath, 0, 20, silent); 68 | } 69 | result = true; 70 | } 71 | else if(!silent) 72 | { 73 | // if we reached here, nothing was done! 74 | ErrorPrompt("SRAM file not found"); 75 | } 76 | S9xSoftReset(); 77 | } 78 | return result; 79 | } 80 | 81 | bool 82 | LoadSRAMAuto (bool silent) 83 | { 84 | char filepath[MAXPATHLEN]; 85 | 86 | // look for Auto save file 87 | if(!MakeFilePath(filepath, FILE_SRAM, Memory.ROMFilename, 0)) 88 | return false; 89 | 90 | if (LoadSRAM(filepath, silent)) 91 | return true; 92 | 93 | // look for file with no number 94 | if(!MakeFilePath(filepath, FILE_SRAM, Memory.ROMFilename, -1)) 95 | return false; 96 | 97 | if(LoadSRAM(filepath, silent)) 98 | return true; 99 | 100 | return false; 101 | } 102 | 103 | /**************************************************************************** 104 | * Save SRAM 105 | ***************************************************************************/ 106 | bool 107 | SaveSRAM (char * filepath, bool silent) 108 | { 109 | bool retval = false; 110 | int offset = 0; 111 | int device; 112 | 113 | if(!FindDevice(filepath, &device)) 114 | return 0; 115 | 116 | if (Settings.SuperFX && Memory.ROMType < 0x15) // doesn't have SRAM 117 | return true; 118 | 119 | if (Settings.SA1 && Memory.ROMType == 0x34) // doesn't have SRAM 120 | return true; 121 | 122 | // determine SRAM size 123 | int size = Memory.SRAMSize ? (1 << (Memory.SRAMSize + 3)) * 128 : 0; 124 | 125 | if (LoROM) 126 | size = size < 0x70000 ? size : 0x70000; 127 | else if (HiROM) 128 | size = size < 0x40000 ? size : 0x40000; 129 | 130 | if (size > 0) 131 | { 132 | offset = SaveFile((char *)Memory.SRAM, filepath, size, silent); 133 | 134 | if (Settings.SRTC || Settings.SPC7110RTC) 135 | { 136 | int pathlen = strlen(filepath); 137 | filepath[pathlen-3] = 'r'; 138 | filepath[pathlen-2] = 't'; 139 | filepath[pathlen-1] = 'c'; 140 | SaveFile((char *)RTCData.reg, filepath, 20, silent); 141 | } 142 | 143 | if (offset > 0) 144 | { 145 | if (!silent) 146 | InfoPrompt("Save successful"); 147 | retval = true; 148 | } 149 | } 150 | else 151 | { 152 | if(!silent) 153 | ErrorPrompt("No SRAM data to save!"); 154 | } 155 | return retval; 156 | } 157 | 158 | bool 159 | SaveSRAMAuto (bool silent) 160 | { 161 | char filepath[1024]; 162 | 163 | // look for file with no number 164 | if(!MakeFilePath(filepath, FILE_SRAM, Memory.ROMFilename, -1)) 165 | return false; 166 | 167 | FILE * fp = fopen (filepath, "rb"); 168 | 169 | if(fp) // file found 170 | { 171 | fclose (fp); 172 | } 173 | else 174 | { 175 | if(!MakeFilePath(filepath, FILE_SRAM, Memory.ROMFilename, 0)) 176 | return false; 177 | } 178 | 179 | return SaveSRAM(filepath, silent); 180 | } 181 | -------------------------------------------------------------------------------- /source/sram.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * crunchy2 April 2007-July 2007 5 | * Michniewski 2008 6 | * Tantric 2008-2022 7 | * 8 | * sram.cpp 9 | * 10 | * SRAM save/load/import/export handling 11 | ***************************************************************************/ 12 | 13 | bool SaveSRAM (char * filepath, bool silent); 14 | bool SaveSRAMAuto (bool silent); 15 | bool LoadSRAM (char * filepath, bool silent); 16 | bool LoadSRAMAuto (bool silent); 17 | -------------------------------------------------------------------------------- /source/utils/gettext.h: -------------------------------------------------------------------------------- 1 | #ifndef _GETTEXT_H_ 2 | #define _GETTEXT_H_ 3 | 4 | bool LoadLanguage(); 5 | 6 | /* 7 | * input msg = a text in ASCII 8 | * output = the translated msg in utf-8 9 | */ 10 | const char *gettext(const char *msg); 11 | 12 | #endif /* _GETTEXT_H_ */ 13 | -------------------------------------------------------------------------------- /source/utils/mayflash.c: -------------------------------------------------------------------------------- 1 | #ifdef HW_RVL 2 | #include 3 | 4 | #define MAYFLASH_VID 0x0E8F 5 | #define MAYFLASH_PID 0x3013 6 | 7 | static bool setup = false; 8 | static bool replugRequired = false; 9 | static s32 deviceId = 0; 10 | static u8 endpoint = 0; 11 | static u8 bMaxPacketSize = 0; 12 | static u32 jpMayflash[2]; 13 | 14 | static bool isMayflashGamepad(usb_device_entry dev) 15 | { 16 | return dev.vid == MAYFLASH_VID && dev.pid == MAYFLASH_PID; 17 | } 18 | 19 | static u8 getEndpoint(usb_devdesc devdesc) 20 | { 21 | if (devdesc.configurations == NULL || devdesc.configurations->interfaces == NULL || 22 | devdesc.configurations->interfaces->endpoints == NULL) 23 | { 24 | return -1; 25 | } 26 | return devdesc.configurations->interfaces->endpoints->bEndpointAddress; 27 | } 28 | 29 | static int removal_cb(int result, void *usrdata) 30 | { 31 | s32 fd = (s32) usrdata; 32 | if (fd == deviceId) 33 | { 34 | deviceId = 0; 35 | } 36 | return 1; 37 | } 38 | 39 | static void open() 40 | { 41 | if (deviceId != 0) 42 | { 43 | return; 44 | } 45 | 46 | usb_device_entry dev_entry[8]; 47 | u8 dev_count; 48 | if (USB_GetDeviceList(dev_entry, 8, USB_CLASS_HID, &dev_count) < 0) 49 | { 50 | return; 51 | } 52 | 53 | for (int i = 0; i < dev_count; ++i) 54 | { 55 | if (!isMayflashGamepad(dev_entry[i])) 56 | { 57 | continue; 58 | } 59 | s32 fd; 60 | if (USB_OpenDevice(dev_entry[i].device_id, dev_entry[i].vid, dev_entry[i].pid, &fd) < 0) 61 | { 62 | continue; 63 | } 64 | 65 | usb_devdesc devdesc; 66 | if (USB_GetDescriptors(fd, &devdesc) < 0) 67 | { 68 | // You have to replug the controller! 69 | replugRequired = true; 70 | USB_CloseDevice(&fd); 71 | break; 72 | } 73 | 74 | deviceId = fd; 75 | replugRequired = false; 76 | endpoint = getEndpoint(devdesc); 77 | bMaxPacketSize = devdesc.bMaxPacketSize0; 78 | USB_DeviceRemovalNotifyAsync(fd, &removal_cb, (void*) fd); 79 | break; 80 | } 81 | 82 | setup = true; 83 | } 84 | 85 | void Mayflash_ScanPads() 86 | { 87 | if (deviceId == 0) 88 | { 89 | return; 90 | } 91 | 92 | uint8_t ATTRIBUTE_ALIGN(32) buf[bMaxPacketSize]; 93 | s32 res = USB_ReadIntrMsg(deviceId, endpoint, sizeof(buf), buf); 94 | if (res < 0) 95 | { 96 | return; 97 | } 98 | 99 | // buf[0] contains the port returned 100 | // you have to make 2 calls to get the status, even if you're only interested in one port 101 | // because it is not sure which port is returned first 102 | 103 | // 1 = Right port 104 | // 2 = Left port 105 | 106 | // Button layout 107 | // A=5,2F 108 | // B=5,4F 109 | // X=5,1F 110 | // Y=5,8F 111 | // Select=6,10 112 | // Start=6,20 113 | // Up=4,00 114 | // Right=3,FF 115 | // Left=3,00 116 | // Down=4,FF 117 | // L=6,04 118 | // R=6,08 119 | 120 | u32 jp = 0; 121 | jp |= (buf[4] == 0x00) ? PAD_BUTTON_UP : 0; 122 | jp |= (buf[4] == 0xFF) ? PAD_BUTTON_DOWN : 0; 123 | jp |= (buf[3] == 0x00) ? PAD_BUTTON_LEFT : 0; 124 | jp |= (buf[3] == 0xFF) ? PAD_BUTTON_RIGHT : 0; 125 | 126 | jp |= ((buf[5] & 0x2F) == 0x2F) ? PAD_BUTTON_A : 0; 127 | jp |= ((buf[5] & 0x4F) == 0x4F) ? PAD_BUTTON_B : 0; 128 | jp |= ((buf[5] & 0x1F) == 0x1F) ? PAD_BUTTON_X : 0; 129 | jp |= ((buf[5] & 0x8F) == 0x8F) ? PAD_BUTTON_Y : 0; 130 | 131 | jp |= ((buf[6] & 0x04) == 0x04) ? PAD_TRIGGER_L : 0; 132 | jp |= ((buf[6] & 0x08) == 0x08) ? PAD_TRIGGER_R : 0; 133 | 134 | jp |= ((buf[6] & 0x20) == 0x20) ? PAD_BUTTON_START : 0; 135 | jp |= ((buf[6] & 0x10) == 0x10) ? PAD_TRIGGER_Z : 0; // SNES select button maps to Z 136 | 137 | // Required, otherwise if the returned port isn't the one we are looking for, jp will be set to zero, 138 | // and held buttons are not possible 139 | 140 | jpMayflash[buf[0] - 1] = jp; 141 | } 142 | 143 | u32 Mayflash_ButtonsHeld(int chan) 144 | { 145 | if(!setup) 146 | { 147 | open(); 148 | } 149 | if (deviceId == 0) 150 | { 151 | return 0; 152 | } 153 | return jpMayflash[chan]; 154 | } 155 | 156 | char* Mayflash_Status() 157 | { 158 | open(); 159 | if (replugRequired) 160 | return "please replug"; 161 | return deviceId ? "connected" : "not found"; 162 | } 163 | 164 | #endif 165 | -------------------------------------------------------------------------------- /source/utils/mayflash.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAYFLASH_H_ 2 | #define _MAYFLASH_H_ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | bool Mayflash_ScanPads(); 11 | u32 Mayflash_ButtonsHeld(int chan); 12 | char* Mayflash_Status(); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /source/utils/oggplayer.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/utils/oggplayer.c -------------------------------------------------------------------------------- /source/utils/oggplayer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saulfabregwiivc/Snes9xTX/5222c7ae890be933d273465f9e62d4db90c2fe97/source/utils/oggplayer.h -------------------------------------------------------------------------------- /source/utils/pngu.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************** 2 | * 3 | * PNGU 4 | * 5 | * Original author: frontier (http://frontier-dev.net) 6 | * Modified by Tantric, 2009-2010 7 | * 8 | ********************************************************************************************/ 9 | 10 | #ifndef __PNGU__ 11 | #define __PNGU__ 12 | 13 | #include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | typedef struct 20 | { 21 | u8 r; 22 | u8 g; 23 | u8 b; 24 | } PNGUCOLOR; 25 | 26 | typedef struct 27 | { 28 | u32 imgWidth; // In pixels 29 | u32 imgHeight; // In pixels 30 | u32 imgBitDepth; // In bitx 31 | u32 imgColorType; // PNGU_COLOR_TYPE_* 32 | u32 validBckgrnd; // Non zero if there is a background color 33 | PNGUCOLOR bckgrnd; // Background color 34 | u32 numTrans; // Number of transparent colors 35 | PNGUCOLOR *trans; // Transparent colors 36 | } PNGUPROP; 37 | 38 | // Image context, always initialize with SelectImageFrom* and free with ReleaseImageContext 39 | struct _IMGCTX; 40 | typedef struct _IMGCTX *IMGCTX; 41 | 42 | /**************************************************************************** 43 | * Image context handling * 44 | ****************************************************************************/ 45 | 46 | // Selects a PNG file, previously loaded into a buffer, and creates an image context for subsequent processing. 47 | IMGCTX PNGU_SelectImageFromBuffer (const void *buffer); 48 | 49 | // Selects a PNG file, from any devoptab device, and creates an image context for subsequent processing. 50 | IMGCTX PNGU_SelectImageFromDevice (const char *filename); 51 | 52 | // Frees resources associated with an image context. Always call this function when you no longer need the IMGCTX. 53 | void PNGU_ReleaseImageContext (IMGCTX ctx); 54 | 55 | /**************************************************************************** 56 | * Miscellaneous * 57 | ****************************************************************************/ 58 | 59 | // Retrieves info from selected PNG file, including image dimensions, color format, background and transparency colors. 60 | int PNGU_GetImageProperties (IMGCTX ctx, PNGUPROP *fileproperties); 61 | 62 | /**************************************************************************** 63 | * Image conversion * 64 | ****************************************************************************/ 65 | 66 | u8 * DecodePNG(const u8 *src, int *width, int *height, u8 *dst, int maxwidth, int maxheight); 67 | u8 * DecodePNGFromFile(const char *filepath, int *width, int *height, u8 *dst, int maxwidth, int maxheight); 68 | int PNGU_EncodeFromRGB (IMGCTX ctx, u32 width, u32 height, void *buffer, u32 stride); 69 | int PNGU_EncodeFromGXTexture (IMGCTX ctx, u32 width, u32 height, void *buffer, u32 stride); 70 | int PNGU_EncodeFromEFB (IMGCTX ctx, u32 width, u32 height); 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /source/utils/sz/7zAlloc.c: -------------------------------------------------------------------------------- 1 | /* 7zAlloc.c */ 2 | 3 | #include 4 | #include "7zAlloc.h" 5 | 6 | /* #define _SZ_ALLOC_DEBUG */ 7 | /* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ 8 | 9 | #ifdef _SZ_ALLOC_DEBUG 10 | 11 | #ifdef _WIN32 12 | #include 13 | #endif 14 | #include 15 | int g_allocCount = 0; 16 | int g_allocCountTemp = 0; 17 | #endif 18 | 19 | void *SzAlloc(size_t size) 20 | { 21 | if (size == 0) 22 | return 0; 23 | #ifdef _SZ_ALLOC_DEBUG 24 | fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount); 25 | g_allocCount++; 26 | #endif 27 | return malloc(size); 28 | } 29 | 30 | void SzFree(void *address) 31 | { 32 | #ifdef _SZ_ALLOC_DEBUG 33 | if (address != 0) 34 | { 35 | g_allocCount--; 36 | fprintf(stderr, "\nFree; count = %10d", g_allocCount); 37 | } 38 | #endif 39 | free(address); 40 | } 41 | 42 | void *SzAllocTemp(size_t size) 43 | { 44 | if (size == 0) 45 | return 0; 46 | #ifdef _SZ_ALLOC_DEBUG 47 | fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp); 48 | g_allocCountTemp++; 49 | #ifdef _WIN32 50 | return HeapAlloc(GetProcessHeap(), 0, size); 51 | #endif 52 | #endif 53 | return malloc(size); 54 | } 55 | 56 | void SzFreeTemp(void *address) 57 | { 58 | #ifdef _SZ_ALLOC_DEBUG 59 | if (address != 0) 60 | { 61 | g_allocCountTemp--; 62 | fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp); 63 | } 64 | #ifdef _WIN32 65 | HeapFree(GetProcessHeap(), 0, address); 66 | return; 67 | #endif 68 | #endif 69 | free(address); 70 | } 71 | -------------------------------------------------------------------------------- /source/utils/sz/7zAlloc.h: -------------------------------------------------------------------------------- 1 | /* 7zAlloc.h */ 2 | 3 | #ifndef __7Z_ALLOC_H 4 | #define __7Z_ALLOC_H 5 | 6 | #include 7 | 8 | typedef struct _ISzAlloc 9 | { 10 | void *(*Alloc)(size_t size); 11 | void (*Free)(void *address); /* address can be 0 */ 12 | } ISzAlloc; 13 | 14 | void *SzAlloc(size_t size); 15 | void SzFree(void *address); 16 | 17 | void *SzAllocTemp(size_t size); 18 | void SzFreeTemp(void *address); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /source/utils/sz/7zBuffer.c: -------------------------------------------------------------------------------- 1 | /* 7zBuffer.c */ 2 | 3 | #include "7zBuffer.h" 4 | #include "7zAlloc.h" 5 | 6 | void SzByteBufferInit(CSzByteBuffer *buffer) 7 | { 8 | buffer->Capacity = 0; 9 | buffer->Items = 0; 10 | } 11 | 12 | int SzByteBufferCreate(CSzByteBuffer *buffer, size_t newCapacity, void * (*allocFunc)(size_t size)) 13 | { 14 | buffer->Capacity = newCapacity; 15 | if (newCapacity == 0) 16 | { 17 | buffer->Items = 0; 18 | return 1; 19 | } 20 | buffer->Items = (Byte *)allocFunc(newCapacity); 21 | return (buffer->Items != 0); 22 | } 23 | 24 | void SzByteBufferFree(CSzByteBuffer *buffer, void (*freeFunc)(void *)) 25 | { 26 | freeFunc(buffer->Items); 27 | buffer->Items = 0; 28 | buffer->Capacity = 0; 29 | } 30 | -------------------------------------------------------------------------------- /source/utils/sz/7zBuffer.h: -------------------------------------------------------------------------------- 1 | /* 7zBuffer.h */ 2 | 3 | #ifndef __7Z_BUFFER_H 4 | #define __7Z_BUFFER_H 5 | 6 | #include 7 | #include "7zTypes.h" 8 | 9 | typedef struct _CSzByteBuffer 10 | { 11 | size_t Capacity; 12 | Byte *Items; 13 | }CSzByteBuffer; 14 | 15 | void SzByteBufferInit(CSzByteBuffer *buffer); 16 | int SzByteBufferCreate(CSzByteBuffer *buffer, size_t newCapacity, void * (*allocFunc)(size_t size)); 17 | void SzByteBufferFree(CSzByteBuffer *buffer, void (*freeFunc)(void *)); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /source/utils/sz/7zCrc.c: -------------------------------------------------------------------------------- 1 | /* 7zCrc.c */ 2 | 3 | #include "7zCrc.h" 4 | 5 | #define kCrcPoly 0xEDB88320 6 | 7 | UInt32 g_CrcTable[256]; 8 | 9 | void InitCrcTable() 10 | { 11 | UInt32 i; 12 | for (i = 0; i < 256; i++) 13 | { 14 | UInt32 r = i; 15 | int j; 16 | for (j = 0; j < 8; j++) 17 | if (r & 1) 18 | r = (r >> 1) ^ kCrcPoly; 19 | else 20 | r >>= 1; 21 | g_CrcTable[i] = r; 22 | } 23 | } 24 | 25 | void CrcInit(UInt32 *crc) { *crc = 0xFFFFFFFF; } 26 | UInt32 CrcGetDigest(UInt32 *crc) { return *crc ^ 0xFFFFFFFF; } 27 | 28 | void CrcUpdateByte(UInt32 *crc, Byte b) 29 | { 30 | *crc = g_CrcTable[((Byte)(*crc)) ^ b] ^ (*crc >> 8); 31 | } 32 | 33 | void CrcUpdateUInt16(UInt32 *crc, UInt16 v) 34 | { 35 | CrcUpdateByte(crc, (Byte)v); 36 | CrcUpdateByte(crc, (Byte)(v >> 8)); 37 | } 38 | 39 | void CrcUpdateUInt32(UInt32 *crc, UInt32 v) 40 | { 41 | int i; 42 | for (i = 0; i < 4; i++) 43 | CrcUpdateByte(crc, (Byte)(v >> (8 * i))); 44 | } 45 | 46 | void CrcUpdateUInt64(UInt32 *crc, UInt64 v) 47 | { 48 | int i; 49 | for (i = 0; i < 8; i++) 50 | { 51 | CrcUpdateByte(crc, (Byte)(v)); 52 | v >>= 8; 53 | } 54 | } 55 | 56 | void CrcUpdate(UInt32 *crc, const void *data, size_t size) 57 | { 58 | UInt32 v = *crc; 59 | const Byte *p = (const Byte *)data; 60 | for (; size > 0 ; size--, p++) 61 | v = g_CrcTable[((Byte)(v)) ^ *p] ^ (v >> 8); 62 | *crc = v; 63 | } 64 | 65 | UInt32 CrcCalculateDigest(const void *data, size_t size) 66 | { 67 | UInt32 crc; 68 | CrcInit(&crc); 69 | CrcUpdate(&crc, data, size); 70 | return CrcGetDigest(&crc); 71 | } 72 | 73 | int CrcVerifyDigest(UInt32 digest, const void *data, size_t size) 74 | { 75 | return (CrcCalculateDigest(data, size) == digest); 76 | } 77 | -------------------------------------------------------------------------------- /source/utils/sz/7zCrc.h: -------------------------------------------------------------------------------- 1 | /* 7zCrc.h */ 2 | 3 | #ifndef __7Z_CRC_H 4 | #define __7Z_CRC_H 5 | 6 | #include 7 | 8 | #include "7zTypes.h" 9 | 10 | extern UInt32 g_CrcTable[256]; 11 | void InitCrcTable(); 12 | 13 | void CrcInit(UInt32 *crc); 14 | UInt32 CrcGetDigest(UInt32 *crc); 15 | void CrcUpdateByte(UInt32 *crc, Byte v); 16 | void CrcUpdateUInt16(UInt32 *crc, UInt16 v); 17 | void CrcUpdateUInt32(UInt32 *crc, UInt32 v); 18 | void CrcUpdateUInt64(UInt32 *crc, UInt64 v); 19 | void CrcUpdate(UInt32 *crc, const void *data, size_t size); 20 | 21 | UInt32 CrcCalculateDigest(const void *data, size_t size); 22 | int CrcVerifyDigest(UInt32 digest, const void *data, size_t size); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /source/utils/sz/7zDecode.h: -------------------------------------------------------------------------------- 1 | /* 7zDecode.h */ 2 | 3 | #if defined(_LZMA_OUT_READ) && !defined(_LZMA_IN_CB) 4 | #error "Fixme: _LZMA_OUT_READ && _LZMA_IN_CB isn't currently possible!" 5 | #endif 6 | 7 | #ifndef __7Z_DECODE_H 8 | #define __7Z_DECODE_H 9 | 10 | #include "7zItem.h" 11 | #include "7zAlloc.h" 12 | #ifdef _LZMA_IN_CB 13 | #include "7zIn.h" 14 | #endif 15 | 16 | SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder, 17 | #ifdef _LZMA_IN_CB 18 | ISzInStream *stream, 19 | #else 20 | const Byte *inBuffer, 21 | #endif 22 | Byte *outBuffer, size_t outSize, 23 | size_t *outSizeProcessed, ISzAlloc *allocMain); 24 | 25 | #ifdef _LZMA_OUT_READ 26 | #ifndef _LZMA_TEMP_BUFFER_SIZE 27 | #define _LZMA_TEMP_BUFFER_SIZE (2048) // size of the temporary buffer in bytes 28 | #endif 29 | 30 | SZ_RESULT SzDecode2(const CFileSize *packSizes, const CFolder *folder, 31 | ISzInStream *stream, 32 | Byte *outBuffer, size_t outSize, 33 | size_t *outSizeProcessed, ISzAlloc *allocMain, 34 | size_t *fileOffset, size_t *fileSize); 35 | #endif // #ifdef _LZMA_OUT_READ 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /source/utils/sz/7zExtract.h: -------------------------------------------------------------------------------- 1 | /* 7zExtract.h */ 2 | 3 | #if defined(_LZMA_OUT_READ) && !defined(_LZMA_IN_CB) 4 | #error "Fixme: _LZMA_OUT_READ && _LZMA_IN_CB isn't currently possible!" 5 | #endif 6 | 7 | #ifndef __7Z_EXTRACT_H 8 | #define __7Z_EXTRACT_H 9 | 10 | #include "7zIn.h" 11 | 12 | /* 13 | SzExtract extracts file from archive 14 | 15 | SzExtract2 does the same but needs less memory 16 | 17 | *outBuffer must be 0 before first call for each new archive. 18 | 19 | Extracting cache: 20 | If you need to decompress more than one file, you can send 21 | these values from previous call: 22 | *blockIndex, 23 | *outBuffer, 24 | *outBufferSize 25 | You can consider "*outBuffer" as cache of solid block. If your archive is solid, 26 | it will increase decompression speed. 27 | 28 | If you use external function, you can declare these 3 cache variables 29 | (blockIndex, outBuffer, outBufferSize) as static in that external function. 30 | 31 | Free *outBuffer and set *outBuffer to 0, if you want to flush cache. 32 | */ 33 | 34 | SZ_RESULT SzExtract( 35 | ISzInStream *inStream, 36 | CArchiveDatabaseEx *db, 37 | UInt32 fileIndex, /* index of file */ 38 | UInt32 *blockIndex, /* index of solid block */ 39 | Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ 40 | size_t *outBufferSize, /* buffer size for output buffer */ 41 | size_t *offset, /* offset of stream for required file in *outBuffer */ 42 | size_t *outSizeProcessed, /* size of file in *outBuffer */ 43 | ISzAlloc *allocMain, 44 | ISzAlloc *allocTemp); 45 | 46 | #ifdef _LZMA_OUT_READ 47 | SZ_RESULT SzExtract2( 48 | ISzInStream *inStream, 49 | CArchiveDatabaseEx *db, 50 | UInt32 fileIndex, /* index of file */ 51 | UInt32 *blockIndex, /* index of solid block */ 52 | Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ 53 | size_t *outBufferSize, /* buffer size for output buffer */ 54 | size_t *offset, /* offset of stream for required file in *outBuffer */ 55 | size_t *outSizeProcessed, /* size of file in *outBuffer */ 56 | ISzAlloc *allocMain, 57 | ISzAlloc *allocTemp); 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /source/utils/sz/7zHeader.c: -------------------------------------------------------------------------------- 1 | /* 7zHeader.c */ 2 | 3 | #include "7zHeader.h" 4 | 5 | Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; 6 | -------------------------------------------------------------------------------- /source/utils/sz/7zHeader.h: -------------------------------------------------------------------------------- 1 | /* 7zHeader.h */ 2 | 3 | #ifndef __7Z_HEADER_H 4 | #define __7Z_HEADER_H 5 | 6 | #include "7zTypes.h" 7 | 8 | #define k7zSignatureSize 6 9 | extern Byte k7zSignature[k7zSignatureSize]; 10 | 11 | #define k7zMajorVersion 0 12 | 13 | #define k7zStartHeaderSize 0x20 14 | 15 | enum EIdEnum 16 | { 17 | k7zIdEnd, 18 | 19 | k7zIdHeader, 20 | 21 | k7zIdArchiveProperties, 22 | 23 | k7zIdAdditionalStreamsInfo, 24 | k7zIdMainStreamsInfo, 25 | k7zIdFilesInfo, 26 | 27 | k7zIdPackInfo, 28 | k7zIdUnPackInfo, 29 | k7zIdSubStreamsInfo, 30 | 31 | k7zIdSize, 32 | k7zIdCRC, 33 | 34 | k7zIdFolder, 35 | 36 | k7zIdCodersUnPackSize, 37 | k7zIdNumUnPackStream, 38 | 39 | k7zIdEmptyStream, 40 | k7zIdEmptyFile, 41 | k7zIdAnti, 42 | 43 | k7zIdName, 44 | k7zIdCreationTime, 45 | k7zIdLastAccessTime, 46 | k7zIdLastWriteTime, 47 | k7zIdWinAttributes, 48 | k7zIdComment, 49 | 50 | k7zIdEncodedHeader, 51 | 52 | k7zIdStartPos 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /source/utils/sz/7zIn.h: -------------------------------------------------------------------------------- 1 | /* 7zIn.h */ 2 | 3 | #ifndef __7Z_IN_H 4 | #define __7Z_IN_H 5 | 6 | #include "7zHeader.h" 7 | #include "7zItem.h" 8 | #include "7zAlloc.h" 9 | 10 | typedef struct _CInArchiveInfo 11 | { 12 | CFileSize StartPositionAfterHeader; 13 | CFileSize DataStartPosition; 14 | }CInArchiveInfo; 15 | 16 | typedef struct _CArchiveDatabaseEx 17 | { 18 | CArchiveDatabase Database; 19 | CInArchiveInfo ArchiveInfo; 20 | UInt32 *FolderStartPackStreamIndex; 21 | CFileSize *PackStreamStartPositions; 22 | UInt32 *FolderStartFileIndex; 23 | UInt32 *FileIndexToFolderIndexMap; 24 | }CArchiveDatabaseEx; 25 | 26 | void SzArDbExInit(CArchiveDatabaseEx *db); 27 | void SzArDbExFree(CArchiveDatabaseEx *db, void (*freeFunc)(void *)); 28 | CFileSize SzArDbGetFolderStreamPos(CArchiveDatabaseEx *db, UInt32 folderIndex, UInt32 indexInFolder); 29 | CFileSize SzArDbGetFolderFullPackSize(CArchiveDatabaseEx *db, UInt32 folderIndex); 30 | 31 | typedef struct _ISzInStream 32 | { 33 | #ifdef _LZMA_IN_CB 34 | SZ_RESULT (*Read)( 35 | void *object, /* pointer to ISzInStream itself */ 36 | void **buffer, /* out: pointer to buffer with data */ 37 | size_t maxRequiredSize, /* max required size to read */ 38 | size_t *processedSize); /* real processed size. 39 | processedSize can be less than maxRequiredSize. 40 | If processedSize == 0, then there are no more 41 | bytes in stream. */ 42 | #else 43 | SZ_RESULT (*Read)(void *object, void *buffer, size_t size, size_t *processedSize); 44 | #endif 45 | SZ_RESULT (*Seek)(void *object, CFileSize pos); 46 | } ISzInStream; 47 | 48 | 49 | int SzArchiveOpen( 50 | ISzInStream *inStream, 51 | CArchiveDatabaseEx *db, 52 | ISzAlloc *allocMain, 53 | ISzAlloc *allocTemp); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /source/utils/sz/7zItem.c: -------------------------------------------------------------------------------- 1 | /* 7zItem.c */ 2 | 3 | #include "7zItem.h" 4 | #include "7zAlloc.h" 5 | 6 | void SzCoderInfoInit(CCoderInfo *coder) 7 | { 8 | SzByteBufferInit(&coder->Properties); 9 | } 10 | 11 | void SzCoderInfoFree(CCoderInfo *coder, void (*freeFunc)(void *p)) 12 | { 13 | SzByteBufferFree(&coder->Properties, freeFunc); 14 | SzCoderInfoInit(coder); 15 | } 16 | 17 | void SzFolderInit(CFolder *folder) 18 | { 19 | folder->NumCoders = 0; 20 | folder->Coders = 0; 21 | folder->NumBindPairs = 0; 22 | folder->BindPairs = 0; 23 | folder->NumPackStreams = 0; 24 | folder->PackStreams = 0; 25 | folder->UnPackSizes = 0; 26 | folder->UnPackCRCDefined = 0; 27 | folder->UnPackCRC = 0; 28 | folder->NumUnPackStreams = 0; 29 | } 30 | 31 | void SzFolderFree(CFolder *folder, void (*freeFunc)(void *p)) 32 | { 33 | UInt32 i; 34 | for (i = 0; i < folder->NumCoders; i++) 35 | SzCoderInfoFree(&folder->Coders[i], freeFunc); 36 | freeFunc(folder->Coders); 37 | freeFunc(folder->BindPairs); 38 | freeFunc(folder->PackStreams); 39 | freeFunc(folder->UnPackSizes); 40 | SzFolderInit(folder); 41 | } 42 | 43 | UInt32 SzFolderGetNumOutStreams(CFolder *folder) 44 | { 45 | UInt32 result = 0; 46 | UInt32 i; 47 | for (i = 0; i < folder->NumCoders; i++) 48 | result += folder->Coders[i].NumOutStreams; 49 | return result; 50 | } 51 | 52 | int SzFolderFindBindPairForInStream(CFolder *folder, UInt32 inStreamIndex) 53 | { 54 | UInt32 i; 55 | for(i = 0; i < folder->NumBindPairs; i++) 56 | if (folder->BindPairs[i].InIndex == inStreamIndex) 57 | return i; 58 | return -1; 59 | } 60 | 61 | 62 | int SzFolderFindBindPairForOutStream(CFolder *folder, UInt32 outStreamIndex) 63 | { 64 | UInt32 i; 65 | for(i = 0; i < folder->NumBindPairs; i++) 66 | if (folder->BindPairs[i].OutIndex == outStreamIndex) 67 | return i; 68 | return -1; 69 | } 70 | 71 | CFileSize SzFolderGetUnPackSize(CFolder *folder) 72 | { 73 | int i = (int)SzFolderGetNumOutStreams(folder); 74 | if (i == 0) 75 | return 0; 76 | for (i--; i >= 0; i--) 77 | if (SzFolderFindBindPairForOutStream(folder, i) < 0) 78 | return folder->UnPackSizes[i]; 79 | /* throw 1; */ 80 | return 0; 81 | } 82 | 83 | /* 84 | int FindPackStreamArrayIndex(int inStreamIndex) const 85 | { 86 | for(int i = 0; i < PackStreams.Size(); i++) 87 | if (PackStreams[i] == inStreamIndex) 88 | return i; 89 | return -1; 90 | } 91 | */ 92 | 93 | void SzFileInit(CFileItem *fileItem) 94 | { 95 | fileItem->IsFileCRCDefined = 0; 96 | fileItem->HasStream = 1; 97 | fileItem->IsDirectory = 0; 98 | fileItem->IsAnti = 0; 99 | fileItem->Name = 0; 100 | } 101 | 102 | void SzFileFree(CFileItem *fileItem, void (*freeFunc)(void *p)) 103 | { 104 | freeFunc(fileItem->Name); 105 | SzFileInit(fileItem); 106 | } 107 | 108 | void SzArchiveDatabaseInit(CArchiveDatabase *db) 109 | { 110 | db->NumPackStreams = 0; 111 | db->PackSizes = 0; 112 | db->PackCRCsDefined = 0; 113 | db->PackCRCs = 0; 114 | db->NumFolders = 0; 115 | db->Folders = 0; 116 | db->NumFiles = 0; 117 | db->Files = 0; 118 | } 119 | 120 | void SzArchiveDatabaseFree(CArchiveDatabase *db, void (*freeFunc)(void *)) 121 | { 122 | UInt32 i; 123 | for (i = 0; i < db->NumFolders; i++) 124 | SzFolderFree(&db->Folders[i], freeFunc); 125 | for (i = 0; i < db->NumFiles; i++) 126 | SzFileFree(&db->Files[i], freeFunc); 127 | freeFunc(db->PackSizes); 128 | freeFunc(db->PackCRCsDefined); 129 | freeFunc(db->PackCRCs); 130 | freeFunc(db->Folders); 131 | freeFunc(db->Files); 132 | SzArchiveDatabaseInit(db); 133 | } 134 | -------------------------------------------------------------------------------- /source/utils/sz/7zItem.h: -------------------------------------------------------------------------------- 1 | /* 7zItem.h */ 2 | 3 | #ifndef __7Z_ITEM_H 4 | #define __7Z_ITEM_H 5 | 6 | #include "7zMethodID.h" 7 | #include "7zHeader.h" 8 | #include "7zBuffer.h" 9 | 10 | typedef struct _CCoderInfo 11 | { 12 | UInt32 NumInStreams; 13 | UInt32 NumOutStreams; 14 | CMethodID MethodID; 15 | CSzByteBuffer Properties; 16 | }CCoderInfo; 17 | 18 | void SzCoderInfoInit(CCoderInfo *coder); 19 | void SzCoderInfoFree(CCoderInfo *coder, void (*freeFunc)(void *p)); 20 | 21 | typedef struct _CBindPair 22 | { 23 | UInt32 InIndex; 24 | UInt32 OutIndex; 25 | }CBindPair; 26 | 27 | typedef struct _CFolder 28 | { 29 | UInt32 NumCoders; 30 | CCoderInfo *Coders; 31 | UInt32 NumBindPairs; 32 | CBindPair *BindPairs; 33 | UInt32 NumPackStreams; 34 | UInt32 *PackStreams; 35 | CFileSize *UnPackSizes; 36 | int UnPackCRCDefined; 37 | UInt32 UnPackCRC; 38 | 39 | UInt32 NumUnPackStreams; 40 | }CFolder; 41 | 42 | void SzFolderInit(CFolder *folder); 43 | CFileSize SzFolderGetUnPackSize(CFolder *folder); 44 | int SzFolderFindBindPairForInStream(CFolder *folder, UInt32 inStreamIndex); 45 | UInt32 SzFolderGetNumOutStreams(CFolder *folder); 46 | CFileSize SzFolderGetUnPackSize(CFolder *folder); 47 | 48 | /* #define CArchiveFileTime UInt64 */ 49 | 50 | typedef struct _CFileItem 51 | { 52 | /* 53 | CArchiveFileTime LastWriteTime; 54 | CFileSize StartPos; 55 | UInt32 Attributes; 56 | */ 57 | CFileSize Size; 58 | UInt32 FileCRC; 59 | char *Name; 60 | 61 | Byte IsFileCRCDefined; 62 | Byte HasStream; 63 | Byte IsDirectory; 64 | Byte IsAnti; 65 | /* 66 | int AreAttributesDefined; 67 | int IsLastWriteTimeDefined; 68 | int IsStartPosDefined; 69 | */ 70 | }CFileItem; 71 | 72 | void SzFileInit(CFileItem *fileItem); 73 | 74 | typedef struct _CArchiveDatabase 75 | { 76 | UInt32 NumPackStreams; 77 | CFileSize *PackSizes; 78 | Byte *PackCRCsDefined; 79 | UInt32 *PackCRCs; 80 | UInt32 NumFolders; 81 | CFolder *Folders; 82 | UInt32 NumFiles; 83 | CFileItem *Files; 84 | }CArchiveDatabase; 85 | 86 | void SzArchiveDatabaseInit(CArchiveDatabase *db); 87 | void SzArchiveDatabaseFree(CArchiveDatabase *db, void (*freeFunc)(void *)); 88 | 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /source/utils/sz/7zMethodID.c: -------------------------------------------------------------------------------- 1 | /* 7zMethodID.c */ 2 | 3 | #include "7zMethodID.h" 4 | 5 | int AreMethodsEqual(CMethodID *a1, CMethodID *a2) 6 | { 7 | int i; 8 | if (a1->IDSize != a2->IDSize) 9 | return 0; 10 | for (i = 0; i < a1->IDSize; i++) 11 | if (a1->ID[i] != a2->ID[i]) 12 | return 0; 13 | return 1; 14 | } 15 | -------------------------------------------------------------------------------- /source/utils/sz/7zMethodID.h: -------------------------------------------------------------------------------- 1 | /* 7zMethodID.h */ 2 | 3 | #ifndef __7Z_METHOD_ID_H 4 | #define __7Z_METHOD_ID_H 5 | 6 | #include "7zTypes.h" 7 | 8 | #define kMethodIDSize 15 9 | 10 | typedef struct _CMethodID 11 | { 12 | Byte ID[kMethodIDSize]; 13 | Byte IDSize; 14 | } CMethodID; 15 | 16 | int AreMethodsEqual(CMethodID *a1, CMethodID *a2); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /source/utils/sz/7zTypes.h: -------------------------------------------------------------------------------- 1 | /* 7zTypes.h */ 2 | 3 | #ifndef __COMMON_TYPES_H 4 | #define __COMMON_TYPES_H 5 | 6 | #ifndef _7ZIP_BYTE_DEFINED 7 | #define _7ZIP_BYTE_DEFINED 8 | #ifndef ZCONF_H 9 | typedef unsigned char Byte; 10 | #endif 11 | #endif 12 | 13 | #ifndef _7ZIP_UINT16_DEFINED 14 | #define _7ZIP_UINT16_DEFINED 15 | typedef unsigned short UInt16; 16 | #endif 17 | 18 | #ifndef _7ZIP_UINT32_DEFINED 19 | #define _7ZIP_UINT32_DEFINED 20 | #ifdef _LZMA_UINT32_IS_ULONG 21 | typedef unsigned long UInt32; 22 | #else 23 | typedef unsigned int UInt32; 24 | #endif 25 | #endif 26 | 27 | /* #define _SZ_NO_INT_64 */ 28 | /* define it your compiler doesn't support long long int */ 29 | 30 | #ifndef _7ZIP_UINT64_DEFINED 31 | #define _7ZIP_UINT64_DEFINED 32 | #ifdef _SZ_NO_INT_64 33 | typedef unsigned long UInt64; 34 | #else 35 | #ifdef _MSC_VER 36 | typedef unsigned __int64 UInt64; 37 | #else 38 | typedef unsigned long long int UInt64; 39 | #endif 40 | #endif 41 | #endif 42 | 43 | 44 | /* #define _SZ_FILE_SIZE_64 */ 45 | /* Use _SZ_FILE_SIZE_64 if you need support for files larger than 4 GB*/ 46 | 47 | #ifndef CFileSize 48 | #ifdef _SZ_FILE_SIZE_64 49 | typedef UInt64 CFileSize; 50 | #else 51 | typedef UInt32 CFileSize; 52 | #endif 53 | #endif 54 | 55 | #define SZ_RESULT int 56 | 57 | #define SZ_OK (0) 58 | #define SZE_DATA_ERROR (1) 59 | #define SZE_OUTOFMEMORY (2) 60 | #define SZE_CRC_ERROR (3) 61 | 62 | #define SZE_NOTIMPL (4) 63 | #define SZE_FAIL (5) 64 | #define SZE_FAILREAD (6) 65 | 66 | #define SZE_ARCHIVE_ERROR (7) 67 | 68 | #define SZE_OUTOFMEMORYDIC (8) 69 | 70 | #define RINOK(x) { int __result_ = (x); if(__result_ != 0) return __result_; } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /source/utils/sz/LzmaDecode.h: -------------------------------------------------------------------------------- 1 | /* 2 | LzmaDecode.h 3 | LZMA Decoder interface 4 | 5 | LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01) 6 | http://www.7-zip.org/ 7 | 8 | LZMA SDK is licensed under two licenses: 9 | 1) GNU Lesser General Public License (GNU LGPL) 10 | 2) Common Public License (CPL) 11 | It means that you can select one of these two licenses and 12 | follow rules of that license. 13 | 14 | SPECIAL EXCEPTION: 15 | Igor Pavlov, as the author of this code, expressly permits you to 16 | statically or dynamically link your code (or bind by name) to the 17 | interfaces of this file without subjecting your linked code to the 18 | terms of the CPL or GNU LGPL. Any modifications or additions 19 | to this file, however, are subject to the LGPL or CPL terms. 20 | */ 21 | 22 | #ifndef __LZMADECODE_H 23 | #define __LZMADECODE_H 24 | 25 | #include "LzmaTypes.h" 26 | 27 | /* #define _LZMA_IN_CB */ 28 | /* Use callback for input data */ 29 | 30 | /* #define _LZMA_OUT_READ */ 31 | /* Use read function for output data */ 32 | 33 | /* #define _LZMA_PROB32 */ 34 | /* It can increase speed on some 32-bit CPUs, 35 | but memory usage will be doubled in that case */ 36 | 37 | /* #define _LZMA_LOC_OPT */ 38 | /* Enable local speed optimizations inside code */ 39 | 40 | #ifdef _LZMA_PROB32 41 | #define CProb UInt32 42 | #else 43 | #define CProb UInt16 44 | #endif 45 | 46 | #define LZMA_RESULT_OK 0 47 | #define LZMA_RESULT_DATA_ERROR 1 48 | 49 | #ifdef _LZMA_IN_CB 50 | typedef struct _ILzmaInCallback 51 | { 52 | int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize); 53 | } ILzmaInCallback; 54 | #endif 55 | 56 | #define LZMA_BASE_SIZE 1846 57 | #define LZMA_LIT_SIZE 768 58 | 59 | #define LZMA_PROPERTIES_SIZE 5 60 | 61 | typedef struct _CLzmaProperties 62 | { 63 | int lc; 64 | int lp; 65 | int pb; 66 | #ifdef _LZMA_OUT_READ 67 | UInt32 DictionarySize; 68 | #endif 69 | }CLzmaProperties; 70 | 71 | int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size); 72 | 73 | #define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp))) 74 | 75 | #define kLzmaNeedInitId (-2) 76 | 77 | typedef struct _CLzmaDecoderState 78 | { 79 | CLzmaProperties Properties; 80 | CProb *Probs; 81 | 82 | #ifdef _LZMA_IN_CB 83 | const unsigned char *Buffer; 84 | const unsigned char *BufferLim; 85 | #endif 86 | 87 | #ifdef _LZMA_OUT_READ 88 | unsigned char *Dictionary; 89 | UInt32 Range; 90 | UInt32 Code; 91 | UInt32 DictionaryPos; 92 | UInt32 GlobalPos; 93 | UInt32 DistanceLimit; 94 | UInt32 Reps[4]; 95 | int State; 96 | int RemainLen; 97 | unsigned char TempDictionary[4]; 98 | #endif 99 | } CLzmaDecoderState; 100 | 101 | #ifdef _LZMA_OUT_READ 102 | #define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; } 103 | #endif 104 | 105 | int LzmaDecode(CLzmaDecoderState *vs, 106 | #ifdef _LZMA_IN_CB 107 | ILzmaInCallback *inCallback, 108 | #else 109 | const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed, 110 | #endif 111 | unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed); 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /source/utils/sz/LzmaTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | LzmaTypes.h 3 | 4 | Types for LZMA Decoder 5 | 6 | This file written and distributed to public domain by Igor Pavlov. 7 | This file is part of LZMA SDK 4.40 (2006-05-01) 8 | */ 9 | 10 | #ifndef __LZMATYPES_H 11 | #define __LZMATYPES_H 12 | 13 | #ifndef _7ZIP_BYTE_DEFINED 14 | #define _7ZIP_BYTE_DEFINED 15 | typedef unsigned char Byte; 16 | #endif 17 | 18 | #ifndef _7ZIP_UINT16_DEFINED 19 | #define _7ZIP_UINT16_DEFINED 20 | typedef unsigned short UInt16; 21 | #endif 22 | 23 | #ifndef _7ZIP_UINT32_DEFINED 24 | #define _7ZIP_UINT32_DEFINED 25 | #ifdef _LZMA_UINT32_IS_ULONG 26 | typedef unsigned long UInt32; 27 | #else 28 | typedef unsigned int UInt32; 29 | #endif 30 | #endif 31 | 32 | /* #define _LZMA_SYSTEM_SIZE_T */ 33 | /* Use system's size_t. You can use it to enable 64-bit sizes supporting */ 34 | 35 | #ifndef _7ZIP_SIZET_DEFINED 36 | #define _7ZIP_SIZET_DEFINED 37 | #ifdef _LZMA_SYSTEM_SIZE_T 38 | #include 39 | typedef size_t SizeT; 40 | #else 41 | typedef UInt32 SizeT; 42 | #endif 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /source/utils/vm/dsihandler.s: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 tueidj All Rights Reserved 2 | * This code may not be used in any project 3 | * without explicit permission from the author. 4 | */ 5 | 6 | #include 7 | #include "asm.h" 8 | 9 | .extern vm_dsi_handler 10 | .extern default_exceptionhandler 11 | 12 | FUNC_START(dsi_handler) 13 | stwu sp,-EXCEPTION_FRAME_END(sp) 14 | stw r6,GPR6_OFFSET(sp) 15 | stw r7,GPR7_OFFSET(sp) 16 | stw r8,GPR8_OFFSET(sp) 17 | stw r9,GPR9_OFFSET(sp) 18 | stw r10,GPR10_OFFSET(sp) 19 | stw r11,GPR11_OFFSET(sp) 20 | stw r12,GPR12_OFFSET(sp) 21 | mfdsisr r4 22 | mfmsr r3 23 | ori r3,r3,MSR_RI 24 | mtmsr r3 25 | 26 | addi r3,sp,8 27 | bl vm_dsi_handler 28 | 29 | # check if it was handled correctly 30 | cmplwi r3,0 31 | 32 | lwz r6,GPR6_OFFSET(sp) 33 | lwz r7,GPR7_OFFSET(sp) 34 | lwz r8,GPR8_OFFSET(sp) 35 | lwz r9,GPR9_OFFSET(sp) 36 | lwz r10,GPR10_OFFSET(sp) 37 | lwz r11,GPR11_OFFSET(sp) 38 | lwz r12,GPR12_OFFSET(sp) 39 | 40 | # clear MSR_RI 41 | mfmsr r3 42 | rlwinm r3,r3,0,31,29 43 | mtmsr r3 44 | 45 | bne 1f 46 | 47 | # jump to libogc's default handler 48 | addi sp,sp,EXCEPTION_FRAME_END 49 | b default_exceptionhandler 50 | 51 | 1: 52 | lwz r3,CR_OFFSET(sp) 53 | lwz r4,LR_OFFSET(sp) 54 | lwz r5,CTR_OFFSET(sp) 55 | lwz r0,XER_OFFSET(sp) 56 | mtcr r3 57 | mtlr r4 58 | mtctr r5 59 | mtxer r0 60 | lwz r0,GPR0_OFFSET(sp) 61 | lwz r5,GPR5_OFFSET(sp) 62 | 63 | lwz r3,SRR0_OFFSET(sp) 64 | lwz r4,SRR1_OFFSET(sp) 65 | mtsrr0 r3 66 | mtsrr1 r4 67 | lwz r3,GPR3_OFFSET(sp) 68 | lwz r4,GPR4_OFFSET(sp) 69 | lwz sp,GPR1_OFFSET(sp) 70 | rfi 71 | FUNC_END(dsi_handler) 72 | -------------------------------------------------------------------------------- /source/utils/vm/vm.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 tueidj All Rights Reserved 2 | * This code may not be used in any project 3 | * without explicit permission from the author. 4 | */ 5 | 6 | #ifndef _VM_H_ 7 | #define _VM_H_ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #define KB (1024) 17 | #define MB (1024*KB) 18 | #define MRAM_BACKING (4*MB) // Use 4MB to page our 16MB 19 | #define ARAM_RESERVED (64*KB) // Reserved for DSP/AESND/etc 20 | #define ARAM_VM_BASE (0x7F000000) // Map ARAM to here 21 | #define ARAM_START (ARAM_RESERVED + ARAM_VM_BASE) 22 | #define ARAM_SIZE ((16*MB) - ARAM_RESERVED) // ARAM is ~16MB 23 | 24 | // maximum virtual memory size 25 | #define MAX_VM_SIZE (256*1024*1024) 26 | // maximum physical memory size 27 | #define MAX_MEM_SIZE ( 8*1024*1024) 28 | // minimum physical memory size 29 | #define MIN_MEM_SIZE (256*1024) 30 | // page size as defined by hardware 31 | #define PAGE_SIZE 4096 32 | #define PAGE_MASK (~(PAGE_SIZE-1)) 33 | 34 | #define VM_VSID 0 35 | #define VM_SEGMENT 0x70000000 36 | 37 | // use 64KB for PTEs 38 | #define HTABMASK 0 39 | #define PTE_SIZE ((HTABMASK+1)*65536) 40 | #define PTE_COUNT (PTE_SIZE>>3) 41 | 42 | //#define VM_FILENAME "/tmp/pagefile.sys" 43 | 44 | // keeps a record of each currently mapped page 45 | typedef union 46 | { 47 | u32 data; 48 | struct 49 | { 50 | u32 valid : 1; 51 | u32 locked : 1; 52 | u32 dirty : 1; 53 | u32 pte_index : 13; 54 | u32 page_index : 16; 55 | }; 56 | } p_map; 57 | 58 | // maps VM addresses to mapped pages 59 | typedef struct 60 | { 61 | // data must be fetched when paging in? 62 | u16 committed : 1; 63 | u16 p_map_index: 12; 64 | } vm_map; 65 | 66 | typedef union 67 | { 68 | u32 data[2]; 69 | struct 70 | { 71 | u32 valid : 1; 72 | u32 VSID : 24; 73 | u32 hash : 1; 74 | u32 API : 6; 75 | 76 | u32 RPN : 20; 77 | u32 pad0 : 3; 78 | u32 R : 1; 79 | u32 C : 1; 80 | u32 WIMG : 4; 81 | u32 pad1 : 1; 82 | u32 PP : 2; 83 | }; 84 | } PTE; 85 | typedef PTE* PTEG; 86 | 87 | extern void* VM_Init(u32 VMSize, u32 MEMSize); 88 | extern void VM_Deinit(void); 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /source/utils/wiidrc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 FIX94 3 | * 4 | * This software may be modified and distributed under the terms 5 | * of the MIT license. See the LICENSE file for details. 6 | */ 7 | #ifndef _WIIDRC_H_ 8 | #define _WIIDRC_H_ 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | struct WiiDRCData { 15 | s16 xAxisL; 16 | s16 xAxisR; 17 | s16 yAxisL; 18 | s16 yAxisR; 19 | u16 button; 20 | u8 battery; 21 | u8 extra; 22 | }; 23 | 24 | #define WIIDRC_BUTTON_A 0x8000 25 | #define WIIDRC_BUTTON_B 0x4000 26 | #define WIIDRC_BUTTON_X 0x2000 27 | #define WIIDRC_BUTTON_Y 0x1000 28 | #define WIIDRC_BUTTON_LEFT 0x0800 29 | #define WIIDRC_BUTTON_RIGHT 0x0400 30 | #define WIIDRC_BUTTON_UP 0x0200 31 | #define WIIDRC_BUTTON_DOWN 0x0100 32 | #define WIIDRC_BUTTON_ZL 0x0080 33 | #define WIIDRC_BUTTON_ZR 0x0040 34 | #define WIIDRC_BUTTON_L 0x0020 35 | #define WIIDRC_BUTTON_R 0x0010 36 | #define WIIDRC_BUTTON_PLUS 0x0008 37 | #define WIIDRC_BUTTON_MINUS 0x0004 38 | #define WIIDRC_BUTTON_HOME 0x0002 39 | #define WIIDRC_BUTTON_SYNC 0x0001 40 | 41 | #define WIIDRC_EXTRA_BUTTON_L3 0x80 42 | #define WIIDRC_EXTRA_BUTTON_R3 0x40 43 | #define WIIDRC_EXTRA_BUTTON_TV 0x20 44 | #define WIIDRC_EXTRA_OVERLAY_TV 0x10 45 | #define WIIDRC_EXTRA_OVERLAY_POWER 0x01 46 | 47 | bool WiiDRC_Init(); 48 | bool WiiDRC_Inited(); 49 | bool WiiDRC_Recalibrate(); 50 | bool WiiDRC_ScanPads(); 51 | bool WiiDRC_Connected(); 52 | bool WiiDRC_ShutdownRequested(); 53 | const u8 *WiiDRC_GetRawI2CAddr(); 54 | const struct WiiDRCData *WiiDRC_Data(); 55 | u32 WiiDRC_ButtonsUp(); 56 | u32 WiiDRC_ButtonsDown(); 57 | u32 WiiDRC_ButtonsHeld(); 58 | s16 WiiDRC_lStickX(); 59 | s16 WiiDRC_lStickY(); 60 | s16 WiiDRC_rStickX(); 61 | s16 WiiDRC_rStickY(); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /source/utils/xbox360.h: -------------------------------------------------------------------------------- 1 | #ifndef _XBOX360_H_ 2 | #define _XBOX360_H_ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | bool XBOX360_ScanPads(); 11 | u32 XBOX360_ButtonsHeld(int chan); 12 | char* XBOX360_Status(); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif -------------------------------------------------------------------------------- /source/video.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * softdev July 2006 5 | * crunchy2 May 2007 6 | * Michniewski 2008 7 | * Tantric 2008-2022 8 | * Tanooki 2019-2023 9 | * 10 | * video.h 11 | * 12 | * Video routines 13 | ***************************************************************************/ 14 | 15 | #ifndef _GCVIDEOH_ 16 | #define _GCVIDEOH_ 17 | 18 | #include 19 | 20 | #include "snes9x/snes9x.h" 21 | 22 | void AllocGfxMem(); 23 | void InitGCVideo (); 24 | void StopGX(); 25 | void ResetVideo_Emu(); 26 | void setGFX(); 27 | void update_video (int width, int height); 28 | void ResetVideo_Menu(); 29 | void TakeScreenshot(); 30 | void ClearScreenshot(); 31 | void Menu_Render(); 32 | void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[], f32 degrees, f32 scaleX, f32 scaleY, u8 alphaF ); 33 | void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled); 34 | 35 | extern GXRModeObj *vmode; 36 | extern int screenheight; 37 | extern int screenwidth; 38 | extern bool progressive; 39 | extern u8 * gameScreenPng; 40 | extern int gameScreenPngSize; 41 | extern u32 FrameTimer; 42 | extern bool vmode_60hz; 43 | extern int timerstyle; 44 | extern int CheckVideo; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /source/vmalloc.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * emu_kidid 2015-2018 5 | * 6 | * vmalloc.cpp 7 | * 8 | * GC VM memory allocator 9 | ***************************************************************************/ 10 | 11 | #ifdef USE_VM 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "utils/vm/vm.h" 18 | 19 | static heap_cntrl vm_heap; 20 | 21 | static int vm_initialised = 0; 22 | 23 | void InitVmManager () 24 | { 25 | __lwp_heap_init(&vm_heap, (void *)ARAM_VM_BASE, ARAM_SIZE, 32); 26 | vm_initialised = 1; 27 | } 28 | 29 | void* vm_malloc(u32 size) 30 | { 31 | if(!vm_initialised) InitVmManager(); 32 | return __lwp_heap_allocate(&vm_heap, size); 33 | } 34 | 35 | bool vm_free(void *ptr) 36 | { 37 | if(!vm_initialised) InitVmManager(); 38 | return __lwp_heap_free(&vm_heap, ptr); 39 | } 40 | 41 | int vm_size_free() 42 | { 43 | if(!vm_initialised) InitVmManager(); 44 | heap_iblock info; 45 | __lwp_heap_getinfo(&vm_heap,&info); 46 | return info.free_size; 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /source/vmalloc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Snes9x Nintendo Wii/GameCube Port 3 | * 4 | * emu_kidid 2015-2018 5 | * 6 | * vmalloc.h 7 | * 8 | * GC VM memory allocator 9 | ***************************************************************************/ 10 | 11 | #ifdef USE_VM 12 | 13 | #ifndef _VMMANAGER_H_ 14 | #define _VMMANAGER_H_ 15 | 16 | void* vm_malloc(u32 size); 17 | bool vm_free(void *ptr); 18 | int vm_size_free(); 19 | #endif 20 | 21 | #endif 22 | --------------------------------------------------------------------------------