mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-09 11:41:35 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d109c22b49 | ||
|
|
98f2f1c23d | ||
|
|
94bc6ff3a2 | ||
|
|
62dc63542c | ||
|
|
dd8acd5872 | ||
|
|
d1113a5af0 | ||
|
|
024e10b5a9 | ||
|
|
c4b2492872 | ||
|
|
44bc9fe291 | ||
|
|
ee7bacd2bc | ||
|
|
90a2070718 | ||
|
|
abf34c06c1 | ||
|
|
661836fd77 | ||
|
|
260f3ac7ce | ||
|
|
f57ab1ccd8 | ||
|
|
ef206b3a27 | ||
|
|
2dce493240 | ||
|
|
83c3d7be57 | ||
|
|
7b0e1e8022 | ||
|
|
86950b4d2a | ||
|
|
fe02783fc7 | ||
|
|
072406e3c3 | ||
|
|
751761d99c | ||
|
|
fe993fafd5 | ||
|
|
057785539b | ||
|
|
048d2f65e0 | ||
|
|
c305f4347d | ||
|
|
3ca62fbbbc | ||
|
|
225699f545 | ||
|
|
35ae61fbc7 | ||
|
|
86dac8c979 | ||
|
|
95431414ae | ||
|
|
b3f7224ea1 | ||
|
|
e583546778 | ||
|
|
a39c37e1ee | ||
|
|
67fb35b645 | ||
|
|
3c1e4c879a | ||
|
|
83a11be669 | ||
|
|
08e35a62d4 | ||
|
|
5461c0d86e | ||
|
|
4eab7c4387 | ||
|
|
59aeb77744 | ||
|
|
c6fc8e45ff | ||
|
|
4dde927c12 | ||
|
|
6325b4cd2e | ||
|
|
4beec3870f | ||
|
|
36a2c96cb7 | ||
|
|
a4a68a2ad5 | ||
|
|
13a2010ed6 | ||
|
|
e37fd21424 | ||
|
|
a2698061a6 | ||
|
|
d00257382a | ||
|
|
51ab2f2509 | ||
|
|
61f9ceccab | ||
|
|
f836a291a0 | ||
|
|
97725e69eb | ||
|
|
d186e14eeb | ||
|
|
08aaa1021c | ||
|
|
b4248038fb | ||
|
|
ca587ab92e | ||
|
|
6f5c33848e | ||
|
|
17d380400e | ||
|
|
2e456b2570 | ||
|
|
fe17a42e62 | ||
|
|
c46866c6e5 | ||
|
|
3117633adf | ||
|
|
8a49321648 | ||
|
|
18f027ed41 | ||
|
|
79b9c68cb5 | ||
|
|
2b1344c3cf | ||
|
|
da26925118 | ||
|
|
f2a152f7c9 | ||
|
|
1953ea7312 | ||
|
|
e55dbe944d | ||
|
|
f5ad906e7b | ||
|
|
7cad2bcd6e | ||
|
|
cc921f25ed | ||
|
|
435109ceae | ||
|
|
ca375f65d5 | ||
|
|
76212f47bf | ||
|
|
6efb904919 | ||
|
|
072342cdab | ||
|
|
09761c0786 | ||
|
|
c48fab00e8 | ||
|
|
d1c562ce4e | ||
|
|
45cae81d51 | ||
|
|
30e28acfb3 | ||
|
|
00459365c4 | ||
|
|
649884bc05 | ||
|
|
e1af420b2d | ||
|
|
613f50dd14 | ||
|
|
a18c0b2b14 | ||
|
|
d7f8500b3a | ||
|
|
7ecf9681c5 | ||
|
|
e9ca7acce9 | ||
|
|
ea68de8070 | ||
|
|
0fa0bfeb74 | ||
|
|
4a5d0d8dfb | ||
|
|
af35a18515 | ||
|
|
5560babc11 | ||
|
|
3e76201d80 | ||
|
|
5b15d8626c | ||
|
|
f8a03a7d5d | ||
|
|
b7b9acb336 | ||
|
|
44e2d66cf5 | ||
|
|
9747767474 | ||
|
|
cee33327f8 | ||
|
|
f70b52a0df | ||
|
|
0b62771b54 | ||
|
|
b168109672 | ||
|
|
d8b6aebe9a | ||
|
|
4812b632c3 | ||
|
|
8320d0a0e9 | ||
|
|
a287ebe736 | ||
|
|
ebea0220cd | ||
|
|
2b01f36fc0 | ||
|
|
7e3092dc93 | ||
|
|
114c723d59 | ||
|
|
da39f8d3d6 | ||
|
|
33b76628aa | ||
|
|
94162f452d | ||
|
|
318d875981 | ||
|
|
520878272c | ||
|
|
fc87336c45 | ||
|
|
d66e039536 | ||
|
|
eeebc2d06b | ||
|
|
7d1ebdf94a | ||
|
|
3d1b0ef35b | ||
|
|
c2ba0d474c | ||
|
|
793c00e614 | ||
|
|
d4093dc31c | ||
|
|
bc66841a29 | ||
|
|
f4cc8a4bca | ||
|
|
539563f0f4 | ||
|
|
8c5d86a6eb | ||
|
|
884c113645 | ||
|
|
70587bc0df | ||
|
|
df4e0bb1e4 | ||
|
|
cdc92af959 | ||
|
|
763a5bf2c0 | ||
|
|
8301cf8a2f | ||
|
|
44da8a6749 | ||
|
|
06309ba1e0 | ||
|
|
004ca0fe89 | ||
|
|
40cce7c9d6 | ||
|
|
1c29d31859 | ||
|
|
d3af29fa1f | ||
|
|
c5d1fd32d5 | ||
|
|
a4767d3d43 | ||
|
|
c26f527c20 | ||
|
|
0c8d85d589 | ||
|
|
0c16e1a134 | ||
|
|
0a887395eb | ||
|
|
9118976c49 | ||
|
|
7f1e599186 | ||
|
|
672102d377 | ||
|
|
fe7f05e717 | ||
|
|
0724ab2ca1 | ||
|
|
c272ba56ad | ||
|
|
381498e945 | ||
|
|
70f07196ea | ||
|
|
c8dee57278 | ||
|
|
0ab305156b | ||
|
|
eac468ba19 | ||
|
|
18f407110b | ||
|
|
ceee10b56c | ||
|
|
9805bcc5f9 | ||
|
|
d5fca50a2f | ||
|
|
4ca72bd7e6 | ||
|
|
62ead00f0f | ||
|
|
5dc573ed38 | ||
|
|
fa053ffc2b | ||
|
|
be6c7bad24 | ||
|
|
2680971bb3 | ||
|
|
630f19f248 | ||
|
|
ef4bee2e4e | ||
|
|
f182a2ad24 | ||
|
|
3eb98951f7 | ||
|
|
f9d4bbf4d3 | ||
|
|
eff4fcecae | ||
|
|
cbfdc9cf97 | ||
|
|
034c7c70fb | ||
|
|
44ad016b91 | ||
|
|
5ed0d00249 | ||
|
|
6336fb4a1b | ||
|
|
99497e21cf | ||
|
|
0181d97cae | ||
|
|
968c73a748 | ||
|
|
13f9e94f61 | ||
|
|
8c1018d573 | ||
|
|
d4d00a35d7 | ||
|
|
e3177fd489 | ||
|
|
dd1300f1cc | ||
|
|
7f03af2b2b | ||
|
|
f431f77834 | ||
|
|
7c28a62b40 | ||
|
|
a360042f77 | ||
|
|
82af27cf33 | ||
|
|
0b78abb31d | ||
|
|
2fd8ffbf22 | ||
|
|
83f7be0cbb | ||
|
|
7f5db4d70f | ||
|
|
4f04c1288b | ||
|
|
8a2c5bf9e1 | ||
|
|
5c05e309c1 | ||
|
|
bd147270eb | ||
|
|
528cf8d472 | ||
|
|
0fce2f409f | ||
|
|
fd7b0b05b8 | ||
|
|
9abc7c00c9 | ||
|
|
ebc5f433cd | ||
|
|
aa4f79f236 | ||
|
|
62f5c53b72 | ||
|
|
534163a57f | ||
|
|
325a9fb48e | ||
|
|
ee43531a99 | ||
|
|
757fa71469 | ||
|
|
bfee7986bd | ||
|
|
9aaad17c1a | ||
|
|
93874bba83 | ||
|
|
9c67452f10 | ||
|
|
0416a2ae61 | ||
|
|
8bbde14019 | ||
|
|
0e8f2339d8 | ||
|
|
9f37427d7a | ||
|
|
6ad4b1f15a | ||
|
|
a39c0f01f9 | ||
|
|
1136820124 | ||
|
|
2a3f3bad23 | ||
|
|
74def91a53 | ||
|
|
bc62e1be08 | ||
|
|
25aea134ef | ||
|
|
e488c3081d | ||
|
|
331f46fb24 | ||
|
|
e88662cab0 | ||
|
|
395f6d1d3c | ||
|
|
94bd78b3e1 | ||
|
|
dc373fb7d0 | ||
|
|
140812d64a | ||
|
|
a91c4e556f | ||
|
|
372c622166 | ||
|
|
d961d68e9c | ||
|
|
33a325a730 | ||
|
|
909b25c7ac | ||
|
|
77f110c23e | ||
|
|
9dc9416ef9 | ||
|
|
0b20f11617 | ||
|
|
c9594776f8 | ||
|
|
8f55b9904d | ||
|
|
093ba1c33d | ||
|
|
67a434d563 | ||
|
|
ff0c3f047a | ||
|
|
2934ba301b | ||
|
|
f3627aaf59 | ||
|
|
dc8a2dea72 | ||
|
|
329969eb05 | ||
|
|
71923af675 | ||
|
|
18e58ca5f4 | ||
|
|
8c3aebbbc8 | ||
|
|
7f40c11eb7 | ||
|
|
0ed668d1b5 | ||
|
|
1c8632cac9 | ||
|
|
e7324989fc | ||
|
|
a7fc3807b9 | ||
|
|
99ad7bcc51 | ||
|
|
5b88e338df | ||
|
|
425af71450 | ||
|
|
19c5eab07a | ||
|
|
e5286cbe39 | ||
|
|
02d40aa212 | ||
|
|
8a5c537e15 | ||
|
|
c6c4f2f4d1 | ||
|
|
5bc7ea4045 | ||
|
|
077acf7894 | ||
|
|
c5f86f12c0 | ||
|
|
243e941d81 | ||
|
|
d67e6b7c15 | ||
|
|
f76bf59fed | ||
|
|
1c4d88eb04 | ||
|
|
ad04db8365 | ||
|
|
a63ccbbdab | ||
|
|
278f314c03 | ||
|
|
a3abda7e7b | ||
|
|
c0a9db111d | ||
|
|
676ce10119 | ||
|
|
c18dce4783 | ||
|
|
088b01b52e | ||
|
|
c0f436b8ab | ||
|
|
3377020242 | ||
|
|
6db58fe1dd | ||
|
|
67c7cd8de9 | ||
|
|
457a3d458a | ||
|
|
6538312d86 | ||
|
|
7f1a5075b1 | ||
|
|
e412ecdefe | ||
|
|
67b89d6f42 | ||
|
|
c8d3278dbc | ||
|
|
3556445660 | ||
|
|
f28fc0cabb | ||
|
|
e0bc548400 | ||
|
|
011a4c8a89 | ||
|
|
87bc5220eb | ||
|
|
673d0ed1a2 | ||
|
|
a5079bdda1 | ||
|
|
fc43e7155e | ||
|
|
4935333b63 | ||
|
|
5a3232adff | ||
|
|
d03f351f33 | ||
|
|
8d5bf997a9 | ||
|
|
0738480439 | ||
|
|
9a5e1a31ad | ||
|
|
5ab7664f49 | ||
|
|
1cb2c60ccc | ||
|
|
1356d0ab4c | ||
|
|
b4c4a65f2d | ||
|
|
ab3cf8daca | ||
|
|
2b6c252747 | ||
|
|
ec9a6ac90a | ||
|
|
a207549f18 | ||
|
|
efbf9354f9 | ||
|
|
216ddc9fd6 | ||
|
|
3b668cccd3 | ||
|
|
30a86a2845 | ||
|
|
a7870aa888 | ||
|
|
271b99981c | ||
|
|
08ef01bb13 | ||
|
|
e778af462a | ||
|
|
9d124b2380 | ||
|
|
f24e7cd665 | ||
|
|
e7f1526942 | ||
|
|
647b1ba53c | ||
|
|
eac8d9f191 | ||
|
|
50babe8432 | ||
|
|
8171977ed7 | ||
|
|
f8aaf1df1e | ||
|
|
04d0d84d01 | ||
|
|
f4aa9fa865 | ||
|
|
40ef7d6f00 | ||
|
|
66b7b1691c | ||
|
|
43972d4c35 | ||
|
|
632545c409 | ||
|
|
3a47e2cd63 | ||
|
|
a221e3e4cd | ||
|
|
b87f50dc9d | ||
|
|
a5b3f421d1 | ||
|
|
182525afa9 | ||
|
|
419afbcb83 | ||
|
|
12ca70a308 | ||
|
|
1fa7663d3b | ||
|
|
2e34c6fc5c | ||
|
|
cb7002559d | ||
|
|
36ec92793f | ||
|
|
4187d70b30 | ||
|
|
5969655c3c | ||
|
|
09d2ec7d3a | ||
|
|
27b975d0fc | ||
|
|
6da64013fa | ||
|
|
d8eb5de380 | ||
|
|
23aa8bbe7a | ||
|
|
3b5472dbac | ||
|
|
3b4e60aada | ||
|
|
8d8fb44c18 | ||
|
|
b46fb60a6e | ||
|
|
f7399bbc8b | ||
|
|
7f7d47b120 | ||
|
|
e7aa3ed0cc | ||
|
|
0ece8b1319 | ||
|
|
557e05dd12 | ||
|
|
08a1496501 | ||
|
|
5a24037c61 | ||
|
|
5dbd1ea35c |
No files matched your search
+9
-1
@@ -1,7 +1,15 @@
|
||||
*.o
|
||||
*.bmpobj
|
||||
*.so
|
||||
*.dll
|
||||
ssnes
|
||||
/ssnes
|
||||
/config.h
|
||||
/config.mk
|
||||
/tools/ssnes-joyconfig
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.suo
|
||||
Debug
|
||||
Release
|
||||
ipch
|
||||
*.user
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2012 - Daniel De Matteis
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <xtl.h>
|
||||
#include <stddef.h>
|
||||
#include <xbdm.h>
|
||||
|
||||
int ssnes_main(int argc, char *argv[]);
|
||||
|
||||
#undef main
|
||||
// Temporary, a more sane implementation should go here.
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//for devits only, we will need to mount all partitions for retail
|
||||
//in a different way
|
||||
DmMapDevkitDrive();
|
||||
|
||||
char arg1[] = "ssnes";
|
||||
char arg2[] = "e:\\roms\\mario.sfc";
|
||||
char arg3[] = "-v";
|
||||
char arg4[] = "-c";
|
||||
char arg5[] = "e:\\roms\\ssnes.cfg";
|
||||
char *argv_[] = { arg1, arg2, arg3, arg4, arg5, NULL };
|
||||
return ssnes_main(sizeof(argv_) / sizeof(argv_[0]) - 1, argv_);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __SSNES_MSVC_COMPAT_H
|
||||
#define __SSNES_MSVC_COMPAT_H
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#undef UNICODE // Do not bother with UNICODE at this time.
|
||||
#include <stddef.h>
|
||||
#include <math.h>
|
||||
|
||||
// Python headers defines ssize_t and sets HAVE_SSIZE_T. Cannot duplicate these efforts.
|
||||
#ifndef HAVE_SSIZE_T
|
||||
typedef int ssize_t;
|
||||
#endif
|
||||
|
||||
#define snprintf _snprintf
|
||||
#define strcasecmp _stricmp
|
||||
|
||||
// Disable some of the annoying warnings.
|
||||
#pragma warning(disable : 4800)
|
||||
#pragma warning(disable : 4244)
|
||||
#pragma warning(disable : 4305)
|
||||
#pragma warning(disable : 4146)
|
||||
#pragma warning(disable : 4267)
|
||||
|
||||
static inline float roundf(float in)
|
||||
{
|
||||
return in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../driver.h"
|
||||
#include <stdlib.h>
|
||||
#include <xtl.h>
|
||||
#include <xaudio2.h>
|
||||
#include "../general.h"
|
||||
|
||||
#define MAX_BUFFERS 16
|
||||
#define MAX_BUFFERS_MASK 15
|
||||
|
||||
struct XAudio : public IXAudio2VoiceCallback
|
||||
{
|
||||
XAudio() :
|
||||
buf(0), pXAudio2(0), pMasteringVoice(0),
|
||||
pSourceVoice(0), nonblock(false), bufsize(0),
|
||||
bufptr(0), write_buffer(0), buffers(0), hEvent(0)
|
||||
{}
|
||||
|
||||
~XAudio()
|
||||
{
|
||||
if (pSourceVoice)
|
||||
{
|
||||
pSourceVoice->Stop(0, XAUDIO2_COMMIT_NOW);
|
||||
pSourceVoice->DestroyVoice();
|
||||
}
|
||||
|
||||
if (pMasteringVoice)
|
||||
pMasteringVoice->DestroyVoice();
|
||||
|
||||
if (pXAudio2)
|
||||
pXAudio2->Release();
|
||||
|
||||
if (hEvent)
|
||||
CloseHandle(hEvent);
|
||||
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
bool init(unsigned rate, unsigned latency)
|
||||
{
|
||||
size_t bufsize_ = latency * rate / 1000;
|
||||
size_t size = bufsize_ * 2 * sizeof(int16_t);
|
||||
|
||||
SSNES_LOG("XAudio2: Requesting %d ms latency, using %d ms latency.\n", latency, (int)bufsize_ * 1000 / rate);
|
||||
|
||||
if (FAILED(XAudio2Create(&pXAudio2, 0)))
|
||||
return false;
|
||||
|
||||
if (FAILED(pXAudio2->CreateMasteringVoice(&pMasteringVoice, 2, rate, 0, 0, NULL)))
|
||||
return false;
|
||||
|
||||
WAVEFORMATEX wfx = {0};
|
||||
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
||||
wfx.nChannels = 2;
|
||||
wfx.nSamplesPerSec = rate;
|
||||
wfx.nBlockAlign = 2 * sizeof(int16_t);
|
||||
wfx.wBitsPerSample = sizeof(int16_t) * 8;
|
||||
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
||||
wfx.cbSize = 0;
|
||||
|
||||
if (FAILED(pXAudio2->CreateSourceVoice(&pSourceVoice, &wfx,
|
||||
XAUDIO2_VOICE_NOSRC, XAUDIO2_DEFAULT_FREQ_RATIO, this, 0, 0)))
|
||||
return false;
|
||||
|
||||
hEvent = CreateEvent(0, FALSE, FALSE, 0);
|
||||
|
||||
bufsize = size / MAX_BUFFERS;
|
||||
buf = new uint8_t[bufsize * MAX_BUFFERS];
|
||||
memset(buf, 0, bufsize * MAX_BUFFERS);
|
||||
|
||||
if (FAILED(pSourceVoice->Start(0)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// It's really 16-bit, but we have to byteswap.
|
||||
size_t write(const uint8_t *buffer, size_t size)
|
||||
{
|
||||
if (nonblock)
|
||||
{
|
||||
size_t avail = bufsize * (MAX_BUFFERS - buffers - 1);
|
||||
if (avail == 0)
|
||||
return 0;
|
||||
if (avail < size)
|
||||
size = avail;
|
||||
}
|
||||
|
||||
unsigned bytes = size;
|
||||
while (bytes)
|
||||
{
|
||||
unsigned need = min(bytes, bufsize - bufptr);
|
||||
uint8_t *base_write = buf + write_buffer * bufsize + bufptr;
|
||||
memcpy(base_write, buffer, need);
|
||||
|
||||
bufptr += need;
|
||||
buffer += need;
|
||||
bytes -= need;
|
||||
|
||||
if (bufptr == bufsize)
|
||||
{
|
||||
while (buffers == MAX_BUFFERS - 1)
|
||||
WaitForSingleObject(hEvent, INFINITE);
|
||||
|
||||
XAUDIO2_BUFFER xa2buffer = {0};
|
||||
xa2buffer.AudioBytes = bufsize;
|
||||
xa2buffer.pAudioData = buf + write_buffer * bufsize;
|
||||
|
||||
if (FAILED(pSourceVoice->SubmitSourceBuffer(&xa2buffer)))
|
||||
return 0;
|
||||
|
||||
InterlockedIncrement(&buffers);
|
||||
bufptr = 0;
|
||||
write_buffer = (write_buffer + 1) & MAX_BUFFERS_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
STDMETHOD_(void, OnBufferStart) (void *) {}
|
||||
STDMETHOD_(void, OnBufferEnd) (void *)
|
||||
{
|
||||
InterlockedDecrement(&buffers);
|
||||
SetEvent(hEvent);
|
||||
}
|
||||
STDMETHOD_(void, OnLoopEnd) (void *) {}
|
||||
STDMETHOD_(void, OnStreamEnd) () {}
|
||||
STDMETHOD_(void, OnVoiceError) (void *, HRESULT) {}
|
||||
STDMETHOD_(void, OnVoiceProcessingPassEnd) () {}
|
||||
STDMETHOD_(void, OnVoiceProcessingPassStart) (UINT32) {}
|
||||
|
||||
uint8_t *buf;
|
||||
IXAudio2 *pXAudio2;
|
||||
IXAudio2MasteringVoice *pMasteringVoice;
|
||||
IXAudio2SourceVoice *pSourceVoice;
|
||||
bool nonblock;
|
||||
unsigned bufsize;
|
||||
unsigned bufptr;
|
||||
unsigned write_buffer;
|
||||
volatile long buffers;
|
||||
HANDLE hEvent;
|
||||
};
|
||||
|
||||
static void *xa_init(const char *device, unsigned rate, unsigned latency)
|
||||
{
|
||||
if (latency < 8)
|
||||
latency = 8; // Do not allow shenanigans.
|
||||
|
||||
XAudio *xa = new XAudio;
|
||||
if (!xa->init(rate, latency))
|
||||
goto error;
|
||||
|
||||
return xa;
|
||||
|
||||
error:
|
||||
SSNES_ERR("Failed to init XAudio2.\n");
|
||||
delete xa;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static ssize_t xa_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
XAudio *xa = (XAudio*)data;
|
||||
size_t ret = xa->write((const uint8_t*)buf, size);
|
||||
|
||||
if (ret == 0)
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool xa_stop(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void xa_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
XAudio *xa = (XAudio*)data;
|
||||
xa->nonblock = state;
|
||||
}
|
||||
|
||||
static bool xa_start(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void xa_free(void *data)
|
||||
{
|
||||
XAudio *xa = (XAudio*)data;
|
||||
if (xa)
|
||||
delete xa;
|
||||
}
|
||||
|
||||
const audio_driver_t audio_xdk360 = {
|
||||
xa_init,
|
||||
xa_write,
|
||||
xa_stop,
|
||||
xa_start,
|
||||
xa_set_nonblock_state,
|
||||
xa_free,
|
||||
NULL,
|
||||
"xdk360"
|
||||
};
|
||||
@@ -0,0 +1,124 @@
|
||||
/* SSNES - A Super Ninteno Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2012 - Daniel De Matteis
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <xtl.h>
|
||||
#include "../driver.h"
|
||||
#include "../libsnes.hpp"
|
||||
|
||||
static XINPUT_STATE state[5];
|
||||
|
||||
static void xdk360_input_poll(void *data)
|
||||
{
|
||||
(void)data;
|
||||
ZeroMemory(&state, sizeof(XINPUT_STATE));
|
||||
|
||||
for (unsigned i = 0; i < 5; i++)
|
||||
XInputGetState(i, &state[i]);
|
||||
}
|
||||
|
||||
static int16_t xdk360_input_state(void *data, const struct snes_keybind **binds,
|
||||
bool port, unsigned device,
|
||||
unsigned index, unsigned id)
|
||||
{
|
||||
(void)data;
|
||||
(void)binds;
|
||||
(void)index;
|
||||
|
||||
if (device != SNES_DEVICE_JOYPAD)
|
||||
return 0;
|
||||
|
||||
unsigned player = 0;
|
||||
if (port == SNES_PORT_2 && device == SNES_DEVICE_MULTITAP)
|
||||
player = index + 1;
|
||||
else if (port == SNES_PORT_2)
|
||||
player = 1;
|
||||
|
||||
// Hardcoded binds.
|
||||
uint64_t button;
|
||||
switch (id)
|
||||
{
|
||||
case SNES_DEVICE_ID_JOYPAD_A:
|
||||
button = XINPUT_GAMEPAD_B;
|
||||
break;
|
||||
case SNES_DEVICE_ID_JOYPAD_B:
|
||||
button = XINPUT_GAMEPAD_A;
|
||||
break;
|
||||
case SNES_DEVICE_ID_JOYPAD_X:
|
||||
button = XINPUT_GAMEPAD_Y;
|
||||
break;
|
||||
case SNES_DEVICE_ID_JOYPAD_Y:
|
||||
button = XINPUT_GAMEPAD_X;
|
||||
break;
|
||||
case SNES_DEVICE_ID_JOYPAD_LEFT:
|
||||
button = XINPUT_GAMEPAD_DPAD_LEFT;
|
||||
break;
|
||||
case SNES_DEVICE_ID_JOYPAD_RIGHT:
|
||||
button = XINPUT_GAMEPAD_DPAD_RIGHT;
|
||||
break;
|
||||
case SNES_DEVICE_ID_JOYPAD_UP:
|
||||
button = XINPUT_GAMEPAD_DPAD_UP;
|
||||
break;
|
||||
case SNES_DEVICE_ID_JOYPAD_DOWN:
|
||||
button = XINPUT_GAMEPAD_DPAD_DOWN;
|
||||
break;
|
||||
case SNES_DEVICE_ID_JOYPAD_START:
|
||||
button = XINPUT_GAMEPAD_START;
|
||||
break;
|
||||
case SNES_DEVICE_ID_JOYPAD_SELECT:
|
||||
button = XINPUT_GAMEPAD_BACK;
|
||||
break;
|
||||
case SNES_DEVICE_ID_JOYPAD_L:
|
||||
button = XINPUT_GAMEPAD_LEFT_SHOULDER;
|
||||
break;
|
||||
case SNES_DEVICE_ID_JOYPAD_R:
|
||||
button = XINPUT_GAMEPAD_RIGHT_SHOULDER;
|
||||
break;
|
||||
default:
|
||||
button = 0;
|
||||
}
|
||||
|
||||
return (state[player].Gamepad.wButtons & button) ? 1 : 0;
|
||||
}
|
||||
|
||||
static void xdk360_free_input(void *data)
|
||||
{
|
||||
(void)data;
|
||||
}
|
||||
|
||||
static void* xdk360_input_init(void)
|
||||
{
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
static bool xdk360_key_pressed(void *data, int key)
|
||||
{
|
||||
(void)data;
|
||||
(void)key;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const input_driver_t input_xdk360 = {
|
||||
xdk360_input_init,
|
||||
xdk360_input_poll,
|
||||
xdk360_input_state,
|
||||
xdk360_key_pressed,
|
||||
xdk360_free_input,
|
||||
"xdk360"};
|
||||
@@ -0,0 +1,304 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <xtl.h>
|
||||
|
||||
#include "../driver.h"
|
||||
#include "../general.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
static const char* g_strPixelShaderProgram =
|
||||
" sampler2D tex : register(s0); "
|
||||
" struct PS_IN "
|
||||
" { "
|
||||
" float2 coord : TEXCOORD0; "
|
||||
" }; "
|
||||
" "
|
||||
" float4 main(PS_IN input) : COLOR "
|
||||
" { "
|
||||
" return tex2D(tex, input.coord); "
|
||||
" } ";
|
||||
|
||||
static const char* g_strVertexShaderProgram =
|
||||
" struct VS_IN "
|
||||
" "
|
||||
" { "
|
||||
" float2 pos : POSITION; "
|
||||
" float2 coord : TEXCOORD0; "
|
||||
" }; "
|
||||
" "
|
||||
" struct VS_OUT "
|
||||
" { "
|
||||
" float4 pos : POSITION; "
|
||||
" float2 coord : TEXCOORD0; "
|
||||
" }; "
|
||||
" "
|
||||
" VS_OUT main(VS_IN input) "
|
||||
" { "
|
||||
" VS_OUT output; "
|
||||
" output.pos = float4(input.pos, 0.0, 1.0); "
|
||||
" output.coord = input.coord; "
|
||||
" return output; "
|
||||
" } ";
|
||||
|
||||
typedef struct DrawVerticeFormats
|
||||
{
|
||||
float x, y;
|
||||
float u, v;
|
||||
} DrawVerticeFormats;
|
||||
|
||||
static bool g_quitting;
|
||||
|
||||
typedef struct xdk360_video
|
||||
{
|
||||
IDirect3D9* xdk360_device;
|
||||
IDirect3DDevice9* xdk360_render_device;
|
||||
IDirect3DVertexShader9 *pVertexShader;
|
||||
IDirect3DPixelShader9* pPixelShader;
|
||||
IDirect3DVertexDeclaration9* pVertexDecl;
|
||||
IDirect3DVertexBuffer9* vertex_buf;
|
||||
IDirect3DTexture9* lpTexture;
|
||||
unsigned frame_count;
|
||||
unsigned last_width, last_height;
|
||||
} xdk360_video_t;
|
||||
|
||||
static void xdk360_gfx_free(void *data)
|
||||
{
|
||||
xdk360_video_t *vid = (xdk360_video_t*)data;
|
||||
if (!vid)
|
||||
return;
|
||||
|
||||
vid->lpTexture->Release();
|
||||
vid->vertex_buf->Release();
|
||||
vid->pVertexDecl->Release();
|
||||
vid->pPixelShader->Release();
|
||||
vid->pVertexShader->Release();
|
||||
vid->xdk360_render_device->Release();
|
||||
vid->xdk360_device->Release();
|
||||
|
||||
free(vid);
|
||||
}
|
||||
|
||||
static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **input, void **input_data)
|
||||
{
|
||||
xdk360_video_t *vid = (xdk360_video_t*)calloc(1, sizeof(xdk360_video_t));
|
||||
if (!vid)
|
||||
return NULL;
|
||||
|
||||
vid->xdk360_device = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
if (!vid->xdk360_device)
|
||||
{
|
||||
free(vid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
D3DPRESENT_PARAMETERS d3dpp;
|
||||
ZeroMemory(&d3dpp, sizeof(d3dpp));
|
||||
|
||||
d3dpp.BackBufferWidth = 1280;
|
||||
d3dpp.BackBufferHeight = 720;
|
||||
d3dpp.BackBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_A8R8G8B8);
|
||||
d3dpp.FrontBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8);
|
||||
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||
d3dpp.MultiSampleQuality = 0;
|
||||
d3dpp.BackBufferCount = 2;
|
||||
d3dpp.EnableAutoDepthStencil = TRUE;
|
||||
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
|
||||
|
||||
vid->xdk360_device->CreateDevice(0, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp,
|
||||
&vid->xdk360_render_device);
|
||||
|
||||
ID3DXBuffer* pShaderCodeV = NULL;
|
||||
ID3DXBuffer* pShaderCodeP = NULL;
|
||||
ID3DXBuffer* pErrorMsg = NULL;
|
||||
|
||||
HRESULT hr = D3DXCompileShader(g_strVertexShaderProgram, (UINT)strlen(g_strVertexShaderProgram),
|
||||
NULL, NULL, "main", "vs_2_0", 0, &pShaderCodeV, &pErrorMsg, NULL);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = D3DXCompileShader(g_strPixelShaderProgram, (UINT)strlen(g_strPixelShaderProgram),
|
||||
NULL, NULL, "main", "ps_2_0", 0, &pShaderCodeP, &pErrorMsg, NULL);
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
OutputDebugString(pErrorMsg ? (char*)pErrorMsg->GetBufferPointer() : "");
|
||||
vid->xdk360_render_device->Release();
|
||||
vid->xdk360_device->Release();
|
||||
free(vid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vid->xdk360_render_device->CreateVertexShader((const DWORD*)pShaderCodeV->GetBufferPointer(), &vid->pVertexShader);
|
||||
vid->xdk360_render_device->CreatePixelShader((const DWORD*)pShaderCodeP->GetBufferPointer(), &vid->pPixelShader);
|
||||
pShaderCodeV->Release();
|
||||
pShaderCodeP->Release();
|
||||
|
||||
vid->xdk360_render_device->CreateTexture(512, 512, 1, 0, D3DFMT_LIN_X1R5G5B5,
|
||||
0, &vid->lpTexture, NULL);
|
||||
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
if (SUCCEEDED(vid->lpTexture->LockRect(0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK)))
|
||||
{
|
||||
memset(d3dlr.pBits, 0, 512 * d3dlr.Pitch);
|
||||
vid->lpTexture->UnlockRect(0);
|
||||
}
|
||||
|
||||
vid->last_width = 512;
|
||||
vid->last_height = 512;
|
||||
|
||||
vid->xdk360_render_device->CreateVertexBuffer(4 * sizeof(DrawVerticeFormats), 0,
|
||||
0, 0, &vid->vertex_buf, NULL);
|
||||
|
||||
static const DrawVerticeFormats init_verts[] = {
|
||||
{ -1.0f, -1.0f, 0.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, 1.0f, 1.0f },
|
||||
{ -1.0f, 1.0f, 0.0f, 0.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, 0.0f },
|
||||
};
|
||||
|
||||
void *verts_ptr;
|
||||
vid->vertex_buf->Lock(0, 0, &verts_ptr, 0);
|
||||
memcpy(verts_ptr, init_verts, sizeof(init_verts));
|
||||
vid->vertex_buf->Unlock();
|
||||
|
||||
static const D3DVERTEXELEMENT9 VertexElements[] =
|
||||
{
|
||||
{ 0, 0 * sizeof(float), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
|
||||
{ 0, 2 * sizeof(float), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
|
||||
D3DDECL_END()
|
||||
};
|
||||
|
||||
vid->xdk360_render_device->CreateVertexDeclaration(VertexElements, &vid->pVertexDecl);
|
||||
|
||||
vid->xdk360_render_device->Clear(0, NULL, D3DCLEAR_TARGET,
|
||||
0xff000000, 1.0f, 0);
|
||||
|
||||
vid->xdk360_render_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
vid->xdk360_render_device->SetRenderState(D3DRS_ZENABLE, FALSE);
|
||||
|
||||
D3DVIEWPORT9 vp = {0};
|
||||
vp.Width = 1280;
|
||||
vp.Height = 720;
|
||||
vp.MinZ = 0.0f;
|
||||
vp.MaxZ = 1.0f;
|
||||
vid->xdk360_render_device->SetViewport(&vp);
|
||||
|
||||
return vid;
|
||||
}
|
||||
|
||||
static bool xdk360_gfx_frame(void *data, const void *frame,
|
||||
unsigned width, unsigned height, unsigned pitch, const char *msg)
|
||||
{
|
||||
xdk360_video_t *vid = (xdk360_video_t*)data;
|
||||
vid->frame_count++;
|
||||
|
||||
vid->xdk360_render_device->Clear(0, NULL, D3DCLEAR_TARGET,
|
||||
0xff000000, 1.0f, 0);
|
||||
|
||||
if (vid->last_width != width || vid->last_height != height)
|
||||
{
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
if (SUCCEEDED(vid->lpTexture->LockRect(0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK)))
|
||||
{
|
||||
memset(d3dlr.pBits, 0, 512 * d3dlr.Pitch);
|
||||
vid->lpTexture->UnlockRect(0);
|
||||
}
|
||||
|
||||
float tex_w = width / 512.0f;
|
||||
float tex_h = height / 512.0f;
|
||||
const DrawVerticeFormats verts[] = {
|
||||
{ -1.0f, -1.0f, 0.0f, tex_h },
|
||||
{ 1.0f, -1.0f, tex_w, tex_h },
|
||||
{ -1.0f, 1.0f, 0.0f, 0.0f },
|
||||
{ 1.0f, 1.0f, tex_w, 0.0f },
|
||||
};
|
||||
|
||||
void *verts_ptr;
|
||||
vid->vertex_buf->Lock(0, 0, &verts_ptr, 0);
|
||||
memcpy(verts_ptr, verts, sizeof(verts));
|
||||
vid->vertex_buf->Unlock();
|
||||
|
||||
vid->last_width = width;
|
||||
vid->last_height = height;
|
||||
}
|
||||
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
if (SUCCEEDED(vid->lpTexture->LockRect(0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK)))
|
||||
{
|
||||
for (unsigned y = 0; y < height; y++)
|
||||
{
|
||||
const uint8_t *in = (const uint8_t*)frame + y * pitch;
|
||||
uint8_t *out = (uint8_t*)d3dlr.pBits + y * d3dlr.Pitch;
|
||||
memcpy(out, in, width * sizeof(uint16_t));
|
||||
}
|
||||
vid->lpTexture->UnlockRect(0);
|
||||
}
|
||||
|
||||
vid->xdk360_render_device->SetTexture(0, vid->lpTexture);
|
||||
vid->xdk360_render_device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
vid->xdk360_render_device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||
vid->xdk360_render_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
|
||||
vid->xdk360_render_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
|
||||
|
||||
vid->xdk360_render_device->SetVertexShader(vid->pVertexShader);
|
||||
vid->xdk360_render_device->SetPixelShader(vid->pPixelShader);
|
||||
|
||||
vid->xdk360_render_device->SetVertexDeclaration(vid->pVertexDecl);
|
||||
vid->xdk360_render_device->SetStreamSource(0, vid->vertex_buf, 0, sizeof(DrawVerticeFormats));
|
||||
|
||||
vid->xdk360_render_device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
vid->xdk360_render_device->Present(NULL, NULL, NULL, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void xdk360_gfx_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
static bool xdk360_gfx_alive(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return !g_quitting;
|
||||
}
|
||||
|
||||
static bool xdk360_gfx_focus(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
const video_driver_t video_xdk360 = {
|
||||
xdk360_gfx_init,
|
||||
xdk360_gfx_frame,
|
||||
xdk360_gfx_set_nonblock_state,
|
||||
xdk360_gfx_alive,
|
||||
xdk360_gfx_focus,
|
||||
NULL,
|
||||
xdk360_gfx_free,
|
||||
"xdk360"
|
||||
};
|
||||
|
||||
@@ -6,3 +6,8 @@ Devin J. Pohly - <[email protected]>
|
||||
|
||||
Chris Moeller - <[email protected]>
|
||||
- CoreAudio audio driver
|
||||
|
||||
Daniel De Matteis - <[email protected]>
|
||||
- PlayStation 3 port
|
||||
- XBox 360 XDK port
|
||||
|
||||
@@ -2,11 +2,11 @@ include config.mk
|
||||
|
||||
TARGET = ssnes tools/ssnes-joyconfig
|
||||
|
||||
OBJ = ssnes.o file.o driver.o settings.o dynamic.o message.o rewind.o movie.o autosave.o gfx/gfx_common.o ups.o bps.o strl.o screenshot.o thread.o audio/hermite.o
|
||||
OBJ = ssnes.o file.o driver.o settings.o dynamic.o message.o rewind.o movie.o gfx/gfx_common.o ups.o bps.o strl.o getopt.o screenshot.o audio/hermite.o audio/utils.o
|
||||
JOYCONFIG_OBJ = tools/ssnes-joyconfig.o conf/config_file.o strl.o
|
||||
HEADERS = $(wildcard */*.h) $(wildcard *.h)
|
||||
|
||||
LIBS = -lm -lpthread
|
||||
LIBS = -lm
|
||||
DEFINES = -DHAVE_CONFIG_H
|
||||
|
||||
ifneq ($(findstring Darwin,$(OS)),)
|
||||
@@ -27,6 +27,11 @@ ifneq ($(findstring Linux,$(OS)),)
|
||||
LIBS += -lrt
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_THREADS), 1)
|
||||
OBJ += autosave.o thread.o
|
||||
LIBS += -lpthread
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_CONFIGFILE), 1)
|
||||
OBJ += conf/config_file.o
|
||||
endif
|
||||
@@ -86,7 +91,7 @@ ifeq ($(HAVE_COREAUDIO), 1)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_SDL), 1)
|
||||
OBJ += gfx/sdl.o gfx/sdlwrap.o input/sdl.o audio/sdl.o fifo_buffer.o
|
||||
OBJ += gfx/sdl_gfx.o gfx/sdlwrap.o input/sdl_input.o audio/sdl_audio.o fifo_buffer.o
|
||||
DEFINES += $(SDL_CFLAGS) $(BSD_LOCAL_INC)
|
||||
LIBS += $(SDL_LIBS)
|
||||
|
||||
@@ -128,7 +133,7 @@ else ifeq ($(HAVE_CG), 1)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_DYLIB), 1)
|
||||
OBJ += gfx/ext.o audio/ext.o
|
||||
OBJ += gfx/ext_gfx.o audio/ext_audio.o
|
||||
LIBS += $(DYLIB_LIB)
|
||||
endif
|
||||
|
||||
@@ -155,10 +160,6 @@ else
|
||||
LIBS += $(libsnes)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_STRL), 1)
|
||||
DEFINES += -DHAVE_STRL
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_PYTHON), 1)
|
||||
DEFINES += $(PYTHON_CFLAGS) -Wno-unused-parameter
|
||||
LIBS += $(PYTHON_LIBS)
|
||||
@@ -175,11 +176,15 @@ ifeq ($(DEBUG), 1)
|
||||
endif
|
||||
|
||||
CFLAGS += -Wall $(OPTIMIZE_FLAG) -g -I. -pedantic
|
||||
ifeq ($(CXX_BUILD), 1)
|
||||
CFLAGS += -std=c++0x -xc++ -D__STDC_CONSTANT_MACROS
|
||||
else
|
||||
ifneq ($(findstring icc,$(CC)),)
|
||||
CFLAGS += -std=c99 -D_GNU_SOURCE
|
||||
else
|
||||
CFLAGS += -std=gnu99
|
||||
endif
|
||||
endif
|
||||
|
||||
all: $(TARGET) config.mk
|
||||
|
||||
@@ -192,7 +197,11 @@ ssnes: $(OBJ)
|
||||
@$(if $(Q), $(shell echo echo LD $@),)
|
||||
|
||||
tools/ssnes-joyconfig: $(JOYCONFIG_OBJ)
|
||||
ifeq ($(CXX_BUILD), 1)
|
||||
$(Q)$(CXX) -o $@ $(JOYCONFIG_OBJ) $(SDL_LIBS) $(LDFLAGS) $(LIBRARY_DIRS)
|
||||
else
|
||||
$(Q)$(CC) -o $@ $(JOYCONFIG_OBJ) $(SDL_LIBS) $(LDFLAGS) $(LIBRARY_DIRS)
|
||||
endif
|
||||
@$(if $(Q), $(shell echo echo LD $@),)
|
||||
|
||||
%.o: %.c config.h config.mk $(HEADERS)
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
###
|
||||
##
|
||||
# Makefile for SSNES PS3. Somewhat generic and avoids using the odd SDK examples.
|
||||
##
|
||||
###
|
||||
##
|
||||
DEBUG = 0
|
||||
CELL_BUILD_TOOLS = GCC
|
||||
|
||||
## Platform detection from nall/Makefile. Only two applicable hosts for PS3 SDK.
|
||||
ifeq ($(platform),)
|
||||
uname := $(shell uname -a)
|
||||
ifeq ($(uname),)
|
||||
platform := win
|
||||
else
|
||||
platform := linux
|
||||
endif
|
||||
endif
|
||||
|
||||
CELL_SDK := /usr/local/cell
|
||||
ifeq ($(platform),win)
|
||||
HOST_DIR := host-win32
|
||||
else
|
||||
HOST_DIR := host-linux
|
||||
endif
|
||||
|
||||
ifeq ($(CELL_BUILD_TOOLS),SNC)
|
||||
CC = $(CELL_SDK)/$(HOST_DIR)/sn/bin/ps3ppusnc
|
||||
CXX = $(CC)
|
||||
LD = $(CELL_SDK)/$(HOST_DIR)/sn/bin/ps3ppuld
|
||||
else
|
||||
CC = $(CELL_SDK)/$(HOST_DIR)/ppu/bin/ppu-lv2-gcc
|
||||
CXX = $(CELL_SDK)/$(HOST_DIR)/ppu/bin/ppu-lv2-g++
|
||||
LD = $(CELL_SDK)/$(HOST_DIR)/ppu/bin/ppu-lv2-g++
|
||||
endif
|
||||
STRIP = $(CELL_SDK)/$(HOST_DIR)/ppu/bin/ppu-lv2-strip
|
||||
|
||||
PPU_TARGET := ssnes.elf
|
||||
|
||||
LDDIRS = -L. -L$(CELL_SDK)/target/ppu/lib/PSGL/RSX/ultra-opt
|
||||
INCDIRS = -I. -Icommon
|
||||
|
||||
MAKE_FSELF_NPDRM = $(CELL_SDK)/$(HOST_DIR)/bin/make_fself_npdrm
|
||||
MAKE_PACKAGE_NPDRM = $(CELL_SDK)/$(HOST_DIR)/bin/make_package_npdrm
|
||||
|
||||
OBJ = fifo_buffer.o ps3/cellframework2/fileio/file_browser.o ps3/ps3_audio.o ps3/menu.o ps3/ps3_input.o ps3/cellframework2/input/pad_input.o getopt.o ssnes.o driver.o file.o settings.o message.o rewind.o movie.o gfx/gfx_common.o ps3/ps3_video_psgl.o gfx/shader_cg.o gfx/snes_state.o ups.o bps.o strl.o screenshot.o audio/hermite.o dynamic.o ps3/main.o audio/utils.o conf/config_file.o gfx/image.o
|
||||
|
||||
LIBS = -ldbgfont -lPSGL -lPSGLcgc -lcgc -lgcm_cmd -lgcm_sys_stub -lsnes -lresc_stub -lm -lio_stub -lfs_stub -lsysutil_stub -lsysutil_game_stub -lsysutil_screenshot_stub -lsysmodule_stub -laudio_stub -lnet_stub -lpthread
|
||||
|
||||
DEFINES = -DSSNES_CONSOLE -DHAVE_OPENGL=1 -DHAVE_CG=1 -DHAVE_FBO=1 -D__CELLOS_LV2__ -DHAVE_CONFIGFILE=1 -DPACKAGE_VERSION=\"0.9.4\" -Dmain=ssnes_main
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
PPU_OPTIMIZE_LV := -O0 -g
|
||||
else
|
||||
PPU_OPTIMIZE_LV := -O3 -g
|
||||
endif
|
||||
|
||||
## Use this for new SDK!
|
||||
CFLAGS = $(PPU_OPTIMIZE_LV) $(DEFINES)
|
||||
CXXFLAGS = $(PPU_OPTIMIZE_LV) $(DEFINES)
|
||||
|
||||
all: pkg
|
||||
|
||||
$(PPU_TARGET): $(OBJ)
|
||||
$(LD) -o $@ $(OBJ) $(LDFLAGS) $(LDDIRS) $(LIBS)
|
||||
$(STRIP) $(PPU_TARGET)
|
||||
|
||||
%.o: %.c config.h
|
||||
$(CC) $(INCDIRS) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
%.o: %.cpp config.h
|
||||
$(CXX) $(INCDIRS) $(CXXFLAGS) -c -o $@ $<
|
||||
|
||||
pkg: $(PPU_TARGET)
|
||||
cp ssnes.cfg ps3/pkg/USRDIR/
|
||||
$(MAKE_FSELF_NPDRM) $(PPU_TARGET) ps3/pkg/USRDIR/EBOOT.BIN
|
||||
$(MAKE_PACKAGE_NPDRM) ps3/pkg/package.conf ps3/pkg
|
||||
|
||||
clean:
|
||||
rm -f $(PPU_TARGET)
|
||||
rm -f $(OBJ)
|
||||
rm -f *.pkg
|
||||
|
||||
.PHONY: all clean pkg
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
###
|
||||
##
|
||||
# Makefile for SSNES Wii.
|
||||
## Doesn't really work yet, beware :V
|
||||
###
|
||||
##
|
||||
|
||||
DEBUG = 0
|
||||
|
||||
CC = powerpc-eabi-gcc
|
||||
CXX = powerpc-eabi-g++
|
||||
LD = powerpc-eabi-ld
|
||||
|
||||
DOL_TARGET := ssnes.dol
|
||||
ELF_TARGET := ssnes.elf
|
||||
|
||||
INCLUDE := -I. -I$(DEVKITPRO)/libogc/include
|
||||
LIBDIRS := -L$(DEVKITPRO)/libogc/lib/wii -L.
|
||||
|
||||
MACHDEP := -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float
|
||||
CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(INCLUDE)
|
||||
CXXFLAGS += -Wall -std=gnu99 $(MACHDEP) $(INCLUDE)
|
||||
LDFLAGS := $(MACHDEP)
|
||||
LIBS := -lfat -lsnes -lwiiuse -logc -lbte -lfreetype
|
||||
|
||||
OBJ = wii/main.o fifo_buffer.o ssnes.o driver.o gfx/fonts.o file.o settings.o message.o rewind.o movie.o ups.o bps.o strl.o screenshot.o audio/hermite.o dynamic.o audio/utils.o conf/config_file.o wii/audio.o wii/input.o wii/video.o console/sgui.o console/list.o console/font.bmpobj
|
||||
|
||||
CFLAGS += -std=gnu99 -DSSNES_CONSOLE -DHAVE_CONFIGFILE=1 -DHAVE_GETOPT_LONG -DHAVE_FREETYPE -DPACKAGE_VERSION=\"0.9.4\" -Dmain=ssnes_main -Wno-char-subscripts
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0 -g
|
||||
CXXFLAGS += -O0 -g
|
||||
else
|
||||
CLFAGS += -O3
|
||||
CXXFLAGS += -O3
|
||||
endif
|
||||
|
||||
all: $(DOL_TARGET)
|
||||
|
||||
%.dol: %.elf
|
||||
elf2dol $< $@
|
||||
|
||||
$(ELF_TARGET): $(OBJ)
|
||||
$(CXX) -o $@ $(LDFLAGS) $(LIBDIRS) $(OBJ) $(LIBS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
%.bmpobj: %.bmp
|
||||
$(LD) -r -b binary -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f $(DOL_TARGET)
|
||||
rm -f $(ELF_TARGET)
|
||||
rm -f $(OBJ)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
+25
-16
@@ -1,7 +1,7 @@
|
||||
TARGET = ssnes.exe
|
||||
JTARGET = ssnes-joyconfig.exe
|
||||
OBJ = ssnes.o file.o driver.o conf/config_file.o settings.o dynamic.o message.o rewind.o movie.o autosave.o gfx/gfx_common.o bps.o ups.o strl.o screenshot.o audio/hermite.o thread.o
|
||||
JOBJ = conf/config_file.o tools/main-stub.o tools/ssnes-joyconfig.o strl.o
|
||||
OBJ = ssnes.o file.o driver.o conf/config_file.o settings.o dynamic.o message.o rewind.o movie.o gfx/gfx_common.o bps.o ups.o strl.o screenshot.o audio/hermite.o getopt.o audio/utils.o posix_string.o
|
||||
JOBJ = conf/config_file.o tools/ssnes-joyconfig.o strl.o posix_string.o
|
||||
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
@@ -13,6 +13,7 @@ HAVE_SDL = 1
|
||||
HAVE_OPENGL = 1
|
||||
HAVE_DYLIB = 1
|
||||
HAVE_NETPLAY = 1
|
||||
HAVE_THREADS = 1
|
||||
DYNAMIC = 1
|
||||
|
||||
ifeq ($(SLIM),)
|
||||
@@ -28,17 +29,22 @@ endif
|
||||
|
||||
libsnes ?= -lsnes
|
||||
|
||||
LIBS = -lm -lshlwapi
|
||||
DEFINES = -I. -DHAVE_CONFIGFILE
|
||||
LIBS = -lm
|
||||
DEFINES = -I. -DHAVE_CONFIGFILE -DPACKAGE_VERSION=\"0.9.4\"
|
||||
LDFLAGS = -L. -static-libgcc
|
||||
LDCXXFLAGS = -static-libstdc++ -s
|
||||
|
||||
ifeq ($(HAVE_SDL), 1)
|
||||
OBJ += gfx/sdl.o gfx/gl.o gfx/sdlwrap.o input/sdl.o audio/sdl.o fifo_buffer.o
|
||||
OBJ += gfx/sdl_gfx.o gfx/gl.o gfx/sdlwrap.o input/sdl_input.o audio/sdl_audio.o fifo_buffer.o
|
||||
LIBS += -lSDL
|
||||
DEFINES += -ISDL -DHAVE_SDL
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_THREADS), 1)
|
||||
OBJ += autosave.o thread.o
|
||||
DEFINES += -DHAVE_THREADS
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_OPENGL), 1)
|
||||
DEFINES += -DHAVE_OPENGL
|
||||
LIBS += -lopengl32
|
||||
@@ -106,7 +112,7 @@ ifeq ($(HAVE_FBO), 1)
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_DYLIB), 1)
|
||||
OBJ += gfx/ext.o audio/ext.o
|
||||
OBJ += gfx/ext_gfx.o audio/ext_audio.o
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_PYTHON), 1)
|
||||
@@ -133,12 +139,16 @@ ifeq ($(HAVE_FFMPEG), 1)
|
||||
OBJ += record/ffemu.o
|
||||
endif
|
||||
|
||||
ifneq ($(V),1)
|
||||
ifneq ($(V), 1)
|
||||
Q := @
|
||||
endif
|
||||
|
||||
CFLAGS += -Wall -O3 -std=gnu99 -I.
|
||||
CXXFLAGS += -Wall -O3 -pedantic -I.
|
||||
CFLAGS += -Wall -O3 -I.
|
||||
ifeq ($(CXX_BUILD), 1)
|
||||
CFLAGS += -std=c++0x -xc++ -D__STDC_CONSTANT_MACROS
|
||||
else
|
||||
CFLAGS += -std=gnu99
|
||||
endif
|
||||
|
||||
all: $(TARGET) $(JTARGET)
|
||||
|
||||
@@ -150,13 +160,12 @@ $(TARGET): $(OBJ)
|
||||
$(Q)$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
|
||||
@$(if $(Q), $(shell echo echo CC $<),)
|
||||
|
||||
%.o: %.cpp
|
||||
$(Q)$(CXX) $(CXXFLAGS) $(DEFINES) -c -o $@ $<
|
||||
@$(if $(Q), $(shell echo echo CXX $<),)
|
||||
|
||||
|
||||
$(JTARGET): $(JOBJ)
|
||||
ifeq ($(CXX_BUILD), 1)
|
||||
$(Q)$(CXX) -o $@ $(JOBJ) -lSDL $(LDFLAGS)
|
||||
else
|
||||
$(Q)$(CC) -o $@ $(JOBJ) -lSDL $(LDFLAGS)
|
||||
endif
|
||||
@$(if $(Q), $(shell echo echo LD $@),)
|
||||
|
||||
clean:
|
||||
@@ -173,10 +182,10 @@ clean:
|
||||
rm -f tools/*.o
|
||||
|
||||
dist_x86: all
|
||||
zip -r ssnes-win32-0.9.2.zip $(TARGET) $(JTARGET) ssnes.cfg snes.dll SDL.dll
|
||||
zip -r ssnes-win32-0.9.4.zip $(TARGET) $(JTARGET) ssnes.cfg snes.dll SDL.dll
|
||||
|
||||
dist_x86_64: all
|
||||
zip -r ssnes-win64-0.9.2.zip $(TARGET) $(JTARGET) ssnes.cfg snes.dll SDL.dll
|
||||
zip -r ssnes-win64-0.9.4.zip $(TARGET) $(JTARGET) ssnes.cfg snes.dll SDL.dll
|
||||
|
||||
libs_x86:
|
||||
wget https://github.com/downloads/Themaister/SSNES/SSNES-win32-libs.zip --no-check-certificate
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
###
|
||||
##
|
||||
# Makefile for SSNES libxenon.
|
||||
##
|
||||
###
|
||||
##
|
||||
|
||||
DEBUG = 0
|
||||
|
||||
CC = xenon-gcc
|
||||
CXX = xenon-g++
|
||||
OBJCOPY = xenon-objcopy
|
||||
STRIP = xenon-strip
|
||||
|
||||
PPU_TARGET := ssnes-libxenon.elf
|
||||
PPU_TARGET_ADJUSTED := ssnes-libxenon.elf32
|
||||
|
||||
LDDIRS = -L. -L$(DEVKITXENON)/usr/lib -L$(DEVKITXENON)/xenon/lib/32
|
||||
INCDIRS = -I. -I$(DEVKITXENON)/usr/include
|
||||
|
||||
OBJ = fifo_buffer.o ssnes.o driver.o file.o settings.o message.o rewind.o movie.o gfx/gfx_common.o ups.o bps.o strl.o screenshot.o audio/hermite.o dynamic.o audio/utils.o conf/config_file.o xenon/main.o xenon/xenon360_audio.o xenon/xenon360_input.o xenon/xenon360_video.o
|
||||
|
||||
LIBS = -lsnes -lxenon -lm -lc
|
||||
DEFINES = -std=gnu99 -DHAVE_CONFIGFILE=1 -DPACKAGE_VERSION=\"0.9.4\" -DSSNES_CONSOLE -DHAVE_GETOPT_LONG=1 -Dmain=ssnes_main
|
||||
DEFINES += -maltivec -mhard-float -m32 -mpowerpc64 -mcpu=cell -mtune=cell -fno-pic -g -Wall -DXENON $(INCDIRS)
|
||||
DEFINES += -u read -u _start -u exc_base
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
OPTIMIZE_LV := -O0 -g
|
||||
else
|
||||
OPTIMIZE_LV := -O3
|
||||
endif
|
||||
|
||||
all: $(PPU_TARGET_ADJUSTED)
|
||||
|
||||
CFLAGS := $(OPTIMIZE_LV) $(DEFINES)
|
||||
|
||||
LDFLAGS := -m32 -n -T $(DEVKITXENON)/app.lds
|
||||
|
||||
$(PPU_TARGET_ADJUSTED): $(PPU_TARGET)
|
||||
$(OBJCOPY) -O elf32-powerpc --adjust-vma 0x80000000 $< $@
|
||||
$(STRIP) $@
|
||||
|
||||
$(PPU_TARGET): $(OBJ)
|
||||
$(CXX) -o $@ $(OBJ) $(LDFLAGS) $(LDDIRS) $(LIBS)
|
||||
|
||||
%.o: %.c config.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f $(PPU_TARGET)
|
||||
rm -f $(OBJ)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
+24
-23
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -16,10 +16,10 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "driver.h"
|
||||
#include "../driver.h"
|
||||
#include <stdlib.h>
|
||||
#include <asoundlib.h>
|
||||
#include "general.h"
|
||||
#include "../general.h"
|
||||
|
||||
#define TRY_ALSA(x) if (x < 0) { \
|
||||
goto error; \
|
||||
@@ -34,7 +34,7 @@ typedef struct alsa
|
||||
|
||||
static bool alsa_use_float(void *data)
|
||||
{
|
||||
alsa_t *alsa = data;
|
||||
alsa_t *alsa = (alsa_t*)data;
|
||||
return alsa->has_float;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ static bool find_float_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||
|
||||
static void *alsa_init(const char *device, unsigned rate, unsigned latency)
|
||||
{
|
||||
alsa_t *alsa = calloc(1, sizeof(alsa_t));
|
||||
alsa_t *alsa = (alsa_t*)calloc(1, sizeof(alsa_t));
|
||||
if (!alsa)
|
||||
return NULL;
|
||||
|
||||
@@ -62,14 +62,17 @@ static void *alsa_init(const char *device, unsigned rate, unsigned latency)
|
||||
if (device)
|
||||
alsa_dev = device;
|
||||
|
||||
TRY_ALSA(snd_pcm_open(&alsa->pcm, alsa_dev, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK));
|
||||
|
||||
unsigned int latency_usec = latency * 1000;
|
||||
unsigned int channels = 2;
|
||||
unsigned periods = 4;
|
||||
snd_pcm_uframes_t buffer_size;
|
||||
snd_pcm_format_t format;
|
||||
|
||||
TRY_ALSA(snd_pcm_open(&alsa->pcm, alsa_dev, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK));
|
||||
|
||||
TRY_ALSA(snd_pcm_hw_params_malloc(¶ms));
|
||||
alsa->has_float = find_float_format(alsa->pcm, params);
|
||||
snd_pcm_format_t format = alsa->has_float ? SND_PCM_FORMAT_FLOAT : SND_PCM_FORMAT_S16;
|
||||
unsigned int channels = 2;
|
||||
format = alsa->has_float ? SND_PCM_FORMAT_FLOAT : SND_PCM_FORMAT_S16;
|
||||
|
||||
TRY_ALSA(snd_pcm_hw_params_any(alsa->pcm, params));
|
||||
TRY_ALSA(snd_pcm_hw_params_set_access(alsa->pcm, params, SND_PCM_ACCESS_RW_INTERLEAVED));
|
||||
@@ -78,12 +81,10 @@ static void *alsa_init(const char *device, unsigned rate, unsigned latency)
|
||||
TRY_ALSA(snd_pcm_hw_params_set_rate(alsa->pcm, params, rate, 0));
|
||||
|
||||
TRY_ALSA(snd_pcm_hw_params_set_buffer_time_near(alsa->pcm, params, &latency_usec, NULL));
|
||||
unsigned periods = 4;
|
||||
TRY_ALSA(snd_pcm_hw_params_set_periods_near(alsa->pcm, params, &periods, NULL));
|
||||
|
||||
TRY_ALSA(snd_pcm_hw_params(alsa->pcm, params));
|
||||
|
||||
snd_pcm_uframes_t buffer_size;
|
||||
snd_pcm_hw_params_get_period_size(params, &buffer_size, NULL);
|
||||
SSNES_LOG("ALSA: Period size: %d frames\n", (int)buffer_size);
|
||||
snd_pcm_hw_params_get_buffer_size(params, &buffer_size);
|
||||
@@ -119,14 +120,14 @@ error:
|
||||
|
||||
static ssize_t alsa_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
alsa_t *alsa = data;
|
||||
alsa_t *alsa = (alsa_t*)data;
|
||||
|
||||
snd_pcm_sframes_t frames;
|
||||
snd_pcm_sframes_t written = 0;
|
||||
int rc;
|
||||
size = snd_pcm_bytes_to_frames(alsa->pcm, size); // Frames to write
|
||||
|
||||
while (written < size)
|
||||
while (written < (snd_pcm_sframes_t)size)
|
||||
{
|
||||
if (!alsa->nonblock)
|
||||
{
|
||||
@@ -166,7 +167,7 @@ static bool alsa_stop(void *data)
|
||||
|
||||
static void alsa_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
alsa_t *alsa = data;
|
||||
alsa_t *alsa = (alsa_t*)data;
|
||||
alsa->nonblock = state;
|
||||
}
|
||||
|
||||
@@ -177,7 +178,7 @@ static bool alsa_start(void *data)
|
||||
|
||||
static void alsa_free(void *data)
|
||||
{
|
||||
alsa_t *alsa = data;
|
||||
alsa_t *alsa = (alsa_t*)data;
|
||||
if (alsa)
|
||||
{
|
||||
if (alsa->pcm)
|
||||
@@ -190,13 +191,13 @@ static void alsa_free(void *data)
|
||||
}
|
||||
|
||||
const audio_driver_t audio_alsa = {
|
||||
.init = alsa_init,
|
||||
.write = alsa_write,
|
||||
.stop = alsa_stop,
|
||||
.start = alsa_start,
|
||||
.use_float = alsa_use_float,
|
||||
.set_nonblock_state = alsa_set_nonblock_state,
|
||||
.free = alsa_free,
|
||||
.ident = "alsa"
|
||||
alsa_init,
|
||||
alsa_write,
|
||||
alsa_stop,
|
||||
alsa_start,
|
||||
alsa_set_nonblock_state,
|
||||
alsa_free,
|
||||
alsa_use_float,
|
||||
"alsa"
|
||||
};
|
||||
|
||||
+50
-48
@@ -1,6 +1,6 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011 - Chris Moeller
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2012 - Chris Moeller
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "general.h"
|
||||
#include "fifo_buffer.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include <pthread.h>
|
||||
|
||||
#include <CoreAudio/CoreAudio.h>
|
||||
@@ -43,7 +43,7 @@ typedef struct coreaudio
|
||||
|
||||
static void coreaudio_free(void *data)
|
||||
{
|
||||
coreaudio_t *dev = data;
|
||||
coreaudio_t *dev = (coreaudio_t*)data;
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
@@ -66,7 +66,7 @@ static OSStatus audio_cb(void *userdata, AudioUnitRenderActionFlags *action_flag
|
||||
const AudioTimeStamp *time_stamp, UInt32 bus_number,
|
||||
UInt32 number_frames, AudioBufferList *io_data)
|
||||
{
|
||||
coreaudio_t *dev = userdata;
|
||||
coreaudio_t *dev = (coreaudio_t*)userdata;
|
||||
(void)time_stamp;
|
||||
(void)bus_number;
|
||||
(void)number_frames;
|
||||
@@ -99,7 +99,7 @@ static void *coreaudio_init(const char *device, unsigned rate, unsigned latency)
|
||||
{
|
||||
(void)device;
|
||||
|
||||
coreaudio_t *dev = calloc(1, sizeof(*dev));
|
||||
coreaudio_t *dev = (coreaudio_t*)calloc(1, sizeof(*dev));
|
||||
if (!dev)
|
||||
return NULL;
|
||||
|
||||
@@ -115,40 +115,46 @@ static void *coreaudio_init(const char *device, unsigned rate, unsigned latency)
|
||||
AudioObjectSetPropertyData(kAudioObjectSystemObject, &addr, 0, NULL,
|
||||
sizeof(CFRunLoopRef), &run_loop);
|
||||
|
||||
ComponentDescription desc = {
|
||||
.componentType = kAudioUnitType_Output,
|
||||
.componentSubType = kAudioUnitSubType_HALOutput,
|
||||
.componentManufacturer = kAudioUnitManufacturer_Apple,
|
||||
};
|
||||
ComponentDescription desc = {0};
|
||||
desc.componentType = kAudioUnitType_Output;
|
||||
desc.componentSubType = kAudioUnitSubType_HALOutput;
|
||||
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||
|
||||
Component comp = FindNextComponent(NULL, &desc);
|
||||
AudioStreamBasicDescription stream_desc = {0};
|
||||
AudioStreamBasicDescription real_desc;
|
||||
AudioChannelLayout layout = {0};
|
||||
AURenderCallbackStruct cb = {0};
|
||||
|
||||
Component comp = NULL;
|
||||
OSStatus res = noErr;
|
||||
UInt32 i_size = 0;
|
||||
size_t fifo_size;
|
||||
|
||||
comp = FindNextComponent(NULL, &desc);
|
||||
if (comp == NULL)
|
||||
goto error;
|
||||
|
||||
OSStatus res = OpenAComponent(comp, &dev->dev);
|
||||
res = OpenAComponent(comp, &dev->dev);
|
||||
if (res != noErr)
|
||||
goto error;
|
||||
|
||||
dev->dev_alive = true;
|
||||
|
||||
AudioStreamBasicDescription stream_desc = {
|
||||
.mSampleRate = rate,
|
||||
.mBitsPerChannel = sizeof(float) * CHAR_BIT,
|
||||
.mChannelsPerFrame = 2,
|
||||
.mBytesPerPacket = 2 * sizeof(float),
|
||||
.mBytesPerFrame = 2 * sizeof(float),
|
||||
.mFramesPerPacket = 1,
|
||||
.mFormatID = kAudioFormatLinearPCM,
|
||||
.mFormatFlags = kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked | (is_little_endian() ? 0 : kAudioFormatFlagIsBigEndian),
|
||||
};
|
||||
stream_desc.mSampleRate = rate;
|
||||
stream_desc.mBitsPerChannel = sizeof(float) * CHAR_BIT;
|
||||
stream_desc.mChannelsPerFrame = 2;
|
||||
stream_desc.mBytesPerPacket = 2 * sizeof(float);
|
||||
stream_desc.mBytesPerFrame = 2 * sizeof(float);
|
||||
stream_desc.mFramesPerPacket = 1;
|
||||
stream_desc.mFormatID = kAudioFormatLinearPCM;
|
||||
stream_desc.mFormatFlags = kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked | (is_little_endian() ? 0 : kAudioFormatFlagIsBigEndian);
|
||||
|
||||
res = AudioUnitSetProperty(dev->dev, kAudioUnitProperty_StreamFormat,
|
||||
kAudioUnitScope_Input, 0, &stream_desc, sizeof(stream_desc));
|
||||
if (res != noErr)
|
||||
goto error;
|
||||
|
||||
AudioStreamBasicDescription real_desc;
|
||||
UInt32 i_size = sizeof(real_desc);
|
||||
i_size = sizeof(real_desc);
|
||||
res = AudioUnitGetProperty(dev->dev, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &real_desc, &i_size);
|
||||
if (res != noErr)
|
||||
goto error;
|
||||
@@ -165,20 +171,16 @@ static void *coreaudio_init(const char *device, unsigned rate, unsigned latency)
|
||||
if (real_desc.mFormatID != stream_desc.mFormatID)
|
||||
goto error;
|
||||
|
||||
AudioChannelLayout layout = {
|
||||
.mChannelLayoutTag = kAudioChannelLayoutTag_UseChannelBitmap,
|
||||
.mChannelBitmap = (1 << 2) - 1,
|
||||
};
|
||||
layout.mChannelLayoutTag = kAudioChannelLayoutTag_UseChannelBitmap;
|
||||
layout.mChannelBitmap = 0x03;
|
||||
|
||||
res = AudioUnitSetProperty(dev->dev, kAudioUnitProperty_AudioChannelLayout,
|
||||
kAudioUnitScope_Input, 0, &layout, sizeof(layout));
|
||||
if (res != noErr)
|
||||
goto error;
|
||||
|
||||
AURenderCallbackStruct cb = {
|
||||
.inputProc = audio_cb,
|
||||
.inputProcRefCon = dev,
|
||||
};
|
||||
cb.inputProc = audio_cb;
|
||||
cb.inputProcRefCon = dev;
|
||||
|
||||
res = AudioUnitSetProperty(dev->dev, kAudioUnitProperty_SetRenderCallback,
|
||||
kAudioUnitScope_Input, 0, &cb, sizeof(cb));
|
||||
@@ -189,7 +191,7 @@ static void *coreaudio_init(const char *device, unsigned rate, unsigned latency)
|
||||
if (res != noErr)
|
||||
goto error;
|
||||
|
||||
size_t fifo_size = (latency * g_settings.audio.out_rate) / 1000;
|
||||
fifo_size = (latency * g_settings.audio.out_rate) / 1000;
|
||||
fifo_size *= 2 * sizeof(float);
|
||||
|
||||
dev->buffer = fifo_new(fifo_size);
|
||||
@@ -212,9 +214,9 @@ error:
|
||||
|
||||
static ssize_t coreaudio_write(void *data, const void *buf_, size_t size)
|
||||
{
|
||||
coreaudio_t *dev = data;
|
||||
coreaudio_t *dev = (coreaudio_t*)data;
|
||||
|
||||
const uint8_t *buf = buf_;
|
||||
const uint8_t *buf = (const uint8_t*)buf_;
|
||||
size_t written = 0;
|
||||
|
||||
while (size > 0)
|
||||
@@ -246,19 +248,19 @@ static ssize_t coreaudio_write(void *data, const void *buf_, size_t size)
|
||||
|
||||
static bool coreaudio_stop(void *data)
|
||||
{
|
||||
coreaudio_t *dev = data;
|
||||
coreaudio_t *dev = (coreaudio_t*)data;
|
||||
return AudioOutputUnitStop(dev->dev) == noErr;
|
||||
}
|
||||
|
||||
static void coreaudio_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
coreaudio_t *dev = data;
|
||||
coreaudio_t *dev = (coreaudio_t*)data;
|
||||
dev->nonblock = state;
|
||||
}
|
||||
|
||||
static bool coreaudio_start(void *data)
|
||||
{
|
||||
coreaudio_t *dev = data;
|
||||
coreaudio_t *dev = (coreaudio_t*)data;
|
||||
return AudioOutputUnitStart(dev->dev) == noErr;
|
||||
}
|
||||
|
||||
@@ -269,13 +271,13 @@ static bool coreaudio_use_float(void *data)
|
||||
}
|
||||
|
||||
const audio_driver_t audio_coreaudio = {
|
||||
.init = coreaudio_init,
|
||||
.write = coreaudio_write,
|
||||
.stop = coreaudio_stop,
|
||||
.start = coreaudio_start,
|
||||
.set_nonblock_state = coreaudio_set_nonblock_state,
|
||||
.free = coreaudio_free,
|
||||
.use_float = coreaudio_use_float,
|
||||
.ident = "coreaudio"
|
||||
coreaudio_init,
|
||||
coreaudio_write,
|
||||
coreaudio_stop,
|
||||
coreaudio_start,
|
||||
coreaudio_set_nonblock_state,
|
||||
coreaudio_free,
|
||||
coreaudio_use_float,
|
||||
"coreaudio"
|
||||
};
|
||||
|
||||
|
||||
+34
-35
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -15,16 +15,16 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
#include "../driver.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <dsound.h>
|
||||
#include "fifo_buffer.h"
|
||||
#include "general.h"
|
||||
#include "../fifo_buffer.h"
|
||||
#include "../general.h"
|
||||
|
||||
typedef struct dsound
|
||||
{
|
||||
@@ -111,7 +111,7 @@ static inline void release_region(dsound_t *ds, const struct audio_lock *region)
|
||||
|
||||
static DWORD CALLBACK dsound_thread(PVOID data)
|
||||
{
|
||||
dsound_t *ds = data;
|
||||
dsound_t *ds = (dsound_t*)data;
|
||||
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
|
||||
|
||||
DWORD write_ptr;
|
||||
@@ -218,7 +218,7 @@ static void dsound_clear_buffer(dsound_t *ds)
|
||||
|
||||
static void dsound_free(void *data)
|
||||
{
|
||||
dsound_t *ds = data;
|
||||
dsound_t *ds = (dsound_t*)data;
|
||||
if (ds)
|
||||
{
|
||||
if (ds->thread)
|
||||
@@ -251,7 +251,10 @@ static void dsound_free(void *data)
|
||||
|
||||
static void *dsound_init(const char *device, unsigned rate, unsigned latency)
|
||||
{
|
||||
dsound_t *ds = calloc(1, sizeof(*ds));
|
||||
WAVEFORMATEX wfx = {0};
|
||||
DSBUFFERDESC bufdesc = {0};
|
||||
|
||||
dsound_t *ds = (dsound_t*)calloc(1, sizeof(*ds));
|
||||
if (!ds)
|
||||
goto error;
|
||||
|
||||
@@ -263,14 +266,12 @@ static void *dsound_init(const char *device, unsigned rate, unsigned latency)
|
||||
if (IDirectSound_SetCooperativeLevel(ds->ds, GetDesktopWindow(), DSSCL_PRIORITY) != DS_OK)
|
||||
goto error;
|
||||
|
||||
WAVEFORMATEX wfx = {
|
||||
.wFormatTag = WAVE_FORMAT_PCM,
|
||||
.nChannels = 2,
|
||||
.nSamplesPerSec = rate,
|
||||
.wBitsPerSample = 16,
|
||||
.nBlockAlign = 2 * sizeof(int16_t),
|
||||
.nAvgBytesPerSec = rate * 2 * sizeof(int16_t),
|
||||
};
|
||||
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
||||
wfx.nChannels = 2;
|
||||
wfx.nSamplesPerSec = rate;
|
||||
wfx.wBitsPerSample = 16;
|
||||
wfx.nBlockAlign = 2 * sizeof(int16_t);
|
||||
wfx.nAvgBytesPerSec = rate * 2 * sizeof(int16_t);
|
||||
|
||||
ds->buffer_size = (latency * wfx.nAvgBytesPerSec) / 1000;
|
||||
ds->buffer_size /= CHUNK_SIZE;
|
||||
@@ -281,12 +282,10 @@ static void *dsound_init(const char *device, unsigned rate, unsigned latency)
|
||||
SSNES_LOG("[DirectSound]: Setting buffer size of %u bytes\n", ds->buffer_size);
|
||||
SSNES_LOG("[DirectSound]: Latency = %u ms\n", (unsigned)((1000 * ds->buffer_size) / wfx.nAvgBytesPerSec));
|
||||
|
||||
DSBUFFERDESC bufdesc = {
|
||||
.dwSize = sizeof(DSBUFFERDESC),
|
||||
.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS,
|
||||
.dwBufferBytes = ds->buffer_size,
|
||||
.lpwfxFormat = &wfx,
|
||||
};
|
||||
bufdesc.dwSize = sizeof(DSBUFFERDESC);
|
||||
bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS;
|
||||
bufdesc.dwBufferBytes = ds->buffer_size;
|
||||
bufdesc.lpwfxFormat = &wfx;
|
||||
|
||||
ds->event = CreateEvent(NULL, false, false, NULL);
|
||||
if (!ds->event)
|
||||
@@ -319,14 +318,14 @@ error:
|
||||
|
||||
static bool dsound_stop(void *data)
|
||||
{
|
||||
dsound_t *ds = data;
|
||||
dsound_t *ds = (dsound_t*)data;
|
||||
dsound_stop_thread(ds);
|
||||
return IDirectSoundBuffer_Stop(ds->dsb) == DS_OK;
|
||||
}
|
||||
|
||||
static bool dsound_start(void *data)
|
||||
{
|
||||
dsound_t *ds = data;
|
||||
dsound_t *ds = (dsound_t*)data;
|
||||
dsound_clear_buffer(ds);
|
||||
|
||||
if (!dsound_start_thread(ds))
|
||||
@@ -337,14 +336,14 @@ static bool dsound_start(void *data)
|
||||
|
||||
static void dsound_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
dsound_t *ds = data;
|
||||
dsound_t *ds = (dsound_t*)data;
|
||||
ds->nonblock = state;
|
||||
}
|
||||
|
||||
static ssize_t dsound_write(void *data, const void *buf_, size_t size)
|
||||
{
|
||||
dsound_t *ds = data;
|
||||
const uint8_t *buf = buf_;
|
||||
dsound_t *ds = (dsound_t*)data;
|
||||
const uint8_t *buf = (const uint8_t*)buf_;
|
||||
|
||||
if (!ds->thread_alive)
|
||||
return -1;
|
||||
@@ -374,14 +373,14 @@ static ssize_t dsound_write(void *data, const void *buf_, size_t size)
|
||||
return written;
|
||||
}
|
||||
|
||||
|
||||
const audio_driver_t audio_dsound = {
|
||||
.init = dsound_init,
|
||||
.write = dsound_write,
|
||||
.stop = dsound_stop,
|
||||
.start = dsound_start,
|
||||
.set_nonblock_state = dsound_set_nonblock_state,
|
||||
.free = dsound_free,
|
||||
.ident = "dsound"
|
||||
dsound_init,
|
||||
dsound_write,
|
||||
dsound_stop,
|
||||
dsound_start,
|
||||
dsound_set_nonblock_state,
|
||||
dsound_free,
|
||||
NULL,
|
||||
"dsound"
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -16,12 +16,12 @@
|
||||
*/
|
||||
|
||||
#include "ext/ssnes_audio.h"
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "driver.h"
|
||||
#include "dynamic.h"
|
||||
#include "general.h"
|
||||
#include "../driver.h"
|
||||
#include "../dynamic.h"
|
||||
#include "../general.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct audio_ext
|
||||
@@ -34,7 +34,7 @@ typedef struct audio_ext
|
||||
|
||||
static void audio_ext_free(void *data)
|
||||
{
|
||||
audio_ext_t *ext = data;
|
||||
audio_ext_t *ext = (audio_ext_t*)data;
|
||||
if (ext)
|
||||
{
|
||||
if (ext->driver && ext->handle)
|
||||
@@ -53,10 +53,13 @@ static void *audio_ext_init(const char *device, unsigned rate, unsigned latency)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
audio_ext_t *ext = calloc(1, sizeof(*ext));
|
||||
audio_ext_t *ext = (audio_ext_t*)calloc(1, sizeof(*ext));
|
||||
if (!ext)
|
||||
return NULL;
|
||||
|
||||
ssnes_audio_driver_info_t info = {0};
|
||||
const ssnes_audio_driver_t *(*plugin_load)(void) = NULL;
|
||||
|
||||
ext->lib = dylib_load(g_settings.audio.external_driver);
|
||||
if (!ext->lib)
|
||||
{
|
||||
@@ -64,7 +67,7 @@ static void *audio_ext_init(const char *device, unsigned rate, unsigned latency)
|
||||
goto error;
|
||||
}
|
||||
|
||||
const ssnes_audio_driver_t* (*plugin_load)(void) = (const ssnes_audio_driver_t* (*)(void))dylib_proc(ext->lib, "ssnes_audio_driver_init");
|
||||
plugin_load = (const ssnes_audio_driver_t *(*)(void))dylib_proc(ext->lib, "ssnes_audio_driver_init");
|
||||
|
||||
if (!plugin_load)
|
||||
{
|
||||
@@ -87,11 +90,9 @@ static void *audio_ext_init(const char *device, unsigned rate, unsigned latency)
|
||||
goto error;
|
||||
}
|
||||
|
||||
ssnes_audio_driver_info_t info = {
|
||||
.device = device,
|
||||
.sample_rate = rate,
|
||||
.latency = latency
|
||||
};
|
||||
info.device = device;
|
||||
info.sample_rate = rate;
|
||||
info.latency = latency;
|
||||
|
||||
ext->handle = ext->driver->init(&info);
|
||||
if (!ext->handle)
|
||||
@@ -115,7 +116,7 @@ error:
|
||||
|
||||
static ssize_t audio_ext_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
audio_ext_t *ext = data;
|
||||
audio_ext_t *ext = (audio_ext_t*)data;
|
||||
unsigned frame_size = ext->is_float ? (2 * sizeof(float)) : (2 * sizeof(int16_t));
|
||||
size /= frame_size;
|
||||
|
||||
@@ -127,37 +128,37 @@ static ssize_t audio_ext_write(void *data, const void *buf, size_t size)
|
||||
|
||||
static bool audio_ext_start(void *data)
|
||||
{
|
||||
audio_ext_t *ext = data;
|
||||
audio_ext_t *ext = (audio_ext_t*)data;
|
||||
return ext->driver->start(ext->handle);
|
||||
}
|
||||
|
||||
static bool audio_ext_stop(void *data)
|
||||
{
|
||||
audio_ext_t *ext = data;
|
||||
audio_ext_t *ext = (audio_ext_t*)data;
|
||||
return ext->driver->stop(ext->handle);
|
||||
}
|
||||
|
||||
static void audio_ext_set_nonblock_state(void *data, bool toggle)
|
||||
{
|
||||
audio_ext_t *ext = data;
|
||||
audio_ext_t *ext = (audio_ext_t*)data;
|
||||
ext->driver->set_nonblock_state(ext->handle, toggle);
|
||||
}
|
||||
|
||||
static bool audio_ext_use_float(void *data)
|
||||
{
|
||||
audio_ext_t *ext = data;
|
||||
audio_ext_t *ext = (audio_ext_t*)data;
|
||||
ext->is_float = ext->driver->use_float(ext->handle);
|
||||
return ext->is_float;
|
||||
}
|
||||
|
||||
|
||||
const audio_driver_t audio_ext = {
|
||||
.init = audio_ext_init,
|
||||
.write = audio_ext_write,
|
||||
.stop = audio_ext_stop,
|
||||
.start = audio_ext_start,
|
||||
.set_nonblock_state = audio_ext_set_nonblock_state,
|
||||
.use_float = audio_ext_use_float,
|
||||
.free = audio_ext_free,
|
||||
.ident = "ext"
|
||||
audio_ext_init,
|
||||
audio_ext_write,
|
||||
audio_ext_stop,
|
||||
audio_ext_start,
|
||||
audio_ext_set_nonblock_state,
|
||||
audio_ext_free,
|
||||
audio_ext_use_float,
|
||||
"ext"
|
||||
};
|
||||
|
||||
+5
-8
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -35,8 +35,8 @@ static inline float hermite_kernel(float mu1, float a, float b, float c, float d
|
||||
mu2 = mu1 * mu1;
|
||||
mu3 = mu2 * mu1;
|
||||
|
||||
m0 = (c - a) * 0.5;
|
||||
m1 = (d - b) * 0.5;
|
||||
m0 = (c - a) * 0.5f;
|
||||
m1 = (d - b) * 0.5f;
|
||||
|
||||
a0 = +2 * mu3 - 3 * mu2 + 1;
|
||||
a1 = mu3 - 2 * mu2 + mu1;
|
||||
@@ -48,10 +48,7 @@ static inline float hermite_kernel(float mu1, float a, float b, float c, float d
|
||||
|
||||
hermite_resampler_t *hermite_new(void)
|
||||
{
|
||||
hermite_resampler_t *re = calloc(1, sizeof(*re));
|
||||
if (!re)
|
||||
return NULL;
|
||||
return re;
|
||||
return (hermite_resampler_t*)calloc(1, sizeof(hermite_resampler_t));
|
||||
}
|
||||
|
||||
// We make sure to allocate enough output data beforehand ... ;)
|
||||
@@ -71,7 +68,7 @@ void hermite_process(hermite_resampler_t *re, struct hermite_data *data)
|
||||
re->r_frac += r_step;
|
||||
for (unsigned i = 0; i < CHANNELS; i++)
|
||||
{
|
||||
float res = hermite_kernel(re->r_frac,
|
||||
float res = hermite_kernel((float)re->r_frac,
|
||||
re->chan_data[i][0], re->chan_data[i][1], re->chan_data[i][2], re->chan_data[i][3]);
|
||||
*out_data++ = res;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
#define __SSNES_HERMITE_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
|
||||
typedef struct hermite_resampler hermite_resampler_t;
|
||||
|
||||
|
||||
+36
-35
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -16,16 +16,16 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "driver.h"
|
||||
#include "../driver.h"
|
||||
#include <stdlib.h>
|
||||
#include "general.h"
|
||||
#include "../general.h"
|
||||
|
||||
#include <jack/jack.h>
|
||||
#include <jack/types.h>
|
||||
#include <jack/ringbuffer.h>
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -45,7 +45,7 @@ typedef struct jack
|
||||
|
||||
static int process_cb(jack_nframes_t nframes, void *data)
|
||||
{
|
||||
jack_t *jd = data;
|
||||
jack_t *jd = (jack_t*)data;
|
||||
if (nframes <= 0)
|
||||
{
|
||||
pthread_cond_signal(&jd->cond);
|
||||
@@ -62,7 +62,7 @@ static int process_cb(jack_nframes_t nframes, void *data)
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
jack_default_audio_sample_t *out = jack_port_get_buffer(jd->ports[i], nframes);
|
||||
jack_default_audio_sample_t *out = (jack_default_audio_sample_t*)jack_port_get_buffer(jd->ports[i], nframes);
|
||||
assert(out);
|
||||
jack_ringbuffer_read(jd->buffer[i], (char*)out, min_avail * sizeof(jack_default_audio_sample_t));
|
||||
|
||||
@@ -77,7 +77,7 @@ static int process_cb(jack_nframes_t nframes, void *data)
|
||||
|
||||
static void shutdown_cb(void *data)
|
||||
{
|
||||
jack_t *jd = data;
|
||||
jack_t *jd = (jack_t*)data;
|
||||
jd->shutdown = true;
|
||||
pthread_cond_signal(&jd->cond);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ static size_t find_buffersize(jack_t *jd, int latency)
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
jack_port_get_latency_range(jd->ports[i], JackPlaybackLatency, &range);
|
||||
if (range.max > jack_latency)
|
||||
if ((int)range.max > jack_latency)
|
||||
jack_latency = range.max;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ static size_t find_buffersize(jack_t *jd, int latency)
|
||||
|
||||
static void *ja_init(const char *device, unsigned rate, unsigned latency)
|
||||
{
|
||||
jack_t *jd = calloc(1, sizeof(jack_t));
|
||||
jack_t *jd = (jack_t*)calloc(1, sizeof(jack_t));
|
||||
if (!jd)
|
||||
return NULL;
|
||||
|
||||
@@ -134,6 +134,9 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency)
|
||||
pthread_mutex_init(&jd->cond_lock, NULL);
|
||||
|
||||
const char **jports = NULL;
|
||||
char *dest_ports[2];
|
||||
size_t bufsize = 0;
|
||||
int parsed = 0;
|
||||
|
||||
jd->client = jack_client_open("SSNES", JackNullOption, NULL);
|
||||
if (jd->client == NULL)
|
||||
@@ -152,7 +155,6 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency)
|
||||
goto error;
|
||||
}
|
||||
|
||||
char *dest_ports[2];
|
||||
jports = jack_get_ports(jd->client, NULL, NULL, JackPortIsPhysical | JackPortIsInput);
|
||||
if (jports == NULL)
|
||||
{
|
||||
@@ -160,7 +162,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency)
|
||||
goto error;
|
||||
}
|
||||
|
||||
size_t bufsize = find_buffersize(jd, latency);
|
||||
bufsize = find_buffersize(jd, latency);
|
||||
SSNES_LOG("JACK: Internal buffer size: %d frames.\n", (int)(bufsize / sizeof(jack_default_audio_sample_t)));
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
@@ -172,7 +174,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency)
|
||||
}
|
||||
}
|
||||
|
||||
int parsed = parse_ports(dest_ports, jports);
|
||||
parsed = parse_ports(dest_ports, jports);
|
||||
|
||||
if (jack_activate(jd->client) < 0)
|
||||
{
|
||||
@@ -191,7 +193,6 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency)
|
||||
|
||||
for (int i = 0; i < parsed; i++)
|
||||
free(dest_ports[i]);
|
||||
|
||||
|
||||
jack_free(jports);
|
||||
return jd;
|
||||
@@ -204,7 +205,7 @@ error:
|
||||
|
||||
static size_t write_buffer(jack_t *jd, const float *buf, size_t size)
|
||||
{
|
||||
jack_default_audio_sample_t out_deinterleaved_buffer[2][FRAMES(size)];
|
||||
jack_default_audio_sample_t out_deinterleaved_buffer[2][AUDIO_CHUNK_SIZE_NONBLOCKING];
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (size_t j = 0; j < FRAMES(size); j++)
|
||||
@@ -218,9 +219,11 @@ static size_t write_buffer(jack_t *jd, const float *buf, size_t size)
|
||||
if (jd->shutdown)
|
||||
return 0;
|
||||
|
||||
size_t avail[2];
|
||||
avail[0] = jack_ringbuffer_write_space(jd->buffer[0]);
|
||||
avail[1] = jack_ringbuffer_write_space(jd->buffer[1]);
|
||||
size_t avail[2] = {
|
||||
jack_ringbuffer_write_space(jd->buffer[0]),
|
||||
jack_ringbuffer_write_space(jd->buffer[1]),
|
||||
};
|
||||
|
||||
size_t min_avail = avail[0] < avail[1] ? avail[0] : avail[1];
|
||||
min_avail /= sizeof(float);
|
||||
|
||||
@@ -229,7 +232,10 @@ static size_t write_buffer(jack_t *jd, const float *buf, size_t size)
|
||||
if (write_frames > 0)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
jack_ringbuffer_write(jd->buffer[i], (const char*)&out_deinterleaved_buffer[i][written], write_frames * sizeof(jack_default_audio_sample_t));
|
||||
{
|
||||
jack_ringbuffer_write(jd->buffer[i], (const char*)&out_deinterleaved_buffer[i][written],
|
||||
write_frames * sizeof(jack_default_audio_sample_t));
|
||||
}
|
||||
written += write_frames;
|
||||
}
|
||||
else
|
||||
@@ -248,9 +254,9 @@ static size_t write_buffer(jack_t *jd, const float *buf, size_t size)
|
||||
|
||||
static ssize_t ja_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
jack_t *jd = data;
|
||||
jack_t *jd = (jack_t*)data;
|
||||
|
||||
return write_buffer(jd, buf, size);
|
||||
return write_buffer(jd, (const float*)buf, size);
|
||||
}
|
||||
|
||||
static bool ja_stop(void *data)
|
||||
@@ -261,7 +267,7 @@ static bool ja_stop(void *data)
|
||||
|
||||
static void ja_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
jack_t *jd = data;
|
||||
jack_t *jd = (jack_t*)data;
|
||||
jd->nonblock = state;
|
||||
}
|
||||
|
||||
@@ -273,7 +279,7 @@ static bool ja_start(void *data)
|
||||
|
||||
static void ja_free(void *data)
|
||||
{
|
||||
jack_t *jd = data;
|
||||
jack_t *jd = (jack_t*)data;
|
||||
|
||||
jd->shutdown = true;
|
||||
|
||||
@@ -299,18 +305,13 @@ static bool ja_use_float(void *data)
|
||||
}
|
||||
|
||||
const audio_driver_t audio_jack = {
|
||||
.init = ja_init,
|
||||
.write = ja_write,
|
||||
.stop = ja_stop,
|
||||
.start = ja_start,
|
||||
.set_nonblock_state = ja_set_nonblock_state,
|
||||
.free = ja_free,
|
||||
.use_float = ja_use_float,
|
||||
.ident = "jack"
|
||||
ja_init,
|
||||
ja_write,
|
||||
ja_stop,
|
||||
ja_start,
|
||||
ja_set_nonblock_state,
|
||||
ja_free,
|
||||
ja_use_float,
|
||||
"jack"
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+20
-21
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -15,8 +15,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "driver.h"
|
||||
#include "../driver.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenAL/al.h>
|
||||
@@ -59,7 +58,7 @@ typedef struct al
|
||||
static void *al_init(const char *device, unsigned rate, unsigned latency)
|
||||
{
|
||||
(void)device;
|
||||
al_t *al = calloc(1, sizeof(al_t));
|
||||
al_t *al = (al_t*)calloc(1, sizeof(al_t));
|
||||
if (!al)
|
||||
return NULL;
|
||||
|
||||
@@ -76,8 +75,8 @@ static void *al_init(const char *device, unsigned rate, unsigned latency)
|
||||
al->rate = rate;
|
||||
|
||||
al->num_buffers = (latency * rate * 2 * 2) / (1000 * BUFSIZE);
|
||||
al->buffers = calloc(al->num_buffers, sizeof(ALuint));
|
||||
al->res_buf = calloc(al->num_buffers, sizeof(ALuint));
|
||||
al->buffers = (ALuint*)calloc(al->num_buffers, sizeof(ALuint));
|
||||
al->res_buf = (ALuint*)calloc(al->num_buffers, sizeof(ALuint));
|
||||
if (al->buffers == NULL || al->res_buf == NULL)
|
||||
goto error;
|
||||
|
||||
@@ -127,10 +126,9 @@ static bool al_get_buffer(al_t *al, ALuint *buffer)
|
||||
if (al->res_ptr == 0)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
struct timespec tv = {
|
||||
.tv_sec = 0,
|
||||
.tv_nsec = 1000000
|
||||
};
|
||||
struct timespec tv = {0};
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_nsec = 1000000;
|
||||
#endif
|
||||
|
||||
for (;;)
|
||||
@@ -155,7 +153,7 @@ static bool al_get_buffer(al_t *al, ALuint *buffer)
|
||||
|
||||
static size_t al_fill_internal_buf(al_t *al, const void *buf, size_t size)
|
||||
{
|
||||
size_t read_size = (BUFSIZE - al->tmpbuf_ptr > size) ? size : (BUFSIZE - al->tmpbuf_ptr);
|
||||
size_t read_size = (BUFSIZE - al->tmpbuf_ptr > (ssize_t)size) ? size : (BUFSIZE - al->tmpbuf_ptr);
|
||||
memcpy(al->tmpbuf + al->tmpbuf_ptr, buf, read_size);
|
||||
al->tmpbuf_ptr += read_size;
|
||||
return read_size;
|
||||
@@ -163,7 +161,7 @@ static size_t al_fill_internal_buf(al_t *al, const void *buf, size_t size)
|
||||
|
||||
static ssize_t al_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
al_t *al = data;
|
||||
al_t *al = (al_t*)data;
|
||||
|
||||
size_t written = 0;
|
||||
while (written < size)
|
||||
@@ -204,7 +202,7 @@ static bool al_stop(void *data)
|
||||
|
||||
static void al_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
al_t *al = data;
|
||||
al_t *al = (al_t*)data;
|
||||
al->nonblock = state;
|
||||
}
|
||||
|
||||
@@ -216,7 +214,7 @@ static bool al_start(void *data)
|
||||
|
||||
static void al_free(void *data)
|
||||
{
|
||||
al_t *al= data;
|
||||
al_t *al = (al_t*)data;
|
||||
if (al)
|
||||
{
|
||||
alSourceStop(al->source);
|
||||
@@ -235,12 +233,13 @@ static void al_free(void *data)
|
||||
}
|
||||
|
||||
const audio_driver_t audio_openal = {
|
||||
.init = al_init,
|
||||
.write = al_write,
|
||||
.stop = al_stop,
|
||||
.start = al_start,
|
||||
.set_nonblock_state = al_set_nonblock_state,
|
||||
.free = al_free,
|
||||
.ident = "openal"
|
||||
al_init,
|
||||
al_write,
|
||||
al_stop,
|
||||
al_start,
|
||||
al_set_nonblock_state,
|
||||
al_free,
|
||||
NULL,
|
||||
"openal"
|
||||
};
|
||||
|
||||
+15
-14
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
static void *oss_init(const char *device, unsigned rate, unsigned latency)
|
||||
{
|
||||
int *fd = calloc(1, sizeof(int));
|
||||
int *fd = (int*)calloc(1, sizeof(int));
|
||||
if (fd == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -98,7 +98,7 @@ static void *oss_init(const char *device, unsigned rate, unsigned latency)
|
||||
|
||||
static ssize_t oss_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
int *fd = data;
|
||||
int *fd = (int*)data;
|
||||
|
||||
if (size == 0)
|
||||
return 0;
|
||||
@@ -116,7 +116,7 @@ static ssize_t oss_write(void *data, const void *buf, size_t size)
|
||||
|
||||
static bool oss_stop(void *data)
|
||||
{
|
||||
int *fd = data;
|
||||
int *fd = (int*)data;
|
||||
ioctl(*fd, SNDCTL_DSP_RESET, 0);
|
||||
return true;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ static bool oss_start(void *data)
|
||||
|
||||
static void oss_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
int *fd = data;
|
||||
int *fd = (int*)data;
|
||||
int rc;
|
||||
if (state)
|
||||
rc = fcntl(*fd, F_SETFL, fcntl(*fd, F_GETFL) | O_NONBLOCK);
|
||||
@@ -140,7 +140,7 @@ static void oss_set_nonblock_state(void *data, bool state)
|
||||
|
||||
static void oss_free(void *data)
|
||||
{
|
||||
int *fd = data;
|
||||
int *fd = (int*)data;
|
||||
|
||||
ioctl(*fd, SNDCTL_DSP_RESET, 0);
|
||||
close(*fd);
|
||||
@@ -148,12 +148,13 @@ static void oss_free(void *data)
|
||||
}
|
||||
|
||||
const audio_driver_t audio_oss = {
|
||||
.init = oss_init,
|
||||
.write = oss_write,
|
||||
.stop = oss_stop,
|
||||
.start = oss_start,
|
||||
.set_nonblock_state = oss_set_nonblock_state,
|
||||
.free = oss_free,
|
||||
.ident = "oss"
|
||||
oss_init,
|
||||
oss_write,
|
||||
oss_stop,
|
||||
oss_start,
|
||||
oss_set_nonblock_state,
|
||||
oss_free,
|
||||
NULL,
|
||||
"oss"
|
||||
};
|
||||
|
||||
|
||||
+30
-35
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "driver.h"
|
||||
#include "general.h"
|
||||
#include <pulse/pulseaudio.h>
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include <string.h>
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -34,7 +34,7 @@ typedef struct
|
||||
|
||||
static void pulse_free(void *data)
|
||||
{
|
||||
pa_t *pa = data;
|
||||
pa_t *pa = (pa_t*)data;
|
||||
if (pa)
|
||||
{
|
||||
if (pa->mainloop)
|
||||
@@ -61,7 +61,7 @@ static void pulse_free(void *data)
|
||||
|
||||
static void context_state_cb(pa_context *c, void *data)
|
||||
{
|
||||
pa_t *pa = data;
|
||||
pa_t *pa = (pa_t*)data;
|
||||
switch (pa_context_get_state(c))
|
||||
{
|
||||
case PA_CONTEXT_READY:
|
||||
@@ -76,7 +76,7 @@ static void context_state_cb(pa_context *c, void *data)
|
||||
|
||||
static void stream_state_cb(pa_stream *s, void *data)
|
||||
{
|
||||
pa_t *pa = data;
|
||||
pa_t *pa = (pa_t*)data;
|
||||
switch (pa_stream_get_state(s)) {
|
||||
case PA_STREAM_READY:
|
||||
case PA_STREAM_FAILED:
|
||||
@@ -92,20 +92,24 @@ static void stream_request_cb(pa_stream *s, size_t length, void *data)
|
||||
{
|
||||
(void)length;
|
||||
(void)s;
|
||||
pa_t *pa = data;
|
||||
pa_t *pa = (pa_t*)data;
|
||||
pa_threaded_mainloop_signal(pa->mainloop, 0);
|
||||
}
|
||||
|
||||
static void stream_latency_update_cb(pa_stream *s, void *data)
|
||||
{
|
||||
(void)s;
|
||||
pa_t *pa = data;
|
||||
pa_t *pa = (pa_t*)data;
|
||||
pa_threaded_mainloop_signal(pa->mainloop, 0);
|
||||
}
|
||||
|
||||
static void *pulse_init(const char *device, unsigned rate, unsigned latency)
|
||||
{
|
||||
pa_t *pa = calloc(1, sizeof(*pa));
|
||||
pa_sample_spec spec;
|
||||
memset(&spec, 0, sizeof(spec));
|
||||
pa_buffer_attr buffer_attr = {0};
|
||||
|
||||
pa_t *pa = (pa_t*)calloc(1, sizeof(*pa));
|
||||
if (!pa)
|
||||
goto error;
|
||||
|
||||
@@ -131,11 +135,9 @@ static void *pulse_init(const char *device, unsigned rate, unsigned latency)
|
||||
if (pa_context_get_state(pa->context) != PA_CONTEXT_READY)
|
||||
goto unlock_error;
|
||||
|
||||
pa_sample_spec spec = {
|
||||
.format = is_little_endian() ? PA_SAMPLE_FLOAT32LE : PA_SAMPLE_FLOAT32BE,
|
||||
.channels = 2,
|
||||
.rate = rate
|
||||
};
|
||||
spec.format = is_little_endian() ? PA_SAMPLE_FLOAT32LE : PA_SAMPLE_FLOAT32BE;
|
||||
spec.channels = 2;
|
||||
spec.rate = rate;
|
||||
|
||||
pa->stream = pa_stream_new(pa->context, "audio", &spec, NULL);
|
||||
if (!pa->stream)
|
||||
@@ -145,13 +147,11 @@ static void *pulse_init(const char *device, unsigned rate, unsigned latency)
|
||||
pa_stream_set_write_callback(pa->stream, stream_request_cb, pa);
|
||||
pa_stream_set_latency_update_callback(pa->stream, stream_latency_update_cb, pa);
|
||||
|
||||
pa_buffer_attr buffer_attr = {
|
||||
.maxlength = -1,
|
||||
.tlength = pa_usec_to_bytes(latency * PA_USEC_PER_MSEC, &spec),
|
||||
.prebuf = -1,
|
||||
.minreq = -1,
|
||||
.fragsize = -1
|
||||
};
|
||||
buffer_attr.maxlength = -1;
|
||||
buffer_attr.tlength = pa_usec_to_bytes(latency * PA_USEC_PER_MSEC, &spec);
|
||||
buffer_attr.prebuf = -1;
|
||||
buffer_attr.minreq = -1;
|
||||
buffer_attr.fragsize = -1;
|
||||
|
||||
if (pa_stream_connect_playback(pa->stream, NULL, &buffer_attr, PA_STREAM_ADJUST_LATENCY, NULL, NULL) < 0)
|
||||
goto error;
|
||||
@@ -174,7 +174,7 @@ error:
|
||||
|
||||
static ssize_t pulse_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
pa_t *pa = data;
|
||||
pa_t *pa = (pa_t*)data;
|
||||
|
||||
pa_threaded_mainloop_lock(pa->mainloop);
|
||||
unsigned length = pa_stream_writable_size(pa->stream);
|
||||
@@ -212,7 +212,7 @@ static bool pulse_start(void *data)
|
||||
|
||||
static void pulse_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
pa_t *pa = data;
|
||||
pa_t *pa = (pa_t*)data;
|
||||
pa->nonblock = state;
|
||||
}
|
||||
|
||||
@@ -223,18 +223,13 @@ static bool pulse_use_float(void *data)
|
||||
}
|
||||
|
||||
const audio_driver_t audio_pulse = {
|
||||
.init = pulse_init,
|
||||
.write = pulse_write,
|
||||
.stop = pulse_stop,
|
||||
.start = pulse_start,
|
||||
.set_nonblock_state = pulse_set_nonblock_state,
|
||||
.use_float = pulse_use_float,
|
||||
.free = pulse_free,
|
||||
.ident = "pulse"
|
||||
pulse_init,
|
||||
pulse_write,
|
||||
pulse_stop,
|
||||
pulse_start,
|
||||
pulse_set_nonblock_state,
|
||||
pulse_free,
|
||||
pulse_use_float,
|
||||
"pulse"
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+14
-18
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <roaraudio.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include "general.h"
|
||||
|
||||
typedef struct
|
||||
@@ -34,7 +34,7 @@ static void *ra_init(const char *device, unsigned rate, unsigned latency)
|
||||
{
|
||||
(void)latency;
|
||||
int err;
|
||||
roar_t *roar = calloc(1, sizeof(roar_t));
|
||||
roar_t *roar = (roar_t*)calloc(1, sizeof(roar_t));
|
||||
if (roar == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -54,7 +54,7 @@ static void *ra_init(const char *device, unsigned rate, unsigned latency)
|
||||
|
||||
static ssize_t ra_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
roar_t *roar = data;
|
||||
roar_t *roar = (roar_t*)data;
|
||||
ssize_t rc;
|
||||
|
||||
if (size == 0)
|
||||
@@ -86,7 +86,7 @@ static bool ra_stop(void *data)
|
||||
|
||||
static void ra_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
roar_t *roar = data;
|
||||
roar_t *roar = (roar_t*)data;
|
||||
if (roar_vs_blocking(roar->vss, (state) ? ROAR_VS_FALSE : ROAR_VS_TRUE, NULL) < 0)
|
||||
fprintf(stderr, "SSNES [ERROR]: Can't set nonblocking. Will not be able to fast-forward.\n");
|
||||
roar->nonblocking = state;
|
||||
@@ -100,23 +100,19 @@ static bool ra_start(void *data)
|
||||
|
||||
static void ra_free(void *data)
|
||||
{
|
||||
roar_t *roar = data;
|
||||
roar_t *roar = (roar_t*)data;
|
||||
roar_vs_close(roar->vss, ROAR_VS_TRUE, NULL);
|
||||
free(data);
|
||||
}
|
||||
|
||||
const audio_driver_t audio_roar = {
|
||||
.init = ra_init,
|
||||
.write = ra_write,
|
||||
.stop = ra_stop,
|
||||
.start = ra_start,
|
||||
.set_nonblock_state = ra_set_nonblock_state,
|
||||
.free = ra_free,
|
||||
.ident = "roar"
|
||||
ra_init,
|
||||
ra_write,
|
||||
ra_stop,
|
||||
ra_start,
|
||||
ra_set_nonblock_state,
|
||||
ra_free,
|
||||
NULL,
|
||||
"roar"
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+18
-17
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <rsound.h>
|
||||
#include "fifo_buffer.h"
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include "SDL.h"
|
||||
|
||||
typedef struct rsd
|
||||
@@ -37,7 +37,7 @@ typedef struct rsd
|
||||
|
||||
static ssize_t audio_cb(void *data, size_t bytes, void *userdata)
|
||||
{
|
||||
rsd_t *rsd = userdata;
|
||||
rsd_t *rsd = (rsd_t*)userdata;
|
||||
|
||||
size_t avail = fifo_read_avail(rsd->buffer);
|
||||
size_t write_size = bytes > avail ? avail : bytes;
|
||||
@@ -49,14 +49,14 @@ static ssize_t audio_cb(void *data, size_t bytes, void *userdata)
|
||||
|
||||
static void err_cb(void *userdata)
|
||||
{
|
||||
rsd_t *rsd = userdata;
|
||||
rsd_t *rsd = (rsd_t*)userdata;
|
||||
rsd->has_error = true;
|
||||
SDL_CondSignal(rsd->cond);
|
||||
}
|
||||
|
||||
static void *rs_init(const char *device, unsigned rate, unsigned latency)
|
||||
{
|
||||
rsd_t *rsd = calloc(1, sizeof(rsd_t));
|
||||
rsd_t *rsd = (rsd_t*)calloc(1, sizeof(rsd_t));
|
||||
if (!rsd)
|
||||
return NULL;
|
||||
|
||||
@@ -100,7 +100,7 @@ static void *rs_init(const char *device, unsigned rate, unsigned latency)
|
||||
|
||||
static ssize_t rs_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
rsd_t *rsd = data;
|
||||
rsd_t *rsd = (rsd_t*)data;
|
||||
|
||||
if (rsd->has_error)
|
||||
return -1;
|
||||
@@ -146,7 +146,7 @@ static ssize_t rs_write(void *data, const void *buf, size_t size)
|
||||
|
||||
static bool rs_stop(void *data)
|
||||
{
|
||||
rsd_t *rsd = data;
|
||||
rsd_t *rsd = (rsd_t*)data;
|
||||
rsd_stop(rsd->rd);
|
||||
|
||||
return true;
|
||||
@@ -154,13 +154,13 @@ static bool rs_stop(void *data)
|
||||
|
||||
static void rs_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
rsd_t *rsd = data;
|
||||
rsd_t *rsd = (rsd_t*)data;
|
||||
rsd->nonblock = state;
|
||||
}
|
||||
|
||||
static bool rs_start(void *data)
|
||||
{
|
||||
rsd_t *rsd = data;
|
||||
rsd_t *rsd = (rsd_t*)data;
|
||||
if (rsd_start(rsd->rd) < 0)
|
||||
return false;
|
||||
|
||||
@@ -169,7 +169,7 @@ static bool rs_start(void *data)
|
||||
|
||||
static void rs_free(void *data)
|
||||
{
|
||||
rsd_t *rsd = data;
|
||||
rsd_t *rsd = (rsd_t*)data;
|
||||
|
||||
rsd_stop(rsd->rd);
|
||||
rsd_free(rsd->rd);
|
||||
@@ -182,12 +182,13 @@ static void rs_free(void *data)
|
||||
}
|
||||
|
||||
const audio_driver_t audio_rsound = {
|
||||
.init = rs_init,
|
||||
.write = rs_write,
|
||||
.stop = rs_stop,
|
||||
.start = rs_start,
|
||||
.set_nonblock_state = rs_set_nonblock_state,
|
||||
.free = rs_free,
|
||||
.ident = "rsound"
|
||||
rs_init,
|
||||
rs_write,
|
||||
rs_stop,
|
||||
rs_start,
|
||||
rs_set_nonblock_state,
|
||||
rs_free,
|
||||
NULL,
|
||||
"rsound"
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -16,36 +16,37 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "driver.h"
|
||||
#include "../driver.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "general.h"
|
||||
#include "fifo_buffer.h"
|
||||
#include "../thread.h"
|
||||
|
||||
#include "../general.h"
|
||||
#include "../fifo_buffer.h"
|
||||
|
||||
typedef struct sdl_audio
|
||||
{
|
||||
bool nonblock;
|
||||
|
||||
SDL_mutex *lock;
|
||||
SDL_cond *cond;
|
||||
slock_t *lock;
|
||||
scond_t *cond;
|
||||
fifo_buffer_t *buffer;
|
||||
} sdl_audio_t;
|
||||
|
||||
static void sdl_audio_cb(void *data, Uint8 *stream, int len)
|
||||
{
|
||||
sdl_audio_t *sdl = data;
|
||||
sdl_audio_t *sdl = (sdl_audio_t*)data;
|
||||
|
||||
size_t avail = fifo_read_avail(sdl->buffer);
|
||||
size_t write_size = len > avail ? avail : len;
|
||||
size_t write_size = len > (int)avail ? avail : len;
|
||||
fifo_read(sdl->buffer, stream, write_size);
|
||||
SDL_CondSignal(sdl->cond);
|
||||
scond_signal(sdl->cond);
|
||||
|
||||
// If underrun, fill rest with silence.
|
||||
memset(stream + write_size, 0, len - write_size);
|
||||
@@ -64,21 +65,20 @@ static void *sdl_audio_init(const char *device, unsigned rate, unsigned latency)
|
||||
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
|
||||
return NULL;
|
||||
|
||||
sdl_audio_t *sdl = calloc(1, sizeof(*sdl));
|
||||
sdl_audio_t *sdl = (sdl_audio_t*)calloc(1, sizeof(*sdl));
|
||||
if (!sdl)
|
||||
return NULL;
|
||||
|
||||
// We have to buffer up some data ourselves, so we let SDL carry approx half of the latency. SDL double buffers audio and we do as well.
|
||||
int frames = find_num_frames(rate, latency / 4);
|
||||
|
||||
SDL_AudioSpec spec = {
|
||||
.freq = rate,
|
||||
.format = AUDIO_S16SYS,
|
||||
.channels = 2,
|
||||
.samples = frames, // This is in audio frames, not samples ... :(
|
||||
.callback = sdl_audio_cb,
|
||||
.userdata = sdl
|
||||
};
|
||||
SDL_AudioSpec spec = {0};
|
||||
spec.freq = rate;
|
||||
spec.format = AUDIO_S16SYS;
|
||||
spec.channels = 2;
|
||||
spec.samples = frames; // This is in audio frames, not samples ... :(
|
||||
spec.callback = sdl_audio_cb;
|
||||
spec.userdata = sdl;
|
||||
|
||||
SDL_AudioSpec out;
|
||||
|
||||
@@ -90,8 +90,8 @@ static void *sdl_audio_init(const char *device, unsigned rate, unsigned latency)
|
||||
}
|
||||
g_settings.audio.out_rate = out.freq;
|
||||
|
||||
sdl->lock = SDL_CreateMutex();
|
||||
sdl->cond = SDL_CreateCond();
|
||||
sdl->lock = slock_new();
|
||||
sdl->cond = scond_new();
|
||||
|
||||
SSNES_LOG("SDL audio: Requested %d ms latency, got %d ms\n", latency, (int)(out.samples * 4 * 1000 / g_settings.audio.out_rate));
|
||||
|
||||
@@ -111,7 +111,7 @@ static void *sdl_audio_init(const char *device, unsigned rate, unsigned latency)
|
||||
|
||||
static ssize_t sdl_audio_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
sdl_audio_t *sdl = data;
|
||||
sdl_audio_t *sdl = (sdl_audio_t*)data;
|
||||
|
||||
ssize_t ret = 0;
|
||||
if (sdl->nonblock)
|
||||
@@ -134,9 +134,9 @@ static ssize_t sdl_audio_write(void *data, const void *buf, size_t size)
|
||||
if (avail == 0)
|
||||
{
|
||||
SDL_UnlockAudio();
|
||||
SDL_mutexP(sdl->lock);
|
||||
SDL_CondWait(sdl->cond, sdl->lock);
|
||||
SDL_mutexV(sdl->lock);
|
||||
slock_lock(sdl->lock);
|
||||
scond_wait(sdl->cond, sdl->lock);
|
||||
slock_unlock(sdl->lock);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -168,7 +168,7 @@ static bool sdl_audio_start(void *data)
|
||||
|
||||
static void sdl_audio_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
sdl_audio_t *sdl = data;
|
||||
sdl_audio_t *sdl = (sdl_audio_t*)data;
|
||||
sdl->nonblock = state;
|
||||
}
|
||||
|
||||
@@ -177,23 +177,24 @@ static void sdl_audio_free(void *data)
|
||||
SDL_CloseAudio();
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
|
||||
sdl_audio_t *sdl = data;
|
||||
sdl_audio_t *sdl = (sdl_audio_t*)data;
|
||||
if (sdl)
|
||||
{
|
||||
fifo_free(sdl->buffer);
|
||||
SDL_DestroyMutex(sdl->lock);
|
||||
SDL_DestroyCond(sdl->cond);
|
||||
slock_free(sdl->lock);
|
||||
scond_free(sdl->cond);
|
||||
}
|
||||
free(sdl);
|
||||
}
|
||||
|
||||
const audio_driver_t audio_sdl = {
|
||||
.init = sdl_audio_init,
|
||||
.write = sdl_audio_write,
|
||||
.stop = sdl_audio_stop,
|
||||
.start = sdl_audio_start,
|
||||
.set_nonblock_state = sdl_audio_set_nonblock_state,
|
||||
.free = sdl_audio_free,
|
||||
.ident = "sdl"
|
||||
sdl_audio_init,
|
||||
sdl_audio_write,
|
||||
sdl_audio_stop,
|
||||
sdl_audio_start,
|
||||
sdl_audio_set_nonblock_state,
|
||||
sdl_audio_free,
|
||||
NULL,
|
||||
"sdl"
|
||||
};
|
||||
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
#include "utils.h"
|
||||
|
||||
#if __SSE2__
|
||||
#include <emmintrin.h>
|
||||
#elif __ALTIVEC__
|
||||
#include <altivec.h>
|
||||
#endif
|
||||
|
||||
void audio_convert_s16_to_float_C(float *out,
|
||||
const int16_t *in, size_t samples)
|
||||
{
|
||||
for (size_t i = 0; i < samples; i++)
|
||||
out[i] = (float)in[i] / 0x8000;
|
||||
}
|
||||
|
||||
void audio_convert_float_to_s16_C(int16_t *out,
|
||||
const float *in, size_t samples)
|
||||
{
|
||||
for (size_t i = 0; i < samples; i++)
|
||||
{
|
||||
int32_t val = (int32_t)(in[i] * 0x8000);
|
||||
out[i] = (val > 0x7FFF) ? 0x7FFF : (val < -0x8000 ? -0x8000 : (int16_t)val);
|
||||
}
|
||||
}
|
||||
|
||||
#if __SSE2__
|
||||
void audio_convert_s16_to_float_SSE2(float *out,
|
||||
const int16_t *in, size_t samples)
|
||||
{
|
||||
__m128 factor = _mm_set1_ps(1.0f / (0x7fff * 0x10000));
|
||||
size_t i;
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
{
|
||||
__m128i input = _mm_loadu_si128((const __m128i *)in);
|
||||
__m128i regs[2] = {
|
||||
_mm_unpacklo_epi16(_mm_setzero_si128(), input),
|
||||
_mm_unpackhi_epi16(_mm_setzero_si128(), input),
|
||||
};
|
||||
|
||||
__m128 output[2] = {
|
||||
_mm_mul_ps(_mm_cvtepi32_ps(regs[0]), factor),
|
||||
_mm_mul_ps(_mm_cvtepi32_ps(regs[1]), factor),
|
||||
};
|
||||
|
||||
_mm_storeu_ps(out + 0, output[0]);
|
||||
_mm_storeu_ps(out + 4, output[1]);
|
||||
}
|
||||
|
||||
audio_convert_s16_to_float_C(out, in, samples - i);
|
||||
}
|
||||
|
||||
void audio_convert_float_to_s16_SSE2(int16_t *out,
|
||||
const float *in, size_t samples)
|
||||
{
|
||||
__m128 factor = _mm_set1_ps((float)0x7fff);
|
||||
size_t i;
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
{
|
||||
__m128 input[2] = { _mm_loadu_ps(in + 0), _mm_loadu_ps(in + 4) };
|
||||
__m128 res[2] = { _mm_mul_ps(input[0], factor), _mm_mul_ps(input[1], factor) };
|
||||
|
||||
__m128i ints[2] = { _mm_cvtps_epi32(res[0]), _mm_cvtps_epi32(res[1]) };
|
||||
__m128i packed = _mm_packs_epi32(ints[0], ints[1]);
|
||||
|
||||
_mm_storeu_si128((__m128i *)out, packed);
|
||||
}
|
||||
|
||||
audio_convert_float_to_s16_C(out, in, samples - i);
|
||||
}
|
||||
#elif __ALTIVEC__
|
||||
void audio_convert_s16_to_float_altivec(float *out,
|
||||
const int16_t *in, size_t samples)
|
||||
{
|
||||
// Unaligned loads/store is a bit expensive, so we optimize for the good path (very likely).
|
||||
if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
{
|
||||
vector signed short input = vec_ld(0, in);
|
||||
vector signed int hi = vec_unpackh(input);
|
||||
vector signed int lo = vec_unpackl(input);
|
||||
vector float out_hi = vec_ctf(hi, 15);
|
||||
vector float out_lo = vec_ctf(lo, 15);
|
||||
|
||||
vec_st(out_hi, 0, out);
|
||||
vec_st(out_lo, 16, out);
|
||||
}
|
||||
|
||||
audio_convert_s16_to_float_C(out, in, samples - i);
|
||||
}
|
||||
else
|
||||
audio_convert_s16_to_float_C(out, in, samples);
|
||||
}
|
||||
|
||||
void audio_convert_float_to_s16_altivec(int16_t *out,
|
||||
const float *in, size_t samples)
|
||||
{
|
||||
// Unaligned loads/store is a bit expensive, so we optimize for the good path (very likely).
|
||||
if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
{
|
||||
vector float input0 = vec_ld( 0, in);
|
||||
vector float input1 = vec_ld(16, in);
|
||||
vector signed int result0 = vec_cts(input0, 15);
|
||||
vector signed int result1 = vec_cts(input1, 15);
|
||||
vec_st(vec_packs(result0, result1), 0, out);
|
||||
}
|
||||
|
||||
audio_convert_float_to_s16_C(out, in, samples - i);
|
||||
}
|
||||
else
|
||||
audio_convert_float_to_s16_C(out, in, samples);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+22
-66
@@ -2,81 +2,37 @@
|
||||
#define AUDIO_UTILS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if __SSE2__
|
||||
#include <mmintrin.h>
|
||||
#include <emmintrin.h>
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_SSE2
|
||||
#define audio_convert_float_to_s16 audio_convert_float_to_s16_SSE2
|
||||
|
||||
void audio_convert_s16_to_float_SSE2(float *out,
|
||||
const int16_t *in, size_t samples);
|
||||
|
||||
void audio_convert_float_to_s16_SSE2(int16_t *out,
|
||||
const float *in, size_t samples);
|
||||
|
||||
#elif __ALTIVEC__
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_altivec
|
||||
#define audio_convert_float_to_s16 audio_convert_float_to_s16_altivec
|
||||
|
||||
void audio_convert_s16_to_float_altivec(float *out,
|
||||
const int16_t *in, size_t samples);
|
||||
|
||||
void audio_convert_float_to_s16_altivec(int16_t *out,
|
||||
const float *in, size_t samples);
|
||||
|
||||
#else
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_C
|
||||
#define audio_convert_float_to_s16 audio_convert_float_to_s16_C
|
||||
#endif
|
||||
|
||||
static inline void audio_convert_s16_to_float_C(float *out,
|
||||
const int16_t *in, unsigned samples)
|
||||
{
|
||||
for (unsigned i = 0; i < samples; i++)
|
||||
out[i] = (float)in[i] / 0x8000;
|
||||
}
|
||||
|
||||
static inline void audio_convert_float_to_s16_C(int16_t *out,
|
||||
const float *in, unsigned samples)
|
||||
{
|
||||
for (unsigned i = 0; i < samples; i++)
|
||||
{
|
||||
int32_t val = in[i] * 0x8000;
|
||||
out[i] = (val > 0x7FFF) ? 0x7FFF : (val < -0x8000 ? -0x8000 : (int16_t)val);
|
||||
}
|
||||
}
|
||||
|
||||
#if __SSE2__
|
||||
static inline void audio_convert_s16_to_float_SSE2(float *out,
|
||||
const int16_t *in, unsigned samples)
|
||||
{
|
||||
__m128 factor = _mm_set1_ps(1.0f / (0x7fff * 0x10000));
|
||||
unsigned i;
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
{
|
||||
__m128i input = _mm_loadu_si128((const __m128i *)in);
|
||||
__m128i regs[2] = {
|
||||
_mm_unpacklo_epi16(_mm_setzero_si128(), input),
|
||||
_mm_unpackhi_epi16(_mm_setzero_si128(), input),
|
||||
};
|
||||
|
||||
__m128 output[2] = {
|
||||
_mm_mul_ps(_mm_cvtepi32_ps(regs[0]), factor),
|
||||
_mm_mul_ps(_mm_cvtepi32_ps(regs[1]), factor),
|
||||
};
|
||||
|
||||
_mm_storeu_ps(out + 0, output[0]);
|
||||
_mm_storeu_ps(out + 4, output[1]);
|
||||
}
|
||||
|
||||
audio_convert_s16_to_float_C(out, in, samples - i);
|
||||
}
|
||||
|
||||
static inline void audio_convert_float_to_s16_SSE2(int16_t *out,
|
||||
const float *in, unsigned samples)
|
||||
{
|
||||
__m128 factor = _mm_set1_ps((float)0x7fff);
|
||||
unsigned i;
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
{
|
||||
__m128 input[2] = { _mm_loadu_ps(in + 0), _mm_loadu_ps(in + 4) };
|
||||
__m128 res[2] = { _mm_mul_ps(input[0], factor), _mm_mul_ps(input[1], factor) };
|
||||
|
||||
__m128i ints[2] = { _mm_cvtps_epi32(res[0]), _mm_cvtps_epi32(res[1]) };
|
||||
__m128i packed = _mm_packs_epi32(ints[0], ints[1]);
|
||||
|
||||
_mm_storeu_si128((__m128i *)out, packed);
|
||||
}
|
||||
|
||||
audio_convert_float_to_s16_C(out, in, samples - i);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
void audio_convert_s16_to_float_C(float *out,
|
||||
const int16_t *in, size_t samples);
|
||||
void audio_convert_float_to_s16_C(int16_t *out,
|
||||
const float *in, size_t samples);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
Simple C interface for XAudio2
|
||||
Author: Hans-Kristian Arntzen
|
||||
License: Public Domain
|
||||
*/
|
||||
|
||||
#include "xaudio.h"
|
||||
#include "xaudio-c.h"
|
||||
#include <stdint.h>
|
||||
#include "../../msvc/msvc_compat.h"
|
||||
|
||||
#define MAX_BUFFERS 16
|
||||
#define MAX_BUFFERS_MASK (MAX_BUFFERS - 1)
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
struct xaudio2
|
||||
{
|
||||
const IXAudio2VoiceCallbackVtbl *lpVtbl;
|
||||
|
||||
uint8_t *buf;
|
||||
IXAudio2 *pXAudio2;
|
||||
IXAudio2MasteringVoice *pMasterVoice;
|
||||
IXAudio2SourceVoice *pSourceVoice;
|
||||
HANDLE hEvent;
|
||||
|
||||
volatile long buffers;
|
||||
unsigned bufsize;
|
||||
unsigned bufptr;
|
||||
unsigned write_buffer;
|
||||
};
|
||||
|
||||
static void WINAPI voice_on_buffer_end(void *handle_, void *data)
|
||||
{
|
||||
(void)data;
|
||||
xaudio2_t *handle = (xaudio2_t*)handle_;
|
||||
InterlockedDecrement(&handle->buffers);
|
||||
SetEvent(handle->hEvent);
|
||||
}
|
||||
|
||||
static void WINAPI dummy_voidp(void *handle, void *data) { (void)handle; (void)data; }
|
||||
static void WINAPI dummy_nil(void *handle) { (void)handle; }
|
||||
static void WINAPI dummy_uint32(void *handle, UINT32 dummy) { (void)handle; (void)dummy; }
|
||||
static void WINAPI dummy_voidp_hresult(void *handle, void *data, HRESULT dummy) { (void)handle; (void)data; (void)dummy; }
|
||||
|
||||
const struct IXAudio2VoiceCallbackVtbl voice_vtable = {
|
||||
dummy_uint32,
|
||||
dummy_nil,
|
||||
dummy_nil,
|
||||
dummy_voidp,
|
||||
voice_on_buffer_end,
|
||||
dummy_voidp,
|
||||
dummy_voidp_hresult,
|
||||
};
|
||||
|
||||
xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels, size_t size)
|
||||
{
|
||||
xaudio2_t *handle = (xaudio2_t*)calloc(1, sizeof(*handle));
|
||||
if (!handle)
|
||||
return NULL;
|
||||
|
||||
handle->lpVtbl = &voice_vtable;
|
||||
CoInitializeEx(0, COINIT_MULTITHREADED);
|
||||
WAVEFORMATEX wfx = {0};
|
||||
|
||||
if (FAILED(XAudio2Create(&handle->pXAudio2)))
|
||||
goto error;
|
||||
|
||||
if (FAILED(IXAudio2_CreateMasteringVoice(handle->pXAudio2,
|
||||
&handle->pMasterVoice, channels, samplerate, 0, 0, 0)))
|
||||
goto error;
|
||||
|
||||
wfx.wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
|
||||
wfx.nChannels = channels;
|
||||
wfx.nSamplesPerSec = samplerate;
|
||||
wfx.nBlockAlign = channels * sizeof(float);
|
||||
wfx.wBitsPerSample = sizeof(float) * 8;
|
||||
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
||||
wfx.cbSize = 0;
|
||||
|
||||
if (FAILED(IXAudio2_CreateSourceVoice(handle->pXAudio2,
|
||||
&handle->pSourceVoice, &wfx,
|
||||
XAUDIO2_VOICE_NOSRC, XAUDIO2_DEFAULT_FREQ_RATIO,
|
||||
(IXAudio2VoiceCallback*)handle, 0, 0)))
|
||||
goto error;
|
||||
|
||||
handle->hEvent = CreateEvent(0, FALSE, FALSE, 0);
|
||||
if (!handle->hEvent)
|
||||
goto error;
|
||||
|
||||
handle->bufsize = size / MAX_BUFFERS;
|
||||
handle->buf = (uint8_t*)calloc(1, handle->bufsize * MAX_BUFFERS);
|
||||
if (!handle->buf)
|
||||
goto error;
|
||||
|
||||
if (FAILED(IXAudio2SourceVoice_Start(handle->pSourceVoice, 0, XAUDIO2_COMMIT_NOW)))
|
||||
goto error;
|
||||
|
||||
return handle;
|
||||
|
||||
error:
|
||||
xaudio2_free(handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t xaudio2_write_avail(xaudio2_t *handle)
|
||||
{
|
||||
return handle->bufsize * (MAX_BUFFERS - handle->buffers - 1);
|
||||
}
|
||||
|
||||
size_t xaudio2_write(xaudio2_t *handle, const void *buf, size_t bytes_)
|
||||
{
|
||||
unsigned bytes = bytes_;
|
||||
const uint8_t *buffer = (const uint8_t*)buf;
|
||||
while (bytes)
|
||||
{
|
||||
unsigned need = min(bytes, handle->bufsize - handle->bufptr);
|
||||
memcpy(handle->buf + handle->write_buffer * handle->bufsize + handle->bufptr,
|
||||
buffer, need);
|
||||
|
||||
handle->bufptr += need;
|
||||
buffer += need;
|
||||
bytes -= need;
|
||||
|
||||
if (handle->bufptr == handle->bufsize)
|
||||
{
|
||||
while (handle->buffers == MAX_BUFFERS - 1)
|
||||
WaitForSingleObject(handle->hEvent, INFINITE);
|
||||
|
||||
XAUDIO2_BUFFER xa2buffer = {0};
|
||||
xa2buffer.AudioBytes = handle->bufsize;
|
||||
xa2buffer.pAudioData = handle->buf + handle->write_buffer * handle->bufsize;
|
||||
|
||||
if (FAILED(IXAudio2SourceVoice_SubmitSourceBuffer(handle->pSourceVoice, &xa2buffer, NULL)))
|
||||
return 0;
|
||||
|
||||
InterlockedIncrement(&handle->buffers);
|
||||
handle->bufptr = 0;
|
||||
handle->write_buffer = (handle->write_buffer + 1) & MAX_BUFFERS_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
return bytes_;
|
||||
}
|
||||
|
||||
void xaudio2_free(xaudio2_t *handle)
|
||||
{
|
||||
if (handle)
|
||||
{
|
||||
if (handle->pSourceVoice)
|
||||
{
|
||||
IXAudio2SourceVoice_Stop(handle->pSourceVoice, 0, XAUDIO2_COMMIT_NOW);
|
||||
IXAudio2SourceVoice_DestroyVoice(handle->pSourceVoice);
|
||||
}
|
||||
|
||||
if (handle->pMasterVoice)
|
||||
IXAudio2MasteringVoice_DestroyVoice(handle->pMasterVoice);
|
||||
|
||||
if (handle->pXAudio2)
|
||||
IXAudio2_Release(handle->pXAudio2);
|
||||
|
||||
if (handle->hEvent)
|
||||
CloseHandle(handle->hEvent);
|
||||
|
||||
free(handle->buf);
|
||||
free(handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
Simple C interface for XAudio2
|
||||
Author: Hans-Kristian Arntzen
|
||||
License: Public Domain
|
||||
*/
|
||||
|
||||
#include "xaudio-c.h"
|
||||
#include "xaudio2.hpp"
|
||||
#include <stdint.h>
|
||||
#include <algorithm>
|
||||
|
||||
struct xaudio2 : public IXAudio2VoiceCallback
|
||||
{
|
||||
xaudio2(unsigned samplerate, unsigned channels, unsigned size) :
|
||||
buf(0), pXAudio2(0), pMasterVoice(0), pSourceVoice(0),
|
||||
buffers(0), bufptr(0)
|
||||
{
|
||||
CoInitializeEx(0, COINIT_MULTITHREADED);
|
||||
if (FAILED(XAudio2Create(&pXAudio2, 0)))
|
||||
throw -1;
|
||||
if (FAILED(pXAudio2->CreateMasteringVoice(
|
||||
&pMasterVoice, channels, samplerate, 0, 0, 0)))
|
||||
throw -1;
|
||||
|
||||
WAVEFORMATEX wfx;
|
||||
wfx.wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
|
||||
wfx.nChannels = channels;
|
||||
wfx.nSamplesPerSec = samplerate;
|
||||
wfx.nBlockAlign = channels * sizeof(float);
|
||||
wfx.wBitsPerSample = sizeof(float) * 8;
|
||||
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
||||
wfx.cbSize = 0;
|
||||
if (FAILED(pXAudio2->CreateSourceVoice(
|
||||
&pSourceVoice, &wfx, XAUDIO2_VOICE_NOSRC, XAUDIO2_DEFAULT_FREQ_RATIO, this, 0, 0)))
|
||||
throw -1;
|
||||
|
||||
hEvent = CreateEvent(0, FALSE, FALSE, 0);
|
||||
if (!hEvent)
|
||||
throw -1;
|
||||
|
||||
pSourceVoice->Start(0);
|
||||
|
||||
bufsize = size / max_buffers;
|
||||
buf = new uint8_t[bufsize * max_buffers];
|
||||
write_buffer = 0;
|
||||
}
|
||||
|
||||
virtual ~xaudio2()
|
||||
{
|
||||
if (pSourceVoice)
|
||||
{
|
||||
pSourceVoice->Stop(0);
|
||||
pSourceVoice->DestroyVoice();
|
||||
}
|
||||
|
||||
if (pMasterVoice)
|
||||
pMasterVoice->DestroyVoice();
|
||||
|
||||
if (pXAudio2)
|
||||
pXAudio2->Release();
|
||||
|
||||
if (hEvent)
|
||||
CloseHandle(hEvent);
|
||||
|
||||
if (buf)
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
size_t write_avail() const
|
||||
{
|
||||
return bufsize * (max_buffers - buffers - 1);
|
||||
}
|
||||
|
||||
size_t write(const void *buffer_, size_t bytes_)
|
||||
{
|
||||
unsigned bytes = bytes_;
|
||||
const uint8_t *buffer = reinterpret_cast<const uint8_t*>(buffer_);
|
||||
while (bytes > 0)
|
||||
{
|
||||
unsigned need = std::min(bytes, bufsize - bufptr);
|
||||
memcpy(buf + write_buffer * bufsize + bufptr,
|
||||
buffer, need);
|
||||
|
||||
bufptr += need;
|
||||
buffer += need;
|
||||
bytes -= need;
|
||||
|
||||
if (bufptr == bufsize)
|
||||
{
|
||||
WaitForSingleObject(hEvent, 0); // Clear out ready state.
|
||||
while (buffers == max_buffers - 1)
|
||||
WaitForSingleObject(hEvent, INFINITE);
|
||||
|
||||
XAUDIO2_BUFFER xa2buffer = {0};
|
||||
xa2buffer.AudioBytes = bufsize;
|
||||
xa2buffer.pAudioData = buf + write_buffer * bufsize;
|
||||
xa2buffer.pContext = 0;
|
||||
if (FAILED(pSourceVoice->SubmitSourceBuffer(&xa2buffer)))
|
||||
return 0;
|
||||
|
||||
InterlockedIncrement(&buffers);
|
||||
bufptr = 0;
|
||||
write_buffer = (write_buffer + 1) & (max_buffers_mask);
|
||||
}
|
||||
}
|
||||
|
||||
return bytes_;
|
||||
}
|
||||
|
||||
enum { max_buffers = 16, max_buffers_mask = max_buffers - 1 };
|
||||
|
||||
STDMETHOD_(void, OnBufferStart) (void *) {}
|
||||
STDMETHOD_(void, OnBufferEnd) (void *)
|
||||
{
|
||||
InterlockedDecrement(&buffers);
|
||||
SetEvent(hEvent);
|
||||
}
|
||||
STDMETHOD_(void, OnLoopEnd) (void *) {}
|
||||
STDMETHOD_(void, OnStreamEnd) () {}
|
||||
STDMETHOD_(void, OnVoiceError) (void *, HRESULT) {}
|
||||
STDMETHOD_(void, OnVoiceProcessingPassEnd) () {}
|
||||
STDMETHOD_(void, OnVoiceProcessingPassStart) (UINT32) {}
|
||||
|
||||
uint8_t *buf;
|
||||
IXAudio2 *pXAudio2;
|
||||
IXAudio2MasteringVoice *pMasterVoice;
|
||||
IXAudio2SourceVoice *pSourceVoice;
|
||||
HANDLE hEvent;
|
||||
|
||||
volatile long buffers;
|
||||
unsigned bufsize;
|
||||
unsigned bufptr;
|
||||
unsigned write_buffer;
|
||||
};
|
||||
|
||||
xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels, size_t size)
|
||||
{
|
||||
xaudio2 *handle = 0;
|
||||
try {
|
||||
handle = new xaudio2(samplerate, channels, size);
|
||||
} catch(...) { delete handle; return 0; }
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
size_t xaudio2_write_avail(xaudio2_t *handle)
|
||||
{
|
||||
try {
|
||||
return handle->write_avail();
|
||||
} catch(...) { return 0; }
|
||||
}
|
||||
|
||||
size_t xaudio2_write(xaudio2_t *handle, const void *buf, size_t bytes)
|
||||
{
|
||||
try {
|
||||
return handle->write(buf, bytes);
|
||||
} catch(...) { return 0; }
|
||||
}
|
||||
|
||||
void xaudio2_free(xaudio2_t *handle)
|
||||
{
|
||||
delete handle;
|
||||
}
|
||||
|
||||
Executable → Regular
+53
-151
@@ -1,35 +1,37 @@
|
||||
/*
|
||||
xaudio2.hpp (2010-08-14)
|
||||
author: OV2
|
||||
xaudio.h (2010-08-14) / (2012-12-04)
|
||||
authors: OV2, Themaister
|
||||
*/
|
||||
|
||||
// Kinda stripped down. Only contains the bare essentials used in SSNES.
|
||||
|
||||
#ifndef XAUDIO2_MINGW_H
|
||||
#define XAUDIO2_MINGW_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define CINTERFACE
|
||||
#endif
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#undef min
|
||||
#undef max
|
||||
#include <basetyps.h>
|
||||
#include <objbase.h>
|
||||
#include <mmreg.h>
|
||||
|
||||
// 64-bit GCC fix
|
||||
#define GUID_EXT EXTERN_C
|
||||
#define GUID_SECT
|
||||
|
||||
#define DEFINE_GUID_X(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) GUID_EXT const GUID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
|
||||
#define DEFINE_GUID_X(n, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
||||
static const GUID n = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
|
||||
#define DEFINE_CLSID_X(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
||||
DEFINE_GUID_X(CLSID_##className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8)
|
||||
#define DEFINE_IID_X(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
||||
DEFINE_GUID_X(IID_##interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8)
|
||||
#define X2DEFAULT(x) =x
|
||||
#define X2DEFAULT(x)
|
||||
|
||||
DEFINE_CLSID_X(XAudio2, e21a7345, eb21, 468e, be, 50, 80, 4d, b9, 7c, f7, 08);
|
||||
DEFINE_CLSID_X(XAudio2_Debug, f7a76c21, 53d4, 46bb, ac, 53, 8b, 45, 9c, ae, 46, bd);
|
||||
DEFINE_IID_X(IXAudio2, 8bcf1f58, 9fe7, 4583, 8a, c6, e2, ad, c4, 65, c8, bb);
|
||||
|
||||
DECLARE_INTERFACE(IXAudio2Voice);
|
||||
#ifndef INTERFACE
|
||||
#define INTERFACE void
|
||||
#endif
|
||||
|
||||
#define XAUDIO2_COMMIT_NOW 0
|
||||
#define XAUDIO2_DEFAULT_CHANNELS 0
|
||||
@@ -46,95 +48,33 @@ typedef enum XAUDIO2_DEVICE_ROLE
|
||||
DefaultCommunicationsDevice = 0x4,
|
||||
DefaultGameDevice = 0x8,
|
||||
GlobalDefaultDevice = 0xf,
|
||||
InvalidDeviceRole = ~GlobalDefaultDevice
|
||||
InvalidDeviceRole = ~GlobalDefaultDevice
|
||||
} XAUDIO2_DEVICE_ROLE;
|
||||
|
||||
typedef struct XAUDIO2_DEVICE_DETAILS
|
||||
{
|
||||
WCHAR DeviceID[256];
|
||||
WCHAR DisplayName[256];
|
||||
XAUDIO2_DEVICE_ROLE Role;
|
||||
WAVEFORMATEXTENSIBLE OutputFormat;
|
||||
} XAUDIO2_DEVICE_DETAILS;
|
||||
|
||||
typedef struct XAUDIO2_VOICE_DETAILS
|
||||
{
|
||||
UINT32 CreationFlags;
|
||||
UINT32 InputChannels;
|
||||
UINT32 InputSampleRate;
|
||||
} XAUDIO2_VOICE_DETAILS;
|
||||
|
||||
typedef enum XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER
|
||||
{
|
||||
Processor1 = 0x00000001,
|
||||
Processor2 = 0x00000002,
|
||||
Processor3 = 0x00000004,
|
||||
Processor4 = 0x00000008,
|
||||
Processor5 = 0x00000010,
|
||||
Processor6 = 0x00000020,
|
||||
Processor7 = 0x00000040,
|
||||
Processor8 = 0x00000080,
|
||||
Processor9 = 0x00000100,
|
||||
Processor10 = 0x00000200,
|
||||
Processor11 = 0x00000400,
|
||||
Processor12 = 0x00000800,
|
||||
Processor13 = 0x00001000,
|
||||
Processor14 = 0x00002000,
|
||||
Processor15 = 0x00004000,
|
||||
Processor16 = 0x00008000,
|
||||
Processor17 = 0x00010000,
|
||||
Processor18 = 0x00020000,
|
||||
Processor19 = 0x00040000,
|
||||
Processor20 = 0x00080000,
|
||||
Processor21 = 0x00100000,
|
||||
Processor22 = 0x00200000,
|
||||
Processor23 = 0x00400000,
|
||||
Processor24 = 0x00800000,
|
||||
Processor25 = 0x01000000,
|
||||
Processor26 = 0x02000000,
|
||||
Processor27 = 0x04000000,
|
||||
Processor28 = 0x08000000,
|
||||
Processor29 = 0x10000000,
|
||||
Processor30 = 0x20000000,
|
||||
Processor31 = 0x40000000,
|
||||
Processor32 = 0x80000000,
|
||||
XAUDIO2_ANY_PROCESSOR = 0xffffffff,
|
||||
XAUDIO2_DEFAULT_PROCESSOR = XAUDIO2_ANY_PROCESSOR
|
||||
XAUDIO2_ANY_PROCESSOR = 0xffffffff,
|
||||
XAUDIO2_DEFAULT_PROCESSOR = XAUDIO2_ANY_PROCESSOR
|
||||
} XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER, XAUDIO2_PROCESSOR;
|
||||
|
||||
typedef struct XAUDIO2_VOICE_SENDS
|
||||
{
|
||||
UINT32 OutputCount;
|
||||
IXAudio2Voice** pOutputVoices;
|
||||
} XAUDIO2_VOICE_SENDS;
|
||||
|
||||
typedef struct XAUDIO2_EFFECT_DESCRIPTOR
|
||||
{
|
||||
IUnknown* pEffect;
|
||||
BOOL InitialState;
|
||||
UINT32 OutputChannels;
|
||||
} XAUDIO2_EFFECT_DESCRIPTOR;
|
||||
|
||||
typedef struct XAUDIO2_EFFECT_CHAIN
|
||||
{
|
||||
UINT32 EffectCount;
|
||||
const XAUDIO2_EFFECT_DESCRIPTOR* pEffectDescriptors;
|
||||
} XAUDIO2_EFFECT_CHAIN;
|
||||
|
||||
typedef enum XAUDIO2_FILTER_TYPE
|
||||
{
|
||||
typedef enum XAUDIO2_FILTER_TYPE {
|
||||
LowPassFilter,
|
||||
BandPassFilter,
|
||||
HighPassFilter
|
||||
HighPassFilter
|
||||
} XAUDIO2_FILTER_TYPE;
|
||||
|
||||
typedef struct XAUDIO2_FILTER_PARAMETERS
|
||||
{
|
||||
XAUDIO2_FILTER_TYPE Type;
|
||||
float Frequency;
|
||||
float OneOverQ;
|
||||
|
||||
} XAUDIO2_FILTER_PARAMETERS;
|
||||
typedef struct XAUDIO2_DEVICE_DETAILS XAUDIO2_DEVICE_DETAILS;
|
||||
typedef struct XAUDIO2_VOICE_DETAILS XAUDIO2_VOICE_DETAILS;
|
||||
typedef struct XAUDIO2_VOICE_SENDS XAUDIO2_VOICE_SENDS;
|
||||
typedef struct XAUDIO2_EFFECT_DESCRIPTOR XAUDIO2_EFFECT_DESCRIPTOR;
|
||||
typedef struct XAUDIO2_EFFECT_CHAIN XAUDIO2_EFFECT_CHAIN;
|
||||
typedef struct XAUDIO2_FILTER_PARAMETERS XAUDIO2_FILTER_PARAMETERS;
|
||||
typedef struct XAUDIO2_BUFFER_WMA XAUDIO2_BUFFER_WMA;
|
||||
typedef struct XAUDIO2_VOICE_STATE XAUDIO2_VOICE_STATE;
|
||||
typedef struct XAUDIO2_PERFORMANCE_DATA XAUDIO2_PERFORMANCE_DATA;
|
||||
typedef struct XAUDIO2_DEBUG_CONFIGURATION XAUDIO2_DEBUG_CONFIGURATION;
|
||||
typedef struct IXAudio2EngineCallback IXAudio2EngineCallback;
|
||||
typedef struct IXAudio2SubmixVoice IXAudio2SubmixVoice;
|
||||
|
||||
typedef struct XAUDIO2_BUFFER
|
||||
{
|
||||
@@ -149,53 +89,6 @@ typedef struct XAUDIO2_BUFFER
|
||||
void *pContext;
|
||||
} XAUDIO2_BUFFER;
|
||||
|
||||
typedef struct XAUDIO2_BUFFER_WMA
|
||||
{
|
||||
const UINT32* pDecodedPacketCumulativeBytes;
|
||||
UINT32 PacketCount;
|
||||
} XAUDIO2_BUFFER_WMA;
|
||||
|
||||
typedef struct XAUDIO2_VOICE_STATE
|
||||
{
|
||||
void *pCurrentBufferContext;
|
||||
UINT32 BuffersQueued;
|
||||
UINT64 SamplesPlayed;
|
||||
} XAUDIO2_VOICE_STATE;
|
||||
|
||||
typedef struct XAUDIO2_PERFORMANCE_DATA
|
||||
{
|
||||
UINT64 AudioCyclesSinceLastQuery;
|
||||
UINT64 TotalCyclesSinceLastQuery;
|
||||
UINT32 MinimumCyclesPerQuantum;
|
||||
UINT32 MaximumCyclesPerQuantum;
|
||||
UINT32 MemoryUsageInBytes;
|
||||
UINT32 CurrentLatencyInSamples;
|
||||
UINT32 GlitchesSinceEngineStarted;
|
||||
UINT32 ActiveSourceVoiceCount;
|
||||
UINT32 TotalSourceVoiceCount;
|
||||
UINT32 ActiveSubmixVoiceCount;
|
||||
UINT32 TotalSubmixVoiceCount;
|
||||
UINT32 ActiveXmaSourceVoices;
|
||||
UINT32 ActiveXmaStreams;
|
||||
} XAUDIO2_PERFORMANCE_DATA;
|
||||
|
||||
typedef struct XAUDIO2_DEBUG_CONFIGURATION
|
||||
{
|
||||
UINT32 TraceMask;
|
||||
UINT32 BreakMask;
|
||||
BOOL LogThreadID;
|
||||
BOOL LogFileline;
|
||||
BOOL LogFunctionName;
|
||||
BOOL LogTiming;
|
||||
} XAUDIO2_DEBUG_CONFIGURATION;
|
||||
|
||||
DECLARE_INTERFACE(IXAudio2EngineCallback)
|
||||
{
|
||||
STDMETHOD_(void, OnProcessingPassStart) (THIS) PURE;
|
||||
STDMETHOD_(void, OnProcessingPassEnd) (THIS) PURE;
|
||||
STDMETHOD_(void, OnCriticalError) (THIS_ HRESULT Error) PURE;
|
||||
};
|
||||
|
||||
DECLARE_INTERFACE(IXAudio2VoiceCallback)
|
||||
{
|
||||
STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired) PURE;
|
||||
@@ -245,17 +138,11 @@ DECLARE_INTERFACE(IXAudio2Voice)
|
||||
Declare_IXAudio2Voice_Methods();
|
||||
};
|
||||
|
||||
|
||||
DECLARE_INTERFACE_(IXAudio2MasteringVoice, IXAudio2Voice)
|
||||
{
|
||||
Declare_IXAudio2Voice_Methods();
|
||||
};
|
||||
|
||||
DECLARE_INTERFACE_(IXAudio2SubmixVoice, IXAudio2Voice)
|
||||
{
|
||||
Declare_IXAudio2Voice_Methods();
|
||||
};
|
||||
|
||||
DECLARE_INTERFACE_(IXAudio2SourceVoice, IXAudio2Voice)
|
||||
{
|
||||
Declare_IXAudio2Voice_Methods();
|
||||
@@ -307,20 +194,35 @@ DECLARE_INTERFACE_(IXAudio2, IUnknown)
|
||||
void *pReserved X2DEFAULT(NULL)) PURE;
|
||||
};
|
||||
|
||||
static inline HRESULT XAudio2Create(IXAudio2** ppXAudio2, UINT32 Flags X2DEFAULT(0),
|
||||
XAUDIO2_PROCESSOR XAudio2Processor X2DEFAULT(XAUDIO2_DEFAULT_PROCESSOR))
|
||||
// C hooks.
|
||||
#define IXAudio2_Initialize(THIS, a, b) (THIS)->lpVtbl->Initialize(THIS, a, b)
|
||||
#define IXAudio2_Release(THIS) (THIS)->lpVtbl->Release(THIS)
|
||||
#define IXAudio2_CreateSourceVoice(THIS, a, b, c, d, e, f, g) (THIS)->lpVtbl->CreateSourceVoice(THIS, a, b, c, d, e, f, g)
|
||||
#define IXAudio2_CreateMasteringVoice(THIS, a, b, c, d, e, f) (THIS)->lpVtbl->CreateMasteringVoice(THIS, a, b, c, d, e, f)
|
||||
|
||||
#define IXAudio2SourceVoice_Start(THIS, a, b) (THIS)->lpVtbl->Start(THIS, a, b)
|
||||
#define IXAudio2SourceVoice_Stop(THIS, a, b) (THIS)->lpVtbl->Stop(THIS, a, b)
|
||||
#define IXAudio2SourceVoice_SubmitSourceBuffer(THIS, a, b) (THIS)->lpVtbl->SubmitSourceBuffer(THIS, a, b)
|
||||
#define IXAudio2SourceVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS)
|
||||
#define IXAudio2MasteringVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS)
|
||||
|
||||
static inline HRESULT XAudio2Create(IXAudio2 **ppXAudio2)
|
||||
{
|
||||
IXAudio2* pXAudio2;
|
||||
HRESULT hr = CoCreateInstance((Flags & XAUDIO2_DEBUG_ENGINE) ? CLSID_XAudio2_Debug : CLSID_XAudio2,
|
||||
NULL, CLSCTX_INPROC_SERVER, IID_IXAudio2, reinterpret_cast<void**>(&pXAudio2));
|
||||
IXAudio2 *pXAudio2;
|
||||
|
||||
#ifdef __cplusplus
|
||||
HRESULT hr = CoCreateInstance(CLSID_XAudio2, NULL, CLSCTX_INPROC_SERVER, IID_IXAudio2, (void**)&pXAudio2);
|
||||
#else
|
||||
HRESULT hr = CoCreateInstance(&CLSID_XAudio2, NULL, CLSCTX_INPROC_SERVER, &IID_IXAudio2, (void**)&pXAudio2);
|
||||
#endif
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = pXAudio2->Initialize(Flags, XAudio2Processor);
|
||||
hr = IXAudio2_Initialize(pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR);
|
||||
if (SUCCEEDED(hr))
|
||||
*ppXAudio2 = pXAudio2;
|
||||
else
|
||||
pXAudio2->Release();
|
||||
IXAudio2_Release(pXAudio2);
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
+19
-18
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -15,10 +15,10 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
#include "../driver.h"
|
||||
#include <stdlib.h>
|
||||
#include "xaudio-c/xaudio-c.h"
|
||||
#include "general.h"
|
||||
#include "../general.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -31,8 +31,8 @@ static void *xa_init(const char *device, unsigned rate, unsigned latency)
|
||||
if (latency < 8)
|
||||
latency = 8; // Do not allow shenanigans.
|
||||
|
||||
xa_t *xa = calloc(1, sizeof(xa_t));
|
||||
if (xa == NULL)
|
||||
xa_t *xa = (xa_t*)calloc(1, sizeof(*xa));
|
||||
if (!xa)
|
||||
return NULL;
|
||||
|
||||
size_t bufsize = latency * rate / 1000;
|
||||
@@ -46,12 +46,13 @@ static void *xa_init(const char *device, unsigned rate, unsigned latency)
|
||||
free(xa);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return xa;
|
||||
}
|
||||
|
||||
static ssize_t xa_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
xa_t *xa = data;
|
||||
xa_t *xa = (xa_t*)data;
|
||||
if (xa->nonblock)
|
||||
{
|
||||
size_t avail = xaudio2_write_avail(xa->xa);
|
||||
@@ -60,8 +61,9 @@ static ssize_t xa_write(void *data, const void *buf, size_t size)
|
||||
if (avail < size)
|
||||
size = avail;
|
||||
}
|
||||
|
||||
size_t ret = xaudio2_write(xa->xa, buf, size);
|
||||
if (ret == 0)
|
||||
if (ret == 0 && size > 0)
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
@@ -74,7 +76,7 @@ static bool xa_stop(void *data)
|
||||
|
||||
static void xa_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
xa_t *xa = data;
|
||||
xa_t *xa = (xa_t*)data;
|
||||
xa->nonblock = state;
|
||||
}
|
||||
|
||||
@@ -92,7 +94,7 @@ static bool xa_use_float(void *data)
|
||||
|
||||
static void xa_free(void *data)
|
||||
{
|
||||
xa_t *xa = data;
|
||||
xa_t *xa = (xa_t*)data;
|
||||
if (xa)
|
||||
{
|
||||
if (xa->xa)
|
||||
@@ -102,13 +104,12 @@ static void xa_free(void *data)
|
||||
}
|
||||
|
||||
const audio_driver_t audio_xa = {
|
||||
.init = xa_init,
|
||||
.write = xa_write,
|
||||
.stop = xa_stop,
|
||||
.start = xa_start,
|
||||
.set_nonblock_state = xa_set_nonblock_state,
|
||||
.use_float = xa_use_float,
|
||||
.free = xa_free,
|
||||
.ident = "xaudio"
|
||||
xa_init,
|
||||
xa_write,
|
||||
xa_stop,
|
||||
xa_start,
|
||||
xa_set_nonblock_state,
|
||||
xa_free,
|
||||
xa_use_float,
|
||||
"xaudio"
|
||||
};
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "autosave.h"
|
||||
#include "thread.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include "boolean.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "general.h"
|
||||
@@ -41,7 +41,7 @@ struct autosave
|
||||
|
||||
static void autosave_thread(void *data)
|
||||
{
|
||||
autosave_t *save = data;
|
||||
autosave_t *save = (autosave_t*)data;
|
||||
|
||||
bool first_log = true;
|
||||
|
||||
@@ -86,7 +86,7 @@ static void autosave_thread(void *data)
|
||||
|
||||
autosave_t *autosave_new(const char *path, const void *data, size_t size, unsigned interval)
|
||||
{
|
||||
autosave_t *handle = calloc(1, sizeof(*handle));
|
||||
autosave_t *handle = (autosave_t*)calloc(1, sizeof(*handle));
|
||||
if (!handle)
|
||||
return NULL;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __SSNES_BOOLEAN_H
|
||||
#define __SSNES_BOOLEAN_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -18,7 +18,8 @@
|
||||
#include "bps.h"
|
||||
#include "movie.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "boolean.h"
|
||||
#include "msvc/msvc_compat.h"
|
||||
|
||||
enum bps_mode
|
||||
{
|
||||
@@ -77,17 +78,15 @@ bps_error_t bps_apply_patch(
|
||||
if (modify_length < 19)
|
||||
return BPS_PATCH_TOO_SMALL;
|
||||
|
||||
struct bps_data bps = {
|
||||
.modify_data = modify_data,
|
||||
.modify_length = modify_length,
|
||||
.target_data = target_data,
|
||||
.target_length = *target_length,
|
||||
.source_data = source_data,
|
||||
.source_length = source_length,
|
||||
|
||||
.modify_checksum = ~0,
|
||||
.target_checksum = ~0,
|
||||
};
|
||||
struct bps_data bps = {0};
|
||||
bps.modify_data = modify_data;
|
||||
bps.modify_length = modify_length;
|
||||
bps.target_data = target_data;
|
||||
bps.target_length = *target_length;
|
||||
bps.source_data = source_data;
|
||||
bps.source_length = source_length;
|
||||
bps.modify_checksum = ~0;
|
||||
bps.target_checksum = ~0;
|
||||
|
||||
if ((bps_read(&bps) != 'B') || (bps_read(&bps) != 'P') || (bps_read(&bps) != 'S') || (bps_read(&bps) != '1'))
|
||||
return BPS_PATCH_INVALID_HEADER;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -57,7 +57,7 @@ static char *strcat_alloc(char *dest, const char *input)
|
||||
size_t input_len = strlen(input);
|
||||
size_t required_len = dest_len + input_len + 1;
|
||||
|
||||
char *output = realloc(dest, required_len);
|
||||
char *output = (char*)realloc(dest, required_len);
|
||||
if (!output)
|
||||
return NULL;
|
||||
|
||||
@@ -126,7 +126,7 @@ static bool xml_grab_cheats(cheat_manager_t *handle, xmlNodePtr ptr)
|
||||
if (handle->size == handle->buf_size)
|
||||
{
|
||||
handle->buf_size *= 2;
|
||||
handle->cheats = realloc(handle->cheats, handle->buf_size * sizeof(struct cheat));
|
||||
handle->cheats = (struct cheat*)realloc(handle->cheats, handle->buf_size * sizeof(struct cheat));
|
||||
if (!handle->cheats)
|
||||
return false;
|
||||
}
|
||||
@@ -242,12 +242,15 @@ cheat_manager_t* cheat_manager_new(const char *path)
|
||||
|
||||
xmlParserCtxtPtr ctx = NULL;
|
||||
xmlDocPtr doc = NULL;
|
||||
cheat_manager_t *handle = calloc(1, sizeof(struct cheat_manager));
|
||||
cheat_manager_t *handle = (cheat_manager_t*)calloc(1, sizeof(struct cheat_manager));
|
||||
if (!handle)
|
||||
return NULL;
|
||||
|
||||
xmlNodePtr head = NULL;
|
||||
xmlNodePtr cur = NULL;
|
||||
|
||||
handle->buf_size = 1;
|
||||
handle->cheats = calloc(handle->buf_size, sizeof(struct cheat));
|
||||
handle->cheats = (struct cheat*)calloc(handle->buf_size, sizeof(struct cheat));
|
||||
if (!handle->cheats)
|
||||
{
|
||||
handle->buf_size = 0;
|
||||
@@ -271,8 +274,7 @@ cheat_manager_t* cheat_manager_new(const char *path)
|
||||
goto error;
|
||||
}
|
||||
|
||||
xmlNodePtr head = xmlDocGetRootElement(doc);
|
||||
xmlNodePtr cur = NULL;
|
||||
head = xmlDocGetRootElement(doc);
|
||||
for (cur = head; cur; cur = cur->next)
|
||||
{
|
||||
if (cur->type == XML_ELEMENT_NODE && strcmp((const char*)cur->name, "database") == 0)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
|
||||
+86
-41
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -22,20 +22,24 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include "strl.h"
|
||||
#include "../strl.h"
|
||||
#include "../posix_string.h"
|
||||
#include "../msvc/msvc_compat.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <sys/param.h> // MAXPATHLEN
|
||||
#else
|
||||
#if !defined(_WIN32) && !defined(__CELLOS_LV2__) && !defined(_XBOX)
|
||||
#include <sys/param.h> // PATH_MAX
|
||||
#elif defined(_WIN32) && !defined(_XBOX)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#elif defined(_XBOX)
|
||||
#include <xtl.h>
|
||||
#endif
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#ifndef PATH_MAX
|
||||
#ifdef PATH_MAX
|
||||
#define MAXPATHLEN PATH_MAX
|
||||
#define PATH_MAX PATH_MAX
|
||||
#else
|
||||
#define MAXPATHLEN 512
|
||||
#define PATH_MAX 512
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -69,7 +73,7 @@ static config_file_t *config_file_new_internal(const char *path, unsigned depth)
|
||||
|
||||
static char *getaline(FILE *file)
|
||||
{
|
||||
char *newline = malloc(9);
|
||||
char *newline = (char*)malloc(9);
|
||||
size_t cur_size = 8;
|
||||
size_t index = 0;
|
||||
|
||||
@@ -79,7 +83,7 @@ static char *getaline(FILE *file)
|
||||
if (index == cur_size)
|
||||
{
|
||||
cur_size *= 2;
|
||||
newline = realloc(newline, cur_size + 1);
|
||||
newline = (char*)realloc(newline, cur_size + 1);
|
||||
}
|
||||
|
||||
newline[index++] = in;
|
||||
@@ -98,7 +102,7 @@ static char *extract_value(char *line, bool is_value)
|
||||
|
||||
// If we don't have an equal sign here, we've got an invalid string...
|
||||
if (*line != '=')
|
||||
return false;
|
||||
return NULL;
|
||||
|
||||
line++;
|
||||
}
|
||||
@@ -112,7 +116,7 @@ static char *extract_value(char *line, bool is_value)
|
||||
line++;
|
||||
char *tok = strtok(line, "\"");
|
||||
if (!tok)
|
||||
return false;
|
||||
return NULL;
|
||||
return strdup(tok);
|
||||
}
|
||||
else if (*line == '\0') // Nothing :(
|
||||
@@ -171,7 +175,7 @@ static void add_child_list(config_file_t *parent, config_file_t *child)
|
||||
static void add_include_list(config_file_t *conf, const char *path)
|
||||
{
|
||||
struct include_list *head = conf->includes;
|
||||
struct include_list *node = calloc(1, sizeof(*node));
|
||||
struct include_list *node = (struct include_list*)calloc(1, sizeof(*node));
|
||||
node->path = strdup(path);
|
||||
|
||||
if (head)
|
||||
@@ -193,19 +197,42 @@ static void add_sub_conf(config_file_t *conf, char *line)
|
||||
|
||||
add_include_list(conf, path);
|
||||
|
||||
char real_path[MAXPATHLEN];
|
||||
char real_path[PATH_MAX];
|
||||
|
||||
#ifndef _WIN32
|
||||
if (*path == '/')
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// Accomodate POSIX systems on Win32.
|
||||
bool is_full_path = *path == '/';
|
||||
|
||||
if (is_full_path)
|
||||
strlcpy(real_path, path, sizeof(real_path));
|
||||
else
|
||||
{
|
||||
// Workaround GetFullPathName not existing on XDK.
|
||||
// : is not a valid element in a path name. (NTFS streams?)
|
||||
if (strchr(path, ':') == NULL)
|
||||
{
|
||||
strlcpy(real_path, conf->path, sizeof(real_path));
|
||||
char *split = strrchr(real_path, '/');
|
||||
if (!split)
|
||||
split = strrchr(real_path, '\\');
|
||||
|
||||
split[1] = '\0';
|
||||
strlcat(real_path, path, sizeof(real_path));
|
||||
}
|
||||
else
|
||||
strlcpy(real_path, path, sizeof(real_path));
|
||||
}
|
||||
#else
|
||||
if (*path == '/')
|
||||
strlcpy(real_path, path, sizeof(real_path));
|
||||
#ifndef __CELLOS_LV2__
|
||||
else if (*path == '~')
|
||||
{
|
||||
const char *home = getenv("HOME");
|
||||
strlcpy(real_path, home ? home : "/", sizeof(real_path));
|
||||
strlcat(real_path, path + 1, sizeof(real_path));
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
strlcpy(real_path, conf->path, sizeof(real_path));
|
||||
@@ -218,25 +245,6 @@ static void add_sub_conf(config_file_t *conf, char *line)
|
||||
else
|
||||
strlcpy(real_path, path, sizeof(real_path));
|
||||
}
|
||||
#else
|
||||
// Accomodate POSIX systems on Win32.
|
||||
bool is_full_path = *path == '/';
|
||||
|
||||
if (is_full_path)
|
||||
strlcpy(real_path, path, sizeof(real_path));
|
||||
else
|
||||
GetFullPathNameA(path, sizeof(real_path), real_path, NULL);
|
||||
|
||||
if (strcmp(path, real_path) != 0)
|
||||
{
|
||||
strlcpy(real_path, conf->path, sizeof(real_path));
|
||||
char *split = strrchr(real_path, '/');
|
||||
if (!split)
|
||||
split = strrchr(real_path, '\\');
|
||||
|
||||
split[1] = '\0';
|
||||
strlcat(real_path, path, sizeof(real_path));
|
||||
}
|
||||
#endif
|
||||
|
||||
config_file_t *sub_conf = config_file_new_internal(real_path, conf->include_depth + 1);
|
||||
@@ -276,7 +284,7 @@ static bool parse_line(config_file_t *conf, struct entry_list *list, char *line)
|
||||
while (isspace(*line))
|
||||
line++;
|
||||
|
||||
char *key = malloc(9);
|
||||
char *key = (char*)malloc(9);
|
||||
size_t cur_size = 8;
|
||||
size_t index = 0;
|
||||
|
||||
@@ -285,7 +293,7 @@ static bool parse_line(config_file_t *conf, struct entry_list *list, char *line)
|
||||
if (index == cur_size)
|
||||
{
|
||||
cur_size *= 2;
|
||||
key = realloc(key, cur_size + 1);
|
||||
key = (char*)realloc(key, cur_size + 1);
|
||||
}
|
||||
|
||||
key[index++] = *line++;
|
||||
@@ -306,7 +314,7 @@ static bool parse_line(config_file_t *conf, struct entry_list *list, char *line)
|
||||
|
||||
static config_file_t *config_file_new_internal(const char *path, unsigned depth)
|
||||
{
|
||||
struct config_file *conf = calloc(1, sizeof(*conf));
|
||||
struct config_file *conf = (struct config_file*)calloc(1, sizeof(*conf));
|
||||
if (!conf)
|
||||
return NULL;
|
||||
|
||||
@@ -332,7 +340,7 @@ static config_file_t *config_file_new_internal(const char *path, unsigned depth)
|
||||
|
||||
while (!feof(file))
|
||||
{
|
||||
struct entry_list *list = calloc(1, sizeof(*list));
|
||||
struct entry_list *list = (struct entry_list*)calloc(1, sizeof(*list));
|
||||
char *line = getaline(file);
|
||||
|
||||
if (line)
|
||||
@@ -411,6 +419,22 @@ bool config_get_double(config_file_t *conf, const char *key, double *in)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool config_get_float(config_file_t *conf, const char *key, float *in)
|
||||
{
|
||||
struct entry_list *list = conf->entries;
|
||||
|
||||
while (list)
|
||||
{
|
||||
if (strcmp(key, list->key) == 0)
|
||||
{
|
||||
*in = (float)strtod(list->value, NULL);
|
||||
return true;
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool config_get_int(config_file_t *conf, const char *key, int *in)
|
||||
{
|
||||
struct entry_list *list = conf->entries;
|
||||
@@ -434,6 +458,23 @@ bool config_get_int(config_file_t *conf, const char *key, int *in)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool config_get_uint(config_file_t *conf, const char *key, unsigned *in)
|
||||
{
|
||||
struct entry_list *list = conf->entries;
|
||||
|
||||
while (list != NULL)
|
||||
{
|
||||
if (strcmp(key, list->key) == 0)
|
||||
{
|
||||
*in = strtol(list->value, NULL, 0);
|
||||
return true;
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool config_get_hex(config_file_t *conf, const char *key, unsigned *in)
|
||||
{
|
||||
struct entry_list *list = conf->entries;
|
||||
@@ -550,7 +591,7 @@ void config_set_string(config_file_t *conf, const char *key, const char *val)
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
struct entry_list *elem = calloc(1, sizeof(*elem));
|
||||
struct entry_list *elem = (struct entry_list*)calloc(1, sizeof(*elem));
|
||||
elem->key = strdup(key);
|
||||
elem->value = strdup(val);
|
||||
|
||||
@@ -563,7 +604,11 @@ void config_set_string(config_file_t *conf, const char *key, const char *val)
|
||||
void config_set_double(config_file_t *conf, const char *key, double val)
|
||||
{
|
||||
char buf[128];
|
||||
#ifdef __cplusplus
|
||||
snprintf(buf, sizeof(buf), "%f", (float)val);
|
||||
#else
|
||||
snprintf(buf, sizeof(buf), "%lf", val);
|
||||
#endif
|
||||
config_set_string(conf, key, buf);
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -20,7 +20,7 @@
|
||||
#define __CONFIG_FILE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -49,8 +49,12 @@ bool config_entry_exists(config_file_t *conf, const char *entry);
|
||||
|
||||
// Extracts a double from config file.
|
||||
bool config_get_double(config_file_t *conf, const char *entry, double *in);
|
||||
// Extracts a float from config file.
|
||||
bool config_get_float(config_file_t *conf, const char *entry, float *in);
|
||||
// Extracts an int from config file.
|
||||
bool config_get_int(config_file_t *conf, const char *entry, int *in);
|
||||
// Extracts an uint from config file.
|
||||
bool config_get_uint(config_file_t *conf, const char *entry, unsigned *in);
|
||||
// Extracts an int from config file. (Hexadecimal)
|
||||
bool config_get_hex(config_file_t *conf, const char *entry, unsigned *in);
|
||||
// Extracts a single char. If value consists of several chars, this is an error.
|
||||
|
||||
+46
-5
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef __CONFIG_DEF_H
|
||||
#define __CONFIG_DEF_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "boolean.h"
|
||||
#include "libsnes.hpp"
|
||||
#include "driver.h"
|
||||
|
||||
@@ -37,6 +37,9 @@
|
||||
#define VIDEO_XVIDEO 11
|
||||
#define VIDEO_SDL 13
|
||||
#define VIDEO_EXT 14
|
||||
#define VIDEO_WII 24
|
||||
#define VIDEO_XENON360 25
|
||||
#define VIDEO_XDK360 28
|
||||
////////////////////////
|
||||
#define AUDIO_RSOUND 1
|
||||
#define AUDIO_OSS 2
|
||||
@@ -50,13 +53,27 @@
|
||||
#define AUDIO_EXT 15
|
||||
#define AUDIO_DSOUND 16
|
||||
#define AUDIO_COREAUDIO 17
|
||||
#define AUDIO_PS3 18
|
||||
#define AUDIO_XENON360 20
|
||||
#define AUDIO_WII 22
|
||||
#define AUDIO_XDK360 27
|
||||
////////////////////////
|
||||
#define INPUT_SDL 7
|
||||
#define INPUT_X 12
|
||||
#define INPUT_PS3 19
|
||||
#define INPUT_XENON360 21
|
||||
#define INPUT_WII 23
|
||||
#define INPUT_XDK360 26
|
||||
////////////////////////
|
||||
|
||||
#if defined(HAVE_OPENGL)
|
||||
#if defined(HAVE_OPENGL) || defined(__CELLOS_LV2__)
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_GL
|
||||
#elif defined(GEKKO)
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_WII
|
||||
#elif defined(XENON)
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_XENON360
|
||||
#elif defined(_XBOX)
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_XDK360
|
||||
#elif defined(HAVE_XVIDEO)
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_XVIDEO
|
||||
#elif defined(HAVE_SDL)
|
||||
@@ -67,7 +84,15 @@
|
||||
#error "Need at least one video driver!"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_ALSA)
|
||||
#if defined(__CELLOS_LV2__)
|
||||
#define AUDIO_DEFAULT_DRIVER AUDIO_PS3
|
||||
#elif defined(XENON)
|
||||
#define AUDIO_DEFAULT_DRIVER AUDIO_XENON360
|
||||
#elif defined(_XBOX)
|
||||
#define AUDIO_DEFAULT_DRIVER AUDIO_XDK360
|
||||
#elif defined(GEKKO)
|
||||
#define AUDIO_DEFAULT_DRIVER AUDIO_WII
|
||||
#elif defined(HAVE_ALSA)
|
||||
#define AUDIO_DEFAULT_DRIVER AUDIO_ALSA
|
||||
#elif defined(HAVE_PULSE)
|
||||
#define AUDIO_DEFAULT_DRIVER AUDIO_PULSE
|
||||
@@ -95,8 +120,16 @@
|
||||
#error "Need at least one audio driver!"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SDL)
|
||||
#if defined(XENON)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_XENON360
|
||||
#elif defined(_XBOX)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_XDK360
|
||||
#elif defined(HAVE_SDL)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_SDL
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_PS3
|
||||
#elif defined(GEKKO)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_WII
|
||||
#elif defined(HAVE_XVIDEO)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_X
|
||||
#else
|
||||
@@ -137,6 +170,9 @@ static const bool crop_overscan = true;
|
||||
|
||||
// Font size for on-screen messages.
|
||||
static const unsigned font_size = 48;
|
||||
// Attempt to scale the font size.
|
||||
// The scale factor will be window_size / desktop_size.
|
||||
static const bool font_scale = true;
|
||||
|
||||
// Offset for where messages will be placed on-screen. Values are in range [0.0, 1.0].
|
||||
static const float message_pos_offset_x = 0.05;
|
||||
@@ -167,7 +203,11 @@ static const bool font_enable = true;
|
||||
// This value should stay close to 60Hz to avoid large pitch changes.
|
||||
// If your monitor does not run at 60Hz, or something close to it, disable VSync,
|
||||
// and leave this at its default.
|
||||
#if defined(__CELLOS_LV2__) || defined(XENON) || defined(GEKKO)
|
||||
static const float refresh_rate = 59.92;
|
||||
#else
|
||||
static const float refresh_rate = 59.95;
|
||||
#endif
|
||||
|
||||
////////////////
|
||||
// Audio
|
||||
@@ -267,6 +307,7 @@ static const struct snes_keybind snes_keybinds_1[] = {
|
||||
{ SSNES_CHEAT_TOGGLE, SK_u, NO_BTN, AXIS_NONE },
|
||||
{ SSNES_SCREENSHOT, SK_PRINT, NO_BTN, AXIS_NONE },
|
||||
{ SSNES_DSP_CONFIG, SK_c, NO_BTN, AXIS_NONE },
|
||||
{ SSNES_MUTE, SK_F9, NO_BTN, AXIS_NONE },
|
||||
{ -1 }
|
||||
};
|
||||
|
||||
|
||||
+13
-1
@@ -2,7 +2,7 @@
|
||||
#define __SSNES_FEATURES_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "boolean.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
@@ -14,6 +14,12 @@ static const bool _sdl_supp = true;
|
||||
static const bool _sdl_supp = false;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
static const bool _thread_supp = true;
|
||||
#else
|
||||
static const bool _thread_supp = false;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
static const bool _opengl_supp = true;
|
||||
#else
|
||||
@@ -68,6 +74,12 @@ static const bool _pulse_supp = true;
|
||||
static const bool _pulse_supp = false;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
static const bool _dsound_supp = true;
|
||||
#else
|
||||
static const bool _dsound_supp = false;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XAUDIO
|
||||
static const bool _xaudio_supp = true;
|
||||
#else
|
||||
|
||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 192 KiB |
+118
@@ -0,0 +1,118 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "list.h"
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct sgui_file
|
||||
{
|
||||
char *path;
|
||||
sgui_file_type_t type;
|
||||
};
|
||||
|
||||
struct sgui_list
|
||||
{
|
||||
struct sgui_file *list;
|
||||
|
||||
size_t capacity;
|
||||
size_t ptr;
|
||||
};
|
||||
|
||||
sgui_list_t *sgui_list_new(void)
|
||||
{
|
||||
return (sgui_list_t*)calloc(1, sizeof(sgui_list_t));
|
||||
}
|
||||
|
||||
bool sgui_list_empty(const sgui_list_t *list)
|
||||
{
|
||||
return list->ptr == 0;
|
||||
}
|
||||
|
||||
void sgui_list_push(sgui_list_t *list, const char *path, sgui_file_type_t type)
|
||||
{
|
||||
if (list->ptr >= list->capacity)
|
||||
{
|
||||
list->capacity++;
|
||||
list->capacity *= 2;
|
||||
list->list = (struct sgui_file*)realloc(list->list, list->capacity * sizeof(struct sgui_file));
|
||||
}
|
||||
|
||||
list->list[list->ptr].path = strdup(path);
|
||||
list->list[list->ptr].type = type;
|
||||
list->ptr++;
|
||||
}
|
||||
|
||||
void sgui_list_pop(sgui_list_t *list)
|
||||
{
|
||||
if (!sgui_list_empty(list))
|
||||
free(list->list[--list->ptr].path);
|
||||
}
|
||||
|
||||
void sgui_list_free(sgui_list_t *list)
|
||||
{
|
||||
for (size_t i = 0; i < list->ptr; i++)
|
||||
free(list->list[i].path);
|
||||
free(list->list);
|
||||
free(list);
|
||||
}
|
||||
|
||||
void sgui_list_clear(sgui_list_t *list)
|
||||
{
|
||||
for (size_t i = 0; i < list->ptr; i++)
|
||||
free(list->list[i].path);
|
||||
list->ptr = 0;
|
||||
}
|
||||
|
||||
void sgui_list_back(const sgui_list_t *list,
|
||||
const char **path, sgui_file_type_t *file_type)
|
||||
{
|
||||
if (sgui_list_size(list) > 0)
|
||||
sgui_list_at(list, sgui_list_size(list) - 1, path, file_type);
|
||||
}
|
||||
|
||||
size_t sgui_list_size(const sgui_list_t *list)
|
||||
{
|
||||
return list->ptr;
|
||||
}
|
||||
|
||||
void sgui_list_at(const sgui_list_t *list, size_t index,
|
||||
const char **path, sgui_file_type_t *file_type)
|
||||
{
|
||||
if (path)
|
||||
*path = list->list[index].path;
|
||||
if (file_type)
|
||||
*file_type = list->list[index].type;
|
||||
}
|
||||
|
||||
static int list_comp(const void *a_, const void *b_)
|
||||
{
|
||||
const struct sgui_file *a = (const struct sgui_file*)a_;
|
||||
const struct sgui_file *b = (const struct sgui_file*)b_;
|
||||
|
||||
if (a->type != b->type)
|
||||
return a->type == SGUI_FILE_DIRECTORY ? -1 : 1;
|
||||
|
||||
return strcmp(a->path, b->path);
|
||||
}
|
||||
|
||||
void sgui_list_sort(sgui_list_t *list)
|
||||
{
|
||||
qsort(list->list, list->ptr, sizeof(struct sgui_file), list_comp);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SGUI_LIST_H__
|
||||
#define SGUI_LIST_H__
|
||||
|
||||
#include "sgui.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct sgui_list sgui_list_t;
|
||||
|
||||
sgui_list_t *sgui_list_new(void);
|
||||
void sgui_list_free(sgui_list_t *list);
|
||||
|
||||
void sgui_list_push(sgui_list_t *list, const char *path, sgui_file_type_t type);
|
||||
void sgui_list_pop(sgui_list_t *list);
|
||||
void sgui_list_clear(sgui_list_t *list);
|
||||
|
||||
bool sgui_list_empty(const sgui_list_t *list);
|
||||
void sgui_list_back(const sgui_list_t *list,
|
||||
const char **path, sgui_file_type_t *type);
|
||||
|
||||
size_t sgui_list_size(const sgui_list_t *list);
|
||||
void sgui_list_at(const sgui_list_t *list, size_t index,
|
||||
const char **path, sgui_file_type_t *type);
|
||||
|
||||
void sgui_list_sort(sgui_list_t *list);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+314
@@ -0,0 +1,314 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "sgui.h"
|
||||
#include "list.h"
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define FONT_WIDTH 5
|
||||
#define FONT_HEIGHT 10
|
||||
#define FONT_WIDTH_STRIDE (FONT_WIDTH + 1)
|
||||
#define FONT_HEIGHT_STRIDE (FONT_HEIGHT + 1)
|
||||
|
||||
#define TERM_WIDTH (((SGUI_WIDTH - 30) / (FONT_WIDTH_STRIDE)))
|
||||
#define TERM_HEIGHT (((SGUI_HEIGHT - 30) / (FONT_HEIGHT_STRIDE)))
|
||||
#define TERM_START_X 15
|
||||
#define TERM_START_Y 15
|
||||
|
||||
struct sgui_handle
|
||||
{
|
||||
uint16_t *frame_buf;
|
||||
size_t frame_buf_pitch;
|
||||
const uint8_t *font_buf;
|
||||
|
||||
sgui_folder_enum_cb_t folder_cb;
|
||||
void *userdata;
|
||||
|
||||
sgui_list_t *path_stack;
|
||||
sgui_list_t *folder_buf;
|
||||
size_t directory_ptr;
|
||||
bool need_refresh;
|
||||
|
||||
char path_buf[PATH_MAX];
|
||||
|
||||
uint16_t font_white[256][FONT_HEIGHT][FONT_WIDTH];
|
||||
uint16_t font_green[256][FONT_HEIGHT][FONT_WIDTH];
|
||||
};
|
||||
|
||||
static void copy_glyph(uint16_t glyph_white[FONT_HEIGHT][FONT_WIDTH],
|
||||
uint16_t glyph_green[FONT_HEIGHT][FONT_WIDTH],
|
||||
const uint8_t *buf)
|
||||
{
|
||||
for (int y = 0; y < FONT_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < FONT_WIDTH; x++)
|
||||
{
|
||||
uint32_t col =
|
||||
((uint32_t)buf[3 * (-y * 256 + x) + 0] << 0) |
|
||||
((uint32_t)buf[3 * (-y * 256 + x) + 1] << 8) |
|
||||
((uint32_t)buf[3 * (-y * 256 + x) + 2] << 16);
|
||||
|
||||
glyph_white[y][x] = col == 0xff ? 0 : 0x7fff;
|
||||
glyph_green[y][x] = col == 0xff ? 0 : (5 << 10) | (20 << 5) | (5 << 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void init_font(sgui_handle_t *sgui, const char *path)
|
||||
{
|
||||
for (unsigned i = 0; i < 256; i++)
|
||||
{
|
||||
unsigned y = i / 16;
|
||||
unsigned x = i % 16;
|
||||
copy_glyph(sgui->font_white[i],
|
||||
sgui->font_green[i],
|
||||
sgui->font_buf + 54 + 3 * (256 * (255 - 16 * y) + 16 * x));
|
||||
}
|
||||
}
|
||||
|
||||
sgui_handle_t *sgui_init(const char *base_path,
|
||||
uint16_t *buf, size_t buf_pitch,
|
||||
const uint8_t *font_buf,
|
||||
sgui_folder_enum_cb_t folder_cb, void *userdata)
|
||||
{
|
||||
sgui_handle_t *sgui = (sgui_handle_t*)calloc(1, sizeof(*sgui));
|
||||
|
||||
sgui->frame_buf = buf;
|
||||
sgui->frame_buf_pitch = buf_pitch;
|
||||
sgui->font_buf = font_buf;
|
||||
|
||||
sgui->folder_cb = folder_cb;
|
||||
sgui->userdata = userdata;
|
||||
|
||||
sgui->path_stack = sgui_list_new();
|
||||
sgui->folder_buf = sgui_list_new();
|
||||
sgui_list_push(sgui->path_stack, base_path, SGUI_FILE_DIRECTORY);
|
||||
|
||||
init_font(sgui, "font.bmp");
|
||||
|
||||
return sgui;
|
||||
}
|
||||
|
||||
void sgui_free(sgui_handle_t *sgui)
|
||||
{
|
||||
sgui_list_free(sgui->path_stack);
|
||||
sgui_list_free(sgui->folder_buf);
|
||||
free(sgui);
|
||||
}
|
||||
|
||||
static uint16_t gray_filler(unsigned x, unsigned y)
|
||||
{
|
||||
x >>= 1;
|
||||
y >>= 1;
|
||||
uint16_t col = ((x + y) & 1) + 1;
|
||||
col <<= 1;
|
||||
return (col << 0) | (col << 5) | (col << 10);
|
||||
}
|
||||
|
||||
static uint16_t green_filler(unsigned x, unsigned y)
|
||||
{
|
||||
x >>= 1;
|
||||
y >>= 1;
|
||||
uint16_t col = ((x + y) & 1) + 1;
|
||||
col <<= 1;
|
||||
return (col << 0) | (col << 6) | (col << 10);
|
||||
}
|
||||
|
||||
static void fill_rect(uint16_t *buf, unsigned pitch,
|
||||
unsigned x, unsigned y,
|
||||
unsigned width, unsigned height,
|
||||
uint16_t (*col)(unsigned x, unsigned y))
|
||||
{
|
||||
for (unsigned j = y; j < y + height; j++)
|
||||
for (unsigned i = x; i < x + width; i++)
|
||||
buf[j * (pitch >> 1) + i] = col(i, j);
|
||||
}
|
||||
|
||||
static void blit_line(sgui_handle_t *sgui,
|
||||
unsigned x, unsigned y, const char *message, bool green)
|
||||
{
|
||||
while (*message)
|
||||
{
|
||||
for (unsigned j = 0; j < FONT_HEIGHT; j++)
|
||||
{
|
||||
for (unsigned i = 0; i < FONT_WIDTH; i++)
|
||||
{
|
||||
uint16_t col = green ?
|
||||
sgui->font_green[(unsigned char)*message][j][i] :
|
||||
sgui->font_white[(unsigned char)*message][j][i];
|
||||
|
||||
if (col)
|
||||
sgui->frame_buf[(y + j) * (sgui->frame_buf_pitch >> 1) + (x + i)] = col;
|
||||
}
|
||||
}
|
||||
|
||||
x += FONT_WIDTH_STRIDE;
|
||||
message++;
|
||||
}
|
||||
}
|
||||
|
||||
static void render_text(sgui_handle_t *sgui, size_t begin, size_t end)
|
||||
{
|
||||
fill_rect(sgui->frame_buf, sgui->frame_buf_pitch,
|
||||
0, 0, SGUI_WIDTH, SGUI_HEIGHT, gray_filler);
|
||||
|
||||
fill_rect(sgui->frame_buf, sgui->frame_buf_pitch,
|
||||
5, 5, SGUI_WIDTH - 10, 5, green_filler);
|
||||
|
||||
fill_rect(sgui->frame_buf, sgui->frame_buf_pitch,
|
||||
5, SGUI_HEIGHT - 10, SGUI_WIDTH - 10, 5, green_filler);
|
||||
|
||||
fill_rect(sgui->frame_buf, sgui->frame_buf_pitch,
|
||||
5, 5, 5, SGUI_HEIGHT - 10, green_filler);
|
||||
|
||||
fill_rect(sgui->frame_buf, sgui->frame_buf_pitch,
|
||||
SGUI_WIDTH - 10, 5, 5, SGUI_HEIGHT - 10, green_filler);
|
||||
|
||||
unsigned x = TERM_START_X;
|
||||
unsigned y = TERM_START_Y;
|
||||
|
||||
for (size_t i = begin; i < end; i++, y += FONT_HEIGHT_STRIDE)
|
||||
{
|
||||
const char *path;
|
||||
sgui_file_type_t type;
|
||||
sgui_list_at(sgui->folder_buf, i, &path, &type);
|
||||
|
||||
char message[TERM_WIDTH + 1];
|
||||
snprintf(message, sizeof(message), "%c %-*s %6s\n",
|
||||
i == sgui->directory_ptr ? '>' : ' ',
|
||||
TERM_WIDTH - (6 + 1 + 2),
|
||||
path,
|
||||
type == SGUI_FILE_PLAIN ? "(FILE)" : "(DIR)");
|
||||
|
||||
blit_line(sgui, x, y, message, i == sgui->directory_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
const char *sgui_iterate(sgui_handle_t *sgui, sgui_action_t action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case SGUI_ACTION_UP:
|
||||
if (sgui->directory_ptr > 0)
|
||||
sgui->directory_ptr--;
|
||||
break;
|
||||
|
||||
case SGUI_ACTION_DOWN:
|
||||
if (sgui->directory_ptr + 1 < sgui_list_size(sgui->folder_buf))
|
||||
sgui->directory_ptr++;
|
||||
break;
|
||||
|
||||
case SGUI_ACTION_LEFT:
|
||||
case SGUI_ACTION_CANCEL:
|
||||
if (sgui_list_size(sgui->path_stack) > 1)
|
||||
{
|
||||
sgui_list_pop(sgui->path_stack);
|
||||
sgui->need_refresh = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SGUI_ACTION_RIGHT:
|
||||
case SGUI_ACTION_OK:
|
||||
{
|
||||
if (sgui_list_size(sgui->folder_buf) == 0)
|
||||
return NULL;
|
||||
|
||||
const char *path = NULL;
|
||||
sgui_file_type_t type = SGUI_FILE_PLAIN;
|
||||
sgui_list_at(sgui->folder_buf, sgui->directory_ptr,
|
||||
&path, &type);
|
||||
|
||||
const char *dir;
|
||||
sgui_list_back(sgui->path_stack, &dir, NULL);
|
||||
|
||||
if (type == SGUI_FILE_DIRECTORY)
|
||||
{
|
||||
char cat_path[PATH_MAX];
|
||||
snprintf(cat_path, sizeof(cat_path), "%s/%s",
|
||||
strcmp(dir, "/") == 0 ? "" : dir, path);
|
||||
|
||||
sgui_list_push(sgui->path_stack, cat_path, SGUI_FILE_DIRECTORY);
|
||||
sgui->need_refresh = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(sgui->path_buf, sizeof(sgui->path_buf), "%s/%s",
|
||||
strcmp(dir, "/") == 0 ? "" : dir, path);
|
||||
return sgui->path_buf;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SGUI_ACTION_REFRESH:
|
||||
sgui->need_refresh = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sgui->need_refresh)
|
||||
{
|
||||
sgui->directory_ptr = 0;
|
||||
sgui_list_clear(sgui->folder_buf);
|
||||
|
||||
const char *path = NULL;
|
||||
sgui_list_back(sgui->path_stack, &path, NULL);
|
||||
|
||||
if (!sgui->folder_cb(path,
|
||||
(sgui_file_enum_cb_t)sgui_list_push,
|
||||
sgui->userdata, sgui->folder_buf))
|
||||
return NULL;
|
||||
|
||||
sgui_list_sort(sgui->folder_buf);
|
||||
|
||||
sgui->need_refresh = false;
|
||||
}
|
||||
|
||||
size_t begin = sgui->directory_ptr >= TERM_HEIGHT / 2 ?
|
||||
sgui->directory_ptr - TERM_HEIGHT / 2 : 0;
|
||||
size_t end = sgui->directory_ptr + TERM_HEIGHT <= sgui_list_size(sgui->folder_buf) ?
|
||||
sgui->directory_ptr + TERM_HEIGHT : sgui_list_size(sgui->folder_buf);
|
||||
|
||||
if (end - begin > TERM_HEIGHT)
|
||||
end = begin + TERM_HEIGHT;
|
||||
|
||||
#if 0
|
||||
printf("========================================\n");
|
||||
for (size_t i = begin; i < end; i++)
|
||||
{
|
||||
const char *path;
|
||||
sgui_file_type_t type;
|
||||
sgui_list_at(sgui->folder_buf, i, &path, &type);
|
||||
|
||||
printf("%c %-50s %s\n",
|
||||
i == sgui->directory_ptr ? '>' : ' ',
|
||||
path,
|
||||
type == SGUI_FILE_PLAIN ? "(FILE)" : "(DIR)");
|
||||
|
||||
}
|
||||
printf("========================================\n");
|
||||
#endif
|
||||
|
||||
render_text(sgui, begin, end);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SGUI_H__
|
||||
#define SGUI_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SGUI_FILE_PLAIN,
|
||||
SGUI_FILE_DIRECTORY
|
||||
} sgui_file_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SGUI_ACTION_UP,
|
||||
SGUI_ACTION_DOWN,
|
||||
SGUI_ACTION_LEFT,
|
||||
SGUI_ACTION_RIGHT,
|
||||
SGUI_ACTION_OK,
|
||||
SGUI_ACTION_CANCEL,
|
||||
SGUI_ACTION_REFRESH,
|
||||
SGUI_ACTION_NOOP
|
||||
} sgui_action_t;
|
||||
|
||||
typedef struct sgui_handle sgui_handle_t;
|
||||
|
||||
typedef void (*sgui_file_enum_cb_t)(void *ctx, const char *path,
|
||||
sgui_file_type_t file_type);
|
||||
typedef bool (*sgui_folder_enum_cb_t)(const char *directory,
|
||||
sgui_file_enum_cb_t file_cb, void *userdata, void *ctx);
|
||||
|
||||
#define SGUI_WIDTH 320
|
||||
#define SGUI_HEIGHT 240
|
||||
|
||||
sgui_handle_t *sgui_init(const char *base_path,
|
||||
uint16_t *framebuf, size_t framebuf_pitch,
|
||||
const uint8_t *font_buf,
|
||||
sgui_folder_enum_cb_t folder_cb, void *userdata);
|
||||
|
||||
const char *sgui_iterate(sgui_handle_t *sgui, sgui_action_t action);
|
||||
|
||||
void sgui_free(sgui_handle_t *sgui);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+10
-1
@@ -124,7 +124,7 @@ Connects a four-way multitap into port 2 of the SNES. This allows for up to 5 pl
|
||||
.TP
|
||||
\fB--record PATH, -r PATH\fR
|
||||
Activates video recording of gameplay into PATH. Using .mkv extension is recommended.
|
||||
Codecs used are FFV1/FLAC, suitable for processing the material further.
|
||||
Codecs used are (FFV1 or H264 RGB lossless (x264))/FLAC, suitable for processing the material further.
|
||||
|
||||
.TP
|
||||
\fB--size WIDTHxHEIGHT\fR
|
||||
@@ -168,6 +168,15 @@ Set FRAMES to 0 to have perfect sync. 0 frames is only suitable for LAN. Default
|
||||
\fB--port PORT\fR
|
||||
Network port used for netplay. This defaults to 55435. This option affects both TCP and UDP.
|
||||
|
||||
.TP
|
||||
\fB--spectate\fR
|
||||
If netplay is used, it will go into a spectator mode.
|
||||
Spectator mode allows one host to live stream game playback to multiple clients.
|
||||
Essentially, clients receive a live streamed BSV movie file.
|
||||
Clients can connect and disconnect at any time.
|
||||
Clients thus cannot interact as player 2.
|
||||
For spectating mode to work, both host and clients will need to use this flag.
|
||||
|
||||
.TP
|
||||
\fB--ups PATCH, -U PATCH\fR
|
||||
Attempts to apply an UPS patch to the current ROM image. No files are altered.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -21,8 +21,8 @@
|
||||
#include "file.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include "posix_string.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
@@ -65,12 +65,30 @@ static const audio_driver_t *audio_drivers[] = {
|
||||
#ifdef HAVE_DYLIB
|
||||
&audio_ext,
|
||||
#endif
|
||||
#ifdef __CELLOS_LV2__
|
||||
&audio_ps3,
|
||||
#endif
|
||||
#ifdef XENON
|
||||
&audio_xenon360,
|
||||
#endif
|
||||
#ifdef _XBOX
|
||||
&audio_xdk360,
|
||||
#endif
|
||||
#ifdef GEKKO
|
||||
&audio_wii,
|
||||
#endif
|
||||
};
|
||||
|
||||
static const video_driver_t *video_drivers[] = {
|
||||
#ifdef HAVE_OPENGL
|
||||
&video_gl,
|
||||
#endif
|
||||
#ifdef XENON
|
||||
&video_xenon360,
|
||||
#endif
|
||||
#ifdef _XBOX
|
||||
&video_xdk360,
|
||||
#endif
|
||||
#ifdef HAVE_SDL
|
||||
&video_sdl,
|
||||
#endif
|
||||
@@ -80,15 +98,30 @@ static const video_driver_t *video_drivers[] = {
|
||||
#ifdef HAVE_DYLIB
|
||||
&video_ext,
|
||||
#endif
|
||||
#ifdef GEKKO
|
||||
&video_wii,
|
||||
#endif
|
||||
};
|
||||
|
||||
static const input_driver_t *input_drivers[] = {
|
||||
#ifdef __CELLOS_LV2__
|
||||
&input_ps3,
|
||||
#endif
|
||||
#ifdef HAVE_SDL
|
||||
&input_sdl,
|
||||
#endif
|
||||
#ifdef HAVE_XVIDEO
|
||||
&input_x,
|
||||
#endif
|
||||
#ifdef XENON
|
||||
&input_xenon360,
|
||||
#endif
|
||||
#ifdef _XBOX
|
||||
&input_xdk360,
|
||||
#endif
|
||||
#ifdef GEKKO
|
||||
&input_wii,
|
||||
#endif
|
||||
};
|
||||
|
||||
static void find_audio_driver(void)
|
||||
@@ -103,10 +136,10 @@ static void find_audio_driver(void)
|
||||
}
|
||||
SSNES_ERR("Couldn't find any audio driver named \"%s\"\n", g_settings.audio.driver);
|
||||
fprintf(stderr, "Available audio drivers are:\n");
|
||||
for (unsigned i = 0; i < sizeof(audio_drivers) / sizeof(audio_driver_t*); i++)
|
||||
for (size_t i = 0; i < sizeof(audio_drivers) / sizeof(audio_driver_t*); i++)
|
||||
fprintf(stderr, "\t%s\n", audio_drivers[i]->ident);
|
||||
|
||||
exit(1);
|
||||
ssnes_fail(1, "find_audio_driver()");
|
||||
}
|
||||
|
||||
static void find_video_driver(void)
|
||||
@@ -121,10 +154,10 @@ static void find_video_driver(void)
|
||||
}
|
||||
SSNES_ERR("Couldn't find any video driver named \"%s\"\n", g_settings.video.driver);
|
||||
fprintf(stderr, "Available video drivers are:\n");
|
||||
for (int i = 0; i < sizeof(video_drivers) / sizeof(video_driver_t*); i++)
|
||||
for (size_t i = 0; i < sizeof(video_drivers) / sizeof(video_driver_t*); i++)
|
||||
fprintf(stderr, "\t%s\n", video_drivers[i]->ident);
|
||||
|
||||
exit(1);
|
||||
ssnes_fail(1, "find_video_driver()");
|
||||
}
|
||||
|
||||
static void find_input_driver(void)
|
||||
@@ -139,10 +172,10 @@ static void find_input_driver(void)
|
||||
}
|
||||
SSNES_ERR("Couldn't find any input driver named \"%s\"\n", g_settings.input.driver);
|
||||
fprintf(stderr, "Available input drivers are:\n");
|
||||
for (int i = 0; i < sizeof(input_drivers) / sizeof(input_driver_t*); i++)
|
||||
for (size_t i = 0; i < sizeof(input_drivers) / sizeof(input_driver_t*); i++)
|
||||
fprintf(stderr, "\t%s\n", input_drivers[i]->ident);
|
||||
|
||||
exit(1);
|
||||
ssnes_fail(1, "find_input_driver()");
|
||||
}
|
||||
|
||||
void init_drivers(void)
|
||||
@@ -153,14 +186,16 @@ void init_drivers(void)
|
||||
|
||||
void uninit_drivers(void)
|
||||
{
|
||||
uninit_video_input();
|
||||
uninit_audio();
|
||||
uninit_video_input();
|
||||
}
|
||||
|
||||
#ifdef HAVE_DYLIB
|
||||
static void init_dsp_plugin(void)
|
||||
{
|
||||
if (!(*g_settings.audio.dsp_plugin))
|
||||
return;
|
||||
ssnes_dsp_info_t info = {0};
|
||||
|
||||
g_extern.audio_data.dsp_lib = dylib_load(g_settings.audio.dsp_plugin);
|
||||
if (!g_extern.audio_data.dsp_lib)
|
||||
@@ -169,7 +204,7 @@ static void init_dsp_plugin(void)
|
||||
return;
|
||||
}
|
||||
|
||||
const ssnes_dsp_plugin_t* (*SSNES_API_CALLTYPE plugin_init)(void) =
|
||||
const ssnes_dsp_plugin_t* (SSNES_API_CALLTYPE *plugin_init)(void) =
|
||||
(const ssnes_dsp_plugin_t *(SSNES_API_CALLTYPE*)(void))dylib_proc(g_extern.audio_data.dsp_lib, "ssnes_dsp_plugin_init");
|
||||
if (!plugin_init)
|
||||
{
|
||||
@@ -192,10 +227,8 @@ static void init_dsp_plugin(void)
|
||||
|
||||
SSNES_LOG("Loaded DSP plugin: \"%s\"\n", g_extern.audio_data.dsp_plugin->ident ? g_extern.audio_data.dsp_plugin->ident : "Unknown");
|
||||
|
||||
const ssnes_dsp_info_t info = {
|
||||
.input_rate = g_settings.audio.in_rate,
|
||||
.output_rate = g_settings.audio.out_rate
|
||||
};
|
||||
info.input_rate = g_settings.audio.in_rate;
|
||||
info.output_rate = g_settings.audio.out_rate;
|
||||
|
||||
g_extern.audio_data.dsp_handle = g_extern.audio_data.dsp_plugin->init(&info);
|
||||
if (!g_extern.audio_data.dsp_handle)
|
||||
@@ -221,6 +254,7 @@ static void deinit_dsp_plugin(void)
|
||||
dylib_close(g_extern.audio_data.dsp_lib);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void adjust_audio_input_rate(void)
|
||||
{
|
||||
@@ -233,9 +267,9 @@ static void adjust_audio_input_rate(void)
|
||||
float timing_skew = fabs(1.0f - g_extern.system.timing.fps / g_settings.video.refresh_rate);
|
||||
if (timing_skew > 0.05f) // We don't want to adjust pitch too much. If we have extreme cases, just don't readjust at all.
|
||||
{
|
||||
SSNES_LOG("Timings deviate too much. Will not adjust. (Display = %.2f Hz, Game = %.2lf Hz)\n",
|
||||
SSNES_LOG("Timings deviate too much. Will not adjust. (Display = %.2f Hz, Game = %.2f Hz)\n",
|
||||
g_settings.video.refresh_rate,
|
||||
g_extern.system.timing.fps);
|
||||
(float)g_extern.system.timing.fps);
|
||||
|
||||
g_settings.video.refresh_rate = g_extern.system.timing.fps;
|
||||
}
|
||||
@@ -256,20 +290,20 @@ static void adjust_audio_input_rate(void)
|
||||
first = false;
|
||||
}
|
||||
|
||||
#define AUDIO_CHUNK_SIZE_BLOCKING 64
|
||||
#define AUDIO_CHUNK_SIZE_NONBLOCKING 2048 // So we don't get complete line-noise when fast-forwarding audio.
|
||||
#define AUDIO_MAX_RATIO 16
|
||||
void init_audio(void)
|
||||
{
|
||||
// Accomodate rewind since at some point we might have two full buffers.
|
||||
size_t max_bufsamples = AUDIO_CHUNK_SIZE_NONBLOCKING * 2;
|
||||
|
||||
// Used for recording even if audio isn't enabled.
|
||||
assert((g_extern.audio_data.conv_outsamples = malloc(max_bufsamples * sizeof(int16_t) * AUDIO_MAX_RATIO)));
|
||||
ssnes_assert(g_extern.audio_data.conv_outsamples = (int16_t*)malloc(max_bufsamples * sizeof(int16_t) * AUDIO_MAX_RATIO));
|
||||
|
||||
g_extern.audio_data.block_chunk_size = AUDIO_CHUNK_SIZE_BLOCKING;
|
||||
g_extern.audio_data.nonblock_chunk_size = AUDIO_CHUNK_SIZE_NONBLOCKING;
|
||||
g_extern.audio_data.chunk_size = g_extern.audio_data.block_chunk_size;
|
||||
|
||||
// Needs to be able to hold full content of a full max_bufsamples in addition to its own.
|
||||
assert((g_extern.audio_data.rewind_buf = malloc(max_bufsamples * sizeof(int16_t))));
|
||||
ssnes_assert(g_extern.audio_data.rewind_buf = (int16_t*)malloc(max_bufsamples * sizeof(int16_t)));
|
||||
g_extern.audio_data.rewind_size = max_bufsamples;
|
||||
|
||||
if (!g_settings.audio.enable)
|
||||
@@ -281,9 +315,6 @@ void init_audio(void)
|
||||
adjust_audio_input_rate();
|
||||
find_audio_driver();
|
||||
|
||||
g_extern.audio_data.block_chunk_size = AUDIO_CHUNK_SIZE_BLOCKING;
|
||||
g_extern.audio_data.nonblock_chunk_size = AUDIO_CHUNK_SIZE_NONBLOCKING;
|
||||
|
||||
driver.audio_data = driver.audio->init(*g_settings.audio.device ? g_settings.audio.device : NULL,
|
||||
g_settings.audio.out_rate, g_settings.audio.latency);
|
||||
|
||||
@@ -303,21 +334,26 @@ void init_audio(void)
|
||||
if (!g_extern.audio_data.source)
|
||||
g_extern.audio_active = false;
|
||||
|
||||
assert((g_extern.audio_data.data = malloc(max_bufsamples * sizeof(float))));
|
||||
ssnes_assert(g_extern.audio_data.data = (float*)malloc(max_bufsamples * sizeof(float)));
|
||||
g_extern.audio_data.data_ptr = 0;
|
||||
assert(g_settings.audio.out_rate < g_settings.audio.in_rate * AUDIO_MAX_RATIO);
|
||||
assert((g_extern.audio_data.outsamples = malloc(max_bufsamples * sizeof(float) * AUDIO_MAX_RATIO)));
|
||||
|
||||
ssnes_assert(g_settings.audio.out_rate < g_settings.audio.in_rate * AUDIO_MAX_RATIO);
|
||||
ssnes_assert(g_extern.audio_data.outsamples = (float*)malloc(max_bufsamples * sizeof(float) * AUDIO_MAX_RATIO));
|
||||
|
||||
g_extern.audio_data.src_ratio =
|
||||
(double)g_settings.audio.out_rate / g_settings.audio.in_rate;
|
||||
|
||||
#ifdef HAVE_DYLIB
|
||||
init_dsp_plugin();
|
||||
#endif
|
||||
}
|
||||
|
||||
void uninit_audio(void)
|
||||
{
|
||||
free(g_extern.audio_data.conv_outsamples); g_extern.audio_data.conv_outsamples = NULL;
|
||||
free(g_extern.audio_data.conv_outsamples);
|
||||
g_extern.audio_data.conv_outsamples = NULL;
|
||||
g_extern.audio_data.data_ptr = 0;
|
||||
|
||||
free(g_extern.audio_data.rewind_buf);
|
||||
g_extern.audio_data.rewind_buf = NULL;
|
||||
|
||||
@@ -335,10 +371,13 @@ void uninit_audio(void)
|
||||
|
||||
free(g_extern.audio_data.data);
|
||||
g_extern.audio_data.data = NULL;
|
||||
|
||||
free(g_extern.audio_data.outsamples);
|
||||
g_extern.audio_data.outsamples = NULL;
|
||||
|
||||
#ifdef HAVE_DYLIB
|
||||
deinit_dsp_plugin();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_DYLIB
|
||||
@@ -377,17 +416,17 @@ static void init_filter(void)
|
||||
unsigned height = g_extern.system.geom.max_height;
|
||||
g_extern.filter.psize(&width, &height);
|
||||
|
||||
unsigned pow2_x = next_pow2(ceil(width));
|
||||
unsigned pow2_y = next_pow2(ceil(height));
|
||||
unsigned pow2_x = next_pow2(width);
|
||||
unsigned pow2_y = next_pow2(height);
|
||||
unsigned maxsize = pow2_x > pow2_y ? pow2_x : pow2_y;
|
||||
g_extern.filter.scale = maxsize / SSNES_SCALE_BASE;
|
||||
|
||||
g_extern.filter.buffer = malloc(SSNES_SCALE_BASE * SSNES_SCALE_BASE * g_extern.filter.scale * g_extern.filter.scale * sizeof(uint32_t));
|
||||
g_extern.filter.buffer = (uint32_t*)malloc(SSNES_SCALE_BASE * SSNES_SCALE_BASE * g_extern.filter.scale * g_extern.filter.scale * sizeof(uint32_t));
|
||||
g_extern.filter.pitch = SSNES_SCALE_BASE * g_extern.filter.scale * sizeof(uint32_t);
|
||||
assert(g_extern.filter.buffer);
|
||||
ssnes_assert(g_extern.filter.buffer);
|
||||
|
||||
g_extern.filter.colormap = malloc(32768 * sizeof(uint32_t));
|
||||
assert(g_extern.filter.colormap);
|
||||
g_extern.filter.colormap = (uint32_t*)malloc(32768 * sizeof(uint32_t));
|
||||
ssnes_assert(g_extern.filter.colormap);
|
||||
|
||||
// Set up conversion map from 16-bit XRGB1555 to 32-bit ARGB.
|
||||
for (int i = 0; i < 32768; i++)
|
||||
@@ -402,7 +441,6 @@ static void init_filter(void)
|
||||
g_extern.filter.colormap[i] = (r << 16) | (g << 8) | (b << 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void deinit_filter(void)
|
||||
{
|
||||
@@ -415,6 +453,7 @@ static void deinit_filter(void)
|
||||
free(g_extern.filter.colormap);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XML
|
||||
static void init_shader_dir(void)
|
||||
@@ -494,16 +533,15 @@ void init_video_input(void)
|
||||
|
||||
SSNES_LOG("Video @ %ux%u\n", width, height);
|
||||
|
||||
video_info_t video = {
|
||||
.width = width,
|
||||
.height = height,
|
||||
.fullscreen = g_settings.video.fullscreen,
|
||||
.vsync = g_settings.video.vsync,
|
||||
.force_aspect = g_settings.video.force_aspect,
|
||||
.smooth = g_settings.video.smooth,
|
||||
.input_scale = scale,
|
||||
.rgb32 = g_extern.filter.active
|
||||
};
|
||||
video_info_t video = {0};
|
||||
video.width = width;
|
||||
video.height = height;
|
||||
video.fullscreen = g_settings.video.fullscreen;
|
||||
video.vsync = g_settings.video.vsync;
|
||||
video.force_aspect = g_settings.video.force_aspect;
|
||||
video.smooth = g_settings.video.smooth;
|
||||
video.input_scale = scale;
|
||||
video.rgb32 = g_extern.filter.active;
|
||||
|
||||
const input_driver_t *tmp = driver.input;
|
||||
driver.video_data = driver.video->init(&video, &driver.input, &driver.input_data);
|
||||
@@ -511,7 +549,7 @@ void init_video_input(void)
|
||||
if (driver.video_data == NULL)
|
||||
{
|
||||
SSNES_ERR("Cannot open video driver ... Exiting ...\n");
|
||||
exit(1);
|
||||
ssnes_fail(1, "init_video_input()");
|
||||
}
|
||||
|
||||
// Video driver didn't provide an input driver so we use configured one.
|
||||
@@ -524,13 +562,13 @@ void init_video_input(void)
|
||||
if (driver.input_data == NULL)
|
||||
{
|
||||
SSNES_ERR("Cannot init input driver. Exiting ...\n");
|
||||
exit(1);
|
||||
ssnes_fail(1, "init_video_input()");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SSNES_ERR("Cannot find input driver. Exiting ...\n");
|
||||
exit(1);
|
||||
ssnes_fail(1, "init_video_input()");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -543,7 +581,9 @@ void uninit_video_input(void)
|
||||
if (driver.video_data && driver.video)
|
||||
driver.video->free(driver.video_data);
|
||||
|
||||
#ifdef HAVE_DYLIB
|
||||
deinit_filter();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XML
|
||||
deinit_shader_dir();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -20,12 +20,16 @@
|
||||
#define __DRIVER__H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdbool.h>
|
||||
#include "boolean.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include "msvc/msvc_compat.h"
|
||||
#include "input/keysym.h"
|
||||
|
||||
#define AUDIO_CHUNK_SIZE_BLOCKING 64
|
||||
#define AUDIO_CHUNK_SIZE_NONBLOCKING 2048 // So we don't get complete line-noise when fast-forwarding audio.
|
||||
#define AUDIO_MAX_RATIO 16
|
||||
|
||||
// SNES has 12 buttons from 0-11 (libsnes.hpp)
|
||||
#define SSNES_FIRST_META_KEY 12
|
||||
enum
|
||||
@@ -52,11 +56,18 @@ enum
|
||||
SSNES_CHEAT_TOGGLE,
|
||||
SSNES_SCREENSHOT,
|
||||
SSNES_DSP_CONFIG,
|
||||
SSNES_MUTE,
|
||||
|
||||
#if defined(__CELLOS_LV2__) || defined(XENON) || defined(_XBOX)
|
||||
SSNES_CHEAT_INPUT,
|
||||
SSNES_INGAME_MENU,
|
||||
SSNES_EXIT_TO_MENU,
|
||||
SSNES_SRAM_WRITE_PROTECT,
|
||||
#endif
|
||||
|
||||
SSNES_BIND_LIST_END
|
||||
};
|
||||
|
||||
|
||||
struct snes_keybind
|
||||
{
|
||||
int id;
|
||||
@@ -89,14 +100,14 @@ typedef struct audio_driver
|
||||
const char *ident;
|
||||
} audio_driver_t;
|
||||
|
||||
#define AXIS_NEG(x) (((uint32_t)(x) << 16) | 0xFFFFU)
|
||||
#define AXIS_POS(x) ((uint32_t)(x) | 0xFFFF0000U)
|
||||
#define AXIS_NONE (0xFFFFFFFFU)
|
||||
#define AXIS_NEG(x) (((uint32_t)(x) << 16) | UINT16_C(0xFFFF))
|
||||
#define AXIS_POS(x) ((uint32_t)(x) | UINT32_C(0xFFFF0000))
|
||||
#define AXIS_NONE UINT32_C(0xFFFFFFFF)
|
||||
|
||||
#define AXIS_NEG_GET(x) (((uint32_t)(x) >> 16) & 0xFFFFU)
|
||||
#define AXIS_POS_GET(x) ((uint32_t)(x) & 0xFFFFU)
|
||||
#define AXIS_NEG_GET(x) (((uint32_t)(x) >> 16) & UINT16_C(0xFFFF))
|
||||
#define AXIS_POS_GET(x) ((uint32_t)(x) & UINT16_C(0xFFFF))
|
||||
|
||||
#define NO_BTN ((uint16_t)0xFFFFU) // I hope no joypad will ever have this many buttons ... ;)
|
||||
#define NO_BTN UINT16_C(0xFFFF) // I hope no joypad will ever have this many buttons ... ;)
|
||||
|
||||
#define HAT_UP_MASK (1 << 15)
|
||||
#define HAT_DOWN_MASK (1 << 14)
|
||||
@@ -132,7 +143,6 @@ typedef struct video_driver
|
||||
const char *ident;
|
||||
} video_driver_t;
|
||||
|
||||
|
||||
typedef struct driver
|
||||
{
|
||||
const audio_driver_t *audio;
|
||||
@@ -166,12 +176,23 @@ extern const audio_driver_t audio_pulse;
|
||||
extern const audio_driver_t audio_ext;
|
||||
extern const audio_driver_t audio_dsound;
|
||||
extern const audio_driver_t audio_coreaudio;
|
||||
extern const audio_driver_t audio_xenon360;
|
||||
extern const audio_driver_t audio_xdk360;
|
||||
extern const audio_driver_t audio_ps3;
|
||||
extern const audio_driver_t audio_wii;
|
||||
extern const video_driver_t video_gl;
|
||||
extern const video_driver_t video_wii;
|
||||
extern const video_driver_t video_xenon360;
|
||||
extern const video_driver_t video_xvideo;
|
||||
extern const video_driver_t video_xdk360;
|
||||
extern const video_driver_t video_sdl;
|
||||
extern const video_driver_t video_ext;
|
||||
extern const input_driver_t input_sdl;
|
||||
extern const input_driver_t input_x;
|
||||
extern const input_driver_t input_ps3;
|
||||
extern const input_driver_t input_xenon360;
|
||||
extern const input_driver_t input_wii;
|
||||
extern const input_driver_t input_xdk360;
|
||||
////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -19,32 +19,37 @@
|
||||
#include "general.h"
|
||||
#include "strl.h"
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <libsnes.hpp>
|
||||
#include "boolean.h"
|
||||
#include "libsnes.hpp"
|
||||
|
||||
#ifdef NEED_DYNAMIC
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
#ifdef NEED_DYNAMIC
|
||||
#define DLSYM(lib, x) dylib_proc(lib, #x)
|
||||
|
||||
#define SYM(type, x) do { \
|
||||
p##x = (type)DLSYM(lib_handle, x); \
|
||||
if (p##x == NULL) { SSNES_ERR("Failed to load symbol: \"%s\"\n", #x); exit(1); } \
|
||||
if (p##x == NULL) { SSNES_ERR("Failed to load symbol: \"%s\"\n", #x); ssnes_fail(1, "init_libsnes_sym()"); } \
|
||||
} while (0)
|
||||
|
||||
#define OPT_SYM(type, x) do { \
|
||||
p##x = (type)DLSYM(lib_handle, x); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
static dylib_t lib_handle = NULL;
|
||||
#endif
|
||||
|
||||
@@ -96,9 +101,10 @@ unsigned (*psnes_get_memory_size)(unsigned);
|
||||
void (*psnes_unload_cartridge)(void);
|
||||
void (*psnes_term)(void);
|
||||
|
||||
#ifdef HAVE_DYLIB
|
||||
#if defined(NEED_DYNAMIC) || defined(GEKKO) || defined(__CELLOS_LV2__) || defined(XENON)
|
||||
static void set_environment(void);
|
||||
#endif
|
||||
static void set_environment_defaults(void);
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
static void load_dynamic(void)
|
||||
@@ -108,7 +114,7 @@ static void load_dynamic(void)
|
||||
if (!lib_handle)
|
||||
{
|
||||
SSNES_ERR("Failed to open dynamic library: \"%s\"\n", g_settings.libsnes);
|
||||
exit(1);
|
||||
ssnes_fail(1, "load_dynamic()");
|
||||
}
|
||||
|
||||
SYM(void (*)(void), snes_init);
|
||||
@@ -144,13 +150,11 @@ static void load_dynamic(void)
|
||||
SYM(void (*)(void), snes_unload_cartridge);
|
||||
SYM(void (*)(void), snes_term);
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define SSYM(x) do { \
|
||||
p##x = x; \
|
||||
} while (0)
|
||||
|
||||
#ifndef HAVE_DYNAMIC
|
||||
static void set_statics(void)
|
||||
{
|
||||
SSYM(snes_init);
|
||||
@@ -183,14 +187,13 @@ static void set_statics(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
void init_dlsym(void)
|
||||
void init_libsnes_sym(void)
|
||||
{
|
||||
// Guarantee that we can do "dirty" casting.
|
||||
// Every OS that this program supports should pass this ...
|
||||
assert(sizeof(void*) == sizeof(void (*)(void)));
|
||||
ssnes_assert(sizeof(void*) == sizeof(void (*)(void)));
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
|
||||
// Try to verify that -lsnes was not linked in from other modules
|
||||
// since loading it dynamically and with -l will fail hard.
|
||||
function_t sym = dylib_proc(NULL, "snes_init");
|
||||
@@ -199,7 +202,7 @@ void init_dlsym(void)
|
||||
SSNES_ERR("Serious problem! SSNES wants to load libsnes dyamically, but it is already linked!\n");
|
||||
SSNES_ERR("This could happen if other modules SSNES depends on link against libsnes directly.\n");
|
||||
SSNES_ERR("Proceeding could cause a crash! Aborting ...\n");
|
||||
exit(1);
|
||||
ssnes_fail(1, "init_libsnes_sym()");
|
||||
}
|
||||
|
||||
if (!*g_settings.libsnes)
|
||||
@@ -218,12 +221,13 @@ void init_dlsym(void)
|
||||
set_statics();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DYLIB
|
||||
set_environment_defaults();
|
||||
#if defined(NEED_DYNAMIC) || defined(GEKKO) || defined(__CELLOS_LV2__) || defined(XENON)
|
||||
set_environment();
|
||||
#endif
|
||||
}
|
||||
|
||||
void uninit_dlsym(void)
|
||||
void uninit_libsnes_sym(void)
|
||||
{
|
||||
#ifdef HAVE_DYNAMIC
|
||||
if (lib_handle)
|
||||
@@ -231,6 +235,7 @@ void uninit_dlsym(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef NEED_DYNAMIC
|
||||
// Platform independent dylib loading.
|
||||
dylib_t dylib_load(const char *path)
|
||||
{
|
||||
@@ -244,7 +249,7 @@ dylib_t dylib_load(const char *path)
|
||||
function_t dylib_proc(dylib_t lib, const char *proc)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
function_t sym = (function_t)GetProcAddress(lib ? lib : GetModuleHandle(NULL), proc);
|
||||
function_t sym = (function_t)GetProcAddress(lib ? (HMODULE)lib : GetModuleHandle(NULL), proc);
|
||||
#else
|
||||
void *ptr_sym = NULL;
|
||||
if (lib)
|
||||
@@ -270,26 +275,28 @@ function_t dylib_proc(dylib_t lib, const char *proc)
|
||||
void dylib_close(dylib_t lib)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
FreeLibrary(lib);
|
||||
FreeLibrary((HMODULE)lib);
|
||||
#else
|
||||
dlclose(lib);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(NEED_DYNAMIC) || defined(GEKKO) || defined(__CELLOS_LV2__) || defined(XENON)
|
||||
static bool environment_cb(unsigned cmd, void *data)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case SNES_ENVIRONMENT_GET_FULLPATH:
|
||||
*(const char**)data = g_extern.system.fullpath;
|
||||
SSNES_LOG("FULLPATH: \"%s\"\n", g_extern.system.fullpath);
|
||||
SSNES_LOG("Environ FULLPATH: \"%s\"\n", g_extern.system.fullpath);
|
||||
break;
|
||||
|
||||
case SNES_ENVIRONMENT_SET_GEOMETRY:
|
||||
g_extern.system.geom = *(const struct snes_geometry*)data;
|
||||
g_extern.system.geom.max_width = next_pow2(g_extern.system.geom.max_width);
|
||||
g_extern.system.geom.max_height = next_pow2(g_extern.system.geom.max_height);
|
||||
SSNES_LOG("SET_GEOMETRY: (%ux%u) / (%ux%u)\n",
|
||||
SSNES_LOG("Environ SET_GEOMETRY: (%ux%u) / (%ux%u)\n",
|
||||
g_extern.system.geom.base_width,
|
||||
g_extern.system.geom.base_height,
|
||||
g_extern.system.geom.max_width,
|
||||
@@ -298,43 +305,46 @@ static bool environment_cb(unsigned cmd, void *data)
|
||||
|
||||
case SNES_ENVIRONMENT_SET_PITCH:
|
||||
g_extern.system.pitch = *(const unsigned*)data;
|
||||
SSNES_LOG("SET_PITCH: %u\n", g_extern.system.pitch);
|
||||
SSNES_LOG("Environ SET_PITCH: %u\n", g_extern.system.pitch);
|
||||
break;
|
||||
|
||||
case SNES_ENVIRONMENT_GET_OVERSCAN:
|
||||
*(bool*)data = !g_settings.video.crop_overscan;
|
||||
SSNES_LOG("GET_OVERSCAN: %u\n", (unsigned)!g_settings.video.crop_overscan);
|
||||
SSNES_LOG("Environ GET_OVERSCAN: %u\n", (unsigned)!g_settings.video.crop_overscan);
|
||||
break;
|
||||
|
||||
case SNES_ENVIRONMENT_SET_TIMING:
|
||||
g_extern.system.timing = *(const struct snes_system_timing*)data;
|
||||
g_extern.system.timing_set = true;
|
||||
SSNES_LOG("Environ SET_TIMING: %.3f Hz/ %.3f Hz\n",
|
||||
(float)g_extern.system.timing.fps, (float)g_extern.system.timing.sample_rate);
|
||||
break;
|
||||
|
||||
case SNES_ENVIRONMENT_GET_CAN_DUPE:
|
||||
*(bool*)data = true;
|
||||
SSNES_LOG("Environ GET_CAN_DUPE: true\n");
|
||||
break;
|
||||
|
||||
case SNES_ENVIRONMENT_SET_NEED_FULLPATH:
|
||||
g_extern.system.need_fullpath = *(const bool*)data;
|
||||
SSNES_LOG("Environ SET_NEED_FULLPATH: %s\n", g_extern.system.need_fullpath ? "true" : "false");
|
||||
break;
|
||||
|
||||
case SNES_ENVIRONMENT_GET_CAN_REWIND:
|
||||
*(bool*)data = g_settings.rewind_enable;
|
||||
SSNES_LOG("Environ GET_CAN_REWIND: %s\n", g_settings.rewind_enable ? "true" : "false");
|
||||
break;
|
||||
|
||||
default:
|
||||
SSNES_LOG("Environ UNSUPPORTED (#%u)!\n", cmd);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DYLIB
|
||||
// Assume SNES as defaults.
|
||||
static void set_environment_defaults(void)
|
||||
{
|
||||
g_extern.system.pitch = 0; // 0 is classic libsnes semantics.
|
||||
g_extern.system.geom = (struct snes_geometry) {
|
||||
.base_width = 256,
|
||||
.base_height = 224,
|
||||
.max_width = 512,
|
||||
.max_height = 512,
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef NEED_DYNAMIC
|
||||
// SSNES extension hooks. Totally optional 'n shizz :)
|
||||
static void set_environment(void)
|
||||
{
|
||||
@@ -349,9 +359,23 @@ static void set_environment(void)
|
||||
|
||||
if (psnes_set_environment)
|
||||
psnes_set_environment(environment_cb);
|
||||
|
||||
set_environment_defaults();
|
||||
}
|
||||
#elif defined(GEKKO) || defined(__CELLOS_LV2__) || defined(XENON)
|
||||
// Not very optional when we're running on a console without dynamic loading support.
|
||||
static void set_environment(void)
|
||||
{
|
||||
snes_set_environment(environment_cb);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Assume SNES as defaults.
|
||||
static void set_environment_defaults(void)
|
||||
{
|
||||
SSNES_LOG("Setting environment defaults (SNES)\n");
|
||||
g_extern.system.pitch = 0; // 0 is classic libsnes semantics.
|
||||
g_extern.system.geom.base_width = 256;
|
||||
g_extern.system.geom.base_height = 224;
|
||||
g_extern.system.geom.max_width = 512;
|
||||
g_extern.system.geom.max_height = 512;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -18,18 +18,30 @@
|
||||
#ifndef __DYNAMIC_H
|
||||
#define __DYNAMIC_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <libsnes.hpp>
|
||||
#include "boolean.h"
|
||||
#include "libsnes.hpp"
|
||||
|
||||
void init_dlsym(void);
|
||||
void uninit_dlsym(void);
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
|
||||
#define NEED_DYNAMIC
|
||||
#else
|
||||
#undef NEED_DYNAMIC
|
||||
#endif
|
||||
|
||||
void init_libsnes_sym(void);
|
||||
void uninit_libsnes_sym(void);
|
||||
|
||||
typedef void *dylib_t;
|
||||
#ifdef NEED_DYNAMIC
|
||||
typedef void (*function_t)(void);
|
||||
|
||||
dylib_t dylib_load(const char *path);
|
||||
void dylib_close(dylib_t lib);
|
||||
function_t dylib_proc(dylib_t lib, const char *proc);
|
||||
#endif
|
||||
|
||||
extern void (*psnes_init)(void);
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/* RSound - A PCM audio client/server
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* RSound is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
@@ -26,11 +26,11 @@ struct fifo_buffer
|
||||
|
||||
fifo_buffer_t *fifo_new(size_t size)
|
||||
{
|
||||
fifo_buffer_t *buf = calloc(1, sizeof(*buf));
|
||||
fifo_buffer_t *buf = (fifo_buffer_t*)calloc(1, sizeof(*buf));
|
||||
if (buf == NULL)
|
||||
return NULL;
|
||||
|
||||
buf->buffer = calloc(1, size + 1);
|
||||
buf->buffer = (uint8_t*)calloc(1, size + 1);
|
||||
if (buf->buffer == NULL)
|
||||
{
|
||||
free(buf);
|
||||
|
||||
+1
-2
@@ -1,5 +1,5 @@
|
||||
/* RSound - A PCM audio client/server
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* RSound is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
@@ -17,7 +17,6 @@
|
||||
#define __BUFFER_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -18,10 +18,9 @@
|
||||
#include "file.h"
|
||||
#include "general.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <libsnes.hpp>
|
||||
#include "boolean.h"
|
||||
#include "libsnes.hpp"
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include "dynamic.h"
|
||||
#include "movie.h"
|
||||
@@ -33,11 +32,16 @@
|
||||
#include "sha256.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <windows.h>
|
||||
#include <shlwapi.h>
|
||||
#ifdef _MSC_VER
|
||||
#define setmode _setmode
|
||||
#endif
|
||||
#elif defined(_XBOX)
|
||||
#include <xtl.h>
|
||||
#define setmode _setmode
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -49,12 +53,13 @@ ssize_t read_file(const char *path, void **buf)
|
||||
{
|
||||
void *rom_buf = NULL;
|
||||
FILE *file = fopen(path, "rb");
|
||||
ssize_t rc = 0;
|
||||
size_t len = 0;
|
||||
if (!file)
|
||||
goto error;
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
long len = ftell(file);
|
||||
ssize_t rc = 0;
|
||||
len = ftell(file);
|
||||
rewind(file);
|
||||
rom_buf = malloc(len + 1);
|
||||
if (!rom_buf)
|
||||
@@ -63,7 +68,7 @@ ssize_t read_file(const char *path, void **buf)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((rc = fread(rom_buf, 1, len, file)) < len)
|
||||
if ((rc = fread(rom_buf, 1, len, file)) < (ssize_t)len)
|
||||
SSNES_WARN("Didn't read whole file.\n");
|
||||
|
||||
*buf = rom_buf;
|
||||
@@ -86,29 +91,33 @@ bool read_file_string(const char *path, char **buf)
|
||||
{
|
||||
*buf = NULL;
|
||||
FILE *file = fopen(path, "r");
|
||||
size_t len = 0;
|
||||
char *ptr = NULL;
|
||||
|
||||
if (!file)
|
||||
goto error;
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
long len = ftell(file) + 2; // Takes account of being able to read in EOF and '\0' at end.
|
||||
len = ftell(file) + 2; // Takes account of being able to read in EOF and '\0' at end.
|
||||
rewind(file);
|
||||
|
||||
*buf = calloc(len, sizeof(char));
|
||||
*buf = (char*)calloc(len, sizeof(char));
|
||||
if (!*buf)
|
||||
goto error;
|
||||
|
||||
char *ptr = *buf;
|
||||
ptr = *buf;
|
||||
|
||||
while (ptr && !feof(file))
|
||||
{
|
||||
size_t bufsize = (size_t)(((ptrdiff_t)*buf + (ptrdiff_t)len) - (ptrdiff_t)ptr);
|
||||
fgets(ptr, bufsize, file);
|
||||
|
||||
ptr = strchr(ptr, '\0');
|
||||
ptr += strlen(ptr);
|
||||
}
|
||||
|
||||
ptr = strchr(ptr, EOF);
|
||||
if (ptr) *ptr = '\0';
|
||||
if (ptr)
|
||||
*ptr = '\0';
|
||||
|
||||
fclose(file);
|
||||
return true;
|
||||
@@ -136,6 +145,7 @@ static void patch_rom(uint8_t **buf, ssize_t *size)
|
||||
ssize_t patch_size = 0;
|
||||
void *patch_data = NULL;
|
||||
enum patch_type type = PATCH_NONE;
|
||||
bool success = false;
|
||||
|
||||
if (g_extern.ups_pref && g_extern.bps_pref)
|
||||
{
|
||||
@@ -168,19 +178,18 @@ static void patch_rom(uint8_t **buf, ssize_t *size)
|
||||
}
|
||||
|
||||
size_t target_size = ret_size * 4; // Just to be sure ...
|
||||
uint8_t *patched_rom = malloc(target_size);
|
||||
uint8_t *patched_rom = (uint8_t*)malloc(target_size);
|
||||
if (!patched_rom)
|
||||
{
|
||||
SSNES_ERR("Failed to allocate memory for patched ROM ...\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
switch (type)
|
||||
{
|
||||
case PATCH_UPS:
|
||||
{
|
||||
ups_error_t err = ups_apply_patch(patch_data, patch_size, ret_buf, ret_size, patched_rom, &target_size);
|
||||
ups_error_t err = ups_apply_patch((const uint8_t*)patch_data, patch_size, ret_buf, ret_size, patched_rom, &target_size);
|
||||
if (err == UPS_SUCCESS)
|
||||
{
|
||||
SSNES_LOG("ROM patched successfully (UPS)!\n");
|
||||
@@ -194,7 +203,7 @@ static void patch_rom(uint8_t **buf, ssize_t *size)
|
||||
|
||||
case PATCH_BPS:
|
||||
{
|
||||
bps_error_t err = bps_apply_patch(patch_data, patch_size, ret_buf, ret_size, patched_rom, &target_size);
|
||||
bps_error_t err = bps_apply_patch((const uint8_t*)patch_data, patch_size, ret_buf, ret_size, patched_rom, &target_size);
|
||||
if (err == BPS_SUCCESS)
|
||||
{
|
||||
SSNES_LOG("ROM patched successfully (BPS)!\n");
|
||||
@@ -237,14 +246,14 @@ static ssize_t read_rom_file(FILE* file, void** buf)
|
||||
|
||||
if (file == NULL) // stdin
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
setmode(0, O_BINARY);
|
||||
#endif
|
||||
|
||||
SSNES_LOG("Reading ROM from stdin ...\n");
|
||||
size_t buf_size = 0xFFFFF; // Some initial guesstimate.
|
||||
size_t buf_ptr = 0;
|
||||
uint8_t *rom_buf = malloc(buf_size);
|
||||
uint8_t *rom_buf = (uint8_t*)malloc(buf_size);
|
||||
if (rom_buf == NULL)
|
||||
{
|
||||
SSNES_ERR("Couldn't allocate memory!\n");
|
||||
@@ -260,7 +269,7 @@ static ssize_t read_rom_file(FILE* file, void** buf)
|
||||
if (buf_ptr < buf_size)
|
||||
break;
|
||||
|
||||
rom_buf = realloc(rom_buf, buf_size * 2);
|
||||
rom_buf = (uint8_t*)realloc(rom_buf, buf_size * 2);
|
||||
if (rom_buf == NULL)
|
||||
{
|
||||
SSNES_ERR("Couldn't allocate memory!\n");
|
||||
@@ -286,14 +295,14 @@ static ssize_t read_rom_file(FILE* file, void** buf)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fread(rom_buf, 1, ret, file) < ret)
|
||||
if (fread(rom_buf, 1, ret, file) < (size_t)ret)
|
||||
{
|
||||
SSNES_ERR("Didn't read whole file.\n");
|
||||
free(rom_buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret_buf = rom_buf;
|
||||
ret_buf = (uint8_t*)rom_buf;
|
||||
}
|
||||
|
||||
// Remove copier header if present (512 first bytes).
|
||||
@@ -359,8 +368,10 @@ static const char *ramtype2str(int type)
|
||||
// Attempt to save valuable RAM data somewhere ...
|
||||
static void dump_to_file_desperate(const void *data, size_t size, int type)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
const char *base = getenv("APPDATA");
|
||||
#elif defined(__CELLOS_LV2__) || defined(_XBOX)
|
||||
const char *base = NULL;
|
||||
#else
|
||||
const char *base = getenv("HOME");
|
||||
#endif
|
||||
@@ -368,9 +379,9 @@ static void dump_to_file_desperate(const void *data, size_t size, int type)
|
||||
if (!base)
|
||||
goto error;
|
||||
|
||||
char path[MAXPATHLEN];
|
||||
char path[PATH_MAX];
|
||||
snprintf(path, sizeof(path), "%s/SSNES-recovery-", base);
|
||||
char timebuf[MAXPATHLEN];
|
||||
char timebuf[PATH_MAX];
|
||||
|
||||
time_t time_;
|
||||
time(&time_);
|
||||
@@ -404,11 +415,14 @@ bool save_state(const char *path)
|
||||
}
|
||||
|
||||
SSNES_LOG("State size: %d bytes.\n", (int)size);
|
||||
psnes_serialize(data, size);
|
||||
bool ret = dump_to_file(path, data, size);
|
||||
free(data);
|
||||
bool ret = psnes_serialize((uint8_t*)data, size);
|
||||
if (ret)
|
||||
ret = dump_to_file(path, data, size);
|
||||
|
||||
if (!ret)
|
||||
SSNES_ERR("Failed to save state to \"%s\".\n", path);
|
||||
|
||||
free(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -417,86 +431,86 @@ bool load_state(const char *path)
|
||||
SSNES_LOG("Loading state: \"%s\".\n", path);
|
||||
void *buf = NULL;
|
||||
ssize_t size = read_file(path, &buf);
|
||||
|
||||
if (size < 0)
|
||||
{
|
||||
SSNES_ERR("Failed to load state from \"%s\".\n", path);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
||||
bool ret = true;
|
||||
SSNES_LOG("State size: %d bytes.\n", (int)size);
|
||||
|
||||
uint8_t *block_buf[2] = {NULL, NULL};
|
||||
int block_type[2] = {-1, -1};
|
||||
unsigned block_size[2] = {0};
|
||||
|
||||
if (g_settings.block_sram_overwrite)
|
||||
{
|
||||
SSNES_LOG("State size: %d bytes.\n", (int)size);
|
||||
|
||||
uint8_t *block_buf[2] = {NULL, NULL};
|
||||
int block_type[2] = {-1, -1};
|
||||
unsigned block_size[2] = {0};
|
||||
|
||||
if (g_settings.block_sram_overwrite)
|
||||
SSNES_LOG("Blocking SRAM overwrite!\n");
|
||||
switch (g_extern.game_type)
|
||||
{
|
||||
SSNES_LOG("Blocking SRAM overwrite!\n");
|
||||
switch (g_extern.game_type)
|
||||
{
|
||||
case SSNES_CART_NORMAL:
|
||||
block_type[0] = SNES_MEMORY_CARTRIDGE_RAM;
|
||||
block_type[1] = SNES_MEMORY_CARTRIDGE_RTC;
|
||||
break;
|
||||
case SSNES_CART_NORMAL:
|
||||
block_type[0] = SNES_MEMORY_CARTRIDGE_RAM;
|
||||
block_type[1] = SNES_MEMORY_CARTRIDGE_RTC;
|
||||
break;
|
||||
|
||||
case SSNES_CART_BSX:
|
||||
case SSNES_CART_BSX_SLOTTED:
|
||||
block_type[0] = SNES_MEMORY_BSX_RAM;
|
||||
block_type[1] = SNES_MEMORY_BSX_PRAM;
|
||||
break;
|
||||
case SSNES_CART_BSX:
|
||||
case SSNES_CART_BSX_SLOTTED:
|
||||
block_type[0] = SNES_MEMORY_BSX_RAM;
|
||||
block_type[1] = SNES_MEMORY_BSX_PRAM;
|
||||
break;
|
||||
|
||||
case SSNES_CART_SUFAMI:
|
||||
block_type[0] = SNES_MEMORY_SUFAMI_TURBO_A_RAM;
|
||||
block_type[1] = SNES_MEMORY_SUFAMI_TURBO_B_RAM;
|
||||
break;
|
||||
case SSNES_CART_SUFAMI:
|
||||
block_type[0] = SNES_MEMORY_SUFAMI_TURBO_A_RAM;
|
||||
block_type[1] = SNES_MEMORY_SUFAMI_TURBO_B_RAM;
|
||||
break;
|
||||
|
||||
case SSNES_CART_SGB:
|
||||
block_type[0] = SNES_MEMORY_GAME_BOY_RAM;
|
||||
block_type[1] = SNES_MEMORY_GAME_BOY_RTC;
|
||||
break;
|
||||
}
|
||||
case SSNES_CART_SGB:
|
||||
block_type[0] = SNES_MEMORY_GAME_BOY_RAM;
|
||||
block_type[1] = SNES_MEMORY_GAME_BOY_RTC;
|
||||
break;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
if (block_type[i] != -1)
|
||||
block_size[i] = psnes_get_memory_size(block_type[i]);
|
||||
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
if (block_size[i])
|
||||
block_buf[i] = malloc(block_size[i]);
|
||||
|
||||
// Backup current SRAM which is overwritten by unserialize.
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
{
|
||||
if (block_buf[i])
|
||||
{
|
||||
const uint8_t *ptr = psnes_get_memory_data(block_type[i]);
|
||||
if (ptr)
|
||||
memcpy(block_buf[i], ptr, block_size[i]);
|
||||
}
|
||||
}
|
||||
|
||||
psnes_unserialize(buf, size);
|
||||
|
||||
// Flush back :D
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
{
|
||||
if (block_buf[i])
|
||||
{
|
||||
uint8_t *ptr = psnes_get_memory_data(block_type[i]);
|
||||
if (ptr)
|
||||
memcpy(ptr, block_buf[i], block_size[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
if (block_buf[i])
|
||||
free(block_buf[i]);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
if (block_type[i] != -1)
|
||||
block_size[i] = psnes_get_memory_size(block_type[i]);
|
||||
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
if (block_size[i])
|
||||
block_buf[i] = (uint8_t*)malloc(block_size[i]);
|
||||
|
||||
// Backup current SRAM which is overwritten by unserialize.
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
{
|
||||
if (block_buf[i])
|
||||
{
|
||||
const uint8_t *ptr = psnes_get_memory_data(block_type[i]);
|
||||
if (ptr)
|
||||
memcpy(block_buf[i], ptr, block_size[i]);
|
||||
}
|
||||
}
|
||||
|
||||
ret = psnes_unserialize((uint8_t*)buf, size);
|
||||
|
||||
// Flush back :D
|
||||
for (unsigned i = 0; i < 2 && ret; i++)
|
||||
{
|
||||
if (block_buf[i])
|
||||
{
|
||||
uint8_t *ptr = psnes_get_memory_data(block_type[i]);
|
||||
if (ptr)
|
||||
memcpy(ptr, block_buf[i], block_size[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
if (block_buf[i])
|
||||
free(block_buf[i]);
|
||||
|
||||
free(buf);
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void load_ram_file(const char *path, int type)
|
||||
@@ -509,7 +523,7 @@ void load_ram_file(const char *path, int type)
|
||||
|
||||
void *buf = NULL;
|
||||
ssize_t rc = read_file(path, &buf);
|
||||
if (rc <= size)
|
||||
if (rc > 0 && rc <= (ssize_t)size)
|
||||
memcpy(data, buf, rc);
|
||||
|
||||
free(buf);
|
||||
@@ -553,48 +567,45 @@ static bool load_sgb_rom(void)
|
||||
FILE *extra_rom = NULL;
|
||||
void *extra_rom_buf = NULL;
|
||||
ssize_t extra_rom_len = 0;
|
||||
char *xml_buf = 0;
|
||||
bool ret = true;
|
||||
|
||||
if ((rom_len = read_rom_file(g_extern.rom_file, &rom_buf)) == -1)
|
||||
{
|
||||
SSNES_ERR("Could not read ROM file.\n");
|
||||
goto error;
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((extra_rom_len = read_file(g_extern.gb_rom_path, &extra_rom_buf)) == -1)
|
||||
{
|
||||
SSNES_ERR("Cannot read GameBoy rom.\n");
|
||||
goto error;
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
char *xml_buf = load_xml_map(g_extern.xml_name);
|
||||
xml_buf = load_xml_map(g_extern.xml_name);
|
||||
|
||||
if (!psnes_load_cartridge_super_game_boy(
|
||||
xml_buf, rom_buf, rom_len,
|
||||
NULL, extra_rom_buf, extra_rom_len))
|
||||
xml_buf, (const uint8_t*)rom_buf, rom_len,
|
||||
NULL, (const uint8_t*)extra_rom_buf, extra_rom_len))
|
||||
{
|
||||
SSNES_ERR("Cannot load SGB/GameBoy rom.\n");
|
||||
goto error;
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (xml_buf)
|
||||
free(xml_buf);
|
||||
|
||||
end:
|
||||
if (g_extern.rom_file)
|
||||
fclose(g_extern.rom_file);
|
||||
if (extra_rom)
|
||||
fclose(extra_rom);
|
||||
free(rom_buf);
|
||||
free(extra_rom_buf);
|
||||
return true;
|
||||
|
||||
error:
|
||||
if (g_extern.rom_file)
|
||||
fclose(g_extern.rom_file);
|
||||
if (extra_rom)
|
||||
fclose(extra_rom);
|
||||
free(rom_buf);
|
||||
free(extra_rom_buf);
|
||||
return false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool load_bsx_rom(bool slotted)
|
||||
@@ -605,62 +616,60 @@ static bool load_bsx_rom(bool slotted)
|
||||
FILE *extra_rom = NULL;
|
||||
void *extra_rom_buf = NULL;
|
||||
ssize_t extra_rom_len = 0;
|
||||
char *xml_buf = 0;
|
||||
bool ret = true;
|
||||
|
||||
if ((rom_len = read_rom_file(g_extern.rom_file, &rom_buf)) == -1)
|
||||
{
|
||||
SSNES_ERR("Could not read ROM file.\n");
|
||||
goto error;
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((extra_rom_len = read_file(g_extern.bsx_rom_path, &extra_rom_buf)) == -1)
|
||||
{
|
||||
SSNES_ERR("Cannot read BSX game rom.\n");
|
||||
goto error;
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
char *xml_buf = load_xml_map(g_extern.xml_name);
|
||||
xml_buf = load_xml_map(g_extern.xml_name);
|
||||
|
||||
if (slotted)
|
||||
{
|
||||
if (!psnes_load_cartridge_bsx_slotted(
|
||||
xml_buf, rom_buf, rom_len,
|
||||
NULL, extra_rom_buf, extra_rom_len))
|
||||
xml_buf, (const uint8_t*)rom_buf, rom_len,
|
||||
NULL, (const uint8_t*)extra_rom_buf, extra_rom_len))
|
||||
{
|
||||
SSNES_ERR("Cannot load BSX slotted rom.\n");
|
||||
goto error;
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!psnes_load_cartridge_bsx(
|
||||
NULL, rom_buf, rom_len,
|
||||
NULL, extra_rom_buf, extra_rom_len))
|
||||
NULL, (const uint8_t*)rom_buf, rom_len,
|
||||
NULL, (const uint8_t*)extra_rom_buf, extra_rom_len))
|
||||
{
|
||||
SSNES_ERR("Cannot load BSX rom.\n");
|
||||
goto error;
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (xml_buf)
|
||||
free(xml_buf);
|
||||
|
||||
end:
|
||||
if (g_extern.rom_file)
|
||||
fclose(g_extern.rom_file);
|
||||
if (extra_rom)
|
||||
fclose(extra_rom);
|
||||
free(rom_buf);
|
||||
free(extra_rom_buf);
|
||||
return true;
|
||||
|
||||
error:
|
||||
if (g_extern.rom_file)
|
||||
fclose(g_extern.rom_file);
|
||||
if (extra_rom)
|
||||
fclose(extra_rom);
|
||||
free(rom_buf);
|
||||
free(extra_rom_buf);
|
||||
return false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool load_sufami_rom(void)
|
||||
@@ -671,63 +680,59 @@ static bool load_sufami_rom(void)
|
||||
FILE *extra_rom[2] = {NULL};
|
||||
void *extra_rom_buf[2] = {NULL};
|
||||
ssize_t extra_rom_len[2] = {0};
|
||||
char *xml_buf = 0;
|
||||
const char *roms[2] = {0};
|
||||
bool ret = true;
|
||||
|
||||
if ((rom_len = read_rom_file(g_extern.rom_file, &rom_buf)) == -1)
|
||||
{
|
||||
SSNES_ERR("Could not read ROM file.\n");
|
||||
goto error;
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
const char *roms[2] = { g_extern.sufami_rom_path[0], g_extern.sufami_rom_path[1] };
|
||||
roms[0] = g_extern.sufami_rom_path[0];
|
||||
roms[1] = g_extern.sufami_rom_path[1];
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
{
|
||||
if (strlen(roms[i]) > 0)
|
||||
if (*(roms[i]))
|
||||
{
|
||||
if ((extra_rom_len[i] = read_file(roms[i], &extra_rom_buf[i])) == -1)
|
||||
{
|
||||
SSNES_ERR("Cannot read Sufami game rom.\n");
|
||||
goto error;
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char *xml_buf = load_xml_map(g_extern.xml_name);
|
||||
xml_buf = load_xml_map(g_extern.xml_name);
|
||||
|
||||
if (!psnes_load_cartridge_sufami_turbo(
|
||||
xml_buf, rom_buf, rom_len,
|
||||
NULL, extra_rom_buf[0], extra_rom_len[0],
|
||||
NULL, extra_rom_buf[1], extra_rom_len[1]))
|
||||
xml_buf, (const uint8_t*)rom_buf, rom_len,
|
||||
NULL, (const uint8_t*)extra_rom_buf[0], extra_rom_len[0],
|
||||
NULL, (const uint8_t*)extra_rom_buf[1], extra_rom_len[1]))
|
||||
{
|
||||
SSNES_ERR("Cannot load Sufami Turbo rom.\n");
|
||||
goto error;
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (xml_buf)
|
||||
free(xml_buf);
|
||||
|
||||
end:
|
||||
if (g_extern.rom_file)
|
||||
fclose(g_extern.rom_file);
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
{
|
||||
if (extra_rom[i])
|
||||
fclose(extra_rom[i]);
|
||||
free(extra_rom_buf[i]);
|
||||
}
|
||||
free(rom_buf);
|
||||
return true;
|
||||
|
||||
error:
|
||||
if (g_extern.rom_file)
|
||||
fclose(g_extern.rom_file);
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (extra_rom[i])
|
||||
fclose(extra_rom[i]);
|
||||
free(extra_rom_buf[i]);
|
||||
}
|
||||
free(rom_buf);
|
||||
return false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool load_normal_rom(void)
|
||||
@@ -735,34 +740,46 @@ static bool load_normal_rom(void)
|
||||
void *rom_buf = NULL;
|
||||
ssize_t rom_len = 0;
|
||||
|
||||
if ((rom_len = read_rom_file(g_extern.rom_file, &rom_buf)) == -1)
|
||||
if (!g_extern.system.need_fullpath)
|
||||
{
|
||||
SSNES_ERR("Could not read ROM file.\n");
|
||||
return false;
|
||||
if ((rom_len = read_rom_file(g_extern.rom_file, &rom_buf)) == -1)
|
||||
{
|
||||
SSNES_ERR("Could not read ROM file.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (g_extern.rom_file)
|
||||
fclose(g_extern.rom_file);
|
||||
|
||||
SSNES_LOG("ROM size: %d bytes\n", (int)rom_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!g_extern.rom_file)
|
||||
{
|
||||
SSNES_ERR("Implementation requires a full path to be set, cannot load ROM from stdin. Aborting ...\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (g_extern.rom_file != NULL)
|
||||
fclose(g_extern.rom_file);
|
||||
|
||||
SSNES_LOG("ROM size: %d bytes\n", (int)rom_len);
|
||||
|
||||
char *xml_buf = load_xml_map(g_extern.xml_name);
|
||||
SSNES_LOG("ROM loading skipped. Implementation will load it on its own.\n");
|
||||
}
|
||||
|
||||
if (!psnes_load_cartridge_normal(xml_buf, rom_buf, rom_len))
|
||||
char *xml_buf = load_xml_map(g_extern.xml_name);
|
||||
|
||||
if (!psnes_load_cartridge_normal(xml_buf, (const uint8_t*)rom_buf, rom_len))
|
||||
{
|
||||
SSNES_ERR("ROM file is not valid!\n");
|
||||
free(rom_buf);
|
||||
free(xml_buf);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (xml_buf)
|
||||
free(xml_buf);
|
||||
|
||||
free(xml_buf);
|
||||
free(rom_buf);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool init_rom_file(enum ssnes_game_type type)
|
||||
{
|
||||
switch (type)
|
||||
@@ -808,27 +825,23 @@ char **dir_list_new(const char *dir, const char *ext)
|
||||
char **dir_list = NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
WIN32_FIND_DATAW ffd;
|
||||
WIN32_FIND_DATA ffd;
|
||||
HANDLE hFind = INVALID_HANDLE_VALUE;
|
||||
|
||||
wchar_t wchar_buf[MAXPATHLEN];
|
||||
char utf8_buf[MAXPATHLEN];
|
||||
char path_buf[PATH_MAX];
|
||||
|
||||
if (strlcpy(utf8_buf, dir, sizeof(utf8_buf)) >= sizeof(utf8_buf))
|
||||
if (strlcpy(path_buf, dir, sizeof(path_buf)) >= sizeof(path_buf))
|
||||
goto error;
|
||||
if (strlcat(utf8_buf, "/*", sizeof(utf8_buf)) >= sizeof(utf8_buf))
|
||||
if (strlcat(path_buf, "/*", sizeof(path_buf)) >= sizeof(path_buf))
|
||||
goto error;
|
||||
|
||||
if (ext)
|
||||
{
|
||||
if (strlcat(utf8_buf, ext, sizeof(utf8_buf)) >= sizeof(utf8_buf))
|
||||
if (strlcat(path_buf, ext, sizeof(path_buf)) >= sizeof(path_buf))
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (MultiByteToWideChar(CP_UTF8, 0, utf8_buf, -1, wchar_buf, MAXPATHLEN) == 0)
|
||||
goto error;
|
||||
|
||||
hFind = FindFirstFileW(wchar_buf, &ffd);
|
||||
hFind = FindFirstFile(path_buf, &ffd);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
goto error;
|
||||
#else
|
||||
@@ -840,7 +853,7 @@ char **dir_list_new(const char *dir, const char *ext)
|
||||
goto error;
|
||||
#endif
|
||||
|
||||
dir_list = calloc(cur_size, sizeof(char*));
|
||||
dir_list = (char**)calloc(cur_size, sizeof(char*));
|
||||
if (!dir_list)
|
||||
goto error;
|
||||
|
||||
@@ -854,32 +867,30 @@ char **dir_list_new(const char *dir, const char *ext)
|
||||
#ifdef _WIN32
|
||||
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
if (WideCharToMultiByte(CP_UTF8, 0, ffd.cFileName, -1, utf8_buf, MAXPATHLEN, NULL, NULL) == 0)
|
||||
continue;
|
||||
if (ext && !strstr(utf8_buf, ext))
|
||||
if (ext && !strstr(ffd.cFileName, ext))
|
||||
continue;
|
||||
#else
|
||||
if (ext && !strstr(entry->d_name, ext))
|
||||
continue;
|
||||
#endif
|
||||
|
||||
dir_list[cur_ptr] = malloc(MAXPATHLEN);
|
||||
dir_list[cur_ptr] = (char*)malloc(PATH_MAX);
|
||||
if (!dir_list[cur_ptr])
|
||||
goto error;
|
||||
|
||||
strlcpy(dir_list[cur_ptr], dir, MAXPATHLEN);
|
||||
strlcat(dir_list[cur_ptr], "/", MAXPATHLEN);
|
||||
strlcpy(dir_list[cur_ptr], dir, PATH_MAX);
|
||||
strlcat(dir_list[cur_ptr], "/", PATH_MAX);
|
||||
#ifdef _WIN32
|
||||
strlcat(dir_list[cur_ptr], utf8_buf, MAXPATHLEN);
|
||||
strlcat(dir_list[cur_ptr], ffd.cFileName, PATH_MAX);
|
||||
#else
|
||||
strlcat(dir_list[cur_ptr], entry->d_name, MAXPATHLEN);
|
||||
strlcat(dir_list[cur_ptr], entry->d_name, PATH_MAX);
|
||||
#endif
|
||||
|
||||
cur_ptr++;
|
||||
if (cur_ptr + 1 == cur_size) // Need to reserve for NULL.
|
||||
{
|
||||
cur_size *= 2;
|
||||
dir_list = realloc(dir_list, cur_size * sizeof(char*));
|
||||
dir_list = (char**)realloc(dir_list, cur_size * sizeof(char*));
|
||||
if (!dir_list)
|
||||
goto error;
|
||||
|
||||
@@ -887,8 +898,8 @@ char **dir_list_new(const char *dir, const char *ext)
|
||||
memset(dir_list + cur_ptr, 0, (cur_size - cur_ptr) * sizeof(char*));
|
||||
}
|
||||
}
|
||||
#ifdef _WIN32
|
||||
while (FindNextFileW(hFind, &ffd) != 0);
|
||||
#if defined(_WIN32)
|
||||
while (FindNextFile(hFind, &ffd) != 0);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -925,10 +936,11 @@ void dir_list_free(char **dir_list)
|
||||
bool path_is_directory(const char *path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
wchar_t buf[MAXPATHLEN];
|
||||
if (MultiByteToWideChar(CP_UTF8, 0, path, -1, buf, MAXPATHLEN) == 0)
|
||||
return false;
|
||||
return PathIsDirectoryW(buf) == FILE_ATTRIBUTE_DIRECTORY;
|
||||
return GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY;
|
||||
#elif defined(__CELLOS_LV2__) || defined(XENON)
|
||||
// Dummy
|
||||
(void)path;
|
||||
return false;
|
||||
#else
|
||||
struct stat buf;
|
||||
if (stat(path, &buf) < 0)
|
||||
@@ -951,25 +963,27 @@ bool path_file_exists(const char *path)
|
||||
|
||||
void fill_pathname(char *out_path, const char *in_path, const char *replace, size_t size)
|
||||
{
|
||||
char tmp_path[MAXPATHLEN];
|
||||
assert(strlcpy(tmp_path, in_path, sizeof(tmp_path)) < sizeof(tmp_path));
|
||||
char tmp_path[PATH_MAX];
|
||||
|
||||
ssnes_assert(strlcpy(tmp_path, in_path, sizeof(tmp_path)) < sizeof(tmp_path));
|
||||
char *tok = strrchr(tmp_path, '.');
|
||||
if (tok != NULL)
|
||||
if (tok)
|
||||
*tok = '\0';
|
||||
assert(strlcpy(out_path, tmp_path, size) < size);
|
||||
assert(strlcat(out_path, replace, size) < size);
|
||||
|
||||
ssnes_assert(strlcpy(out_path, tmp_path, size) < size);
|
||||
ssnes_assert(strlcat(out_path, replace, size) < size);
|
||||
}
|
||||
|
||||
void fill_pathname_noext(char *out_path, const char *in_path, const char *replace, size_t size)
|
||||
{
|
||||
assert(strlcpy(out_path, in_path, size) < size);
|
||||
assert(strlcat(out_path, replace, size) < size);
|
||||
ssnes_assert(strlcpy(out_path, in_path, size) < size);
|
||||
ssnes_assert(strlcat(out_path, replace, size) < size);
|
||||
}
|
||||
|
||||
void fill_pathname_dir(char *in_dir, const char *in_basename, const char *replace, size_t size)
|
||||
{
|
||||
assert(strlcat(in_dir, "/", size) < size);
|
||||
|
||||
ssnes_assert(strlcat(in_dir, "/", size) < size);
|
||||
|
||||
const char *base = strrchr(in_basename, '/');
|
||||
if (!base)
|
||||
base = strrchr(in_basename, '\\');
|
||||
@@ -979,6 +993,6 @@ void fill_pathname_dir(char *in_dir, const char *in_basename, const char *replac
|
||||
else
|
||||
base = in_basename;
|
||||
|
||||
assert(strlcat(in_dir, base, size) < size);
|
||||
assert(strlcat(in_dir, replace, size) < size);
|
||||
ssnes_assert(strlcat(in_dir, base, size) < size);
|
||||
ssnes_assert(strlcat(in_dir, replace, size) < size);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef __SSNES_FILE_H
|
||||
#define __SSNES_FILE_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "boolean.h"
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
@@ -55,5 +55,4 @@ void fill_pathname_noext(char *out_path, const char *in_path, const char *replac
|
||||
// Concatenates in_basename and replace to in_dir.
|
||||
void fill_pathname_dir(char *in_dir, const char *in_basename, const char *replace, size_t size);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -19,39 +19,52 @@
|
||||
#ifndef __SSNES_GENERAL_H
|
||||
#define __SSNES_GENERAL_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "boolean.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
#include <setjmp.h>
|
||||
#include "driver.h"
|
||||
#include "record/ffemu.h"
|
||||
#include "message.h"
|
||||
#include "rewind.h"
|
||||
#include "movie.h"
|
||||
#include "autosave.h"
|
||||
#include "netplay.h"
|
||||
#include "dynamic.h"
|
||||
#include "cheats.h"
|
||||
#include "audio/ext/ssnes_dsp.h"
|
||||
#include "strl.h"
|
||||
|
||||
#ifdef __CELLOS_LV2__
|
||||
#include <sys/timer.h>
|
||||
#endif
|
||||
|
||||
#ifdef XENON
|
||||
#include <time/time.h>
|
||||
#endif
|
||||
|
||||
#if defined(XENON) || defined(__CELLOS_LV2__)
|
||||
#undef PATH_MAX
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETPLAY
|
||||
#include "netplay.h"
|
||||
#endif
|
||||
|
||||
#include "audio/hermite.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <sys/param.h> // MAXPATHLEN
|
||||
#else
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#ifdef PATH_MAX
|
||||
#define MAXPATHLEN PATH_MAX
|
||||
#else
|
||||
#define MAXPATHLEN 512
|
||||
#endif
|
||||
#include "msvc/msvc_compat.h"
|
||||
#elif defined(_XBOX)
|
||||
#include <xtl.h>
|
||||
#include "360/msvc_compat.h"
|
||||
#endif
|
||||
|
||||
#define MAX_PLAYERS 5
|
||||
@@ -82,22 +95,23 @@ struct settings
|
||||
bool force_aspect;
|
||||
bool crop_overscan;
|
||||
float aspect_ratio;
|
||||
char cg_shader_path[MAXPATHLEN];
|
||||
char bsnes_shader_path[MAXPATHLEN];
|
||||
char filter_path[MAXPATHLEN];
|
||||
char cg_shader_path[PATH_MAX];
|
||||
char bsnes_shader_path[PATH_MAX];
|
||||
char filter_path[PATH_MAX];
|
||||
enum ssnes_shader_type shader_type;
|
||||
float refresh_rate;
|
||||
|
||||
bool render_to_texture;
|
||||
double fbo_scale_x;
|
||||
double fbo_scale_y;
|
||||
char second_pass_shader[MAXPATHLEN];
|
||||
float fbo_scale_x;
|
||||
float fbo_scale_y;
|
||||
char second_pass_shader[PATH_MAX];
|
||||
bool second_pass_smooth;
|
||||
char shader_dir[MAXPATHLEN];
|
||||
char shader_dir[PATH_MAX];
|
||||
|
||||
char font_path[MAXPATHLEN];
|
||||
char font_path[PATH_MAX];
|
||||
unsigned font_size;
|
||||
bool font_enable;
|
||||
bool font_scale;
|
||||
float msg_pos_x;
|
||||
float msg_pos_y;
|
||||
float msg_color_r;
|
||||
@@ -110,7 +124,7 @@ struct settings
|
||||
bool hires_record;
|
||||
bool post_filter_record;
|
||||
|
||||
char external_driver[MAXPATHLEN];
|
||||
char external_driver[PATH_MAX];
|
||||
} video;
|
||||
|
||||
struct
|
||||
@@ -120,12 +134,12 @@ struct settings
|
||||
unsigned out_rate;
|
||||
float in_rate;
|
||||
float rate_step;
|
||||
char device[MAXPATHLEN];
|
||||
char device[PATH_MAX];
|
||||
unsigned latency;
|
||||
bool sync;
|
||||
|
||||
char dsp_plugin[MAXPATHLEN];
|
||||
char external_driver[MAXPATHLEN];
|
||||
char dsp_plugin[PATH_MAX];
|
||||
char external_driver[PATH_MAX];
|
||||
} audio;
|
||||
|
||||
struct
|
||||
@@ -137,11 +151,11 @@ struct settings
|
||||
bool netplay_client_swap_input;
|
||||
} input;
|
||||
|
||||
char libsnes[MAXPATHLEN];
|
||||
char cheat_database[MAXPATHLEN];
|
||||
char cheat_settings_path[MAXPATHLEN];
|
||||
char libsnes[PATH_MAX];
|
||||
char cheat_database[PATH_MAX];
|
||||
char cheat_settings_path[PATH_MAX];
|
||||
|
||||
char screenshot_directory[MAXPATHLEN];
|
||||
char screenshot_directory[PATH_MAX];
|
||||
|
||||
bool rewind_enable;
|
||||
size_t rewind_buffer_size;
|
||||
@@ -154,13 +168,25 @@ struct settings
|
||||
bool savestate_auto_index;
|
||||
};
|
||||
|
||||
// Settings and/or global state that is specific to a console-style implementation.
|
||||
#ifdef SSNES_CONSOLE
|
||||
struct console_settings
|
||||
{
|
||||
bool block_config_read;
|
||||
#ifdef __CELLOS_LV2__
|
||||
bool return_to_multiman_enable;
|
||||
#endif
|
||||
bool screenshots_enable;
|
||||
};
|
||||
#endif
|
||||
|
||||
enum ssnes_game_type
|
||||
{
|
||||
SSNES_CART_NORMAL = 0,
|
||||
SSNES_CART_SGB,
|
||||
SSNES_CART_BSX,
|
||||
SSNES_CART_BSX_SLOTTED,
|
||||
SSNES_CART_SUFAMI,
|
||||
SSNES_CART_SUFAMI
|
||||
};
|
||||
|
||||
|
||||
@@ -183,29 +209,29 @@ struct global
|
||||
enum ssnes_game_type game_type;
|
||||
uint32_t cart_crc;
|
||||
|
||||
char gb_rom_path[MAXPATHLEN];
|
||||
char bsx_rom_path[MAXPATHLEN];
|
||||
char sufami_rom_path[2][MAXPATHLEN];
|
||||
char gb_rom_path[PATH_MAX];
|
||||
char bsx_rom_path[PATH_MAX];
|
||||
char sufami_rom_path[2][PATH_MAX];
|
||||
bool has_set_save_path;
|
||||
bool has_set_state_path;
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
char config_path[MAXPATHLEN];
|
||||
char config_path[PATH_MAX];
|
||||
#endif
|
||||
|
||||
char basename[MAXPATHLEN];
|
||||
char savefile_name_srm[MAXPATHLEN];
|
||||
char savefile_name_rtc[MAXPATHLEN]; // Make sure that fill_pathname has space.
|
||||
char savefile_name_psrm[MAXPATHLEN];
|
||||
char savefile_name_asrm[MAXPATHLEN];
|
||||
char savefile_name_bsrm[MAXPATHLEN];
|
||||
char savestate_name[MAXPATHLEN];
|
||||
char xml_name[MAXPATHLEN];
|
||||
char basename[PATH_MAX];
|
||||
char savefile_name_srm[PATH_MAX];
|
||||
char savefile_name_rtc[PATH_MAX]; // Make sure that fill_pathname has space.
|
||||
char savefile_name_psrm[PATH_MAX];
|
||||
char savefile_name_asrm[PATH_MAX];
|
||||
char savefile_name_bsrm[PATH_MAX];
|
||||
char savestate_name[PATH_MAX];
|
||||
char xml_name[PATH_MAX];
|
||||
|
||||
bool ups_pref;
|
||||
bool bps_pref;
|
||||
char ups_name[MAXPATHLEN];
|
||||
char bps_name[MAXPATHLEN];
|
||||
char ups_name[PATH_MAX];
|
||||
char bps_name[PATH_MAX];
|
||||
|
||||
unsigned state_slot;
|
||||
|
||||
@@ -213,9 +239,10 @@ struct global
|
||||
{
|
||||
struct snes_geometry geom;
|
||||
unsigned pitch; // If 0, has classic libsnes semantics.
|
||||
char fullpath[MAXPATHLEN];
|
||||
char fullpath[PATH_MAX];
|
||||
struct snes_system_timing timing;
|
||||
bool timing_set;
|
||||
bool need_fullpath;
|
||||
} system;
|
||||
|
||||
struct
|
||||
@@ -231,6 +258,7 @@ struct global
|
||||
double src_ratio;
|
||||
|
||||
bool use_float;
|
||||
bool mute;
|
||||
|
||||
float *outsamples;
|
||||
int16_t *conv_outsamples;
|
||||
@@ -263,17 +291,18 @@ struct global
|
||||
// Rewind support.
|
||||
state_manager_t *state_manager;
|
||||
void *state_buf;
|
||||
size_t state_size;
|
||||
bool frame_is_reverse;
|
||||
|
||||
// Movie playback/recording support.
|
||||
struct
|
||||
{
|
||||
bsv_movie_t *movie;
|
||||
char movie_path[MAXPATHLEN];
|
||||
char movie_path[PATH_MAX];
|
||||
bool movie_playback;
|
||||
|
||||
// Immediate playback/recording.
|
||||
char movie_start_path[MAXPATHLEN];
|
||||
char movie_start_path[PATH_MAX];
|
||||
bool movie_start_recording;
|
||||
bool movie_start_playback;
|
||||
bool movie_end;
|
||||
@@ -281,6 +310,7 @@ struct global
|
||||
|
||||
bool sram_load_disable;
|
||||
bool sram_save_disable;
|
||||
bool use_sram;
|
||||
|
||||
// Pausing support
|
||||
bool is_paused;
|
||||
@@ -290,17 +320,20 @@ struct global
|
||||
autosave_t *autosave[2];
|
||||
|
||||
// Netplay.
|
||||
#ifdef HAVE_NETPLAY
|
||||
netplay_t *netplay;
|
||||
char netplay_server[MAXPATHLEN];
|
||||
char netplay_server[PATH_MAX];
|
||||
bool netplay_enable;
|
||||
bool netplay_is_client;
|
||||
bool netplay_is_spectate;
|
||||
unsigned netplay_sync_frames;
|
||||
uint16_t netplay_port;
|
||||
#endif
|
||||
|
||||
// FFmpeg record.
|
||||
#ifdef HAVE_FFMPEG
|
||||
ffemu_t *rec;
|
||||
char record_path[MAXPATHLEN];
|
||||
char record_path[PATH_MAX];
|
||||
bool recording;
|
||||
unsigned record_width;
|
||||
unsigned record_height;
|
||||
@@ -327,12 +360,25 @@ struct global
|
||||
#ifdef HAVE_XML
|
||||
cheat_manager_t *cheat;
|
||||
#endif
|
||||
|
||||
bool error_in_init;
|
||||
char error_string[1024];
|
||||
jmp_buf error_sjlj_context;
|
||||
};
|
||||
|
||||
void parse_config(void);
|
||||
void config_set_defaults(void);
|
||||
|
||||
void ssnes_main_clear_state(void);
|
||||
int ssnes_main_init(int argc, char *argv[]);
|
||||
bool ssnes_main_iterate(void);
|
||||
void ssnes_main_deinit(void);
|
||||
|
||||
extern struct settings g_settings;
|
||||
extern struct global g_extern;
|
||||
#ifdef SSNES_CONSOLE
|
||||
extern struct console_settings g_console;
|
||||
#endif
|
||||
|
||||
#define SSNES_LOG(...) do { \
|
||||
if (g_extern.verbose) \
|
||||
@@ -384,19 +430,41 @@ static inline uint8_t is_little_endian(void)
|
||||
return u.y[0];
|
||||
}
|
||||
|
||||
static inline void ssnes_sleep(unsigned usec)
|
||||
#ifdef GEKKO
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
static inline void ssnes_sleep(unsigned msec)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Sleep(10);
|
||||
#ifdef __CELLOS_LV2__
|
||||
sys_timer_usleep(1000 * msec);
|
||||
#elif defined(_WIN32)
|
||||
Sleep(msec);
|
||||
#elif defined(XENON)
|
||||
udelay(1000 * msec);
|
||||
#elif defined(GEKKO)
|
||||
usleep(1000 * msec);
|
||||
#else
|
||||
struct timespec tv = {
|
||||
.tv_sec = 0,
|
||||
.tv_nsec = 10000000
|
||||
};
|
||||
struct timespec tv = {0};
|
||||
tv.tv_sec = msec / 1000;
|
||||
tv.tv_nsec = (msec % 1000) * 1000000;
|
||||
nanosleep(&tv, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define ssnes_assert(cond) \
|
||||
if (!(cond)) { SSNES_ERR("Assertion failed at %s:%d!\n", __FILE__, __LINE__); exit(2); }
|
||||
|
||||
static inline void ssnes_fail(int error_code, const char *error)
|
||||
{
|
||||
// We cannot longjmp unless we're in ssnes_main_init().
|
||||
// If not, something went very wrong, and we should just exit right away.
|
||||
ssnes_assert(g_extern.error_in_init);
|
||||
|
||||
strlcpy(g_extern.error_string, error, sizeof(g_extern.error_string));
|
||||
longjmp(g_extern.error_sjlj_context, error_code);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "getopt_ssnes.h"
|
||||
|
||||
#ifndef HAVE_GETOPT_LONG
|
||||
|
||||
#include <string.h>
|
||||
#include "boolean.h"
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include "msvc/msvc_compat.h"
|
||||
#include "general.h"
|
||||
|
||||
char *optarg;
|
||||
int optind, opterr, optopt;
|
||||
|
||||
static bool is_short_option(const char *str)
|
||||
{
|
||||
return str[0] == '-' && str[1] != '-';
|
||||
}
|
||||
|
||||
static bool is_long_option(const char *str)
|
||||
{
|
||||
return str[0] == '-' && str[1] == '-';
|
||||
}
|
||||
|
||||
static int find_short_index(char * const *argv)
|
||||
{
|
||||
for (int index = 0; argv[index]; index++)
|
||||
{
|
||||
if (is_short_option(argv[index]))
|
||||
return index;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int find_long_index(char * const *argv)
|
||||
{
|
||||
for (int index = 0; argv[index]; index++)
|
||||
{
|
||||
if (is_long_option(argv[index]))
|
||||
return index;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int parse_short(const char *optstring, char * const *argv)
|
||||
{
|
||||
char arg = argv[0][1];
|
||||
if (arg == ':')
|
||||
return '?';
|
||||
|
||||
const char *opt = strchr(optstring, arg);
|
||||
if (!opt)
|
||||
return '?';
|
||||
|
||||
bool multiple_opt = argv[0][2];
|
||||
bool takes_arg = opt[1] == ':';
|
||||
if (multiple_opt && takes_arg) // Makes little sense to allow.
|
||||
return '?';
|
||||
|
||||
if (takes_arg)
|
||||
{
|
||||
optarg = argv[1];
|
||||
optind += 2;
|
||||
return optarg ? opt[0] : '?';
|
||||
}
|
||||
else if (multiple_opt)
|
||||
{
|
||||
memmove(&argv[0][1], &argv[0][2], strlen(&argv[0][2]) + 1);
|
||||
return opt[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
optind++;
|
||||
return opt[0];
|
||||
}
|
||||
}
|
||||
|
||||
static int parse_long(const struct option *longopts, char * const *argv)
|
||||
{
|
||||
const struct option *opt = NULL;
|
||||
for (size_t indice = 0; longopts[indice].name; indice++)
|
||||
{
|
||||
if (strcmp(longopts[indice].name, &argv[0][2]) == 0)
|
||||
{
|
||||
opt = &longopts[indice];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!opt)
|
||||
return '?';
|
||||
|
||||
// getopt_long has an "optional" arg, but we don't bother with that.
|
||||
if (opt->has_arg && !argv[1])
|
||||
return '?';
|
||||
|
||||
if (opt->has_arg)
|
||||
{
|
||||
optarg = argv[1];
|
||||
optind += 2;
|
||||
}
|
||||
else
|
||||
optind++;
|
||||
|
||||
if (opt->flag)
|
||||
{
|
||||
*opt->flag = opt->val;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return opt->val;
|
||||
}
|
||||
|
||||
static void shuffle_block(char **begin, char **last, char **end)
|
||||
{
|
||||
ptrdiff_t len = last - begin;
|
||||
const char **tmp = (const char**)calloc(len, sizeof(const char*));
|
||||
ssnes_assert(tmp);
|
||||
|
||||
memcpy(tmp, begin, sizeof(tmp));
|
||||
memmove(begin, last, (end - last) * sizeof(char*));
|
||||
memcpy(end - len, tmp, sizeof(tmp));
|
||||
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
int getopt_long(int argc, char *argv[],
|
||||
const char *optstring, const struct option *longopts, int *longindex)
|
||||
{
|
||||
(void)longindex;
|
||||
if (argc == 1)
|
||||
return -1;
|
||||
|
||||
if (optind == 0)
|
||||
optind = 1;
|
||||
|
||||
int short_index = find_short_index(&argv[optind]);
|
||||
int long_index = find_long_index(&argv[optind]);
|
||||
|
||||
// We're done here.
|
||||
if (short_index == -1 && long_index == -1)
|
||||
return -1;
|
||||
|
||||
// Reorder argv so that non-options come last.
|
||||
// Non-POSIXy, but that's what getopt does by default.
|
||||
if ((short_index > 0) && ((short_index < long_index) || (long_index == -1)))
|
||||
{
|
||||
shuffle_block(&argv[optind], &argv[optind + short_index], &argv[argc]);
|
||||
short_index = 0;
|
||||
}
|
||||
else if ((long_index > 0) && ((long_index < short_index) || (short_index == -1)))
|
||||
{
|
||||
shuffle_block(&argv[optind], &argv[optind + long_index], &argv[argc]);
|
||||
long_index = 0;
|
||||
}
|
||||
|
||||
ssnes_assert(short_index == 0 || long_index == 0);
|
||||
|
||||
if (short_index == 0)
|
||||
return parse_short(optstring, &argv[optind]);
|
||||
else if (long_index == 0)
|
||||
return parse_long(longopts, &argv[optind]);
|
||||
else
|
||||
return '?';
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __SSNES_GETOPT_H
|
||||
#define __SSNES_GETOPT_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
// Custom implementation of the GNU getopt_long for portability.
|
||||
// Not designed to be fully compatible,
|
||||
// but compatible with the features SSNES uses.
|
||||
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
#include <getopt.h>
|
||||
#else
|
||||
// Avoid possible naming collitions during link since we prefer to use the actual name.
|
||||
#define getopt_long(argc, argv, optstring, longopts, longindex) __getopt_long_ssnes(argc, argv, optstring, longopts, longindex)
|
||||
|
||||
struct option
|
||||
{
|
||||
const char *name;
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
// argv[] is declared with char * const argv[] in GNU,
|
||||
// but this makes no sense, as non-POSIX getopt_long mutates argv (non-opts are moved to the end).
|
||||
int getopt_long(int argc, char *argv[],
|
||||
const char *optstring, const struct option *longopts, int *longindex);
|
||||
extern char *optarg;
|
||||
extern int optind, opterr, optopt;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+60
-62
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
#define SSNES_DLL_IMPORT
|
||||
#include "ext/ssnes_video.h"
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "dynamic.h"
|
||||
#include "general.h"
|
||||
#include "../dynamic.h"
|
||||
#include "../general.h"
|
||||
#include "sdlwrap.h"
|
||||
#include "gfx_common.h"
|
||||
|
||||
@@ -56,13 +56,13 @@ static void *input_ext_init(void)
|
||||
|
||||
static void input_ext_poll(void *data)
|
||||
{
|
||||
input_ext_t *ext = data;
|
||||
input_ext_t *ext = (input_ext_t*)data;
|
||||
ext->driver->poll(ext->handle);
|
||||
}
|
||||
|
||||
static int16_t input_ext_input_state(void *data, const struct snes_keybind **snes_keybinds, bool port, unsigned device, unsigned index, unsigned id)
|
||||
{
|
||||
input_ext_t *ext = data;
|
||||
input_ext_t *ext = (input_ext_t*)data;
|
||||
|
||||
unsigned player = 0;
|
||||
if (device == SNES_DEVICE_MULTITAP)
|
||||
@@ -74,7 +74,7 @@ static int16_t input_ext_input_state(void *data, const struct snes_keybind **sne
|
||||
|
||||
for (unsigned i = 0; g_settings.input.binds[player - 1][i].id != -1; i++)
|
||||
{
|
||||
if (g_settings.input.binds[player - 1][i].id == id)
|
||||
if (g_settings.input.binds[player - 1][i].id == (int)id)
|
||||
{
|
||||
ssnes_bind = &g_settings.input.binds[player - 1][i];
|
||||
break;
|
||||
@@ -83,11 +83,10 @@ static int16_t input_ext_input_state(void *data, const struct snes_keybind **sne
|
||||
|
||||
if (ssnes_bind)
|
||||
{
|
||||
struct ssnes_keybind bind = {
|
||||
.key = ssnes_bind->key,
|
||||
.joykey = ssnes_bind->joykey,
|
||||
.joyaxis = ssnes_bind->joyaxis
|
||||
};
|
||||
struct ssnes_keybind bind = {0};
|
||||
bind.key = ssnes_bind->key;
|
||||
bind.joykey = ssnes_bind->joykey;
|
||||
bind.joyaxis = ssnes_bind->joyaxis;
|
||||
|
||||
return ext->driver->input_state(ext->handle, &bind, player);
|
||||
}
|
||||
@@ -97,7 +96,7 @@ static int16_t input_ext_input_state(void *data, const struct snes_keybind **sne
|
||||
|
||||
static bool input_ext_key_pressed(void *data, int key)
|
||||
{
|
||||
input_ext_t *ext = data;
|
||||
input_ext_t *ext = (input_ext_t*)data;
|
||||
|
||||
const struct snes_keybind *ssnes_bind = NULL;
|
||||
for (unsigned i = 0; g_settings.input.binds[0][i].id != -1; i++)
|
||||
@@ -111,11 +110,10 @@ static bool input_ext_key_pressed(void *data, int key)
|
||||
|
||||
if (ssnes_bind)
|
||||
{
|
||||
struct ssnes_keybind bind = {
|
||||
.key = ssnes_bind->key,
|
||||
.joykey = ssnes_bind->joykey,
|
||||
.joyaxis = ssnes_bind->joyaxis
|
||||
};
|
||||
struct ssnes_keybind bind = {0};
|
||||
bind.key = ssnes_bind->key;
|
||||
bind.joykey = ssnes_bind->joykey;
|
||||
bind.joyaxis = ssnes_bind->joyaxis;
|
||||
|
||||
return ext->driver->input_state(ext->handle, &bind, 1);
|
||||
}
|
||||
@@ -125,7 +123,7 @@ static bool input_ext_key_pressed(void *data, int key)
|
||||
|
||||
static void input_ext_free(void *data)
|
||||
{
|
||||
input_ext_t *ext = data;
|
||||
input_ext_t *ext = (input_ext_t*)data;
|
||||
if (ext)
|
||||
{
|
||||
if (ext->driver && ext->handle)
|
||||
@@ -144,15 +142,14 @@ static void input_ext_free(void *data)
|
||||
}
|
||||
|
||||
static const input_driver_t input_ext = {
|
||||
.init = input_ext_init,
|
||||
.poll = input_ext_poll,
|
||||
.input_state = input_ext_input_state,
|
||||
.key_pressed = input_ext_key_pressed,
|
||||
.free = input_ext_free,
|
||||
.ident = "ext"
|
||||
input_ext_init,
|
||||
input_ext_poll,
|
||||
input_ext_input_state,
|
||||
input_ext_key_pressed,
|
||||
input_ext_free,
|
||||
"ext"
|
||||
};
|
||||
|
||||
|
||||
//////////// Video hook
|
||||
typedef struct
|
||||
{
|
||||
@@ -162,7 +159,7 @@ typedef struct
|
||||
|
||||
static void video_ext_free(void *data)
|
||||
{
|
||||
ext_t *ext = data;
|
||||
ext_t *ext = (ext_t*)data;
|
||||
if (ext)
|
||||
{
|
||||
if (ext->driver && ext->handle)
|
||||
@@ -182,25 +179,25 @@ static void video_ext_free(void *data)
|
||||
|
||||
static bool video_ext_focus(void *data)
|
||||
{
|
||||
ext_t *ext = data;
|
||||
ext_t *ext = (ext_t*)data;
|
||||
return ext->driver->focus(ext->handle);
|
||||
}
|
||||
|
||||
static bool video_ext_alive(void *data)
|
||||
{
|
||||
ext_t *ext = data;
|
||||
ext_t *ext = (ext_t*)data;
|
||||
return ext->driver->alive(ext->handle);
|
||||
}
|
||||
|
||||
static void video_ext_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
ext_t *ext = data;
|
||||
ext_t *ext = (ext_t*)data;
|
||||
ext->driver->set_nonblock_state(ext->handle, state);
|
||||
}
|
||||
|
||||
static bool video_ext_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg)
|
||||
{
|
||||
ext_t *ext = data;
|
||||
ext_t *ext = (ext_t*)data;
|
||||
return ext->driver->frame(ext->handle, frame, width, height, pitch, msg);
|
||||
}
|
||||
|
||||
@@ -214,7 +211,7 @@ static void *setup_input(ext_t *ext, const ssnes_input_driver_t *driver)
|
||||
if (!handle)
|
||||
return NULL;
|
||||
|
||||
input_ext_t *wrap_handle = input_ext.init();
|
||||
input_ext_t *wrap_handle = (input_ext_t*)input_ext.init();
|
||||
if (!wrap_handle)
|
||||
return NULL;
|
||||
|
||||
@@ -268,29 +265,28 @@ static bool setup_video(ext_t *ext, const video_info_t *video, const input_drive
|
||||
gfx_window_title_reset();
|
||||
gfx_window_title(title_buf, sizeof(title_buf));
|
||||
|
||||
ssnes_video_info_t info = {
|
||||
.width = video->width,
|
||||
.height = video->height,
|
||||
.fullscreen = video->fullscreen,
|
||||
.vsync = video->vsync,
|
||||
.force_aspect = video->force_aspect,
|
||||
.aspect_ratio = g_settings.video.aspect_ratio,
|
||||
.smooth = video->smooth,
|
||||
.input_scale = video->input_scale,
|
||||
.color_format = video->rgb32 ? SSNES_COLOR_FORMAT_ARGB8888 : SSNES_COLOR_FORMAT_XRGB1555,
|
||||
.xml_shader = xml_shader,
|
||||
.cg_shader = cg_shader,
|
||||
.ttf_font = font,
|
||||
.ttf_font_size = g_settings.video.font_size,
|
||||
.ttf_font_color = (font_color_r << 16) | (font_color_g << 8) | (font_color_b << 0),
|
||||
.title_hint = title_buf,
|
||||
ssnes_video_info_t info = {0};
|
||||
info.width = video->width;
|
||||
info.height = video->height;
|
||||
info.fullscreen = video->fullscreen;
|
||||
info.vsync = video->vsync;
|
||||
info.force_aspect = video->force_aspect;
|
||||
info.aspect_ratio = g_settings.video.aspect_ratio;
|
||||
info.smooth = video->smooth;
|
||||
info.input_scale = video->input_scale;
|
||||
info.color_format = video->rgb32 ? SSNES_COLOR_FORMAT_ARGB8888 : SSNES_COLOR_FORMAT_XRGB1555;
|
||||
info.xml_shader = xml_shader;
|
||||
info.cg_shader = cg_shader;
|
||||
info.ttf_font = font;
|
||||
info.ttf_font_size = g_settings.video.font_size;
|
||||
info.ttf_font_color = (font_color_r << 16) | (font_color_g << 8) | (font_color_b << 0);
|
||||
info.title_hint = title_buf;
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
.python_state_new = py_state_new,
|
||||
.python_state_get = py_state_get,
|
||||
.python_state_free = py_state_free,
|
||||
info.python_state_new = py_state_new;
|
||||
info.python_state_get = py_state_get;
|
||||
info.python_state_free = py_state_free;
|
||||
#endif
|
||||
};
|
||||
|
||||
const ssnes_input_driver_t *input_driver = NULL;
|
||||
ext->handle = ext->driver->init(&info, &input_driver);
|
||||
@@ -308,10 +304,12 @@ static bool setup_video(ext_t *ext, const video_info_t *video, const input_drive
|
||||
|
||||
static void *video_ext_init(const video_info_t *video, const input_driver_t **input, void **input_data)
|
||||
{
|
||||
ext_t *ext = calloc(1, sizeof(*ext));
|
||||
ext_t *ext = (ext_t*)calloc(1, sizeof(*ext));
|
||||
if (!ext)
|
||||
return NULL;
|
||||
|
||||
const ssnes_video_driver_t *(*video_init)(void) = NULL;
|
||||
|
||||
if (!(*g_settings.video.external_driver))
|
||||
{
|
||||
SSNES_ERR("External driver needs video_external_driver path to be set!\n");
|
||||
@@ -325,8 +323,7 @@ static void *video_ext_init(const video_info_t *video, const input_driver_t **in
|
||||
goto error;
|
||||
}
|
||||
|
||||
const ssnes_video_driver_t* (*video_init)(void) =
|
||||
(const ssnes_video_driver_t *(*)(void))dylib_proc(g_lib, "ssnes_video_init");
|
||||
video_init = (const ssnes_video_driver_t *(*)(void))dylib_proc(g_lib, "ssnes_video_init");
|
||||
if (!video_init)
|
||||
{
|
||||
SSNES_ERR("Couldn't find function ssnes_video_init in library ...\n");
|
||||
@@ -355,12 +352,13 @@ error:
|
||||
}
|
||||
|
||||
const video_driver_t video_ext = {
|
||||
.init = video_ext_init,
|
||||
.frame = video_ext_frame,
|
||||
.alive = video_ext_alive,
|
||||
.set_nonblock_state = video_ext_set_nonblock_state,
|
||||
.focus = video_ext_focus,
|
||||
.free = video_ext_free,
|
||||
.ident = "ext"
|
||||
video_ext_init,
|
||||
video_ext_frame,
|
||||
video_ext_set_nonblock_state,
|
||||
video_ext_alive,
|
||||
video_ext_focus,
|
||||
NULL,
|
||||
video_ext_free,
|
||||
"ext"
|
||||
};
|
||||
|
||||
+8
-7
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "fonts.h"
|
||||
#include "file.h"
|
||||
#include "../file.h"
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
@@ -33,11 +33,12 @@ struct font_renderer
|
||||
font_renderer_t *font_renderer_new(const char *font_path, unsigned font_size)
|
||||
{
|
||||
(void)font_size;
|
||||
font_renderer_t *handle = calloc(1, sizeof(*handle));
|
||||
FT_Error err;
|
||||
font_renderer_t *handle = (font_renderer_t*)calloc(1, sizeof(*handle));
|
||||
if (!handle)
|
||||
goto error;
|
||||
|
||||
FT_Error err = FT_Init_FreeType(&handle->lib);
|
||||
err = FT_Init_FreeType(&handle->lib);
|
||||
if (err)
|
||||
goto error;
|
||||
|
||||
@@ -78,11 +79,11 @@ void font_renderer_msg(font_renderer_t *handle, const char *msg, struct font_out
|
||||
|
||||
if (!err)
|
||||
{
|
||||
struct font_output *tmp = calloc(1, sizeof(*tmp));
|
||||
struct font_output *tmp = (struct font_output*)calloc(1, sizeof(*tmp));
|
||||
if (!tmp)
|
||||
break;
|
||||
|
||||
tmp->output = malloc(slot->bitmap.pitch * slot->bitmap.rows);
|
||||
tmp->output = (uint8_t*)malloc(slot->bitmap.pitch * slot->bitmap.rows);
|
||||
if (!tmp->output)
|
||||
{
|
||||
free(tmp);
|
||||
@@ -155,7 +156,7 @@ static const char *font_paths[] = {
|
||||
// Highly OS/platform dependent.
|
||||
const char *font_renderer_get_default_font(void)
|
||||
{
|
||||
for (unsigned i = 0; i < sizeof(font_paths) / sizeof(font_paths[0]); i++)
|
||||
for (size_t i = 0; i < sizeof(font_paths) / sizeof(font_paths[0]); i++)
|
||||
{
|
||||
if (path_file_exists(font_paths[i]))
|
||||
return font_paths[i];
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
|
||||
+30
-3
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -16,8 +16,35 @@
|
||||
*/
|
||||
|
||||
#include "gfx_common.h"
|
||||
#include "general.h"
|
||||
#include "../general.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <sys/time.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <mmsystem.h>
|
||||
static int gettimeofday(struct timeval *val, void *dummy)
|
||||
{
|
||||
(void)dummy;
|
||||
DWORD msec = timeGetTime();
|
||||
uint64_t usec = msec * 1000;
|
||||
val->tv_sec = usec / 1000000;
|
||||
val->tv_usec = usec % 1000000;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __CELLOS_LV2__
|
||||
#include <sys/sys_time.h>
|
||||
static int gettimeofday(struct timeval *val, void *dummy)
|
||||
{
|
||||
(void)dummy;
|
||||
uint64_t usec = sys_time_get_system_time();
|
||||
val->tv_sec = usec / 1000000;
|
||||
val->tv_usec = usec % 1000000;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static float tv_to_fps(const struct timeval *tv, const struct timeval *new_tv, int frames)
|
||||
{
|
||||
@@ -62,7 +89,7 @@ bool gfx_window_title(char *buf, size_t size)
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include "dynamic.h"
|
||||
#include "../dynamic.h"
|
||||
// We only load this library once, so we let it be unloaded at application shutdown,
|
||||
// since unloading it early seems to cause issues on some systems.
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -19,7 +19,7 @@
|
||||
#define __GFX_COMMON_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
|
||||
bool gfx_window_title(char *buf, size_t size);
|
||||
void gfx_window_title_reset(void);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -16,15 +16,13 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "driver.h"
|
||||
#include "../driver.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include "libsnes.hpp"
|
||||
#include "../libsnes.hpp"
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <string.h>
|
||||
#include "general.h"
|
||||
#include <assert.h>
|
||||
#include "../general.h"
|
||||
#include <math.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -34,12 +32,12 @@
|
||||
#include "gl_common.h"
|
||||
#include "gfx_common.h"
|
||||
#include "sdlwrap.h"
|
||||
#include "strl.h"
|
||||
#include "../strl.h"
|
||||
|
||||
#define NO_SDL_GLEXT
|
||||
#include "SDL.h"
|
||||
#include "SDL_opengl.h"
|
||||
#include "input/ssnes_sdl_input.h"
|
||||
#include "../input/ssnes_sdl_input.h"
|
||||
|
||||
#ifdef HAVE_CG
|
||||
#include "shader_cg.h"
|
||||
@@ -85,6 +83,7 @@ static const GLfloat white_color[] = {
|
||||
1, 1, 1, 1,
|
||||
};
|
||||
|
||||
#define LOAD_SYM(sym) if (!p##sym) { SDL_SYM_WRAP(p##sym, #sym) }
|
||||
|
||||
#ifdef HAVE_FBO
|
||||
#ifdef _WIN32
|
||||
@@ -94,7 +93,6 @@ static PFNGLFRAMEBUFFERTEXTURE2DPROC pglFramebufferTexture2D = NULL;
|
||||
static PFNGLCHECKFRAMEBUFFERSTATUSPROC pglCheckFramebufferStatus = NULL;
|
||||
static PFNGLDELETEFRAMEBUFFERSPROC pglDeleteFramebuffers = NULL;
|
||||
|
||||
#define LOAD_SYM(sym) if (!p##sym) { SDL_SYM_WRAP(p##sym, #sym) }
|
||||
static bool load_fbo_proc(void)
|
||||
{
|
||||
LOAD_SYM(glGenFramebuffers);
|
||||
@@ -192,6 +190,7 @@ typedef struct gl
|
||||
char font_last_msg[256];
|
||||
int font_last_width, font_last_height;
|
||||
GLfloat font_color[16];
|
||||
GLfloat font_color_dark[16];
|
||||
#endif
|
||||
|
||||
} gl_t;
|
||||
@@ -386,6 +385,13 @@ static inline void gl_init_font(gl_t *gl, const char *font_path, unsigned font_s
|
||||
gl->font_color[4 * i + 3] = 1.0;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 4; i++)
|
||||
{
|
||||
for (unsigned j = 0; j < 3; j++)
|
||||
gl->font_color_dark[4 * i + j] = 0.3 * gl->font_color[4 * i + j];
|
||||
gl->font_color_dark[4 * i + 3] = 1.0;
|
||||
}
|
||||
|
||||
#else
|
||||
(void)gl;
|
||||
(void)font_path;
|
||||
@@ -748,12 +754,16 @@ static void blit_fonts(gl_t *gl, const struct font_output *head, const struct fo
|
||||
}
|
||||
|
||||
static void calculate_font_coords(gl_t *gl,
|
||||
GLfloat font_vertex[8], GLfloat font_tex_coords[8])
|
||||
GLfloat font_vertex[8], GLfloat font_vertex_dark[8], GLfloat font_tex_coords[8])
|
||||
{
|
||||
GLfloat scale_factor = g_settings.video.font_scale ?
|
||||
(GLfloat)gl->full_x / (GLfloat)gl->vp_width :
|
||||
1.0f;
|
||||
|
||||
GLfloat lx = g_settings.video.msg_pos_x;
|
||||
GLfloat hx = (GLfloat)gl->font_last_width / gl->vp_width + lx;
|
||||
GLfloat hx = (GLfloat)gl->font_last_width / (gl->vp_width * scale_factor) + lx;
|
||||
GLfloat ly = g_settings.video.msg_pos_y;
|
||||
GLfloat hy = (GLfloat)gl->font_last_height / gl->vp_height + ly;
|
||||
GLfloat hy = (GLfloat)gl->font_last_height / (gl->vp_height * scale_factor) + ly;
|
||||
|
||||
font_vertex[0] = lx;
|
||||
font_vertex[1] = ly;
|
||||
@@ -764,6 +774,14 @@ static void calculate_font_coords(gl_t *gl,
|
||||
font_vertex[6] = hx;
|
||||
font_vertex[7] = ly;
|
||||
|
||||
GLfloat shift_x = 2.0f / gl->vp_width;
|
||||
GLfloat shift_y = 2.0f / gl->vp_height;
|
||||
for (unsigned i = 0; i < 4; i++)
|
||||
{
|
||||
font_vertex_dark[2 * i + 0] = font_vertex[2 * i + 0] - shift_x;
|
||||
font_vertex_dark[2 * i + 1] = font_vertex[2 * i + 1] - shift_y;
|
||||
}
|
||||
|
||||
lx = 0.0f;
|
||||
hx = (GLfloat)gl->font_last_width / gl->font_tex_w;
|
||||
ly = 1.0f - (GLfloat)gl->font_last_height / gl->font_tex_h;
|
||||
@@ -785,15 +803,14 @@ static void gl_render_msg(gl_t *gl, const char *msg)
|
||||
return;
|
||||
|
||||
GLfloat font_vertex[8];
|
||||
GLfloat font_vertex_dark[8];
|
||||
GLfloat font_tex_coords[8];
|
||||
|
||||
// Deactivate custom shaders. Enable the font texture.
|
||||
gl_shader_use(0);
|
||||
set_viewport(gl, gl->win_width, gl->win_height, false);
|
||||
glBindTexture(GL_TEXTURE_2D, gl->font_tex);
|
||||
glVertexPointer(2, GL_FLOAT, 0, font_vertex);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, font_tex_coords);
|
||||
glColorPointer(4, GL_FLOAT, 0, gl->font_color);
|
||||
|
||||
// Need blending.
|
||||
// Using fixed function pipeline here since we cannot guarantee presence of shaders (would be kinda overkill anyways).
|
||||
@@ -818,8 +835,13 @@ static void gl_render_msg(gl_t *gl, const char *msg)
|
||||
gl->font_last_width = geom.width;
|
||||
gl->font_last_height = geom.height;
|
||||
}
|
||||
calculate_font_coords(gl, font_vertex, font_tex_coords);
|
||||
calculate_font_coords(gl, font_vertex, font_vertex_dark, font_tex_coords);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, font_vertex_dark);
|
||||
glColorPointer(4, GL_FLOAT, 0, gl->font_color_dark);
|
||||
glDrawArrays(GL_QUADS, 0, 4);
|
||||
glVertexPointer(2, GL_FLOAT, 0, font_vertex);
|
||||
glColorPointer(4, GL_FLOAT, 0, gl->font_color);
|
||||
glDrawArrays(GL_QUADS, 0, 4);
|
||||
|
||||
// Go back to old rendering path.
|
||||
@@ -875,7 +897,7 @@ static void check_window(gl_t *gl)
|
||||
|
||||
static bool gl_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg)
|
||||
{
|
||||
gl_t *gl = data;
|
||||
gl_t *gl = (gl_t*)data;
|
||||
|
||||
gl_shader_use(1);
|
||||
gl->frame_count++;
|
||||
@@ -1034,11 +1056,13 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
||||
0, 0, 0, width, height, gl->texture_type,
|
||||
gl->texture_fmt, frame);
|
||||
|
||||
struct gl_tex_info tex_info = {
|
||||
.tex = gl->texture[gl->tex_index],
|
||||
.input_size = {width, height},
|
||||
.tex_size = {gl->tex_w, gl->tex_h}
|
||||
};
|
||||
struct gl_tex_info tex_info = {0};
|
||||
tex_info.tex = gl->texture[gl->tex_index];
|
||||
tex_info.input_size[0] = width;
|
||||
tex_info.input_size[1] = height;
|
||||
tex_info.tex_size[0] = gl->tex_w;
|
||||
tex_info.tex_size[1] = gl->tex_h;
|
||||
|
||||
struct gl_tex_info fbo_tex_info[MAX_SHADERS];
|
||||
unsigned fbo_tex_info_cnt = 0;
|
||||
memcpy(tex_info.coord, gl->tex_coords, sizeof(gl->tex_coords));
|
||||
@@ -1145,7 +1169,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
||||
|
||||
static void gl_free(void *data)
|
||||
{
|
||||
gl_t *gl = data;
|
||||
gl_t *gl = (gl_t*)data;
|
||||
|
||||
gl_deinit_font(gl);
|
||||
gl_shader_deinit();
|
||||
@@ -1171,7 +1195,7 @@ static void gl_free(void *data)
|
||||
|
||||
static void gl_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
gl_t *gl = data;
|
||||
gl_t *gl = (gl_t*)data;
|
||||
if (gl->vsync)
|
||||
{
|
||||
SSNES_LOG("GL VSync => %s\n", state ? "off" : "on");
|
||||
@@ -1189,7 +1213,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
return NULL;
|
||||
|
||||
const SDL_VideoInfo *video_info = SDL_GetVideoInfo();
|
||||
assert(video_info);
|
||||
ssnes_assert(video_info);
|
||||
unsigned full_x = video_info->current_w;
|
||||
unsigned full_y = video_info->current_h;
|
||||
SSNES_LOG("Detecting desktop resolution %ux%u.\n", full_x, full_y);
|
||||
@@ -1227,7 +1251,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
}
|
||||
#endif
|
||||
|
||||
gl_t *gl = calloc(1, sizeof(gl_t));
|
||||
gl_t *gl = (gl_t*)calloc(1, sizeof(gl_t));
|
||||
if (!gl)
|
||||
{
|
||||
sdlwrap_destroy();
|
||||
@@ -1342,7 +1366,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
}
|
||||
|
||||
// Hook up SDL input driver to get SDL_QUIT events and RESIZE.
|
||||
sdl_input_t *sdl_input = input_sdl.init();
|
||||
sdl_input_t *sdl_input = (sdl_input_t*)input_sdl.init();
|
||||
if (sdl_input)
|
||||
{
|
||||
*input = &input_sdl;
|
||||
@@ -1365,7 +1389,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
|
||||
static bool gl_alive(void *data)
|
||||
{
|
||||
gl_t *gl = data;
|
||||
gl_t *gl = (gl_t*)data;
|
||||
check_window(gl);
|
||||
return !gl->quitting;
|
||||
}
|
||||
@@ -1379,14 +1403,7 @@ static bool gl_focus(void *data)
|
||||
#ifdef HAVE_XML
|
||||
static bool gl_xml_shader(void *data, const char *path)
|
||||
{
|
||||
gl_t *gl = data;
|
||||
|
||||
//if (!gl_check_error())
|
||||
// SSNES_WARN("Error happened before deinit!\n");
|
||||
|
||||
|
||||
//if (!gl_check_error())
|
||||
// SSNES_WARN("Error happened in deinit!\n");
|
||||
gl_t *gl = (gl_t*)data;
|
||||
|
||||
#ifdef HAVE_FBO
|
||||
if (gl->fbo_inited)
|
||||
@@ -1405,9 +1422,6 @@ static bool gl_xml_shader(void *data, const char *path)
|
||||
|
||||
gl_shader_deinit();
|
||||
|
||||
//if (!gl_check_error())
|
||||
// SSNES_WARN("Failed to deinit rendering path properly!\n");
|
||||
|
||||
if (!gl_glsl_init(path))
|
||||
return false;
|
||||
|
||||
@@ -1425,17 +1439,17 @@ static bool gl_xml_shader(void *data, const char *path)
|
||||
#endif
|
||||
|
||||
const video_driver_t video_gl = {
|
||||
.init = gl_init,
|
||||
.frame = gl_frame,
|
||||
.alive = gl_alive,
|
||||
.set_nonblock_state = gl_set_nonblock_state,
|
||||
.focus = gl_focus,
|
||||
.free = gl_free,
|
||||
gl_init,
|
||||
gl_frame,
|
||||
gl_set_nonblock_state,
|
||||
gl_alive,
|
||||
gl_focus,
|
||||
#ifdef HAVE_XML
|
||||
.xml_shader = gl_xml_shader,
|
||||
gl_xml_shader,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
.ident = "gl"
|
||||
gl_free,
|
||||
"gl"
|
||||
};
|
||||
|
||||
|
||||
|
||||
+8
-8
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -18,16 +18,19 @@
|
||||
#ifndef __GL_COMMON_H
|
||||
#define __GL_COMMON_H
|
||||
|
||||
#include "general.h"
|
||||
#include <assert.h>
|
||||
#include "../general.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__)
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glext.h>
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
#include <PSGL/psgl.h>
|
||||
#include <PSGL/psglu.h>
|
||||
#include <GLES/glext.h>
|
||||
#else
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
@@ -57,9 +60,6 @@ static inline bool gl_check_error(void)
|
||||
case GL_OUT_OF_MEMORY:
|
||||
SSNES_ERR("GL: Out of memory. Harhar.\n");
|
||||
break;
|
||||
case GL_TABLE_TOO_LARGE:
|
||||
SSNES_ERR("GL: Table too large. Big tables scare you! :(\n");
|
||||
break;
|
||||
case GL_NO_ERROR:
|
||||
return true;
|
||||
break;
|
||||
|
||||
+11
-11
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -16,16 +16,16 @@
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
#include "image.h"
|
||||
#include "file.h"
|
||||
#include "../file.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include "general.h"
|
||||
#include "../general.h"
|
||||
|
||||
#ifdef HAVE_SDL_IMAGE
|
||||
|
||||
@@ -40,7 +40,7 @@ bool texture_image_load(const char *path, struct texture_image *out_img)
|
||||
out_img->height = img->h;
|
||||
|
||||
size_t size = out_img->width * out_img->height * sizeof(uint32_t);
|
||||
out_img->pixels = malloc(size);
|
||||
out_img->pixels = (uint32_t*)malloc(size);
|
||||
if (!out_img->pixels)
|
||||
{
|
||||
SDL_FreeSurface(img);
|
||||
@@ -52,12 +52,12 @@ bool texture_image_load(const char *path, struct texture_image *out_img)
|
||||
SSNES_LOG("SDL_image: %dx%d @ %d bpp\n", img->w, img->h, img->format->BitsPerPixel);
|
||||
if (img->format->BitsPerPixel == 32)
|
||||
{
|
||||
for (unsigned y = 0; y < img->h; y++)
|
||||
for (int y = 0; y < img->h; y++)
|
||||
{
|
||||
uint32_t *dst = out_img->pixels + y * img->w;
|
||||
const uint32_t *src = (const uint32_t*)img->pixels + y * img->pitch / sizeof(uint32_t);
|
||||
|
||||
for (unsigned x = 0; x < img->w; x++)
|
||||
for (int x = 0; x < img->w; x++)
|
||||
{
|
||||
uint32_t r = (src[x] & fmt->Rmask) >> fmt->Rshift;
|
||||
uint32_t g = (src[x] & fmt->Gmask) >> fmt->Gshift;
|
||||
@@ -69,12 +69,12 @@ bool texture_image_load(const char *path, struct texture_image *out_img)
|
||||
}
|
||||
else if (img->format->BitsPerPixel == 24)
|
||||
{
|
||||
for (unsigned y = 0; y < img->h; y++)
|
||||
for (int y = 0; y < img->h; y++)
|
||||
{
|
||||
uint32_t *dst = out_img->pixels + y * img->w;
|
||||
const uint8_t *src = (const uint8_t*)img->pixels + y * img->pitch;
|
||||
|
||||
for (unsigned x = 0; x < img->w; x++)
|
||||
for (int x = 0; x < img->w; x++)
|
||||
{
|
||||
// Correct?
|
||||
uint32_t color = 0;
|
||||
@@ -113,7 +113,7 @@ bool texture_image_load(const char *path, struct texture_image *out_img)
|
||||
if (len < 0)
|
||||
return false;
|
||||
|
||||
uint8_t *buf = raw_buf;
|
||||
uint8_t *buf = (uint8_t*)raw_buf;
|
||||
|
||||
if (buf[2] != 2) // Uncompressed RGB
|
||||
{
|
||||
@@ -134,7 +134,7 @@ bool texture_image_load(const char *path, struct texture_image *out_img)
|
||||
SSNES_LOG("Loaded TGA: (%ux%u @ %u bpp)\n", width, height, bits);
|
||||
|
||||
unsigned size = width * height * sizeof(uint32_t);
|
||||
out_img->pixels = malloc(size);
|
||||
out_img->pixels = (uint32_t*)malloc(size);
|
||||
out_img->width = width;
|
||||
out_img->height = height;
|
||||
if (!out_img->pixels)
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -19,7 +19,7 @@
|
||||
#define __SSNES_IMAGE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
|
||||
struct texture_image
|
||||
{
|
||||
@@ -30,5 +30,5 @@ struct texture_image
|
||||
|
||||
bool texture_image_load(const char *path, struct texture_image* img);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+14
-11
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -16,17 +16,18 @@
|
||||
*/
|
||||
|
||||
#include <Python.h>
|
||||
#include <stdbool.h>
|
||||
#include "../../boolean.h"
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "dynamic.h"
|
||||
#include "libsnes.hpp"
|
||||
#include "../../dynamic.h"
|
||||
#include "../../libsnes.hpp"
|
||||
#include "py_state.h"
|
||||
#include "general.h"
|
||||
#include "strl.h"
|
||||
#include "file.h"
|
||||
#include "../../general.h"
|
||||
#include "../../strl.h"
|
||||
#include "../../posix_string.h"
|
||||
#include "../../file.h"
|
||||
|
||||
#define PY_READ_FUNC_DECL(RAMTYPE) py_read_##RAMTYPE
|
||||
#define PY_READ_FUNC(RAMTYPE) \
|
||||
@@ -161,6 +162,7 @@ static void py_set_attrs(PyObject *mod)
|
||||
DECL_ATTR_SSNES(CHEAT_TOGGLE);
|
||||
DECL_ATTR_SSNES(SCREENSHOT);
|
||||
DECL_ATTR_SSNES(DSP_CONFIG);
|
||||
DECL_ATTR_SSNES(MUTE);
|
||||
}
|
||||
|
||||
static PyModuleDef SNESModule = {
|
||||
@@ -194,7 +196,7 @@ static char *dupe_newline(const char *str)
|
||||
return NULL;
|
||||
|
||||
unsigned size = strlen(str) + 2;
|
||||
char *ret = malloc(size);
|
||||
char *ret = (char*)malloc(size);
|
||||
if (!ret)
|
||||
return NULL;
|
||||
|
||||
@@ -212,7 +214,7 @@ static char *align_program(const char *program)
|
||||
return NULL;
|
||||
|
||||
size_t prog_size = strlen(program) + 1;
|
||||
char *new_prog = calloc(1, prog_size);
|
||||
char *new_prog = (char*)calloc(1, prog_size);
|
||||
if (!new_prog)
|
||||
return NULL;
|
||||
|
||||
@@ -249,7 +251,8 @@ py_state_t *py_state_new(const char *script, unsigned is_file, const char *pycla
|
||||
Py_Initialize();
|
||||
SSNES_LOG("Initialized Python runtime!\n");
|
||||
|
||||
py_state_t *handle = calloc(1, sizeof(*handle));
|
||||
py_state_t *handle = (py_state_t*)calloc(1, sizeof(*handle));
|
||||
PyObject *hook = NULL;
|
||||
|
||||
handle->main = PyImport_AddModule("__main__");
|
||||
if (!handle->main)
|
||||
@@ -291,7 +294,7 @@ py_state_t *py_state_new(const char *script, unsigned is_file, const char *pycla
|
||||
}
|
||||
Py_INCREF(handle->dict);
|
||||
|
||||
PyObject *hook = PyDict_GetItemString(handle->dict, pyclass);
|
||||
hook = PyDict_GetItemString(handle->dict, pyclass);
|
||||
if (!hook)
|
||||
{
|
||||
SSNES_ERR("Python: PyDict_GetItemString() failed.\n");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -19,7 +19,7 @@
|
||||
#define __SSNES_PY_STATE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "../../boolean.h"
|
||||
|
||||
#ifndef PY_STATE_OMIT_DECLARATION
|
||||
typedef struct py_state py_state_t;
|
||||
|
||||
+45
-52
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -16,12 +16,11 @@
|
||||
*/
|
||||
|
||||
#include "SDL.h"
|
||||
#include "driver.h"
|
||||
#include <assert.h>
|
||||
#include "../driver.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "general.h"
|
||||
#include "input/ssnes_sdl_input.h"
|
||||
#include "../general.h"
|
||||
#include "../input/ssnes_sdl_input.h"
|
||||
#include "gfx_common.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -37,8 +36,7 @@ static void convert_32bit_32bit_direct(uint32_t *out, unsigned outpitch, const u
|
||||
static void convert_15bit_15bit_shift(uint16_t *out, unsigned outpitch, const uint16_t *input, unsigned width, unsigned height, unsigned pitch, const SDL_PixelFormat *fmt);
|
||||
static void convert_32bit_32bit_shift(uint32_t *out, unsigned outpitch, const uint32_t *input, unsigned width, unsigned height, unsigned pitch, const SDL_PixelFormat *fmt);
|
||||
|
||||
typedef struct sdl_video sdl_video_t;
|
||||
struct sdl_video
|
||||
typedef struct sdl_video
|
||||
{
|
||||
SDL_Surface *screen, *buffer;
|
||||
bool quitting;
|
||||
@@ -56,11 +54,11 @@ struct sdl_video
|
||||
uint8_t font_g;
|
||||
uint8_t font_b;
|
||||
#endif
|
||||
};
|
||||
} sdl_video_t;
|
||||
|
||||
static void sdl_gfx_free(void *data)
|
||||
{
|
||||
sdl_video_t *vid = data;
|
||||
sdl_video_t *vid = (sdl_video_t*)data;
|
||||
if (!vid)
|
||||
return;
|
||||
|
||||
@@ -148,7 +146,7 @@ static void sdl_render_msg_15(sdl_video_t *vid, SDL_Surface *buffer, const char
|
||||
int rbase_y = base_y - head->off_y;
|
||||
if (rbase_y >= 0)
|
||||
{
|
||||
for (int y = 0; y < head->height && (y + rbase_y) < height; y++)
|
||||
for (int y = 0; y < (int)head->height && (y + rbase_y) < (int)height; y++)
|
||||
{
|
||||
if (rbase_x < 0)
|
||||
continue;
|
||||
@@ -156,7 +154,7 @@ static void sdl_render_msg_15(sdl_video_t *vid, SDL_Surface *buffer, const char
|
||||
const uint8_t *a = head->output + head->pitch * y;
|
||||
uint16_t *out = (uint16_t*)buffer->pixels + (rbase_y - head->height + y) * (buffer->pitch >> 1) + rbase_x;
|
||||
|
||||
for (int x = 0; x < head->width && (x + rbase_x) < width; x++)
|
||||
for (int x = 0; x < (int)head->width && (x + rbase_x) < (int)width; x++)
|
||||
{
|
||||
unsigned blend = a[x];
|
||||
unsigned out_pix = out[x];
|
||||
@@ -209,7 +207,7 @@ static void sdl_render_msg_32(sdl_video_t *vid, SDL_Surface *buffer, const char
|
||||
int rbase_y = base_y - head->off_y;
|
||||
if (rbase_y >= 0)
|
||||
{
|
||||
for (int y = 0; y < head->height && (y + rbase_y) < height; y++)
|
||||
for (int y = 0; y < (int)head->height && (y + rbase_y) < (int)height; y++)
|
||||
{
|
||||
if (rbase_x < 0)
|
||||
continue;
|
||||
@@ -217,7 +215,7 @@ static void sdl_render_msg_32(sdl_video_t *vid, SDL_Surface *buffer, const char
|
||||
const uint8_t *a = head->output + head->pitch * y;
|
||||
uint32_t *out = (uint32_t*)buffer->pixels + (rbase_y - head->height + y) * (buffer->pitch >> 2) + rbase_x;
|
||||
|
||||
for (int x = 0; x < head->width && (x + rbase_x) < width; x++)
|
||||
for (int x = 0; x < (int)head->width && (x + rbase_x) < (int)width; x++)
|
||||
{
|
||||
unsigned blend = a[x];
|
||||
unsigned out_pix = out[x];
|
||||
@@ -255,16 +253,19 @@ static void *sdl_gfx_init(const video_info_t *video, const input_driver_t **inpu
|
||||
|
||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||
|
||||
sdl_video_t *vid = calloc(1, sizeof(*vid));
|
||||
sdl_video_t *vid = (sdl_video_t*)calloc(1, sizeof(*vid));
|
||||
if (!vid)
|
||||
return NULL;
|
||||
|
||||
const SDL_VideoInfo *video_info = SDL_GetVideoInfo();
|
||||
assert(video_info);
|
||||
ssnes_assert(video_info);
|
||||
unsigned full_x = video_info->current_w;
|
||||
unsigned full_y = video_info->current_h;
|
||||
SSNES_LOG("Detecting desktop resolution %ux%u.\n", full_x, full_y);
|
||||
|
||||
sdl_input_t *sdl_input = NULL;
|
||||
const SDL_PixelFormat *fmt = NULL;
|
||||
|
||||
if (!video->fullscreen)
|
||||
SSNES_LOG("Creating window @ %ux%u\n", video->width, video->height);
|
||||
|
||||
@@ -287,7 +288,7 @@ static void *sdl_gfx_init(const video_info_t *video, const input_driver_t **inpu
|
||||
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
||||
const SDL_PixelFormat *fmt = vid->screen->format;
|
||||
fmt = vid->screen->format;
|
||||
if (vid->render32)
|
||||
{
|
||||
SSNES_LOG("SDL: Creating 32-bit buffer.\n");
|
||||
@@ -311,20 +312,22 @@ static void *sdl_gfx_init(const video_info_t *video, const input_driver_t **inpu
|
||||
goto error;
|
||||
}
|
||||
|
||||
sdl_input_t *sdl_input = input_sdl.init();
|
||||
sdl_input = (sdl_input_t*)input_sdl.init();
|
||||
if (sdl_input)
|
||||
{
|
||||
*input = &input_sdl;
|
||||
*input_data = sdl_input;
|
||||
}
|
||||
else
|
||||
{
|
||||
*input = NULL;
|
||||
*input_data = NULL;
|
||||
}
|
||||
|
||||
vid->rgb32 = video->rgb32;
|
||||
|
||||
sdl_init_font(vid, g_settings.video.font_path, g_settings.video.font_size);
|
||||
|
||||
|
||||
if (fmt->Rshift == 10 && fmt->Gshift == 5 && fmt->Bshift == 0) // XRGB1555
|
||||
{
|
||||
SSNES_LOG("SDL: 15-bit format matches. Fast blit.\n");
|
||||
@@ -469,7 +472,7 @@ static void check_window(sdl_video_t *vid)
|
||||
|
||||
static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg)
|
||||
{
|
||||
sdl_video_t *vid = data;
|
||||
sdl_video_t *vid = (sdl_video_t*)data;
|
||||
|
||||
if (SDL_MUSTLOCK(vid->buffer))
|
||||
SDL_LockSurface(vid->buffer);
|
||||
@@ -477,41 +480,31 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, unsigne
|
||||
// :(
|
||||
// 15-bit -> 32-bit (Sometimes 15-bit won't work on "modern" OSes :\)
|
||||
if (vid->upsample)
|
||||
{
|
||||
convert_15bit_32bit(vid->buffer->pixels, vid->buffer->pitch, frame, width, height, pitch, vid->screen->format);
|
||||
}
|
||||
convert_15bit_32bit((uint32_t*)vid->buffer->pixels, vid->buffer->pitch, (const uint16_t*)frame, width, height, pitch, vid->screen->format);
|
||||
// 15-bit -> 15-bit
|
||||
else if (!vid->rgb32)
|
||||
{
|
||||
vid->convert_15_func(vid->buffer->pixels, vid->buffer->pitch, frame, width, height, pitch, vid->screen->format);
|
||||
}
|
||||
vid->convert_15_func((uint16_t*)vid->buffer->pixels, vid->buffer->pitch, (const uint16_t*)frame, width, height, pitch, vid->screen->format);
|
||||
// 32-bit -> 15-bit
|
||||
else if (vid->rgb32 && g_settings.video.force_16bit)
|
||||
{
|
||||
convert_32bit_15bit(vid->buffer->pixels, vid->buffer->pitch, frame, width, height, pitch, vid->screen->format);
|
||||
}
|
||||
convert_32bit_15bit((uint16_t*)vid->buffer->pixels, vid->buffer->pitch, (const uint32_t*)frame, width, height, pitch, vid->screen->format);
|
||||
// 32-bit -> 32-bit
|
||||
else
|
||||
{
|
||||
vid->convert_32_func(vid->buffer->pixels, vid->buffer->pitch, frame, width, height, pitch, vid->screen->format);
|
||||
}
|
||||
vid->convert_32_func((uint32_t*)vid->buffer->pixels, vid->buffer->pitch, (const uint32_t*)frame, width, height, pitch, vid->screen->format);
|
||||
|
||||
if (SDL_MUSTLOCK(vid->buffer))
|
||||
SDL_UnlockSurface(vid->buffer);
|
||||
|
||||
SDL_Rect src = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.w = width,
|
||||
.h = height
|
||||
};
|
||||
SDL_Rect src = {0};
|
||||
src.x = 0;
|
||||
src.y = 0;
|
||||
src.w = width;
|
||||
src.h = height;
|
||||
|
||||
SDL_Rect dest = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.w = vid->screen->w,
|
||||
.h = vid->screen->h
|
||||
};
|
||||
SDL_Rect dest = {0};
|
||||
dest.x = 0;
|
||||
dest.y = 0;
|
||||
dest.w = vid->screen->w;
|
||||
dest.h = vid->screen->h;
|
||||
|
||||
SDL_SoftStretch(vid->buffer, &src, vid->screen, &dest);
|
||||
|
||||
@@ -540,7 +533,7 @@ static void sdl_gfx_set_nonblock_state(void *data, bool state)
|
||||
|
||||
static bool sdl_gfx_alive(void *data)
|
||||
{
|
||||
sdl_video_t *vid = data;
|
||||
sdl_video_t *vid = (sdl_video_t*)data;
|
||||
check_window(vid);
|
||||
return !vid->quitting;
|
||||
}
|
||||
@@ -551,14 +544,14 @@ static bool sdl_gfx_focus(void *data)
|
||||
return (SDL_GetAppState() & (SDL_APPINPUTFOCUS | SDL_APPACTIVE)) == (SDL_APPINPUTFOCUS | SDL_APPACTIVE);
|
||||
}
|
||||
|
||||
|
||||
const video_driver_t video_sdl = {
|
||||
.init = sdl_gfx_init,
|
||||
.frame = sdl_gfx_frame,
|
||||
.alive = sdl_gfx_alive,
|
||||
.set_nonblock_state = sdl_gfx_set_nonblock_state,
|
||||
.focus = sdl_gfx_focus,
|
||||
.free = sdl_gfx_free,
|
||||
.ident = "sdl"
|
||||
sdl_gfx_init,
|
||||
sdl_gfx_frame,
|
||||
sdl_gfx_set_nonblock_state,
|
||||
sdl_gfx_alive,
|
||||
sdl_gfx_focus,
|
||||
NULL,
|
||||
sdl_gfx_free,
|
||||
"sdl"
|
||||
};
|
||||
|
||||
+44
-32
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -17,8 +17,7 @@
|
||||
|
||||
#include "sdlwrap.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "general.h"
|
||||
#include <assert.h>
|
||||
#include "../general.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenGL/OpenGL.h>
|
||||
@@ -42,52 +41,54 @@ void sdlwrap_set_swap_interval(unsigned interval, bool inited)
|
||||
{
|
||||
g_interval = interval;
|
||||
|
||||
bool success = true;
|
||||
#if SDL_MODERN
|
||||
if (g_window)
|
||||
SDL_GL_SetSwapInterval(g_interval);
|
||||
success = SDL_GL_SetSwapInterval(g_interval) == 0;
|
||||
#else
|
||||
if (inited)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
static BOOL (APIENTRY *wgl_swap_interval)(int) = NULL;
|
||||
if (!wgl_swap_interval)
|
||||
{
|
||||
SDL_SYM_WRAP(wgl_swap_interval, "wglSwapIntervalEXT");
|
||||
}
|
||||
if (wgl_swap_interval) wgl_swap_interval(g_interval);
|
||||
|
||||
if (wgl_swap_interval)
|
||||
success = wgl_swap_interval(g_interval);
|
||||
#elif defined(__APPLE__) && defined(HAVE_OPENGL)
|
||||
GLint val = g_interval;
|
||||
CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &val);
|
||||
success = CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &val) == 0;
|
||||
#else
|
||||
static int (*glx_swap_interval)(int) = NULL;
|
||||
if (!glx_swap_interval)
|
||||
{
|
||||
SDL_SYM_WRAP(glx_swap_interval, "glXSwapIntervalSGI");
|
||||
}
|
||||
if (!glx_swap_interval)
|
||||
{
|
||||
SDL_SYM_WRAP(glx_swap_interval, "glXSwapIntervalMESA");
|
||||
}
|
||||
if (glx_swap_interval)
|
||||
glx_swap_interval(g_interval);
|
||||
|
||||
if (glx_swap_interval)
|
||||
success = glx_swap_interval(g_interval) == 0;
|
||||
else
|
||||
SSNES_WARN("Could not find GLX VSync call. :(\n");
|
||||
SSNES_WARN("Could not find GLX VSync call.\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
if (!success)
|
||||
SSNES_WARN("Failed to set swap interval!\n");
|
||||
}
|
||||
|
||||
bool sdlwrap_init(void)
|
||||
{
|
||||
#if SDL_MODERN
|
||||
return SDL_VideoInit(NULL) == 0;
|
||||
bool ret = SDL_VideoInit(NULL) == 0;
|
||||
#else
|
||||
if (SDL_WasInit(SDL_INIT_VIDEO))
|
||||
return true;
|
||||
|
||||
return SDL_Init(SDL_INIT_VIDEO) == 0;
|
||||
bool ret = SDL_Init(SDL_INIT_VIDEO) == 0;
|
||||
#endif
|
||||
if (!ret)
|
||||
SSNES_ERR("Failed to init SDL video!\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if SDL_MODERN
|
||||
@@ -135,21 +136,29 @@ bool sdlwrap_set_video_mode(
|
||||
#endif
|
||||
|
||||
#if SDL_MODERN
|
||||
if (bits == 15)
|
||||
{
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||
}
|
||||
g_window = SDL_CreateWindow("SSNES", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | (fullscreen ? SDL_WINDOW_FULLSCREEN : resizable));
|
||||
if (!g_window)
|
||||
return false;
|
||||
g_ctx = SDL_GL_CreateContext(g_window);
|
||||
if (bits == 15)
|
||||
{
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||
}
|
||||
|
||||
g_window = SDL_CreateWindow("SSNES", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | (fullscreen ? SDL_WINDOW_FULLSCREEN : resizable));
|
||||
if (!g_window)
|
||||
{
|
||||
SSNES_ERR("Failed to create SDL window!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
g_ctx = SDL_GL_CreateContext(g_window);
|
||||
#else
|
||||
if (!SDL_SetVideoMode(width, height, bits,
|
||||
SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : resizable)))
|
||||
{
|
||||
SSNES_ERR("Failed to create SDL window!\n");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
int attr = 0;
|
||||
@@ -230,7 +239,7 @@ bool sdlwrap_key_pressed(int key)
|
||||
|
||||
// 1.2 specific workaround for tiling WMs. In 1.3 we call GetSize directly, so we don't need to rely on
|
||||
// proper event handling (I hope).
|
||||
#if !defined(__APPLE__) && !defined(_WIN32) && !SDL_MODERN
|
||||
#if !defined(__APPLE__) && !defined(_WIN32) && !SDL_MODERN && !defined(XENON)
|
||||
static void sdlwrap_get_window_size(unsigned *width, unsigned *height)
|
||||
{
|
||||
SDL_SysWMinfo info;
|
||||
@@ -308,7 +317,7 @@ void sdlwrap_check_window(bool *quit,
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(__APPLE__) && !defined(_WIN32)
|
||||
#if !defined(__APPLE__) && !defined(_WIN32) && !defined(XENON)
|
||||
// Hack to workaround limitations in tiling WMs ...
|
||||
if (!*resize && !g_fullscreen)
|
||||
{
|
||||
@@ -328,7 +337,10 @@ void sdlwrap_check_window(bool *quit,
|
||||
|
||||
bool sdlwrap_get_wm_info(SDL_SysWMinfo *info)
|
||||
{
|
||||
#if SDL_MODERN
|
||||
#ifdef XENON
|
||||
(void)info;
|
||||
return false;
|
||||
#elif SDL_MODERN
|
||||
if (g_window)
|
||||
return SDL_GetWindowWMInfo(g_window, info);
|
||||
else
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef __SDLWRAP_H
|
||||
#define __SDLWRAP_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_version.h"
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
// Not legal to cast (void*) to fn-pointer. Need workaround to be compliant.
|
||||
#define SDL_SYM_WRAP(sym, symbol) { \
|
||||
assert(sizeof(void*) == sizeof(void (*)(void))); \
|
||||
ssnes_assert(sizeof(void*) == sizeof(void (*)(void))); \
|
||||
void *sym__ = SDL_GL_GetProcAddress(symbol); \
|
||||
memcpy(&(sym), &sym__, sizeof(void*)); \
|
||||
}
|
||||
|
||||
+38
-26
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -18,12 +18,13 @@
|
||||
#include "shader_cg.h"
|
||||
#include <Cg/cg.h>
|
||||
#include <Cg/cgGL.h>
|
||||
#include "general.h"
|
||||
#include "../general.h"
|
||||
#include <string.h>
|
||||
#include "strl.h"
|
||||
#include "conf/config_file.h"
|
||||
#include "../strl.h"
|
||||
#include "../conf/config_file.h"
|
||||
#include "image.h"
|
||||
#include "dynamic.h"
|
||||
#include "../dynamic.h"
|
||||
#include "../posix_string.h"
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
#include "snes_state.h"
|
||||
@@ -312,7 +313,9 @@ void gl_cg_deinit(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __CELLOS_LV2__
|
||||
cgDestroyContext(cgCtx);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define SET_LISTING_INDEX(type, index) \
|
||||
@@ -444,8 +447,10 @@ static bool load_textures(const char *dir_path, config_file_t *conf)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, smooth ? GL_LINEAR : GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, smooth ? GL_LINEAR : GL_NEAREST);
|
||||
|
||||
#ifndef __CELLOS_LV2__
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, img.width);
|
||||
#endif
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0, GL_RGBA, img.width, img.height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, img.pixels);
|
||||
|
||||
@@ -479,6 +484,13 @@ static bool load_imports(const char *dir_path, config_file_t *conf)
|
||||
|
||||
struct snes_tracker_uniform_info info[MAX_VARIABLES];
|
||||
unsigned info_cnt = 0;
|
||||
struct snes_tracker_info tracker_info = {0};
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
char script_path[128];
|
||||
char *script = NULL;
|
||||
char *script_class = NULL;
|
||||
#endif
|
||||
|
||||
const char *id = strtok(imports, ";");
|
||||
while (id && info_cnt < MAX_VARIABLES)
|
||||
@@ -512,7 +524,7 @@ static bool load_imports(const char *dir_path, config_file_t *conf)
|
||||
}
|
||||
|
||||
enum snes_tracker_type tracker_type;
|
||||
enum snes_ram_type ram_type = SNES_MEMORY_WRAM;
|
||||
enum snes_ram_type ram_type = SSNES_STATE_NONE;
|
||||
|
||||
if (strcmp(semantic, "capture") == 0)
|
||||
tracker_type = SSNES_STATE_CAPTURE;
|
||||
@@ -619,20 +631,15 @@ static bool load_imports(const char *dir_path, config_file_t *conf)
|
||||
id = strtok(NULL, ";");
|
||||
}
|
||||
|
||||
struct snes_tracker_info tracker_info = {
|
||||
.wram = psnes_get_memory_data(SNES_MEMORY_WRAM),
|
||||
.vram = psnes_get_memory_data(SNES_MEMORY_VRAM),
|
||||
.cgram = psnes_get_memory_data(SNES_MEMORY_CGRAM),
|
||||
.oam = psnes_get_memory_data(SNES_MEMORY_OAM),
|
||||
.apuram = psnes_get_memory_data(SNES_MEMORY_APURAM),
|
||||
.info = info,
|
||||
.info_elem = info_cnt,
|
||||
};
|
||||
tracker_info.wram = psnes_get_memory_data(SNES_MEMORY_WRAM);
|
||||
tracker_info.vram = psnes_get_memory_data(SNES_MEMORY_VRAM);
|
||||
tracker_info.cgram = psnes_get_memory_data(SNES_MEMORY_CGRAM);
|
||||
tracker_info.oam = psnes_get_memory_data(SNES_MEMORY_OAM);
|
||||
tracker_info.apuram = psnes_get_memory_data(SNES_MEMORY_APURAM);
|
||||
tracker_info.info = info;
|
||||
tracker_info.info_elem = info_cnt;
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
char script_path[128];
|
||||
char *script = NULL;
|
||||
char *script_class = NULL;
|
||||
if (config_get_string(conf, "import_script", &script))
|
||||
{
|
||||
strlcpy(script_path, dir_path, sizeof(script_path));
|
||||
@@ -681,6 +688,11 @@ static bool load_preset(const char *path)
|
||||
cgGLLoadProgram(prg[0].fprg);
|
||||
cgGLLoadProgram(prg[0].vprg);
|
||||
|
||||
int shaders;
|
||||
// Basedir.
|
||||
char dir_path[PATH_MAX];
|
||||
char *ptr = NULL;
|
||||
|
||||
SSNES_LOG("Loading Cg meta-shader: %s\n", path);
|
||||
config_file_t *conf = config_file_new(path);
|
||||
if (!conf)
|
||||
@@ -689,7 +701,6 @@ static bool load_preset(const char *path)
|
||||
goto error;
|
||||
}
|
||||
|
||||
int shaders;
|
||||
if (!config_get_int(conf, "shaders", &shaders))
|
||||
{
|
||||
SSNES_ERR("Cannot find \"shaders\" param.\n");
|
||||
@@ -715,7 +726,7 @@ static bool load_preset(const char *path)
|
||||
prg[shaders + 1] = prg[0];
|
||||
|
||||
// Check filter params.
|
||||
for (unsigned i = 0; i < shaders; i++)
|
||||
for (int i = 0; i < shaders; i++)
|
||||
{
|
||||
bool smooth;
|
||||
char filter_name_buf[64];
|
||||
@@ -725,7 +736,7 @@ static bool load_preset(const char *path)
|
||||
}
|
||||
|
||||
// Bigass for-loop ftw. Check scaling params.
|
||||
for (unsigned i = 0; i < shaders; i++)
|
||||
for (int i = 0; i < shaders; i++)
|
||||
{
|
||||
char *scale_type = NULL;
|
||||
char *scale_type_x = NULL;
|
||||
@@ -850,10 +861,8 @@ static bool load_preset(const char *path)
|
||||
free(scale_type_y);
|
||||
}
|
||||
|
||||
// Basedir.
|
||||
char dir_path[MAXPATHLEN];
|
||||
strlcpy(dir_path, path, sizeof(dir_path));
|
||||
char *ptr = strrchr(dir_path, '/');
|
||||
ptr = strrchr(dir_path, '/');
|
||||
if (!ptr) ptr = strrchr(dir_path, '\\');
|
||||
if (ptr)
|
||||
ptr[1] = '\0';
|
||||
@@ -861,11 +870,11 @@ static bool load_preset(const char *path)
|
||||
dir_path[0] = '\0';
|
||||
|
||||
// Finally load shaders :)
|
||||
for (unsigned i = 0; i < shaders; i++)
|
||||
for (int i = 0; i < shaders; i++)
|
||||
{
|
||||
char *shader_path;
|
||||
char attr_buf[64];
|
||||
char path_buf[MAXPATHLEN];
|
||||
char path_buf[PATH_MAX];
|
||||
|
||||
print_buf(attr_buf, "shader%u", i);
|
||||
if (config_get_string(conf, attr_buf, &shader_path))
|
||||
@@ -940,6 +949,9 @@ error:
|
||||
|
||||
bool gl_cg_init(const char *path)
|
||||
{
|
||||
#ifdef __CELLOS_LV2__
|
||||
cgRTCgcInit();
|
||||
#endif
|
||||
cgCtx = cgCreateContext();
|
||||
if (cgCtx == NULL)
|
||||
{
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef __SSNES_CG_H
|
||||
#define __SSNES_CG_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include "gl_common.h"
|
||||
|
||||
bool gl_cg_init(const char *path);
|
||||
|
||||
+58
-37
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -15,13 +15,14 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include <string.h>
|
||||
#include "general.h"
|
||||
#include "../general.h"
|
||||
#include "shader_glsl.h"
|
||||
#include "strl.h"
|
||||
#include "../strl.h"
|
||||
#include "../posix_string.h"
|
||||
#include "snes_state.h"
|
||||
#include "dynamic.h"
|
||||
#include "../dynamic.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenGL/gl.h>
|
||||
@@ -36,6 +37,7 @@
|
||||
#include "sdlwrap.h"
|
||||
#include "SDL_opengl.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
@@ -121,7 +123,7 @@ static char gl_teximage_uniforms[MAX_TEXTURES][64];
|
||||
static snes_tracker_t *gl_snes_tracker = NULL;
|
||||
static struct snes_tracker_uniform_info gl_tracker_info[MAX_VARIABLES];
|
||||
static unsigned gl_tracker_info_cnt = 0;
|
||||
static char gl_tracker_script[MAXPATHLEN];
|
||||
static char gl_tracker_script[PATH_MAX];
|
||||
static char gl_tracker_script_class[64];
|
||||
static xmlChar *gl_script_program = NULL;
|
||||
|
||||
@@ -333,6 +335,8 @@ static bool get_texture_image(const char *shader_path, xmlNodePtr ptr)
|
||||
xmlChar *filename = xmlGetProp(ptr, (const xmlChar*)"file");
|
||||
xmlChar *filter = xmlGetProp(ptr, (const xmlChar*)"filter");
|
||||
xmlChar *id = xmlGetProp(ptr, (const xmlChar*)"id");
|
||||
char *last = NULL;
|
||||
struct texture_image img;
|
||||
|
||||
if (!id)
|
||||
{
|
||||
@@ -349,16 +353,15 @@ static bool get_texture_image(const char *shader_path, xmlNodePtr ptr)
|
||||
if (filter && strcmp((const char*)filter, "nearest") == 0)
|
||||
linear = false;
|
||||
|
||||
char tex_path[MAXPATHLEN];
|
||||
char tex_path[PATH_MAX];
|
||||
strlcpy(tex_path, shader_path, sizeof(tex_path));
|
||||
|
||||
char *last = strrchr(tex_path, '/');
|
||||
last = strrchr(tex_path, '/');
|
||||
if (!last) last = strrchr(tex_path, '\\');
|
||||
if (last) last[1] = '\0';
|
||||
|
||||
strlcat(tex_path, (const char*)filename, sizeof(tex_path));
|
||||
|
||||
struct texture_image img;
|
||||
SSNES_LOG("Loading texture image from: \"%s\" ...\n", tex_path);
|
||||
if (!texture_image_load(tex_path, &img))
|
||||
{
|
||||
@@ -477,13 +480,18 @@ static bool get_import_value(xmlNodePtr ptr)
|
||||
xmlChar *cgram = xmlGetProp(ptr, (const xmlChar*)"cgram");
|
||||
xmlChar *bitmask = xmlGetProp(ptr, (const xmlChar*)"mask");
|
||||
|
||||
unsigned memtype;
|
||||
enum snes_tracker_type tracker_type;
|
||||
enum snes_ram_type ram_type = SSNES_STATE_NONE;
|
||||
uint32_t addr = 0;
|
||||
unsigned mask_value = 0;
|
||||
|
||||
if (!semantic || !id)
|
||||
{
|
||||
SSNES_ERR("No semantic or ID for import value!\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
enum snes_tracker_type tracker_type;
|
||||
|
||||
if (strcmp((const char*)semantic, "capture") == 0)
|
||||
tracker_type = SSNES_STATE_CAPTURE;
|
||||
@@ -505,9 +513,6 @@ static bool get_import_value(xmlNodePtr ptr)
|
||||
goto error;
|
||||
}
|
||||
|
||||
enum snes_ram_type ram_type = SSNES_STATE_NONE;
|
||||
uint32_t addr = 0;
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
if (tracker_type != SSNES_STATE_PYTHON)
|
||||
#endif
|
||||
@@ -541,7 +546,6 @@ static bool get_import_value(xmlNodePtr ptr)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned memtype;
|
||||
switch (ram_type)
|
||||
{
|
||||
case SSNES_STATE_WRAM:
|
||||
@@ -570,7 +574,6 @@ static bool get_import_value(xmlNodePtr ptr)
|
||||
goto error;
|
||||
}
|
||||
|
||||
unsigned mask_value = 0;
|
||||
if (bitmask)
|
||||
mask_value = strtoul((const char*)bitmask, NULL, 16);
|
||||
|
||||
@@ -618,6 +621,10 @@ static unsigned get_xml_shaders(const char *path, struct shader_program *prog, s
|
||||
|
||||
SSNES_LOG("Loading XML shader: %s\n", path);
|
||||
xmlDocPtr doc = xmlCtxtReadFile(ctx, path, NULL, 0);
|
||||
xmlNodePtr head = NULL;
|
||||
xmlNodePtr cur = NULL;
|
||||
unsigned num = 0;
|
||||
|
||||
if (!doc)
|
||||
{
|
||||
SSNES_ERR("Failed to parse XML file: %s\n", path);
|
||||
@@ -630,8 +637,8 @@ static unsigned get_xml_shaders(const char *path, struct shader_program *prog, s
|
||||
goto error;
|
||||
}
|
||||
|
||||
xmlNodePtr head = xmlDocGetRootElement(doc);
|
||||
xmlNodePtr cur = NULL;
|
||||
head = xmlDocGetRootElement(doc);
|
||||
|
||||
for (cur = head; cur; cur = cur->next)
|
||||
{
|
||||
if (cur->type == XML_ELEMENT_NODE && strcmp((const char*)cur->name, "shader") == 0)
|
||||
@@ -652,7 +659,6 @@ static unsigned get_xml_shaders(const char *path, struct shader_program *prog, s
|
||||
if (!cur) // We couldn't find any GLSL shader :(
|
||||
goto error;
|
||||
|
||||
unsigned num = 0;
|
||||
memset(prog, 0, sizeof(struct shader_program) * size);
|
||||
|
||||
// Iterate to check if we find fragment and/or vertex shaders.
|
||||
@@ -739,11 +745,19 @@ static void print_shader_log(GLuint obj)
|
||||
|
||||
pglGetShaderiv(obj, GL_INFO_LOG_LENGTH, &max_len);
|
||||
|
||||
char info_log[max_len];
|
||||
if (max_len == 0)
|
||||
return;
|
||||
|
||||
char *info_log = (char*)malloc(max_len);
|
||||
if (!info_log)
|
||||
return;
|
||||
|
||||
pglGetShaderInfoLog(obj, max_len, &info_len, info_log);
|
||||
|
||||
if (info_len > 0)
|
||||
SSNES_LOG("Shader log: %s\n", info_log);
|
||||
|
||||
free(info_log);
|
||||
}
|
||||
|
||||
static void print_linker_log(GLuint obj)
|
||||
@@ -753,11 +767,19 @@ static void print_linker_log(GLuint obj)
|
||||
|
||||
pglGetProgramiv(obj, GL_INFO_LOG_LENGTH, &max_len);
|
||||
|
||||
char info_log[max_len];
|
||||
if (max_len == 0)
|
||||
return;
|
||||
|
||||
char *info_log = (char*)malloc(max_len);
|
||||
if (!info_log)
|
||||
return;
|
||||
|
||||
pglGetProgramInfoLog(obj, max_len, &info_len, info_log);
|
||||
|
||||
if (info_len > 0)
|
||||
SSNES_LOG("Linker log: %s\n", info_log);
|
||||
|
||||
free(info_log);
|
||||
}
|
||||
|
||||
static bool compile_shader(GLuint shader, const char *program)
|
||||
@@ -906,10 +928,10 @@ bool gl_glsl_init(const char *path)
|
||||
return false;
|
||||
}
|
||||
|
||||
struct shader_program stock_prog = {
|
||||
.vertex = strdup(stock_vertex),
|
||||
.fragment = strdup(stock_fragment),
|
||||
};
|
||||
struct shader_program stock_prog = {0};
|
||||
stock_prog.vertex = strdup(stock_vertex);
|
||||
stock_prog.fragment = strdup(stock_fragment);
|
||||
|
||||
if (!compile_programs(&gl_program[0], &stock_prog, 1))
|
||||
return false;
|
||||
|
||||
@@ -958,15 +980,14 @@ bool gl_glsl_init(const char *path)
|
||||
|
||||
if (gl_tracker_info_cnt > 0)
|
||||
{
|
||||
struct snes_tracker_info info = {
|
||||
.wram = psnes_get_memory_data(SNES_MEMORY_WRAM),
|
||||
.vram = psnes_get_memory_data(SNES_MEMORY_VRAM),
|
||||
.cgram = psnes_get_memory_data(SNES_MEMORY_CGRAM),
|
||||
.apuram = psnes_get_memory_data(SNES_MEMORY_APURAM),
|
||||
.oam = psnes_get_memory_data(SNES_MEMORY_OAM),
|
||||
.info = gl_tracker_info,
|
||||
.info_elem = gl_tracker_info_cnt,
|
||||
};
|
||||
struct snes_tracker_info info = {0};
|
||||
info.wram = psnes_get_memory_data(SNES_MEMORY_WRAM);
|
||||
info.vram = psnes_get_memory_data(SNES_MEMORY_VRAM);
|
||||
info.cgram = psnes_get_memory_data(SNES_MEMORY_CGRAM);
|
||||
info.apuram = psnes_get_memory_data(SNES_MEMORY_APURAM);
|
||||
info.oam = psnes_get_memory_data(SNES_MEMORY_OAM);
|
||||
info.info = gl_tracker_info;
|
||||
info.info_elem = gl_tracker_info_cnt;
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
if (*gl_tracker_script)
|
||||
@@ -999,7 +1020,7 @@ void gl_glsl_deinit(void)
|
||||
if (glsl_enable)
|
||||
{
|
||||
pglUseProgram(0);
|
||||
for (int i = 0; i <= gl_num_programs; i++)
|
||||
for (unsigned i = 0; i <= gl_num_programs; i++)
|
||||
{
|
||||
if (gl_program[i] == 0)
|
||||
continue;
|
||||
@@ -1064,15 +1085,15 @@ void gl_glsl_set_params(unsigned width, unsigned height,
|
||||
|
||||
GLint location;
|
||||
|
||||
float inputSize[2] = {width, height};
|
||||
float inputSize[2] = {(float)width, (float)height};
|
||||
location = pglGetUniformLocation(gl_program[active_index], "rubyInputSize");
|
||||
pglUniform2fv(location, 1, inputSize);
|
||||
|
||||
float outputSize[2] = {out_width, out_height};
|
||||
float outputSize[2] = {(float)out_width, (float)out_height};
|
||||
location = pglGetUniformLocation(gl_program[active_index], "rubyOutputSize");
|
||||
pglUniform2fv(location, 1, outputSize);
|
||||
|
||||
float textureSize[2] = {tex_width, tex_height};
|
||||
float textureSize[2] = {(float)tex_width, (float)tex_height};
|
||||
location = pglGetUniformLocation(gl_program[active_index], "rubyTextureSize");
|
||||
pglUniform2fv(location, 1, textureSize);
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef __SSNES_GLSL_H
|
||||
#define __SSNES_GLSL_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include "gl_common.h"
|
||||
|
||||
bool gl_glsl_init(const char *path);
|
||||
|
||||
+6
-7
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -17,10 +17,9 @@
|
||||
|
||||
#include "snes_state.h"
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include "strl.h"
|
||||
#include "general.h"
|
||||
#include <libsnes.hpp>
|
||||
#include "../strl.h"
|
||||
#include "../general.h"
|
||||
#include "../libsnes.hpp"
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
#include "py_state/py_state.h"
|
||||
@@ -63,7 +62,7 @@ struct snes_tracker
|
||||
|
||||
snes_tracker_t* snes_tracker_init(const struct snes_tracker_info *info)
|
||||
{
|
||||
snes_tracker_t *tracker = calloc(1, sizeof(*tracker));
|
||||
snes_tracker_t *tracker = (snes_tracker_t*)calloc(1, sizeof(*tracker));
|
||||
if (!tracker)
|
||||
return NULL;
|
||||
|
||||
@@ -80,7 +79,7 @@ snes_tracker_t* snes_tracker_init(const struct snes_tracker_info *info)
|
||||
}
|
||||
#endif
|
||||
|
||||
tracker->info = calloc(info->info_elem, sizeof(struct snes_tracker_internal));
|
||||
tracker->info = (struct snes_tracker_internal*)calloc(info->info_elem, sizeof(struct snes_tracker_internal));
|
||||
tracker->info_elem = info->info_elem;
|
||||
|
||||
for (unsigned i = 0; i < info->info_elem; i++)
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -19,7 +19,7 @@
|
||||
#define __SSNES_SNES_STATE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
|
||||
+58
-54
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -37,8 +37,7 @@
|
||||
|
||||
// Adapted from bSNES and MPlayer source.
|
||||
|
||||
typedef struct xv xv_t;
|
||||
struct xv
|
||||
typedef struct xv
|
||||
{
|
||||
Display *display;
|
||||
GC gc;
|
||||
@@ -76,12 +75,12 @@ struct xv
|
||||
uint8_t font_v;
|
||||
#endif
|
||||
|
||||
void (*render_func)(xv_t*, const void *frame, unsigned width, unsigned height, unsigned pitch);
|
||||
};
|
||||
void (*render_func)(struct xv*, const void *frame, unsigned width, unsigned height, unsigned pitch);
|
||||
} xv_t;
|
||||
|
||||
static void xv_set_nonblock_state(void *data, bool state)
|
||||
{
|
||||
xv_t *xv = data;
|
||||
xv_t *xv = (xv_t*)data;
|
||||
Atom atom = XInternAtom(xv->display, "XV_SYNC_TO_VBLANK", true);
|
||||
if (atom != None && xv->port)
|
||||
XvSetPortAttribute(xv->display, xv->port, atom, !state);
|
||||
@@ -108,9 +107,9 @@ static inline void calculate_yuv(uint8_t *y, uint8_t *u, uint8_t *v, unsigned r,
|
||||
|
||||
static void init_yuv_tables(xv_t *xv)
|
||||
{
|
||||
xv->ytable = malloc(0x8000);
|
||||
xv->utable = malloc(0x8000);
|
||||
xv->vtable = malloc(0x8000);
|
||||
xv->ytable = (uint8_t*)malloc(0x8000);
|
||||
xv->utable = (uint8_t*)malloc(0x8000);
|
||||
xv->vtable = (uint8_t*)malloc(0x8000);
|
||||
|
||||
for (unsigned i = 0; i < 0x8000; i++)
|
||||
{
|
||||
@@ -217,7 +216,7 @@ static void xv_init_font(xv_t *xv, const char *font_path, unsigned font_size)
|
||||
// We render @ 2x scale to combat chroma downsampling. Also makes fonts more bearable :)
|
||||
static void render16_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned height, unsigned pitch)
|
||||
{
|
||||
const uint16_t *input = input_;
|
||||
const uint16_t *input = (const uint16_t*)input_;
|
||||
uint8_t *output = (uint8_t*)xv->image->data;
|
||||
|
||||
for (unsigned y = 0; y < height; y++)
|
||||
@@ -245,7 +244,7 @@ static void render16_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned
|
||||
|
||||
static void render16_uyvy(xv_t *xv, const void *input_, unsigned width, unsigned height, unsigned pitch)
|
||||
{
|
||||
const uint16_t *input = input_;
|
||||
const uint16_t *input = (const uint16_t*)input_;
|
||||
uint8_t *output = (uint8_t*)xv->image->data;
|
||||
|
||||
for (unsigned y = 0; y < height; y++)
|
||||
@@ -273,7 +272,7 @@ static void render16_uyvy(xv_t *xv, const void *input_, unsigned width, unsigned
|
||||
|
||||
static void render32_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned height, unsigned pitch)
|
||||
{
|
||||
const uint32_t *input = input_;
|
||||
const uint32_t *input = (const uint32_t*)input_;
|
||||
uint8_t *output = (uint8_t*)xv->image->data;
|
||||
|
||||
for (unsigned y = 0; y < height; y++)
|
||||
@@ -302,7 +301,7 @@ static void render32_yuy2(xv_t *xv, const void *input_, unsigned width, unsigned
|
||||
|
||||
static void render32_uyvy(xv_t *xv, const void *input_, unsigned width, unsigned height, unsigned pitch)
|
||||
{
|
||||
const uint32_t *input = input_;
|
||||
const uint32_t *input = (const uint32_t*)input_;
|
||||
uint16_t *output = (uint16_t*)xv->image->data;
|
||||
|
||||
for (unsigned y = 0; y < height; y++)
|
||||
@@ -343,20 +342,20 @@ struct format_desc
|
||||
|
||||
static const struct format_desc formats[] = {
|
||||
{
|
||||
.render_16 = render16_yuy2,
|
||||
.render_32 = render32_yuy2,
|
||||
.components = { 'Y', 'U', 'Y', 'V' },
|
||||
.luma_index = { 0, 2 },
|
||||
.u_index = 1,
|
||||
.v_index = 3,
|
||||
render16_yuy2,
|
||||
render32_yuy2,
|
||||
{ 'Y', 'U', 'Y', 'V' },
|
||||
{ 0, 2 },
|
||||
1,
|
||||
3,
|
||||
},
|
||||
{
|
||||
.render_16 = render16_uyvy,
|
||||
.render_32 = render32_uyvy,
|
||||
.components = { 'U', 'Y', 'V', 'Y' },
|
||||
.luma_index = { 1, 3 },
|
||||
.u_index = 0,
|
||||
.v_index = 2,
|
||||
render16_uyvy,
|
||||
render32_uyvy,
|
||||
{ 'U', 'Y', 'V', 'Y' },
|
||||
{ 1, 3 },
|
||||
0,
|
||||
2,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -400,11 +399,21 @@ static bool adaptor_set_format(xv_t *xv, Display *dpy, XvPortID port, const vide
|
||||
|
||||
static void *xv_init(const video_info_t *video, const input_driver_t **input, void **input_data)
|
||||
{
|
||||
xv_t *xv = calloc(1, sizeof(*xv));
|
||||
xv_t *xv = (xv_t*)calloc(1, sizeof(*xv));
|
||||
if (!xv)
|
||||
return NULL;
|
||||
|
||||
xv->display = XOpenDisplay(NULL);
|
||||
struct sigaction sa;
|
||||
unsigned adaptor_count = 0;
|
||||
int visualmatches = 0;
|
||||
XSetWindowAttributes attributes = {0};
|
||||
unsigned width = 0, height = 0;
|
||||
char buf[128];
|
||||
Atom atom = 0;
|
||||
void *xinput = NULL;
|
||||
XVisualInfo *visualinfo = NULL;
|
||||
XVisualInfo visualtemplate = {0};
|
||||
|
||||
if (!XShmQueryExtension(xv->display))
|
||||
{
|
||||
@@ -417,7 +426,6 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
// Find an appropriate Xv port.
|
||||
xv->port = 0;
|
||||
XvAdaptorInfo *adaptor_info;
|
||||
unsigned adaptor_count = 0;
|
||||
XvQueryAdaptors(xv->display, DefaultRootWindow(xv->display), &adaptor_count, &adaptor_info);
|
||||
for (unsigned i = 0; i < adaptor_count; i++)
|
||||
{
|
||||
@@ -442,13 +450,11 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
goto error;
|
||||
}
|
||||
|
||||
XVisualInfo visualtemplate;
|
||||
visualtemplate.visualid = xv->visualid;
|
||||
visualtemplate.screen = DefaultScreen(xv->display);
|
||||
visualtemplate.depth = xv->depth;
|
||||
visualtemplate.visual = 0;
|
||||
int visualmatches = 0;
|
||||
XVisualInfo *visualinfo = XGetVisualInfo(xv->display, VisualIDMask | VisualScreenMask | VisualDepthMask, &visualtemplate, &visualmatches);
|
||||
visualinfo = XGetVisualInfo(xv->display, VisualIDMask | VisualScreenMask | VisualDepthMask, &visualtemplate, &visualmatches);
|
||||
if (visualmatches < 1 || !visualinfo->visual)
|
||||
{
|
||||
if (visualinfo) XFree(visualinfo);
|
||||
@@ -457,13 +463,12 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
}
|
||||
|
||||
xv->colormap = XCreateColormap(xv->display, DefaultRootWindow(xv->display), visualinfo->visual, AllocNone);
|
||||
XSetWindowAttributes attributes;
|
||||
attributes.colormap = xv->colormap;
|
||||
attributes.border_pixel = 0;
|
||||
attributes.event_mask = StructureNotifyMask | DestroyNotify | ClientMessage;
|
||||
|
||||
unsigned width = video->fullscreen ? ((video->width == 0) ? g_extern.system.geom.base_width : video->width) : video->width;
|
||||
unsigned height = video->fullscreen ? ((video->height == 0) ? g_extern.system.geom.base_height : video->height) : video->height;
|
||||
width = video->fullscreen ? ((video->width == 0) ? g_extern.system.geom.base_width : video->width) : video->width;
|
||||
height = video->fullscreen ? ((video->height == 0) ? g_extern.system.geom.base_height : video->height) : video->height;
|
||||
xv->window = XCreateWindow(xv->display, DefaultRootWindow(xv->display),
|
||||
0, 0, width, height,
|
||||
0, xv->depth, InputOutput, visualinfo->visual,
|
||||
@@ -474,7 +479,6 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
|
||||
XMapWindow(xv->display, xv->window);
|
||||
|
||||
char buf[128];
|
||||
if (gfx_window_title(buf, sizeof(buf)))
|
||||
XStoreName(xv->display, xv->window, buf);
|
||||
|
||||
@@ -485,7 +489,7 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
xv->gc = XCreateGC(xv->display, xv->window, 0, 0);
|
||||
|
||||
// Set colorkey to auto paint, so that Xv video output is always visible
|
||||
Atom atom = XInternAtom(xv->display, "XV_AUTOPAINT_COLORKEY", true);
|
||||
atom = XInternAtom(xv->display, "XV_AUTOPAINT_COLORKEY", true);
|
||||
if (atom != None) XvSetPortAttribute(xv->display, xv->port, atom, 1);
|
||||
|
||||
xv->width = g_extern.system.geom.max_width;
|
||||
@@ -501,7 +505,7 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
xv->height = xv->image->height;
|
||||
|
||||
xv->shminfo.shmid = shmget(IPC_PRIVATE, xv->image->data_size, IPC_CREAT | 0777);
|
||||
xv->shminfo.shmaddr = xv->image->data = shmat(xv->shminfo.shmid, NULL, 0);
|
||||
xv->shminfo.shmaddr = xv->image->data = (char*)shmat(xv->shminfo.shmid, NULL, 0);
|
||||
xv->shminfo.readOnly = false;
|
||||
if (!XShmAttach(xv->display, &xv->shminfo))
|
||||
{
|
||||
@@ -515,7 +519,6 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
if (xv->quit_atom)
|
||||
XSetWMProtocols(xv->display, xv->window, &xv->quit_atom, 1);
|
||||
|
||||
struct sigaction sa;
|
||||
sa.sa_handler = sighandler;
|
||||
sa.sa_flags = SA_RESTART;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
@@ -525,7 +528,7 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
xv_set_nonblock_state(xv, !video->vsync);
|
||||
xv->focus = true;
|
||||
|
||||
void *xinput = input_x.init();
|
||||
xinput = input_x.init();
|
||||
if (xinput)
|
||||
{
|
||||
*input = &input_x;
|
||||
@@ -575,7 +578,7 @@ static bool check_resize(xv_t *xv, unsigned width, unsigned height)
|
||||
return false;
|
||||
}
|
||||
|
||||
xv->shminfo.shmaddr = xv->image->data = shmat(xv->shminfo.shmid, NULL, 0);
|
||||
xv->shminfo.shmaddr = xv->image->data = (char*)shmat(xv->shminfo.shmid, NULL, 0);
|
||||
xv->shminfo.readOnly = false;
|
||||
|
||||
if (!XShmAttach(xv->display, &xv->shminfo))
|
||||
@@ -648,13 +651,13 @@ static void xv_render_msg(xv_t *xv, const char *msg, unsigned width, unsigned he
|
||||
int base_y = _base_y - head->off_y;
|
||||
if (base_y >= 0)
|
||||
{
|
||||
for (int y = 0; y < head->height && (base_y + y) < height; y++)
|
||||
for (int y = 0; y < (int)head->height && (base_y + y) < height; y++)
|
||||
{
|
||||
if (base_x < 0)
|
||||
continue;
|
||||
|
||||
const uint8_t * restrict a = head->output + head->pitch * y;
|
||||
uint8_t * restrict out = (uint8_t*)xv->image->data + (base_y - head->height + y) * pitch + base_x;
|
||||
const uint8_t *a = head->output + head->pitch * y;
|
||||
uint8_t *out = (uint8_t*)xv->image->data + (base_y - head->height + y) * pitch + base_x;
|
||||
|
||||
for (int x = 0; x < (head->width << 1) && (base_x + x) < pitch; x += 4)
|
||||
{
|
||||
@@ -698,7 +701,7 @@ static void xv_render_msg(xv_t *xv, const char *msg, unsigned width, unsigned he
|
||||
|
||||
static bool xv_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg)
|
||||
{
|
||||
xv_t *xv = data;
|
||||
xv_t *xv = (xv_t*)data;
|
||||
|
||||
if (!check_resize(xv, width, height))
|
||||
return false;
|
||||
@@ -728,7 +731,7 @@ static bool xv_frame(void *data, const void *frame, unsigned width, unsigned hei
|
||||
|
||||
static bool xv_alive(void *data)
|
||||
{
|
||||
xv_t *xv = data;
|
||||
xv_t *xv = (xv_t*)data;
|
||||
|
||||
XEvent event;
|
||||
while (XPending(xv->display))
|
||||
@@ -737,7 +740,7 @@ static bool xv_alive(void *data)
|
||||
switch (event.type)
|
||||
{
|
||||
case ClientMessage:
|
||||
if (event.xclient.data.l[0] == xv->quit_atom)
|
||||
if ((Atom)event.xclient.data.l[0] == xv->quit_atom)
|
||||
return false;
|
||||
break;
|
||||
case DestroyNotify:
|
||||
@@ -758,14 +761,14 @@ static bool xv_alive(void *data)
|
||||
|
||||
static bool xv_focus(void *data)
|
||||
{
|
||||
xv_t *xv = data;
|
||||
xv_t *xv = (xv_t*)data;
|
||||
return xv->focus;
|
||||
}
|
||||
|
||||
|
||||
static void xv_free(void *data)
|
||||
{
|
||||
xv_t *xv = data;
|
||||
xv_t *xv = (xv_t*)data;
|
||||
XShmDetach(xv->display, &xv->shminfo);
|
||||
shmdt(xv->shminfo.shmaddr);
|
||||
shmctl(xv->shminfo.shmid, IPC_RMID, NULL);
|
||||
@@ -791,12 +794,13 @@ static void xv_free(void *data)
|
||||
}
|
||||
|
||||
const video_driver_t video_xvideo = {
|
||||
.init = xv_init,
|
||||
.frame = xv_frame,
|
||||
.alive = xv_alive,
|
||||
.set_nonblock_state = xv_set_nonblock_state,
|
||||
.focus = xv_focus,
|
||||
.free = xv_free,
|
||||
.ident = "xvideo"
|
||||
xv_init,
|
||||
xv_frame,
|
||||
xv_set_nonblock_state,
|
||||
xv_alive,
|
||||
xv_focus,
|
||||
NULL,
|
||||
xv_free,
|
||||
"xvideo"
|
||||
};
|
||||
|
||||
+15
-5
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "ssnes_dinput.h"
|
||||
#include "SDL.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
@@ -46,7 +46,7 @@ void sdl_dinput_free(sdl_dinput_t *di)
|
||||
|
||||
static BOOL CALLBACK enum_axes_cb(const DIDEVICEOBJECTINSTANCE *inst, void *p)
|
||||
{
|
||||
LPDIRECTINPUTDEVICE8 joypad = p;
|
||||
LPDIRECTINPUTDEVICE8 joypad = (LPDIRECTINPUTDEVICE8)p;
|
||||
|
||||
DIPROPRANGE range;
|
||||
memset(&range, 0, sizeof(range));
|
||||
@@ -63,7 +63,7 @@ static BOOL CALLBACK enum_axes_cb(const DIDEVICEOBJECTINSTANCE *inst, void *p)
|
||||
|
||||
static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
||||
{
|
||||
sdl_dinput_t *di = p;
|
||||
sdl_dinput_t *di = (sdl_dinput_t*)p;
|
||||
|
||||
unsigned active = 0;
|
||||
unsigned n;
|
||||
@@ -82,7 +82,11 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
||||
if (n == MAX_PLAYERS)
|
||||
return DIENUM_CONTINUE;
|
||||
|
||||
#ifdef __cplusplus
|
||||
if (FAILED(IDirectInput8_CreateDevice(di->ctx, inst->guidInstance, &di->joypad[n], NULL)))
|
||||
#else
|
||||
if (FAILED(IDirectInput8_CreateDevice(di->ctx, &inst->guidInstance, &di->joypad[n], NULL)))
|
||||
#endif
|
||||
return DIENUM_CONTINUE;
|
||||
|
||||
IDirectInputDevice8_SetDataFormat(di->joypad[n], &c_dfDIJoystick2);
|
||||
@@ -97,7 +101,7 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
||||
|
||||
sdl_dinput_t* sdl_dinput_init(void)
|
||||
{
|
||||
sdl_dinput_t *di = calloc(1, sizeof(*di));
|
||||
sdl_dinput_t *di = (sdl_dinput_t*)calloc(1, sizeof(*di));
|
||||
if (!di)
|
||||
return NULL;
|
||||
|
||||
@@ -118,9 +122,15 @@ sdl_dinput_t* sdl_dinput_init(void)
|
||||
di->hWnd = info.window;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
if (FAILED(DirectInput8Create(
|
||||
GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8,
|
||||
(void**)&di->ctx, NULL)))
|
||||
#else
|
||||
if (FAILED(DirectInput8Create(
|
||||
GetModuleHandle(NULL), DIRECTINPUT_VERSION, &IID_IDirectInput8,
|
||||
(void**)&di->ctx, NULL)))
|
||||
#endif
|
||||
{
|
||||
SSNES_ERR("Failed to init DirectInput.\n");
|
||||
goto error;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -15,14 +15,14 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
#include "../driver.h"
|
||||
|
||||
#include "../gfx/sdlwrap.h"
|
||||
#include <stdbool.h>
|
||||
#include "general.h"
|
||||
#include "../boolean.h"
|
||||
#include "../general.h"
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <libsnes.hpp>
|
||||
#include "../libsnes.hpp"
|
||||
#include "ssnes_sdl_input.h"
|
||||
#include "keysym.h"
|
||||
|
||||
@@ -126,7 +126,7 @@ static void init_lut(void)
|
||||
static void *sdl_input_init(void)
|
||||
{
|
||||
init_lut();
|
||||
sdl_input_t *sdl = calloc(1, sizeof(*sdl));
|
||||
sdl_input_t *sdl = (sdl_input_t*)calloc(1, sizeof(*sdl));
|
||||
if (!sdl)
|
||||
return NULL;
|
||||
|
||||
@@ -189,7 +189,7 @@ static bool sdl_joykey_pressed(sdl_input_t *sdl, int port_num, uint16_t joykey)
|
||||
if (GET_HAT_DIR(joykey))
|
||||
{
|
||||
int hat = GET_HAT(joykey);
|
||||
if (hat < sdl->num_hats[port_num])
|
||||
if (hat < (int)sdl->num_hats[port_num])
|
||||
{
|
||||
Uint8 dir = SDL_JoystickGetHat(sdl->joysticks[port_num], hat);
|
||||
switch (GET_HAT_DIR(joykey))
|
||||
@@ -273,7 +273,7 @@ static bool sdl_bind_button_pressed(void *data, int key)
|
||||
for (unsigned i = 0; binds[i].id != -1; i++)
|
||||
{
|
||||
if (binds[i].id == key)
|
||||
return sdl_is_pressed(data, 0, &binds[i]);
|
||||
return sdl_is_pressed((sdl_input_t*)data, 0, &binds[i]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -352,8 +352,9 @@ static int16_t sdl_justifier_device_state(sdl_input_t *sdl, unsigned index, unsi
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t sdl_input_state(void *data, const struct snes_keybind **binds, bool port, unsigned device, unsigned index, unsigned id)
|
||||
static int16_t sdl_input_state(void *data_, const struct snes_keybind **binds, bool port, unsigned device, unsigned index, unsigned id)
|
||||
{
|
||||
sdl_input_t *data = (sdl_input_t*)data_;
|
||||
switch (device)
|
||||
{
|
||||
case SNES_DEVICE_JOYPAD:
|
||||
@@ -381,7 +382,7 @@ static void sdl_input_free(void *data)
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event));
|
||||
|
||||
sdl_input_t *sdl = data;
|
||||
sdl_input_t *sdl = (sdl_input_t*)data;
|
||||
|
||||
#ifdef HAVE_DINPUT
|
||||
sdl_dinput_free(sdl->di);
|
||||
@@ -412,7 +413,7 @@ static void sdl_poll_mouse(sdl_input_t *sdl)
|
||||
static void sdl_input_poll(void *data)
|
||||
{
|
||||
SDL_PumpEvents();
|
||||
sdl_input_t *sdl = data;
|
||||
sdl_input_t *sdl = (sdl_input_t*)data;
|
||||
|
||||
#ifdef HAVE_DINPUT
|
||||
sdl_dinput_poll(sdl->di);
|
||||
@@ -424,11 +425,11 @@ static void sdl_input_poll(void *data)
|
||||
}
|
||||
|
||||
const input_driver_t input_sdl = {
|
||||
.init = sdl_input_init,
|
||||
.poll = sdl_input_poll,
|
||||
.input_state = sdl_input_state,
|
||||
.key_pressed = sdl_bind_button_pressed,
|
||||
.free = sdl_input_free,
|
||||
.ident = "sdl"
|
||||
sdl_input_init,
|
||||
sdl_input_poll,
|
||||
sdl_input_state,
|
||||
sdl_bind_button_pressed,
|
||||
sdl_input_free,
|
||||
"sdl"
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -22,8 +22,8 @@
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
|
||||
#include <dinput.h>
|
||||
#include <stdbool.h>
|
||||
#include "general.h"
|
||||
#include "../boolean.h"
|
||||
#include "../general.h"
|
||||
|
||||
// Piggyback joypad driver for SDL.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -19,7 +19,7 @@
|
||||
#define __SSNES_SDL_INPUT_H
|
||||
|
||||
#include "SDL.h"
|
||||
#include "general.h"
|
||||
#include "../general.h"
|
||||
|
||||
#ifdef HAVE_DINPUT
|
||||
#include "ssnes_dinput.h"
|
||||
|
||||
+15
-15
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "driver.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include <stdbool.h>
|
||||
#include "../boolean.h"
|
||||
#include "general.h"
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
@@ -135,7 +135,7 @@ static void init_lut(void)
|
||||
|
||||
static void *x_input_init(void)
|
||||
{
|
||||
x11_input_t *x11 = calloc(1, sizeof(*x11));
|
||||
x11_input_t *x11 = (x11_input_t*)calloc(1, sizeof(*x11));
|
||||
if (!x11)
|
||||
return NULL;
|
||||
|
||||
@@ -146,7 +146,7 @@ static void *x_input_init(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
x11->sdl = input_sdl.init();
|
||||
x11->sdl = (sdl_input_t*)input_sdl.init();
|
||||
if (!x11->sdl)
|
||||
{
|
||||
free(x11);
|
||||
@@ -171,7 +171,7 @@ static bool x_is_pressed(x11_input_t *x11, const struct snes_keybind *binds, uns
|
||||
{
|
||||
for (int i = 0; binds[i].id != -1; i++)
|
||||
{
|
||||
if (binds[i].id == id)
|
||||
if (binds[i].id == (int)id)
|
||||
return x_key_pressed(x11, binds[i].key);
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ static bool x_is_pressed(x11_input_t *x11, const struct snes_keybind *binds, uns
|
||||
|
||||
static bool x_bind_button_pressed(void *data, int key)
|
||||
{
|
||||
x11_input_t *x11 = data;
|
||||
x11_input_t *x11 = (x11_input_t*)data;
|
||||
bool pressed = x_is_pressed(x11, g_settings.input.binds[0], key);
|
||||
if (!pressed)
|
||||
return input_sdl.key_pressed(x11->sdl, key);
|
||||
@@ -189,7 +189,7 @@ static bool x_bind_button_pressed(void *data, int key)
|
||||
|
||||
static int16_t x_input_state(void *data, const struct snes_keybind **binds, bool port, unsigned device, unsigned index, unsigned id)
|
||||
{
|
||||
x11_input_t *x11 = data;
|
||||
x11_input_t *x11 = (x11_input_t*)data;
|
||||
bool pressed = false;
|
||||
|
||||
switch (device)
|
||||
@@ -213,7 +213,7 @@ static int16_t x_input_state(void *data, const struct snes_keybind **binds, bool
|
||||
|
||||
static void x_input_free(void *data)
|
||||
{
|
||||
x11_input_t *x11 = data;
|
||||
x11_input_t *x11 = (x11_input_t*)data;
|
||||
input_sdl.free(x11->sdl);
|
||||
XCloseDisplay(x11->display);
|
||||
free(data);
|
||||
@@ -221,17 +221,17 @@ static void x_input_free(void *data)
|
||||
|
||||
static void x_input_poll(void *data)
|
||||
{
|
||||
x11_input_t *x11 = data;
|
||||
x11_input_t *x11 = (x11_input_t*)data;
|
||||
XQueryKeymap(x11->display, x11->state);
|
||||
input_sdl.poll(x11->sdl);
|
||||
}
|
||||
|
||||
const input_driver_t input_x = {
|
||||
.init = x_input_init,
|
||||
.poll = x_input_poll,
|
||||
.input_state = x_input_state,
|
||||
.key_pressed = x_bind_button_pressed,
|
||||
.free = x_input_free,
|
||||
.ident = "x"
|
||||
x_input_init,
|
||||
x_input_poll,
|
||||
x_input_state,
|
||||
x_bind_button_pressed,
|
||||
x_input_free,
|
||||
"x"
|
||||
};
|
||||
|
||||
+32
-8
@@ -67,14 +67,38 @@ extern "C" {
|
||||
#define SNES_MEMORY_CGRAM 104
|
||||
|
||||
// SSNES extension. Not required to be implemented for a working implementation.
|
||||
#define SNES_ENVIRONMENT_GET_FULLPATH 0 // const char ** -- Full path of game loaded.
|
||||
#define SNES_ENVIRONMENT_SET_GEOMETRY 1 // const struct snes_geometry * -- Window geometry information for the system/game.
|
||||
#define SNES_ENVIRONMENT_SET_PITCH 2 // const unsigned * -- Pitch of game image.
|
||||
#define SNES_ENVIRONMENT_GET_OVERSCAN 3 // bool * -- Boolean value whether or not the implementation should use overscan.
|
||||
#define SNES_ENVIRONMENT_SET_TIMING 4 // const struct snes_system_timing * -- Set exact timings of the system.
|
||||
// Used primarily for video recording.
|
||||
#define SNES_ENVIRONMENT_GET_CAN_DUPE 5 // bool * -- Boolean value whether or not SSNES supports frame duping,
|
||||
// passing NULL to video frame callback.
|
||||
#define SNES_ENVIRONMENT_GET_FULLPATH 0 // const char ** --
|
||||
// Full path of game loaded.
|
||||
//
|
||||
#define SNES_ENVIRONMENT_SET_GEOMETRY 1 // const struct snes_geometry * --
|
||||
// Window geometry information for the system/game.
|
||||
//
|
||||
#define SNES_ENVIRONMENT_SET_PITCH 2 // const unsigned * --
|
||||
// Pitch of game image.
|
||||
//
|
||||
#define SNES_ENVIRONMENT_GET_OVERSCAN 3 // bool * --
|
||||
// Boolean value whether or not the implementation should use overscan.
|
||||
//
|
||||
#define SNES_ENVIRONMENT_SET_TIMING 4 // const struct snes_system_timing * --
|
||||
// Set exact timings of the system. Used primarily for video recording.
|
||||
//
|
||||
#define SNES_ENVIRONMENT_GET_CAN_DUPE 5 // bool * --
|
||||
// Boolean value whether or not SSNES supports frame duping,
|
||||
// passing NULL to video frame callback.
|
||||
//
|
||||
//
|
||||
#define SNES_ENVIRONMENT_SET_NEED_FULLPATH 6 // const bool * --
|
||||
// Boolean value telling if implementation needs a valid fullpath to be able to run.
|
||||
// If this is the case, SSNES will not open the rom directly,
|
||||
// and pass NULL to rom data.
|
||||
// Implementation must then use SNES_ENVIRONMENT_GET_FULLPATH.
|
||||
// This is useful for implementations with very large roms,
|
||||
// which are impractical to load fully into RAM.
|
||||
//
|
||||
#define SNES_ENVIRONMENT_GET_CAN_REWIND 7 // bool * --
|
||||
// Boolean value telling if SSNES is able to rewind.
|
||||
// Some implementations might need to take extra precautions
|
||||
// to allow this as smoothly as possible.
|
||||
|
||||
struct snes_geometry
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -18,7 +18,8 @@
|
||||
#include "message.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include "boolean.h"
|
||||
#include "posix_string.h"
|
||||
|
||||
struct queue_elem
|
||||
{
|
||||
@@ -37,12 +38,12 @@ struct msg_queue
|
||||
|
||||
msg_queue_t *msg_queue_new(size_t size)
|
||||
{
|
||||
msg_queue_t *queue = calloc(1, sizeof(*queue));
|
||||
msg_queue_t *queue = (msg_queue_t*)calloc(1, sizeof(*queue));
|
||||
if (!queue)
|
||||
return NULL;
|
||||
|
||||
queue->size = size + 1;
|
||||
queue->elems = calloc(queue->size, sizeof(struct queue_elem*));
|
||||
queue->elems = (struct queue_elem**)calloc(queue->size, sizeof(struct queue_elem*));
|
||||
|
||||
if (!queue->elems)
|
||||
{
|
||||
@@ -65,7 +66,7 @@ void msg_queue_push(msg_queue_t *queue, const char *msg, unsigned prio, unsigned
|
||||
if (queue->ptr >= queue->size)
|
||||
return;
|
||||
|
||||
struct queue_elem *new_elem = calloc(1, sizeof(struct queue_elem));
|
||||
struct queue_elem *new_elem = (struct queue_elem*)calloc(1, sizeof(struct queue_elem));
|
||||
new_elem->prio = prio;
|
||||
new_elem->duration = duration;
|
||||
new_elem->msg = msg ? strdup(msg) : NULL;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -18,9 +18,9 @@
|
||||
#include "movie.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "general.h"
|
||||
#include "dynamic.h"
|
||||
#include <assert.h>
|
||||
|
||||
// CRC32 implementation taken from BSNES source :)
|
||||
|
||||
@@ -115,6 +115,14 @@ static inline uint32_t swap_if_big32(uint32_t val)
|
||||
return (val >> 24) | ((val >> 8) & 0xFF00) | ((val << 8) & 0xFF0000) | (val << 24);
|
||||
}
|
||||
|
||||
static inline uint32_t swap_if_little32(uint32_t val)
|
||||
{
|
||||
if (!is_little_endian()) // Big-endian
|
||||
return val;
|
||||
else
|
||||
return (val >> 24) | ((val >> 8) & 0xFF00) | ((val << 8) & 0xFF0000) | (val << 24);
|
||||
}
|
||||
|
||||
static inline uint16_t swap_if_big16(uint16_t val)
|
||||
{
|
||||
if (is_little_endian())
|
||||
@@ -140,7 +148,8 @@ static bool init_playback(bsv_movie_t *handle, const char *path)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (swap_if_big32(header[MAGIC_INDEX]) != BSV_MAGIC)
|
||||
// Compatibility with old implementation that used incorrect documentation.
|
||||
if (swap_if_little32(header[MAGIC_INDEX]) != BSV_MAGIC && swap_if_big32(header[MAGIC_INDEX]) != BSV_MAGIC)
|
||||
{
|
||||
SSNES_ERR("Movie file is not a valid BSV1 file!\n");
|
||||
return false;
|
||||
@@ -157,7 +166,7 @@ static bool init_playback(bsv_movie_t *handle, const char *path)
|
||||
// If we're playing back from the start, state_size is 0.
|
||||
if (state_size)
|
||||
{
|
||||
handle->state = malloc(state_size);
|
||||
handle->state = (uint8_t*)malloc(state_size);
|
||||
if (!handle->state)
|
||||
return false;
|
||||
|
||||
@@ -170,7 +179,7 @@ static bool init_playback(bsv_movie_t *handle, const char *path)
|
||||
if (psnes_serialize_size() != state_size)
|
||||
{
|
||||
SSNES_ERR("Movie format seems to have a different serializer version. Cannot continue.\n");
|
||||
exit(1);
|
||||
ssnes_fail(1, "init_playback()");
|
||||
}
|
||||
|
||||
// Unserialize to start playback.
|
||||
@@ -192,7 +201,10 @@ static bool init_record(bsv_movie_t *handle, const char *path)
|
||||
}
|
||||
|
||||
uint32_t header[4] = {0};
|
||||
header[MAGIC_INDEX] = swap_if_big32(BSV_MAGIC);
|
||||
|
||||
// This value is supposed to show up as BSV1 in a HEX editor.
|
||||
header[MAGIC_INDEX] = swap_if_little32(BSV_MAGIC);
|
||||
|
||||
header[CRC_INDEX] = swap_if_big32(g_extern.cart_crc);
|
||||
|
||||
uint32_t state_size = psnes_serialize_size();
|
||||
@@ -200,7 +212,7 @@ static bool init_record(bsv_movie_t *handle, const char *path)
|
||||
header[STATE_SIZE_INDEX] = swap_if_big32(state_size);
|
||||
fwrite(header, 4, sizeof(uint32_t), handle->file);
|
||||
|
||||
handle->state = malloc(state_size);
|
||||
handle->state = (uint8_t*)malloc(state_size);
|
||||
if (!handle->state)
|
||||
return false;
|
||||
|
||||
@@ -238,12 +250,13 @@ bool bsv_movie_get_input(bsv_movie_t *handle, int16_t *input)
|
||||
|
||||
void bsv_movie_set_input(bsv_movie_t *handle, int16_t input)
|
||||
{
|
||||
input = swap_if_big16(input);
|
||||
fwrite(&input, sizeof(int16_t), 1, handle->file);
|
||||
}
|
||||
|
||||
bsv_movie_t *bsv_movie_init(const char *path, enum ssnes_movie_type type)
|
||||
{
|
||||
bsv_movie_t *handle = calloc(1, sizeof(*handle));
|
||||
bsv_movie_t *handle = (bsv_movie_t*)calloc(1, sizeof(*handle));
|
||||
if (!handle)
|
||||
return NULL;
|
||||
|
||||
@@ -256,7 +269,7 @@ bsv_movie_t *bsv_movie_init(const char *path, enum ssnes_movie_type type)
|
||||
goto error;
|
||||
|
||||
// Just pick something really large :D ~1 million frames rewind should do the trick.
|
||||
if (!(handle->frame_pos = calloc((1 << 20), sizeof(size_t))))
|
||||
if (!(handle->frame_pos = (size_t*)calloc((1 << 20), sizeof(size_t))))
|
||||
goto error;
|
||||
|
||||
handle->frame_pos[0] = handle->min_file_pos;
|
||||
@@ -315,3 +328,57 @@ void bsv_movie_frame_rewind(bsv_movie_t *handle)
|
||||
fseek(handle->file, handle->min_file_pos, SEEK_SET);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *bsv_header_generate(size_t *size)
|
||||
{
|
||||
uint32_t bsv_header[4] = {0};
|
||||
unsigned serialize_size = psnes_serialize_size();
|
||||
size_t header_size = sizeof(bsv_header) + serialize_size;
|
||||
*size = header_size;
|
||||
|
||||
uint8_t *header = (uint8_t*)malloc(header_size);
|
||||
if (!header)
|
||||
return NULL;
|
||||
|
||||
bsv_header[MAGIC_INDEX] = swap_if_little32(BSV_MAGIC);
|
||||
bsv_header[CRC_INDEX] = swap_if_big32(g_extern.cart_crc);
|
||||
bsv_header[STATE_SIZE_INDEX] = swap_if_big32(serialize_size);
|
||||
|
||||
if (serialize_size && !psnes_serialize(header + sizeof(bsv_header), serialize_size))
|
||||
{
|
||||
free(header);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(header, bsv_header, sizeof(bsv_header));
|
||||
return header;
|
||||
}
|
||||
|
||||
bool bsv_parse_header(const uint32_t *header)
|
||||
{
|
||||
uint32_t in_bsv = swap_if_little32(header[MAGIC_INDEX]);
|
||||
if (in_bsv != BSV_MAGIC)
|
||||
{
|
||||
SSNES_ERR("BSV magic mismatch, got 0x%x, expected 0x%x!\n",
|
||||
in_bsv, BSV_MAGIC);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t in_crc = swap_if_big32(header[CRC_INDEX]);
|
||||
if (in_crc != g_extern.cart_crc)
|
||||
{
|
||||
SSNES_ERR("CRC32 mismatch, got 0x%x, expected 0x%x!\n", in_crc, g_extern.cart_crc);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t in_state_size = swap_if_big32(header[STATE_SIZE_INDEX]);
|
||||
if (in_state_size != psnes_serialize_size())
|
||||
{
|
||||
SSNES_ERR("Serialization size mismatch, got 0x%x, expected 0x%x!\n",
|
||||
in_state_size, psnes_serialize_size());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -19,16 +19,20 @@
|
||||
#define __SSNES_MOVIE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include "boolean.h"
|
||||
|
||||
typedef struct bsv_movie bsv_movie_t;
|
||||
|
||||
enum ssnes_movie_type
|
||||
{
|
||||
SSNES_MOVIE_PLAYBACK,
|
||||
SSNES_MOVIE_RECORD,
|
||||
SSNES_MOVIE_RECORD
|
||||
};
|
||||
|
||||
uint8_t *bsv_header_generate(size_t *size);
|
||||
bool bsv_parse_header(const uint32_t *header);
|
||||
|
||||
bsv_movie_t *bsv_movie_init(const char *path, enum ssnes_movie_type type);
|
||||
|
||||
// Playback
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SSNES-360", "SSNES-360.vcxproj", "{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
CodeAnalysis|Xbox 360 = CodeAnalysis|Xbox 360
|
||||
Debug|Xbox 360 = Debug|Xbox 360
|
||||
Profile_FastCap|Xbox 360 = Profile_FastCap|Xbox 360
|
||||
Profile|Xbox 360 = Profile|Xbox 360
|
||||
Release_LTCG|Xbox 360 = Release_LTCG|Xbox 360
|
||||
Release|Xbox 360 = Release|Xbox 360
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}.CodeAnalysis|Xbox 360.ActiveCfg = CodeAnalysis|Xbox 360
|
||||
{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}.CodeAnalysis|Xbox 360.Build.0 = CodeAnalysis|Xbox 360
|
||||
{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}.Debug|Xbox 360.ActiveCfg = Debug|Xbox 360
|
||||
{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}.Debug|Xbox 360.Build.0 = Debug|Xbox 360
|
||||
{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}.Profile_FastCap|Xbox 360.ActiveCfg = Profile_FastCap|Xbox 360
|
||||
{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}.Profile_FastCap|Xbox 360.Build.0 = Profile_FastCap|Xbox 360
|
||||
{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}.Profile|Xbox 360.ActiveCfg = Profile|Xbox 360
|
||||
{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}.Profile|Xbox 360.Build.0 = Profile|Xbox 360
|
||||
{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}.Release_LTCG|Xbox 360.ActiveCfg = Release_LTCG|Xbox 360
|
||||
{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}.Release_LTCG|Xbox 360.Build.0 = Release_LTCG|Xbox 360
|
||||
{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}.Release|Xbox 360.ActiveCfg = Release|Xbox 360
|
||||
{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}.Release|Xbox 360.Build.0 = Release|Xbox 360
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,307 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="CodeAnalysis|Xbox 360">
|
||||
<Configuration>CodeAnalysis</Configuration>
|
||||
<Platform>Xbox 360</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Xbox 360">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Xbox 360</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Profile|Xbox 360">
|
||||
<Configuration>Profile</Configuration>
|
||||
<Platform>Xbox 360</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Profile_FastCap|Xbox 360">
|
||||
<Configuration>Profile_FastCap</Configuration>
|
||||
<Platform>Xbox 360</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Xbox 360">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Xbox 360</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_LTCG|Xbox 360">
|
||||
<Configuration>Release_LTCG</Configuration>
|
||||
<Platform>Xbox 360</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9CE8EEF7-CC1C-4A04-BB5C-62411CB5BADE}</ProjectGuid>
|
||||
<Keyword>Xbox360Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='CodeAnalysis|Xbox 360'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Xbox 360'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile_FastCap|Xbox 360'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_LTCG|Xbox 360'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='CodeAnalysis|Xbox 360'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Profile|Xbox 360'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Profile_FastCap|Xbox 360'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release_LTCG|Xbox 360'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='CodeAnalysis|Xbox 360'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Xbox 360'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile_FastCap|Xbox 360'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_LTCG|Xbox 360'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>_DEBUG;_XBOX;PACKAGE_VERSION="0.9.4";%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.4";_CRT_SECURE_NO_WARNINGS;main=ssnes_main;HAVE_CONFIGFILE</PreprocessorDefinitions>
|
||||
<CallAttributedProfiling>Callcap</CallAttributedProfiling>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
|
||||
<AdditionalDependencies>xapilibd.lib;d3d9d.lib;d3dx9d.lib;xgraphicsd.lib;xboxkrnl.lib;xnetd.lib;xaudiod2.lib;xactd3.lib;x3daudiod.lib;xmcored.lib;xbdm.lib;vcompd.lib;$(SolutionDir)\Debug\snes9x-next-360-msvc2010.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<Deploy>
|
||||
<DeploymentType>CopyToHardDrive</DeploymentType>
|
||||
</Deploy>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='CodeAnalysis|Xbox 360'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<PREfast>AnalyzeOnly</PREfast>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>_DEBUG;_XBOX;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.4";_CRT_SECURE_NO_WARNINGS;main=ssnes_main;HAVE_CONFIGFILE;SSNES_CONSOLE</PreprocessorDefinitions>
|
||||
<CallAttributedProfiling>Callcap</CallAttributedProfiling>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
|
||||
<AdditionalDependencies>xapilibd.lib;d3d9d.lib;d3dx9d.lib;xgraphicsd.lib;xboxkrnl.lib;xnetd.lib;xaudiod2.lib;xactd3.lib;x3daudiod.lib;xmcored.lib;xbdm.lib;vcompd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Xbox 360'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<StringPooling>true</StringPooling>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>NDEBUG;_XBOX;PROFILE;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.4";_CRT_SECURE_NO_WARNINGS;main=ssnes_main;HAVE_CONFIGFILE</PreprocessorDefinitions>
|
||||
<CallAttributedProfiling>Callcap</CallAttributedProfiling>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>false</EnableCOMDATFolding>
|
||||
<IgnoreSpecificDefaultLibraries>xapilib.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
|
||||
<SetChecksum>true</SetChecksum>
|
||||
<AdditionalDependencies>xapilibi.lib;d3d9i.lib;d3dx9.lib;xgraphics.lib;xboxkrnl.lib;xnet.lib;xaudio2.lib;xact3i.lib;x3daudioi.lib;xmcorei.lib;xbdm.lib;vcomp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile_FastCap|Xbox 360'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<StringPooling>true</StringPooling>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CallAttributedProfiling>Fastcap</CallAttributedProfiling>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>NDEBUG;_XBOX;PROFILE;FASTCAP;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.4";_CRT_SECURE_NO_WARNINGS;main=ssnes_main;HAVE_CONFIGFILE</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>false</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
|
||||
<SetChecksum>true</SetChecksum>
|
||||
<AdditionalDependencies>xapilib.lib;d3d9.lib;d3dx9.lib;xgraphics.lib;xboxkrnl.lib;xnet.lib;xaudio2.lib;xact3.lib;x3daudio.lib;xmcore.lib;vcomp.lib;xbdm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<StringPooling>true</StringPooling>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>NDEBUG;_XBOX;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.4";_CRT_SECURE_NO_WARNINGS;main=ssnes_main;HAVE_CONFIGFILE</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
|
||||
<SetChecksum>true</SetChecksum>
|
||||
<AdditionalDependencies>xapilib.lib;d3d9.lib;d3dx9.lib;xgraphics.lib;xboxkrnl.lib;xnet.lib;xaudio2.lib;xact3.lib;x3daudio.lib;xmcore.lib;vcomp.lib;xbdm.lib;$(SolutionDir)\Release\snes9x-next-360-msvc2010.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<Deploy>
|
||||
<DeploymentType>CopyToHardDrive</DeploymentType>
|
||||
</Deploy>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_LTCG|Xbox 360'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<StringPooling>true</StringPooling>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>NDEBUG;_XBOX;LTCG;%(PreprocessorDefinitions);PACKAGE_VERSION="0.9.4";_CRT_SECURE_NO_WARNINGS;main=ssnes_main;HAVE_CONFIGFILE</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
|
||||
<SetChecksum>true</SetChecksum>
|
||||
<AdditionalDependencies>xapilib.lib;d3d9ltcg.lib;d3dx9.lib;xgraphics.lib;xboxkrnl.lib;xnet.lib;xaudio2.lib;xact3ltcg.lib;x3daudioltcg.lib;xmcoreltcg.lib;vcomp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\360\main.c" />
|
||||
<ClCompile Include="..\..\360\xdk360_audio.cpp" />
|
||||
<ClCompile Include="..\..\360\xdk360_input.cpp" />
|
||||
<ClCompile Include="..\..\360\xdk360_video.cpp" />
|
||||
<ClCompile Include="..\..\audio\hermite.c" />
|
||||
<ClCompile Include="..\..\audio\utils.c" />
|
||||
<ClCompile Include="..\..\autosave.c" />
|
||||
<ClCompile Include="..\..\bps.c" />
|
||||
<ClCompile Include="..\..\cheats.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\conf\config_file.c" />
|
||||
<ClCompile Include="..\..\driver.c" />
|
||||
<ClCompile Include="..\..\dynamic.c" />
|
||||
<ClCompile Include="..\..\fifo_buffer.c" />
|
||||
<ClCompile Include="..\..\file.c" />
|
||||
<ClCompile Include="..\..\getopt.c" />
|
||||
<ClCompile Include="..\..\message.c" />
|
||||
<ClCompile Include="..\..\movie.c" />
|
||||
<ClCompile Include="..\..\netplay.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\posix_string.c" />
|
||||
<ClCompile Include="..\..\rewind.c" />
|
||||
<ClCompile Include="..\..\screenshot.c" />
|
||||
<ClCompile Include="..\..\settings.c" />
|
||||
<ClCompile Include="..\..\sha256.c" />
|
||||
<ClCompile Include="..\..\ssnes.c" />
|
||||
<ClCompile Include="..\..\strl.c" />
|
||||
<ClCompile Include="..\..\thread.c" />
|
||||
<ClCompile Include="..\..\ups.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\360\msvc_compat.h" />
|
||||
<ClInclude Include="..\..\360\xdk360_audio.h" />
|
||||
<ClInclude Include="..\..\audio\hermite.h" />
|
||||
<ClInclude Include="..\..\audio\utils.h" />
|
||||
<ClInclude Include="..\..\autosave.h" />
|
||||
<ClInclude Include="..\..\boolean.h" />
|
||||
<ClInclude Include="..\..\bps.h" />
|
||||
<ClInclude Include="..\..\cheats.h" />
|
||||
<ClInclude Include="..\..\config.def.h" />
|
||||
<ClInclude Include="..\..\config.features.h" />
|
||||
<ClInclude Include="..\..\conf\config_file.h" />
|
||||
<ClInclude Include="..\..\driver.h" />
|
||||
<ClInclude Include="..\..\dynamic.h" />
|
||||
<ClInclude Include="..\..\fifo_buffer.h" />
|
||||
<ClInclude Include="..\..\file.h" />
|
||||
<ClInclude Include="..\..\general.h" />
|
||||
<ClInclude Include="..\..\getopt_ssnes.h" />
|
||||
<ClInclude Include="..\..\libsnes.hpp" />
|
||||
<ClInclude Include="..\..\message.h" />
|
||||
<ClInclude Include="..\..\movie.h" />
|
||||
<ClInclude Include="..\..\netplay.h" />
|
||||
<ClInclude Include="..\..\posix_string.h" />
|
||||
<ClInclude Include="..\..\rewind.h" />
|
||||
<ClInclude Include="..\..\screenshot.h" />
|
||||
<ClInclude Include="..\..\sha256.h" />
|
||||
<ClInclude Include="..\..\strl.h" />
|
||||
<ClInclude Include="..\..\thread.h" />
|
||||
<ClInclude Include="..\..\ups.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,200 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\360">
|
||||
<UniqueIdentifier>{740056e8-6476-4e8c-b9cb-767bebdb5c60}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\audio">
|
||||
<UniqueIdentifier>{747ac5fa-bd8a-4e60-9246-7a8fb0d38b85}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\360">
|
||||
<UniqueIdentifier>{b9371e8d-2e72-4ced-8bf6-6ee6a77a1f78}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\audio">
|
||||
<UniqueIdentifier>{c8038d65-499b-493b-80e9-90bd7c57383f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\conf">
|
||||
<UniqueIdentifier>{755ce6db-d242-40fb-9c8b-c14154fc94e1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\conf">
|
||||
<UniqueIdentifier>{82e8787f-e939-4783-82e1-fcab34285121}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\360\xdk360_video.cpp">
|
||||
<Filter>Source Files\360</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\360\xdk360_input.cpp">
|
||||
<Filter>Source Files\360</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ups.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\autosave.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\bps.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\cheats.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\driver.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\dynamic.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\fifo_buffer.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\file.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\getopt.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\message.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\movie.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\netplay.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\posix_string.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\rewind.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\screenshot.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\settings.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\sha256.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ssnes.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\strl.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\thread.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\audio\hermite.c">
|
||||
<Filter>Source Files\audio</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\audio\utils.c">
|
||||
<Filter>Source Files\audio</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\360\xdk360_audio.cpp">
|
||||
<Filter>Source Files\360</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\360\main.c">
|
||||
<Filter>Source Files\360</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\conf\config_file.c">
|
||||
<Filter>Source Files\conf</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\ups.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\autosave.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\boolean.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\bps.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\cheats.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\config.def.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\config.features.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\driver.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\dynamic.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\fifo_buffer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\file.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\general.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\getopt_ssnes.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\libsnes.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\message.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\movie.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\netplay.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\posix_string.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\rewind.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\screenshot.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\sha256.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\strl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\thread.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\360\xdk360_audio.h">
|
||||
<Filter>Header Files\360</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\360\msvc_compat.h">
|
||||
<Filter>Header Files\360</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\audio\hermite.h">
|
||||
<Filter>Header Files\audio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\audio\utils.h">
|
||||
<Filter>Header Files\audio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\conf\config_file.h">
|
||||
<Filter>Header Files\conf</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual C++ Express 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SSNES", "SSNES\SSNES.vcxproj", "{032D1FA7-7AA5-47BB-B51B-68B75ADE729D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{032D1FA7-7AA5-47BB-B51B-68B75ADE729D}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{032D1FA7-7AA5-47BB-B51B-68B75ADE729D}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{032D1FA7-7AA5-47BB-B51B-68B75ADE729D}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{032D1FA7-7AA5-47BB-B51B-68B75ADE729D}.Debug|x64.Build.0 = Debug|x64
|
||||
{032D1FA7-7AA5-47BB-B51B-68B75ADE729D}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{032D1FA7-7AA5-47BB-B51B-68B75ADE729D}.Release|Win32.Build.0 = Release|Win32
|
||||
{032D1FA7-7AA5-47BB-B51B-68B75ADE729D}.Release|x64.ActiveCfg = Release|x64
|
||||
{032D1FA7-7AA5-47BB-B51B-68B75ADE729D}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,258 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{032D1FA7-7AA5-47BB-B51B-68B75ADE729D}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>SSNES</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\..\x64libs.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>ssnes</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>ssnes</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>ssnes</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>ssnes</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<AdditionalOptions>/D HAVE_SDL /D PACKAGE_VERSION=\"0.9.4\" /D _CRT_SECURE_NO_WARNINGS /D HAVE_NETPLAY /D HAVE_THREADS /D HAVE_OPENGL /D HAVE_DYLIB /D HAVE_DYNAMIC /D HAVE_CG /D HAVE_XAUDIO /D HAVE_FBO /D HAVE_CONFIGFILE /D HAVE_DSOUND /D HAVE_FFMPEG /D HAVE_FFMPEG_ALLOC_CONTEXT3 /D HAVE_FFMPEG_AVCODEC_OPEN2 /D HAVE_FFMPEG_AVIO_OPEN /D HAVE_FFMPEG_AVFORMAT_WRITE_HEADER /D HAVE_FFMPEG_AVFORMAT_NEW_STREAM /D HAVE_X264RGB /D HAVE_PYTHON /D HAVE_SDL_IMAGE /D HAVE_FREETYPE /D HAVE_XML %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>SDL.lib;SDL_image.lib;opengl32.lib;ws2_32.lib;dxguid.lib;dinput8.lib;cg.lib;cgGL.lib;winmm.lib;shlwapi.lib;dsound.lib;avcodec.lib;avformat.lib;swscale.lib;avutil.lib;freetype.lib;libxml2.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<AdditionalOptions>/D HAVE_SDL /D PACKAGE_VERSION=\"0.9.4\" /D _CRT_SECURE_NO_WARNINGS /D HAVE_NETPLAY /D HAVE_THREADS /D HAVE_OPENGL /D HAVE_DYLIB /D HAVE_DYNAMIC /D HAVE_CG /D HAVE_XAUDIO /D HAVE_FBO /D HAVE_CONFIGFILE /D HAVE_DSOUND /D HAVE_FFMPEG /D HAVE_FFMPEG_ALLOC_CONTEXT3 /D HAVE_FFMPEG_AVCODEC_OPEN2 /D HAVE_FFMPEG_AVIO_OPEN /D HAVE_FFMPEG_AVFORMAT_WRITE_HEADER /D HAVE_FFMPEG_AVFORMAT_NEW_STREAM /D HAVE_X264RGB /D HAVE_PYTHON /D HAVE_SDL_IMAGE /D HAVE_FREETYPE /D HAVE_XML %(AdditionalOptions)</AdditionalOptions>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>SDL.lib;SDL_image.lib;opengl32.lib;ws2_32.lib;dxguid.lib;dinput8.lib;cg.lib;cgGL.lib;winmm.lib;shlwapi.lib;dsound.lib;avcodec.lib;avformat.lib;swscale.lib;avutil.lib;freetype.lib;libxml2.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/D HAVE_SDL /D PACKAGE_VERSION=\"0.9.4\" /D _CRT_SECURE_NO_WARNINGS /D HAVE_NETPLAY /D HAVE_THREADS /D HAVE_OPENGL /D HAVE_DYLIB /D HAVE_DYNAMIC /D HAVE_CG /D HAVE_XAUDIO /D HAVE_FBO /D HAVE_CONFIGFILE /D HAVE_DSOUND /D HAVE_FFMPEG /D HAVE_FFMPEG_ALLOC_CONTEXT3 /D HAVE_FFMPEG_AVCODEC_OPEN2 /D HAVE_FFMPEG_AVIO_OPEN /D HAVE_FFMPEG_AVFORMAT_WRITE_HEADER /D HAVE_FFMPEG_AVFORMAT_NEW_STREAM /D HAVE_X264RGB /D HAVE_PYTHON /D HAVE_SDL_IMAGE /D HAVE_FREETYPE /D HAVE_XML %(AdditionalOptions)</AdditionalOptions>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>SDL.lib;SDL_image.lib;opengl32.lib;ws2_32.lib;dxguid.lib;dinput8.lib;cg.lib;cgGL.lib;winmm.lib;shlwapi.lib;dsound.lib;avcodec.lib;avformat.lib;swscale.lib;avutil.lib;freetype.lib;libxml2.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/D HAVE_SDL /D PACKAGE_VERSION=\"0.9.4\" /D _CRT_SECURE_NO_WARNINGS /D HAVE_NETPLAY /D HAVE_THREADS /D HAVE_OPENGL /D HAVE_DYLIB /D HAVE_DYNAMIC /D HAVE_CG /D HAVE_XAUDIO /D HAVE_FBO /D HAVE_CONFIGFILE /D HAVE_DSOUND /D HAVE_FFMPEG /D HAVE_FFMPEG_ALLOC_CONTEXT3 /D HAVE_FFMPEG_AVCODEC_OPEN2 /D HAVE_FFMPEG_AVIO_OPEN /D HAVE_FFMPEG_AVFORMAT_WRITE_HEADER /D HAVE_FFMPEG_AVFORMAT_NEW_STREAM /D HAVE_X264RGB /D HAVE_PYTHON /D HAVE_SDL_IMAGE /D HAVE_FREETYPE /D HAVE_XML %(AdditionalOptions)</AdditionalOptions>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>SDL.lib;SDL_image.lib;opengl32.lib;ws2_32.lib;dxguid.lib;dinput8.lib;cg.lib;cgGL.lib;winmm.lib;shlwapi.lib;dsound.lib;avcodec.lib;avformat.lib;swscale.lib;avutil.lib;freetype.lib;libxml2.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\audio\dsound.c" />
|
||||
<ClCompile Include="..\..\..\audio\ext_audio.c" />
|
||||
<ClCompile Include="..\..\..\audio\hermite.c" />
|
||||
<ClCompile Include="..\..\..\audio\sdl_audio.c" />
|
||||
<ClCompile Include="..\..\..\audio\utils.c" />
|
||||
<ClCompile Include="..\..\..\audio\xaudio-c\xaudio-c.c" />
|
||||
<ClCompile Include="..\..\..\audio\xaudio.c" />
|
||||
<ClCompile Include="..\..\..\autosave.c" />
|
||||
<ClCompile Include="..\..\..\bps.c" />
|
||||
<ClCompile Include="..\..\..\cheats.c" />
|
||||
<ClCompile Include="..\..\..\conf\config_file.c" />
|
||||
<ClCompile Include="..\..\..\driver.c" />
|
||||
<ClCompile Include="..\..\..\dynamic.c" />
|
||||
<ClCompile Include="..\..\..\fifo_buffer.c" />
|
||||
<ClCompile Include="..\..\..\file.c" />
|
||||
<ClCompile Include="..\..\..\getopt.c" />
|
||||
<ClCompile Include="..\..\..\gfx\ext_gfx.c" />
|
||||
<ClCompile Include="..\..\..\gfx\fonts.c" />
|
||||
<ClCompile Include="..\..\..\gfx\gfx_common.c" />
|
||||
<ClCompile Include="..\..\..\gfx\gl.c" />
|
||||
<ClCompile Include="..\..\..\gfx\image.c" />
|
||||
<ClCompile Include="..\..\..\gfx\py_state\py_state.c" />
|
||||
<ClCompile Include="..\..\..\gfx\sdl_gfx.c" />
|
||||
<ClCompile Include="..\..\..\gfx\sdlwrap.c" />
|
||||
<ClCompile Include="..\..\..\gfx\shader_cg.c" />
|
||||
<ClCompile Include="..\..\..\gfx\shader_glsl.c" />
|
||||
<ClCompile Include="..\..\..\gfx\snes_state.c" />
|
||||
<ClCompile Include="..\..\..\input\dinput.c" />
|
||||
<ClCompile Include="..\..\..\input\sdl_input.c" />
|
||||
<ClCompile Include="..\..\..\message.c" />
|
||||
<ClCompile Include="..\..\..\movie.c" />
|
||||
<ClCompile Include="..\..\..\netplay.c" />
|
||||
<ClCompile Include="..\..\..\posix_string.c" />
|
||||
<ClCompile Include="..\..\..\record\ffemu.c" />
|
||||
<ClCompile Include="..\..\..\rewind.c" />
|
||||
<ClCompile Include="..\..\..\screenshot.c" />
|
||||
<ClCompile Include="..\..\..\settings.c" />
|
||||
<ClCompile Include="..\..\..\sha256.c" />
|
||||
<ClCompile Include="..\..\..\ssnes.c" />
|
||||
<ClCompile Include="..\..\..\strl.c" />
|
||||
<ClCompile Include="..\..\..\thread.c" />
|
||||
<ClCompile Include="..\..\..\ups.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\audio\ext\ssnes_audio.h" />
|
||||
<ClInclude Include="..\..\..\audio\ext\ssnes_dsp.h" />
|
||||
<ClInclude Include="..\..\..\audio\hermite.h" />
|
||||
<ClInclude Include="..\..\..\audio\utils.h" />
|
||||
<ClInclude Include="..\..\..\audio\xaudio-c\xaudio-c.h" />
|
||||
<ClInclude Include="..\..\..\audio\xaudio-c\xaudio.h" />
|
||||
<ClInclude Include="..\..\..\autosave.h" />
|
||||
<ClInclude Include="..\..\..\boolean.h" />
|
||||
<ClInclude Include="..\..\..\bps.h" />
|
||||
<ClInclude Include="..\..\..\cheats.h" />
|
||||
<ClInclude Include="..\..\..\config.def.h" />
|
||||
<ClInclude Include="..\..\..\config.features.h" />
|
||||
<ClInclude Include="..\..\..\conf\config_file.h" />
|
||||
<ClInclude Include="..\..\..\driver.h" />
|
||||
<ClInclude Include="..\..\..\dynamic.h" />
|
||||
<ClInclude Include="..\..\..\fifo_buffer.h" />
|
||||
<ClInclude Include="..\..\..\file.h" />
|
||||
<ClInclude Include="..\..\..\general.h" />
|
||||
<ClInclude Include="..\..\..\getopt_ssnes.h" />
|
||||
<ClInclude Include="..\..\..\gfx\ext\ssnes_video.h" />
|
||||
<ClInclude Include="..\..\..\gfx\fonts.h" />
|
||||
<ClInclude Include="..\..\..\gfx\gfx_common.h" />
|
||||
<ClInclude Include="..\..\..\gfx\gl_common.h" />
|
||||
<ClInclude Include="..\..\..\gfx\image.h" />
|
||||
<ClInclude Include="..\..\..\gfx\py_state\py_state.h" />
|
||||
<ClInclude Include="..\..\..\gfx\sdlwrap.h" />
|
||||
<ClInclude Include="..\..\..\gfx\shader_cg.h" />
|
||||
<ClInclude Include="..\..\..\gfx\shader_glsl.h" />
|
||||
<ClInclude Include="..\..\..\gfx\snes_state.h" />
|
||||
<ClInclude Include="..\..\..\input\keysym.h" />
|
||||
<ClInclude Include="..\..\..\input\ssnes_dinput.h" />
|
||||
<ClInclude Include="..\..\..\input\ssnes_sdl_input.h" />
|
||||
<ClInclude Include="..\..\..\libsnes.hpp" />
|
||||
<ClInclude Include="..\..\..\message.h" />
|
||||
<ClInclude Include="..\..\..\movie.h" />
|
||||
<ClInclude Include="..\..\..\netplay.h" />
|
||||
<ClInclude Include="..\..\..\posix_string.h" />
|
||||
<ClInclude Include="..\..\..\record\ffemu.h" />
|
||||
<ClInclude Include="..\..\..\rewind.h" />
|
||||
<ClInclude Include="..\..\..\screenshot.h" />
|
||||
<ClInclude Include="..\..\..\sha256.h" />
|
||||
<ClInclude Include="..\..\..\strl.h" />
|
||||
<ClInclude Include="..\..\..\thread.h" />
|
||||
<ClInclude Include="..\..\..\ups.h" />
|
||||
<ClInclude Include="..\..\msvc_compat.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,300 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\gfx\ext_gfx.c">
|
||||
<Filter>Sources\gfx</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\gfx\gfx_common.c">
|
||||
<Filter>Sources\gfx</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\gfx\gl.c">
|
||||
<Filter>Sources\gfx</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\gfx\sdl_gfx.c">
|
||||
<Filter>Sources\gfx</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\gfx\sdlwrap.c">
|
||||
<Filter>Sources\gfx</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\gfx\shader_cg.c">
|
||||
<Filter>Sources\gfx</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\gfx\shader_glsl.c">
|
||||
<Filter>Sources\gfx</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\audio\dsound.c">
|
||||
<Filter>Sources\audio</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\audio\ext_audio.c">
|
||||
<Filter>Sources\audio</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\audio\sdl_audio.c">
|
||||
<Filter>Sources\audio</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\audio\xaudio.c">
|
||||
<Filter>Sources\audio</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\audio\xaudio-c\xaudio-c.c">
|
||||
<Filter>Sources\audio</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\input\dinput.c">
|
||||
<Filter>Sources\input</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\input\sdl_input.c">
|
||||
<Filter>Sources\input</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\autosave.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\audio\utils.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\bps.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\cheats.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\conf\config_file.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\driver.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\dynamic.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\record\ffemu.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\fifo_buffer.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\file.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\gfx\fonts.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\getopt.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\audio\hermite.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\gfx\image.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\message.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\movie.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\netplay.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\posix_string.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\gfx\py_state\py_state.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\rewind.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\screenshot.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\settings.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\sha256.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\gfx\snes_state.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\ssnes.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\strl.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\thread.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\ups.c">
|
||||
<Filter>Sources\top</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\autosave.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\boolean.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\bps.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\cheats.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\config.def.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\config.features.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\conf\config_file.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\driver.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\dynamic.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\record\ffemu.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\fifo_buffer.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\file.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\general.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\getopt_ssnes.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\libsnes.hpp">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\message.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\movie.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\msvc_compat.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\netplay.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\posix_string.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\rewind.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\sha256.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\strl.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\thread.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\ups.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\audio\utils.h">
|
||||
<Filter>Headers\top</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\gfx\fonts.h">
|
||||
<Filter>Headers\gfx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\gfx\gfx_common.h">
|
||||
<Filter>Headers\gfx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\gfx\gl_common.h">
|
||||
<Filter>Headers\gfx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\gfx\py_state\py_state.h">
|
||||
<Filter>Headers\gfx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\gfx\sdlwrap.h">
|
||||
<Filter>Headers\gfx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\gfx\shader_cg.h">
|
||||
<Filter>Headers\gfx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\gfx\shader_glsl.h">
|
||||
<Filter>Headers\gfx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\gfx\snes_state.h">
|
||||
<Filter>Headers\gfx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\gfx\ext\ssnes_video.h">
|
||||
<Filter>Headers\gfx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\input\ssnes_sdl_input.h">
|
||||
<Filter>Headers\input</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\input\ssnes_dinput.h">
|
||||
<Filter>Headers\input</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\input\keysym.h">
|
||||
<Filter>Headers\input</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\gfx\image.h">
|
||||
<Filter>Headers\gfx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\screenshot.h">
|
||||
<Filter>Headers\gfx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\audio\hermite.h">
|
||||
<Filter>Headers\audio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\audio\xaudio-c\xaudio.h">
|
||||
<Filter>Headers\audio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\audio\ext\ssnes_audio.h">
|
||||
<Filter>Headers\audio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\audio\ext\ssnes_dsp.h">
|
||||
<Filter>Headers\audio</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\audio\xaudio-c\xaudio-c.h">
|
||||
<Filter>Headers\audio</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Headers">
|
||||
<UniqueIdentifier>{28fed54e-87b3-4bc6-ae27-7cea25ef2e43}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Sources">
|
||||
<UniqueIdentifier>{75ab8cb3-2b54-4d04-94b0-bbd92a445ee4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Sources\gfx">
|
||||
<UniqueIdentifier>{4482f76d-5312-4ffd-a97e-c1339ed6b43d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Sources\audio">
|
||||
<UniqueIdentifier>{0cc589b9-03ab-4f7a-a7f0-9a4e4f39139e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Sources\top">
|
||||
<UniqueIdentifier>{2ebd2975-3e8c-4be6-b8a5-b63185e39ef4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Sources\input">
|
||||
<UniqueIdentifier>{f5587648-1c52-408e-80de-effb813294f1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Headers\top">
|
||||
<UniqueIdentifier>{3e498457-23e5-469a-8f36-5bd9430d9e00}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Headers\gfx">
|
||||
<UniqueIdentifier>{efcb213b-6038-4ad9-a2c4-07d8063ca5d8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Headers\input">
|
||||
<UniqueIdentifier>{3542518e-8825-483f-992b-3c680ef3de4c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Headers\audio">
|
||||
<UniqueIdentifier>{8adc8069-5b48-4fca-9fe8-22214a5fcc08}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,56 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
* SSNES is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with SSNES.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __SSNES_MSVC_COMPAT_H
|
||||
#define __SSNES_MSVC_COMPAT_H
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#undef UNICODE // Do not bother with UNICODE at this time.
|
||||
#include <stddef.h>
|
||||
#include <math.h>
|
||||
|
||||
// Python headers defines ssize_t and sets HAVE_SSIZE_T. Cannot duplicate these efforts.
|
||||
#ifndef HAVE_SSIZE_T
|
||||
#if defined(_WIN64)
|
||||
typedef __int64 ssize_t;
|
||||
#elif defined(_WIN32)
|
||||
typedef int ssize_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define snprintf _snprintf
|
||||
|
||||
// Disable some of the annoying warnings.
|
||||
#pragma warning(disable : 4800)
|
||||
#pragma warning(disable : 4244)
|
||||
#pragma warning(disable : 4305)
|
||||
#pragma warning(disable : 4146)
|
||||
#pragma warning(disable : 4267)
|
||||
|
||||
static inline float roundf(float in)
|
||||
{
|
||||
return in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f);
|
||||
}
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX MAX_PATH
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
||||
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||
*
|
||||
* Some code herein may be based on code found in BSNES.
|
||||
*
|
||||
@@ -41,9 +41,18 @@
|
||||
#include "message.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <assert.h>
|
||||
|
||||
// Checks if input port/index is controlled by netplay or not.
|
||||
static bool netplay_is_alive(netplay_t *handle);
|
||||
|
||||
static bool netplay_poll(netplay_t *handle);
|
||||
static int16_t netplay_input_state(netplay_t *handle, bool port, unsigned device, unsigned index, unsigned id);
|
||||
|
||||
// If we're fast-forward replaying to resync, check if we should actually show frame.
|
||||
static bool netplay_should_skip(netplay_t *handle);
|
||||
static bool netplay_can_poll(netplay_t *handle);
|
||||
static const struct snes_callbacks* netplay_callbacks(netplay_t *handle);
|
||||
static void netplay_set_spectate_input(netplay_t *handle, int16_t input);
|
||||
|
||||
#ifdef _WIN32
|
||||
// Woohoo, Winsock has headers from the STONE AGE! :D
|
||||
@@ -53,6 +62,8 @@
|
||||
#else
|
||||
#define CONST_CAST
|
||||
#define NONCONST_CAST
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#define PREV_PTR(x) ((x) == 0 ? handle->buffer_size - 1 : (x) - 1)
|
||||
@@ -70,6 +81,7 @@ struct delta_frame
|
||||
};
|
||||
|
||||
#define UDP_FRAME_PACKETS 16
|
||||
#define MAX_SPECTATORS 16
|
||||
|
||||
struct netplay
|
||||
{
|
||||
@@ -101,6 +113,14 @@ struct netplay
|
||||
bool has_client_addr;
|
||||
|
||||
unsigned timeout_cnt;
|
||||
|
||||
// Spectating.
|
||||
bool spectate;
|
||||
bool spectate_client;
|
||||
int spectate_fds[MAX_SPECTATORS];
|
||||
uint16_t *spectate_input;
|
||||
size_t spectate_input_ptr;
|
||||
size_t spectate_input_size;
|
||||
};
|
||||
|
||||
static void warn_hangup(void)
|
||||
@@ -136,7 +156,51 @@ int16_t input_state_net(bool port, unsigned device, unsigned index, unsigned id)
|
||||
return netplay_callbacks(g_extern.netplay)->state_cb(port, device, index, id);
|
||||
}
|
||||
|
||||
static bool init_tcp_socket(netplay_t *handle, const char *server, uint16_t port)
|
||||
static void log_connection(const struct sockaddr_storage *their_addr, unsigned slot)
|
||||
{
|
||||
union
|
||||
{
|
||||
const struct sockaddr_storage *storage;
|
||||
const struct sockaddr_in *v4;
|
||||
const struct sockaddr_in6 *v6;
|
||||
} u;
|
||||
u.storage = their_addr;
|
||||
|
||||
const char *str = NULL;
|
||||
if (their_addr->ss_family == AF_INET)
|
||||
{
|
||||
char buf[INET_ADDRSTRLEN] = {0};
|
||||
str = buf;
|
||||
struct sockaddr_in in;
|
||||
memset(&in, 0, sizeof(in));
|
||||
in.sin_family = AF_INET;
|
||||
memcpy(&in.sin_addr, &u.v4->sin_addr, sizeof(struct in_addr));
|
||||
|
||||
getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in), buf, sizeof(buf),
|
||||
NULL, 0, NI_NUMERICHOST);
|
||||
}
|
||||
else if (their_addr->ss_family == AF_INET6)
|
||||
{
|
||||
char buf[INET6_ADDRSTRLEN] = {0};
|
||||
str = buf;
|
||||
struct sockaddr_in6 in;
|
||||
memset(&in, 0, sizeof(in));
|
||||
in.sin6_family = AF_INET6;
|
||||
memcpy(&in.sin6_addr, &u.v6->sin6_addr, sizeof(struct in6_addr));
|
||||
|
||||
getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in6),
|
||||
buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
|
||||
}
|
||||
|
||||
if (str)
|
||||
{
|
||||
char msg[512];
|
||||
snprintf(msg, sizeof(msg), "Got connection from: \"%s\" (#%u)", str, slot);
|
||||
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
|
||||
}
|
||||
}
|
||||
|
||||
static bool init_tcp_socket(netplay_t *handle, const char *server, uint16_t port, bool spectate)
|
||||
{
|
||||
struct addrinfo hints, *res = NULL;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
@@ -173,6 +237,22 @@ static bool init_tcp_socket(netplay_t *handle, const char *server, uint16_t port
|
||||
{
|
||||
SSNES_ERR("Failed to connect to server.\n");
|
||||
close(handle->fd);
|
||||
handle->fd = -1;
|
||||
freeaddrinfo(res);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (handle->spectate)
|
||||
{
|
||||
int yes = 1;
|
||||
setsockopt(handle->fd, SOL_SOCKET, SO_REUSEADDR, CONST_CAST &yes, sizeof(int));
|
||||
|
||||
if (bind(handle->fd, res->ai_addr, res->ai_addrlen) < 0 ||
|
||||
listen(handle->fd, MAX_SPECTATORS) < 0)
|
||||
{
|
||||
SSNES_ERR("Failed to bind socket.\n");
|
||||
close(handle->fd);
|
||||
handle->fd = -1;
|
||||
freeaddrinfo(res);
|
||||
return false;
|
||||
}
|
||||
@@ -182,23 +262,31 @@ static bool init_tcp_socket(netplay_t *handle, const char *server, uint16_t port
|
||||
int yes = 1;
|
||||
setsockopt(handle->fd, SOL_SOCKET, SO_REUSEADDR, CONST_CAST &yes, sizeof(int));
|
||||
|
||||
if (bind(handle->fd, res->ai_addr, res->ai_addrlen) < 0 || listen(handle->fd, 1) < 0)
|
||||
if (bind(handle->fd, res->ai_addr, res->ai_addrlen) < 0 ||
|
||||
listen(handle->fd, 1) < 0)
|
||||
{
|
||||
SSNES_ERR("Failed to bind socket.\n");
|
||||
close(handle->fd);
|
||||
handle->fd = -1;
|
||||
freeaddrinfo(res);
|
||||
return false;
|
||||
}
|
||||
int new_fd = accept(handle->fd, NULL, NULL);
|
||||
|
||||
struct sockaddr_storage their_addr;
|
||||
socklen_t addr_size = sizeof(their_addr);
|
||||
int new_fd = accept(handle->fd, (struct sockaddr*)&their_addr, &addr_size);
|
||||
if (new_fd < 0)
|
||||
{
|
||||
SSNES_ERR("Failed to accept socket.\n");
|
||||
close(handle->fd);
|
||||
handle->fd = -1;
|
||||
freeaddrinfo(res);
|
||||
return false;
|
||||
}
|
||||
close(handle->fd);
|
||||
handle->fd = new_fd;
|
||||
|
||||
log_connection(&their_addr, 0);
|
||||
}
|
||||
|
||||
freeaddrinfo(res);
|
||||
@@ -244,6 +332,7 @@ static bool init_udp_socket(netplay_t *handle, const char *server, uint16_t port
|
||||
{
|
||||
SSNES_ERR("Failed to bind socket.\n");
|
||||
close(handle->udp_fd);
|
||||
handle->udp_fd = -1;
|
||||
}
|
||||
|
||||
freeaddrinfo(handle->addr);
|
||||
@@ -266,10 +355,13 @@ static bool init_socket(netplay_t *handle, const char *server, uint16_t port)
|
||||
signal(SIGPIPE, SIG_IGN); // Do not like SIGPIPE killing our app :(
|
||||
#endif
|
||||
|
||||
if (!init_tcp_socket(handle, server, port))
|
||||
return false;
|
||||
if (!init_udp_socket(handle, server, port))
|
||||
if (!init_tcp_socket(handle, server, port, handle->spectate))
|
||||
return false;
|
||||
if (!handle->spectate)
|
||||
{
|
||||
if (!init_udp_socket(handle, server, port))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -347,7 +439,7 @@ static bool get_info(netplay_t *handle)
|
||||
// Send SRAM data to our Player 2 :)
|
||||
const uint8_t *sram = psnes_get_memory_data(SNES_MEMORY_CARTRIDGE_RAM);
|
||||
unsigned sram_size = psnes_get_memory_size(SNES_MEMORY_CARTRIDGE_RAM);
|
||||
while (sram_size > 0)
|
||||
while (sram_size)
|
||||
{
|
||||
ssize_t ret = send(handle->fd, CONST_CAST sram, sram_size, 0);
|
||||
if (ret <= 0)
|
||||
@@ -362,28 +454,78 @@ static bool get_info(netplay_t *handle)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool get_info_spectate(netplay_t *handle)
|
||||
{
|
||||
uint32_t header[4];
|
||||
if (recv(handle->fd, NONCONST_CAST header, sizeof(header), 0) != (ssize_t)sizeof(header))
|
||||
{
|
||||
SSNES_ERR("Cannot get header from host!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned save_state_size = psnes_serialize_size();
|
||||
if (!bsv_parse_header(header))
|
||||
{
|
||||
SSNES_ERR("Received invalid BSV header from host!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t *buf = (uint8_t*)malloc(save_state_size);
|
||||
if (!buf)
|
||||
return false;
|
||||
|
||||
size_t size = save_state_size;
|
||||
uint8_t *tmp_buf = buf;
|
||||
while (size)
|
||||
{
|
||||
ssize_t ret = recv(handle->fd, NONCONST_CAST tmp_buf, size, 0);
|
||||
if (ret <= 0)
|
||||
{
|
||||
SSNES_ERR("Failed to receive save state from host!\n");
|
||||
free(tmp_buf);
|
||||
return false;
|
||||
}
|
||||
|
||||
size -= ret;
|
||||
tmp_buf += ret;
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
if (save_state_size)
|
||||
ret = psnes_unserialize(buf, save_state_size);
|
||||
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void init_buffers(netplay_t *handle)
|
||||
{
|
||||
handle->buffer = calloc(handle->buffer_size, sizeof(*handle->buffer));
|
||||
handle->buffer = (struct delta_frame*)calloc(handle->buffer_size, sizeof(*handle->buffer));
|
||||
handle->state_size = psnes_serialize_size();
|
||||
for (unsigned i = 0; i < handle->buffer_size; i++)
|
||||
{
|
||||
handle->buffer[i].state = malloc(handle->state_size);
|
||||
handle->buffer[i].state = (uint8_t*)malloc(handle->state_size);
|
||||
handle->buffer[i].is_simulated = true;
|
||||
}
|
||||
}
|
||||
|
||||
netplay_t *netplay_new(const char *server, uint16_t port, unsigned frames, const struct snes_callbacks *cb)
|
||||
netplay_t *netplay_new(const char *server, uint16_t port, unsigned frames, const struct snes_callbacks *cb, bool spectate)
|
||||
{
|
||||
(void)spectate;
|
||||
|
||||
if (frames > UDP_FRAME_PACKETS)
|
||||
frames = UDP_FRAME_PACKETS;
|
||||
|
||||
netplay_t *handle = calloc(1, sizeof(*handle));
|
||||
netplay_t *handle = (netplay_t*)calloc(1, sizeof(*handle));
|
||||
if (!handle)
|
||||
return NULL;
|
||||
|
||||
handle->fd = -1;
|
||||
handle->udp_fd = -1;
|
||||
handle->cbs = *cb;
|
||||
handle->port = server ? 0 : 1;
|
||||
handle->spectate = spectate;
|
||||
handle->spectate_client = server != NULL;
|
||||
|
||||
if (!init_socket(handle, server, port))
|
||||
{
|
||||
@@ -391,35 +533,50 @@ netplay_t *netplay_new(const char *server, uint16_t port, unsigned frames, const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (server)
|
||||
if (spectate)
|
||||
{
|
||||
if (!send_info(handle))
|
||||
if (server)
|
||||
{
|
||||
close(handle->fd);
|
||||
free(handle);
|
||||
return NULL;
|
||||
if (!get_info_spectate(handle))
|
||||
goto error;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < MAX_SPECTATORS; i++)
|
||||
handle->spectate_fds[i] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!get_info(handle))
|
||||
if (server)
|
||||
{
|
||||
close(handle->fd);
|
||||
free(handle);
|
||||
return NULL;
|
||||
if (!send_info(handle))
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!get_info(handle))
|
||||
goto error;
|
||||
}
|
||||
|
||||
handle->buffer_size = frames + 1;
|
||||
|
||||
init_buffers(handle);
|
||||
handle->has_connection = true;
|
||||
}
|
||||
|
||||
handle->buffer_size = frames + 1;
|
||||
|
||||
init_buffers(handle);
|
||||
handle->has_connection = true;
|
||||
|
||||
return handle;
|
||||
|
||||
error:
|
||||
if (handle->fd >= 0)
|
||||
close(handle->fd);
|
||||
if (handle->udp_fd >= 0)
|
||||
close(handle->udp_fd);
|
||||
|
||||
free(handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool netplay_is_alive(netplay_t *handle)
|
||||
static bool netplay_is_alive(netplay_t *handle)
|
||||
{
|
||||
return handle->has_connection;
|
||||
}
|
||||
@@ -434,7 +591,9 @@ static bool send_chunk(netplay_t *handle)
|
||||
|
||||
if (addr)
|
||||
{
|
||||
if (sendto(handle->udp_fd, CONST_CAST handle->packet_buffer, sizeof(handle->packet_buffer), 0, addr, sizeof(struct sockaddr)) != sizeof(handle->packet_buffer))
|
||||
if (sendto(handle->udp_fd, CONST_CAST handle->packet_buffer,
|
||||
sizeof(handle->packet_buffer), 0, addr,
|
||||
sizeof(struct sockaddr)) != sizeof(handle->packet_buffer))
|
||||
{
|
||||
warn_hangup();
|
||||
handle->has_connection = false;
|
||||
@@ -451,10 +610,9 @@ static int poll_input(netplay_t *handle, bool block)
|
||||
{
|
||||
int max_fd = (handle->fd > handle->udp_fd ? handle->fd : handle->udp_fd) + 1;
|
||||
|
||||
const struct timeval tv = {
|
||||
.tv_sec = 0,
|
||||
.tv_usec = block ? (RETRY_MS * 1000) : 0
|
||||
};
|
||||
struct timeval tv = {0};
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = block ? (RETRY_MS * 1000) : 0;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -566,14 +724,14 @@ static void parse_packet(netplay_t *handle, uint32_t *buffer, unsigned size)
|
||||
static bool receive_data(netplay_t *handle, uint32_t *buffer, size_t size)
|
||||
{
|
||||
socklen_t addrlen = sizeof(handle->their_addr);
|
||||
if (recvfrom(handle->udp_fd, NONCONST_CAST buffer, size, 0, (struct sockaddr*)&handle->their_addr, &addrlen) != size)
|
||||
if (recvfrom(handle->udp_fd, NONCONST_CAST buffer, size, 0, (struct sockaddr*)&handle->their_addr, &addrlen) != (ssize_t)size)
|
||||
return false;
|
||||
handle->has_client_addr = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Poll network to see if we have anything new. If our network buffer is full, we simply have to block for new input data.
|
||||
bool netplay_poll(netplay_t *handle)
|
||||
static bool netplay_poll(netplay_t *handle)
|
||||
{
|
||||
if (!handle->has_connection)
|
||||
return false;
|
||||
@@ -594,16 +752,6 @@ bool netplay_poll(netplay_t *handle)
|
||||
return true;
|
||||
}
|
||||
|
||||
//fprintf(stderr, "Before poll: Other ptr: %lu, Read ptr: %lu, Self ptr: %lu\n", handle->other_ptr, handle->read_ptr, handle->self_ptr);
|
||||
/*
|
||||
if (handle->buffer_size > 1)
|
||||
{
|
||||
assert(handle->other_ptr != handle->self_ptr);
|
||||
assert(handle->read_ptr != handle->self_ptr);
|
||||
}
|
||||
assert(handle->other_ptr == handle->read_ptr);
|
||||
*/
|
||||
|
||||
// We might have reached the end of the buffer, where we simply have to block.
|
||||
int res = poll_input(handle, handle->other_ptr == handle->self_ptr);
|
||||
if (res == -1)
|
||||
@@ -641,8 +789,6 @@ bool netplay_poll(netplay_t *handle)
|
||||
}
|
||||
}
|
||||
|
||||
//fprintf(stderr, "After poll: Other ptr: %lu, Read ptr: %lu, Self ptr: %lu\n", handle->other_ptr, handle->read_ptr, handle->self_ptr);
|
||||
|
||||
if (handle->read_ptr != handle->self_ptr)
|
||||
simulate_input(handle);
|
||||
else
|
||||
@@ -677,28 +823,42 @@ int16_t netplay_input_state(netplay_t *handle, bool port, unsigned device, unsig
|
||||
void netplay_free(netplay_t *handle)
|
||||
{
|
||||
close(handle->fd);
|
||||
close(handle->udp_fd);
|
||||
|
||||
for (unsigned i = 0; i < handle->buffer_size; i++)
|
||||
free(handle->buffer[i].state);
|
||||
|
||||
free(handle->buffer);
|
||||
if (handle->spectate)
|
||||
{
|
||||
for (unsigned i = 0; i < MAX_SPECTATORS; i++)
|
||||
if (handle->spectate_fds[i] >= 0)
|
||||
close(handle->spectate_fds[i]);
|
||||
|
||||
free(handle->spectate_input);
|
||||
}
|
||||
else
|
||||
{
|
||||
close(handle->udp_fd);
|
||||
|
||||
for (unsigned i = 0; i < handle->buffer_size; i++)
|
||||
free(handle->buffer[i].state);
|
||||
|
||||
free(handle->buffer);
|
||||
}
|
||||
|
||||
if (handle->addr)
|
||||
freeaddrinfo(handle->addr);
|
||||
|
||||
free(handle);
|
||||
}
|
||||
|
||||
const struct snes_callbacks* netplay_callbacks(netplay_t *handle)
|
||||
static const struct snes_callbacks* netplay_callbacks(netplay_t *handle)
|
||||
{
|
||||
return &handle->cbs;
|
||||
}
|
||||
|
||||
bool netplay_should_skip(netplay_t *handle)
|
||||
static bool netplay_should_skip(netplay_t *handle)
|
||||
{
|
||||
return handle->is_replay && handle->has_connection;
|
||||
}
|
||||
|
||||
void netplay_pre_frame(netplay_t *handle)
|
||||
static void netplay_pre_frame_net(netplay_t *handle)
|
||||
{
|
||||
psnes_serialize(handle->buffer[handle->self_ptr].state, handle->state_size);
|
||||
handle->can_poll = true;
|
||||
@@ -706,8 +866,140 @@ void netplay_pre_frame(netplay_t *handle)
|
||||
input_poll_net();
|
||||
}
|
||||
|
||||
// Here we check if we have new input and replay from recorded input.
|
||||
void netplay_post_frame(netplay_t *handle)
|
||||
static inline uint16_t swap_if_big16(uint16_t input)
|
||||
{
|
||||
if (is_little_endian())
|
||||
return input;
|
||||
else
|
||||
return (input << 8) | (input >> 8);
|
||||
}
|
||||
|
||||
static void netplay_set_spectate_input(netplay_t *handle, int16_t input)
|
||||
{
|
||||
if (handle->spectate_input_ptr >= handle->spectate_input_size)
|
||||
{
|
||||
handle->spectate_input_size++;
|
||||
handle->spectate_input_size *= 2;
|
||||
handle->spectate_input = (uint16_t*)realloc(handle->spectate_input,
|
||||
handle->spectate_input_size * sizeof(uint16_t));
|
||||
}
|
||||
|
||||
handle->spectate_input[handle->spectate_input_ptr++] = swap_if_big16(input);
|
||||
}
|
||||
|
||||
int16_t input_state_spectate(bool port, unsigned device, unsigned index, unsigned id)
|
||||
{
|
||||
int16_t res = netplay_callbacks(g_extern.netplay)->state_cb(port, device, index, id);
|
||||
netplay_set_spectate_input(g_extern.netplay, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int16_t netplay_get_spectate_input(netplay_t *handle, bool port, unsigned device, unsigned index, unsigned id)
|
||||
{
|
||||
int16_t inp;
|
||||
if (recv(handle->fd, NONCONST_CAST &inp, sizeof(inp), 0) == (ssize_t)sizeof(inp))
|
||||
return swap_if_big16(inp);
|
||||
else
|
||||
{
|
||||
SSNES_ERR("Connection with host was cut!\n");
|
||||
msg_queue_clear(g_extern.msg_queue);
|
||||
msg_queue_push(g_extern.msg_queue, "Connection with host was cut!", 1, 180);
|
||||
|
||||
psnes_set_input_state(netplay_callbacks(g_extern.netplay)->state_cb);
|
||||
return netplay_callbacks(g_extern.netplay)->state_cb(port, device, index, id);
|
||||
}
|
||||
}
|
||||
|
||||
int16_t input_state_spectate_client(bool port, unsigned device, unsigned index, unsigned id)
|
||||
{
|
||||
return netplay_get_spectate_input(g_extern.netplay, port, device, index, id);
|
||||
}
|
||||
|
||||
static void netplay_pre_frame_spectate(netplay_t *handle)
|
||||
{
|
||||
if (handle->spectate_client)
|
||||
return;
|
||||
|
||||
fd_set fds;
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(handle->fd, &fds);
|
||||
|
||||
struct timeval tmp_tv = {0};
|
||||
if (select(handle->fd + 1, &fds, NULL, NULL, &tmp_tv) <= 0)
|
||||
return;
|
||||
|
||||
if (!FD_ISSET(handle->fd, &fds))
|
||||
return;
|
||||
|
||||
struct sockaddr_storage their_addr;
|
||||
socklen_t addr_size = sizeof(their_addr);
|
||||
int new_fd = accept(handle->fd, (struct sockaddr*)&their_addr, &addr_size);
|
||||
if (new_fd < 0)
|
||||
{
|
||||
SSNES_ERR("Failed to accept incoming spectator!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int index = -1;
|
||||
for (unsigned i = 0; i < MAX_SPECTATORS; i++)
|
||||
{
|
||||
if (handle->spectate_fds[i] == -1)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// No vacant client streams :(
|
||||
if (index == -1)
|
||||
{
|
||||
close(new_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
size_t header_size;
|
||||
uint8_t *header = bsv_header_generate(&header_size);
|
||||
if (!header)
|
||||
{
|
||||
SSNES_ERR("Failed to generate BSV header!\n");
|
||||
close(new_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
int bufsize = header_size;
|
||||
setsockopt(new_fd, SOL_SOCKET, SO_SNDBUF, CONST_CAST &bufsize, sizeof(int));
|
||||
|
||||
const uint8_t *tmp_header = header;
|
||||
while (header_size)
|
||||
{
|
||||
ssize_t ret = send(new_fd, CONST_CAST tmp_header, header_size, 0);
|
||||
if (ret <= 0)
|
||||
{
|
||||
SSNES_ERR("Failed to send header to client!\n");
|
||||
close(new_fd);
|
||||
free(header);
|
||||
return;
|
||||
}
|
||||
|
||||
header_size -= ret;
|
||||
tmp_header += ret;
|
||||
}
|
||||
|
||||
free(header);
|
||||
handle->spectate_fds[index] = new_fd;
|
||||
|
||||
log_connection(&their_addr, index);
|
||||
}
|
||||
|
||||
void netplay_pre_frame(netplay_t *handle)
|
||||
{
|
||||
if (handle->spectate)
|
||||
netplay_pre_frame_spectate(handle);
|
||||
else
|
||||
netplay_pre_frame_net(handle);
|
||||
}
|
||||
|
||||
static void netplay_post_frame_net(netplay_t *handle)
|
||||
{
|
||||
handle->frame_count++;
|
||||
|
||||
@@ -718,7 +1010,7 @@ void netplay_post_frame(netplay_t *handle)
|
||||
// Skip ahead if we predicted correctly. Skip until our simulation failed.
|
||||
while (handle->other_frame_count < handle->read_frame_count)
|
||||
{
|
||||
struct delta_frame *ptr = &handle->buffer[handle->other_ptr];
|
||||
const struct delta_frame *ptr = &handle->buffer[handle->other_ptr];
|
||||
if ((ptr->simulated_input_state != ptr->real_input_state) && !ptr->used_real)
|
||||
break;
|
||||
handle->other_ptr = NEXT_PTR(handle->other_ptr);
|
||||
@@ -735,9 +1027,13 @@ void netplay_post_frame(netplay_t *handle)
|
||||
while (first || (handle->tmp_ptr != handle->self_ptr))
|
||||
{
|
||||
psnes_serialize(handle->buffer[handle->tmp_ptr].state, handle->state_size);
|
||||
#ifdef HAVE_THREADS
|
||||
lock_autosave();
|
||||
#endif
|
||||
psnes_run();
|
||||
#ifdef HAVE_THREADS
|
||||
unlock_autosave();
|
||||
#endif
|
||||
handle->tmp_ptr = NEXT_PTR(handle->tmp_ptr);
|
||||
first = false;
|
||||
}
|
||||
@@ -747,3 +1043,48 @@ void netplay_post_frame(netplay_t *handle)
|
||||
}
|
||||
}
|
||||
|
||||
static void netplay_post_frame_spectate(netplay_t *handle)
|
||||
{
|
||||
if (handle->spectate_client)
|
||||
return;
|
||||
|
||||
for (unsigned i = 0; i < MAX_SPECTATORS; i++)
|
||||
{
|
||||
if (handle->spectate_fds[i] == -1)
|
||||
continue;
|
||||
|
||||
size_t send_size = handle->spectate_input_ptr * sizeof(int16_t);
|
||||
const uint8_t *tmp_buf = (const uint8_t*)handle->spectate_input;
|
||||
while (send_size)
|
||||
{
|
||||
ssize_t ret = send(handle->spectate_fds[i], CONST_CAST tmp_buf, send_size, 0);
|
||||
if (ret <= 0)
|
||||
{
|
||||
SSNES_LOG("Client (#%u) disconnected ...\n", i);
|
||||
|
||||
char msg[512];
|
||||
snprintf(msg, sizeof(msg), "Client (#%u) disconnected!", i);
|
||||
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
|
||||
|
||||
close(handle->spectate_fds[i]);
|
||||
handle->spectate_fds[i] = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
tmp_buf += ret;
|
||||
send_size -= ret;
|
||||
}
|
||||
}
|
||||
|
||||
handle->spectate_input_ptr = 0;
|
||||
}
|
||||
|
||||
// Here we check if we have new input and replay from recorded input.
|
||||
void netplay_post_frame(netplay_t *handle)
|
||||
{
|
||||
if (handle->spectate)
|
||||
netplay_post_frame_spectate(handle);
|
||||
else
|
||||
netplay_post_frame_net(handle);
|
||||
}
|
||||
|
||||
Loaded 100 of 156 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user