├── .gitattributes
├── .gitignore
├── android
├── AndroidManifest.xml
├── ant.properties
├── assets
│ └── smb3.nes
├── build.properties
├── build.xml
├── default.properties
├── jni
│ ├── Android.mk
│ ├── Application.mk
│ ├── SDL
│ │ └── Android.mk
│ └── src
│ │ ├── Android.mk
│ │ ├── Android_static.mk
│ │ └── nimbase.h
├── local.properties
├── proguard-project.txt
├── project.properties
├── res
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ ├── layout
│ │ └── main.xml
│ └── values
│ │ └── strings.xml
└── src
│ └── org
│ ├── libsdl
│ └── app
│ │ └── SDLActivity.java
│ └── nimes
│ └── nimesActivity.java
├── circle.yml
├── emscripten
├── SDL2
│ ├── SDL.h
│ ├── SDL_assert.h
│ ├── SDL_atomic.h
│ ├── SDL_audio.h
│ ├── SDL_bits.h
│ ├── SDL_blendmode.h
│ ├── SDL_clipboard.h
│ ├── SDL_config.h
│ ├── SDL_cpuinfo.h
│ ├── SDL_egl.h
│ ├── SDL_endian.h
│ ├── SDL_error.h
│ ├── SDL_events.h
│ ├── SDL_filesystem.h
│ ├── SDL_gamecontroller.h
│ ├── SDL_gesture.h
│ ├── SDL_haptic.h
│ ├── SDL_hints.h
│ ├── SDL_joystick.h
│ ├── SDL_keyboard.h
│ ├── SDL_keycode.h
│ ├── SDL_loadso.h
│ ├── SDL_log.h
│ ├── SDL_main.h
│ ├── SDL_messagebox.h
│ ├── SDL_mouse.h
│ ├── SDL_mutex.h
│ ├── SDL_name.h
│ ├── SDL_opengl.h
│ ├── SDL_opengl_glext.h
│ ├── SDL_opengles.h
│ ├── SDL_opengles2.h
│ ├── SDL_opengles2_gl2.h
│ ├── SDL_opengles2_gl2ext.h
│ ├── SDL_opengles2_gl2platform.h
│ ├── SDL_opengles2_khrplatform.h
│ ├── SDL_pixels.h
│ ├── SDL_platform.h
│ ├── SDL_power.h
│ ├── SDL_quit.h
│ ├── SDL_rect.h
│ ├── SDL_render.h
│ ├── SDL_revision.h
│ ├── SDL_rwops.h
│ ├── SDL_scancode.h
│ ├── SDL_shape.h
│ ├── SDL_stdinc.h
│ ├── SDL_surface.h
│ ├── SDL_system.h
│ ├── SDL_syswm.h
│ ├── SDL_test.h
│ ├── SDL_test_assert.h
│ ├── SDL_test_common.h
│ ├── SDL_test_compare.h
│ ├── SDL_test_crc32.h
│ ├── SDL_test_font.h
│ ├── SDL_test_fuzzer.h
│ ├── SDL_test_harness.h
│ ├── SDL_test_images.h
│ ├── SDL_test_log.h
│ ├── SDL_test_md5.h
│ ├── SDL_test_random.h
│ ├── SDL_thread.h
│ ├── SDL_timer.h
│ ├── SDL_touch.h
│ ├── SDL_types.h
│ ├── SDL_version.h
│ ├── SDL_video.h
│ ├── begin_code.h
│ └── close_code.h
├── libSDL2.a
└── readme.md
├── license.txt
├── nakefile.nim
├── nimes.nimble
├── readme.md
└── src
├── nes.nim
├── nes
├── apu.nim
├── cartridge.nim
├── controller.nim
├── cpu.nim
├── mapper.nim
├── mapper1.nim
├── mapper2.nim
├── mapper3.nim
├── mapper4.nim
├── mapper7.nim
├── mem.nim
├── ppu.nim
└── types.nim
├── nim.cfg
├── nimes.nim
└── rewinder.nim
/.gitattributes:
--------------------------------------------------------------------------------
1 | android/* linguist-vendored
2 | emscripten/* linguist-vendored
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !*/
3 | !*.*
4 | nimcache/
5 | *.swp
6 | *.nes
7 |
8 | android/bin
9 | android/gen
10 | android/libs
11 | android/obj
12 | android/jni/src/*.c
13 |
--------------------------------------------------------------------------------
/android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
29 |
34 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/android/ant.properties:
--------------------------------------------------------------------------------
1 | # This file is used to override default values used by the Ant build system.
2 | #
3 | # This file must be checked into Version Control Systems, as it is
4 | # integral to the build system of your project.
5 |
6 | # This file is only used by the Ant script.
7 |
8 | # You can use this to override default values such as
9 | # 'source.dir' for the location of your java source folder and
10 | # 'out.dir' for the location of your output folder.
11 |
12 | # You can also use it define how the release builds are signed by declaring
13 | # the following properties:
14 | # 'key.store' for the location of your keystore and
15 | # 'key.alias' for the name of the key to use.
16 | # The password will be asked during the build when you use the 'release' target.
17 |
18 |
--------------------------------------------------------------------------------
/android/assets/smb3.nes:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/def-/nimes/baefb72c290471f5b487910e1545614b9a3d24b3/android/assets/smb3.nes
--------------------------------------------------------------------------------
/android/build.properties:
--------------------------------------------------------------------------------
1 | # This file is used to override default values used by the Ant build system.
2 | #
3 | # This file must be checked in Version Control Systems, as it is
4 | # integral to the build system of your project.
5 |
6 | # This file is only used by the Ant script.
7 |
8 | # You can use this to override default values such as
9 | # 'source.dir' for the location of your java source folder and
10 | # 'out.dir' for the location of your output folder.
11 |
12 | # You can also use it define how the release builds are signed by declaring
13 | # the following properties:
14 | # 'key.store' for the location of your keystore and
15 | # 'key.alias' for the name of the key to use.
16 | # The password will be asked during the build when you use the 'release' target.
17 |
18 |
--------------------------------------------------------------------------------
/android/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
30 |
31 |
32 |
36 |
37 |
38 |
39 |
40 |
41 |
50 |
51 |
52 |
53 |
57 |
58 |
70 |
71 |
72 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/android/default.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "build.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-12
12 |
--------------------------------------------------------------------------------
/android/jni/Android.mk:
--------------------------------------------------------------------------------
1 | include $(call all-subdir-makefiles)
2 |
--------------------------------------------------------------------------------
/android/jni/Application.mk:
--------------------------------------------------------------------------------
1 |
2 | # Uncomment this if you're using STL in your project
3 | # See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
4 | # APP_STL := stlport_static
5 |
6 | APP_ABI := armeabi armeabi-v7a x86
7 |
--------------------------------------------------------------------------------
/android/jni/SDL/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 |
3 | ###########################
4 | #
5 | # SDL shared library
6 | #
7 | ###########################
8 |
9 | include $(CLEAR_VARS)
10 |
11 | LOCAL_MODULE := SDL2
12 |
13 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
14 |
15 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
16 |
17 | LOCAL_SRC_FILES := \
18 | $(subst $(LOCAL_PATH)/,, \
19 | $(wildcard $(LOCAL_PATH)/src/*.c) \
20 | $(wildcard $(LOCAL_PATH)/src/audio/*.c) \
21 | $(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
22 | $(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
23 | $(LOCAL_PATH)/src/atomic/SDL_atomic.c \
24 | $(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
25 | $(wildcard $(LOCAL_PATH)/src/core/android/*.c) \
26 | $(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \
27 | $(wildcard $(LOCAL_PATH)/src/dynapi/*.c) \
28 | $(wildcard $(LOCAL_PATH)/src/events/*.c) \
29 | $(wildcard $(LOCAL_PATH)/src/file/*.c) \
30 | $(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
31 | $(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
32 | $(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
33 | $(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
34 | $(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
35 | $(wildcard $(LOCAL_PATH)/src/power/*.c) \
36 | $(wildcard $(LOCAL_PATH)/src/power/android/*.c) \
37 | $(wildcard $(LOCAL_PATH)/src/filesystem/android/*.c) \
38 | $(wildcard $(LOCAL_PATH)/src/render/*.c) \
39 | $(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
40 | $(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
41 | $(wildcard $(LOCAL_PATH)/src/thread/*.c) \
42 | $(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
43 | $(wildcard $(LOCAL_PATH)/src/timer/*.c) \
44 | $(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
45 | $(wildcard $(LOCAL_PATH)/src/video/*.c) \
46 | $(wildcard $(LOCAL_PATH)/src/video/android/*.c) \
47 | $(wildcard $(LOCAL_PATH)/src/test/*.c))
48 |
49 | LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -O3
50 | LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
51 |
52 | include $(BUILD_SHARED_LIBRARY)
53 |
54 | ###########################
55 | #
56 | # SDL static library
57 | #
58 | ###########################
59 |
60 | LOCAL_MODULE := SDL2_static
61 |
62 | LOCAL_MODULE_FILENAME := libSDL2
63 |
64 | LOCAL_SRC_FILES += $(subst $(LOCAL_PATH)/,,$(LOCAL_PATH)/src/main/android/SDL_android_main.c)
65 |
66 | LOCAL_LDLIBS :=
67 | LOCAL_EXPORT_LDLIBS := -Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
68 |
69 | include $(BUILD_STATIC_LIBRARY)
70 |
--------------------------------------------------------------------------------
/android/jni/src/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 |
3 | include $(CLEAR_VARS)
4 |
5 | LOCAL_MODULE := main
6 |
7 | SDL_PATH := ../SDL
8 |
9 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include
10 |
11 | # Add your application source files here...
12 | LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \
13 | nimes_nimes.c nimes_apu.c nimes_cartridge.c nimes_controller.c nimes_cpu.c nimes_mapper1.c nimes_mapper2.c nimes_mapper3.c nimes_mapper4.c nimes_mapper7.c nimes_mapper.c nimes_mem.c nimes_nes.c nimes_ppu.c nimes_types.c sdl2_audio.c sdl2_joystick.c sdl2_sdl2.c stdlib_macros.c stdlib_os.c stdlib_parseutils.c stdlib_posix.c stdlib_strutils.c stdlib_system.c stdlib_times.c stdlib_unsigned.c nimbase.h
14 |
15 | LOCAL_SHARED_LIBRARIES := SDL2
16 |
17 | LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog
18 | LOCAL_CFLAGS += -O3
19 |
20 | include $(BUILD_SHARED_LIBRARY)
21 |
--------------------------------------------------------------------------------
/android/jni/src/Android_static.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 |
3 | include $(CLEAR_VARS)
4 |
5 | LOCAL_MODULE := main
6 |
7 | LOCAL_SRC_FILES := YourSourceHere.c
8 |
9 | LOCAL_STATIC_LIBRARIES := SDL2_static
10 |
11 | include $(BUILD_SHARED_LIBRARY)
12 | $(call import-module,SDL)LOCAL_PATH := $(call my-dir)
13 |
--------------------------------------------------------------------------------
/android/local.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 |
7 | # location of the SDK. This is only used by Ant
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk.dir=/opt/android-sdk-update-manager
11 |
--------------------------------------------------------------------------------
/android/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/android/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-12
15 |
--------------------------------------------------------------------------------
/android/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/def-/nimes/baefb72c290471f5b487910e1545614b9a3d24b3/android/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/def-/nimes/baefb72c290471f5b487910e1545614b9a3d24b3/android/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/def-/nimes/baefb72c290471f5b487910e1545614b9a3d24b3/android/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/def-/nimes/baefb72c290471f5b487910e1545614b9a3d24b3/android/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/android/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | NimES (video output only)
4 |
5 |
--------------------------------------------------------------------------------
/android/src/org/nimes/nimesActivity.java:
--------------------------------------------------------------------------------
1 | package org.nimes;
2 | import org.libsdl.app.SDLActivity;
3 | public class nimesActivity extends SDLActivity {}
4 |
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | dependencies:
2 | pre:
3 | - |
4 | if [ ! -x ~/nim/bin/nim ]; then
5 | git clone -b devel --depth 1 git://github.com/nim-lang/nim ~/nim/
6 | git clone --depth 1 git://github.com/nim-lang/csources ~/nim/csources/
7 | cd ~/nim/csources; sh build.sh; cd ..; rm -rf csources
8 | bin/nim c koch; ./koch boot -d:release
9 | ln -fs ~/nim/bin/nim ~/bin/nim
10 | else
11 | cd ~/nim; git fetch origin
12 | git merge FETCH_HEAD | grep "Already up-to-date" || (bin/nim c koch; ./koch boot -d:release)
13 | fi
14 | if [ ! -x ~/nimble ]; then
15 | git clone --depth 1 https://github.com/nim-lang/nimble ~/nimble/
16 | cd ~/nimble
17 | nim -d:release c -r src/nimble -y install
18 | ln -fs ~/.nimble/bin/nimble ~/bin/nimble
19 | else
20 | cd ~/nimble; git fetch origin
21 | git merge FETCH_HEAD | grep "Already up-to-date" || (nim -d:release c -r src/nimble -y install)
22 | fi
23 |
24 | cache_directories:
25 | - "~/bin/"
26 | - "~/nim/"
27 | - "~/nimble/"
28 | - "~/.nimble/"
29 |
30 | ## Customize test commands
31 | test:
32 | override:
33 | - nimble build
34 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL.h
24 | *
25 | * Main include header for the SDL library
26 | */
27 |
28 |
29 | #ifndef _SDL_H
30 | #define _SDL_H
31 |
32 | #include "SDL_main.h"
33 | #include "SDL_stdinc.h"
34 | #include "SDL_assert.h"
35 | #include "SDL_atomic.h"
36 | #include "SDL_audio.h"
37 | #include "SDL_clipboard.h"
38 | #include "SDL_cpuinfo.h"
39 | #include "SDL_endian.h"
40 | #include "SDL_error.h"
41 | #include "SDL_events.h"
42 | #include "SDL_filesystem.h"
43 | #include "SDL_joystick.h"
44 | #include "SDL_gamecontroller.h"
45 | #include "SDL_haptic.h"
46 | #include "SDL_hints.h"
47 | #include "SDL_loadso.h"
48 | #include "SDL_log.h"
49 | #include "SDL_messagebox.h"
50 | #include "SDL_mutex.h"
51 | #include "SDL_power.h"
52 | #include "SDL_render.h"
53 | #include "SDL_rwops.h"
54 | #include "SDL_system.h"
55 | #include "SDL_thread.h"
56 | #include "SDL_timer.h"
57 | #include "SDL_version.h"
58 | #include "SDL_video.h"
59 |
60 | #include "begin_code.h"
61 | /* Set up for C function definitions, even when using C++ */
62 | #ifdef __cplusplus
63 | extern "C" {
64 | #endif
65 |
66 | /* As of version 0.5, SDL is loaded dynamically into the application */
67 |
68 | /**
69 | * \name SDL_INIT_*
70 | *
71 | * These are the flags which may be passed to SDL_Init(). You should
72 | * specify the subsystems which you will be using in your application.
73 | */
74 | /* @{ */
75 | #define SDL_INIT_TIMER 0x00000001
76 | #define SDL_INIT_AUDIO 0x00000010
77 | #define SDL_INIT_VIDEO 0x00000020 /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */
78 | #define SDL_INIT_JOYSTICK 0x00000200 /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */
79 | #define SDL_INIT_HAPTIC 0x00001000
80 | #define SDL_INIT_GAMECONTROLLER 0x00002000 /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */
81 | #define SDL_INIT_EVENTS 0x00004000
82 | #define SDL_INIT_NOPARACHUTE 0x00100000 /**< compatibility; this flag is ignored. */
83 | #define SDL_INIT_EVERYTHING ( \
84 | SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
85 | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \
86 | )
87 | /* @} */
88 |
89 | /**
90 | * This function initializes the subsystems specified by \c flags
91 | */
92 | extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
93 |
94 | /**
95 | * This function initializes specific SDL subsystems
96 | *
97 | * Subsystem initialization is ref-counted, you must call
98 | * SDL_QuitSubSystem for each SDL_InitSubSystem to correctly
99 | * shutdown a subsystem manually (or call SDL_Quit to force shutdown).
100 | * If a subsystem is already loaded then this call will
101 | * increase the ref-count and return.
102 | */
103 | extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
104 |
105 | /**
106 | * This function cleans up specific SDL subsystems
107 | */
108 | extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
109 |
110 | /**
111 | * This function returns a mask of the specified subsystems which have
112 | * previously been initialized.
113 | *
114 | * If \c flags is 0, it returns a mask of all initialized subsystems.
115 | */
116 | extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
117 |
118 | /**
119 | * This function cleans up all initialized subsystems. You should
120 | * call it upon all exit conditions.
121 | */
122 | extern DECLSPEC void SDLCALL SDL_Quit(void);
123 |
124 | /* Ends C function definitions when using C++ */
125 | #ifdef __cplusplus
126 | }
127 | #endif
128 | #include "close_code.h"
129 |
130 | #endif /* _SDL_H */
131 |
132 | /* vi: set ts=4 sw=4 expandtab: */
133 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_bits.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_bits.h
24 | *
25 | * Functions for fiddling with bits and bitmasks.
26 | */
27 |
28 | #ifndef _SDL_bits_h
29 | #define _SDL_bits_h
30 |
31 | #include "SDL_stdinc.h"
32 |
33 | #include "begin_code.h"
34 | /* Set up for C function definitions, even when using C++ */
35 | #ifdef __cplusplus
36 | extern "C" {
37 | #endif
38 |
39 | /**
40 | * \file SDL_bits.h
41 | */
42 |
43 | /**
44 | * Get the index of the most significant bit. Result is undefined when called
45 | * with 0. This operation can also be stated as "count leading zeroes" and
46 | * "log base 2".
47 | *
48 | * \return Index of the most significant bit, or -1 if the value is 0.
49 | */
50 | SDL_FORCE_INLINE int
51 | SDL_MostSignificantBitIndex32(Uint32 x)
52 | {
53 | #if defined(__GNUC__) && __GNUC__ >= 4
54 | /* Count Leading Zeroes builtin in GCC.
55 | * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html
56 | */
57 | if (x == 0) {
58 | return -1;
59 | }
60 | return 31 - __builtin_clz(x);
61 | #else
62 | /* Based off of Bit Twiddling Hacks by Sean Eron Anderson
63 | * , released in the public domain.
64 | * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog
65 | */
66 | const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};
67 | const int S[] = {1, 2, 4, 8, 16};
68 |
69 | int msbIndex = 0;
70 | int i;
71 |
72 | if (x == 0) {
73 | return -1;
74 | }
75 |
76 | for (i = 4; i >= 0; i--)
77 | {
78 | if (x & b[i])
79 | {
80 | x >>= S[i];
81 | msbIndex |= S[i];
82 | }
83 | }
84 |
85 | return msbIndex;
86 | #endif
87 | }
88 |
89 | /* Ends C function definitions when using C++ */
90 | #ifdef __cplusplus
91 | }
92 | #endif
93 | #include "close_code.h"
94 |
95 | #endif /* _SDL_bits_h */
96 |
97 | /* vi: set ts=4 sw=4 expandtab: */
98 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_blendmode.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_blendmode.h
24 | *
25 | * Header file declaring the SDL_BlendMode enumeration
26 | */
27 |
28 | #ifndef _SDL_blendmode_h
29 | #define _SDL_blendmode_h
30 |
31 | #include "begin_code.h"
32 | /* Set up for C function definitions, even when using C++ */
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /**
38 | * \brief The blend mode used in SDL_RenderCopy() and drawing operations.
39 | */
40 | typedef enum
41 | {
42 | SDL_BLENDMODE_NONE = 0x00000000, /**< no blending
43 | dstRGBA = srcRGBA */
44 | SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending
45 | dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
46 | dstA = srcA + (dstA * (1-srcA)) */
47 | SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending
48 | dstRGB = (srcRGB * srcA) + dstRGB
49 | dstA = dstA */
50 | SDL_BLENDMODE_MOD = 0x00000004 /**< color modulate
51 | dstRGB = srcRGB * dstRGB
52 | dstA = dstA */
53 | } SDL_BlendMode;
54 |
55 | /* Ends C function definitions when using C++ */
56 | #ifdef __cplusplus
57 | }
58 | #endif
59 | #include "close_code.h"
60 |
61 | #endif /* _SDL_blendmode_h */
62 |
63 | /* vi: set ts=4 sw=4 expandtab: */
64 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_clipboard.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_clipboard.h
24 | *
25 | * Include file for SDL clipboard handling
26 | */
27 |
28 | #ifndef _SDL_clipboard_h
29 | #define _SDL_clipboard_h
30 |
31 | #include "SDL_stdinc.h"
32 |
33 | #include "begin_code.h"
34 | /* Set up for C function definitions, even when using C++ */
35 | #ifdef __cplusplus
36 | extern "C" {
37 | #endif
38 |
39 | /* Function prototypes */
40 |
41 | /**
42 | * \brief Put UTF-8 text into the clipboard
43 | *
44 | * \sa SDL_GetClipboardText()
45 | */
46 | extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
47 |
48 | /**
49 | * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free()
50 | *
51 | * \sa SDL_SetClipboardText()
52 | */
53 | extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void);
54 |
55 | /**
56 | * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty
57 | *
58 | * \sa SDL_GetClipboardText()
59 | */
60 | extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
61 |
62 |
63 | /* Ends C function definitions when using C++ */
64 | #ifdef __cplusplus
65 | }
66 | #endif
67 | #include "close_code.h"
68 |
69 | #endif /* _SDL_clipboard_h */
70 |
71 | /* vi: set ts=4 sw=4 expandtab: */
72 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_cpuinfo.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_cpuinfo.h
24 | *
25 | * CPU feature detection for SDL.
26 | */
27 |
28 | #ifndef _SDL_cpuinfo_h
29 | #define _SDL_cpuinfo_h
30 |
31 | #include "SDL_stdinc.h"
32 |
33 | /* Need to do this here because intrin.h has C++ code in it */
34 | /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
35 | #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
36 | #include
37 | #ifndef _WIN64
38 | #define __MMX__
39 | #define __3dNOW__
40 | #endif
41 | #define __SSE__
42 | #define __SSE2__
43 | #elif defined(__MINGW64_VERSION_MAJOR)
44 | #include
45 | #else
46 | #ifdef __ALTIVEC__
47 | #if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__)
48 | #include
49 | #undef pixel
50 | #endif
51 | #endif
52 | #ifdef __MMX__
53 | #include
54 | #endif
55 | #ifdef __3dNOW__
56 | #include
57 | #endif
58 | #ifdef __SSE__
59 | #include
60 | #endif
61 | #ifdef __SSE2__
62 | #include
63 | #endif
64 | #endif
65 |
66 | #include "begin_code.h"
67 | /* Set up for C function definitions, even when using C++ */
68 | #ifdef __cplusplus
69 | extern "C" {
70 | #endif
71 |
72 | /* This is a guess for the cacheline size used for padding.
73 | * Most x86 processors have a 64 byte cache line.
74 | * The 64-bit PowerPC processors have a 128 byte cache line.
75 | * We'll use the larger value to be generally safe.
76 | */
77 | #define SDL_CACHELINE_SIZE 128
78 |
79 | /**
80 | * This function returns the number of CPU cores available.
81 | */
82 | extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
83 |
84 | /**
85 | * This function returns the L1 cache line size of the CPU
86 | *
87 | * This is useful for determining multi-threaded structure padding
88 | * or SIMD prefetch sizes.
89 | */
90 | extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
91 |
92 | /**
93 | * This function returns true if the CPU has the RDTSC instruction.
94 | */
95 | extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
96 |
97 | /**
98 | * This function returns true if the CPU has AltiVec features.
99 | */
100 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
101 |
102 | /**
103 | * This function returns true if the CPU has MMX features.
104 | */
105 | extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
106 |
107 | /**
108 | * This function returns true if the CPU has 3DNow! features.
109 | */
110 | extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
111 |
112 | /**
113 | * This function returns true if the CPU has SSE features.
114 | */
115 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
116 |
117 | /**
118 | * This function returns true if the CPU has SSE2 features.
119 | */
120 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
121 |
122 | /**
123 | * This function returns true if the CPU has SSE3 features.
124 | */
125 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
126 |
127 | /**
128 | * This function returns true if the CPU has SSE4.1 features.
129 | */
130 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
131 |
132 | /**
133 | * This function returns true if the CPU has SSE4.2 features.
134 | */
135 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
136 |
137 | /**
138 | * This function returns true if the CPU has AVX features.
139 | */
140 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void);
141 |
142 | /**
143 | * This function returns true if the CPU has AVX2 features.
144 | */
145 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void);
146 |
147 | /**
148 | * This function returns the amount of RAM configured in the system, in MB.
149 | */
150 | extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void);
151 |
152 |
153 | /* Ends C function definitions when using C++ */
154 | #ifdef __cplusplus
155 | }
156 | #endif
157 | #include "close_code.h"
158 |
159 | #endif /* _SDL_cpuinfo_h */
160 |
161 | /* vi: set ts=4 sw=4 expandtab: */
162 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_endian.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_endian.h
24 | *
25 | * Functions for reading and writing endian-specific values
26 | */
27 |
28 | #ifndef _SDL_endian_h
29 | #define _SDL_endian_h
30 |
31 | #include "SDL_stdinc.h"
32 |
33 | /**
34 | * \name The two types of endianness
35 | */
36 | /* @{ */
37 | #define SDL_LIL_ENDIAN 1234
38 | #define SDL_BIG_ENDIAN 4321
39 | /* @} */
40 |
41 | #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */
42 | #ifdef __linux__
43 | #include
44 | #define SDL_BYTEORDER __BYTE_ORDER
45 | #else /* __linux __ */
46 | #if defined(__hppa__) || \
47 | defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
48 | (defined(__MIPS__) && defined(__MISPEB__)) || \
49 | defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
50 | defined(__sparc__)
51 | #define SDL_BYTEORDER SDL_BIG_ENDIAN
52 | #else
53 | #define SDL_BYTEORDER SDL_LIL_ENDIAN
54 | #endif
55 | #endif /* __linux __ */
56 | #endif /* !SDL_BYTEORDER */
57 |
58 |
59 | #include "begin_code.h"
60 | /* Set up for C function definitions, even when using C++ */
61 | #ifdef __cplusplus
62 | extern "C" {
63 | #endif
64 |
65 | /**
66 | * \file SDL_endian.h
67 | */
68 | #if defined(__GNUC__) && defined(__i386__) && \
69 | !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */)
70 | SDL_FORCE_INLINE Uint16
71 | SDL_Swap16(Uint16 x)
72 | {
73 | __asm__("xchgb %b0,%h0": "=q"(x):"0"(x));
74 | return x;
75 | }
76 | #elif defined(__GNUC__) && defined(__x86_64__)
77 | SDL_FORCE_INLINE Uint16
78 | SDL_Swap16(Uint16 x)
79 | {
80 | __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x));
81 | return x;
82 | }
83 | #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
84 | SDL_FORCE_INLINE Uint16
85 | SDL_Swap16(Uint16 x)
86 | {
87 | int result;
88 |
89 | __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x));
90 | return (Uint16)result;
91 | }
92 | #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__)
93 | SDL_FORCE_INLINE Uint16
94 | SDL_Swap16(Uint16 x)
95 | {
96 | __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc");
97 | return x;
98 | }
99 | #else
100 | SDL_FORCE_INLINE Uint16
101 | SDL_Swap16(Uint16 x)
102 | {
103 | return SDL_static_cast(Uint16, ((x << 8) | (x >> 8)));
104 | }
105 | #endif
106 |
107 | #if defined(__GNUC__) && defined(__i386__)
108 | SDL_FORCE_INLINE Uint32
109 | SDL_Swap32(Uint32 x)
110 | {
111 | __asm__("bswap %0": "=r"(x):"0"(x));
112 | return x;
113 | }
114 | #elif defined(__GNUC__) && defined(__x86_64__)
115 | SDL_FORCE_INLINE Uint32
116 | SDL_Swap32(Uint32 x)
117 | {
118 | __asm__("bswapl %0": "=r"(x):"0"(x));
119 | return x;
120 | }
121 | #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
122 | SDL_FORCE_INLINE Uint32
123 | SDL_Swap32(Uint32 x)
124 | {
125 | Uint32 result;
126 |
127 | __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x));
128 | __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x));
129 | __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x));
130 | return result;
131 | }
132 | #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__)
133 | SDL_FORCE_INLINE Uint32
134 | SDL_Swap32(Uint32 x)
135 | {
136 | __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc");
137 | return x;
138 | }
139 | #else
140 | SDL_FORCE_INLINE Uint32
141 | SDL_Swap32(Uint32 x)
142 | {
143 | return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) |
144 | ((x >> 8) & 0x0000FF00) | (x >> 24)));
145 | }
146 | #endif
147 |
148 | #if defined(__GNUC__) && defined(__i386__)
149 | SDL_FORCE_INLINE Uint64
150 | SDL_Swap64(Uint64 x)
151 | {
152 | union
153 | {
154 | struct
155 | {
156 | Uint32 a, b;
157 | } s;
158 | Uint64 u;
159 | } v;
160 | v.u = x;
161 | __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a),
162 | "1"(v.s.
163 | b));
164 | return v.u;
165 | }
166 | #elif defined(__GNUC__) && defined(__x86_64__)
167 | SDL_FORCE_INLINE Uint64
168 | SDL_Swap64(Uint64 x)
169 | {
170 | __asm__("bswapq %0": "=r"(x):"0"(x));
171 | return x;
172 | }
173 | #else
174 | SDL_FORCE_INLINE Uint64
175 | SDL_Swap64(Uint64 x)
176 | {
177 | Uint32 hi, lo;
178 |
179 | /* Separate into high and low 32-bit values and swap them */
180 | lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
181 | x >>= 32;
182 | hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
183 | x = SDL_Swap32(lo);
184 | x <<= 32;
185 | x |= SDL_Swap32(hi);
186 | return (x);
187 | }
188 | #endif
189 |
190 |
191 | SDL_FORCE_INLINE float
192 | SDL_SwapFloat(float x)
193 | {
194 | union
195 | {
196 | float f;
197 | Uint32 ui32;
198 | } swapper;
199 | swapper.f = x;
200 | swapper.ui32 = SDL_Swap32(swapper.ui32);
201 | return swapper.f;
202 | }
203 |
204 |
205 | /**
206 | * \name Swap to native
207 | * Byteswap item from the specified endianness to the native endianness.
208 | */
209 | /* @{ */
210 | #if SDL_BYTEORDER == SDL_LIL_ENDIAN
211 | #define SDL_SwapLE16(X) (X)
212 | #define SDL_SwapLE32(X) (X)
213 | #define SDL_SwapLE64(X) (X)
214 | #define SDL_SwapFloatLE(X) (X)
215 | #define SDL_SwapBE16(X) SDL_Swap16(X)
216 | #define SDL_SwapBE32(X) SDL_Swap32(X)
217 | #define SDL_SwapBE64(X) SDL_Swap64(X)
218 | #define SDL_SwapFloatBE(X) SDL_SwapFloat(X)
219 | #else
220 | #define SDL_SwapLE16(X) SDL_Swap16(X)
221 | #define SDL_SwapLE32(X) SDL_Swap32(X)
222 | #define SDL_SwapLE64(X) SDL_Swap64(X)
223 | #define SDL_SwapFloatLE(X) SDL_SwapFloat(X)
224 | #define SDL_SwapBE16(X) (X)
225 | #define SDL_SwapBE32(X) (X)
226 | #define SDL_SwapBE64(X) (X)
227 | #define SDL_SwapFloatBE(X) (X)
228 | #endif
229 | /* @} *//* Swap to native */
230 |
231 | /* Ends C function definitions when using C++ */
232 | #ifdef __cplusplus
233 | }
234 | #endif
235 | #include "close_code.h"
236 |
237 | #endif /* _SDL_endian_h */
238 |
239 | /* vi: set ts=4 sw=4 expandtab: */
240 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_error.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_error.h
24 | *
25 | * Simple error message routines for SDL.
26 | */
27 |
28 | #ifndef _SDL_error_h
29 | #define _SDL_error_h
30 |
31 | #include "SDL_stdinc.h"
32 |
33 | #include "begin_code.h"
34 | /* Set up for C function definitions, even when using C++ */
35 | #ifdef __cplusplus
36 | extern "C" {
37 | #endif
38 |
39 | /* Public functions */
40 | /* SDL_SetError() unconditionally returns -1. */
41 | extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
42 | extern DECLSPEC const char *SDLCALL SDL_GetError(void);
43 | extern DECLSPEC void SDLCALL SDL_ClearError(void);
44 |
45 | /**
46 | * \name Internal error functions
47 | *
48 | * \internal
49 | * Private error reporting function - used internally.
50 | */
51 | /* @{ */
52 | #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM)
53 | #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED)
54 | #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param))
55 | typedef enum
56 | {
57 | SDL_ENOMEM,
58 | SDL_EFREAD,
59 | SDL_EFWRITE,
60 | SDL_EFSEEK,
61 | SDL_UNSUPPORTED,
62 | SDL_LASTERROR
63 | } SDL_errorcode;
64 | /* SDL_Error() unconditionally returns -1. */
65 | extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code);
66 | /* @} *//* Internal error functions */
67 |
68 | /* Ends C function definitions when using C++ */
69 | #ifdef __cplusplus
70 | }
71 | #endif
72 | #include "close_code.h"
73 |
74 | #endif /* _SDL_error_h */
75 |
76 | /* vi: set ts=4 sw=4 expandtab: */
77 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_filesystem.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_filesystem.h
24 | *
25 | * \brief Include file for filesystem SDL API functions
26 | */
27 |
28 | #ifndef _SDL_filesystem_h
29 | #define _SDL_filesystem_h
30 |
31 | #include "SDL_stdinc.h"
32 |
33 | #include "begin_code.h"
34 |
35 | /* Set up for C function definitions, even when using C++ */
36 | #ifdef __cplusplus
37 | extern "C" {
38 | #endif
39 |
40 | /**
41 | * \brief Get the path where the application resides.
42 | *
43 | * Get the "base path". This is the directory where the application was run
44 | * from, which is probably the installation directory, and may or may not
45 | * be the process's current working directory.
46 | *
47 | * This returns an absolute path in UTF-8 encoding, and is guaranteed to
48 | * end with a path separator ('\\' on Windows, '/' most other places).
49 | *
50 | * The pointer returned by this function is owned by you. Please call
51 | * SDL_free() on the pointer when you are done with it, or it will be a
52 | * memory leak. This is not necessarily a fast call, though, so you should
53 | * call this once near startup and save the string if you need it.
54 | *
55 | * Some platforms can't determine the application's path, and on other
56 | * platforms, this might be meaningless. In such cases, this function will
57 | * return NULL.
58 | *
59 | * \return String of base dir in UTF-8 encoding, or NULL on error.
60 | *
61 | * \sa SDL_GetPrefPath
62 | */
63 | extern DECLSPEC char *SDLCALL SDL_GetBasePath(void);
64 |
65 | /**
66 | * \brief Get the user-and-app-specific path where files can be written.
67 | *
68 | * Get the "pref dir". This is meant to be where users can write personal
69 | * files (preferences and save games, etc) that are specific to your
70 | * application. This directory is unique per user, per application.
71 | *
72 | * This function will decide the appropriate location in the native filesystem,
73 | * create the directory if necessary, and return a string of the absolute
74 | * path to the directory in UTF-8 encoding.
75 | *
76 | * On Windows, the string might look like:
77 | * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\"
78 | *
79 | * On Linux, the string might look like:
80 | * "/home/bob/.local/share/My Program Name/"
81 | *
82 | * On Mac OS X, the string might look like:
83 | * "/Users/bob/Library/Application Support/My Program Name/"
84 | *
85 | * (etc.)
86 | *
87 | * You specify the name of your organization (if it's not a real organization,
88 | * your name or an Internet domain you own might do) and the name of your
89 | * application. These should be untranslated proper names.
90 | *
91 | * Both the org and app strings may become part of a directory name, so
92 | * please follow these rules:
93 | *
94 | * - Try to use the same org string (including case-sensitivity) for
95 | * all your applications that use this function.
96 | * - Always use a unique app string for each one, and make sure it never
97 | * changes for an app once you've decided on it.
98 | * - Unicode characters are legal, as long as it's UTF-8 encoded, but...
99 | * - ...only use letters, numbers, and spaces. Avoid punctuation like
100 | * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
101 | *
102 | * This returns an absolute path in UTF-8 encoding, and is guaranteed to
103 | * end with a path separator ('\\' on Windows, '/' most other places).
104 | *
105 | * The pointer returned by this function is owned by you. Please call
106 | * SDL_free() on the pointer when you are done with it, or it will be a
107 | * memory leak. This is not necessarily a fast call, though, so you should
108 | * call this once near startup and save the string if you need it.
109 | *
110 | * You should assume the path returned by this function is the only safe
111 | * place to write files (and that SDL_GetBasePath(), while it might be
112 | * writable, or even the parent of the returned path, aren't where you
113 | * should be writing things).
114 | *
115 | * Some platforms can't determine the pref path, and on other
116 | * platforms, this might be meaningless. In such cases, this function will
117 | * return NULL.
118 | *
119 | * \param org The name of your organization.
120 | * \param app The name of your application.
121 | * \return UTF-8 string of user dir in platform-dependent notation. NULL
122 | * if there's a problem (creating directory failed, etc).
123 | *
124 | * \sa SDL_GetBasePath
125 | */
126 | extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app);
127 |
128 | /* Ends C function definitions when using C++ */
129 | #ifdef __cplusplus
130 | }
131 | #endif
132 | #include "close_code.h"
133 |
134 | #endif /* _SDL_filesystem_h */
135 |
136 | /* vi: set ts=4 sw=4 expandtab: */
137 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_gesture.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_gesture.h
24 | *
25 | * Include file for SDL gesture event handling.
26 | */
27 |
28 | #ifndef _SDL_gesture_h
29 | #define _SDL_gesture_h
30 |
31 | #include "SDL_stdinc.h"
32 | #include "SDL_error.h"
33 | #include "SDL_video.h"
34 |
35 | #include "SDL_touch.h"
36 |
37 |
38 | #include "begin_code.h"
39 | /* Set up for C function definitions, even when using C++ */
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | typedef Sint64 SDL_GestureID;
45 |
46 | /* Function prototypes */
47 |
48 | /**
49 | * \brief Begin Recording a gesture on the specified touch, or all touches (-1)
50 | *
51 | *
52 | */
53 | extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);
54 |
55 |
56 | /**
57 | * \brief Save all currently loaded Dollar Gesture templates
58 | *
59 | *
60 | */
61 | extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst);
62 |
63 | /**
64 | * \brief Save a currently loaded Dollar Gesture template
65 | *
66 | *
67 | */
68 | extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst);
69 |
70 |
71 | /**
72 | * \brief Load Dollar Gesture templates from a file
73 | *
74 | *
75 | */
76 | extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src);
77 |
78 |
79 | /* Ends C function definitions when using C++ */
80 | #ifdef __cplusplus
81 | }
82 | #endif
83 | #include "close_code.h"
84 |
85 | #endif /* _SDL_gesture_h */
86 |
87 | /* vi: set ts=4 sw=4 expandtab: */
88 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_keyboard.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_keyboard.h
24 | *
25 | * Include file for SDL keyboard event handling
26 | */
27 |
28 | #ifndef _SDL_keyboard_h
29 | #define _SDL_keyboard_h
30 |
31 | #include "SDL_stdinc.h"
32 | #include "SDL_error.h"
33 | #include "SDL_keycode.h"
34 | #include "SDL_video.h"
35 |
36 | #include "begin_code.h"
37 | /* Set up for C function definitions, even when using C++ */
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | /**
43 | * \brief The SDL keysym structure, used in key events.
44 | *
45 | * \note If you are looking for translated character input, see the ::SDL_TEXTINPUT event.
46 | */
47 | typedef struct SDL_Keysym
48 | {
49 | SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */
50 | SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */
51 | Uint16 mod; /**< current key modifiers */
52 | Uint32 unused;
53 | } SDL_Keysym;
54 |
55 | /* Function prototypes */
56 |
57 | /**
58 | * \brief Get the window which currently has keyboard focus.
59 | */
60 | extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
61 |
62 | /**
63 | * \brief Get a snapshot of the current state of the keyboard.
64 | *
65 | * \param numkeys if non-NULL, receives the length of the returned array.
66 | *
67 | * \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values.
68 | *
69 | * \b Example:
70 | * \code
71 | * const Uint8 *state = SDL_GetKeyboardState(NULL);
72 | * if ( state[SDL_SCANCODE_RETURN] ) {
73 | * printf(" is pressed.\n");
74 | * }
75 | * \endcode
76 | */
77 | extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
78 |
79 | /**
80 | * \brief Get the current key modifier state for the keyboard.
81 | */
82 | extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void);
83 |
84 | /**
85 | * \brief Set the current key modifier state for the keyboard.
86 | *
87 | * \note This does not change the keyboard state, only the key modifier flags.
88 | */
89 | extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);
90 |
91 | /**
92 | * \brief Get the key code corresponding to the given scancode according
93 | * to the current keyboard layout.
94 | *
95 | * See ::SDL_Keycode for details.
96 | *
97 | * \sa SDL_GetKeyName()
98 | */
99 | extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode);
100 |
101 | /**
102 | * \brief Get the scancode corresponding to the given key code according to the
103 | * current keyboard layout.
104 | *
105 | * See ::SDL_Scancode for details.
106 | *
107 | * \sa SDL_GetScancodeName()
108 | */
109 | extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key);
110 |
111 | /**
112 | * \brief Get a human-readable name for a scancode.
113 | *
114 | * \return A pointer to the name for the scancode.
115 | * If the scancode doesn't have a name, this function returns
116 | * an empty string ("").
117 | *
118 | * \sa SDL_Scancode
119 | */
120 | extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode);
121 |
122 | /**
123 | * \brief Get a scancode from a human-readable name
124 | *
125 | * \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized
126 | *
127 | * \sa SDL_Scancode
128 | */
129 | extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name);
130 |
131 | /**
132 | * \brief Get a human-readable name for a key.
133 | *
134 | * \return A pointer to a UTF-8 string that stays valid at least until the next
135 | * call to this function. If you need it around any longer, you must
136 | * copy it. If the key doesn't have a name, this function returns an
137 | * empty string ("").
138 | *
139 | * \sa SDL_Key
140 | */
141 | extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key);
142 |
143 | /**
144 | * \brief Get a key code from a human-readable name
145 | *
146 | * \return key code, or SDLK_UNKNOWN if the name wasn't recognized
147 | *
148 | * \sa SDL_Keycode
149 | */
150 | extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
151 |
152 | /**
153 | * \brief Start accepting Unicode text input events.
154 | * This function will show the on-screen keyboard if supported.
155 | *
156 | * \sa SDL_StopTextInput()
157 | * \sa SDL_SetTextInputRect()
158 | * \sa SDL_HasScreenKeyboardSupport()
159 | */
160 | extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
161 |
162 | /**
163 | * \brief Return whether or not Unicode text input events are enabled.
164 | *
165 | * \sa SDL_StartTextInput()
166 | * \sa SDL_StopTextInput()
167 | */
168 | extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void);
169 |
170 | /**
171 | * \brief Stop receiving any text input events.
172 | * This function will hide the on-screen keyboard if supported.
173 | *
174 | * \sa SDL_StartTextInput()
175 | * \sa SDL_HasScreenKeyboardSupport()
176 | */
177 | extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
178 |
179 | /**
180 | * \brief Set the rectangle used to type Unicode text inputs.
181 | * This is used as a hint for IME and on-screen keyboard placement.
182 | *
183 | * \sa SDL_StartTextInput()
184 | */
185 | extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect);
186 |
187 | /**
188 | * \brief Returns whether the platform has some screen keyboard support.
189 | *
190 | * \return SDL_TRUE if some keyboard support is available else SDL_FALSE.
191 | *
192 | * \note Not all screen keyboard functions are supported on all platforms.
193 | *
194 | * \sa SDL_IsScreenKeyboardShown()
195 | */
196 | extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void);
197 |
198 | /**
199 | * \brief Returns whether the screen keyboard is shown for given window.
200 | *
201 | * \param window The window for which screen keyboard should be queried.
202 | *
203 | * \return SDL_TRUE if screen keyboard is shown else SDL_FALSE.
204 | *
205 | * \sa SDL_HasScreenKeyboardSupport()
206 | */
207 | extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window);
208 |
209 | /* Ends C function definitions when using C++ */
210 | #ifdef __cplusplus
211 | }
212 | #endif
213 | #include "close_code.h"
214 |
215 | #endif /* _SDL_keyboard_h */
216 |
217 | /* vi: set ts=4 sw=4 expandtab: */
218 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_loadso.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_loadso.h
24 | *
25 | * System dependent library loading routines
26 | *
27 | * Some things to keep in mind:
28 | * \li These functions only work on C function names. Other languages may
29 | * have name mangling and intrinsic language support that varies from
30 | * compiler to compiler.
31 | * \li Make sure you declare your function pointers with the same calling
32 | * convention as the actual library function. Your code will crash
33 | * mysteriously if you do not do this.
34 | * \li Avoid namespace collisions. If you load a symbol from the library,
35 | * it is not defined whether or not it goes into the global symbol
36 | * namespace for the application. If it does and it conflicts with
37 | * symbols in your code or other shared libraries, you will not get
38 | * the results you expect. :)
39 | */
40 |
41 | #ifndef _SDL_loadso_h
42 | #define _SDL_loadso_h
43 |
44 | #include "SDL_stdinc.h"
45 | #include "SDL_error.h"
46 |
47 | #include "begin_code.h"
48 | /* Set up for C function definitions, even when using C++ */
49 | #ifdef __cplusplus
50 | extern "C" {
51 | #endif
52 |
53 | /**
54 | * This function dynamically loads a shared object and returns a pointer
55 | * to the object handle (or NULL if there was an error).
56 | * The 'sofile' parameter is a system dependent name of the object file.
57 | */
58 | extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile);
59 |
60 | /**
61 | * Given an object handle, this function looks up the address of the
62 | * named function in the shared object and returns it. This address
63 | * is no longer valid after calling SDL_UnloadObject().
64 | */
65 | extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle,
66 | const char *name);
67 |
68 | /**
69 | * Unload a shared object from memory.
70 | */
71 | extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle);
72 |
73 | /* Ends C function definitions when using C++ */
74 | #ifdef __cplusplus
75 | }
76 | #endif
77 | #include "close_code.h"
78 |
79 | #endif /* _SDL_loadso_h */
80 |
81 | /* vi: set ts=4 sw=4 expandtab: */
82 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_log.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_log.h
24 | *
25 | * Simple log messages with categories and priorities.
26 | *
27 | * By default logs are quiet, but if you're debugging SDL you might want:
28 | *
29 | * SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);
30 | *
31 | * Here's where the messages go on different platforms:
32 | * Windows: debug output stream
33 | * Android: log output
34 | * Others: standard error output (stderr)
35 | */
36 |
37 | #ifndef _SDL_log_h
38 | #define _SDL_log_h
39 |
40 | #include "SDL_stdinc.h"
41 |
42 | #include "begin_code.h"
43 | /* Set up for C function definitions, even when using C++ */
44 | #ifdef __cplusplus
45 | extern "C" {
46 | #endif
47 |
48 |
49 | /**
50 | * \brief The maximum size of a log message
51 | *
52 | * Messages longer than the maximum size will be truncated
53 | */
54 | #define SDL_MAX_LOG_MESSAGE 4096
55 |
56 | /**
57 | * \brief The predefined log categories
58 | *
59 | * By default the application category is enabled at the INFO level,
60 | * the assert category is enabled at the WARN level, test is enabled
61 | * at the VERBOSE level and all other categories are enabled at the
62 | * CRITICAL level.
63 | */
64 | enum
65 | {
66 | SDL_LOG_CATEGORY_APPLICATION,
67 | SDL_LOG_CATEGORY_ERROR,
68 | SDL_LOG_CATEGORY_ASSERT,
69 | SDL_LOG_CATEGORY_SYSTEM,
70 | SDL_LOG_CATEGORY_AUDIO,
71 | SDL_LOG_CATEGORY_VIDEO,
72 | SDL_LOG_CATEGORY_RENDER,
73 | SDL_LOG_CATEGORY_INPUT,
74 | SDL_LOG_CATEGORY_TEST,
75 |
76 | /* Reserved for future SDL library use */
77 | SDL_LOG_CATEGORY_RESERVED1,
78 | SDL_LOG_CATEGORY_RESERVED2,
79 | SDL_LOG_CATEGORY_RESERVED3,
80 | SDL_LOG_CATEGORY_RESERVED4,
81 | SDL_LOG_CATEGORY_RESERVED5,
82 | SDL_LOG_CATEGORY_RESERVED6,
83 | SDL_LOG_CATEGORY_RESERVED7,
84 | SDL_LOG_CATEGORY_RESERVED8,
85 | SDL_LOG_CATEGORY_RESERVED9,
86 | SDL_LOG_CATEGORY_RESERVED10,
87 |
88 | /* Beyond this point is reserved for application use, e.g.
89 | enum {
90 | MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM,
91 | MYAPP_CATEGORY_AWESOME2,
92 | MYAPP_CATEGORY_AWESOME3,
93 | ...
94 | };
95 | */
96 | SDL_LOG_CATEGORY_CUSTOM
97 | };
98 |
99 | /**
100 | * \brief The predefined log priorities
101 | */
102 | typedef enum
103 | {
104 | SDL_LOG_PRIORITY_VERBOSE = 1,
105 | SDL_LOG_PRIORITY_DEBUG,
106 | SDL_LOG_PRIORITY_INFO,
107 | SDL_LOG_PRIORITY_WARN,
108 | SDL_LOG_PRIORITY_ERROR,
109 | SDL_LOG_PRIORITY_CRITICAL,
110 | SDL_NUM_LOG_PRIORITIES
111 | } SDL_LogPriority;
112 |
113 |
114 | /**
115 | * \brief Set the priority of all log categories
116 | */
117 | extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority);
118 |
119 | /**
120 | * \brief Set the priority of a particular log category
121 | */
122 | extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category,
123 | SDL_LogPriority priority);
124 |
125 | /**
126 | * \brief Get the priority of a particular log category
127 | */
128 | extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category);
129 |
130 | /**
131 | * \brief Reset all priorities to default.
132 | *
133 | * \note This is called in SDL_Quit().
134 | */
135 | extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void);
136 |
137 | /**
138 | * \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO
139 | */
140 | extern DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
141 |
142 | /**
143 | * \brief Log a message with SDL_LOG_PRIORITY_VERBOSE
144 | */
145 | extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
146 |
147 | /**
148 | * \brief Log a message with SDL_LOG_PRIORITY_DEBUG
149 | */
150 | extern DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
151 |
152 | /**
153 | * \brief Log a message with SDL_LOG_PRIORITY_INFO
154 | */
155 | extern DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
156 |
157 | /**
158 | * \brief Log a message with SDL_LOG_PRIORITY_WARN
159 | */
160 | extern DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
161 |
162 | /**
163 | * \brief Log a message with SDL_LOG_PRIORITY_ERROR
164 | */
165 | extern DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
166 |
167 | /**
168 | * \brief Log a message with SDL_LOG_PRIORITY_CRITICAL
169 | */
170 | extern DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
171 |
172 | /**
173 | * \brief Log a message with the specified category and priority.
174 | */
175 | extern DECLSPEC void SDLCALL SDL_LogMessage(int category,
176 | SDL_LogPriority priority,
177 | SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(3);
178 |
179 | /**
180 | * \brief Log a message with the specified category and priority.
181 | */
182 | extern DECLSPEC void SDLCALL SDL_LogMessageV(int category,
183 | SDL_LogPriority priority,
184 | const char *fmt, va_list ap);
185 |
186 | /**
187 | * \brief The prototype for the log output function
188 | */
189 | typedef void (*SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message);
190 |
191 | /**
192 | * \brief Get the current log output function.
193 | */
194 | extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata);
195 |
196 | /**
197 | * \brief This function allows you to replace the default log output
198 | * function with one of your own.
199 | */
200 | extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata);
201 |
202 |
203 | /* Ends C function definitions when using C++ */
204 | #ifdef __cplusplus
205 | }
206 | #endif
207 | #include "close_code.h"
208 |
209 | #endif /* _SDL_log_h */
210 |
211 | /* vi: set ts=4 sw=4 expandtab: */
212 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_main.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #ifndef _SDL_main_h
23 | #define _SDL_main_h
24 |
25 | #include "SDL_stdinc.h"
26 |
27 | /**
28 | * \file SDL_main.h
29 | *
30 | * Redefine main() on some platforms so that it is called by SDL.
31 | */
32 |
33 | #ifndef SDL_MAIN_HANDLED
34 | #if defined(__WIN32__)
35 | /* On Windows SDL provides WinMain(), which parses the command line and passes
36 | the arguments to your main function.
37 |
38 | If you provide your own WinMain(), you may define SDL_MAIN_HANDLED
39 | */
40 | #define SDL_MAIN_AVAILABLE
41 |
42 | #elif defined(__WINRT__)
43 | /* On WinRT, SDL provides a main function that initializes CoreApplication,
44 | creating an instance of IFrameworkView in the process.
45 |
46 | Please note that #include'ing SDL_main.h is not enough to get a main()
47 | function working. In non-XAML apps, the file,
48 | src/main/winrt/SDL_WinRT_main_NonXAML.cpp, or a copy of it, must be compiled
49 | into the app itself. In XAML apps, the function, SDL_WinRTRunApp must be
50 | called, with a pointer to the Direct3D-hosted XAML control passed in.
51 | */
52 | #define SDL_MAIN_NEEDED
53 |
54 | #elif defined(__IPHONEOS__)
55 | /* On iOS SDL provides a main function that creates an application delegate
56 | and starts the iOS application run loop.
57 |
58 | See src/video/uikit/SDL_uikitappdelegate.m for more details.
59 | */
60 | #define SDL_MAIN_NEEDED
61 |
62 | #elif defined(__ANDROID__)
63 | /* On Android SDL provides a Java class in SDLActivity.java that is the
64 | main activity entry point.
65 |
66 | See README-android.txt for more details on extending that class.
67 | */
68 | #define SDL_MAIN_NEEDED
69 |
70 | #elif defined(__NACL__)
71 | /* On NACL we use ppapi_simple to set up the application helper code,
72 | then wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before
73 | starting the user main function.
74 | All user code is run in a separate thread by ppapi_simple, thus
75 | allowing for blocking io to take place via nacl_io
76 | */
77 | #define SDL_MAIN_NEEDED
78 |
79 | #endif
80 | #endif /* SDL_MAIN_HANDLED */
81 |
82 | #ifdef __cplusplus
83 | #define C_LINKAGE "C"
84 | #else
85 | #define C_LINKAGE
86 | #endif /* __cplusplus */
87 |
88 | /**
89 | * \file SDL_main.h
90 | *
91 | * The application's main() function must be called with C linkage,
92 | * and should be declared like this:
93 | * \code
94 | * #ifdef __cplusplus
95 | * extern "C"
96 | * #endif
97 | * int main(int argc, char *argv[])
98 | * {
99 | * }
100 | * \endcode
101 | */
102 |
103 | #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
104 | #define main SDL_main
105 | #endif
106 |
107 | /**
108 | * The prototype for the application's main() function
109 | */
110 | extern C_LINKAGE int SDL_main(int argc, char *argv[]);
111 |
112 |
113 | #include "begin_code.h"
114 | #ifdef __cplusplus
115 | extern "C" {
116 | #endif
117 |
118 | /**
119 | * This is called by the real SDL main function to let the rest of the
120 | * library know that initialization was done properly.
121 | *
122 | * Calling this yourself without knowing what you're doing can cause
123 | * crashes and hard to diagnose problems with your application.
124 | */
125 | extern DECLSPEC void SDLCALL SDL_SetMainReady(void);
126 |
127 | #ifdef __WIN32__
128 |
129 | /**
130 | * This can be called to set the application class at startup
131 | */
132 | extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style,
133 | void *hInst);
134 | extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
135 |
136 | #endif /* __WIN32__ */
137 |
138 |
139 | #ifdef __WINRT__
140 |
141 | /**
142 | * \brief Initializes and launches an SDL/WinRT application.
143 | *
144 | * \param mainFunction The SDL app's C-style main().
145 | * \param reserved Reserved for future use; should be NULL
146 | * \return 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more
147 | * information on the failure.
148 | */
149 | extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * reserved);
150 |
151 | #endif /* __WINRT__ */
152 |
153 |
154 | #ifdef __cplusplus
155 | }
156 | #endif
157 | #include "close_code.h"
158 |
159 | #endif /* _SDL_main_h */
160 |
161 | /* vi: set ts=4 sw=4 expandtab: */
162 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_messagebox.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #ifndef _SDL_messagebox_h
23 | #define _SDL_messagebox_h
24 |
25 | #include "SDL_stdinc.h"
26 | #include "SDL_video.h" /* For SDL_Window */
27 |
28 | #include "begin_code.h"
29 | /* Set up for C function definitions, even when using C++ */
30 | #ifdef __cplusplus
31 | extern "C" {
32 | #endif
33 |
34 | /**
35 | * \brief SDL_MessageBox flags. If supported will display warning icon, etc.
36 | */
37 | typedef enum
38 | {
39 | SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */
40 | SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */
41 | SDL_MESSAGEBOX_INFORMATION = 0x00000040 /**< informational dialog */
42 | } SDL_MessageBoxFlags;
43 |
44 | /**
45 | * \brief Flags for SDL_MessageBoxButtonData.
46 | */
47 | typedef enum
48 | {
49 | SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */
50 | SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */
51 | } SDL_MessageBoxButtonFlags;
52 |
53 | /**
54 | * \brief Individual button data.
55 | */
56 | typedef struct
57 | {
58 | Uint32 flags; /**< ::SDL_MessageBoxButtonFlags */
59 | int buttonid; /**< User defined button id (value returned via SDL_ShowMessageBox) */
60 | const char * text; /**< The UTF-8 button text */
61 | } SDL_MessageBoxButtonData;
62 |
63 | /**
64 | * \brief RGB value used in a message box color scheme
65 | */
66 | typedef struct
67 | {
68 | Uint8 r, g, b;
69 | } SDL_MessageBoxColor;
70 |
71 | typedef enum
72 | {
73 | SDL_MESSAGEBOX_COLOR_BACKGROUND,
74 | SDL_MESSAGEBOX_COLOR_TEXT,
75 | SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,
76 | SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
77 | SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,
78 | SDL_MESSAGEBOX_COLOR_MAX
79 | } SDL_MessageBoxColorType;
80 |
81 | /**
82 | * \brief A set of colors to use for message box dialogs
83 | */
84 | typedef struct
85 | {
86 | SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX];
87 | } SDL_MessageBoxColorScheme;
88 |
89 | /**
90 | * \brief MessageBox structure containing title, text, window, etc.
91 | */
92 | typedef struct
93 | {
94 | Uint32 flags; /**< ::SDL_MessageBoxFlags */
95 | SDL_Window *window; /**< Parent window, can be NULL */
96 | const char *title; /**< UTF-8 title */
97 | const char *message; /**< UTF-8 message text */
98 |
99 | int numbuttons;
100 | const SDL_MessageBoxButtonData *buttons;
101 |
102 | const SDL_MessageBoxColorScheme *colorScheme; /**< ::SDL_MessageBoxColorScheme, can be NULL to use system settings */
103 | } SDL_MessageBoxData;
104 |
105 | /**
106 | * \brief Create a modal message box.
107 | *
108 | * \param messageboxdata The SDL_MessageBoxData structure with title, text, etc.
109 | * \param buttonid The pointer to which user id of hit button should be copied.
110 | *
111 | * \return -1 on error, otherwise 0 and buttonid contains user id of button
112 | * hit or -1 if dialog was closed.
113 | *
114 | * \note This function should be called on the thread that created the parent
115 | * window, or on the main thread if the messagebox has no parent. It will
116 | * block execution of that thread until the user clicks a button or
117 | * closes the messagebox.
118 | */
119 | extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
120 |
121 | /**
122 | * \brief Create a simple modal message box
123 | *
124 | * \param flags ::SDL_MessageBoxFlags
125 | * \param title UTF-8 title text
126 | * \param message UTF-8 message text
127 | * \param window The parent window, or NULL for no parent
128 | *
129 | * \return 0 on success, -1 on error
130 | *
131 | * \sa SDL_ShowMessageBox
132 | */
133 | extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window);
134 |
135 |
136 | /* Ends C function definitions when using C++ */
137 | #ifdef __cplusplus
138 | }
139 | #endif
140 | #include "close_code.h"
141 |
142 | #endif /* _SDL_messagebox_h */
143 |
144 | /* vi: set ts=4 sw=4 expandtab: */
145 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_mutex.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #ifndef _SDL_mutex_h
23 | #define _SDL_mutex_h
24 |
25 | /**
26 | * \file SDL_mutex.h
27 | *
28 | * Functions to provide thread synchronization primitives.
29 | */
30 |
31 | #include "SDL_stdinc.h"
32 | #include "SDL_error.h"
33 |
34 | #include "begin_code.h"
35 | /* Set up for C function definitions, even when using C++ */
36 | #ifdef __cplusplus
37 | extern "C" {
38 | #endif
39 |
40 | /**
41 | * Synchronization functions which can time out return this value
42 | * if they time out.
43 | */
44 | #define SDL_MUTEX_TIMEDOUT 1
45 |
46 | /**
47 | * This is the timeout value which corresponds to never time out.
48 | */
49 | #define SDL_MUTEX_MAXWAIT (~(Uint32)0)
50 |
51 |
52 | /**
53 | * \name Mutex functions
54 | */
55 | /* @{ */
56 |
57 | /* The SDL mutex structure, defined in SDL_sysmutex.c */
58 | struct SDL_mutex;
59 | typedef struct SDL_mutex SDL_mutex;
60 |
61 | /**
62 | * Create a mutex, initialized unlocked.
63 | */
64 | extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void);
65 |
66 | /**
67 | * Lock the mutex.
68 | *
69 | * \return 0, or -1 on error.
70 | */
71 | #define SDL_mutexP(m) SDL_LockMutex(m)
72 | extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex);
73 |
74 | /**
75 | * Try to lock the mutex
76 | *
77 | * \return 0, SDL_MUTEX_TIMEDOUT, or -1 on error
78 | */
79 | extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex);
80 |
81 | /**
82 | * Unlock the mutex.
83 | *
84 | * \return 0, or -1 on error.
85 | *
86 | * \warning It is an error to unlock a mutex that has not been locked by
87 | * the current thread, and doing so results in undefined behavior.
88 | */
89 | #define SDL_mutexV(m) SDL_UnlockMutex(m)
90 | extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex);
91 |
92 | /**
93 | * Destroy a mutex.
94 | */
95 | extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex);
96 |
97 | /* @} *//* Mutex functions */
98 |
99 |
100 | /**
101 | * \name Semaphore functions
102 | */
103 | /* @{ */
104 |
105 | /* The SDL semaphore structure, defined in SDL_syssem.c */
106 | struct SDL_semaphore;
107 | typedef struct SDL_semaphore SDL_sem;
108 |
109 | /**
110 | * Create a semaphore, initialized with value, returns NULL on failure.
111 | */
112 | extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
113 |
114 | /**
115 | * Destroy a semaphore.
116 | */
117 | extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem);
118 |
119 | /**
120 | * This function suspends the calling thread until the semaphore pointed
121 | * to by \c sem has a positive count. It then atomically decreases the
122 | * semaphore count.
123 | */
124 | extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem);
125 |
126 | /**
127 | * Non-blocking variant of SDL_SemWait().
128 | *
129 | * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would
130 | * block, and -1 on error.
131 | */
132 | extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
133 |
134 | /**
135 | * Variant of SDL_SemWait() with a timeout in milliseconds.
136 | *
137 | * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not
138 | * succeed in the allotted time, and -1 on error.
139 | *
140 | * \warning On some platforms this function is implemented by looping with a
141 | * delay of 1 ms, and so should be avoided if possible.
142 | */
143 | extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms);
144 |
145 | /**
146 | * Atomically increases the semaphore's count (not blocking).
147 | *
148 | * \return 0, or -1 on error.
149 | */
150 | extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem);
151 |
152 | /**
153 | * Returns the current count of the semaphore.
154 | */
155 | extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem);
156 |
157 | /* @} *//* Semaphore functions */
158 |
159 |
160 | /**
161 | * \name Condition variable functions
162 | */
163 | /* @{ */
164 |
165 | /* The SDL condition variable structure, defined in SDL_syscond.c */
166 | struct SDL_cond;
167 | typedef struct SDL_cond SDL_cond;
168 |
169 | /**
170 | * Create a condition variable.
171 | *
172 | * Typical use of condition variables:
173 | *
174 | * Thread A:
175 | * SDL_LockMutex(lock);
176 | * while ( ! condition ) {
177 | * SDL_CondWait(cond, lock);
178 | * }
179 | * SDL_UnlockMutex(lock);
180 | *
181 | * Thread B:
182 | * SDL_LockMutex(lock);
183 | * ...
184 | * condition = true;
185 | * ...
186 | * SDL_CondSignal(cond);
187 | * SDL_UnlockMutex(lock);
188 | *
189 | * There is some discussion whether to signal the condition variable
190 | * with the mutex locked or not. There is some potential performance
191 | * benefit to unlocking first on some platforms, but there are some
192 | * potential race conditions depending on how your code is structured.
193 | *
194 | * In general it's safer to signal the condition variable while the
195 | * mutex is locked.
196 | */
197 | extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void);
198 |
199 | /**
200 | * Destroy a condition variable.
201 | */
202 | extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond);
203 |
204 | /**
205 | * Restart one of the threads that are waiting on the condition variable.
206 | *
207 | * \return 0 or -1 on error.
208 | */
209 | extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond);
210 |
211 | /**
212 | * Restart all threads that are waiting on the condition variable.
213 | *
214 | * \return 0 or -1 on error.
215 | */
216 | extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond);
217 |
218 | /**
219 | * Wait on the condition variable, unlocking the provided mutex.
220 | *
221 | * \warning The mutex must be locked before entering this function!
222 | *
223 | * The mutex is re-locked once the condition variable is signaled.
224 | *
225 | * \return 0 when it is signaled, or -1 on error.
226 | */
227 | extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex);
228 |
229 | /**
230 | * Waits for at most \c ms milliseconds, and returns 0 if the condition
231 | * variable is signaled, ::SDL_MUTEX_TIMEDOUT if the condition is not
232 | * signaled in the allotted time, and -1 on error.
233 | *
234 | * \warning On some platforms this function is implemented by looping with a
235 | * delay of 1 ms, and so should be avoided if possible.
236 | */
237 | extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond,
238 | SDL_mutex * mutex, Uint32 ms);
239 |
240 | /* @} *//* Condition variable functions */
241 |
242 |
243 | /* Ends C function definitions when using C++ */
244 | #ifdef __cplusplus
245 | }
246 | #endif
247 | #include "close_code.h"
248 |
249 | #endif /* _SDL_mutex_h */
250 |
251 | /* vi: set ts=4 sw=4 expandtab: */
252 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_name.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #ifndef _SDLname_h_
23 | #define _SDLname_h_
24 |
25 | #if defined(__STDC__) || defined(__cplusplus)
26 | #define NeedFunctionPrototypes 1
27 | #endif
28 |
29 | #define SDL_NAME(X) SDL_##X
30 |
31 | #endif /* _SDLname_h_ */
32 |
33 | /* vi: set ts=4 sw=4 expandtab: */
34 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_opengles.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_opengles.h
24 | *
25 | * This is a simple file to encapsulate the OpenGL ES 1.X API headers.
26 | */
27 |
28 | #ifdef __IPHONEOS__
29 | #include
30 | #include
31 | #else
32 | #include
33 | #include
34 | #endif
35 |
36 | #ifndef APIENTRY
37 | #define APIENTRY
38 | #endif
39 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_opengles2.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_opengles2.h
24 | *
25 | * This is a simple file to encapsulate the OpenGL ES 2.0 API headers.
26 | */
27 | #ifndef _MSC_VER
28 |
29 | #ifdef __IPHONEOS__
30 | #include
31 | #include
32 | #else
33 | #include
34 | #include
35 | #include
36 | #endif
37 |
38 | #else /* _MSC_VER */
39 |
40 | /* OpenGL ES2 headers for Visual Studio */
41 | #include "SDL_opengles2_khrplatform.h"
42 | #include "SDL_opengles2_gl2platform.h"
43 | #include "SDL_opengles2_gl2.h"
44 | #include "SDL_opengles2_gl2ext.h"
45 |
46 | #endif /* _MSC_VER */
47 |
48 | #ifndef APIENTRY
49 | #define APIENTRY GL_APIENTRY
50 | #endif
51 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_opengles2_gl2platform.h:
--------------------------------------------------------------------------------
1 | #ifndef __gl2platform_h_
2 | #define __gl2platform_h_
3 |
4 | /* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */
5 |
6 | /*
7 | * This document is licensed under the SGI Free Software B License Version
8 | * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
9 | */
10 |
11 | /* Platform-specific types and definitions for OpenGL ES 2.X gl2.h
12 | *
13 | * Adopters may modify khrplatform.h and this file to suit their platform.
14 | * You are encouraged to submit all modifications to the Khronos group so that
15 | * they can be included in future versions of this file. Please submit changes
16 | * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
17 | * by filing a bug against product "OpenGL-ES" component "Registry".
18 | */
19 |
20 | /*#include */
21 |
22 | #ifndef GL_APICALL
23 | #define GL_APICALL KHRONOS_APICALL
24 | #endif
25 |
26 | #ifndef GL_APIENTRY
27 | #define GL_APIENTRY KHRONOS_APIENTRY
28 | #endif
29 |
30 | #endif /* __gl2platform_h_ */
31 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_platform.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_platform.h
24 | *
25 | * Try to get a standard set of platform defines.
26 | */
27 |
28 | #ifndef _SDL_platform_h
29 | #define _SDL_platform_h
30 |
31 | #if defined(_AIX)
32 | #undef __AIX__
33 | #define __AIX__ 1
34 | #endif
35 | #if defined(__HAIKU__)
36 | #undef __HAIKU__
37 | #define __HAIKU__ 1
38 | #endif
39 | #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__)
40 | #undef __BSDI__
41 | #define __BSDI__ 1
42 | #endif
43 | #if defined(_arch_dreamcast)
44 | #undef __DREAMCAST__
45 | #define __DREAMCAST__ 1
46 | #endif
47 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
48 | #undef __FREEBSD__
49 | #define __FREEBSD__ 1
50 | #endif
51 | #if defined(hpux) || defined(__hpux) || defined(__hpux__)
52 | #undef __HPUX__
53 | #define __HPUX__ 1
54 | #endif
55 | #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE)
56 | #undef __IRIX__
57 | #define __IRIX__ 1
58 | #endif
59 | #if (defined(linux) || defined(__linux) || defined(__linux__))
60 | #undef __LINUX__
61 | #define __LINUX__ 1
62 | #endif
63 | #if defined(ANDROID) || defined(__ANDROID__)
64 | #undef __ANDROID__
65 | #undef __LINUX__ /* do we need to do this? */
66 | #define __ANDROID__ 1
67 | #endif
68 |
69 | #if defined(__APPLE__)
70 | /* lets us know what version of Mac OS X we're compiling on */
71 | #include "AvailabilityMacros.h"
72 | #include "TargetConditionals.h"
73 | #if TARGET_OS_IPHONE
74 | /* if compiling for iPhone */
75 | #undef __IPHONEOS__
76 | #define __IPHONEOS__ 1
77 | #undef __MACOSX__
78 | #else
79 | /* if not compiling for iPhone */
80 | #undef __MACOSX__
81 | #define __MACOSX__ 1
82 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
83 | # error SDL for Mac OS X only supports deploying on 10.5 and above.
84 | #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */
85 | #endif /* TARGET_OS_IPHONE */
86 | #endif /* defined(__APPLE__) */
87 |
88 | #if defined(__NetBSD__)
89 | #undef __NETBSD__
90 | #define __NETBSD__ 1
91 | #endif
92 | #if defined(__OpenBSD__)
93 | #undef __OPENBSD__
94 | #define __OPENBSD__ 1
95 | #endif
96 | #if defined(__OS2__)
97 | #undef __OS2__
98 | #define __OS2__ 1
99 | #endif
100 | #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)
101 | #undef __OSF__
102 | #define __OSF__ 1
103 | #endif
104 | #if defined(__QNXNTO__)
105 | #undef __QNXNTO__
106 | #define __QNXNTO__ 1
107 | #endif
108 | #if defined(riscos) || defined(__riscos) || defined(__riscos__)
109 | #undef __RISCOS__
110 | #define __RISCOS__ 1
111 | #endif
112 | #if defined(__sun) && defined(__SVR4)
113 | #undef __SOLARIS__
114 | #define __SOLARIS__ 1
115 | #endif
116 |
117 | #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
118 | /* Try to find out if we're compiling for WinRT or non-WinRT */
119 | /* If _USING_V110_SDK71_ is defined it means we are using the v110_xp or v120_xp toolset. */
120 | #if (defined(_MSC_VER) && (_MSC_VER >= 1700) && !_USING_V110_SDK71_) /* _MSC_VER==1700 for MSVC 2012 */
121 | #include
122 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
123 | #undef __WINDOWS__
124 | #define __WINDOWS__ 1
125 | /* See if we're compiling for WinRT: */
126 | #elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
127 | #undef __WINRT__
128 | #define __WINRT__ 1
129 | #endif
130 | #else
131 | #undef __WINDOWS__
132 | #define __WINDOWS__ 1
133 | #endif /* _MSC_VER < 1700 */
134 | #endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */
135 |
136 | #if defined(__WINDOWS__)
137 | #undef __WIN32__
138 | #define __WIN32__ 1
139 | #endif
140 | #if defined(__PSP__)
141 | #undef __PSP__
142 | #define __PSP__ 1
143 | #endif
144 |
145 | /* The NACL compiler defines __native_client__ and __pnacl__
146 | * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi
147 | */
148 | #if defined(__native_client__)
149 | #undef __LINUX__
150 | #undef __NACL__
151 | #define __NACL__ 1
152 | #endif
153 | #if defined(__pnacl__)
154 | #undef __LINUX__
155 | #undef __PNACL__
156 | #define __PNACL__ 1
157 | /* PNACL with newlib supports static linking only */
158 | #define __SDL_NOGETPROCADDR__
159 | #endif
160 |
161 |
162 | #include "begin_code.h"
163 | /* Set up for C function definitions, even when using C++ */
164 | #ifdef __cplusplus
165 | extern "C" {
166 | #endif
167 |
168 | /**
169 | * \brief Gets the name of the platform.
170 | */
171 | extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void);
172 |
173 | /* Ends C function definitions when using C++ */
174 | #ifdef __cplusplus
175 | }
176 | #endif
177 | #include "close_code.h"
178 |
179 | #endif /* _SDL_platform_h */
180 |
181 | /* vi: set ts=4 sw=4 expandtab: */
182 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_power.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #ifndef _SDL_power_h
23 | #define _SDL_power_h
24 |
25 | /**
26 | * \file SDL_power.h
27 | *
28 | * Header for the SDL power management routines.
29 | */
30 |
31 | #include "SDL_stdinc.h"
32 |
33 | #include "begin_code.h"
34 | /* Set up for C function definitions, even when using C++ */
35 | #ifdef __cplusplus
36 | extern "C" {
37 | #endif
38 |
39 | /**
40 | * \brief The basic state for the system's power supply.
41 | */
42 | typedef enum
43 | {
44 | SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */
45 | SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */
46 | SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */
47 | SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */
48 | SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */
49 | } SDL_PowerState;
50 |
51 |
52 | /**
53 | * \brief Get the current power supply details.
54 | *
55 | * \param secs Seconds of battery life left. You can pass a NULL here if
56 | * you don't care. Will return -1 if we can't determine a
57 | * value, or we're not running on a battery.
58 | *
59 | * \param pct Percentage of battery life left, between 0 and 100. You can
60 | * pass a NULL here if you don't care. Will return -1 if we
61 | * can't determine a value, or we're not running on a battery.
62 | *
63 | * \return The state of the battery (if any).
64 | */
65 | extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct);
66 |
67 | /* Ends C function definitions when using C++ */
68 | #ifdef __cplusplus
69 | }
70 | #endif
71 | #include "close_code.h"
72 |
73 | #endif /* _SDL_power_h */
74 |
75 | /* vi: set ts=4 sw=4 expandtab: */
76 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_quit.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_quit.h
24 | *
25 | * Include file for SDL quit event handling.
26 | */
27 |
28 | #ifndef _SDL_quit_h
29 | #define _SDL_quit_h
30 |
31 | #include "SDL_stdinc.h"
32 | #include "SDL_error.h"
33 |
34 | /**
35 | * \file SDL_quit.h
36 | *
37 | * An ::SDL_QUIT event is generated when the user tries to close the application
38 | * window. If it is ignored or filtered out, the window will remain open.
39 | * If it is not ignored or filtered, it is queued normally and the window
40 | * is allowed to close. When the window is closed, screen updates will
41 | * complete, but have no effect.
42 | *
43 | * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt)
44 | * and SIGTERM (system termination request), if handlers do not already
45 | * exist, that generate ::SDL_QUIT events as well. There is no way
46 | * to determine the cause of an ::SDL_QUIT event, but setting a signal
47 | * handler in your application will override the default generation of
48 | * quit events for that signal.
49 | *
50 | * \sa SDL_Quit()
51 | */
52 |
53 | /* There are no functions directly affecting the quit event */
54 |
55 | #define SDL_QuitRequested() \
56 | (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0))
57 |
58 | #endif /* _SDL_quit_h */
59 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_rect.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_rect.h
24 | *
25 | * Header file for SDL_rect definition and management functions.
26 | */
27 |
28 | #ifndef _SDL_rect_h
29 | #define _SDL_rect_h
30 |
31 | #include "SDL_stdinc.h"
32 | #include "SDL_error.h"
33 | #include "SDL_pixels.h"
34 | #include "SDL_rwops.h"
35 |
36 | #include "begin_code.h"
37 | /* Set up for C function definitions, even when using C++ */
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | /**
43 | * \brief The structure that defines a point
44 | *
45 | * \sa SDL_EnclosePoints
46 | * \sa SDL_PointInRect
47 | */
48 | typedef struct SDL_Point
49 | {
50 | int x;
51 | int y;
52 | } SDL_Point;
53 |
54 | /**
55 | * \brief A rectangle, with the origin at the upper left.
56 | *
57 | * \sa SDL_RectEmpty
58 | * \sa SDL_RectEquals
59 | * \sa SDL_HasIntersection
60 | * \sa SDL_IntersectRect
61 | * \sa SDL_UnionRect
62 | * \sa SDL_EnclosePoints
63 | */
64 | typedef struct SDL_Rect
65 | {
66 | int x, y;
67 | int w, h;
68 | } SDL_Rect;
69 |
70 | /**
71 | * \brief Returns true if point resides inside a rectangle.
72 | */
73 | SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r)
74 | {
75 | return ( (p->x >= r->x) && (p->x < (r->x + r->w)) &&
76 | (p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE;
77 | }
78 |
79 | /**
80 | * \brief Returns true if the rectangle has no area.
81 | */
82 | SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r)
83 | {
84 | return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE;
85 | }
86 |
87 | /**
88 | * \brief Returns true if the two rectangles are equal.
89 | */
90 | SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b)
91 | {
92 | return (a && b && (a->x == b->x) && (a->y == b->y) &&
93 | (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE;
94 | }
95 |
96 | /**
97 | * \brief Determine whether two rectangles intersect.
98 | *
99 | * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
100 | */
101 | extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
102 | const SDL_Rect * B);
103 |
104 | /**
105 | * \brief Calculate the intersection of two rectangles.
106 | *
107 | * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
108 | */
109 | extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
110 | const SDL_Rect * B,
111 | SDL_Rect * result);
112 |
113 | /**
114 | * \brief Calculate the union of two rectangles.
115 | */
116 | extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
117 | const SDL_Rect * B,
118 | SDL_Rect * result);
119 |
120 | /**
121 | * \brief Calculate a minimal rectangle enclosing a set of points
122 | *
123 | * \return SDL_TRUE if any points were within the clipping rect
124 | */
125 | extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
126 | int count,
127 | const SDL_Rect * clip,
128 | SDL_Rect * result);
129 |
130 | /**
131 | * \brief Calculate the intersection of a rectangle and line segment.
132 | *
133 | * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
134 | */
135 | extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
136 | rect, int *X1,
137 | int *Y1, int *X2,
138 | int *Y2);
139 |
140 | /* Ends C function definitions when using C++ */
141 | #ifdef __cplusplus
142 | }
143 | #endif
144 | #include "close_code.h"
145 |
146 | #endif /* _SDL_rect_h */
147 |
148 | /* vi: set ts=4 sw=4 expandtab: */
149 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_revision.h:
--------------------------------------------------------------------------------
1 | #define SDL_REVISION "hg-9578:e78393ffcd50"
2 | #define SDL_REVISION_NUMBER 9578
3 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_shape.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #ifndef _SDL_shape_h
23 | #define _SDL_shape_h
24 |
25 | #include "SDL_stdinc.h"
26 | #include "SDL_pixels.h"
27 | #include "SDL_rect.h"
28 | #include "SDL_surface.h"
29 | #include "SDL_video.h"
30 |
31 | #include "begin_code.h"
32 | /* Set up for C function definitions, even when using C++ */
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /** \file SDL_shape.h
38 | *
39 | * Header file for the shaped window API.
40 | */
41 |
42 | #define SDL_NONSHAPEABLE_WINDOW -1
43 | #define SDL_INVALID_SHAPE_ARGUMENT -2
44 | #define SDL_WINDOW_LACKS_SHAPE -3
45 |
46 | /**
47 | * \brief Create a window that can be shaped with the specified position, dimensions, and flags.
48 | *
49 | * \param title The title of the window, in UTF-8 encoding.
50 | * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or
51 | * ::SDL_WINDOWPOS_UNDEFINED.
52 | * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or
53 | * ::SDL_WINDOWPOS_UNDEFINED.
54 | * \param w The width of the window.
55 | * \param h The height of the window.
56 | * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following:
57 | * ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED,
58 | * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_RESIZABLE,
59 | * ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED,
60 | * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset.
61 | *
62 | * \return The window created, or NULL if window creation failed.
63 | *
64 | * \sa SDL_DestroyWindow()
65 | */
66 | extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
67 |
68 | /**
69 | * \brief Return whether the given window is a shaped window.
70 | *
71 | * \param window The window to query for being shaped.
72 | *
73 | * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL.
74 | * \sa SDL_CreateShapedWindow
75 | */
76 | extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window);
77 |
78 | /** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */
79 | typedef enum {
80 | /** \brief The default mode, a binarized alpha cutoff of 1. */
81 | ShapeModeDefault,
82 | /** \brief A binarized alpha cutoff with a given integer value. */
83 | ShapeModeBinarizeAlpha,
84 | /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */
85 | ShapeModeReverseBinarizeAlpha,
86 | /** \brief A color key is applied. */
87 | ShapeModeColorKey
88 | } WindowShapeMode;
89 |
90 | #define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha)
91 |
92 | /** \brief A union containing parameters for shaped windows. */
93 | typedef union {
94 | /** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */
95 | Uint8 binarizationCutoff;
96 | SDL_Color colorKey;
97 | } SDL_WindowShapeParams;
98 |
99 | /** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */
100 | typedef struct SDL_WindowShapeMode {
101 | /** \brief The mode of these window-shape parameters. */
102 | WindowShapeMode mode;
103 | /** \brief Window-shape parameters. */
104 | SDL_WindowShapeParams parameters;
105 | } SDL_WindowShapeMode;
106 |
107 | /**
108 | * \brief Set the shape and parameters of a shaped window.
109 | *
110 | * \param window The shaped window whose parameters should be set.
111 | * \param shape A surface encoding the desired shape for the window.
112 | * \param shape_mode The parameters to set for the shaped window.
113 | *
114 | * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW
115 | * if the SDL_Window* given does not reference a valid shaped window.
116 | *
117 | * \sa SDL_WindowShapeMode
118 | * \sa SDL_GetShapedWindowMode.
119 | */
120 | extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
121 |
122 | /**
123 | * \brief Get the shape parameters of a shaped window.
124 | *
125 | * \param window The shaped window whose parameters should be retrieved.
126 | * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape.
127 | *
128 | * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode
129 | * data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if
130 | * the SDL_Window* given is a shapeable window currently lacking a shape.
131 | *
132 | * \sa SDL_WindowShapeMode
133 | * \sa SDL_SetWindowShape
134 | */
135 | extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode);
136 |
137 | /* Ends C function definitions when using C++ */
138 | #ifdef __cplusplus
139 | }
140 | #endif
141 | #include "close_code.h"
142 |
143 | #endif /* _SDL_shape_h */
144 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_system.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_system.h
24 | *
25 | * Include file for platform specific SDL API functions
26 | */
27 |
28 | #ifndef _SDL_system_h
29 | #define _SDL_system_h
30 |
31 | #include "SDL_stdinc.h"
32 | #include "SDL_keyboard.h"
33 | #include "SDL_render.h"
34 | #include "SDL_video.h"
35 |
36 | #include "begin_code.h"
37 | /* Set up for C function definitions, even when using C++ */
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 |
43 | /* Platform specific functions for Windows */
44 | #ifdef __WIN32__
45 |
46 | /**
47 | \brief Returns the D3D9 adapter index that matches the specified display index.
48 |
49 | This adapter index can be passed to IDirect3D9::CreateDevice and controls
50 | on which monitor a full screen application will appear.
51 | */
52 | extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex );
53 |
54 | typedef struct IDirect3DDevice9 IDirect3DDevice9;
55 | /**
56 | \brief Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer.
57 |
58 | Once you are done using the device, you should release it to avoid a resource leak.
59 | */
60 | extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer);
61 |
62 | /**
63 | \brief Returns the DXGI Adapter and Output indices for the specified display index.
64 |
65 | These can be passed to EnumAdapters and EnumOutputs respectively to get the objects
66 | required to create a DX10 or DX11 device and swap chain.
67 | */
68 | extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex );
69 |
70 | #endif /* __WIN32__ */
71 |
72 |
73 | /* Platform specific functions for iOS */
74 | #if defined(__IPHONEOS__) && __IPHONEOS__
75 |
76 | #define SDL_iOSSetAnimationCallback(window, interval, callback, callbackParam) SDL_iPhoneSetAnimationCallback(window, interval, callback, callbackParam)
77 | extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
78 |
79 | #define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled)
80 | extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
81 |
82 | #endif /* __IPHONEOS__ */
83 |
84 |
85 | /* Platform specific functions for Android */
86 | #if defined(__ANDROID__) && __ANDROID__
87 |
88 | /**
89 | \brief Get the JNI environment for the current thread
90 |
91 | This returns JNIEnv*, but the prototype is void* so we don't need jni.h
92 | */
93 | extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv();
94 |
95 | /**
96 | \brief Get the SDL Activity object for the application
97 |
98 | This returns jobject, but the prototype is void* so we don't need jni.h
99 | The jobject returned by SDL_AndroidGetActivity is a local reference.
100 | It is the caller's responsibility to properly release it
101 | (using env->Push/PopLocalFrame or manually with env->DeleteLocalRef)
102 | */
103 | extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity();
104 |
105 | /**
106 | See the official Android developer guide for more information:
107 | http://developer.android.com/guide/topics/data/data-storage.html
108 | */
109 | #define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01
110 | #define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02
111 |
112 | /**
113 | \brief Get the path used for internal storage for this application.
114 |
115 | This path is unique to your application and cannot be written to
116 | by other applications.
117 | */
118 | extern DECLSPEC const char * SDLCALL SDL_AndroidGetInternalStoragePath();
119 |
120 | /**
121 | \brief Get the current state of external storage, a bitmask of these values:
122 | SDL_ANDROID_EXTERNAL_STORAGE_READ
123 | SDL_ANDROID_EXTERNAL_STORAGE_WRITE
124 |
125 | If external storage is currently unavailable, this will return 0.
126 | */
127 | extern DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState();
128 |
129 | /**
130 | \brief Get the path used for external storage for this application.
131 |
132 | This path is unique to your application, but is public and can be
133 | written to by other applications.
134 | */
135 | extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath();
136 |
137 | #endif /* __ANDROID__ */
138 |
139 | /* Platform specific functions for WinRT */
140 | #if defined(__WINRT__) && __WINRT__
141 |
142 | /**
143 | * \brief WinRT / Windows Phone path types
144 | */
145 | typedef enum
146 | {
147 | /** \brief The installed app's root directory.
148 | Files here are likely to be read-only. */
149 | SDL_WINRT_PATH_INSTALLED_LOCATION,
150 |
151 | /** \brief The app's local data store. Files may be written here */
152 | SDL_WINRT_PATH_LOCAL_FOLDER,
153 |
154 | /** \brief The app's roaming data store. Unsupported on Windows Phone.
155 | Files written here may be copied to other machines via a network
156 | connection.
157 | */
158 | SDL_WINRT_PATH_ROAMING_FOLDER,
159 |
160 | /** \brief The app's temporary data store. Unsupported on Windows Phone.
161 | Files written here may be deleted at any time. */
162 | SDL_WINRT_PATH_TEMP_FOLDER
163 | } SDL_WinRT_Path;
164 |
165 |
166 | /**
167 | * \brief Retrieves a WinRT defined path on the local file system
168 | *
169 | * \note Documentation on most app-specific path types on WinRT
170 | * can be found on MSDN, at the URL:
171 | * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
172 | *
173 | * \param pathType The type of path to retrieve.
174 | * \return A UCS-2 string (16-bit, wide-char) containing the path, or NULL
175 | * if the path is not available for any reason. Not all paths are
176 | * available on all versions of Windows. This is especially true on
177 | * Windows Phone. Check the documentation for the given
178 | * SDL_WinRT_Path for more information on which path types are
179 | * supported where.
180 | */
181 | extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType);
182 |
183 | /**
184 | * \brief Retrieves a WinRT defined path on the local file system
185 | *
186 | * \note Documentation on most app-specific path types on WinRT
187 | * can be found on MSDN, at the URL:
188 | * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
189 | *
190 | * \param pathType The type of path to retrieve.
191 | * \return A UTF-8 string (8-bit, multi-byte) containing the path, or NULL
192 | * if the path is not available for any reason. Not all paths are
193 | * available on all versions of Windows. This is especially true on
194 | * Windows Phone. Check the documentation for the given
195 | * SDL_WinRT_Path for more information on which path types are
196 | * supported where.
197 | */
198 | extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType);
199 |
200 | #endif /* __WINRT__ */
201 |
202 | /* Ends C function definitions when using C++ */
203 | #ifdef __cplusplus
204 | }
205 | #endif
206 | #include "close_code.h"
207 |
208 | #endif /* _SDL_system_h */
209 |
210 | /* vi: set ts=4 sw=4 expandtab: */
211 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_test.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_test.h
24 | *
25 | * Include file for SDL test framework.
26 | *
27 | * This code is a part of the SDL2_test library, not the main SDL library.
28 | */
29 |
30 | #ifndef _SDL_test_h
31 | #define _SDL_test_h
32 |
33 | #include "SDL.h"
34 | #include "SDL_test_common.h"
35 | #include "SDL_test_font.h"
36 | #include "SDL_test_random.h"
37 | #include "SDL_test_fuzzer.h"
38 | #include "SDL_test_crc32.h"
39 | #include "SDL_test_md5.h"
40 | #include "SDL_test_log.h"
41 | #include "SDL_test_assert.h"
42 | #include "SDL_test_harness.h"
43 | #include "SDL_test_images.h"
44 | #include "SDL_test_compare.h"
45 |
46 | #include "begin_code.h"
47 | /* Set up for C function definitions, even when using C++ */
48 | #ifdef __cplusplus
49 | extern "C" {
50 | #endif
51 |
52 | /* Global definitions */
53 |
54 | /*
55 | * Note: Maximum size of SDLTest log message is less than SDLs limit
56 | * to ensure we can fit additional information such as the timestamp.
57 | */
58 | #define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584
59 |
60 | /* Ends C function definitions when using C++ */
61 | #ifdef __cplusplus
62 | }
63 | #endif
64 | #include "close_code.h"
65 |
66 | #endif /* _SDL_test_h */
67 |
68 | /* vi: set ts=4 sw=4 expandtab: */
69 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_test_assert.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_test_assert.h
24 | *
25 | * Include file for SDL test framework.
26 | *
27 | * This code is a part of the SDL2_test library, not the main SDL library.
28 | */
29 |
30 | /*
31 | *
32 | * Assert API for test code and test cases
33 | *
34 | */
35 |
36 | #ifndef _SDL_test_assert_h
37 | #define _SDL_test_assert_h
38 |
39 | #include "begin_code.h"
40 | /* Set up for C function definitions, even when using C++ */
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 | /**
46 | * \brief Fails the assert.
47 | */
48 | #define ASSERT_FAIL 0
49 |
50 | /**
51 | * \brief Passes the assert.
52 | */
53 | #define ASSERT_PASS 1
54 |
55 | /**
56 | * \brief Assert that logs and break execution flow on failures.
57 | *
58 | * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
59 | * \param assertDescription Message to log with the assert describing it.
60 | */
61 | void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2);
62 |
63 | /**
64 | * \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters.
65 | *
66 | * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
67 | * \param assertDescription Message to log with the assert describing it.
68 | *
69 | * \returns Returns the assertCondition so it can be used to externally to break execution flow if desired.
70 | */
71 | int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2);
72 |
73 | /**
74 | * \brief Explicitly pass without checking an assertion condition. Updates assertion counter.
75 | *
76 | * \param assertDescription Message to log with the assert describing it.
77 | */
78 | void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1);
79 |
80 | /**
81 | * \brief Resets the assert summary counters to zero.
82 | */
83 | void SDLTest_ResetAssertSummary();
84 |
85 | /**
86 | * \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR.
87 | */
88 | void SDLTest_LogAssertSummary();
89 |
90 |
91 | /**
92 | * \brief Converts the current assert summary state to a test result.
93 | *
94 | * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT
95 | */
96 | int SDLTest_AssertSummaryToTestResult();
97 |
98 | #ifdef __cplusplus
99 | }
100 | #endif
101 | #include "close_code.h"
102 |
103 | #endif /* _SDL_test_assert_h */
104 |
105 | /* vi: set ts=4 sw=4 expandtab: */
106 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_test_common.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_test_common.h
24 | *
25 | * Include file for SDL test framework.
26 | *
27 | * This code is a part of the SDL2_test library, not the main SDL library.
28 | */
29 |
30 | /* Ported from original test\common.h file. */
31 |
32 | #ifndef _SDL_test_common_h
33 | #define _SDL_test_common_h
34 |
35 | #include "SDL.h"
36 |
37 | #if defined(__PSP__)
38 | #define DEFAULT_WINDOW_WIDTH 480
39 | #define DEFAULT_WINDOW_HEIGHT 272
40 | #else
41 | #define DEFAULT_WINDOW_WIDTH 640
42 | #define DEFAULT_WINDOW_HEIGHT 480
43 | #endif
44 |
45 | #define VERBOSE_VIDEO 0x00000001
46 | #define VERBOSE_MODES 0x00000002
47 | #define VERBOSE_RENDER 0x00000004
48 | #define VERBOSE_EVENT 0x00000008
49 | #define VERBOSE_AUDIO 0x00000010
50 |
51 | typedef struct
52 | {
53 | /* SDL init flags */
54 | char **argv;
55 | Uint32 flags;
56 | Uint32 verbose;
57 |
58 | /* Video info */
59 | const char *videodriver;
60 | int display;
61 | const char *window_title;
62 | const char *window_icon;
63 | Uint32 window_flags;
64 | int window_x;
65 | int window_y;
66 | int window_w;
67 | int window_h;
68 | int window_minW;
69 | int window_minH;
70 | int window_maxW;
71 | int window_maxH;
72 | int logical_w;
73 | int logical_h;
74 | float scale;
75 | int depth;
76 | int refresh_rate;
77 | int num_windows;
78 | SDL_Window **windows;
79 |
80 | /* Renderer info */
81 | const char *renderdriver;
82 | Uint32 render_flags;
83 | SDL_bool skip_renderer;
84 | SDL_Renderer **renderers;
85 | SDL_Texture **targets;
86 |
87 | /* Audio info */
88 | const char *audiodriver;
89 | SDL_AudioSpec audiospec;
90 |
91 | /* GL settings */
92 | int gl_red_size;
93 | int gl_green_size;
94 | int gl_blue_size;
95 | int gl_alpha_size;
96 | int gl_buffer_size;
97 | int gl_depth_size;
98 | int gl_stencil_size;
99 | int gl_double_buffer;
100 | int gl_accum_red_size;
101 | int gl_accum_green_size;
102 | int gl_accum_blue_size;
103 | int gl_accum_alpha_size;
104 | int gl_stereo;
105 | int gl_multisamplebuffers;
106 | int gl_multisamplesamples;
107 | int gl_retained_backing;
108 | int gl_accelerated;
109 | int gl_major_version;
110 | int gl_minor_version;
111 | int gl_debug;
112 | int gl_profile_mask;
113 | } SDLTest_CommonState;
114 |
115 | #include "begin_code.h"
116 | /* Set up for C function definitions, even when using C++ */
117 | #ifdef __cplusplus
118 | extern "C" {
119 | #endif
120 |
121 | /* Function prototypes */
122 |
123 | /**
124 | * \brief Parse command line parameters and create common state.
125 | *
126 | * \param argv Array of command line parameters
127 | * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO)
128 | *
129 | * \returns Returns a newly allocated common state object.
130 | */
131 | SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags);
132 |
133 | /**
134 | * \brief Process one common argument.
135 | *
136 | * \param state The common state describing the test window to create.
137 | * \param index The index of the argument to process in argv[].
138 | *
139 | * \returns The number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error.
140 | */
141 | int SDLTest_CommonArg(SDLTest_CommonState * state, int index);
142 |
143 | /**
144 | * \brief Returns common usage information
145 | *
146 | * \param state The common state describing the test window to create.
147 | *
148 | * \returns String with usage information
149 | */
150 | const char *SDLTest_CommonUsage(SDLTest_CommonState * state);
151 |
152 | /**
153 | * \brief Open test window.
154 | *
155 | * \param state The common state describing the test window to create.
156 | *
157 | * \returns True if initialization succeeded, false otherwise
158 | */
159 | SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state);
160 |
161 | /**
162 | * \brief Common event handler for test windows.
163 | *
164 | * \param state The common state used to create test window.
165 | * \param event The event to handle.
166 | * \param done Flag indicating we are done.
167 | *
168 | */
169 | void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done);
170 |
171 | /**
172 | * \brief Close test window.
173 | *
174 | * \param state The common state used to create test window.
175 | *
176 | */
177 | void SDLTest_CommonQuit(SDLTest_CommonState * state);
178 |
179 |
180 | /* Ends C function definitions when using C++ */
181 | #ifdef __cplusplus
182 | }
183 | #endif
184 | #include "close_code.h"
185 |
186 | #endif /* _SDL_test_common_h */
187 |
188 | /* vi: set ts=4 sw=4 expandtab: */
189 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_test_compare.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_test_compare.h
24 | *
25 | * Include file for SDL test framework.
26 | *
27 | * This code is a part of the SDL2_test library, not the main SDL library.
28 | */
29 |
30 | /*
31 |
32 | Defines comparison functions (i.e. for surfaces).
33 |
34 | */
35 |
36 | #ifndef _SDL_test_compare_h
37 | #define _SDL_test_compare_h
38 |
39 | #include "SDL.h"
40 |
41 | #include "SDL_test_images.h"
42 |
43 | #include "begin_code.h"
44 | /* Set up for C function definitions, even when using C++ */
45 | #ifdef __cplusplus
46 | extern "C" {
47 | #endif
48 |
49 | /**
50 | * \brief Compares a surface and with reference image data for equality
51 | *
52 | * \param surface Surface used in comparison
53 | * \param referenceSurface Test Surface used in comparison
54 | * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy.
55 | *
56 | * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ.
57 | */
58 | int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error);
59 |
60 |
61 | /* Ends C function definitions when using C++ */
62 | #ifdef __cplusplus
63 | }
64 | #endif
65 | #include "close_code.h"
66 |
67 | #endif /* _SDL_test_compare_h */
68 |
69 | /* vi: set ts=4 sw=4 expandtab: */
70 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_test_crc32.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_test_crc32.h
24 | *
25 | * Include file for SDL test framework.
26 | *
27 | * This code is a part of the SDL2_test library, not the main SDL library.
28 | */
29 |
30 | /*
31 |
32 | Implements CRC32 calculations (default output is Perl String::CRC32 compatible).
33 |
34 | */
35 |
36 | #ifndef _SDL_test_crc32_h
37 | #define _SDL_test_crc32_h
38 |
39 | #include "begin_code.h"
40 | /* Set up for C function definitions, even when using C++ */
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 |
46 | /* ------------ Definitions --------- */
47 |
48 | /* Definition shared by all CRC routines */
49 |
50 | #ifndef CrcUint32
51 | #define CrcUint32 unsigned int
52 | #endif
53 | #ifndef CrcUint8
54 | #define CrcUint8 unsigned char
55 | #endif
56 |
57 | #ifdef ORIGINAL_METHOD
58 | #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */
59 | #else
60 | #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */
61 | #endif
62 |
63 | /**
64 | * Data structure for CRC32 (checksum) computation
65 | */
66 | typedef struct {
67 | CrcUint32 crc32_table[256]; /* CRC table */
68 | } SDLTest_Crc32Context;
69 |
70 | /* ---------- Function Prototypes ------------- */
71 |
72 | /**
73 | * \brief Initialize the CRC context
74 | *
75 | * Note: The function initializes the crc table required for all crc calculations.
76 | *
77 | * \param crcContext pointer to context variable
78 | *
79 | * \returns 0 for OK, -1 on error
80 | *
81 | */
82 | int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext);
83 |
84 |
85 | /**
86 | * \brief calculate a crc32 from a data block
87 | *
88 | * \param crcContext pointer to context variable
89 | * \param inBuf input buffer to checksum
90 | * \param inLen length of input buffer
91 | * \param crc32 pointer to Uint32 to store the final CRC into
92 | *
93 | * \returns 0 for OK, -1 on error
94 | *
95 | */
96 | int SDLTest_crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32);
97 |
98 | /* Same routine broken down into three steps */
99 | int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32);
100 | int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32);
101 | int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32);
102 |
103 |
104 | /**
105 | * \brief clean up CRC context
106 | *
107 | * \param crcContext pointer to context variable
108 | *
109 | * \returns 0 for OK, -1 on error
110 | *
111 | */
112 |
113 | int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext);
114 |
115 |
116 | /* Ends C function definitions when using C++ */
117 | #ifdef __cplusplus
118 | }
119 | #endif
120 | #include "close_code.h"
121 |
122 | #endif /* _SDL_test_crc32_h */
123 |
124 | /* vi: set ts=4 sw=4 expandtab: */
125 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_test_font.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_test_font.h
24 | *
25 | * Include file for SDL test framework.
26 | *
27 | * This code is a part of the SDL2_test library, not the main SDL library.
28 | */
29 |
30 | #ifndef _SDL_test_font_h
31 | #define _SDL_test_font_h
32 |
33 | #include "begin_code.h"
34 | /* Set up for C function definitions, even when using C++ */
35 | #ifdef __cplusplus
36 | extern "C" {
37 | #endif
38 |
39 | /* Function prototypes */
40 |
41 | #define FONT_CHARACTER_SIZE 8
42 |
43 | /**
44 | * \brief Draw a string in the currently set font.
45 | *
46 | * \param renderer The renderer to draw on.
47 | * \param x The X coordinate of the upper left corner of the character.
48 | * \param y The Y coordinate of the upper left corner of the character.
49 | * \param c The character to draw.
50 | *
51 | * \returns Returns 0 on success, -1 on failure.
52 | */
53 | int SDLTest_DrawCharacter( SDL_Renderer *renderer, int x, int y, char c );
54 |
55 | /**
56 | * \brief Draw a string in the currently set font.
57 | *
58 | * \param renderer The renderer to draw on.
59 | * \param x The X coordinate of the upper left corner of the string.
60 | * \param y The Y coordinate of the upper left corner of the string.
61 | * \param s The string to draw.
62 | *
63 | * \returns Returns 0 on success, -1 on failure.
64 | */
65 | int SDLTest_DrawString( SDL_Renderer * renderer, int x, int y, const char *s );
66 |
67 |
68 | /* Ends C function definitions when using C++ */
69 | #ifdef __cplusplus
70 | }
71 | #endif
72 | #include "close_code.h"
73 |
74 | #endif /* _SDL_test_font_h */
75 |
76 | /* vi: set ts=4 sw=4 expandtab: */
77 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_test_harness.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_test_harness.h
24 | *
25 | * Include file for SDL test framework.
26 | *
27 | * This code is a part of the SDL2_test library, not the main SDL library.
28 | */
29 |
30 | /*
31 | Defines types for test case definitions and the test execution harness API.
32 |
33 | Based on original GSOC code by Markus Kauppila
34 | */
35 |
36 | #ifndef _SDL_test_harness_h
37 | #define _SDL_test_harness_h
38 |
39 | #include "begin_code.h"
40 | /* Set up for C function definitions, even when using C++ */
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 |
46 | /* ! Definitions for test case structures */
47 | #define TEST_ENABLED 1
48 | #define TEST_DISABLED 0
49 |
50 | /* ! Definition of all the possible test return values of the test case method */
51 | #define TEST_ABORTED -1
52 | #define TEST_STARTED 0
53 | #define TEST_COMPLETED 1
54 | #define TEST_SKIPPED 2
55 |
56 | /* ! Definition of all the possible test results for the harness */
57 | #define TEST_RESULT_PASSED 0
58 | #define TEST_RESULT_FAILED 1
59 | #define TEST_RESULT_NO_ASSERT 2
60 | #define TEST_RESULT_SKIPPED 3
61 | #define TEST_RESULT_SETUP_FAILURE 4
62 |
63 | /* !< Function pointer to a test case setup function (run before every test) */
64 | typedef void (*SDLTest_TestCaseSetUpFp)(void *arg);
65 |
66 | /* !< Function pointer to a test case function */
67 | typedef int (*SDLTest_TestCaseFp)(void *arg);
68 |
69 | /* !< Function pointer to a test case teardown function (run after every test) */
70 | typedef void (*SDLTest_TestCaseTearDownFp)(void *arg);
71 |
72 | /**
73 | * Holds information about a single test case.
74 | */
75 | typedef struct SDLTest_TestCaseReference {
76 | /* !< Func2Stress */
77 | SDLTest_TestCaseFp testCase;
78 | /* !< Short name (or function name) "Func2Stress" */
79 | char *name;
80 | /* !< Long name or full description "This test pushes func2() to the limit." */
81 | char *description;
82 | /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */
83 | int enabled;
84 | } SDLTest_TestCaseReference;
85 |
86 | /**
87 | * Holds information about a test suite (multiple test cases).
88 | */
89 | typedef struct SDLTest_TestSuiteReference {
90 | /* !< "PlatformSuite" */
91 | char *name;
92 | /* !< The function that is run before each test. NULL skips. */
93 | SDLTest_TestCaseSetUpFp testSetUp;
94 | /* !< The test cases that are run as part of the suite. Last item should be NULL. */
95 | const SDLTest_TestCaseReference **testCases;
96 | /* !< The function that is run after each test. NULL skips. */
97 | SDLTest_TestCaseTearDownFp testTearDown;
98 | } SDLTest_TestSuiteReference;
99 |
100 |
101 | /**
102 | * \brief Execute a test suite using the given run seed and execution key.
103 | *
104 | * \param testSuites Suites containing the test case.
105 | * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one.
106 | * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one.
107 | * \param filter Filter specification. NULL disables. Case sensitive.
108 | * \param testIterations Number of iterations to run each test case.
109 | *
110 | * \returns Test run result; 0 when all tests passed, 1 if any tests failed.
111 | */
112 | int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations);
113 |
114 |
115 | /* Ends C function definitions when using C++ */
116 | #ifdef __cplusplus
117 | }
118 | #endif
119 | #include "close_code.h"
120 |
121 | #endif /* _SDL_test_harness_h */
122 |
123 | /* vi: set ts=4 sw=4 expandtab: */
124 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_test_images.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_test_images.h
24 | *
25 | * Include file for SDL test framework.
26 | *
27 | * This code is a part of the SDL2_test library, not the main SDL library.
28 | */
29 |
30 | /*
31 |
32 | Defines some images for tests.
33 |
34 | */
35 |
36 | #ifndef _SDL_test_images_h
37 | #define _SDL_test_images_h
38 |
39 | #include "SDL.h"
40 |
41 | #include "begin_code.h"
42 | /* Set up for C function definitions, even when using C++ */
43 | #ifdef __cplusplus
44 | extern "C" {
45 | #endif
46 |
47 | /**
48 | *Type for test images.
49 | */
50 | typedef struct SDLTest_SurfaceImage_s {
51 | int width;
52 | int height;
53 | unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
54 | const char *pixel_data;
55 | } SDLTest_SurfaceImage_t;
56 |
57 | /* Test images */
58 | SDL_Surface *SDLTest_ImageBlit();
59 | SDL_Surface *SDLTest_ImageBlitColor();
60 | SDL_Surface *SDLTest_ImageBlitAlpha();
61 | SDL_Surface *SDLTest_ImageBlitBlendAdd();
62 | SDL_Surface *SDLTest_ImageBlitBlend();
63 | SDL_Surface *SDLTest_ImageBlitBlendMod();
64 | SDL_Surface *SDLTest_ImageBlitBlendNone();
65 | SDL_Surface *SDLTest_ImageBlitBlendAll();
66 | SDL_Surface *SDLTest_ImageFace();
67 | SDL_Surface *SDLTest_ImagePrimitives();
68 | SDL_Surface *SDLTest_ImagePrimitivesBlend();
69 |
70 | /* Ends C function definitions when using C++ */
71 | #ifdef __cplusplus
72 | }
73 | #endif
74 | #include "close_code.h"
75 |
76 | #endif /* _SDL_test_images_h */
77 |
78 | /* vi: set ts=4 sw=4 expandtab: */
79 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_test_log.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_test_log.h
24 | *
25 | * Include file for SDL test framework.
26 | *
27 | * This code is a part of the SDL2_test library, not the main SDL library.
28 | */
29 |
30 | /*
31 | *
32 | * Wrapper to log in the TEST category
33 | *
34 | */
35 |
36 | #ifndef _SDL_test_log_h
37 | #define _SDL_test_log_h
38 |
39 | #include "begin_code.h"
40 | /* Set up for C function definitions, even when using C++ */
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 | /**
46 | * \brief Prints given message with a timestamp in the TEST category and INFO priority.
47 | *
48 | * \param fmt Message to be logged
49 | */
50 | void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
51 |
52 | /**
53 | * \brief Prints given message with a timestamp in the TEST category and the ERROR priority.
54 | *
55 | * \param fmt Message to be logged
56 | */
57 | void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
58 |
59 | /* Ends C function definitions when using C++ */
60 | #ifdef __cplusplus
61 | }
62 | #endif
63 | #include "close_code.h"
64 |
65 | #endif /* _SDL_test_log_h */
66 |
67 | /* vi: set ts=4 sw=4 expandtab: */
68 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_test_md5.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_test_md5.h
24 | *
25 | * Include file for SDL test framework.
26 | *
27 | * This code is a part of the SDL2_test library, not the main SDL library.
28 | */
29 |
30 | /*
31 | ***********************************************************************
32 | ** Header file for implementation of MD5 **
33 | ** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
34 | ** Created: 2/17/90 RLR **
35 | ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
36 | ** Revised (for MD5): RLR 4/27/91 **
37 | ** -- G modified to have y&~z instead of y&z **
38 | ** -- FF, GG, HH modified to add in last register done **
39 | ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 **
40 | ** -- distinct additive constant for each step **
41 | ** -- round 4 added, working mod 7 **
42 | ***********************************************************************
43 | */
44 |
45 | /*
46 | ***********************************************************************
47 | ** Message-digest routines: **
48 | ** To form the message digest for a message M **
49 | ** (1) Initialize a context buffer mdContext using MD5Init **
50 | ** (2) Call MD5Update on mdContext and M **
51 | ** (3) Call MD5Final on mdContext **
52 | ** The message digest is now in mdContext->digest[0...15] **
53 | ***********************************************************************
54 | */
55 |
56 | #ifndef _SDL_test_md5_h
57 | #define _SDL_test_md5_h
58 |
59 | #include "begin_code.h"
60 | /* Set up for C function definitions, even when using C++ */
61 | #ifdef __cplusplus
62 | extern "C" {
63 | #endif
64 |
65 | /* ------------ Definitions --------- */
66 |
67 | /* typedef a 32-bit type */
68 | typedef unsigned long int MD5UINT4;
69 |
70 | /* Data structure for MD5 (Message-Digest) computation */
71 | typedef struct {
72 | MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
73 | MD5UINT4 buf[4]; /* scratch buffer */
74 | unsigned char in[64]; /* input buffer */
75 | unsigned char digest[16]; /* actual digest after Md5Final call */
76 | } SDLTest_Md5Context;
77 |
78 | /* ---------- Function Prototypes ------------- */
79 |
80 | /**
81 | * \brief initialize the context
82 | *
83 | * \param mdContext pointer to context variable
84 | *
85 | * Note: The function initializes the message-digest context
86 | * mdContext. Call before each new use of the context -
87 | * all fields are set to zero.
88 | */
89 | void SDLTest_Md5Init(SDLTest_Md5Context * mdContext);
90 |
91 |
92 | /**
93 | * \brief update digest from variable length data
94 | *
95 | * \param mdContext pointer to context variable
96 | * \param inBuf pointer to data array/string
97 | * \param inLen length of data array/string
98 | *
99 | * Note: The function updates the message-digest context to account
100 | * for the presence of each of the characters inBuf[0..inLen-1]
101 | * in the message whose digest is being computed.
102 | */
103 |
104 | void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf,
105 | unsigned int inLen);
106 |
107 |
108 | /**
109 | * \brief complete digest computation
110 | *
111 | * \param mdContext pointer to context variable
112 | *
113 | * Note: The function terminates the message-digest computation and
114 | * ends with the desired message digest in mdContext.digest[0..15].
115 | * Always call before using the digest[] variable.
116 | */
117 |
118 | void SDLTest_Md5Final(SDLTest_Md5Context * mdContext);
119 |
120 |
121 | /* Ends C function definitions when using C++ */
122 | #ifdef __cplusplus
123 | }
124 | #endif
125 | #include "close_code.h"
126 |
127 | #endif /* _SDL_test_md5_h */
128 |
129 | /* vi: set ts=4 sw=4 expandtab: */
130 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_test_random.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_test_random.h
24 | *
25 | * Include file for SDL test framework.
26 | *
27 | * This code is a part of the SDL2_test library, not the main SDL library.
28 | */
29 |
30 | /*
31 |
32 | A "32-bit Multiply with carry random number generator. Very fast.
33 | Includes a list of recommended multipliers.
34 |
35 | multiply-with-carry generator: x(n) = a*x(n-1) + carry mod 2^32.
36 | period: (a*2^31)-1
37 |
38 | */
39 |
40 | #ifndef _SDL_test_random_h
41 | #define _SDL_test_random_h
42 |
43 | #include "begin_code.h"
44 | /* Set up for C function definitions, even when using C++ */
45 | #ifdef __cplusplus
46 | extern "C" {
47 | #endif
48 |
49 | /* --- Definitions */
50 |
51 | /*
52 | * Macros that return a random number in a specific format.
53 | */
54 | #define SDLTest_RandomInt(c) ((int)SDLTest_Random(c))
55 |
56 | /*
57 | * Context structure for the random number generator state.
58 | */
59 | typedef struct {
60 | unsigned int a;
61 | unsigned int x;
62 | unsigned int c;
63 | unsigned int ah;
64 | unsigned int al;
65 | } SDLTest_RandomContext;
66 |
67 |
68 | /* --- Function prototypes */
69 |
70 | /**
71 | * \brief Initialize random number generator with two integers.
72 | *
73 | * Note: The random sequence of numbers returned by ...Random() is the
74 | * same for the same two integers and has a period of 2^31.
75 | *
76 | * \param rndContext pointer to context structure
77 | * \param xi integer that defines the random sequence
78 | * \param ci integer that defines the random sequence
79 | *
80 | */
81 | void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi,
82 | unsigned int ci);
83 |
84 | /**
85 | * \brief Initialize random number generator based on current system time.
86 | *
87 | * \param rndContext pointer to context structure
88 | *
89 | */
90 | void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext);
91 |
92 |
93 | /**
94 | * \brief Initialize random number generator based on current system time.
95 | *
96 | * Note: ...RandomInit() or ...RandomInitTime() must have been called
97 | * before using this function.
98 | *
99 | * \param rndContext pointer to context structure
100 | *
101 | * \returns A random number (32bit unsigned integer)
102 | *
103 | */
104 | unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext);
105 |
106 |
107 | /* Ends C function definitions when using C++ */
108 | #ifdef __cplusplus
109 | }
110 | #endif
111 | #include "close_code.h"
112 |
113 | #endif /* _SDL_test_random_h */
114 |
115 | /* vi: set ts=4 sw=4 expandtab: */
116 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_timer.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #ifndef _SDL_timer_h
23 | #define _SDL_timer_h
24 |
25 | /**
26 | * \file SDL_timer.h
27 | *
28 | * Header for the SDL time management routines.
29 | */
30 |
31 | #include "SDL_stdinc.h"
32 | #include "SDL_error.h"
33 |
34 | #include "begin_code.h"
35 | /* Set up for C function definitions, even when using C++ */
36 | #ifdef __cplusplus
37 | extern "C" {
38 | #endif
39 |
40 | /**
41 | * \brief Get the number of milliseconds since the SDL library initialization.
42 | *
43 | * \note This value wraps if the program runs for more than ~49 days.
44 | */
45 | extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void);
46 |
47 | /**
48 | * \brief Compare SDL ticks values, and return true if A has passed B
49 | *
50 | * e.g. if you want to wait 100 ms, you could do this:
51 | * Uint32 timeout = SDL_GetTicks() + 100;
52 | * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) {
53 | * ... do work until timeout has elapsed
54 | * }
55 | */
56 | #define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0)
57 |
58 | /**
59 | * \brief Get the current value of the high resolution counter
60 | */
61 | extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void);
62 |
63 | /**
64 | * \brief Get the count per second of the high resolution counter
65 | */
66 | extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void);
67 |
68 | /**
69 | * \brief Wait a specified number of milliseconds before returning.
70 | */
71 | extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
72 |
73 | /**
74 | * Function prototype for the timer callback function.
75 | *
76 | * The callback function is passed the current timer interval and returns
77 | * the next timer interval. If the returned value is the same as the one
78 | * passed in, the periodic alarm continues, otherwise a new alarm is
79 | * scheduled. If the callback returns 0, the periodic alarm is cancelled.
80 | */
81 | typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param);
82 |
83 | /**
84 | * Definition of the timer ID type.
85 | */
86 | typedef int SDL_TimerID;
87 |
88 | /**
89 | * \brief Add a new timer to the pool of timers already running.
90 | *
91 | * \return A timer ID, or NULL when an error occurs.
92 | */
93 | extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval,
94 | SDL_TimerCallback callback,
95 | void *param);
96 |
97 | /**
98 | * \brief Remove a timer knowing its ID.
99 | *
100 | * \return A boolean value indicating success or failure.
101 | *
102 | * \warning It is not safe to remove a timer multiple times.
103 | */
104 | extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id);
105 |
106 |
107 | /* Ends C function definitions when using C++ */
108 | #ifdef __cplusplus
109 | }
110 | #endif
111 | #include "close_code.h"
112 |
113 | #endif /* _SDL_timer_h */
114 |
115 | /* vi: set ts=4 sw=4 expandtab: */
116 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_touch.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_touch.h
24 | *
25 | * Include file for SDL touch event handling.
26 | */
27 |
28 | #ifndef _SDL_touch_h
29 | #define _SDL_touch_h
30 |
31 | #include "SDL_stdinc.h"
32 | #include "SDL_error.h"
33 | #include "SDL_video.h"
34 |
35 | #include "begin_code.h"
36 | /* Set up for C function definitions, even when using C++ */
37 | #ifdef __cplusplus
38 | extern "C" {
39 | #endif
40 |
41 | typedef Sint64 SDL_TouchID;
42 | typedef Sint64 SDL_FingerID;
43 |
44 | typedef struct SDL_Finger
45 | {
46 | SDL_FingerID id;
47 | float x;
48 | float y;
49 | float pressure;
50 | } SDL_Finger;
51 |
52 | /* Used as the device ID for mouse events simulated with touch input */
53 | #define SDL_TOUCH_MOUSEID ((Uint32)-1)
54 |
55 |
56 | /* Function prototypes */
57 |
58 | /**
59 | * \brief Get the number of registered touch devices.
60 | */
61 | extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void);
62 |
63 | /**
64 | * \brief Get the touch ID with the given index, or 0 if the index is invalid.
65 | */
66 | extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index);
67 |
68 | /**
69 | * \brief Get the number of active fingers for a given touch device.
70 | */
71 | extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID);
72 |
73 | /**
74 | * \brief Get the finger object of the given touch, with the given index.
75 | */
76 | extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index);
77 |
78 | /* Ends C function definitions when using C++ */
79 | #ifdef __cplusplus
80 | }
81 | #endif
82 | #include "close_code.h"
83 |
84 | #endif /* _SDL_touch_h */
85 |
86 | /* vi: set ts=4 sw=4 expandtab: */
87 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_types.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_types.h
24 | *
25 | * \deprecated
26 | */
27 |
28 | /* DEPRECATED */
29 | #include "SDL_stdinc.h"
30 |
--------------------------------------------------------------------------------
/emscripten/SDL2/SDL_version.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file SDL_version.h
24 | *
25 | * This header defines the current SDL version.
26 | */
27 |
28 | #ifndef _SDL_version_h
29 | #define _SDL_version_h
30 |
31 | #include "SDL_stdinc.h"
32 |
33 | #include "begin_code.h"
34 | /* Set up for C function definitions, even when using C++ */
35 | #ifdef __cplusplus
36 | extern "C" {
37 | #endif
38 |
39 | /**
40 | * \brief Information the version of SDL in use.
41 | *
42 | * Represents the library's version as three levels: major revision
43 | * (increments with massive changes, additions, and enhancements),
44 | * minor revision (increments with backwards-compatible changes to the
45 | * major revision), and patchlevel (increments with fixes to the minor
46 | * revision).
47 | *
48 | * \sa SDL_VERSION
49 | * \sa SDL_GetVersion
50 | */
51 | typedef struct SDL_version
52 | {
53 | Uint8 major; /**< major version */
54 | Uint8 minor; /**< minor version */
55 | Uint8 patch; /**< update version */
56 | } SDL_version;
57 |
58 | /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
59 | */
60 | #define SDL_MAJOR_VERSION 2
61 | #define SDL_MINOR_VERSION 0
62 | #define SDL_PATCHLEVEL 4
63 |
64 | /**
65 | * \brief Macro to determine SDL version program was compiled against.
66 | *
67 | * This macro fills in a SDL_version structure with the version of the
68 | * library you compiled against. This is determined by what header the
69 | * compiler uses. Note that if you dynamically linked the library, you might
70 | * have a slightly newer or older version at runtime. That version can be
71 | * determined with SDL_GetVersion(), which, unlike SDL_VERSION(),
72 | * is not a macro.
73 | *
74 | * \param x A pointer to a SDL_version struct to initialize.
75 | *
76 | * \sa SDL_version
77 | * \sa SDL_GetVersion
78 | */
79 | #define SDL_VERSION(x) \
80 | { \
81 | (x)->major = SDL_MAJOR_VERSION; \
82 | (x)->minor = SDL_MINOR_VERSION; \
83 | (x)->patch = SDL_PATCHLEVEL; \
84 | }
85 |
86 | /**
87 | * This macro turns the version numbers into a numeric value:
88 | * \verbatim
89 | (1,2,3) -> (1203)
90 | \endverbatim
91 | *
92 | * This assumes that there will never be more than 100 patchlevels.
93 | */
94 | #define SDL_VERSIONNUM(X, Y, Z) \
95 | ((X)*1000 + (Y)*100 + (Z))
96 |
97 | /**
98 | * This is the version number macro for the current SDL version.
99 | */
100 | #define SDL_COMPILEDVERSION \
101 | SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
102 |
103 | /**
104 | * This macro will evaluate to true if compiled with SDL at least X.Y.Z.
105 | */
106 | #define SDL_VERSION_ATLEAST(X, Y, Z) \
107 | (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
108 |
109 | /**
110 | * \brief Get the version of SDL that is linked against your program.
111 | *
112 | * If you are linking to SDL dynamically, then it is possible that the
113 | * current version will be different than the version you compiled against.
114 | * This function returns the current version, while SDL_VERSION() is a
115 | * macro that tells you what version you compiled with.
116 | *
117 | * \code
118 | * SDL_version compiled;
119 | * SDL_version linked;
120 | *
121 | * SDL_VERSION(&compiled);
122 | * SDL_GetVersion(&linked);
123 | * printf("We compiled against SDL version %d.%d.%d ...\n",
124 | * compiled.major, compiled.minor, compiled.patch);
125 | * printf("But we linked against SDL version %d.%d.%d.\n",
126 | * linked.major, linked.minor, linked.patch);
127 | * \endcode
128 | *
129 | * This function may be called safely at any time, even before SDL_Init().
130 | *
131 | * \sa SDL_VERSION
132 | */
133 | extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver);
134 |
135 | /**
136 | * \brief Get the code revision of SDL that is linked against your program.
137 | *
138 | * Returns an arbitrary string (a hash value) uniquely identifying the
139 | * exact revision of the SDL library in use, and is only useful in comparing
140 | * against other revisions. It is NOT an incrementing number.
141 | */
142 | extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
143 |
144 | /**
145 | * \brief Get the revision number of SDL that is linked against your program.
146 | *
147 | * Returns a number uniquely identifying the exact revision of the SDL
148 | * library in use. It is an incrementing number based on commits to
149 | * hg.libsdl.org.
150 | */
151 | extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void);
152 |
153 |
154 | /* Ends C function definitions when using C++ */
155 | #ifdef __cplusplus
156 | }
157 | #endif
158 | #include "close_code.h"
159 |
160 | #endif /* _SDL_version_h */
161 |
162 | /* vi: set ts=4 sw=4 expandtab: */
163 |
--------------------------------------------------------------------------------
/emscripten/SDL2/begin_code.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file begin_code.h
24 | *
25 | * This file sets things up for C dynamic library function definitions,
26 | * static inlined functions, and structures aligned at 4-byte alignment.
27 | * If you don't like ugly C preprocessor code, don't look at this file. :)
28 | */
29 |
30 | /* This shouldn't be nested -- included it around code only. */
31 | #ifdef _begin_code_h
32 | #error Nested inclusion of begin_code.h
33 | #endif
34 | #define _begin_code_h
35 |
36 | #ifndef SDL_DEPRECATED
37 | # if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */
38 | # define SDL_DEPRECATED __attribute__((deprecated))
39 | # else
40 | # define SDL_DEPRECATED
41 | # endif
42 | #endif
43 |
44 | #ifndef SDL_UNUSED
45 | # ifdef __GNUC__
46 | # define SDL_UNUSED __attribute__((unused))
47 | # else
48 | # define SDL_UNUSED
49 | # endif
50 | #endif
51 |
52 | /* Some compilers use a special export keyword */
53 | #ifndef DECLSPEC
54 | # if defined(__WIN32__) || defined(__WINRT__)
55 | # ifdef __BORLANDC__
56 | # ifdef BUILD_SDL
57 | # define DECLSPEC
58 | # else
59 | # define DECLSPEC __declspec(dllimport)
60 | # endif
61 | # else
62 | # define DECLSPEC __declspec(dllexport)
63 | # endif
64 | # else
65 | # if defined(__GNUC__) && __GNUC__ >= 4
66 | # define DECLSPEC __attribute__ ((visibility("default")))
67 | # elif defined(__GNUC__) && __GNUC__ >= 2
68 | # define DECLSPEC __declspec(dllexport)
69 | # else
70 | # define DECLSPEC
71 | # endif
72 | # endif
73 | #endif
74 |
75 | /* By default SDL uses the C calling convention */
76 | #ifndef SDLCALL
77 | #if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
78 | #define SDLCALL __cdecl
79 | #else
80 | #define SDLCALL
81 | #endif
82 | #endif /* SDLCALL */
83 |
84 | /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
85 | #ifdef __SYMBIAN32__
86 | #undef DECLSPEC
87 | #define DECLSPEC
88 | #endif /* __SYMBIAN32__ */
89 |
90 | /* Force structure packing at 4 byte alignment.
91 | This is necessary if the header is included in code which has structure
92 | packing set to an alternate value, say for loading structures from disk.
93 | The packing is reset to the previous value in close_code.h
94 | */
95 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
96 | #ifdef _MSC_VER
97 | #pragma warning(disable: 4103)
98 | #endif
99 | #ifdef __BORLANDC__
100 | #pragma nopackwarning
101 | #endif
102 | #ifdef _M_X64
103 | /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */
104 | #pragma pack(push,8)
105 | #else
106 | #pragma pack(push,4)
107 | #endif
108 | #endif /* Compiler needs structure packing set */
109 |
110 | #ifndef SDL_INLINE
111 | #if defined(__GNUC__)
112 | #define SDL_INLINE __inline__
113 | #elif defined(_MSC_VER) || defined(__BORLANDC__) || \
114 | defined(__DMC__) || defined(__SC__) || \
115 | defined(__WATCOMC__) || defined(__LCC__) || \
116 | defined(__DECC)
117 | #define SDL_INLINE __inline
118 | #ifndef __inline__
119 | #define __inline__ __inline
120 | #endif
121 | #else
122 | #define SDL_INLINE inline
123 | #ifndef __inline__
124 | #define __inline__ inline
125 | #endif
126 | #endif
127 | #endif /* SDL_INLINE not defined */
128 |
129 | #ifndef SDL_FORCE_INLINE
130 | #if defined(_MSC_VER)
131 | #define SDL_FORCE_INLINE __forceinline
132 | #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
133 | #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
134 | #else
135 | #define SDL_FORCE_INLINE static SDL_INLINE
136 | #endif
137 | #endif /* SDL_FORCE_INLINE not defined */
138 |
139 | /* Apparently this is needed by several Windows compilers */
140 | #if !defined(__MACH__)
141 | #ifndef NULL
142 | #ifdef __cplusplus
143 | #define NULL 0
144 | #else
145 | #define NULL ((void *)0)
146 | #endif
147 | #endif /* NULL */
148 | #endif /* ! Mac OS X - breaks precompiled headers */
149 |
--------------------------------------------------------------------------------
/emscripten/SDL2/close_code.h:
--------------------------------------------------------------------------------
1 | /*
2 | Simple DirectMedia Layer
3 | Copyright (C) 1997-2014 Sam Lantinga
4 |
5 | This software is provided 'as-is', without any express or implied
6 | warranty. In no event will the authors be held liable for any damages
7 | arising from the use of this software.
8 |
9 | Permission is granted to anyone to use this software for any purpose,
10 | including commercial applications, and to alter it and redistribute it
11 | freely, subject to the following restrictions:
12 |
13 | 1. The origin of this software must not be misrepresented; you must not
14 | claim that you wrote the original software. If you use this software
15 | in a product, an acknowledgment in the product documentation would be
16 | appreciated but is not required.
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 | 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | /**
23 | * \file close_code.h
24 | *
25 | * This file reverses the effects of begin_code.h and should be included
26 | * after you finish any function and structure declarations in your headers
27 | */
28 |
29 | #undef _begin_code_h
30 |
31 | /* Reset structure packing at previous byte alignment */
32 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
33 | #ifdef __BORLANDC__
34 | #pragma nopackwarning
35 | #endif
36 | #pragma pack(pop)
37 | #endif /* Compiler needs structure packing set */
38 |
--------------------------------------------------------------------------------
/emscripten/libSDL2.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/def-/nimes/baefb72c290471f5b487910e1545614b9a3d24b3/emscripten/libSDL2.a
--------------------------------------------------------------------------------
/emscripten/readme.md:
--------------------------------------------------------------------------------
1 | This is just here for easier building with emscripten.
2 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015 Dennis Felsing
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/nakefile.nim:
--------------------------------------------------------------------------------
1 | import nake
2 | import os
3 |
4 | task "desktop", "Builds NimES for Desktop":
5 | shell "nim -d:release c src/nimes"
6 |
7 | task "web", "Builds NimES for the Web":
8 | shell "nim -d:release -d:emscripten c src/nimes"
9 |
10 | task "android", "Builds NimES for Android":
11 | shell "nim -d:release -d:android c src/nimes"
12 | shell "cd android && ndk-build"
13 | shell "cd android && ant debug"
14 |
15 | task "clean", "Removes build files":
16 | removeDir "nimcache"
17 | removeDir "src/nimcache"
18 |
19 | removeFile "src/nimes"
20 | removeFile "src/nimes.js"
21 | removeFile "src/nimes.html"
22 | removeFile "src/nimes.html.mem"
23 | removeFile "src/nimes.data"
24 |
25 | removeDir "android/bin"
26 | removeDir "android/gen"
27 | removeDir "android/libs"
28 | removeDir "android/obj"
29 | for file in walkFiles "android/jni/src/*.c":
30 | removeFile file
31 |
--------------------------------------------------------------------------------
/nimes.nimble:
--------------------------------------------------------------------------------
1 | # Package
2 |
3 | version = "0.1"
4 | author = "Dennis Felsing"
5 | description = "NimES: NES Emulator in Nim"
6 | license = "MIT"
7 |
8 | srcDir = "src"
9 | bin = @["nimes"]
10 | skipExt = @["nim"]
11 |
12 | # Dependencies
13 |
14 | requires "nim >= 0.12.0"
15 | requires "sdl2 >= 1.0"
16 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # NimES: NES emulator in Nim [](https://circleci.com/gh/def-/nimes)
2 |
3 | This is a NES emulator written in the [Nim](http://nim-lang.org/) programming
4 | language. I made it mainly for fun and demonstration purposes. Nim can be used
5 | to write elegant and performant code and have it run almost anywhere, including
6 | Android and JavaScript. You can build the emulator natively (should work on
7 | Linux, Mac OS X, Windows and other platforms supporting SDL2), build it to
8 | Android or use the [JavaScript](http://hookrace.net/nimes/) version that is
9 | compiled from the same source code with the help of emscripten.
10 |
11 | ## [Live Demo](http://hookrace.net/nimes/)
12 |
13 |    
14 |
15 | ## Building
16 |
17 | You need [Nim 0.11](http://nim-lang.org/download.html) or [devel](https://github.com/Araq/Nim) and the SDL2 development libraries ([Windows, Mac OS X download](https://www.libsdl.org/download-2.0.php)) installed on your system:
18 |
19 | apt-get install libsdl2-dev # Ubuntu/Debian (wheezy-backports for Debian 7)
20 | brew install sdl2 # Mac OS X with homebrew
21 | yum install SDL2-devel # Fedora/CentOS
22 | pacman -S sdl2 # Arch Linux
23 | emerge libsdl2 # Gentoo
24 |
25 | With [nimble](https://github.com/nim-lang/nimble) installed you can then install NimES:
26 |
27 | nimble install nimes
28 |
29 | There are a few possibilities to build NimES if you got the source already:
30 |
31 | nimble install # installs nimes into ~/.nimble/bin OR
32 | nimble build # builds the binary in src/nimes OR
33 | nim -d:release c src/nimes # same without nimble
34 |
35 | $ nimes
36 | Usage: nimes
37 |
38 | If you don't want to use nimble, you'll have to get Nim's [SDL2
39 | wrapper](https://github.com/nim-lang/sdl2) manually.
40 |
41 | You can also use [nake](https://github.com/fowlmouth/nake) for building:
42 |
43 | $ nake
44 | Available tasks:
45 | desktop - Builds NimES for Desktop
46 | web - Builds NimES for the Web
47 | android - Builds NimES for Android
48 | clean - Removes build files
49 |
50 | ## Building with Emscripten
51 |
52 | Building to JavaScript is a bit more complicated. You need the [Emscripten SDK](https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html) installed.
53 |
54 | nim -d:release -d:emscripten c src/nimes
55 |
56 | You need the files `tetris.nes, pacman.nes, smb.nes, smb3.nes` available for this.
57 |
58 | ## Building for Android
59 |
60 | You need the Android SDK (12 or later) and NDK (7 or later) installed. So far NimES on Android only opens a predefined `smb3.nes` and controls don't even work. This is mainly to demonstrate that it could easily be ported to Android.
61 |
62 | nim -d:release -d:android c src/nimes
63 | cd android
64 | ndk-build
65 | ant debug
66 |
67 | The resulting apk is in `bin/org.nimes-debug.apk`. You can try this [nimes.apk](http://hookrace.net/nimes/nimes.apk). Some work will be necessary to improve the performance of the program as well as implement Android controls.
68 |
69 | Porting to Android was pretty simple by following [this guide](https://wiki.libsdl.org/Android).
70 |
71 | ## Controls
72 |
73 | | Key | Action |
74 | | ----- | ------------------------ |
75 | | ←↑↓→ | ←↑↓→ |
76 | | Z/Y | A |
77 | | X | B |
78 | | Enter | Start |
79 | | Space | Select |
80 | | 1-5 | Zoom 1-5× |
81 | | R | Reset |
82 | | P | Pause |
83 | | M | Mute |
84 | | F | 250% speed while pressed |
85 | | F9 | Reset speed |
86 | | F10 | Speed - 5% |
87 | | F11 | Speed + 5% |
88 |
89 | ## TODO / What's missing
90 |
91 | - Loading screen to select games (also in emscripten)
92 | - Second player
93 | - Settings for controls/gamepad/joystick
94 | - Saving
95 | - Android
96 | - Performance could be improved significantly by making PPU render by scanline, not by pixel
97 | - More mappers (0,1,2,3,4,7 working, [NES mapper list](http://tuxnes.sourceforge.net/nesmapper.txt))
98 | - PAL video (NTSC only currently)
99 |
100 | ## Source code information
101 |
102 | The NES emulation code largely follows fogleman's excellent [NES emulator in
103 | Go](https://github.com/fogleman/nes) as well as these info materials and some
104 | other emulators:
105 |
106 | - https://web.archive.org/web/20150909055529/http://www.obelisk.demon.co.uk/6502/
107 | - http://nesdev.com/
108 |
--------------------------------------------------------------------------------
/src/nes.nim:
--------------------------------------------------------------------------------
1 | import nes/types, nes/cpu, nes/apu, nes/ppu, nes/cartridge, nes/controller,
2 | nes/mapper
3 |
4 | export types.NES, types.NESObj, types.Buttons, setButtons, resolution
5 |
6 | proc newNES*(path: string): NES =
7 | new result
8 | try:
9 | result.cartridge = newCartridge(path)
10 | except ValueError:
11 | raise newException(ValueError,
12 | "failed to open " & path & ": " & getCurrentExceptionMsg())
13 | result.mapper = newMapper(result)
14 | result.cpu = initCPU(result)
15 | result.apu = initAPU(result)
16 | result.ppu = initPPU(result)
17 |
18 | proc reset*(nes: NES) =
19 | nes.cpu.reset()
20 | nes.ppu.reset()
21 |
22 | proc step*(nes: NES): int =
23 | result = nes.cpu.step()
24 |
25 | for i in 1 .. result*3:
26 | nes.ppu.step()
27 | nes.mapper.step(nes.mapper)
28 |
29 | when not defined(emscripten):
30 | for i in 1 .. result:
31 | nes.apu.step()
32 |
33 | proc run*(nes: NES, seconds: float) =
34 | var cycles = int(cpu.frequency * seconds)
35 | while cycles > 0:
36 | cycles -= nes.step()
37 |
38 | proc buffer*(nes: NES): var Picture =
39 | nes.ppu.front
40 |
--------------------------------------------------------------------------------
/src/nes/cartridge.nim:
--------------------------------------------------------------------------------
1 | import types
2 |
3 | export types.Cartridge
4 |
5 | const iNESMagic = 0x1A53454E
6 |
7 | type iNESHeader {.packed.} = object
8 | magic: uint32
9 | numPRG, numCHR, control1, control2, numRAM: uint8
10 | padding: array[7, uint8]
11 |
12 | when not defined(android):
13 | proc newCartridge*(path: string): Cartridge =
14 | new result
15 |
16 | var file = open path
17 | defer: close file
18 |
19 | var header: iNESHeader
20 | # Read directly into the header object
21 | if file.readBuffer(addr header, sizeof header) != sizeof header:
22 | raise newException(ValueError, "header can't be read")
23 |
24 | if header.magic != iNESMagic:
25 | raise newException(ValueError, "header not conforming to iNES format")
26 |
27 | let
28 | mapper1 = header.control1 shr 4
29 | mapper2 = header.control2 shr 4
30 | result.mapper = mapper1 or (mapper2 shl 4)
31 |
32 | let
33 | mirror1 = header.control1 and 1
34 | mirror2 = (header.control1 shr 3) and 1
35 | result.mirror = mirror1 or (mirror2 shl 1'u8)
36 |
37 | result.battery = ((header.control1 shr 1) and 1) != 0
38 |
39 | result.prg = newSeq[uint8](header.numPRG.int * 16384)
40 | result.chr = newSeq[uint8](header.numCHR.int * 8192)
41 |
42 | if (header.control1 and 4) == 4:
43 | var trainer: array[512, uint8]
44 | if file.readBytes(trainer, 0, trainer.len) != trainer.len:
45 | raise newException(ValueError, "Trainer can't be read")
46 |
47 | if file.readBytes(result.prg, 0, result.prg.len) != result.prg.len:
48 | raise newException(ValueError, "PRG ROM can't be read")
49 |
50 | if header.numCHR == 0:
51 | result.chr.setLen(8192)
52 | elif file.readBytes(result.chr, 0, result.chr.len) != result.chr.len:
53 | raise newException(ValueError, "CHR ROM can't be read")
54 |
55 | else:
56 | # Just a hack for Android
57 | # TODO: Unify with proper proc if we get real Android support
58 |
59 | from sdl2 import rwFromFile, read, freeRW
60 |
61 | proc newCartridge*(path: string): Cartridge =
62 | new result
63 |
64 | var file = rwFromFile(path.cstring, "r")
65 | defer: freeRW file
66 |
67 | var header: iNESHeader
68 | # Read directly into the header object
69 | if read(file, addr header, 1, sizeof header) != sizeof header:
70 | raise newException(ValueError, "header can't be read")
71 |
72 | if header.magic != iNESMagic:
73 | raise newException(ValueError, "header not conforming to iNES format")
74 |
75 | let
76 | mapper1 = header.control1 shr 4
77 | mapper2 = header.control2 shr 4
78 | result.mapper = mapper1 or (mapper2 shl 4)
79 |
80 | let
81 | mirror1 = header.control1 and 1
82 | mirror2 = (header.control1 shr 3) and 1
83 | result.mirror = mirror1 or (mirror2 shl 1'u8)
84 |
85 | result.battery = ((header.control1 shr 1) and 1) != 0
86 |
87 | result.prg = newSeq[uint8](header.numPRG.int * 16384)
88 | result.chr = newSeq[uint8](header.numCHR.int * 8192)
89 |
90 | if (header.control1 and 4) == 4:
91 | var trainer: array[512, uint8]
92 | if read(file, addr trainer[0], 1, trainer.len) != trainer.len:
93 | raise newException(ValueError, "Trainer can't be read")
94 |
95 | if read(file, addr result.prg[0], 1, result.prg.len) != result.prg.len:
96 | raise newException(ValueError, "PRG ROM can't be read")
97 |
98 | if header.numCHR == 0:
99 | result.chr.setLen(8192)
100 | elif read(file, addr result.chr[0], 1, result.chr.len) != result.chr.len:
101 | raise newException(ValueError, "CHR ROM can't be read")
102 |
--------------------------------------------------------------------------------
/src/nes/controller.nim:
--------------------------------------------------------------------------------
1 | import types
2 |
3 | export types.Controller, types.Buttons
4 |
5 | proc read*(c: var Controller): uint8 =
6 | if c.index < 8 and c.buttons[c.index]:
7 | result = 1
8 | inc c.index
9 | if (c.strobe and 1) == 1:
10 | c.index = 0
11 |
12 | proc write*(c: var Controller, val: uint8) =
13 | c.strobe = val
14 | if (c.strobe and 1) == 1:
15 | c.index = 0
16 |
17 | proc setButtons*(c: var Controller, buttons: Buttons) =
18 | c.buttons = buttons
19 |
--------------------------------------------------------------------------------
/src/nes/mapper.nim:
--------------------------------------------------------------------------------
1 | import types, mapper1, mapper2, mapper3, mapper4, mapper7
2 |
3 | proc newMapper*(nes: NES): Mapper =
4 | result = case nes.cartridge.mapper
5 | of 0, 2: newMapper2(nes.cartridge)
6 | of 1: newMapper1(nes.cartridge)
7 | of 3: newMapper3(nes.cartridge)
8 | of 4: newMapper4(nes.cartridge, nes)
9 | of 7: newMapper7(nes.cartridge)
10 | else: raise newException(ValueError, "unknown mapper " & $nes.cartridge.mapper)
11 |
12 | template step*(m: Mapper) =
13 | m.step(m)
14 |
15 | template `[]`*(m: Mapper, adr: uint16): uint8 =
16 | m.idx(m, adr)
17 |
18 | template `[]=`*(m: Mapper, adr: uint16, val: uint8) =
19 | m.idxSet(m, adr, val)
20 |
--------------------------------------------------------------------------------
/src/nes/mapper1.nim:
--------------------------------------------------------------------------------
1 | import types
2 |
3 | type Mapper1* = ref object of Mapper
4 | cartridge: Cartridge
5 | shiftRegister, control, prgMode, chrMode, prgBank, chrBank0, chrBank1: uint8
6 | prgOffsets, chrOffsets: array[0..1, int]
7 |
8 | proc prgBankOffset(m: Mapper1, index: int): int =
9 | var index = if index >= 0x80: index - 0x100 else: index
10 | index = index mod (m.cartridge.prg.len div 0x4000)
11 | result = index * 0x4000
12 | if result < 0:
13 | result += m.cartridge.prg.len
14 |
15 | proc chrBankOffset(m: Mapper1, index: int): int =
16 | var index = if index >= 0x80: index - 0x100 else: index
17 | index = index mod (m.cartridge.chr.len div 0x1000)
18 | result = index * 0x1000
19 | if result < 0:
20 | result += m.cartridge.chr.len
21 |
22 | proc writeControl(m: Mapper1, val: uint8) =
23 | m.control = val
24 | m.chrMode = (val shr 4) and 1
25 | m.prgMode = (val shr 2) and 3
26 |
27 | case val and 3
28 | of 0: m.cartridge.mirror = mirrorSingle0.uint8
29 | of 1: m.cartridge.mirror = mirrorSingle1.uint8
30 | of 2: m.cartridge.mirror = mirrorVertical.uint8
31 | of 3: m.cartridge.mirror = mirrorHorizontal.uint8
32 | else: discard
33 |
34 | proc updateOffsets(m: Mapper1) =
35 | case m.prgMode
36 | of 0, 1:
37 | m.prgOffsets[0] = m.prgBankOffset(int(m.prgBank and 0xFE))
38 | m.prgOffsets[1] = m.prgBankOffset(int(m.prgBank or 0x01))
39 | of 2:
40 | m.prgOffsets[0] = 0
41 | m.prgOffsets[1] = m.prgBankOffset(m.prgBank.int)
42 | of 3:
43 | m.prgOffsets[0] = m.prgBankOffset(m.prgBank.int)
44 | m.prgOffsets[1] = m.prgBankOffset(-1)
45 | else: discard
46 |
47 | case m.chrMode
48 | of 0:
49 | m.chrOffsets[0] = m.chrBankOffset(int(m.chrBank0 and 0xFE))
50 | m.chrOffsets[1] = m.chrBankOffset(int(m.chrBank0 or 0x01))
51 | of 1:
52 | m.chrOffsets[0] = m.chrBankOffset(m.chrBank0.int)
53 | m.chrOffsets[1] = m.chrBankOffset(m.chrBank1.int)
54 | else: discard
55 |
56 | proc writeRegister(m: Mapper1, adr: uint16, val: uint8) =
57 | case adr
58 | of 0x0000..0x9FFF: m.writeControl(val)
59 | of 0xA000..0xBFFF: m.chrBank0 = val
60 | of 0xC000..0xDFFF: m.chrBank1 = val
61 | of 0xE000..0xFFFF: m.prgBank = val and 0x0F
62 | m.updateOffsets()
63 |
64 | proc loadRegister(m: Mapper1, adr: uint16, val: uint8) =
65 | if (val and 0x80) == 0x80:
66 | m.shiftRegister = 0x10
67 | m.writeControl(m.control and 0x0C)
68 | m.updateOffsets()
69 | else:
70 | let complete = (m.shiftRegister and 1) == 1
71 | m.shiftRegister = (m.shiftRegister shr 1) or (uint8(val and 1) shl 4)
72 | if complete:
73 | m.writeRegister(adr, m.shiftRegister)
74 | m.shiftRegister = 0x10
75 |
76 | proc step(m: Mapper) =
77 | discard
78 |
79 | proc idx(m: Mapper, adr: uint16): uint8 =
80 | var m = Mapper1(m)
81 | case adr
82 | of 0x0000..0x1FFF:
83 | let bank = adr div 0x1000
84 | let offset = adr mod 0x1000
85 | result = m.cartridge.chr[m.chrOffsets[bank]+offset.int]
86 | of 0x6000..0x7FFF: result = m.cartridge.sram[adr.int - 0x6000]
87 | of 0x8000..0xFFFF:
88 | let adr = adr - 0x8000
89 | let bank = adr div 0x4000
90 | let offset = adr mod 0x4000
91 | result = m.cartridge.prg[m.prgOffsets[bank]+offset.int]
92 | else: raise newException(ValueError, "unhandled mapper1 read at: " & $adr)
93 |
94 | proc idxSet(m: Mapper, adr: uint16, val: uint8) =
95 | var m = Mapper1(m)
96 | case adr
97 | of 0x0000..0x1FFF:
98 | let bank = adr div 0x1000
99 | let offset = adr mod 0x1000
100 | m.cartridge.chr[m.chrOffsets[bank]+offset.int] = val
101 | of 0x6000..0x7FFF: m.cartridge.sram[adr.int - 0x6000] = val
102 | of 0x8000..0xFFFF: m.loadRegister(adr, val)
103 | else: raise newException(ValueError, "unhandled mapper1 write at: " & $adr)
104 |
105 | proc newMapper1*(cartridge: Cartridge): Mapper1 =
106 | new result
107 | result.cartridge = cartridge
108 | result.shiftRegister = 0x10
109 | result.prgOffsets[1] = result.prgBankOffset(-1)
110 | result.idx = idx
111 | result.idxSet = idxSet
112 | result.step = step
113 |
--------------------------------------------------------------------------------
/src/nes/mapper2.nim:
--------------------------------------------------------------------------------
1 | import types
2 |
3 | type Mapper2* = ref object of Mapper
4 | cartridge: Cartridge
5 | prgBanks, prgBank1, prgBank2: int
6 |
7 | proc step(m: Mapper) =
8 | discard
9 |
10 | proc idx(m: Mapper, adr: uint16): uint8 =
11 | var m = Mapper2(m)
12 | case adr
13 | of 0x0000..0x1FFF: result = m.cartridge.chr[adr.int]
14 | of 0x6000..0x7FFF: result = m.cartridge.sram[adr.int - 0x6000]
15 | of 0x8000..0xBFFF: result = m.cartridge.prg[m.prgBank1*0x4000 + int(adr - 0x8000)]
16 | of 0xC000..0xFFFF: result = m.cartridge.prg[m.prgBank2*0x4000 + int(adr - 0xC000)]
17 | else: raise newException(ValueError, "unhandled mapper2 read at: " & $adr)
18 |
19 | proc idxSet(m: Mapper, adr: uint16, val: uint8) =
20 | var m = Mapper2(m)
21 | case adr
22 | of 0x0000..0x1FFF: m.cartridge.chr[adr.int] = val
23 | of 0x6000..0x7FFF: m.cartridge.sram[adr.int - 0x6000] = val
24 | of 0x8000..0xFFFF: m.prgBank1 = val.int mod m.prgBanks
25 | else: raise newException(ValueError, "unhandled mapper2 write at: " & $adr)
26 |
27 | proc newMapper2*(cartridge: Cartridge): Mapper2 =
28 | result = Mapper2(
29 | cartridge: cartridge,
30 | prgBanks: cartridge.prg.len div 0x4000,
31 | prgBank1: 0,
32 | prgBank2: cartridge.prg.len div 0x4000 - 1,
33 | step: step,
34 | idx: idx,
35 | idxSet: idxSet
36 | )
37 |
--------------------------------------------------------------------------------
/src/nes/mapper3.nim:
--------------------------------------------------------------------------------
1 | import types
2 |
3 | type Mapper3* = ref object of Mapper
4 | cartridge: Cartridge
5 | chrBank, prgBank1, prgBank2: int
6 |
7 | proc step(m: Mapper) =
8 | discard
9 |
10 | proc idx(m: Mapper, adr: uint16): uint8 =
11 | var m = Mapper3(m)
12 | case adr
13 | of 0x0000..0x1FFF: result = m.cartridge.chr[adr.int]
14 | of 0x6000..0x7FFF: result = m.cartridge.sram[adr.int - 0x6000]
15 | of 0x8000..0xBFFF: result = m.cartridge.prg[m.prgBank1*0x4000 + int(adr - 0x8000)]
16 | of 0xC000..0xFFFF: result = m.cartridge.prg[m.prgBank2*0x4000 + int(adr - 0xC000)]
17 | else: raise newException(ValueError, "unhandled mapper3 read at: " & $adr)
18 |
19 | proc idxSet(m: Mapper, adr: uint16, val: uint8) =
20 | var m = Mapper3(m)
21 | case adr
22 | of 0x0000..0x1FFF: m.cartridge.chr[m.chrBank*0x2000 + adr.int] = val
23 | of 0x6000..0x7FFF: m.cartridge.sram[adr.int - 0x6000] = val
24 | of 0x8000..0xFFFF: m.prgBank1 = val.int and 3
25 | else: raise newException(ValueError, "unhandled mapper3 write at: " & $adr)
26 |
27 | proc newMapper3*(cartridge: Cartridge): Mapper3 =
28 | new result
29 | result.cartridge = cartridge
30 | let prgBanks = cartridge.prg.len div 0x4000
31 | result.chrBank = 0
32 | result.prgBank1 = 0
33 | result.prgBank2 = prgBanks - 1
34 | result.idx = idx
35 | result.idxSet = idxSet
36 | result.step = step
37 |
--------------------------------------------------------------------------------
/src/nes/mapper4.nim:
--------------------------------------------------------------------------------
1 | import types
2 |
3 | type Mapper4* = ref object of Mapper
4 | cartridge: Cartridge
5 | nes: NES
6 | register, prgMode, chrMode, reload, counter: uint8
7 | registers: array[0..7, uint8]
8 | prgOffsets: array[0..3, int]
9 | chrOffsets: array[0..7, int]
10 | irqEnable: bool
11 |
12 | proc prgBankOffset(m: Mapper4, index: int): int =
13 | var index = if index >= 0x80: index - 0x100 else: index
14 | index = index mod (m.cartridge.prg.len div 0x2000)
15 | result = index * 0x2000
16 | if result < 0:
17 | result += m.cartridge.prg.len
18 |
19 | proc chrBankOffset(m: Mapper4, index: int): int =
20 | var index = if index >= 0x80: index - 0x100 else: index
21 | index = index mod (m.cartridge.chr.len div 0x0400)
22 | result = index * 0x0400
23 | if result < 0:
24 | result += m.cartridge.chr.len
25 |
26 | proc updateOffsets(m: Mapper4) =
27 | case m.prgMode
28 | of 0:
29 | m.prgOffsets[0] = m.prgBankOffset(m.registers[6].int)
30 | m.prgOffsets[1] = m.prgBankOffset(m.registers[7].int)
31 | m.prgOffsets[2] = m.prgBankOffset(-2)
32 | m.prgOffsets[3] = m.prgBankOffset(-1)
33 | of 1:
34 | m.prgOffsets[0] = m.prgBankOffset(-2)
35 | m.prgOffsets[1] = m.prgBankOffset(m.registers[7].int)
36 | m.prgOffsets[2] = m.prgBankOffset(m.registers[6].int)
37 | m.prgOffsets[3] = m.prgBankOffset(-1)
38 | else: discard
39 |
40 | case m.chrMode
41 | of 0:
42 | m.chrOffsets[0] = m.chrBankOffset(int(m.registers[0] and 0xFE))
43 | m.chrOffsets[1] = m.chrBankOffset(int(m.registers[0] or 0x01))
44 | m.chrOffsets[2] = m.chrBankOffset(int(m.registers[1] and 0xFE))
45 | m.chrOffsets[3] = m.chrBankOffset(int(m.registers[1] or 0x01))
46 | m.chrOffsets[4] = m.chrBankOffset(m.registers[2].int)
47 | m.chrOffsets[5] = m.chrBankOffset(m.registers[3].int)
48 | m.chrOffsets[6] = m.chrBankOffset(m.registers[4].int)
49 | m.chrOffsets[7] = m.chrBankOffset(m.registers[5].int)
50 | of 1:
51 | m.chrOffsets[0] = m.chrBankOffset(m.registers[2].int)
52 | m.chrOffsets[1] = m.chrBankOffset(m.registers[3].int)
53 | m.chrOffsets[2] = m.chrBankOffset(m.registers[4].int)
54 | m.chrOffsets[3] = m.chrBankOffset(m.registers[5].int)
55 | m.chrOffsets[4] = m.chrBankOffset(int(m.registers[0] and 0xFE))
56 | m.chrOffsets[5] = m.chrBankOffset(int(m.registers[0] or 0x01))
57 | m.chrOffsets[6] = m.chrBankOffset(int(m.registers[1] and 0xFE))
58 | m.chrOffsets[7] = m.chrBankOffset(int(m.registers[1] or 0x01))
59 | else: discard
60 |
61 | proc writeBankSelect(m: Mapper4, val: uint8) =
62 | m.prgMode = (val shr 6) and 1
63 | m.chrMode = (val shr 7) and 1
64 | m.register = val and 7
65 |
66 | proc writeMirror(m: Mapper4, val: uint8) =
67 | case val and 1
68 | of 0: m.cartridge.mirror = mirrorVertical.uint8
69 | of 1: m.cartridge.mirror = mirrorHorizontal.uint8
70 | else: discard
71 |
72 | proc writeRegister(m: Mapper4, adr: uint16, val: uint8) =
73 | case adr
74 | of 0x0000..0x9FFF:
75 | if adr mod 2 == 0: m.writeBankSelect(val)
76 | else: m.registers[m.register] = val
77 | m.updateOffsets()
78 | of 0xA000..0xBFFF:
79 | if adr mod 2 == 0: m.writeMirror(val)
80 | else: discard # write protect
81 | of 0xC000..0xDFFF:
82 | if adr mod 2 == 0: m.reload = val
83 | else: m.counter = 0
84 | of 0xE000..0xFFFF:
85 | if adr mod 2 == 0: m.irqEnable = false
86 | else: m.irqEnable = true
87 |
88 | proc step(m: Mapper) =
89 | var m = Mapper4(m)
90 | let ppu = m.nes.ppu
91 |
92 | if ppu.cycle != 300:
93 | return
94 | if ppu.scanLine in 240..260:
95 | return
96 | if not ppu.flagShowBackground and not ppu.flagShowSprites:
97 | return
98 |
99 | if m.counter == 0:
100 | m.counter = m.reload
101 | else:
102 | dec m.counter
103 | if m.counter == 0 and m.irqEnable:
104 | m.nes.cpu.triggerIRQ()
105 |
106 | proc idx(m: Mapper, adr: uint16): uint8 =
107 | var m = Mapper4(m)
108 | case adr
109 | of 0x0000..0x1FFF:
110 | let bank = adr div 0x0400
111 | let offset = adr mod 0x0400
112 | result = m.cartridge.chr[m.chrOffsets[bank]+offset.int]
113 | of 0x6000..0x7FFF: result = m.cartridge.sram[adr.int - 0x6000]
114 | of 0x8000..0xFFFF:
115 | let adr = adr - 0x8000
116 | let bank = adr div 0x2000
117 | let offset = adr mod 0x2000
118 | result = m.cartridge.prg[m.prgOffsets[bank]+offset.int]
119 | else: raise newException(ValueError, "unhandled mapper4 read at: " & $adr)
120 |
121 | proc idxSet(m: Mapper, adr: uint16, val: uint8) =
122 | var m = Mapper4(m)
123 | case adr
124 | of 0x0000..0x1FFF:
125 | let bank = adr div 0x0400
126 | let offset = adr mod 0x0400
127 | m.cartridge.chr[m.chrOffsets[bank]+offset.int] = val
128 | of 0x6000..0x7FFF: m.cartridge.sram[adr.int - 0x6000] = val
129 | of 0x8000..0xFFFF: m.writeRegister(adr, val)
130 | else: raise newException(ValueError, "unhandled mapper4 write at: " & $adr)
131 |
132 | proc newMapper4*(cartridge: Cartridge, nes: NES): Mapper4 =
133 | new result
134 | result.cartridge = cartridge
135 | result.nes = nes
136 | result.prgOffsets[0] = result.prgBankOffset(0)
137 | result.prgOffsets[1] = result.prgBankOffset(1)
138 | result.prgOffsets[2] = result.prgBankOffset(-2)
139 | result.prgOffsets[3] = result.prgBankOffset(-1)
140 | result.idx = idx
141 | result.idxSet = idxSet
142 | result.step = step
143 |
--------------------------------------------------------------------------------
/src/nes/mapper7.nim:
--------------------------------------------------------------------------------
1 | import types
2 |
3 | type Mapper7* = ref object of Mapper
4 | cartridge: Cartridge
5 | prgBank: int
6 |
7 | proc step(m: Mapper) =
8 | discard
9 |
10 | proc idx(m: Mapper, adr: uint16): uint8 =
11 | var m = Mapper7(m)
12 | case adr
13 | of 0x0000..0x1FFF: result = m.cartridge.chr[adr.int]
14 | of 0x6000..0x7FFF: result = m.cartridge.sram[adr.int - 0x6000]
15 | of 0x8000..0xFFFF: result = m.cartridge.prg[m.prgBank*0x8000 + int(adr - 0x8000)]
16 | else: raise newException(ValueError, "unhandled mapper7 read at: " & $adr)
17 |
18 | proc idxSet(m: Mapper, adr: uint16, val: uint8) =
19 | var m = Mapper7(m)
20 | case adr
21 | of 0x0000..0x1FFF: m.cartridge.chr[adr.int] = val
22 | of 0x6000..0x7FFF: m.cartridge.sram[adr.int - 0x6000] = val
23 | of 0x8000..0xFFFF:
24 | m.prgBank = int(val and 7)
25 | case val and 0x10
26 | of 0x00: m.cartridge.mirror = mirrorSingle0.uint8
27 | of 0x10: m.cartridge.mirror = mirrorSingle1.uint8
28 | else: discard
29 | else: raise newException(ValueError, "unhandled mapper7 write at: " & $adr)
30 |
31 | proc newMapper7*(cartridge: Cartridge): Mapper7 =
32 | new result
33 | result.cartridge = cartridge
34 | result.prgBank = 0
35 | result.idx = idx
36 | result.idxSet = idxSet
37 | result.step = step
38 |
--------------------------------------------------------------------------------
/src/nes/types.nim:
--------------------------------------------------------------------------------
1 | type
2 | NES* = ref NESObj
3 | NESObj* = object
4 | cpu*: CPU
5 | apu*: APU
6 | ppu*: PPU
7 | cartridge*: Cartridge
8 | controllers*: array[2, Controller]
9 | mapper*: Mapper
10 | ram*: array[2048'u16, uint8]
11 |
12 | CPU* = object
13 | mem*: CPUMemory
14 | cycles*: uint64
15 | pc*: uint16
16 | sp*, a*, x*, y*: uint8
17 | c*, z*, i*, d*, b*, u*, v*, n*: bool
18 | interrupt*: Interrupt
19 | stall*: int
20 |
21 | Interrupt* = enum iNone, iNMI, iIRQ
22 |
23 | CPUMemory* = ref object
24 | nes*: NES
25 |
26 | PPU* = object
27 | mem*: PPUMemory
28 | nes*: NES
29 |
30 | # Current state
31 | cycle*, scanLine*: int
32 | frame*: uint64
33 |
34 | # PPU memory
35 | paletteData*: array[32, uint8]
36 | nameTableData*: array[2048, uint8]
37 | oamData*: array[256, uint8]
38 | front*: Picture
39 | back*: ref Picture
40 |
41 | # Registers
42 | v*, t*: uint16
43 | x*, w*, f*, register*: uint8
44 |
45 | # NMI
46 | nmiOccured*, nmiOutput*, nmiPrevious*: bool
47 | nmiDelay*: uint8
48 |
49 | # Tiles
50 | nameTable*, attributeTable*, lowTile*, highTile*: uint8
51 | tileData*: uint64
52 |
53 | # Sprites
54 | spriteCount*: int
55 | spritePatterns*: array[8, uint32]
56 | spritePositions*, spritePriorities*, spriteIndices*: array[8, uint8]
57 |
58 | # $2000 PPU Control
59 | flagNameTable*: range[0'u8..3'u8]
60 | flagIncrement*, flagSpriteTable*, flagBackgroundTable*: bool
61 | flagSpriteSize*, flagMasterSlave*: bool
62 |
63 | # $2001 PPU Mask
64 | flagGrayscale*, flagShowLeftBackground*, flagShowLeftSprites*: bool
65 | flagShowBackground*, flagShowSprites*: bool
66 | flagRedTint*, flagGreenTint*, flagBlueTint*: bool
67 |
68 | # $2002 PPU Status
69 | flagSpriteZeroHit*, flagSpriteOverflow*: bool
70 |
71 | # $2003 OAM Address
72 | oamAddress*: uint8
73 |
74 | # Buffer for $2007 Data Read
75 | bufferedData*: uint8
76 |
77 | Color* = tuple[r, g, b, a: uint8]
78 |
79 | Picture* = array[240, array[256, Color]]
80 |
81 | PPUMemory* = ref object
82 | nes*: NES
83 |
84 | APU* = object
85 | nes*: NES
86 | chan*: array[4096, float32]
87 | chanPos*: int
88 |
89 | pulse*: array[2, Pulse]
90 | triangle*: Triangle
91 | noise*: Noise
92 | dmc*: DMC
93 | cycle*: uint64
94 | framePeriod*, frameValue*: uint8
95 | frameIRQ*: bool
96 |
97 | Pulse* = object
98 | enabled*: bool
99 | channel*: uint8
100 |
101 | lengthEnabled*: bool
102 | lengthValue*: uint8
103 |
104 | timerPeriod*, timerValue*: uint16
105 |
106 | dutyMode*, dutyValue*: uint8
107 |
108 | sweepReload*, sweepEnabled*, sweepNegate*: bool
109 | sweepShift*, sweepPeriod*, sweepValue*: uint8
110 |
111 | envelopeEnabled*, envelopeLoop*, envelopeStart*: bool
112 | envelopePeriod*, envelopeValue*, envelopeVolume*: uint8
113 |
114 | constantVolume*: uint8
115 |
116 | Noise* = object
117 | enabled*, mode*: bool
118 |
119 | shiftRegister*: uint16
120 |
121 | lengthEnabled*: bool
122 | lengthValue*: uint8
123 |
124 | timerPeriod*, timerValue*: uint16
125 |
126 | envelopeEnabled*, envelopeLoop*, envelopeStart*: bool
127 | envelopePeriod*, envelopeValue*, envelopeVolume*: uint8
128 |
129 | constantVolume*: uint8
130 |
131 | Triangle* = object
132 | enabled*: bool
133 |
134 | lengthEnabled*: bool
135 | lengthValue*: uint8
136 |
137 | timerPeriod*, timerValue*: uint16
138 |
139 | dutyValue*: uint8
140 |
141 | counterPeriod*, counterValue*: uint8
142 | counterReload*: bool
143 |
144 | DMC* = object
145 | cpu*: CPU
146 | enabled*: bool
147 | value*: uint8
148 |
149 | sampleAddress*, sampleLength*: uint16
150 |
151 | currentAddress*, currentLength*: uint16
152 |
153 | shiftRegister*, bitCount*, tickValue*, tickPeriod*: uint8
154 | loop*, irq*: bool
155 |
156 | Cartridge* = ref object
157 | prg*, chr*: seq[uint8]
158 | sram*: array[0x2000, uint8]
159 | mapper*, mirror*: uint8
160 | battery*: bool
161 |
162 | Controller* = object
163 | buttons*: Buttons
164 | index*, strobe*: uint8
165 |
166 | Buttons* = array[8, bool]
167 |
168 | Mapper* = ref object of RootObj
169 | step*: proc(m: Mapper)
170 | idx*: proc(m: Mapper, adr: uint16): uint8
171 | idxSet*: proc(m: Mapper, adr: uint16, val: uint8)
172 |
173 | MirrorModes* = enum
174 | mirrorHorizontal = 0, mirrorVertical, mirrorSingle0, mirrorSingle1, mirrorFour
175 |
176 | BitSet* = distinct uint8
177 |
178 | const frequency* = 1789773
179 |
180 | proc bit*(val: uint8, bit: range[0..7]): bool =
181 | ((val shr bit) and 1) != 0
182 |
183 | proc triggerNMI*(cpu: var CPU) =
184 | cpu.interrupt = iNMI
185 |
186 | proc triggerIRQ*(cpu: var CPU) =
187 | if not cpu.i:
188 | cpu.interrupt = iIRQ
189 |
--------------------------------------------------------------------------------
/src/nim.cfg:
--------------------------------------------------------------------------------
1 | threads = on # required for SDL2 audio callback
2 |
3 | @if emscripten:
4 | define = SDL_Static
5 | gc = none
6 | cc = clang
7 | clang.exe = "emcc"
8 | clang.linkerexe = "emcc"
9 | clang.options.linker = ""
10 | cpu = "i386"
11 | out = "nimes.html"
12 | warning[GcMem] = off
13 | passC = "-Wno-warn-absolute-paths -Iemscripten -s USE_SDL=2 -s ASM_JS=1"
14 | passL = "-O3 -Lemscripten -s USE_SDL=2 -s ASM_JS=1 --preload-file tetris.nes --preload-file pacman.nes --preload-file smb.nes --preload-file smb3.nes -s TOTAL_MEMORY=16777216"
15 | @end
16 |
17 | @if android:
18 | cpu = "i386"
19 | nimcache = "./android/jni/src"
20 | compileOnly
21 | noMain
22 | @end
23 |
24 | @if musl:
25 | passL = "-static"
26 | gcc.exe = "/usr/local/musl/bin/musl-gcc"
27 | gcc.linkerexe = "/usr/local/musl/bin/musl-gcc"
28 | @end
29 |
--------------------------------------------------------------------------------
/src/rewinder.nim:
--------------------------------------------------------------------------------
1 | import nes
2 |
3 | # TODO: State of Cartridge and Mapper is missing, a bit ugly to add
4 |
5 | const rewindSize = 600
6 |
7 | type Rewinder* = ref object
8 | states: array[rewindSize, NESObj]
9 | pos: int
10 | stored: int
11 |
12 | proc newRewinder*: Rewinder =
13 | new result
14 |
15 | proc empty*(r: Rewinder): bool =
16 | r.stored == 0
17 |
18 | proc pop*(r: var Rewinder): NESObj = # This may be slow and need a popInto()
19 | r.pos = (r.pos + rewindSize - 1) mod rewindSize
20 | copyMem(addr result, addr r.states[r.pos], sizeof(result))
21 | r.stored = max(r.stored - 1, 0)
22 |
23 | proc push*(r: var Rewinder, c: var NESObj) =
24 | copyMem(addr r.states[r.pos], addr c, sizeof(c))
25 | r.pos = (r.pos + 1) mod rewindSize
26 | r.stored = min(r.stored + 1, rewindSize)
27 |
--------------------------------------------------------------------------------