├── .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