├── .gitignore ├── 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 ├── 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 │ │ ├── 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 └── Playdate │ ├── Source │ ├── assets │ │ ├── images │ │ │ ├── cursor.png │ │ │ ├── frame.png │ │ │ └── loading.png │ │ ├── launcher │ │ │ ├── Icon.png │ │ │ └── card.png │ │ └── fonts │ │ │ ├── font-Cuberick-Bold-table-12-15.png │ │ │ └── font-Cuberick-Bold.fnt │ ├── main.lua │ └── pdxinfo │ ├── .gitignore │ ├── src │ ├── PlaydateMain.h │ ├── Common.h │ ├── DrawLCDBitmap.h │ ├── CityOverview.h │ ├── Menu.h │ ├── PlaydateMain.cpp │ ├── DrawMap.h │ ├── BuildingScore.h │ ├── MicroCity.h │ ├── Menu.cpp │ ├── Dithering.h │ ├── Dithering.cpp │ ├── DrawLCDBitmap.cpp │ ├── CityInfo.h │ ├── CityOverview.cpp │ ├── DrawMap.cpp │ └── BuildingScore.cpp │ ├── .vscode │ ├── cmake-kits.json │ ├── playdate_simulator.cmake │ ├── environment.cmake │ ├── launch.json │ ├── arm.patched.cmake │ └── playdate_game.patched.cmake │ └── CMakeLists.txt ├── Playdate.code-workspace ├── readme-jp.md └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Source/.DS_Store 3 | Source/Playdate/Source/pdex.elf 4 | -------------------------------------------------------------------------------- /Images/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Images/demo.gif -------------------------------------------------------------------------------- /Images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Images/logo.png -------------------------------------------------------------------------------- /Images/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Images/tiles.png -------------------------------------------------------------------------------- /Images/Terrain1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Images/Terrain1.png -------------------------------------------------------------------------------- /Images/Terrain2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Images/Terrain2.png -------------------------------------------------------------------------------- /Images/Terrain3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Images/Terrain3.png -------------------------------------------------------------------------------- /Package/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Package/banner.png -------------------------------------------------------------------------------- /Package/screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Package/screen1.png -------------------------------------------------------------------------------- /Package/screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/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/abenokobo/MicroCity-Playdate/HEAD/Source/Windows/SDL/lib/x64/SDL2.dll -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x64/SDL2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Source/Windows/SDL/lib/x64/SDL2.lib -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x86/SDL2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Source/Windows/SDL/lib/x86/SDL2.dll -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x86/SDL2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Source/Windows/SDL/lib/x86/SDL2.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/SDL/lib/x64/SDL2main.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Source/Windows/SDL/lib/x64/SDL2main.lib -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x64/SDL2test.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Source/Windows/SDL/lib/x64/SDL2test.lib -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x86/SDL2main.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Source/Windows/SDL/lib/x86/SDL2main.lib -------------------------------------------------------------------------------- /Source/Windows/SDL/lib/x86/SDL2test.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Source/Windows/SDL/lib/x86/SDL2test.lib -------------------------------------------------------------------------------- /Source/Playdate/Source/assets/images/cursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Source/Playdate/Source/assets/images/cursor.png -------------------------------------------------------------------------------- /Source/Playdate/Source/assets/images/frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Source/Playdate/Source/assets/images/frame.png -------------------------------------------------------------------------------- /Source/Playdate/Source/assets/launcher/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Source/Playdate/Source/assets/launcher/Icon.png -------------------------------------------------------------------------------- /Source/Playdate/Source/assets/launcher/card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Source/Playdate/Source/assets/launcher/card.png -------------------------------------------------------------------------------- /Source/Playdate/Source/assets/images/loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Source/Playdate/Source/assets/images/loading.png -------------------------------------------------------------------------------- /Source/Windows/MicroCity/WinDebug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void CreateDebugWindow(void); 4 | void UpdateDebugView(void); 5 | void SetCurrentDebugView(int index); 6 | -------------------------------------------------------------------------------- /Source/Playdate/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | MicroCity.pdx 3 | MicroCity.pdx.zip 4 | Source/pdex.bin 5 | Source/pdex.dll 6 | Source/pdex.dylib 7 | src/.DS_Store 8 | .DS_Store 9 | 10 | -------------------------------------------------------------------------------- /Source/Playdate/Source/assets/fonts/font-Cuberick-Bold-table-12-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abenokobo/MicroCity-Playdate/HEAD/Source/Playdate/Source/assets/fonts/font-Cuberick-Bold-table-12-15.png -------------------------------------------------------------------------------- /Source/Playdate/src/PlaydateMain.h: -------------------------------------------------------------------------------- 1 | #ifndef __PLAYDATE_MAIN_H 2 | #define __PLAYDATE_MAIN_H 3 | 4 | 5 | #include "MicroCity.h" 6 | 7 | 8 | 9 | #endif // __PLAYDATE_MAIN_H 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Source/Playdate/Source/main.lua: -------------------------------------------------------------------------------- 1 | local pd = playdate 2 | 3 | function _addMenuFromLua(name, callback) 4 | local menu = playdate.getSystemMenu() 5 | local menuItem, error = menu:addMenuItem(name, callback) 6 | end 7 | -------------------------------------------------------------------------------- /Source/Playdate/Source/pdxinfo: -------------------------------------------------------------------------------- 1 | name=MicroCity 2 | author=James Howard, Abeno Studio 3 | bundleID=com.abenokobo.microcity 4 | version=v1.0.4 5 | imagePath=assets/launcher 6 | description=City simulator game for microcontrollers 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Playdate.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "name": "Playdate", 5 | "path": "Source/Playdate" 6 | }, 7 | { 8 | "path": "Source/MicroCity" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /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/Playdate/.vscode/cmake-kits.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Playdate Simulator", 4 | "toolchainFile": "${workspaceFolder}/.vscode/playdate_simulator.cmake" 5 | }, 6 | { 7 | "name": "Playdate Device", 8 | "toolchainFile": "${workspaceFolder}/.vscode/arm.patched.cmake" 9 | } 10 | ] 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /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/Playdate/src/Common.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMMON_H 2 | #define __COMMON_H 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #include 10 | 11 | #pragma GCC diagnostic push 12 | #include "pd_api.h" 13 | #pragma GCC diagnostic pop 14 | 15 | extern PlaydateAPI* gpd; 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | 22 | #include 23 | #include 24 | 25 | 26 | static const int PLAYDATE_ZOOM_SCALE = 3; 27 | 28 | 29 | 30 | #endif // __COMMON_H 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /readme-jp.md: -------------------------------------------------------------------------------- 1 | # MicroCity 2 | 3 | ![Demo](Images/demo.gif) 4 | 5 | MicroCity は組み込みシステム向けに作成された、都市開発シミュレーションゲームです。 6 | 7 | [English](readme.md) 8 | 9 | ## MicroCity for Playdate 10 | 11 | MicroCity for Playdate は [jhhoward/MicroCity](https://github.com/jhhoward/MicroCity) からフォークされました。 12 | 13 | ## ダウンロード 14 | 15 | [releases](https://github.com/abenokobo/MicroCity-Playdate/releases) から最新の MicroCity.pdx.zip をダウンロードしてください。 16 | 17 | ## インストール 18 | 19 | [Playdate ゲームのサイドロード(英語)](https://help.play.date/games/sideloading/) 20 | 21 | ## ビルド 22 | 23 | [Playdate.code-workspace](Playdate.code-workspace) を Visual Studio Code で開くと、Playdate 用のプロジェクトを読み込みます。 24 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # MicroCity 2 | 3 | ![Demo](Images/demo.gif) 4 | 5 | City simulator game for microcontrollers 6 | 7 | [日本語](readme-jp.md) 8 | 9 | ## MicroCity for Playdate 10 | 11 | MicroCity for Playdate is a forked from [jhhoward/MicroCity](https://github.com/jhhoward/MicroCity) 12 | 13 | ## Download 14 | 15 | Download the latest MicroCity.pdx.zip from [releases](https://github.com/abenokobo/MicroCity-Playdate/releases). 16 | 17 | ## Install guide 18 | 19 | [Sideloading a game on the Playdate console](https://help.play.date/games/sideloading/) 20 | 21 | ## How to build 22 | 23 | Open [Playdate.code-workspace](Playdate.code-workspace) in Visual Studio Code to load the project for Playdate. 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/Playdate/src/DrawLCDBitmap.h: -------------------------------------------------------------------------------- 1 | #ifndef __DRAW_LCDBITMAP_H 2 | #define __DRAW_LCDBITMAP_H 3 | 4 | 5 | #include "Common.h" 6 | 7 | 8 | 9 | class DrawLCDBitmap 10 | { 11 | private: 12 | 13 | 14 | /// 15 | LCDBitmap* m_bmp; 16 | 17 | /// 18 | uint8_t* m_buffer; 19 | 20 | /// 21 | int m_rowBytes; 22 | 23 | /// 24 | DrawLCDBitmap(LCDBitmap* bmp); 25 | 26 | 27 | 28 | public: 29 | 30 | /// 31 | ~DrawLCDBitmap(); 32 | 33 | /// 34 | void PutPixel(uint8_t x, uint8_t y, uint8_t color); 35 | 36 | /// 37 | void DrawBitmap(const uint8_t* src, uint8_t x, uint8_t y, uint8_t w, uint8_t h); 38 | 39 | /// 40 | LCDBitmap* GetLCDBitmap(); 41 | 42 | /// 43 | static std::shared_ptr CreateInstance(int width, int height, LCDColor bgcolor); 44 | }; 45 | 46 | 47 | #endif // __DRAW_LCDBITMAP_H 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Source/Playdate/.vscode/playdate_simulator.cmake: -------------------------------------------------------------------------------- 1 | # mac: 2 | # No use cmake kit. 3 | # cmake guess what compilers and env. 4 | 5 | if (APPLE) 6 | set(__BUILD_MACHINE "Mac") 7 | 8 | if (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64") 9 | # Generate Universal Binary only when building with M1. 10 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64 -arch arm64") 11 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64 -arch arm64") 12 | endif() 13 | else() 14 | set(__BUILD_MACHINE "Windows") 15 | 16 | # Use MinGW when on Windows. 17 | set(TOOLCHAIN_DIR $ENV{PLAYDATE_MINGW}) 18 | set(TOOLCHAIN_PREFIX "x86_64-w64-mingw32-") 19 | set(TOOLCHAIN_POSTFIX ".exe") 20 | 21 | set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/${TOOLCHAIN_PREFIX}gcc${TOOLCHAIN_POSTFIX}) 22 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/${TOOLCHAIN_PREFIX}g++${TOOLCHAIN_POSTFIX}) 23 | set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) 24 | endif() 25 | -------------------------------------------------------------------------------- /Source/Playdate/src/CityOverview.h: -------------------------------------------------------------------------------- 1 | #ifndef __CITY_OVERVIEW_H 2 | #define __CITY_OVERVIEW_H 3 | 4 | 5 | #include "Common.h" 6 | #include "Game.h" 7 | 8 | 9 | class CityOverview 10 | { 11 | private: 12 | 13 | 14 | #ifndef NDEBUG 15 | void DebugOut(); 16 | #endif 17 | 18 | /// 19 | bool IsBuildings(int x, int y); 20 | 21 | /// 22 | void UpdateBuildingsOverview(); 23 | 24 | /// 25 | void UpdatConnectionsOverview(); 26 | 27 | /// 28 | void InitializeOverview(); 29 | 30 | 31 | 32 | public: 33 | 34 | 35 | int nPopulation; 36 | 37 | int nResidential; 38 | int nCommercial; 39 | int nIndustrial; 40 | 41 | int nPowerplant; 42 | int nPark; 43 | int nPoliceDept; 44 | int nFireDept; 45 | int nStadium; 46 | 47 | int nRoads; 48 | int nPowerline; 49 | 50 | /// 51 | CityOverview(); 52 | 53 | /// 54 | void UpdateOverview(); 55 | }; 56 | 57 | 58 | #endif // __CITY_OVERVIEW_H 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /Source/Playdate/src/Menu.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __MENU_H 4 | #define __MENU_H 5 | 6 | 7 | #include "Common.h" 8 | #include "BuildingScore.h" 9 | #include "CityInfo.h" 10 | #include "DrawMap.h" 11 | 12 | 13 | 14 | class Menu 15 | { 16 | private: 17 | 18 | 19 | /// 20 | std::shared_ptr m_spDrawMap; 21 | 22 | /// 23 | std::shared_ptr m_spCityInfo; 24 | 25 | /// 26 | std::shared_ptr m_spCityInfoActive; 27 | 28 | /// 29 | LCDBitmap* m_bmpMenu; 30 | 31 | 32 | 33 | public: 34 | 35 | 36 | /// 37 | Menu(); 38 | 39 | /// 40 | ~Menu(); 41 | 42 | /// 43 | void Initialize(const std::shared_ptr& buildingScore); 44 | 45 | /// 46 | LCDBitmap* GetMenuBitmap(); 47 | 48 | /// 49 | void OnMenuCityInfo(); 50 | 51 | /// 52 | void OnExitCityInfo(); 53 | 54 | /// 55 | std::shared_ptr& GetCityInfo(); 56 | }; 57 | 58 | 59 | #endif // __MENU_H 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /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/Playdate/src/PlaydateMain.cpp: -------------------------------------------------------------------------------- 1 | #include "PlaydateMain.h" 2 | 3 | 4 | PlaydateAPI* gpd = NULL; 5 | 6 | 7 | 8 | /// 9 | static int update(__attribute__ ((unused)) void* ud) 10 | { 11 | MicroCity::GetInstance().Update(); 12 | return 1; 13 | } 14 | 15 | 16 | /// 17 | extern "C" int eventHandler 18 | ( 19 | PlaydateAPI* playdate 20 | , PDSystemEvent event 21 | , uint32_t arg 22 | ) 23 | { 24 | if (event == kEventInitLua) 25 | { 26 | gpd = playdate; 27 | 28 | gpd->display->setRefreshRate(25); 29 | gpd->graphics->fillRect(0, 0, 400, 240, kColorBlack); 30 | gpd->system->setUpdateCallback(update, NULL); 31 | 32 | MicroCity::GetInstance().Initialize(); 33 | } 34 | else if (event == kEventPause) 35 | { 36 | MicroCity::GetInstance().OnPause(); 37 | } 38 | else if (event == kEventTerminate) 39 | { 40 | MicroCity::Finalize(); 41 | } 42 | 43 | return 0; 44 | } 45 | 46 | 47 | // undefined reference 48 | extern "C" void __dso_handle(void) 49 | { 50 | } 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /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/Playdate/.vscode/environment.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # SDK 3 | # 4 | 5 | string(SUBSTRING "${CMAKE_HOST_SYSTEM_NAME}" 0 4 _HOSTNAME) 6 | if (_HOSTNAME STREQUAL "MSYS") 7 | set(CMAKE_HOST_WIN32 true) 8 | endif() 9 | 10 | if (APPLE) 11 | execute_process( 12 | COMMAND bash -c "egrep '^\\s*SDKRoot' $HOME/.Playdate/config" 13 | COMMAND head -n 1 14 | COMMAND cut -c9- 15 | OUTPUT_VARIABLE SDK 16 | OUTPUT_STRIP_TRAILING_WHITESPACE 17 | ) 18 | set(LIB_EXTENSION dylib) 19 | elseif (CMAKE_HOST_WIN32) 20 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++") 21 | set(SDK $ENV{PLAYDATE_SDK_PATH}) 22 | set(LIB_EXTENSION dll) 23 | else () 24 | message(FATAL_ERROR "Platform not supported!") 25 | endif() 26 | 27 | 28 | # 29 | # DEFINE 30 | # 31 | 32 | add_definitions(-D_PLAYDATE) 33 | if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") 34 | add_definitions(-D_DEBUG) 35 | endif() 36 | 37 | 38 | # 39 | # For Debug... 40 | # 41 | 42 | #message(STATUS "*** dump start cmake variables ***") 43 | #get_cmake_property(_variableNames VARIABLES) 44 | #foreach(_variableName ${_variableNames}) 45 | # message(STATUS "${_variableName}=${${_variableName}}") 46 | #endforeach() 47 | #message(STATUS "*** dump end ***") 48 | -------------------------------------------------------------------------------- /Source/Playdate/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | 9 | { 10 | "name": "Playdate Debug", 11 | "type": "cppdbg", 12 | "request": "launch", 13 | "stopAtEntry": false, 14 | "cwd": "${workspaceFolder}", 15 | "environment": [], 16 | "preLaunchTask": "", 17 | "windows": { 18 | "miDebuggerPath": "${env:PLAYDATE_MINGW}/bin/gdb.exe", 19 | "MIMode": "gdb", 20 | "program": "${env:PLAYDATE_SDK_PATH}/bin/PlaydateSimulator.exe", 21 | "args": ["${workspaceFolder}/MicroCity.pdx"], 22 | "externalConsole": true, 23 | }, 24 | "osx": { 25 | "MIMode": "lldb", 26 | "program": "${env:HOME}/Developer/PlaydateSDK/bin/Playdate Simulator.app/Contents/MacOS/Playdate Simulator", 27 | "args": ["MicroCity.pdx"], 28 | "externalConsole": false, 29 | }, 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /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/Playdate/src/DrawMap.h: -------------------------------------------------------------------------------- 1 | #ifndef __DRAW_MAP_H 2 | #define __DRAW_MAP_H 3 | 4 | 5 | #include "Common.h" 6 | #include "BuildingScore.h" 7 | 8 | 9 | 10 | class DrawLCDBitmap; 11 | 12 | 13 | enum MapInfo 14 | { 15 | MapInfo_None, 16 | MapInfo_PopulationDestiny, 17 | MapInfo_Crime, 18 | MapInfo_Pollution, 19 | MapInfo_COUNT 20 | }; 21 | 22 | 23 | 24 | class DrawMap 25 | { 26 | private: 27 | 28 | 29 | /// 30 | static const int MAP_COUNT = 3; 31 | 32 | /// 33 | std::shared_ptr m_spBuildingScore; 34 | 35 | /// 36 | std::shared_ptr m_bmpTerrains[MAP_COUNT]; 37 | 38 | 39 | 40 | 41 | /// 42 | void CreateTerrainBitmap(uint8_t terrainType); 43 | 44 | /// 45 | void CreateTerrainBitmaps(); 46 | 47 | /// 48 | void DrawMapFrame(int mapLeft, int mapTop); 49 | 50 | /// 51 | void DrawCurrentTerrain(int mapLeft, int mapTop); 52 | 53 | /// 54 | void DrawMapCursor(int mapLeft, int mapTop); 55 | 56 | 57 | 58 | public: 59 | 60 | 61 | /// 62 | DrawMap(); 63 | 64 | /// 65 | ~DrawMap(); 66 | 67 | /// 68 | bool Initialize(const std::shared_ptr& buildingScore); 69 | 70 | /// 71 | void DrawCurrentMap(MapInfo info, int mapLeft, int mapTop); 72 | }; 73 | 74 | 75 | 76 | #endif // __DRAW_MAP_H 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /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/Playdate/.vscode/arm.patched.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/environment.cmake) 2 | add_link_options(-specs=nano.specs -specs=nosys.specs) 3 | 4 | 5 | 6 | # 7 | # Toolchain 8 | # 9 | 10 | if (CMAKE_HOST_WIN32) 11 | set (SUFFIX .exe) 12 | else() 13 | set (SUFFIX "") 14 | endif() 15 | 16 | set(CMAKE_SYSTEM_NAME Generic) 17 | set(CMAKE_SYSTEM_PROCESSOR ARM) 18 | set(TOOLCHAIN_PREFIX arm-none-eabi-) 19 | 20 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 21 | 22 | if (CMAKE_HOST_WIN32) 23 | set(TOOLCHAIN $ENV{PLAYDATE_ARM_GCC}/bin) 24 | else () 25 | find_program(CROSS_GCC_PATH ${TOOLCHAIN_PREFIX}gcc${SUFFIX} NO_CACHE) 26 | get_filename_component(TOOLCHAIN ${CROSS_GCC_PATH} PATH) 27 | endif() 28 | 29 | 30 | set(CMAKE_C_COMPILER ${TOOLCHAIN}/${TOOLCHAIN_PREFIX}gcc${SUFFIX}) 31 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN}/${TOOLCHAIN_PREFIX}g++${SUFFIX}) 32 | set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) 33 | 34 | set(CMAKE_OBJCOPY ${TOOLCHAIN}/${TOOLCHAIN_PREFIX}objcopy${SUFFIX} CACHE INTERNAL "objcopy tool") 35 | set(CMAKE_STRIP ${TOOLCHAIN}/${TOOLCHAIN_PREFIX}strip${SUFFIX} CACHE INTERNAL "strip tool") 36 | set(CMAKE_SIZE_UTIL ${TOOLCHAIN}/${TOOLCHAIN_PREFIX}size${SUFFIX} CACHE INTERNAL "size tool") 37 | 38 | set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}) 39 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 40 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 41 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 42 | 43 | set(TOOLCHAIN armgcc) 44 | 45 | MESSAGE(STATUS "arm.patched.cmake loaded") 46 | -------------------------------------------------------------------------------- /Source/Playdate/src/BuildingScore.h: -------------------------------------------------------------------------------- 1 | #ifndef __MAP_SCORE_H 2 | #define __MAP_SCORE_H 3 | 4 | 5 | #include "Common.h" 6 | #include "Game.h" 7 | 8 | 9 | enum BuildingScoreKind 10 | { 11 | BuildingScoreKind_PopulationDestiny = 0, 12 | BuildingScoreKind_Crime, 13 | BuildingScoreKind_Pollution, 14 | BuildingScoreKind_COUNT 15 | }; 16 | 17 | 18 | class BuildingScore 19 | { 20 | private: 21 | 22 | 23 | /// 24 | static const int BS_WIDTH = MAP_WIDTH * PLAYDATE_ZOOM_SCALE; 25 | static const int BS_HEIGHT = MAP_HEIGHT * PLAYDATE_ZOOM_SCALE; 26 | 27 | 28 | /// 29 | uint8_t m_buildingScore[MAX_BUILDINGS][BuildingScoreKind_COUNT]; 30 | 31 | /// 32 | uint8_t m_grayBuildingScore[BS_WIDTH * BS_HEIGHT]; 33 | 34 | /// 35 | LCDBitmap* m_bmpWork; 36 | 37 | /// 38 | LCDBitmap* m_bmpBuildingScore; 39 | 40 | /// 41 | void ClearBuildingScore(); 42 | 43 | /// 44 | void PutBuildingScore(uint8_t x, uint8_t y, uint8_t score); 45 | 46 | /// 47 | void UpdateBuildingScore(BuildingScoreKind kind); 48 | 49 | 50 | 51 | public: 52 | 53 | /// 54 | BuildingScore(); 55 | 56 | /// 57 | ~BuildingScore(); 58 | 59 | /// 60 | void UpdateBuildingScore(Building* building, int score, int crime, int pollution, int localInfluence, int populationEffect, int randomEffect); 61 | 62 | /// 63 | void DrawBuildingScore(BuildingScoreKind kind, uint8_t x, uint8_t y); 64 | }; 65 | 66 | 67 | 68 | #endif // __MAP_SCORE_H 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /Source/Playdate/src/MicroCity.h: -------------------------------------------------------------------------------- 1 | #ifndef __PLAYDATE_MICROCITY_H 2 | #define __PLAYDATE_MICROCITY_H 3 | 4 | 5 | #include "Common.h" 6 | #include "DrawLCDBitmap.h" 7 | #include "Menu.h" 8 | #include "CityInfo.h" 9 | #include "BuildingScore.h" 10 | 11 | 12 | 13 | class MicroCity 14 | { 15 | private: 16 | 17 | 18 | /// 19 | static std::shared_ptr m_gspInstance; 20 | 21 | /// 22 | bool m_bStarted; 23 | 24 | /// 25 | std::shared_ptr m_spCityInfo; 26 | 27 | /// 28 | std::shared_ptr m_spBuildingScore; 29 | 30 | /// 31 | std::shared_ptr m_spMenu; 32 | 33 | /// 34 | std::shared_ptr m_spDrawDisplay; 35 | 36 | /// 37 | MicroCity(); 38 | 39 | 40 | 41 | public: 42 | 43 | 44 | /// 45 | ~MicroCity(); 46 | 47 | /// 48 | void Initialize(); 49 | 50 | /// 51 | void Update(); 52 | 53 | /// 54 | void OnPause(); 55 | 56 | /// 57 | void OnMenuCityInfo(); 58 | 59 | /// 60 | void OnExitCityInfo(); 61 | 62 | /// 63 | void PutPixel(uint8_t x, uint8_t y, uint8_t color); 64 | 65 | /// 66 | void DrawBitmap(const uint8_t* data, uint8_t x, uint8_t y, uint8_t w, uint8_t h); 67 | 68 | /// 69 | void UpdateBuildingScore(Building* building, int score, int crime, int pollution, int localInfluence, int populationEffect, int randomEffect); 70 | 71 | /// 72 | static MicroCity& GetInstance(); 73 | 74 | /// 75 | static void Finalize(); 76 | }; 77 | 78 | 79 | #endif // __PLAYDATE_MICROCITY_H 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /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/Playdate/src/Menu.cpp: -------------------------------------------------------------------------------- 1 | #include "Menu.h" 2 | #include "Interface.h" 3 | 4 | 5 | 6 | /// 7 | Menu::Menu() 8 | : m_bmpMenu(NULL) 9 | { 10 | } 11 | 12 | 13 | /// 14 | Menu::~Menu() 15 | { 16 | if (m_bmpMenu) 17 | { 18 | gpd->graphics->freeBitmap(m_bmpMenu); 19 | } 20 | } 21 | 22 | /// 23 | void Menu::Initialize(const std::shared_ptr& buildingScore) 24 | { 25 | m_spDrawMap = std::make_shared(); 26 | m_spDrawMap->Initialize(buildingScore); 27 | m_spCityInfo = std::make_shared(m_spDrawMap); 28 | 29 | m_bmpMenu = gpd->graphics->newBitmap(400, 240, kColorWhite); 30 | } 31 | 32 | 33 | 34 | /// 35 | LCDBitmap* Menu::GetMenuBitmap() 36 | { 37 | static const int MAP_POSX = 28; 38 | static const int MAP_POSY = 48; 39 | 40 | if (UIState.state != StartScreen && UIState.state != NewCityMenu) 41 | { 42 | gpd->graphics->pushContext(m_bmpMenu); 43 | gpd->graphics->clear(kColorWhite); 44 | 45 | m_spDrawMap->DrawCurrentMap(MapInfo_None, MAP_POSX, MAP_POSY); 46 | 47 | gpd->graphics->popContext(); 48 | 49 | return m_bmpMenu; 50 | } 51 | 52 | return NULL; 53 | } 54 | 55 | 56 | /// 57 | void Menu::OnMenuCityInfo() 58 | { 59 | assert(m_spCityInfo); 60 | m_spCityInfo->InitializeCityInfo(); 61 | m_spCityInfoActive = m_spCityInfo; 62 | } 63 | 64 | 65 | /// 66 | void Menu::OnExitCityInfo() 67 | { 68 | m_spCityInfoActive = NULL; 69 | } 70 | 71 | 72 | /// 73 | std::shared_ptr& Menu::GetCityInfo() 74 | { 75 | return m_spCityInfoActive; 76 | } 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /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/Playdate/src/Dithering.h: -------------------------------------------------------------------------------- 1 | #ifndef __DITHERING_H 2 | #define __DITHERING_H 3 | 4 | 5 | 6 | 7 | class Dithering 8 | { 9 | private: 10 | 11 | 12 | /// 13 | static inline void SetPixel(unsigned char* dstBuf, int rowBytes, int x, int y) 14 | { 15 | unsigned char* nowDst = dstBuf + (rowBytes * y) + (x / 8); 16 | *nowDst |= 1 << (7 - (x % 8)); 17 | } 18 | 19 | /// 20 | static inline void SetDiffusion(unsigned char* ptr, unsigned char diffNum, int quantError) 21 | { 22 | int append = (diffNum * 1.0f) / 16.0f * quantError; 23 | int newchar = *ptr + append; 24 | if (newchar >= 0xff) 25 | { 26 | *ptr = 0xff; 27 | } 28 | else 29 | if (newchar <= 0x0) 30 | { 31 | *ptr = 0x0; 32 | } 33 | else 34 | { 35 | *ptr = newchar; 36 | } 37 | } 38 | 39 | /// 40 | static void FloydSteinbergRaw(unsigned char* srcBuf, int width, int height, unsigned char* dstBuf, int rowBytes, int x, int y); 41 | 42 | 43 | public: 44 | 45 | /* 46 | FloydSteinberg 47 | 48 | srcBuf: Source 8bit grayscale bitmap 49 | width: Source bitmap width 50 | height: Source bitmap height 51 | dstBuf: Destination 1bit binary bitmap (MSB order) 52 | rowBytes: Destination bitmap row bytes 53 | serpentine: Use serpentine scanning scanning 54 | */ 55 | static bool FloydSteinberg(unsigned char* srcBuf, int width, int height, unsigned char* dstBuf, int rowBytes, bool serpentine); 56 | }; 57 | 58 | 59 | #endif // __DITHERING_H 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /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/Playdate/src/Dithering.cpp: -------------------------------------------------------------------------------- 1 | #include "Dithering.h" 2 | 3 | 4 | /// 5 | void Dithering::FloydSteinbergRaw(unsigned char* srcBuf, int width, int height, unsigned char* dstBuf, int rowBytes, int x, int y) 6 | { 7 | signed int quantError; 8 | unsigned char oldPixel = srcBuf[x + (y * width)]; 9 | if (oldPixel > 0x7f) 10 | { 11 | quantError = oldPixel - 0xff; 12 | SetPixel(dstBuf, rowBytes, x, y); 13 | } 14 | else 15 | { 16 | quantError = oldPixel; 17 | } 18 | 19 | /* 20 | | |X|7| 21 | |3|5|1| 22 | */ 23 | if (x != width - 1) 24 | { 25 | SetDiffusion(srcBuf + (x + 1) + (y * width), 7, quantError); 26 | } 27 | 28 | if ((x != 0) && (y != height - 1)) 29 | { 30 | SetDiffusion(srcBuf + (x - 1) + ((y + 1) * width), 3, quantError); 31 | } 32 | 33 | if (y != height - 1) 34 | { 35 | SetDiffusion(srcBuf + x + ((y + 1) * width), 5, quantError); 36 | } 37 | 38 | if ((x != width - 1) && (y != height - 1)) 39 | { 40 | SetDiffusion(srcBuf + (x + 1) + ((y + 1) * width), 1, quantError); 41 | } 42 | } 43 | 44 | 45 | /// 46 | bool Dithering::FloydSteinberg(unsigned char* srcBuf, int width, int height, unsigned char* dstBuf, int rowBytes, bool serpentine) 47 | { 48 | int y = 0; 49 | for (y = 0; y < height; y++) 50 | { 51 | if (!serpentine || (y % 2 == 0)) 52 | { 53 | for (int x = 0; x < width; x++) 54 | { 55 | FloydSteinbergRaw(srcBuf, width, height, dstBuf, rowBytes, x, y); 56 | } 57 | } 58 | else 59 | { 60 | for (int x = width -1; x >= 0; x--) 61 | { 62 | FloydSteinbergRaw(srcBuf, width, height, dstBuf, rowBytes, x, y); 63 | } 64 | } 65 | } 66 | 67 | return true; 68 | } 69 | -------------------------------------------------------------------------------- /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/Playdate/src/DrawLCDBitmap.cpp: -------------------------------------------------------------------------------- 1 | #include "DrawLCDBitmap.h" 2 | 3 | 4 | /// 5 | DrawLCDBitmap::DrawLCDBitmap(LCDBitmap* bmp) 6 | { 7 | assert(bmp); 8 | 9 | m_bmp = bmp; 10 | int dummy; 11 | uint8_t* pdummy; 12 | gpd->graphics->getBitmapData(m_bmp, &dummy, &dummy, &m_rowBytes, &pdummy, &m_buffer); 13 | } 14 | 15 | 16 | /// 17 | DrawLCDBitmap::~DrawLCDBitmap() 18 | { 19 | if (m_bmp) 20 | { 21 | gpd->graphics->freeBitmap(m_bmp); 22 | } 23 | } 24 | 25 | 26 | /// 27 | void DrawLCDBitmap::PutPixel(uint8_t x, uint8_t y, uint8_t color) 28 | { 29 | assert(m_buffer != NULL); 30 | 31 | uint8_t* block = m_buffer + (y * m_rowBytes) + (x / 8); 32 | uint8_t data = 0x80 >> (x % 8); 33 | *block = color ? *block | data : *block & ~data; 34 | } 35 | 36 | 37 | /// 38 | void DrawLCDBitmap::DrawBitmap(const uint8_t* src, uint8_t x, uint8_t y, uint8_t w, uint8_t h) 39 | { 40 | assert(m_buffer != NULL); 41 | 42 | for (int j = 0; j < h; j++) 43 | { 44 | for (int i = 0; i < w; i++) 45 | { 46 | int blockX = i / 8; 47 | int blockY = j / 8; 48 | int blocksPerWidth = w / 8; 49 | int blockIndex = blockY * blocksPerWidth + blockX; 50 | uint8_t pixels = src[blockIndex * 8 + i % 8]; 51 | uint8_t mask = 1 << (j % 8); 52 | if (pixels & mask) 53 | { 54 | PutPixel(x + i, y + j, 1); 55 | } 56 | } 57 | } 58 | } 59 | 60 | 61 | /// 62 | LCDBitmap* DrawLCDBitmap::GetLCDBitmap() 63 | { 64 | return m_bmp; 65 | } 66 | 67 | 68 | 69 | /// 70 | std::shared_ptr DrawLCDBitmap::CreateInstance(int width, int height, LCDColor bgcolor) 71 | { 72 | DrawLCDBitmap* p = NULL; 73 | auto bmp = gpd->graphics->newBitmap(width, height, bgcolor); 74 | if (bmp) 75 | { 76 | p = new DrawLCDBitmap(bmp); 77 | if (!p) 78 | { 79 | gpd->graphics->freeBitmap(bmp); 80 | } 81 | } 82 | return std::shared_ptr(p); 83 | } 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /Source/Playdate/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | set (CMAKE_CXX_STANDARD 11) 3 | add_definitions(-D_PLAYDATE) 4 | 5 | if (APPLE) 6 | execute_process( 7 | COMMAND bash -c "egrep '^\\s*SDKRoot' $HOME/.Playdate/config" 8 | COMMAND head -n 1 9 | COMMAND cut -c9- 10 | OUTPUT_VARIABLE SDK 11 | OUTPUT_STRIP_TRAILING_WHITESPACE 12 | ) 13 | set(LIB_EXTENSION dylib) 14 | else() 15 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++") 16 | set(SDK $ENV{PLAYDATE_SDK_PATH}) 17 | set(LIB_EXTENSION dll) 18 | endif() 19 | 20 | set(PLAYDATE_GAME_NAME MicroCity) 21 | set(PLAYDATE_GAME_DEVICE MicroCity_DEVICE) 22 | 23 | project(${PLAYDATE_GAME_NAME} C CXX ASM) 24 | 25 | 26 | include_directories( 27 | src 28 | ../MicroCity 29 | ) 30 | 31 | 32 | set(SOURCE 33 | src/Dithering.cpp 34 | src/BuildingScore.cpp 35 | src/CityInfo.cpp 36 | src/CityOverview.cpp 37 | 38 | src/DrawLCDBitmap.cpp 39 | src/Menu.cpp 40 | src/DrawMap.cpp 41 | src/MicroCity.cpp 42 | src/PlaydateMain.cpp 43 | 44 | ../MicroCity/Building.cpp 45 | ../MicroCity/Connectivity.cpp 46 | ../MicroCity/Draw.cpp 47 | ../MicroCity/Font.cpp 48 | ../MicroCity/Game.cpp 49 | ../MicroCity/Interface.cpp 50 | ../MicroCity/Simulation.cpp 51 | ../MicroCity/Strings.cpp 52 | ../MicroCity/Terrain.cpp 53 | ) 54 | 55 | 56 | if (TOOLCHAIN STREQUAL "armgcc") 57 | add_definitions(-D_PLAYDATE_DEVICE) 58 | set(PLAYDATE_TARGET_NAME ${PLAYDATE_GAME_DEVICE}) 59 | add_executable(${PLAYDATE_TARGET_NAME} ${SDK}/C_API/buildsupport/setup.c ${SOURCE}) 60 | else() 61 | set(PLAYDATE_TARGET_NAME ${PLAYDATE_GAME_NAME}) 62 | add_library(${PLAYDATE_TARGET_NAME} SHARED ${SOURCE}) 63 | endif() 64 | 65 | set_property(TARGET ${PLAYDATE_TARGET_NAME} APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${PLAYDATE_GAME_NAME}.pdx") 66 | include(${CMAKE_CURRENT_SOURCE_DIR}/.vscode/playdate_game.patched.cmake) 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /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/Playdate/src/CityInfo.h: -------------------------------------------------------------------------------- 1 | #ifndef __CITY_INFO_H 2 | #define __CITY_INFO_H 3 | 4 | 5 | #include 6 | #include "Common.h" 7 | #include "DrawMap.h" 8 | #include "CityOverview.h" 9 | 10 | 11 | 12 | class CityInfo 13 | { 14 | private: 15 | 16 | 17 | /// 18 | LCDFont* m_fntTitle; 19 | 20 | /// 21 | LCDFont* m_fntOverview; 22 | 23 | /// 24 | LCDBitmap* m_bmpFrame; 25 | 26 | /// 27 | LCDBitmap* m_bmpLoading; 28 | 29 | /// 30 | LCDBitmap* m_bmpMapCursor; 31 | 32 | /// 33 | std::shared_ptr m_spDrawMap; 34 | 35 | /// 36 | std::shared_ptr m_spCityOverview; 37 | 38 | 39 | /// 40 | static const int MAP_INFO_COUNT = 3; 41 | static const MapInfo MAP_INFOS[MAP_INFO_COUNT]; 42 | static const char* MAP_DESCS[MAP_INFO_COUNT]; 43 | 44 | /// 45 | LCDBitmap* m_bmpOverview; 46 | 47 | /// 48 | LCDBitmap* m_bmpMaps[MAP_INFO_COUNT]; 49 | 50 | /// 51 | void DrawContextCurrentMap(); 52 | 53 | /// 54 | void DrawOverviewText(const char* szTitle, const char* szDsc, bool breakY, int& x, int& y); 55 | 56 | /// 57 | void DrawContextCityOverview(); 58 | 59 | /// 60 | void DrawCurrentMap(); 61 | 62 | /// 63 | void DrawCityOverview(); 64 | 65 | /// 66 | void DrawNowLoading(); 67 | 68 | /// 69 | void DrawCityInfo(); 70 | 71 | 72 | /// 73 | int m_nMapSelected; 74 | LCDBitmap* m_bmpMapCurrent; 75 | LCDBitmap* m_bmpMapLast; 76 | int m_nStartPosY; 77 | int m_nEndPosY; 78 | unsigned int m_nCurrentTime; 79 | 80 | /// 81 | void SelectPreviousMap(); 82 | 83 | /// 84 | void SelectNextMap(); 85 | 86 | /// 87 | void UpdateSelectedMap(int index); 88 | 89 | /// 90 | int GetCurrentMapPosY(); 91 | 92 | /// 93 | void DrawMapCursor(); 94 | 95 | 96 | 97 | public: 98 | 99 | 100 | /// 101 | CityInfo(const std::shared_ptr& drawMap); 102 | 103 | /// 104 | ~CityInfo(); 105 | 106 | /// 107 | void InitializeCityInfo(); 108 | 109 | /// 110 | void Update(); 111 | }; 112 | 113 | 114 | #endif // __CITY_INFO_H 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /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/Playdate/Source/assets/fonts/font-Cuberick-Bold.fnt: -------------------------------------------------------------------------------- 1 | tracking=1 2 | space 6 3 | ! 2 4 | " 7 5 | # 9 6 | $ 8 7 | % 8 8 | & 8 9 | ' 3 10 | ( 3 11 | ) 3 12 | * 6 13 | + 6 14 | , 3 15 | - 4 16 | . 2 17 | / 6 18 | 0 8 19 | 1 6 20 | 2 7 21 | 3 7 22 | 4 8 23 | 5 7 24 | 6 7 25 | 7 7 26 | 8 7 27 | 9 7 28 | : 2 29 | ; 2 30 | < 7 31 | = 7 32 | > 7 33 | ? 6 34 | @ 10 35 | A 8 36 | B 8 37 | C 8 38 | D 8 39 | E 6 40 | F 6 41 | G 8 42 | H 8 43 | I 2 44 | J 6 45 | K 7 46 | L 6 47 | M 12 48 | N 9 49 | O 8 50 | P 8 51 | Q 9 52 | R 8 53 | S 8 54 | T 8 55 | U 8 56 | V 9 57 | W 12 58 | X 8 59 | Y 8 60 | Z 8 61 | [ 3 62 | \ 6 63 | ] 3 64 | ^ 6 65 | _ 7 66 | ` 3 67 | a 6 68 | b 6 69 | c 6 70 | d 6 71 | e 6 72 | f 5 73 | g 6 74 | h 6 75 | i 2 76 | j 3 77 | k 7 78 | l 2 79 | m 10 80 | n 6 81 | o 6 82 | p 6 83 | q 6 84 | r 5 85 | s 6 86 | t 6 87 | u 6 88 | v 7 89 | w 10 90 | x 7 91 | y 7 92 | z 6 93 | { 5 94 | | 2 95 | } 5 96 | ~ 7 97 | ™ 9 98 | … 12 99 | ¥ 8 100 | ‼ 5 101 | © 10 102 | ® 10 103 | � 10 104 | 105 | va -1 106 | Wm -1 107 | Ok 0 108 | Eu 0 109 | Fo 0 110 | Pe -1 111 | W; -1 112 | Ol 0 113 | Ev 0 114 | Vu -1 115 | He 0 116 | Yd -1 117 | Fr 0 118 | Ye -1 119 | Nu 0 120 | Wr -1 121 | Ft -1 122 | Fu 0 123 | Ic 0 124 | Wt -1 125 | Id 0 126 | J, 0 127 | Wu -1 128 | Xo 0 129 | Yi -1 130 | Ac 0 131 | J. 0 132 | B, 0 133 | Ad 0 134 | Po -1 135 | Fy -1 136 | Ae 0 137 | Ja 0 138 | Rd -1 139 | S, -1 140 | Y: -1 141 | B. 0 142 | Wy -1 143 | Re -1 144 | Ho 0 145 | Ag 0 146 | Gu 0 147 | Y; -1 148 | S. -1 149 | Bb 0 150 | Xu 0 151 | Je 0 152 | Yp -1 153 | C, 0 154 | T, -1 155 | C. 0 156 | Xy -1 157 | Io 0 158 | Ca 0 159 | Hu 0 160 | T. -1 161 | Yu -1 162 | Ta -1 163 | Iq 0 164 | Ao 0 165 | Ke 0 166 | Bi 0 167 | Yv -1 168 | Ap 0 169 | D, 0 170 | Si -1 171 | Hy 0 172 | Aq 0 173 | Ro -1 174 | Tc -1 175 | Bk 0 176 | U, -1 177 | It 0 178 | D. 0 179 | Te -1 180 | Jo 0 181 | Da 0 182 | Bl 0 183 | U. -1 184 | At -1 185 | Ua -1 186 | Au 0 187 | Rt -1 188 | Av -1 189 | Ru -1 190 | Ma 0 191 | Aw -1 192 | Ti -1 193 | Sp -1 194 | V, -1 195 | Br 0 196 | Ko 0 197 | Ay -1 198 | Mc 0 199 | Ju 0 200 | Md 0 201 | T: -1 202 | N, 0 203 | V. -1 204 | Va -1 205 | Ug -1 206 | Bu 0 207 | Me 0 208 | T; -1 209 | N. 0 210 | F, -2 211 | To -1 212 | Na 0 213 | Su -1 214 | W, -1 215 | Cr 0 216 | F. -2 217 | Ve -1 218 | Ku 0 219 | By -1 220 | Fa -1 221 | Tr -1 222 | W. -1 223 | O, -1 224 | Ts -1 225 | Ne 0 226 | Um -1 227 | Un -1 228 | O. -1 229 | Tu -1 230 | Oa 0 231 | Fe -1 232 | Vi -1 233 | Up -1 234 | Ob 0 235 | Wd -1 236 | Tw -1 237 | Mo 0 238 | Lu 0 239 | Ni 0 240 | V: -1 241 | Ty -1 242 | Us -1 243 | Fi 0 244 | V; -1 245 | Xa -1 246 | Vo -1 247 | Ly -1 248 | Pa -1 249 | Wi -1 250 | Oh 0 251 | Y, -1 252 | F: -1 253 | Xe 0 254 | No 0 255 | F; -1 256 | Vr -1 257 | W: -1 258 | Y. -1 -------------------------------------------------------------------------------- /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/Playdate/.vscode/playdate_game.patched.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # CMake include file for Playdate games 3 | # 4 | cmake_minimum_required(VERSION 3.19) 5 | 6 | include(${SDK}/C_API/buildsupport/playdate.cmake) 7 | 8 | set(BUILD_SUB_DIR "") 9 | 10 | if (TOOLCHAIN STREQUAL "armgcc") 11 | set_property(TARGET ${PLAYDATE_GAME_DEVICE} PROPERTY OUTPUT_NAME "${PLAYDATE_GAME_DEVICE}.elf") 12 | 13 | add_custom_command( 14 | TARGET ${PLAYDATE_GAME_DEVICE} POST_BUILD 15 | COMMAND ${CMAKE_STRIP} --strip-unneeded -R .comment -g 16 | ${PLAYDATE_GAME_DEVICE}.elf 17 | -o ${CMAKE_CURRENT_SOURCE_DIR}/Source/pdex.elf 18 | ) 19 | 20 | add_custom_command( 21 | TARGET ${PLAYDATE_GAME_DEVICE} POST_BUILD 22 | COMMAND ${PDC} Source ${PLAYDATE_GAME_NAME}.pdx 23 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 24 | ) 25 | 26 | set_property( 27 | TARGET ${PLAYDATE_GAME_DEVICE} PROPERTY ADDITIONAL_CLEAN_FILES 28 | ${CMAKE_CURRENT_SOURCE_DIR}/${PLAYDATE_GAME_NAME}.pdx 29 | ) 30 | 31 | else () 32 | 33 | if (MSVC) 34 | if(${CMAKE_GENERATOR} MATCHES "Visual Studio*" ) 35 | set(BUILD_SUB_DIR $/) 36 | file(TO_NATIVE_PATH ${SDK}/bin/PlaydateSimulator.exe SIMPATH) 37 | file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${PLAYDATE_GAME_NAME}.pdx SIMGAMEPATH) 38 | set_property(TARGET ${PLAYDATE_GAME_NAME} PROPERTY VS_DEBUGGER_COMMAND ${SIMPATH}) 39 | set_property(TARGET ${PLAYDATE_GAME_NAME} PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "\"${SIMGAMEPATH}\"") 40 | endif() 41 | 42 | add_custom_command( 43 | TARGET ${PLAYDATE_GAME_NAME} POST_BUILD 44 | COMMAND ${CMAKE_COMMAND} -E copy 45 | ${CMAKE_CURRENT_BINARY_DIR}/${BUILD_SUB_DIR}${PLAYDATE_GAME_NAME}.dll 46 | ${CMAKE_CURRENT_SOURCE_DIR}/Source/pdex.dll) 47 | 48 | elseif(MINGW) 49 | add_custom_command( 50 | TARGET ${PLAYDATE_GAME_NAME} POST_BUILD 51 | COMMAND ${CMAKE_COMMAND} -E copy 52 | ${CMAKE_CURRENT_BINARY_DIR}/msys-${PLAYDATE_GAME_NAME}.dll 53 | ${CMAKE_CURRENT_SOURCE_DIR}/Source/pdex.dll) 54 | elseif(APPLE) 55 | if(${CMAKE_GENERATOR} MATCHES "Xcode" ) 56 | set(BUILD_SUB_DIR $/) 57 | set_property(TARGET ${PLAYDATE_GAME_NAME} PROPERTY XCODE_SCHEME_ARGUMENTS \"${CMAKE_CURRENT_SOURCE_DIR}/${PLAYDATE_GAME_NAME}.pdx\") 58 | set_property(TARGET ${PLAYDATE_GAME_NAME} PROPERTY XCODE_SCHEME_EXECUTABLE ${SDK}/bin/Playdate\ Simulator.app) 59 | endif() 60 | 61 | add_custom_command( 62 | TARGET ${PLAYDATE_GAME_NAME} POST_BUILD 63 | COMMAND ${CMAKE_COMMAND} -E copy 64 | ${CMAKE_CURRENT_BINARY_DIR}/${BUILD_SUB_DIR}lib${PLAYDATE_GAME_NAME}.dylib 65 | ${CMAKE_CURRENT_SOURCE_DIR}/Source/pdex.dylib) 66 | 67 | elseif(UNIX) 68 | add_custom_command( 69 | TARGET ${PLAYDATE_GAME_NAME} POST_BUILD 70 | COMMAND ${CMAKE_COMMAND} -E copy 71 | ${CMAKE_CURRENT_BINARY_DIR}/lib${PLAYDATE_GAME_NAME}.so 72 | ${CMAKE_CURRENT_SOURCE_DIR}/Source/pdex.so) 73 | else() 74 | message(FATAL_ERROR "Platform not supported!") 75 | endif() 76 | 77 | set_property( 78 | TARGET ${PLAYDATE_GAME_NAME} PROPERTY ADDITIONAL_CLEAN_FILES 79 | ${CMAKE_CURRENT_SOURCE_DIR}/${PLAYDATE_GAME_NAME}.pdx 80 | ) 81 | 82 | add_custom_command( 83 | TARGET ${PLAYDATE_GAME_NAME} POST_BUILD 84 | COMMAND ${PDC} ${CMAKE_CURRENT_SOURCE_DIR}/Source 85 | ${CMAKE_CURRENT_SOURCE_DIR}/${PLAYDATE_GAME_NAME}.pdx) 86 | 87 | endif () 88 | -------------------------------------------------------------------------------- /Source/MicroCity/Defines.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(_WIN32) || (_PLAYDATE) 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 _PLAYDATE 21 | #define DISPLAY_WIDTH 128 22 | #define DISPLAY_HEIGHT 80 23 | #define MAP_WIDTH 48 24 | #define MAP_HEIGHT 48 25 | 26 | #elif defined(_WIN32) 27 | //#define DISPLAY_WIDTH 192 28 | //#define DISPLAY_HEIGHT 192 29 | #define DISPLAY_WIDTH 128 30 | #define DISPLAY_HEIGHT 64 31 | #define MAP_WIDTH 48 32 | #define MAP_HEIGHT 48 33 | #else 34 | #define DISPLAY_WIDTH 128 35 | #define DISPLAY_HEIGHT 64 36 | #define MAP_WIDTH 48 37 | #define MAP_HEIGHT 48 38 | #endif 39 | 40 | 41 | #define MAX_SCROLL_X (MAP_WIDTH * TILE_SIZE - DISPLAY_WIDTH) 42 | #define MAX_SCROLL_Y (MAP_HEIGHT * TILE_SIZE - DISPLAY_HEIGHT) 43 | 44 | #define VISIBLE_TILES_X ((DISPLAY_WIDTH / TILE_SIZE) + 1) 45 | #define VISIBLE_TILES_Y ((DISPLAY_HEIGHT / TILE_SIZE) + 1) 46 | 47 | #define MAX_BUILDINGS 130 48 | 49 | // How long a button has to be held before the first event repeats 50 | #define INPUT_REPEAT_TIME 10 51 | 52 | // When repeating, how long between each event is fired 53 | #define INPUT_REPEAT_FREQUENCY 2 54 | 55 | #define BULLDOZER_COST 1 56 | #define ROAD_COST 10 57 | #define POWERLINE_COST 5 58 | 59 | #define FIRST_TERRAIN_TILE 1 60 | #define FIRST_WATER_TILE 17 61 | #define LAST_WATER_TILE (FIRST_WATER_TILE + 3) 62 | 63 | #define FIRST_FIRE_TILE 232 64 | #define LAST_FIRE_TILE (FIRST_FIRE_TILE + 3) 65 | 66 | #define FIRST_ROAD_TILE 5 67 | #define FIRST_ROAD_TRAFFIC_TILE (FIRST_ROAD_TILE + 16) 68 | #define LAST_ROAD_TRAFFIC_TILE (FIRST_ROAD_TRAFFIC_TILE + 10) 69 | #define FIRST_POWERLINE_TILE 53 70 | #define FIRST_POWERLINE_ROAD_TILE 49 71 | 72 | #define FIRST_ROAD_BRIDGE_TILE 32 73 | #define FIRST_POWERLINE_BRIDGE_TILE 34 74 | 75 | #define FIRST_BUILDING_TILE 224 76 | 77 | #define FIRST_EDGE_TILE 79 78 | #define NORTH_WEST_EDGE_TILE FIRST_EDGE_TILE 79 | #define NORTH_EAST_EDGE_TILE (FIRST_EDGE_TILE + 16) 80 | #define SOUTH_WEST_EDGE_TILE (FIRST_EDGE_TILE + 32) 81 | #define SOUTH_EAST_EDGE_TILE (FIRST_EDGE_TILE + 48) 82 | 83 | #define POWERCUT_TILE 48 84 | #define RUBBLE_TILE 51 85 | 86 | #define FIRST_BRUSH_TILE 240 87 | 88 | #define NUM_TOOLBAR_BUTTONS 13 89 | 90 | #define MAX_POPULATION_DENSITY 15 91 | 92 | #define NUM_TERRAIN_TYPES 3 93 | 94 | #define STARTING_TAX_RATE 7 95 | #define STARTING_FUNDS 10000 96 | 97 | #define FIRE_AND_POLICE_MAINTENANCE_COST 100 98 | #define ROAD_MAINTENANCE_COST 10 99 | 100 | #define POPULATION_MULTIPLIER 17 101 | 102 | #define MIN_BUDGET_DISPLAY_TIME 16 103 | 104 | #define BUILDING_MAX_FIRE_COUNTER 3 105 | 106 | #define MIN_FRAMES_BETWEEN_DISASTER 2500 107 | #define FRAMES_PER_YEAR (MAX_BUILDINGS * 12) 108 | #define MIN_TIME_BETWEEN_DISASTERS (FRAMES_PER_YEAR * 2) 109 | #define MAX_TIME_BETWEEN_DISASTERS (FRAMES_PER_YEAR * 6) 110 | 111 | #define DISASTER_MESSAGE_DISPLAY_TIME 60 112 | -------------------------------------------------------------------------------- /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/Playdate/src/CityOverview.cpp: -------------------------------------------------------------------------------- 1 | #include "CityOverview.h" 2 | 3 | 4 | 5 | #ifndef NDEBUG 6 | /// 7 | void CityOverview::DebugOut() 8 | { 9 | gpd->system->logToConsole("====="); 10 | gpd->system->logToConsole("Population %d", nPopulation); 11 | gpd->system->logToConsole("R:%d C:%d I:%d", nResidential, nCommercial, nIndustrial); 12 | gpd->system->logToConsole("PoliceDept:%d FireDept:%d Park:%d", nPoliceDept, nFireDept, nPark); 13 | gpd->system->logToConsole("Powerplant:%d Stadium:%d", nPowerplant, nStadium); 14 | } 15 | #endif 16 | 17 | 18 | /// 19 | bool CityOverview::IsBuildings(int x, int y) 20 | { 21 | for (int n = 0; n < MAX_BUILDINGS; n++) 22 | { 23 | Building* building = &State.buildings[n]; 24 | if (!building->type) 25 | { 26 | continue; 27 | } 28 | 29 | if (x < building->x || y < building->y) 30 | { 31 | continue; 32 | } 33 | 34 | const BuildingInfo* info = GetBuildingInfo(building->type); 35 | uint8_t width = pgm_read_byte(&info->width); 36 | uint8_t height = pgm_read_byte(&info->height); 37 | 38 | if (x < building->x + width && y < building->y + height) 39 | { 40 | return true; 41 | } 42 | } 43 | return false; 44 | } 45 | 46 | 47 | /// 48 | void CityOverview::UpdateBuildingsOverview() 49 | { 50 | for (int n = 0; n < MAX_BUILDINGS; n++) 51 | { 52 | Building& bld = State.buildings[n]; 53 | 54 | switch (bld.type) 55 | { 56 | case Residential: 57 | nResidential++; 58 | break; 59 | 60 | case Industrial: 61 | nIndustrial++; 62 | break; 63 | 64 | case Commercial: 65 | nCommercial++; 66 | break; 67 | 68 | case Powerplant: 69 | nPowerplant++; 70 | break; 71 | 72 | case Park: 73 | nPark++; 74 | break; 75 | 76 | case PoliceDept: 77 | nPoliceDept++; 78 | break; 79 | 80 | case FireDept: 81 | nFireDept++; 82 | break; 83 | 84 | case Stadium: 85 | nStadium++; 86 | break; 87 | 88 | default: 89 | break; 90 | } 91 | } 92 | } 93 | 94 | 95 | /// 96 | void CityOverview::UpdatConnectionsOverview() 97 | { 98 | for (int y = 0; y < MAX_SCROLL_Y; y++) 99 | { 100 | for (int x = 0; x < MAX_SCROLL_X; x++) 101 | { 102 | if (IsBuildings(x, y)) 103 | { 104 | continue; 105 | } 106 | 107 | auto connections = GetConnections(x, y); 108 | if ((connections & RoadMask) == RoadMask) 109 | { 110 | nRoads++; 111 | } 112 | 113 | if ((connections & PowerlineMask) == PowerlineMask) 114 | { 115 | nPowerline++; 116 | } 117 | } 118 | } 119 | } 120 | 121 | 122 | 123 | /// 124 | CityOverview::CityOverview() 125 | : nPopulation(0) 126 | , nResidential(0) 127 | , nCommercial(0) 128 | , nIndustrial(0) 129 | , nPowerplant(0) 130 | , nPark(0) 131 | , nPoliceDept(0) 132 | , nFireDept(0) 133 | , nStadium(0) 134 | , nRoads(0) 135 | , nPowerline(0) 136 | { 137 | } 138 | 139 | 140 | /// 141 | void CityOverview::UpdateOverview() 142 | { 143 | nPopulation = (State.residentialPopulation + State.commercialPopulation + State.residentialPopulation) * POPULATION_MULTIPLIER; 144 | UpdateBuildingsOverview(); 145 | UpdatConnectionsOverview(); 146 | 147 | #ifndef NDEBUG 148 | #ifdef _WIN32 149 | //_sleep(5000); 150 | #endif 151 | //DebugOut(); 152 | #endif 153 | } 154 | 155 | 156 | -------------------------------------------------------------------------------- /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/Playdate/src/DrawMap.cpp: -------------------------------------------------------------------------------- 1 | #include "DrawMap.h" 2 | #include "Game.h" 3 | #include "Interface.h" 4 | #include "DrawLCDBitmap.h" 5 | 6 | 7 | 8 | 9 | /// 10 | void DrawMap::CreateTerrainBitmap(uint8_t terrainType) 11 | { 12 | m_bmpTerrains[terrainType] = DrawLCDBitmap::CreateInstance(MAP_WIDTH, MAP_HEIGHT, kColorBlack); 13 | m_bmpTerrains[terrainType]->DrawBitmap(GetTerrainData(terrainType), 0, 0, MAP_WIDTH, MAP_HEIGHT); 14 | } 15 | 16 | 17 | /// 18 | void DrawMap::CreateTerrainBitmaps() 19 | { 20 | for (uint8_t i = 0; i < MAP_COUNT; i++) 21 | { 22 | CreateTerrainBitmap(i); 23 | } 24 | } 25 | 26 | 27 | /// 28 | void DrawMap::DrawMapFrame(int mapLeft, int mapTop) 29 | { 30 | static const int MAP_BORDER = 3; 31 | static const int MAP_MARGIN = 3; 32 | 33 | gpd->graphics->fillRect( 34 | mapLeft - MAP_BORDER - MAP_MARGIN, 35 | mapTop - MAP_BORDER - MAP_MARGIN, 36 | (MAP_WIDTH * PLAYDATE_ZOOM_SCALE) + ((MAP_BORDER + MAP_MARGIN) * 2), 37 | (MAP_HEIGHT * PLAYDATE_ZOOM_SCALE) + ((MAP_BORDER + MAP_MARGIN) * 2), 38 | kColorBlack); 39 | 40 | gpd->graphics->fillRect( 41 | mapLeft - MAP_MARGIN, 42 | mapTop - MAP_MARGIN, 43 | (MAP_WIDTH * PLAYDATE_ZOOM_SCALE) + (MAP_MARGIN * 2), 44 | (MAP_HEIGHT * PLAYDATE_ZOOM_SCALE) + (MAP_MARGIN * 2), 45 | kColorWhite); 46 | } 47 | 48 | 49 | /// 50 | void DrawMap::DrawCurrentTerrain(int mapLeft, int mapTop) 51 | { 52 | gpd->graphics->drawScaledBitmap( 53 | m_bmpTerrains[State.terrainType]->GetLCDBitmap(), 54 | mapLeft, mapTop, PLAYDATE_ZOOM_SCALE, PLAYDATE_ZOOM_SCALE); 55 | } 56 | 57 | 58 | /// 59 | static const LCDPattern cursor = { 60 | 0b10101010, 61 | 0b01010101, 62 | 0b10101010, 63 | 0b01010101, 64 | 0b10101010, 65 | 0b01010101, 66 | 0b10101010, 67 | 0b01010101, 68 | 69 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 70 | }; 71 | 72 | 73 | /// 74 | void DrawMap::DrawMapCursor(int mapLeft, int mapTop) 75 | { 76 | int tileScrollX = (UIState.scrollX + 4) >> TILE_SIZE_SHIFT; 77 | int tileScrollY = (UIState.scrollY + 4) >> TILE_SIZE_SHIFT; 78 | 79 | for (int i = 0; i < PLAYDATE_ZOOM_SCALE; i++) 80 | { 81 | gpd->graphics->drawRect( 82 | mapLeft + (tileScrollX * PLAYDATE_ZOOM_SCALE) + i, 83 | mapTop + (tileScrollY * PLAYDATE_ZOOM_SCALE) + i, 84 | (DISPLAY_WIDTH / TILE_SIZE) * PLAYDATE_ZOOM_SCALE - (i * 2), 85 | (DISPLAY_HEIGHT / TILE_SIZE) * PLAYDATE_ZOOM_SCALE - (i * 2), 86 | (LCDColor)cursor); 87 | } 88 | } 89 | 90 | 91 | 92 | /// 93 | DrawMap::DrawMap() 94 | { 95 | } 96 | 97 | 98 | /// 99 | DrawMap::~DrawMap() 100 | { 101 | } 102 | 103 | 104 | /// 105 | bool DrawMap::Initialize(const std::shared_ptr& buildingScore) 106 | { 107 | m_spBuildingScore = buildingScore; 108 | CreateTerrainBitmaps(); 109 | return true; 110 | } 111 | 112 | 113 | /// 114 | void DrawMap::DrawCurrentMap(MapInfo info, int mapLeft, int mapTop) 115 | { 116 | DrawMapFrame(mapLeft, mapTop); 117 | DrawCurrentTerrain(mapLeft, mapTop); 118 | 119 | switch (info) 120 | { 121 | case MapInfo_PopulationDestiny: 122 | m_spBuildingScore->DrawBuildingScore(BuildingScoreKind_PopulationDestiny, mapLeft, mapTop); 123 | break; 124 | 125 | case MapInfo_Crime: 126 | m_spBuildingScore->DrawBuildingScore(BuildingScoreKind_Crime, mapLeft, mapTop); 127 | break; 128 | 129 | case MapInfo_Pollution: 130 | m_spBuildingScore->DrawBuildingScore(BuildingScoreKind_Pollution, mapLeft, mapTop); 131 | break; 132 | 133 | case MapInfo_None: 134 | default: 135 | break; 136 | } 137 | 138 | DrawMapCursor(mapLeft, mapTop); 139 | } 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /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/Playdate/src/BuildingScore.cpp: -------------------------------------------------------------------------------- 1 | #include "BuildingScore.h" 2 | #include "Dithering.h" 3 | 4 | 5 | static const int BUILDING_ELEMENT_SIZE = 3; 6 | 7 | 8 | 9 | /// 10 | void BuildingScore::ClearBuildingScore() 11 | { 12 | gpd->graphics->pushContext(m_bmpWork); 13 | gpd->graphics->clear(kColorBlack); 14 | gpd->graphics->popContext(); 15 | 16 | gpd->graphics->pushContext(m_bmpBuildingScore); 17 | gpd->graphics->clear(kColorClear); 18 | gpd->graphics->popContext(); 19 | 20 | ::memset(&m_grayBuildingScore, 0, sizeof(uint8_t) * BS_WIDTH * BS_HEIGHT); 21 | } 22 | 23 | 24 | /// 25 | void BuildingScore::PutBuildingScore(uint8_t x, uint8_t y, uint8_t score) 26 | { 27 | int nX = x * PLAYDATE_ZOOM_SCALE; 28 | int nY = y * PLAYDATE_ZOOM_SCALE; 29 | for (int i = 0; i < PLAYDATE_ZOOM_SCALE * BUILDING_ELEMENT_SIZE; i++) 30 | { 31 | for (int j = 0; j < PLAYDATE_ZOOM_SCALE * BUILDING_ELEMENT_SIZE; j++) 32 | { 33 | m_grayBuildingScore[nX + i + ((nY + j) * BS_WIDTH)] = score; 34 | } 35 | } 36 | } 37 | 38 | 39 | /// 40 | void BuildingScore::UpdateBuildingScore(BuildingScoreKind kind) 41 | { 42 | ClearBuildingScore(); 43 | for (int n = 0; n < MAX_BUILDINGS; n++) 44 | { 45 | PutBuildingScore(State.buildings[n].x, State.buildings[n].y, m_buildingScore[n][kind]); 46 | } 47 | } 48 | 49 | 50 | 51 | /// 52 | BuildingScore::BuildingScore() 53 | : m_bmpWork(NULL) 54 | , m_bmpBuildingScore(NULL) 55 | { 56 | ::memset(&m_buildingScore, 0, sizeof(int) * MAX_BUILDINGS * BuildingScoreKind_COUNT); 57 | } 58 | 59 | 60 | /// 61 | BuildingScore::~BuildingScore() 62 | { 63 | if (m_bmpWork) 64 | { 65 | gpd->graphics->freeBitmap(m_bmpWork); 66 | } 67 | 68 | if (m_bmpBuildingScore) 69 | { 70 | gpd->graphics->freeBitmap(m_bmpBuildingScore); 71 | } 72 | } 73 | 74 | 75 | 76 | // from Simulation.cpp 77 | static const float SIM_MAX_CRIME = 50.0f; 78 | 79 | 80 | /// 81 | void BuildingScore::UpdateBuildingScore(Building* building, int score, int crime, int pollution, int localInfluence, int populationEffect, int randomEffect) 82 | { 83 | for (int n = 0; n < MAX_BUILDINGS; n++) 84 | { 85 | if (building == &State.buildings[n]) 86 | { 87 | int populationDensity = (building->populationDensity + 1) << 4; 88 | m_buildingScore[n][BuildingScoreKind_PopulationDestiny] = populationDensity < 0xff ? populationDensity : 0xff; 89 | 90 | int recCrime = static_cast((crime / SIM_MAX_CRIME) * 0xff); 91 | m_buildingScore[n][BuildingScoreKind_Crime] = recCrime < 0xff ? recCrime : 0xff; 92 | 93 | m_buildingScore[n][BuildingScoreKind_Pollution] = pollution < 0xff ? pollution : 0xff; 94 | return; 95 | } 96 | } 97 | } 98 | 99 | 100 | /// 101 | void BuildingScore::DrawBuildingScore(BuildingScoreKind kind, uint8_t x, uint8_t y) 102 | { 103 | if (m_bmpBuildingScore == NULL) 104 | { 105 | m_bmpWork = gpd->graphics->newBitmap(MAP_WIDTH * PLAYDATE_ZOOM_SCALE, MAP_HEIGHT * PLAYDATE_ZOOM_SCALE, kColorBlack); 106 | m_bmpBuildingScore = gpd->graphics->newBitmap(MAP_WIDTH * PLAYDATE_ZOOM_SCALE, MAP_HEIGHT * PLAYDATE_ZOOM_SCALE, kColorClear); 107 | } 108 | assert(m_bmpWork != NULL); 109 | assert(m_bmpBuildingScore != NULL); 110 | 111 | UpdateBuildingScore(kind); 112 | 113 | int dummy; 114 | uint8_t* pdummy; 115 | int rowBytes = 0; 116 | uint8_t* dstBuf = NULL; 117 | gpd->graphics->getBitmapData(m_bmpWork, &dummy, &dummy, &rowBytes, &pdummy, &dstBuf); 118 | Dithering::FloydSteinberg(m_grayBuildingScore, BS_WIDTH, BS_HEIGHT, dstBuf, rowBytes, false); 119 | 120 | gpd->graphics->pushContext(m_bmpBuildingScore); 121 | gpd->graphics->setDrawMode(kDrawModeInverted); 122 | gpd->graphics->drawBitmap(m_bmpWork, 0, 0, kBitmapUnflipped); 123 | gpd->graphics->popContext(); 124 | 125 | gpd->graphics->setDrawMode(kDrawModeWhiteTransparent); 126 | gpd->graphics->drawBitmap(m_bmpBuildingScore, x, y, kBitmapUnflipped); 127 | gpd->graphics->setDrawMode(kDrawModeCopy); 128 | 129 | #if 0 130 | gpd->lua->pushBitmap(m_bmpBuildingScore); 131 | gpd->lua->pushString("debug.gif"); 132 | const char* outerr = NULL; 133 | gpd->lua->callFunction("playdate.datastore.writeImage", 2, &outerr); 134 | #endif 135 | } 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------