693 Commits
Author SHA1 Message Date
Flyinghead aa97a6d64f pvr: last naomi2 poly was ignored in some cases
Fix the disappearing moustache in wild riders
Fix other potential edge cases in pvr parsing
2022-08-25 19:34:23 +02:00
scribam 72136c2bfc deps: update sdl to version 2.24.0 2022-08-22 12:29:34 +02:00
scribam 7457db8bba android: update android gradle plugin to version 7.2.2 2022-08-06 17:30:10 +02:00
GABO1423 69125b490e (UWP) Build Tweaks (#709)
* (UWP) Disable Vulkan Build Flag

* (CI) Remove UWP Build Flag
2022-08-04 17:37:06 +02:00
vkedwardli 3c94cd3194 Fix macOS accent menu (#708)
* `SDL_StartTextInput` only when textfield is focused

* [macOS] "Reveal in Finder" button for Home Directory

* only enable for `USE_SDL`
2022-08-04 17:35:40 +02:00
bslenul 75ff5409f4 Switch broadcast region for San Francisco Rush 2049 and Sega Smash Pack - Volume 1 2022-07-25 11:26:12 +02:00
Flyinghead 642fad9a6e cfg: per-game settings must be deleted when changed back to standard
When a per-game setting is the same as the standard one, it is ignored
and not saved to emu.cfg. However the previously saved per-game setting
wasn't deleted, making it impossible to revert.

Issue #653
2022-07-25 11:25:42 +02:00
GABO1423 5ae7ac3eca (UWP) Add Additional Rescap Capabilities 2022-07-22 18:13:11 +02:00
Edward Li 885862a45e Get writable log path for macOS also 2022-07-22 18:12:43 +02:00
Edward Li 9b751fced8 NSLog with UTF-8, better color handling 2022-07-22 18:12:43 +02:00
Flyinghead 76bf574668 gl,gl4: disable anisotropic filtering if not linear
Issue #695
2022-07-15 20:36:29 +02:00
Edward Li c77c3ab015 DRY 2022-07-09 11:46:27 +02:00
Edward Li 8acd81cc43 Add MacPorts as alternative link 2022-07-09 11:46:27 +02:00
Enrique Santos c0e52b9a1a load game: destroy old maple devices before create call 2022-07-08 20:38:16 +02:00
Flyinghead 0840da1bd5 sdl: fix inverted axis detection 2022-07-08 20:36:20 +02:00
vkedwardli 852df89f93 [macOS] Handle Quit menu item properly (#684)
* [macOS] Handle Quit menu item properly

* cleanup
2022-07-05 14:37:28 +02:00
vkedwardli b5eb8694f6 macOS Breakpad (#683)
* Breakpad.framework and dump_syms

* Use ExceptionHandler manually instead of using public methods from the framework

* Change macOS buildType to RelWithDebInfo and enable building Breakpad framework

* Enable symbol upload on GitHub runner

* Compile Breakpad directly instead of embedding the Breakpad.framework

* Print minidump location also

* Ignore `EXC_MASK_BAD_ACCESS` again
2022-07-05 14:36:21 +02:00
Flyinghead f4986008fe jvs: fix 86-request decoding
Fixes kingrt66 inputs when networked
Issue #673
2022-07-05 14:34:57 +02:00
Flyinghead d6644c4935 lr: terminate emu during deinit on android
Issue #566 is for linux only, not android
2022-07-03 18:38:59 +02:00
Flyinghead 5bb8c86903 uwp: force windows sdk version to one compatible with current xbox fw
Fixes error at install: The package requires OS version 10.0.22621.0 or
higher on the Windows.Universal device family. The device is currently
running OS version 10.0.22000.4970.
2022-07-01 12:16:30 +02:00
vkedwardli a659b57e63 Install Vulkan SDK in generate_xcode_project.command (#678) 2022-06-30 14:11:26 +02:00
vkedwardli 44e96c544b Use source_group to create folder hierarchy for Xcode project (#679) 2022-06-30 14:10:15 +02:00
scribam 0a5b8891a8 android: update gradle 2022-06-30 14:09:20 +02:00
Flyinghead 6a5db32d5d don't protect RTT textures vram
Fixes Spikers Battle RTT texture spurious update before use
(transitions)
2022-06-27 13:37:22 +02:00
Flyinghead b0f3e065be ui: wrong scaling after imgui driver reset
ImGuiStyle::ScaleAllSizes() is cumulative so reset style before calling
it
Issue #676
2022-06-27 13:32:30 +02:00
Flyinghead fe895211c1 ui: reset imgui driver before creating new one
Possible fix for Issue #676
2022-06-26 15:23:30 +02:00
Flyinghead 907131b7f5 allow ForceWindowsCE option to be used in per-game config
Issue #252
2022-06-24 13:27:21 +02:00
Flyinghead 76508146ae cheats: only apply widescreen cheat if current value is expected
Issue  #180
2022-06-24 11:47:24 +02:00
vkedwardli 867b519a2b [macOS] Fix imagemagick not found on GitHub runners (#674)
disable dep check for brew reinstall
2022-06-21 09:50:05 +02:00
Flyinghead 74852520dc maxspeed: allow use of per-game network settings
Issue #671
2022-06-20 20:56:53 +02:00
Flyinghead faec4d8e50 gl: always use int arithmetic in palette index glsl calculation 2022-06-20 20:52:15 +02:00
Flyinghead d2aca1d621 savestate: overflow crash when serializing 2022-06-20 20:49:09 +02:00
Flyinghead 05961ac883 android build fix 2022-06-11 13:41:44 +02:00
flyinghead afd07c25ba pvr: store tex address in render context. texture cache refactoring
Store FT_W_SOF1 and FT_W_CTRL in render context since they can be
modified before render end. New tentative fix for vf4 water reflection
flashing black during netplay.
Refactor texture cache to use constructors. RTT code moved from
renderers.
Partial revert of ddcd3861d3
2022-06-11 13:24:22 +02:00
flyinghead 7ab92d88b1 msvc x86 build fix 2022-06-10 17:57:53 +02:00
flyinghead 3780299803 win32 raw api: user-friendly names for devices
Issue #664
2022-06-10 17:20:29 +02:00
flyinghead d78bb9ed3f don't list hidden folders and files on windows. Better parent dir prompt
Issue #666
2022-06-10 15:29:28 +02:00
Flyinghead b5f1552ed8 elan: don't crash on invalid texture xfer size
Issue #647: fixes initdv3jb area conquered crash
2022-06-06 15:54:25 +02:00
Gabriel Morazán 917cc7f27c Readme Updates. (#659)
* Update Reicast Link
2022-06-05 17:32:59 +02:00
Gabriel Morazán 2327e73ee7 (README) Update Xbox Section 2022-06-02 18:11:49 +02:00
Gabriel Morazán 397ddef68c (Libretro) Actually allow DX11 only cores.
Simple build fix.
2022-06-02 18:11:49 +02:00
Gabriel Morazán 3ec7f293ee (Libretro) Allow a DX11 only core to be built. (#657)
Main use case is Xbox systems.
2022-06-01 22:27:51 +02:00
flyinghead 26c8e8dab8 dx11 oit: naomi2 regression. Tr modvols shader needs divPosZ too 2022-06-01 19:26:56 +02:00
Flyinghead fdcea88519 gl4: wrong depth for transparent polys with native depth interp
Issue #630
2022-06-01 19:26:56 +02:00
flyinghead bf6c73060b native depth interpolation option to help AMD gpus
When enabled, set 1/z in pos.w and use native interpolation for colors,
UV and depth.
Get rid of manual modvol clipping in dx11.
2022-06-01 19:26:56 +02:00
Flyinghead ddcd3861d3 ggpo: don't protect rtt texture vram if ggpo is enabled
tentative fix for flashing water reflection texture in vf4 during
netplay
2022-05-31 17:42:42 +02:00
Flyinghead 971d47eb42 sdl: SDL_QuitSubSystem() on exit
Tentative fix for issue #654
2022-05-31 17:42:42 +02:00
Enrique Santos 13bd42bdab chat: disable window timeout after you respond to message 2022-05-30 16:15:44 +02:00
Flyinghead 71ac212dc7 elan: disable texture for vertices without UV coordinates
Fixes initial D white transparent quad at start of race
2022-05-30 16:15:15 +02:00
Flyinghead 2319a00c4f vk: bump moltenvk to 1.3.211.0 2022-05-29 13:35:22 +02:00
Flyinghead 1268077f6b cheat: missing cheat value in constructor
Fixes vf4tuned dimm check cheat writing random value (SH4 exception,
boot loop)
2022-05-29 13:30:06 +02:00
vkedwardli 5c579de459 Enable Texture Upscaling on macOS (#645)
* Compile a universal libomp
* static linking OpenMP
2022-05-28 13:00:20 +02:00
Flyinghead 167faff1f3 vk: invalid lightgun crosshair if maple device A isn't a lightgun 2022-05-28 12:58:53 +02:00
Flyinghead 22ad95cbfe ios: diagonal DPad buttons. Pan between buttons. Help tip for menu
Add diagonal DPad buttons
Allow switching virtual button without lifting finger.
Display help tip on first startup about pausing/opening menu.
2022-05-27 18:32:55 +02:00
Flyinghead db8508cefc ios: update AltKit 2022-05-27 18:20:16 +02:00
Flyinghead 5ac0772a2a vk oit: out of pool memory with moltenvk during render to texture 2022-05-26 18:06:30 +02:00
Flyinghead e2c2d6606d Fix Dead or Alive 2: Limited Edition (JP) widescreen cheat
Issue #625
2022-05-26 17:54:45 +02:00
Flyinghead 48361f58b6 vk oit: wrong temporary framebuffer dimensions 2022-05-25 16:44:24 +02:00
Enrique Santos dcb439f74a add ggpo chat window timeout 2022-05-23 11:42:11 +02:00
flyinghead 739a27be63 dx11 oit: render target and depth/stencil must have same dimensions
Fixes glitches during doa2 attract mode (depth/stencil missing).
2022-05-23 11:41:37 +02:00
Flyinghead e84cdce398 reios: flashrom read returns 0 on success. system id/timezone flash fix
flashrom read returns 0 on success, not size read.
Fixes Slave Zero (PAL) crash
2022-05-21 15:46:22 +02:00
Flyinghead af2fe242f9 flash: console id is checksummed 2022-05-18 14:58:21 +02:00
Flyinghead 0fb177bf85 reios: fix regression on many games due to 77a2bbbb
Jeremy McGrath
Skies of Arcadia
Speed Devils Online
Sydney 2000
Tech Romancer
Time Stalkers
Virtua Athlete 2000
Quake 3 (EU)
Climax Landers (JP)
Frame Gride
Pop'n'Music 1 & 2
Simple2000 2 & 3
2022-05-18 14:56:14 +02:00
Edward Li baab70c509 Rumble using MacBook's Taptic Engine (take 2) 2022-05-17 16:37:37 +02:00
scribam bc1c70bd1a ci: remove brew install libomp 2022-05-17 16:36:57 +02:00
scribam 12929c4571 openmp: use _OPENMP preprocessor, search openmp pkg unconditionally if enabled 2022-05-17 16:36:57 +02:00
Flyinghead 62522e4eb3 vk: naomi2 crash when lightModel is null
fixes crash at end of tutorial in kingrt66
2022-05-17 16:36:34 +02:00
Flyinghead 221060cc70 widescreen cheat for Dynamite Deka2 (JP), Zombie Revenge (naomi)
Better Dynamite Deka ex (naomi) widescreen cheat.
Courtesy of Goddamn Superhero
2022-05-16 13:06:38 +02:00
Flyinghead 58d1f7cee1 pvr: reset nextContext in Reset(). Use tactx_Alloc for direct fb render
Fix crash with multipass renders
Issue #634
2022-05-16 13:04:38 +02:00
Flyinghead 430256266f pvr: lightModels TA overrun on beach spikers
Better sizing of TA_context lists
2022-05-15 13:41:03 +02:00
Flyinghead f9e38b11d9 pvr: restore TA_context pool
fixes performance regression on android
2022-05-15 13:37:58 +02:00
Flyinghead 78e075546a libretro android build fix 2022-05-15 13:35:23 +02:00
jdgleaver 0e23b0bedd (libretro) Add option to detect and notifiy frontend of internal frame rate changes (60 <-> 30 <-> 20 fps, etc.)
Improves frame pacing in games with locked 30 fps and 20 fps frame rates
2022-05-13 17:13:25 +02:00
Flyinghead 903c768f7f vk oit: First frame after init wasn't displayed 2022-05-13 17:12:31 +02:00
Flyinghead cd22ba1a2b android: use WifiManager.MulticastLock to receive broadcast packets
In many cases, broadcast UDP packets can't be received on android unless
a MulticastLock is held.
2022-05-12 17:39:49 +02:00
flyinghead cce8cb8528 dx11 oit: missing TextureFiltering support
Issue #628
2022-05-11 19:16:31 +02:00
jdgleaver 6c6b447ea1 (libretro) Limit maximum number of audio samples that can be uploaded per call of retro_run() 2022-05-05 18:02:40 +02:00
Flyinghead 4554450d1d oit: add max layers and pixel buffer size options 2022-05-05 18:01:05 +02:00
Flyinghead a0d1dbf833 dx11: don't create the device in debug mode 2022-05-04 19:38:43 +02:00
Flyinghead a1a89df17f change vf4ft dimm check cheat. Don't apply cheat if not needed.
Fixes the SH4 exception seen with the previous cheat on some platforms.
Don't write memory if value is unchanged to avoid unnecessary protection
faults.
2022-05-04 10:30:35 +02:00
Flyinghead cf36384481 use nearest/point sampling to draw framebuffer if nearest is forced 2022-05-03 17:55:02 +02:00
flyinghead 9103371362 vk: increase descSet pool size for storage buffers and input attachments
Fixes out of host memory error on macOS
Issue #619
2022-05-03 17:49:46 +02:00
flyinghead 1b5ad34c8e dx11: (oit) use temporary render target for multipass
Render to temporary render target at end of pass and swap with regular
RT.
Fixes Tony Hawk 2 missing transparent geometry and character shadow.
Issue #618
2022-05-03 17:47:43 +02:00
Flyinghead c57e88850c lr: avoid crash when rewind is on
Issue #471
2022-05-01 19:22:22 +02:00
scribam 101a831534 cmake/macos: remove multitouch library 2022-05-01 12:34:43 +02:00
Flyinghead 3cc991fa4f oit: poly number/vertex id overflow
Use 17 bits for vertex id but substract first vtx index
Use 13 bits for poly number instead of 12
Panzer Front uses more than 4095 tr polys.
Issue #616
2022-05-01 12:33:53 +02:00
Flyinghead c348f4ccad allow a core without open gl to be built
Issue #515
2022-04-30 18:05:12 +02:00
Flyinghead 0181685d2f cheats: use software name as additional condition for widescreen
don't enable widescreen cheat for code veronica X
Issue #229
2022-04-30 12:08:36 +02:00
Flyinghead 39bb94dd55 jvs: don't scale ninja assault lightgun coordinates
Fixes reload issues (Issue #610)
2022-04-30 11:50:56 +02:00
Flyinghead 77a2bbbb8d reios: cancel gd dma int in g1_end_dma. drv_stat returns busy when busy
Cancel G1 DMA interrupt in G1_DMA_END (fixes MSR, Psychic Force, Pro
Pinball, Sega Swirl)
GET_DRV_STAT must return busy when drive is busy (fixes Hell Gate, Zero
Gunner)
Better named constants
2022-04-29 15:18:41 +02:00
Flyinghead afb0a80de1 pvr: autosort needs empty passes to be accounted for
Issue #612
2022-04-29 11:37:17 +02:00
Flyinghead 49932e02a6 gdrom: generate raw subcode 2022-04-27 14:32:53 +02:00
Flyinghead 990a4ad583 vk: ignore pipeline cache if loading fails 2022-04-27 14:30:03 +02:00
Flyinghead fc9e1e401b naomi: emulate midi ffb drive board response
needed for driving simulator
2022-04-27 14:28:58 +02:00
scribam 15ca7e82bd ci: fix java-version for actions/setup-java 2022-04-26 10:14:58 +02:00
Flyinghead 3b81bbcae5 naomi2: gmp diffuse/specular flags select vertex or model colors only
These flags shouldn't be used to disable diffuse/specular shading
Fixes road surface glitches in initdv3e (Usui map)
2022-04-21 13:55:09 +02:00
Flyinghead 902fc2cbe8 naomi: override Region settings if current region BIOS isn't found 2022-04-20 14:16:15 +02:00
Flyinghead 50f5dabf4a naomi2: use diffuse/specular color before light routing
fixes lion's jacket color and shun's face glitch (vf4)
2022-04-20 14:13:42 +02:00
scribam aa6c9e2106 msvc: fix linking issues in debug build 2022-04-17 13:24:37 +02:00
scribam 919fdb3594 ci: add distribution input to actions/setup-java@v3 2022-04-17 13:24:11 +02:00
Flyinghead c625cc68bf lr: increase vk descSet pool size. Insert card binding
vk: Use same descriptor set pool sizes for standalone and core
lr: bind "Insert Card" to L button (Naomi button 6)
lr: reset input descriptors when loading a new game
lr: don't reset maple devices in arcade mode: reloading eeprom cancels game settings
2022-04-17 13:23:16 +02:00
flyinghead d732140bf9 Merge pull request #595 from flyinghead/dev
Naomi 2 support
2022-04-16 14:24:49 +02:00
Flyinghead db525bd5db android: fix touchscreen on Retroid Pocket 2+
Unexpected event source for touchscreen events
2022-04-15 18:06:15 +02:00
Flyinghead 039c666247 more types.h clean up. better aica handler templates 2022-04-15 17:03:49 +02:00
Flyinghead ed5c24c281 arm64 build fix 2022-04-15 11:17:22 +02:00
Flyinghead f2f4010203 clean up types.h, refactoring 2022-04-14 11:34:45 +02:00
Flyinghead a9e261d280 simplify TA parsing 2022-04-13 20:36:52 +02:00
Flyinghead a710674cd4 gui: init once. reset ui driver when needed. android 120+ Hz support
ImGui is now initialized once at startup and shutdown before
terminating. graphics initialization is independent.
Move more imgui stuff into imgui drivers.
switch: set scaling on external screen to 1.4, same as xbox
UI scaling refactoring.
2022-04-13 18:06:19 +02:00
Flyinghead ddfc00ed9f Merge remote-tracking branch 'origin/master' into dev 2022-04-13 16:29:41 +02:00
Flyinghead ac71970561 don't save built-in cheats (vf4 dimm check) 2022-04-13 13:10:56 +02:00
Flyinghead fd50529d86 gl: (lr) black screen when vmu display is on
need to call glBindVertexArray(0) to avoid VAO being modified by the
frontend
2022-04-12 18:23:09 +02:00
Flyinghead 52d95e537c lr ci: disable switch build 2022-04-11 15:56:43 +02:00
Flyinghead 15b21fff2b vk: don't use anisotropic with nearest. Use linear mipmap filter
Issue #580
2022-04-11 13:35:48 +02:00
scribam f46bccfecd cmake: reunified dx9 files 2022-04-10 11:28:09 +02:00
Flyinghead 1f55973f72 libretro ci: add switch build 2022-04-10 11:27:37 +02:00
scribam 3d5fd61285 macos: fix size for image icons 2022-04-09 12:06:17 +02:00
scribam 069b501ca3 android: update android gradle plugin to version 7.1.3 2022-04-09 12:05:22 +02:00
flyinghead d035af7ff0 xbox: low resolution (640x480) with recent firmware
Device ids for xbox series s/x returned from
GetGamingDeviceModelInformation() have changed
2022-04-09 12:04:51 +02:00
scribam 20302cd378 cmake: add XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER 2022-04-07 23:09:08 +02:00
scribam 959685e260 ci: use xcode for macos 2022-04-06 14:54:28 +02:00
Flyinghead e0058c17ff lr: don't terminate emu on deinit. gl4: buffer wasn't released on term()
shared libraries containing gnuc unique symbols are never unloaded on
linux, and possibly other platforms. So don't terminate the emulator on
deinit and init it only once.
Issue #566

gl4: buffer not released on term() was causing crashes or black screen when restarted.
2022-04-05 14:53:47 +02:00
Flyinghead bf61f5cfe8 Merge remote-tracking branch 'origin/master' into dev 2022-04-04 12:11:10 +02:00
Flyinghead 8dcc25e1a9 ta: default base/offset color is white, not black
fixes black players in NHL 2K
2022-04-04 11:47:11 +02:00
Flyinghead a428167dc6 naomi network: alienfnt startup crash if not connected 2022-04-04 11:43:54 +02:00
Flyinghead e46d819c46 aws needs bash shell 2022-04-04 11:41:28 +02:00
Flyinghead 48e3a3eb68 aica: double arm clock speed
actual aica arm clock seems to be 22.5792 MHz, which means 512 cycles
per sample at 44.1 KHz (from 256)
fixes vf4 audio hiccup in character selection screen
2022-04-03 20:53:44 +02:00
Flyinghead a635fb3f77 test automation build fix, better exit 2022-04-03 20:46:50 +02:00
scribam 274f2fe10d ci: add ninja, update actions and ccache support 2022-04-03 15:38:49 +02:00
Flyinghead 320f679038 win32 build fix 2022-04-02 16:59:57 +02:00
Flyinghead 94c20ba29f elan: reset TA parser before loading state 2022-04-02 16:43:15 +02:00
Flyinghead 8baebcfb5b maxspeed networking. Store aw force feedback value 2022-04-02 16:41:52 +02:00
flyinghead 2c96d49cf2 dx9, dx11: support for forced point/linear tex sampling and anisotropy 2022-04-02 11:18:48 +02:00
Hugo Locurcio a9cabdc342 Add texture filter override setting, expose anisotropic filtering
The new texture filter option can be set to:

- Default (keeps the game's intended filter mode).
- Force Nearest-Neighbor (crisper appearance).
- Force Linear (smoother appearance).

Additionally, mipmapping can now be enabled on nearest neighbor-filtered
textures (which is used if nearest-neighbor filtering is enabled, including
with anisotropic filtering).

Anisotropic filtering was already implemented in both OpenGL and Vulkan,
but it was not exposed in the GUI.
2022-04-01 16:00:41 +02:00
Hugo Locurcio 90a95b4688 Add 6×, 7×, 8× and 9× options for internal resolution
This can be used to get a smoother image (supersampling) on
1440p and 4K displays. The 9× setting is also suited for native
resolution rendering on 8K displays.
2022-04-01 16:00:28 +02:00
flyinghead 7fcce4a59b naomi network: ignore WSAECONNRESET. Longer timeout for client 2022-03-30 15:48:23 +02:00
Flyinghead 554ffcd08f naomi: use platform-independent network error codes (win32) 2022-03-30 14:13:02 +02:00
scribam 0c46ea13c7 ci: use windows-latest 2022-03-27 18:14:38 +02:00
Flyinghead af0574c04e build fixes for msvc, ios and android 2022-03-27 15:57:01 +02:00
Flyinghead 6c38295d62 new naomi network protocol. vblank event. initd rumble support
new vblank event, used by cheats, lua and naomi net
new udp net protocol for naomi. rx/tx on vblank on emu thread.
input: rumble power configurable (Issue #158)
ui: rumble intensity slider, enable/disable upnp
aica: hook to consume midi out
decode midi out to simulate rumble for initd
upnp can now be disabled
2022-03-27 15:23:21 +02:00
Flyinghead 1e01dbb151 wrong line padding value when copying RTT to vram due to previous commit 2022-03-26 20:51:07 +01:00
Flyinghead be270259ee crash with RTT and copy to VRAM if width > linestride
RTT texture width must not exceed FB_W_LINESTRIDE
fixes Flag to flag crash
2022-03-25 15:41:16 +01:00
Nikos Chantziaras 03f9955f8b libretro: present frames before audio upload
retro_audio_sample_batch_t can block for a long time if the frontend
performs audio sync. This unnecessarily delays frame presentation.
2022-03-23 21:30:03 +01:00
Flyinghead 55e613fae5 widescreen cheats for gun spike, initdv3e, alpilotj, monkey ball
Courtesy of Esppiral
2022-03-21 17:51:31 +01:00
Flyinghead a5bad2b9b7 more naomi widescreen cheats. Fix vathlete 4-player mode
widescreen cheats for asndynmt, doa2m, slashout, spikers battle,
18wheeler, beach spikers. Courtesy of Esppiral
vathlete needs 2 I/O boards for 4-player mode
2022-03-20 17:49:50 +01:00
Flyinghead ebb251d8cf widescreen cheat for vf4tuned
Courtesy of Esppiral
2022-03-19 11:30:45 +01:00
Flyinghead 56768f2d3d naomi2: use TA parser. Use N2light directly with vk, dx11
Use TA parser to handle list type and clipping for Naomi 2 polys.
Pass all pass-throuch TA data to TA parser but stop on naomi2 command.
Set default projection matrix instead of identity (fixes Area conquered
screen invisible in initd).
Change N2Light and N2LightModel so they are usable in GLSL (vulkan) and
HLSL (dx11).
TA parser throws exception for unhandled param.
ta_vtx.cpp refactoring.
Support for subtractive lights (diffuse+specular). Used in some clubk
circuits.
Fix vulkan crash when direct FB render.
2022-03-16 17:28:45 +01:00
Flyinghead 5b3d36e081 naomi2: network support for clubk and initd
clubk: don't reverse handle by default
hotd2 doesn't have a proper game id or standard eeprom
2022-03-15 19:44:24 +01:00
Flyinghead ad08590197 vulkan: cache per-poly desc sets in map
avoid desc set pool exhaustion in per-triangle
2022-03-13 11:39:30 +01:00
Flyinghead 53b5588bda Merge remote-tracking branch 'origin/master' into dev 2022-03-13 11:01:27 +01:00
Flyinghead 1015a8c098 naomi2: vulkan support
oit: use #define instead of functions in GLSL
2022-03-12 17:56:46 +01:00
Flyinghead 27ddc215cc naomi2: boost lights by constant factor. simplify shaders 2022-03-08 17:38:29 +01:00
Flyinghead c11a6cd432 naomi2: partial gles2 compatibility
Issue #553
2022-03-07 20:32:08 +01:00
Flyinghead 514eedbc63 maple: do not raise maple_dma interrupt for light gun
Issue #474 (Virtua Cop 2 momentarily freezes when shot fired)
2022-03-07 19:16:49 +01:00
Flyinghead 1f61f80c92 input: fix naomi rotary encoders
Games with multiple JVS input boards poll inputs more than once,
ignoring some relative mouse movements.

Issue #557
2022-03-06 17:57:16 +01:00
scribam 830ffd0559 deps/picotcp: pico_ipv6_source_dev_find requires PICO_SUPPORT_IPV6
Backport https://github.com/virtualsquare/picotcp/commit/529074aab4f53a87426673548d6793ced666b6ed
2022-02-28 07:24:50 +01:00
scribam ed066df469 deps: update miniupnpc 2022-02-28 07:24:36 +01:00
scribam e6676c7d09 android: update gradle 2022-02-27 08:33:44 +01:00
scribam 33115a39a3 android: use latest cmake from android studio 2022-02-27 08:33:44 +01:00
Flyinghead 6538360fe1 switch: use devkita64:20220128 instead of latest
fixes peformance issue
2022-02-26 08:14:10 +01:00
Flyinghead 3a62e432da switch: revert a92c2899c8
back to .obj instead of .o
2022-02-25 18:35:58 +01:00
Flyinghead 9c3f60c26c CI: windows-2019 for windows. devkita64:20220128 for switch 2022-02-25 18:30:28 +01:00
Flyinghead ed0e5b8c5a remaining references to windows-latest -> windows-2019 2022-02-25 17:47:47 +01:00
Flyinghead c75d94bd90 use windows-2019 for windows builds 2022-02-25 17:36:13 +01:00
Depal1 a8d6374d76 Add installation on MacOS via Homebrew 2022-02-25 17:18:35 +01:00
cmitu 4b10402c5b Disable stencil usage on low end VC4 devices (Pi3)
Make the libretro core boot again when using the legacy VC4 GLES drivers.
Based on https://github.com/libretro/flycast/commit/ee9cd16f

Fixes: https://github.com/flyinghead/flycast/issues/539
2022-02-24 07:17:48 +01:00
Flyinghead e5863920c4 naomi2: fix beach spiker crash
VUR vertices can also have environment mapping
2022-02-22 08:48:51 +01:00
Flyinghead 7f61b44d42 imgui: better drag scrolling code 2022-02-21 19:48:52 +01:00
Flyinghead a5660fa2b4 missing changes from previous commit 2022-02-18 17:40:00 +01:00
Flyinghead ecc03e3ebc naomi: use boot rom id to configure eeprom
Make eeprom from scratch if it doesn't exist based on boot id info.
Override eeprom settings to make game happy
Change region to supported one
Get rid of per-rom region info in rom list
New option to configure Naomi games in free play
2022-02-18 17:35:20 +01:00
Flyinghead a92c2899c8 switch build: cmake is now producing .o instead of .obj 2022-02-18 16:42:05 +01:00
Flyinghead af4638e83f naomi2: fix another initdv2 end of race crash 2022-02-18 16:40:26 +01:00
Flyinghead cecf1a5497 naomi2: fix initdv2 end of race crash 2022-02-17 18:31:20 +01:00
Flyinghead f2374982b8 pvr: don't merge polys with != palette. 2nd pass sometimes ignored
polys with different palette index shouldn't be merged.
If a pass isn't using any opaque, it can't be found. Fall back to using
the transparent or punch-through list in this case.
2022-02-17 18:30:29 +01:00
Flyinghead d736dd027d naomi2: initd card support. lua: fix multi-threading crash
initial d card reader support. insert card button.
lua: use mutex to enforce thread-safety
2022-02-16 19:02:04 +01:00
Flyinghead 214db9e0b1 gl4: depth pass need texture and UV for punch-through polys 2022-02-15 17:18:32 +01:00
Flyinghead 3bbc89afc9 dx11: fix crash with modvols 2022-02-15 17:16:45 +01:00
Flyinghead e35ccbbb18 naomi2: force region for some roms. elan clean up 2022-02-15 17:15:44 +01:00
Flyinghead 20571c5aa1 chd: MIL-CD support
Issue #529
2022-02-15 11:34:11 +01:00
Flyinghead 3872a6b475 libretro: support VMU and lightgun crosshair with dx11 OIT renderer
OIT support was missing
Issue #525
2022-02-15 11:06:51 +01:00
Flyinghead 083a1c85a8 gl: shader compile error on shield tablet
Don't use GL_NV_shader_noperspective_interpolation since it's not really
needed (and wasn't enabled)

Issue #510
2022-02-14 18:54:27 +01:00
Flyinghead 943e0285ac libretro: support VMU and lightgun crosshair with dx11 renderer
Issue #525
2022-02-14 18:47:23 +01:00
Flyinghead d7abfc688c dx11: oit depth pass needs the palette for PT polygons
Punch-through polys may use a palette, which is needed for alpha testing
Issue #467
2022-02-14 18:41:38 +01:00
Flyinghead 8f01ef90cf gl,dx9,dx11: only render frame when Renderer::present() has been called
Issue #511
2022-02-14 18:38:58 +01:00
flyinghead 8d071bf4ea naomi2: dx11 support. fix ambient color. no depth write in per-strip
dx11: naomi2 support
n2: ambient color was swapping red and blue
gl, dx11: don't write depth in per-strip to avoid missing geometry,
prefer wrong depth order/blending for now
optimize naomi2 per-triangle sorting
2022-02-13 21:01:45 +01:00
github-actions[bot] 3929fe64a3 Fetch translations & Recreate libretro_core_options_intl.h 2022-02-11 22:20:12 +00:00
Flyinghead a14086d484 naomi2: shader error in gles. Invert clubkart wheel axis 2022-02-11 19:06:58 +01:00
Flyinghead 20d25059bf naomi2: remove geom shader. Merge transparent polys. bump mapping fix.
elan: Get rid of geometry shader and do geometry clipping manually.
pvr: Aggressively merge transparent polys in per-triangl and OIT mode, duplicating the last vertex to merge opposite cull mode strips.
gl4: reset OIT pointers in final shader. No need for clear pass.
gl4: alternate between 2 buffers for verts.index/tr poly params.
gl4: use gl_VertexID + poly number for poly index.
gl: new GlBuffer class.
2022-02-11 15:54:18 +01:00
Flyinghead ccee7162bc naomi2: soulsurfer inputs, 2-volume UV, wrong TA parser selected
TAParserDX was used for pass-through TA data. Fixes health bar color in
vf4 and dust color in kingrt66.
2-volume missing u1/v1. Fixes clubk shadows.
2022-02-08 10:32:56 +01:00
Flyinghead 4fe8e40569 libretro: fix texupscale and max upscaled texture size settings value 2022-02-06 20:42:41 +01:00
Flyinghead b91b3d5da6 libretro: use correct #ifdef for omp support
enables xBRZ upscaling
2022-02-06 17:52:30 +01:00
Flyinghead debbae6ab1 naomi2: elan v10 emulation. texture dma xfers. 2-volume support
emulate elan v10 (fixes modvol in vf4, initd, beachspiker, wldrider)
wrong color order for model and vtx color
model param override xor support
improved light direction precision. Angle attenuation algo change
get rid of alpha light and modifier volume hacks
texture dma xfer from main and elan ram
gl4: use geometry only vtx and geom shaders for depth pass
2-volume support
2022-02-05 14:50:12 +01:00
Flyinghead 2c6f01ae38 naomi2: kingrt66 wiper button. initd gear up/down
kingrt66: map wiper button, remap shift H and R
initd: map gear up and down
wldrider: remap push and pull
2022-02-05 14:29:01 +01:00
github-actions[bot] 92f81fa054 Fetch translations & Recreate libretro_core_options_intl.h 2022-02-04 22:19:01 +00:00
Flyinghead 0362fd1079 naomi2: disable elan when net rollbacking, optimizations. ggpo: RTT fix
n2: do not process elan commands during ggpo rollbacks.
n2: Cache model colors to avoid unpacking for each vtx
pvr: merge equivalent polys with different culling by duping a vtx
pvr: fix crash during direct FB render
pvr: use correct color ordering for naomi2. Use identify matrix for null matrix pointers
ggpo: do not signal end of frame on a render to texture
2022-02-01 17:37:54 +01:00
Flyinghead 38765dc89a pvr: fix multipass. naomi2: constant color shading.
pvr: link multipass TA contexts. Each pass has its own.
pvr: get rid of context pool
naomi2: constant color shading. Use model diffuse and specular
selection. Don't use vtx color for offset color.
naomi2: pseudo-parallel lights fix
naomi2: pass-through TA data needs forced list type. Terminate with
end-of-list
enable RTT copy to vram for Beach Spikers
2022-01-31 20:40:09 +01:00
Flyinghead 78306b3c12 ggpo: memory leak in free_buffer 2022-01-30 12:39:00 +01:00
Flyinghead e51a291195 ggpo: wrong elan ram offset calculation 2022-01-30 12:39:00 +01:00
flyinghead d551848a9b dummy commit 2022-01-29 19:39:08 +01:00
Flyinghead fe6247dded cheats: iOS build fix 2022-01-29 18:40:19 +01:00
Flyinghead 5fb8b458bb pvr: use TA_OL_BASE instead of PARAM_BASE/TA_ISP_BASE to id TA context
Writes current TA_OL_BASE to all tiles OPB block. Read from region array
at render time to identify context.
Fixes vf4 water reflections RTT
get rid of dump_frame/read_frame
2022-01-29 18:39:38 +01:00
Flyinghead 4e21391f8c ggpo: memory leak in free_buffer 2022-01-29 16:58:28 +01:00
github-actions[bot] 9ab4bb963f Fetch translations & Recreate libretro_core_options_intl.h 2022-01-28 22:20:29 +00:00
Flyinghead 340c55c570 build fix 2022-01-28 22:30:07 +01:00
Flyinghead de1322b928 naomi2: Fix T&L matrix. vmem elan ram support.
Fix T&L matrix (wild riders)
Open GL support for normal/light matrix
handle elan RAM in vmem
2022-01-28 21:24:30 +01:00
Flyinghead 010d257b69 naomi2: vf4tuned cheat/hack to skip DIMM fw version check 2022-01-28 20:02:07 +01:00
Flyinghead 58f05f74cf jvs: set received jvs message trail to zero
fixes sh4 crash during naomi boot
2022-01-28 11:31:30 +01:00
Flyinghead e5d517dad2 use platform.isConsole(), platform.isNaomi(), ... 2022-01-27 17:52:19 +01:00
Flyinghead 965dea5fe6 test fix 2022-01-27 16:44:37 +01:00
Flyinghead 1ffcc75031 naomi2: implement SB_ISTNRM for clxb. serialize elan state 2022-01-27 16:40:12 +01:00
Flyinghead e084cc9a3a jvs: set received jvs message trail to zero
fixes sh4 crash during naomi boot
2022-01-27 15:50:44 +01:00
Flyinghead 6ed78d1202 another GL_CLIP_DISTANCE0 build fix 2022-01-26 22:37:38 +01:00
Flyinghead 270eaa1452 GL_CLIP_DISTANCE1 undefined 2022-01-26 22:19:53 +01:00
Flyinghead e1038ea632 naomi2: fix regressions. 2-volume and bump mapping support WIP
optimize open gl uniforms
2022-01-26 22:15:10 +01:00
Flyinghead 8947100701 libretro: missing new param to gl4GetProgram 2022-01-25 15:43:30 +01:00
Flyinghead cb99e7d920 naomi2: do T&L on the gpu. bypass TA format. env mapping.
fix model/instance/matrix parsing
handle culling reversed model flag
geometry shader for near plane clipping
2022-01-25 15:37:04 +01:00
DisasterMo a4b0a69c45 Enable Indonesian, Swedish and Ukrainian localisations 2022-01-22 19:18:41 +01:00
github-actions[bot] 2a364910c0 Fetch translations & Recreate libretro_core_options_intl.h 2022-01-21 22:20:49 +00:00
Flyinghead 45ba648622 dx11: VersionHelpers.h -> versionhelpers.h
the mingw version is all lowercase
2022-01-19 14:37:49 +01:00
Flyinghead dcd48f4264 ios: on-screen keyboard support 2022-01-19 13:48:16 +01:00
Flyinghead b048921c11 naomi2: fix clipping, parallel light direction, reset state on loadstate 2022-01-18 18:25:40 +01:00
Edward Li 8ee9f1b1d9 Cleanup macOS screen DPI calculation (included in SDL 2.0.20 now) 2022-01-18 11:58:57 +01:00
Edward Li f2c39e4004 Update SDL to 2.0.20 2022-01-18 11:58:57 +01:00
Flyinghead 4335aa563f naomi2 WIP 2022-01-16 22:41:42 +01:00
Flyinghead 62ec3546d6 dx11: uwp doesn't need texture conversions 2022-01-16 10:37:55 +01:00
Flyinghead 8bb0bd05f9 ui: limit scaling further on small low-resolution screens (retroid) 2022-01-16 09:58:33 +01:00
Flyinghead e538242962 dx11: convert 16-bit textures to 32 bits on windows7
1555, 4444 and 565 aren't supported on win7
Issue: https://github.com/libretro/flycast/issues/1123
2022-01-16 09:54:39 +01:00
github-actions[bot] d70d2ad405 Fetch translations & Recreate libretro_core_options_intl.h 2022-01-14 22:21:28 +00:00
Julien Reichardt 4f638f6d77 Use service button instead of coin
The service button can also be used to add coins.
2022-01-11 14:09:54 +01:00
Julien Reichardt 80d78705b0 Add default coin mapping 2022-01-10 12:13:14 +01:00
github-actions[bot] 140cec7c59 Fetch translations & Recreate libretro_core_options_intl.h 2022-01-07 22:20:58 +00:00
scribam 746b3c5a54 sdl: fix joystick rumble 2022-01-06 08:59:39 +01:00
Flyinghead a4788b5b24 zero-init sh4 context when no vmem is available
Issue #439
2022-01-03 18:44:47 +01:00
cmitu 8dcf0f58b5 postprocess: fix GLES2-only build
Added a missing `ifndef` guard for `glBindVertexArray`, useful for GLES2-only builds.
2022-01-02 10:51:03 +01:00
Julien Reichardt a8080c5db3 Fix missing libSDL2.a static library on Linux 2022-01-01 18:29:46 +01:00
github-actions[bot] a52977d1cf Fetch translations & Recreate libretro_core_options_intl.h 2021-12-31 22:20:45 +00:00
Edward Li 0bb6fed822 Remove junk folder when packaging macOS app 2021-12-26 23:20:58 +01:00
Flyinghead d86305a7c3 android: on-screen gamepad not editable in Open GL
Swap wasn't called during editing
Issue #464
2021-12-26 16:03:19 +01:00
Edward Li 5aeef17d09 macOS: Enable "New Instance" in File and Dock menu for SDL 2021-12-25 21:46:19 +01:00
Flyinghead 2d41d993e3 macOS: patch SDL to compile in metal and vulkan
https://github.com/libsdl-org/SDL/issues/5010
2021-12-25 21:45:13 +01:00
github-actions[bot] 503cc7ea97 Fetch translations & Recreate libretro_core_options_intl.h 2021-12-24 22:21:05 +00:00
Flyinghead 7f41847c5c android: bigger on-screen gamepad analog handle. Update project README 2021-12-24 19:46:09 +01:00
scribam fde683a82e ci: cmake install for switch builds 2021-12-23 22:31:39 +01:00
scribam 4feff7d917 ci: add ccache for switch builds 2021-12-23 22:31:39 +01:00
asdf288 e61951a319 Fix typo in GLES2 library name 2021-12-23 22:31:25 +01:00
Flyinghead da81274eb9 lr: gl stencil param isn't obsolete but required
Issue #454
2021-12-23 22:30:44 +01:00
flyinghead 8740141a93 Merge pull request #451 from flyinghead/net-rollback
Merge net-rollback branch
2021-12-23 11:21:29 +01:00
Flyinghead 9223a2b530 readme: link to gamr13's xbox page 2021-12-22 21:41:01 +01:00
Flyinghead 300c74e3fc Merge remote-tracking branch 'origin/master' into net-rollback
# Conflicts:
#	CMakeLists.txt
#	shell/libretro/libretro.cpp
#	shell/libretro/libretro_core_options.h
2021-12-22 21:31:17 +01:00
Flyinghead 3f82c7fb6f iOS: use play and record audio session only when necessary
Change audio session to play and record when a microphone is connected.
Use a play only session otherwise. Issue #360

Hide VSync-related gui option.
2021-12-21 21:36:12 +01:00
Flyinghead 2cb7a1d96c android CI: upload to S3 after dumping symbols 2021-12-21 21:26:31 +01:00
Flyinghead 00562455e0 android CI: choose the openssl flavor of curl 2021-12-20 16:11:54 +01:00
Flyinghead bb88dcfe66 android CI: install libcurl for breakpad. Disable breakpad on macOS 2021-12-20 16:08:22 +01:00
Flyinghead 970e594009 Build with breakpad submodule. Use gcc 11 on windows. 2021-12-20 15:45:46 +01:00
Flyinghead cd5a784277 add breakpad as submodule 2021-12-20 15:23:28 +01:00
Flyinghead 771f653174 delete breakpad 2021-12-20 15:20:26 +01:00
scribam 109cb81ab7 ci: add cmake install and refactor artifact generation 2021-12-20 14:36:48 +01:00
Flyinghead bf87f7ba84 Compilation error on armv7 with gcc 9 2021-12-20 14:27:19 +01:00
scribam 92b8eae2dc ci: cleanup cmake build type 2021-12-19 15:02:05 +01:00
scribam 776f86c7f2 README.md: add badge for Windows UWP CI 2021-12-19 13:29:41 +01:00
cmitu c10c3a1cfe cmake: amend 2b827e43, fix the typo for GLES3_LIBRARIES 2021-12-19 13:28:47 +01:00
scribam 94fccc5112 ci: fix ccache cache key 2021-12-19 11:18:32 +01:00
scribam 73fa0e3efc cmake/deps: update sdl to version 2.0.18 2021-12-19 11:18:24 +01:00
cmitu 2b827e43d7 cmake: add more GLES3 library names
Some systems provide the GLES3 implementation in the same GLESv2 library file, most notably Mesa.
Added the alternative library name when GLES3 is requested.

This makes the build work on the Pi4 - I've only tested it with the libretro core and the GLES 3.1 context is succesfully used.
2021-12-19 10:56:32 +01:00
cmitu e706368225 cmake: add support for legacy RPI GLES2 libs
Raspberry Pi 3 can use the legacy Broadcom GLES2 libraries from /opt/vc/lib.
They are the default GLESv2 libraries on Raspberry PI OS 10 (Buster) and older.
2021-12-19 10:56:32 +01:00
flyinghead 2f5271ab83 yabf4 2021-12-18 13:33:42 +01:00
flyinghead 4e448b23a8 yabf3 2021-12-18 13:25:41 +01:00
flyinghead 38002d4907 yabf2 2021-12-18 13:14:04 +01:00
flyinghead fd81f9b1b4 yabf 2021-12-18 13:11:17 +01:00
flyinghead 77900f5745 ci: env var not replaced 2021-12-18 12:25:02 +01:00
flyinghead 8684aac4f2 yaml parse error 2021-12-18 12:19:09 +01:00
flyinghead b1e0bc90ba uwp: remove angle, upload to S3. windows: don't build SDL 2021-12-18 11:50:03 +01:00
scribam 8e305bfd0f android/vmem: use constant ASHMEM_NAME_DEF 2021-12-18 11:46:04 +01:00
scribam 32716e1480 android: update com.android.tools.build:gradle to version 7.0.4 2021-12-18 11:46:04 +01:00
jdgleaver 833eccb6c4 (libretro) Sanitise core options 2021-12-18 10:16:37 +01:00
github-actions[bot] f64b3618f2 Fetch translations & Recreate libretro_core_options_intl.h 2021-12-17 22:20:56 +00:00
Flyinghead 325cd9a066 DSP crash on apple M1
Issue #415
2021-12-17 13:43:45 +01:00
Flyinghead 544c711fd7 savestate: compatibility between nvmem and !nvmem savestates 2021-12-17 13:41:46 +01:00
Flyinghead e02afb34d1 dx11: wrong shadow scale factor. vk: object leak. Code duplication
dx11: shadow scale factor inverted in per-pixel
vulkan: clear deleted overlay images when terminating
Use color struct for FOG_COL_VERT, FOG_COL_RAM, FOG_CLAMP_MIN,
FOG_CLAMP_MAX and VO_BORDER_COL. Avoid code duplication in renderers.
2021-12-17 13:40:42 +01:00
Flyinghead dc5acd24b2 Merge remote-tracking branch 'origin/master' into net-rollback 2021-12-17 12:40:37 +01:00
Flyinghead 7555263e38 wrungpo had wrong decryption key
Issue https://github.com/libretro/flycast/issues/1108
2021-12-17 11:55:17 +01:00
Flyinghead 71d016722e vulkan: fix various validation errors
oit: skip to new frame even if previous frame was never presented
libretro: quad pipeline used for overlay must use subpass 2 in per-pixel
overlay: delay destruction of VMUs images
libretro: WaitIdle on queue instead of wait_sync_index
2021-12-16 21:26:55 +01:00
jdgleaver 96560e4914 (libretro) Move audio batch callback onto main thread + improve audio sample pacing 2021-12-16 18:21:08 +01:00
Flyinghead 04be40767b android: fallback to /dev/ashmem if ASharedMemory fails. More logs
Issue #439
2021-12-15 23:09:59 +01:00
Flyinghead 5a6197cfc6 libretro: never request a GLES3 context
RA doesn't give us the opportunity to retry if GLES3 isn't supported.
Issue #405
2021-12-15 21:23:35 +01:00
flyinghead 5fca12af49 msvc compilation warnings 2021-12-15 17:58:58 +01:00
flyinghead 853830a446 log errno when failing to open a disk or folder. Better win32 errors
Log errno when failing to open a disk or folder (game scanner)
Better win32 error codes with GetLastError() for opendir, stat, access
2021-12-15 17:55:42 +01:00
flyinghead 2f47f72957 dx11: recreate texture if dimensions or format change. Clear rtt depth
Fixes a crash when switching Copy to VRam on as the RTT texture is no
longer upscaled when updated.
Clear RTT depth/stencil before render.
2021-12-15 11:32:04 +01:00
flyinghead de35cf9840 dx11: fix fullscreen toggling
Prevent DXGI from monitoring Alt+Enter and let SDL handle it
2021-12-15 10:37:52 +01:00
flyinghead 18d8107992 dx11: no color interpolation for flat shading
Fixes Evolution WoSD
refactor setFirstProvokingVertex (dx9, dx11, vk)
Set .1 depth scale for V-Rallye to fix missing background image in menus
(dx11, dx9)
2021-12-15 09:37:58 +01:00
flyinghead 2478b72a3e lr dx11: fix exit crash. Save shader cache where vk cache is 2021-12-14 16:48:23 +01:00
flyinghead 4d60150345 libretro: dx11 crash in single-threaded. Use compiler and feature level
libretro: Null first frame erroneously set as valid causing a crash with dx11 (single-threaded rendering)
libretro: pass dx11 compiler pointer to shaders
dx11: use feature level to check if per-pixel is supported
2021-12-14 10:41:04 +01:00
flyinghead 6a3a8d5578 libretro: dx11 support. dx11 shader cache. dx9 clipping planes
dx11: use 32-bit float depth texture to avoid loss of precision (SA2 into logo)
dx11: cache shader blobs to disk if not provided by OS
dx11: swap interval depends on screen refresh rate (1 for 60 Hz, 2 for 120 Hz, ...)
dx9: use clipping planes to avoid interpolation errors in rasterizer (daytona, mermaid lake)
directsound: use comptr
gui: fix navigation issue with OptionArrowButtons due to missing id
2021-12-13 21:02:44 +01:00
scribam 08828991e7 dx11: msvc x86 build fix 2021-12-12 18:43:36 +01:00
flyinghead 4c14a96888 vk, gl4: out of bound array index when sorting pixels 2021-12-12 18:42:50 +01:00
flyinghead 0478ec9696 dx11: per-pixel renderer 2021-12-11 18:53:35 +01:00
flyinghead 46044c068b cheats: don't rely on cheat count on load. Fix compile warnings 2021-12-11 18:33:28 +01:00
github-actions[bot] c6fe6b83ac Fetch translations & Recreate libretro_core_options_intl.h 2021-12-10 22:20:46 +00:00
flyinghead cc39d4dd7d vmem: close shared mem file descriptor when terminating
Tentative fix for Issue #439
2021-12-10 14:04:45 +01:00
flyinghead b79c049bd4 dx11: wrong shader hash calculation 2021-12-09 09:26:36 +01:00
flyinghead 4cbf19c97e libretro: nvmem not saved when rom path mixes slash and backslash
Issue https://github.com/libretro/flycast/issues/1114
2021-12-07 17:15:35 +01:00
flyinghead 27041cbf59 dx11: better clipping algo. modvol cull mode. win: exception code
dx11: use faster clipping algorithm for modifier volumes
dx11: modifier volumes need cull mode. Fixes Daytona shadows.
win: the fault handler was treating some software exceptions as fatal (msvc)
uwp: remove async hacks and disable MS task wait exception. Fixes error reporting when loading a game.
2021-12-06 17:43:22 +01:00
IlDucci 8e2c72ed1b [Core options text] Typo fixes and minor style changes
- Changes the main category sublabels to match RetroArch's style.
 - Adds a missing period, as reported in Crowdin.
 - Adds an extra minor description to the Language setting.
2021-12-05 12:23:35 +01:00
flyinghead 7820c9bc44 dx9/11: fix rtt2vram crash. dx11: modvol fix and more
dx11: clip modvol triangles before sending them to the gpu
dx9,11: wrong source pointer for rtt to vram
dx11: handle source RowPitch when copy rtt to vram
dx11: crash at reinit
dx11: wrong scissor with direct fb rendering
dx11: blend ops are different for the alpha channel

Fix mingw CI build
2021-12-04 19:16:11 +01:00
github-actions[bot] 92fff9acf5 Fetch translations & Recreate libretro_core_options_intl.h 2021-12-03 22:21:13 +00:00
flyinghead 91da49dc52 mingw: downgrade cmake 2021-12-03 23:08:59 +01:00
flyinghead b5a45417d9 mingw: downgrade gcc to 10.3 2021-12-03 22:29:41 +01:00
Edward Li 3db4993077 Xcode project file (debug friendly) generator with predefined LLDB Init File to bypass SIGBUS error 2021-12-03 15:49:47 +01:00
Edward Li bc1a5fdd8d Make LLDB ignore EXC_BAD_ACCESS for debugging 2021-12-03 15:49:47 +01:00
flyinghead 191f1c38df dx11: scissoring fix. 4K UI scaling
Clearing of side columns in 4:3 uses the quad drawer so it needs to be
called early. Border color was wrong. Fixes GTA2.
Scale UI x2 in 4K mode.
2021-12-03 15:48:42 +01:00
flyinghead adb61259c1 mingw ci: enable dump_syms ouput 2021-12-02 17:20:56 +01:00
DisasterMo ddc2e84e45 Add automatic Crowdin synchronization 2021-12-01 21:28:51 +01:00
flyinghead a050a61f2e ci: install dx9 sdk for mingw 2021-12-01 21:28:21 +01:00
flyinghead 99195c3f4c dx11: set clip planes on X and Y. rend: Force palette update at init
dx11: Set clip planes at X -1/1 and Y -1/1 to avoid rasterizer errors.
Fixes Daytona Mermaid lake depth issues
dx11: fix texture wrap around at UV 1 with nearest filtering
dx9: inside clipping
all renderers: force full palette update at init
2021-12-01 14:54:03 +01:00
flyinghead 280c159078 uwp: fix dirent. Implement access() and stat()
Use UWP version of FindFirstFileEx
Implement basic access() and stat()
Add home dir to list of drives
Allow external storage folders to be added and scanned for games
2021-12-01 14:40:17 +01:00
flyinghead 6a8f1b941e dx11: overlay support. inside clipping. 4K support on xbox. log fix
dx11: support for vmu and lightgun crosshair overlays
dx11: implement inside clipping (fixes 18 wheeler rear view mirror)
dx11: tentative 4K support on xbox
iOS,uwp: save log file in home (iOS)/data(uwp) directory
uwp: don't sign app on pull requests
2021-11-29 18:22:25 +01:00
scribam 8a6ce19e1e input: cleanup virtual function specifier 2021-11-29 18:19:22 +01:00
flyinghead d071adea9a dx11: fix modifier volumes, rotation. sdl: on-screen keyboard support
dx11: Back face stencil ops need to be set
dx11: Rotate CCW instead of CW
dx11: Present with NO_WAIT when fast forwarding
sdl: support for on-screen keyboard. Delay keys up by one frame to allow quick key presses.
ui: better fix to wait for future on UWP
2021-11-28 16:19:03 +01:00
flyinghead 3d7455316f linux build fix 2021-11-27 14:39:28 +01:00
scribam 3f50baa318 picotcp: fix alloca on freebsd 2021-11-27 14:32:04 +01:00
scribam 8164c96379 deps: update libchdr and remove patch 2021-11-27 14:31:22 +01:00
flyinghead 4ab3f01867 uwp: external storage support. enable picotcp 2021-11-27 14:30:36 +01:00
flyinghead dbb277f749 Potential crash when starting game with non-default renderer
Renderer is switched to default and back to the selected one during
reset on the emu thread. The render thread may pick up this change.
2021-11-27 14:13:24 +01:00
flyinghead 0579f2ede6 7z: use fopen on all platforms 2021-11-27 14:08:07 +01:00
orbea ef3af9aad3 cmake: Add an install target (#421)
Don't install glslang or xbyak
2021-11-27 10:42:09 +01:00
flyinghead d5694036fa libretro: don't crash if frontend doesn't implement
RETRO_ENVIRONMENT_GET_CLEAR_ALL_THREAD_WAITS_CB

Issue #418
2021-11-27 10:41:11 +01:00
flyinghead f91847dad0 DX11 renderer WIP 2021-11-26 18:08:41 +01:00
flyinghead c4eaa973f0 picotcp: use strcasecmp 2021-11-24 14:17:00 +01:00
flyinghead 42fa77c81f uwp: the back button (B) shouldn't close the app 2021-11-24 13:42:25 +01:00
flyinghead e4bfeb9e44 picotcp: MSVC support 2021-11-24 13:41:04 +01:00
cglmrfreeman 67f2162fb3 Fix linux breakpad issues when glibc-2.34 is installed
As outlined by [Samuli Piippo in the qtwebengine chromium patch](https://codereview.qt-project.org/c/yocto/meta-qt6/+/378728/2/recipes-qt/qt6/qtwebengine/chromium/0004-breakpad-fix-build-with-glibc-2.34.patch), SIGSTCKZ is no longer being compile time constant in glibc-2.34. The proposed fix compiles on my end and I have not tested on a linux distro with an earlier version of glibc.
2021-11-23 20:23:28 +01:00
flyinghead 465499f6c3 libretro: don't set preferred GLES version when initializing context
Issue #405
2021-11-22 15:28:18 +01:00
flyinghead ea75311a34 uwp: yml typo 2021-11-21 15:34:01 +01:00
flyinghead 33fd8a9ec7 uwp: sign appx package 2021-11-21 15:18:55 +01:00
BornPosthumous 417ffc09f8 Allows override of flycast.lua file (#411) 2021-11-21 15:16:11 +01:00
flyinghead 1057f50f86 uwp CI fix 2021-11-20 19:13:55 +01:00
flyinghead 5b933cde61 uwp: use ccache for CI. gui_util.h typo 2021-11-20 18:24:21 +01:00
flyinghead 47442d1bc9 fix libchdr patch 2021-11-20 17:32:12 +01:00
flyinghead f25c83e006 uwp CI fix 2021-11-20 16:21:27 +01:00
flyinghead bc34024e32 uwp: fix crash when opening menu/canceling load. CI job 2021-11-20 16:18:27 +01:00
flyinghead 628bef9094 libretro: don't set minimum GLES version when initializing context
Issue #405
2021-11-20 14:14:19 +01:00
flyinghead 63598019e1 naomi: rename deathcox to deathcoxj, new deathcox parent rom
MAMESET 0.227 changes
Issue #409
2021-11-20 14:06:19 +01:00
flyinghead 501244ed25 x64 rec: incorrect stack alignment of memory handlers on windows 2021-11-20 12:29:07 +01:00
flyinghead e12912450c missing changes 2021-11-19 23:29:35 +01:00
flyinghead 8262c9ece7 UWP support - WIP 2021-11-19 23:18:45 +01:00
Flyinghead cc208ce451 libretro: arm32 android build must use arm mode, not thumb
Issue #405
2021-11-16 16:46:28 +01:00
scribam c6374a899c win32: build fix when sdl2 is not enabled 2021-11-14 22:56:43 +01:00
Flyinghead 8f80bcb159 New serialize framework. Delay maple dma xfer
New serialize framework. Refactor serialization into modules.
Maple dma xfer must not be executed immediately. Delay until interrupt
is raised.
Fixes Geist Force freeze at start.
2021-11-13 15:56:42 +01:00
Flyinghead e56ecfec40 vk,dx9: black screen/crash in single-threaded on direct fb access
When rendering happens after the render timeout (initial sega copyright
screen and more), the frame is never swapped and never displayed. Causes
a crash in vk since the acquired swapchain image is never
presented/released.
2021-11-11 11:17:39 +01:00
Flyinghead 80cf422a5e dynarec: fix CLRS and SETS ops
Destination reg was missing
Fix crash in OpenTyrian/SDL_DREAMHAL
Issue #403
2021-11-11 10:44:22 +01:00
Flyinghead d788c310ee apple build fix 2021-11-10 21:21:25 +01:00
Flyinghead 7583db3bef vk: option to duplicate frames to simulate swap interval > 1
Issue #293
2021-11-10 20:55:22 +01:00
Flyinghead ac5abd96bb ui: imgui driver, GraphicsContext interface, dx9 swap interval
Refactor imgui backend code into imgui drivers for gl, vk, dx9
Generic GraphicsContext interface for gl/vk/dx9 contexts
Simplify graphics api switching code
dx9, gl(sdl): set swap interval based on monitor refresh rate.
2021-11-10 20:35:30 +01:00
Flyinghead aa944ac5e8 vk: fix vmu transparency in lr core 2021-11-10 18:42:11 +01:00
Flyinghead 35e1fb9ae5 cmake: change default libretro target 2021-11-10 10:17:40 +01:00
twinaphex a15863ae35 (Libretro) CI integration - and necessary fix for compiling Windows
core cross-compiled on Linux
2021-11-09 18:48:55 +01:00
Flyinghead a04fd06e38 gl: iOS doesn't like smooth. More precision needed for vertex colors 2021-11-09 10:38:41 +01:00
scribam f6cc2c7b91 ci: use msys2 only for mingw builds 2021-11-09 10:37:43 +01:00
Flyinghead 99ee526ac5 gles3 doesn't support noperspective. vk needs higher prec for color/uv/z
noperspective not supported in gles 3. Use smooth instead
Vulkan now needs higher precision for colors, UV and z (adreno 630)
2021-11-08 16:53:47 +01:00
scribam d100067e02 cmake: use AltKit default include directory for AltKit-Swift.h 2021-11-08 11:58:42 +01:00
scribam f777c62a66 android: update com.android.tools.build:gradle to version 7.0.3 2021-11-08 11:58:42 +01:00
Flyinghead 06ef0e5fdc vk,gl: use w=1 in shaders. Fix translucent modvols
Use w=1 to avoid multiply/divide of xy as in dx9
Disable rendering when video output disabled
Use original w value in pixel struct to avoid precision loss (samsptk)
vk oit: missing memory barrier was producing Tr modvol glitches (JSR)
gl oit: Tr modvol needs full vertex shader
2021-11-07 18:21:44 +01:00
Flyinghead 5209623064 cue: ignore unrecognized REM entries. parse one line at a time 2021-11-05 19:14:08 +01:00
Flyinghead 7c53413bc5 vk oit: fix depth-only Tr pass
Cosmic smash
2021-11-05 18:36:09 +01:00
Flyinghead 42f92b8dc1 ggpo lib: compile warnings, remove legacy chat 2021-11-05 18:34:23 +01:00
Flyinghead 986baccf83 lr build fix 2021-11-04 13:11:18 +01:00
Flyinghead 32d31e7644 vk: implement TranslucentPolygonDepthMask
Fixes Cosmic Smash
vma: instance is needed at init
Partial vk support for iOS
2021-11-04 09:13:47 +01:00
Flyinghead 03161446b9 can't launch BIOS after playing a game 2021-11-04 08:57:15 +01:00
Flyinghead 17bbb7f145 vk: disable small tex optimization on macOS. Fix libMoltenVK embedding
small textures linear optimization leads to texture corruption with
moltenvk.
Copy libMoltenVk to correct runtime output dir.
2021-11-02 09:44:24 +01:00
Flyinghead 71c4ec34d5 iOS build fix 2021-11-01 13:30:36 +01:00
Flyinghead da3ed74c4e vulkan: moltenvk support on macOS - WIP
sdl: save/restore window position in config
2021-11-01 13:05:22 +01:00
Flyinghead 46ae8f92cc input: per game input mapping 2021-11-01 12:39:50 +01:00
Flyinghead 9b3dec5f70 imgui: fix crash when closing chat with gamepad DPad button down
backport https://github.com/ocornut/imgui/commit/25679a411ee33272d4d047192b30af03e3a384fc
2021-10-27 12:28:31 +02:00
Flyinghead 146bfb28d1 ggpo: always use P1 input in netplay even if playing as P2
fix imgui assert
2021-10-27 12:26:17 +02:00
Flyinghead 46fb331275 look for BIOS files in Content Path folders if not found in data folder 2021-10-27 12:24:30 +02:00
Flyinghead ff39b8b252 macOS: use ~/Library/Application Support/Flycast as home directory
still use ~/.flycast or ~/.reicast if found for backward-compatibility
Issue #336
2021-10-27 12:22:24 +02:00
LaercioMBR 004250ed23 InputDescriptors for radirgyn and mamonoro 2021-10-24 14:07:40 +02:00
Flyinghead 037339f3be ggpo: savestate md5 wasn't computed 2021-10-21 12:03:04 +02:00
Flyinghead e0437ab447 msvc fix 2021-10-20 15:28:34 +02:00
Flyinghead 808a161d39 ggpo: make chat thread-safe. Deadlock on early rollback
Make ggpo_send_message() thread-safe
Deadlock UI/emu threads if rollback happens before first render
Disable rollback wait in single-thread mode
2021-10-20 14:41:18 +02:00
LaercioMBR 6d8e1794a0 Fix Metal Slug 6 inputs (#393) 2021-10-20 14:36:02 +02:00
Flyinghead 89338c0b4b win32 build fix 2021-10-19 17:24:17 +02:00
Flyinghead 7f7cbd5666 missing change 2021-10-19 17:05:00 +02:00
LaercioMBR 846ed76808 InputDescriptors for Dolphin Blue, Demolish Fist and ggx15 2021-10-19 17:02:01 +02:00
Flyinghead ab45b5ec8a ggpo: keyboard/mouse games support. Fix chat when keyboard disabled
ggpo: support for arcade games using keyboard (totd, luptype) and
mouse/rotary encoders (waiwai drive)
Chat and UI now usable when the keyboard is not set to a maple port.
2021-10-19 16:56:46 +02:00
Flyinghead db93a4c4a7 ggpo: in-game chat
use menu key to open/close chat window
disable keyboard/mouse controllers when using chat
disabled controllers can now use emu keys (menu, escape, ff)
2021-10-18 16:40:17 +02:00
Flyinghead 59566eb363 ggpo: support application messages 2021-10-18 16:26:24 +02:00
LaercioMBR 7fb85e5b25 Standardizing InputDescriptors names, added kov7sprt_inputs (#389) 2021-10-18 11:24:38 +02:00
Flyinghead c061912574 android: fix hang when mount returns too much data
Issue #387
2021-10-16 18:16:17 +02:00
Flyinghead 3eeb7e7cae build fix 2021-10-16 18:15:11 +02:00
Flyinghead cf653640b3 ggpo: verify md5 of bios, game and savestate
Verify md5 of flash, eeprom, vmus if no savestate used
Use chd header SHA1 as digest
Load .state.net state file at start

Force real BIOS for some games
2021-10-16 17:56:21 +02:00
Flyinghead 5cfd897298 android: more activity init logs 2021-10-15 13:14:42 +02:00
Flyinghead 7ecb6a6d96 ggpo: Fix udp packet size. Fix verif mismatch due to uninit'ed var 2021-10-15 13:07:21 +02:00
Flyinghead c08f177d3b libretro build fix 2021-10-14 11:51:39 +02:00
Flyinghead 1c6e722961 android: add app external & internal files dir. Race condition at start
Fix crash at startup due to race condition with game scanner
Don't allow selection of non-writable folder during onboarding
Add private internal and external Files folders to list of storage
locations to choose from
Assign first external android gamepad to port A instead of B

ui: Fix layout of controller mapping dialog when port=All
2021-10-14 11:39:27 +02:00
Flyinghead 0d49817f00 fix crash when [config]pvr.rend is invalid for the current platform 2021-10-14 10:52:35 +02:00
Flyinghead 85c21df5e7 Use allocAligned/freeAligned for all aligned allocs 2021-10-14 10:46:44 +02:00
Flyinghead f9d5b8eb74 ui: limit max scaling on small low-res screens (<= 640x480) 2021-10-12 17:34:42 +02:00
Flyinghead bcc3337c58 cheats: support for bit-level RA codes
log start of address space, RAM, VRAM, audio RAM at boot
fix add cheat dialog layout
don't crash on wrong gdrom unlock code
2021-10-12 17:28:01 +02:00
Flyinghead 163888f329 GameShark cheat codes support 2021-10-10 17:24:17 +02:00
Flyinghead 8b986dfab3 vmu beep support 2021-10-10 16:33:37 +02:00
Flyinghead 19bd6d0bca test automation clean up
less #ifdef
force mute audio
don't force vsync
2021-10-10 16:26:36 +02:00
Flyinghead c2caef4ad5 ui: use SDL clipboard functions for imgui
allow cut & paste on linux
2021-10-07 19:14:29 +02:00
Flyinghead 1d9ac4918c pvr: fix SPG_VBLANK_INT reset value 2021-10-07 16:24:00 +02:00
Flyinghead bc3be1029c fix sh4 scheduler. use common cycle counter in sh4 context
scheduler reset and unregister
schedule requests during reset(), not init()
preserve cntx.sh4_sched_next on sh4 reset
Use cntx.cycle_counter in dynarecs and interpreter
Fixes Confidential Mission hang at boot with HLE
2021-10-07 16:18:32 +02:00
Flyinghead bc238de5ce switch: open 4 controllers. android: java7 compatibility 2021-10-06 18:55:04 +02:00
Flyinghead 1072235b1a lua: ui bindings 2021-10-04 19:42:45 +02:00
Flyinghead 3c2c7b379d ggpo: pair with first received sync request if remote IP not specified 2021-10-04 19:38:33 +02:00
Flyinghead 4af194035c win: fix binary s3 upload 2021-10-04 19:21:18 +02:00
Flyinghead 3171cfd381 win: fix binary s3 upload 2021-10-03 21:46:37 +02:00
Flyinghead 8183bf7f95 linux build fix 2021-10-03 20:42:25 +02:00
flyinghead 82bec1e324 lua: build fix for linux and win. dx9: crash on exit 2021-10-03 20:22:52 +02:00
Flyinghead 897cc01f93 some lua bindings 2021-10-03 18:34:27 +02:00
Flyinghead 5bcfa35737 Better background game loader
Pass LoadProgress object to report load progress and cancel
Better UI
Cancel with exception
Fix issues when stopping/exiting in !threaded
dx9: call gui_term on shutdown
2021-10-02 11:30:40 +02:00
Flyinghead c1bcf91dd6 pvr: render timeout when using ggpo or !threaded
will cause ggpo desyncs with previous versions
2021-10-01 16:48:01 +02:00
Flyinghead 621e4d196e crash when enabling bba per-game 2021-10-01 16:14:27 +02:00
Flyinghead 45ebc2239f ggpo: exchange verification data during sync 2021-10-01 16:07:32 +02:00
Flyinghead a6248905a0 ggpo: report UDP bind error. Better error reporting for net init
fix ggpo lib warnings
2021-09-30 17:24:51 +02:00
Flyinghead 699dcdaf5b Merge remote-tracking branch 'origin/master' into net-rollback
# Conflicts:
#	core/hw/maple/maple_if.cpp
#	core/rend/mainui.cpp
#	shell/libretro/libretro.cpp
2021-09-30 15:03:29 +02:00
Flyinghead 23d1f6b507 imgui: bug when drag scrolling in a combo's popup 2021-09-30 14:36:29 +02:00
Flyinghead f72f4c49fb macos: fix freeze in !threaded. input: fix crash when saving mapping
audiostream: delete legacy [audio]disable option
2021-09-30 14:31:51 +02:00
Flyinghead 2803ee8274 imgread.ImagePath clean up. ggpo: poll input late if !thread 2021-09-30 14:24:17 +02:00
Flyinghead 0d2e6f5e98 remove safe mode/div matching option
mismatched delete/free() in TexCache.cpp
2021-09-29 11:57:51 +02:00
Flyinghead 99bf7f77c4 single-threaded mode. refactoring.
single-threaded mode similar to libretro core
stateful Emulator object
disable memory watcher when !gppo
ggpo: poll input as late as possible in !threaded
2021-09-29 10:22:58 +02:00
Flyinghead 7fe2ab720f refactor screen_width/height 2021-09-27 20:29:23 +02:00
Flyinghead 18cecc8d38 gl,vk: use VO_BORDER_COL for clear color 2021-09-27 13:39:08 +02:00
scribam 5d068fc2d4 Update .gitignore 2021-09-27 11:52:18 +02:00
scribam 84d98763f1 README.md: add Nintendo Switch CI badge 2021-09-27 11:52:18 +02:00
scribam 86356c737c Update man page 2021-09-27 11:52:18 +02:00
scribam 1fa233aae7 Remove makefiles and xcode project files 2021-09-27 11:52:18 +02:00
Flyinghead 1dc01314a1 input: don't poll input on emu thread
fixes device reset errors with dx9 on Alt+Enter and other renderer
crashes
2021-09-27 11:51:39 +02:00
Flyinghead fb40bb22df vk: CommandPool size must be 2. Fix lightgun xhair validation error 2021-09-27 11:19:50 +02:00
Flyinghead 1dc22ec76c sdl: null init sdl_controller 2021-09-26 22:02:21 +02:00
Flyinghead 41ac140076 ggpo: lightgun support for arcade games
ui: display button names in arcade mode only
2021-09-26 21:28:31 +02:00
scribam 4e019cc233 Update issue templates 2021-09-25 16:04:23 +02:00
scribam 36007ceb68 android: update com.android.tools.build:gradle to version 7.0.2 2021-09-25 16:04:15 +02:00
scribam 25fdeac697 cmake: iOS minor fixes 2021-09-25 16:04:05 +02:00
Cameron Bates 07d27edb76 Add more keys, gui hotkey 2021-09-22 20:16:11 +02:00
Flyinghead 39fabf39ae naomi: free play eeprom for many games
inputs for ggx, doa2, toyfight, ausfache
don't label common buttons (coin, test, service, start)
2021-09-22 14:26:13 +02:00
Flyinghead 945a483e9b ggpo: less log 2021-09-22 14:20:55 +02:00
Flyinghead 1725dbfa98 input: fix arcade mode for on-screen gamepads.
Use same layout as gamepad arcade for on-screen gamepads (ABXYRL)
map RT and LT to buttons 5 and 6 in arcade
android: Fix non-working fast-forward button
Use maple port in lastAxisValue state
naomi: use default alienfnt buttons: 1-4
2021-09-21 15:56:01 +02:00
Cameron Bates 67790abf0e [iOS] Update AltKit (#366) 2021-09-21 10:12:19 +02:00
scribam 3ec08f6ae1 ci: simplify C/C++ CI workflow 2021-09-21 10:11:56 +02:00
Flyinghead c419654a11 input: don't register multiple button presses when holding axis
keyboard: map left stick and coin button by default
2021-09-20 14:07:42 +02:00
flyinghead 51ad6094e8 input: fix axis bound to emu buttons 2021-09-20 10:05:13 +02:00
flyinghead 5b7d189058 sdl: fix hat button names 2021-09-19 22:35:23 +02:00
Flyinghead 7d57d55414 iOS build fix 2021-09-19 18:55:09 +02:00
Flyinghead 65956dbc8d input: merge buttons and axes
Default mappings for arcade and console
Default mappings for arcade stick/hitbox
Proper handling of inverted axes
ggpo: automatic analog setting for arcade games
2021-09-19 18:27:21 +02:00
Flyinghead d75072362a vk oit: work around adreno 600 driver regression
Android 11 adreno 600 driver v502: PixelBuffer.pixels.length() is
returning 0 in some cases.

Issue #361
2021-09-18 18:08:52 +02:00
Joshua L 22947af854 Sdl gamecontrollerdb.txt fix (#356)
sdl: load gamecontrollerdb.txt before calling SDL_InitSubSystem
2021-09-18 18:07:07 +02:00
Flyinghead 50a67dbd3e build fix 2021-09-16 20:27:57 +02:00
Flyinghead 7fd954e10d rend: apply vscalefactor to scissor in 240p/480p
fixes SF3 3rd strike half-screen in 240p mode
2021-09-16 19:27:59 +02:00
Flyinghead 4c53fcecfa ggpo: detect input size mismatch and abort gracefully 2021-09-16 19:24:49 +02:00
bslenul 17348dae8a [Libretro] Middle mouse fix 2021-09-15 17:26:01 +02:00
Flyinghead 05d495b282 dx9: Fix RenderLastFrame
Fixes black blackground when opening the menu during a game
2021-09-15 17:24:55 +02:00
Flyinghead 3b7a940e9b android: use list of axes for default mapping and axis handling
Issue #338
2021-09-15 14:44:56 +02:00
Cameron Bates 501c6f260a Remove mouse invert option and invert gcmouse by default 2021-09-14 23:43:16 +02:00
Cameron Bates e1fa2b9831 [iOS] GCMouse support (#353) 2021-09-14 11:51:44 +02:00
Edward Li 043175ae4d Rumble using MacBook's Taptic Engine 2021-09-14 11:44:37 +02:00
Flyinghead 8b266b1327 ggpo: force aica.nobatch 2021-09-13 13:01:52 +02:00
flyinghead f7abe3bb34 Merge pull request #351 from flyinghead/libretro
Merge Libretro branch
2021-09-13 10:03:53 +02:00
Flyinghead 480e85f615 ggpo: UI for analog axes settings. Display stats option 2021-09-12 17:42:58 +02:00
Cameron Bates 0182d1ca09 Add dummy value for ALTDeviceID 2021-09-12 15:59:25 +02:00
Flyinghead 99a0dce8cd arm build fix 2021-09-11 19:17:36 +02:00
Flyinghead badcace987 ggpo: analog axes support. Fix right trigger. use miniupnp.
Analog stick X/Y support
Right trigger was ignored
Forward UDP port 19713 with miniupnp before starting ggpo session
Use recursive_mutex for ggpo
2021-09-11 18:50:11 +02:00
Flyinghead e8b73e22b7 Merge remote-tracking branch 'origin/libretro' into net-rollback 2021-09-11 18:11:36 +02:00
Cameron Bates 45f68d59ff iOS Keyboard Support (#347)
PR adds in support for iOS keyboards using GCKeyboard
2021-09-11 13:08:35 +02:00
Flyinghead 1762987aae reios: reset gdrom state at reset
Fixes "Reboot to BIOS" exception when loading another game
2021-09-11 11:22:58 +02:00
Flyinghead ad2e142b01 ui: Show mouse cursor when emu throws an exception. lr: fix vulkan init 2021-09-10 15:32:13 +02:00
Flyinghead 88fa5d5c41 arm64 dsp: don't JitWriteProtect twice. ios: Hide VSync. pvr: fix mutex 2021-09-10 15:26:18 +02:00
Flyinghead e45ec4324f Merge remote-tracking branch 'origin/master' into libretro 2021-09-10 12:19:29 +02:00
Flyinghead d9a8e29a94 missing change 2021-09-09 18:31:08 +02:00
Flyinghead 3ced57a263 network: use interface for startup. avoid deadlock on exit
Use common interface for naomi and ggpo
Simpler ggpo interface
Fix deadlocks on exit with ggpo
2021-09-09 18:17:05 +02:00
Flyinghead 458868a634 ggpo: always save delta ram. Disable ff,cheats,savestates when online
ggpo: always save delta ram on save_game_state as frames may be rerun
and resaved
Global network online status (ggpo, naomi, modem, bba)
Disable fast forward, cheats and savestates when online.
2021-09-08 17:18:01 +02:00
Flyinghead 7ecc0543f4 ggpo: fix common assert() sync.cpp:238 2021-09-08 16:21:54 +02:00
Flyinghead 6d6f3d38d4 libretro build fix 2021-09-07 17:18:56 +02:00
Flyinghead a4e715fa71 serialize modem, aw coin, pvr direct fb state, TA cur context 2021-09-07 16:43:50 +02:00
Flyinghead 8594d11693 maple: refactor usage of rt/lt. zero out joystick values if ggpo active
Fix mouse cursor being invisible when emu throws an exception
2021-09-07 16:30:56 +02:00
Flyinghead a4c14ebef7 Merge remote-tracking branch 'origin/libretro' into net-rollback 2021-09-07 15:02:39 +02:00
Flyinghead 599874c9c1 dx9: VSync option support 2021-09-07 14:16:05 +02:00
Flyinghead 5121b0df93 maple: mutually exclusive btns per controller. better D2A axes
Handle mutually exclusive buttons (U/D, L/R) in each controller.
Track digital X/Y axes state to allow for proper handling of U+D and
L+R. Issue #334
SDL: Ignore key repeat events
2021-09-07 10:54:00 +02:00
Flyinghead e3a2f1cfbe ggpo: transmit RT and LT as digital inputs 2021-09-06 17:16:41 +02:00
Flyinghead 414fb9dba2 ramwatch: protect all ram, not just the bottom half 2021-09-06 16:14:38 +02:00
Flyinghead a402c69c55 ggpo: detect frame rate and use it to pause when ahead 2021-09-05 20:47:37 +02:00
Flyinghead c007165a0f input: naomi btns 5/6 and 7/8 shouldn't be mutually exclusive 2021-09-05 20:12:40 +02:00
Flyinghead a3d50fc197 Merge remote-tracking branch 'origin/libretro' into net-rollback 2021-09-05 20:07:37 +02:00
flyinghead baa0ac44ca paypalme link 2021-09-05 17:30:26 +02:00
Flyinghead 6768901446 allow semicolon in content paths 2021-09-05 10:30:19 +02:00
Flyinghead 35e77976a6 ui: use input from all keyboards
Issue #339
2021-09-05 10:29:12 +02:00
Enrique Santos dba805e8c4 ggpo: static rtc when ggpo is enabled 2021-09-04 18:47:34 +02:00
Enrique Santos e3aca85efd ggpo: add frame delay to settings (#343) 2021-09-04 18:47:21 +02:00
Flyinghead f35a18bb63 ggpo: use bargraphs for net stats 2021-09-04 12:03:29 +02:00
flyinghead a6ad0208db uTip link 2021-09-03 23:54:40 +02:00
Flyinghead e02ccbf32a gl: update fog and texture palette in Process() 2021-09-03 11:12:47 +02:00
Flyinghead b362a55c04 ggpo: rollback glitches. win32 init. switch build. stats
Block net rollbacks until the current frame has been processed to avoid
glitched textures.
Call WSAStartup at init on windows
Display net stats when in game
Switch build fix
2021-09-03 11:11:46 +02:00
Flyinghead 69d0801121 net rollback with ggpo 2021-09-02 17:51:23 +02:00
flyinghead f85bca06d7 dsp: rec crash on windows 2021-09-02 12:34:38 +02:00
scribam 3589e94121 android: update com.android.tools.build:gradle to version 7.0.1 2021-08-31 17:52:51 +02:00
Flyinghead 2baf2cfed6 ci: always install dx2010 2021-08-30 12:13:52 +02:00
Flyinghead 4d5c93adfa ios: add entitlements and sign IPA with ldid 2021-08-29 11:58:05 +02:00
Flyinghead 93eff7fac6 sh4: fix TMU regression
introduced by 05d51cc35c
fixes SA2 running too fast
2021-08-29 11:55:42 +02:00
scribam ce68a9c708 ci: update switch workflow
Checkout submodules non-recursively
Add ninja to speed up compilation
Simplify some steps
2021-08-29 10:45:47 +02:00
scribam 280dad1c07 ci: update android workflow
Checkout submodules non-recursively
Add ccache to speed up compilation
Use ninja and specify target to build only dump_syms
Use official aws-actions/configure-aws-credentials action and awscli to upload artifacts to s3 bucket
2021-08-29 10:45:47 +02:00
Flyinghead c3d954263b gdrom: fix soft reset. ignore slave requests. Unknown ATA cmds handling
Retain currently inserted disk during soft reset
Correct DriveSelect value. Ignore slave drive commands and return 0
status.
Properly handle unknown ATA commands.
Fixes DreamShell boot and CDI boot from BIOS
2021-08-27 18:29:41 +02:00
Flyinghead e058ba5d3b sh4: always perform hard-reset of sh4 and its registers
Fixes infinite loop after reboot
2021-08-27 18:20:40 +02:00
Flyinghead 05d51cc35c sh4: timer underflow lost if TCOR is 0 or very small
Fixes DreamShell boot
2021-08-27 17:55:50 +02:00
vkedwardli a51f310e96 Add volume slider in audio settings (#329)
Use logarithmic volume scale
2021-08-26 13:30:23 +02:00
Flyinghead 89ccdf2814 rend: better fix to force even width rendering 2021-08-26 13:28:13 +02:00
Flyinghead 52af352fcd input: never load mapping file for !remappable controllers
Fixes android on-screen gamepad not working when a (wrong) mapping file
exists for it.

Issue #325
Issue #330
2021-08-26 13:25:18 +02:00
Flyinghead 088287227e x64 msvc build fix 2021-08-26 11:01:44 +02:00
Flyinghead ad1f9527c1 x86 msvc build fix 2021-08-26 10:34:01 +02:00
Flyinghead ca17717af7 dsp: map TEMP/MEMS/MIXS regs to sh4 and aica address space. Clean up 2021-08-26 10:16:07 +02:00
Flyinghead 2a849ccba5 ui: hide dirs on iOS. Fix home on android. force even width rendering
Hide content and home dirs on iOS
Show home dir and allow change on android
Force even width for rendering resolution
2021-08-26 10:08:50 +02:00
Flyinghead 4bf20846bc iOS: output audio to speakers, not the receiver 2021-08-26 10:02:38 +02:00
Flyinghead ad80184e7f missing cmake change 2021-08-24 20:54:17 +02:00
Flyinghead e5ca63db20 aica: arm32 dsp dynarec. Correct dsp level when dsp disabled 2021-08-24 20:49:53 +02:00
vkedwardli 7a33ae35e0 [macOS] Fix DelayFrameSwapping and optimise Vsync logic (#307)
* Support macOS 10.15 and 11
* Enable VSync option on macOS. Use "swapOnVSync" logic from other wsi
* Limit `mainui_rend_frame()` to 5 iterations max: 4 renders and the final swap
2021-08-24 11:43:19 +02:00
Flyinghead ce58ba3472 pvr: detect swap on FB_R_SOF2 too. Force render res. to even width
Fixes Soul Calibur FPS /2 drop with Delay Frame Swapping on
2021-08-24 11:40:53 +02:00
Flyinghead 43ae2ea5f5 macOS: upgrade SDL to 2.0.16
fixes Xbox series X controller support
2021-08-23 17:56:40 +02:00
Flyinghead 2f03922b43 build fix 2021-08-23 14:25:27 +02:00
Flyinghead 5db2856270 missing changes from previous commit 2021-08-23 14:16:52 +02:00
Flyinghead e3e3229612 iOS: multiple controller/rumble support. GL: fix black screen after RTT
iOS:
* multiple controllers support. Rumble support.
* fix audio recording
* declare CHD/GDI/CUE/CDI content types
* start game when opening file URL
* Use safe area for UI and virtual gamepad
* Better icons
2021-08-23 14:02:12 +02:00
Flyinghead 8b2ed736a6 libretro: fix random shutdown when saving/loading state
Issue #326
2021-08-23 11:29:17 +02:00
Flyinghead 27da5f84c4 cmake: fix miniupnpc name warning
Issue #302
2021-08-23 10:23:04 +02:00
Flyinghead 98d04702ae sdl: set vsync swap interval to 2 for 120 Hz displays
Issue #293
2021-08-23 10:11:04 +02:00
Flyinghead a0664a49d2 ci: install awscli 2021-08-22 21:21:32 +02:00
Flyinghead 55fb0a6efb ci: fix switch s3 upload 2021-08-22 21:00:58 +02:00
Flyinghead 7fb83f4f77 libretro: fix content closing when loading or saving state 2021-08-22 20:41:02 +02:00
scribam 3006cd4f60 .cirrus.yml: update to freebsd-13-0 2021-08-22 11:44:34 +02:00
Flyinghead 970f8c6dcd upload iOS and switch builds to S3 2021-08-20 19:57:20 +02:00
Flyinghead c99de2370f build fix 2021-08-20 08:39:37 +02:00
Flyinghead 8c9ff4a66f iOS: DSP fix 2021-08-20 08:32:29 +02:00
Flyinghead 42eeddcbfb iOS: on-screen gamepad layout fix 2021-08-17 10:13:30 +02:00
Flyinghead 8b0f17fb25 iOS: bundle_version must not be null. Add Document Browser support 2021-08-16 13:09:53 +02:00
Flyinghead a3900495d5 iOS: map menu button to Options, start to Menu. Analog triggers 2021-08-16 11:46:45 +02:00
Flyinghead d7bc1f0f77 apple: disable delay frame swapping, libretro: set base_width/height to 640x480, use gl 3.2 on macOS 2021-08-15 10:50:53 +02:00
scribam 281a04837f switch: simplify standalone build 2021-08-13 08:31:32 +02:00
Flyinghead 3ea688be69 iOS: pause/resume based on focus. autosave state on background. VGamepad fix
Get rid of swipe gesture (fixes touch not being delivered)
Use UP+DOWN or LEFT+RIGHT to open menu.
Arcade shortcuts (RT + A/B/X)
Disable system gestures
Monitor network and restart AltKit as needed.
2021-08-12 11:22:22 +02:00
Flyinghead c27180fb32 android: fix navbar background. Add shortcuts for Coin/Service/Test
Fix black navigation bar background.
Shortcuts for virtual gamepad:
RT + A -> D (Coint)
RT + B -> C (Service)
RT + X -> Z (Test)
Issue #137

Don't deliver mouse clicks if analog triggers or stick are used
2021-08-11 12:58:57 +02:00
Flyinghead 1bea7853ef iOS: CI job, JIT status, touch fixes 2021-08-10 17:04:36 +02:00
Flyinghead 104521517c Build fix 2021-08-10 12:00:05 +02:00
Flyinghead bb217e5c49 iOS: AltKit source 2021-08-10 11:34:11 +02:00
Flyinghead 12f302d356 iOS: uv need high precision in fragment shader. cmake build. virtual joystick. AltKit integration 2021-08-10 11:32:22 +02:00
Edward Li 6f233462c1 Add missing JITWriteProtect to DSP 2021-08-09 09:02:59 +02:00
Flyinghead 77e7c25e9c iOS support. Work in progress 2021-08-06 10:30:30 +02:00
Flyinghead b027a6b9a1 android: add missing oboe lib links 2021-08-05 22:06:32 +02:00
Flyinghead 6bb4575c95 Merge remote-tracking branch 'origin/master' into libretro 2021-08-05 18:17:30 +02:00
Flyinghead 37eace9db4 osx: lockup when emulator aborts. Race condition when starting emu 2021-08-05 17:43:26 +02:00
Flyinghead 0414406471 win32 build fix. disable breakpad on BSD 2021-08-03 11:59:19 +02:00
Flyinghead 8c000f327e missing include 2021-08-03 10:08:13 +02:00
Flyinghead 951e70328f Use exception when load content fails. ui: graceful stop on fatal error
libretro: catch/detect fatal errors and shutdown
2021-08-03 10:05:09 +02:00
Flyinghead 2dd7717128 glGetString(GL_EXTENSIONS) may return null in core contexts
xcode project missing update
2021-08-03 09:49:20 +02:00
Flyinghead 9d6c548730 naomi: close cart on reset. sh4: replace some verify by throw
Close naomi/aw cart on reset. Reset input mapping/button names
Get rid of ngen_GetFeatures()
throw exception instead of failing verify if not internal error
catch sh4 exceptions in dynarecs and throw fatal error
2021-08-03 09:47:13 +02:00
Flyinghead 8a46853dfd lr: deadlock on exit with custom textures (win32)
less log
2021-08-02 12:07:40 +02:00
Flyinghead 789fd21bb7 bsd build fix 2021-08-02 12:05:24 +02:00
Flyinghead 3fa97b5ce7 bsd build fix 2021-08-02 10:20:45 +02:00
Flyinghead c8ebbc657a x86 win32 build fix 2021-08-02 10:09:19 +02:00
Flyinghead b59585437c arm32 dynarec: windows ce support 2021-08-01 17:25:48 +02:00
Flyinghead 6f4e1365b1 x86: stack unwind fixes 2021-08-01 17:07:17 +02:00
scribam fcef404f50 android: update gradle and dependencies 2021-07-30 19:35:07 +02:00
Flyinghead aabb492d01 x86 stack unwinding support (android) 2021-07-30 19:13:52 +02:00
Flyinghead cfa21934bb x64: fix stack unwinding issue. don't save xmm regs on stack 2021-07-30 19:10:34 +02:00
Flyinghead 7561ce753a unwind info for arm64. use static c++ lib for android
include oboe static libs
get rid of old regalloc
2021-07-29 17:46:46 +02:00
Flyinghead 5ac0e58886 android: mouse move events missing when btn down. Mouse wheel support
Issue #304
2021-07-27 10:32:22 +02:00
vkedwardli a14fc35e47 Support Fast Forward in macOS (#303) 2021-07-26 20:36:14 +02:00
Flyinghead 5fd00e3063 specify RelWithDebInfo output dir 2021-07-26 00:13:05 +02:00
Flyinghead a46a012c3c tentative fix against .NET stupidity 2021-07-25 22:42:05 +02:00
Flyinghead 3072105efe github: don't upload symbols for linux 2021-07-25 22:27:17 +02:00
Flyinghead 8f09ac2611 github: don't parameterize shell 2021-07-25 22:22:08 +02:00
Flyinghead e12be7cf29 add breakpad support for android, linux and windown 2021-07-25 21:55:29 +02:00
flyinghead 588d79641a msvc x64 build fix 2021-07-25 11:47:14 +02:00
Flyinghead daac6de533 macos build fix 2021-07-24 23:30:12 +02:00
flyinghead c6d7307efe x86 build fix 2021-07-24 23:17:27 +02:00
Flyinghead 710f379bd3 unwind info for x64 dynarecs
delegate to previous signal handler, proper abort for win32
arm32: use builtin gcc __clear_cache
dyna/driver.cpp: no need for a code buffer in win32, cleanup
2021-07-24 22:24:37 +02:00
vkedwardli e4d9be86b4 Fix cmake macOS ARM not building (#301)
set `CMAKE_OSX_ARCHITECTURES` as Cache Entry
2021-07-24 15:52:56 +02:00
vkedwardli 3c483c61e7 Support Apple Silicon (macOS ARM Universal Binary) (#253)
* Add audio arm64 cpp into Xcode project

* Build universal binary for SDL2 also

* Add vixl aarch64 dependency + build arm64 in cmake

* hardcode pagesize for M1 CPU

* Use `MAP_JIT` and toggle between RX and RW

* add pthread.h for cmake

* Disable audio dynarec temporary

* Enable aica arm dynarec

* Supports `br` with condition

* Dynamic linker flag for libSDL2.a since Homebrew path is different on arm (for xcodeproj)

* Fallback path for Intel

* de-dup for arm64, allow cross compilation on both Intel and Apple Silicon Mac

* Rename WriteProtect() to JITWriteProtect(), Move JITWriteProtect from arm7_rec to arm7_rec_arm64

* Remove CodeCache memset

* Remove keyboard_device.cpp from xcodeproj

* Use hard tab

* Update libchdr to support compiling on M1 (thanks @scribam)
2021-07-23 22:34:12 +02:00
Flyinghead c453d14352 libretro: better error handling. fix reset issue with rotated games
compilation warnings, clean up
2021-07-21 16:19:57 +02:00
Flyinghead de060d66ab don't save flash if no game started. libretro: fix notifications
compilation warnings, non-functional changes
2021-07-20 19:21:11 +02:00
Flyinghead c458a8f5e7 os_[Un]InstallFaultHandler. Uninstall fault handler at shutdown 2021-07-20 13:06:08 +02:00
Flyinghead 4a77f847b4 libretro: fix arcade flash files path. ui: stop spamming dc_stop 2021-07-20 10:06:44 +02:00
Flyinghead edc6474f27 save nvmem/flash files when stopping emu 2021-07-19 18:20:58 +02:00
Flyinghead 117f47e3a2 rend: shader builder utility 2021-07-19 12:49:47 +02:00
Flyinghead 4f11ff76a5 input: don't toggle fastforward when game isn't running
it resets the vulkan swapchain and causes random crashes
2021-07-19 12:10:14 +02:00
Flyinghead 10e97b63be jvs: no default mapping if button is remapped to P1 or P2
fixes jambo down-lever pausing the game
2021-07-19 10:15:24 +02:00
Flyinghead af76a09e03 gl: repeat % operator for printf. remove Switch special case 2021-07-18 18:15:35 +02:00
scribam 147bd8341d android: update compileSdkVersion/targetSdkVersion to version 29 2021-07-17 19:35:14 +02:00
scribam 5c0dd67094 android: cleanup jni files 2021-07-17 19:35:14 +02:00
scribam 49688d6523 android: migrate to androidx 2021-07-17 19:35:14 +02:00
scribam 850f23be82 android: update project files 2021-07-17 19:35:14 +02:00
Flyinghead 9e5769912b gl: workaround nouveau bug (oit). Use float palette coords for switch
Don't switch render type before terminating current one.
2021-07-17 15:53:47 +02:00
Flyinghead ab50bc9936 libretro: VGA cable option shown twice. fix arcade/dc option visibility 2021-07-16 17:41:40 +02:00
Flyinghead a604a3904f win: make sure not to call VirtualAlloc with null during jit alloc 2021-07-16 17:35:29 +02:00
Flyinghead e112f2d8af gl: GLES2 build compatibility 2021-07-15 19:24:56 +02:00
Flyinghead 376d2e1433 libretro: fix keyboard input 2021-07-15 18:44:57 +02:00
Flyinghead ed0caa119a Merge remote-tracking branch 'origin/master' into libretro
# Conflicts:
#	CMakeLists.txt
2021-07-15 18:43:29 +02:00
Flyinghead f768146d8e switch: unneeded init functions. needed exit one 2021-07-15 16:50:54 +02:00
Flyinghead 412083d9ea libretro: blank vmus at unload/reset 2021-07-15 15:43:10 +02:00
Flyinghead 07cdb42ff7 switch: set UI scaling factor depending on docking mode 2021-07-15 14:44:39 +02:00
Flyinghead 1e37e8f333 switch: dsp dynarec fix 2021-07-15 12:24:42 +02:00
Flyinghead 4fa89c4a45 switch: build with miniupnp. set correct window size
organize header
remove unneeded switch-specific code
2021-07-15 12:19:11 +02:00
Flyinghead 0d7a2128b6 libretro: fix 32-bit arm build. delete useless #def in pvr2 filter 2021-07-15 12:06:04 +02:00
scribam 9aa3d8b987 android: do not filter abi, allow x86_64 build 2021-07-15 09:54:41 +02:00
scribam eaf44bc18c android: generate release apk with debug keystore, update ci and gradle 2021-07-15 09:54:41 +02:00
Flyinghead ae33c8de18 sdl: increase audio buffer size. libretro: set PIC option 2021-07-15 00:26:00 +02:00
Flyinghead b12e82c344 libretro: add switch lib as artifact 2021-07-14 22:00:05 +02:00
Flyinghead 8dee648d01 arm64 rec: put ngen_FailedToFindBlock at a fixed address
transitioning to MMU will fail it this function's address changes
happens if vmem is disabled (switch)
2021-07-14 21:03:02 +02:00
Flyinghead 8e6dc54b16 switch: add .. entry to folder chooser. start at / 2021-07-14 20:55:22 +02:00
Flyinghead db9c48b085 switch: typo 2021-07-14 17:48:41 +02:00
Flyinghead c0171f5fd1 switch: open sdl joysticks 0 & 1 at init 2021-07-14 17:22:17 +02:00
Flyinghead 9a5a55d074 switch: use /flycast as config folder 2021-07-14 16:38:12 +02:00
Flyinghead 855836d9aa switch: arm rec EntryPoints need rx. fix arm & dsp cache flush 2021-07-14 14:57:43 +02:00
Flyinghead 8a0a0bcdfc switch: use 256x256 jpeg as app icon 2021-07-14 13:57:40 +02:00
Flyinghead 43c00568c6 switch: standalone build 2021-07-14 13:02:57 +02:00
Flyinghead 31be731de0 input: fix atomiswave keyboard bindings 2021-07-14 09:42:13 +02:00
Flyinghead 113ef66e26 libretro: use HAVE_LIBNX in libretro-common 2021-07-13 21:06:03 +02:00
Flyinghead 4d38e69f63 lr switch: enable aica arm and dsp dynarecs. handle rw/rx offset 2021-07-13 20:51:17 +02:00
Flyinghead 8c02345dfd lr switch: use toolchain ar. really disable lto 2021-07-13 19:18:36 +02:00
Flyinghead a2efde1103 libretro: more switch fixes
combine all static libraries into one
save/restore gl state in !threaded mode
patch libchdr
build fixes
2021-07-13 18:51:40 +02:00
Flyinghead eb81583d9f sh4 dyna: support for !vmem 2021-07-13 17:09:26 +02:00
Flyinghead 44213bf830 lr: fix res change for rotated games. display version. vmem: simplify 2021-07-13 13:45:01 +02:00
scribam f187f77e3d Add basic GitHub Actions for Libretro Nintendo Switch 2021-07-12 22:22:07 +02:00
Flyinghead 63a3f02368 libretro: better switch support 2021-07-12 20:14:21 +02:00
Flyinghead 994e6826b4 libretro: option changes (resolution, widescreen, rotation)
Use RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO or
RETRO_ENVIRONMENT_SET_GEOMETRY to report resolution/aspect ratio
changes.
Handle rotation without restarting.
2021-07-12 09:57:58 +02:00
Flyinghead 97991fd8fc gl: delete libretro vmu and crosshair textures when terminating 2021-07-11 20:43:04 +02:00
Flyinghead 1fdda98d8d libretro: return max savestate size. unprotect ram and vram on reset
fixes random crash when saving state
2021-07-11 17:42:30 +02:00
Flyinghead a73ca94124 savestate: push vmu lcd image when loading 2021-07-11 12:37:21 +02:00
Flyinghead 82d2aa8a47 savestate: fix test 2021-07-10 19:30:13 +02:00
Flyinghead 75af07331a savestate: save gdrom read buffer. other fixes
Issue #294
2021-07-10 19:16:19 +02:00
Flyinghead 4be4ad07f3 libretro: m3u playlists 2021-07-10 18:00:21 +02:00
Flyinghead 57874a9bcb libretro: savestate compatibility. B1/D1 vmus now visible 2021-07-10 17:39:16 +02:00
Flyinghead ec7968b2f4 libretro: Reset. Reso not applied (vk). xhair always displayed (vk).
Fix Content Reset crash
Render resolution not set at startup with vulkan !threaded
vk: Crosshair always displayed (white) even when off
Better handling of multiple render (rend_single_frame returns false)
2021-07-09 18:17:14 +02:00
Flyinghead 81546fe727 libretro: handle ThreadedRendering transition. Fix hang in !threaded 2021-07-09 16:28:28 +02:00
Flyinghead 7948bac6ba libretro: fix per-game VMU A1 option 2021-07-09 16:23:46 +02:00
Flyinghead eceb5ba982 naomi: keyboard needs player number 2021-07-09 14:34:11 +02:00
Flyinghead 345dab9633 libretro: fix nvidia palette issue. request 3.2 to get a core gl ctx 2021-07-09 13:10:30 +02:00
Flyinghead 5c952021b7 libretro: vmu and crosshair display. lightgun fixes 2021-07-08 20:09:09 +02:00
Flyinghead 80a5b44fe9 enable vulkan in lr ci builds 2021-07-08 12:52:00 +02:00
Flyinghead b66e6560ca libretro: vulkan support 2021-07-08 12:47:00 +02:00
Flyinghead 673c2988d6 libretro: backport libnx support. Fix log source paths 2021-07-07 19:01:37 +02:00
Flyinghead 042f2e0224 custom textures: saturate colors when dumping RGBA4444 and RGBA5551 2021-07-07 17:19:13 +02:00
Flyinghead b300bb9f7a libretro: non-threaded rendering 2021-07-07 13:12:16 +02:00
Flyinghead 205f2690d6 gl4: delete fog & palette textures when terminating
fixes fullscreen toggle screen corruption
2021-07-07 10:54:10 +02:00
scribam aeea301ee3 Minor include header changes 2021-07-07 10:37:11 +02:00
Flyinghead 8e6bbed74f libretro: aw coin fix. screen rotation. disable loading notifications 2021-07-07 09:48:10 +02:00
flyinghead ef506d49aa libretro: pvr2 postprocessing filter 2021-07-06 21:37:47 +02:00
flyinghead c205a888a9 options: anisotropic filtering, oit pixel buffer size, fast gdrom load 2021-07-06 16:19:12 +02:00
flyinghead a3b66aec1f libretro: win32 support. build fix. 2021-07-06 13:22:54 +02:00
Flyinghead 68f4c50bd3 missing change 2021-07-05 19:48:49 +02:00
Flyinghead 7dbd79750c WIP libretro core update 2021-07-05 19:44:08 +02:00
Flyinghead fd301186c7 android: avoid duplicates in controllers list 2021-07-05 19:26:57 +02:00
Flyinghead b40328e621 input: don't change mapper if file not found. sdl: fix default bindings 2021-07-05 09:59:46 +02:00
flyinghead 7cd832e914 input: use default mapping if no mapping file is found 2021-07-04 23:27:29 +02:00
flyinghead 44feea4c01 Merge pull request #288 from flyinghead/fh/directx
DirectX9 renderer
2021-07-04 18:35:19 +02:00
flyinghead c5ce475359 Merge remote-tracking branch 'origin/master' into fh/directx
# Conflicts:
#	core/input/gamepad_device.cpp
2021-07-04 17:53:49 +02:00
flyinghead 894a0540b9 sdl: convert keyboard mapping from keycodes to scancode on first load 2021-07-04 17:45:45 +02:00
flyinghead 967f4570ed rawinput: simplify USB device names 2021-07-04 15:51:33 +02:00
Flyinghead 14360beaf7 gdrom: reset registers and state on reset
Issue #281
2021-06-27 12:53:54 +02:00
Enrique Santos 46e3258629 Controller Mapping: System Profiles & Unmap Button (#269)
* add unmap button
* separate controller profiles for dc & arcade games
* loads current system mapping on menu exit
* simplify, use default filename for dc controls
* create blank mapping file for sdl controllers if not found
2021-06-27 12:49:47 +02:00
Flyinghead b3ad0a62c1 gl: fix multiple rendering with GLES 2
fixes split-screen multiplayer for SW1 Racer, Q3, Re-volt
2021-06-19 10:48:32 +02:00
scribam a5edd9c7ff deps: remove crypto folder (unused) 2021-06-19 10:46:22 +02:00
Flyinghead 7f49accc22 Merge remote-tracking branch 'origin/master' into fh/directx 2021-06-07 20:53:31 +02:00
Flyinghead b8c2a695b8 ui: allow drag scrolling anywhere. change some ui elements
allow scrolling by dragging (almost) anywhere
move physical devices before dreamcast ones
hide insets when displaying full screen window
reduce scroll bar size on android
fix controller mapping column sizes
2021-06-07 12:18:05 +02:00
Flyinghead c73bbc85bd savestate: rzip size must be 64-bit on all platforms 2021-06-06 11:18:42 +02:00
scribam d6545b253b Misc cleanup 2021-06-06 11:15:06 +02:00
Flyinghead 293761bdf5 gui: separate auto-load and auto-save options. Fix tool tips on android 2021-06-04 11:11:23 +02:00
scribam d862453956 github actions: authorize aws actions on main repository only 2021-06-04 11:08:30 +02:00
Flyinghead 58974c9305 savestate slots 2021-06-03 13:50:40 +02:00
keita yoshimoto cddb6609f1 Multiple save states (#248) 2021-06-03 13:22:40 +02:00
scribam 4a9c51a6c8 github actions: remove flac installation from macos 2021-05-31 23:24:43 +02:00
scribam 329ae11d2f Remove snap configuration file 2021-05-31 23:24:33 +02:00
Flyinghead c3bc5cfc3b vk oit: use a 2nd depth attachment for subpass 1
subpass 1 needs writable depth buffer (see
9f60c5e854)
2021-05-30 18:20:04 +02:00
scribam 24f9003cd3 cirrus ci: add ccache support 2021-05-29 14:32:06 +02:00
scribam 4c2bf59c46 github actions: extend cache for Android build 2021-05-29 14:32:06 +02:00
scribam 642a89733b ci: remove flac package 2021-05-29 14:13:05 +02:00
scribam 2b3d9427e1 .cirrus.yml: use CIRRUS_CLONE_SUBMODULES to checkout submodules 2021-05-29 14:12:51 +02:00
scribam 6368241b77 cmake: fix compilation on FreeBSD 2021-05-29 14:12:51 +02:00
scribam 57ae9022dd Update Windows resource and version.h.in files 2021-05-28 14:56:04 +02:00
flyinghead 7ed68952ba Merge remote-tracking branch 'origin/master' into fh/directx
# Conflicts:
#	core/deps/patches/SDL.patch
#	core/hw/maple/maple_devs.cpp
#	core/rend/gl4/gles.cpp
#	core/rend/gles/gles.cpp
#	core/rend/gui.cpp
#	core/rend/gui.h
#	shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj
2021-05-26 22:38:48 +02:00
flyinghead 4696733eb4 dx9: linear filtering for fog texture. swap only when frame rendered 2021-05-26 21:40:43 +02:00
flyinghead 5f5d31730c sdl: hide mouse in fullscreen. fix & refactor mouse devices
support rawinput mouse wheel
simplify mapping load
2021-05-19 18:13:52 +02:00
Flyinghead e07977eea9 mac,x11: propagate win/sdl mouse/keyboard changes 2021-05-10 13:48:12 +02:00
flyinghead 71fb024061 rawinput: proper conversion of abs coordinates
Issue #138
get rid of libPvr_GetRenderTarget() -> getNativeHwnd()
2021-05-04 12:03:09 +02:00
flyinghead 54cfc6e09b build fix for non-windows 2021-04-29 19:15:34 +02:00
Flyinghead 150cfa29e7 Merge remote-tracking branch 'origin/master' into fh/directx 2021-04-29 19:06:38 +02:00
flyinghead b90cdf9588 RawInput driver. Multiple keyboards support
Merge Keyboard and KbGamepad
Always use system mouse for UI
Issue #138

Fix DX9 when not using SDL
2021-04-29 18:58:04 +02:00
flyinghead 6316479930 get rid of unneeded pixel unpacker and use better name 2021-04-29 18:38:58 +02:00
flyinghead f9603dc11a vk: use texture pointers instead of u64 2021-04-17 19:04:00 +02:00
flyinghead 5359e9a09d allow gpu-handled palette textures to be replaced by custom version
Issue #219
Fix incorrect texture size calculation for VQ textures.
Reorder BaseTextureCacheData fields to have hottest on top
2021-04-17 18:40:58 +02:00
flyinghead 28d2c6db73 dx9: rotate 90deg 2021-04-16 21:58:37 +02:00
flyinghead abc8b18b78 dx9: mipmaps. load/dump textures. vmu/crosshair display.
upload all texture mipmaps to gpu
dump textures. load custom textures
vmu and lightgun xhair display
fix dx9 half-pixel offset
fix 565_32 unpacker bug
2021-04-16 18:30:47 +02:00
flyinghead c889bfa6d4 dx9: copy to vram. clipping. fix depth/stencil size. better reset
Coordinate device reset with dxcontext. Keep compiled shaders.
Don't use automatic depth/stencil on backbuffer. Manually handle it.
Implement scissoring/clipping
multipass translucent depth
Render-to-texture copy to vram
2021-04-15 15:17:32 +02:00
flyinghead f2a0098fed build fix 2 2021-04-13 12:22:01 +02:00
flyinghead b549c56b23 build fix. default Delay Frame Swapping to true 2021-04-13 11:20:11 +02:00
flyinghead f107d380b9 WIP directx9 renderer 2021-04-12 22:49:04 +02:00
901 changed files with 180919 additions and 48264 deletions

No files matched your search

+8 -3
View File
@@ -1,9 +1,14 @@
freebsd_instance:
image_family: freebsd-12-2
image_family: freebsd-13-0
env:
CCACHE_DIR: /tmp/ccache
CIRRUS_CLONE_SUBMODULES: true
task:
install_script: pkg install -y alsa-lib cmake evdev-proto flac git libao libevdev libudev-devd libzip mesa-libs miniupnpc ninja pkgconf png pulseaudio sdl2
install_script: pkg install -y alsa-lib ccache cmake evdev-proto git libao libevdev libudev-devd libzip mesa-libs miniupnpc ninja pkgconf png pulseaudio sdl2
ccache_cache:
folder: /tmp/ccache
script:
- git submodule update --init --recursive
- cmake -B build -DCMAKE_BUILD_TYPE=Release -G Ninja
- cmake --build build --config Release
+1
View File
@@ -0,0 +1 @@
custom: ['https://utip.io/flyinghead', 'https://www.paypal.com/paypalme/FlycastEmu']
@@ -1,3 +1,12 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
**Please Note: This form is the minimum required information for submitting bugs.**
**Removing this form may lead to your issue being closed until it is completed.**
+20
View File
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
+51 -26
View File
@@ -8,44 +8,69 @@ jobs:
steps:
- name: Set up build environment
run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;20.0.5594570"
run: |
sudo apt-get update
sudo apt-get -y install ccache libcurl4-openssl-dev ninja-build
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
submodules: true
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
path: ~/.ccache
key: android-ccache-${{ github.sha }}
restore-keys: android-ccache-
- uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: android-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: android-gradle-
- name: Gradle
working-directory: shell/android-studio
run: ./gradlew assembleDebug --parallel
run: ./gradlew assembleRelease --parallel
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: flycast-debug.apk
path: shell/android-studio/flycast/build/outputs/apk/debug/flycast-debug.apk
name: flycast-release.apk
path: shell/android-studio/flycast/build/outputs/apk/release/flycast-release.apk
- name: Set up git vars
- name: Build dump_syms
working-directory: core/deps/breakpad
run: |
echo GIT_BUILD=`git describe --all --always | sed 's/remotes\/origin/heads/'`-$GITHUB_SHA >> $GITHUB_ENV
./configure --prefix=$PWD
make -j2
make install
- name: Clean up
run: rm -f shell/android-studio/flycast/build/outputs/apk/debug/*.json
- name: Extract symbols
run: |
DUMP_SYMS=./core/deps/breakpad/bin/dump_syms
SO_DIR=shell/android-studio/flycast/build/intermediates/cmake/release/obj
for arch in arm64-v8a armeabi-v7a x86 x86_64 ; do
$DUMP_SYMS $SO_DIR/$arch/libflycast.so > libflycast.so.sym
BUILD_ID=`head -1 libflycast.so.sym | awk '{ print $4 }'`
mkdir -p symbols/libflycast.so/$BUILD_ID
mv libflycast.so.sym symbols/libflycast.so/$BUILD_ID
done
- uses: jakejarvis/s3-sync-action@master
- name: Configure AWS Credentials
id: aws-credentials
uses: aws-actions/configure-aws-credentials@v1
with:
args: --acl public-read --follow-symlinks
env:
AWS_S3_BUCKET: flycast-builds
AWS_ACCESS_KEY_ID: AKIAJOZQS4H2PHQWYFCA
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }}
AWS_REGION: 'us-east-2'
SOURCE_DIR: 'shell/android-studio/flycast/build/outputs/apk/debug/'
DEST_DIR: android/${{ env.GIT_BUILD }}
if: ${{ github.event_name == 'push' }}
aws-access-key-id: AKIAJOZQS4H2PHQWYFCA
aws-secret-access-key: ${{ secrets.S3_SECRET_KEY }}
aws-region: us-east-2
if: github.repository == 'flyinghead/flycast' && github.event_name == 'push'
- name: Upload to S3
run: aws s3 sync shell/android-studio/flycast/build/outputs/apk/release s3://flycast-builds/android/${GITHUB_REF#refs/}-$GITHUB_SHA --acl public-read --exclude='*.json' --follow-symlinks
if: ${{ steps.aws-credentials.outputs.aws-account-id != '' }}
- name: Upload to S3 (symbols)
run: aws s3 sync symbols s3://flycast-symbols/android --follow-symlinks
if: ${{ steps.aws-credentials.outputs.aws-account-id != '' }}
+85 -52
View File
@@ -7,97 +7,130 @@ jobs:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
defaults:
run:
shell: ${{ matrix.config.shell }}
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
strategy:
matrix:
config:
- {name: i686-pc-windows-msvc, os: windows-latest, cmakeArgs: -DCMAKE_SYSTEM_VERSION="10.0.18362.0" -G "Visual Studio 16 2019" -A Win32}
- {name: x86_64-apple-darwin, os: macos-latest, cmakeArgs: -G "Xcode", destDir: osx}
- {name: x86_64-pc-linux-gnu, os: ubuntu-latest}
- {name: x86_64-pc-windows-msvc, os: windows-latest, cmakeArgs: -DCMAKE_SYSTEM_VERSION="10.0.18362.0" -G "Visual Studio 16 2019" -A x64}
- {name: x86_64-w64-mingw32, os: windows-latest, cmakeArgs: -G "MinGW Makefiles", destDir: win}
- {name: i686-pc-windows-msvc, os: windows-latest, shell: cmd, arch: x86, cmakeArgs: -G Ninja, buildType: Release}
- {name: apple-darwin, os: macos-latest, shell: sh, cmakeArgs: -G Xcode -DAPPLE_BREAKPAD=ON, destDir: osx, buildType: RelWithDebInfo}
- {name: apple-ios, os: macos-latest, shell: sh, cmakeArgs: -DCMAKE_SYSTEM_NAME=iOS -G Xcode, destDir: ios, buildType: Release}
- {name: x86_64-pc-linux-gnu, os: ubuntu-latest, shell: sh, cmakeArgs: -G Ninja, buildType: Release}
- {name: x86_64-pc-windows-msvc, os: windows-latest, shell: cmd, arch: x64, cmakeArgs: -G Ninja, buildType: Release}
- {name: x86_64-w64-mingw32, os: windows-latest, shell: 'msys2 {0}', cmakeArgs: -G Ninja, destDir: win, buildType: RelWithDebInfo}
- {name: libretro-x86_64-pc-linux-gnu, os: ubuntu-latest, shell: sh, cmakeArgs: -DLIBRETRO=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -G Ninja, buildType: Release}
- {name: libretro-x86_64-w64-mingw32, os: windows-latest, shell: 'msys2 {0}', cmakeArgs: -DLIBRETRO=ON -G Ninja, buildType: Release}
steps:
- name: Set up build environment (macos-latest)
- name: Set up build environment (macOS)
run: |
brew install ccache flac libao libomp pulseaudio zlib
echo "/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
echo "CCACHE_DIR=/tmp/ccache" >> $GITHUB_ENV
if: matrix.config.os == 'macos-latest'
brew update
brew install libao ldid ninja pulseaudio
VULKAN_VER=1.3.211.0 && aria2c --parameterized-uri=true https://{sdk.lunarg.com/sdk/download/$VULKAN_VER/mac,distfiles.macports.org/MoltenVK}/vulkansdk-macos-$VULKAN_VER.dmg
hdiutil attach ./vulkansdk-macos-*.dmg
sudo /Volumes/vulkansdk-macos-*/InstallVulkan.app/Contents/MacOS/InstallVulkan --root $HOME/VulkanSDK --accept-licenses --default-answer --confirm-command install
hdiutil detach /Volumes/vulkansdk-macos-*
echo "VULKAN_SDK=$HOME/VulkanSDK/macOS" >> $GITHUB_ENV
if: runner.os == 'macOS'
- name: Set up build environment (ubuntu-latest)
- name: Set up build environment (Linux)
run: |
sudo apt-get update
sudo apt-get -y install ccache libao-dev libasound2-dev libevdev-dev libflac-dev libgl1-mesa-dev libpulse-dev libsdl2-dev libudev-dev libzip-dev libminiupnpc-dev
echo "CCACHE_DIR=/tmp/ccache" >> $GITHUB_ENV
if: matrix.config.os == 'ubuntu-latest'
sudo apt-get -y install ccache libao-dev libasound2-dev libevdev-dev libgl1-mesa-dev liblua5.3-dev libminiupnpc-dev libpulse-dev libsdl2-dev libudev-dev libzip-dev ninja-build
if: runner.os == 'Linux'
- uses: actions/cache@v2
- name: Set up build environment (Windows, MinGW)
uses: msys2/setup-msys2@v2
with:
path: /tmp/ccache
key: ccache-${{ matrix.config.os }}-${{ github.sha }}
restore-keys: ccache-${{ matrix.config.os }}-
if: matrix.config.os != 'windows-latest'
msystem: MINGW64
install: git make mingw-w64-x86_64-ccache mingw-w64-x86_64-cmake mingw-w64-x86_64-lua mingw-w64-x86_64-ninja mingw-w64-x86_64-SDL2 mingw-w64-x86_64-toolchain
if: matrix.config.shell == 'msys2 {0}'
- uses: actions/checkout@v2
- name: Set up build environment (Windows, Visual Studio)
run: |
choco install ccache directx-sdk ninja
echo DXSDK_DIR=C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)>> %GITHUB_ENV%
if: matrix.config.shell == 'cmd'
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.config.arch }}
if: matrix.config.shell == 'cmd'
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
submodules: true
- name: Create artifact directory
run: mkdir -p build/artifact
- name: Compile a universal OpenMP (macOS)
run: export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1; brew reinstall --build-from-source --formula ./shell/apple/libomp.rb
if: runner.os == 'macOS'
- name: Build SDL (macos-latest)
run: |
cd shell/apple
mkdir artifacts
brew install --build-from-source ./sdl2.rb
if: matrix.config.os == 'macos-latest'
- uses: actions/cache@v3
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ matrix.config.name }}-${{ github.sha }}
restore-keys: ccache-${{ matrix.config.name }}-
if: runner.os != 'macOS'
- name: CMake
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=artifact ${{ matrix.config.cmakeArgs }}
cmake --build build --config Release --parallel 2
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config.buildType }} -DCMAKE_INSTALL_PREFIX=artifact ${{ matrix.config.cmakeArgs }}
cmake --build build --config ${{ matrix.config.buildType }} --target install
- name: Unit Tests
run: |
mkdir -p build/tests
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=tests -DENABLE_CTEST=ON ${{ matrix.config.cmakeArgs }}
cmake --build build --config Release --parallel 2
./build/tests/flycast
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config.buildType }} -DCMAKE_INSTALL_PREFIX=artifact -DENABLE_CTEST=ON ${{ matrix.config.cmakeArgs }}
cmake --build build --config ${{ matrix.config.buildType }}
./build/flycast
if: matrix.config.name == 'x86_64-pc-linux-gnu'
- uses: actions/upload-artifact@v2
- name: Dump symbols
run: |
core/deps/breakpad/bin/dump_syms artifact/bin/flycast.exe > flycast.exe.sym 2>/dev/null
BUILD_ID=`head -1 flycast.exe.sym | awk '{ print $4 }'`
mkdir -p symbols/flycast.exe/$BUILD_ID
mv flycast.exe.sym symbols/flycast.exe/$BUILD_ID
strip artifact/bin/flycast.exe
if: matrix.config.name == 'x86_64-w64-mingw32'
- uses: actions/upload-artifact@v3
with:
name: flycast-${{ matrix.config.name }}
path: build/artifact
path: artifact/bin
- name: Package app (macos)
run: |
cd build/artifact
rm -rf Flycast.swiftmodule
zip -r flycast.app.zip Flycast.app
rm -rf Flycast.app
if: matrix.config.os == 'macos-latest'
cd artifact/bin
zip -rm flycast.app.zip Flycast.app
if: matrix.config.name == 'apple-darwin'
- name: Package app (windows)
run: |
powershell Compress-Archive build/artifact/flycast.exe build/artifact/flycast.zip
rm build/artifact/flycast.exe
powershell Compress-Archive artifact/bin/flycast.exe artifact/bin/flycast.zip
rm artifact/bin/flycast.exe
if: matrix.config.name == 'x86_64-w64-mingw32'
- name: Set up git vars
run: |
echo GIT_BUILD=`git describe --all --always | sed 's/remotes\/origin/heads/'`-$GITHUB_SHA >> $GITHUB_ENV
shell: bash
- name: Configure AWS Credentials
id: aws-credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: AKIAJOZQS4H2PHQWYFCA
aws-secret-access-key: ${{ secrets.S3_SECRET_KEY }}
aws-region: us-east-2
if: github.event_name == 'push'
if: github.repository == 'flyinghead/flycast' && github.event_name == 'push' && matrix.config.destDir != ''
- name: Upload to S3
run: aws s3 sync build/artifact s3://flycast-builds/${{ matrix.config.destDir }}/${{ env.GIT_BUILD }} --acl public-read --follow-symlinks
if: github.event_name == 'push' && matrix.config.destDir != ''
run: aws s3 sync artifact/bin s3://flycast-builds/${{ matrix.config.destDir }}/${GITHUB_REF#refs/}-$GITHUB_SHA --acl public-read --follow-symlinks
shell: bash
if: ${{ steps.aws-credentials.outputs.aws-account-id != '' }}
- name: Upload symbols to S3 (Windows-MinGW, macOS)
run: aws s3 sync symbols s3://flycast-symbols/${{ matrix.config.destDir }} --follow-symlinks
shell: bash
if: ${{ steps.aws-credentials.outputs.aws-account-id != '' && (matrix.config.name == 'x86_64-w64-mingw32' || matrix.config.name == 'apple-darwin') }}
+34
View File
@@ -0,0 +1,34 @@
# Prepare source texts & upload them to Crowdin
name: Crowdin Source Texts Upload
# on change to the English texts
on:
push:
branches:
- master
paths:
- 'shell/libretro/libretro_core_options.h'
jobs:
upload_source_file:
runs-on: ubuntu-latest
steps:
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 8
- name: Setup Python
uses: actions/setup-python@v3
- name: Checkout
uses: actions/checkout@v3
- name: Upload Source
shell: bash
env:
CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }}
run: |
python3 intl/upload_workflow.py $CROWDIN_API_KEY "flyinghead-flycast" "shell/libretro/libretro_core_options.h"
+47
View File
@@ -0,0 +1,47 @@
# Download translations form Crowdin & Recreate libretro_core_options_intl.h
name: Crowdin Translation Integration
on:
schedule:
# please choose a random time & weekday to avoid all repos synching at the same time
- cron: '15 22 * * 5' # Fridays at 10:15 PM, UTC
jobs:
create_intl_file:
runs-on: ubuntu-latest
steps:
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 8
- name: Setup Python
uses: actions/setup-python@v3
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- name: Create intl file
shell: bash
env:
CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }}
run: |
python3 intl/download_workflow.py $CROWDIN_API_KEY "flyinghead-flycast" "shell/libretro/libretro_core_options_intl.h"
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions[bot]"
git add intl/*_workflow.py "shell/libretro/libretro_core_options_intl.h"
git commit -m "Fetch translations & Recreate libretro_core_options_intl.h"
- name: GitHub Push
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
+59
View File
@@ -0,0 +1,59 @@
name: Nintendo Switch CI
on: [push, pull_request]
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ubuntu-latest
container: devkitpro/devkita64:20220128
strategy:
matrix:
config:
- {name: standalone, destDir: switch}
- {name: libretro, cmakeArgs: -DLIBRETRO=ON}
steps:
- name: Set up build environment
run: |
sudo apt-get update
sudo apt-get -y install awscli ccache ninja-build
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- uses: actions/cache@v3
with:
path: ~/.ccache
key: ccache-switch-${{ matrix.config.name }}-${{ github.sha }}
restore-keys: ccache-switch-${{ matrix.config.name }}-
- name: CMake
run: |
$DEVKITPRO/portlibs/switch/bin/aarch64-none-elf-cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=artifact -G Ninja ${{ matrix.config.cmakeArgs }}
cmake --build build --config Release --target install
- uses: actions/upload-artifact@v3
with:
name: flycast-switch-${{ matrix.config.name }}
path: artifact/bin
- name: Package app
run: zip -m artifact/bin/flycast.nro.zip artifact/bin/flycast.nro
if: hashFiles('artifact/bin/flycast.nro') != ''
- name: Configure AWS Credentials
id: aws-credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: AKIAJOZQS4H2PHQWYFCA
aws-secret-access-key: ${{ secrets.S3_SECRET_KEY }}
aws-region: us-east-2
if: github.repository == 'flyinghead/flycast' && github.event_name == 'push' && matrix.config.destDir != ''
- name: Upload to S3
run: aws s3 sync artifact/bin s3://flycast-builds/${{ matrix.config.destDir }}/${GITHUB_REF#refs/}-$GITHUB_SHA --acl public-read --follow-symlinks
if: ${{ steps.aws-credentials.outputs.aws-account-id != '' }}
+69
View File
@@ -0,0 +1,69 @@
name: Windows UWP CI
on: [push, pull_request]
jobs:
build:
runs-on: windows-latest
env:
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg/bincache
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: bootstrap vcpkg
run: |
git clone https://github.com/microsoft/vcpkg
mkdir vcpkg\bincache
vcpkg\bootstrap-vcpkg.bat
- uses: actions/cache@v3
with:
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: vcpkg-${{ hashFiles( 'vcpkg.json' ) }}
- name: CMake
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -DCMAKE_SYSTEM_PROCESSOR=AMD64 -DCMAKE_CROSSCOMPILING=OFF -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake
cmake --build build --config Release --parallel 2
shell: cmd
- uses: ilammy/msvc-dev-cmd@v1
- name: Package app
run: |
mkdir build\artifact
cd build\AppPackages\flycast\flycast_*_x64_Test
mkdir tmp
ren *.msix flycast.msix
makeappx.exe unpack /p .\flycast.msix /d tmp
copy ..\..\..\Release\*.dll tmp
makeappx pack /d tmp /p ..\..\..\artifact\flycast.appx
- name: Sign app
run: signtool sign /f shell\uwp\sign_cert.pfx /p '${{ secrets.SIGN_CERT_PWD }}' /v /fd SHA256 build\artifact\flycast.appx
if: github.repository == 'flyinghead/flycast' && github.event_name == 'push'
- uses: actions/upload-artifact@v3
with:
name: flycast-uwp
path: build/artifact
- name: Configure AWS Credentials
id: aws-credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: AKIAJOZQS4H2PHQWYFCA
aws-secret-access-key: ${{ secrets.S3_SECRET_KEY }}
aws-region: us-east-2
if: github.repository == 'flyinghead/flycast' && github.event_name == 'push'
- name: Upload to S3
run: aws s3 sync build/artifact s3://flycast-builds/xbox/${GITHUB_REF#refs/}-$GITHUB_SHA --acl public-read --follow-symlinks
shell: bash
if: ${{ steps.aws-credentials.outputs.aws-account-id != '' }}
+4 -58
View File
@@ -1,65 +1,11 @@
.DS_Store
*.class
*.orig
*build_obj
Workdir/data
Workdir/reicast*
Workdir/vmu*
Workdir/webui*
Workdir/emu.cfg
Workdir/lib*ant.properties
build/
# iOS General
# macOS
.DS_Store
*/build/*
**/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
*.hmap
emulator.xccheckout
reicast.xccheckout
build/*
*.so
*Karen_angelXwind*
local.properties
ant.properties
*build_obj
*.d
Workdir/data
Workdir/reicast*
Workdir/vmu*
Workdir/webui*
Workdir/emu.cfg
Workdir/lib*ant.properties
reicast-ios.xccheckout
# Linux General
shell/linux/.map
shell/linux/flycast.elf.map
shell/linux/nosym-flycast.elf
shell/linux/flycast.elf
shell/linux/dispframe.elf
# Visual Studio
generated
.vs
# Android Studio
*.iml
shell/android-studio/.gradle/
shell/android-studio/flycast/.cxx/
shell/android-studio/flycast/build/
shell/android-studio/flycast/local.properties
.vs/
out/
# JetBrains IDES
.idea/
+131
View File
@@ -0,0 +1,131 @@
# DESCRIPTION: GitLab CI/CD for libRetro (NOT FOR GitLab-proper)
##############################################################################
################################# BOILERPLATE ################################
##############################################################################
# Core definitions
.core-defs:
variables:
GIT_SUBMODULE_STRATEGY: recursive
CORENAME: flycast
CORE_ARGS: -DLIBRETRO=ON -DCMAKE_BUILD_TYPE=Release
.core-defs-linux:
extends: .core-defs
variables:
CORE_ARGS: -DLIBRETRO=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DCMAKE_BUILD_TYPE=Release
.core-defs-osx-x64:
extends: .core-defs
variables:
CORE_ARGS: -DLIBRETRO=ON -G Xcode -DCMAKE_BUILD_TYPE=Release
EXTRA_PATH: Release
.core-defs-android:
extends: .core-defs
script:
- cmake $CORE_ARGS -DANDROID_PLATFORM=android-$API_LEVEL -DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_STL=c++_static -DANDROID_ABI=$ANDROID_ABI -DANDROID_ARM_MODE=arm "$CMAKE_SOURCE_ROOT" -B$BUILD_DIR
- cmake --build $BUILD_DIR --target ${CORENAME}_libretro --config Release -- -j $NUMPROC
- mv $BUILD_DIR/${CORENAME}_libretro.so $LIBNAME
- if [ $STRIP_CORE_LIB -eq 1 ]; then $NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip $LIBNAME; fi
variables:
API_LEVEL: 18
# Inclusion templates, required for the build to work
include:
################################## DESKTOPS ################################
# Windows
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-cmake-mingw.yml'
# MacOS
- project: 'libretro-infrastructure/ci-templates'
file: 'osx-cmake-x86.yml'
# Linux
- project: 'libretro-infrastructure/ci-templates'
file: '/linux-cmake.yml'
################################## CELLULAR ################################
# Android
- project: 'libretro-infrastructure/ci-templates'
file: '/android-cmake.yml'
################################## CONSOLES ################################
# Nintendo Switch
# - project: 'libretro-infrastructure/ci-templates'
# file: '/libnx-static.yml'
# Stages for building
stages:
- build-prepare
- build-shared
# - build-static
##############################################################################
#################################### STAGES ##################################
##############################################################################
#
################################### DESKTOPS #################################
# Windows 64-bit
libretro-build-windows-x64:
extends:
- .libretro-windows-cmake-x86_64
- .core-defs
# Windows 32-bit
libretro-build-windows-i686:
extends:
- .libretro-windows-cmake-x86
- .core-defs
# Linux 64-bit
libretro-build-linux-x64:
extends:
- .libretro-linux-cmake-x86_64
- .core-defs-linux
# Linux 32-bit
libretro-build-linux-i686:
extends:
- .libretro-linux-cmake-x86
- .core-defs-linux
# MacOS 64-bit
libretro-build-osx-x64:
extends:
- .libretro-osx-cmake-x86
- .core-defs-osx-x64
################################### CELLULAR #################################
# Android ARMv7a
android-armeabi-v7a:
extends:
- .libretro-android-cmake-armeabi-v7a
- .core-defs-android
# Android ARMv8a
android-arm64-v8a:
extends:
- .libretro-android-cmake-arm64-v8a
- .core-defs-android
# Android 64-bit x86
android-x86_64:
extends:
- .libretro-android-cmake-x86_64
- .core-defs-android
# Android 32-bit x86
android-x86:
extends:
- .libretro-android-cmake-x86
- .core-defs-android
################################### CONSOLES #################################
# Nintendo Switch
#libretro-build-libnx-aarch64:
# extends:
# - .libretro-libnx-static-retroarch-master
# - .core-defs
+6
View File
@@ -4,3 +4,9 @@
[submodule "core/deps/libchdr"]
path = core/deps/libchdr
url = https://github.com/rtissera/libchdr.git
[submodule "core/deps/luabridge"]
path = core/deps/luabridge
url = https://github.com/vinniefalco/LuaBridge.git
[submodule "core/deps/breakpad"]
path = core/deps/breakpad
url = https://github.com/flyinghead/mingw-breakpad
+948 -348
View File
File diff suppressed because it is too large. Load diff
+26 -12
View File
@@ -1,11 +1,13 @@
# Flycast
[![C/C++ CI](https://github.com/flyinghead/flycast/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/flyinghead/flycast/actions/workflows/c-cpp.yml)
[![Android CI](https://github.com/flyinghead/flycast/actions/workflows/android.yml/badge.svg)](https://github.com/flyinghead/flycast/actions/workflows/android.yml)
[![C/C++ CI](https://github.com/flyinghead/flycast/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/flyinghead/flycast/actions/workflows/c-cpp.yml)
[![Nintendo Switch CI](https://github.com/flyinghead/flycast/actions/workflows/switch.yml/badge.svg)](https://github.com/flyinghead/flycast/actions/workflows/switch.yml)
[![Windows UWP CI](https://github.com/flyinghead/flycast/actions/workflows/uwp.yml/badge.svg)](https://github.com/flyinghead/flycast/actions/workflows/uwp.yml)
![flycast logo](https://github.com/flyinghead/flycast/raw/master/shell/linux/flycast.png)
**Flycast** is a multi-platform Sega Dreamcast, Naomi and Atomiswave emulator derived from [**reicast**](https://reicast.com/).
**Flycast** is a multi-platform Sega Dreamcast, Naomi, Naomi 2, and Atomiswave emulator derived from [**reicast**](https://github.com/skmp/reicast-emulator).
Information about configuration and supported features can be found on [**TheArcadeStriker's flycast wiki**](https://github.com/TheArcadeStriker/flycast-wiki/wiki).
@@ -13,24 +15,36 @@ Join us on our [**Discord server**](https://discord.gg/X8YWP8w) for a chat.
## Install
### Flatpak
### Flatpak (Linux)
1. [Set up Flatpak](https://www.flatpak.org/setup/)
1. [Set up Flatpak](https://www.flatpak.org/setup/).
2. Install Flycast from [Flathub](https://flathub.org/apps/details/org.flycast.Flycast)
2. Install Flycast from [Flathub](https://flathub.org/apps/details/org.flycast.Flycast):
`flatpak install -y org.flycast.Flycast`
3. Run Flycast
3. Run Flycast:
`flatpak run org.flycast.Flycast`
### Homebrew (MacOS)
1. [Set up Homebrew](https://brew.sh).
2. Install Flycast via Homebrew:
`brew install --cask flycast`
### Xbox One/Series
#### Retail:
Open [**gamr13's github page**](https://gamr13.github.io/) from your Xbox console.
#### Dev Mode:
Grab the latest build from [**the builds page**](https://flyinghead.github.io/flycast-builds/), or the [**GitHub Actions**](https://github.com/flyinghead/flycast/actions/workflows/uwp.yml). Then install it using the **Xbox Device Portal**.
### Binaries
Get fresh builds for your system [on the builds page](https://flyinghead.github.io/flycast-builds/).
Get fresh builds for your system [**on the builds page**](https://flyinghead.github.io/flycast-builds/).
**New:** Now automated test results are available as well.
## Disclaimer
All code contritbuted to this fork is *not* bound by the Individual Contributor License Agreement of the upstream repository (https://github.com/reicast/reicast-emulator) and shall *not* be considered as a contribution to the upstream repository.
**New:** Now automated test results are available as well.
-1
View File
@@ -7,7 +7,6 @@ Here lies the core of our codebase. Everything that's OS inspecific rests here.
### Some rudimentary categories are:
- hw -- DC Hardware Components Implementation
- nullDC.cpp -- Main entry points
- emitter -- x86 code emitter
- khronos -- OpenGL and Vulkan headers
- oslib -- Audio drivers
- cfg -- Configuration backend structure
+1 -11
View File
@@ -33,20 +33,10 @@ bool SzArchive::Open(const char* path)
File_Close(&archiveStream.file);
File_Construct(&archiveStream.file);
#ifdef USE_WINDOWS_FILE
nowide::wstackstring wpath;
if (!wpath.convert(path))
return false;
archiveStream.file.handle = CreateFileW(wpath.c_str(),
GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (archiveStream.file.handle == INVALID_HANDLE_VALUE)
return false;
#else
archiveStream.file.file = nowide::fopen(path, "rb");
if (archiveStream.file.file == nullptr)
return false;
#endif
FileInStream_CreateVTable(&archiveStream);
LookToRead2_CreateVTable(&lookStream, 0);
lookStream.buf = (Byte *)ISzAlloc_Alloc(&g_Alloc, kInputBufSize);
+8 -1
View File
@@ -39,6 +39,12 @@ bool RZipFile::Open(const std::string& path, bool write)
Close();
return false;
}
// savestates created on 32-bit platforms used to have a 32-bit size
if (size >> 32 != 0)
{
size &= 0xffffffff;
std::fseek(file, -4, SEEK_CUR);
}
chunk = new u8[maxChunkSize];
chunkIndex = 0;
chunkSize = 0;
@@ -109,9 +115,10 @@ size_t RZipFile::Write(const void *data, size_t length)
verify(std::ftell(file) == 0);
maxChunkSize = 1024 * 1024;
size = length;
if (std::fwrite(RZipHeader, sizeof(RZipHeader), 1, file) != 1
|| std::fwrite(&maxChunkSize, sizeof(maxChunkSize), 1, file) != 1
|| std::fwrite(&length, sizeof(length), 1, file) != 1)
|| std::fwrite(&size, sizeof(size), 1, file) != 1)
return 0;
const u8 *p = (const u8 *)data;
// compression output buffer must be 0.1% larger + 12 bytes
+2 -1
View File
@@ -32,10 +32,11 @@ public:
size_t Size() const { return size; }
size_t Read(void *data, size_t length);
size_t Write(const void *data, size_t length);
FILE *rawFile() const { return file; }
private:
FILE *file = nullptr;
size_t size = 0;
u64 size = 0;
u32 maxChunkSize = 0;
u8 *chunk = nullptr;
u32 chunkSize = 0;
+21 -21
View File
@@ -181,13 +181,17 @@
#define FEAT_DSPREC DYNAREC_NONE
#endif
#ifdef __SWITCH__
#define FEAT_NO_RWX_PAGES
#endif
//defaults
#ifndef FEAT_SHREC
#if HOST_CPU == CPU_MIPS
#define FEAT_SHREC DYNAREC_NONE
#else
#if HOST_CPU == CPU_ARM || HOST_CPU == CPU_ARM64 || HOST_CPU == CPU_X86 || HOST_CPU == CPU_X64
#define FEAT_SHREC DYNAREC_JIT
#else
#define FEAT_SHREC DYNAREC_NONE
#endif
#endif
@@ -200,30 +204,13 @@
#endif
#ifndef FEAT_DSPREC
#if HOST_CPU == CPU_X86 || HOST_CPU == CPU_ARM64 || HOST_CPU == CPU_X64
#if HOST_CPU == CPU_ARM || HOST_CPU == CPU_ARM64 || HOST_CPU == CPU_X86 || HOST_CPU == CPU_X64
#define FEAT_DSPREC DYNAREC_JIT
#else
#define FEAT_DSPREC DYNAREC_NONE
#endif
#endif
#if HOST_CPU == CPU_X64 || HOST_CPU == CPU_ARM64
#define HOST_64BIT_CPU
#endif
#define USE_MINIUPNPC
// Compiler Related
#ifndef _MSC_VER
#define ATTR_USED __attribute__((used))
#define ATTR_UNUSED __attribute__((used))
#else
#define ATTR_USED
#define ATTR_UNUSED
#endif
// Some restrictions on FEAT_NO_RWX_PAGES
#if defined(FEAT_NO_RWX_PAGES) && FEAT_SHREC == DYNAREC_JIT
#if HOST_CPU != CPU_X64 && HOST_CPU != CPU_ARM64
@@ -231,6 +218,19 @@
#endif
#endif
#ifdef _WIN32
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
#define TARGET_UWP
#endif
#if !defined(LIBRETRO) && !defined(TARGET_UWP)
#define USE_DX9
#endif
#endif
#if !defined(LIBRETRO) && !defined(TARGET_NO_EXCEPTIONS)
#define USE_GGPO
#endif
// TARGET PLATFORM
+12
View File
@@ -82,6 +82,13 @@ s32 cfgLoadInt(const std::string& section, const std::string& key, s32 def)
return cfgdb.get_int(section, key, def);
}
int64_t cfgLoadInt64(const std::string& section, const std::string& key, int64_t def) {
return cfgdb.get_int64(section, key, def);
}
void cfgSaveInt64(const std::string& section, const std::string& key, int64_t value) {
cfgdb.set_int64(section, key, value);
}
void cfgSaveBool(const std::string& section, const std::string& key, bool value)
{
cfgSaveStr(section, key, value ? "yes" : "no");
@@ -112,6 +119,11 @@ void cfgDeleteSection(const std::string& section)
cfgdb.delete_section(section);
}
void cfgDeleteEntry(const std::string& section, const std::string& key)
{
cfgdb.delete_entry(section, key);
}
void cfgSetAutoSave(bool autoSave)
{
::autoSave = autoSave;
+3
View File
@@ -5,6 +5,8 @@
bool cfgOpen();
s32 cfgLoadInt(const std::string& section, const std::string& key, s32 def);
void cfgSaveInt(const std::string& section, const std::string& key, s32 value);
int64_t cfgLoadInt64(const std::string& section, const std::string& key, int64_t def);
void cfgSaveInt64(const std::string& section, const std::string& key, int64_t value);
std::string cfgLoadStr(const std::string& section, const std::string& key, const std::string& def);
void cfgSaveStr(const std::string& section, const std::string& key, const std::string& value);
void cfgSaveBool(const std::string& section, const std::string& key, bool value);
@@ -17,3 +19,4 @@ bool ParseCommandLine(int argc, char *argv[]);
void cfgSetAutoSave(bool autoSave);
bool cfgHasSection(const std::string& section);
void cfgDeleteSection(const std::string& section);
void cfgDeleteEntry(const std::string& section, const std::string& key);
+28 -62
View File
@@ -1,8 +1,5 @@
/*
Command line parsing
~yay~
Nothing too interesting here, really
*/
#include <cstdio>
@@ -10,39 +7,9 @@
#include <cstring>
#include "cfg/cfg.h"
#include "stdclass.h"
char* trim_ws(char* str)
{
if (str==0 || strlen(str)==0)
return 0;
while(*str)
{
if (!isspace(*str))
break;
str++;
}
size_t l=strlen(str);
if (l==0)
return 0;
while(l>0)
{
if (!isspace(str[l-1]))
break;
str[l-1]=0;
l--;
}
if (l==0)
return 0;
return str;
}
int setconfig(char** arg,int cl)
static int setconfig(char *arg[], int cl)
{
int rv=0;
for(;;)
@@ -50,43 +17,38 @@ int setconfig(char** arg,int cl)
if (cl<1)
{
WARN_LOG(COMMON, "-config : invalid number of parameters, format is section:key=value");
return rv;
break;
}
char* sep=strstr(arg[1],":");
if (sep==0)
std::string value(arg[1]);
auto seppos = value.find(':');
if (seppos == std::string::npos)
{
WARN_LOG(COMMON, "-config : invalid parameter %s, format is section:key=value", arg[1]);
return rv;
WARN_LOG(COMMON, "-config : invalid parameter %s, format is section:key=value", value.c_str());
break;
}
char* value=strstr(sep+1,"=");
if (value==0)
auto eqpos = value.find('=', seppos);
if (eqpos == std::string::npos)
{
WARN_LOG(COMMON, "-config : invalid parameter %s, format is section:key=value", arg[1]);
return rv;
WARN_LOG(COMMON, "-config : invalid parameter %s, format is section:key=value", value.c_str());
break;
}
*sep++=0;
*value++=0;
std::string sect = trim_ws(value.substr(0, seppos));
std::string key = trim_ws(value.substr(seppos + 1, eqpos - seppos - 1));
value = trim_ws(value.substr(eqpos + 1));
char* sect=trim_ws(arg[1]);
char* key=trim_ws(sep);
value=trim_ws(value);
if (sect==0 || key==0)
if (sect.empty() || key.empty())
{
WARN_LOG(COMMON, "-config : invalid parameter, format is section:key=value");
return rv;
break;
}
const char* constval = value;
if (constval==0)
constval="";
INFO_LOG(COMMON, "Virtual cfg %s:%s=%s", sect, key, value);
INFO_LOG(COMMON, "Virtual cfg %s:%s=%s", sect.c_str(), key.c_str(), value.c_str());
cfgSetVirtual(sect,key,value);
cfgSetVirtual(sect, key, value);
rv++;
if (cl>=3 && stricmp(arg[2],",")==0)
if (cl>=3 && strcmp(arg[2],",")==0)
{
cl-=2;
arg+=2;
@@ -114,7 +76,7 @@ static int showhelp()
bool ParseCommandLine(int argc,char* argv[])
{
settings.imgread.ImagePath[0] = '\0';
settings.content.path.clear();
int cl=argc-2;
char** arg=argv+1;
while(cl>=0)
@@ -136,6 +98,10 @@ bool ParseCommandLine(int argc,char* argv[])
cl--;
}
#endif
else if ((*arg)[0] == '-')
{
WARN_LOG(COMMON, "Ignoring unknown command line option '%s'", *arg);
}
else
{
char* extension = strrchr(*arg, '.');
@@ -145,18 +111,18 @@ bool ParseCommandLine(int argc,char* argv[])
|| stricmp(extension, ".gdi") == 0 || stricmp(extension, ".cue") == 0))
{
INFO_LOG(COMMON, "Using '%s' as cd image", *arg);
strcpy(settings.imgread.ImagePath, *arg);
settings.content.path = *arg;
}
else if (extension && stricmp(extension, ".elf") == 0)
{
INFO_LOG(COMMON, "Using '%s' as reios elf file", *arg);
cfgSetVirtual("config", "bios.UseReios", "yes");
strcpy(settings.imgread.ImagePath, *arg);
settings.content.path = *arg;
}
else
{
INFO_LOG(COMMON, "Using '%s' as rom", *arg);
strcpy(settings.imgread.ImagePath, *arg);
settings.content.path = *arg;
}
}
arg++;
+54 -62
View File
@@ -1,7 +1,7 @@
#include "ini.h"
#include "types.h"
#include <sstream>
char* trim_ws(char* str);
#include "stdclass.h"
namespace emucfg {
@@ -24,6 +24,14 @@ int ConfigEntry::get_int()
}
}
int64_t ConfigEntry::get_int64()
{
int base = 10;
if (strstr(this->value.c_str(), "0x") != nullptr)
base = 16;
return (int64_t)strtoll(this->value.c_str(), nullptr, base);
}
bool ConfigEntry::get_bool()
{
if (stricmp(this->value.c_str(), "yes") == 0 ||
@@ -158,6 +166,19 @@ int ConfigFile::get_int(const std::string& section_name, const std::string& entr
}
}
int64_t ConfigFile::get_int64(const std::string& section_name, const std::string& entry_name, int64_t default_value)
{
ConfigEntry* entry = this->get_entry(section_name, entry_name);
if (entry == NULL)
{
return default_value;
}
else
{
return entry->get_int64();
}
}
bool ConfigFile::get_bool(const std::string& section_name, const std::string& entry_name, bool default_value)
{
ConfigEntry* entry = this->get_entry(section_name, entry_name);
@@ -188,6 +209,13 @@ void ConfigFile::set_int(const std::string& section_name, const std::string& ent
this->set(section_name, entry_name, str_value.str(), is_virtual);
}
void ConfigFile::set_int64(const std::string& section_name, const std::string& entry_name, int64_t value, bool is_virtual)
{
std::stringstream str_value;
str_value << value;
this->set(section_name, entry_name, str_value.str(), is_virtual);
}
void ConfigFile::set_bool(const std::string& section_name, const std::string& entry_name, bool value, bool is_virtual)
{
std::string str_value = (value ? "yes" : "no");
@@ -196,74 +224,37 @@ void ConfigFile::set_bool(const std::string& section_name, const std::string& en
void ConfigFile::parse(FILE* file)
{
if(file == NULL)
{
if (file == nullptr)
return;
}
char line[512];
char current_section[512] = { '\0' };
std::string section;
int cline = 0;
while(file && !feof(file))
while (true)
{
if (std::fgets(line, 512, file) == NULL || std::feof(file))
{
if (std::fgets(line, sizeof(line), file) == nullptr)
break;
}
cline++;
if (strlen(line) < 3)
std::string s(line);
s = trim_ws(s, " \r\n");
if (s.empty())
continue;
if (s.length() >= 3 && s[0] == '[' && s[s.length() - 1] == ']')
{
section = s.substr(1, s.length() - 2);
continue;
}
if (line[strlen(line)-1] == '\r' ||
line[strlen(line)-1] == '\n')
auto eqpos = s.find('=');
if (eqpos == std::string::npos)
{
line[strlen(line)-1] = '\0';
}
char* tl = trim_ws(line);
if (tl[0] == '[' && tl[strlen(tl)-1] == ']')
{
tl[strlen(tl)-1] = '\0';
// FIXME: Data loss if buffer is too small
strncpy(current_section, tl+1, sizeof(current_section));
current_section[sizeof(current_section) - 1] = '\0';
trim_ws(current_section);
}
else
{
if (strlen(current_section) == 0)
{
continue; //no open section
}
char* separator = strstr(tl, "=");
if (!separator)
{
WARN_LOG(COMMON, "Malformed entry on config - ignoring @ %d(%s)", cline, tl);
continue;
}
*separator = '\0';
char* name = trim_ws(tl);
char* value = trim_ws(separator + 1);
if (name == NULL || value == NULL)
{
//printf("Malformed entry on config - ignoring @ %d(%s)\n",cline, tl);
continue;
}
else
{
this->set(std::string(current_section), std::string(name), std::string(value));
}
WARN_LOG(COMMON, "Malformed entry on config - ignoring line %d: %s", cline, s.c_str());
continue;
}
std::string property = trim_ws(s.substr(0, eqpos));
std::string value = trim_ws(s.substr(eqpos + 1));
if (value.length() >= 2 && value[0] == '"' && value[value.length() - 1] == '"')
value = value.substr(1, value.length() - 2);
set(section, property, value);
}
}
@@ -274,7 +265,8 @@ void ConfigFile::save(FILE* file)
const std::string& section_name = section_it.first;
const ConfigSection& section = section_it.second;
std::fprintf(file, "[%s]\n", section_name.c_str());
if (!section_name.empty())
std::fprintf(file, "[%s]\n", section_name.c_str());
for (const auto& entry_it : section.entries)
{
@@ -282,8 +274,8 @@ void ConfigFile::save(FILE* file)
const ConfigEntry& entry = entry_it.second;
std::fprintf(file, "%s = %s\n", entry_name.c_str(), entry.get_string().c_str());
}
std::fputs("\n", file);
if (!section_name.empty())
std::fputc('\n', file);
}
}
+6 -1
View File
@@ -1,6 +1,8 @@
#pragma once
#include "types.h"
#include <cstdio>
#include <map>
#include <string>
namespace emucfg {
@@ -9,6 +11,7 @@ struct ConfigEntry {
const std::string& get_string() const;
int get_int();
bool get_bool();
int64_t get_int64();
};
struct ConfigSection {
@@ -39,10 +42,12 @@ struct ConfigFile {
/* getting values */
std::string get(const std::string& section_name, const std::string& entry_name, const std::string& default_value = "");
int get_int(const std::string& section_name, const std::string& entry_name, int default_value = 0);
int64_t get_int64(const std::string& section_name, const std::string& entry_name, int64_t default_value = 0);
bool get_bool(const std::string& section_name, const std::string& entry_name, bool default_value = false);
/* setting values */
void set(const std::string& section_name, const std::string& entry_name, const std::string& value, bool is_virtual = false);
void set_int(const std::string& section_name, const std::string& entry_name, int value, bool is_virtual = false);
void set_int64(const std::string& section_name, const std::string& entry_name, int64_t value, bool is_virtual = false);
void set_bool(const std::string& section_name, const std::string& entry_name, bool value, bool is_virtual = false);
void delete_section(const std::string& section_name);
+35 -4
View File
@@ -17,6 +17,7 @@
along with Flycast. If not, see <https://www.gnu.org/licenses/>.
*/
#include "option.h"
#include "network/naomi_network.h"
namespace config {
@@ -24,7 +25,6 @@ namespace config {
Option<bool> DynarecEnabled("Dynarec.Enabled", true);
Option<bool> DynarecIdleSkip("Dynarec.idleskip", true);
Option<bool> DynarecSafeMode("Dynarec.safe-mode");
// General
@@ -34,12 +34,14 @@ Option<int> Broadcast("Dreamcast.Broadcast", 0); // NTSC
Option<int> Language("Dreamcast.Language", 1); // English
Option<bool> FullMMU("Dreamcast.FullMMU");
Option<bool> ForceWindowsCE("Dreamcast.ForceWindowsCE");
Option<bool> AutoSavestate("Dreamcast.AutoSavestate");
Option<bool> AutoLoadState("Dreamcast.AutoLoadState");
Option<bool> AutoSaveState("Dreamcast.AutoSaveState");
Option<int> SavestateSlot("Dreamcast.SavestateSlot");
Option<bool> ForceFreePlay("ForceFreePlay", true);
// Sound
Option<bool> DSPEnabled("aica.DSPEnabled", false);
Option<bool> DisableSound("aica.NoSound");
#if HOST_CPU == CPU_ARM
Option<int> AudioBufferSize("aica.BufferSize", 5644); // 128 ms
#else
@@ -54,6 +56,7 @@ Option<bool> AutoLatency("aica.AutoLatency",
);
OptionString AudioBackend("backend", "auto", "audio");
AudioVolumeOption AudioVolume;
// Rendering
@@ -75,7 +78,11 @@ Option<bool> Fog("rend.Fog", true);
Option<bool> FloatVMUs("rend.FloatVMUs");
Option<bool> Rotate90("rend.Rotate90");
Option<bool> PerStripSorting("rend.PerStripSorting");
Option<bool> DelayFrameSwapping("rend.DelayFrameSwapping");
#ifdef __APPLE__
Option<bool> DelayFrameSwapping("rend.DelayFrameSwapping", false);
#else
Option<bool> DelayFrameSwapping("rend.DelayFrameSwapping", true);
#endif
Option<bool> WidescreenGameHacks("rend.WidescreenGameHacks");
std::array<Option<int>, 4> CrosshairColor {
Option<int>("rend.CrossHairColor1"),
@@ -88,12 +95,20 @@ Option<int> MaxThreads("pvr.MaxThreads", 3);
Option<int> AutoSkipFrame("pvr.AutoSkipFrame", 0);
Option<int> RenderResolution("rend.Resolution", 480);
Option<bool> VSync("rend.vsync", true);
Option<int64_t> PixelBufferSize("rend.PixelBufferSize", 512 * 1024 * 1024);
Option<int> AnisotropicFiltering("rend.AnisotropicFiltering", 1);
Option<int> TextureFiltering("rend.TextureFiltering", 0); // Default
Option<bool> ThreadedRendering("rend.ThreadedRendering", true);
Option<bool> DupeFrames("rend.DupeFrames", false);
Option<int> PerPixelLayers("rend.PerPixelLayers", 32);
Option<bool> NativeDepthInterpolation("rend.NativeDepthInterpolation", false);
// Misc
Option<bool> SerialConsole("Debug.SerialConsoleEnabled");
Option<bool> SerialPTY("Debug.SerialPTY");
Option<bool> UseReios("UseReios");
Option<bool> FastGDRomLoad("FastGDRomLoad", false);
Option<bool> OpenGlChecks("OpenGlChecks", false, "validate");
@@ -106,7 +121,16 @@ Option<bool> NetworkEnable("Enable", false, "network");
Option<bool> ActAsServer("ActAsServer", false, "network");
OptionString DNS("DNS", "46.101.91.123", "network");
OptionString NetworkServer("server", "", "network");
Option<int> LocalPort("LocalPort", NaomiNetwork::SERVER_PORT, "network");
Option<bool> EmulateBBA("EmulateBBA", false, "network");
Option<bool> EnableUPnP("EnableUPnP", true, "network");
Option<bool> GGPOEnable("GGPO", false, "network");
Option<int> GGPODelay("GGPODelay", 0, "network");
Option<bool> NetworkStats("Stats", true, "network");
Option<int> GGPOAnalogAxes("GGPOAnalogAxes", 0, "network");
Option<bool> GGPOChat("GGPOChat", true, "network");
Option<bool> GGPOChatTimeoutToggle("GGPOChatTimeoutToggle", true, "network");
Option<int> GGPOChatTimeout("GGPOChatTimeout", 10, "network");
#ifdef SUPPORT_DISPMANX
Option<bool> DispmanxMaintainAspect("maintain_aspect", true, "dispmanx");
@@ -141,5 +165,12 @@ std::array<std::array<Option<MapleDeviceType>, 2>, 4> MapleExpansionDevices {
Option<MapleDeviceType>("device4.1", MDT_None, "input"),
Option<MapleDeviceType>("device4.2", MDT_None, "input"),
};
#ifdef _WIN32
Option<bool> UseRawInput("RawInput", false, "input");
#endif
#ifdef USE_LUA
OptionString LuaFileName("LuaFileName", "flycast.lua");
#endif
} // namespace config
+166 -58
View File
@@ -20,8 +20,12 @@
#include <string>
#include <vector>
#include <array>
#include <cmath>
#include "cfg.h"
#include "hw/maple/maple_cfg.h"
#ifdef LIBRETRO
#include <libretro.h>
#endif
namespace config {
@@ -33,6 +37,10 @@ public:
virtual void reset() = 0;
};
#ifdef LIBRETRO
#include "option_lr.h"
#else
class Settings {
public:
void reset() {
@@ -62,10 +70,6 @@ public:
cfgSetAutoSave(true);
}
const std::string& getGameId() const {
return gameId;
}
void setGameId(const std::string& gameId) {
this->gameId = gameId;
}
@@ -117,7 +121,7 @@ public:
void load() override {
if (PerGameOption && settings.hasPerGameConfig())
set(doLoad(settings.getGameId(), section + "." + name));
set(doLoad(settings.gameId, section + "." + name));
else
{
set(doLoad(section, name));
@@ -138,10 +142,14 @@ public:
else if (PerGameOption && settings.hasPerGameConfig())
{
if (value == doLoad(section, name))
{
// delete existing per-game option if any
cfgDeleteEntry(settings.gameId, section + "." + name);
return;
}
}
if (PerGameOption && settings.hasPerGameConfig())
doSave(settings.getGameId(), section + "." + name);
doSave(settings.gameId, section + "." + name);
else
doSave(section, name);
}
@@ -171,9 +179,16 @@ protected:
return cfgLoadBool(section, name, value);
}
template <typename U = T>
enable_if_t<std::is_same<U, int64_t>::value, T>
doLoad(const std::string& section, const std::string& name) const
{
return cfgLoadInt64(section, name, value);
}
template <typename U = T>
enable_if_t<(std::is_integral<U>::value || std::is_enum<U>::value)
&& !std::is_same<U, bool>::value, T>
&& !std::is_same<U, bool>::value && !std::is_same<U, int64_t>::value, T>
doLoad(const std::string& section, const std::string& name) const
{
return (T)cfgLoadInt(section, name, (int)value);
@@ -194,7 +209,7 @@ protected:
if (strValue.empty())
return value;
else
return atof(strValue.c_str());
return (float)atof(strValue.c_str());
}
template <typename U = T>
@@ -208,14 +223,50 @@ protected:
std::vector<std::string> newValue;
while (true)
{
std::string::size_type end = paths.find(';', start);
if (end == std::string::npos)
end = paths.size();
if (start != end)
newValue.push_back(paths.substr(start, end - start));
if (end == paths.size())
break;
start = end + 1;
if (paths[start] == '"')
{
std::string v;
start++;
while (true)
{
if (paths[start] == '"')
{
if (start + 1 >= paths.size())
{
newValue.push_back(v);
return newValue;
}
if (paths[start + 1] == '"')
{
v += paths[start++];
start++;
}
else if (paths[start + 1] == ';')
{
newValue.push_back(v);
start += 2;
break;
}
else
{
v += paths[start++];
}
}
else
v += paths[start++];
}
}
else
{
std::string::size_type end = paths.find(';', start);
if (end == std::string::npos)
end = paths.size();
if (start != end)
newValue.push_back(paths.substr(start, end - start));
if (end == paths.size())
break;
start = end + 1;
}
}
return newValue;
}
@@ -227,9 +278,16 @@ protected:
cfgSaveBool(section, name, value);
}
template <typename U = T>
enable_if_t<std::is_same<U, int64_t>::value>
doSave(const std::string& section, const std::string& name) const
{
cfgSaveInt64(section, name, value);
}
template <typename U = T>
enable_if_t<(std::is_integral<U>::value || std::is_enum<U>::value)
&& !std::is_same<U, bool>::value>
&& !std::is_same<U, bool>::value && !std::is_same<U, int64_t>::value>
doSave(const std::string& section, const std::string& name) const
{
cfgSaveInt(section, name, (int)value);
@@ -256,12 +314,32 @@ protected:
doSave(const std::string& section, const std::string& name) const
{
std::string s;
for (auto& v : value)
for (const auto& v : value)
{
if (s.empty())
s = v;
if (!s.empty())
s += ';';
if (v.find(';') != std::string::npos || (!v.empty() && v[0] == '"'))
{
s += '"';
std::string v2 = v;
while (true)
{
auto pos = v2.find('"');
if (pos != std::string::npos)
{
s += v2.substr(0, pos + 1) + '"';
v2 = v2.substr(pos + 1);
}
else
{
s += v2;
break;
}
}
s += '"';
}
else
s += ";" + v;
s += v;
}
cfgSaveStr(section, name, s);
}
@@ -274,20 +352,15 @@ protected:
bool overridden = false;
Settings& settings;
};
#endif
using OptionString = Option<std::string>;
template<typename T, T value = T()>
class ConstOption {
public:
operator T() const { return value; }
};
// Dynarec
extern Option<bool> DynarecEnabled;
extern Option<bool> DynarecIdleSkip;
extern Option<bool> DynarecSafeMode;
constexpr bool DynarecSafeMode = false;
// General
@@ -297,55 +370,63 @@ extern Option<int> Broadcast; // 0 -> NTSC, 1 -> PAL, 2 -> PAL/M, 3 -> PAL/N, 4
extern Option<int> Language; // 0 -> JP, 1 -> EN, 2 -> DE, 3 -> FR, 4 -> SP, 5 -> IT, 6 -> default
extern Option<bool> FullMMU;
extern Option<bool> ForceWindowsCE;
extern Option<bool> AutoSavestate;
extern Option<bool> AutoLoadState;
extern Option<bool> AutoSaveState;
extern Option<int> SavestateSlot;
extern Option<bool> ForceFreePlay;
// Sound
constexpr ConstOption<bool, true> LimitFPS;
constexpr bool LimitFPS = true;
extern Option<bool> DSPEnabled;
extern Option<bool> DisableSound;
extern Option<int> AudioBufferSize; //In samples ,*4 for bytes
extern Option<bool> AutoLatency;
extern OptionString AudioBackend;
class AudioVolumeOption : public Option<int> {
public:
AudioVolumeOption() : Option<int>("aica.Volume", 100) {};
float logarithmic_volume_scale = 1.0;
void load() override {
Option<int>::load();
calcDbPower();
}
float dbPower()
{
return logarithmic_volume_scale;
}
void calcDbPower()
{
// dB scaling calculation: https://www.dr-lex.be/info-stuff/volumecontrols.html
logarithmic_volume_scale = std::min(std::exp(4.605f * float(value) / 100.f) / 100.f, 1.f);
if (value < 10)
logarithmic_volume_scale *= value / 10.f;
}
};
extern AudioVolumeOption AudioVolume;
// Rendering
class RendererOption : public Option<RenderType> {
public:
RendererOption()
#ifdef USE_DX9
: Option<RenderType>("pvr.rend", RenderType::DirectX9) {}
#elif defined(TARGET_UWP)
: Option<RenderType>("pvr.rend", RenderType::DirectX11) {}
#else
: Option<RenderType>("pvr.rend", RenderType::OpenGL) {}
#endif
bool isOpenGL() const {
return value == RenderType::OpenGL || value == RenderType::OpenGL_OIT;
}
void set(RenderType v)
{
newValue = v;
}
RenderType& operator=(const RenderType& v) { set(v); return value; }
void load() override {
RenderType current = value;
Option<RenderType>::load();
newValue = value;
value = current;
}
void reset() override {
// don't reset the value to avoid vk -> gl -> vk quick switching
// don't reset the value to avoid quick switching when starting a game
overridden = false;
}
bool pendingChange() {
return newValue != value;
}
void commit() {
value = newValue;
}
private:
RenderType newValue = RenderType();
};
extern RendererOption RendererType;
extern Option<bool> UseMipmaps;
@@ -355,9 +436,12 @@ extern Option<bool> ShowFPS;
extern Option<bool> RenderToTextureBuffer;
extern Option<bool> TranslucentPolygonDepthMask;
extern Option<bool> ModifierVolumes;
constexpr ConstOption<bool, true> Clipping;
constexpr bool Clipping = true;
#ifndef LIBRETRO
extern Option<int> TextureUpscale;
extern Option<int> MaxFilteredTextureSize;
extern Option<int> PerPixelLayers;
#endif
extern Option<float> ExtraDepthScale;
extern Option<bool> CustomTextures;
extern Option<bool> DumpTextures;
@@ -374,12 +458,19 @@ extern Option<int> MaxThreads;
extern Option<int> AutoSkipFrame; // 0: none, 1: some, 2: more
extern Option<int> RenderResolution;
extern Option<bool> VSync;
extern Option<int64_t> PixelBufferSize;
extern Option<int> AnisotropicFiltering;
extern Option<int> TextureFiltering; // 0: default, 1: force nearest, 2: force linear
extern Option<bool> ThreadedRendering;
extern Option<bool> DupeFrames;
extern Option<bool> NativeDepthInterpolation;
// Misc
extern Option<bool> SerialConsole;
extern Option<bool> SerialPTY;
extern Option<bool> UseReios;
extern Option<bool> FastGDRomLoad;
extern Option<bool> OpenGlChecks;
@@ -392,7 +483,16 @@ extern Option<bool> NetworkEnable;
extern Option<bool> ActAsServer;
extern OptionString DNS;
extern OptionString NetworkServer;
extern Option<int> LocalPort;
extern Option<bool> EmulateBBA;
extern Option<bool> EnableUPnP;
extern Option<bool> GGPOEnable;
extern Option<int> GGPODelay;
extern Option<bool> NetworkStats;
extern Option<int> GGPOAnalogAxes;
extern Option<bool> GGPOChat;
extern Option<bool> GGPOChatTimeoutToggle;
extern Option<int> GGPOChatTimeout;
#ifdef SUPPORT_DISPMANX
extern Option<bool> DispmanxMaintainAspect;
@@ -409,6 +509,14 @@ extern Option<int> MouseSensitivity;
extern Option<int> VirtualGamepadVibration;
extern std::array<Option<MapleDeviceType>, 4> MapleMainDevices;
extern std::array<std::array<Option<MapleDeviceType>, 2>, 4> MapleExpansionDevices;
#ifdef _WIN32
extern Option<bool> UseRawInput;
#else
constexpr bool UseRawInput = false;
#endif
#ifdef USE_LUA
extern OptionString LuaFileName;
#endif
} // namespace config
+644 -308
View File
File diff suppressed because it is too large. Load diff
+30 -9
View File
@@ -27,6 +27,7 @@ struct WidescreenCheat
const char *area_or_version;
u32 addresses[16];
u32 values[16];
u32 origValues[16];
};
struct Cheat
@@ -39,17 +40,30 @@ struct Cheat
runNextIfEq,
runNextIfNeq,
runNextIfGt,
runNextIfLt
runNextIfLt,
copy
};
Type type = Type::disabled;
Type type;
std::string description;
bool enabled = false;
u32 size = 0;
u32 address = 0;
u32 value = 0;
u32 repeatCount = 1;
u32 repeatValueIncrement = 0;
u32 repeatAddressIncrement = 0;
bool enabled;
u32 size;
u32 address;
u32 value;
u8 valueMask;
u32 repeatCount;
u32 repeatValueIncrement;
u32 repeatAddressIncrement;
u32 destAddress;
bool builtIn;
Cheat(Type type = Type::disabled, const std::string& description = "", bool enabled = false, u32 size = 0, u32 address = 0,
u32 value = 0, u8 valueMask = 0, u32 repeatCount = 1, u32 repeatValueIncrement = 0,
u32 repeatAddressIncrement = 0, u32 destAddress = 0, bool builtIn = false)
: type(type), description(description), enabled(enabled), size(size), address(address), value(value), valueMask(valueMask),
repeatCount(repeatCount), repeatValueIncrement(repeatValueIncrement), repeatAddressIncrement(repeatAddressIncrement),
destAddress(destAddress), builtIn(builtIn)
{
}
};
class CheatManager
@@ -62,12 +76,15 @@ public:
bool cheatEnabled(size_t index) const { return cheats[index].enabled; }
void enableCheat(size_t index, bool enabled) { cheats[index].enabled = enabled; }
void loadCheatFile(const std::string& filename);
void saveCheatFile(const std::string& filename);
// Returns true if using 16:9 anamorphic screen ratio
bool isWidescreen() const { return widescreen_cheat != nullptr; }
void addGameSharkCheat(const std::string& name, const std::string& s);
private:
u32 readRam(u32 addr, u32 bits);
void writeRam(u32 addr, u32 value, u32 bits);
void setActive(bool active);
static const WidescreenCheat widescreen_cheats[];
static const WidescreenCheat naomi_widescreen_cheats[];
@@ -75,6 +92,10 @@ private:
bool active = false;
std::vector<Cheat> cheats;
std::string gameId;
friend class CheatManagerTest_TestLoad_Test;
friend class CheatManagerTest_TestGameShark_Test;
friend class CheatManagerTest_TestSave_Test;
};
extern CheatManager cheatManager;
-260
View File
@@ -1,260 +0,0 @@
RZDCY_FILES :=
RZDCY_SRC_DIR ?= $(call my-dir)
VERSION_HEADER := $(RZDCY_SRC_DIR)/version.h
RZDCY_MODULES := cfg/ hw/arm7/ hw/aica/ hw/holly/ hw/ hw/gdrom/ hw/maple/ \
hw/mem/ hw/pvr/ hw/sh4/ hw/sh4/interpr/ hw/sh4/modules/ profiler/ oslib/ \
hw/naomi/ imgread/ ./ deps/libchdr/src/ deps/libchdr/deps/zlib-1.2.11/ \
deps/libelf/ deps/chdpsr/ rend/ reios/ deps/xbrz/ \
deps/imgui/ archive/ input/ log/ wsi/ network/ hw/bba/ debug/ \
hw/modem/ deps/picotcp/modules/ deps/picotcp/stack/
ifndef NO_REC
ifndef NOT_ARM
RZDCY_MODULES += rec-ARM/ deps/vixl/ deps/vixl/aarch32/
endif
ifdef X86_REC
RZDCY_MODULES += rec-x86/
endif
ifdef X64_REC
RZDCY_MODULES += rec-x64/
endif
ifdef CPP_REC
RZDCY_MODULES += rec-cpp/
endif
ifdef ARM64_REC
RZDCY_MODULES += rec-ARM64/ deps/vixl/ deps/vixl/aarch64/
endif
endif
ifndef NO_REND
RZDCY_MODULES += rend/gles/
ifndef USE_GLES
ifndef USE_DISPMANX
RZDCY_MODULES += rend/gl4/
endif
endif
ifdef USE_VULKAN
RZDCY_MODULES += rend/vulkan/ rend/vulkan/oit/ deps/volk/ \
deps/glslang/glslang/MachineIndependent/ \
deps/glslang/glslang/MachineIndependent/preprocessor/ \
deps/glslang/glslang/GenericCodeGen/ \
deps/glslang/OGLCompilersDLL/ \
deps/glslang/SPIRV/
ifdef FOR_WINDOWS
RZDCY_FILES += $(RZDCY_SRC_DIR)/deps/glslang/glslang/OSDependent/Windows/ossource.cpp
else
RZDCY_FILES += $(RZDCY_SRC_DIR)/deps/glslang/glslang/OSDependent/Unix/ossource.cpp
endif
endif
else
RZDCY_MODULES += rend/norend/
endif
ifdef USE_SDL
RZDCY_MODULES += sdl/
endif
ifdef FOR_LINUX
ifndef UNIT_TESTS
RZDCY_MODULES += linux-dist/
endif
RZDCY_MODULES += linux/
endif
ifdef FOR_WINDOWS
ifndef UNIT_TESTS
RZDCY_FILES += $(RZDCY_SRC_DIR)/windows/winmain.cpp
endif
RZDCY_FILES += $(RZDCY_SRC_DIR)/windows/win_vmem.cpp
RZDCY_CFLAGS += -I$(RZDCY_SRC_DIR)/deps/dirent
endif
ifdef USE_VULKAN
ifdef FOR_WINDOWS
RZDCY_CFLAGS += -DVK_USE_PLATFORM_WIN32_KHR
else
RZDCY_CFLAGS += -DVK_USE_PLATFORM_XLIB_KHR
endif
RZDCY_CFLAGS += -D USE_VULKAN
endif
RZDCY_CFLAGS += -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/rend/gles -I$(RZDCY_SRC_DIR)/deps \
-I$(RZDCY_SRC_DIR)/deps/vixl -I$(RZDCY_SRC_DIR)/khronos -I$(RZDCY_SRC_DIR)/deps/glslang \
-I$(RZDCY_SRC_DIR)/deps/glm -I$(RZDCY_SRC_DIR)/deps/xbyak -I$(RZDCY_SRC_DIR)/deps/nowide/include \
-I$(RZDCY_SRC_DIR)/deps/picotcp/include -I$(RZDCY_SRC_DIR)/deps/picotcp/modules \
-I$(RZDCY_SRC_DIR)/deps/libchdr/include -I$(RZDCY_SRC_DIR)/deps/libchdr/deps/zlib-1.2.11/ \
-I$(RZDCY_SRC_DIR)/deps/libchdr/deps/lzma-19.00 -I$(RZDCY_SRC_DIR)/deps/libchdr/deps/lzma-19.00/include
ifdef USE_SYSTEM_MINIUPNPC
RZDCY_CFLAGS += -I/usr/include/miniupnpc
else
RZDCY_CFLAGS += -I$(RZDCY_SRC_DIR)/deps/miniupnpc
endif
ifdef NO_REC
RZDCY_CFLAGS += -DTARGET_NO_REC
else
RZDCY_MODULES += hw/sh4/dyna/
endif
ifdef USE_GLES
RZDCY_CFLAGS += -DGLES -fPIC
endif
ifdef CHD5_FLAC
RZDCY_CFLAGS += -DCHD5_FLAC -I$(RZDCY_SRC_DIR)/deps/flac/src/libFLAC/include/ -I$(RZDCY_SRC_DIR)/deps/flac/include
RZDCY_CFLAGS += -DHAVE_CONFIG_H
RZDCY_MODULES += deps/flac/src/libFLAC/
endif
# 7-Zip/LZMA settings (CHDv5)
ifdef CHD5_LZMA
RZDCY_MODULES += deps/lzma/
RZDCY_CFLAGS += -D_7ZIP_ST -DCHD5_LZMA
endif
RZDCY_CFLAGS += -DXXH_INLINE_ALL -I$(RZDCY_SRC_DIR)/deps/xxHash -I$(RZDCY_SRC_DIR)/deps/stb
RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.cpp))
RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.cc))
RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.c))
RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.S))
ifdef STATIC_LIBZIP
RZDCY_CFLAGS += -I$(RZDCY_SRC_DIR)/deps/libzip/lib
LIBZIP_DIR = $(RZDCY_SRC_DIR)/deps/libzip/lib
RZDCY_FILES += $(LIBZIP_DIR)/zip_add.c \
$(LIBZIP_DIR)/zip_add_dir.c \
$(LIBZIP_DIR)/zip_add_entry.c \
$(LIBZIP_DIR)/zip_algorithm_deflate.c \
$(LIBZIP_DIR)/zip_buffer.c \
$(LIBZIP_DIR)/zip_close.c \
$(LIBZIP_DIR)/zip_delete.c \
$(LIBZIP_DIR)/zip_dir_add.c \
$(LIBZIP_DIR)/zip_dirent.c \
$(LIBZIP_DIR)/zip_discard.c \
$(LIBZIP_DIR)/zip_entry.c \
$(LIBZIP_DIR)/zip_error.c \
$(LIBZIP_DIR)/zip_error_clear.c \
$(LIBZIP_DIR)/zip_error_get.c \
$(LIBZIP_DIR)/zip_error_get_sys_type.c \
$(LIBZIP_DIR)/zip_error_strerror.c \
$(LIBZIP_DIR)/zip_error_to_str.c \
$(LIBZIP_DIR)/zip_extra_field.c \
$(LIBZIP_DIR)/zip_extra_field_api.c \
$(LIBZIP_DIR)/zip_fclose.c \
$(LIBZIP_DIR)/zip_fdopen.c \
$(LIBZIP_DIR)/zip_file_add.c \
$(LIBZIP_DIR)/zip_file_error_clear.c \
$(LIBZIP_DIR)/zip_file_error_get.c \
$(LIBZIP_DIR)/zip_file_get_comment.c \
$(LIBZIP_DIR)/zip_file_get_external_attributes.c \
$(LIBZIP_DIR)/zip_file_get_offset.c \
$(LIBZIP_DIR)/zip_file_rename.c \
$(LIBZIP_DIR)/zip_file_replace.c \
$(LIBZIP_DIR)/zip_file_set_comment.c \
$(LIBZIP_DIR)/zip_file_set_encryption.c \
$(LIBZIP_DIR)/zip_file_set_external_attributes.c \
$(LIBZIP_DIR)/zip_file_set_mtime.c \
$(LIBZIP_DIR)/zip_file_strerror.c \
$(LIBZIP_DIR)/zip_fopen.c \
$(LIBZIP_DIR)/zip_fopen_encrypted.c \
$(LIBZIP_DIR)/zip_fopen_index.c \
$(LIBZIP_DIR)/zip_fopen_index_encrypted.c \
$(LIBZIP_DIR)/zip_fread.c \
$(LIBZIP_DIR)/zip_fseek.c \
$(LIBZIP_DIR)/zip_ftell.c \
$(LIBZIP_DIR)/zip_get_archive_comment.c \
$(LIBZIP_DIR)/zip_get_archive_flag.c \
$(LIBZIP_DIR)/zip_get_encryption_implementation.c \
$(LIBZIP_DIR)/zip_get_file_comment.c \
$(LIBZIP_DIR)/zip_get_name.c \
$(LIBZIP_DIR)/zip_get_num_entries.c \
$(LIBZIP_DIR)/zip_get_num_files.c \
$(LIBZIP_DIR)/zip_hash.c \
$(LIBZIP_DIR)/zip_io_util.c \
$(LIBZIP_DIR)/zip_libzip_version.c \
$(LIBZIP_DIR)/zip_memdup.c \
$(LIBZIP_DIR)/zip_name_locate.c \
$(LIBZIP_DIR)/zip_new.c \
$(LIBZIP_DIR)/zip_open.c \
$(LIBZIP_DIR)/zip_pkware.c \
$(LIBZIP_DIR)/zip_progress.c \
$(LIBZIP_DIR)/zip_rename.c \
$(LIBZIP_DIR)/zip_replace.c \
$(LIBZIP_DIR)/zip_set_archive_comment.c \
$(LIBZIP_DIR)/zip_set_archive_flag.c \
$(LIBZIP_DIR)/zip_set_default_password.c \
$(LIBZIP_DIR)/zip_set_file_comment.c \
$(LIBZIP_DIR)/zip_set_file_compression.c \
$(LIBZIP_DIR)/zip_set_name.c \
$(LIBZIP_DIR)/zip_source_accept_empty.c \
$(LIBZIP_DIR)/zip_source_begin_write.c \
$(LIBZIP_DIR)/zip_source_begin_write_cloning.c \
$(LIBZIP_DIR)/zip_source_buffer.c \
$(LIBZIP_DIR)/zip_source_call.c \
$(LIBZIP_DIR)/zip_source_close.c \
$(LIBZIP_DIR)/zip_source_commit_write.c \
$(LIBZIP_DIR)/zip_source_compress.c \
$(LIBZIP_DIR)/zip_source_crc.c \
$(LIBZIP_DIR)/zip_source_error.c \
$(LIBZIP_DIR)/zip_source_file_common.c \
$(LIBZIP_DIR)/zip_source_file_stdio.c \
$(LIBZIP_DIR)/zip_source_free.c \
$(LIBZIP_DIR)/zip_source_function.c \
$(LIBZIP_DIR)/zip_source_get_file_attributes.c \
$(LIBZIP_DIR)/zip_source_is_deleted.c \
$(LIBZIP_DIR)/zip_source_layered.c \
$(LIBZIP_DIR)/zip_source_open.c \
$(LIBZIP_DIR)/zip_source_pkware_decode.c \
$(LIBZIP_DIR)/zip_source_pkware_encode.c \
$(LIBZIP_DIR)/zip_source_read.c \
$(LIBZIP_DIR)/zip_source_remove.c \
$(LIBZIP_DIR)/zip_source_rollback_write.c \
$(LIBZIP_DIR)/zip_source_seek.c \
$(LIBZIP_DIR)/zip_source_seek_write.c \
$(LIBZIP_DIR)/zip_source_stat.c \
$(LIBZIP_DIR)/zip_source_supports.c \
$(LIBZIP_DIR)/zip_source_tell.c \
$(LIBZIP_DIR)/zip_source_tell_write.c \
$(LIBZIP_DIR)/zip_source_window.c \
$(LIBZIP_DIR)/zip_source_write.c \
$(LIBZIP_DIR)/zip_source_zip.c \
$(LIBZIP_DIR)/zip_source_zip_new.c \
$(LIBZIP_DIR)/zip_stat.c \
$(LIBZIP_DIR)/zip_stat_index.c \
$(LIBZIP_DIR)/zip_stat_init.c \
$(LIBZIP_DIR)/zip_strerror.c \
$(LIBZIP_DIR)/zip_string.c \
$(LIBZIP_DIR)/zip_unchange.c \
$(LIBZIP_DIR)/zip_unchange_all.c \
$(LIBZIP_DIR)/zip_unchange_archive.c \
$(LIBZIP_DIR)/zip_unchange_data.c \
$(LIBZIP_DIR)/zip_utf-8.c \
$(LIBZIP_DIR)/zip_err_str.c
ifdef FOR_WINDOWS
RZDCY_FILES += $(LIBZIP_DIR)/zip_source_file_win32.c \
$(LIBZIP_DIR)/zip_source_file_win32_named.c \
$(LIBZIP_DIR)/zip_source_file_win32_utf16.c \
$(LIBZIP_DIR)/zip_source_file_win32_utf8.c \
$(LIBZIP_DIR)/zip_source_file_win32_ansi.c \
$(LIBZIP_DIR)/zip_random_win32.c
else
RZDCY_FILES += $(LIBZIP_DIR)/zip_mkstempm.c \
$(LIBZIP_DIR)/zip_source_file_stdio_named.c \
$(LIBZIP_DIR)/zip_random_unix.c
endif
endif
$(VERSION_HEADER):
echo "#define REICAST_VERSION \"`git describe --tags --always`\"" > $(VERSION_HEADER)
echo "#define GIT_HASH \"`git rev-parse --short HEAD`\"" >> $(VERSION_HEADER)
echo "#define BUILD_DATE \"`date '+%Y-%m-%d %H:%M:%S %Z'`\"" >> $(VERSION_HEADER)
+8 -8
View File
@@ -77,14 +77,14 @@ public:
{
if (pc != 1)
Sh4cntx.pc = pc;
dc_resume();
emu.start();
}
void step()
{
bool restoreBreakpoint = removeMatchpoint(0, Sh4cntx.pc, 2);
u32 savedPc = Sh4cntx.pc;
dc_step();
emu.step();
if (restoreBreakpoint)
insertMatchpoint(0, savedPc, 2);
}
@@ -222,7 +222,7 @@ public:
{
config::DynarecEnabled = false;
exception = SIGINT;
dc_stop();
emu.stop();
return exception;
}
@@ -236,7 +236,7 @@ public:
void postDebugTrap()
{
// needed to join the emu thread since debugTrap() is called by it
dc_stop();
emu.stop();
}
u32 currentException()
@@ -246,14 +246,14 @@ public:
void restart()
{
dc_stop();
dc_reset(true);
dc_resume();
emu.unloadGame();
emu.loadGame(settings.content.path.c_str());
emu.start();
}
void detach()
{
dc_resume();
emu.start();
}
void kill()
+4 -2
View File
@@ -31,7 +31,7 @@
namespace debugger {
static void emuEventCallback(Event event);
static void emuEventCallback(Event event, void *);
class GdbServer
{
@@ -73,6 +73,8 @@ public:
void term()
{
EventManager::unlisten(Event::Resume, emuEventCallback);
EventManager::unlisten(Event::Terminate, emuEventCallback);
stop();
if (VALID(clientSocket))
{
@@ -863,7 +865,7 @@ void subroutineReturn()
gdbServer.agent.subroutineReturn();
}
static void emuEventCallback(Event event)
static void emuEventCallback(Event event, void *)
{
switch (event)
{
Submodule core/deps/breakpad added at d2657e1267.
-239
View File
@@ -1,239 +0,0 @@
/*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
* This code is in the public domain; do with it what you wish.
*
* Equivalent code is available from RSA Data Security, Inc.
* This code has been tested against that, and is equivalent,
* except that you don't need to include two pages of legalese
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
* MD5Context structure, pass it to MD5Init, call MD5Update as
* needed on buffers full of bytes, and then call MD5Final, which
* will fill a supplied 16-byte array with the digest.
*
* Changed so as no longer to depend on Colin Plumb's `usual.h' header
* definitions; now uses stuff from dpkg's config.h.
* - Ian Jackson <[email protected]>.
* Still in the public domain.
*/
#include <string.h> /* for memcpy() */
#include "md5.h"
#ifndef LSB_FIRST
void
byteSwap(UWORD32 *buf, unsigned words)
{
md5byte *p = (md5byte *)buf;
do {
*buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 |
((unsigned)p[1] << 8 | p[0]);
p += 4;
} while (--words);
}
#else
#define byteSwap(buf,words)
#endif
/*
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
* initialization constants.
*/
void
MD5Init(struct MD5Context *ctx)
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
ctx->bytes[0] = 0;
ctx->bytes[1] = 0;
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
{
UWORD32 t;
/* Update byte count */
t = ctx->bytes[0];
if ((ctx->bytes[0] = t + len) < t)
ctx->bytes[1]++; /* Carry from low to high */
t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
if (t > len) {
memcpy((md5byte *)ctx->in + 64 - t, buf, len);
return;
}
/* First chunk is an odd size */
memcpy((md5byte *)ctx->in + 64 - t, buf, t);
byteSwap(ctx->in, 16);
MD5Transform(ctx->buf, ctx->in);
buf += t;
len -= t;
/* Process data in 64-byte chunks */
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteSwap(ctx->in, 16);
MD5Transform(ctx->buf, ctx->in);
buf += 64;
len -= 64;
}
/* Handle any remaining bytes of data. */
memcpy(ctx->in, buf, len);
}
/*
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void
MD5Final(md5byte digest[16], struct MD5Context *ctx)
{
int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
md5byte *p = (md5byte *)ctx->in + count;
/* Set the first char of padding to 0x80. There is always room. */
*p++ = 0x80;
/* Bytes of padding needed to make 56 bytes (-8..55) */
count = 56 - 1 - count;
if (count < 0) { /* Padding forces an extra block */
memset(p, 0, count + 8);
byteSwap(ctx->in, 16);
MD5Transform(ctx->buf, ctx->in);
p = (md5byte *)ctx->in;
count = 56;
}
memset(p, 0, count);
byteSwap(ctx->in, 14);
/* Append length in bits and transform */
ctx->in[14] = ctx->bytes[0] << 3;
ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
MD5Transform(ctx->buf, ctx->in);
byteSwap(ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
}
#ifndef ASM_MD5
/* The four core functions - F1 is optimized somewhat */
/* #define F1(x, y, z) (x & y | ~x & z) */
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f,w,x,y,z,in,s) \
(w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
* reflect the addition of 16 longwords of new data. MD5Update blocks
* the data and converts bytes into longwords for this routine.
*/
void
MD5Transform(UWORD32 buf[4], UWORD32 const in[16])
{
register UWORD32 a, b, c, d;
a = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}
#endif
-42
View File
@@ -1,42 +0,0 @@
/*
* This is the header file for the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
* This code is in the public domain; do with it what you wish.
*
* Equivalent code is available from RSA Data Security, Inc.
* This code has been tested against that, and is equivalent,
* except that you don't need to include two pages of legalese
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
* MD5Context structure, pass it to MD5Init, call MD5Update as
* needed on buffers full of bytes, and then call MD5Final, which
* will fill a supplied 16-byte array with the digest.
*
* Changed so as no longer to depend on Colin Plumb's `usual.h'
* header definitions; now uses stuff from dpkg's config.h
* - Ian Jackson <[email protected]>.
* Still in the public domain.
*/
#ifndef MD5_H
#define MD5_H
typedef unsigned int UWORD32;
#define md5byte unsigned char
struct MD5Context {
UWORD32 buf[4];
UWORD32 bytes[2];
UWORD32 in[16];
};
void MD5Init(struct MD5Context *context);
void MD5Update(struct MD5Context *context, md5byte const *buf, unsigned len);
void MD5Final(unsigned char digest[16], struct MD5Context *context);
void MD5Transform(UWORD32 buf[4], UWORD32 const in[16]);
#endif /* !MD5_H */
-387
View File
@@ -1,387 +0,0 @@
/* sha1.h
*
* The sha1 hash function.
*/
/* nettle, low-level cryptographics library
*
* Copyright 2001 Peter Gutmann, Andrew Kuchling, Niels Moeller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#include "sha1.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
static unsigned int READ_UINT32(const UINT8* data)
{
return ((UINT32)data[0] << 24) |
((UINT32)data[1] << 16) |
((UINT32)data[2] << 8) |
((UINT32)data[3]);
}
static void WRITE_UINT32(unsigned char* data, UINT32 val)
{
data[0] = (val >> 24) & 0xFF;
data[1] = (val >> 16) & 0xFF;
data[2] = (val >> 8) & 0xFF;
data[3] = (val >> 0) & 0xFF;
}
/* A block, treated as a sequence of 32-bit words. */
#define SHA1_DATA_LENGTH 16
/* The SHA f()-functions. The f1 and f3 functions can be optimized to
save one boolean operation each - thanks to Rich Schroeppel,
[email protected] for discovering this */
/* #define f1(x,y,z) ( ( x & y ) | ( ~x & z ) ) Rounds 0-19 */
#define f1(x,y,z) ( z ^ ( x & ( y ^ z ) ) ) /* Rounds 0-19 */
#define f2(x,y,z) ( x ^ y ^ z ) /* Rounds 20-39 */
/* #define f3(x,y,z) ( ( x & y ) | ( x & z ) | ( y & z ) ) Rounds 40-59 */
#define f3(x,y,z) ( ( x & y ) | ( z & ( x | y ) ) ) /* Rounds 40-59 */
#define f4(x,y,z) ( x ^ y ^ z ) /* Rounds 60-79 */
/* The SHA Mysterious Constants */
#define K1 0x5A827999L /* Rounds 0-19 */
#define K2 0x6ED9EBA1L /* Rounds 20-39 */
#define K3 0x8F1BBCDCL /* Rounds 40-59 */
#define K4 0xCA62C1D6L /* Rounds 60-79 */
/* SHA initial values */
#define h0init 0x67452301L
#define h1init 0xEFCDAB89L
#define h2init 0x98BADCFEL
#define h3init 0x10325476L
#define h4init 0xC3D2E1F0L
/* 32-bit rotate left - kludged with shifts */
#ifdef _MSC_VER
#define ROTL(n,X) _lrotl(X, n)
#else
#define ROTL(n,X) ( ( (X) << (n) ) | ( (X) >> ( 32 - (n) ) ) )
#endif
/* The initial expanding function. The hash function is defined over an
80-word expanded input array W, where the first 16 are copies of the input
data, and the remaining 64 are defined by
W[ i ] = W[ i - 16 ] ^ W[ i - 14 ] ^ W[ i - 8 ] ^ W[ i - 3 ]
This implementation generates these values on the fly in a circular
buffer - thanks to Colin Plumb, [email protected] for this
optimization.
The updated SHA changes the expanding function by adding a rotate of 1
bit. Thanks to Jim Gillogly, [email protected], and an anonymous contributor
for this information */
#define expand(W,i) ( W[ i & 15 ] = \
ROTL( 1, ( W[ i & 15 ] ^ W[ (i - 14) & 15 ] ^ \
W[ (i - 8) & 15 ] ^ W[ (i - 3) & 15 ] ) ) )
/* The prototype SHA sub-round. The fundamental sub-round is:
a' = e + ROTL( 5, a ) + f( b, c, d ) + k + data;
b' = a;
c' = ROTL( 30, b );
d' = c;
e' = d;
but this is implemented by unrolling the loop 5 times and renaming the
variables ( e, a, b, c, d ) = ( a', b', c', d', e' ) each iteration.
This code is then replicated 20 times for each of the 4 functions, using
the next 20 values from the W[] array each time */
#define subRound(a, b, c, d, e, f, k, data) \
( e += ROTL( 5, a ) + f( b, c, d ) + k + data, b = ROTL( 30, b ) )
/* Initialize the SHA values */
void
sha1_init(struct sha1_ctx *ctx)
{
/* Set the h-vars to their initial values */
ctx->digest[ 0 ] = h0init;
ctx->digest[ 1 ] = h1init;
ctx->digest[ 2 ] = h2init;
ctx->digest[ 3 ] = h3init;
ctx->digest[ 4 ] = h4init;
/* Initialize bit count */
ctx->count_low = ctx->count_high = 0;
/* Initialize buffer */
ctx->index = 0;
}
/* Perform the SHA transformation. Note that this code, like MD5, seems to
break some optimizing compilers due to the complexity of the expressions
and the size of the basic block. It may be necessary to split it into
sections, e.g. based on the four subrounds
Note that this function destroys the data area */
static void
sha1_transform(UINT32 *state, UINT32 *data)
{
UINT32 A, B, C, D, E; /* Local vars */
/* Set up first buffer and local data buffer */
A = state[0];
B = state[1];
C = state[2];
D = state[3];
E = state[4];
/* Heavy mangling, in 4 sub-rounds of 20 interations each. */
subRound( A, B, C, D, E, f1, K1, data[ 0] );
subRound( E, A, B, C, D, f1, K1, data[ 1] );
subRound( D, E, A, B, C, f1, K1, data[ 2] );
subRound( C, D, E, A, B, f1, K1, data[ 3] );
subRound( B, C, D, E, A, f1, K1, data[ 4] );
subRound( A, B, C, D, E, f1, K1, data[ 5] );
subRound( E, A, B, C, D, f1, K1, data[ 6] );
subRound( D, E, A, B, C, f1, K1, data[ 7] );
subRound( C, D, E, A, B, f1, K1, data[ 8] );
subRound( B, C, D, E, A, f1, K1, data[ 9] );
subRound( A, B, C, D, E, f1, K1, data[10] );
subRound( E, A, B, C, D, f1, K1, data[11] );
subRound( D, E, A, B, C, f1, K1, data[12] );
subRound( C, D, E, A, B, f1, K1, data[13] );
subRound( B, C, D, E, A, f1, K1, data[14] );
subRound( A, B, C, D, E, f1, K1, data[15] );
subRound( E, A, B, C, D, f1, K1, expand( data, 16 ) );
subRound( D, E, A, B, C, f1, K1, expand( data, 17 ) );
subRound( C, D, E, A, B, f1, K1, expand( data, 18 ) );
subRound( B, C, D, E, A, f1, K1, expand( data, 19 ) );
subRound( A, B, C, D, E, f2, K2, expand( data, 20 ) );
subRound( E, A, B, C, D, f2, K2, expand( data, 21 ) );
subRound( D, E, A, B, C, f2, K2, expand( data, 22 ) );
subRound( C, D, E, A, B, f2, K2, expand( data, 23 ) );
subRound( B, C, D, E, A, f2, K2, expand( data, 24 ) );
subRound( A, B, C, D, E, f2, K2, expand( data, 25 ) );
subRound( E, A, B, C, D, f2, K2, expand( data, 26 ) );
subRound( D, E, A, B, C, f2, K2, expand( data, 27 ) );
subRound( C, D, E, A, B, f2, K2, expand( data, 28 ) );
subRound( B, C, D, E, A, f2, K2, expand( data, 29 ) );
subRound( A, B, C, D, E, f2, K2, expand( data, 30 ) );
subRound( E, A, B, C, D, f2, K2, expand( data, 31 ) );
subRound( D, E, A, B, C, f2, K2, expand( data, 32 ) );
subRound( C, D, E, A, B, f2, K2, expand( data, 33 ) );
subRound( B, C, D, E, A, f2, K2, expand( data, 34 ) );
subRound( A, B, C, D, E, f2, K2, expand( data, 35 ) );
subRound( E, A, B, C, D, f2, K2, expand( data, 36 ) );
subRound( D, E, A, B, C, f2, K2, expand( data, 37 ) );
subRound( C, D, E, A, B, f2, K2, expand( data, 38 ) );
subRound( B, C, D, E, A, f2, K2, expand( data, 39 ) );
subRound( A, B, C, D, E, f3, K3, expand( data, 40 ) );
subRound( E, A, B, C, D, f3, K3, expand( data, 41 ) );
subRound( D, E, A, B, C, f3, K3, expand( data, 42 ) );
subRound( C, D, E, A, B, f3, K3, expand( data, 43 ) );
subRound( B, C, D, E, A, f3, K3, expand( data, 44 ) );
subRound( A, B, C, D, E, f3, K3, expand( data, 45 ) );
subRound( E, A, B, C, D, f3, K3, expand( data, 46 ) );
subRound( D, E, A, B, C, f3, K3, expand( data, 47 ) );
subRound( C, D, E, A, B, f3, K3, expand( data, 48 ) );
subRound( B, C, D, E, A, f3, K3, expand( data, 49 ) );
subRound( A, B, C, D, E, f3, K3, expand( data, 50 ) );
subRound( E, A, B, C, D, f3, K3, expand( data, 51 ) );
subRound( D, E, A, B, C, f3, K3, expand( data, 52 ) );
subRound( C, D, E, A, B, f3, K3, expand( data, 53 ) );
subRound( B, C, D, E, A, f3, K3, expand( data, 54 ) );
subRound( A, B, C, D, E, f3, K3, expand( data, 55 ) );
subRound( E, A, B, C, D, f3, K3, expand( data, 56 ) );
subRound( D, E, A, B, C, f3, K3, expand( data, 57 ) );
subRound( C, D, E, A, B, f3, K3, expand( data, 58 ) );
subRound( B, C, D, E, A, f3, K3, expand( data, 59 ) );
subRound( A, B, C, D, E, f4, K4, expand( data, 60 ) );
subRound( E, A, B, C, D, f4, K4, expand( data, 61 ) );
subRound( D, E, A, B, C, f4, K4, expand( data, 62 ) );
subRound( C, D, E, A, B, f4, K4, expand( data, 63 ) );
subRound( B, C, D, E, A, f4, K4, expand( data, 64 ) );
subRound( A, B, C, D, E, f4, K4, expand( data, 65 ) );
subRound( E, A, B, C, D, f4, K4, expand( data, 66 ) );
subRound( D, E, A, B, C, f4, K4, expand( data, 67 ) );
subRound( C, D, E, A, B, f4, K4, expand( data, 68 ) );
subRound( B, C, D, E, A, f4, K4, expand( data, 69 ) );
subRound( A, B, C, D, E, f4, K4, expand( data, 70 ) );
subRound( E, A, B, C, D, f4, K4, expand( data, 71 ) );
subRound( D, E, A, B, C, f4, K4, expand( data, 72 ) );
subRound( C, D, E, A, B, f4, K4, expand( data, 73 ) );
subRound( B, C, D, E, A, f4, K4, expand( data, 74 ) );
subRound( A, B, C, D, E, f4, K4, expand( data, 75 ) );
subRound( E, A, B, C, D, f4, K4, expand( data, 76 ) );
subRound( D, E, A, B, C, f4, K4, expand( data, 77 ) );
subRound( C, D, E, A, B, f4, K4, expand( data, 78 ) );
subRound( B, C, D, E, A, f4, K4, expand( data, 79 ) );
/* Build message digest */
state[0] += A;
state[1] += B;
state[2] += C;
state[3] += D;
state[4] += E;
}
static void
sha1_block(struct sha1_ctx *ctx, const UINT8 *block)
{
UINT32 data[SHA1_DATA_LENGTH];
int i;
/* Update block count */
if (!++ctx->count_low)
++ctx->count_high;
/* Endian independent conversion */
for (i = 0; i<SHA1_DATA_LENGTH; i++, block += 4)
data[i] = READ_UINT32(block);
sha1_transform(ctx->digest, data);
}
void
sha1_update(struct sha1_ctx *ctx,
unsigned length, const UINT8 *buffer)
{
if (ctx->index)
{ /* Try to fill partial block */
unsigned left = SHA1_DATA_SIZE - ctx->index;
if (length < left)
{
memcpy(ctx->block + ctx->index, buffer, length);
ctx->index += length;
return; /* Finished */
}
else
{
memcpy(ctx->block + ctx->index, buffer, left);
sha1_block(ctx, ctx->block);
buffer += left;
length -= left;
}
}
while (length >= SHA1_DATA_SIZE)
{
sha1_block(ctx, buffer);
buffer += SHA1_DATA_SIZE;
length -= SHA1_DATA_SIZE;
}
ctx->index = length;
if (length)
/* Buffer leftovers */
memcpy(ctx->block, buffer, length);
}
/* Final wrapup - pad to SHA1_DATA_SIZE-byte boundary with the bit pattern
1 0* (64-bit count of bits processed, MSB-first) */
void
sha1_final(struct sha1_ctx *ctx)
{
UINT32 data[SHA1_DATA_LENGTH];
int i;
int words;
i = ctx->index;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
assert(i < SHA1_DATA_SIZE);
ctx->block[i++] = 0x80;
/* Fill rest of word */
for( ; i & 3; i++)
ctx->block[i] = 0;
/* i is now a multiple of the word size 4 */
words = i >> 2;
for (i = 0; i < words; i++)
data[i] = READ_UINT32(ctx->block + 4*i);
if (words > (SHA1_DATA_LENGTH-2))
{ /* No room for length in this block. Process it and
* pad with another one */
for (i = words ; i < SHA1_DATA_LENGTH; i++)
data[i] = 0;
sha1_transform(ctx->digest, data);
for (i = 0; i < (SHA1_DATA_LENGTH-2); i++)
data[i] = 0;
}
else
for (i = words ; i < SHA1_DATA_LENGTH - 2; i++)
data[i] = 0;
/* There are 512 = 2^9 bits in one block */
data[SHA1_DATA_LENGTH-2] = (ctx->count_high << 9) | (ctx->count_low >> 23);
data[SHA1_DATA_LENGTH-1] = (ctx->count_low << 9) | (ctx->index << 3);
sha1_transform(ctx->digest, data);
}
void
sha1_digest(const struct sha1_ctx *ctx,
unsigned length,
UINT8 *digest)
{
unsigned i;
unsigned words;
unsigned leftover;
assert(length <= SHA1_DIGEST_SIZE);
words = length / 4;
leftover = length % 4;
for (i = 0; i < words; i++, digest += 4)
WRITE_UINT32(digest, ctx->digest[i]);
if (leftover)
{
UINT32 word;
unsigned j = leftover;
assert(i < _SHA1_DIGEST_LENGTH);
word = ctx->digest[i];
switch (leftover)
{
default:
/* this is just here to keep the compiler happy; it can never happen */
case 3:
digest[--j] = (word >> 8) & 0xff;
/* Fall through */
case 2:
digest[--j] = (word >> 16) & 0xff;
/* Fall through */
case 1:
digest[--j] = (word >> 24) & 0xff;
}
}
}
-63
View File
@@ -1,63 +0,0 @@
/* sha1.h
*
* The sha1 hash function.
*/
/* nettle, low-level cryptographics library
*
* Copyright 2001 Niels Moeller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef NETTLE_SHA1_H_INCLUDED
#define NETTLE_SHA1_H_INCLUDED
#include "../chdr/coretypes.h"
#define SHA1_DIGEST_SIZE 20
#define SHA1_DATA_SIZE 64
/* Digest is kept internally as 4 32-bit words. */
#define _SHA1_DIGEST_LENGTH 5
struct sha1_ctx
{
UINT32 digest[_SHA1_DIGEST_LENGTH]; /* Message digest */
UINT32 count_low, count_high; /* 64-bit block count */
UINT8 block[SHA1_DATA_SIZE]; /* SHA1 data buffer */
unsigned int index; /* index into buffer */
};
void
sha1_init(struct sha1_ctx *ctx);
void
sha1_update(struct sha1_ctx *ctx,
unsigned length,
const UINT8 *data);
void
sha1_final(struct sha1_ctx *ctx);
void
sha1_digest(const struct sha1_ctx *ctx,
unsigned length,
UINT8 *digest);
#endif /* NETTLE_SHA1_H_INCLUDED */
-161
View File
@@ -1,161 +0,0 @@
/*********************************************************************
* Filename: sha256.c
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Implementation of the SHA-256 hashing algorithm.
SHA-256 is one of the three algorithms in the SHA2
specification. The others, SHA-384 and SHA-512, are not
offered in this implementation.
Algorithm specification can be found here:
* http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf
This implementation uses little endian byte order.
*********************************************************************/
/*************************** HEADER FILES ***************************/
#include <stdlib.h>
#include <string.h>
#include "sha256.h"
#define WORD uint32_t
#define BYTE uint8_t
/****************************** MACROS ******************************/
#define ROTLEFT(a,b) (((a) << (b)) | ((a) >> (32-(b))))
#define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
#define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z)))
#define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
#define EP0(x) (ROTRIGHT(x,2) ^ ROTRIGHT(x,13) ^ ROTRIGHT(x,22))
#define EP1(x) (ROTRIGHT(x,6) ^ ROTRIGHT(x,11) ^ ROTRIGHT(x,25))
#define SIG0(x) (ROTRIGHT(x,7) ^ ROTRIGHT(x,18) ^ ((x) >> 3))
#define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10))
/**************************** VARIABLES *****************************/
static const WORD k[64] = {
0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,
0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,
0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967,
0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,
0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,
0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,
0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
};
/*********************** FUNCTION DEFINITIONS ***********************/
void sha256_transform(SHA256_CTX *ctx, const BYTE data[])
{
WORD a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
for (i = 0, j = 0; i < 16; ++i, j += 4)
m[i] = (data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]);
for ( ; i < 64; ++i)
m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
a = ctx->state[0];
b = ctx->state[1];
c = ctx->state[2];
d = ctx->state[3];
e = ctx->state[4];
f = ctx->state[5];
g = ctx->state[6];
h = ctx->state[7];
for (i = 0; i < 64; ++i) {
t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[i];
t2 = EP0(a) + MAJ(a,b,c);
h = g;
g = f;
f = e;
e = d + t1;
d = c;
c = b;
b = a;
a = t1 + t2;
}
ctx->state[0] += a;
ctx->state[1] += b;
ctx->state[2] += c;
ctx->state[3] += d;
ctx->state[4] += e;
ctx->state[5] += f;
ctx->state[6] += g;
ctx->state[7] += h;
}
void sha256_init(SHA256_CTX *ctx)
{
ctx->datalen = 0;
ctx->bitlen = 0;
ctx->state[0] = 0x6a09e667;
ctx->state[1] = 0xbb67ae85;
ctx->state[2] = 0x3c6ef372;
ctx->state[3] = 0xa54ff53a;
ctx->state[4] = 0x510e527f;
ctx->state[5] = 0x9b05688c;
ctx->state[6] = 0x1f83d9ab;
ctx->state[7] = 0x5be0cd19;
}
void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len)
{
WORD i;
for (i = 0; i < len; ++i) {
ctx->data[ctx->datalen] = data[i];
ctx->datalen++;
if (ctx->datalen == 64) {
sha256_transform(ctx, ctx->data);
ctx->bitlen += 512;
ctx->datalen = 0;
}
}
}
void sha256_final(SHA256_CTX *ctx, BYTE hash[])
{
WORD i;
i = ctx->datalen;
// Pad whatever data is left in the buffer.
if (ctx->datalen < 56) {
ctx->data[i++] = 0x80;
while (i < 56)
ctx->data[i++] = 0x00;
}
else {
ctx->data[i++] = 0x80;
while (i < 64)
ctx->data[i++] = 0x00;
sha256_transform(ctx, ctx->data);
memset(ctx->data, 0, 56);
}
// Append to the padding the total message's length in bits and transform.
ctx->bitlen += ctx->datalen * 8;
ctx->data[63] = (BYTE)(ctx->bitlen);
ctx->data[62] = (BYTE)(ctx->bitlen >> 8);
ctx->data[61] = (BYTE)(ctx->bitlen >> 16);
ctx->data[60] = (BYTE)(ctx->bitlen >> 24);
ctx->data[59] = (BYTE)(ctx->bitlen >> 32);
ctx->data[58] = (BYTE)(ctx->bitlen >> 40);
ctx->data[57] = (BYTE)(ctx->bitlen >> 48);
ctx->data[56] = (BYTE)(ctx->bitlen >> 56);
sha256_transform(ctx, ctx->data);
// Since this implementation uses little endian byte ordering and SHA uses big endian,
// reverse all the bytes when copying the final state to the output hash.
for (i = 0; i < 4; ++i) {
hash[i] = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff;
hash[i + 4] = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff;
hash[i + 8] = (ctx->state[2] >> (24 - i * 8)) & 0x000000ff;
hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0x000000ff;
hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0x000000ff;
hash[i + 20] = (ctx->state[5] >> (24 - i * 8)) & 0x000000ff;
hash[i + 24] = (ctx->state[6] >> (24 - i * 8)) & 0x000000ff;
hash[i + 28] = (ctx->state[7] >> (24 - i * 8)) & 0x000000ff;
}
}
-37
View File
@@ -1,37 +0,0 @@
/*********************************************************************
* Filename: sha256.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding SHA1 implementation.
*********************************************************************/
#ifndef SHA256_H
#define SHA256_H
/*************************** HEADER FILES ***************************/
#include <stddef.h>
#include <stdint.h>
/****************************** MACROS ******************************/
#define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest
/**************************** DATA TYPES ****************************/
/*
typedef uint8_t BYTE; // 8-bit byte
typedef uint32_t WORD; // 32-bit word, change to "long" for 16-bit machines
*/
typedef struct {
uint8_t data[64];
uint32_t datalen;
uint64_t bitlen;
uint32_t state[8];
} SHA256_CTX;
/*********************** FUNCTION DECLARATIONS **********************/
void sha256_init(SHA256_CTX *ctx);
void sha256_update(SHA256_CTX *ctx, const uint8_t data[], size_t len);
void sha256_final(SHA256_CTX *ctx, uint8_t hash[]);
#endif // SHA256_H
+7 -1
View File
@@ -29,6 +29,10 @@
#include <sys/stat.h>
#include <errno.h>
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
#define FindFirstFileExW FindFirstFileExFromAppW
#endif
/* Indicates that d_type field is available in dirent structure */
#define _DIRENT_HAVE_D_TYPE
@@ -613,7 +617,7 @@ dirent_first(
/* Failed to re-open directory: no directory entry in memory */
dirp->cached = 0;
datap = NULL;
dirent_set_errno(GetLastError()); /* Not a valid errno but better than nothing */
}
return datap;
}
@@ -647,6 +651,8 @@ dirent_next(
FindClose (dirp->handle);
dirp->handle = INVALID_HANDLE_VALUE;
p = NULL;
if (GetLastError() != ERROR_NO_MORE_FILES)
dirent_set_errno(GetLastError());
}
} else {
+618
View File
@@ -0,0 +1,618 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _GGPONET_H_
#define _GGPONET_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
// On windows, export at build time and import at runtime.
// ELF systems don't need an explicit export/import.
#ifdef _WIN32
# if defined(GGPO_SHARED_LIB)
# ifdef GGPO_SDK_EXPORT
# define GGPO_API __declspec(dllexport)
# else
# define GGPO_API __declspec(dllimport)
# endif
# else
# define GGPO_API
# endif
#else
# define GGPO_API
#endif
#ifdef __GNUC__
#if defined(_WIN32) && !defined(_WIN64)
#define __cdecl __attribute__((cdecl))
#elif !defined(__cdecl)
#define __cdecl
#endif
#endif
#define GGPO_MAX_PLAYERS 4
#define GGPO_MAX_PREDICTION_FRAMES 8
#define GGPO_MAX_SPECTATORS 32
#define GGPO_SPECTATOR_INPUT_INTERVAL 4
typedef struct GGPOSession GGPOSession;
typedef int GGPOPlayerHandle;
typedef enum {
GGPO_PLAYERTYPE_LOCAL,
GGPO_PLAYERTYPE_REMOTE,
GGPO_PLAYERTYPE_SPECTATOR,
} GGPOPlayerType;
/*
* The GGPOPlayer structure used to describe players in ggpo_add_player
*
* size: Should be set to the sizeof(GGPOPlayer)
*
* type: One of the GGPOPlayerType values describing how inputs should be handled
* Local players must have their inputs updated every frame via
* ggpo_add_local_inputs. Remote players values will come over the
* network.
*
* player_num: The player number. Should be between 1 and the number of players
* In the game (e.g. in a 2 player game, either 1 or 2).
*
* If type == GGPO_PLAYERTYPE_REMOTE:
*
* u.remote.ip_address: The ip address of the ggpo session which will host this
* player.
*
* u.remote.port: The port where udp packets should be sent to reach this player.
* All the local inputs for this session will be sent to this player at
* ip_address:port.
*
*/
typedef struct GGPOPlayer {
int size;
GGPOPlayerType type;
int player_num;
union {
struct {
bool _unused;
} local;
struct {
char ip_address[32];
unsigned short port;
} remote;
} u;
} GGPOPlayer;
typedef struct GGPOLocalEndpoint {
int player_num;
} GGPOLocalEndpoint;
#define GGPO_ERRORLIST \
GGPO_ERRORLIST_ENTRY(GGPO_OK, 0) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_SUCCESS, 0) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_GENERAL_FAILURE, -1) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_INVALID_SESSION, 1) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_INVALID_PLAYER_HANDLE, 2) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_PLAYER_OUT_OF_RANGE, 3) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_PREDICTION_THRESHOLD, 4) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_UNSUPPORTED, 5) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_NOT_SYNCHRONIZED, 6) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_IN_ROLLBACK, 7) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_INPUT_DROPPED, 8) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_PLAYER_DISCONNECTED, 9) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_TOO_MANY_SPECTATORS, 10) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_INVALID_REQUEST, 11) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_INPUT_SIZE_DIFF, 12) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_NETWORK_ERROR, 13) \
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_VERIFICATION_ERROR, 14)
#define GGPO_ERRORLIST_ENTRY(name, value) name = value,
typedef enum {
GGPO_ERRORLIST
} GGPOErrorCode;
#undef GGPO_ERRORLIST_ENTRY
#define GGPO_SUCCEEDED(result) ((result) == GGPO_ERRORCODE_SUCCESS)
#define GGPO_INVALID_HANDLE (-1)
/*
* The GGPOEventCode enumeration describes what type of event just happened.
*
* GGPO_EVENTCODE_CONNECTED_TO_PEER - Handshake with the game running on the
* other side of the network has been completed.
*
* GGPO_EVENTCODE_SYNCHRONIZING_WITH_PEER - Beginning the synchronization
* process with the client on the other end of the networking. The count
* and total fields in the u.synchronizing struct of the GGPOEvent
* object indicate progress.
*
* GGPO_EVENTCODE_SYNCHRONIZED_WITH_PEER - The synchronziation with this
* peer has finished.
*
* GGPO_EVENTCODE_RUNNING - All the clients have synchronized. You may begin
* sending inputs with ggpo_synchronize_inputs.
*
* GGPO_EVENTCODE_DISCONNECTED_FROM_PEER - The network connection on
* the other end of the network has closed.
*
* GGPO_EVENTCODE_TIMESYNC - The time synchronziation code has determined
* that this client is too far ahead of the other one and should slow
* down to ensure fairness. The u.timesync.frames_ahead parameter in
* the GGPOEvent object indicates how many frames the client is.
*
*/
typedef enum {
GGPO_EVENTCODE_CONNECTED_TO_PEER = 1000,
GGPO_EVENTCODE_SYNCHRONIZING_WITH_PEER = 1001,
GGPO_EVENTCODE_SYNCHRONIZED_WITH_PEER = 1002,
GGPO_EVENTCODE_RUNNING = 1003,
GGPO_EVENTCODE_DISCONNECTED_FROM_PEER = 1004,
GGPO_EVENTCODE_TIMESYNC = 1005,
GGPO_EVENTCODE_CONNECTION_INTERRUPTED = 1006,
GGPO_EVENTCODE_CONNECTION_RESUMED = 1007,
} GGPOEventCode;
/*
* The GGPOEvent structure contains an asynchronous event notification sent
* by the on_event callback. See GGPOEventCode, above, for a detailed
* explanation of each event.
*/
typedef struct {
GGPOEventCode code;
union {
struct {
GGPOPlayerHandle player;
} connected;
struct {
GGPOPlayerHandle player;
int count;
int total;
} synchronizing;
struct {
GGPOPlayerHandle player;
} synchronized;
struct {
GGPOPlayerHandle player;
} disconnected;
struct {
int frames_ahead;
} timesync;
struct {
GGPOPlayerHandle player;
int disconnect_timeout;
} connection_interrupted;
struct {
GGPOPlayerHandle player;
} connection_resumed;
} u;
} GGPOEvent;
/*
* The GGPOSessionCallbacks structure contains the callback functions that
* your application must implement. GGPO.net will periodically call these
* functions during the game. All callback functions must be implemented.
*/
typedef struct {
/*
* begin_game callback - This callback has been deprecated. You must
* implement it, but should ignore the 'game' parameter.
*/
bool (__cdecl *begin_game)(const char *game);
/*
* save_game_state - The client should allocate a buffer, copy the
* entire contents of the current game state into it, and copy the
* length into the *len parameter. Optionally, the client can compute
* a checksum of the data and store it in the *checksum argument.
*/
bool (__cdecl *save_game_state)(unsigned char **buffer, int *len, int *checksum, int frame);
/*
* load_game_state - GGPO.net will call this function at the beginning
* of a rollback. The buffer and len parameters contain a previously
* saved state returned from the save_game_state function. The client
* should make the current game state match the state contained in the
* buffer.
*/
bool (__cdecl *load_game_state)(unsigned char *buffer, int len);
/*
* log_game_state - Used in diagnostic testing. The client should use
* the ggpo_log function to write the contents of the specified save
* state in a human readible form.
*/
bool (__cdecl *log_game_state)(char *filename, unsigned char *buffer, int len);
/*
* free_buffer - Frees a game state allocated in save_game_state. You
* should deallocate the memory contained in the buffer.
*/
void (__cdecl *free_buffer)(void *buffer);
/*
* advance_frame - Called during a rollback. You should advance your game
* state by exactly one frame. Before each frame, call ggpo_synchronize_input
* to retrieve the inputs you should use for that frame. After each frame,
* you should call ggpo_advance_frame to notify GGPO.net that you're
* finished.
*
* The flags parameter is reserved. It can safely be ignored at this time.
*/
bool (__cdecl *advance_frame)(int flags);
/*
* on_event - Notification that something has happened. See the GGPOEventCode
* structure above for more information.
*/
bool (__cdecl *on_event)(GGPOEvent *info);
/*
* on_message - Delivers an application message. Allows arbitrary data to be
* exchanged with peers. This callback is optional.
*/
void (__cdecl *on_message)(unsigned char *msg, int len);
} GGPOSessionCallbacks;
/*
* The GGPONetworkStats function contains some statistics about the current
* session.
*
* network.send_queue_len - The length of the queue containing UDP packets
* which have not yet been acknowledged by the end client. The length of
* the send queue is a rough indication of the quality of the connection.
* The longer the send queue, the higher the round-trip time between the
* clients. The send queue will also be longer than usual during high
* packet loss situations.
*
* network.recv_queue_len - The number of inputs currently buffered by the
* GGPO.net network layer which have yet to be validated. The length of
* the prediction queue is roughly equal to the current frame number
* minus the frame number of the last packet in the remote queue.
*
* network.ping - The roundtrip packet transmission time as calcuated
* by GGPO.net. This will be roughly equal to the actual round trip
* packet transmission time + 2 the interval at which you call ggpo_idle
* or ggpo_advance_frame.
*
* network.kbps_sent - The estimated bandwidth used between the two
* clients, in kilobits per second.
*
* timesync.local_frames_behind - The number of frames GGPO.net calculates
* that the local client is behind the remote client at this instant in
* time. For example, if at this instant the current game client is running
* frame 1002 and the remote game client is running frame 1009, this value
* will mostly likely roughly equal 7.
*
* timesync.remote_frames_behind - The same as local_frames_behind, but
* calculated from the perspective of the remote player.
*
*/
typedef struct GGPONetworkStats {
struct {
int send_queue_len;
int recv_queue_len;
int ping;
int kbps_sent;
} network;
struct {
int local_frames_behind;
int remote_frames_behind;
} timesync;
struct {
int predicted_frames;
} sync;
} GGPONetworkStats;
/*
* ggpo_start_session --
*
* Used to being a new GGPO.net session. The ggpo object returned by ggpo_start_session
* uniquely identifies the state for this session and should be passed to all other
* functions.
*
* session - An out parameter to the new ggpo session object.
*
* cb - A GGPOSessionCallbacks structure which contains the callbacks you implement
* to help GGPO.net synchronize the two games. You must implement all functions in
* cb, even if they do nothing but 'return true';
*
* game - The name of the game. This is used internally for GGPO for logging purposes only.
*
* num_players - The number of players which will be in this game. The number of players
* per session is fixed. If you need to change the number of players or any player
* disconnects, you must start a new session.
*
* input_size - The size of the game inputs which will be passsed to ggpo_add_local_input.
*
* local_port - The port GGPO should bind to for UDP traffic.
*
* verification - Some optional data that will be matched with the peers during initial sync.
* Can be set to null if verification_size is zero. This can be used to check that all peers are
* running the same version of the application and of the game, are using the same settings, etc.
*
* verification_size - Size of the verification data. Can be set to zero to not exchange verification data.
* Maximum size is 256 bytes.
*/
GGPO_API GGPOErrorCode __cdecl ggpo_start_session(GGPOSession **session,
GGPOSessionCallbacks *cb,
const char *game,
int num_players,
int input_size,
unsigned short localport,
const void *verification,
int verification_size);
/*
* ggpo_add_player --
*
* Must be called for each player in the session (e.g. in a 3 player session, must
* be called 3 times).
*
* player - A GGPOPlayer struct used to describe the player.
*
* handle - An out parameter to a handle used to identify this player in the future.
* (e.g. in the on_event callbacks).
*/
GGPO_API GGPOErrorCode __cdecl ggpo_add_player(GGPOSession *session,
GGPOPlayer *player,
GGPOPlayerHandle *handle);
/*
* ggpo_start_synctest --
*
* Used to being a new GGPO.net sync test session. During a sync test, every
* frame of execution is run twice: once in prediction mode and once again to
* verify the result of the prediction. If the checksums of your save states
* do not match, the test is aborted.
*
* cb - A GGPOSessionCallbacks structure which contains the callbacks you implement
* to help GGPO.net synchronize the two games. You must implement all functions in
* cb, even if they do nothing but 'return true';
*
* game - The name of the game. This is used internally for GGPO for logging purposes only.
*
* num_players - The number of players which will be in this game. The number of players
* per session is fixed. If you need to change the number of players or any player
* disconnects, you must start a new session.
*
* input_size - The size of the game inputs which will be passsed to ggpo_add_local_input.
*
* frames - The number of frames to run before verifying the prediction. The
* recommended value is 1.
*
*/
GGPO_API GGPOErrorCode __cdecl ggpo_start_synctest(GGPOSession **session,
GGPOSessionCallbacks *cb,
const char *game,
int num_players,
int input_size,
int frames);
/*
* ggpo_start_spectating --
*
* Start a spectator session.
*
* cb - A GGPOSessionCallbacks structure which contains the callbacks you implement
* to help GGPO.net synchronize the two games. You must implement all functions in
* cb, even if they do nothing but 'return true';
*
* game - The name of the game. This is used internally for GGPO for logging purposes only.
*
* num_players - The number of players which will be in this game. The number of players
* per session is fixed. If you need to change the number of players or any player
* disconnects, you must start a new session.
*
* input_size - The size of the game inputs which will be passsed to ggpo_add_local_input.
*
* local_port - The port GGPO should bind to for UDP traffic.
*
* host_ip - The IP address of the host who will serve you the inputs for the game. Any
* player partcipating in the session can serve as a host.
*
* host_port - The port of the session on the host
*
* verification - Some optional data that will be matched with the peers during initial sync.
* Can be set to null if verification_size is zero. This can be used to check that all peers are
* running the same version of the application and of the game, are using the same settings, etc.
*
* verification_size - Size of the verification data. Can be set to zero to not exchange verification data.
* Maximum size is 256 bytes.
*/
GGPO_API GGPOErrorCode __cdecl ggpo_start_spectating(GGPOSession **session,
GGPOSessionCallbacks *cb,
const char *game,
int num_players,
int input_size,
unsigned short local_port,
char *host_ip,
unsigned short host_port,
const void *verification,
int verification_size);
/*
* ggpo_close_session --
* Used to close a session. You must call ggpo_close_session to
* free the resources allocated in ggpo_start_session.
*/
GGPO_API GGPOErrorCode __cdecl ggpo_close_session(GGPOSession *);
/*
* ggpo_set_frame_delay --
*
* Change the amount of frames ggpo will delay local input. Must be called
* before the first call to ggpo_synchronize_input.
*/
GGPO_API GGPOErrorCode __cdecl ggpo_set_frame_delay(GGPOSession *,
GGPOPlayerHandle player,
int frame_delay);
/*
* ggpo_idle --
* Should be called periodically by your application to give GGPO.net
* a chance to do some work. Most packet transmissions and rollbacks occur
* in ggpo_idle.
*
* timeout - The amount of time GGPO.net is allowed to spend in this function,
* in milliseconds.
*/
GGPO_API GGPOErrorCode __cdecl ggpo_idle(GGPOSession *,
int timeout);
/*
* ggpo_add_local_input --
*
* Used to notify GGPO.net of inputs that should be trasmitted to remote
* players. ggpo_add_local_input must be called once every frame for
* all player of type GGPO_PLAYERTYPE_LOCAL.
*
* player - The player handle returned for this player when you called
* ggpo_add_local_player.
*
* values - The controller inputs for this player.
*
* size - The size of the controller inputs. This must be exactly equal to the
* size passed into ggpo_start_session.
*/
GGPO_API GGPOErrorCode __cdecl ggpo_add_local_input(GGPOSession *,
GGPOPlayerHandle player,
void *values,
int size);
/*
* ggpo_synchronize_input --
*
* You should call ggpo_synchronize_input before every frame of execution,
* including those frames which happen during rollback.
*
* values - When the function returns, the values parameter will contain
* inputs for this frame for all players. The values array must be at
* least (size * players) large.
*
* size - The size of the values array.
*
* disconnect_flags - Indicated whether the input in slot (1 << flag) is
* valid. If a player has disconnected, the input in the values array for
* that player will be zeroed and the i-th flag will be set. For example,
* if only player 3 has disconnected, disconnect flags will be 8 (i.e. 1 << 3).
*/
GGPO_API GGPOErrorCode __cdecl ggpo_synchronize_input(GGPOSession *,
void *values,
int size,
int *disconnect_flags);
/*
* ggpo_disconnect_player --
*
* Disconnects a remote player from a game. Will return GGPO_ERRORCODE_PLAYER_DISCONNECTED
* if you try to disconnect a player who has already been disconnected.
*/
GGPO_API GGPOErrorCode __cdecl ggpo_disconnect_player(GGPOSession *,
GGPOPlayerHandle player);
/*
* ggpo_advance_frame --
*
* You should call ggpo_advance_frame to notify GGPO.net that you have
* advanced your gamestate by a single frame. You should call this everytime
* you advance the gamestate by a frame, even during rollbacks. GGPO.net
* may call your save_state callback before this function returns.
*/
GGPO_API GGPOErrorCode __cdecl ggpo_advance_frame(GGPOSession *);
/*
* ggpo_get_network_stats --
*
* Used to fetch some statistics about the quality of the network connection.
*
* player - The player handle returned from the ggpo_add_player function you used
* to add the remote player.
*
* stats - Out parameter to the network statistics.
*/
GGPO_API GGPOErrorCode __cdecl ggpo_get_network_stats(GGPOSession *,
GGPOPlayerHandle player,
GGPONetworkStats *stats);
/*
* ggpo_set_disconnect_timeout --
*
* Sets the disconnect timeout. The session will automatically disconnect
* from a remote peer if it has not received a packet in the timeout window.
* You will be notified of the disconnect via a GGPO_EVENTCODE_DISCONNECTED_FROM_PEER
* event.
*
* Setting a timeout value of 0 will disable automatic disconnects.
*
* timeout - The time in milliseconds to wait before disconnecting a peer.
*/
GGPO_API GGPOErrorCode __cdecl ggpo_set_disconnect_timeout(GGPOSession *,
int timeout);
/*
* ggpo_set_disconnect_notify_start --
*
* The time to wait before the first GGPO_EVENTCODE_NETWORK_INTERRUPTED timeout
* will be sent.
*
* timeout - The amount of time which needs to elapse without receiving a packet
* before the GGPO_EVENTCODE_NETWORK_INTERRUPTED event is sent.
*/
GGPO_API GGPOErrorCode __cdecl ggpo_set_disconnect_notify_start(GGPOSession *,
int timeout);
/*
* ggpo_log --
*
* Used to write to the ggpo.net log. In the current versions of the
* SDK, a log file is only generated if the "quark.log" environment
* variable is set to 1. This will change in future versions of the
* SDK.
*/
GGPO_API void __cdecl ggpo_log(GGPOSession *,
const char *fmt, ...);
/*
* ggpo_logv --
*
* A varargs compatible version of ggpo_log. See ggpo_log for
* more details.
*/
GGPO_API void __cdecl ggpo_logv(GGPOSession *,
const char *fmt,
va_list args);
/*
* ggpo_send_message --
*
* Sends application-specific data to other peers. The message is
* delivered by the on_user_message callback.
* If spectators is true, the message is also sent to spectators.
*/
GGPO_API GGPOErrorCode __cdecl ggpo_send_message(GGPOSession *,
const void *msg,
int len,
bool spectators);
#ifdef __cplusplus
};
#endif
#endif
@@ -0,0 +1,34 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _BACKEND_H
#define _BACKEND_H
#include "../ggpo_types.h"
#include "ggponet.h"
struct GGPOSession {
virtual ~GGPOSession() { }
virtual GGPOErrorCode DoPoll(int timeout) { return GGPO_OK; }
virtual GGPOErrorCode AddPlayer(GGPOPlayer *player, GGPOPlayerHandle *handle) = 0;
virtual GGPOErrorCode AddLocalInput(GGPOPlayerHandle player, void *values, int size) = 0;
virtual GGPOErrorCode SyncInput(void *values, int size, int *disconnect_flags) = 0;
virtual GGPOErrorCode IncrementFrame(void) { return GGPO_OK; }
virtual GGPOErrorCode DisconnectPlayer(GGPOPlayerHandle handle) { return GGPO_OK; }
virtual GGPOErrorCode GetNetworkStats(GGPONetworkStats *stats, GGPOPlayerHandle handle) { return GGPO_OK; }
virtual GGPOErrorCode Logv(const char *fmt, va_list list) { ::Logv(fmt, list); return GGPO_OK; }
virtual GGPOErrorCode SetFrameDelay(GGPOPlayerHandle player, int delay) { return GGPO_ERRORCODE_UNSUPPORTED; }
virtual GGPOErrorCode SetDisconnectTimeout(int timeout) { return GGPO_ERRORCODE_UNSUPPORTED; }
virtual GGPOErrorCode SetDisconnectNotifyStart(int timeout) { return GGPO_ERRORCODE_UNSUPPORTED; }
virtual GGPOErrorCode SendMessage(const void *msg, int len, bool spectators) { return GGPO_ERRORCODE_UNSUPPORTED; }
};
typedef struct GGPOSession Quark, IQuarkBackend; /* XXX: nuke this */
#endif
+664
View File
@@ -0,0 +1,664 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#include "p2p.h"
#include <chrono>
#include <thread>
static const int RECOMMENDATION_INTERVAL = 240;
static const int DEFAULT_DISCONNECT_TIMEOUT = 5000;
static const int DEFAULT_DISCONNECT_NOTIFY_START = 750;
Peer2PeerBackend::Peer2PeerBackend(GGPOSessionCallbacks *cb,
const char *gamename,
uint16 localport,
int num_players,
int input_size,
const void *verification,
int verification_size) :
_sync(_local_connect_status),
_endpoints(nullptr),
_num_spectators(0),
_input_size(input_size),
_num_players(num_players),
_next_spectator_frame(0),
_disconnect_timeout(DEFAULT_DISCONNECT_TIMEOUT),
_disconnect_notify_start(DEFAULT_DISCONNECT_NOTIFY_START)
{
_callbacks = *cb;
_synchronizing = true;
_next_recommended_sleep = 0;
/*
* Initialize the synchronziation layer
*/
Sync::Config config = { 0 };
config.num_players = num_players;
config.input_size = input_size;
config.callbacks = _callbacks;
config.num_prediction_frames = MAX_PREDICTION_FRAMES;
_sync.Init(config);
/*
* Initialize the UDP port
*/
_udp.Init(localport, &_poll, this);
_endpoints = new UdpProtocol[_num_players];
for (int i = 0; i < _num_players; i++)
_endpoints[i].SetVerificationData(verification, verification_size);
memset(_local_connect_status, 0, sizeof(_local_connect_status));
for (unsigned i = 0; i < ARRAY_SIZE(_local_connect_status); i++) {
_local_connect_status[i].last_frame = -1;
}
/*
* Preload the ROM
*/
_callbacks.begin_game(gamename);
}
Peer2PeerBackend::~Peer2PeerBackend()
{
delete [] _endpoints;
}
void
Peer2PeerBackend::AddRemotePlayer(char *ip,
uint16 port,
int queue)
{
/*
* Start the state machine (xxx: no)
*/
_synchronizing = true;
_endpoints[queue].Init(&_udp, _poll, queue, ip, port, _local_connect_status);
_endpoints[queue].SetDisconnectTimeout(_disconnect_timeout);
_endpoints[queue].SetDisconnectNotifyStart(_disconnect_notify_start);
_endpoints[queue].Synchronize();
}
GGPOErrorCode Peer2PeerBackend::AddSpectator(char *ip,
uint16 port)
{
if (_num_spectators == GGPO_MAX_SPECTATORS) {
return GGPO_ERRORCODE_TOO_MANY_SPECTATORS;
}
/*
* Currently, we can only add spectators before the game starts.
*/
if (!_synchronizing) {
return GGPO_ERRORCODE_INVALID_REQUEST;
}
int queue = _num_spectators++;
_spectators[queue].Init(&_udp, _poll, queue + 1000, ip, port, _local_connect_status);
_spectators[queue].SetDisconnectTimeout(_disconnect_timeout);
_spectators[queue].SetDisconnectNotifyStart(_disconnect_notify_start);
_spectators[queue].Synchronize();
return GGPO_OK;
}
GGPOErrorCode
Peer2PeerBackend::DoPoll(int timeout)
{
if (!_sync.InRollback()) {
_poll.Pump(0);
PollUdpProtocolEvents();
if (!_synchronizing) {
_sync.CheckSimulation(timeout);
// notify all of our endpoints of their local frame number for their
// next connection quality report
int current_frame = _sync.GetFrameCount();
for (int i = 0; i < _num_players; i++) {
_endpoints[i].SetLocalFrameNumber(current_frame);
}
int total_min_confirmed;
if (_num_players <= 2) {
total_min_confirmed = Poll2Players(current_frame);
} else {
total_min_confirmed = PollNPlayers(current_frame);
}
Log("last confirmed frame in p2p backend is %d.\n", total_min_confirmed);
if (total_min_confirmed >= 0) {
ASSERT(total_min_confirmed != INT_MAX);
if (_num_spectators > 0) {
while (_next_spectator_frame <= total_min_confirmed) {
Log("pushing frame %d to spectators.\n", _next_spectator_frame);
GameInput input;
input.frame = _next_spectator_frame;
input.size = _input_size * _num_players;
_sync.GetConfirmedInputs(input.bits, _input_size * _num_players, _next_spectator_frame);
for (int i = 0; i < _num_spectators; i++) {
_spectators[i].SendInput(input);
}
_next_spectator_frame++;
}
}
Log("setting confirmed frame in sync to %d.\n", total_min_confirmed);
_sync.SetLastConfirmedFrame(total_min_confirmed);
}
// send timesync notifications if now is the proper time
if (current_frame > _next_recommended_sleep) {
int interval = 0;
for (int i = 0; i < _num_players; i++) {
interval = MAX(interval, _endpoints[i].RecommendFrameDelay());
}
if (interval > 0) {
GGPOEvent info;
info.code = GGPO_EVENTCODE_TIMESYNC;
info.u.timesync.frames_ahead = interval;
_callbacks.on_event(&info);
_next_recommended_sleep = current_frame + RECOMMENDATION_INTERVAL;
}
}
// XXX: this is obviously a farce...
if (timeout)
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
return GGPO_OK;
}
int Peer2PeerBackend::Poll2Players(int current_frame)
{
int i;
// discard confirmed frames as appropriate
int total_min_confirmed = MAX_INT;
for (i = 0; i < _num_players; i++) {
bool queue_connected = true;
if (_endpoints[i].IsRunning()) {
int ignore;
queue_connected = _endpoints[i].GetPeerConnectStatus(i, &ignore);
}
if (!_local_connect_status[i].disconnected) {
total_min_confirmed = MIN(_local_connect_status[i].last_frame, total_min_confirmed);
}
Log(" local endp: connected = %d, last_received = %d, total_min_confirmed = %d.\n", !_local_connect_status[i].disconnected, _local_connect_status[i].last_frame, total_min_confirmed);
if (!queue_connected && !_local_connect_status[i].disconnected) {
Log("disconnecting i %d by remote request.\n", i);
DisconnectPlayerQueue(i, total_min_confirmed);
}
Log(" total_min_confirmed = %d.\n", total_min_confirmed);
}
return total_min_confirmed;
}
int Peer2PeerBackend::PollNPlayers(int current_frame)
{
int i, queue, last_received;
// discard confirmed frames as appropriate
int total_min_confirmed = MAX_INT;
for (queue = 0; queue < _num_players; queue++) {
bool queue_connected = true;
int queue_min_confirmed = MAX_INT;
Log("considering queue %d.\n", queue);
for (i = 0; i < _num_players; i++) {
// we're going to do a lot of logic here in consideration of endpoint i.
// keep accumulating the minimum confirmed point for all n*n packets and
// throw away the rest.
if (_endpoints[i].IsRunning()) {
bool connected = _endpoints[i].GetPeerConnectStatus(queue, &last_received);
queue_connected = queue_connected && connected;
queue_min_confirmed = MIN(last_received, queue_min_confirmed);
Log(" endpoint %d: connected = %d, last_received = %d, queue_min_confirmed = %d.\n", i, connected, last_received, queue_min_confirmed);
} else {
Log(" endpoint %d: ignoring... not running.\n", i);
}
}
// merge in our local status only if we're still connected!
if (!_local_connect_status[queue].disconnected) {
queue_min_confirmed = MIN(_local_connect_status[queue].last_frame, queue_min_confirmed);
}
Log(" local endp: connected = %d, last_received = %d, queue_min_confirmed = %d.\n", !_local_connect_status[queue].disconnected, _local_connect_status[queue].last_frame, queue_min_confirmed);
if (queue_connected) {
total_min_confirmed = MIN(queue_min_confirmed, total_min_confirmed);
} else {
// check to see if this disconnect notification is further back than we've been before. If
// so, we need to re-adjust. This can happen when we detect our own disconnect at frame n
// and later receive a disconnect notification for frame n-1.
if (!_local_connect_status[queue].disconnected || _local_connect_status[queue].last_frame > queue_min_confirmed) {
Log("disconnecting queue %d by remote request.\n", queue);
DisconnectPlayerQueue(queue, queue_min_confirmed);
}
}
Log(" total_min_confirmed = %d.\n", total_min_confirmed);
}
return total_min_confirmed;
}
GGPOErrorCode
Peer2PeerBackend::AddPlayer(GGPOPlayer *player,
GGPOPlayerHandle *handle)
{
if (player->type == GGPO_PLAYERTYPE_SPECTATOR) {
return AddSpectator(player->u.remote.ip_address, player->u.remote.port);
}
int queue = player->player_num - 1;
if (player->player_num < 1 || player->player_num > _num_players) {
return GGPO_ERRORCODE_PLAYER_OUT_OF_RANGE;
}
*handle = QueueToPlayerHandle(queue);
if (player->type == GGPO_PLAYERTYPE_REMOTE) {
AddRemotePlayer(player->u.remote.ip_address, player->u.remote.port, queue);
}
return GGPO_OK;
}
GGPOErrorCode
Peer2PeerBackend::AddLocalInput(GGPOPlayerHandle player,
void *values,
int size)
{
int queue;
GameInput input;
GGPOErrorCode result;
if (_sync.InRollback()) {
return GGPO_ERRORCODE_IN_ROLLBACK;
}
if (_synchronizing) {
return GGPO_ERRORCODE_NOT_SYNCHRONIZED;
}
result = PlayerHandleToQueue(player, &queue);
if (!GGPO_SUCCEEDED(result)) {
return result;
}
input.init(-1, (char *)values, size);
// Feed the input for the current frame into the synchronzation layer.
if (!_sync.AddLocalInput(queue, input)) {
return GGPO_ERRORCODE_PREDICTION_THRESHOLD;
}
if (input.frame != GameInput::NullFrame) { // xxx: <- comment why this is the case
// Update the local connect status state to indicate that we've got a
// confirmed local frame for this player. this must come first so it
// gets incorporated into the next packet we send.
Log("setting local connect status for local queue %d to %d", queue, input.frame);
_local_connect_status[queue].last_frame = input.frame;
// Send the input to all the remote players.
for (int i = 0; i < _num_players; i++) {
if (_endpoints[i].IsInitialized()) {
_endpoints[i].SendInput(input);
}
}
}
return GGPO_OK;
}
GGPOErrorCode
Peer2PeerBackend::SyncInput(void *values,
int size,
int *disconnect_flags)
{
int flags;
// Wait until we've started to return inputs.
if (_synchronizing) {
return GGPO_ERRORCODE_NOT_SYNCHRONIZED;
}
flags = _sync.SynchronizeInputs(values, size);
if (disconnect_flags) {
*disconnect_flags = flags;
}
return GGPO_OK;
}
GGPOErrorCode
Peer2PeerBackend::IncrementFrame(void)
{
Log("End of frame (%d)...\n", _sync.GetFrameCount());
_sync.IncrementFrame();
DoPoll(0);
PollSyncEvents();
return GGPO_OK;
}
void
Peer2PeerBackend::PollSyncEvents(void)
{
Sync::Event e;
while (_sync.GetEvent(e)) {
OnSyncEvent(e);
}
return;
}
void
Peer2PeerBackend::PollUdpProtocolEvents(void)
{
UdpProtocol::Event evt;
for (int i = 0; i < _num_players; i++) {
while (_endpoints[i].GetEvent(evt)) {
OnUdpProtocolPeerEvent(evt, i);
}
}
for (int i = 0; i < _num_spectators; i++) {
while (_spectators[i].GetEvent(evt)) {
OnUdpProtocolSpectatorEvent(evt, i);
}
}
}
void
Peer2PeerBackend::OnUdpProtocolPeerEvent(UdpProtocol::Event &evt, int queue)
{
OnUdpProtocolEvent(evt, QueueToPlayerHandle(queue));
switch (evt.type) {
case UdpProtocol::Event::Input:
if (!_local_connect_status[queue].disconnected) {
int current_remote_frame = _local_connect_status[queue].last_frame;
int new_remote_frame = evt.u.input.input.frame;
ASSERT(current_remote_frame == -1 || new_remote_frame == (current_remote_frame + 1));
_sync.AddRemoteInput(queue, evt.u.input.input);
// Notify the other endpoints which frame we received from a peer
Log("setting remote connect status for queue %d to %d\n", queue, evt.u.input.input.frame);
_local_connect_status[queue].last_frame = evt.u.input.input.frame;
}
break;
case UdpProtocol::Event::Disconnected:
DisconnectPlayer(QueueToPlayerHandle(queue));
break;
case UdpProtocol::Event::AppData:
if (evt.u.app_data.spectators)
for (int i = 0; i < _num_spectators; i++)
if (_spectators[i].IsInitialized())
_spectators[i].SendAppData(evt.u.app_data.data, evt.u.app_data.size, true);
Log("calling on_message callback with %d bytes", evt.u.app_data.size);
if (_callbacks.on_message != nullptr)
_callbacks.on_message(evt.u.app_data.data, evt.u.app_data.size);
break;
default:
break;
}
}
void
Peer2PeerBackend::OnUdpProtocolSpectatorEvent(UdpProtocol::Event &evt, int queue)
{
GGPOPlayerHandle handle = QueueToSpectatorHandle(queue);
OnUdpProtocolEvent(evt, handle);
if (evt.type == UdpProtocol::Event::Disconnected)
{
_spectators[queue].Disconnect();
GGPOEvent info;
info.code = GGPO_EVENTCODE_DISCONNECTED_FROM_PEER;
info.u.disconnected.player = handle;
_callbacks.on_event(&info);
}
}
void
Peer2PeerBackend::OnUdpProtocolEvent(UdpProtocol::Event &evt, GGPOPlayerHandle handle)
{
GGPOEvent info;
switch (evt.type) {
case UdpProtocol::Event::Connected:
info.code = GGPO_EVENTCODE_CONNECTED_TO_PEER;
info.u.connected.player = handle;
_callbacks.on_event(&info);
break;
case UdpProtocol::Event::Synchronizing:
info.code = GGPO_EVENTCODE_SYNCHRONIZING_WITH_PEER;
info.u.synchronizing.player = handle;
info.u.synchronizing.count = evt.u.synchronizing.count;
info.u.synchronizing.total = evt.u.synchronizing.total;
_callbacks.on_event(&info);
break;
case UdpProtocol::Event::Synchronzied:
info.code = GGPO_EVENTCODE_SYNCHRONIZED_WITH_PEER;
info.u.synchronized.player = handle;
_callbacks.on_event(&info);
CheckInitialSync();
break;
case UdpProtocol::Event::NetworkInterrupted:
info.code = GGPO_EVENTCODE_CONNECTION_INTERRUPTED;
info.u.connection_interrupted.player = handle;
info.u.connection_interrupted.disconnect_timeout = evt.u.network_interrupted.disconnect_timeout;
_callbacks.on_event(&info);
break;
case UdpProtocol::Event::NetworkResumed:
info.code = GGPO_EVENTCODE_CONNECTION_RESUMED;
info.u.connection_resumed.player = handle;
_callbacks.on_event(&info);
break;
default:
break;
}
}
/*
* Called only as the result of a local decision to disconnect. The remote
* decisions to disconnect are a result of us parsing the peer_connect_settings
* blob in every endpoint periodically.
*/
GGPOErrorCode
Peer2PeerBackend::DisconnectPlayer(GGPOPlayerHandle player)
{
int queue;
GGPOErrorCode result;
result = PlayerHandleToQueue(player, &queue);
if (!GGPO_SUCCEEDED(result)) {
return result;
}
if (_local_connect_status[queue].disconnected) {
return GGPO_ERRORCODE_PLAYER_DISCONNECTED;
}
if (!_endpoints[queue].IsInitialized()) {
int current_frame = _sync.GetFrameCount();
// xxx: we should be tracking who the local player is, but for now assume
// that if the endpoint is not initalized, this must be the local player.
Log("Disconnecting local player %d at frame %d by user request.\n", queue, _local_connect_status[queue].last_frame);
for (int i = 0; i < _num_players; i++) {
if (_endpoints[i].IsInitialized()) {
DisconnectPlayerQueue(i, current_frame);
}
}
} else {
Log("Disconnecting queue %d at frame %d by user request.\n", queue, _local_connect_status[queue].last_frame);
DisconnectPlayerQueue(queue, _local_connect_status[queue].last_frame);
}
return GGPO_OK;
}
void
Peer2PeerBackend::DisconnectPlayerQueue(int queue, int syncto)
{
GGPOEvent info;
int framecount = _sync.GetFrameCount();
_endpoints[queue].Disconnect();
Log("Changing queue %d local connect status for last frame from %d to %d on disconnect request (current: %d).\n",
queue, _local_connect_status[queue].last_frame, syncto, framecount);
_local_connect_status[queue].disconnected = 1;
_local_connect_status[queue].last_frame = syncto;
if (syncto != GameInput::NullFrame && syncto < framecount) {
Log("adjusting simulation to account for the fact that %d disconnected @ %d.\n", queue, syncto);
_sync.AdjustSimulation(syncto);
Log("finished adjusting simulation.\n");
}
info.code = GGPO_EVENTCODE_DISCONNECTED_FROM_PEER;
info.u.disconnected.player = QueueToPlayerHandle(queue);
_callbacks.on_event(&info);
CheckInitialSync();
}
GGPOErrorCode
Peer2PeerBackend::GetNetworkStats(GGPONetworkStats *stats, GGPOPlayerHandle player)
{
int queue;
GGPOErrorCode result;
result = PlayerHandleToQueue(player, &queue);
if (!GGPO_SUCCEEDED(result)) {
return result;
}
memset(stats, 0, sizeof *stats);
_endpoints[queue].GetNetworkStats(stats);
stats->sync.predicted_frames = _sync.GetPredictedFrames();
return GGPO_OK;
}
GGPOErrorCode
Peer2PeerBackend::SetFrameDelay(GGPOPlayerHandle player, int delay)
{
int queue;
GGPOErrorCode result;
result = PlayerHandleToQueue(player, &queue);
if (!GGPO_SUCCEEDED(result)) {
return result;
}
_sync.SetFrameDelay(queue, delay);
return GGPO_OK;
}
GGPOErrorCode
Peer2PeerBackend::SetDisconnectTimeout(int timeout)
{
_disconnect_timeout = timeout;
for (int i = 0; i < _num_players; i++) {
if (_endpoints[i].IsInitialized()) {
_endpoints[i].SetDisconnectTimeout(_disconnect_timeout);
}
}
return GGPO_OK;
}
GGPOErrorCode
Peer2PeerBackend::SetDisconnectNotifyStart(int timeout)
{
_disconnect_notify_start = timeout;
for (int i = 0; i < _num_players; i++) {
if (_endpoints[i].IsInitialized()) {
_endpoints[i].SetDisconnectNotifyStart(_disconnect_notify_start);
}
}
return GGPO_OK;
}
GGPOErrorCode
Peer2PeerBackend::PlayerHandleToQueue(GGPOPlayerHandle player, int *queue)
{
int offset = ((int)player - 1);
if (offset < 0 || offset >= _num_players) {
return GGPO_ERRORCODE_INVALID_PLAYER_HANDLE;
}
*queue = offset;
return GGPO_OK;
}
void
Peer2PeerBackend::OnMsg(sockaddr_in &from, UdpMsg *msg, int len)
{
for (int i = 0; i < _num_players; i++) {
if (_endpoints[i].HandlesMsg(from, msg)) {
_endpoints[i].OnMsg(msg, len);
return;
}
}
for (int i = 0; i < _num_spectators; i++) {
if (_spectators[i].HandlesMsg(from, msg)) {
_spectators[i].OnMsg(msg, len);
return;
}
}
}
void
Peer2PeerBackend::CheckInitialSync()
{
int i;
if (_synchronizing) {
// Check to see if everyone is now synchronized. If so,
// go ahead and tell the client that we're ok to accept input.
for (i = 0; i < _num_players; i++) {
// xxx: IsInitialized() must go... we're actually using it as a proxy for "represents the local player"
if (_endpoints[i].IsInitialized() && !_endpoints[i].IsSynchronized() && !_local_connect_status[i].disconnected) {
return;
}
}
for (i = 0; i < _num_spectators; i++) {
if (_spectators[i].IsInitialized() && !_spectators[i].IsSynchronized()) {
return;
}
}
GGPOEvent info;
info.code = GGPO_EVENTCODE_RUNNING;
_callbacks.on_event(&info);
_synchronizing = false;
}
}
GGPOErrorCode Peer2PeerBackend::SendMessage(const void *msg, int len, bool spectators)
{
if (_synchronizing)
return GGPO_ERRORCODE_NOT_SYNCHRONIZED;
if (len > MAX_APPDATA_SIZE)
return GGPO_ERRORCODE_INVALID_REQUEST;
for (int i = 0; i < _num_players; i++)
if (_endpoints[i].IsInitialized())
_endpoints[i].SendAppData(msg, len, spectators);
if (spectators)
for (int i = 0; i < _num_spectators; i++)
if (_spectators[i].IsInitialized())
_spectators[i].SendAppData(msg, len, spectators);
return GGPO_ERRORCODE_SUCCESS;
}
+79
View File
@@ -0,0 +1,79 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _P2P_H
#define _P2P_H
#include "ggpo_types.h"
#include "ggpo_poll.h"
#include "sync.h"
#include "backend.h"
#include "timesync.h"
#include "network/udp_proto.h"
class Peer2PeerBackend : public IQuarkBackend, IPollSink, Udp::Callbacks {
public:
Peer2PeerBackend(GGPOSessionCallbacks *cb, const char *gamename, uint16 localport, int num_players, int input_size,
const void *verification, int verification_size);
virtual ~Peer2PeerBackend();
public:
GGPOErrorCode DoPoll(int timeout) override;
GGPOErrorCode AddPlayer(GGPOPlayer *player, GGPOPlayerHandle *handle) override;
GGPOErrorCode AddLocalInput(GGPOPlayerHandle player, void *values, int size) override;
GGPOErrorCode SyncInput(void *values, int size, int *disconnect_flags) override;
GGPOErrorCode IncrementFrame(void) override;
GGPOErrorCode DisconnectPlayer(GGPOPlayerHandle handle) override;
GGPOErrorCode GetNetworkStats(GGPONetworkStats *stats, GGPOPlayerHandle handle) override;
GGPOErrorCode SetFrameDelay(GGPOPlayerHandle player, int delay) override;
GGPOErrorCode SetDisconnectTimeout(int timeout) override;
GGPOErrorCode SetDisconnectNotifyStart(int timeout) override;
GGPOErrorCode SendMessage(const void *msg, int len, bool spectators) override;
public:
void OnMsg(sockaddr_in &from, UdpMsg *msg, int len) override;
protected:
GGPOErrorCode PlayerHandleToQueue(GGPOPlayerHandle player, int *queue);
GGPOPlayerHandle QueueToPlayerHandle(int queue) { return (GGPOPlayerHandle)(queue + 1); }
GGPOPlayerHandle QueueToSpectatorHandle(int queue) { return (GGPOPlayerHandle)(queue + 1000); } /* out of range of the player array, basically */
void DisconnectPlayerQueue(int queue, int syncto);
void PollSyncEvents(void);
void PollUdpProtocolEvents(void);
void CheckInitialSync(void);
int Poll2Players(int current_frame);
int PollNPlayers(int current_frame);
void AddRemotePlayer(char *remoteip, uint16 reportport, int queue);
GGPOErrorCode AddSpectator(char *remoteip, uint16 reportport);
virtual void OnSyncEvent(Sync::Event &e) { }
virtual void OnUdpProtocolEvent(UdpProtocol::Event &e, GGPOPlayerHandle handle);
virtual void OnUdpProtocolPeerEvent(UdpProtocol::Event &e, int queue);
virtual void OnUdpProtocolSpectatorEvent(UdpProtocol::Event &e, int queue);
protected:
GGPOSessionCallbacks _callbacks;
Poll _poll;
Sync _sync;
Udp _udp;
UdpProtocol *_endpoints;
UdpProtocol _spectators[GGPO_MAX_SPECTATORS];
int _num_spectators;
int _input_size;
bool _synchronizing;
int _num_players;
int _next_recommended_sleep;
int _next_spectator_frame;
int _disconnect_timeout;
int _disconnect_notify_start;
UdpMsg::connect_status _local_connect_status[UDP_MSG_MAX_PLAYERS];
};
#endif
@@ -0,0 +1,189 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#include "spectator.h"
SpectatorBackend::SpectatorBackend(GGPOSessionCallbacks *cb,
const char* gamename,
uint16 localport,
int num_players,
int input_size,
char *hostip,
u_short hostport,
const void *verification,
int verification_size) :
_input_size(input_size),
_num_players(num_players),
_next_input_to_send(0)
{
_callbacks = *cb;
_synchronizing = true;
for (size_t i = 0; i < ARRAY_SIZE(_inputs); i++) {
_inputs[i].frame = -1;
}
/*
* Initialize the UDP port
*/
_udp.Init(localport, &_poll, this);
/*
* Init the host endpoint
*/
_host.SetVerificationData(verification, verification_size);
_host.Init(&_udp, _poll, 0, hostip, hostport, NULL);
_host.Synchronize();
/*
* Preload the ROM
*/
_callbacks.begin_game(gamename);
}
SpectatorBackend::~SpectatorBackend()
{
}
GGPOErrorCode
SpectatorBackend::DoPoll(int timeout)
{
_poll.Pump(0);
PollUdpProtocolEvents();
return GGPO_OK;
}
GGPOErrorCode
SpectatorBackend::SyncInput(void *values,
int size,
int *disconnect_flags)
{
// Wait until we've started to return inputs.
if (_synchronizing) {
return GGPO_ERRORCODE_NOT_SYNCHRONIZED;
}
GameInput &input = _inputs[_next_input_to_send % SPECTATOR_FRAME_BUFFER_SIZE];
if (input.frame < _next_input_to_send) {
// Haven't received the input from the host yet. Wait
return GGPO_ERRORCODE_PREDICTION_THRESHOLD;
}
if (input.frame > _next_input_to_send) {
// The host is way way way far ahead of the spectator. How'd this
// happen? Anyway, the input we need is gone forever.
return GGPO_ERRORCODE_GENERAL_FAILURE;
}
ASSERT(size >= _input_size * _num_players);
memcpy(values, input.bits, _input_size * _num_players);
if (disconnect_flags) {
*disconnect_flags = 0; // xxx: should get them from the host!
}
_next_input_to_send++;
return GGPO_OK;
}
GGPOErrorCode
SpectatorBackend::IncrementFrame(void)
{
Log("End of frame (%d)...\n", _next_input_to_send - 1);
DoPoll(0);
PollUdpProtocolEvents();
return GGPO_OK;
}
void
SpectatorBackend::PollUdpProtocolEvents(void)
{
UdpProtocol::Event evt;
while (_host.GetEvent(evt)) {
OnUdpProtocolEvent(evt);
}
}
void
SpectatorBackend::OnUdpProtocolEvent(UdpProtocol::Event &evt)
{
GGPOEvent info;
switch (evt.type) {
case UdpProtocol::Event::Connected:
info.code = GGPO_EVENTCODE_CONNECTED_TO_PEER;
info.u.connected.player = 0;
_callbacks.on_event(&info);
break;
case UdpProtocol::Event::Synchronizing:
info.code = GGPO_EVENTCODE_SYNCHRONIZING_WITH_PEER;
info.u.synchronizing.player = 0;
info.u.synchronizing.count = evt.u.synchronizing.count;
info.u.synchronizing.total = evt.u.synchronizing.total;
_callbacks.on_event(&info);
break;
case UdpProtocol::Event::Synchronzied:
if (_synchronizing) {
info.code = GGPO_EVENTCODE_SYNCHRONIZED_WITH_PEER;
info.u.synchronized.player = 0;
_callbacks.on_event(&info);
info.code = GGPO_EVENTCODE_RUNNING;
_callbacks.on_event(&info);
_synchronizing = false;
}
break;
case UdpProtocol::Event::NetworkInterrupted:
info.code = GGPO_EVENTCODE_CONNECTION_INTERRUPTED;
info.u.connection_interrupted.player = 0;
info.u.connection_interrupted.disconnect_timeout = evt.u.network_interrupted.disconnect_timeout;
_callbacks.on_event(&info);
break;
case UdpProtocol::Event::NetworkResumed:
info.code = GGPO_EVENTCODE_CONNECTION_RESUMED;
info.u.connection_resumed.player = 0;
_callbacks.on_event(&info);
break;
case UdpProtocol::Event::Disconnected:
info.code = GGPO_EVENTCODE_DISCONNECTED_FROM_PEER;
info.u.disconnected.player = 0;
_callbacks.on_event(&info);
break;
case UdpProtocol::Event::Input:
{
GameInput& input = evt.u.input.input;
_host.SetLocalFrameNumber(input.frame);
_host.SendInputAck();
_inputs[input.frame % SPECTATOR_FRAME_BUFFER_SIZE] = input;
}
break;
case UdpProtocol::Event::AppData:
Log("calling on_message callback with %d bytes", evt.u.app_data.size);
if (_callbacks.on_message != nullptr)
_callbacks.on_message(evt.u.app_data.data, evt.u.app_data.size);
break;
default:
break;
}
}
void
SpectatorBackend::OnMsg(sockaddr_in &from, UdpMsg *msg, int len)
{
if (_host.HandlesMsg(from, msg)) {
_host.OnMsg(msg, len);
}
}
@@ -0,0 +1,60 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _SPECTATOR_H
#define _SPECTATOR_H
#include "../ggpo_poll.h"
#include "../ggpo_types.h"
#include "sync.h"
#include "backend.h"
#include "timesync.h"
#include "network/udp_proto.h"
#define SPECTATOR_FRAME_BUFFER_SIZE 64
class SpectatorBackend : public IQuarkBackend, IPollSink, Udp::Callbacks {
public:
SpectatorBackend(GGPOSessionCallbacks *cb, const char *gamename, uint16 localport, int num_players, int input_size, char *hostip, u_short hostport,
const void *verification, int verification_size);
virtual ~SpectatorBackend();
public:
GGPOErrorCode DoPoll(int timeout) override;
GGPOErrorCode AddPlayer(GGPOPlayer *player, GGPOPlayerHandle *handle) override { return GGPO_ERRORCODE_UNSUPPORTED; }
GGPOErrorCode AddLocalInput(GGPOPlayerHandle player, void *values, int size) override { return GGPO_OK; }
GGPOErrorCode SyncInput(void *values, int size, int *disconnect_flags) override;
GGPOErrorCode IncrementFrame(void) override;
GGPOErrorCode DisconnectPlayer(GGPOPlayerHandle handle) override { return GGPO_ERRORCODE_UNSUPPORTED; }
GGPOErrorCode GetNetworkStats(GGPONetworkStats *stats, GGPOPlayerHandle handle) override { return GGPO_ERRORCODE_UNSUPPORTED; }
GGPOErrorCode SetFrameDelay(GGPOPlayerHandle player, int delay) override { return GGPO_ERRORCODE_UNSUPPORTED; }
GGPOErrorCode SetDisconnectTimeout(int timeout) override { return GGPO_ERRORCODE_UNSUPPORTED; }
GGPOErrorCode SetDisconnectNotifyStart(int timeout) override { return GGPO_ERRORCODE_UNSUPPORTED; }
public:
void OnMsg(sockaddr_in &from, UdpMsg *msg, int len) override;
protected:
void PollUdpProtocolEvents(void);
void CheckInitialSync(void);
void OnUdpProtocolEvent(UdpProtocol::Event &e);
protected:
GGPOSessionCallbacks _callbacks;
Poll _poll;
Udp _udp;
UdpProtocol _host;
bool _synchronizing;
int _input_size;
int _num_players;
int _next_input_to_send;
GameInput _inputs[SPECTATOR_FRAME_BUFFER_SIZE];
};
#endif
@@ -0,0 +1,224 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#include "synctest.h"
SyncTestBackend::SyncTestBackend(GGPOSessionCallbacks *cb,
const char *gamename,
int frames,
int num_players) :
_sync(NULL)
{
_callbacks = *cb;
_num_players = num_players;
_check_distance = frames;
_last_verified = 0;
_rollingback = false;
_running = false;
_logfp = NULL;
_current_input.erase();
strcpy(_game, gamename);
/*
* Initialize the synchronziation layer
*/
Sync::Config config = { 0 };
config.callbacks = _callbacks;
config.num_prediction_frames = MAX_PREDICTION_FRAMES;
_sync.Init(config);
/*
* Preload the ROM
*/
_callbacks.begin_game(gamename);
}
SyncTestBackend::~SyncTestBackend()
{
}
GGPOErrorCode
SyncTestBackend::DoPoll(int timeout)
{
if (!_running) {
GGPOEvent info;
info.code = GGPO_EVENTCODE_RUNNING;
_callbacks.on_event(&info);
_running = true;
}
return GGPO_OK;
}
GGPOErrorCode
SyncTestBackend::AddPlayer(GGPOPlayer *player, GGPOPlayerHandle *handle)
{
if (player->player_num < 1 || player->player_num > _num_players) {
return GGPO_ERRORCODE_PLAYER_OUT_OF_RANGE;
}
*handle = (GGPOPlayerHandle)(player->player_num - 1);
return GGPO_OK;
}
GGPOErrorCode
SyncTestBackend::AddLocalInput(GGPOPlayerHandle player, void *values, int size)
{
if (!_running) {
return GGPO_ERRORCODE_NOT_SYNCHRONIZED;
}
int index = (int)player;
for (int i = 0; i < size; i++) {
_current_input.bits[(index * size) + i] |= ((char *)values)[i];
}
return GGPO_OK;
}
GGPOErrorCode
SyncTestBackend::SyncInput(void *values,
int size,
int *disconnect_flags)
{
BeginLog(false);
if (_rollingback) {
_last_input = _saved_frames.front().input;
} else {
if (_sync.GetFrameCount() == 0 && _sync.GetLastSavedFrame().buf == nullptr) {
_sync.SaveCurrentFrame();
}
_last_input = _current_input;
}
memcpy(values, _last_input.bits, size);
if (disconnect_flags) {
*disconnect_flags = 0;
}
return GGPO_OK;
}
GGPOErrorCode
SyncTestBackend::IncrementFrame(void)
{
_sync.IncrementFrame();
_current_input.erase();
Log("End of frame(%d)...\n", _sync.GetFrameCount());
EndLog();
if (_rollingback) {
return GGPO_OK;
}
int frame = _sync.GetFrameCount();
// Hold onto the current frame in our queue of saved states. We'll need
// the checksum later to verify that our replay of the same frame got the
// same results.
SavedInfo info;
info.frame = frame;
info.input = _last_input;
info.cbuf = _sync.GetLastSavedFrame().cbuf;
info.buf = (char *)malloc(info.cbuf);
memcpy(info.buf, _sync.GetLastSavedFrame().buf, info.cbuf);
info.checksum = _sync.GetLastSavedFrame().checksum;
_saved_frames.push(info);
if (frame - _last_verified == _check_distance) {
// We've gone far enough ahead and should now start replaying frames.
// Load the last verified frame and set the rollback flag to true.
_sync.LoadFrame(_last_verified);
_rollingback = true;
while(!_saved_frames.empty()) {
_callbacks.advance_frame(0);
// Verify that the checksumn of this frame is the same as the one in our
// list.
info = _saved_frames.front();
_saved_frames.pop();
if (info.frame != _sync.GetFrameCount()) {
RaiseSyncError("Frame number %d does not match saved frame number %d", info.frame, frame);
}
int checksum = _sync.GetLastSavedFrame().checksum;
if (info.checksum != checksum) {
LogSaveStates(info);
RaiseSyncError("Checksum for frame %d does not match saved (%d != %d)", frame, checksum, info.checksum);
}
else
printf("Checksum %08d for frame %d matches.\n", checksum, info.frame);
free(info.buf);
}
_last_verified = frame;
_rollingback = false;
}
return GGPO_OK;
}
void
SyncTestBackend::RaiseSyncError(const char *fmt, ...)
{
char buf[1024];
va_list args;
va_start(args, fmt);
vsnprintf(buf, ARRAY_SIZE(buf), fmt, args);
va_end(args);
puts(buf);
#ifdef _WIN32
OutputDebugStringA(buf);
#endif
EndLog();
// DebugBreak();
}
GGPOErrorCode
SyncTestBackend::Logv(char *fmt, va_list list)
{
if (_logfp) {
vfprintf(_logfp, fmt, list);
}
return GGPO_OK;
}
void
SyncTestBackend::BeginLog(int saving)
{
EndLog();
char filename[MAX_PATH];
#ifdef _WIN32
CreateDirectoryA("synclogs", NULL);
#else
mkdir("synclogs", 0755);
#endif
snprintf(filename, ARRAY_SIZE(filename), "synclogs/%s-%04d-%s.log",
saving ? "state" : "log",
_sync.GetFrameCount(),
_rollingback ? "replay" : "original");
_logfp = fopen(filename, "w");
}
void
SyncTestBackend::EndLog()
{
if (_logfp) {
fprintf(_logfp, "Closing log file.\n");
fclose(_logfp);
_logfp = NULL;
}
}
void
SyncTestBackend::LogSaveStates(SavedInfo &info)
{
char filename[MAX_PATH];
snprintf(filename, ARRAY_SIZE(filename), "synclogs/state-%04d-original.log", _sync.GetFrameCount());
_callbacks.log_game_state(filename, (unsigned char *)info.buf, info.cbuf);
snprintf(filename, ARRAY_SIZE(filename), "synclogs/state-%04d-replay.log", _sync.GetFrameCount());
_callbacks.log_game_state(filename, _sync.GetLastSavedFrame().buf, _sync.GetLastSavedFrame().cbuf);
}
@@ -0,0 +1,60 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _SYNCTEST_H
#define _SYNCTEST_H
#include "ggpo_types.h"
#include "backend.h"
#include "sync.h"
#include "ring_buffer.h"
class SyncTestBackend : public IQuarkBackend {
public:
SyncTestBackend(GGPOSessionCallbacks *cb, const char *gamename, int frames, int num_players);
virtual ~SyncTestBackend();
virtual GGPOErrorCode DoPoll(int timeout);
virtual GGPOErrorCode AddPlayer(GGPOPlayer *player, GGPOPlayerHandle *handle);
virtual GGPOErrorCode AddLocalInput(GGPOPlayerHandle player, void *values, int size);
virtual GGPOErrorCode SyncInput(void *values, int size, int *disconnect_flags);
virtual GGPOErrorCode IncrementFrame(void);
virtual GGPOErrorCode Logv(char *fmt, va_list list);
protected:
struct SavedInfo {
int frame;
int checksum;
char *buf;
int cbuf;
GameInput input;
};
void RaiseSyncError(const char *fmt, ...);
void BeginLog(int saving);
void EndLog();
void LogSaveStates(SavedInfo &info);
protected:
GGPOSessionCallbacks _callbacks;
Sync _sync;
int _num_players;
int _check_distance;
int _last_verified;
bool _rollingback;
bool _running;
FILE *_logfp;
char _game[128];
GameInput _current_input;
GameInput _last_input;
RingBuffer<SavedInfo, 32> _saved_frames;
};
#endif
+55
View File
@@ -0,0 +1,55 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#include "ggpo_types.h"
#include "bitvector.h"
void
BitVector_SetBit(uint8 *vector, int *offset)
{
vector[(*offset) / 8] |= (1 << ((*offset) % 8));
*offset += 1;
}
void
BitVector_ClearBit(uint8 *vector, int *offset)
{
vector[(*offset) / 8] &= ~(1 << ((*offset) % 8));
*offset += 1;
}
void
BitVector_WriteNibblet(uint8 *vector, int nibble, int *offset)
{
ASSERT(nibble < (1 << BITVECTOR_NIBBLE_SIZE));
for (int i = 0; i < BITVECTOR_NIBBLE_SIZE; i++) {
if (nibble & (1 << i)) {
BitVector_SetBit(vector, offset);
} else {
BitVector_ClearBit(vector, offset);
}
}
}
int
BitVector_ReadBit(uint8 *vector, int *offset)
{
int retval = !!(vector[(*offset) / 8] & (1 << ((*offset) % 8)));
*offset += 1;
return retval;
}
int
BitVector_ReadNibblet(uint8 *vector, int *offset)
{
int nibblet = 0;
for (int i = 0; i < BITVECTOR_NIBBLE_SIZE; i++) {
nibblet |= (BitVector_ReadBit(vector, offset) << i);
}
return nibblet;
}
+19
View File
@@ -0,0 +1,19 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _BITVECTOR_H
#define _BITVECTOR_H
#define BITVECTOR_NIBBLE_SIZE 8
void BitVector_SetBit(uint8 *vector, int *offset);
void BitVector_ClearBit(uint8 *vector, int *offset);
void BitVector_WriteNibblet(uint8 *vector, int nibble, int *offset);
int BitVector_ReadBit(uint8 *vector, int *offset);
int BitVector_ReadNibblet(uint8 *vector, int *offset);
#endif // _BITVECTOR_H
+89
View File
@@ -0,0 +1,89 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#include "game_input.h"
#include "ggpo_types.h"
#include "log.h"
void
GameInput::init(int iframe, char *ibits, int isize, int offset)
{
ASSERT(isize);
ASSERT(isize <= GAMEINPUT_MAX_BYTES);
frame = iframe;
size = isize;
memset(bits, 0, sizeof(bits));
if (ibits) {
memcpy(bits + (offset * isize), ibits, isize);
}
}
void
GameInput::init(int iframe, char *ibits, int isize)
{
ASSERT(isize);
ASSERT(isize <= GAMEINPUT_MAX_BYTES * GAMEINPUT_MAX_PLAYERS);
frame = iframe;
size = isize;
memset(bits, 0, sizeof(bits));
if (ibits) {
memcpy(bits, ibits, isize);
}
}
void
GameInput::desc(char *buf, size_t buf_size, bool show_frame) const
{
ASSERT(size);
size_t remaining = buf_size;
if (show_frame) {
remaining -= snprintf(buf, buf_size, "(frame:%d size:%d ", frame, size);
} else {
remaining -= snprintf(buf, buf_size, "(size:%d ", size);
}
for (int i = 0; i < size * 8; i++) {
char buf2[16];
if (value(i)) {
int c = snprintf(buf2, ARRAY_SIZE(buf2), "%2d ", i);
strncat(buf, buf2, ARRAY_SIZE(buf2));
remaining -= c;
}
}
strcat(buf, ")");
}
void
GameInput::log(char *prefix, bool show_frame) const
{
char buf[1024];
size_t c = strlen(prefix);
strcpy(buf, prefix);
desc(buf + c, ARRAY_SIZE(buf) - c, show_frame);
strcat(buf, "\n");
Log(buf);
}
bool
GameInput::equal(GameInput &other, bool bitsonly)
{
if (!bitsonly && frame != other.frame) {
Log("frames don't match: %d, %d\n", frame, other.frame);
}
if (size != other.size) {
Log("sizes don't match: %d, %d\n", size, other.size);
}
if (memcmp(bits, other.bits, size)) {
Log("bits don't match\n");
}
ASSERT(size && other.size);
return (bitsonly || frame == other.frame) &&
size == other.size &&
memcmp(bits, other.bits, size) == 0;
}
+40
View File
@@ -0,0 +1,40 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _GAMEINPUT_H
#define _GAMEINPUT_H
#include <stdio.h>
#include <memory.h>
// GAMEINPUT_MAX_BYTES * GAMEINPUT_MAX_PLAYERS * 8 must be less than
// 2^BITVECTOR_NIBBLE_SIZE (see bitvector.h)
#define GAMEINPUT_MAX_BYTES 9
#define GAMEINPUT_MAX_PLAYERS 2
struct GameInput {
enum Constants {
NullFrame = -1
};
int frame;
int size; /* size in bytes of the entire input for all players */
char bits[GAMEINPUT_MAX_BYTES * GAMEINPUT_MAX_PLAYERS];
bool is_null() { return frame == NullFrame; }
void init(int frame, char *bits, int size, int offset);
void init(int frame, char *bits, int size);
bool value(int i) const { return (bits[i/8] & (1 << (i%8))) != 0; }
void set(int i) { bits[i/8] |= (1 << (i%8)); }
void clear(int i) { bits[i/8] &= ~(1 << (i%8)); }
void erase() { memset(bits, 0, sizeof(bits)); }
void desc(char *buf, size_t buf_size, bool show_frame = true) const;
void log(char *prefix, bool show_frame = true) const;
bool equal(GameInput &input, bool bitsonly = false);
};
#endif
+66
View File
@@ -0,0 +1,66 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _POLL_H
#define _POLL_H
#include "static_buffer.h"
#define MAX_POLLABLE_HANDLES 64
class IPollSink {
public:
virtual ~IPollSink() { }
virtual bool OnHandlePoll(void *) { return true; }
virtual bool OnMsgPoll(void *) { return true; }
virtual bool OnPeriodicPoll(void *, int ) { return true; }
virtual bool OnLoopPoll(void *) { return true; }
};
class Poll {
public:
Poll(void);
// void RegisterHandle(IPollSink *sink, HANDLE h, void *cookie = NULL);
void RegisterMsgLoop(IPollSink *sink, void *cookie = NULL);
void RegisterPeriodic(IPollSink *sink, int interval, void *cookie = NULL);
void RegisterLoop(IPollSink *sink, void *cookie = NULL);
void Run();
bool Pump(int timeout);
protected:
int ComputeWaitTime(int elapsed);
struct PollSinkCb {
IPollSink *sink;
void *cookie;
PollSinkCb() : sink(NULL), cookie(NULL) { }
PollSinkCb(IPollSink *s, void *c) : sink(s), cookie(c) { }
};
struct PollPeriodicSinkCb : public PollSinkCb {
int interval;
int last_fired;
PollPeriodicSinkCb() : PollSinkCb(NULL, NULL), interval(0), last_fired(0) { }
PollPeriodicSinkCb(IPollSink *s, void *c, int i) :
PollSinkCb(s, c), interval(i), last_fired(0) { }
};
int _start_time;
int _handle_count;
#ifdef _WIN32
HANDLE _handles[MAX_POLLABLE_HANDLES];
#endif
PollSinkCb _handle_sinks[MAX_POLLABLE_HANDLES];
StaticBuffer<PollSinkCb, 16> _msg_sinks;
StaticBuffer<PollSinkCb, 16> _loop_sinks;
StaticBuffer<PollPeriodicSinkCb, 16> _periodic_sinks;
};
#endif
+99
View File
@@ -0,0 +1,99 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _TYPES_H
#define _TYPES_H
/*
* Keep the compiler happy
*/
#ifdef _MSC_VER
/*
* Disable specific compiler warnings
* 4018 - '<' : signed/unsigned mismatch
* 4100 - 'xxx' : unreferenced formal parameter
* 4127 - conditional expression is constant
* 4201 - nonstandard extension used : nameless struct/union
* 4389 - '!=' : signed/unsigned mismatch
* 4800 - 'int' : forcing value to bool 'true' or 'false' (performance warning)
*/
#pragma warning(disable: 4018 4100 4127 4201 4389 4800)
#endif
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
#define TARGET_UWP
#endif
/*
* Simple types
*/
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned char byte;
typedef char int8;
typedef short int16;
typedef int int32;
#include "ggponet.h"
#include <stdexcept>
class GGPOException : public std::runtime_error {
public:
GGPOException(const char *what, GGPOErrorCode ggpoError)
: std::runtime_error(what), ggpoError(ggpoError) {}
GGPOErrorCode ggpoError;
};
/*
* Additional headers
*/
#if defined(_WIN32)
# include "platform_windows.h"
#elif defined(__unix__) || defined(__APPLE__) || defined(__SWITCH__)
# include "platform_linux.h"
#else
# error Unsupported platform
#endif
#include "log.h"
/*
* Macros
*/
#define ASSERT(x) \
do { \
if (!(x)) { \
char assert_buf[1024]; \
snprintf(assert_buf, sizeof(assert_buf) - 1, "Assertion: %s @ %s:%d (pid:%ld)", #x, __FILE__, __LINE__, (long)GGPOPlatform::GetProcessID()); \
Log("%s\n", assert_buf); \
Log("\n"); \
Log("\n"); \
Log("\n"); \
GGPOPlatform::AssertFailed(assert_buf); \
exit(0); \
} \
} while (false)
#ifndef ARRAY_SIZE
# define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#endif
#ifndef MAX_INT
# define MAX_INT 0xEFFFFFF
#endif
#ifndef MAX
# define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif
#ifndef MIN
# define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif
#endif // _TYPES_H
+321
View File
@@ -0,0 +1,321 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#include "input_queue.h"
#include "ggpo_types.h"
#define PREVIOUS_FRAME(offset) (((offset) == 0) ? (INPUT_QUEUE_LENGTH - 1) : ((offset) - 1))
InputQueue::InputQueue(int input_size)
{
Init(-1, input_size);
}
InputQueue::~InputQueue()
{
}
void
InputQueue::Init(int id, int input_size)
{
_id = id;
_head = 0;
_tail = 0;
_length = 0;
_frame_delay = 0;
_first_frame = true;
_last_user_added_frame = GameInput::NullFrame;
_first_incorrect_frame = GameInput::NullFrame;
_last_frame_requested = GameInput::NullFrame;
_last_added_frame = GameInput::NullFrame;
_prediction.init(GameInput::NullFrame, NULL, input_size);
/*
* This is safe because we know the GameInput is a proper structure (as in,
* no virtual methods, no contained classes, etc.).
*/
memset(_inputs, 0, sizeof _inputs);
for (size_t i = 0; i < ARRAY_SIZE(_inputs); i++) {
_inputs[i].size = input_size;
}
}
int
InputQueue::GetLastConfirmedFrame()
{
Log("returning last confirmed frame %d.\n", _last_added_frame);
return _last_added_frame;
}
int
InputQueue::GetFirstIncorrectFrame()
{
return _first_incorrect_frame;
}
void
InputQueue::DiscardConfirmedFrames(int frame)
{
ASSERT(frame >= 0);
if (_last_frame_requested != GameInput::NullFrame) {
frame = MIN(frame, _last_frame_requested);
}
Log("discarding confirmed frames up to %d (last_added:%d length:%d [head:%d tail:%d]).\n",
frame, _last_added_frame, _length, _head, _tail);
if (frame >= _last_added_frame) {
_tail = _head;
} else {
int offset = frame - _inputs[_tail].frame + 1;
Log("difference of %d frames.\n", offset);
ASSERT(offset >= 0);
_tail = (_tail + offset) % INPUT_QUEUE_LENGTH;
_length -= offset;
}
Log("after discarding, new tail is %d (frame:%d).\n", _tail, _inputs[_tail].frame);
ASSERT(_length >= 0);
}
void
InputQueue::ResetPrediction(int frame)
{
ASSERT(_first_incorrect_frame == GameInput::NullFrame || frame <= _first_incorrect_frame);
Log("resetting all prediction errors back to frame %d.\n", frame);
/*
* There's nothing really to do other than reset our prediction
* state and the incorrect frame counter...
*/
_prediction.frame = GameInput::NullFrame;
_first_incorrect_frame = GameInput::NullFrame;
_last_frame_requested = GameInput::NullFrame;
}
bool
InputQueue::GetConfirmedInput(int requested_frame, GameInput *input)
{
ASSERT(_first_incorrect_frame == GameInput::NullFrame || requested_frame < _first_incorrect_frame);
int offset = requested_frame % INPUT_QUEUE_LENGTH;
if (_inputs[offset].frame != requested_frame) {
return false;
}
*input = _inputs[offset];
return true;
}
bool
InputQueue::GetInput(int requested_frame, GameInput *input)
{
Log("requesting input frame %d.\n", requested_frame);
/*
* No one should ever try to grab any input when we have a prediction
* error. Doing so means that we're just going further down the wrong
* path. ASSERT this to verify that it's true.
*/
ASSERT(_first_incorrect_frame == GameInput::NullFrame);
/*
* Remember the last requested frame number for later. We'll need
* this in AddInput() to drop out of prediction mode.
*/
_last_frame_requested = requested_frame;
ASSERT(requested_frame >= _inputs[_tail].frame);
if (_prediction.frame == GameInput::NullFrame) {
/*
* If the frame requested is in our range, fetch it out of the queue and
* return it.
*/
int offset = requested_frame - _inputs[_tail].frame;
if (offset < _length) {
offset = (offset + _tail) % INPUT_QUEUE_LENGTH;
ASSERT(_inputs[offset].frame == requested_frame);
*input = _inputs[offset];
Log("returning confirmed frame number %d.\n", input->frame);
return true;
}
/*
* The requested frame isn't in the queue. Bummer. This means we need
* to return a prediction frame. Predict that the user will do the
* same thing they did last time.
*/
if (requested_frame == 0) {
Log("basing new prediction frame from nothing, you're client wants frame 0.\n");
_prediction.erase();
} else if (_last_added_frame == GameInput::NullFrame) {
Log("basing new prediction frame from nothing, since we have no frames yet.\n");
_prediction.erase();
} else {
Log("basing new prediction frame from previously added frame (queue entry:%d, frame:%d).\n",
PREVIOUS_FRAME(_head), _inputs[PREVIOUS_FRAME(_head)].frame);
_prediction = _inputs[PREVIOUS_FRAME(_head)];
}
_prediction.frame++;
}
ASSERT(_prediction.frame >= 0);
/*
* If we've made it this far, we must be predicting. Go ahead and
* forward the prediction frame contents. Be sure to return the
* frame number requested by the client, though.
*/
*input = _prediction;
input->frame = requested_frame;
Log("returning prediction frame number %d (%d).\n", input->frame, _prediction.frame);
return false;
}
void
InputQueue::AddInput(GameInput &input)
{
int new_frame;
Log("adding input frame number %d to queue.\n", input.frame);
/*
* These next two lines simply verify that inputs are passed in
* sequentially by the user, regardless of frame delay.
*/
ASSERT(_last_user_added_frame == GameInput::NullFrame ||
input.frame == _last_user_added_frame + 1);
_last_user_added_frame = input.frame;
/*
* Move the queue head to the correct point in preparation to
* input the frame into the queue.
*/
new_frame = AdvanceQueueHead(input.frame);
if (new_frame != GameInput::NullFrame) {
AddDelayedInputToQueue(input, new_frame);
}
/*
* Update the frame number for the input. This will also set the
* frame to GameInput::NullFrame for frames that get dropped (by
* design).
*/
input.frame = new_frame;
}
void
InputQueue::AddDelayedInputToQueue(GameInput &input, int frame_number)
{
Log("adding delayed input frame number %d to queue.\n", frame_number);
if (input.size != _prediction.size)
throw GGPOException("Input size differs from peer", GGPO_ERRORCODE_INPUT_SIZE_DIFF);
ASSERT(_last_added_frame == GameInput::NullFrame || frame_number == _last_added_frame + 1);
ASSERT(frame_number == 0 || _inputs[PREVIOUS_FRAME(_head)].frame == frame_number - 1);
/*
* Add the frame to the back of the queue
*/
_inputs[_head] = input;
_inputs[_head].frame = frame_number;
_head = (_head + 1) % INPUT_QUEUE_LENGTH;
_length++;
_first_frame = false;
_last_added_frame = frame_number;
if (_prediction.frame != GameInput::NullFrame) {
ASSERT(frame_number == _prediction.frame);
/*
* We've been predicting... See if the inputs we've gotten match
* what we've been predicting. If so, don't worry about it. If not,
* remember the first input which was incorrect so we can report it
* in GetFirstIncorrectFrame()
*/
if (_first_incorrect_frame == GameInput::NullFrame && !_prediction.equal(input, true)) {
Log("frame %d does not match prediction. marking error.\n", frame_number);
_first_incorrect_frame = frame_number;
}
/*
* If this input is the same frame as the last one requested and we
* still haven't found any mis-predicted inputs, we can dump out
* of predition mode entirely! Otherwise, advance the prediction frame
* count up.
*/
if (_prediction.frame == _last_frame_requested && _first_incorrect_frame == GameInput::NullFrame) {
Log("prediction is correct! dumping out of prediction mode.\n");
_prediction.frame = GameInput::NullFrame;
} else {
_prediction.frame++;
}
}
ASSERT(_length <= INPUT_QUEUE_LENGTH);
}
int
InputQueue::AdvanceQueueHead(int frame)
{
Log("advancing queue head to frame %d.\n", frame);
int expected_frame = _first_frame ? 0 : _inputs[PREVIOUS_FRAME(_head)].frame + 1;
frame += _frame_delay;
if (expected_frame > frame) {
/*
* This can occur when the frame delay has dropped since the last
* time we shoved a frame into the system. In this case, there's
* no room on the queue. Toss it.
*/
Log("Dropping input frame %d (expected next frame to be %d).\n",
frame, expected_frame);
return GameInput::NullFrame;
}
while (expected_frame < frame) {
/*
* This can occur when the frame delay has been increased since the last
* time we shoved a frame into the system. We need to replicate the
* last frame in the queue several times in order to fill the space
* left.
*/
Log("Adding padding frame %d to account for change in frame delay.\n",
expected_frame);
GameInput &last_frame = _inputs[PREVIOUS_FRAME(_head)];
AddDelayedInputToQueue(last_frame, expected_frame);
expected_frame++;
}
ASSERT(frame == 0 || frame == _inputs[PREVIOUS_FRAME(_head)].frame + 1);
return frame;
}
void
InputQueue::Log(const char *fmt, ...)
{
char buf[1024];
size_t offset;
va_list args;
offset = snprintf(buf, ARRAY_SIZE(buf), "input q%d | ", _id);
va_start(args, fmt);
vsnprintf(buf + offset, ARRAY_SIZE(buf) - offset - 1, fmt, args);
buf[ARRAY_SIZE(buf)-1] = '\0';
::Log(buf);
va_end(args);
}
+60
View File
@@ -0,0 +1,60 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _INPUT_QUEUE_H
#define _INPUT_QUEUE_H
#include "game_input.h"
#define INPUT_QUEUE_LENGTH 128
#define DEFAULT_INPUT_SIZE 4
class InputQueue {
public:
InputQueue(int input_size = DEFAULT_INPUT_SIZE);
~InputQueue();
public:
void Init(int id, int input_size);
int GetLastConfirmedFrame();
int GetFirstIncorrectFrame();
int GetLength() { return _length; }
void SetFrameDelay(int delay) { _frame_delay = delay; }
void ResetPrediction(int frame);
void DiscardConfirmedFrames(int frame);
bool GetConfirmedInput(int frame, GameInput *input);
bool GetInput(int frame, GameInput *input);
void AddInput(GameInput &input);
protected:
int AdvanceQueueHead(int frame);
void AddDelayedInputToQueue(GameInput &input, int i);
void Log(const char *fmt, ...);
protected:
int _id;
int _head;
int _tail;
int _length;
bool _first_frame;
int _last_user_added_frame;
int _last_added_frame;
int _first_incorrect_frame;
int _last_frame_requested;
int _frame_delay;
GameInput _inputs[INPUT_QUEUE_LENGTH];
GameInput _prediction;
};
#endif
+31
View File
@@ -0,0 +1,31 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#include "ggpo_types.h"
#include "log/Log.h"
#include "log/LogManager.h"
#include <string>
void Log(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
Logv(fmt, args);
va_end(args);
}
void Logv(const char* fmt, va_list args)
{
std::string copy;
if (fmt[strlen(fmt) - 1] == '\n') {
copy = fmt;
copy.pop_back();
fmt = copy.c_str();
}
if (LogManager::GetInstance())
LogManager::GetInstance()->Log(LogTypes::LDEBUG, LogTypes::NETWORK, __FILE__, __LINE__, fmt, args);
}
+14
View File
@@ -0,0 +1,14 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _LOG_H
#define _LOG_H
extern void Log(const char *fmt, ...);
extern void Logv(const char *fmt, va_list list);
#endif
+276
View File
@@ -0,0 +1,276 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#include "backends/p2p.h"
#include "backends/synctest.h"
#include "backends/spectator.h"
#include "ggpo_types.h"
#include "ggponet.h"
struct Init
{
Init() {
srand(GGPOPlatform::GetCurrentTimeMS() + GGPOPlatform::GetProcessID());
#ifdef _WIN32
WSADATA wsaData;
WSAStartup(MAKEWORD(2, 0), &wsaData);
#endif
}
};
static Init init;
void
ggpo_log(GGPOSession *ggpo, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
ggpo_logv(ggpo, fmt, args);
va_end(args);
}
void
ggpo_logv(GGPOSession *ggpo, const char *fmt, va_list args)
{
if (ggpo)
ggpo->Logv(fmt, args);
}
GGPOErrorCode
ggpo_start_session(GGPOSession **session,
GGPOSessionCallbacks *cb,
const char *game,
int num_players,
int input_size,
unsigned short localport,
const void *verification,
int verification_size)
{
try {
*session= (GGPOSession *)new Peer2PeerBackend(cb,
game,
localport,
num_players,
input_size,
verification,
verification_size);
return GGPO_OK;
} catch (const GGPOException& e) {
Log("GGPOException in ggpo_start_session: %s", e.what());
return e.ggpoError;
}
}
GGPOErrorCode
ggpo_add_player(GGPOSession *ggpo,
GGPOPlayer *player,
GGPOPlayerHandle *handle)
{
if (!ggpo)
return GGPO_ERRORCODE_INVALID_SESSION;
try {
return ggpo->AddPlayer(player, handle);
} catch (const GGPOException& e) {
Log("GGPOException in ggpo_add_player: %s", e.what());
return e.ggpoError;
}
}
GGPOErrorCode
ggpo_start_synctest(GGPOSession **ggpo,
GGPOSessionCallbacks *cb,
const char *game,
int num_players,
int input_size,
int frames)
{
try {
*ggpo = (GGPOSession *)new SyncTestBackend(cb, game, frames, num_players);
return GGPO_OK;
} catch (const GGPOException& e) {
Log("GGPOException in ggpo_start_synctest: %s", e.what());
return e.ggpoError;
}
}
GGPOErrorCode
ggpo_set_frame_delay(GGPOSession *ggpo,
GGPOPlayerHandle player,
int frame_delay)
{
if (!ggpo)
return GGPO_ERRORCODE_INVALID_SESSION;
try {
return ggpo->SetFrameDelay(player, frame_delay);
} catch (const GGPOException& e) {
Log("GGPOException in ggpo_set_frame_delay: %s", e.what());
return e.ggpoError;
}
}
GGPOErrorCode
ggpo_idle(GGPOSession *ggpo, int timeout)
{
if (!ggpo)
return GGPO_ERRORCODE_INVALID_SESSION;
try {
return ggpo->DoPoll(timeout);
} catch (const GGPOException& e) {
Log("GGPOException in ggpo_idle: %s", e.what());
return e.ggpoError;
}
}
GGPOErrorCode
ggpo_add_local_input(GGPOSession *ggpo,
GGPOPlayerHandle player,
void *values,
int size)
{
if (!ggpo)
return GGPO_ERRORCODE_INVALID_SESSION;
try {
return ggpo->AddLocalInput(player, values, size);
} catch (const GGPOException& e) {
Log("GGPOException in ggpo_add_local_input: %s", e.what());
return e.ggpoError;
}
}
GGPOErrorCode
ggpo_synchronize_input(GGPOSession *ggpo,
void *values,
int size,
int *disconnect_flags)
{
if (!ggpo)
return GGPO_ERRORCODE_INVALID_SESSION;
try {
return ggpo->SyncInput(values, size, disconnect_flags);
} catch (const GGPOException& e) {
Log("GGPOException in ggpo_synchronize_input: %s", e.what());
return e.ggpoError;
}
}
GGPOErrorCode ggpo_disconnect_player(GGPOSession *ggpo,
GGPOPlayerHandle player)
{
if (!ggpo)
return GGPO_ERRORCODE_INVALID_SESSION;
try {
return ggpo->DisconnectPlayer(player);
} catch (const GGPOException& e) {
Log("GGPOException in ggpo_disconnect_player: %s", e.what());
return e.ggpoError;
}
}
GGPOErrorCode
ggpo_advance_frame(GGPOSession *ggpo)
{
if (!ggpo)
return GGPO_ERRORCODE_INVALID_SESSION;
try {
return ggpo->IncrementFrame();
} catch (const GGPOException& e) {
Log("GGPOException in ggpo_advance_frame: %s", e.what());
return e.ggpoError;
}
}
GGPOErrorCode
ggpo_get_network_stats(GGPOSession *ggpo,
GGPOPlayerHandle player,
GGPONetworkStats *stats)
{
if (!ggpo)
return GGPO_ERRORCODE_INVALID_SESSION;
try {
return ggpo->GetNetworkStats(stats, player);
} catch (const GGPOException& e) {
Log("GGPOException in ggpo_get_network_stats: %s", e.what());
return e.ggpoError;
}
}
GGPOErrorCode
ggpo_close_session(GGPOSession *ggpo)
{
if (!ggpo) {
return GGPO_ERRORCODE_INVALID_SESSION;
}
delete ggpo;
return GGPO_OK;
}
GGPOErrorCode
ggpo_set_disconnect_timeout(GGPOSession *ggpo, int timeout)
{
if (!ggpo)
return GGPO_ERRORCODE_INVALID_SESSION;
try {
return ggpo->SetDisconnectTimeout(timeout);
} catch (const GGPOException& e) {
Log("GGPOException in ggpo_set_disconnect_timeout: %s", e.what());
return e.ggpoError;
}
}
GGPOErrorCode
ggpo_set_disconnect_notify_start(GGPOSession *ggpo, int timeout)
{
if (!ggpo)
return GGPO_ERRORCODE_INVALID_SESSION;
try {
return ggpo->SetDisconnectNotifyStart(timeout);
} catch (const GGPOException& e) {
Log("GGPOException in ggpo_set_disconnect_notify_start: %s", e.what());
return e.ggpoError;
}
}
GGPOErrorCode ggpo_start_spectating(GGPOSession **session,
GGPOSessionCallbacks *cb,
const char *game,
int num_players,
int input_size,
unsigned short local_port,
char *host_ip,
unsigned short host_port,
const void *verification,
int verification_size)
{
try {
*session= (GGPOSession *)new SpectatorBackend(cb,
game,
local_port,
num_players,
input_size,
host_ip,
host_port,
verification,
verification_size);
return GGPO_OK;
} catch (const GGPOException& e) {
Log("GGPOException in ggpo_start_spectating: %s", e.what());
return e.ggpoError;
}
}
GGPOErrorCode ggpo_send_message(GGPOSession *ggpo,
const void *msg,
int len,
bool spectators)
{
if (ggpo == nullptr)
return GGPO_ERRORCODE_INVALID_SESSION;
return ggpo->SendMessage(msg, len, spectators);
}
+130
View File
@@ -0,0 +1,130 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#include "ggpo_types.h"
#include "udp.h"
SOCKET
CreateSocket(uint16 bind_port, int retries)
{
SOCKET s;
sockaddr_in sin;
uint16 port;
int optval = 1;
s = socket(AF_INET, SOCK_DGRAM, 0);
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&optval, sizeof optval);
optval = 0;
setsockopt(s, SOL_SOCKET, SO_LINGER, (const char *)&optval, sizeof optval);
// non-blocking...
#ifndef _WIN32
fcntl(s, F_SETFL, O_NONBLOCK);
#else
u_long iMode = 1;
ioctlsocket(s, FIONBIO, &iMode);
#endif
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl(INADDR_ANY);
for (port = bind_port; port <= bind_port + retries; port++) {
sin.sin_port = htons(port);
if (bind(s, (sockaddr *)&sin, sizeof sin) == 0) {
Log("Udp bound to port: %d.\n", port);
return s;
}
}
closesocket(s);
return INVALID_SOCKET;
}
Udp::Udp() :
_socket(INVALID_SOCKET),
_callbacks(NULL)
{
}
Udp::~Udp(void)
{
if (_socket != INVALID_SOCKET) {
closesocket(_socket);
_socket = INVALID_SOCKET;
}
}
void
Udp::Init(uint16 port, Poll *poll, Callbacks *callbacks)
{
_callbacks = callbacks;
poll->RegisterLoop(this);
Log("binding udp socket to port %d.\n", port);
_socket = CreateSocket(port, 0);
if (_socket == INVALID_SOCKET)
throw GGPOException("Socket creation or bind failed", GGPO_ERRORCODE_NETWORK_ERROR);
}
void
Udp::SendTo(char *buffer, int len, int flags, struct sockaddr *dst, int destlen)
{
struct sockaddr_in *to = (struct sockaddr_in *)dst;
int res = sendto(_socket, buffer, len, flags, dst, destlen);
if (res == SOCKET_ERROR) {
int err = WSAGetLastError();
Log("unknown error in sendto (erro: %d wsaerr: %d).\n", res, err);
ASSERT(false && "Unknown error in sendto");
}
char dst_ip[1024];
Log("sent packet length %d to %s:%d (ret:%d).\n", len, inet_ntop(AF_INET, (void *)&to->sin_addr, dst_ip, ARRAY_SIZE(dst_ip)), ntohs(to->sin_port), res);
}
bool
Udp::OnLoopPoll(void *cookie)
{
uint8 recv_buf[MAX_UDP_PACKET_SIZE];
sockaddr_in recv_addr;
socklen_t recv_addr_len;
for (;;) {
recv_addr_len = sizeof(recv_addr);
int len = recvfrom(_socket, (char *)recv_buf, MAX_UDP_PACKET_SIZE, 0, (struct sockaddr *)&recv_addr, &recv_addr_len);
// TODO: handle len == 0... indicates a disconnect.
if (len == -1) {
int error = WSAGetLastError();
if (error != WSAEWOULDBLOCK) {
Log("recvfrom WSAGetLastError returned %d (%x).\n", error, error);
}
break;
} else if (len > 0) {
char src_ip[1024];
Log("recvfrom returned (len:%d from:%s:%d).\n", len, inet_ntop(AF_INET, (void*)&recv_addr.sin_addr, src_ip, ARRAY_SIZE(src_ip)), ntohs(recv_addr.sin_port) );
UdpMsg *msg = (UdpMsg *)recv_buf;
_callbacks->OnMsg(recv_addr, msg, len);
}
}
return true;
}
void
Udp::Log(const char *fmt, ...)
{
char buf[1024];
size_t offset;
va_list args;
strcpy(buf, "udp | ");
offset = strlen(buf);
va_start(args, fmt);
vsnprintf(buf + offset, ARRAY_SIZE(buf) - offset - 1, fmt, args);
buf[ARRAY_SIZE(buf)-1] = '\0';
::Log(buf);
va_end(args);
}
+58
View File
@@ -0,0 +1,58 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _UDP_H
#define _UDP_H
#include "ggpo_poll.h"
#include "udp_msg.h"
#include "ggponet.h"
#include "ring_buffer.h"
#define MAX_UDP_ENDPOINTS 16
constexpr size_t MAX_UDP_PACKET_SIZE = sizeof(UdpMsg);
class Udp : public IPollSink
{
public:
struct Stats {
int bytes_sent;
int packets_sent;
float kbps_sent;
};
struct Callbacks {
virtual ~Callbacks() { }
virtual void OnMsg(sockaddr_in &from, UdpMsg *msg, int len) = 0;
};
protected:
void Log(const char *fmt, ...);
public:
Udp();
void Init(uint16 port, Poll *p, Callbacks *callbacks);
void SendTo(char *buffer, int len, int flags, struct sockaddr *dst, int destlen);
virtual bool OnLoopPoll(void *cookie);
public:
~Udp(void);
protected:
// Network transmission information
SOCKET _socket;
// state management
Callbacks *_callbacks;
};
#endif
+121
View File
@@ -0,0 +1,121 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _UDP_MSG_H
#define _UDP_MSG_H
#define MAX_COMPRESSED_BITS 4096
#define UDP_MSG_MAX_PLAYERS 4
#define MAX_VERIFICATION_SIZE 256
#define MAX_APPDATA_SIZE 512
#pragma pack(push, 1)
struct UdpMsg
{
enum MsgType {
Invalid = 0,
SyncRequest = 1,
SyncReply = 2,
Input = 3,
QualityReport = 4,
QualityReply = 5,
KeepAlive = 6,
InputAck = 7,
AppData = 8
};
struct connect_status {
unsigned int disconnected:1;
int last_frame:31;
};
struct {
uint16 magic;
uint16 sequence_number;
uint8 type; /* packet type */
} hdr;
union {
struct {
uint32 random_request; /* please reply back with this random data */
uint16 remote_magic;
uint8 remote_endpoint;
uint8 verification[MAX_VERIFICATION_SIZE];
} sync_request;
struct {
uint32 random_reply; /* OK, here's your random data back */
uint8 verification_failure; /* set to one by peer if verification failed */
} sync_reply;
struct {
int8 frame_advantage; /* what's the other guy's frame advantage? */
uint32 ping;
} quality_report;
struct {
uint32 pong;
} quality_reply;
struct {
connect_status peer_connect_status[UDP_MSG_MAX_PLAYERS];
uint32 start_frame;
int disconnect_requested:1;
int ack_frame:31;
uint16 num_bits;
uint8 input_size; // XXX: shouldn't be in every single packet!
uint8 bits[MAX_COMPRESSED_BITS / 8]; /* must be last */
} input;
struct {
int ack_frame:31;
} input_ack;
struct {
uint16 size;
uint8 spectators;
uint8 data[MAX_APPDATA_SIZE];
} app_data;
} u;
int verification_size = 0;
public:
int PacketSize() {
return sizeof(hdr) + PayloadSize();
}
int PayloadSize() {
switch (hdr.type) {
case SyncRequest: return (int)(&u.sync_request.verification[0] - (uint8 *)&u) + verification_size;
case SyncReply: return sizeof(u.sync_reply);
case QualityReport: return sizeof(u.quality_report);
case QualityReply: return sizeof(u.quality_reply);
case InputAck: return sizeof(u.input_ack);
case KeepAlive: return 0;
case Input:
{
int size = (int)((char *)&u.input.bits - (char *)&u.input);
size += (u.input.num_bits + 7) / 8;
return size;
}
case AppData: return sizeof(u.app_data) - sizeof(u.app_data.data) + u.app_data.size;
}
ASSERT(false);
return 0;
}
UdpMsg(MsgType t) { hdr.type = (uint8)t; }
};
#pragma pack(pop)
#endif
@@ -0,0 +1,830 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#include "udp_proto.h"
#include "../ggpo_types.h"
#include "bitvector.h"
static const int UDP_HEADER_SIZE = 28; /* Size of IP + UDP headers */
static const int NUM_SYNC_PACKETS = 5;
static const int SYNC_RETRY_INTERVAL = 2000;
static const int SYNC_FIRST_RETRY_INTERVAL = 500;
static const int RUNNING_RETRY_INTERVAL = 200;
static const int KEEP_ALIVE_INTERVAL = 200;
static const int QUALITY_REPORT_INTERVAL = 1000;
static const int NETWORK_STATS_INTERVAL = 1000;
static const int UDP_SHUTDOWN_TIMER = 5000;
static const int MAX_SEQ_DISTANCE = (1 << 15);
UdpProtocol::UdpProtocol() :
_udp(NULL),
_magic_number(0),
_queue(-1),
_remote_magic_number(0),
_connected(false),
_packets_sent(0),
_bytes_sent(0),
_stats_start_time(0),
_local_frame_advantage(0),
_remote_frame_advantage(0),
_last_send_time(0),
_shutdown_timeout(0),
_disconnect_event_sent(false),
_disconnect_timeout(0),
_disconnect_notify_start(0),
_disconnect_notify_sent(false),
_next_send_seq(0),
_next_recv_seq(0)
{
_last_sent_input.init(-1, NULL, 1);
_last_received_input.init(-1, NULL, 1);
_last_acked_input.init(-1, NULL, 1);
memset(&_state, 0, sizeof _state);
memset(_peer_connect_status, 0, sizeof(_peer_connect_status));
for (unsigned i = 0; i < ARRAY_SIZE(_peer_connect_status); i++) {
_peer_connect_status[i].last_frame = -1;
}
memset(&_peer_addr, 0, sizeof _peer_addr);
_oo_packet.msg = NULL;
_send_latency = GGPOPlatform::GetConfigInt("GGPO_NETWORK_DELAY");
_oop_percent = GGPOPlatform::GetConfigInt("GGPO_OOP_PERCENT");
}
UdpProtocol::~UdpProtocol()
{
ClearSendQueue();
}
void
UdpProtocol::Init(Udp *udp,
Poll &poll,
int queue,
char *ip,
u_short port,
UdpMsg::connect_status *status)
{
_udp = udp;
_queue = queue;
_local_connect_status = status;
_peer_addr.sin_family = AF_INET;
if (ip != nullptr && ip[0] != '\0')
{
_peer_addr.sin_port = htons(port);
inet_pton(AF_INET, ip, &_peer_addr.sin_addr.s_addr);
}
do {
_magic_number = (uint16)rand();
} while (_magic_number == 0);
poll.RegisterLoop(this);
}
void
UdpProtocol::SendInput(GameInput &input)
{
if (_udp) {
if (_current_state == Running) {
/*
* Check to see if this is a good time to adjust for the rift...
*/
_timesync.advance_frame(input, _local_frame_advantage, _remote_frame_advantage);
/*
* Save this input packet
*
* XXX: This queue may fill up for spectators who do not ack input packets in a timely
* manner. When this happens, we can either resize the queue (ug) or disconnect them
* (better, but still ug). For the meantime, make this queue really big to decrease
* the odds of this happening...
*/
_pending_output.push(input);
}
SendPendingOutput();
}
}
void
UdpProtocol::SendPendingOutput()
{
UdpMsg *msg = new UdpMsg(UdpMsg::Input);
int i, j, offset = 0;
uint8 *bits;
GameInput last;
if (_pending_output.size()) {
last = _last_acked_input;
bits = msg->u.input.bits;
msg->u.input.start_frame = _pending_output.front().frame;
msg->u.input.input_size = (uint8)_pending_output.front().size;
ASSERT(last.frame == -1 || last.frame + 1 == (int)msg->u.input.start_frame);
for (j = 0; j < _pending_output.size(); j++) {
GameInput &current = _pending_output.item(j);
if (memcmp(current.bits, last.bits, current.size) != 0) {
ASSERT((GAMEINPUT_MAX_BYTES * GAMEINPUT_MAX_PLAYERS * 8) < (1 << BITVECTOR_NIBBLE_SIZE));
for (i = 0; i < current.size * 8; i++) {
ASSERT(i < (1 << BITVECTOR_NIBBLE_SIZE));
if (current.value(i) != last.value(i)) {
BitVector_SetBit(msg->u.input.bits, &offset);
(current.value(i) ? BitVector_SetBit : BitVector_ClearBit)(bits, &offset);
BitVector_WriteNibblet(bits, i, &offset);
}
}
}
BitVector_ClearBit(msg->u.input.bits, &offset);
last = _last_sent_input = current;
}
} else {
msg->u.input.start_frame = 0;
msg->u.input.input_size = 0;
}
msg->u.input.ack_frame = _last_received_input.frame;
msg->u.input.num_bits = (uint16)offset;
msg->u.input.disconnect_requested = _current_state == Disconnected;
if (_local_connect_status) {
memcpy(msg->u.input.peer_connect_status, _local_connect_status, sizeof(UdpMsg::connect_status) * UDP_MSG_MAX_PLAYERS);
} else {
memset(msg->u.input.peer_connect_status, 0, sizeof(UdpMsg::connect_status) * UDP_MSG_MAX_PLAYERS);
}
ASSERT(offset < MAX_COMPRESSED_BITS);
SendMsg(msg);
}
void
UdpProtocol::SendInputAck()
{
UdpMsg *msg = new UdpMsg(UdpMsg::InputAck);
msg->u.input_ack.ack_frame = _last_received_input.frame;
SendMsg(msg);
}
bool
UdpProtocol::GetEvent(UdpProtocol::Event &e)
{
if (_event_queue.size() == 0) {
return false;
}
e = _event_queue.front();
_event_queue.pop();
return true;
}
bool
UdpProtocol::OnLoopPoll(void *cookie)
{
if (!_udp) {
return true;
}
unsigned int now = GGPOPlatform::GetCurrentTimeMS();
unsigned int next_interval;
PumpSendQueue();
switch (_current_state) {
case Syncing:
next_interval = (_state.sync.roundtrips_remaining == NUM_SYNC_PACKETS) ? SYNC_FIRST_RETRY_INTERVAL : SYNC_RETRY_INTERVAL;
if (_last_send_time && _last_send_time + next_interval < now && _peer_addr.sin_addr.s_addr != 0) {
Log("No luck syncing after %d ms... Re-queueing sync packet.\n", next_interval);
SendSyncRequest();
}
break;
case Running:
// xxx: rig all this up with a timer wrapper
if (!_state.running.last_input_packet_recv_time || _state.running.last_input_packet_recv_time + RUNNING_RETRY_INTERVAL < now) {
Log("Haven't exchanged packets in a while (last received:%d last sent:%d). Resending.\n", _last_received_input.frame, _last_sent_input.frame);
SendPendingOutput();
_state.running.last_input_packet_recv_time = now;
}
if (!_state.running.last_quality_report_time || _state.running.last_quality_report_time + QUALITY_REPORT_INTERVAL < now) {
UdpMsg *msg = new UdpMsg(UdpMsg::QualityReport);
msg->u.quality_report.ping = GGPOPlatform::GetCurrentTimeMS();
msg->u.quality_report.frame_advantage = (uint8)_local_frame_advantage;
SendMsg(msg);
_state.running.last_quality_report_time = now;
}
if (!_state.running.last_network_stats_interval || _state.running.last_network_stats_interval + NETWORK_STATS_INTERVAL < now) {
UpdateNetworkStats();
_state.running.last_network_stats_interval = now;
}
if (_last_send_time && _last_send_time + KEEP_ALIVE_INTERVAL < now) {
Log("Sending keep alive packet\n");
SendMsg(new UdpMsg(UdpMsg::KeepAlive));
}
if (_disconnect_timeout && _disconnect_notify_start &&
!_disconnect_notify_sent && (_last_recv_time + _disconnect_notify_start < now)) {
Log("Endpoint has stopped receiving packets for %d ms. Sending notification.\n", _disconnect_notify_start);
Event e(Event::NetworkInterrupted);
e.u.network_interrupted.disconnect_timeout = _disconnect_timeout - _disconnect_notify_start;
QueueEvent(e);
_disconnect_notify_sent = true;
}
if (_disconnect_timeout && (_last_recv_time + _disconnect_timeout < now)) {
if (!_disconnect_event_sent) {
Log("Endpoint has stopped receiving packets for %d ms. Disconnecting.\n", _disconnect_timeout);
QueueEvent(Event(Event::Disconnected));
_disconnect_event_sent = true;
}
}
break;
case Disconnected:
if (_shutdown_timeout < now) {
Log("Shutting down udp connection.\n");
_udp = NULL;
_shutdown_timeout = 0;
}
break;
default:
break;
}
return true;
}
void
UdpProtocol::Disconnect()
{
_current_state = Disconnected;
_shutdown_timeout = GGPOPlatform::GetCurrentTimeMS() + UDP_SHUTDOWN_TIMER;
}
void
UdpProtocol::SendSyncRequest()
{
_state.sync.random = rand() & 0xFFFF;
UdpMsg *msg = new UdpMsg(UdpMsg::SyncRequest);
msg->u.sync_request.random_request = _state.sync.random;
msg->verification_size = verification.size();
if (!verification.empty())
memcpy(&msg->u.sync_request.verification[0], &verification[0], verification.size());
SendMsg(msg);
}
void
UdpProtocol::SendMsg(UdpMsg *msg)
{
LogMsg("send", msg);
{
std::lock_guard<std::mutex> lock(_send_mutex);
_packets_sent++;
_last_send_time = GGPOPlatform::GetCurrentTimeMS();
_bytes_sent += msg->PacketSize();
msg->hdr.magic = _magic_number;
msg->hdr.sequence_number = _next_send_seq++;
_send_queue.push(QueueEntry(GGPOPlatform::GetCurrentTimeMS(), _peer_addr, msg));
}
PumpSendQueue();
}
bool
UdpProtocol::HandlesMsg(sockaddr_in &from,
UdpMsg *msg)
{
if (!_udp) {
return false;
}
if (_peer_addr.sin_addr.s_addr == 0)
{
_peer_addr.sin_addr.s_addr = from.sin_addr.s_addr;
_peer_addr.sin_port = from.sin_port;
return true;
}
return _peer_addr.sin_addr.s_addr == from.sin_addr.s_addr &&
_peer_addr.sin_port == from.sin_port;
}
void
UdpProtocol::OnMsg(UdpMsg *msg, int len)
{
bool handled = false;
typedef bool (UdpProtocol::*DispatchFn)(UdpMsg *msg, int len);
static const DispatchFn table[] = {
&UdpProtocol::OnInvalid, /* Invalid */
&UdpProtocol::OnSyncRequest, /* SyncRequest */
&UdpProtocol::OnSyncReply, /* SyncReply */
&UdpProtocol::OnInput, /* Input */
&UdpProtocol::OnQualityReport, /* QualityReport */
&UdpProtocol::OnQualityReply, /* QualityReply */
&UdpProtocol::OnKeepAlive, /* KeepAlive */
&UdpProtocol::OnInputAck, /* InputAck */
&UdpProtocol::OnAppData, /* AppData */
};
// filter out messages that don't match what we expect
uint16 seq = msg->hdr.sequence_number;
if (msg->hdr.type != UdpMsg::SyncRequest &&
msg->hdr.type != UdpMsg::SyncReply) {
if (msg->hdr.magic != _remote_magic_number) {
LogMsg("recv rejecting", msg);
return;
}
// filter out out-of-order packets
uint16 skipped = (uint16)((int)seq - (int)_next_recv_seq);
// Log("checking sequence number -> next - seq : %d - %d = %d\n", seq, _next_recv_seq, skipped);
if (skipped > MAX_SEQ_DISTANCE) {
Log("dropping out of order packet (seq: %d, last seq:%d)\n", seq, _next_recv_seq);
return;
}
}
_next_recv_seq = seq;
LogMsg("recv", msg);
if (msg->hdr.type >= ARRAY_SIZE(table)) {
OnInvalid(msg, len);
} else {
handled = (this->*(table[msg->hdr.type]))(msg, len);
}
if (handled) {
_last_recv_time = GGPOPlatform::GetCurrentTimeMS();
if (_disconnect_notify_sent && _current_state == Running) {
QueueEvent(Event(Event::NetworkResumed));
_disconnect_notify_sent = false;
}
}
}
void
UdpProtocol::UpdateNetworkStats(void)
{
int now = GGPOPlatform::GetCurrentTimeMS();
if (_stats_start_time == 0) {
_stats_start_time = now;
}
int total_bytes_sent = _bytes_sent + (UDP_HEADER_SIZE * _packets_sent);
float seconds = (float)((now - _stats_start_time) / 1000.0);
float Bps = total_bytes_sent / seconds;
float udp_overhead = (float)(100.0 * (UDP_HEADER_SIZE * _packets_sent) / _bytes_sent);
_kbps_sent = int(Bps / 1024);
Log("Network Stats -- Bandwidth: %.2f KBps Packets Sent: %5d (%.2f pps) "
"KB Sent: %.2f UDP Overhead: %.2f %%.\n",
_kbps_sent,
_packets_sent,
(float)_packets_sent * 1000 / (now - _stats_start_time),
total_bytes_sent / 1024.0,
udp_overhead);
}
void
UdpProtocol::QueueEvent(const UdpProtocol::Event &evt)
{
LogEvent("Queuing event", evt);
_event_queue.push(evt);
}
void
UdpProtocol::Synchronize()
{
if (_udp) {
_current_state = Syncing;
_state.sync.roundtrips_remaining = NUM_SYNC_PACKETS;
if (_peer_addr.sin_addr.s_addr != 0)
SendSyncRequest();
}
}
bool
UdpProtocol::GetPeerConnectStatus(int id, int *frame)
{
*frame = _peer_connect_status[id].last_frame;
return !_peer_connect_status[id].disconnected;
}
void
UdpProtocol::Log(const char *fmt, ...)
{
char buf[1024];
size_t offset;
va_list args;
snprintf(buf, ARRAY_SIZE(buf), "udpproto%d | ", _queue);
offset = strlen(buf);
va_start(args, fmt);
vsnprintf(buf + offset, ARRAY_SIZE(buf) - offset - 1, fmt, args);
buf[ARRAY_SIZE(buf)-1] = '\0';
::Log(buf);
va_end(args);
}
void
UdpProtocol::LogMsg(const char *prefix, UdpMsg *msg)
{
switch (msg->hdr.type) {
case UdpMsg::SyncRequest:
Log("%s sync-request (%d).\n", prefix,
msg->u.sync_request.random_request);
break;
case UdpMsg::SyncReply:
Log("%s sync-reply (%d).\n", prefix,
msg->u.sync_reply.random_reply);
break;
case UdpMsg::QualityReport:
Log("%s quality report.\n", prefix);
break;
case UdpMsg::QualityReply:
Log("%s quality reply.\n", prefix);
break;
case UdpMsg::KeepAlive:
Log("%s keep alive.\n", prefix);
break;
case UdpMsg::Input:
Log("%s game-compressed-input %d (+ %d bits).\n", prefix, msg->u.input.start_frame, msg->u.input.num_bits);
break;
case UdpMsg::InputAck:
Log("%s input ack.\n", prefix);
break;
case UdpMsg::AppData:
Log("%s app data (%d bytes).\n", prefix, msg->u.app_data.size);
break;
default:
ASSERT(false && "Unknown UdpMsg type.");
}
}
void
UdpProtocol::LogEvent(const char *prefix, const UdpProtocol::Event &evt)
{
if (evt.type == UdpProtocol::Event::Synchronzied)
Log("%s (event: Synchronzied).\n", prefix);
}
bool
UdpProtocol::OnInvalid(UdpMsg *msg, int len)
{
ASSERT(false && "Invalid msg in UdpProtocol");
return false;
}
bool
UdpProtocol::OnSyncRequest(UdpMsg *msg, int len)
{
if (_remote_magic_number != 0 && msg->hdr.magic != _remote_magic_number) {
Log("Ignoring sync request from unknown endpoint (%d != %d).\n",
msg->hdr.magic, _remote_magic_number);
return false;
}
UdpMsg *reply = new UdpMsg(UdpMsg::SyncReply);
reply->u.sync_reply.random_reply = msg->u.sync_request.random_request;
// Calculate incoming verif data size
msg->verification_size = 0;
int msgVerifSize = len - msg->PacketSize();
if (msgVerifSize != (int)verification.size()
|| (msgVerifSize != 0 && memcmp(&msg->u.sync_request.verification[0], &verification[0], msgVerifSize)))
{
Log("Verification mismatch: size received %d expected %d", msgVerifSize, (int)verification.size());
reply->u.sync_reply.verification_failure = 1;
SendMsg(reply);
throw GGPOException("Verification mismatch", GGPO_ERRORCODE_VERIFICATION_ERROR);
}
// FIXME
if (_state.sync.roundtrips_remaining == NUM_SYNC_PACKETS && msg->hdr.sequence_number == 0) {
Log("Sync request 0 received... Re-queueing sync packet.\n");
SendSyncRequest();
}
reply->u.sync_reply.verification_failure = 0;
SendMsg(reply);
return true;
}
bool
UdpProtocol::OnSyncReply(UdpMsg *msg, int len)
{
if (_current_state != Syncing) {
Log("Ignoring SyncReply while not synching.\n");
return msg->hdr.magic == _remote_magic_number;
}
if (msg->u.sync_reply.random_reply != _state.sync.random) {
Log("sync reply %d != %d. Keep looking...\n",
msg->u.sync_reply.random_reply, _state.sync.random);
return false;
}
if (msg->u.sync_reply.verification_failure == 1)
throw GGPOException("Peer reported verification failure", GGPO_ERRORCODE_VERIFICATION_ERROR);
if (!_connected) {
QueueEvent(Event(Event::Connected));
_connected = true;
}
Log("Checking sync state (%d round trips remaining).\n", _state.sync.roundtrips_remaining);
if (--_state.sync.roundtrips_remaining == 0) {
Log("Synchronized!\n");
QueueEvent(UdpProtocol::Event(UdpProtocol::Event::Synchronzied));
_current_state = Running;
_last_received_input.frame = -1;
_remote_magic_number = msg->hdr.magic;
} else {
UdpProtocol::Event evt(UdpProtocol::Event::Synchronizing);
evt.u.synchronizing.total = NUM_SYNC_PACKETS;
evt.u.synchronizing.count = NUM_SYNC_PACKETS - _state.sync.roundtrips_remaining;
QueueEvent(evt);
SendSyncRequest();
}
return true;
}
bool
UdpProtocol::OnInput(UdpMsg *msg, int len)
{
/*
* If a disconnect is requested, go ahead and disconnect now.
*/
bool disconnect_requested = msg->u.input.disconnect_requested;
if (disconnect_requested) {
if (_current_state != Disconnected && !_disconnect_event_sent) {
Log("Disconnecting endpoint on remote request.\n");
QueueEvent(Event(Event::Disconnected));
_disconnect_event_sent = true;
}
} else {
/*
* Update the peer connection status if this peer is still considered to be part
* of the network.
*/
UdpMsg::connect_status* remote_status = msg->u.input.peer_connect_status;
for (unsigned i = 0; i < ARRAY_SIZE(_peer_connect_status); i++) {
ASSERT(remote_status[i].last_frame >= _peer_connect_status[i].last_frame);
_peer_connect_status[i].disconnected = _peer_connect_status[i].disconnected || remote_status[i].disconnected;
_peer_connect_status[i].last_frame = MAX(_peer_connect_status[i].last_frame, remote_status[i].last_frame);
}
}
/*
* Decompress the input.
*/
int last_received_frame_number = _last_received_input.frame;
if (msg->u.input.num_bits) {
int offset = 0;
uint8 *bits = (uint8 *)msg->u.input.bits;
int numBits = msg->u.input.num_bits;
int currentFrame = msg->u.input.start_frame;
_last_received_input.size = msg->u.input.input_size;
if (_last_received_input.frame < 0) {
_last_received_input.frame = msg->u.input.start_frame - 1;
}
while (offset < numBits) {
/*
* Keep walking through the frames (parsing bits) until we reach
* the inputs for the frame right after the one we're on.
*/
ASSERT(currentFrame <= (_last_received_input.frame + 1));
bool useInputs = currentFrame == _last_received_input.frame + 1;
while (BitVector_ReadBit(bits, &offset)) {
int on = BitVector_ReadBit(bits, &offset);
int button = BitVector_ReadNibblet(bits, &offset);
if (useInputs) {
if (on) {
_last_received_input.set(button);
} else {
_last_received_input.clear(button);
}
}
}
ASSERT(offset <= numBits);
/*
* Now if we want to use these inputs, go ahead and send them to
* the emulator.
*/
if (useInputs) {
/*
* Move forward 1 frame in the stream.
*/
char desc[1024];
ASSERT(currentFrame == _last_received_input.frame + 1);
_last_received_input.frame = currentFrame;
/*
* Send the event to the emualtor
*/
UdpProtocol::Event evt(UdpProtocol::Event::Input);
evt.u.input.input = _last_received_input;
_last_received_input.desc(desc, ARRAY_SIZE(desc));
_state.running.last_input_packet_recv_time = GGPOPlatform::GetCurrentTimeMS();
Log("Sending frame %d to emu queue %d (%s).\n", _last_received_input.frame, _queue, desc);
QueueEvent(evt);
} else {
Log("Skipping past frame:(%d) current is %d.\n", currentFrame, _last_received_input.frame);
}
/*
* Move forward 1 frame in the input stream.
*/
currentFrame++;
}
}
ASSERT(_last_received_input.frame >= last_received_frame_number);
/*
* Get rid of our buffered input
*/
while (_pending_output.size() && _pending_output.front().frame < msg->u.input.ack_frame) {
Log("Throwing away pending output frame %d\n", _pending_output.front().frame);
_last_acked_input = _pending_output.front();
_pending_output.pop();
}
return true;
}
bool
UdpProtocol::OnInputAck(UdpMsg *msg, int len)
{
/*
* Get rid of our buffered input
*/
while (_pending_output.size() && _pending_output.front().frame < msg->u.input_ack.ack_frame) {
Log("Throwing away pending output frame %d\n", _pending_output.front().frame);
_last_acked_input = _pending_output.front();
_pending_output.pop();
}
return true;
}
bool
UdpProtocol::OnQualityReport(UdpMsg *msg, int len)
{
// send a reply so the other side can compute the round trip transmit time.
UdpMsg *reply = new UdpMsg(UdpMsg::QualityReply);
reply->u.quality_reply.pong = msg->u.quality_report.ping;
SendMsg(reply);
_remote_frame_advantage = msg->u.quality_report.frame_advantage;
return true;
}
bool
UdpProtocol::OnQualityReply(UdpMsg *msg, int len)
{
_round_trip_time = GGPOPlatform::GetCurrentTimeMS() - msg->u.quality_reply.pong;
return true;
}
bool
UdpProtocol::OnKeepAlive(UdpMsg *msg, int len)
{
return true;
}
void
UdpProtocol::GetNetworkStats(struct GGPONetworkStats *s)
{
s->network.ping = _round_trip_time;
s->network.send_queue_len = _pending_output.size();
s->network.kbps_sent = _kbps_sent;
s->timesync.remote_frames_behind = _remote_frame_advantage;
s->timesync.local_frames_behind = _local_frame_advantage;
}
void
UdpProtocol::SetLocalFrameNumber(int localFrame)
{
/*
* Estimate which frame the other guy is one by looking at the
* last frame they gave us plus some delta for the one-way packet
* trip time.
*/
int remoteFrame = _last_received_input.frame + (_round_trip_time * 60 / 1000);
/*
* Our frame advantage is how many frames *behind* the other guy
* we are. Counter-intuative, I know. It's an advantage because
* it means they'll have to predict more often and our moves will
* pop more frequenetly.
*/
_local_frame_advantage = remoteFrame - localFrame;
}
int
UdpProtocol::RecommendFrameDelay()
{
// XXX: require idle input should be a configuration parameter
return _timesync.recommend_frame_wait_duration(false);
}
void
UdpProtocol::SetDisconnectTimeout(int timeout)
{
_disconnect_timeout = timeout;
}
void
UdpProtocol::SetDisconnectNotifyStart(int timeout)
{
_disconnect_notify_start = timeout;
}
void
UdpProtocol::PumpSendQueue()
{
std::lock_guard<std::mutex> lock(_send_mutex);
while (!_send_queue.empty()) {
QueueEntry &entry = _send_queue.front();
if (_send_latency) {
// should really come up with a gaussian distributation based on the configured
// value, but this will do for now.
int jitter = (_send_latency * 2 / 3) + ((rand() % _send_latency) / 3);
if ((int)GGPOPlatform::GetCurrentTimeMS() < _send_queue.front().queue_time + jitter) {
break;
}
}
if (_oop_percent && !_oo_packet.msg && ((rand() % 100) < _oop_percent)) {
int delay = rand() % (_send_latency * 10 + 1000);
Log("creating rogue oop (seq: %d delay: %d)\n", entry.msg->hdr.sequence_number, delay);
_oo_packet.send_time = GGPOPlatform::GetCurrentTimeMS() + delay;
_oo_packet.msg = entry.msg;
_oo_packet.dest_addr = entry.dest_addr;
} else {
ASSERT(entry.dest_addr.sin_addr.s_addr);
_udp->SendTo((char *)entry.msg, entry.msg->PacketSize(), 0,
(struct sockaddr *)&entry.dest_addr, sizeof entry.dest_addr);
delete entry.msg;
}
_send_queue.pop();
}
if (_oo_packet.msg && _oo_packet.send_time < (int)GGPOPlatform::GetCurrentTimeMS()) {
Log("sending rogue oop!");
_udp->SendTo((char *)_oo_packet.msg, _oo_packet.msg->PacketSize(), 0,
(struct sockaddr *)&_oo_packet.dest_addr, sizeof _oo_packet.dest_addr);
delete _oo_packet.msg;
_oo_packet.msg = NULL;
}
}
void
UdpProtocol::ClearSendQueue()
{
std::lock_guard<std::mutex> lock(_send_mutex);
while (!_send_queue.empty()) {
delete _send_queue.front().msg;
_send_queue.pop();
}
}
void UdpProtocol::SendAppData(const void *data, int len, bool spectators)
{
if (_udp == nullptr)
return;
if (_current_state != Synchronzied && _current_state != Running)
return;
UdpMsg *msg = new UdpMsg(UdpMsg::AppData);
msg->u.app_data.spectators = spectators;
msg->u.app_data.size = len;
memcpy(msg->u.app_data.data, data, len);
SendMsg(msg);
}
bool UdpProtocol::OnAppData(UdpMsg *msg, int len)
{
UdpProtocol::Event evt(UdpProtocol::Event::AppData);
evt.u.app_data.spectators = msg->u.app_data.spectators != 0;
evt.u.app_data.size = msg->u.app_data.size;
memcpy(evt.u.app_data.data, msg->u.app_data.data, msg->u.app_data.size);
QueueEvent(evt);
return true;
}
+224
View File
@@ -0,0 +1,224 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _UDP_PROTO_H_
#define _UDP_PROTO_H_
#include "ggpo_poll.h"
#include "udp.h"
#include "udp_msg.h"
#include "game_input.h"
#include "timesync.h"
#include "ggponet.h"
#include "ring_buffer.h"
#include <vector>
#include <mutex>
class UdpProtocol : public IPollSink
{
public:
struct Stats {
int ping;
int remote_frame_advantage;
int local_frame_advantage;
int send_queue_len;
Udp::Stats udp;
};
struct Event {
enum Type {
Unknown = -1,
Connected,
Synchronizing,
Synchronzied,
Input,
Disconnected,
NetworkInterrupted,
NetworkResumed,
AppData,
};
Type type;
union {
struct {
GameInput input;
} input;
struct {
int total;
int count;
} synchronizing;
struct {
int disconnect_timeout;
} network_interrupted;
struct {
bool spectators;
int size;
uint8 data[MAX_APPDATA_SIZE];
} app_data;
} u;
Event(Type t = Unknown) : type(t) { }
};
public:
virtual bool OnLoopPoll(void *cookie);
public:
UdpProtocol();
virtual ~UdpProtocol();
void Init(Udp *udp, Poll &p, int queue, char *ip, u_short port, UdpMsg::connect_status *status);
void Synchronize();
bool GetPeerConnectStatus(int id, int *frame);
bool IsInitialized() { return _udp != NULL; }
bool IsSynchronized() { return _current_state == Running; }
bool IsRunning() { return _current_state == Running; }
void SendInput(GameInput &input);
void SendInputAck();
bool HandlesMsg(sockaddr_in &from, UdpMsg *msg);
void OnMsg(UdpMsg *msg, int len);
void Disconnect();
void SendAppData(const void *data, int len, bool spectators);
void GetNetworkStats(struct GGPONetworkStats *stats);
bool GetEvent(UdpProtocol::Event &e);
void GGPONetworkStats(Stats *stats);
void SetLocalFrameNumber(int num);
int RecommendFrameDelay();
void SetVerificationData(const void *verification, int verification_size) {
ASSERT(verification_size <= MAX_VERIFICATION_SIZE);
this->verification.resize(verification_size);
memcpy(&this->verification[0], verification, verification_size);
}
void SetDisconnectTimeout(int timeout);
void SetDisconnectNotifyStart(int timeout);
protected:
enum State {
Syncing,
Synchronzied,
Running,
Disconnected
};
struct QueueEntry {
int queue_time;
sockaddr_in dest_addr;
UdpMsg *msg;
QueueEntry() {}
QueueEntry(int time, sockaddr_in &dst, UdpMsg *m) : queue_time(time), dest_addr(dst), msg(m) { }
};
bool CreateSocket(int retries);
void UpdateNetworkStats(void);
void QueueEvent(const UdpProtocol::Event &evt);
void ClearSendQueue(void);
void Log(const char *fmt, ...);
void LogMsg(const char *prefix, UdpMsg *msg);
void LogEvent(const char *prefix, const UdpProtocol::Event &evt);
void SendSyncRequest();
void SendMsg(UdpMsg *msg);
void PumpSendQueue();
void SendPendingOutput();
bool OnInvalid(UdpMsg *msg, int len);
bool OnSyncRequest(UdpMsg *msg, int len);
bool OnSyncReply(UdpMsg *msg, int len);
bool OnInput(UdpMsg *msg, int len);
bool OnInputAck(UdpMsg *msg, int len);
bool OnQualityReport(UdpMsg *msg, int len);
bool OnQualityReply(UdpMsg *msg, int len);
bool OnKeepAlive(UdpMsg *msg, int len);
bool OnAppData(UdpMsg *msg, int len);
protected:
/*
* Network transmission information
*/
Udp *_udp;
sockaddr_in _peer_addr;
uint16 _magic_number;
int _queue;
uint16 _remote_magic_number;
bool _connected;
int _send_latency;
int _oop_percent;
struct {
int send_time;
sockaddr_in dest_addr;
UdpMsg* msg;
} _oo_packet;
RingBuffer<QueueEntry, 64> _send_queue;
std::mutex _send_mutex;
std::vector<uint8> verification;
/*
* Stats
*/
int _round_trip_time;
int _packets_sent;
int _bytes_sent;
int _kbps_sent;
int _stats_start_time;
/*
* The state machine
*/
UdpMsg::connect_status *_local_connect_status;
UdpMsg::connect_status _peer_connect_status[UDP_MSG_MAX_PLAYERS];
State _current_state;
union {
struct {
uint32 roundtrips_remaining;
uint32 random;
} sync;
struct {
uint32 last_quality_report_time;
uint32 last_network_stats_interval;
uint32 last_input_packet_recv_time;
} running;
} _state;
/*
* Fairness.
*/
int _local_frame_advantage;
int _remote_frame_advantage;
/*
* Packet loss...
*/
RingBuffer<GameInput, 64> _pending_output;
GameInput _last_received_input;
GameInput _last_sent_input;
GameInput _last_acked_input;
unsigned int _last_send_time;
unsigned int _last_recv_time;
unsigned int _shutdown_timeout;
unsigned int _disconnect_event_sent;
unsigned int _disconnect_timeout;
unsigned int _disconnect_notify_start;
bool _disconnect_notify_sent;
uint16 _next_send_seq;
uint16 _next_recv_seq;
/*
* Rift synchronization.
*/
TimeSync _timesync;
/*
* Event queue
*/
RingBuffer<UdpProtocol::Event, 64> _event_queue;
};
#endif
@@ -0,0 +1,38 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#if defined(__unix__) || defined(__APPLE__) || defined(__SWITCH__)
#include "platform_linux.h"
#include <time.h>
#include <strings.h>
#include <chrono>
uint32_t GGPOPlatform::GetCurrentTimeMS()
{
using namespace std::chrono;
static steady_clock::time_point startTime = steady_clock::now();
return (uint32_t)duration_cast<milliseconds>(steady_clock::now() - startTime).count();
}
int GGPOPlatform::GetConfigInt(const char* name)
{
char *buf = getenv(name);
if (buf == nullptr)
return 0;
return atoi(buf);
}
bool GGPOPlatform::GetConfigBool(const char* name)
{
char *buf = getenv(name);
if (buf == nullptr)
return false;
return atoi(buf) != 0 || strcasecmp(buf, "true") == 0;
}
#endif
+69
View File
@@ -0,0 +1,69 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _GGPO_LINUX_H_
#define _GGPO_LINUX_H_
#include <limits>
#include <stdio.h>
#include <stdarg.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <cstdint>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#ifdef __SWITCH__
#include "nswitch.h"
#else
#include <netinet/ip.h>
#endif
#include <netinet/tcp.h>
#include <arpa/inet.h>
using SOCKET = int;
#define closesocket close
#define INVALID_SOCKET (-1)
#define SOCKET_ERROR (-1)
#define WSAEWOULDBLOCK EWOULDBLOCK
constexpr size_t MAX_PATH = 4096;
#ifdef INT_MAX
#undef INT_MAX
#endif
constexpr int INT_MAX = std::numeric_limits<int>::max();
class GGPOPlatform {
public: // types
typedef pid_t ProcessID;
public: // functions
static ProcessID GetProcessID() { return getpid(); }
static void AssertFailed(char *msg) { fprintf(stderr, "%s", msg); }
static uint32_t GetCurrentTimeMS();
static int GetConfigInt(const char* name);
static bool GetConfigBool(const char* name);
};
extern "C" {
inline static void DebugBreak()
{
__builtin_trap();
}
inline static int WSAGetLastError() {
return errno;
}
}
#endif
@@ -0,0 +1,28 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifdef _WIN32
#include "platform_windows.h"
int
GGPOPlatform::GetConfigInt(const char* name)
{
char buf[1024];
if (GetEnvironmentVariableA(name, buf, ARRAY_SIZE(buf)) == 0) {
return 0;
}
return atoi(buf);
}
bool GGPOPlatform::GetConfigBool(const char* name)
{
char buf[1024];
if (GetEnvironmentVariableA(name, buf, ARRAY_SIZE(buf)) == 0) {
return false;
}
return atoi(buf) != 0 || _stricmp(buf, "true") == 0;
}
#endif
@@ -0,0 +1,44 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _GGPO_WINDOWS_H_
#define _GGPO_WINDOWS_H_
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#include <stdio.h>
#include <chrono>
#include "ggpo_types.h"
class GGPOPlatform {
public: // types
typedef DWORD ProcessID;
public: // functions
static ProcessID GetProcessID() { return GetCurrentProcessId(); }
static void AssertFailed(char *msg) {
#ifndef TARGET_UWP
MessageBoxA(NULL, msg, "GGPO Assertion Failed", MB_OK | MB_ICONEXCLAMATION);
#endif
}
static uint32 GetCurrentTimeMS() {
#ifdef TARGET_UWP
using namespace std::chrono;
static steady_clock::time_point startTime = steady_clock::now();
return (uint32_t)duration_cast<milliseconds>(steady_clock::now() - startTime).count();
#else
return timeGetTime();
#endif
}
static int GetConfigInt(const char* name);
static bool GetConfigBool(const char* name);
};
#endif
+127
View File
@@ -0,0 +1,127 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#include "ggpo_poll.h"
#include "ggpo_types.h"
#ifndef _WIN32
#include <chrono>
#include <thread>
constexpr int INFINITE = -1;
#endif
Poll::Poll(void) :
_start_time(0),
_handle_count(0)
{
/*
* Create a dummy handle to simplify things.
*/
#ifdef _WIN32
_handles[_handle_count++] = CreateEvent(NULL, true, false, NULL);
#endif
}
#if 0
void
Poll::RegisterHandle(IPollSink *sink, HANDLE h, void *cookie)
{
ASSERT(_handle_count < MAX_POLLABLE_HANDLES - 1);
_handles[_handle_count] = h;
_handle_sinks[_handle_count] = PollSinkCb(sink, cookie);
_handle_count++;
}
#endif
void
Poll::RegisterMsgLoop(IPollSink *sink, void *cookie)
{
_msg_sinks.push_back(PollSinkCb(sink, cookie));
}
void
Poll::RegisterLoop(IPollSink *sink, void *cookie)
{
_loop_sinks.push_back(PollSinkCb(sink, cookie));
}
void
Poll::RegisterPeriodic(IPollSink *sink, int interval, void *cookie)
{
_periodic_sinks.push_back(PollPeriodicSinkCb(sink, cookie, interval));
}
void
Poll::Run()
{
while (Pump(100)) {
continue;
}
}
bool
Poll::Pump(int timeout)
{
int i;
bool finished = false;
if (_start_time == 0) {
_start_time = GGPOPlatform::GetCurrentTimeMS();
}
int elapsed = GGPOPlatform::GetCurrentTimeMS() - _start_time;
int maxwait = ComputeWaitTime(elapsed);
if (maxwait != INFINITE) {
timeout = MIN(timeout, maxwait);
}
#ifdef _WIN32
DWORD res = WaitForMultipleObjects(_handle_count, _handles, false, timeout);
if (res >= WAIT_OBJECT_0 && res < WAIT_OBJECT_0 + _handle_count) {
i = res - WAIT_OBJECT_0;
finished = !_handle_sinks[i].sink->OnHandlePoll(_handle_sinks[i].cookie) || finished;
}
#else
if (timeout > 0)
std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
#endif
for (i = 0; i < _msg_sinks.size(); i++) {
PollSinkCb &cb = _msg_sinks[i];
finished = !cb.sink->OnMsgPoll(cb.cookie) || finished;
}
for (i = 0; i < _periodic_sinks.size(); i++) {
PollPeriodicSinkCb &cb = _periodic_sinks[i];
if (cb.interval + cb.last_fired <= elapsed) {
cb.last_fired = (elapsed / cb.interval) * cb.interval;
finished = !cb.sink->OnPeriodicPoll(cb.cookie, cb.last_fired) || finished;
}
}
for (i = 0; i < _loop_sinks.size(); i++) {
PollSinkCb &cb = _loop_sinks[i];
finished = !cb.sink->OnLoopPoll(cb.cookie) || finished;
}
return finished;
}
int
Poll::ComputeWaitTime(int elapsed)
{
int waitTime = INFINITE;
size_t count = _periodic_sinks.size();
if (count > 0) {
for (size_t i = 0; i < count; i++) {
PollPeriodicSinkCb &cb = _periodic_sinks[i];
int timeout = (cb.interval + cb.last_fired) - elapsed;
if (waitTime == INFINITE || (timeout < waitTime)) {
waitTime = MAX(timeout, 0);
}
}
}
return waitTime;
}
+60
View File
@@ -0,0 +1,60 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _RING_BUFFER_H
#define _RING_BUFFER_H
#include "ggpo_types.h"
template<class T, int N> class RingBuffer
{
public:
RingBuffer<T, N>() :
_head(0),
_tail(0),
_size(0) {
}
T &front() {
ASSERT(_size != N);
return _elements[_tail];
}
T &item(int i) {
ASSERT(i < _size);
return _elements[(_tail + i) % N];
}
void pop() {
ASSERT(_size != N);
_tail = (_tail + 1) % N;
_size--;
}
void push(const T &t) {
ASSERT(_size != (N-1));
_elements[_head] = t;
_head = (_head + 1) % N;
_size++;
}
int size() {
return _size;
}
bool empty() {
return _size == 0;
}
protected:
T _elements[N];
int _head;
int _tail;
int _size;
};
#endif
+40
View File
@@ -0,0 +1,40 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _STATIC_BUFFER_H
#define _STATIC_BUFFER_H
#include "ggpo_types.h"
template<class T, int N> class StaticBuffer
{
public:
StaticBuffer<T, N>() :
_size(0) {
}
T& operator[](int i) {
ASSERT(i >= 0 && i < _size);
return _elements[i];
}
void push_back(const T &t) {
ASSERT(_size != (N-1));
_elements[_size++] = t;
}
int size() {
return _size;
}
protected:
T _elements[N];
int _size;
};
#endif
+304
View File
@@ -0,0 +1,304 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#include "sync.h"
Sync::Sync(UdpMsg::connect_status *connect_status) :
_input_queues(NULL),
_local_connect_status(connect_status)
{
_framecount = 0;
_last_confirmed_frame = -1;
_max_prediction_frames = 0;
memset(&_savedstate, 0, sizeof(_savedstate));
}
Sync::~Sync()
{
/*
* Delete frames manually here rather than in a destructor of the SavedFrame
* structure so we can efficently copy frames via weak references.
*/
for (size_t i = 0; i < ARRAY_SIZE(_savedstate.frames); i++) {
_callbacks.free_buffer(_savedstate.frames[i].buf);
}
delete [] _input_queues;
_input_queues = NULL;
}
void
Sync::Init(Sync::Config &config)
{
_config = config;
_callbacks = config.callbacks;
_framecount = 0;
_rollingback = false;
_max_prediction_frames = config.num_prediction_frames;
CreateQueues(config);
}
void
Sync::SetLastConfirmedFrame(int frame)
{
_last_confirmed_frame = frame;
if (_last_confirmed_frame > 0) {
for (int i = 0; i < _config.num_players; i++) {
_input_queues[i].DiscardConfirmedFrames(frame - 1);
}
}
}
bool
Sync::AddLocalInput(int queue, GameInput &input)
{
int frames_behind = _framecount - _last_confirmed_frame;
if (_framecount >= _max_prediction_frames && frames_behind >= _max_prediction_frames) {
Log("Rejecting input from emulator: reached prediction barrier.\n");
return false;
}
if (_framecount == 0) {
SaveCurrentFrame();
}
Log("Sending undelayed local frame %d to queue %d.\n", _framecount, queue);
input.frame = _framecount;
_input_queues[queue].AddInput(input);
return true;
}
void
Sync::AddRemoteInput(int queue, GameInput &input)
{
_input_queues[queue].AddInput(input);
}
int
Sync::GetConfirmedInputs(void *values, int size, int frame)
{
int disconnect_flags = 0;
char *output = (char *)values;
ASSERT(size >= _config.num_players * _config.input_size);
memset(output, 0, size);
for (int i = 0; i < _config.num_players; i++) {
GameInput input;
if (_local_connect_status[i].disconnected && frame > _local_connect_status[i].last_frame) {
disconnect_flags |= (1 << i);
input.erase();
} else {
_input_queues[i].GetConfirmedInput(frame, &input);
}
memcpy(output + (i * _config.input_size), input.bits, _config.input_size);
}
return disconnect_flags;
}
int
Sync::SynchronizeInputs(void *values, int size)
{
int disconnect_flags = 0;
char *output = (char *)values;
ASSERT(size >= _config.num_players * _config.input_size);
memset(output, 0, size);
for (int i = 0; i < _config.num_players; i++) {
GameInput input;
if (_local_connect_status[i].disconnected && _framecount > _local_connect_status[i].last_frame) {
disconnect_flags |= (1 << i);
input.erase();
} else {
_input_queues[i].GetInput(_framecount, &input);
}
memcpy(output + (i * _config.input_size), input.bits, _config.input_size);
}
return disconnect_flags;
}
void
Sync::CheckSimulation(int timeout)
{
int seek_to;
if (!CheckSimulationConsistency(&seek_to)) {
AdjustSimulation(seek_to);
}
}
void
Sync::IncrementFrame(void)
{
_framecount++;
SaveCurrentFrame();
}
void
Sync::AdjustSimulation(int seek_to)
{
int framecount = _framecount;
int count = _framecount - seek_to;
Log("Catching up\n");
_rollingback = true;
/*
* Flush our input queue and load the last frame.
*/
LoadFrame(seek_to);
ASSERT(_framecount == seek_to);
/*
* Advance frame by frame (stuffing notifications back to
* the master).
*/
ResetPrediction(_framecount);
for (int i = 0; i < count; i++) {
_callbacks.advance_frame(0);
}
ASSERT(_framecount == framecount);
_rollingback = false;
Log("---\n");
}
void
Sync::LoadFrame(int frame)
{
// find the frame in question
if (frame == _framecount) {
Log("Skipping NOP.\n");
return;
}
// Move the head pointer back and load it up
_savedstate.head = FindSavedFrameIndex(frame);
SavedFrame *state = _savedstate.frames + _savedstate.head;
Log("=== Loading frame info %d (size: %d checksum: %08x).\n",
state->frame, state->cbuf, state->checksum);
ASSERT(state->buf && state->cbuf);
_callbacks.load_game_state(state->buf, state->cbuf);
// Reset framecount and the head of the state ring-buffer to point in
// advance of the current frame (as if we had just finished executing it).
_framecount = state->frame;
_savedstate.head = (_savedstate.head + 1) % ARRAY_SIZE(_savedstate.frames);
}
void
Sync::SaveCurrentFrame()
{
/*
* See StateCompress for the real save feature implemented by FinalBurn.
* Write everything into the head, then advance the head pointer.
*/
SavedFrame *state = _savedstate.frames + _savedstate.head;
if (state->buf) {
_callbacks.free_buffer(state->buf);
state->buf = NULL;
}
state->frame = _framecount;
_callbacks.save_game_state(&state->buf, &state->cbuf, &state->checksum, state->frame);
Log("=== Saved frame info %d (size: %d checksum: %08x).\n", state->frame, state->cbuf, state->checksum);
_savedstate.head = (_savedstate.head + 1) % ARRAY_SIZE(_savedstate.frames);
}
Sync::SavedFrame&
Sync::GetLastSavedFrame()
{
int i = _savedstate.head - 1;
if (i < 0) {
i = ARRAY_SIZE(_savedstate.frames) - 1;
}
return _savedstate.frames[i];
}
int
Sync::FindSavedFrameIndex(int frame)
{
int i, count = ARRAY_SIZE(_savedstate.frames);
for (i = 0; i < count; i++) {
if (_savedstate.frames[i].frame == frame) {
break;
}
}
if (i == count) {
ASSERT(false);
}
return i;
}
bool
Sync::CreateQueues(Config &config)
{
delete [] _input_queues;
_input_queues = new InputQueue[_config.num_players];
for (int i = 0; i < _config.num_players; i++) {
_input_queues[i].Init(i, _config.input_size);
}
return true;
}
bool
Sync::CheckSimulationConsistency(int *seekTo)
{
int first_incorrect = GameInput::NullFrame;
for (int i = 0; i < _config.num_players; i++) {
int incorrect = _input_queues[i].GetFirstIncorrectFrame();
Log("considering incorrect frame %d reported by queue %d.\n", incorrect, i);
if (incorrect != GameInput::NullFrame && (first_incorrect == GameInput::NullFrame || incorrect < first_incorrect)) {
first_incorrect = incorrect;
}
}
if (first_incorrect == GameInput::NullFrame) {
Log("prediction ok. proceeding.\n");
return true;
}
*seekTo = first_incorrect;
return false;
}
void
Sync::SetFrameDelay(int queue, int delay)
{
_input_queues[queue].SetFrameDelay(delay);
}
void
Sync::ResetPrediction(int frameNumber)
{
for (int i = 0; i < _config.num_players; i++) {
_input_queues[i].ResetPrediction(frameNumber);
}
}
bool
Sync::GetEvent(Event &e)
{
if (_event_queue.size()) {
e = _event_queue.front();
_event_queue.pop();
return true;
}
return false;
}
+105
View File
@@ -0,0 +1,105 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _SYNC_H
#define _SYNC_H
#include "ggponet.h"
#include "game_input.h"
#include "ggpo_types.h"
#include "input_queue.h"
#include "ring_buffer.h"
#include "network/udp_msg.h"
#define MAX_PREDICTION_FRAMES 8
class SyncTestBackend;
class Sync {
public:
struct Config {
GGPOSessionCallbacks callbacks;
int num_prediction_frames;
int num_players;
int input_size;
};
struct Event {
enum {
ConfirmedInput,
} type;
union {
struct {
GameInput input;
} confirmedInput;
} u;
};
public:
Sync(UdpMsg::connect_status *connect_status);
virtual ~Sync();
void Init(Config &config);
void SetLastConfirmedFrame(int frame);
void SetFrameDelay(int queue, int delay);
bool AddLocalInput(int queue, GameInput &input);
void AddRemoteInput(int queue, GameInput &input);
int GetConfirmedInputs(void *values, int size, int frame);
int SynchronizeInputs(void *values, int size);
void CheckSimulation(int timeout);
void AdjustSimulation(int seek_to);
void IncrementFrame(void);
int GetFrameCount() { return _framecount; }
bool InRollback() { return _rollingback; }
int GetPredictedFrames() { return _framecount - _last_confirmed_frame; }
bool GetEvent(Event &e);
protected:
friend SyncTestBackend;
struct SavedFrame {
byte *buf;
int cbuf;
int frame;
int checksum;
SavedFrame() : buf(NULL), cbuf(0), frame(-1), checksum(0) { }
};
struct SavedState {
SavedFrame frames[MAX_PREDICTION_FRAMES + 2];
int head;
};
void LoadFrame(int frame);
void SaveCurrentFrame();
int FindSavedFrameIndex(int frame);
SavedFrame &GetLastSavedFrame();
bool CreateQueues(Config &config);
bool CheckSimulationConsistency(int *seekTo);
void ResetPrediction(int frameNumber);
protected:
GGPOSessionCallbacks _callbacks;
SavedState _savedstate;
Config _config;
bool _rollingback;
int _last_confirmed_frame;
int _framecount;
int _max_prediction_frames;
InputQueue *_input_queues;
RingBuffer<Event, 32> _event_queue;
UdpMsg::connect_status *_local_connect_status;
};
#endif
+85
View File
@@ -0,0 +1,85 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#include "timesync.h"
TimeSync::TimeSync()
{
memset(_local, 0, sizeof(_local));
memset(_remote, 0, sizeof(_remote));
_next_prediction = FRAME_WINDOW_SIZE * 3;
}
TimeSync::~TimeSync()
{
}
void
TimeSync::advance_frame(GameInput &input, int advantage, int radvantage)
{
// Remember the last frame and frame advantage
_last_inputs[input.frame % ARRAY_SIZE(_last_inputs)] = input;
_local[input.frame % ARRAY_SIZE(_local)] = advantage;
_remote[input.frame % ARRAY_SIZE(_remote)] = radvantage;
}
int
TimeSync::recommend_frame_wait_duration(bool require_idle_input)
{
// Average our local and remote frame advantages
int sum = 0;
float advantage, radvantage;
for (size_t i = 0; i < ARRAY_SIZE(_local); i++) {
sum += _local[i];
}
advantage = sum / (float)ARRAY_SIZE(_local);
sum = 0;
for (size_t i = 0; i < ARRAY_SIZE(_remote); i++) {
sum += _remote[i];
}
radvantage = sum / (float)ARRAY_SIZE(_remote);
static int count = 0;
count++;
// See if someone should take action. The person furthest ahead
// needs to slow down so the other user can catch up.
// Only do this if both clients agree on who's ahead!!
if (advantage >= radvantage) {
return 0;
}
// Both clients agree that we're the one ahead. Split
// the difference between the two to figure out how long to
// sleep for.
int sleep_frames = (int)(((radvantage - advantage) / 2) + 0.5);
Log("iteration %d: sleep frames is %d\n", count, sleep_frames);
// Some things just aren't worth correcting for. Make sure
// the difference is relevant before proceeding.
if (sleep_frames < MIN_FRAME_ADVANTAGE) {
return 0;
}
// Make sure our input had been "idle enough" before recommending
// a sleep. This tries to make the emulator sleep while the
// user's input isn't sweeping in arcs (e.g. fireball motions in
// Street Fighter), which could cause the player to miss moves.
if (require_idle_input) {
for (size_t i = 1; i < ARRAY_SIZE(_last_inputs); i++) {
if (!_last_inputs[i].equal(_last_inputs[0], true)) {
Log("iteration %d: rejecting due to input stuff at position %d...!!!\n", count, i);
return 0;
}
}
}
// Success!!! Recommend the number of frames to sleep and adjust
return MIN(sleep_frames, MAX_FRAME_ADVANTAGE);
}
+34
View File
@@ -0,0 +1,34 @@
/* -----------------------------------------------------------------------
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
*
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef _TIMESYNC_H
#define _TIMESYNC_H
#include "game_input.h"
#include "ggpo_types.h"
#define FRAME_WINDOW_SIZE 40
#define MIN_UNIQUE_FRAMES 10
#define MIN_FRAME_ADVANTAGE 3
#define MAX_FRAME_ADVANTAGE 9
class TimeSync {
public:
TimeSync();
virtual ~TimeSync ();
void advance_frame(GameInput &input, int advantage, int radvantage);
int recommend_frame_wait_duration(bool require_idle_input);
protected:
int _local[FRAME_WINDOW_SIZE];
int _remote[FRAME_WINDOW_SIZE];
GameInput _last_inputs[MIN_UNIQUE_FRAMES];
int _next_prediction;
};
#endif
+3 -1
View File
@@ -2795,6 +2795,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) : DrawListInst
DrawList = &DrawListInst;
DrawList->_Data = &context->DrawListSharedData;
DrawList->_OwnerName = Name;
DragScrolling = false;
}
ImGuiWindow::~ImGuiWindow()
@@ -6160,11 +6161,12 @@ void ImGui::FocusWindow(ImGuiWindow* window)
g.NavWindow = window;
if (window && g.NavDisableMouseHover)
g.NavMousePosDirty = true;
g.NavInitRequest = false;
g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId
g.NavFocusScopeId = 0;
g.NavIdIsAlive = false;
g.NavLayer = ImGuiNavLayer_Main;
g.NavInitRequest = g.NavMoveRequest = false;
NavUpdateAnyRequestFlag();
//IMGUI_DEBUG_LOG("FocusWindow(\"%s\")\n", window ? window->Name : NULL);
}
+1
View File
@@ -825,6 +825,7 @@ enum ImGuiWindowFlags_
ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse,
ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
ImGuiWindowFlags_DragScrolling = 1 << 21, // Allow scrolling by dragging content
// [Internal]
ImGuiWindowFlags_NavFlattened = 1 << 23, // [BETA] Allow gamepad/keyboard navigation to cross over parent border to this child (only use on child that have no scrolling!)
+2
View File
@@ -1619,6 +1619,8 @@ struct IMGUI_API ImGuiWindow
ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
ImVec2 ScrollTargetEdgeSnapDist; // 0.0f = no snapping, >0.0f snapping threshold
ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar.
ImVec2 ScrollSpeed;
bool DragScrolling;
bool ScrollbarX, ScrollbarY; // Are scrollbars visible?
bool Active; // Set to true on Begin(), unless Collapsed
bool WasActive;
+28
View File
@@ -636,7 +636,30 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
ClearActiveID();
}
if (!(flags & ImGuiButtonFlags_NoNavFocus))
{
g.NavDisableHighlight = true;
// Check if dragging (except for scrollbars)
if (held && !hovered && !pressed)
{
ImVec2 delta = GetMouseDragDelta(ImGuiMouseButton_Left);
if (delta.x != 0.f || delta.y != 0.f)
{
ClearActiveID();
// Find an ancestor window that allows drag scrolling.
ImGuiWindow *scrollableWindow = window;
while (scrollableWindow != nullptr
&& (scrollableWindow->Flags & ImGuiWindowFlags_ChildWindow)
&& !(scrollableWindow->Flags & ImGuiWindowFlags_DragScrolling)
&& scrollableWindow->ScrollMax.x == 0.0f
&& scrollableWindow->ScrollMax.y == 0.0f)
scrollableWindow = scrollableWindow->ParentWindow;
if (scrollableWindow != nullptr && (scrollableWindow->Flags & ImGuiWindowFlags_DragScrolling))
scrollableWindow->DragScrolling = true;
held = false;
pressed = false;
}
}
}
}
else if (g.ActiveIdSource == ImGuiInputSource_Nav)
{
@@ -6007,6 +6030,11 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
if (flags & ImGuiSelectableFlags_Disabled)
selected = false;
if (window->DragScrolling)
{
selected = false;
button_flags |= ImGuiButtonFlags_Disabled;
}
const bool was_selected = selected;
bool hovered, held;
@@ -0,0 +1,58 @@
/* Copyright (C) 2010-2018 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (compat_strcasestr.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <ctype.h>
#include <compat/strcasestr.h>
/* Pretty much strncasecmp. */
static int casencmp(const char *a, const char *b, size_t n)
{
size_t i;
for (i = 0; i < n; i++)
{
int a_lower = tolower(a[i]);
int b_lower = tolower(b[i]);
if (a_lower != b_lower)
return a_lower - b_lower;
}
return 0;
}
char *strcasestr_retro__(const char *haystack, const char *needle)
{
size_t i, search_off;
size_t hay_len = strlen(haystack);
size_t needle_len = strlen(needle);
if (needle_len > hay_len)
return NULL;
search_off = hay_len - needle_len;
for (i = 0; i <= search_off; i++)
if (!casencmp(haystack + i, needle, needle_len))
return (char*)haystack + i;
return NULL;
}
@@ -0,0 +1,69 @@
/* Copyright (C) 2010-2018 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (compat_strl.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <ctype.h>
#include <compat/strl.h>
/* Implementation of strlcpy()/strlcat() based on OpenBSD. */
#ifndef __MACH__
size_t strlcpy(char *dest, const char *source, size_t size)
{
size_t src_size = 0;
size_t n = size;
if (n)
while (--n && (*dest++ = *source++)) src_size++;
if (!n)
{
if (size) *dest = '\0';
while (*source++) src_size++;
}
return src_size;
}
size_t strlcat(char *dest, const char *source, size_t size)
{
size_t len = strlen(dest);
dest += len;
if (len > size)
size = 0;
else
size -= len;
return len + strlcpy(dest, source, size);
}
#endif
char *strldup(const char *s, size_t n)
{
char *dst = (char*)malloc(sizeof(char) * (n + 1));
strlcpy(dst, s, n);
return dst;
}
@@ -0,0 +1,60 @@
/* Copyright (C) 2010-2018 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (fopen_utf8.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <compat/fopen_utf8.h>
#include <encodings/utf.h>
#include <stdio.h>
#include <stdlib.h>
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX)
#ifndef LEGACY_WIN32
#define LEGACY_WIN32
#endif
#endif
#ifdef _WIN32
#undef fopen
void *fopen_utf8(const char * filename, const char * mode)
{
#if defined(_XBOX)
return fopen(filename, mode);
#elif defined(LEGACY_WIN32)
FILE *ret = NULL;
char * filename_local = utf8_to_local_string_alloc(filename);
if (!filename_local)
return NULL;
ret = fopen(filename_local, mode);
if (filename_local)
free(filename_local);
return ret;
#else
wchar_t * filename_w = utf8_to_utf16_string_alloc(filename);
wchar_t * mode_w = utf8_to_utf16_string_alloc(mode);
FILE* ret = _wfopen(filename_w, mode_w);
free(filename_w);
free(mode_w);
return ret;
#endif
}
#endif
@@ -0,0 +1,510 @@
/* Copyright (C) 2010-2018 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (encoding_utf.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <boolean.h>
#include <compat/strl.h>
#include <retro_inline.h>
#include <encodings/utf.h>
#if defined(_WIN32) && !defined(_XBOX)
#include <windows.h>
#elif defined(_XBOX)
#include <xtl.h>
#endif
static unsigned leading_ones(uint8_t c)
{
unsigned ones = 0;
while (c & 0x80)
{
ones++;
c <<= 1;
}
return ones;
}
/* Simple implementation. Assumes the sequence is
* properly synchronized and terminated. */
size_t utf8_conv_utf32(uint32_t *out, size_t out_chars,
const char *in, size_t in_size)
{
unsigned i;
size_t ret = 0;
while (in_size && out_chars)
{
unsigned extra, shift;
uint32_t c;
uint8_t first = *in++;
unsigned ones = leading_ones(first);
if (ones > 6 || ones == 1) /* Invalid or desync. */
break;
extra = ones ? ones - 1 : ones;
if (1 + extra > in_size) /* Overflow. */
break;
shift = (extra - 1) * 6;
c = (first & ((1 << (7 - ones)) - 1)) << (6 * extra);
for (i = 0; i < extra; i++, in++, shift -= 6)
c |= (*in & 0x3f) << shift;
*out++ = c;
in_size -= 1 + extra;
out_chars--;
ret++;
}
return ret;
}
bool utf16_conv_utf8(uint8_t *out, size_t *out_chars,
const uint16_t *in, size_t in_size)
{
static uint8_t kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
size_t out_pos = 0;
size_t in_pos = 0;
for (;;)
{
unsigned numAdds;
uint32_t value;
if (in_pos == in_size)
{
*out_chars = out_pos;
return true;
}
value = in[in_pos++];
if (value < 0x80)
{
if (out)
out[out_pos] = (char)value;
out_pos++;
continue;
}
if (value >= 0xD800 && value < 0xE000)
{
uint32_t c2;
if (value >= 0xDC00 || in_pos == in_size)
break;
c2 = in[in_pos++];
if (c2 < 0xDC00 || c2 >= 0xE000)
break;
value = (((value - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000;
}
for (numAdds = 1; numAdds < 5; numAdds++)
if (value < (((uint32_t)1) << (numAdds * 5 + 6)))
break;
if (out)
out[out_pos] = (char)(kUtf8Limits[numAdds - 1]
+ (value >> (6 * numAdds)));
out_pos++;
do
{
numAdds--;
if (out)
out[out_pos] = (char)(0x80
+ ((value >> (6 * numAdds)) & 0x3F));
out_pos++;
}while (numAdds != 0);
}
*out_chars = out_pos;
return false;
}
/* Acts mostly like strlcpy.
*
* Copies the given number of UTF-8 characters,
* but at most d_len bytes.
*
* Always NULL terminates.
* Does not copy half a character.
*
* Returns number of bytes. 's' is assumed valid UTF-8.
* Use only if 'chars' is considerably less than 'd_len'. */
size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars)
{
const uint8_t *sb = (const uint8_t*)s;
const uint8_t *sb_org = sb;
if (!s)
return 0;
while (*sb && chars-- > 0)
{
sb++;
while ((*sb & 0xC0) == 0x80) sb++;
}
if ((size_t)(sb - sb_org) > d_len-1 /* NUL */)
{
sb = sb_org + d_len-1;
while ((*sb & 0xC0) == 0x80) sb--;
}
memcpy(d, sb_org, sb-sb_org);
d[sb-sb_org] = '\0';
return sb-sb_org;
}
const char *utf8skip(const char *str, size_t chars)
{
const uint8_t *strb = (const uint8_t*)str;
if (!chars)
return str;
do
{
strb++;
while ((*strb & 0xC0)==0x80) strb++;
chars--;
} while(chars);
return (const char*)strb;
}
size_t utf8len(const char *string)
{
size_t ret = 0;
if (!string)
return 0;
while (*string)
{
if ((*string & 0xC0) != 0x80)
ret++;
string++;
}
return ret;
}
#define utf8_walkbyte(string) (*((*(string))++))
/* Does not validate the input, returns garbage if it's not UTF-8. */
uint32_t utf8_walk(const char **string)
{
uint8_t first = utf8_walkbyte(string);
uint32_t ret = 0;
if (first < 128)
return first;
ret = (ret << 6) | (utf8_walkbyte(string) & 0x3F);
if (first >= 0xE0)
{
ret = (ret << 6) | (utf8_walkbyte(string) & 0x3F);
if (first >= 0xF0)
{
ret = (ret << 6) | (utf8_walkbyte(string) & 0x3F);
return ret | (first & 7) << 18;
}
return ret | (first & 15) << 12;
}
return ret | (first & 31) << 6;
}
static bool utf16_to_char(uint8_t **utf_data,
size_t *dest_len, const uint16_t *in)
{
unsigned len = 0;
while (in[len] != '\0')
len++;
utf16_conv_utf8(NULL, dest_len, in, len);
*dest_len += 1;
*utf_data = (uint8_t*)malloc(*dest_len);
if (*utf_data == 0)
return false;
return utf16_conv_utf8(*utf_data, dest_len, in, len);
}
bool utf16_to_char_string(const uint16_t *in, char *s, size_t len)
{
size_t dest_len = 0;
uint8_t *utf16_data = NULL;
bool ret = utf16_to_char(&utf16_data, &dest_len, in);
if (ret)
{
utf16_data[dest_len] = 0;
strlcpy(s, (const char*)utf16_data, len);
}
free(utf16_data);
utf16_data = NULL;
return ret;
}
#if defined(_WIN32) && !defined(_XBOX) && !defined(UNICODE)
/* Returned pointer MUST be freed by the caller if non-NULL. */
static char *mb_to_mb_string_alloc(const char *str,
enum CodePage cp_in, enum CodePage cp_out)
{
char *path_buf = NULL;
wchar_t *path_buf_wide = NULL;
int path_buf_len = 0;
int path_buf_wide_len = MultiByteToWideChar(cp_in, 0, str, -1, NULL, 0);
/* Windows 95 will return 0 from these functions with
* a UTF8 codepage set without MSLU.
*
* From an unknown MSDN version (others omit this info):
* - CP_UTF8 Windows 98/Me, Windows NT 4.0 and later:
* Translate using UTF-8. When this is set, dwFlags must be zero.
* - Windows 95: Under the Microsoft Layer for Unicode,
* MultiByteToWideChar also supports CP_UTF7 and CP_UTF8.
*/
if (path_buf_wide_len)
{
path_buf_wide = (wchar_t*)
calloc(path_buf_wide_len + sizeof(wchar_t), sizeof(wchar_t));
if (path_buf_wide)
{
MultiByteToWideChar(cp_in, 0,
str, -1, path_buf_wide, path_buf_wide_len);
if (*path_buf_wide)
{
path_buf_len = WideCharToMultiByte(cp_out, 0,
path_buf_wide, -1, NULL, 0, NULL, NULL);
if (path_buf_len)
{
path_buf = (char*)
calloc(path_buf_len + sizeof(char), sizeof(char));
if (path_buf)
{
WideCharToMultiByte(cp_out, 0,
path_buf_wide, -1, path_buf,
path_buf_len, NULL, NULL);
free(path_buf_wide);
if (*path_buf)
return path_buf;
free(path_buf);
return NULL;
}
}
else
{
free(path_buf_wide);
return strdup(str);
}
}
}
}
else
return strdup(str);
if (path_buf_wide)
free(path_buf_wide);
return NULL;
}
#endif
/* Returned pointer MUST be freed by the caller if non-NULL. */
char* utf8_to_local_string_alloc(const char *str)
{
if (str && *str)
{
#if defined(_WIN32) && !defined(_XBOX) && !defined(UNICODE)
return mb_to_mb_string_alloc(str, CODEPAGE_UTF8, CODEPAGE_LOCAL);
#else
/* assume string needs no modification if not on Windows */
return strdup(str);
#endif
}
return NULL;
}
/* Returned pointer MUST be freed by the caller if non-NULL. */
char* local_to_utf8_string_alloc(const char *str)
{
if (str && *str)
{
#if defined(_WIN32) && !defined(_XBOX) && !defined(UNICODE)
return mb_to_mb_string_alloc(str, CODEPAGE_LOCAL, CODEPAGE_UTF8);
#else
/* assume string needs no modification if not on Windows */
return strdup(str);
#endif
}
return NULL;
}
/* Returned pointer MUST be freed by the caller if non-NULL. */
wchar_t* utf8_to_utf16_string_alloc(const char *str)
{
#ifdef _WIN32
int len = 0;
int out_len = 0;
#else
size_t len = 0;
size_t out_len = 0;
#endif
wchar_t *buf = NULL;
if (!str || !*str)
return NULL;
#ifdef _WIN32
len = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
if (len)
{
buf = (wchar_t*)calloc(len, sizeof(wchar_t));
if (!buf)
return NULL;
out_len = MultiByteToWideChar(CP_UTF8, 0, str, -1, buf, len);
}
else
{
/* fallback to ANSI codepage instead */
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
if (len)
{
buf = (wchar_t*)calloc(len, sizeof(wchar_t));
if (!buf)
return NULL;
out_len = MultiByteToWideChar(CP_ACP, 0, str, -1, buf, len);
}
}
if (out_len < 0)
{
free(buf);
return NULL;
}
#else
/* NOTE: For now, assume non-Windows platforms' locale is already UTF-8. */
len = mbstowcs(NULL, str, 0) + 1;
if (len)
{
buf = (wchar_t*)calloc(len, sizeof(wchar_t));
if (!buf)
return NULL;
out_len = mbstowcs(buf, str, len);
}
if (out_len == (size_t)-1)
{
free(buf);
return NULL;
}
#endif
return buf;
}
/* Returned pointer MUST be freed by the caller if non-NULL. */
char* utf16_to_utf8_string_alloc(const wchar_t *str)
{
#ifdef _WIN32
int len = 0;
#else
size_t len = 0;
#endif
char *buf = NULL;
if (!str || !*str)
return NULL;
#ifdef _WIN32
{
UINT code_page = CP_UTF8;
len = WideCharToMultiByte(code_page,
0, str, -1, NULL, 0, NULL, NULL);
/* fallback to ANSI codepage instead */
if (!len)
{
code_page = CP_ACP;
len = WideCharToMultiByte(code_page,
0, str, -1, NULL, 0, NULL, NULL);
}
buf = (char*)calloc(len, sizeof(char));
if (!buf)
return NULL;
if (WideCharToMultiByte(code_page,
0, str, -1, buf, len, NULL, NULL) < 0)
{
free(buf);
return NULL;
}
}
#else
/* NOTE: For now, assume non-Windows platforms'
* locale is already UTF-8. */
len = wcstombs(NULL, str, 0) + 1;
if (len)
{
buf = (char*)calloc(len, sizeof(char));
if (!buf)
return NULL;
if (wcstombs(buf, str, len) == (size_t)-1)
{
free(buf);
return NULL;
}
}
#endif
return buf;
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,118 @@
/* Copyright (C) 2010-2019 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (retro_dirent.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <retro_common.h>
#include <boolean.h>
#include <retro_dirent.h>
#define VFS_FRONTEND
#include <vfs/vfs_implementation.h>
static retro_vfs_opendir_t dirent_opendir_cb = NULL;
static retro_vfs_readdir_t dirent_readdir_cb = NULL;
static retro_vfs_dirent_get_name_t dirent_dirent_get_name_cb = NULL;
static retro_vfs_dirent_is_dir_t dirent_dirent_is_dir_cb = NULL;
static retro_vfs_closedir_t dirent_closedir_cb = NULL;
void dirent_vfs_init(const struct retro_vfs_interface_info* vfs_info)
{
const struct retro_vfs_interface* vfs_iface;
dirent_opendir_cb = NULL;
dirent_readdir_cb = NULL;
dirent_dirent_get_name_cb = NULL;
dirent_dirent_is_dir_cb = NULL;
dirent_closedir_cb = NULL;
vfs_iface = vfs_info->iface;
if (vfs_info->required_interface_version < DIRENT_REQUIRED_VFS_VERSION || !vfs_iface)
return;
dirent_opendir_cb = vfs_iface->opendir;
dirent_readdir_cb = vfs_iface->readdir;
dirent_dirent_get_name_cb = vfs_iface->dirent_get_name;
dirent_dirent_is_dir_cb = vfs_iface->dirent_is_dir;
dirent_closedir_cb = vfs_iface->closedir;
}
struct RDIR *retro_opendir_include_hidden(const char *name, bool include_hidden)
{
if (dirent_opendir_cb != NULL)
return (struct RDIR *)dirent_opendir_cb(name, include_hidden);
return (struct RDIR *)retro_vfs_opendir_impl(name, include_hidden);
}
struct RDIR *retro_opendir(const char *name)
{
return retro_opendir_include_hidden(name, false);
}
bool retro_dirent_error(struct RDIR *rdir)
{
/* Left for compatibility */
return false;
}
int retro_readdir(struct RDIR *rdir)
{
if (dirent_readdir_cb != NULL)
return dirent_readdir_cb((struct retro_vfs_dir_handle *)rdir);
return retro_vfs_readdir_impl((struct retro_vfs_dir_handle *)rdir);
}
const char *retro_dirent_get_name(struct RDIR *rdir)
{
if (dirent_dirent_get_name_cb != NULL)
return dirent_dirent_get_name_cb((struct retro_vfs_dir_handle *)rdir);
return retro_vfs_dirent_get_name_impl((struct retro_vfs_dir_handle *)rdir);
}
/**
*
* retro_dirent_is_dir:
* @rdir : pointer to the directory entry.
* @unused : deprecated, included for compatibility reasons, pass NULL
*
* Is the directory listing entry a directory?
*
* Returns: true if directory listing entry is
* a directory, false if not.
*/
bool retro_dirent_is_dir(struct RDIR *rdir, const char *unused)
{
if (dirent_dirent_is_dir_cb != NULL)
return dirent_dirent_is_dir_cb((struct retro_vfs_dir_handle *)rdir);
return retro_vfs_dirent_is_dir_impl((struct retro_vfs_dir_handle *)rdir);
}
void retro_closedir(struct RDIR *rdir)
{
if (dirent_closedir_cb != NULL)
dirent_closedir_cb((struct retro_vfs_dir_handle *)rdir);
else
retro_vfs_closedir_impl((struct retro_vfs_dir_handle *)rdir);
}
File diff suppressed because it is too large. Load diff
+11
View File
@@ -0,0 +1,11 @@
# Autogenerate GL extension loaders
## OpenGL desktop
Use Khronos' recent [header](www.opengl.org/registry/api/glext.h).
./glgen.py /usr/include/GL/glext.h glsym_gl.h glsym_gl.c
## OpenGL ES
./glgen.py /usr/include/GLES2/gl2ext.h glsym_es2.h glsym_es2.c
+157
View File
@@ -0,0 +1,157 @@
#!/usr/bin/env python3
"""
License statement applies to this file (glgen.py) only.
"""
"""
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
import sys
import os
import re
banned_ext = [ 'AMD', 'APPLE', 'NV', 'NVX', 'ATI', '3DLABS', 'SUN', 'SGI', 'SGIX', 'SGIS', 'INTEL', '3DFX', 'IBM', 'MESA', 'GREMEDY', 'OML', 'PGI', 'I3D', 'INGL', 'MTX', 'QCOM', 'IMG', 'ANGLE', 'SUNX', 'INGR' ]
def noext(sym):
for ext in banned_ext:
if sym.endswith(ext):
return False
return True
def fix_multiline_functions(lines):
fixed_lines = []
temp_lines = []
for line in lines:
if line.count('(') > line.count(')'):
temp_lines.append(line)
else:
if len(temp_lines) > 0:
if line.count(')') > line.count('('):
temp_lines.append(line)
fixed_line = re.sub(' +',' ', ''.join(temp_lines).replace('\n','').replace('\t',''))
fixed_lines.append(fixed_line)
temp_lines = []
else:
temp_lines.append(line)
else:
fixed_lines.append(line)
return fixed_lines
def find_gl_symbols(lines):
typedefs = []
syms = []
for line in lines:
m = re.search(r'^typedef.+PFN(\S+)PROC.+$', line)
g = re.search(r'^.+(gl\S+)\W*\(.+\).*$', line)
if m and noext(m.group(1)):
typedefs.append(m.group(0).replace('PFN', 'RGLSYM').replace('GLDEBUGPROC', 'RGLGENGLDEBUGPROC'))
if g and noext(g.group(1)):
syms.append(g.group(1))
return (typedefs, syms)
def generate_defines(gl_syms):
res = []
for line in gl_syms:
res.append('#define {} __rglgen_{}'.format(line, line))
return res
def generate_declarations(gl_syms):
return ['RGLSYM' + x.upper() + 'PROC ' + '__rglgen_' + x + ';' for x in gl_syms]
def generate_macros(gl_syms):
return [' SYM(' + x.replace('gl', '') + '),' for x in gl_syms]
def dump(f, lines):
f.write('\n'.join(lines))
f.write('\n\n')
if __name__ == '__main__':
if len(sys.argv) > 4:
for banned in sys.argv[4:]:
banned_ext.append(banned)
with open(sys.argv[1], 'r') as f:
lines = fix_multiline_functions(f.readlines())
typedefs, syms = find_gl_symbols(lines)
overrides = generate_defines(syms)
declarations = generate_declarations(syms)
externs = ['extern ' + x for x in declarations]
macros = generate_macros(syms)
with open(sys.argv[2], 'w') as f:
f.write('#ifndef RGLGEN_DECL_H__\n')
f.write('#define RGLGEN_DECL_H__\n')
f.write('#ifdef __cplusplus\n')
f.write('extern "C" {\n')
f.write('#endif\n')
f.write('#ifdef GL_APIENTRY\n')
f.write('typedef void (GL_APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);\n')
f.write('typedef void (GL_APIENTRY *RGLGENGLDEBUGPROCKHR)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);\n')
f.write('#else\n')
f.write('#ifndef APIENTRY\n')
f.write('#define APIENTRY\n')
f.write('#endif\n')
f.write('#ifndef APIENTRYP\n')
f.write('#define APIENTRYP APIENTRY *\n')
f.write('#endif\n')
f.write('typedef void (APIENTRY *RGLGENGLDEBUGPROCARB)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);\n')
f.write('typedef void (APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);\n')
f.write('#endif\n')
f.write('#ifndef GL_OES_EGL_image\n')
f.write('typedef void *GLeglImageOES;\n')
f.write('#endif\n')
f.write('#if !defined(GL_OES_fixed_point) && !defined(HAVE_OPENGLES2)\n')
f.write('typedef GLint GLfixed;\n')
f.write('#endif\n')
f.write('#if defined(OSX) && !defined(MAC_OS_X_VERSION_10_7)\n')
f.write('typedef long long int GLint64;\n')
f.write('typedef unsigned long long int GLuint64;\n')
f.write('typedef unsigned long long int GLuint64EXT;\n')
f.write('typedef struct __GLsync *GLsync;\n')
f.write('#endif\n')
dump(f, typedefs)
dump(f, overrides)
dump(f, externs)
f.write('struct rglgen_sym_map { const char *sym; void *ptr; };\n')
f.write('extern const struct rglgen_sym_map rglgen_symbol_map[];\n')
f.write('#ifdef __cplusplus\n')
f.write('}\n')
f.write('#endif\n')
f.write('#endif\n')
with open(sys.argv[3], 'w') as f:
f.write('#include "glsym/glsym.h"\n')
f.write('#include <stddef.h>\n')
f.write('#define SYM(x) { "gl" #x, &(gl##x) }\n')
f.write('const struct rglgen_sym_map rglgen_symbol_map[] = {\n')
dump(f, macros)
f.write(' { NULL, NULL },\n')
f.write('};\n')
dump(f, declarations)
+409
View File
@@ -0,0 +1,409 @@
#include "glsym/glsym.h"
#include <stddef.h>
#define SYM(x) { "gl" #x, &(gl##x) }
const struct rglgen_sym_map rglgen_symbol_map[] = {
SYM(BlendBarrierKHR),
SYM(DebugMessageControlKHR),
SYM(DebugMessageInsertKHR),
SYM(DebugMessageCallbackKHR),
SYM(GetDebugMessageLogKHR),
SYM(PushDebugGroupKHR),
SYM(PopDebugGroupKHR),
SYM(ObjectLabelKHR),
SYM(GetObjectLabelKHR),
SYM(ObjectPtrLabelKHR),
SYM(GetObjectPtrLabelKHR),
SYM(GetPointervKHR),
SYM(GetGraphicsResetStatusKHR),
SYM(ReadnPixelsKHR),
SYM(GetnUniformfvKHR),
SYM(GetnUniformivKHR),
SYM(GetnUniformuivKHR),
SYM(EGLImageTargetTexture2DOES),
SYM(EGLImageTargetRenderbufferStorageOES),
SYM(CopyImageSubDataOES),
SYM(EnableiOES),
SYM(DisableiOES),
SYM(BlendEquationiOES),
SYM(BlendEquationSeparateiOES),
SYM(BlendFunciOES),
SYM(BlendFuncSeparateiOES),
SYM(ColorMaskiOES),
SYM(IsEnablediOES),
SYM(DrawElementsBaseVertexOES),
SYM(DrawRangeElementsBaseVertexOES),
SYM(DrawElementsInstancedBaseVertexOES),
SYM(MultiDrawElementsBaseVertexOES),
SYM(FramebufferTextureOES),
SYM(GetProgramBinaryOES),
SYM(ProgramBinaryOES),
SYM(MapBufferOES),
SYM(UnmapBufferOES),
SYM(GetBufferPointervOES),
SYM(PrimitiveBoundingBoxOES),
SYM(MinSampleShadingOES),
SYM(PatchParameteriOES),
SYM(TexImage3DOES),
SYM(TexSubImage3DOES),
SYM(CopyTexSubImage3DOES),
SYM(CompressedTexImage3DOES),
SYM(CompressedTexSubImage3DOES),
SYM(FramebufferTexture3DOES),
SYM(TexParameterIivOES),
SYM(TexParameterIuivOES),
SYM(GetTexParameterIivOES),
SYM(GetTexParameterIuivOES),
SYM(SamplerParameterIivOES),
SYM(SamplerParameterIuivOES),
SYM(GetSamplerParameterIivOES),
SYM(GetSamplerParameterIuivOES),
SYM(TexBufferOES),
SYM(TexBufferRangeOES),
SYM(TexStorage3DMultisampleOES),
SYM(TextureViewOES),
SYM(BindVertexArrayOES),
SYM(DeleteVertexArraysOES),
SYM(GenVertexArraysOES),
SYM(IsVertexArrayOES),
SYM(ViewportArrayvOES),
SYM(ViewportIndexedfOES),
SYM(ViewportIndexedfvOES),
SYM(ScissorArrayvOES),
SYM(ScissorIndexedOES),
SYM(ScissorIndexedvOES),
SYM(DepthRangeArrayfvOES),
SYM(DepthRangeIndexedfOES),
SYM(GetFloati_vOES),
SYM(DrawArraysInstancedBaseInstanceEXT),
SYM(DrawElementsInstancedBaseInstanceEXT),
SYM(DrawElementsInstancedBaseVertexBaseInstanceEXT),
SYM(BindFragDataLocationIndexedEXT),
SYM(BindFragDataLocationEXT),
SYM(GetProgramResourceLocationIndexEXT),
SYM(GetFragDataIndexEXT),
SYM(BufferStorageEXT),
SYM(ClearTexImageEXT),
SYM(ClearTexSubImageEXT),
SYM(CopyImageSubDataEXT),
SYM(LabelObjectEXT),
SYM(GetObjectLabelEXT),
SYM(InsertEventMarkerEXT),
SYM(PushGroupMarkerEXT),
SYM(PopGroupMarkerEXT),
SYM(DiscardFramebufferEXT),
SYM(GenQueriesEXT),
SYM(DeleteQueriesEXT),
SYM(IsQueryEXT),
SYM(BeginQueryEXT),
SYM(EndQueryEXT),
SYM(QueryCounterEXT),
SYM(GetQueryivEXT),
SYM(GetQueryObjectivEXT),
SYM(GetQueryObjectuivEXT),
SYM(DrawBuffersEXT),
SYM(EnableiEXT),
SYM(DisableiEXT),
SYM(BlendEquationiEXT),
SYM(BlendEquationSeparateiEXT),
SYM(BlendFunciEXT),
SYM(BlendFuncSeparateiEXT),
SYM(ColorMaskiEXT),
SYM(IsEnablediEXT),
SYM(DrawElementsBaseVertexEXT),
SYM(DrawRangeElementsBaseVertexEXT),
SYM(DrawElementsInstancedBaseVertexEXT),
SYM(MultiDrawElementsBaseVertexEXT),
SYM(DrawArraysInstancedEXT),
SYM(DrawElementsInstancedEXT),
SYM(FramebufferTextureEXT),
SYM(VertexAttribDivisorEXT),
SYM(MapBufferRangeEXT),
SYM(FlushMappedBufferRangeEXT),
SYM(MultiDrawArraysEXT),
SYM(MultiDrawElementsEXT),
SYM(MultiDrawArraysIndirectEXT),
SYM(MultiDrawElementsIndirectEXT),
SYM(RenderbufferStorageMultisampleEXT),
SYM(FramebufferTexture2DMultisampleEXT),
SYM(ReadBufferIndexedEXT),
SYM(DrawBuffersIndexedEXT),
SYM(GetIntegeri_vEXT),
SYM(PolygonOffsetClampEXT),
SYM(PrimitiveBoundingBoxEXT),
SYM(RasterSamplesEXT),
SYM(GetGraphicsResetStatusEXT),
SYM(ReadnPixelsEXT),
SYM(GetnUniformfvEXT),
SYM(GetnUniformivEXT),
SYM(ActiveShaderProgramEXT),
SYM(BindProgramPipelineEXT),
SYM(CreateShaderProgramvEXT),
SYM(DeleteProgramPipelinesEXT),
SYM(GenProgramPipelinesEXT),
SYM(GetProgramPipelineInfoLogEXT),
SYM(GetProgramPipelineivEXT),
SYM(IsProgramPipelineEXT),
SYM(ProgramParameteriEXT),
SYM(ProgramUniform1fEXT),
SYM(ProgramUniform1fvEXT),
SYM(ProgramUniform1iEXT),
SYM(ProgramUniform1ivEXT),
SYM(ProgramUniform2fEXT),
SYM(ProgramUniform2fvEXT),
SYM(ProgramUniform2iEXT),
SYM(ProgramUniform2ivEXT),
SYM(ProgramUniform3fEXT),
SYM(ProgramUniform3fvEXT),
SYM(ProgramUniform3iEXT),
SYM(ProgramUniform3ivEXT),
SYM(ProgramUniform4fEXT),
SYM(ProgramUniform4fvEXT),
SYM(ProgramUniform4iEXT),
SYM(ProgramUniform4ivEXT),
SYM(ProgramUniformMatrix2fvEXT),
SYM(ProgramUniformMatrix3fvEXT),
SYM(ProgramUniformMatrix4fvEXT),
SYM(UseProgramStagesEXT),
SYM(ValidateProgramPipelineEXT),
SYM(ProgramUniform1uiEXT),
SYM(ProgramUniform2uiEXT),
SYM(ProgramUniform3uiEXT),
SYM(ProgramUniform4uiEXT),
SYM(ProgramUniform1uivEXT),
SYM(ProgramUniform2uivEXT),
SYM(ProgramUniform3uivEXT),
SYM(ProgramUniform4uivEXT),
SYM(ProgramUniformMatrix2x3fvEXT),
SYM(ProgramUniformMatrix3x2fvEXT),
SYM(ProgramUniformMatrix2x4fvEXT),
SYM(ProgramUniformMatrix4x2fvEXT),
SYM(ProgramUniformMatrix3x4fvEXT),
SYM(ProgramUniformMatrix4x3fvEXT),
SYM(FramebufferPixelLocalStorageSizeEXT),
SYM(GetFramebufferPixelLocalStorageSizeEXT),
SYM(ClearPixelLocalStorageuiEXT),
SYM(TexPageCommitmentEXT),
SYM(PatchParameteriEXT),
SYM(TexParameterIivEXT),
SYM(TexParameterIuivEXT),
SYM(GetTexParameterIivEXT),
SYM(GetTexParameterIuivEXT),
SYM(SamplerParameterIivEXT),
SYM(SamplerParameterIuivEXT),
SYM(GetSamplerParameterIivEXT),
SYM(GetSamplerParameterIuivEXT),
SYM(TexBufferEXT),
SYM(TexBufferRangeEXT),
SYM(TexStorage1DEXT),
SYM(TexStorage2DEXT),
SYM(TexStorage3DEXT),
SYM(TextureStorage1DEXT),
SYM(TextureStorage2DEXT),
SYM(TextureStorage3DEXT),
SYM(TextureViewEXT),
SYM(FramebufferTextureMultiviewOVR),
SYM(FramebufferTextureMultisampleMultiviewOVR),
{ NULL, NULL },
};
RGLSYMGLBLENDBARRIERKHRPROC __rglgen_glBlendBarrierKHR;
RGLSYMGLDEBUGMESSAGECONTROLKHRPROC __rglgen_glDebugMessageControlKHR;
RGLSYMGLDEBUGMESSAGEINSERTKHRPROC __rglgen_glDebugMessageInsertKHR;
RGLSYMGLDEBUGMESSAGECALLBACKKHRPROC __rglgen_glDebugMessageCallbackKHR;
RGLSYMGLGETDEBUGMESSAGELOGKHRPROC __rglgen_glGetDebugMessageLogKHR;
RGLSYMGLPUSHDEBUGGROUPKHRPROC __rglgen_glPushDebugGroupKHR;
RGLSYMGLPOPDEBUGGROUPKHRPROC __rglgen_glPopDebugGroupKHR;
RGLSYMGLOBJECTLABELKHRPROC __rglgen_glObjectLabelKHR;
RGLSYMGLGETOBJECTLABELKHRPROC __rglgen_glGetObjectLabelKHR;
RGLSYMGLOBJECTPTRLABELKHRPROC __rglgen_glObjectPtrLabelKHR;
RGLSYMGLGETOBJECTPTRLABELKHRPROC __rglgen_glGetObjectPtrLabelKHR;
RGLSYMGLGETPOINTERVKHRPROC __rglgen_glGetPointervKHR;
RGLSYMGLGETGRAPHICSRESETSTATUSKHRPROC __rglgen_glGetGraphicsResetStatusKHR;
RGLSYMGLREADNPIXELSKHRPROC __rglgen_glReadnPixelsKHR;
RGLSYMGLGETNUNIFORMFVKHRPROC __rglgen_glGetnUniformfvKHR;
RGLSYMGLGETNUNIFORMIVKHRPROC __rglgen_glGetnUniformivKHR;
RGLSYMGLGETNUNIFORMUIVKHRPROC __rglgen_glGetnUniformuivKHR;
RGLSYMGLEGLIMAGETARGETTEXTURE2DOESPROC __rglgen_glEGLImageTargetTexture2DOES;
RGLSYMGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC __rglgen_glEGLImageTargetRenderbufferStorageOES;
RGLSYMGLCOPYIMAGESUBDATAOESPROC __rglgen_glCopyImageSubDataOES;
RGLSYMGLENABLEIOESPROC __rglgen_glEnableiOES;
RGLSYMGLDISABLEIOESPROC __rglgen_glDisableiOES;
RGLSYMGLBLENDEQUATIONIOESPROC __rglgen_glBlendEquationiOES;
RGLSYMGLBLENDEQUATIONSEPARATEIOESPROC __rglgen_glBlendEquationSeparateiOES;
RGLSYMGLBLENDFUNCIOESPROC __rglgen_glBlendFunciOES;
RGLSYMGLBLENDFUNCSEPARATEIOESPROC __rglgen_glBlendFuncSeparateiOES;
RGLSYMGLCOLORMASKIOESPROC __rglgen_glColorMaskiOES;
RGLSYMGLISENABLEDIOESPROC __rglgen_glIsEnablediOES;
RGLSYMGLDRAWELEMENTSBASEVERTEXOESPROC __rglgen_glDrawElementsBaseVertexOES;
RGLSYMGLDRAWRANGEELEMENTSBASEVERTEXOESPROC __rglgen_glDrawRangeElementsBaseVertexOES;
RGLSYMGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC __rglgen_glDrawElementsInstancedBaseVertexOES;
RGLSYMGLMULTIDRAWELEMENTSBASEVERTEXOESPROC __rglgen_glMultiDrawElementsBaseVertexOES;
RGLSYMGLFRAMEBUFFERTEXTUREOESPROC __rglgen_glFramebufferTextureOES;
RGLSYMGLGETPROGRAMBINARYOESPROC __rglgen_glGetProgramBinaryOES;
RGLSYMGLPROGRAMBINARYOESPROC __rglgen_glProgramBinaryOES;
RGLSYMGLMAPBUFFEROESPROC __rglgen_glMapBufferOES;
RGLSYMGLUNMAPBUFFEROESPROC __rglgen_glUnmapBufferOES;
RGLSYMGLGETBUFFERPOINTERVOESPROC __rglgen_glGetBufferPointervOES;
RGLSYMGLPRIMITIVEBOUNDINGBOXOESPROC __rglgen_glPrimitiveBoundingBoxOES;
RGLSYMGLMINSAMPLESHADINGOESPROC __rglgen_glMinSampleShadingOES;
RGLSYMGLPATCHPARAMETERIOESPROC __rglgen_glPatchParameteriOES;
RGLSYMGLTEXIMAGE3DOESPROC __rglgen_glTexImage3DOES;
RGLSYMGLTEXSUBIMAGE3DOESPROC __rglgen_glTexSubImage3DOES;
RGLSYMGLCOPYTEXSUBIMAGE3DOESPROC __rglgen_glCopyTexSubImage3DOES;
RGLSYMGLCOMPRESSEDTEXIMAGE3DOESPROC __rglgen_glCompressedTexImage3DOES;
RGLSYMGLCOMPRESSEDTEXSUBIMAGE3DOESPROC __rglgen_glCompressedTexSubImage3DOES;
RGLSYMGLFRAMEBUFFERTEXTURE3DOESPROC __rglgen_glFramebufferTexture3DOES;
RGLSYMGLTEXPARAMETERIIVOESPROC __rglgen_glTexParameterIivOES;
RGLSYMGLTEXPARAMETERIUIVOESPROC __rglgen_glTexParameterIuivOES;
RGLSYMGLGETTEXPARAMETERIIVOESPROC __rglgen_glGetTexParameterIivOES;
RGLSYMGLGETTEXPARAMETERIUIVOESPROC __rglgen_glGetTexParameterIuivOES;
RGLSYMGLSAMPLERPARAMETERIIVOESPROC __rglgen_glSamplerParameterIivOES;
RGLSYMGLSAMPLERPARAMETERIUIVOESPROC __rglgen_glSamplerParameterIuivOES;
RGLSYMGLGETSAMPLERPARAMETERIIVOESPROC __rglgen_glGetSamplerParameterIivOES;
RGLSYMGLGETSAMPLERPARAMETERIUIVOESPROC __rglgen_glGetSamplerParameterIuivOES;
RGLSYMGLTEXBUFFEROESPROC __rglgen_glTexBufferOES;
RGLSYMGLTEXBUFFERRANGEOESPROC __rglgen_glTexBufferRangeOES;
RGLSYMGLTEXSTORAGE3DMULTISAMPLEOESPROC __rglgen_glTexStorage3DMultisampleOES;
RGLSYMGLTEXTUREVIEWOESPROC __rglgen_glTextureViewOES;
RGLSYMGLBINDVERTEXARRAYOESPROC __rglgen_glBindVertexArrayOES;
RGLSYMGLDELETEVERTEXARRAYSOESPROC __rglgen_glDeleteVertexArraysOES;
RGLSYMGLGENVERTEXARRAYSOESPROC __rglgen_glGenVertexArraysOES;
RGLSYMGLISVERTEXARRAYOESPROC __rglgen_glIsVertexArrayOES;
RGLSYMGLVIEWPORTARRAYVOESPROC __rglgen_glViewportArrayvOES;
RGLSYMGLVIEWPORTINDEXEDFOESPROC __rglgen_glViewportIndexedfOES;
RGLSYMGLVIEWPORTINDEXEDFVOESPROC __rglgen_glViewportIndexedfvOES;
RGLSYMGLSCISSORARRAYVOESPROC __rglgen_glScissorArrayvOES;
RGLSYMGLSCISSORINDEXEDOESPROC __rglgen_glScissorIndexedOES;
RGLSYMGLSCISSORINDEXEDVOESPROC __rglgen_glScissorIndexedvOES;
RGLSYMGLDEPTHRANGEARRAYFVOESPROC __rglgen_glDepthRangeArrayfvOES;
RGLSYMGLDEPTHRANGEINDEXEDFOESPROC __rglgen_glDepthRangeIndexedfOES;
RGLSYMGLGETFLOATI_VOESPROC __rglgen_glGetFloati_vOES;
RGLSYMGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC __rglgen_glDrawArraysInstancedBaseInstanceEXT;
RGLSYMGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC __rglgen_glDrawElementsInstancedBaseInstanceEXT;
RGLSYMGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC __rglgen_glDrawElementsInstancedBaseVertexBaseInstanceEXT;
RGLSYMGLBINDFRAGDATALOCATIONINDEXEDEXTPROC __rglgen_glBindFragDataLocationIndexedEXT;
RGLSYMGLBINDFRAGDATALOCATIONEXTPROC __rglgen_glBindFragDataLocationEXT;
RGLSYMGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC __rglgen_glGetProgramResourceLocationIndexEXT;
RGLSYMGLGETFRAGDATAINDEXEXTPROC __rglgen_glGetFragDataIndexEXT;
RGLSYMGLBUFFERSTORAGEEXTPROC __rglgen_glBufferStorageEXT;
RGLSYMGLCLEARTEXIMAGEEXTPROC __rglgen_glClearTexImageEXT;
RGLSYMGLCLEARTEXSUBIMAGEEXTPROC __rglgen_glClearTexSubImageEXT;
RGLSYMGLCOPYIMAGESUBDATAEXTPROC __rglgen_glCopyImageSubDataEXT;
RGLSYMGLLABELOBJECTEXTPROC __rglgen_glLabelObjectEXT;
RGLSYMGLGETOBJECTLABELEXTPROC __rglgen_glGetObjectLabelEXT;
RGLSYMGLINSERTEVENTMARKEREXTPROC __rglgen_glInsertEventMarkerEXT;
RGLSYMGLPUSHGROUPMARKEREXTPROC __rglgen_glPushGroupMarkerEXT;
RGLSYMGLPOPGROUPMARKEREXTPROC __rglgen_glPopGroupMarkerEXT;
RGLSYMGLDISCARDFRAMEBUFFEREXTPROC __rglgen_glDiscardFramebufferEXT;
RGLSYMGLGENQUERIESEXTPROC __rglgen_glGenQueriesEXT;
RGLSYMGLDELETEQUERIESEXTPROC __rglgen_glDeleteQueriesEXT;
RGLSYMGLISQUERYEXTPROC __rglgen_glIsQueryEXT;
RGLSYMGLBEGINQUERYEXTPROC __rglgen_glBeginQueryEXT;
RGLSYMGLENDQUERYEXTPROC __rglgen_glEndQueryEXT;
RGLSYMGLQUERYCOUNTEREXTPROC __rglgen_glQueryCounterEXT;
RGLSYMGLGETQUERYIVEXTPROC __rglgen_glGetQueryivEXT;
RGLSYMGLGETQUERYOBJECTIVEXTPROC __rglgen_glGetQueryObjectivEXT;
RGLSYMGLGETQUERYOBJECTUIVEXTPROC __rglgen_glGetQueryObjectuivEXT;
RGLSYMGLDRAWBUFFERSEXTPROC __rglgen_glDrawBuffersEXT;
RGLSYMGLENABLEIEXTPROC __rglgen_glEnableiEXT;
RGLSYMGLDISABLEIEXTPROC __rglgen_glDisableiEXT;
RGLSYMGLBLENDEQUATIONIEXTPROC __rglgen_glBlendEquationiEXT;
RGLSYMGLBLENDEQUATIONSEPARATEIEXTPROC __rglgen_glBlendEquationSeparateiEXT;
RGLSYMGLBLENDFUNCIEXTPROC __rglgen_glBlendFunciEXT;
RGLSYMGLBLENDFUNCSEPARATEIEXTPROC __rglgen_glBlendFuncSeparateiEXT;
RGLSYMGLCOLORMASKIEXTPROC __rglgen_glColorMaskiEXT;
RGLSYMGLISENABLEDIEXTPROC __rglgen_glIsEnablediEXT;
RGLSYMGLDRAWELEMENTSBASEVERTEXEXTPROC __rglgen_glDrawElementsBaseVertexEXT;
RGLSYMGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC __rglgen_glDrawRangeElementsBaseVertexEXT;
RGLSYMGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC __rglgen_glDrawElementsInstancedBaseVertexEXT;
RGLSYMGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC __rglgen_glMultiDrawElementsBaseVertexEXT;
RGLSYMGLDRAWARRAYSINSTANCEDEXTPROC __rglgen_glDrawArraysInstancedEXT;
RGLSYMGLDRAWELEMENTSINSTANCEDEXTPROC __rglgen_glDrawElementsInstancedEXT;
RGLSYMGLFRAMEBUFFERTEXTUREEXTPROC __rglgen_glFramebufferTextureEXT;
RGLSYMGLVERTEXATTRIBDIVISOREXTPROC __rglgen_glVertexAttribDivisorEXT;
RGLSYMGLMAPBUFFERRANGEEXTPROC __rglgen_glMapBufferRangeEXT;
RGLSYMGLFLUSHMAPPEDBUFFERRANGEEXTPROC __rglgen_glFlushMappedBufferRangeEXT;
RGLSYMGLMULTIDRAWARRAYSEXTPROC __rglgen_glMultiDrawArraysEXT;
RGLSYMGLMULTIDRAWELEMENTSEXTPROC __rglgen_glMultiDrawElementsEXT;
RGLSYMGLMULTIDRAWARRAYSINDIRECTEXTPROC __rglgen_glMultiDrawArraysIndirectEXT;
RGLSYMGLMULTIDRAWELEMENTSINDIRECTEXTPROC __rglgen_glMultiDrawElementsIndirectEXT;
RGLSYMGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __rglgen_glRenderbufferStorageMultisampleEXT;
RGLSYMGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC __rglgen_glFramebufferTexture2DMultisampleEXT;
RGLSYMGLREADBUFFERINDEXEDEXTPROC __rglgen_glReadBufferIndexedEXT;
RGLSYMGLDRAWBUFFERSINDEXEDEXTPROC __rglgen_glDrawBuffersIndexedEXT;
RGLSYMGLGETINTEGERI_VEXTPROC __rglgen_glGetIntegeri_vEXT;
RGLSYMGLPOLYGONOFFSETCLAMPEXTPROC __rglgen_glPolygonOffsetClampEXT;
RGLSYMGLPRIMITIVEBOUNDINGBOXEXTPROC __rglgen_glPrimitiveBoundingBoxEXT;
RGLSYMGLRASTERSAMPLESEXTPROC __rglgen_glRasterSamplesEXT;
RGLSYMGLGETGRAPHICSRESETSTATUSEXTPROC __rglgen_glGetGraphicsResetStatusEXT;
RGLSYMGLREADNPIXELSEXTPROC __rglgen_glReadnPixelsEXT;
RGLSYMGLGETNUNIFORMFVEXTPROC __rglgen_glGetnUniformfvEXT;
RGLSYMGLGETNUNIFORMIVEXTPROC __rglgen_glGetnUniformivEXT;
RGLSYMGLACTIVESHADERPROGRAMEXTPROC __rglgen_glActiveShaderProgramEXT;
RGLSYMGLBINDPROGRAMPIPELINEEXTPROC __rglgen_glBindProgramPipelineEXT;
RGLSYMGLCREATESHADERPROGRAMVEXTPROC __rglgen_glCreateShaderProgramvEXT;
RGLSYMGLDELETEPROGRAMPIPELINESEXTPROC __rglgen_glDeleteProgramPipelinesEXT;
RGLSYMGLGENPROGRAMPIPELINESEXTPROC __rglgen_glGenProgramPipelinesEXT;
RGLSYMGLGETPROGRAMPIPELINEINFOLOGEXTPROC __rglgen_glGetProgramPipelineInfoLogEXT;
RGLSYMGLGETPROGRAMPIPELINEIVEXTPROC __rglgen_glGetProgramPipelineivEXT;
RGLSYMGLISPROGRAMPIPELINEEXTPROC __rglgen_glIsProgramPipelineEXT;
RGLSYMGLPROGRAMPARAMETERIEXTPROC __rglgen_glProgramParameteriEXT;
RGLSYMGLPROGRAMUNIFORM1FEXTPROC __rglgen_glProgramUniform1fEXT;
RGLSYMGLPROGRAMUNIFORM1FVEXTPROC __rglgen_glProgramUniform1fvEXT;
RGLSYMGLPROGRAMUNIFORM1IEXTPROC __rglgen_glProgramUniform1iEXT;
RGLSYMGLPROGRAMUNIFORM1IVEXTPROC __rglgen_glProgramUniform1ivEXT;
RGLSYMGLPROGRAMUNIFORM2FEXTPROC __rglgen_glProgramUniform2fEXT;
RGLSYMGLPROGRAMUNIFORM2FVEXTPROC __rglgen_glProgramUniform2fvEXT;
RGLSYMGLPROGRAMUNIFORM2IEXTPROC __rglgen_glProgramUniform2iEXT;
RGLSYMGLPROGRAMUNIFORM2IVEXTPROC __rglgen_glProgramUniform2ivEXT;
RGLSYMGLPROGRAMUNIFORM3FEXTPROC __rglgen_glProgramUniform3fEXT;
RGLSYMGLPROGRAMUNIFORM3FVEXTPROC __rglgen_glProgramUniform3fvEXT;
RGLSYMGLPROGRAMUNIFORM3IEXTPROC __rglgen_glProgramUniform3iEXT;
RGLSYMGLPROGRAMUNIFORM3IVEXTPROC __rglgen_glProgramUniform3ivEXT;
RGLSYMGLPROGRAMUNIFORM4FEXTPROC __rglgen_glProgramUniform4fEXT;
RGLSYMGLPROGRAMUNIFORM4FVEXTPROC __rglgen_glProgramUniform4fvEXT;
RGLSYMGLPROGRAMUNIFORM4IEXTPROC __rglgen_glProgramUniform4iEXT;
RGLSYMGLPROGRAMUNIFORM4IVEXTPROC __rglgen_glProgramUniform4ivEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX2FVEXTPROC __rglgen_glProgramUniformMatrix2fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX3FVEXTPROC __rglgen_glProgramUniformMatrix3fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX4FVEXTPROC __rglgen_glProgramUniformMatrix4fvEXT;
RGLSYMGLUSEPROGRAMSTAGESEXTPROC __rglgen_glUseProgramStagesEXT;
RGLSYMGLVALIDATEPROGRAMPIPELINEEXTPROC __rglgen_glValidateProgramPipelineEXT;
RGLSYMGLPROGRAMUNIFORM1UIEXTPROC __rglgen_glProgramUniform1uiEXT;
RGLSYMGLPROGRAMUNIFORM2UIEXTPROC __rglgen_glProgramUniform2uiEXT;
RGLSYMGLPROGRAMUNIFORM3UIEXTPROC __rglgen_glProgramUniform3uiEXT;
RGLSYMGLPROGRAMUNIFORM4UIEXTPROC __rglgen_glProgramUniform4uiEXT;
RGLSYMGLPROGRAMUNIFORM1UIVEXTPROC __rglgen_glProgramUniform1uivEXT;
RGLSYMGLPROGRAMUNIFORM2UIVEXTPROC __rglgen_glProgramUniform2uivEXT;
RGLSYMGLPROGRAMUNIFORM3UIVEXTPROC __rglgen_glProgramUniform3uivEXT;
RGLSYMGLPROGRAMUNIFORM4UIVEXTPROC __rglgen_glProgramUniform4uivEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC __rglgen_glProgramUniformMatrix2x3fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC __rglgen_glProgramUniformMatrix3x2fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC __rglgen_glProgramUniformMatrix2x4fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC __rglgen_glProgramUniformMatrix4x2fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC __rglgen_glProgramUniformMatrix3x4fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC __rglgen_glProgramUniformMatrix4x3fvEXT;
RGLSYMGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC __rglgen_glFramebufferPixelLocalStorageSizeEXT;
RGLSYMGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC __rglgen_glGetFramebufferPixelLocalStorageSizeEXT;
RGLSYMGLCLEARPIXELLOCALSTORAGEUIEXTPROC __rglgen_glClearPixelLocalStorageuiEXT;
RGLSYMGLTEXPAGECOMMITMENTEXTPROC __rglgen_glTexPageCommitmentEXT;
RGLSYMGLPATCHPARAMETERIEXTPROC __rglgen_glPatchParameteriEXT;
RGLSYMGLTEXPARAMETERIIVEXTPROC __rglgen_glTexParameterIivEXT;
RGLSYMGLTEXPARAMETERIUIVEXTPROC __rglgen_glTexParameterIuivEXT;
RGLSYMGLGETTEXPARAMETERIIVEXTPROC __rglgen_glGetTexParameterIivEXT;
RGLSYMGLGETTEXPARAMETERIUIVEXTPROC __rglgen_glGetTexParameterIuivEXT;
RGLSYMGLSAMPLERPARAMETERIIVEXTPROC __rglgen_glSamplerParameterIivEXT;
RGLSYMGLSAMPLERPARAMETERIUIVEXTPROC __rglgen_glSamplerParameterIuivEXT;
RGLSYMGLGETSAMPLERPARAMETERIIVEXTPROC __rglgen_glGetSamplerParameterIivEXT;
RGLSYMGLGETSAMPLERPARAMETERIUIVEXTPROC __rglgen_glGetSamplerParameterIuivEXT;
RGLSYMGLTEXBUFFEREXTPROC __rglgen_glTexBufferEXT;
RGLSYMGLTEXBUFFERRANGEEXTPROC __rglgen_glTexBufferRangeEXT;
RGLSYMGLTEXSTORAGE1DEXTPROC __rglgen_glTexStorage1DEXT;
RGLSYMGLTEXSTORAGE2DEXTPROC __rglgen_glTexStorage2DEXT;
RGLSYMGLTEXSTORAGE3DEXTPROC __rglgen_glTexStorage3DEXT;
RGLSYMGLTEXTURESTORAGE1DEXTPROC __rglgen_glTextureStorage1DEXT;
RGLSYMGLTEXTURESTORAGE2DEXTPROC __rglgen_glTextureStorage2DEXT;
RGLSYMGLTEXTURESTORAGE3DEXTPROC __rglgen_glTextureStorage3DEXT;
RGLSYMGLTEXTUREVIEWEXTPROC __rglgen_glTextureViewEXT;
RGLSYMGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC __rglgen_glFramebufferTextureMultiviewOVR;
RGLSYMGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC __rglgen_glFramebufferTextureMultisampleMultiviewOVR;
+413
View File
@@ -0,0 +1,413 @@
#include "glsym/glsym.h"
#include <stddef.h>
#define SYM(x) { "gl" #x, &(gl##x) }
const struct rglgen_sym_map rglgen_symbol_map[] = {
SYM(BlendBarrierKHR),
SYM(DebugMessageControlKHR),
SYM(DebugMessageInsertKHR),
SYM(DebugMessageCallbackKHR),
SYM(GetDebugMessageLogKHR),
SYM(PushDebugGroupKHR),
SYM(PopDebugGroupKHR),
SYM(ObjectLabelKHR),
SYM(GetObjectLabelKHR),
SYM(ObjectPtrLabelKHR),
SYM(GetObjectPtrLabelKHR),
SYM(GetPointervKHR),
SYM(GetGraphicsResetStatusKHR),
SYM(ReadnPixelsKHR),
SYM(GetnUniformfvKHR),
SYM(GetnUniformivKHR),
SYM(GetnUniformuivKHR),
SYM(EGLImageTargetTexture2DOES),
SYM(EGLImageTargetRenderbufferStorageOES),
SYM(CopyImageSubDataOES),
SYM(EnableiOES),
SYM(DisableiOES),
SYM(BlendEquationiOES),
SYM(BlendEquationSeparateiOES),
SYM(BlendFunciOES),
SYM(BlendFuncSeparateiOES),
SYM(ColorMaskiOES),
SYM(IsEnablediOES),
SYM(DrawElementsBaseVertexOES),
SYM(DrawRangeElementsBaseVertexOES),
SYM(DrawElementsInstancedBaseVertexOES),
SYM(MultiDrawElementsBaseVertexOES),
SYM(FramebufferTextureOES),
SYM(GetProgramBinaryOES),
SYM(ProgramBinaryOES),
SYM(MapBufferOES),
SYM(UnmapBufferOES),
SYM(GetBufferPointervOES),
SYM(PrimitiveBoundingBoxOES),
SYM(MinSampleShadingOES),
SYM(PatchParameteriOES),
SYM(TexImage3DOES),
SYM(TexSubImage3DOES),
SYM(CopyTexSubImage3DOES),
SYM(CompressedTexImage3DOES),
SYM(CompressedTexSubImage3DOES),
SYM(FramebufferTexture3DOES),
SYM(TexParameterIivOES),
SYM(TexParameterIuivOES),
SYM(GetTexParameterIivOES),
SYM(GetTexParameterIuivOES),
SYM(SamplerParameterIivOES),
SYM(SamplerParameterIuivOES),
SYM(GetSamplerParameterIivOES),
SYM(GetSamplerParameterIuivOES),
SYM(TexBufferOES),
SYM(TexBufferRangeOES),
SYM(TexStorage3DMultisampleOES),
SYM(TextureViewOES),
SYM(BindVertexArrayOES),
SYM(DeleteVertexArraysOES),
SYM(GenVertexArraysOES),
SYM(IsVertexArrayOES),
SYM(ViewportArrayvOES),
SYM(ViewportIndexedfOES),
SYM(ViewportIndexedfvOES),
SYM(ScissorArrayvOES),
SYM(ScissorIndexedOES),
SYM(ScissorIndexedvOES),
SYM(DepthRangeArrayfvOES),
SYM(DepthRangeIndexedfOES),
SYM(GetFloati_vOES),
SYM(DrawArraysInstancedBaseInstanceEXT),
SYM(DrawElementsInstancedBaseInstanceEXT),
SYM(DrawElementsInstancedBaseVertexBaseInstanceEXT),
SYM(BindFragDataLocationIndexedEXT),
SYM(BindFragDataLocationEXT),
SYM(GetProgramResourceLocationIndexEXT),
SYM(GetFragDataIndexEXT),
SYM(BufferStorageEXT),
SYM(ClearTexImageEXT),
SYM(ClearTexSubImageEXT),
SYM(CopyImageSubDataEXT),
SYM(LabelObjectEXT),
SYM(GetObjectLabelEXT),
SYM(InsertEventMarkerEXT),
SYM(PushGroupMarkerEXT),
SYM(PopGroupMarkerEXT),
SYM(DiscardFramebufferEXT),
SYM(GenQueriesEXT),
SYM(DeleteQueriesEXT),
SYM(IsQueryEXT),
SYM(BeginQueryEXT),
SYM(EndQueryEXT),
SYM(QueryCounterEXT),
SYM(GetQueryivEXT),
SYM(GetQueryObjectivEXT),
SYM(GetQueryObjectuivEXT),
SYM(GetQueryObjecti64vEXT),
SYM(GetQueryObjectui64vEXT),
SYM(DrawBuffersEXT),
SYM(EnableiEXT),
SYM(DisableiEXT),
SYM(BlendEquationiEXT),
SYM(BlendEquationSeparateiEXT),
SYM(BlendFunciEXT),
SYM(BlendFuncSeparateiEXT),
SYM(ColorMaskiEXT),
SYM(IsEnablediEXT),
SYM(DrawElementsBaseVertexEXT),
SYM(DrawRangeElementsBaseVertexEXT),
SYM(DrawElementsInstancedBaseVertexEXT),
SYM(MultiDrawElementsBaseVertexEXT),
SYM(DrawArraysInstancedEXT),
SYM(DrawElementsInstancedEXT),
SYM(FramebufferTextureEXT),
SYM(VertexAttribDivisorEXT),
SYM(MapBufferRangeEXT),
SYM(FlushMappedBufferRangeEXT),
SYM(MultiDrawArraysEXT),
SYM(MultiDrawElementsEXT),
SYM(MultiDrawArraysIndirectEXT),
SYM(MultiDrawElementsIndirectEXT),
SYM(RenderbufferStorageMultisampleEXT),
SYM(FramebufferTexture2DMultisampleEXT),
SYM(ReadBufferIndexedEXT),
SYM(DrawBuffersIndexedEXT),
SYM(GetIntegeri_vEXT),
SYM(PolygonOffsetClampEXT),
SYM(PrimitiveBoundingBoxEXT),
SYM(RasterSamplesEXT),
SYM(GetGraphicsResetStatusEXT),
SYM(ReadnPixelsEXT),
SYM(GetnUniformfvEXT),
SYM(GetnUniformivEXT),
SYM(ActiveShaderProgramEXT),
SYM(BindProgramPipelineEXT),
SYM(CreateShaderProgramvEXT),
SYM(DeleteProgramPipelinesEXT),
SYM(GenProgramPipelinesEXT),
SYM(GetProgramPipelineInfoLogEXT),
SYM(GetProgramPipelineivEXT),
SYM(IsProgramPipelineEXT),
SYM(ProgramParameteriEXT),
SYM(ProgramUniform1fEXT),
SYM(ProgramUniform1fvEXT),
SYM(ProgramUniform1iEXT),
SYM(ProgramUniform1ivEXT),
SYM(ProgramUniform2fEXT),
SYM(ProgramUniform2fvEXT),
SYM(ProgramUniform2iEXT),
SYM(ProgramUniform2ivEXT),
SYM(ProgramUniform3fEXT),
SYM(ProgramUniform3fvEXT),
SYM(ProgramUniform3iEXT),
SYM(ProgramUniform3ivEXT),
SYM(ProgramUniform4fEXT),
SYM(ProgramUniform4fvEXT),
SYM(ProgramUniform4iEXT),
SYM(ProgramUniform4ivEXT),
SYM(ProgramUniformMatrix2fvEXT),
SYM(ProgramUniformMatrix3fvEXT),
SYM(ProgramUniformMatrix4fvEXT),
SYM(UseProgramStagesEXT),
SYM(ValidateProgramPipelineEXT),
SYM(ProgramUniform1uiEXT),
SYM(ProgramUniform2uiEXT),
SYM(ProgramUniform3uiEXT),
SYM(ProgramUniform4uiEXT),
SYM(ProgramUniform1uivEXT),
SYM(ProgramUniform2uivEXT),
SYM(ProgramUniform3uivEXT),
SYM(ProgramUniform4uivEXT),
SYM(ProgramUniformMatrix2x3fvEXT),
SYM(ProgramUniformMatrix3x2fvEXT),
SYM(ProgramUniformMatrix2x4fvEXT),
SYM(ProgramUniformMatrix4x2fvEXT),
SYM(ProgramUniformMatrix3x4fvEXT),
SYM(ProgramUniformMatrix4x3fvEXT),
SYM(FramebufferPixelLocalStorageSizeEXT),
SYM(GetFramebufferPixelLocalStorageSizeEXT),
SYM(ClearPixelLocalStorageuiEXT),
SYM(TexPageCommitmentEXT),
SYM(PatchParameteriEXT),
SYM(TexParameterIivEXT),
SYM(TexParameterIuivEXT),
SYM(GetTexParameterIivEXT),
SYM(GetTexParameterIuivEXT),
SYM(SamplerParameterIivEXT),
SYM(SamplerParameterIuivEXT),
SYM(GetSamplerParameterIivEXT),
SYM(GetSamplerParameterIuivEXT),
SYM(TexBufferEXT),
SYM(TexBufferRangeEXT),
SYM(TexStorage1DEXT),
SYM(TexStorage2DEXT),
SYM(TexStorage3DEXT),
SYM(TextureStorage1DEXT),
SYM(TextureStorage2DEXT),
SYM(TextureStorage3DEXT),
SYM(TextureViewEXT),
SYM(FramebufferTextureMultiviewOVR),
SYM(FramebufferTextureMultisampleMultiviewOVR),
{ NULL, NULL },
};
RGLSYMGLBLENDBARRIERKHRPROC __rglgen_glBlendBarrierKHR;
RGLSYMGLDEBUGMESSAGECONTROLKHRPROC __rglgen_glDebugMessageControlKHR;
RGLSYMGLDEBUGMESSAGEINSERTKHRPROC __rglgen_glDebugMessageInsertKHR;
RGLSYMGLDEBUGMESSAGECALLBACKKHRPROC __rglgen_glDebugMessageCallbackKHR;
RGLSYMGLGETDEBUGMESSAGELOGKHRPROC __rglgen_glGetDebugMessageLogKHR;
RGLSYMGLPUSHDEBUGGROUPKHRPROC __rglgen_glPushDebugGroupKHR;
RGLSYMGLPOPDEBUGGROUPKHRPROC __rglgen_glPopDebugGroupKHR;
RGLSYMGLOBJECTLABELKHRPROC __rglgen_glObjectLabelKHR;
RGLSYMGLGETOBJECTLABELKHRPROC __rglgen_glGetObjectLabelKHR;
RGLSYMGLOBJECTPTRLABELKHRPROC __rglgen_glObjectPtrLabelKHR;
RGLSYMGLGETOBJECTPTRLABELKHRPROC __rglgen_glGetObjectPtrLabelKHR;
RGLSYMGLGETPOINTERVKHRPROC __rglgen_glGetPointervKHR;
RGLSYMGLGETGRAPHICSRESETSTATUSKHRPROC __rglgen_glGetGraphicsResetStatusKHR;
RGLSYMGLREADNPIXELSKHRPROC __rglgen_glReadnPixelsKHR;
RGLSYMGLGETNUNIFORMFVKHRPROC __rglgen_glGetnUniformfvKHR;
RGLSYMGLGETNUNIFORMIVKHRPROC __rglgen_glGetnUniformivKHR;
RGLSYMGLGETNUNIFORMUIVKHRPROC __rglgen_glGetnUniformuivKHR;
RGLSYMGLEGLIMAGETARGETTEXTURE2DOESPROC __rglgen_glEGLImageTargetTexture2DOES;
RGLSYMGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC __rglgen_glEGLImageTargetRenderbufferStorageOES;
RGLSYMGLCOPYIMAGESUBDATAOESPROC __rglgen_glCopyImageSubDataOES;
RGLSYMGLENABLEIOESPROC __rglgen_glEnableiOES;
RGLSYMGLDISABLEIOESPROC __rglgen_glDisableiOES;
RGLSYMGLBLENDEQUATIONIOESPROC __rglgen_glBlendEquationiOES;
RGLSYMGLBLENDEQUATIONSEPARATEIOESPROC __rglgen_glBlendEquationSeparateiOES;
RGLSYMGLBLENDFUNCIOESPROC __rglgen_glBlendFunciOES;
RGLSYMGLBLENDFUNCSEPARATEIOESPROC __rglgen_glBlendFuncSeparateiOES;
RGLSYMGLCOLORMASKIOESPROC __rglgen_glColorMaskiOES;
RGLSYMGLISENABLEDIOESPROC __rglgen_glIsEnablediOES;
RGLSYMGLDRAWELEMENTSBASEVERTEXOESPROC __rglgen_glDrawElementsBaseVertexOES;
RGLSYMGLDRAWRANGEELEMENTSBASEVERTEXOESPROC __rglgen_glDrawRangeElementsBaseVertexOES;
RGLSYMGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC __rglgen_glDrawElementsInstancedBaseVertexOES;
RGLSYMGLMULTIDRAWELEMENTSBASEVERTEXOESPROC __rglgen_glMultiDrawElementsBaseVertexOES;
RGLSYMGLFRAMEBUFFERTEXTUREOESPROC __rglgen_glFramebufferTextureOES;
RGLSYMGLGETPROGRAMBINARYOESPROC __rglgen_glGetProgramBinaryOES;
RGLSYMGLPROGRAMBINARYOESPROC __rglgen_glProgramBinaryOES;
RGLSYMGLMAPBUFFEROESPROC __rglgen_glMapBufferOES;
RGLSYMGLUNMAPBUFFEROESPROC __rglgen_glUnmapBufferOES;
RGLSYMGLGETBUFFERPOINTERVOESPROC __rglgen_glGetBufferPointervOES;
RGLSYMGLPRIMITIVEBOUNDINGBOXOESPROC __rglgen_glPrimitiveBoundingBoxOES;
RGLSYMGLMINSAMPLESHADINGOESPROC __rglgen_glMinSampleShadingOES;
RGLSYMGLPATCHPARAMETERIOESPROC __rglgen_glPatchParameteriOES;
RGLSYMGLTEXIMAGE3DOESPROC __rglgen_glTexImage3DOES;
RGLSYMGLTEXSUBIMAGE3DOESPROC __rglgen_glTexSubImage3DOES;
RGLSYMGLCOPYTEXSUBIMAGE3DOESPROC __rglgen_glCopyTexSubImage3DOES;
RGLSYMGLCOMPRESSEDTEXIMAGE3DOESPROC __rglgen_glCompressedTexImage3DOES;
RGLSYMGLCOMPRESSEDTEXSUBIMAGE3DOESPROC __rglgen_glCompressedTexSubImage3DOES;
RGLSYMGLFRAMEBUFFERTEXTURE3DOESPROC __rglgen_glFramebufferTexture3DOES;
RGLSYMGLTEXPARAMETERIIVOESPROC __rglgen_glTexParameterIivOES;
RGLSYMGLTEXPARAMETERIUIVOESPROC __rglgen_glTexParameterIuivOES;
RGLSYMGLGETTEXPARAMETERIIVOESPROC __rglgen_glGetTexParameterIivOES;
RGLSYMGLGETTEXPARAMETERIUIVOESPROC __rglgen_glGetTexParameterIuivOES;
RGLSYMGLSAMPLERPARAMETERIIVOESPROC __rglgen_glSamplerParameterIivOES;
RGLSYMGLSAMPLERPARAMETERIUIVOESPROC __rglgen_glSamplerParameterIuivOES;
RGLSYMGLGETSAMPLERPARAMETERIIVOESPROC __rglgen_glGetSamplerParameterIivOES;
RGLSYMGLGETSAMPLERPARAMETERIUIVOESPROC __rglgen_glGetSamplerParameterIuivOES;
RGLSYMGLTEXBUFFEROESPROC __rglgen_glTexBufferOES;
RGLSYMGLTEXBUFFERRANGEOESPROC __rglgen_glTexBufferRangeOES;
RGLSYMGLTEXSTORAGE3DMULTISAMPLEOESPROC __rglgen_glTexStorage3DMultisampleOES;
RGLSYMGLTEXTUREVIEWOESPROC __rglgen_glTextureViewOES;
RGLSYMGLBINDVERTEXARRAYOESPROC __rglgen_glBindVertexArrayOES;
RGLSYMGLDELETEVERTEXARRAYSOESPROC __rglgen_glDeleteVertexArraysOES;
RGLSYMGLGENVERTEXARRAYSOESPROC __rglgen_glGenVertexArraysOES;
RGLSYMGLISVERTEXARRAYOESPROC __rglgen_glIsVertexArrayOES;
RGLSYMGLVIEWPORTARRAYVOESPROC __rglgen_glViewportArrayvOES;
RGLSYMGLVIEWPORTINDEXEDFOESPROC __rglgen_glViewportIndexedfOES;
RGLSYMGLVIEWPORTINDEXEDFVOESPROC __rglgen_glViewportIndexedfvOES;
RGLSYMGLSCISSORARRAYVOESPROC __rglgen_glScissorArrayvOES;
RGLSYMGLSCISSORINDEXEDOESPROC __rglgen_glScissorIndexedOES;
RGLSYMGLSCISSORINDEXEDVOESPROC __rglgen_glScissorIndexedvOES;
RGLSYMGLDEPTHRANGEARRAYFVOESPROC __rglgen_glDepthRangeArrayfvOES;
RGLSYMGLDEPTHRANGEINDEXEDFOESPROC __rglgen_glDepthRangeIndexedfOES;
RGLSYMGLGETFLOATI_VOESPROC __rglgen_glGetFloati_vOES;
RGLSYMGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC __rglgen_glDrawArraysInstancedBaseInstanceEXT;
RGLSYMGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC __rglgen_glDrawElementsInstancedBaseInstanceEXT;
RGLSYMGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC __rglgen_glDrawElementsInstancedBaseVertexBaseInstanceEXT;
RGLSYMGLBINDFRAGDATALOCATIONINDEXEDEXTPROC __rglgen_glBindFragDataLocationIndexedEXT;
RGLSYMGLBINDFRAGDATALOCATIONEXTPROC __rglgen_glBindFragDataLocationEXT;
RGLSYMGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC __rglgen_glGetProgramResourceLocationIndexEXT;
RGLSYMGLGETFRAGDATAINDEXEXTPROC __rglgen_glGetFragDataIndexEXT;
RGLSYMGLBUFFERSTORAGEEXTPROC __rglgen_glBufferStorageEXT;
RGLSYMGLCLEARTEXIMAGEEXTPROC __rglgen_glClearTexImageEXT;
RGLSYMGLCLEARTEXSUBIMAGEEXTPROC __rglgen_glClearTexSubImageEXT;
RGLSYMGLCOPYIMAGESUBDATAEXTPROC __rglgen_glCopyImageSubDataEXT;
RGLSYMGLLABELOBJECTEXTPROC __rglgen_glLabelObjectEXT;
RGLSYMGLGETOBJECTLABELEXTPROC __rglgen_glGetObjectLabelEXT;
RGLSYMGLINSERTEVENTMARKEREXTPROC __rglgen_glInsertEventMarkerEXT;
RGLSYMGLPUSHGROUPMARKEREXTPROC __rglgen_glPushGroupMarkerEXT;
RGLSYMGLPOPGROUPMARKEREXTPROC __rglgen_glPopGroupMarkerEXT;
RGLSYMGLDISCARDFRAMEBUFFEREXTPROC __rglgen_glDiscardFramebufferEXT;
RGLSYMGLGENQUERIESEXTPROC __rglgen_glGenQueriesEXT;
RGLSYMGLDELETEQUERIESEXTPROC __rglgen_glDeleteQueriesEXT;
RGLSYMGLISQUERYEXTPROC __rglgen_glIsQueryEXT;
RGLSYMGLBEGINQUERYEXTPROC __rglgen_glBeginQueryEXT;
RGLSYMGLENDQUERYEXTPROC __rglgen_glEndQueryEXT;
RGLSYMGLQUERYCOUNTEREXTPROC __rglgen_glQueryCounterEXT;
RGLSYMGLGETQUERYIVEXTPROC __rglgen_glGetQueryivEXT;
RGLSYMGLGETQUERYOBJECTIVEXTPROC __rglgen_glGetQueryObjectivEXT;
RGLSYMGLGETQUERYOBJECTUIVEXTPROC __rglgen_glGetQueryObjectuivEXT;
RGLSYMGLGETQUERYOBJECTI64VEXTPROC __rglgen_glGetQueryObjecti64vEXT;
RGLSYMGLGETQUERYOBJECTUI64VEXTPROC __rglgen_glGetQueryObjectui64vEXT;
RGLSYMGLDRAWBUFFERSEXTPROC __rglgen_glDrawBuffersEXT;
RGLSYMGLENABLEIEXTPROC __rglgen_glEnableiEXT;
RGLSYMGLDISABLEIEXTPROC __rglgen_glDisableiEXT;
RGLSYMGLBLENDEQUATIONIEXTPROC __rglgen_glBlendEquationiEXT;
RGLSYMGLBLENDEQUATIONSEPARATEIEXTPROC __rglgen_glBlendEquationSeparateiEXT;
RGLSYMGLBLENDFUNCIEXTPROC __rglgen_glBlendFunciEXT;
RGLSYMGLBLENDFUNCSEPARATEIEXTPROC __rglgen_glBlendFuncSeparateiEXT;
RGLSYMGLCOLORMASKIEXTPROC __rglgen_glColorMaskiEXT;
RGLSYMGLISENABLEDIEXTPROC __rglgen_glIsEnablediEXT;
RGLSYMGLDRAWELEMENTSBASEVERTEXEXTPROC __rglgen_glDrawElementsBaseVertexEXT;
RGLSYMGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC __rglgen_glDrawRangeElementsBaseVertexEXT;
RGLSYMGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC __rglgen_glDrawElementsInstancedBaseVertexEXT;
RGLSYMGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC __rglgen_glMultiDrawElementsBaseVertexEXT;
RGLSYMGLDRAWARRAYSINSTANCEDEXTPROC __rglgen_glDrawArraysInstancedEXT;
RGLSYMGLDRAWELEMENTSINSTANCEDEXTPROC __rglgen_glDrawElementsInstancedEXT;
RGLSYMGLFRAMEBUFFERTEXTUREEXTPROC __rglgen_glFramebufferTextureEXT;
RGLSYMGLVERTEXATTRIBDIVISOREXTPROC __rglgen_glVertexAttribDivisorEXT;
RGLSYMGLMAPBUFFERRANGEEXTPROC __rglgen_glMapBufferRangeEXT;
RGLSYMGLFLUSHMAPPEDBUFFERRANGEEXTPROC __rglgen_glFlushMappedBufferRangeEXT;
RGLSYMGLMULTIDRAWARRAYSEXTPROC __rglgen_glMultiDrawArraysEXT;
RGLSYMGLMULTIDRAWELEMENTSEXTPROC __rglgen_glMultiDrawElementsEXT;
RGLSYMGLMULTIDRAWARRAYSINDIRECTEXTPROC __rglgen_glMultiDrawArraysIndirectEXT;
RGLSYMGLMULTIDRAWELEMENTSINDIRECTEXTPROC __rglgen_glMultiDrawElementsIndirectEXT;
RGLSYMGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __rglgen_glRenderbufferStorageMultisampleEXT;
RGLSYMGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC __rglgen_glFramebufferTexture2DMultisampleEXT;
RGLSYMGLREADBUFFERINDEXEDEXTPROC __rglgen_glReadBufferIndexedEXT;
RGLSYMGLDRAWBUFFERSINDEXEDEXTPROC __rglgen_glDrawBuffersIndexedEXT;
RGLSYMGLGETINTEGERI_VEXTPROC __rglgen_glGetIntegeri_vEXT;
RGLSYMGLPOLYGONOFFSETCLAMPEXTPROC __rglgen_glPolygonOffsetClampEXT;
RGLSYMGLPRIMITIVEBOUNDINGBOXEXTPROC __rglgen_glPrimitiveBoundingBoxEXT;
RGLSYMGLRASTERSAMPLESEXTPROC __rglgen_glRasterSamplesEXT;
RGLSYMGLGETGRAPHICSRESETSTATUSEXTPROC __rglgen_glGetGraphicsResetStatusEXT;
RGLSYMGLREADNPIXELSEXTPROC __rglgen_glReadnPixelsEXT;
RGLSYMGLGETNUNIFORMFVEXTPROC __rglgen_glGetnUniformfvEXT;
RGLSYMGLGETNUNIFORMIVEXTPROC __rglgen_glGetnUniformivEXT;
RGLSYMGLACTIVESHADERPROGRAMEXTPROC __rglgen_glActiveShaderProgramEXT;
RGLSYMGLBINDPROGRAMPIPELINEEXTPROC __rglgen_glBindProgramPipelineEXT;
RGLSYMGLCREATESHADERPROGRAMVEXTPROC __rglgen_glCreateShaderProgramvEXT;
RGLSYMGLDELETEPROGRAMPIPELINESEXTPROC __rglgen_glDeleteProgramPipelinesEXT;
RGLSYMGLGENPROGRAMPIPELINESEXTPROC __rglgen_glGenProgramPipelinesEXT;
RGLSYMGLGETPROGRAMPIPELINEINFOLOGEXTPROC __rglgen_glGetProgramPipelineInfoLogEXT;
RGLSYMGLGETPROGRAMPIPELINEIVEXTPROC __rglgen_glGetProgramPipelineivEXT;
RGLSYMGLISPROGRAMPIPELINEEXTPROC __rglgen_glIsProgramPipelineEXT;
RGLSYMGLPROGRAMPARAMETERIEXTPROC __rglgen_glProgramParameteriEXT;
RGLSYMGLPROGRAMUNIFORM1FEXTPROC __rglgen_glProgramUniform1fEXT;
RGLSYMGLPROGRAMUNIFORM1FVEXTPROC __rglgen_glProgramUniform1fvEXT;
RGLSYMGLPROGRAMUNIFORM1IEXTPROC __rglgen_glProgramUniform1iEXT;
RGLSYMGLPROGRAMUNIFORM1IVEXTPROC __rglgen_glProgramUniform1ivEXT;
RGLSYMGLPROGRAMUNIFORM2FEXTPROC __rglgen_glProgramUniform2fEXT;
RGLSYMGLPROGRAMUNIFORM2FVEXTPROC __rglgen_glProgramUniform2fvEXT;
RGLSYMGLPROGRAMUNIFORM2IEXTPROC __rglgen_glProgramUniform2iEXT;
RGLSYMGLPROGRAMUNIFORM2IVEXTPROC __rglgen_glProgramUniform2ivEXT;
RGLSYMGLPROGRAMUNIFORM3FEXTPROC __rglgen_glProgramUniform3fEXT;
RGLSYMGLPROGRAMUNIFORM3FVEXTPROC __rglgen_glProgramUniform3fvEXT;
RGLSYMGLPROGRAMUNIFORM3IEXTPROC __rglgen_glProgramUniform3iEXT;
RGLSYMGLPROGRAMUNIFORM3IVEXTPROC __rglgen_glProgramUniform3ivEXT;
RGLSYMGLPROGRAMUNIFORM4FEXTPROC __rglgen_glProgramUniform4fEXT;
RGLSYMGLPROGRAMUNIFORM4FVEXTPROC __rglgen_glProgramUniform4fvEXT;
RGLSYMGLPROGRAMUNIFORM4IEXTPROC __rglgen_glProgramUniform4iEXT;
RGLSYMGLPROGRAMUNIFORM4IVEXTPROC __rglgen_glProgramUniform4ivEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX2FVEXTPROC __rglgen_glProgramUniformMatrix2fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX3FVEXTPROC __rglgen_glProgramUniformMatrix3fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX4FVEXTPROC __rglgen_glProgramUniformMatrix4fvEXT;
RGLSYMGLUSEPROGRAMSTAGESEXTPROC __rglgen_glUseProgramStagesEXT;
RGLSYMGLVALIDATEPROGRAMPIPELINEEXTPROC __rglgen_glValidateProgramPipelineEXT;
RGLSYMGLPROGRAMUNIFORM1UIEXTPROC __rglgen_glProgramUniform1uiEXT;
RGLSYMGLPROGRAMUNIFORM2UIEXTPROC __rglgen_glProgramUniform2uiEXT;
RGLSYMGLPROGRAMUNIFORM3UIEXTPROC __rglgen_glProgramUniform3uiEXT;
RGLSYMGLPROGRAMUNIFORM4UIEXTPROC __rglgen_glProgramUniform4uiEXT;
RGLSYMGLPROGRAMUNIFORM1UIVEXTPROC __rglgen_glProgramUniform1uivEXT;
RGLSYMGLPROGRAMUNIFORM2UIVEXTPROC __rglgen_glProgramUniform2uivEXT;
RGLSYMGLPROGRAMUNIFORM3UIVEXTPROC __rglgen_glProgramUniform3uivEXT;
RGLSYMGLPROGRAMUNIFORM4UIVEXTPROC __rglgen_glProgramUniform4uivEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC __rglgen_glProgramUniformMatrix2x3fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC __rglgen_glProgramUniformMatrix3x2fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC __rglgen_glProgramUniformMatrix2x4fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC __rglgen_glProgramUniformMatrix4x2fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC __rglgen_glProgramUniformMatrix3x4fvEXT;
RGLSYMGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC __rglgen_glProgramUniformMatrix4x3fvEXT;
RGLSYMGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC __rglgen_glFramebufferPixelLocalStorageSizeEXT;
RGLSYMGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC __rglgen_glGetFramebufferPixelLocalStorageSizeEXT;
RGLSYMGLCLEARPIXELLOCALSTORAGEUIEXTPROC __rglgen_glClearPixelLocalStorageuiEXT;
RGLSYMGLTEXPAGECOMMITMENTEXTPROC __rglgen_glTexPageCommitmentEXT;
RGLSYMGLPATCHPARAMETERIEXTPROC __rglgen_glPatchParameteriEXT;
RGLSYMGLTEXPARAMETERIIVEXTPROC __rglgen_glTexParameterIivEXT;
RGLSYMGLTEXPARAMETERIUIVEXTPROC __rglgen_glTexParameterIuivEXT;
RGLSYMGLGETTEXPARAMETERIIVEXTPROC __rglgen_glGetTexParameterIivEXT;
RGLSYMGLGETTEXPARAMETERIUIVEXTPROC __rglgen_glGetTexParameterIuivEXT;
RGLSYMGLSAMPLERPARAMETERIIVEXTPROC __rglgen_glSamplerParameterIivEXT;
RGLSYMGLSAMPLERPARAMETERIUIVEXTPROC __rglgen_glSamplerParameterIuivEXT;
RGLSYMGLGETSAMPLERPARAMETERIIVEXTPROC __rglgen_glGetSamplerParameterIivEXT;
RGLSYMGLGETSAMPLERPARAMETERIUIVEXTPROC __rglgen_glGetSamplerParameterIuivEXT;
RGLSYMGLTEXBUFFEREXTPROC __rglgen_glTexBufferEXT;
RGLSYMGLTEXBUFFERRANGEEXTPROC __rglgen_glTexBufferRangeEXT;
RGLSYMGLTEXSTORAGE1DEXTPROC __rglgen_glTexStorage1DEXT;
RGLSYMGLTEXSTORAGE2DEXTPROC __rglgen_glTexStorage2DEXT;
RGLSYMGLTEXSTORAGE3DEXTPROC __rglgen_glTexStorage3DEXT;
RGLSYMGLTEXTURESTORAGE1DEXTPROC __rglgen_glTextureStorage1DEXT;
RGLSYMGLTEXTURESTORAGE2DEXTPROC __rglgen_glTextureStorage2DEXT;
RGLSYMGLTEXTURESTORAGE3DEXTPROC __rglgen_glTextureStorage3DEXT;
RGLSYMGLTEXTUREVIEWEXTPROC __rglgen_glTextureViewEXT;
RGLSYMGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC __rglgen_glFramebufferTextureMultiviewOVR;
RGLSYMGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC __rglgen_glFramebufferTextureMultisampleMultiviewOVR;
File diff suppressed because it is too large. Load diff
+45
View File
@@ -0,0 +1,45 @@
/* Copyright (C) 2010-2018 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this libretro SDK code part (glsym).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdint.h>
#include <string.h>
#include <glsym/rglgen.h>
#include <glsym/glsym.h>
void rglgen_resolve_symbols_custom(rglgen_proc_address_t proc,
const struct rglgen_sym_map *map)
{
for (; map->sym; map++)
{
rglgen_func_t func = proc(map->sym);
memcpy(map->ptr, &func, sizeof(func));
}
}
void rglgen_resolve_symbols(rglgen_proc_address_t proc)
{
if (!proc)
return;
rglgen_resolve_symbols_custom(proc, rglgen_symbol_map);
}
+149
View File
@@ -0,0 +1,149 @@
#!/usr/bin/env python3
"""
License statement applies to this file (glgen.py) only.
"""
"""
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
import sys
import os
import re
banned_ext = [ 'AMD', 'APPLE', 'NV', 'NVX', 'ATI', '3DLABS', 'SUN', 'SGI', 'SGIX', 'SGIS', 'INTEL', '3DFX', 'IBM', 'MESA', 'GREMEDY', 'OML', 'PGI', 'I3D', 'INGL', 'MTX', 'QCOM', 'IMG', 'ANGLE', 'SUNX', 'INGR' ]
def noext(sym):
for ext in banned_ext:
if sym.endswith(ext):
return False
return True
def fix_multiline_functions(lines):
fixed_lines = []
temp_lines = []
for line in lines:
if line.count('(') > line.count(')'):
temp_lines.append(line)
else:
if len(temp_lines) > 0:
if line.count(')') > line.count('('):
temp_lines.append(line)
fixed_line = re.sub(' +',' ', ''.join(temp_lines).replace('\n','').replace('\t',''))
fixed_lines.append(fixed_line)
temp_lines = []
else:
temp_lines.append(line)
else:
fixed_lines.append(line)
return fixed_lines
def find_gl_symbols(lines):
typedefs = []
syms = []
for line in lines:
m = re.search(r'^typedef.+PFN(\S+)PROC.+$', line)
g = re.search(r'^.+(gl\S+)\W*\(.+\).*$', line)
if m and noext(m.group(1)):
typedefs.append(m.group(0).replace('PFN', 'RGLSYM').replace('GLDEBUGPROC', 'RGLGENGLDEBUGPROC'))
if g and noext(g.group(1)):
syms.append(g.group(1))
return (typedefs, syms)
def generate_defines(gl_syms):
res = []
for line in gl_syms:
res.append('#define {} __rglgen_{}'.format(line, line))
return res
def generate_declarations(gl_syms):
return ['RGLSYM' + x.upper() + 'PROC ' + '__rglgen_' + x + ';' for x in gl_syms]
def generate_macros(gl_syms):
return [' SYM(' + x.replace('gl', '') + '),' for x in gl_syms]
def dump(f, lines):
f.write('\n'.join(lines))
f.write('\n\n')
if __name__ == '__main__':
if len(sys.argv) > 4:
for banned in sys.argv[4:]:
banned_ext.append(banned)
with open(sys.argv[1], 'r') as f:
lines = fix_multiline_functions(f.readlines())
typedefs, syms = find_gl_symbols(lines)
overrides = generate_defines(syms)
declarations = generate_declarations(syms)
externs = ['extern ' + x for x in declarations]
macros = generate_macros(syms)
with open(sys.argv[2], 'w') as f:
f.write('#ifndef RGLGEN_DECL_H__\n')
f.write('#define RGLGEN_DECL_H__\n')
f.write('#ifdef __cplusplus\n')
f.write('extern "C" {\n')
f.write('#endif\n')
f.write('#ifdef GL_APIENTRY\n')
f.write('typedef void (GL_APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);\n')
f.write('#else\n')
f.write('#ifndef APIENTRY\n')
f.write('#define APIENTRY\n')
f.write('#endif\n')
f.write('#ifndef APIENTRYP\n')
f.write('#define APIENTRYP APIENTRY *\n')
f.write('#endif\n')
f.write('typedef void (APIENTRY *RGLGENGLDEBUGPROCARB)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);\n')
f.write('typedef void (APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);\n')
f.write('#endif\n')
f.write('#ifndef GL_OES_EGL_image\n')
f.write('typedef void *GLeglImageOES;\n')
f.write('#endif\n')
f.write('#if !defined(GL_OES_fixed_point) && !defined(HAVE_OPENGLES2)\n')
f.write('typedef GLint GLfixed;\n')
f.write('#endif\n')
dump(f, typedefs)
dump(f, overrides)
dump(f, externs)
f.write('struct rglgen_sym_map { const char *sym; void *ptr; };\n')
f.write('extern const struct rglgen_sym_map rglgen_symbol_map[];\n')
f.write('#ifdef __cplusplus\n')
f.write('}\n')
f.write('#endif\n')
f.write('#endif\n')
with open(sys.argv[3], 'w') as f:
f.write('#include "glsym/glsym.h"\n')
f.write('#include <stddef.h>\n')
f.write('#define SYM(x) { "gl" #x, &(gl##x) }\n')
f.write('const struct rglgen_sym_map rglgen_symbol_map[] = {\n')
dump(f, macros)
f.write(' { NULL, NULL },\n')
f.write('};\n')
dump(f, declarations)
+158
View File
@@ -0,0 +1,158 @@
#!/usr/bin/env python3
"""
License statement applies to this file (xglgen.py) only.
"""
"""
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
import sys
import os
import re
banned_ext = [ 'AMD', 'APPLE', 'NV', 'NVX', 'ATI', '3DLABS', 'SUN', 'SGI', 'SGIX', 'SGIS', 'INTEL', '3DFX', 'IBM', 'MESA', 'GREMEDY', 'OML', 'PGI', 'I3D', 'INGL', 'MTX', 'QCOM', 'IMG', 'ANGLE', 'SUNX', 'INGR' ]
def noext(sym):
for ext in banned_ext:
if sym.endswith(ext):
return False
return True
def fix_multiline_functions(lines):
fixed_lines = []
temp_lines = []
for line in lines:
if line.count('(') > line.count(')'):
temp_lines.append(line)
else:
if len(temp_lines) > 0:
if line.count(')') > line.count('('):
temp_lines.append(line)
fixed_line = re.sub(' +',' ', ''.join(temp_lines).replace('\n','').replace('\t',''))
fixed_lines.append(fixed_line)
temp_lines = []
else:
temp_lines.append(line)
else:
fixed_lines.append(line)
return fixed_lines
def find_gl_symbols(lines):
typedefs = []
syms = []
for line in lines:
# Note this doesn't work automated; this script is designed as a helper
m = re.search(r'^typedef.+PFN(\S+)PROC.+$', line)
g = re.search(r'^GLAPI\s(.+)\s(.+)\s(gl\S+)\W*\((.+)\).*', line)
if g and noext(g.group(3)):
typedefs.append('typedef ' + g.group(1) + ' (APIENTRYP RGLSYM' + g.group(3).upper() + 'PROC) (' + g.group(4) + ');')
syms.append(g.group(3))
return (typedefs, syms)
def generate_defines(gl_syms):
res = []
for line in gl_syms:
res.append('#define {} __rglgen_{}'.format(line, line))
return res
def generate_declarations(gl_syms):
return ['RGLSYM' + x.upper() + 'PROC ' + x + ';' for x in gl_syms]
def generate_macros(gl_syms):
return [' SYM(' + x.replace('gl', '') + '),' for x in gl_syms]
def dump(f, lines):
f.write('\n'.join(lines))
f.write('\n\n')
if __name__ == '__main__':
if len(sys.argv) > 4:
for banned in sys.argv[4:]:
banned_ext.append(banned)
with open(sys.argv[1], 'r') as f:
lines = fix_multiline_functions(f.readlines())
typedefs, syms = find_gl_symbols(lines)
overrides = generate_defines(syms)
declarations = generate_declarations(syms)
externs = ['extern ' + x for x in declarations]
macros = generate_macros(syms)
with open(sys.argv[2], 'w') as f:
f.write('#ifndef RGLGEN_DECL_H__\n')
f.write('#define RGLGEN_DECL_H__\n')
f.write('#ifdef __cplusplus\n')
f.write('extern "C" {\n')
f.write('#endif\n')
f.write('#ifdef GL_APIENTRY\n')
f.write('typedef void (GL_APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);\n')
f.write('typedef void (GL_APIENTRY *RGLGENGLDEBUGPROCKHR)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);\n')
f.write('#else\n')
f.write('#ifndef APIENTRY\n')
f.write('#define APIENTRY\n')
f.write('#endif\n')
f.write('#ifndef APIENTRYP\n')
f.write('#define APIENTRYP APIENTRY *\n')
f.write('#endif\n')
f.write('typedef void (APIENTRY *RGLGENGLDEBUGPROCARB)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);\n')
f.write('typedef void (APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);\n')
f.write('#endif\n')
f.write('#ifndef GL_OES_EGL_image\n')
f.write('typedef void *GLeglImageOES;\n')
f.write('#endif\n')
f.write('#if !defined(GL_OES_fixed_point) && !defined(HAVE_OPENGLES2)\n')
f.write('typedef GLint GLfixed;\n')
f.write('#endif\n')
f.write('#if defined(OSX) && !defined(MAC_OS_X_VERSION_10_7)\n')
f.write('typedef long long int GLint64;\n')
f.write('typedef unsigned long long int GLuint64;\n')
f.write('typedef unsigned long long int GLuint64EXT;\n')
f.write('typedef struct __GLsync *GLsync;\n')
f.write('#endif\n')
dump(f, typedefs)
dump(f, overrides)
dump(f, externs)
f.write('struct rglgen_sym_map { const char *sym; void *ptr; };\n')
f.write('extern const struct rglgen_sym_map rglgen_symbol_map[];\n')
f.write('#ifdef __cplusplus\n')
f.write('}\n')
f.write('#endif\n')
f.write('#endif\n')
with open(sys.argv[3], 'w') as f:
f.write('#include "glsym/glsym.h"\n')
f.write('#include <stddef.h>\n')
f.write('#define SYM(x) { "gl" #x, &(gl##x) }\n')
f.write('const struct rglgen_sym_map rglgen_symbol_map[] = {\n')
dump(f, macros)
f.write(' { NULL, NULL },\n')
f.write('};\n')
dump(f, declarations)
@@ -0,0 +1,39 @@
/* Copyright (C) 2010-2018 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (boolean.h).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __LIBRETRO_SDK_BOOLEAN_H
#define __LIBRETRO_SDK_BOOLEAN_H
#ifndef __cplusplus
#if defined(_MSC_VER) && _MSC_VER < 1800 && !defined(SN_TARGET_PS3)
/* Hack applied for MSVC when compiling in C89 mode as it isn't C99 compliant. */
#define bool unsigned char
#define true 1
#define false 0
#else
#include <stdbool.h>
#endif
#endif
#endif
@@ -0,0 +1,127 @@
/* Copyright (C) 2010-2019 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (cdrom.h).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __LIBRETRO_SDK_CDROM_H
#define __LIBRETRO_SDK_CDROM_H
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <sys/types.h>
#include <vfs/vfs.h>
#include <libretro.h>
#include <retro_common_api.h>
#include <retro_inline.h>
#include <boolean.h>
struct string_list;
RETRO_BEGIN_DECLS
typedef struct
{
unsigned short g1_timeout;
unsigned short g2_timeout;
unsigned short g3_timeout;
} cdrom_group_timeouts_t;
typedef struct
{
unsigned lba_start; /* start of pregap */
unsigned lba; /* start of data */
unsigned track_size; /* in LBAs */
unsigned track_bytes;
unsigned char track_num;
unsigned char min; /* start of data */
unsigned char sec;
unsigned char frame;
unsigned char mode;
bool audio;
} cdrom_track_t;
typedef struct
{
char drive;
unsigned char num_tracks;
cdrom_group_timeouts_t timeouts;
cdrom_track_t track[99];
} cdrom_toc_t;
void cdrom_lba_to_msf(unsigned lba, unsigned char *min, unsigned char *sec, unsigned char *frame);
unsigned cdrom_msf_to_lba(unsigned char min, unsigned char sec, unsigned char frame);
void increment_msf(unsigned char *min, unsigned char *sec, unsigned char *frame);
int cdrom_read_subq(libretro_vfs_implementation_file *stream, unsigned char *buf, size_t len);
int cdrom_write_cue(libretro_vfs_implementation_file *stream, char **out_buf, size_t *out_len, char cdrom_drive, unsigned char *num_tracks, cdrom_toc_t *toc);
/* needs 32 bytes for full vendor, product and version */
int cdrom_get_inquiry(const libretro_vfs_implementation_file *stream, char *model, int len, bool *is_cdrom);
int cdrom_read(libretro_vfs_implementation_file *stream, cdrom_group_timeouts_t *timeouts, unsigned char min, unsigned char sec, unsigned char frame, void *s, size_t len, size_t skip);
int cdrom_read_lba(libretro_vfs_implementation_file *stream, unsigned lba, void *s, size_t len, size_t skip);
int cdrom_set_read_speed(libretro_vfs_implementation_file *stream, unsigned speed);
int cdrom_stop(const libretro_vfs_implementation_file *stream);
int cdrom_unlock(const libretro_vfs_implementation_file *stream);
int cdrom_open_tray(const libretro_vfs_implementation_file *stream);
int cdrom_close_tray(const libretro_vfs_implementation_file *stream);
/* must be freed by the caller */
struct string_list* cdrom_get_available_drives(void);
bool cdrom_is_media_inserted(const libretro_vfs_implementation_file *stream);
bool cdrom_drive_has_media(const char drive);
void cdrom_get_current_config_core(const libretro_vfs_implementation_file *stream);
void cdrom_get_current_config_profiles(const libretro_vfs_implementation_file *stream);
void cdrom_get_current_config_cdread(const libretro_vfs_implementation_file *stream);
void cdrom_get_current_config_multiread(const libretro_vfs_implementation_file *stream);
void cdrom_get_current_config_random_readable(const libretro_vfs_implementation_file *stream);
int cdrom_get_sense(const libretro_vfs_implementation_file *stream, unsigned char *sense, size_t len);
bool cdrom_set_read_cache(const libretro_vfs_implementation_file *stream, bool enabled);
bool cdrom_get_timeouts(libretro_vfs_implementation_file *stream, cdrom_group_timeouts_t *timeouts);
bool cdrom_has_atip(const libretro_vfs_implementation_file *stream);
void cdrom_device_fillpath(char *path, size_t len, char drive, unsigned char track, bool is_cue);
RETRO_END_DECLS
#endif
@@ -0,0 +1,65 @@
/* Copyright (C) 2010-2018 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (clamping.h).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _LIBRETRO_SDK_CLAMPING_H
#define _LIBRETRO_SDK_CLAMPING_H
#include <stdint.h>
#include <retro_inline.h>
/**
* clamp_float:
* @val : initial value
* @lower : lower limit that value should be clamped against
* @upper : upper limit that value should be clamped against
*
* Clamps a floating point value.
*
* Returns: a clamped value of initial float value @val.
*/
static INLINE float clamp_float(float val, float lower, float upper)
{
if (val < lower)
return lower;
if (val > upper)
return upper;
return val;
}
/**
* clamp_8bit:
* @val : initial value
*
* Clamps an unsigned 8-bit value.
*
* Returns: a clamped value of initial unsigned 8-bit value @val.
*/
static INLINE uint8_t clamp_8bit(int val)
{
if (val > 255)
return 255;
if (val < 0)
return 0;
return (uint8_t)val;
}
#endif
@@ -0,0 +1,84 @@
/* Copyright (C) 2010-2018 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (apple_compat.h).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __APPLE_COMPAT_H
#define __APPLE_COMPAT_H
#ifdef __APPLE__
#include <AvailabilityMacros.h>
#endif
#ifdef __OBJC__
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
typedef int NSInteger;
typedef unsigned NSUInteger;
typedef float CGFloat;
#endif
#ifndef __has_feature
/* Compatibility with non-Clang compilers. */
#define __has_feature(x) 0
#endif
#ifndef CF_RETURNS_RETAINED
#if __has_feature(attribute_cf_returns_retained)
#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
#else
#define CF_RETURNS_RETAINED
#endif
#endif
#ifndef NS_INLINE
#define NS_INLINE inline
#endif
NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetainCompat(id X)
{
#if __has_feature(objc_arc)
return (__bridge_retained CFTypeRef)X;
#else
return X;
#endif
}
#endif
#ifdef IOS
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>
#import <Foundation/Foundation.h>
#endif
#else
#ifdef __OBJC__
#include <objc/objc-runtime.h>
#endif
#endif
#endif
Loaded 100 of 901 files, more files were not shown because too many files have changed in this diff. Show more