├── Images ├── demo.gif ├── logo.png ├── tiles.png ├── Terrain1.png ├── Terrain2.png └── Terrain3.png ├── Package ├── banner.png ├── screen1.png ├── screen2.png └── info.json ├── Source ├── MicroCity │ ├── Simulation.h │ ├── Strings.h │ ├── Terrain.h │ ├── Font.h │ ├── Connectivity.h │ ├── Draw.h │ ├── Building.h │ ├── Game.h │ ├── Interface.h │ ├── Game.cpp │ ├── Terrain1.inc.h │ ├── Terrain2.inc.h │ ├── Terrain3.inc.h │ ├── Strings.cpp │ ├── Terrain.cpp │ ├── LogoBitmap.h │ ├── MicroCity.ino │ ├── Defines.h │ └── Building.cpp └── Windows │ ├── SDL │ ├── include │ │ ├── SDL_revision.h │ │ ├── SDL_opengles2_gl2platform.h │ │ ├── SDL_types.h │ │ ├── SDL_name.h │ │ ├── SDL_opengles.h │ │ ├── close_code.h │ │ ├── SDL_opengles2.h │ │ ├── SDL_test_log.h │ │ ├── SDL_test.h │ │ ├── SDL_clipboard.h │ │ ├── SDL_quit.h │ │ ├── SDL_test_compare.h │ │ ├── SDL_test_images.h │ │ ├── SDL_blendmode.h │ │ ├── SDL_gesture.h │ │ ├── SDL_error.h │ │ ├── SDL_test_font.h │ │ ├── SDL_touch.h │ │ ├── SDL_power.h │ │ ├── SDL_bits.h │ │ ├── SDL_loadso.h │ │ ├── SDL_test_random.h │ │ ├── SDL_test_assert.h │ │ ├── SDL_test_crc32.h │ │ ├── SDL_timer.h │ │ ├── SDL.h │ │ ├── SDL_test_harness.h │ │ ├── begin_code.h │ │ ├── SDL_cpuinfo.h │ │ ├── SDL_rect.h │ │ ├── SDL_test_md5.h │ │ ├── SDL_messagebox.h │ │ ├── SDL_main.h │ │ ├── SDL_platform.h │ │ ├── SDL_test_common.h │ │ ├── SDL_filesystem.h │ │ ├── SDL_version.h │ │ ├── SDL_shape.h │ │ └── SDL_config.h │ ├── lib │ │ ├── x64 │ │ │ ├── SDL2.dll │ │ │ ├── SDL2.lib │ │ │ ├── SDL2main.lib │ │ │ └── SDL2test.lib │ │ └── x86 │ │ │ ├── SDL2.dll │ │ │ ├── SDL2.lib │ │ │ ├── SDL2main.lib │ │ │ └── SDL2test.lib │ ├── docs │ │ ├── README-platforms.md │ │ ├── README-wince.md │ │ ├── README-psp.md │ │ ├── README-pandora.md │ │ ├── README-hg.md │ │ ├── README-cmake.md │ │ ├── README-emscripten.md │ │ ├── README-windows.md │ │ ├── README-porting.md │ │ ├── README.md │ │ ├── README-directfb.md │ │ ├── README-linux.md │ │ ├── README-gesture.md │ │ ├── README-touch.md │ │ └── README-nacl.md │ ├── README-SDL.txt │ ├── BUGS.txt │ ├── README.txt │ └── COPYING.txt │ └── MicroCity │ ├── WinDebug.h │ ├── MicroCity.sln │ ├── WinDebug.cpp │ └── WinMain.cpp └── readme.md /Images/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Images/demo.gif -------------------------------------------------------------------------------- /Images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Images/logo.png -------------------------------------------------------------------------------- /Images/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Images/tiles.png -------------------------------------------------------------------------------- /Images/Terrain1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Images/Terrain1.png -------------------------------------------------------------------------------- /Images/Terrain2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Images/Terrain2.png -------------------------------------------------------------------------------- /Images/Terrain3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Images/Terrain3.png -------------------------------------------------------------------------------- /Package/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Package/banner.png -------------------------------------------------------------------------------- /Package/screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Package/screen1.png -------------------------------------------------------------------------------- /Package/screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Package/screen2.png -------------------------------------------------------------------------------- /Source/MicroCity/Simulation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void Simulate(void); 4 | bool StartRandomFire(void); -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_revision.h: -------------------------------------------------------------------------------- 1 | #define SDL_REVISION "hg-10556:007dfe83abf8" 2 | #define SDL_REVISION_NUMBER 10556 3 | -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x64/SDL2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Source/Windows/SDL/lib/x64/SDL2.dll -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x64/SDL2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Source/Windows/SDL/lib/x64/SDL2.lib -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x86/SDL2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Source/Windows/SDL/lib/x86/SDL2.dll -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x86/SDL2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Source/Windows/SDL/lib/x86/SDL2.lib -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x64/SDL2main.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Source/Windows/SDL/lib/x64/SDL2main.lib -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x64/SDL2test.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Source/Windows/SDL/lib/x64/SDL2test.lib -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x86/SDL2main.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Source/Windows/SDL/lib/x86/SDL2main.lib -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x86/SDL2test.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jhhoward/MicroCity/HEAD/Source/Windows/SDL/lib/x86/SDL2test.lib -------------------------------------------------------------------------------- /Source/MicroCity/Strings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | const char* GetToolbarString(int index); 4 | const char* GetMonthString(int index); 5 | 6 | -------------------------------------------------------------------------------- /Source/Windows/MicroCity/WinDebug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void CreateDebugWindow(void); 4 | void UpdateDebugView(void); 5 | void SetCurrentDebugView(int index); 6 | -------------------------------------------------------------------------------- /Source/MicroCity/Terrain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | uint8_t GetTerrainTile(int x, int y); 4 | bool IsTerrainClear(int x, int y); 5 | 6 | const char* GetTerrainDescription(uint8_t index); 7 | const uint8_t* GetTerrainData(uint8_t index); 8 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-platforms.md: -------------------------------------------------------------------------------- 1 | Platforms 2 | ========= 3 | 4 | We maintain the list of supported platforms on our wiki now, and how to 5 | build and install SDL for those platforms: 6 | 7 | https://wiki.libsdl.org/Installation 8 | 9 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-wince.md: -------------------------------------------------------------------------------- 1 | WinCE 2 | ===== 3 | 4 | Windows CE is no longer supported by SDL. 5 | 6 | We have left the CE support in SDL 1.2 for those that must have it, and we 7 | have support for Windows Phone 8 and WinRT in SDL2, as of SDL 2.0.3. 8 | 9 | --ryan. 10 | 11 | -------------------------------------------------------------------------------- /Source/MicroCity/Font.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define FONT_WIDTH 4 6 | #define FONT_HEIGHT 6 7 | 8 | void DrawString(const char* str, uint8_t x, uint8_t y); 9 | void DrawInt(int16_t val, uint8_t x, uint8_t y); 10 | uint8_t DrawCurrency(int32_t val, uint8_t x, uint8_t y); 11 | 12 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-psp.md: -------------------------------------------------------------------------------- 1 | PSP 2 | ====== 3 | SDL port for the Sony PSP contributed by 4 | Captian Lex 5 | 6 | Credit to 7 | Marcus R.Brown,Jim Paris,Matthew H for the original SDL 1.2 for PSP 8 | Geecko for his PSP GU lib "Glib2d" 9 | 10 | Building 11 | -------- 12 | To build for the PSP, make sure psp-config is in the path and run: 13 | make -f Makefile.psp 14 | 15 | 16 | 17 | To Do 18 | ------ 19 | PSP Screen Keyboard 20 | -------------------------------------------------------------------------------- /Source/MicroCity/Connectivity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Connectivity refers to roads + power lines 4 | 5 | enum ConnectivityMask 6 | { 7 | RoadMask = 1, 8 | PowerlineMask = 2 9 | }; 10 | 11 | uint8_t GetConnections(int x, int y); 12 | void SetConnections(int x, int y, uint8_t newVal); 13 | void CalculatePowerConnectivity(void); 14 | int GetConnectivityTileVariant(int x, int y, uint8_t mask); 15 | bool IsSuitableForBridgedTile(int x, int y, uint8_t mask); 16 | uint8_t* GetPowerGrid(); 17 | -------------------------------------------------------------------------------- /Source/Windows/SDL/README-SDL.txt: -------------------------------------------------------------------------------- 1 | 2 | Please distribute this file with the SDL runtime environment: 3 | 4 | The Simple DirectMedia Layer (SDL for short) is a cross-platform library 5 | designed to make it easy to write multi-media software, such as games 6 | and emulators. 7 | 8 | The Simple DirectMedia Layer library source code is available from: 9 | http://www.libsdl.org/ 10 | 11 | This library is distributed under the terms of the zlib license: 12 | http://www.zlib.net/zlib_license.html 13 | 14 | -------------------------------------------------------------------------------- /Source/Windows/SDL/BUGS.txt: -------------------------------------------------------------------------------- 1 | 2 | Bugs are now managed in the SDL bug tracker, here: 3 | 4 | https://bugzilla.libsdl.org/ 5 | 6 | You may report bugs there, and search to see if a given issue has already 7 | been reported, discussed, and maybe even fixed. 8 | 9 | 10 | You may also find help on the SDL mailing list. Subscription information: 11 | 12 | http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org 13 | 14 | Bug reports are welcome here, but we really appreciate if you use Bugzilla, as 15 | bugs discussed on the mailing list may be forgotten or missed. 16 | 17 | -------------------------------------------------------------------------------- /Source/MicroCity/Draw.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Building.h" 6 | 7 | void PutPixel(uint8_t x, uint8_t y, uint8_t colour); 8 | void DrawFilledRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t colour); 9 | void DrawRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t colour); 10 | void DrawBitmap(const uint8_t* bmp, uint8_t x, uint8_t y, uint8_t w, uint8_t h); 11 | 12 | void Draw(void); 13 | 14 | void ResetVisibleTileCache(void); 15 | void RefreshBuildingTiles(Building* building); 16 | void RefreshTile(uint8_t x, uint8_t y); 17 | void RefreshTileAndConnectedNeighbours(uint8_t x, uint8_t y); 18 | 19 | void SetTile(uint8_t x, uint8_t y, uint8_t tile); 20 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # MicroCity 2 | 3 | ![Demo](Images/demo.gif) 4 | 5 | MicroCity is a city simulation game for the [Arduboy miniature game system](https://www.arduboy.com) inspired by SimCity 6 | 7 | ## Build instructions 8 | To compile from source you will need the [Arduboy2 library](https://github.com/MLXXXp/Arduboy2) and the Arduino IDE 9 | 10 | Open /Source/MicroCity/MicroCity.ino in the Arduino IDE and hit build 11 | 12 | ## Flashing other games 13 | Note that there is a bug with the Arduboy bootloader when flashing new games. If flashing a new Arduino sketch after having previously flashing MicroCity, then first boot the Arduboy into *flashlight mode* by holding the up button whilst switching on the device. 14 | -------------------------------------------------------------------------------- /Source/Windows/SDL/README.txt: -------------------------------------------------------------------------------- 1 | 2 | Simple DirectMedia Layer 3 | 4 | (SDL) 5 | 6 | Version 2.0 7 | 8 | --- 9 | http://www.libsdl.org/ 10 | 11 | Simple DirectMedia Layer is a cross-platform development library designed 12 | to provide low level access to audio, keyboard, mouse, joystick, and graphics 13 | hardware via OpenGL and Direct3D. It is used by video playback software, 14 | emulators, and popular games including Valve's award winning catalog 15 | and many Humble Bundle games. 16 | 17 | More extensive documentation is available in the docs directory, starting 18 | with README.md 19 | 20 | Enjoy! 21 | Sam Lantinga (slouken@libsdl.org) 22 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-pandora.md: -------------------------------------------------------------------------------- 1 | Pandora 2 | ===================================================================== 3 | 4 | ( http://openpandora.org/ ) 5 | - A pandora specific video driver was written to allow SDL 2.0 with OpenGL ES 6 | support to work on the pandora under the framebuffer. This driver do not have 7 | input support for now, so if you use it you will have to add your own control code. 8 | The video driver name is "pandora" so if you have problem running it from 9 | the framebuffer, try to set the following variable before starting your application : 10 | "export SDL_VIDEODRIVER=pandora" 11 | 12 | - OpenGL ES support was added to the x11 driver, so it's working like the normal 13 | x11 driver one with OpenGLX support, with SDL input event's etc.. 14 | 15 | 16 | David Carré (Cpasjuste) 17 | cpasjuste@gmail.com 18 | -------------------------------------------------------------------------------- /Source/Windows/SDL/COPYING.txt: -------------------------------------------------------------------------------- 1 | 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-hg.md: -------------------------------------------------------------------------------- 1 | Mercurial 2 | ========= 3 | 4 | The latest development version of SDL is available via Mercurial. 5 | Mercurial allows you to get up-to-the-minute fixes and enhancements; 6 | as a developer works on a source tree, you can use "hg" to mirror that 7 | source tree instead of waiting for an official release. Please look 8 | at the Mercurial website ( http://mercurial.selenic.com/ ) for more 9 | information on using hg, where you can also download software for 10 | Mac OS X, Windows, and Unix systems. 11 | 12 | hg clone http://hg.libsdl.org/SDL 13 | 14 | If you are building SDL with an IDE, you will need to copy the file 15 | include/SDL_config.h.default to include/SDL_config.h before building. 16 | 17 | If you are building SDL via configure, you will need to run autogen.sh 18 | before running configure. 19 | 20 | There is a web interface to the subversion repository at: 21 | http://hg.libsdl.org/SDL/ 22 | 23 | There is an RSS feed available at that URL, for those that want to 24 | track commits in real time. 25 | 26 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/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 | -------------------------------------------------------------------------------- /Package/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 2, 3 | "title": "MicroCity", 4 | "description": "MicroCity is a city simulation game inspired by SimCity", 5 | "author": "James Howard", 6 | "version": "1.1", 7 | "date": "2018-02-22", 8 | "genre": "Misc", 9 | "publisher": "", 10 | "idea": "", 11 | "code": "", 12 | "art": "", 13 | "sound": "", 14 | "url": "https://github.com/jhhoward/MicroCity", 15 | "sourceUrl": "https://github.com/jhhoward/MicroCity", 16 | "email": "", 17 | "companion": "", 18 | "banner": "banner.png", 19 | "screenshots": [ 20 | { 21 | "title": "", 22 | "filename": "screen1.png" 23 | }, 24 | { 25 | "title": "", 26 | "filename": "screen2.png" 27 | } 28 | ], 29 | "binaries": [ 30 | { 31 | "title": "MicroCity", 32 | "filename": "MicroCity.hex", 33 | "device": "Arduboy" 34 | } 35 | ], 36 | "buttons": [ 37 | { 38 | "control": "", 39 | "action": "" 40 | } 41 | ], 42 | "eeprom": { 43 | "variable": false, 44 | "start": 16, 45 | "end": 1023 46 | } 47 | } -------------------------------------------------------------------------------- /Source/MicroCity/Building.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum BuildingType 6 | { 7 | BuildingType_None = 0, 8 | Residential, 9 | Commercial, 10 | Industrial, 11 | Powerplant, 12 | Park, 13 | PoliceDept, 14 | FireDept, 15 | Stadium, 16 | Rubble3x3, 17 | Rubble4x4, 18 | Num_BuildingTypes = Stadium + 1 19 | }; 20 | 21 | inline bool IsRubble(uint8_t buildingType) 22 | { 23 | return buildingType >= Rubble3x3; 24 | } 25 | 26 | typedef struct 27 | { 28 | uint8_t x : 6; 29 | uint8_t y : 6; 30 | uint8_t type : 4; 31 | uint8_t populationDensity : 4; 32 | uint8_t onFire : 2; 33 | bool heavyTraffic : 1; 34 | bool hasPower : 1; 35 | } Building; 36 | 37 | typedef struct 38 | { 39 | uint16_t cost; 40 | uint8_t width; 41 | uint8_t height; 42 | uint8_t drawTile; 43 | } BuildingInfo; 44 | 45 | bool PlaceBuilding(uint8_t buildingType, uint8_t x, uint8_t y); 46 | bool CanPlaceBuilding(uint8_t buildingType, uint8_t x, uint8_t y); 47 | const BuildingInfo* GetBuildingInfo(uint8_t buildingType); 48 | Building* GetBuilding(uint8_t x, uint8_t y); 49 | void DestroyBuilding(Building* building); 50 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-cmake.md: -------------------------------------------------------------------------------- 1 | CMake 2 | ================================================================================ 3 | (www.cmake.org) 4 | 5 | SDL's build system was traditionally based on autotools. Over time, this 6 | approach has suffered from several issues across the different supported 7 | platforms. 8 | To solve these problems, a new build system based on CMake is under development. 9 | It works in parallel to the legacy system, so users can experiment with it 10 | without complication. 11 | While still experimental, the build system should be usable on the following 12 | platforms: 13 | 14 | * FreeBSD 15 | * Linux 16 | * VS.NET 2010 17 | * MinGW and Msys 18 | * OS X with support for XCode 19 | 20 | 21 | ================================================================================ 22 | Usage 23 | ================================================================================ 24 | 25 | Assuming the source for SDL is located at ~/sdl 26 | 27 | cd ~ 28 | mkdir build 29 | cd build 30 | cmake ../sdl 31 | 32 | This will build the static and dynamic versions of SDL in the ~/build directory. 33 | -------------------------------------------------------------------------------- /Source/MicroCity/Game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef _WIN32 4 | #include 5 | #endif 6 | #include 7 | #include "Defines.h" 8 | #include "Building.h" 9 | #include "Connectivity.h" 10 | #include "Terrain.h" 11 | 12 | typedef struct 13 | { 14 | uint16_t year; // Starts at 1900 15 | uint8_t month; 16 | uint8_t simulationStep; 17 | 18 | int32_t money; 19 | 20 | // 2 bits per tile : road and power line 21 | uint8_t connectionMap[MAP_WIDTH * MAP_HEIGHT / 4]; 22 | 23 | uint8_t terrainType; 24 | uint8_t taxRate; 25 | 26 | uint16_t residentialPopulation; 27 | uint16_t industrialPopulation; 28 | uint16_t commercialPopulation; 29 | 30 | int32_t taxesCollected; 31 | uint8_t policeBudget; 32 | uint8_t fireBudget; 33 | uint16_t roadBudget; 34 | 35 | uint16_t timeToNextDisaster; 36 | 37 | Building buildings[MAX_BUILDINGS]; 38 | } GameState; 39 | 40 | extern GameState State; 41 | 42 | uint16_t GetRandFromSeed(uint16_t randVal); 43 | uint16_t GetRand(); 44 | 45 | void InitGame(void); 46 | void TickGame(void); 47 | 48 | void SaveCity(void); 49 | bool LoadCity(void); 50 | 51 | void FocusTile(uint8_t x, uint8_t y); 52 | 53 | 54 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-emscripten.md: -------------------------------------------------------------------------------- 1 | Emscripten 2 | ================================================================================ 3 | 4 | Build: 5 | 6 | $ mkdir build 7 | $ cd build 8 | $ emconfigure ../configure --host=asmjs-unknown-emscripten --disable-assembly --disable-threads --enable-cpuinfo=false CFLAGS="-O2" 9 | $ emmake make 10 | 11 | Or with cmake: 12 | 13 | $ mkdir build 14 | $ cd build 15 | $ emcmake cmake .. 16 | $ emmake make 17 | 18 | To build one of the tests: 19 | 20 | $ cd test/ 21 | $ emcc -O2 --js-opts 0 -g4 testdraw2.c -I../include ../build/.libs/libSDL2.a ../build/libSDL2_test.a -o a.html 22 | 23 | Uses GLES2 renderer or software 24 | 25 | tests: https://dl.dropboxusercontent.com/u/17360362/SDL2-em/index.html 26 | 27 | Some other SDL2 libraries can be easily built (assuming SDL2 is installed somewhere): 28 | 29 | SDL_mixer (http://www.libsdl.org/projects/SDL_mixer/): 30 | 31 | $ EMCONFIGURE_JS=1 emconfigure ../configure 32 | build as usual... 33 | 34 | SDL_gfx (http://cms.ferzkopp.net/index.php/software/13-sdl-gfx): 35 | 36 | $ EMCONFIGURE_JS=1 emconfigure ../configure --disable-mmx 37 | build as usual... 38 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/MicroCity/Interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Building.h" 5 | 6 | #define INPUT_LEFT 1 7 | #define INPUT_RIGHT 2 8 | #define INPUT_UP 4 9 | #define INPUT_DOWN 8 10 | #define INPUT_A 16 11 | #define INPUT_B 32 12 | 13 | enum BrushTypes 14 | { 15 | Bulldozer, 16 | RoadBrush, 17 | PowerlineBrush, 18 | FirstBuildingBrush, 19 | LastBuildingBrush = FirstBuildingBrush + Num_BuildingTypes - 2 20 | }; 21 | 22 | enum 23 | { 24 | SaveLoadToolbarButton = LastBuildingBrush + 1, 25 | BudgetToolbarButton 26 | }; 27 | 28 | enum 29 | { 30 | StartScreen, 31 | NewCityMenu, 32 | InGame, 33 | InGameDisaster, 34 | ShowingToolbar, 35 | SaveLoadMenu, 36 | BudgetMenu 37 | }; 38 | 39 | typedef struct 40 | { 41 | int16_t scrollX, scrollY; // Where on the map (in pixels) display is scrolled to 42 | uint8_t selectX, selectY; // Which tile is selected 43 | uint8_t brush; // What will be placed 44 | uint8_t selection; // For when toolbar is open or in a menu 45 | uint8_t state; // Which state the game is in 46 | bool autoBudget : 1; 47 | } UIStateStruct; 48 | 49 | extern UIStateStruct UIState; 50 | 51 | uint8_t GetInput(); 52 | 53 | void ProcessInput(void); 54 | void UpdateInterface(void); 55 | 56 | void GetBuildingBrushLocation(BuildingType buildingType, uint8_t* outX, uint8_t* outY); 57 | 58 | 59 | -------------------------------------------------------------------------------- /Source/Windows/MicroCity/MicroCity.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MicroCity", "MicroCity.vcxproj", "{81269073-28D8-47D3-97FB-12F08DE2C936}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {81269073-28D8-47D3-97FB-12F08DE2C936}.Debug|x64.ActiveCfg = Debug|x64 17 | {81269073-28D8-47D3-97FB-12F08DE2C936}.Debug|x64.Build.0 = Debug|x64 18 | {81269073-28D8-47D3-97FB-12F08DE2C936}.Debug|x86.ActiveCfg = Debug|Win32 19 | {81269073-28D8-47D3-97FB-12F08DE2C936}.Debug|x86.Build.0 = Debug|Win32 20 | {81269073-28D8-47D3-97FB-12F08DE2C936}.Release|x64.ActiveCfg = Release|x64 21 | {81269073-28D8-47D3-97FB-12F08DE2C936}.Release|x64.Build.0 = Release|x64 22 | {81269073-28D8-47D3-97FB-12F08DE2C936}.Release|x86.ActiveCfg = Release|Win32 23 | {81269073-28D8-47D3-97FB-12F08DE2C936}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_opengles.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | #include "SDL_config.h" 28 | 29 | #ifdef __IPHONEOS__ 30 | #include 31 | #include 32 | #else 33 | #include 34 | #include 35 | #endif 36 | 37 | #ifndef APIENTRY 38 | #define APIENTRY 39 | #endif 40 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/close_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/MicroCity/Game.cpp: -------------------------------------------------------------------------------- 1 | #include "Game.h" 2 | #include "Draw.h" 3 | #include "Interface.h" 4 | #include "Simulation.h" 5 | 6 | GameState State; 7 | 8 | uint16_t GetRandFromSeed(uint16_t randVal) 9 | { 10 | uint16_t lsb = randVal & 1; 11 | randVal >>= 1; 12 | if (lsb == 1) 13 | randVal ^= 0xB400u; 14 | 15 | return randVal; 16 | } 17 | 18 | uint16_t GetRand() 19 | { 20 | static uint16_t randVal = 0xABC; 21 | 22 | randVal = GetRandFromSeed(randVal); 23 | 24 | return randVal - 1; 25 | } 26 | 27 | void InitGame() 28 | { 29 | uint8_t* ptr = (uint8_t*)(&State); 30 | for (int n = 0; n < sizeof(GameState); n++) 31 | { 32 | *ptr = 0; 33 | ptr++; 34 | } 35 | 36 | State.taxRate = STARTING_TAX_RATE; 37 | State.timeToNextDisaster = MAX_TIME_BETWEEN_DISASTERS; 38 | 39 | ResetVisibleTileCache(); 40 | UIState.brush = RoadBrush; //FirstBuildingBrush + 1; 41 | FocusTile(MAP_WIDTH / 2, MAP_HEIGHT / 2); 42 | 43 | State.money = STARTING_FUNDS; 44 | UIState.autoBudget = true; 45 | } 46 | 47 | void FocusTile(uint8_t x, uint8_t y) 48 | { 49 | UIState.selectX = x; 50 | UIState.selectY = y; 51 | UIState.scrollX = UIState.selectX * 8 + TILE_SIZE / 2 - DISPLAY_WIDTH / 2; 52 | UIState.scrollY = UIState.selectY * 8 + TILE_SIZE / 2 - DISPLAY_HEIGHT / 2; 53 | } 54 | 55 | void TickGame() 56 | { 57 | if (UIState.state == InGame || UIState.state == ShowingToolbar) 58 | { 59 | Simulate(); 60 | } 61 | if (UIState.state == InGameDisaster) 62 | { 63 | if (UIState.selection == 0) 64 | { 65 | UIState.state = InGame; 66 | } 67 | else UIState.selection--; 68 | } 69 | 70 | ProcessInput(); 71 | UpdateInterface(); 72 | 73 | Draw(); 74 | } 75 | 76 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_opengles2.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | #include "SDL_config.h" 28 | 29 | #ifndef _MSC_VER 30 | 31 | #ifdef __IPHONEOS__ 32 | #include 33 | #include 34 | #else 35 | #include 36 | #include 37 | #include 38 | #endif 39 | 40 | #else /* _MSC_VER */ 41 | 42 | /* OpenGL ES2 headers for Visual Studio */ 43 | #include "SDL_opengles2_khrplatform.h" 44 | #include "SDL_opengles2_gl2platform.h" 45 | #include "SDL_opengles2_gl2.h" 46 | #include "SDL_opengles2_gl2ext.h" 47 | 48 | #endif /* _MSC_VER */ 49 | 50 | #ifndef APIENTRY 51 | #define APIENTRY GL_APIENTRY 52 | #endif 53 | -------------------------------------------------------------------------------- /Source/MicroCity/Terrain1.inc.h: -------------------------------------------------------------------------------- 1 | // 48, 48 2 | // 0 3 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 4 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x0f, 5 | 0x07, 0x01, 0xc0, 0xe0, 0xf8, 0xfc, 0xfe, 0xff, 6 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 7 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 8 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 9 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 10 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xc0, 11 | 0x80, 0x00, 0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x7f, 12 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 13 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 14 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 15 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 16 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 17 | 0xff, 0xff, 0xfe, 0xfc, 0xf8, 0xf8, 0xf0, 0xe0, 18 | 0xc0, 0x80, 0x01, 0x03, 0x07, 0x0f, 0x3f, 0xff, 19 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 20 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 21 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 22 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 23 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 24 | 0xff, 0xff, 0xfe, 0xf8, 0xe0, 0x00, 0x00, 0x00, 25 | 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 26 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 27 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 28 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 29 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 30 | 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 31 | 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 32 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 33 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 34 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 35 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 36 | 0x3f, 0x0f, 0x07, 0x00, 0x00, 0x80, 0xc0, 0xf8, 37 | 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 38 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 39 | -------------------------------------------------------------------------------- /Source/MicroCity/Terrain2.inc.h: -------------------------------------------------------------------------------- 1 | // 48, 48 2 | // 0 3 | 0x00, 0xf0, 0xf8, 0xfc, 0xfc, 0xfc, 0xfe, 0xfe, 4 | 0xfe, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfe, 5 | 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfc, 6 | 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 7 | 0xfc, 0xfc, 0xfc, 0xfc, 0xfe, 0xfe, 0xfe, 0xfe, 8 | 0xfe, 0xfe, 0xfe, 0xfe, 0xfc, 0xf8, 0xc0, 0x00, 9 | 0x00, 0x00, 0x81, 0xc3, 0xe3, 0xe3, 0xe3, 0xe3, 10 | 0xe3, 0xe3, 0xe3, 0xc7, 0x07, 0x0f, 0xff, 0xff, 11 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 12 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 13 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 14 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 15 | 0x00, 0x00, 0x1f, 0x3f, 0x7f, 0x7f, 0x7f, 0x7f, 16 | 0x3f, 0x3f, 0x3f, 0x0f, 0x80, 0xc0, 0xff, 0xff, 17 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 18 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x0f, 19 | 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x07, 0x07, 20 | 0x07, 0x03, 0x03, 0x83, 0xc3, 0xc1, 0x80, 0x00, 21 | 0x00, 0x00, 0x00, 0xc0, 0xf8, 0xfc, 0xfe, 0xfe, 22 | 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 23 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 24 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 25 | 0xfc, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xfc, 0xfe, 26 | 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 27 | 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 28 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 29 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 30 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 31 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 32 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 33 | 0x00, 0x3c, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x3f, 34 | 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 35 | 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x07, 0x0f, 0x0f, 36 | 0x0f, 0x0f, 0x3f, 0x3f, 0x7f, 0x7f, 0x3f, 0x3f, 37 | 0x3f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x3f, 0x7f, 38 | 0x7f, 0x7f, 0x7f, 0x7f, 0x3f, 0x1e, 0x00, 0x00, 39 | -------------------------------------------------------------------------------- /Source/MicroCity/Terrain3.inc.h: -------------------------------------------------------------------------------- 1 | // 48, 48 2 | // 0 3 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 4 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 5 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 6 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 7 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 8 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 9 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 10 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 11 | 0x7f, 0x7f, 0x3f, 0x3f, 0x3f, 0x7f, 0xff, 0xff, 12 | 0xff, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 13 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 14 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 15 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 16 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 17 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 18 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x0f, 0x7f, 19 | 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 20 | 0x7f, 0x7f, 0x3f, 0x3f, 0x3f, 0x1f, 0x00, 0x00, 21 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 22 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 23 | 0xfe, 0xfe, 0xfc, 0xf8, 0xf0, 0x80, 0x00, 0x00, 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xf0, 0xf8, 25 | 0xfc, 0xfc, 0xfc, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 26 | 0xf8, 0xfc, 0xfc, 0xfc, 0xf8, 0xf0, 0x00, 0x00, 27 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 28 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 29 | 0xff, 0xff, 0xff, 0xff, 0x1f, 0x03, 0x00, 0x00, 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0f, 0x0f, 31 | 0x1f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 32 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 33 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 34 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 35 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 36 | 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 37 | 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 38 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 39 | -------------------------------------------------------------------------------- /Source/MicroCity/Strings.cpp: -------------------------------------------------------------------------------- 1 | #include "Defines.h" 2 | 3 | const char BulldozerStr[] PROGMEM = "Bulldozer"; 4 | const char RoadStr[] PROGMEM = "Road"; 5 | const char PowerlineStr[] PROGMEM = "Powerline"; 6 | const char ResidentialStr[] PROGMEM = "Residential"; 7 | const char CommericalStr[] PROGMEM = "Commercial"; 8 | const char IndustrialStr[] PROGMEM = "Industrial"; 9 | const char PowerplantStr[] PROGMEM = "Powerplant"; 10 | const char ParkStr[] PROGMEM = "Park"; 11 | const char PoliceDeptStr[] PROGMEM = "Police Dept"; 12 | const char FireDeptStr[] PROGMEM = "Fire Dept"; 13 | const char StadiumStr[] PROGMEM = "Stadium"; 14 | const char SaveLoadStr[] PROGMEM = "Save/Load"; 15 | const char BudgetStr[] PROGMEM = "Budget"; 16 | 17 | const char* const ToolbarStrings[] PROGMEM = 18 | { 19 | BulldozerStr, 20 | RoadStr, 21 | PowerlineStr, 22 | ResidentialStr, 23 | CommericalStr, 24 | IndustrialStr, 25 | PowerplantStr, 26 | ParkStr, 27 | PoliceDeptStr, 28 | FireDeptStr, 29 | StadiumStr, 30 | SaveLoadStr, 31 | BudgetStr, 32 | }; 33 | 34 | const char* GetToolbarString(int index) 35 | { 36 | return (const char*)pgm_read_ptr(&ToolbarStrings[index]); 37 | } 38 | 39 | const char JanStr[] PROGMEM = "Jan"; 40 | const char FebStr[] PROGMEM = "Feb"; 41 | const char MarStr[] PROGMEM = "Mar"; 42 | const char AprStr[] PROGMEM = "Apr"; 43 | const char MayStr[] PROGMEM = "May"; 44 | const char JunStr[] PROGMEM = "Jun"; 45 | const char JulStr[] PROGMEM = "Jul"; 46 | const char AugStr[] PROGMEM = "Aug"; 47 | const char SepStr[] PROGMEM = "Sep"; 48 | const char OctStr[] PROGMEM = "Oct"; 49 | const char NovStr[] PROGMEM = "Nov"; 50 | const char DecStr[] PROGMEM = "Dec"; 51 | 52 | const char* const MonthStrings[] PROGMEM = 53 | { 54 | JanStr, 55 | FebStr, 56 | MarStr, 57 | AprStr, 58 | MayStr, 59 | JunStr, 60 | JulStr, 61 | AugStr, 62 | SepStr, 63 | OctStr, 64 | NovStr, 65 | DecStr 66 | }; 67 | 68 | const char* GetMonthString(int index) 69 | { 70 | return (const char*)pgm_read_ptr(&MonthStrings[index]); 71 | } 72 | 73 | 74 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-windows.md: -------------------------------------------------------------------------------- 1 | Windows 2 | ================================================================================ 3 | 4 | ================================================================================ 5 | OpenGL ES 2.x support 6 | ================================================================================ 7 | 8 | SDL has support for OpenGL ES 2.x under Windows via two alternative 9 | implementations. 10 | The most straightforward method consists in running your app in a system with 11 | a graphic card paired with a relatively recent (as of November of 2013) driver 12 | which supports the WGL_EXT_create_context_es2_profile extension. Vendors known 13 | to ship said extension on Windows currently include nVidia and Intel. 14 | 15 | The other method involves using the ANGLE library (https://code.google.com/p/angleproject/) 16 | If an OpenGL ES 2.x context is requested and no WGL_EXT_create_context_es2_profile 17 | extension is found, SDL will try to load the libEGL.dll library provided by 18 | ANGLE. 19 | To obtain the ANGLE binaries, you can either compile from source from 20 | https://chromium.googlesource.com/angle/angle or copy the relevant binaries from 21 | a recent Chrome/Chromium install for Windows. The files you need are: 22 | 23 | * libEGL.dll 24 | * libGLESv2.dll 25 | * d3dcompiler_46.dll (supports Windows Vista or later, better shader compiler) 26 | or... 27 | * d3dcompiler_43.dll (supports Windows XP or later) 28 | 29 | If you compile ANGLE from source, you can configure it so it does not need the 30 | d3dcompiler_* DLL at all (for details on this, see their documentation). 31 | However, by default SDL will try to preload the d3dcompiler_46.dll to 32 | comply with ANGLE's requirements. If you wish SDL to preload d3dcompiler_43.dll (to 33 | support Windows XP) or to skip this step at all, you can use the 34 | SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more details). 35 | 36 | Known Bugs: 37 | 38 | * SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears 39 | that there's a bug in the library which prevents the window contents from 40 | refreshing if this is set to anything other than the default value. 41 | 42 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-porting.md: -------------------------------------------------------------------------------- 1 | Porting 2 | ======= 3 | 4 | * Porting To A New Platform 5 | 6 | The first thing you have to do when porting to a new platform, is look at 7 | include/SDL_platform.h and create an entry there for your operating system. 8 | The standard format is "__PLATFORM__", where PLATFORM is the name of the OS. 9 | Ideally SDL_platform.h will be able to auto-detect the system it's building 10 | on based on C preprocessor symbols. 11 | 12 | There are two basic ways of building SDL at the moment: 13 | 14 | 1. The "UNIX" way: ./configure; make; make install 15 | 16 | If you have a GNUish system, then you might try this. Edit configure.in, 17 | take a look at the large section labelled: 18 | 19 | "Set up the configuration based on the host platform!" 20 | 21 | Add a section for your platform, and then re-run autogen.sh and build! 22 | 23 | 2. Using an IDE: 24 | 25 | If you're using an IDE or other non-configure build system, you'll probably 26 | want to create a custom SDL_config.h for your platform. Edit SDL_config.h, 27 | add a section for your platform, and create a custom SDL_config_{platform}.h, 28 | based on SDL_config.h.minimal and SDL_config.h.in 29 | 30 | Add the top level include directory to the header search path, and then add 31 | the following sources to the project: 32 | 33 | src/*.c 34 | src/atomic/*.c 35 | src/audio/*.c 36 | src/cpuinfo/*.c 37 | src/events/*.c 38 | src/file/*.c 39 | src/haptic/*.c 40 | src/joystick/*.c 41 | src/power/*.c 42 | src/render/*.c 43 | src/stdlib/*.c 44 | src/thread/*.c 45 | src/timer/*.c 46 | src/video/*.c 47 | src/audio/disk/*.c 48 | src/audio/dummy/*.c 49 | src/filesystem/dummy/*.c 50 | src/video/dummy/*.c 51 | src/haptic/dummy/*.c 52 | src/joystick/dummy/*.c 53 | src/main/dummy/*.c 54 | src/thread/generic/*.c 55 | src/timer/dummy/*.c 56 | src/loadso/dummy/*.c 57 | 58 | 59 | Once you have a working library without any drivers, you can go back to each 60 | of the major subsystems and start implementing drivers for your platform. 61 | 62 | If you have any questions, don't hesitate to ask on the SDL mailing list: 63 | http://www.libsdl.org/mailing-list.php 64 | 65 | Enjoy! 66 | Sam Lantinga (slouken@libsdl.org) 67 | 68 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_test_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/MicroCity/Terrain.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Terrain.h" 3 | #include "Game.h" 4 | #include "Defines.h" 5 | 6 | const uint8_t Terrain1Data[] PROGMEM = 7 | { 8 | #include "Terrain1.inc.h" 9 | }; 10 | const uint8_t Terrain2Data[] PROGMEM = 11 | { 12 | #include "Terrain2.inc.h" 13 | }; 14 | const uint8_t Terrain3Data[] PROGMEM = 15 | { 16 | #include "Terrain3.inc.h" 17 | }; 18 | 19 | const char Terrain1Str[] PROGMEM = "River"; 20 | const char Terrain2Str[] PROGMEM = "Island"; 21 | const char Terrain3Str[] PROGMEM = "Lake"; 22 | 23 | const char* GetTerrainDescription(uint8_t index) 24 | { 25 | switch (index) 26 | { 27 | default: 28 | case 0: 29 | return Terrain1Str; 30 | case 1: 31 | return Terrain2Str; 32 | case 2: 33 | return Terrain3Str; 34 | } 35 | } 36 | 37 | const uint8_t* GetTerrainData(uint8_t index) 38 | { 39 | switch (index) 40 | { 41 | default: 42 | case 0: return Terrain1Data; 43 | case 1: return Terrain2Data; 44 | case 2: return Terrain3Data; 45 | } 46 | 47 | } 48 | 49 | bool IsTerrainClear(int x, int y) 50 | { 51 | int blockX = x >> 3; 52 | int blockY = y >> 3; 53 | uint8_t blockU = x & 7; 54 | uint8_t blockV = y & 7; 55 | int index = (blockY * (MAP_WIDTH / 8) + blockX) * 8 + blockU; 56 | uint8_t mask = 1 << blockV; 57 | 58 | const uint8_t* terrainData = GetTerrainData(State.terrainType); 59 | 60 | uint8_t blockData = pgm_read_byte(&terrainData[index]); 61 | 62 | return (blockData & mask) != 0; 63 | } 64 | 65 | uint8_t GetTerrainTile(int x, int y) 66 | { 67 | bool northClear = y == 0 || IsTerrainClear(x, y - 1); 68 | bool eastClear = x >= MAP_WIDTH - 1 || IsTerrainClear(x + 1, y); 69 | bool southClear = y >= MAP_HEIGHT - 1 || IsTerrainClear(x, y + 1); 70 | bool westClear = x == 0 || IsTerrainClear(x - 1, y); 71 | 72 | if (IsTerrainClear(x, y)) 73 | { 74 | if (!northClear && !westClear) 75 | return NORTH_WEST_EDGE_TILE; 76 | if (!northClear && !eastClear) 77 | return NORTH_EAST_EDGE_TILE; 78 | if (!southClear && !westClear) 79 | return SOUTH_WEST_EDGE_TILE; 80 | if (!southClear && !eastClear) 81 | return SOUTH_EAST_EDGE_TILE; 82 | 83 | return FIRST_TERRAIN_TILE + ((((y * 359)) ^ ((x * 431))) & 3); 84 | } 85 | else 86 | { 87 | return FIRST_WATER_TILE + ((((y * 359)) ^ ((x * 431))) & 3); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 SDL's 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_clipboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README.md: -------------------------------------------------------------------------------- 1 | Simple DirectMedia Layer {#mainpage} 2 | ======================== 3 | 4 | (SDL) 5 | 6 | Version 2.0 7 | 8 | --- 9 | http://www.libsdl.org/ 10 | 11 | Simple DirectMedia Layer is a cross-platform development library designed 12 | to provide low level access to audio, keyboard, mouse, joystick, and graphics 13 | hardware via OpenGL and Direct3D. It is used by video playback software, 14 | emulators, and popular games including Valve's award winning catalog 15 | and many Humble Bundle games. 16 | 17 | SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. 18 | Support for other platforms may be found in the source code. 19 | 20 | SDL is written in C, works natively with C++, and there are bindings 21 | available for several other languages, including C# and Python. 22 | 23 | This library is distributed under the zlib license, which can be found 24 | in the file "COPYING.txt". 25 | 26 | The best way to learn how to use SDL is to check out the header files in 27 | the "include" subdirectory and the programs in the "test" subdirectory. 28 | The header files and test programs are well commented and always up to date. 29 | 30 | More documentation and FAQs are available online at [the wiki](http://wiki.libsdl.org/) 31 | 32 | - [Android](README-android.md) 33 | - [CMake](README-cmake.md) 34 | - [DirectFB](README-directfb.md) 35 | - [DynAPI](README-dynapi.md) 36 | - [Emscripten](README-emscripten.md) 37 | - [Gesture](README-gesture.md) 38 | - [Mercurial](README-hg.md) 39 | - [iOS](README-ios.md) 40 | - [Linux](README-linux.md) 41 | - [OS X](README-macosx.md) 42 | - [Native Client](README-nacl.md) 43 | - [Pandora](README-pandora.md) 44 | - [Supported Platforms](README-platforms.md) 45 | - [Porting information](README-porting.md) 46 | - [PSP](README-psp.md) 47 | - [Raspberry Pi](README-raspberrypi.md) 48 | - [Touch](README-touch.md) 49 | - [WinCE](README-wince.md) 50 | - [Windows](README-windows.md) 51 | - [WinRT](README-winrt.md) 52 | 53 | If you need help with the library, or just want to discuss SDL related 54 | issues, you can join the [developers mailing list](http://www.libsdl.org/mailing-list.php) 55 | 56 | If you want to report bugs or contribute patches, please submit them to 57 | [bugzilla](http://bugzilla.libsdl.org/) 58 | 59 | Enjoy! 60 | 61 | 62 | Sam Lantinga 63 | 64 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_test_compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_test_images.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_blendmode.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/MicroCity/LogoBitmap.h: -------------------------------------------------------------------------------- 1 | unsigned char const LogoBitmap[] PROGMEM = 2 | { 3 | // 72, 40 4 | 0x00, 0xfe, 0x02, 0xfa, 0x0a, 0xea, 0xea, 0xea, 5 | 0xea, 0xea, 0xea, 0xda, 0xda, 0xea, 0xea, 0xea, 6 | 0xea, 0xea, 0xea, 0x0a, 0xfa, 0x0a, 0xea, 0xea, 7 | 0xea, 0x0a, 0xfa, 0x32, 0xda, 0xea, 0xea, 0xea, 8 | 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0x0a, 9 | 0xfa, 0x0a, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 10 | 0xea, 0xea, 0xea, 0xea, 0xea, 0x1a, 0xf2, 0x62, 11 | 0xb2, 0xda, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 12 | 0xea, 0xda, 0xb2, 0x62, 0xc2, 0x02, 0xfe, 0x00, 13 | 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 14 | 0x00, 0xfe, 0x40, 0x5f, 0x5f, 0x40, 0xfe, 0x00, 15 | 0xff, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 16 | 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 17 | 0x7e, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 18 | 0xff, 0x00, 0xff, 0xff, 0xff, 0x38, 0xba, 0xba, 19 | 0x7a, 0xf8, 0xff, 0xbf, 0x3f, 0xc0, 0xff, 0x00, 20 | 0xff, 0xff, 0xff, 0x00, 0x7e, 0x42, 0x7e, 0x00, 21 | 0xff, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 22 | 0x00, 0xff, 0x80, 0x1f, 0x10, 0x17, 0x17, 0x17, 23 | 0x10, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x10, 24 | 0x17, 0x17, 0x17, 0x10, 0x1f, 0x10, 0xf7, 0x37, 25 | 0xd7, 0x50, 0x5f, 0x56, 0x5d, 0x5b, 0x17, 0xf7, 26 | 0x17, 0xd7, 0x17, 0xf7, 0x17, 0x57, 0x57, 0xd0, 27 | 0x5f, 0x50, 0x17, 0xf7, 0x17, 0xd0, 0x9f, 0x71, 28 | 0x9f, 0xd0, 0x17, 0xf7, 0x17, 0x10, 0x1f, 0x06, 29 | 0x0d, 0x1b, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 30 | 0x17, 0x1b, 0x0d, 0x06, 0x03, 0x80, 0xff, 0x00, 31 | 0xff, 0xfe, 0xfd, 0xfb, 0xf6, 0xec, 0xd8, 0xb0, 32 | 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0, 34 | 0xbf, 0xa0, 0xaf, 0xa9, 0xa9, 0xa9, 0x89, 0xff, 35 | 0x80, 0xbf, 0x80, 0xff, 0x01, 0xff, 0x80, 0xbf, 36 | 0x80, 0xff, 0x01, 0x01, 0x03, 0xfe, 0x81, 0xbf, 37 | 0x81, 0xfe, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x60, 39 | 0xb0, 0xd8, 0xec, 0xf6, 0xfb, 0xfd, 0xfe, 0xff, 40 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 41 | 0xff, 0xfe, 0xfd, 0xfb, 0xfa, 0xfa, 0xfa, 0xfa, 42 | 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 43 | 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 44 | 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 45 | 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 46 | 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 47 | 0xfa, 0xfa, 0xfa, 0xfa, 0xfb, 0xfd, 0xfe, 0xff, 48 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 49 | }; 50 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_gesture.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_test_font.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_power.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/MicroCity/MicroCity.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Draw.h" 4 | #include "Interface.h" 5 | #include "Game.h" 6 | #include "Simulation.h" 7 | 8 | Arduboy2Base arduboy; 9 | 10 | uint8_t GetInput() 11 | { 12 | uint8_t result = 0; 13 | 14 | if(arduboy.pressed(A_BUTTON)) 15 | { 16 | result |= INPUT_A; 17 | } 18 | if(arduboy.pressed(B_BUTTON)) 19 | { 20 | result |= INPUT_B; 21 | } 22 | if(arduboy.pressed(UP_BUTTON)) 23 | { 24 | result |= INPUT_UP; 25 | } 26 | if(arduboy.pressed(DOWN_BUTTON)) 27 | { 28 | result |= INPUT_DOWN; 29 | } 30 | if(arduboy.pressed(LEFT_BUTTON)) 31 | { 32 | result |= INPUT_LEFT; 33 | } 34 | if(arduboy.pressed(RIGHT_BUTTON)) 35 | { 36 | result |= INPUT_RIGHT; 37 | } 38 | 39 | return result; 40 | } 41 | 42 | void PutPixel(uint8_t x, uint8_t y, uint8_t colour) 43 | { 44 | arduboy.drawPixel(x, y, colour); 45 | } 46 | 47 | /* 48 | void DrawFilledRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t colour) 49 | { 50 | arduboy.fillRect(x, y, w, h, colour); 51 | } 52 | 53 | void DrawRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t colour) 54 | { 55 | arduboy.drawRect(x, y, w, h, colour); 56 | } 57 | */ 58 | 59 | void DrawBitmap(const uint8_t* bmp, uint8_t x, uint8_t y, uint8_t w, uint8_t h) 60 | { 61 | arduboy.drawBitmap(x, y, bmp, w, h, WHITE); 62 | } 63 | 64 | void SaveCity() 65 | { 66 | uint16_t address = EEPROM_STORAGE_SPACE_START; 67 | 68 | // Add a header so we know that the EEPROM contains a saved city 69 | EEPROM.update(address++, 'C'); 70 | EEPROM.update(address++, 'T'); 71 | EEPROM.update(address++, 'Y'); 72 | EEPROM.update(address++, '1'); 73 | 74 | uint8_t* ptr = (uint8_t*) &State; 75 | for(size_t n = 0; n < sizeof(GameState); n++) 76 | { 77 | EEPROM.update(address++, *ptr); 78 | ptr++; 79 | } 80 | } 81 | 82 | bool LoadCity() 83 | { 84 | uint16_t address = EEPROM_STORAGE_SPACE_START; 85 | 86 | if(EEPROM.read(address++) != 'C') return false; 87 | if(EEPROM.read(address++) != 'T') return false; 88 | if(EEPROM.read(address++) != 'Y') return false; 89 | if(EEPROM.read(address++) != '1') return false; 90 | 91 | uint8_t* ptr = (uint8_t*) &State; 92 | for(size_t n = 0; n < sizeof(GameState); n++) 93 | { 94 | *ptr = EEPROM.read(address++); 95 | ptr++; 96 | } 97 | 98 | return true; 99 | } 100 | 101 | uint8_t* GetPowerGrid() 102 | { 103 | return arduboy.getBuffer(); 104 | } 105 | 106 | void setup() 107 | { 108 | arduboy.boot(); 109 | arduboy.flashlight(); 110 | arduboy.systemButtons(); 111 | arduboy.bootLogo(); 112 | arduboy.setFrameRate(25); 113 | 114 | InitGame(); 115 | } 116 | 117 | void loop() 118 | { 119 | if(arduboy.nextFrame()) 120 | { 121 | TickGame(); 122 | arduboy.display(false); 123 | } 124 | } 125 | 126 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/MicroCity/Defines.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if _WIN32 4 | #include 5 | #include 6 | #define PROGMEM 7 | #define PSTR 8 | #define pgm_read_byte(x) (*((uint8_t*)x)) 9 | #define pgm_read_word(x) (*((uint16_t*)x)) 10 | #define pgm_read_ptr(x) (*((uintptr_t*)x)) 11 | #define strlen_P(x) strlen(x) 12 | #else 13 | #include 14 | //#define pgm_read_ptr pgm_read_word 15 | #endif 16 | 17 | #define TILE_SIZE 8 18 | #define TILE_SIZE_SHIFT 3 19 | 20 | #ifdef _WIN32 21 | //#define DISPLAY_WIDTH 192 22 | //#define DISPLAY_HEIGHT 192 23 | #define DISPLAY_WIDTH 128 24 | #define DISPLAY_HEIGHT 64 25 | #define MAP_WIDTH 48 26 | #define MAP_HEIGHT 48 27 | #else 28 | #define DISPLAY_WIDTH 128 29 | #define DISPLAY_HEIGHT 64 30 | #define MAP_WIDTH 48 31 | #define MAP_HEIGHT 48 32 | #endif 33 | 34 | 35 | #define MAX_SCROLL_X (MAP_WIDTH * TILE_SIZE - DISPLAY_WIDTH) 36 | #define MAX_SCROLL_Y (MAP_HEIGHT * TILE_SIZE - DISPLAY_HEIGHT) 37 | 38 | #define VISIBLE_TILES_X ((DISPLAY_WIDTH / TILE_SIZE) + 1) 39 | #define VISIBLE_TILES_Y ((DISPLAY_HEIGHT / TILE_SIZE) + 1) 40 | 41 | #define MAX_BUILDINGS 130 42 | 43 | // How long a button has to be held before the first event repeats 44 | #define INPUT_REPEAT_TIME 10 45 | 46 | // When repeating, how long between each event is fired 47 | #define INPUT_REPEAT_FREQUENCY 2 48 | 49 | #define BULLDOZER_COST 1 50 | #define ROAD_COST 10 51 | #define POWERLINE_COST 5 52 | 53 | #define FIRST_TERRAIN_TILE 1 54 | #define FIRST_WATER_TILE 17 55 | #define LAST_WATER_TILE (FIRST_WATER_TILE + 3) 56 | 57 | #define FIRST_FIRE_TILE 232 58 | #define LAST_FIRE_TILE (FIRST_FIRE_TILE + 3) 59 | 60 | #define FIRST_ROAD_TILE 5 61 | #define FIRST_ROAD_TRAFFIC_TILE (FIRST_ROAD_TILE + 16) 62 | #define LAST_ROAD_TRAFFIC_TILE (FIRST_ROAD_TRAFFIC_TILE + 10) 63 | #define FIRST_POWERLINE_TILE 53 64 | #define FIRST_POWERLINE_ROAD_TILE 49 65 | 66 | #define FIRST_ROAD_BRIDGE_TILE 32 67 | #define FIRST_POWERLINE_BRIDGE_TILE 34 68 | 69 | #define FIRST_BUILDING_TILE 224 70 | 71 | #define FIRST_EDGE_TILE 79 72 | #define NORTH_WEST_EDGE_TILE FIRST_EDGE_TILE 73 | #define NORTH_EAST_EDGE_TILE (FIRST_EDGE_TILE + 16) 74 | #define SOUTH_WEST_EDGE_TILE (FIRST_EDGE_TILE + 32) 75 | #define SOUTH_EAST_EDGE_TILE (FIRST_EDGE_TILE + 48) 76 | 77 | #define POWERCUT_TILE 48 78 | #define RUBBLE_TILE 51 79 | 80 | #define FIRST_BRUSH_TILE 240 81 | 82 | #define NUM_TOOLBAR_BUTTONS 13 83 | 84 | #define MAX_POPULATION_DENSITY 15 85 | 86 | #define NUM_TERRAIN_TYPES 3 87 | 88 | #define STARTING_TAX_RATE 7 89 | #define STARTING_FUNDS 10000 90 | 91 | #define FIRE_AND_POLICE_MAINTENANCE_COST 100 92 | #define ROAD_MAINTENANCE_COST 10 93 | 94 | #define POPULATION_MULTIPLIER 17 95 | 96 | #define MIN_BUDGET_DISPLAY_TIME 16 97 | 98 | #define BUILDING_MAX_FIRE_COUNTER 3 99 | 100 | #define MIN_FRAMES_BETWEEN_DISASTER 2500 101 | #define FRAMES_PER_YEAR (MAX_BUILDINGS * 12) 102 | #define MIN_TIME_BETWEEN_DISASTERS (FRAMES_PER_YEAR * 2) 103 | #define MAX_TIME_BETWEEN_DISASTERS (FRAMES_PER_YEAR * 6) 104 | 105 | #define DISASTER_MESSAGE_DISPLAY_TIME 60 106 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-directfb.md: -------------------------------------------------------------------------------- 1 | DirectFB 2 | ======== 3 | 4 | Supports: 5 | 6 | - Hardware YUV overlays 7 | - OpenGL - software only 8 | - 2D/3D accelerations (depends on directfb driver) 9 | - multiple displays 10 | - windows 11 | 12 | What you need: 13 | 14 | * DirectFB 1.0.1, 1.2.x, 1.3.0 15 | * Kernel-Framebuffer support: required: vesafb, radeonfb .... 16 | * Mesa 7.0.x - optional for OpenGL 17 | 18 | /etc/directfbrc 19 | 20 | This file should contain the following lines to make 21 | your joystick work and avoid crashes: 22 | ------------------------ 23 | disable-module=joystick 24 | disable-module=cle266 25 | disable-module=cyber5k 26 | no-linux-input-grab 27 | ------------------------ 28 | 29 | To disable to use x11 backend when DISPLAY variable is found use 30 | 31 | export SDL_DIRECTFB_X11_CHECK=0 32 | 33 | To disable the use of linux input devices, i.e. multimice/multikeyboard support, 34 | use 35 | 36 | export SDL_DIRECTFB_LINUX_INPUT=0 37 | 38 | To use hardware accelerated YUV-overlays for YUV-textures, use: 39 | 40 | export SDL_DIRECTFB_YUV_DIRECT=1 41 | 42 | This is disabled by default. It will only support one 43 | YUV texture, namely the first. Every other YUV texture will be 44 | rendered in software. 45 | 46 | In addition, you may use (directfb-1.2.x) 47 | 48 | export SDL_DIRECTFB_YUV_UNDERLAY=1 49 | 50 | to make the YUV texture an underlay. This will make the cursor to 51 | be shown. 52 | 53 | Simple Window Manager 54 | ===================== 55 | 56 | The driver has support for a very, very basic window manager you may 57 | want to use when running with "wm=default". Use 58 | 59 | export SDL_DIRECTFB_WM=1 60 | 61 | to enable basic window borders. In order to have the window title rendered, 62 | you need to have the following font installed: 63 | 64 | /usr/share/fonts/truetype/freefont/FreeSans.ttf 65 | 66 | OpenGL Support 67 | ============== 68 | 69 | The following instructions will give you *software* OpenGL. However this 70 | works at least on all directfb supported platforms. 71 | 72 | As of this writing 20100802 you need to pull Mesa from git and do the following: 73 | 74 | ------------------------ 75 | git clone git://anongit.freedesktop.org/git/mesa/mesa 76 | cd mesa 77 | git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a 78 | ------------------------ 79 | 80 | Edit configs/linux-directfb so that the Directories-section looks like 81 | ------------------------ 82 | # Directories 83 | SRC_DIRS = mesa glu 84 | GLU_DIRS = sgi 85 | DRIVER_DIRS = directfb 86 | PROGRAM_DIRS = 87 | ------------------------ 88 | 89 | make linux-directfb 90 | make 91 | 92 | echo Installing - please enter sudo pw. 93 | 94 | sudo make install INSTALL_DIR=/usr/local/dfb_GL 95 | cd src/mesa/drivers/directfb 96 | make 97 | sudo make install INSTALL_DIR=/usr/local/dfb_GL 98 | ------------------------ 99 | 100 | To run the SDL - testprograms: 101 | 102 | export SDL_VIDEODRIVER=directfb 103 | export LD_LIBRARY_PATH=/usr/local/dfb_GL/lib 104 | export LD_PRELOAD=/usr/local/dfb_GL/libGL.so.7 105 | 106 | ./testgl 107 | 108 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_loadso.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_test_random.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_test_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-linux.md: -------------------------------------------------------------------------------- 1 | Linux 2 | ================================================================================ 3 | 4 | By default SDL will only link against glibc, the rest of the features will be 5 | enabled dynamically at runtime depending on the available features on the target 6 | system. So, for example if you built SDL with Xinerama support and the target 7 | system does not have the Xinerama libraries installed, it will be disabled 8 | at runtime, and you won't get a missing library error, at least with the 9 | default configuration parameters. 10 | 11 | 12 | ================================================================================ 13 | Build Dependencies 14 | ================================================================================ 15 | 16 | Ubuntu 13.04, all available features enabled: 17 | 18 | sudo apt-get install build-essential mercurial make cmake autoconf automake \ 19 | libtool libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev \ 20 | libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev \ 21 | libxss-dev libgl1-mesa-dev libesd0-dev libdbus-1-dev libudev-dev \ 22 | libgles1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev \ 23 | fcitx-libs-dev 24 | 25 | Ubuntu 16.04 can also add "libwayland-dev libxkbcommon-dev wayland-protocols" 26 | to that command line for Wayland support. 27 | 28 | Ubuntu 16.10 can also add "libmirclient-dev libxkbcommon-dev" to that command 29 | line for Mir support. 30 | 31 | NOTES: 32 | - This includes all the audio targets except arts, because Ubuntu pulled the 33 | artsc0-dev package, but in theory SDL still supports it. 34 | - DirectFB isn't included because the configure script (currently) fails to find 35 | it at all. You can do "sudo apt-get install libdirectfb-dev" and fix the 36 | configure script to include DirectFB support. Send patches. :) 37 | 38 | 39 | ================================================================================ 40 | Joystick does not work 41 | ================================================================================ 42 | 43 | If you compiled or are using a version of SDL with udev support (and you should!) 44 | there's a few issues that may cause SDL to fail to detect your joystick. To 45 | debug this, start by installing the evtest utility. On Ubuntu/Debian: 46 | 47 | sudo apt-get install evtest 48 | 49 | Then run: 50 | 51 | sudo evtest 52 | 53 | You'll hopefully see your joystick listed along with a name like "/dev/input/eventXX" 54 | Now run: 55 | 56 | cat /dev/input/event/XX 57 | 58 | If you get a permission error, you need to set a udev rule to change the mode of 59 | your device (see below) 60 | 61 | Also, try: 62 | 63 | sudo udevadm info --query=all --name=input/eventXX 64 | 65 | If you see a line stating ID_INPUT_JOYSTICK=1, great, if you don't see it, 66 | you need to set up an udev rule to force this variable. 67 | 68 | A combined rule for the Saitek Pro Flight Rudder Pedals to fix both issues looks 69 | like: 70 | 71 | SUBSYSTEM=="input", ATTRS{idProduct}=="0763", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1" 72 | SUBSYSTEM=="input", ATTRS{idProduct}=="0764", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1" 73 | 74 | You can set up similar rules for your device by changing the values listed in 75 | idProduct and idVendor. To obtain these values, try: 76 | 77 | sudo udevadm info -a --name=input/eventXX | grep idVendor 78 | sudo udevadm info -a --name=input/eventXX | grep idProduct 79 | 80 | If multiple values come up for each of these, the one you want is the first one of each. 81 | 82 | On other systems which ship with an older udev (such as CentOS), you may need 83 | to set up a rule such as: 84 | 85 | SUBSYSTEM=="input", ENV{ID_CLASS}=="joystick", ENV{ID_INPUT_JOYSTICK}="1" 86 | 87 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_test_crc32.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 0 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-gesture.md: -------------------------------------------------------------------------------- 1 | Dollar Gestures 2 | =========================================================================== 3 | SDL provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures. 4 | 5 | Gestures can be performed with any number of fingers (the centroid of the fingers must follow the path of the gesture), but the number of fingers must be constant (a finger cannot go down in the middle of a gesture). The path of a gesture is considered the path from the time when the final finger went down, to the first time any finger comes up. 6 | 7 | Dollar gestures are assigned an Id based on a hash function. This is guaranteed to remain constant for a given gesture. There is a (small) chance that two different gestures will be assigned the same ID. In this case, simply re-recording one of the gestures should result in a different ID. 8 | 9 | Recording: 10 | ---------- 11 | To begin recording on a touch device call: 12 | SDL_RecordGesture(SDL_TouchID touchId), where touchId is the id of the touch device you wish to record on, or -1 to record on all connected devices. 13 | 14 | Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event. 15 | A SDL_DOLLARRECORD event is a dgesture with the following fields: 16 | 17 | * event.dgesture.touchId - the Id of the touch used to record the gesture. 18 | * event.dgesture.gestureId - the unique id of the recorded gesture. 19 | 20 | 21 | Performing: 22 | ----------- 23 | As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields: 24 | 25 | * event.dgesture.touchId - the Id of the touch which performed the gesture. 26 | * event.dgesture.gestureId - the unique id of the closest gesture to the performed stroke. 27 | * event.dgesture.error - the difference between the gesture template and the actual performed gesture. Lower error is a better match. 28 | * event.dgesture.numFingers - the number of fingers used to draw the stroke. 29 | 30 | Most programs will want to define an appropriate error threshold and check to be sure that the error of a gesture is not abnormally high (an indicator that no gesture was performed). 31 | 32 | 33 | 34 | Saving: 35 | ------- 36 | To save a template, call SDL_SaveDollarTemplate(gestureId, dst) where gestureId is the id of the gesture you want to save, and dst is an SDL_RWops pointer to the file where the gesture will be stored. 37 | 38 | To save all currently loaded templates, call SDL_SaveAllDollarTemplates(dst) where dst is an SDL_RWops pointer to the file where the gesture will be stored. 39 | 40 | Both functions return the number of gestures successfully saved. 41 | 42 | 43 | Loading: 44 | -------- 45 | To load templates from a file, call SDL_LoadDollarTemplates(touchId,src) where touchId is the id of the touch to load to (or -1 to load to all touch devices), and src is an SDL_RWops pointer to a gesture save file. 46 | 47 | SDL_LoadDollarTemplates returns the number of templates successfully loaded. 48 | 49 | 50 | 51 | =========================================================================== 52 | Multi Gestures 53 | =========================================================================== 54 | SDL provides simple support for pinch/rotate/swipe gestures. 55 | Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields: 56 | 57 | * event.mgesture.touchId - the Id of the touch on which the gesture was performed. 58 | * event.mgesture.x - the normalized x coordinate of the gesture. (0..1) 59 | * event.mgesture.y - the normalized y coordinate of the gesture. (0..1) 60 | * event.mgesture.dTheta - the amount that the fingers rotated during this motion. 61 | * event.mgesture.dDist - the amount that the fingers pinched during this motion. 62 | * event.mgesture.numFingers - the number of fingers used in the gesture. 63 | 64 | 65 | =========================================================================== 66 | Notes 67 | =========================================================================== 68 | For a complete example see test/testgesture.c 69 | 70 | Please direct questions/comments to: 71 | jim.tla+sdl_touch@gmail.com 72 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-touch.md: -------------------------------------------------------------------------------- 1 | Touch 2 | =========================================================================== 3 | System Specific Notes 4 | =========================================================================== 5 | Linux: 6 | The linux touch system is currently based off event streams, and proc/bus/devices. The active user must be given permissions to read /dev/input/TOUCHDEVICE, where TOUCHDEVICE is the event stream for your device. Currently only Wacom tablets are supported. If you have an unsupported tablet contact me at jim.tla+sdl_touch@gmail.com and I will help you get support for it. 7 | 8 | Mac: 9 | The Mac and iPhone APIs are pretty. If your touch device supports them then you'll be fine. If it doesn't, then there isn't much we can do. 10 | 11 | iPhone: 12 | Works out of box. 13 | 14 | Windows: 15 | Unfortunately there is no windows support as of yet. Support for Windows 7 is planned, but we currently have no way to test. If you have a Windows 7 WM_TOUCH supported device, and are willing to help test please contact me at jim.tla+sdl_touch@gmail.com 16 | 17 | =========================================================================== 18 | Events 19 | =========================================================================== 20 | SDL_FINGERDOWN: 21 | Sent when a finger (or stylus) is placed on a touch device. 22 | Fields: 23 | * event.tfinger.touchId - the Id of the touch device. 24 | * event.tfinger.fingerId - the Id of the finger which just went down. 25 | * event.tfinger.x - the x coordinate of the touch (0..1) 26 | * event.tfinger.y - the y coordinate of the touch (0..1) 27 | * event.tfinger.pressure - the pressure of the touch (0..1) 28 | 29 | SDL_FINGERMOTION: 30 | Sent when a finger (or stylus) is moved on the touch device. 31 | Fields: 32 | Same as SDL_FINGERDOWN but with additional: 33 | * event.tfinger.dx - change in x coordinate during this motion event. 34 | * event.tfinger.dy - change in y coordinate during this motion event. 35 | 36 | SDL_FINGERUP: 37 | Sent when a finger (or stylus) is lifted from the touch device. 38 | Fields: 39 | Same as SDL_FINGERDOWN. 40 | 41 | 42 | =========================================================================== 43 | Functions 44 | =========================================================================== 45 | SDL provides the ability to access the underlying SDL_Finger structures. 46 | These structures should _never_ be modified. 47 | 48 | The following functions are included from SDL_touch.h 49 | 50 | To get a SDL_TouchID call SDL_GetTouchDevice(int index). 51 | This returns a SDL_TouchID. 52 | IMPORTANT: If the touch has been removed, or there is no touch with the given index, SDL_GetTouchDevice() will return 0. Be sure to check for this! 53 | 54 | The number of touch devices can be queried with SDL_GetNumTouchDevices(). 55 | 56 | A SDL_TouchID may be used to get pointers to SDL_Finger. 57 | 58 | SDL_GetNumTouchFingers(touchID) may be used to get the number of fingers currently down on the device. 59 | 60 | The most common reason to access SDL_Finger is to query the fingers outside the event. In most cases accessing the fingers is using the event. This would be accomplished by code like the following: 61 | 62 | float x = event.tfinger.x; 63 | float y = event.tfinger.y; 64 | 65 | 66 | 67 | To get a SDL_Finger, call SDL_GetTouchFinger(SDL_TouchID touchID, int index), where touchID is a SDL_TouchID, and index is the requested finger. 68 | This returns a SDL_Finger *, or NULL if the finger does not exist, or has been removed. 69 | A SDL_Finger is guaranteed to be persistent for the duration of a touch, but it will be de-allocated as soon as the finger is removed. This occurs when the SDL_FINGERUP event is _added_ to the event queue, and thus _before_ the SDL_FINGERUP event is polled. 70 | As a result, be very careful to check for NULL return values. 71 | 72 | A SDL_Finger has the following fields: 73 | * x, y: 74 | The current coordinates of the touch. 75 | * pressure: 76 | The pressure of the touch. 77 | 78 | 79 | =========================================================================== 80 | Notes 81 | =========================================================================== 82 | For a complete example see test/testgesture.c 83 | 84 | Please direct questions/comments to: 85 | jim.tla+sdl_touch@gmail.com 86 | (original author, API was changed since) 87 | -------------------------------------------------------------------------------- /Source/Windows/MicroCity/WinDebug.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Defines.h" 3 | #include "Game.h" 4 | 5 | #define DEBUG_ZOOM_SCALE 5 6 | 7 | SDL_Window* DebugWindow; 8 | SDL_Renderer* DebugRenderer; 9 | SDL_Surface* DebugSurface; 10 | SDL_Texture* DebugTexture; 11 | 12 | void DebugPutPixel(int x, int y, Uint32 col) 13 | { 14 | SDL_Surface* surface = DebugSurface; 15 | 16 | int bpp = surface->format->BytesPerPixel; 17 | Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; 18 | 19 | *(Uint32 *)p = col; 20 | } 21 | 22 | typedef struct 23 | { 24 | int score; 25 | int crime; 26 | int pollution; 27 | int localInfluence; 28 | int populationEffect; 29 | int randomEffect; 30 | } BuildingDebug; 31 | 32 | const char* DebugViewNames[] = 33 | { 34 | "Score", 35 | "Crime", 36 | "Pollution", 37 | "Local influence", 38 | "Population effect", 39 | "Random effect" 40 | }; 41 | 42 | BuildingDebug BuildingDebugValues[MAX_BUILDINGS]; 43 | 44 | int CurrentDebugView = 0; 45 | 46 | void DebugBuildingScore(Building* building, int score, int crime, int pollution, int localInfluence, int populationEffect, int randomEffect) 47 | { 48 | for (int n = 0; n < MAX_BUILDINGS; n++) 49 | { 50 | if (building == &State.buildings[n]) 51 | { 52 | BuildingDebugValues[n].score = score; 53 | BuildingDebugValues[n].crime = crime; 54 | BuildingDebugValues[n].pollution = pollution; 55 | BuildingDebugValues[n].localInfluence = localInfluence; 56 | BuildingDebugValues[n].populationEffect = populationEffect; 57 | BuildingDebugValues[n].randomEffect = randomEffect; 58 | return; 59 | } 60 | } 61 | } 62 | 63 | void SetCurrentDebugView(int index) 64 | { 65 | CurrentDebugView = index; 66 | SDL_SetWindowTitle(DebugWindow, DebugViewNames[index]); 67 | } 68 | 69 | void UpdateDebugView() 70 | { 71 | for (int y = 0; y < MAP_HEIGHT; y++) 72 | { 73 | for (int x = 0; x < MAP_WIDTH; x++) 74 | { 75 | Uint32 col = SDL_MapRGBA(DebugSurface->format, 0, 0, 0, 255); 76 | 77 | DebugPutPixel(x, y, col); 78 | } 79 | } 80 | 81 | for (int n = 0; n < MAX_BUILDINGS; n++) 82 | { 83 | Building* building = &State.buildings[n]; 84 | if (building->type && !IsRubble(building->type)) 85 | { 86 | Uint32 col = SDL_MapRGBA(DebugSurface->format, 0, 0, 0, 255); 87 | 88 | int value = 0; 89 | 90 | switch (CurrentDebugView) 91 | { 92 | case 0: 93 | value = BuildingDebugValues[n].score; 94 | break; 95 | case 1: 96 | value = -BuildingDebugValues[n].crime; 97 | break; 98 | case 2: 99 | value = -BuildingDebugValues[n].pollution; 100 | break; 101 | case 3: 102 | value = BuildingDebugValues[n].localInfluence; 103 | break; 104 | case 4: 105 | value = BuildingDebugValues[n].populationEffect; 106 | break; 107 | case 5: 108 | value = BuildingDebugValues[n].randomEffect; 109 | break; 110 | } 111 | 112 | value *= 3; 113 | 114 | if (value > 0) 115 | { 116 | uint8_t intensity = value < 255 ? value : 255; 117 | col = SDL_MapRGBA(DebugSurface->format, 0, intensity, 0, 255); 118 | } 119 | else 120 | { 121 | uint8_t intensity = value > -255 ? -value : 255; 122 | col = SDL_MapRGBA(DebugSurface->format, intensity, 0, 0, 255); 123 | } 124 | 125 | const BuildingInfo* info = GetBuildingInfo(building->type); 126 | for (int i = 0; i < info->width; i++) 127 | { 128 | for (int j = 0; j < info->height; j++) 129 | { 130 | DebugPutPixel(building->x + i, building->y + j, col); 131 | } 132 | } 133 | } 134 | } 135 | 136 | SDL_UpdateTexture(DebugTexture, NULL, DebugSurface->pixels, DebugSurface->pitch); 137 | SDL_RenderCopy(DebugRenderer, DebugTexture, NULL, NULL); 138 | SDL_RenderPresent(DebugRenderer); 139 | 140 | } 141 | 142 | void CreateDebugWindow() 143 | { 144 | // Debug window 145 | SDL_CreateWindowAndRenderer(MAP_WIDTH * DEBUG_ZOOM_SCALE, MAP_HEIGHT * DEBUG_ZOOM_SCALE, SDL_WINDOW_RESIZABLE, &DebugWindow, &DebugRenderer); 146 | SDL_RenderSetLogicalSize(DebugRenderer, MAP_WIDTH, MAP_HEIGHT); 147 | 148 | DebugSurface = SDL_CreateRGBSurface(0, MAP_WIDTH, MAP_HEIGHT, 32, 149 | 0x000000ff, 150 | 0x0000ff00, 151 | 0x00ff0000, 152 | 0xff000000 153 | ); 154 | DebugTexture = SDL_CreateTexture(DebugRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, DebugSurface->w, DebugSurface->h); 155 | 156 | } -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 0x00000001u 76 | #define SDL_INIT_AUDIO 0x00000010u 77 | #define SDL_INIT_VIDEO 0x00000020u /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ 78 | #define SDL_INIT_JOYSTICK 0x00000200u /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */ 79 | #define SDL_INIT_HAPTIC 0x00001000u 80 | #define SDL_INIT_GAMECONTROLLER 0x00002000u /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */ 81 | #define SDL_INIT_EVENTS 0x00004000u 82 | #define SDL_INIT_NOPARACHUTE 0x00100000u /**< 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/docs/README-nacl.md: -------------------------------------------------------------------------------- 1 | Native Client 2 | ================================================================================ 3 | 4 | Requirements: 5 | 6 | * Native Client SDK (https://developer.chrome.com/native-client), 7 | (tested with Pepper version 33 or higher). 8 | 9 | The SDL backend for Chrome's Native Client has been tested only with the PNaCl 10 | toolchain, which generates binaries designed to run on ARM and x86_32/64 11 | platforms. This does not mean it won't work with the other toolchains! 12 | 13 | ================================================================================ 14 | Building SDL for NaCl 15 | ================================================================================ 16 | 17 | Set up the right environment variables (see naclbuild.sh), then configure SDL with: 18 | 19 | configure --host=pnacl --prefix some/install/destination 20 | 21 | Then "make". 22 | 23 | As an example of how to create a deployable app a Makefile project is provided 24 | in test/nacl/Makefile, which includes some monkey patching of the common.mk file 25 | provided by NaCl, without which linking properly to SDL won't work (the search 26 | path can't be modified externally, so the linker won't find SDL's binaries unless 27 | you dump them into the SDK path, which is inconvenient). 28 | Also provided in test/nacl is the required support file, such as index.html, 29 | manifest.json, etc. 30 | SDL apps for NaCl run on a worker thread using the ppapi_simple infrastructure. 31 | This allows for blocking calls on all the relevant systems (OpenGL ES, filesystem), 32 | hiding the asynchronous nature of the browser behind the scenes...which is not the 33 | same as making it disappear! 34 | 35 | 36 | ================================================================================ 37 | Running tests 38 | ================================================================================ 39 | 40 | Due to the nature of NaCl programs, building and running SDL tests is not as 41 | straightforward as one would hope. The script naclbuild.sh in build-scripts 42 | automates the process and should serve as a guide for users of SDL trying to build 43 | their own applications. 44 | 45 | Basic usage: 46 | 47 | ./naclbuild.sh path/to/pepper/toolchain (i.e. ~/naclsdk/pepper_35) 48 | 49 | This will build testgles2.c by default. 50 | 51 | If you want to build a different test, for example testrendercopyex.c: 52 | 53 | SOURCES=~/sdl/SDL/test/testrendercopyex.c ./naclbuild.sh ~/naclsdk/pepper_35 54 | 55 | Once the build finishes, you have to serve the contents with a web server (the 56 | script will give you instructions on how to do that with Python). 57 | 58 | ================================================================================ 59 | RWops and nacl_io 60 | ================================================================================ 61 | 62 | SDL_RWops work transparently with nacl_io. Two functions control the mount points: 63 | 64 | int mount(const char* source, const char* target, 65 | const char* filesystemtype, 66 | unsigned long mountflags, const void *data); 67 | int umount(const char *target); 68 | 69 | For convenience, SDL will by default mount an httpfs tree at / before calling 70 | the app's main function. Such setting can be overridden by calling: 71 | 72 | umount("/"); 73 | 74 | And then mounting a different filesystem at / 75 | 76 | It's important to consider that the asynchronous nature of file operations on a 77 | browser is hidden from the application, effectively providing the developer with 78 | a set of blocking file operations just like you get in a regular desktop 79 | environment, which eases the job of porting to Native Client, but also introduces 80 | a set of challenges of its own, in particular when big file sizes and slow 81 | connections are involved. 82 | 83 | For more information on how nacl_io and mount points work, see: 84 | 85 | https://developer.chrome.com/native-client/devguide/coding/nacl_io 86 | https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h 87 | 88 | To be able to save into the directory "/save/" (like backup of game) : 89 | 90 | mount("", "/save", "html5fs", 0, "type=PERSISTENT"); 91 | 92 | And add to manifest.json : 93 | 94 | "permissions": [ 95 | "unlimitedStorage" 96 | ] 97 | 98 | ================================================================================ 99 | TODO - Known Issues 100 | ================================================================================ 101 | * Testing of all systems with a real application (something other than SDL's tests) 102 | * Key events don't seem to work properly 103 | 104 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_test_harness.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/begin_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | # else 68 | # define DECLSPEC 69 | # endif 70 | # endif 71 | #endif 72 | 73 | /* By default SDL uses the C calling convention */ 74 | #ifndef SDLCALL 75 | #if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) 76 | #define SDLCALL __cdecl 77 | #else 78 | #define SDLCALL 79 | #endif 80 | #endif /* SDLCALL */ 81 | 82 | /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ 83 | #ifdef __SYMBIAN32__ 84 | #undef DECLSPEC 85 | #define DECLSPEC 86 | #endif /* __SYMBIAN32__ */ 87 | 88 | /* Force structure packing at 4 byte alignment. 89 | This is necessary if the header is included in code which has structure 90 | packing set to an alternate value, say for loading structures from disk. 91 | The packing is reset to the previous value in close_code.h 92 | */ 93 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) 94 | #ifdef _MSC_VER 95 | #pragma warning(disable: 4103) 96 | #endif 97 | #ifdef __BORLANDC__ 98 | #pragma nopackwarning 99 | #endif 100 | #ifdef _M_X64 101 | /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ 102 | #pragma pack(push,8) 103 | #else 104 | #pragma pack(push,4) 105 | #endif 106 | #endif /* Compiler needs structure packing set */ 107 | 108 | #ifndef SDL_INLINE 109 | #if defined(__GNUC__) 110 | #define SDL_INLINE __inline__ 111 | #elif defined(_MSC_VER) || defined(__BORLANDC__) || \ 112 | defined(__DMC__) || defined(__SC__) || \ 113 | defined(__WATCOMC__) || defined(__LCC__) || \ 114 | defined(__DECC) 115 | #define SDL_INLINE __inline 116 | #ifndef __inline__ 117 | #define __inline__ __inline 118 | #endif 119 | #else 120 | #define SDL_INLINE inline 121 | #ifndef __inline__ 122 | #define __inline__ inline 123 | #endif 124 | #endif 125 | #endif /* SDL_INLINE not defined */ 126 | 127 | #ifndef SDL_FORCE_INLINE 128 | #if defined(_MSC_VER) 129 | #define SDL_FORCE_INLINE __forceinline 130 | #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) 131 | #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ 132 | #else 133 | #define SDL_FORCE_INLINE static SDL_INLINE 134 | #endif 135 | #endif /* SDL_FORCE_INLINE not defined */ 136 | 137 | /* Apparently this is needed by several Windows compilers */ 138 | #if !defined(__MACH__) 139 | #ifndef NULL 140 | #ifdef __cplusplus 141 | #define NULL 0 142 | #else 143 | #define NULL ((void *)0) 144 | #endif 145 | #endif /* NULL */ 146 | #endif /* ! Mac OS X - breaks precompiled headers */ 147 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_rect.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_test_md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_messagebox.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_main.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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.md 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 | -------------------------------------------------------------------------------- /Source/MicroCity/Building.cpp: -------------------------------------------------------------------------------- 1 | #include "Game.h" 2 | #include "Building.h" 3 | #include "Connectivity.h" 4 | #include "Draw.h" 5 | 6 | const BuildingInfo BuildingMetaData[] PROGMEM = 7 | { 8 | // None, 9 | { 0, 0, 0, 0 }, 10 | // Residential, 11 | { 100, 3, 3, 64 }, 12 | // Commercial, 13 | { 100, 3, 3, 67 }, 14 | // Industrial, 15 | { 100, 3, 3, 70 }, 16 | // Powerplant, 17 | { 3000, 4, 4, 160 }, 18 | // Park, 19 | { 50, 3, 3, 73 }, 20 | // PoliceDept, 21 | { 500, 3, 3, 76 }, 22 | // FireDept, 23 | { 500, 3, 3, 124 }, 24 | // Stadium, 25 | { 3000, 4, 4, 164 }, 26 | // Rubble3x3, 27 | { 0, 3, 3, 0 }, 28 | // Rubble4x4, 29 | { 0, 4, 4, 0 }, 30 | }; 31 | 32 | const BuildingInfo* GetBuildingInfo(uint8_t buildingType) 33 | { 34 | return &BuildingMetaData[buildingType]; 35 | } 36 | 37 | bool PlaceBuilding(uint8_t buildingType, uint8_t x, uint8_t y) 38 | { 39 | int index = 0; 40 | 41 | while (index < MAX_BUILDINGS) 42 | { 43 | if (State.buildings[index].type == 0) 44 | { 45 | break; 46 | } 47 | index++; 48 | } 49 | 50 | if (index == MAX_BUILDINGS) 51 | { 52 | // Look for rubble placements and replace them instead: 53 | index = 0; 54 | 55 | while (index < MAX_BUILDINGS) 56 | { 57 | if (State.buildings[index].type == Rubble3x3 || State.buildings[index].type == Rubble4x4) 58 | { 59 | break; 60 | } 61 | index++; 62 | } 63 | 64 | if (index == MAX_BUILDINGS) 65 | { 66 | return false; 67 | } 68 | } 69 | 70 | Building* newBuilding = &State.buildings[index]; 71 | newBuilding->type = buildingType; 72 | newBuilding->x = x; 73 | newBuilding->y = y; 74 | newBuilding->populationDensity = 0; 75 | newBuilding->hasPower = false; 76 | newBuilding->onFire = 0; 77 | 78 | // Internally building space is represented as power lines to correctly flood fill etc 79 | const BuildingInfo* metadata = GetBuildingInfo(buildingType); 80 | uint8_t width = pgm_read_byte(&metadata->width); 81 | uint8_t height = pgm_read_byte(&metadata->height); 82 | uint8_t connectionMask = buildingType == Park ? 0 : PowerlineMask; 83 | 84 | for (int i = x; i < x + width; i++) 85 | { 86 | for (int j = y; j < y + height; j++) 87 | { 88 | SetConnections(i, j, connectionMask); 89 | } 90 | } 91 | 92 | // Check for overlapping rubble and remove 93 | for (int n = 0; n < MAX_BUILDINGS; n++) 94 | { 95 | Building* building = &State.buildings[n]; 96 | 97 | if (IsRubble(building->type)) 98 | { 99 | const BuildingInfo* otherMetadata = GetBuildingInfo(building->type); 100 | uint8_t otherWidth = pgm_read_byte(&otherMetadata->width); 101 | uint8_t otherHeight = pgm_read_byte(&otherMetadata->height); 102 | 103 | if (x + width > building->x && x < building->x + otherWidth 104 | && y + height > building->y && y < building->y + otherHeight) 105 | { 106 | building->type = 0; 107 | } 108 | } 109 | } 110 | 111 | RefreshBuildingTiles(newBuilding); 112 | 113 | return true; 114 | } 115 | 116 | bool CanPlaceBuilding(uint8_t buildingType, uint8_t x, uint8_t y) 117 | { 118 | const BuildingInfo* metadata = GetBuildingInfo(buildingType); 119 | uint8_t width = pgm_read_byte(&metadata->width); 120 | uint8_t height = pgm_read_byte(&metadata->height); 121 | 122 | if (x + width > MAP_WIDTH) 123 | return false; 124 | if (y + height > MAP_HEIGHT) 125 | return false; 126 | 127 | // Check if trying to build on top of road 128 | for (int i = x; i < x + width; i++) 129 | { 130 | for (int j = y; j < y + height; j++) 131 | { 132 | // Check terrain is not water 133 | if (IsTerrainClear(i, j) == false) 134 | return false; 135 | 136 | if (GetConnections(i, j) & RoadMask) 137 | return false; 138 | } 139 | } 140 | 141 | // Check building overlaps 142 | for (int n = 0; n < MAX_BUILDINGS; n++) 143 | { 144 | Building* building = &State.buildings[n]; 145 | 146 | if (building->type && !IsRubble(building->type)) 147 | { 148 | const BuildingInfo* otherMetadata = GetBuildingInfo(building->type); 149 | uint8_t otherWidth = pgm_read_byte(&otherMetadata->width); 150 | uint8_t otherHeight = pgm_read_byte(&otherMetadata->height); 151 | 152 | if (x + width > building->x && x < building->x + otherWidth 153 | && y + height > building->y && y < building->y + otherHeight) 154 | { 155 | return false; 156 | } 157 | } 158 | 159 | } 160 | 161 | return true; 162 | } 163 | 164 | Building* GetBuilding(uint8_t x, uint8_t y) 165 | { 166 | for (int n = 0; n < MAX_BUILDINGS; n++) 167 | { 168 | Building* building = &State.buildings[n]; 169 | 170 | if (building->type) 171 | { 172 | const BuildingInfo* metadata = GetBuildingInfo(building->type); 173 | uint8_t width = pgm_read_byte(&metadata->width); 174 | uint8_t height = pgm_read_byte(&metadata->height); 175 | 176 | if (x >= building->x && x < building->x + width && y >= building->y && y < building->y + height) 177 | { 178 | return building; 179 | } 180 | } 181 | } 182 | 183 | return nullptr; 184 | } 185 | 186 | void DestroyBuilding(Building* building) 187 | { 188 | const BuildingInfo* info = GetBuildingInfo(building->type); 189 | uint8_t width = pgm_read_byte(&info->width); 190 | uint8_t height = pgm_read_byte(&info->height); 191 | 192 | for (int y = building->y; y < building->y + height; y++) 193 | { 194 | for (int x = building->x; x < building->x + width; x++) 195 | { 196 | SetConnections(x, y, 0); 197 | } 198 | } 199 | 200 | building->onFire = 0; 201 | building->type = width == 3 ? Rubble3x3 : Rubble4x4; 202 | 203 | for (uint8_t y = building->y; y < building->y + height; y++) 204 | { 205 | for (uint8_t x = building->x; x < building->x + width; x++) 206 | { 207 | SetTile(x, y, RUBBLE_TILE); 208 | } 209 | } 210 | } -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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_TV 74 | #undef __TVOS__ 75 | #define __TVOS__ 1 76 | #endif 77 | #if TARGET_OS_IPHONE 78 | /* if compiling for iOS */ 79 | #undef __IPHONEOS__ 80 | #define __IPHONEOS__ 1 81 | #undef __MACOSX__ 82 | #else 83 | /* if not compiling for iOS */ 84 | #undef __MACOSX__ 85 | #define __MACOSX__ 1 86 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 87 | # error SDL for Mac OS X only supports deploying on 10.6 and above. 88 | #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */ 89 | #endif /* TARGET_OS_IPHONE */ 90 | #endif /* defined(__APPLE__) */ 91 | 92 | #if defined(__NetBSD__) 93 | #undef __NETBSD__ 94 | #define __NETBSD__ 1 95 | #endif 96 | #if defined(__OpenBSD__) 97 | #undef __OPENBSD__ 98 | #define __OPENBSD__ 1 99 | #endif 100 | #if defined(__OS2__) 101 | #undef __OS2__ 102 | #define __OS2__ 1 103 | #endif 104 | #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) 105 | #undef __OSF__ 106 | #define __OSF__ 1 107 | #endif 108 | #if defined(__QNXNTO__) 109 | #undef __QNXNTO__ 110 | #define __QNXNTO__ 1 111 | #endif 112 | #if defined(riscos) || defined(__riscos) || defined(__riscos__) 113 | #undef __RISCOS__ 114 | #define __RISCOS__ 1 115 | #endif 116 | #if defined(__sun) && defined(__SVR4) 117 | #undef __SOLARIS__ 118 | #define __SOLARIS__ 1 119 | #endif 120 | 121 | #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) 122 | /* Try to find out if we're compiling for WinRT or non-WinRT */ 123 | /* If _USING_V110_SDK71_ is defined it means we are using the v110_xp or v120_xp toolset. */ 124 | #if (defined(_MSC_VER) && (_MSC_VER >= 1700) && !_USING_V110_SDK71_) /* _MSC_VER==1700 for MSVC 2012 */ 125 | #include 126 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 127 | #undef __WINDOWS__ 128 | #define __WINDOWS__ 1 129 | /* See if we're compiling for WinRT: */ 130 | #elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) 131 | #undef __WINRT__ 132 | #define __WINRT__ 1 133 | #endif 134 | #else 135 | #undef __WINDOWS__ 136 | #define __WINDOWS__ 1 137 | #endif /* _MSC_VER < 1700 */ 138 | #endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */ 139 | 140 | #if defined(__WINDOWS__) 141 | #undef __WIN32__ 142 | #define __WIN32__ 1 143 | #endif 144 | #if defined(__PSP__) 145 | #undef __PSP__ 146 | #define __PSP__ 1 147 | #endif 148 | 149 | /* The NACL compiler defines __native_client__ and __pnacl__ 150 | * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi 151 | */ 152 | #if defined(__native_client__) 153 | #undef __LINUX__ 154 | #undef __NACL__ 155 | #define __NACL__ 1 156 | #endif 157 | #if defined(__pnacl__) 158 | #undef __LINUX__ 159 | #undef __PNACL__ 160 | #define __PNACL__ 1 161 | /* PNACL with newlib supports static linking only */ 162 | #define __SDL_NOGETPROCADDR__ 163 | #endif 164 | 165 | 166 | #include "begin_code.h" 167 | /* Set up for C function definitions, even when using C++ */ 168 | #ifdef __cplusplus 169 | extern "C" { 170 | #endif 171 | 172 | /** 173 | * \brief Gets the name of the platform. 174 | */ 175 | extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); 176 | 177 | /* Ends C function definitions when using C++ */ 178 | #ifdef __cplusplus 179 | } 180 | #endif 181 | #include "close_code.h" 182 | 183 | #endif /* _SDL_platform_h */ 184 | 185 | /* vi: set ts=4 sw=4 expandtab: */ 186 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_test_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_filesystem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 5 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 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_shape.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | -------------------------------------------------------------------------------- /Source/Windows/MicroCity/WinMain.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "Defines.h" 6 | #include "Game.h" 7 | #include "Interface.h" 8 | #include "lodepng.h" 9 | #include "Simulation.h" 10 | #include "WinDebug.h" 11 | 12 | #define ZOOM_SCALE 3 13 | #define SAVEGAME_NAME "savedcity.cty" 14 | 15 | SDL_Window* AppWindow; 16 | SDL_Renderer* AppRenderer; 17 | SDL_Surface* ScreenSurface; 18 | SDL_Texture* ScreenTexture; 19 | 20 | uint8_t InputMask = 0; 21 | 22 | bool IsRecording = false; 23 | int CurrentRecordingFrame = 0; 24 | 25 | struct KeyMap 26 | { 27 | SDL_Keycode key; 28 | uint8_t mask; 29 | }; 30 | 31 | KeyMap KeyMappings[] = 32 | { 33 | { SDLK_LEFT, INPUT_LEFT }, 34 | { SDLK_RIGHT, INPUT_RIGHT }, 35 | { SDLK_UP, INPUT_UP }, 36 | { SDLK_DOWN, INPUT_DOWN }, 37 | { SDLK_z, INPUT_A }, 38 | { SDLK_x, INPUT_B }, 39 | }; 40 | 41 | void SaveCity() 42 | { 43 | FILE* fs; 44 | 45 | if (fopen_s(&fs, SAVEGAME_NAME, "wb") == 0) 46 | { 47 | fwrite(&State, sizeof(GameState), 1, fs); 48 | fflush(fs); 49 | fclose(fs); 50 | } 51 | } 52 | 53 | bool LoadCity() 54 | { 55 | FILE* fs; 56 | 57 | if (fopen_s(&fs, SAVEGAME_NAME, "rb") == 0) 58 | { 59 | fread(&State, sizeof(GameState), 1, fs); 60 | fclose(fs); 61 | 62 | if (State.timeToNextDisaster > MAX_TIME_BETWEEN_DISASTERS) 63 | { 64 | State.timeToNextDisaster = MIN_TIME_BETWEEN_DISASTERS; 65 | } 66 | return true; 67 | } 68 | 69 | return false; 70 | } 71 | 72 | void PutPixel(uint8_t x, uint8_t y, uint8_t colour) 73 | { 74 | SDL_Surface* surface = ScreenSurface; 75 | 76 | Uint32 col = colour ? SDL_MapRGBA(surface->format, 255, 255, 255, 255) : SDL_MapRGBA(surface->format, 0, 0, 0, 255); 77 | 78 | int bpp = surface->format->BytesPerPixel; 79 | Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; 80 | 81 | *(Uint32 *)p = col; 82 | } 83 | 84 | void DrawBitmap(const uint8_t* data, uint8_t x, uint8_t y, uint8_t w, uint8_t h) 85 | { 86 | for (int j = 0; j < h; j++) 87 | { 88 | for (int i = 0; i < w; i++) 89 | { 90 | int blockX = i / 8; 91 | int blockY = j / 8; 92 | int blocksPerWidth = w / 8; 93 | int blockIndex = blockY * blocksPerWidth + blockX; 94 | uint8_t pixels = data[blockIndex * 8 + i % 8]; 95 | uint8_t mask = 1 << (j % 8); 96 | if (pixels & mask) 97 | { 98 | PutPixel(x + i, y + j, 1); 99 | } 100 | } 101 | } 102 | } 103 | 104 | uint8_t GetInput() 105 | { 106 | return InputMask; 107 | } 108 | 109 | uint8_t* GetPowerGrid() 110 | { 111 | static uint8_t PowerGrid[DISPLAY_WIDTH * DISPLAY_HEIGHT / 8]; 112 | return PowerGrid; 113 | } 114 | 115 | int main(int argc, char* argv[]) 116 | { 117 | SDL_Init(SDL_INIT_EVERYTHING); 118 | 119 | CreateDebugWindow(); 120 | 121 | SDL_CreateWindowAndRenderer(DISPLAY_WIDTH * ZOOM_SCALE, DISPLAY_HEIGHT * ZOOM_SCALE, SDL_WINDOW_RESIZABLE, &AppWindow, &AppRenderer); 122 | SDL_RenderSetLogicalSize(AppRenderer, DISPLAY_WIDTH, DISPLAY_HEIGHT); 123 | 124 | ScreenSurface = SDL_CreateRGBSurface(0, DISPLAY_WIDTH, DISPLAY_HEIGHT, 32, 125 | 0x000000ff, 126 | 0x0000ff00, 127 | 0x00ff0000, 128 | 0xff000000 129 | ); 130 | ScreenTexture = SDL_CreateTexture(AppRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, ScreenSurface->w, ScreenSurface->h); 131 | 132 | InitGame(); 133 | 134 | bool running = true; 135 | int playRate = 1; 136 | 137 | while (running) 138 | { 139 | SDL_Event event; 140 | while (SDL_PollEvent(&event)) 141 | { 142 | switch (event.type) 143 | { 144 | case SDL_QUIT: 145 | running = false; 146 | break; 147 | case SDL_KEYDOWN: 148 | for (int n = 0; n < sizeof(KeyMappings); n++) 149 | { 150 | if (event.key.keysym.sym == KeyMappings[n].key) 151 | { 152 | InputMask |= KeyMappings[n].mask; 153 | } 154 | } 155 | switch (event.key.keysym.sym) 156 | { 157 | case SDLK_f: 158 | StartRandomFire(); 159 | break; 160 | case SDLK_F1: 161 | SaveCity(); 162 | break; 163 | case SDLK_F2: 164 | LoadCity(); 165 | break; 166 | case SDLK_ESCAPE: 167 | running = false; 168 | break; 169 | case SDLK_TAB: 170 | playRate = 10; 171 | break; 172 | case SDLK_F12: 173 | { 174 | lodepng::encode(std::string("screenshot.png"), (unsigned char*)(ScreenSurface->pixels), ScreenSurface->w, ScreenSurface->h); 175 | } 176 | break; 177 | case SDLK_F11: 178 | IsRecording = !IsRecording; 179 | break; 180 | case SDLK_1: 181 | SetCurrentDebugView(0); 182 | break; 183 | case SDLK_2: 184 | SetCurrentDebugView(1); 185 | break; 186 | case SDLK_3: 187 | SetCurrentDebugView(2); 188 | break; 189 | case SDLK_4: 190 | SetCurrentDebugView(3); 191 | break; 192 | case SDLK_5: 193 | SetCurrentDebugView(4); 194 | break; 195 | case SDLK_6: 196 | SetCurrentDebugView(5); 197 | break; 198 | } 199 | break; 200 | case SDL_KEYUP: 201 | for (int n = 0; n < sizeof(KeyMappings); n++) 202 | { 203 | if (event.key.keysym.sym == KeyMappings[n].key) 204 | { 205 | InputMask &= ~KeyMappings[n].mask; 206 | } 207 | } 208 | if (event.key.keysym.sym == SDLK_TAB) 209 | playRate = 1; 210 | break; 211 | } 212 | } 213 | 214 | SDL_SetRenderDrawColor(AppRenderer, 206, 221, 231, 255); 215 | SDL_RenderClear(AppRenderer); 216 | 217 | //memset(ScreenSurface->pixels, 0, ScreenSurface->format->BytesPerPixel * ScreenSurface->w * ScreenSurface->h); 218 | 219 | for (int n = 0; n < playRate; n++) 220 | { 221 | TickGame(); 222 | } 223 | 224 | if (IsRecording) 225 | { 226 | std::ostringstream filename; 227 | filename << "Frame"; 228 | filename << std::setfill('0') << std::setw(5) << CurrentRecordingFrame << ".png"; 229 | 230 | lodepng::encode(filename.str(), (unsigned char*)(ScreenSurface->pixels), ScreenSurface->w, ScreenSurface->h); 231 | CurrentRecordingFrame++; 232 | } 233 | 234 | SDL_UpdateTexture(ScreenTexture, NULL, ScreenSurface->pixels, ScreenSurface->pitch); 235 | SDL_Rect src, dest; 236 | src.x = src.y = dest.x = dest.y = 0; 237 | src.w = DISPLAY_WIDTH; 238 | src.h = DISPLAY_HEIGHT; 239 | dest.w = DISPLAY_WIDTH; 240 | dest.h = DISPLAY_HEIGHT; 241 | SDL_RenderCopy(AppRenderer, ScreenTexture, &src, &dest); 242 | SDL_RenderPresent(AppRenderer); 243 | 244 | SDL_Delay(1000 / 25); 245 | 246 | UpdateDebugView(); 247 | } 248 | 249 | return 0; 250 | } 251 | -------------------------------------------------------------------------------- /Source/Windows/SDL/include/SDL_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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_config_windows_h 23 | #define _SDL_config_windows_h 24 | 25 | #include "SDL_platform.h" 26 | 27 | /* This is a set of defines to configure the SDL features */ 28 | 29 | #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) 30 | #if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) 31 | #define HAVE_STDINT_H 1 32 | #elif defined(_MSC_VER) 33 | typedef signed __int8 int8_t; 34 | typedef unsigned __int8 uint8_t; 35 | typedef signed __int16 int16_t; 36 | typedef unsigned __int16 uint16_t; 37 | typedef signed __int32 int32_t; 38 | typedef unsigned __int32 uint32_t; 39 | typedef signed __int64 int64_t; 40 | typedef unsigned __int64 uint64_t; 41 | #ifndef _UINTPTR_T_DEFINED 42 | #ifdef _WIN64 43 | typedef unsigned __int64 uintptr_t; 44 | #else 45 | typedef unsigned int uintptr_t; 46 | #endif 47 | #define _UINTPTR_T_DEFINED 48 | #endif 49 | /* Older Visual C++ headers don't have the Win64-compatible typedefs... */ 50 | #if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) 51 | #define DWORD_PTR DWORD 52 | #endif 53 | #if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) 54 | #define LONG_PTR LONG 55 | #endif 56 | #else /* !__GNUC__ && !_MSC_VER */ 57 | typedef signed char int8_t; 58 | typedef unsigned char uint8_t; 59 | typedef signed short int16_t; 60 | typedef unsigned short uint16_t; 61 | typedef signed int int32_t; 62 | typedef unsigned int uint32_t; 63 | typedef signed long long int64_t; 64 | typedef unsigned long long uint64_t; 65 | #ifndef _SIZE_T_DEFINED_ 66 | #define _SIZE_T_DEFINED_ 67 | typedef unsigned int size_t; 68 | #endif 69 | typedef unsigned int uintptr_t; 70 | #endif /* __GNUC__ || _MSC_VER */ 71 | #endif /* !_STDINT_H_ && !HAVE_STDINT_H */ 72 | 73 | #ifdef _WIN64 74 | # define SIZEOF_VOIDP 8 75 | #else 76 | # define SIZEOF_VOIDP 4 77 | #endif 78 | 79 | #define HAVE_DDRAW_H 1 80 | #define HAVE_DINPUT_H 1 81 | #define HAVE_DSOUND_H 1 82 | #define HAVE_DXGI_H 1 83 | #define HAVE_XINPUT_H 1 84 | 85 | /* This is disabled by default to avoid C runtime dependencies and manifest requirements */ 86 | #ifdef HAVE_LIBC 87 | /* Useful headers */ 88 | #define HAVE_STDIO_H 1 89 | #define STDC_HEADERS 1 90 | #define HAVE_STRING_H 1 91 | #define HAVE_CTYPE_H 1 92 | #define HAVE_MATH_H 1 93 | #define HAVE_SIGNAL_H 1 94 | 95 | /* C library functions */ 96 | #define HAVE_MALLOC 1 97 | #define HAVE_CALLOC 1 98 | #define HAVE_REALLOC 1 99 | #define HAVE_FREE 1 100 | #define HAVE_ALLOCA 1 101 | #define HAVE_QSORT 1 102 | #define HAVE_ABS 1 103 | #define HAVE_MEMSET 1 104 | #define HAVE_MEMCPY 1 105 | #define HAVE_MEMMOVE 1 106 | #define HAVE_MEMCMP 1 107 | #define HAVE_STRLEN 1 108 | #define HAVE__STRREV 1 109 | #define HAVE__STRUPR 1 110 | #define HAVE__STRLWR 1 111 | #define HAVE_STRCHR 1 112 | #define HAVE_STRRCHR 1 113 | #define HAVE_STRSTR 1 114 | #define HAVE__LTOA 1 115 | #define HAVE__ULTOA 1 116 | #define HAVE_STRTOL 1 117 | #define HAVE_STRTOUL 1 118 | #define HAVE_STRTOD 1 119 | #define HAVE_ATOI 1 120 | #define HAVE_ATOF 1 121 | #define HAVE_STRCMP 1 122 | #define HAVE_STRNCMP 1 123 | #define HAVE__STRICMP 1 124 | #define HAVE__STRNICMP 1 125 | #define HAVE_ATAN 1 126 | #define HAVE_ATAN2 1 127 | #define HAVE_ACOS 1 128 | #define HAVE_ASIN 1 129 | #define HAVE_CEIL 1 130 | #define HAVE_COS 1 131 | #define HAVE_COSF 1 132 | #define HAVE_FABS 1 133 | #define HAVE_FLOOR 1 134 | #define HAVE_LOG 1 135 | #define HAVE_POW 1 136 | #define HAVE_SIN 1 137 | #define HAVE_SINF 1 138 | #define HAVE_SQRT 1 139 | #define HAVE_SQRTF 1 140 | #define HAVE_TAN 1 141 | #define HAVE_TANF 1 142 | #if _MSC_VER >= 1800 143 | #define HAVE_STRTOLL 1 144 | #define HAVE_VSSCANF 1 145 | #define HAVE_COPYSIGN 1 146 | #define HAVE_SCALBN 1 147 | #endif 148 | #if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) 149 | #define HAVE_M_PI 1 150 | #endif 151 | #else 152 | #define HAVE_STDARG_H 1 153 | #define HAVE_STDDEF_H 1 154 | #endif 155 | 156 | /* Enable various audio drivers */ 157 | #define SDL_AUDIO_DRIVER_DSOUND 1 158 | #define SDL_AUDIO_DRIVER_XAUDIO2 1 159 | #define SDL_AUDIO_DRIVER_WINMM 1 160 | #define SDL_AUDIO_DRIVER_DISK 1 161 | #define SDL_AUDIO_DRIVER_DUMMY 1 162 | 163 | /* Enable various input drivers */ 164 | #define SDL_JOYSTICK_DINPUT 1 165 | #define SDL_JOYSTICK_XINPUT 1 166 | #define SDL_HAPTIC_DINPUT 1 167 | #define SDL_HAPTIC_XINPUT 1 168 | 169 | /* Enable various shared object loading systems */ 170 | #define SDL_LOADSO_WINDOWS 1 171 | 172 | /* Enable various threading systems */ 173 | #define SDL_THREAD_WINDOWS 1 174 | 175 | /* Enable various timer systems */ 176 | #define SDL_TIMER_WINDOWS 1 177 | 178 | /* Enable various video drivers */ 179 | #define SDL_VIDEO_DRIVER_DUMMY 1 180 | #define SDL_VIDEO_DRIVER_WINDOWS 1 181 | 182 | #ifndef SDL_VIDEO_RENDER_D3D 183 | #define SDL_VIDEO_RENDER_D3D 1 184 | #endif 185 | #ifndef SDL_VIDEO_RENDER_D3D11 186 | #define SDL_VIDEO_RENDER_D3D11 0 187 | #endif 188 | 189 | /* Enable OpenGL support */ 190 | #ifndef SDL_VIDEO_OPENGL 191 | #define SDL_VIDEO_OPENGL 1 192 | #endif 193 | #ifndef SDL_VIDEO_OPENGL_WGL 194 | #define SDL_VIDEO_OPENGL_WGL 1 195 | #endif 196 | #ifndef SDL_VIDEO_RENDER_OGL 197 | #define SDL_VIDEO_RENDER_OGL 1 198 | #endif 199 | #ifndef SDL_VIDEO_RENDER_OGL_ES2 200 | #define SDL_VIDEO_RENDER_OGL_ES2 1 201 | #endif 202 | #ifndef SDL_VIDEO_OPENGL_ES2 203 | #define SDL_VIDEO_OPENGL_ES2 1 204 | #endif 205 | #ifndef SDL_VIDEO_OPENGL_EGL 206 | #define SDL_VIDEO_OPENGL_EGL 1 207 | #endif 208 | 209 | 210 | /* Enable system power support */ 211 | #define SDL_POWER_WINDOWS 1 212 | 213 | /* Enable filesystem support */ 214 | #define SDL_FILESYSTEM_WINDOWS 1 215 | 216 | /* Enable assembly routines (Win64 doesn't have inline asm) */ 217 | #ifndef _WIN64 218 | #define SDL_ASSEMBLY_ROUTINES 1 219 | #endif 220 | 221 | #endif /* _SDL_config_windows_h */ 222 | --------------------------------------------------------------------------------