├── .gitignore ├── .gitmodules ├── .travis.yml ├── INSTALL ├── Makefile ├── Makefile.nmake ├── README.md ├── Win32 └── SDL-1.2.15 │ ├── include │ ├── SDL.h │ ├── SDL_active.h │ ├── SDL_audio.h │ ├── SDL_byteorder.h │ ├── SDL_cdrom.h │ ├── SDL_config.h │ ├── SDL_config.h.default │ ├── SDL_config.h.in │ ├── SDL_config_dreamcast.h │ ├── SDL_config_macos.h │ ├── SDL_config_macosx.h │ ├── SDL_config_minimal.h │ ├── SDL_config_nds.h │ ├── SDL_config_os2.h │ ├── SDL_config_symbian.h │ ├── SDL_config_win32.h │ ├── SDL_copying.h │ ├── SDL_cpuinfo.h │ ├── SDL_endian.h │ ├── SDL_error.h │ ├── SDL_events.h │ ├── SDL_getenv.h │ ├── SDL_joystick.h │ ├── SDL_keyboard.h │ ├── SDL_keysym.h │ ├── SDL_loadso.h │ ├── SDL_main.h │ ├── SDL_mouse.h │ ├── SDL_mutex.h │ ├── SDL_name.h │ ├── SDL_opengl.h │ ├── SDL_platform.h │ ├── SDL_quit.h │ ├── SDL_rwops.h │ ├── SDL_stdinc.h │ ├── SDL_syswm.h │ ├── SDL_thread.h │ ├── SDL_timer.h │ ├── SDL_types.h │ ├── SDL_version.h │ ├── SDL_video.h │ ├── begin_code.h │ ├── close_code.h │ └── doxyfile │ └── lib │ └── x86 │ ├── SDL.dll │ ├── SDL.lib │ └── SDLmain.lib ├── Z80Emu_VS2015 ├── Z80Emu_VS2015.ico ├── Z80Emu_VS2015.sln ├── Z80Emu_VS2015.vcxproj └── Z80Emu_VS2015.vcxproj.filters ├── roms └── 48k.rom ├── src ├── cpu │ ├── cpuintf.c │ ├── cpuintf.h │ ├── mz80 │ │ ├── cpuintf.c │ │ ├── mz80.c │ │ └── mz80.h │ ├── z80core │ │ ├── Z80Core.cpp │ │ ├── Z80Core.h │ │ ├── Z80CoreOpcodeTables.h │ │ ├── Z80Core_CBOpcodes.cpp │ │ ├── Z80Core_CBOpcodes.h │ │ ├── Z80Core_CInterface.cpp │ │ ├── Z80Core_CInterface.h │ │ ├── Z80Core_DDCB_FDCBOpcodes.cpp │ │ ├── Z80Core_DDCB_FDCBOpcodes.h │ │ ├── Z80Core_DDOpcodes.cpp │ │ ├── Z80Core_DDOpcodes.h │ │ ├── Z80Core_EDOpcodes.cpp │ │ ├── Z80Core_EDOpcodes.h │ │ ├── Z80Core_FDOpcodes.cpp │ │ ├── Z80Core_FDOpcodes.h │ │ ├── Z80Core_MainOpcodes.cpp │ │ ├── Z80Core_MainOpcodes.h │ │ └── cpuintf.c │ └── z80emu │ │ ├── cpuintf.c │ │ ├── instructions.h │ │ ├── macros.h │ │ ├── maketables.c │ │ ├── tables.h │ │ ├── z80emu.c │ │ ├── z80emu.h │ │ ├── zextest.c │ │ └── zextest.h ├── osdep │ ├── dummy.c │ ├── osdep.h │ ├── sdl1.2.c │ └── sdl2.c └── zxem │ ├── zxem.c │ ├── zxem.h │ ├── zxio.c │ ├── zxio.h │ ├── zxvid.c │ └── zxvid.h ├── testfiles ├── zexall.com ├── zexall.z80 ├── zexdoc.com └── zexdoc.z80 └── tests ├── cputest.c ├── tests.expected └── tests.in /.gitignore: -------------------------------------------------------------------------------- 1 | obj 2 | zxem 3 | maketables -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "SDL1.2"] 2 | path = src/thirdparty/SDL1.2 3 | url = https://github.com/MikeDX/SDL1.2 4 | [submodule "SDL2"] 5 | path = src/thirdparty/SDL2 6 | url = https://github.com/MikeDX/SDL2 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | before_script: 4 | - sudo apt-get update -qq 5 | - sudo apt-get install libsdl1.2-dev 6 | 7 | script: make 8 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | For Linux or Mac, just type "make". It will compile the example zextest. 2 | 3 | For Windows, open a Visual C++ command prompt and then type: 4 | 5 | nmake /f Makefile.nmake 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # ZXEM MAKEFILE 2 | OLEVEL = -O3 3 | CFLAGS = -Isrc/zxem -Isrc/osdep -Isrc/cpu -Wall -pedantic $(OLEVEL) -fomit-frame-pointer 4 | SDL = 1 5 | ZCC = $(ZCC) 6 | #CPU = z80emu 7 | #CPU = mz80 8 | #CPU = deadz80 9 | CPU = z80core 10 | 11 | TARGET = zxem 12 | TEST_TARGET = tests/zxtest 13 | OBJDIR = obj 14 | ifndef PLAT 15 | PLAT = NATIVE 16 | endif 17 | 18 | ifdef DEBUG 19 | OLEVEL = -O0 -g 20 | endif 21 | 22 | OSD_SOURCE = src/osdep/dummy.c 23 | 24 | ifdef SDL 25 | ifeq ($(SDL), 1) 26 | OSD_SOURCE = src/osdep/sdl1.2.c 27 | OSDFLAGS = $(shell sdl-config --cflags) 28 | OSDLIBS = $(shell sdl-config --libs) 29 | endif 30 | ifeq ($(SDL), 2) 31 | OSD_SOURCE = src/osdep/sdl2.c 32 | OSDFLAGS = $(shell sdl2-config --cflags) 33 | OSDLIBS = $(shell sdl2-config --libs) 34 | endif 35 | endif 36 | 37 | 38 | ifeq ($(PLAT), HTML) 39 | ZCC = emcc 40 | AR = emar 41 | OSDFLAGS = -s USE_SDL=$(SDL) 42 | OSDLIBS = 43 | OLEVEL += -s ASM_JS=1 44 | LINKFLAGS = $(OSDFLAGS) $(OLEVEL) --preload-files roms/ --preload-files scr/ --emrun 45 | TARGET := $(TARGET).html 46 | OBJDIR = objhtml 47 | endif 48 | 49 | ifeq ($(CPU), z80emu) 50 | CPUOBJ = $(OBJDIR)/z80emu.o 51 | CPUINTC = src/cpu/z80emu/cpuintf.c 52 | endif 53 | 54 | ifeq ($(CPU), mz80) 55 | CPUOBJ = $(OBJDIR)/mz80.o 56 | CPUINTC = src/cpu/mz80/cpuintf.c 57 | endif 58 | 59 | ifeq ($(CPU), deadz80) 60 | CPUOBJ = $(OBJDIR)/deadz80.o 61 | CPUINTC = src/cpu/deadz80/cpuintf.c 62 | endif 63 | 64 | ifeq ($(CPU), z80core) 65 | CPUOBJ = $(OBJDIR)/z80core_Z80Core.o $(OBJDIR)/z80core_Z80Core_CBOpcodes.o $(OBJDIR)/z80core_Z80Core_DDCB_FDCBOpcodes.o $(OBJDIR)/z80core_Z80Core_DDOpcodes.o $(OBJDIR)/z80core_Z80Core_EDOpcodes.o $(OBJDIR)/z80core_Z80Core_FDOpcodes.o $(OBJDIR)/z80core_Z80Core_MainOpcodes.o $(OBJDIR)/z80core_Z80Core_CInterface.o 66 | CPUINTC = src/cpu/z80core/cpuintf.c 67 | 68 | # add permissive for initialising members in class definitions (Z80Core.h) 69 | CFLAGS += -fpermissive 70 | 71 | #compile as c++ when using z80 core 72 | ifeq ($(PLAT), HTML) 73 | ZCC = em++ 74 | else 75 | ZCC = $(CXX) 76 | endif 77 | 78 | endif 79 | 80 | 81 | all: $(OBJDIR) $(TARGET) 82 | 83 | $(OBJDIR): 84 | mkdir $(OBJDIR) 85 | 86 | tables.h: maketables.c 87 | $(ZCC) -Wall $< -o maketables 88 | ./maketables > $@ 89 | 90 | # MULTI CPU CORE! 91 | # Z80EMU - BROKEN 92 | $(OBJDIR)/z80emu.o: src/cpu/z80emu/z80emu.c src/cpu/z80emu/z80emu.h src/cpu/z80emu/instructions.h src/cpu/z80emu/macros.h src/cpu/z80emu/tables.h 93 | $(ZCC) $(CFLAGS) -c $< -o $@ 94 | 95 | # MZ80 - Issues on 64bit :( 96 | $(OBJDIR)/mz80.o: src/cpu/mz80/mz80.c src/cpu/mz80/mz80.h src/cpu/cpuintf.h 97 | $(ZCC) $(CFLAGS) -c $< -o $@ 98 | 99 | # DEADZ80 - Dead? 100 | $(OBJDIR)/deadz80.o: src/cpu/deadz80/deadz80.c src/cpu/deadz80/deadz80.h src/cpu/deadz80/opcodes.h src/cpu/cpuintf.h 101 | $(ZCC) $(CFLAGS) -c $< -o $@ 102 | 103 | # Z80CORE - SUCCESS! 104 | $(OBJDIR)/z80core_%.o: src/cpu/z80core/%.cpp 105 | $(ZCC) $(CFLAGS) -c $< -o $@ 106 | 107 | #$(OBJDIR)/z80core.a: src/cpu/z80core/Z80Core.o src/cpu/z80core/Z80Core_CBOpcodes.o src/cpu/z80core/Z80Core_DDCB_FDCBOpcodes.o src/cpu/z80core/Z80Core_DDOpcodes.o src/cpu/z80core/Z80Core_EDOpcodes.o src/cpu/z80core/Z80Core_FDOpcodes.o src/cpu/z80core/Z80Core_MainOpcodes.o 108 | # $(AR) cr $@ src/cpu/z80core/*.o 109 | 110 | $(OBJDIR)/zxem.o: src/zxem/zxem.c src/zxem/zxem.h src/osdep/osdep.h 111 | $(ZCC) $(CFLAGS) $(OSDFLAGS) -c $< -o $@ 112 | 113 | $(OBJDIR)/zxvid.o: src/zxem/zxvid.c src/zxem/zxem.h src/osdep/osdep.h 114 | $(ZCC) $(CFLAGS) -c $< -o $@ 115 | 116 | $(OBJDIR)/zxio.o: src/zxem/zxio.c src/zxem/zxem.h src/osdep/osdep.h 117 | $(ZCC) $(CFLAGS) -c $< -o $@ 118 | 119 | $(OBJDIR)/osdep.o: $(OSD_SOURCE) src/zxem/zxem.h src/osdep/osdep.h 120 | $(ZCC) $(CFLAGS) $(OSDFLAGS) -c $(OSD_SOURCE) -o $@ 121 | 122 | $(OBJDIR)/cpuintf.o: $(CPUINTC) 123 | $(ZCC) $(CFLAGS) -c $< -o $@ 124 | 125 | OBJECT_FILES = $(OBJDIR)/zxem.o $(CPUOBJ) $(OBJDIR)/zxvid.o $(OBJDIR)/zxio.o $(OBJDIR)/osdep.o $(OBJDIR)/cpuintf.o 126 | 127 | $(TARGET): $(OBJECT_FILES) 128 | $(ZCC) $(CFLAGS) $(OBJECT_FILES) $(OSDLIBS) $(LINKFLAGS) -o $@ 129 | 130 | $(TEST_TARGET): tests/cputest.c src/cpu/z80emu/z80emu.h $(OBJDIR)/z80emu.o 131 | $(ZCC) $(CFLAGS) $< $(OBJDIR)/z80emu.o -o $@ 132 | 133 | 134 | clean: 135 | rm $(OBJDIR)/*.o 136 | rm $(TARGET) 137 | -------------------------------------------------------------------------------- /Makefile.nmake: -------------------------------------------------------------------------------- 1 | CC = cl 2 | CFLAGS = /O2 3 | 4 | all: zextest.exe 5 | 6 | tables.h: maketables.c 7 | $(CC) maketables.c 8 | maketables > $@ 9 | 10 | z80emu.obj: z80emu.c z80emu.h instructions.h macros.h tables.h 11 | $(CC) $(CFLAGS) /c z80emu.c 12 | 13 | zextest.obj: zextest.c z80emu.h 14 | $(CC) /c zextest.c 15 | 16 | OBJECT_FILES = zextest.obj z80emu.obj 17 | 18 | zextest.exe: $(OBJECT_FILES) 19 | link $(OBJECT_FILES) /out:zextest.exe 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZXEMU 2 | 3 | Version 0.0.2 4 | https://github.com/MikeDX/z80emu/ 5 | Copyright (c) 2016 MikeDX 6 | 7 | Uses Z80 Cpu Core by Adrian Brown 8 | 9 | ZXEMU is a free open source cross platform ZX Spectrum emulator, currently work in progress hoping to support various models of ZX Spectrum. 10 | 11 | [Play online](http://js.mikedx.co.uk/zxem.html) 12 | 13 | [![Build Status](https://travis-ci.org/MikeDX/z80emu.svg?branch=master)](https://travis-ci.org/MikeDX/z80emu) 14 | 15 | ## TODO list 16 | - [x] Working Z80 CPU Core 17 | - [x] Screen renderer (pixels, ink, paper, bright, flash) 18 | - [x] Keyboard input 19 | - [x] Spectrum 48k rom support 20 | - [x] .scr image viewer 21 | - [x] Windows port 22 | - [x] OSX port 23 | - [x] Linux 24 | - [x] Android port 25 | - [x] Html/Javascript port (compile with make PLAT=HTML) 26 | - [x] Raspberry Pi port 27 | - [ ] 'BEEP' sound output 28 | - [ ] Spectrum 128K support 29 | - [ ] AY-3-8912 emulation 30 | - [ ] Configurable gamepad 31 | - [ ] TZX Support 32 | - [ ] Z80 Snapshot support 33 | - [ ] SNA Snapshot support 34 | - [ ] TAP Support 35 | 36 | Please help to test and develop this project! 37 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL.h 24 | * Main include header for the SDL library 25 | */ 26 | 27 | #ifndef _SDL_H 28 | #define _SDL_H 29 | 30 | #include "SDL_main.h" 31 | #include "SDL_stdinc.h" 32 | #include "SDL_audio.h" 33 | #include "SDL_cdrom.h" 34 | #include "SDL_cpuinfo.h" 35 | #include "SDL_endian.h" 36 | #include "SDL_error.h" 37 | #include "SDL_events.h" 38 | #include "SDL_loadso.h" 39 | #include "SDL_mutex.h" 40 | #include "SDL_rwops.h" 41 | #include "SDL_thread.h" 42 | #include "SDL_timer.h" 43 | #include "SDL_video.h" 44 | #include "SDL_version.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 | /** @file SDL.h 53 | * @note As of version 0.5, SDL is loaded dynamically into the application 54 | */ 55 | 56 | /** @name SDL_INIT Flags 57 | * These are the flags which may be passed to SDL_Init() -- you should 58 | * specify the subsystems which you will be using in your application. 59 | */ 60 | /*@{*/ 61 | #define SDL_INIT_TIMER 0x00000001 62 | #define SDL_INIT_AUDIO 0x00000010 63 | #define SDL_INIT_VIDEO 0x00000020 64 | #define SDL_INIT_CDROM 0x00000100 65 | #define SDL_INIT_JOYSTICK 0x00000200 66 | #define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */ 67 | #define SDL_INIT_EVENTTHREAD 0x01000000 /**< Not supported on all OS's */ 68 | #define SDL_INIT_EVERYTHING 0x0000FFFF 69 | /*@}*/ 70 | 71 | /** This function loads the SDL dynamically linked library and initializes 72 | * the subsystems specified by 'flags' (and those satisfying dependencies) 73 | * Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup 74 | * signal handlers for some commonly ignored fatal signals (like SIGSEGV) 75 | */ 76 | extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); 77 | 78 | /** This function initializes specific SDL subsystems */ 79 | extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); 80 | 81 | /** This function cleans up specific SDL subsystems */ 82 | extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); 83 | 84 | /** This function returns mask of the specified subsystems which have 85 | * been initialized. 86 | * If 'flags' is 0, it returns a mask of all initialized subsystems. 87 | */ 88 | extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); 89 | 90 | /** This function cleans up all initialized subsystems and unloads the 91 | * dynamically linked library. You should call it upon all exit conditions. 92 | */ 93 | extern DECLSPEC void SDLCALL SDL_Quit(void); 94 | 95 | /* Ends C function definitions when using C++ */ 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | #include "close_code.h" 100 | 101 | #endif /* _SDL_H */ 102 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_active.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file SDL_active.h 25 | * Include file for SDL application focus event handling 26 | */ 27 | 28 | #ifndef _SDL_active_h 29 | #define _SDL_active_h 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 | /** @name The available application states */ 41 | /*@{*/ 42 | #define SDL_APPMOUSEFOCUS 0x01 /**< The app has mouse coverage */ 43 | #define SDL_APPINPUTFOCUS 0x02 /**< The app has input focus */ 44 | #define SDL_APPACTIVE 0x04 /**< The application is active */ 45 | /*@}*/ 46 | 47 | /* Function prototypes */ 48 | /** 49 | * This function returns the current state of the application, which is a 50 | * bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and 51 | * SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to 52 | * see your application, otherwise it has been iconified or disabled. 53 | */ 54 | extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void); 55 | 56 | 57 | /* Ends C function definitions when using C++ */ 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | #include "close_code.h" 62 | 63 | #endif /* _SDL_active_h */ 64 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_byteorder.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file SDL_byteorder.h 25 | * @deprecated Use SDL_endian.h instead 26 | */ 27 | 28 | /* DEPRECATED */ 29 | #include "SDL_endian.h" 30 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_cdrom.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file SDL_cdrom.h 25 | * This is the CD-audio control API for Simple DirectMedia Layer 26 | */ 27 | 28 | #ifndef _SDL_cdrom_h 29 | #define _SDL_cdrom_h 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 | * @file SDL_cdrom.h 42 | * In order to use these functions, SDL_Init() must have been called 43 | * with the SDL_INIT_CDROM flag. This causes SDL to scan the system 44 | * for CD-ROM drives, and load appropriate drivers. 45 | */ 46 | 47 | /** The maximum number of CD-ROM tracks on a disk */ 48 | #define SDL_MAX_TRACKS 99 49 | 50 | /** @name Track Types 51 | * The types of CD-ROM track possible 52 | */ 53 | /*@{*/ 54 | #define SDL_AUDIO_TRACK 0x00 55 | #define SDL_DATA_TRACK 0x04 56 | /*@}*/ 57 | 58 | /** The possible states which a CD-ROM drive can be in. */ 59 | typedef enum { 60 | CD_TRAYEMPTY, 61 | CD_STOPPED, 62 | CD_PLAYING, 63 | CD_PAUSED, 64 | CD_ERROR = -1 65 | } CDstatus; 66 | 67 | /** Given a status, returns true if there's a disk in the drive */ 68 | #define CD_INDRIVE(status) ((int)(status) > 0) 69 | 70 | typedef struct SDL_CDtrack { 71 | Uint8 id; /**< Track number */ 72 | Uint8 type; /**< Data or audio track */ 73 | Uint16 unused; 74 | Uint32 length; /**< Length, in frames, of this track */ 75 | Uint32 offset; /**< Offset, in frames, from start of disk */ 76 | } SDL_CDtrack; 77 | 78 | /** This structure is only current as of the last call to SDL_CDStatus() */ 79 | typedef struct SDL_CD { 80 | int id; /**< Private drive identifier */ 81 | CDstatus status; /**< Current drive status */ 82 | 83 | /** The rest of this structure is only valid if there's a CD in drive */ 84 | /*@{*/ 85 | int numtracks; /**< Number of tracks on disk */ 86 | int cur_track; /**< Current track position */ 87 | int cur_frame; /**< Current frame offset within current track */ 88 | SDL_CDtrack track[SDL_MAX_TRACKS+1]; 89 | /*@}*/ 90 | } SDL_CD; 91 | 92 | /** @name Frames / MSF Conversion Functions 93 | * Conversion functions from frames to Minute/Second/Frames and vice versa 94 | */ 95 | /*@{*/ 96 | #define CD_FPS 75 97 | #define FRAMES_TO_MSF(f, M,S,F) { \ 98 | int value = f; \ 99 | *(F) = value%CD_FPS; \ 100 | value /= CD_FPS; \ 101 | *(S) = value%60; \ 102 | value /= 60; \ 103 | *(M) = value; \ 104 | } 105 | #define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F)) 106 | /*@}*/ 107 | 108 | /* CD-audio API functions: */ 109 | 110 | /** 111 | * Returns the number of CD-ROM drives on the system, or -1 if 112 | * SDL_Init() has not been called with the SDL_INIT_CDROM flag. 113 | */ 114 | extern DECLSPEC int SDLCALL SDL_CDNumDrives(void); 115 | 116 | /** 117 | * Returns a human-readable, system-dependent identifier for the CD-ROM. 118 | * Example: 119 | * - "/dev/cdrom" 120 | * - "E:" 121 | * - "/dev/disk/ide/1/master" 122 | */ 123 | extern DECLSPEC const char * SDLCALL SDL_CDName(int drive); 124 | 125 | /** 126 | * Opens a CD-ROM drive for access. It returns a drive handle on success, 127 | * or NULL if the drive was invalid or busy. This newly opened CD-ROM 128 | * becomes the default CD used when other CD functions are passed a NULL 129 | * CD-ROM handle. 130 | * Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. 131 | */ 132 | extern DECLSPEC SDL_CD * SDLCALL SDL_CDOpen(int drive); 133 | 134 | /** 135 | * This function returns the current status of the given drive. 136 | * If the drive has a CD in it, the table of contents of the CD and current 137 | * play position of the CD will be stored in the SDL_CD structure. 138 | */ 139 | extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom); 140 | 141 | /** 142 | * Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' 143 | * tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play 144 | * until the end of the CD. This function will skip data tracks. 145 | * This function should only be called after calling SDL_CDStatus() to 146 | * get track information about the CD. 147 | * For example: 148 | * @code 149 | * // Play entire CD: 150 | * if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) 151 | * SDL_CDPlayTracks(cdrom, 0, 0, 0, 0); 152 | * // Play last track: 153 | * if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) { 154 | * SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0); 155 | * } 156 | * // Play first and second track and 10 seconds of third track: 157 | * if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) 158 | * SDL_CDPlayTracks(cdrom, 0, 0, 2, 10); 159 | * @endcode 160 | * 161 | * @return This function returns 0, or -1 if there was an error. 162 | */ 163 | extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom, 164 | int start_track, int start_frame, int ntracks, int nframes); 165 | 166 | /** 167 | * Play the given CD starting at 'start' frame for 'length' frames. 168 | * @return It returns 0, or -1 if there was an error. 169 | */ 170 | extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD *cdrom, int start, int length); 171 | 172 | /** Pause play 173 | * @return returns 0, or -1 on error 174 | */ 175 | extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD *cdrom); 176 | 177 | /** Resume play 178 | * @return returns 0, or -1 on error 179 | */ 180 | extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD *cdrom); 181 | 182 | /** Stop play 183 | * @return returns 0, or -1 on error 184 | */ 185 | extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD *cdrom); 186 | 187 | /** Eject CD-ROM 188 | * @return returns 0, or -1 on error 189 | */ 190 | extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD *cdrom); 191 | 192 | /** Closes the handle for the CD-ROM drive */ 193 | extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom); 194 | 195 | 196 | /* Ends C function definitions when using C++ */ 197 | #ifdef __cplusplus 198 | } 199 | #endif 200 | #include "close_code.h" 201 | 202 | #endif /* _SDL_video_h */ 203 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_h 24 | #define _SDL_config_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* Add any platform that doesn't build using the configure system */ 29 | #if defined(__DREAMCAST__) 30 | #include "SDL_config_dreamcast.h" 31 | #elif defined(__MACOS__) 32 | #include "SDL_config_macos.h" 33 | #elif defined(__MACOSX__) 34 | #include "SDL_config_macosx.h" 35 | #elif defined(__SYMBIAN32__) 36 | #include "SDL_config_symbian.h" /* must be before win32! */ 37 | #elif defined(__WIN32__) 38 | #include "SDL_config_win32.h" 39 | #elif defined(__OS2__) 40 | #include "SDL_config_os2.h" 41 | #else 42 | #include "SDL_config_minimal.h" 43 | #endif /* platform config */ 44 | 45 | #endif /* _SDL_config_h */ 46 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_config.h.default: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_h 24 | #define _SDL_config_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* Add any platform that doesn't build using the configure system */ 29 | #if defined(__DREAMCAST__) 30 | #include "SDL_config_dreamcast.h" 31 | #elif defined(__MACOS__) 32 | #include "SDL_config_macos.h" 33 | #elif defined(__MACOSX__) 34 | #include "SDL_config_macosx.h" 35 | #elif defined(__SYMBIAN32__) 36 | #include "SDL_config_symbian.h" /* must be before win32! */ 37 | #elif defined(__WIN32__) 38 | #include "SDL_config_win32.h" 39 | #elif defined(__OS2__) 40 | #include "SDL_config_os2.h" 41 | #else 42 | #include "SDL_config_minimal.h" 43 | #endif /* platform config */ 44 | 45 | #endif /* _SDL_config_h */ 46 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_config_dreamcast.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_dreamcast_h 24 | #define _SDL_config_dreamcast_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This is a set of defines to configure the SDL features */ 29 | 30 | typedef signed char int8_t; 31 | typedef unsigned char uint8_t; 32 | typedef signed short int16_t; 33 | typedef unsigned short uint16_t; 34 | typedef signed int int32_t; 35 | typedef unsigned int uint32_t; 36 | typedef signed long long int64_t; 37 | typedef unsigned long long uint64_t; 38 | typedef unsigned long uintptr_t; 39 | #define SDL_HAS_64BIT_TYPE 1 40 | 41 | /* Useful headers */ 42 | #define HAVE_SYS_TYPES_H 1 43 | #define HAVE_STDIO_H 1 44 | #define STDC_HEADERS 1 45 | #define HAVE_STRING_H 1 46 | #define HAVE_CTYPE_H 1 47 | 48 | /* C library functions */ 49 | #define HAVE_MALLOC 1 50 | #define HAVE_CALLOC 1 51 | #define HAVE_REALLOC 1 52 | #define HAVE_FREE 1 53 | #define HAVE_ALLOCA 1 54 | #define HAVE_GETENV 1 55 | #define HAVE_PUTENV 1 56 | #define HAVE_QSORT 1 57 | #define HAVE_ABS 1 58 | #define HAVE_BCOPY 1 59 | #define HAVE_MEMSET 1 60 | #define HAVE_MEMCPY 1 61 | #define HAVE_MEMMOVE 1 62 | #define HAVE_MEMCMP 1 63 | #define HAVE_STRLEN 1 64 | #define HAVE_STRDUP 1 65 | #define HAVE_INDEX 1 66 | #define HAVE_RINDEX 1 67 | #define HAVE_STRCHR 1 68 | #define HAVE_STRRCHR 1 69 | #define HAVE_STRSTR 1 70 | #define HAVE_STRTOL 1 71 | #define HAVE_STRTOD 1 72 | #define HAVE_ATOI 1 73 | #define HAVE_ATOF 1 74 | #define HAVE_STRCMP 1 75 | #define HAVE_STRNCMP 1 76 | #define HAVE_STRICMP 1 77 | #define HAVE_STRCASECMP 1 78 | #define HAVE_SSCANF 1 79 | #define HAVE_SNPRINTF 1 80 | #define HAVE_VSNPRINTF 1 81 | 82 | /* Enable various audio drivers */ 83 | #define SDL_AUDIO_DRIVER_DC 1 84 | #define SDL_AUDIO_DRIVER_DISK 1 85 | #define SDL_AUDIO_DRIVER_DUMMY 1 86 | 87 | /* Enable various cdrom drivers */ 88 | #define SDL_CDROM_DC 1 89 | 90 | /* Enable various input drivers */ 91 | #define SDL_JOYSTICK_DC 1 92 | 93 | /* Enable various shared object loading systems */ 94 | #define SDL_LOADSO_DUMMY 1 95 | 96 | /* Enable various threading systems */ 97 | #define SDL_THREAD_DC 1 98 | 99 | /* Enable various timer systems */ 100 | #define SDL_TIMER_DC 1 101 | 102 | /* Enable various video drivers */ 103 | #define SDL_VIDEO_DRIVER_DC 1 104 | #define SDL_VIDEO_DRIVER_DUMMY 1 105 | 106 | #endif /* _SDL_config_dreamcast_h */ 107 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_config_macos.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_macos_h 24 | #define _SDL_config_macos_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This is a set of defines to configure the SDL features */ 29 | 30 | #include 31 | 32 | typedef SInt8 int8_t; 33 | typedef UInt8 uint8_t; 34 | typedef SInt16 int16_t; 35 | typedef UInt16 uint16_t; 36 | typedef SInt32 int32_t; 37 | typedef UInt32 uint32_t; 38 | typedef SInt64 int64_t; 39 | typedef UInt64 uint64_t; 40 | typedef unsigned long uintptr_t; 41 | 42 | #define SDL_HAS_64BIT_TYPE 1 43 | 44 | /* Useful headers */ 45 | #define HAVE_STDIO_H 1 46 | #define STDC_HEADERS 1 47 | #define HAVE_STRING_H 1 48 | #define HAVE_CTYPE_H 1 49 | #define HAVE_MATH_H 1 50 | #define HAVE_SIGNAL_H 1 51 | 52 | /* C library functions */ 53 | #define HAVE_MALLOC 1 54 | #define HAVE_CALLOC 1 55 | #define HAVE_REALLOC 1 56 | #define HAVE_FREE 1 57 | #define HAVE_ALLOCA 1 58 | #define HAVE_ABS 1 59 | #define HAVE_MEMSET 1 60 | #define HAVE_MEMCPY 1 61 | #define HAVE_MEMMOVE 1 62 | #define HAVE_MEMCMP 1 63 | #define HAVE_STRLEN 1 64 | #define HAVE_STRCHR 1 65 | #define HAVE_STRRCHR 1 66 | #define HAVE_STRSTR 1 67 | #define HAVE_ITOA 1 68 | #define HAVE_STRTOL 1 69 | #define HAVE_STRTOD 1 70 | #define HAVE_ATOI 1 71 | #define HAVE_ATOF 1 72 | #define HAVE_STRCMP 1 73 | #define HAVE_STRNCMP 1 74 | #define HAVE_SSCANF 1 75 | 76 | /* Enable various audio drivers */ 77 | #define SDL_AUDIO_DRIVER_SNDMGR 1 78 | #define SDL_AUDIO_DRIVER_DISK 1 79 | #define SDL_AUDIO_DRIVER_DUMMY 1 80 | 81 | /* Enable various cdrom drivers */ 82 | #if TARGET_API_MAC_CARBON 83 | #define SDL_CDROM_DUMMY 1 84 | #else 85 | #define SDL_CDROM_MACOS 1 86 | #endif 87 | 88 | /* Enable various input drivers */ 89 | #if TARGET_API_MAC_CARBON 90 | #define SDL_JOYSTICK_DUMMY 1 91 | #else 92 | #define SDL_JOYSTICK_MACOS 1 93 | #endif 94 | 95 | /* Enable various shared object loading systems */ 96 | #define SDL_LOADSO_MACOS 1 97 | 98 | /* Enable various threading systems */ 99 | #define SDL_THREADS_DISABLED 1 100 | 101 | /* Enable various timer systems */ 102 | #define SDL_TIMER_MACOS 1 103 | 104 | /* Enable various video drivers */ 105 | #define SDL_VIDEO_DRIVER_DUMMY 1 106 | #define SDL_VIDEO_DRIVER_DRAWSPROCKET 1 107 | #define SDL_VIDEO_DRIVER_TOOLBOX 1 108 | 109 | /* Enable OpenGL support */ 110 | #define SDL_VIDEO_OPENGL 1 111 | 112 | #endif /* _SDL_config_macos_h */ 113 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_config_macosx.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_macosx_h 24 | #define _SDL_config_macosx_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ 29 | #include 30 | 31 | /* This is a set of defines to configure the SDL features */ 32 | 33 | #define SDL_HAS_64BIT_TYPE 1 34 | 35 | /* Useful headers */ 36 | /* If we specified an SDK or have a post-PowerPC chip, then alloca.h exists. */ 37 | #if ( (MAC_OS_X_VERSION_MIN_REQUIRED >= 1030) || (!defined(__POWERPC__)) ) 38 | #define HAVE_ALLOCA_H 1 39 | #endif 40 | #define HAVE_SYS_TYPES_H 1 41 | #define HAVE_STDIO_H 1 42 | #define STDC_HEADERS 1 43 | #define HAVE_STRING_H 1 44 | #define HAVE_INTTYPES_H 1 45 | #define HAVE_STDINT_H 1 46 | #define HAVE_CTYPE_H 1 47 | #define HAVE_MATH_H 1 48 | #define HAVE_SIGNAL_H 1 49 | 50 | /* C library functions */ 51 | #define HAVE_MALLOC 1 52 | #define HAVE_CALLOC 1 53 | #define HAVE_REALLOC 1 54 | #define HAVE_FREE 1 55 | #define HAVE_ALLOCA 1 56 | #define HAVE_GETENV 1 57 | #define HAVE_PUTENV 1 58 | #define HAVE_UNSETENV 1 59 | #define HAVE_QSORT 1 60 | #define HAVE_ABS 1 61 | #define HAVE_BCOPY 1 62 | #define HAVE_MEMSET 1 63 | #define HAVE_MEMCPY 1 64 | #define HAVE_MEMMOVE 1 65 | #define HAVE_MEMCMP 1 66 | #define HAVE_STRLEN 1 67 | #define HAVE_STRLCPY 1 68 | #define HAVE_STRLCAT 1 69 | #define HAVE_STRDUP 1 70 | #define HAVE_STRCHR 1 71 | #define HAVE_STRRCHR 1 72 | #define HAVE_STRSTR 1 73 | #define HAVE_STRTOL 1 74 | #define HAVE_STRTOUL 1 75 | #define HAVE_STRTOLL 1 76 | #define HAVE_STRTOULL 1 77 | #define HAVE_STRTOD 1 78 | #define HAVE_ATOI 1 79 | #define HAVE_ATOF 1 80 | #define HAVE_STRCMP 1 81 | #define HAVE_STRNCMP 1 82 | #define HAVE_STRCASECMP 1 83 | #define HAVE_STRNCASECMP 1 84 | #define HAVE_SSCANF 1 85 | #define HAVE_SNPRINTF 1 86 | #define HAVE_VSNPRINTF 1 87 | #define HAVE_SIGACTION 1 88 | #define HAVE_SETJMP 1 89 | #define HAVE_NANOSLEEP 1 90 | 91 | /* Enable various audio drivers */ 92 | #define SDL_AUDIO_DRIVER_COREAUDIO 1 93 | #define SDL_AUDIO_DRIVER_DISK 1 94 | #define SDL_AUDIO_DRIVER_DUMMY 1 95 | 96 | /* Enable various cdrom drivers */ 97 | #define SDL_CDROM_MACOSX 1 98 | 99 | /* Enable various input drivers */ 100 | #define SDL_JOYSTICK_IOKIT 1 101 | 102 | /* Enable various shared object loading systems */ 103 | #ifdef __ppc__ 104 | /* For Mac OS X 10.2 compatibility */ 105 | #define SDL_LOADSO_DLCOMPAT 1 106 | #else 107 | #define SDL_LOADSO_DLOPEN 1 108 | #endif 109 | 110 | /* Enable various threading systems */ 111 | #define SDL_THREAD_PTHREAD 1 112 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 113 | 114 | /* Enable various timer systems */ 115 | #define SDL_TIMER_UNIX 1 116 | 117 | /* Enable various video drivers */ 118 | #define SDL_VIDEO_DRIVER_DUMMY 1 119 | #if ((defined TARGET_API_MAC_CARBON) && (TARGET_API_MAC_CARBON)) 120 | #define SDL_VIDEO_DRIVER_TOOLBOX 1 121 | #else 122 | #define SDL_VIDEO_DRIVER_QUARTZ 1 123 | #endif 124 | #define SDL_VIDEO_DRIVER_DGA 1 125 | #define SDL_VIDEO_DRIVER_X11 1 126 | #define SDL_VIDEO_DRIVER_X11_DGAMOUSE 1 127 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" 128 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" 129 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" 130 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER "/usr/X11R6/lib/libXrender.1.dylib" 131 | #define SDL_VIDEO_DRIVER_X11_VIDMODE 1 132 | #define SDL_VIDEO_DRIVER_X11_XINERAMA 1 133 | #define SDL_VIDEO_DRIVER_X11_XME 1 134 | #define SDL_VIDEO_DRIVER_X11_XRANDR 1 135 | #define SDL_VIDEO_DRIVER_X11_XV 1 136 | 137 | /* Enable OpenGL support */ 138 | #define SDL_VIDEO_OPENGL 1 139 | #define SDL_VIDEO_OPENGL_GLX 1 140 | 141 | /* Disable screensaver */ 142 | #define SDL_VIDEO_DISABLE_SCREENSAVER 1 143 | 144 | /* Enable assembly routines */ 145 | #define SDL_ASSEMBLY_ROUTINES 1 146 | #ifdef __ppc__ 147 | #define SDL_ALTIVEC_BLITTERS 1 148 | #endif 149 | 150 | #endif /* _SDL_config_macosx_h */ 151 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_config_minimal.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_minimal_h 24 | #define _SDL_config_minimal_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This is the minimal configuration that can be used to build SDL */ 29 | 30 | #include 31 | 32 | typedef signed char int8_t; 33 | typedef unsigned char uint8_t; 34 | typedef signed short int16_t; 35 | typedef unsigned short uint16_t; 36 | typedef signed int int32_t; 37 | typedef unsigned int uint32_t; 38 | typedef unsigned int size_t; 39 | typedef unsigned long uintptr_t; 40 | 41 | /* Enable the dummy audio driver (src/audio/dummy/\*.c) */ 42 | #define SDL_AUDIO_DRIVER_DUMMY 1 43 | 44 | /* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ 45 | #define SDL_CDROM_DISABLED 1 46 | 47 | /* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ 48 | #define SDL_JOYSTICK_DISABLED 1 49 | 50 | /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ 51 | #define SDL_LOADSO_DISABLED 1 52 | 53 | /* Enable the stub thread support (src/thread/generic/\*.c) */ 54 | #define SDL_THREADS_DISABLED 1 55 | 56 | /* Enable the stub timer support (src/timer/dummy/\*.c) */ 57 | #define SDL_TIMERS_DISABLED 1 58 | 59 | /* Enable the dummy video driver (src/video/dummy/\*.c) */ 60 | #define SDL_VIDEO_DRIVER_DUMMY 1 61 | 62 | #endif /* _SDL_config_minimal_h */ 63 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_config_nds.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_nds_h 24 | #define _SDL_config_nds_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This is a set of defines to configure the SDL features */ 29 | 30 | /* General platform specific identifiers */ 31 | #include "SDL_platform.h" 32 | 33 | /* C datatypes */ 34 | #define SDL_HAS_64BIT_TYPE 1 35 | 36 | /* Endianness */ 37 | #define SDL_BYTEORDER 1234 38 | 39 | /* Useful headers */ 40 | #define HAVE_ALLOCA_H 1 41 | #define HAVE_SYS_TYPES_H 1 42 | #define HAVE_STDIO_H 1 43 | #define STDC_HEADERS 1 44 | #define HAVE_STDLIB_H 1 45 | #define HAVE_STDARG_H 1 46 | #define HAVE_MALLOC_H 1 47 | #define HAVE_STRING_H 1 48 | #define HAVE_INTTYPES_H 1 49 | #define HAVE_STDINT_H 1 50 | #define HAVE_CTYPE_H 1 51 | #define HAVE_MATH_H 1 52 | #define HAVE_ICONV_H 1 53 | #define HAVE_SIGNAL_H 1 54 | 55 | /* C library functions */ 56 | #define HAVE_MALLOC 1 57 | #define HAVE_CALLOC 1 58 | #define HAVE_REALLOC 1 59 | #define HAVE_FREE 1 60 | #define HAVE_ALLOCA 1 61 | #define HAVE_GETENV 1 62 | #define HAVE_PUTENV 1 63 | #define HAVE_UNSETENV 1 64 | #define HAVE_QSORT 1 65 | #define HAVE_ABS 1 66 | #define HAVE_BCOPY 1 67 | #define HAVE_MEMSET 1 68 | #define HAVE_MEMCPY 1 69 | #define HAVE_MEMMOVE 1 70 | #define HAVE_STRLEN 1 71 | #define HAVE_STRLCPY 1 72 | #define HAVE_STRLCAT 1 73 | #define HAVE_STRDUP 1 74 | #define HAVE_STRCHR 1 75 | #define HAVE_STRRCHR 1 76 | #define HAVE_STRSTR 1 77 | #define HAVE_STRTOL 1 78 | #define HAVE_STRTOUL 1 79 | #define HAVE_STRTOLL 1 80 | #define HAVE_STRTOULL 1 81 | #define HAVE_ATOI 1 82 | #define HAVE_ATOF 1 83 | #define HAVE_STRCMP 1 84 | #define HAVE_STRNCMP 1 85 | #define HAVE_STRCASECMP 1 86 | #define HAVE_STRNCASECMP 1 87 | #define HAVE_SSCANF 1 88 | #define HAVE_SNPRINTF 1 89 | #define HAVE_VSNPRINTF 1 90 | #define HAVE_SETJMP 1 91 | 92 | /* Enable various audio drivers */ 93 | #define SDL_AUDIO_DRIVER_NDS 1 94 | #define SDL_AUDIO_DRIVER_DUMMY 1 95 | 96 | /* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ 97 | #define SDL_CDROM_DISABLED 1 98 | 99 | /* Enable various input drivers */ 100 | #define SDL_JOYSTICK_NDS 1 101 | 102 | /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ 103 | #define SDL_LOADSO_DISABLED 1 104 | 105 | /* Enable the stub thread support (src/thread/generic/\*.c) */ 106 | #define SDL_THREADS_DISABLED 1 107 | 108 | /* Enable various timer systems */ 109 | #define SDL_TIMER_NDS 1 110 | 111 | /* Enable various video drivers */ 112 | #define SDL_VIDEO_DRIVER_NDS 1 113 | #define SDL_VIDEO_DRIVER_DUMMY 1 114 | 115 | #endif /* _SDL_config_nds_h */ 116 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_config_os2.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_os2_h 24 | #define _SDL_config_os2_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This is a set of defines to configure the SDL features */ 29 | 30 | typedef signed char int8_t; 31 | typedef unsigned char uint8_t; 32 | typedef signed short int16_t; 33 | typedef unsigned short uint16_t; 34 | typedef signed int int32_t; 35 | typedef unsigned int uint32_t; 36 | typedef unsigned int size_t; 37 | typedef unsigned long uintptr_t; 38 | typedef signed long long int64_t; 39 | typedef unsigned long long uint64_t; 40 | 41 | #define SDL_HAS_64BIT_TYPE 1 42 | 43 | /* Use Watcom's LIBC */ 44 | #define HAVE_LIBC 1 45 | 46 | /* Useful headers */ 47 | #define HAVE_SYS_TYPES_H 1 48 | #define HAVE_STDIO_H 1 49 | #define STDC_HEADERS 1 50 | #define HAVE_STDLIB_H 1 51 | #define HAVE_STDARG_H 1 52 | #define HAVE_MALLOC_H 1 53 | #define HAVE_MEMORY_H 1 54 | #define HAVE_STRING_H 1 55 | #define HAVE_STRINGS_H 1 56 | #define HAVE_INTTYPES_H 1 57 | #define HAVE_STDINT_H 1 58 | #define HAVE_CTYPE_H 1 59 | #define HAVE_MATH_H 1 60 | #define HAVE_SIGNAL_H 1 61 | 62 | /* C library functions */ 63 | #define HAVE_MALLOC 1 64 | #define HAVE_CALLOC 1 65 | #define HAVE_REALLOC 1 66 | #define HAVE_FREE 1 67 | #define HAVE_ALLOCA 1 68 | #define HAVE_GETENV 1 69 | #define HAVE_PUTENV 1 70 | #define HAVE_UNSETENV 1 71 | #define HAVE_QSORT 1 72 | #define HAVE_ABS 1 73 | #define HAVE_BCOPY 1 74 | #define HAVE_MEMSET 1 75 | #define HAVE_MEMCPY 1 76 | #define HAVE_MEMMOVE 1 77 | #define HAVE_MEMCMP 1 78 | #define HAVE_STRLEN 1 79 | #define HAVE_STRLCPY 1 80 | #define HAVE_STRLCAT 1 81 | #define HAVE_STRDUP 1 82 | #define HAVE__STRREV 1 83 | #define HAVE__STRUPR 1 84 | #define HAVE__STRLWR 1 85 | #define HAVE_INDEX 1 86 | #define HAVE_RINDEX 1 87 | #define HAVE_STRCHR 1 88 | #define HAVE_STRRCHR 1 89 | #define HAVE_STRSTR 1 90 | #define HAVE_ITOA 1 91 | #define HAVE__LTOA 1 92 | #define HAVE__UITOA 1 93 | #define HAVE__ULTOA 1 94 | #define HAVE_STRTOL 1 95 | #define HAVE__I64TOA 1 96 | #define HAVE__UI64TOA 1 97 | #define HAVE_STRTOLL 1 98 | #define HAVE_STRTOD 1 99 | #define HAVE_ATOI 1 100 | #define HAVE_ATOF 1 101 | #define HAVE_STRCMP 1 102 | #define HAVE_STRNCMP 1 103 | #define HAVE_STRICMP 1 104 | #define HAVE_STRCASECMP 1 105 | #define HAVE_SSCANF 1 106 | #define HAVE_SNPRINTF 1 107 | #define HAVE_VSNPRINTF 1 108 | #define HAVE_SETJMP 1 109 | #define HAVE_CLOCK_GETTIME 1 110 | 111 | /* Enable various audio drivers */ 112 | #define SDL_AUDIO_DRIVER_DART 1 113 | #define SDL_AUDIO_DRIVER_DISK 1 114 | #define SDL_AUDIO_DRIVER_DUMMY 1 115 | 116 | /* Enable various cdrom drivers */ 117 | #define SDL_CDROM_OS2 1 118 | 119 | /* Enable various input drivers */ 120 | #define SDL_JOYSTICK_OS2 1 121 | 122 | /* Enable various shared object loading systems */ 123 | #define SDL_LOADSO_OS2 1 124 | 125 | /* Enable various threading systems */ 126 | #define SDL_THREAD_OS2 1 127 | 128 | /* Enable various timer systems */ 129 | #define SDL_TIMER_OS2 1 130 | 131 | /* Enable various video drivers */ 132 | #define SDL_VIDEO_DRIVER_DUMMY 1 133 | #define SDL_VIDEO_DRIVER_OS2FS 1 134 | 135 | /* Enable OpenGL support */ 136 | /* Nothing here yet for OS/2... :( */ 137 | 138 | /* Enable assembly routines where available */ 139 | #define SDL_ASSEMBLY_ROUTINES 1 140 | 141 | #endif /* _SDL_config_os2_h */ 142 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_config_symbian.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /* 24 | 25 | Symbian version Markus Mertama 26 | 27 | */ 28 | 29 | 30 | #ifndef _SDL_CONFIG_SYMBIAN_H 31 | #define _SDL_CONFIG_SYMBIAN_H 32 | 33 | #include "SDL_platform.h" 34 | 35 | /* This is the minimal configuration that can be used to build SDL */ 36 | 37 | 38 | #include 39 | #include 40 | 41 | 42 | #ifdef __GCCE__ 43 | #define SYMBIAN32_GCCE 44 | #endif 45 | 46 | #ifndef _SIZE_T_DEFINED 47 | typedef unsigned int size_t; 48 | #endif 49 | 50 | #ifndef _INTPTR_T_DECLARED 51 | typedef unsigned int uintptr_t; 52 | #endif 53 | 54 | #ifndef _INT8_T_DECLARED 55 | typedef signed char int8_t; 56 | #endif 57 | 58 | #ifndef _UINT8_T_DECLARED 59 | typedef unsigned char uint8_t; 60 | #endif 61 | 62 | #ifndef _INT16_T_DECLARED 63 | typedef signed short int16_t; 64 | #endif 65 | 66 | #ifndef _UINT16_T_DECLARED 67 | typedef unsigned short uint16_t; 68 | #endif 69 | 70 | #ifndef _INT32_T_DECLARED 71 | typedef signed int int32_t; 72 | #endif 73 | 74 | #ifndef _UINT32_T_DECLARED 75 | typedef unsigned int uint32_t; 76 | #endif 77 | 78 | #ifndef _INT64_T_DECLARED 79 | typedef signed long long int64_t; 80 | #endif 81 | 82 | #ifndef _UINT64_T_DECLARED 83 | typedef unsigned long long uint64_t; 84 | #endif 85 | 86 | #define SDL_AUDIO_DRIVER_EPOCAUDIO 1 87 | 88 | 89 | /* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ 90 | #define SDL_CDROM_DISABLED 1 91 | 92 | /* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ 93 | #define SDL_JOYSTICK_DISABLED 1 94 | 95 | /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ 96 | #define SDL_LOADSO_DISABLED 1 97 | 98 | #define SDL_THREAD_SYMBIAN 1 99 | 100 | #define SDL_VIDEO_DRIVER_EPOC 1 101 | 102 | #define SDL_VIDEO_OPENGL 0 103 | 104 | #define SDL_HAS_64BIT_TYPE 1 105 | 106 | #define HAVE_LIBC 1 107 | #define HAVE_STDIO_H 1 108 | #define STDC_HEADERS 1 109 | #define HAVE_STRING_H 1 110 | #define HAVE_CTYPE_H 1 111 | #define HAVE_MATH_H 1 112 | 113 | #define HAVE_MALLOC 1 114 | #define HAVE_CALLOC 1 115 | #define HAVE_REALLOC 1 116 | #define HAVE_FREE 1 117 | /*#define HAVE_ALLOCA 1*/ 118 | #define HAVE_QSORT 1 119 | #define HAVE_ABS 1 120 | #define HAVE_MEMSET 1 121 | #define HAVE_MEMCPY 1 122 | #define HAVE_MEMMOVE 1 123 | #define HAVE_MEMCMP 1 124 | #define HAVE_STRLEN 1 125 | #define HAVE__STRUPR 1 126 | #define HAVE_STRCHR 1 127 | #define HAVE_STRRCHR 1 128 | #define HAVE_STRSTR 1 129 | #define HAVE_ITOA 1 130 | #define HAVE_STRTOL 1 131 | #define HAVE_STRTOUL 1 132 | #define HAVE_STRTOLL 1 133 | #define HAVE_STRTOD 1 134 | #define HAVE_ATOI 1 135 | #define HAVE_ATOF 1 136 | #define HAVE_STRCMP 1 137 | #define HAVE_STRNCMP 1 138 | /*#define HAVE__STRICMP 1*/ 139 | #define HAVE__STRNICMP 1 140 | #define HAVE_SSCANF 1 141 | #define HAVE_STDARG_H 1 142 | #define HAVE_STDDEF_H 1 143 | 144 | 145 | 146 | #endif /* _SDL_CONFIG_SYMBIAN_H */ 147 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_config_win32.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_win32_h 24 | #define _SDL_config_win32_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This is a set of defines to configure the SDL features */ 29 | 30 | #if defined(__GNUC__) || defined(__DMC__) 31 | #define HAVE_STDINT_H 1 32 | #elif defined(_MSC_VER) 33 | typedef signed __int8 int8_t; 34 | typedef unsigned __int8 uint8_t; 35 | typedef signed __int16 int16_t; 36 | typedef unsigned __int16 uint16_t; 37 | typedef signed __int32 int32_t; 38 | typedef unsigned __int32 uint32_t; 39 | typedef signed __int64 int64_t; 40 | typedef unsigned __int64 uint64_t; 41 | #ifndef _UINTPTR_T_DEFINED 42 | #ifdef _WIN64 43 | typedef unsigned __int64 uintptr_t; 44 | #else 45 | typedef unsigned int uintptr_t; 46 | #endif 47 | #define _UINTPTR_T_DEFINED 48 | #endif 49 | /* Older Visual C++ headers don't have the Win64-compatible typedefs... */ 50 | #if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) 51 | #define DWORD_PTR DWORD 52 | #endif 53 | #if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) 54 | #define LONG_PTR LONG 55 | #endif 56 | #else /* !__GNUC__ && !_MSC_VER */ 57 | typedef signed char int8_t; 58 | typedef unsigned char uint8_t; 59 | typedef signed short int16_t; 60 | typedef unsigned short uint16_t; 61 | typedef signed int int32_t; 62 | typedef unsigned int uint32_t; 63 | typedef signed long long int64_t; 64 | typedef unsigned long long uint64_t; 65 | #ifndef _SIZE_T_DEFINED_ 66 | #define _SIZE_T_DEFINED_ 67 | typedef unsigned int size_t; 68 | #endif 69 | typedef unsigned int uintptr_t; 70 | #endif /* __GNUC__ || _MSC_VER */ 71 | #define SDL_HAS_64BIT_TYPE 1 72 | 73 | /* Enabled for SDL 1.2 (binary compatibility) */ 74 | #define HAVE_LIBC 1 75 | #ifdef HAVE_LIBC 76 | /* Useful headers */ 77 | #define HAVE_STDIO_H 1 78 | #define STDC_HEADERS 1 79 | #define HAVE_STRING_H 1 80 | #define HAVE_CTYPE_H 1 81 | #define HAVE_MATH_H 1 82 | #ifndef _WIN32_WCE 83 | #define HAVE_SIGNAL_H 1 84 | #endif 85 | 86 | /* C library functions */ 87 | #define HAVE_MALLOC 1 88 | #define HAVE_CALLOC 1 89 | #define HAVE_REALLOC 1 90 | #define HAVE_FREE 1 91 | #define HAVE_ALLOCA 1 92 | #define HAVE_QSORT 1 93 | #define HAVE_ABS 1 94 | #define HAVE_MEMSET 1 95 | #define HAVE_MEMCPY 1 96 | #define HAVE_MEMMOVE 1 97 | #define HAVE_MEMCMP 1 98 | #define HAVE_STRLEN 1 99 | #define HAVE__STRREV 1 100 | #define HAVE__STRUPR 1 101 | #define HAVE__STRLWR 1 102 | #define HAVE_STRCHR 1 103 | #define HAVE_STRRCHR 1 104 | #define HAVE_STRSTR 1 105 | #define HAVE_ITOA 1 106 | #define HAVE__LTOA 1 107 | #define HAVE__ULTOA 1 108 | #define HAVE_STRTOL 1 109 | #define HAVE_STRTOUL 1 110 | #define HAVE_STRTOLL 1 111 | #define HAVE_STRTOD 1 112 | #define HAVE_ATOI 1 113 | #define HAVE_ATOF 1 114 | #define HAVE_STRCMP 1 115 | #define HAVE_STRNCMP 1 116 | #define HAVE__STRICMP 1 117 | #define HAVE__STRNICMP 1 118 | #define HAVE_SSCANF 1 119 | #else 120 | #define HAVE_STDARG_H 1 121 | #define HAVE_STDDEF_H 1 122 | #endif 123 | 124 | /* Enable various audio drivers */ 125 | #ifndef _WIN32_WCE 126 | #define SDL_AUDIO_DRIVER_DSOUND 1 127 | #endif 128 | #define SDL_AUDIO_DRIVER_WAVEOUT 1 129 | #define SDL_AUDIO_DRIVER_DISK 1 130 | #define SDL_AUDIO_DRIVER_DUMMY 1 131 | 132 | /* Enable various cdrom drivers */ 133 | #ifdef _WIN32_WCE 134 | #define SDL_CDROM_DISABLED 1 135 | #else 136 | #define SDL_CDROM_WIN32 1 137 | #endif 138 | 139 | /* Enable various input drivers */ 140 | #ifdef _WIN32_WCE 141 | #define SDL_JOYSTICK_DISABLED 1 142 | #else 143 | #define SDL_JOYSTICK_WINMM 1 144 | #endif 145 | 146 | /* Enable various shared object loading systems */ 147 | #define SDL_LOADSO_WIN32 1 148 | 149 | /* Enable various threading systems */ 150 | #define SDL_THREAD_WIN32 1 151 | 152 | /* Enable various timer systems */ 153 | #ifdef _WIN32_WCE 154 | #define SDL_TIMER_WINCE 1 155 | #else 156 | #define SDL_TIMER_WIN32 1 157 | #endif 158 | 159 | /* Enable various video drivers */ 160 | #ifdef _WIN32_WCE 161 | #define SDL_VIDEO_DRIVER_GAPI 1 162 | #endif 163 | #ifndef _WIN32_WCE 164 | #define SDL_VIDEO_DRIVER_DDRAW 1 165 | #endif 166 | #define SDL_VIDEO_DRIVER_DUMMY 1 167 | #define SDL_VIDEO_DRIVER_WINDIB 1 168 | 169 | /* Enable OpenGL support */ 170 | #ifndef _WIN32_WCE 171 | #define SDL_VIDEO_OPENGL 1 172 | #define SDL_VIDEO_OPENGL_WGL 1 173 | #endif 174 | 175 | /* Disable screensaver */ 176 | #define SDL_VIDEO_DISABLE_SCREENSAVER 1 177 | 178 | /* Enable assembly routines (Win64 doesn't have inline asm) */ 179 | #ifndef _WIN64 180 | #define SDL_ASSEMBLY_ROUTINES 1 181 | #endif 182 | 183 | #endif /* _SDL_config_win32_h */ 184 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_copying.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file SDL_cpuinfo.h 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 | #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 | /** This function returns true if the CPU has the RDTSC instruction */ 40 | extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); 41 | 42 | /** This function returns true if the CPU has MMX features */ 43 | extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); 44 | 45 | /** This function returns true if the CPU has MMX Ext. features */ 46 | extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void); 47 | 48 | /** This function returns true if the CPU has 3DNow features */ 49 | extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); 50 | 51 | /** This function returns true if the CPU has 3DNow! Ext. features */ 52 | extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void); 53 | 54 | /** This function returns true if the CPU has SSE features */ 55 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); 56 | 57 | /** This function returns true if the CPU has SSE2 features */ 58 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); 59 | 60 | /** This function returns true if the CPU has AltiVec features */ 61 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); 62 | 63 | /* Ends C function definitions when using C++ */ 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #include "close_code.h" 68 | 69 | #endif /* _SDL_cpuinfo_h */ 70 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_endian.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file SDL_endian.h 25 | * Functions for reading and writing endian-specific values 26 | */ 27 | 28 | #ifndef _SDL_endian_h 29 | #define _SDL_endian_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | /** @name SDL_ENDIANs 34 | * The two types of endianness 35 | */ 36 | /*@{*/ 37 | #define SDL_LIL_ENDIAN 1234 38 | #define SDL_BIG_ENDIAN 4321 39 | /*@}*/ 40 | 41 | #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ 42 | #ifdef __linux__ 43 | #include 44 | #define SDL_BYTEORDER __BYTE_ORDER 45 | #else /* __linux __ */ 46 | #if defined(__hppa__) || \ 47 | defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ 48 | (defined(__MIPS__) && defined(__MISPEB__)) || \ 49 | defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ 50 | defined(__sparc__) 51 | #define SDL_BYTEORDER SDL_BIG_ENDIAN 52 | #else 53 | #define SDL_BYTEORDER SDL_LIL_ENDIAN 54 | #endif 55 | #endif /* __linux __ */ 56 | #endif /* !SDL_BYTEORDER */ 57 | 58 | 59 | #include "begin_code.h" 60 | /* Set up for C function definitions, even when using C++ */ 61 | #ifdef __cplusplus 62 | extern "C" { 63 | #endif 64 | 65 | /** 66 | * @name SDL_Swap Functions 67 | * Use inline functions for compilers that support them, and static 68 | * functions for those that do not. Because these functions become 69 | * static for compilers that do not support inline functions, this 70 | * header should only be included in files that actually use them. 71 | */ 72 | /*@{*/ 73 | #if defined(__GNUC__) && defined(__i386__) && \ 74 | !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) 75 | static __inline__ Uint16 SDL_Swap16(Uint16 x) 76 | { 77 | __asm__("xchgb %b0,%h0" : "=q" (x) : "0" (x)); 78 | return x; 79 | } 80 | #elif defined(__GNUC__) && defined(__x86_64__) 81 | static __inline__ Uint16 SDL_Swap16(Uint16 x) 82 | { 83 | __asm__("xchgb %b0,%h0" : "=Q" (x) : "0" (x)); 84 | return x; 85 | } 86 | #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) 87 | static __inline__ Uint16 SDL_Swap16(Uint16 x) 88 | { 89 | int result; 90 | 91 | __asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "0" (x >> 8), "r" (x)); 92 | return (Uint16)result; 93 | } 94 | #elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) 95 | static __inline__ Uint16 SDL_Swap16(Uint16 x) 96 | { 97 | __asm__("rorw #8,%0" : "=d" (x) : "0" (x) : "cc"); 98 | return x; 99 | } 100 | #else 101 | static __inline__ Uint16 SDL_Swap16(Uint16 x) { 102 | return SDL_static_cast(Uint16, ((x<<8)|(x>>8))); 103 | } 104 | #endif 105 | 106 | #if defined(__GNUC__) && defined(__i386__) && \ 107 | !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) 108 | static __inline__ Uint32 SDL_Swap32(Uint32 x) 109 | { 110 | __asm__("bswap %0" : "=r" (x) : "0" (x)); 111 | return x; 112 | } 113 | #elif defined(__GNUC__) && defined(__x86_64__) 114 | static __inline__ Uint32 SDL_Swap32(Uint32 x) 115 | { 116 | __asm__("bswapl %0" : "=r" (x) : "0" (x)); 117 | return x; 118 | } 119 | #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) 120 | static __inline__ Uint32 SDL_Swap32(Uint32 x) 121 | { 122 | Uint32 result; 123 | 124 | __asm__("rlwimi %0,%2,24,16,23" : "=&r" (result) : "0" (x>>24), "r" (x)); 125 | __asm__("rlwimi %0,%2,8,8,15" : "=&r" (result) : "0" (result), "r" (x)); 126 | __asm__("rlwimi %0,%2,24,0,7" : "=&r" (result) : "0" (result), "r" (x)); 127 | return result; 128 | } 129 | #elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) 130 | static __inline__ Uint32 SDL_Swap32(Uint32 x) 131 | { 132 | __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0" : "=d" (x) : "0" (x) : "cc"); 133 | return x; 134 | } 135 | #else 136 | static __inline__ Uint32 SDL_Swap32(Uint32 x) { 137 | return SDL_static_cast(Uint32, ((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24))); 138 | } 139 | #endif 140 | 141 | #ifdef SDL_HAS_64BIT_TYPE 142 | #if defined(__GNUC__) && defined(__i386__) && \ 143 | !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) 144 | static __inline__ Uint64 SDL_Swap64(Uint64 x) 145 | { 146 | union { 147 | struct { Uint32 a,b; } s; 148 | Uint64 u; 149 | } v; 150 | v.u = x; 151 | __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1" 152 | : "=r" (v.s.a), "=r" (v.s.b) 153 | : "0" (v.s.a), "1" (v.s.b)); 154 | return v.u; 155 | } 156 | #elif defined(__GNUC__) && defined(__x86_64__) 157 | static __inline__ Uint64 SDL_Swap64(Uint64 x) 158 | { 159 | __asm__("bswapq %0" : "=r" (x) : "0" (x)); 160 | return x; 161 | } 162 | #else 163 | static __inline__ Uint64 SDL_Swap64(Uint64 x) 164 | { 165 | Uint32 hi, lo; 166 | 167 | /* Separate into high and low 32-bit values and swap them */ 168 | lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); 169 | x >>= 32; 170 | hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); 171 | x = SDL_Swap32(lo); 172 | x <<= 32; 173 | x |= SDL_Swap32(hi); 174 | return (x); 175 | } 176 | #endif 177 | #else 178 | /* This is mainly to keep compilers from complaining in SDL code. 179 | * If there is no real 64-bit datatype, then compilers will complain about 180 | * the fake 64-bit datatype that SDL provides when it compiles user code. 181 | */ 182 | #define SDL_Swap64(X) (X) 183 | #endif /* SDL_HAS_64BIT_TYPE */ 184 | /*@}*/ 185 | 186 | /** 187 | * @name SDL_SwapLE and SDL_SwapBE Functions 188 | * Byteswap item from the specified endianness to the native endianness 189 | */ 190 | /*@{*/ 191 | #if SDL_BYTEORDER == SDL_LIL_ENDIAN 192 | #define SDL_SwapLE16(X) (X) 193 | #define SDL_SwapLE32(X) (X) 194 | #define SDL_SwapLE64(X) (X) 195 | #define SDL_SwapBE16(X) SDL_Swap16(X) 196 | #define SDL_SwapBE32(X) SDL_Swap32(X) 197 | #define SDL_SwapBE64(X) SDL_Swap64(X) 198 | #else 199 | #define SDL_SwapLE16(X) SDL_Swap16(X) 200 | #define SDL_SwapLE32(X) SDL_Swap32(X) 201 | #define SDL_SwapLE64(X) SDL_Swap64(X) 202 | #define SDL_SwapBE16(X) (X) 203 | #define SDL_SwapBE32(X) (X) 204 | #define SDL_SwapBE64(X) (X) 205 | #endif 206 | /*@}*/ 207 | 208 | /* Ends C function definitions when using C++ */ 209 | #ifdef __cplusplus 210 | } 211 | #endif 212 | #include "close_code.h" 213 | 214 | #endif /* _SDL_endian_h */ 215 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file SDL_error.h 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 | /** 40 | * @name Public functions 41 | */ 42 | /*@{*/ 43 | extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...); 44 | extern DECLSPEC char * SDLCALL SDL_GetError(void); 45 | extern DECLSPEC void SDLCALL SDL_ClearError(void); 46 | /*@}*/ 47 | 48 | /** 49 | * @name Private functions 50 | * @internal Private error message function - used internally 51 | */ 52 | /*@{*/ 53 | #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) 54 | #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) 55 | typedef enum { 56 | SDL_ENOMEM, 57 | SDL_EFREAD, 58 | SDL_EFWRITE, 59 | SDL_EFSEEK, 60 | SDL_UNSUPPORTED, 61 | SDL_LASTERROR 62 | } SDL_errorcode; 63 | extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code); 64 | /*@}*/ 65 | 66 | /* Ends C function definitions when using C++ */ 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | #include "close_code.h" 71 | 72 | #endif /* _SDL_error_h */ 73 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_getenv.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_getenv.h 24 | * @deprecated Use SDL_stdinc.h instead 25 | */ 26 | 27 | /* DEPRECATED */ 28 | #include "SDL_stdinc.h" 29 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_joystick.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_joystick.h 24 | * Include file for SDL joystick event handling 25 | */ 26 | 27 | #ifndef _SDL_joystick_h 28 | #define _SDL_joystick_h 29 | 30 | #include "SDL_stdinc.h" 31 | #include "SDL_error.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 | /** @file SDL_joystick.h 40 | * @note In order to use these functions, SDL_Init() must have been called 41 | * with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system 42 | * for joysticks, and load appropriate drivers. 43 | */ 44 | 45 | /** The joystick structure used to identify an SDL joystick */ 46 | struct _SDL_Joystick; 47 | typedef struct _SDL_Joystick SDL_Joystick; 48 | 49 | /* Function prototypes */ 50 | /** 51 | * Count the number of joysticks attached to the system 52 | */ 53 | extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); 54 | 55 | /** 56 | * Get the implementation dependent name of a joystick. 57 | * 58 | * This can be called before any joysticks are opened. 59 | * If no name can be found, this function returns NULL. 60 | */ 61 | extern DECLSPEC const char * SDLCALL SDL_JoystickName(int device_index); 62 | 63 | /** 64 | * Open a joystick for use. 65 | * 66 | * @param[in] device_index 67 | * The index passed as an argument refers to 68 | * the N'th joystick on the system. This index is the value which will 69 | * identify this joystick in future joystick events. 70 | * 71 | * @return This function returns a joystick identifier, or NULL if an error occurred. 72 | */ 73 | extern DECLSPEC SDL_Joystick * SDLCALL SDL_JoystickOpen(int device_index); 74 | 75 | /** 76 | * Returns 1 if the joystick has been opened, or 0 if it has not. 77 | */ 78 | extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index); 79 | 80 | /** 81 | * Get the device index of an opened joystick. 82 | */ 83 | extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick *joystick); 84 | 85 | /** 86 | * Get the number of general axis controls on a joystick 87 | */ 88 | extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick); 89 | 90 | /** 91 | * Get the number of trackballs on a joystick 92 | * 93 | * Joystick trackballs have only relative motion events associated 94 | * with them and their state cannot be polled. 95 | */ 96 | extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick); 97 | 98 | /** 99 | * Get the number of POV hats on a joystick 100 | */ 101 | extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick); 102 | 103 | /** 104 | * Get the number of buttons on a joystick 105 | */ 106 | extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick); 107 | 108 | /** 109 | * Update the current state of the open joysticks. 110 | * 111 | * This is called automatically by the event loop if any joystick 112 | * events are enabled. 113 | */ 114 | extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); 115 | 116 | /** 117 | * Enable/disable joystick event polling. 118 | * 119 | * If joystick events are disabled, you must call SDL_JoystickUpdate() 120 | * yourself and check the state of the joystick when you want joystick 121 | * information. 122 | * 123 | * @param[in] state The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. 124 | */ 125 | extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); 126 | 127 | /** 128 | * Get the current state of an axis control on a joystick 129 | * 130 | * @param[in] axis The axis indices start at index 0. 131 | * 132 | * @return The state is a value ranging from -32768 to 32767. 133 | */ 134 | extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis); 135 | 136 | /** 137 | * @name Hat Positions 138 | * The return value of SDL_JoystickGetHat() is one of the following positions: 139 | */ 140 | /*@{*/ 141 | #define SDL_HAT_CENTERED 0x00 142 | #define SDL_HAT_UP 0x01 143 | #define SDL_HAT_RIGHT 0x02 144 | #define SDL_HAT_DOWN 0x04 145 | #define SDL_HAT_LEFT 0x08 146 | #define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) 147 | #define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) 148 | #define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) 149 | #define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) 150 | /*@}*/ 151 | 152 | /** 153 | * Get the current state of a POV hat on a joystick 154 | * 155 | * @param[in] hat The hat indices start at index 0. 156 | */ 157 | extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat); 158 | 159 | /** 160 | * Get the ball axis change since the last poll 161 | * 162 | * @param[in] ball The ball indices start at index 0. 163 | * 164 | * @return This returns 0, or -1 if you passed it invalid parameters. 165 | */ 166 | extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy); 167 | 168 | /** 169 | * Get the current state of a button on a joystick 170 | * 171 | * @param[in] button The button indices start at index 0. 172 | */ 173 | extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button); 174 | 175 | /** 176 | * Close a joystick previously opened with SDL_JoystickOpen() 177 | */ 178 | extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick); 179 | 180 | 181 | /* Ends C function definitions when using C++ */ 182 | #ifdef __cplusplus 183 | } 184 | #endif 185 | #include "close_code.h" 186 | 187 | #endif /* _SDL_joystick_h */ 188 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_keyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_keyboard.h 24 | * Include file for SDL keyboard event handling 25 | */ 26 | 27 | #ifndef _SDL_keyboard_h 28 | #define _SDL_keyboard_h 29 | 30 | #include "SDL_stdinc.h" 31 | #include "SDL_error.h" 32 | #include "SDL_keysym.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 | /** Keysym structure 41 | * 42 | * - The scancode is hardware dependent, and should not be used by general 43 | * applications. If no hardware scancode is available, it will be 0. 44 | * 45 | * - The 'unicode' translated character is only available when character 46 | * translation is enabled by the SDL_EnableUNICODE() API. If non-zero, 47 | * this is a UNICODE character corresponding to the keypress. If the 48 | * high 9 bits of the character are 0, then this maps to the equivalent 49 | * ASCII character: 50 | * @code 51 | * char ch; 52 | * if ( (keysym.unicode & 0xFF80) == 0 ) { 53 | * ch = keysym.unicode & 0x7F; 54 | * } else { 55 | * An international character.. 56 | * } 57 | * @endcode 58 | */ 59 | typedef struct SDL_keysym { 60 | Uint8 scancode; /**< hardware specific scancode */ 61 | SDLKey sym; /**< SDL virtual keysym */ 62 | SDLMod mod; /**< current key modifiers */ 63 | Uint16 unicode; /**< translated character */ 64 | } SDL_keysym; 65 | 66 | /** This is the mask which refers to all hotkey bindings */ 67 | #define SDL_ALL_HOTKEYS 0xFFFFFFFF 68 | 69 | /* Function prototypes */ 70 | /** 71 | * Enable/Disable UNICODE translation of keyboard input. 72 | * 73 | * This translation has some overhead, so translation defaults off. 74 | * 75 | * @param[in] enable 76 | * If 'enable' is 1, translation is enabled. 77 | * If 'enable' is 0, translation is disabled. 78 | * If 'enable' is -1, the translation state is not changed. 79 | * 80 | * @return It returns the previous state of keyboard translation. 81 | */ 82 | extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); 83 | 84 | #define SDL_DEFAULT_REPEAT_DELAY 500 85 | #define SDL_DEFAULT_REPEAT_INTERVAL 30 86 | /** 87 | * Enable/Disable keyboard repeat. Keyboard repeat defaults to off. 88 | * 89 | * @param[in] delay 90 | * 'delay' is the initial delay in ms between the time when a key is 91 | * pressed, and keyboard repeat begins. 92 | * 93 | * @param[in] interval 94 | * 'interval' is the time in ms between keyboard repeat events. 95 | * 96 | * If 'delay' is set to 0, keyboard repeat is disabled. 97 | */ 98 | extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); 99 | extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); 100 | 101 | /** 102 | * Get a snapshot of the current state of the keyboard. 103 | * Returns an array of keystates, indexed by the SDLK_* syms. 104 | * Usage: 105 | * @code 106 | * Uint8 *keystate = SDL_GetKeyState(NULL); 107 | * if ( keystate[SDLK_RETURN] ) //... \ is pressed. 108 | * @endcode 109 | */ 110 | extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys); 111 | 112 | /** 113 | * Get the current key modifier state 114 | */ 115 | extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); 116 | 117 | /** 118 | * Set the current key modifier state. 119 | * This does not change the keyboard state, only the key modifier flags. 120 | */ 121 | extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); 122 | 123 | /** 124 | * Get the name of an SDL virtual keysym 125 | */ 126 | extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key); 127 | 128 | 129 | /* Ends C function definitions when using C++ */ 130 | #ifdef __cplusplus 131 | } 132 | #endif 133 | #include "close_code.h" 134 | 135 | #endif /* _SDL_keyboard_h */ 136 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_loadso.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_loadso.h 24 | * System dependent library loading routines 25 | */ 26 | 27 | /** @file SDL_loadso.h 28 | * Some things to keep in mind: 29 | * - These functions only work on C function names. Other languages may 30 | * have name mangling and intrinsic language support that varies from 31 | * compiler to compiler. 32 | * - Make sure you declare your function pointers with the same calling 33 | * convention as the actual library function. Your code will crash 34 | * mysteriously if you do not do this. 35 | * - Avoid namespace collisions. If you load a symbol from the library, 36 | * it is not defined whether or not it goes into the global symbol 37 | * namespace for the application. If it does and it conflicts with 38 | * symbols in your code or other shared libraries, you will not get 39 | * the results you expect. :) 40 | */ 41 | 42 | 43 | #ifndef _SDL_loadso_h 44 | #define _SDL_loadso_h 45 | 46 | #include "SDL_stdinc.h" 47 | #include "SDL_error.h" 48 | 49 | #include "begin_code.h" 50 | /* Set up for C function definitions, even when using C++ */ 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | /** 56 | * This function dynamically loads a shared object and returns a pointer 57 | * to the object handle (or NULL if there was an error). 58 | * The 'sofile' parameter is a system dependent name of the object file. 59 | */ 60 | extern DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile); 61 | 62 | /** 63 | * Given an object handle, this function looks up the address of the 64 | * named function in the shared object and returns it. This address 65 | * is no longer valid after calling SDL_UnloadObject(). 66 | */ 67 | extern DECLSPEC void * SDLCALL SDL_LoadFunction(void *handle, const char *name); 68 | 69 | /** Unload a shared object from memory */ 70 | extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); 71 | 72 | /* Ends C function definitions when using C++ */ 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | #include "close_code.h" 77 | 78 | #endif /* _SDL_loadso_h */ 79 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_main.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_main_h 24 | #define _SDL_main_h 25 | 26 | #include "SDL_stdinc.h" 27 | 28 | /** @file SDL_main.h 29 | * Redefine main() on Win32 and MacOS so that it is called by winmain.c 30 | */ 31 | 32 | #if defined(__WIN32__) || \ 33 | (defined(__MWERKS__) && !defined(__BEOS__)) || \ 34 | defined(__MACOS__) || defined(__MACOSX__) || \ 35 | defined(__SYMBIAN32__) || defined(QWS) 36 | 37 | #ifdef __cplusplus 38 | #define C_LINKAGE "C" 39 | #else 40 | #define C_LINKAGE 41 | #endif /* __cplusplus */ 42 | 43 | /** The application's main() function must be called with C linkage, 44 | * and should be declared like this: 45 | * @code 46 | * #ifdef __cplusplus 47 | * extern "C" 48 | * #endif 49 | * int main(int argc, char *argv[]) 50 | * { 51 | * } 52 | * @endcode 53 | */ 54 | #define main SDL_main 55 | 56 | /** The prototype for the application's main() function */ 57 | extern C_LINKAGE int SDL_main(int argc, char *argv[]); 58 | 59 | 60 | /** @name From the SDL library code -- needed for registering the app on Win32 */ 61 | /*@{*/ 62 | #ifdef __WIN32__ 63 | 64 | #include "begin_code.h" 65 | #ifdef __cplusplus 66 | extern "C" { 67 | #endif 68 | 69 | /** This should be called from your WinMain() function, if any */ 70 | extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst); 71 | /** This can also be called, but is no longer necessary */ 72 | extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); 73 | /** This can also be called, but is no longer necessary (SDL_Quit calls it) */ 74 | extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | #include "close_code.h" 79 | #endif 80 | /*@}*/ 81 | 82 | /** @name From the SDL library code -- needed for registering QuickDraw on MacOS */ 83 | /*@{*/ 84 | #if defined(__MACOS__) 85 | 86 | #include "begin_code.h" 87 | #ifdef __cplusplus 88 | extern "C" { 89 | #endif 90 | 91 | /** Forward declaration so we don't need to include QuickDraw.h */ 92 | struct QDGlobals; 93 | 94 | /** This should be called from your main() function, if any */ 95 | extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | #include "close_code.h" 101 | #endif 102 | /*@}*/ 103 | 104 | #endif /* Need to redefine main()? */ 105 | 106 | #endif /* _SDL_main_h */ 107 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_mouse.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_mouse.h 24 | * Include file for SDL mouse event handling 25 | */ 26 | 27 | #ifndef _SDL_mouse_h 28 | #define _SDL_mouse_h 29 | 30 | #include "SDL_stdinc.h" 31 | #include "SDL_error.h" 32 | #include "SDL_video.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 | typedef struct WMcursor WMcursor; /**< Implementation dependent */ 41 | typedef struct SDL_Cursor { 42 | SDL_Rect area; /**< The area of the mouse cursor */ 43 | Sint16 hot_x, hot_y; /**< The "tip" of the cursor */ 44 | Uint8 *data; /**< B/W cursor data */ 45 | Uint8 *mask; /**< B/W cursor mask */ 46 | Uint8 *save[2]; /**< Place to save cursor area */ 47 | WMcursor *wm_cursor; /**< Window-manager cursor */ 48 | } SDL_Cursor; 49 | 50 | /* Function prototypes */ 51 | /** 52 | * Retrieve the current state of the mouse. 53 | * The current button state is returned as a button bitmask, which can 54 | * be tested using the SDL_BUTTON(X) macros, and x and y are set to the 55 | * current mouse cursor position. You can pass NULL for either x or y. 56 | */ 57 | extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y); 58 | 59 | /** 60 | * Retrieve the current state of the mouse. 61 | * The current button state is returned as a button bitmask, which can 62 | * be tested using the SDL_BUTTON(X) macros, and x and y are set to the 63 | * mouse deltas since the last call to SDL_GetRelativeMouseState(). 64 | */ 65 | extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); 66 | 67 | /** 68 | * Set the position of the mouse cursor (generates a mouse motion event) 69 | */ 70 | extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y); 71 | 72 | /** 73 | * Create a cursor using the specified data and mask (in MSB format). 74 | * The cursor width must be a multiple of 8 bits. 75 | * 76 | * The cursor is created in black and white according to the following: 77 | * data mask resulting pixel on screen 78 | * 0 1 White 79 | * 1 1 Black 80 | * 0 0 Transparent 81 | * 1 0 Inverted color if possible, black if not. 82 | * 83 | * Cursors created with this function must be freed with SDL_FreeCursor(). 84 | */ 85 | extern DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor 86 | (Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); 87 | 88 | /** 89 | * Set the currently active cursor to the specified one. 90 | * If the cursor is currently visible, the change will be immediately 91 | * represented on the display. 92 | */ 93 | extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor *cursor); 94 | 95 | /** 96 | * Returns the currently active cursor. 97 | */ 98 | extern DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void); 99 | 100 | /** 101 | * Deallocates a cursor created with SDL_CreateCursor(). 102 | */ 103 | extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor *cursor); 104 | 105 | /** 106 | * Toggle whether or not the cursor is shown on the screen. 107 | * The cursor start off displayed, but can be turned off. 108 | * SDL_ShowCursor() returns 1 if the cursor was being displayed 109 | * before the call, or 0 if it was not. You can query the current 110 | * state by passing a 'toggle' value of -1. 111 | */ 112 | extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); 113 | 114 | /*@{*/ 115 | /** Used as a mask when testing buttons in buttonstate 116 | * Button 1: Left mouse button 117 | * Button 2: Middle mouse button 118 | * Button 3: Right mouse button 119 | * Button 4: Mouse wheel up (may also be a real button) 120 | * Button 5: Mouse wheel down (may also be a real button) 121 | */ 122 | #define SDL_BUTTON(X) (1 << ((X)-1)) 123 | #define SDL_BUTTON_LEFT 1 124 | #define SDL_BUTTON_MIDDLE 2 125 | #define SDL_BUTTON_RIGHT 3 126 | #define SDL_BUTTON_WHEELUP 4 127 | #define SDL_BUTTON_WHEELDOWN 5 128 | #define SDL_BUTTON_X1 6 129 | #define SDL_BUTTON_X2 7 130 | #define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) 131 | #define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) 132 | #define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) 133 | #define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) 134 | #define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) 135 | /*@}*/ 136 | 137 | /* Ends C function definitions when using C++ */ 138 | #ifdef __cplusplus 139 | } 140 | #endif 141 | #include "close_code.h" 142 | 143 | #endif /* _SDL_mouse_h */ 144 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_mutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_mutex_h 24 | #define _SDL_mutex_h 25 | 26 | /** @file SDL_mutex.h 27 | * Functions to provide thread synchronization primitives 28 | * 29 | * @note These are independent of the other SDL routines. 30 | */ 31 | 32 | #include "SDL_stdinc.h" 33 | #include "SDL_error.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 | /** Synchronization functions which can time out return this value 42 | * if they time out. 43 | */ 44 | #define SDL_MUTEX_TIMEDOUT 1 45 | 46 | /** This is the timeout value which corresponds to never time out */ 47 | #define SDL_MUTEX_MAXWAIT (~(Uint32)0) 48 | 49 | 50 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 51 | /** @name Mutex functions */ /*@{*/ 52 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 53 | 54 | /** The SDL mutex structure, defined in SDL_mutex.c */ 55 | struct SDL_mutex; 56 | typedef struct SDL_mutex SDL_mutex; 57 | 58 | /** Create a mutex, initialized unlocked */ 59 | extern DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void); 60 | 61 | #define SDL_LockMutex(m) SDL_mutexP(m) 62 | /** Lock the mutex 63 | * @return 0, or -1 on error 64 | */ 65 | extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex *mutex); 66 | 67 | #define SDL_UnlockMutex(m) SDL_mutexV(m) 68 | /** Unlock the mutex 69 | * @return 0, or -1 on error 70 | * 71 | * It is an error to unlock a mutex that has not been locked by 72 | * the current thread, and doing so results in undefined behavior. 73 | */ 74 | extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex *mutex); 75 | 76 | /** Destroy a mutex */ 77 | extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex); 78 | 79 | /*@}*/ 80 | 81 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 82 | /** @name Semaphore functions */ /*@{*/ 83 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 84 | 85 | /** The SDL semaphore structure, defined in SDL_sem.c */ 86 | struct SDL_semaphore; 87 | typedef struct SDL_semaphore SDL_sem; 88 | 89 | /** Create a semaphore, initialized with value, returns NULL on failure. */ 90 | extern DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value); 91 | 92 | /** Destroy a semaphore */ 93 | extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem); 94 | 95 | /** 96 | * This function suspends the calling thread until the semaphore pointed 97 | * to by sem has a positive count. It then atomically decreases the semaphore 98 | * count. 99 | */ 100 | extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem); 101 | 102 | /** Non-blocking variant of SDL_SemWait(). 103 | * @return 0 if the wait succeeds, 104 | * SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. 105 | */ 106 | extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem); 107 | 108 | /** Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if 109 | * the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in 110 | * the allotted time, and -1 on error. 111 | * 112 | * On some platforms this function is implemented by looping with a delay 113 | * of 1 ms, and so should be avoided if possible. 114 | */ 115 | extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms); 116 | 117 | /** Atomically increases the semaphore's count (not blocking). 118 | * @return 0, or -1 on error. 119 | */ 120 | extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem); 121 | 122 | /** Returns the current count of the semaphore */ 123 | extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem); 124 | 125 | /*@}*/ 126 | 127 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 128 | /** @name Condition_variable_functions */ /*@{*/ 129 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 130 | 131 | /*@{*/ 132 | /** The SDL condition variable structure, defined in SDL_cond.c */ 133 | struct SDL_cond; 134 | typedef struct SDL_cond SDL_cond; 135 | /*@}*/ 136 | 137 | /** Create a condition variable */ 138 | extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void); 139 | 140 | /** Destroy a condition variable */ 141 | extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond); 142 | 143 | /** Restart one of the threads that are waiting on the condition variable, 144 | * @return 0 or -1 on error. 145 | */ 146 | extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond); 147 | 148 | /** Restart all threads that are waiting on the condition variable, 149 | * @return 0 or -1 on error. 150 | */ 151 | extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond); 152 | 153 | /** Wait on the condition variable, unlocking the provided mutex. 154 | * The mutex must be locked before entering this function! 155 | * The mutex is re-locked once the condition variable is signaled. 156 | * @return 0 when it is signaled, or -1 on error. 157 | */ 158 | extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut); 159 | 160 | /** Waits for at most 'ms' milliseconds, and returns 0 if the condition 161 | * variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not 162 | * signaled in the allotted time, and -1 on error. 163 | * On some platforms this function is implemented by looping with a delay 164 | * of 1 ms, and so should be avoided if possible. 165 | */ 166 | extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms); 167 | 168 | /*@}*/ 169 | 170 | /* Ends C function definitions when using C++ */ 171 | #ifdef __cplusplus 172 | } 173 | #endif 174 | #include "close_code.h" 175 | 176 | #endif /* _SDL_mutex_h */ 177 | 178 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_name.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SDLname_h_ 3 | #define _SDLname_h_ 4 | 5 | #if defined(__STDC__) || defined(__cplusplus) 6 | #define NeedFunctionPrototypes 1 7 | #endif 8 | 9 | #define SDL_NAME(X) SDL_##X 10 | 11 | #endif /* _SDLname_h_ */ 12 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_platform.h 24 | * Try to get a standard set of platform defines 25 | */ 26 | 27 | #ifndef _SDL_platform_h 28 | #define _SDL_platform_h 29 | 30 | #if defined(_AIX) 31 | #undef __AIX__ 32 | #define __AIX__ 1 33 | #endif 34 | #if defined(__BEOS__) 35 | #undef __BEOS__ 36 | #define __BEOS__ 1 37 | #endif 38 | #if defined(__HAIKU__) 39 | #undef __HAIKU__ 40 | #define __HAIKU__ 1 41 | #endif 42 | #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) 43 | #undef __BSDI__ 44 | #define __BSDI__ 1 45 | #endif 46 | #if defined(_arch_dreamcast) 47 | #undef __DREAMCAST__ 48 | #define __DREAMCAST__ 1 49 | #endif 50 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) 51 | #undef __FREEBSD__ 52 | #define __FREEBSD__ 1 53 | #endif 54 | #if defined(__HAIKU__) 55 | #undef __HAIKU__ 56 | #define __HAIKU__ 1 57 | #endif 58 | #if defined(hpux) || defined(__hpux) || defined(__hpux__) 59 | #undef __HPUX__ 60 | #define __HPUX__ 1 61 | #endif 62 | #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) 63 | #undef __IRIX__ 64 | #define __IRIX__ 1 65 | #endif 66 | #if defined(linux) || defined(__linux) || defined(__linux__) 67 | #undef __LINUX__ 68 | #define __LINUX__ 1 69 | #endif 70 | #if defined(__APPLE__) 71 | #undef __MACOSX__ 72 | #define __MACOSX__ 1 73 | #elif defined(macintosh) 74 | #undef __MACOS__ 75 | #define __MACOS__ 1 76 | #endif 77 | #if defined(__NetBSD__) 78 | #undef __NETBSD__ 79 | #define __NETBSD__ 1 80 | #endif 81 | #if defined(__OpenBSD__) 82 | #undef __OPENBSD__ 83 | #define __OPENBSD__ 1 84 | #endif 85 | #if defined(__OS2__) 86 | #undef __OS2__ 87 | #define __OS2__ 1 88 | #endif 89 | #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) 90 | #undef __OSF__ 91 | #define __OSF__ 1 92 | #endif 93 | #if defined(__QNXNTO__) 94 | #undef __QNXNTO__ 95 | #define __QNXNTO__ 1 96 | #endif 97 | #if defined(riscos) || defined(__riscos) || defined(__riscos__) 98 | #undef __RISCOS__ 99 | #define __RISCOS__ 1 100 | #endif 101 | #if defined(__SVR4) 102 | #undef __SOLARIS__ 103 | #define __SOLARIS__ 1 104 | #endif 105 | #if defined(WIN32) || defined(_WIN32) 106 | #undef __WIN32__ 107 | #define __WIN32__ 1 108 | #endif 109 | 110 | #endif /* _SDL_platform_h */ 111 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_quit.h 24 | * Include file for SDL quit event handling 25 | */ 26 | 27 | #ifndef _SDL_quit_h 28 | #define _SDL_quit_h 29 | 30 | #include "SDL_stdinc.h" 31 | #include "SDL_error.h" 32 | 33 | /** @file SDL_quit.h 34 | * An SDL_QUITEVENT is generated when the user tries to close the application 35 | * window. If it is ignored or filtered out, the window will remain open. 36 | * If it is not ignored or filtered, it is queued normally and the window 37 | * is allowed to close. When the window is closed, screen updates will 38 | * complete, but have no effect. 39 | * 40 | * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) 41 | * and SIGTERM (system termination request), if handlers do not already 42 | * exist, that generate SDL_QUITEVENT events as well. There is no way 43 | * to determine the cause of an SDL_QUITEVENT, but setting a signal 44 | * handler in your application will override the default generation of 45 | * quit events for that signal. 46 | */ 47 | 48 | /** @file SDL_quit.h 49 | * There are no functions directly affecting the quit event 50 | */ 51 | 52 | #define SDL_QuitRequested() \ 53 | (SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK)) 54 | 55 | #endif /* _SDL_quit_h */ 56 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_rwops.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_rwops.h 24 | * This file provides a general interface for SDL to read and write 25 | * data sources. It can easily be extended to files, memory, etc. 26 | */ 27 | 28 | #ifndef _SDL_rwops_h 29 | #define _SDL_rwops_h 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 | /** This is the read/write operation structure -- very basic */ 41 | 42 | typedef struct SDL_RWops { 43 | /** Seek to 'offset' relative to whence, one of stdio's whence values: 44 | * SEEK_SET, SEEK_CUR, SEEK_END 45 | * Returns the final offset in the data source. 46 | */ 47 | int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence); 48 | 49 | /** Read up to 'maxnum' objects each of size 'size' from the data 50 | * source to the area pointed at by 'ptr'. 51 | * Returns the number of objects read, or -1 if the read failed. 52 | */ 53 | int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum); 54 | 55 | /** Write exactly 'num' objects each of size 'objsize' from the area 56 | * pointed at by 'ptr' to data source. 57 | * Returns 'num', or -1 if the write failed. 58 | */ 59 | int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num); 60 | 61 | /** Close and free an allocated SDL_FSops structure */ 62 | int (SDLCALL *close)(struct SDL_RWops *context); 63 | 64 | Uint32 type; 65 | union { 66 | #if defined(__WIN32__) && !defined(__SYMBIAN32__) 67 | struct { 68 | int append; 69 | void *h; 70 | struct { 71 | void *data; 72 | int size; 73 | int left; 74 | } buffer; 75 | } win32io; 76 | #endif 77 | #ifdef HAVE_STDIO_H 78 | struct { 79 | int autoclose; 80 | FILE *fp; 81 | } stdio; 82 | #endif 83 | struct { 84 | Uint8 *base; 85 | Uint8 *here; 86 | Uint8 *stop; 87 | } mem; 88 | struct { 89 | void *data1; 90 | } unknown; 91 | } hidden; 92 | 93 | } SDL_RWops; 94 | 95 | 96 | /** @name Functions to create SDL_RWops structures from various data sources */ 97 | /*@{*/ 98 | 99 | extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode); 100 | 101 | #ifdef HAVE_STDIO_H 102 | extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose); 103 | #endif 104 | 105 | extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size); 106 | extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size); 107 | 108 | extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void); 109 | extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area); 110 | 111 | /*@}*/ 112 | 113 | /** @name Seek Reference Points */ 114 | /*@{*/ 115 | #define RW_SEEK_SET 0 /**< Seek from the beginning of data */ 116 | #define RW_SEEK_CUR 1 /**< Seek relative to current read point */ 117 | #define RW_SEEK_END 2 /**< Seek relative to the end of data */ 118 | /*@}*/ 119 | 120 | /** @name Macros to easily read and write from an SDL_RWops structure */ 121 | /*@{*/ 122 | #define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) 123 | #define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) 124 | #define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) 125 | #define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) 126 | #define SDL_RWclose(ctx) (ctx)->close(ctx) 127 | /*@}*/ 128 | 129 | /** @name Read an item of the specified endianness and return in native format */ 130 | /*@{*/ 131 | extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src); 132 | extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src); 133 | extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src); 134 | extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src); 135 | extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src); 136 | extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src); 137 | /*@}*/ 138 | 139 | /** @name Write an item of native format to the specified endianness */ 140 | /*@{*/ 141 | extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value); 142 | extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value); 143 | extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value); 144 | extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value); 145 | extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value); 146 | extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value); 147 | /*@}*/ 148 | 149 | /* Ends C function definitions when using C++ */ 150 | #ifdef __cplusplus 151 | } 152 | #endif 153 | #include "close_code.h" 154 | 155 | #endif /* _SDL_rwops_h */ 156 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_syswm.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_syswm.h 24 | * Include file for SDL custom system window manager hooks 25 | */ 26 | 27 | #ifndef _SDL_syswm_h 28 | #define _SDL_syswm_h 29 | 30 | #include "SDL_stdinc.h" 31 | #include "SDL_error.h" 32 | #include "SDL_version.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 | /** @file SDL_syswm.h 41 | * Your application has access to a special type of event 'SDL_SYSWMEVENT', 42 | * which contains window-manager specific information and arrives whenever 43 | * an unhandled window event occurs. This event is ignored by default, but 44 | * you can enable it with SDL_EventState() 45 | */ 46 | #ifdef SDL_PROTOTYPES_ONLY 47 | struct SDL_SysWMinfo; 48 | typedef struct SDL_SysWMinfo SDL_SysWMinfo; 49 | #else 50 | 51 | /* This is the structure for custom window manager events */ 52 | #if defined(SDL_VIDEO_DRIVER_X11) 53 | #if defined(__APPLE__) && defined(__MACH__) 54 | /* conflicts with Quickdraw.h */ 55 | #define Cursor X11Cursor 56 | #endif 57 | 58 | #include 59 | #include 60 | 61 | #if defined(__APPLE__) && defined(__MACH__) 62 | /* matches the re-define above */ 63 | #undef Cursor 64 | #endif 65 | 66 | /** These are the various supported subsystems under UNIX */ 67 | typedef enum { 68 | SDL_SYSWM_X11 69 | } SDL_SYSWM_TYPE; 70 | 71 | /** The UNIX custom event structure */ 72 | struct SDL_SysWMmsg { 73 | SDL_version version; 74 | SDL_SYSWM_TYPE subsystem; 75 | union { 76 | XEvent xevent; 77 | } event; 78 | }; 79 | 80 | /** The UNIX custom window manager information structure. 81 | * When this structure is returned, it holds information about which 82 | * low level system it is using, and will be one of SDL_SYSWM_TYPE. 83 | */ 84 | typedef struct SDL_SysWMinfo { 85 | SDL_version version; 86 | SDL_SYSWM_TYPE subsystem; 87 | union { 88 | struct { 89 | Display *display; /**< The X11 display */ 90 | Window window; /**< The X11 display window */ 91 | /** These locking functions should be called around 92 | * any X11 functions using the display variable, 93 | * but not the gfxdisplay variable. 94 | * They lock the event thread, so should not be 95 | * called around event functions or from event filters. 96 | */ 97 | /*@{*/ 98 | void (*lock_func)(void); 99 | void (*unlock_func)(void); 100 | /*@}*/ 101 | 102 | /** @name Introduced in SDL 1.0.2 */ 103 | /*@{*/ 104 | Window fswindow; /**< The X11 fullscreen window */ 105 | Window wmwindow; /**< The X11 managed input window */ 106 | /*@}*/ 107 | 108 | /** @name Introduced in SDL 1.2.12 */ 109 | /*@{*/ 110 | Display *gfxdisplay; /**< The X11 display to which rendering is done */ 111 | /*@}*/ 112 | } x11; 113 | } info; 114 | } SDL_SysWMinfo; 115 | 116 | #elif defined(SDL_VIDEO_DRIVER_NANOX) 117 | #include 118 | 119 | /** The generic custom event structure */ 120 | struct SDL_SysWMmsg { 121 | SDL_version version; 122 | int data; 123 | }; 124 | 125 | /** The windows custom window manager information structure */ 126 | typedef struct SDL_SysWMinfo { 127 | SDL_version version ; 128 | GR_WINDOW_ID window ; /* The display window */ 129 | } SDL_SysWMinfo; 130 | 131 | #elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI) 132 | #define WIN32_LEAN_AND_MEAN 133 | #include 134 | 135 | /** The windows custom event structure */ 136 | struct SDL_SysWMmsg { 137 | SDL_version version; 138 | HWND hwnd; /**< The window for the message */ 139 | UINT msg; /**< The type of message */ 140 | WPARAM wParam; /**< WORD message parameter */ 141 | LPARAM lParam; /**< LONG message parameter */ 142 | }; 143 | 144 | /** The windows custom window manager information structure */ 145 | typedef struct SDL_SysWMinfo { 146 | SDL_version version; 147 | HWND window; /**< The Win32 display window */ 148 | HGLRC hglrc; /**< The OpenGL context, if any */ 149 | } SDL_SysWMinfo; 150 | 151 | #elif defined(SDL_VIDEO_DRIVER_RISCOS) 152 | 153 | /** RISC OS custom event structure */ 154 | struct SDL_SysWMmsg { 155 | SDL_version version; 156 | int eventCode; /**< The window for the message */ 157 | int pollBlock[64]; 158 | }; 159 | 160 | /** The RISC OS custom window manager information structure */ 161 | typedef struct SDL_SysWMinfo { 162 | SDL_version version; 163 | int wimpVersion; /**< Wimp version running under */ 164 | int taskHandle; /**< The RISC OS task handle */ 165 | int window; /**< The RISC OS display window */ 166 | } SDL_SysWMinfo; 167 | 168 | #elif defined(SDL_VIDEO_DRIVER_PHOTON) 169 | #include 170 | #include 171 | 172 | /** The QNX custom event structure */ 173 | struct SDL_SysWMmsg { 174 | SDL_version version; 175 | int data; 176 | }; 177 | 178 | /** The QNX custom window manager information structure */ 179 | typedef struct SDL_SysWMinfo { 180 | SDL_version version; 181 | int data; 182 | } SDL_SysWMinfo; 183 | 184 | #else 185 | 186 | /** The generic custom event structure */ 187 | struct SDL_SysWMmsg { 188 | SDL_version version; 189 | int data; 190 | }; 191 | 192 | /** The generic custom window manager information structure */ 193 | typedef struct SDL_SysWMinfo { 194 | SDL_version version; 195 | int data; 196 | } SDL_SysWMinfo; 197 | 198 | #endif /* video driver type */ 199 | 200 | #endif /* SDL_PROTOTYPES_ONLY */ 201 | 202 | /* Function prototypes */ 203 | /** 204 | * This function gives you custom hooks into the window manager information. 205 | * It fills the structure pointed to by 'info' with custom information and 206 | * returns 0 if the function is not implemented, 1 if the function is 207 | * implemented and no error occurred, and -1 if the version member of 208 | * the 'info' structure is not filled in or not supported. 209 | * 210 | * You typically use this function like this: 211 | * @code 212 | * SDL_SysWMinfo info; 213 | * SDL_VERSION(&info.version); 214 | * if ( SDL_GetWMInfo(&info) ) { ... } 215 | * @endcode 216 | */ 217 | extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info); 218 | 219 | 220 | /* Ends C function definitions when using C++ */ 221 | #ifdef __cplusplus 222 | } 223 | #endif 224 | #include "close_code.h" 225 | 226 | #endif /* _SDL_syswm_h */ 227 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_thread_h 24 | #define _SDL_thread_h 25 | 26 | /** @file SDL_thread.h 27 | * Header for the SDL thread management routines 28 | * 29 | * @note These are independent of the other SDL routines. 30 | */ 31 | 32 | #include "SDL_stdinc.h" 33 | #include "SDL_error.h" 34 | 35 | /* Thread synchronization primitives */ 36 | #include "SDL_mutex.h" 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 | /** The SDL thread structure, defined in SDL_thread.c */ 45 | struct SDL_Thread; 46 | typedef struct SDL_Thread SDL_Thread; 47 | 48 | /** Create a thread */ 49 | #if ((defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__)) && !defined(__SYMBIAN32__) 50 | /** 51 | * We compile SDL into a DLL on OS/2. This means, that it's the DLL which 52 | * creates a new thread for the calling process with the SDL_CreateThread() 53 | * API. There is a problem with this, that only the RTL of the SDL.DLL will 54 | * be initialized for those threads, and not the RTL of the calling application! 55 | * To solve this, we make a little hack here. 56 | * We'll always use the caller's _beginthread() and _endthread() APIs to 57 | * start a new thread. This way, if it's the SDL.DLL which uses this API, 58 | * then the RTL of SDL.DLL will be used to create the new thread, and if it's 59 | * the application, then the RTL of the application will be used. 60 | * So, in short: 61 | * Always use the _beginthread() and _endthread() of the calling runtime library! 62 | */ 63 | #define SDL_PASSED_BEGINTHREAD_ENDTHREAD 64 | #ifndef _WIN32_WCE 65 | #include /* This has _beginthread() and _endthread() defined! */ 66 | #endif 67 | 68 | #ifdef __OS2__ 69 | typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg); 70 | typedef void (*pfnSDL_CurrentEndThread)(void); 71 | #else 72 | typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, 73 | unsigned (__stdcall *func)(void *), void *arg, 74 | unsigned, unsigned *threadID); 75 | typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); 76 | #endif 77 | 78 | extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); 79 | 80 | #ifdef __OS2__ 81 | #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread) 82 | #elif defined(_WIN32_WCE) 83 | #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL) 84 | #else 85 | #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex) 86 | #endif 87 | #else 88 | extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data); 89 | #endif 90 | 91 | /** Get the 32-bit thread identifier for the current thread */ 92 | extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void); 93 | 94 | /** Get the 32-bit thread identifier for the specified thread, 95 | * equivalent to SDL_ThreadID() if the specified thread is NULL. 96 | */ 97 | extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread *thread); 98 | 99 | /** Wait for a thread to finish. 100 | * The return code for the thread function is placed in the area 101 | * pointed to by 'status', if 'status' is not NULL. 102 | */ 103 | extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status); 104 | 105 | /** Forcefully kill a thread without worrying about its state */ 106 | extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread); 107 | 108 | 109 | /* Ends C function definitions when using C++ */ 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | #include "close_code.h" 114 | 115 | #endif /* _SDL_thread_h */ 116 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_timer_h 24 | #define _SDL_timer_h 25 | 26 | /** @file SDL_timer.h 27 | * Header for the SDL time management routines 28 | */ 29 | 30 | #include "SDL_stdinc.h" 31 | #include "SDL_error.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 | /** This is the OS scheduler timeslice, in milliseconds */ 40 | #define SDL_TIMESLICE 10 41 | 42 | /** This is the maximum resolution of the SDL timer on all platforms */ 43 | #define TIMER_RESOLUTION 10 /**< Experimentally determined */ 44 | 45 | /** 46 | * Get the number of milliseconds since the SDL library initialization. 47 | * Note that this value wraps if the program runs for more than ~49 days. 48 | */ 49 | extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); 50 | 51 | /** Wait a specified number of milliseconds before returning */ 52 | extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); 53 | 54 | /** Function prototype for the timer callback function */ 55 | typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval); 56 | 57 | /** 58 | * Set a callback to run after the specified number of milliseconds has 59 | * elapsed. The callback function is passed the current timer interval 60 | * and returns the next timer interval. If the returned value is the 61 | * same as the one passed in, the periodic alarm continues, otherwise a 62 | * new alarm is scheduled. If the callback returns 0, the periodic alarm 63 | * is cancelled. 64 | * 65 | * To cancel a currently running timer, call SDL_SetTimer(0, NULL); 66 | * 67 | * The timer callback function may run in a different thread than your 68 | * main code, and so shouldn't call any functions from within itself. 69 | * 70 | * The maximum resolution of this timer is 10 ms, which means that if 71 | * you request a 16 ms timer, your callback will run approximately 20 ms 72 | * later on an unloaded system. If you wanted to set a flag signaling 73 | * a frame update at 30 frames per second (every 33 ms), you might set a 74 | * timer for 30 ms: 75 | * @code SDL_SetTimer((33/10)*10, flag_update); @endcode 76 | * 77 | * If you use this function, you need to pass SDL_INIT_TIMER to SDL_Init(). 78 | * 79 | * Under UNIX, you should not use raise or use SIGALRM and this function 80 | * in the same program, as it is implemented using setitimer(). You also 81 | * should not use this function in multi-threaded applications as signals 82 | * to multi-threaded apps have undefined behavior in some implementations. 83 | * 84 | * This function returns 0 if successful, or -1 if there was an error. 85 | */ 86 | extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback); 87 | 88 | /** @name New timer API 89 | * New timer API, supports multiple timers 90 | * Written by Stephane Peter 91 | */ 92 | /*@{*/ 93 | 94 | /** 95 | * Function prototype for the new timer callback function. 96 | * The callback function is passed the current timer interval and returns 97 | * the next timer interval. If the returned value is the same as the one 98 | * passed in, the periodic alarm continues, otherwise a new alarm is 99 | * scheduled. If the callback returns 0, the periodic alarm is cancelled. 100 | */ 101 | typedef Uint32 (SDLCALL *SDL_NewTimerCallback)(Uint32 interval, void *param); 102 | 103 | /** Definition of the timer ID type */ 104 | typedef struct _SDL_TimerID *SDL_TimerID; 105 | 106 | /** Add a new timer to the pool of timers already running. 107 | * Returns a timer ID, or NULL when an error occurs. 108 | */ 109 | extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param); 110 | 111 | /** 112 | * Remove one of the multiple timers knowing its ID. 113 | * Returns a boolean value indicating success. 114 | */ 115 | extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t); 116 | 117 | /*@}*/ 118 | 119 | /* Ends C function definitions when using C++ */ 120 | #ifdef __cplusplus 121 | } 122 | #endif 123 | #include "close_code.h" 124 | 125 | #endif /* _SDL_timer_h */ 126 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_types.h 24 | * @deprecated Use SDL_stdinc.h instead. 25 | */ 26 | 27 | /* DEPRECATED */ 28 | #include "SDL_stdinc.h" 29 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/SDL_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_version.h 24 | * This header defines the current SDL version 25 | */ 26 | 27 | #ifndef _SDL_version_h 28 | #define _SDL_version_h 29 | 30 | #include "SDL_stdinc.h" 31 | 32 | #include "begin_code.h" 33 | /* Set up for C function definitions, even when using C++ */ 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /** @name Version Number 39 | * Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL 40 | */ 41 | /*@{*/ 42 | #define SDL_MAJOR_VERSION 1 43 | #define SDL_MINOR_VERSION 2 44 | #define SDL_PATCHLEVEL 15 45 | /*@}*/ 46 | 47 | typedef struct SDL_version { 48 | Uint8 major; 49 | Uint8 minor; 50 | Uint8 patch; 51 | } SDL_version; 52 | 53 | /** 54 | * This macro can be used to fill a version structure with the compile-time 55 | * version of the SDL library. 56 | */ 57 | #define SDL_VERSION(X) \ 58 | { \ 59 | (X)->major = SDL_MAJOR_VERSION; \ 60 | (X)->minor = SDL_MINOR_VERSION; \ 61 | (X)->patch = SDL_PATCHLEVEL; \ 62 | } 63 | 64 | /** This macro turns the version numbers into a numeric value: 65 | * (1,2,3) -> (1203) 66 | * This assumes that there will never be more than 100 patchlevels 67 | */ 68 | #define SDL_VERSIONNUM(X, Y, Z) \ 69 | ((X)*1000 + (Y)*100 + (Z)) 70 | 71 | /** This is the version number macro for the current SDL version */ 72 | #define SDL_COMPILEDVERSION \ 73 | SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) 74 | 75 | /** This macro will evaluate to true if compiled with SDL at least X.Y.Z */ 76 | #define SDL_VERSION_ATLEAST(X, Y, Z) \ 77 | (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) 78 | 79 | /** This function gets the version of the dynamically linked SDL library. 80 | * it should NOT be used to fill a version structure, instead you should 81 | * use the SDL_Version() macro. 82 | */ 83 | extern DECLSPEC const SDL_version * SDLCALL SDL_Linked_Version(void); 84 | 85 | /* Ends C function definitions when using C++ */ 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | #include "close_code.h" 90 | 91 | #endif /* _SDL_version_h */ 92 | -------------------------------------------------------------------------------- /Win32/SDL-1.2.15/include/begin_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file begin_code.h 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 | /** 31 | * @file begin_code.h 32 | * This shouldn't be nested -- included it around code only. 33 | */ 34 | #ifdef _begin_code_h 35 | #error Nested inclusion of begin_code.h 36 | #endif 37 | #define _begin_code_h 38 | 39 | /** 40 | * @def DECLSPEC 41 | * Some compilers use a special export keyword 42 | */ 43 | #ifndef DECLSPEC 44 | # if defined(__BEOS__) || defined(__HAIKU__) 45 | # if defined(__GNUC__) 46 | # define DECLSPEC 47 | # else 48 | # define DECLSPEC __declspec(export) 49 | # endif 50 | # elif defined(__WIN32__) 51 | # ifdef __BORLANDC__ 52 | # ifdef BUILD_SDL 53 | # define DECLSPEC 54 | # else 55 | # define DECLSPEC __declspec(dllimport) 56 | # endif 57 | # else 58 | # define DECLSPEC __declspec(dllexport) 59 | # endif 60 | # elif defined(__OS2__) 61 | # ifdef __WATCOMC__ 62 | # ifdef BUILD_SDL 63 | # define DECLSPEC __declspec(dllexport) 64 | # else 65 | # define DECLSPEC 66 | # endif 67 | # elif defined (__GNUC__) && __GNUC__ < 4 68 | # /* Added support for GCC-EMX = 4 81 | # define DECLSPEC __attribute__ ((visibility("default"))) 82 | # else 83 | # define DECLSPEC 84 | # endif 85 | # endif 86 | #endif 87 | 88 | /** 89 | * @def SDLCALL 90 | * By default SDL uses the C calling convention 91 | */ 92 | #ifndef SDLCALL 93 | # if defined(__WIN32__) && !defined(__GNUC__) 94 | # define SDLCALL __cdecl 95 | # elif defined(__OS2__) 96 | # if defined (__GNUC__) && __GNUC__ < 4 97 | # /* Added support for GCC-EMX 6 | #include "Z80Core_CInterface.h" 7 | #include "Z80Core.h" 8 | 9 | //----------------------------------------------------------------------------------------- 10 | 11 | extern "C" 12 | { 13 | 14 | //----------------------------------------------------------------------------------------- 15 | 16 | void *Z80CORE_Create() 17 | { 18 | return reinterpret_cast(new CZ80Core()); 19 | } 20 | 21 | //----------------------------------------------------------------------------------------- 22 | 23 | void Z80CORE_Destroy(void *core) 24 | { 25 | delete reinterpret_cast(core); 26 | } 27 | 28 | //----------------------------------------------------------------------------------------- 29 | 30 | void Z80CORE_Initialise(void *core, Z80CoreRead mem_read, Z80CoreWrite mem_write, Z80CoreRead io_read, Z80CoreWrite io_write, Z80CoreContention mem_contention_handling, Z80CoreContention io_contention_handling, int member_class) 31 | { 32 | reinterpret_cast(core)->Initialise(mem_read, mem_write, io_read, io_write, mem_contention_handling, io_contention_handling, member_class); 33 | } 34 | 35 | //----------------------------------------------------------------------------------------- 36 | 37 | void Z80CORE_Reset(void *core) 38 | { 39 | reinterpret_cast(core)->Reset(); 40 | } 41 | 42 | //----------------------------------------------------------------------------------------- 43 | 44 | int Z80CORE_Execute(void *core, int num_tstates) 45 | { 46 | return reinterpret_cast(core)->Execute(num_tstates); 47 | } 48 | 49 | //----------------------------------------------------------------------------------------- 50 | 51 | void Z80CORE_SignalInterrupt(void *core) 52 | { 53 | reinterpret_cast(core)->SignalInterrupt(); 54 | } 55 | 56 | //----------------------------------------------------------------------------------------- 57 | 58 | unsigned char Z80CORE_GetByteRegister(void *core, eZ80BYTEREGISTERS r) 59 | { 60 | return reinterpret_cast(core)->GetRegister((CZ80Core::eZ80BYTEREGISTERS)r); 61 | } 62 | 63 | //----------------------------------------------------------------------------------------- 64 | 65 | unsigned short Z80CORE_GetWordRegister(void *core, eZ80WORDREGISTERS r) 66 | { 67 | return reinterpret_cast(core)->GetRegister((CZ80Core::eZ80WORDREGISTERS)r); 68 | } 69 | 70 | //----------------------------------------------------------------------------------------- 71 | 72 | void Z80CORE_SetByteRegister(void *core, eZ80BYTEREGISTERS r, unsigned char data) 73 | { 74 | reinterpret_cast(core)->SetRegister((CZ80Core::eZ80BYTEREGISTERS)r, data); 75 | } 76 | 77 | //----------------------------------------------------------------------------------------- 78 | 79 | void Z80CORE_SetWordRegister(void *core, eZ80WORDREGISTERS r, unsigned short data) 80 | { 81 | reinterpret_cast(core)->SetRegister((CZ80Core::eZ80WORDREGISTERS)r, data); 82 | } 83 | 84 | //----------------------------------------------------------------------------------------- 85 | 86 | unsigned char Z80CORE_GetIFF1(void *core) 87 | { 88 | return reinterpret_cast(core)->GetIFF1(); 89 | } 90 | 91 | //----------------------------------------------------------------------------------------- 92 | 93 | unsigned char Z80CORE_GetIFF2(void *core) 94 | { 95 | return reinterpret_cast(core)->GetIFF2(); 96 | } 97 | 98 | //----------------------------------------------------------------------------------------- 99 | 100 | unsigned char Z80CORE_GetIMMode(void *core) 101 | { 102 | return reinterpret_cast(core)->GetIMMode(); 103 | } 104 | 105 | //----------------------------------------------------------------------------------------- 106 | 107 | unsigned int Z80CORE_GetTStates(void *core) 108 | { 109 | return reinterpret_cast(core)->GetTStates(); 110 | } 111 | 112 | //----------------------------------------------------------------------------------------- 113 | 114 | void Z80CORE_ResetTStates(void *core, unsigned int count) 115 | { 116 | reinterpret_cast(core)->ResetTStates(count); 117 | } 118 | 119 | //----------------------------------------------------------------------------------------- 120 | 121 | void Z80CORE_SetIFF1(void *core, unsigned char iff1) 122 | { 123 | reinterpret_cast(core)->SetIFF1(iff1); 124 | } 125 | 126 | //----------------------------------------------------------------------------------------- 127 | 128 | void Z80CORE_SetIFF2(void *core, unsigned char iff2) 129 | { 130 | reinterpret_cast(core)->SetIFF2(iff2); 131 | } 132 | 133 | //----------------------------------------------------------------------------------------- 134 | 135 | void Z80CORE_SetIMMode(void *core, unsigned char immode) 136 | { 137 | reinterpret_cast(core)->SetIMMode(immode); 138 | } 139 | 140 | //----------------------------------------------------------------------------------------- 141 | 142 | } 143 | 144 | //----------------------------------------------------------------------------------------- 145 | -------------------------------------------------------------------------------- /src/cpu/z80core/Z80Core_CInterface.h: -------------------------------------------------------------------------------- 1 | // 2 | // TZT ZX Spectrum Emulator 3 | // 4 | 5 | #ifndef __Z80CORE_CINTERFACE_H__ 6 | #define __Z80CORE_CINTERFACE_H__ 7 | 8 | //----------------------------------------------------------------------------------------- 9 | 10 | #ifdef __cplusplus 11 | extern "C" 12 | { 13 | #endif 14 | 15 | //----------------------------------------------------------------------------------------- 16 | 17 | typedef unsigned char(*Z80CoreRead)(unsigned short address, int param); 18 | typedef void(*Z80CoreWrite)(unsigned short address, unsigned char data, int param); 19 | typedef void(*Z80CoreContention)(unsigned short address, unsigned int tstates, int param); 20 | 21 | //----------------------------------------------------------------------------------------- 22 | 23 | typedef enum 24 | { 25 | eREG_A, 26 | eREG_F, 27 | eREG_B, 28 | eREG_C, 29 | eREG_D, 30 | eREG_E, 31 | eREG_H, 32 | eREG_L, 33 | 34 | eREG_ALT_A, 35 | eREG_ALT_F, 36 | eREG_ALT_B, 37 | eREG_ALT_C, 38 | eREG_ALT_D, 39 | eREG_ALT_E, 40 | eREG_ALT_H, 41 | eREG_ALT_L, 42 | 43 | eREG_I, 44 | eREG_R, 45 | } eZ80BYTEREGISTERS; 46 | 47 | typedef enum 48 | { 49 | eREG_AF, 50 | eREG_HL, 51 | eREG_BC, 52 | eREG_DE, 53 | eREG_ALT_AF, 54 | eREG_ALT_HL, 55 | eREG_ALT_BC, 56 | eREG_ALT_DE, 57 | 58 | eREG_IX, 59 | eREG_IY, 60 | eREG_SP, 61 | eREG_PC, 62 | 63 | } eZ80WORDREGISTERS; 64 | 65 | //----------------------------------------------------------------------------------------- 66 | 67 | void *Z80CORE_Create(); 68 | void Z80CORE_Destroy(void *core); 69 | void Z80CORE_Initialise(void *core, Z80CoreRead mem_read, Z80CoreWrite mem_write, Z80CoreRead io_read, Z80CoreWrite io_write, Z80CoreContention mem_contention_handling, Z80CoreContention io_contention_handling, int member_class); 70 | void Z80CORE_Reset(void *core); 71 | int Z80CORE_Execute(void *core, int num_tstates); 72 | void Z80CORE_SignalInterrupt(void *core); 73 | unsigned char Z80CORE_GetByteRegister(void *core, eZ80BYTEREGISTERS r); 74 | unsigned short Z80CORE_GetWordRegister(void *core, eZ80WORDREGISTERS r); 75 | void Z80CORE_SetByteRegister(void *core, eZ80BYTEREGISTERS r, unsigned char data); 76 | void Z80CORE_SetWordRegister(void *core, eZ80WORDREGISTERS r, unsigned short data); 77 | unsigned char Z80CORE_GetIFF1(void *core); 78 | unsigned char Z80CORE_GetIFF2(void *core); 79 | unsigned char Z80CORE_GetIMMode(void *core); 80 | unsigned int Z80CORE_GetTStates(void *core); 81 | void Z80CORE_ResetTStates(void *core, unsigned int count); 82 | void Z80CORE_SetIFF1(void *core, unsigned char iff1); 83 | void Z80CORE_SetIFF2(void *core, unsigned char iff2); 84 | void Z80CORE_SetIMMode(void *core, unsigned char immode); 85 | 86 | //----------------------------------------------------------------------------------------- 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | //----------------------------------------------------------------------------------------- 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /src/cpu/z80core/Z80Core_DDOpcodes.h: -------------------------------------------------------------------------------- 1 | void ADD_IX_BC(unsigned char opcode); 2 | void ADD_IX_DE(unsigned char opcode); 3 | void LD_IX_nn(unsigned char opcode); 4 | void LD_off_nn_IX(unsigned char opcode); 5 | void INC_IX(unsigned char opcode); 6 | void INC_IXh(unsigned char opcode); 7 | void DEC_IXh(unsigned char opcode); 8 | void LD_IXh_n(unsigned char opcode); 9 | void ADD_IX_IX(unsigned char opcode); 10 | void LD_IX_off_nn(unsigned char opcode); 11 | void DEC_IX(unsigned char opcode); 12 | void INC_IXl(unsigned char opcode); 13 | void DEC_IXl(unsigned char opcode); 14 | void LD_IXl_n(unsigned char opcode); 15 | void INC_off_IX_d(unsigned char opcode); 16 | void DEC_off_IX_d(unsigned char opcode); 17 | void LD_off_IX_d_n(unsigned char opcode); 18 | void ADD_IX_SP(unsigned char opcode); 19 | void LD_B_IXh(unsigned char opcode); 20 | void LD_B_IXl(unsigned char opcode); 21 | void LD_B_off_IX_d(unsigned char opcode); 22 | void LD_C_IXh(unsigned char opcode); 23 | void LD_C_IXl(unsigned char opcode); 24 | void LD_C_off_IX_d(unsigned char opcode); 25 | void LD_D_IXh(unsigned char opcode); 26 | void LD_D_IXl(unsigned char opcode); 27 | void LD_D_off_IX_d(unsigned char opcode); 28 | void LD_E_IXh(unsigned char opcode); 29 | void LD_E_IXl(unsigned char opcode); 30 | void LD_E_off_IX_d(unsigned char opcode); 31 | void LD_IXh_B(unsigned char opcode); 32 | void LD_IXh_C(unsigned char opcode); 33 | void LD_IXh_D(unsigned char opcode); 34 | void LD_IXh_E(unsigned char opcode); 35 | void LD_IXh_IXh(unsigned char opcode); 36 | void LD_IXh_IXl(unsigned char opcode); 37 | void LD_H_off_IX_d(unsigned char opcode); 38 | void LD_IXh_A(unsigned char opcode); 39 | void LD_IXl_B(unsigned char opcode); 40 | void LD_IXl_C(unsigned char opcode); 41 | void LD_IXl_D(unsigned char opcode); 42 | void LD_IXl_E(unsigned char opcode); 43 | void LD_IXl_IXh(unsigned char opcode); 44 | void LD_IXl_IXl(unsigned char opcode); 45 | void LD_L_off_IX_d(unsigned char opcode); 46 | void LD_IXl_A(unsigned char opcode); 47 | void LD_off_IX_d_B(unsigned char opcode); 48 | void LD_off_IX_d_C(unsigned char opcode); 49 | void LD_off_IX_d_D(unsigned char opcode); 50 | void LD_off_IX_d_E(unsigned char opcode); 51 | void LD_off_IX_d_H(unsigned char opcode); 52 | void LD_off_IX_d_L(unsigned char opcode); 53 | void LD_off_IX_d_A(unsigned char opcode); 54 | void LD_A_IXh(unsigned char opcode); 55 | void LD_A_IXl(unsigned char opcode); 56 | void LD_A_off_IX_d(unsigned char opcode); 57 | void ADD_A_IXh(unsigned char opcode); 58 | void ADD_A_IXl(unsigned char opcode); 59 | void ADD_A_off_IX_d(unsigned char opcode); 60 | void ADC_A_IXh(unsigned char opcode); 61 | void ADC_A_IXl(unsigned char opcode); 62 | void ADC_A_off_IX_d(unsigned char opcode); 63 | void SUB_A_IXh(unsigned char opcode); 64 | void SUB_A_IXl(unsigned char opcode); 65 | void SUB_A_off_IX_d(unsigned char opcode); 66 | void SBC_A_IXh(unsigned char opcode); 67 | void SBC_A_IXl(unsigned char opcode); 68 | void SBC_A_off_IX_d(unsigned char opcode); 69 | void AND_IXh(unsigned char opcode); 70 | void AND_IXl(unsigned char opcode); 71 | void AND_off_IX_d(unsigned char opcode); 72 | void XOR_IXh(unsigned char opcode); 73 | void XOR_IXl(unsigned char opcode); 74 | void XOR_off_IX_d(unsigned char opcode); 75 | void OR_IXh(unsigned char opcode); 76 | void OR_IXl(unsigned char opcode); 77 | void OR_off_IX_d(unsigned char opcode); 78 | void CP_IXh(unsigned char opcode); 79 | void CP_IXl(unsigned char opcode); 80 | void CP_off_IX_d(unsigned char opcode); 81 | void POP_IX(unsigned char opcode); 82 | void EX_off_SP_IX(unsigned char opcode); 83 | void PUSH_IX(unsigned char opcode); 84 | void JP_off_IX(unsigned char opcode); 85 | void LD_SP_IX(unsigned char opcode); -------------------------------------------------------------------------------- /src/cpu/z80core/Z80Core_EDOpcodes.h: -------------------------------------------------------------------------------- 1 | void IN_B_off_C(unsigned char opcode); 2 | void OUT_off_C_B(unsigned char opcode); 3 | void SBC_HL_BC(unsigned char opcode); 4 | void LD_off_nn_BC(unsigned char opcode); 5 | void NEG(unsigned char opcode); 6 | void RETN(unsigned char opcode); 7 | void IM_0(unsigned char opcode); 8 | void LD_I_A(unsigned char opcode); 9 | void IN_C_off_C(unsigned char opcode); 10 | void OUT_off_C_C(unsigned char opcode); 11 | void ADC_HL_BC(unsigned char opcode); 12 | void LD_BC_off_nn(unsigned char opcode); 13 | void RETI(unsigned char opcode); 14 | void LD_R_A(unsigned char opcode); 15 | void IN_D_off_C(unsigned char opcode); 16 | void OUT_off_C_D(unsigned char opcode); 17 | void SBC_HL_DE(unsigned char opcode); 18 | void LD_off_nn_DE(unsigned char opcode); 19 | void IM_1(unsigned char opcode); 20 | void LD_A_I(unsigned char opcode); 21 | void IN_E_off_C(unsigned char opcode); 22 | void OUT_off_C_E(unsigned char opcode); 23 | void ADC_HL_DE(unsigned char opcode); 24 | void LD_DE_off_nn(unsigned char opcode); 25 | void IM_2(unsigned char opcode); 26 | void LD_A_R(unsigned char opcode); 27 | void IN_H_off_C(unsigned char opcode); 28 | void OUT_off_C_H(unsigned char opcode); 29 | void SBC_HL_HL(unsigned char opcode); 30 | void RRD(unsigned char opcode); 31 | void IN_L_off_C(unsigned char opcode); 32 | void OUT_off_C_L(unsigned char opcode); 33 | void ADC_HL_HL(unsigned char opcode); 34 | void RLD(unsigned char opcode); 35 | void IN_F_off_C(unsigned char opcode); 36 | void OUT_off_C_0(unsigned char opcode); 37 | void SBC_HL_SP(unsigned char opcode); 38 | void LD_off_nn_SP(unsigned char opcode); 39 | void IN_A_off_C(unsigned char opcode); 40 | void OUT_off_C_A(unsigned char opcode); 41 | void ADC_HL_SP(unsigned char opcode); 42 | void LD_SP_off_nn(unsigned char opcode); 43 | void LDI(unsigned char opcode); 44 | void CPI(unsigned char opcode); 45 | void INI(unsigned char opcode); 46 | void OUTI(unsigned char opcode); 47 | void LDD(unsigned char opcode); 48 | void CPD(unsigned char opcode); 49 | void IND(unsigned char opcode); 50 | void OUTD(unsigned char opcode); 51 | void LDIR(unsigned char opcode); 52 | void CPIR(unsigned char opcode); 53 | void INIR(unsigned char opcode); 54 | void OTIR(unsigned char opcode); 55 | void LDDR(unsigned char opcode); 56 | void CPDR(unsigned char opcode); 57 | void INDR(unsigned char opcode); 58 | void OTDR(unsigned char opcode); -------------------------------------------------------------------------------- /src/cpu/z80core/Z80Core_FDOpcodes.h: -------------------------------------------------------------------------------- 1 | void ADD_IY_BC(unsigned char opcode); 2 | void ADD_IY_DE(unsigned char opcode); 3 | void LD_IY_nn(unsigned char opcode); 4 | void LD_off_nn_IY(unsigned char opcode); 5 | void INC_IY(unsigned char opcode); 6 | void INC_IYh(unsigned char opcode); 7 | void DEC_IYh(unsigned char opcode); 8 | void LD_IYh_n(unsigned char opcode); 9 | void ADD_IY_IY(unsigned char opcode); 10 | void LD_IY_off_nn(unsigned char opcode); 11 | void DEC_IY(unsigned char opcode); 12 | void INC_IYl(unsigned char opcode); 13 | void DEC_IYl(unsigned char opcode); 14 | void LD_IYl_n(unsigned char opcode); 15 | void INC_off_IY_d(unsigned char opcode); 16 | void DEC_off_IY_d(unsigned char opcode); 17 | void LD_off_IY_d_n(unsigned char opcode); 18 | void ADD_IY_SP(unsigned char opcode); 19 | void LD_B_IYh(unsigned char opcode); 20 | void LD_B_IYl(unsigned char opcode); 21 | void LD_B_off_IY_d(unsigned char opcode); 22 | void LD_C_IYh(unsigned char opcode); 23 | void LD_C_IYl(unsigned char opcode); 24 | void LD_C_off_IY_d(unsigned char opcode); 25 | void LD_D_IYh(unsigned char opcode); 26 | void LD_D_IYl(unsigned char opcode); 27 | void LD_D_off_IY_d(unsigned char opcode); 28 | void LD_E_IYh(unsigned char opcode); 29 | void LD_E_IYl(unsigned char opcode); 30 | void LD_E_off_IY_d(unsigned char opcode); 31 | void LD_IYh_B(unsigned char opcode); 32 | void LD_IYh_C(unsigned char opcode); 33 | void LD_IYh_D(unsigned char opcode); 34 | void LD_IYh_E(unsigned char opcode); 35 | void LD_IYh_IYh(unsigned char opcode); 36 | void LD_IYh_IYl(unsigned char opcode); 37 | void LD_H_off_IY_d(unsigned char opcode); 38 | void LD_IYh_A(unsigned char opcode); 39 | void LD_IYl_B(unsigned char opcode); 40 | void LD_IYl_C(unsigned char opcode); 41 | void LD_IYl_D(unsigned char opcode); 42 | void LD_IYl_E(unsigned char opcode); 43 | void LD_IYl_IYh(unsigned char opcode); 44 | void LD_IYl_IYl(unsigned char opcode); 45 | void LD_L_off_IY_d(unsigned char opcode); 46 | void LD_IYl_A(unsigned char opcode); 47 | void LD_off_IY_d_B(unsigned char opcode); 48 | void LD_off_IY_d_C(unsigned char opcode); 49 | void LD_off_IY_d_D(unsigned char opcode); 50 | void LD_off_IY_d_E(unsigned char opcode); 51 | void LD_off_IY_d_H(unsigned char opcode); 52 | void LD_off_IY_d_L(unsigned char opcode); 53 | void LD_off_IY_d_A(unsigned char opcode); 54 | void LD_A_IYh(unsigned char opcode); 55 | void LD_A_IYl(unsigned char opcode); 56 | void LD_A_off_IY_d(unsigned char opcode); 57 | void ADD_A_IYh(unsigned char opcode); 58 | void ADD_A_IYl(unsigned char opcode); 59 | void ADD_A_off_IY_d(unsigned char opcode); 60 | void ADC_A_IYh(unsigned char opcode); 61 | void ADC_A_IYl(unsigned char opcode); 62 | void ADC_A_off_IY_d(unsigned char opcode); 63 | void SUB_A_IYh(unsigned char opcode); 64 | void SUB_A_IYl(unsigned char opcode); 65 | void SUB_A_off_IY_d(unsigned char opcode); 66 | void SBC_A_IYh(unsigned char opcode); 67 | void SBC_A_IYl(unsigned char opcode); 68 | void SBC_A_off_IY_d(unsigned char opcode); 69 | void AND_IYh(unsigned char opcode); 70 | void AND_IYl(unsigned char opcode); 71 | void AND_off_IY_d(unsigned char opcode); 72 | void XOR_IYh(unsigned char opcode); 73 | void XOR_IYl(unsigned char opcode); 74 | void XOR_off_IY_d(unsigned char opcode); 75 | void OR_IYh(unsigned char opcode); 76 | void OR_IYl(unsigned char opcode); 77 | void OR_off_IY_d(unsigned char opcode); 78 | void CP_IYh(unsigned char opcode); 79 | void CP_IYl(unsigned char opcode); 80 | void CP_off_IY_d(unsigned char opcode); 81 | void POP_IY(unsigned char opcode); 82 | void EX_off_SP_IY(unsigned char opcode); 83 | void PUSH_IY(unsigned char opcode); 84 | void JP_off_IY(unsigned char opcode); 85 | void LD_SP_IY(unsigned char opcode); -------------------------------------------------------------------------------- /src/cpu/z80core/cpuintf.c: -------------------------------------------------------------------------------- 1 | /* cpuintf.c 2 | * 3 | * CPU Interface (z80core) 4 | * 5 | * z80Core by Adrian Brown (website / contact??) 6 | * 7 | * Allows ZXEM to be used with different cpu cores 8 | * 9 | */ 10 | 11 | #include "zxem.h" 12 | #include "Z80Core_CInterface.h" 13 | 14 | #define MAX_CPU 10 15 | 16 | void *zxcpu[MAX_CPU]; 17 | uint8_t num_cpus = -1; 18 | 19 | unsigned char coreRead(unsigned short addr, int param) { 20 | return readbyte(addr); 21 | } 22 | 23 | void coreWrite(unsigned short address, unsigned char data, int param) { 24 | writebyte(address, data); 25 | } 26 | 27 | unsigned char IORead(unsigned short addr, int param) { 28 | return input(addr); 29 | } 30 | 31 | void IOWrite(unsigned short address, unsigned char data,int param) { 32 | output(address, data); 33 | } 34 | 35 | // Just return, dont handle contention 36 | void coreContention(unsigned short address, unsigned int tstates,int param) { 37 | return; 38 | } 39 | 40 | // create CPU context and return a handle 41 | uint8_t CPU_Create(void) { 42 | num_cpus++; 43 | if(num_cpusGetTStates(); 66 | // printf("Executing: %d\n",ticks); 67 | return Z80CORE_Execute(zxcpu[cpuid], ticks); 68 | // printf("Done!\n"); 69 | // return zxcpu[cpuid]->GetTStates()-oticks; 70 | } 71 | 72 | 73 | // Call interrupt on a CPU 74 | void CPU_Interrupt(uint8_t cpuid) { 75 | 76 | // printf("Interrupt!\n"); 77 | Z80CORE_SignalInterrupt(zxcpu[cpuid]); 78 | 79 | // do we have to do anything else?? 80 | Z80CORE_Execute(zxcpu[cpuid], 13); 81 | 82 | // printf("Finished Interrupt!\n"); 83 | } 84 | 85 | // Call an NMI on a CPU 86 | void CPU_NMI(uint8_t cpuid) { 87 | // TODO 88 | } 89 | 90 | 91 | void CPU_SetReg(uint8_t cpuid, char *reg, uint16_t value) { 92 | 93 | int creg = reg[0]+reg[1]*256; 94 | 95 | switch(creg) { 96 | case 66: // B 97 | Z80CORE_SetByteRegister(zxcpu[cpuid], eREG_B, value); 98 | return; 99 | break; 100 | case 73: // I 101 | Z80CORE_SetByteRegister(zxcpu[cpuid], eREG_I, value); 102 | return; 103 | break; 104 | case 17232: // PC 105 | Z80CORE_SetWordRegister(zxcpu[cpuid], eREG_PC, value); 106 | return; 107 | break; 108 | 109 | default: 110 | printf("Unimplemented reg [%s] (%d)\n",reg, creg); 111 | return; 112 | 113 | } 114 | 115 | } 116 | 117 | uint16_t CPU_GetReg(uint8_t cpuid, char *reg) { 118 | 119 | int creg=reg[0]+reg[1]*256; 120 | // printf("REG: %s %d\n",reg,creg); 121 | switch(creg) { 122 | case 66: // B 123 | return Z80CORE_GetByteRegister(zxcpu[cpuid], eREG_B); 124 | break; 125 | case 17232: // PC 126 | return Z80CORE_GetWordRegister(zxcpu[cpuid], eREG_PC); 127 | break; 128 | default: 129 | printf("Unimplemented reg return %s\n",reg); 130 | return 0; 131 | } 132 | 133 | return 0; 134 | } 135 | -------------------------------------------------------------------------------- /src/cpu/z80emu/cpuintf.c: -------------------------------------------------------------------------------- 1 | /* cpuintf.c 2 | * 3 | * CPU Interface (mz80) 4 | * 5 | * Allows ZXEM to be used with different cpu cores 6 | * 7 | */ 8 | 9 | #include "zxem.h" 10 | #include "z80emu.h" 11 | 12 | #define MAX_CPU 10 13 | 14 | Z80_STATE *zxcpu[MAX_CPU]; 15 | uint8_t num_cpus = -1; 16 | 17 | // create CPU context and return a handle 18 | uint8_t CPU_Create(void) { 19 | num_cpus++; 20 | if(num_cpusmemory = zxmem; 23 | zxcpu[num_cpus]->readbyte = readbyte; 24 | zxcpu[num_cpus]->readword = readword; 25 | zxcpu[num_cpus]->writeword = writeword; 26 | zxcpu[num_cpus]->writebyte = writebyte; 27 | zxcpu[num_cpus]->input = input; 28 | zxcpu[num_cpus]->output = output; 29 | return num_cpus; 30 | } 31 | 32 | return 255; 33 | } 34 | 35 | // reset a CPU context 36 | void CPU_Reset(uint8_t cpuid) { 37 | 38 | Z80Reset(zxcpu[cpuid]); 39 | zxcpu[cpuid]->im = Z80_INTERRUPT_MODE_0; 40 | } 41 | 42 | 43 | // Assign a block of memory as read/write 44 | void CPU_MEMRW(int addr, int length) { 45 | 46 | } 47 | 48 | // Assign a block of memory as read only 49 | void CPU_MEMR(int addr, int length) { 50 | 51 | } 52 | 53 | // Destroy a CPU context 54 | void CPU_Destroy(uint8_t cpuid) { 55 | free(zxcpu[cpuid]); 56 | zxcpu[cpuid]=NULL; 57 | } 58 | 59 | // Emulatoe virtual CPU 60 | int CPU_Emulate(uint8_t cpuid, int ticks) { 61 | return Z80Emulate(zxcpu[cpuid], ticks); 62 | } 63 | 64 | int oim; 65 | 66 | // Call interrupt on a CPU 67 | void CPU_Interrupt(uint8_t cpuid) { 68 | if(oim!=zxcpu[cpuid]->im) { 69 | oim = zxcpu[cpuid]->im; 70 | printf("New interrupt: MODE: %d ",zxcpu[cpuid]->im); 71 | switch(oim) { 72 | case Z80_INTERRUPT_MODE_0: 73 | printf("mode 0\n"); 74 | break; 75 | case Z80_INTERRUPT_MODE_1: 76 | printf("mode 1\n"); 77 | break; 78 | case Z80_INTERRUPT_MODE_2: 79 | printf("mode 2\n"); 80 | break; 81 | default: 82 | printf("????\n"); 83 | } 84 | 85 | } 86 | 87 | Z80Emulate(zxcpu[cpuid], Z80Interrupt(zxcpu[cpuid],0xff)); 88 | 89 | } 90 | 91 | // Call an NMI on a CPU 92 | void CPU_NMI(uint8_t cpuid) { 93 | // TODO 94 | } 95 | 96 | 97 | uint16_t CPU_GetReg(uint8_t cpuid, char *reg) { 98 | 99 | int creg=reg[0]+reg[1]*256; 100 | // printf("REG: %s %d\n",reg,creg); 101 | switch(creg) { 102 | case 66: // B 103 | return zxcpu[cpuid]->registers.byte[Z80_B]; 104 | break; 105 | case 17232: // PC 106 | return zxcpu[cpuid]->pc; 107 | break; 108 | default: 109 | printf("Unimplemented reg return %s\n",reg); 110 | return 0; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/cpu/z80emu/instructions.h: -------------------------------------------------------------------------------- 1 | /* instructions.h 2 | * Declaration of the "generic" instructions emulated. 3 | * 4 | * Copyright (c) 2012 Lin Ke-Fong 5 | * 6 | * This program is free, do whatever you want with it. 7 | */ 8 | 9 | /* Some "instructions" handle two opcodes hence they need their encodings to 10 | * be able to distinguish them. 11 | */ 12 | 13 | #define OPCODE_LD_A_I 0x57 14 | #define OPCODE_LD_I_A 0x47 15 | 16 | #define OPCODE_LDI 0xa0 17 | #define OPCODE_LDIR 0xb0 18 | #define OPCODE_CPI 0xa1 19 | #define OPCODE_CPIR 0xb1 20 | 21 | #define OPCODE_RLD 0x6f 22 | 23 | #if defined(Z80_CATCH_RETI) && defined(Z80_CATCH_RETN) 24 | # define OPCODE_RETI 0x4d 25 | #endif 26 | 27 | #define OPCODE_INI 0xa2 28 | #define OPCODE_INIR 0xb2 29 | #define OPCODE_OUTI 0xa3 30 | #define OPCODE_OTIR 0xb3 31 | 32 | /* Instruction numbers, opcodes are converted to these numbers using tables 33 | * generated by maketables.c. 34 | */ 35 | 36 | enum { 37 | 38 | /* 8-bit load group. */ 39 | 40 | LD_R_R, 41 | LD_R_N, 42 | 43 | LD_R_INDIRECT_HL, 44 | LD_INDIRECT_HL_R, 45 | LD_INDIRECT_HL_N, 46 | 47 | LD_A_INDIRECT_BC, 48 | LD_A_INDIRECT_DE, 49 | LD_A_INDIRECT_NN, 50 | LD_INDIRECT_BC_A, 51 | LD_INDIRECT_DE_A, 52 | LD_INDIRECT_NN_A, 53 | 54 | LD_A_I_LD_A_R, /* Handle "LD A, I" and "LD A, R". */ 55 | LD_I_A_LD_R_A, /* Handle "LD I, A" and "LD I, A". */ 56 | 57 | /* 16-bit load group. */ 58 | 59 | LD_RR_NN, 60 | 61 | LD_HL_INDIRECT_NN, 62 | LD_RR_INDIRECT_NN, 63 | LD_INDIRECT_NN_HL, 64 | LD_INDIRECT_NN_RR, 65 | 66 | LD_SP_HL, 67 | 68 | PUSH_SS, 69 | POP_SS, 70 | 71 | /* Exchange, block transfer, and search group. */ 72 | 73 | EX_DE_HL, 74 | EX_AF_AF_PRIME, 75 | EXX, 76 | EX_INDIRECT_SP_HL, 77 | 78 | LDI_LDD, /* Handle "LDI" and "LDD". */ 79 | LDIR_LDDR, /* Handle "LDIR" and "LDDR". */ 80 | 81 | CPI_CPD, /* Handle "CPI" and "CPD". */ 82 | CPIR_CPDR, /* Handle "CPIR" and "CPDR". */ 83 | 84 | /* 8-bit arithmetic and logical group. */ 85 | 86 | ADD_R, 87 | ADD_N, 88 | ADD_INDIRECT_HL, 89 | 90 | ADC_R, 91 | ADC_N, 92 | ADC_INDIRECT_HL, 93 | 94 | SUB_R, 95 | SUB_N, 96 | SUB_INDIRECT_HL, 97 | 98 | SBC_R, 99 | SBC_N, 100 | SBC_INDIRECT_HL, 101 | 102 | AND_R, 103 | AND_N, 104 | AND_INDIRECT_HL, 105 | 106 | XOR_R, 107 | XOR_N, 108 | XOR_INDIRECT_HL, 109 | 110 | OR_R, 111 | OR_N, 112 | OR_INDIRECT_HL, 113 | 114 | CP_R, 115 | CP_N, 116 | CP_INDIRECT_HL, 117 | 118 | INC_R, 119 | INC_INDIRECT_HL, 120 | DEC_R, 121 | DEC_INDIRECT_HL, 122 | 123 | /* 16-bit arithmetic group. */ 124 | 125 | ADD_HL_RR, 126 | 127 | ADC_HL_RR, 128 | SBC_HL_RR, 129 | 130 | INC_RR, 131 | DEC_RR, 132 | 133 | /* General-purpose arithmetic and CPU control group. */ 134 | 135 | DAA, 136 | 137 | CPL, 138 | NEG, 139 | 140 | CCF, 141 | SCF, 142 | 143 | NOP, 144 | HALT, 145 | 146 | DI, 147 | EI, 148 | 149 | IM_N, 150 | 151 | /* Rotate and shift group. */ 152 | 153 | RLCA, 154 | RLA, 155 | RRCA, 156 | RRA, 157 | 158 | RLC_R, 159 | RLC_INDIRECT_HL, 160 | RL_R, 161 | RL_INDIRECT_HL, 162 | RRC_R, 163 | RRC_INDIRECT_HL, 164 | RR_R, 165 | RR_INDIRECT_HL, 166 | SLA_R, 167 | SLA_INDIRECT_HL, 168 | SLL_R, 169 | SLL_INDIRECT_HL, 170 | SRA_R, 171 | SRA_INDIRECT_HL, 172 | SRL_R, 173 | SRL_INDIRECT_HL, 174 | 175 | RLD_RRD, /* Handle "RLD" and "RRD". */ 176 | 177 | /* Bit set, reset, and test group. */ 178 | 179 | BIT_B_R, 180 | BIT_B_INDIRECT_HL, 181 | SET_B_R, 182 | SET_B_INDIRECT_HL, 183 | RES_B_R, 184 | RES_B_INDIRECT_HL, 185 | 186 | /* Jump group. */ 187 | 188 | JP_NN, 189 | JP_CC_NN, 190 | JR_E, 191 | JR_DD_E, 192 | JP_HL, 193 | DJNZ_E, 194 | 195 | /* Call and return group. */ 196 | 197 | CALL_NN, 198 | CALL_CC_NN, 199 | RET, 200 | RET_CC, 201 | 202 | RETI_RETN, /* Handle "RETI" and "RETN". */ 203 | 204 | RST_P, 205 | 206 | /* Input and output group. */ 207 | 208 | IN_A_N, 209 | IN_R_C, /* Correctly handle undocumented "IN F, (C)" 210 | * instruction. 211 | */ 212 | 213 | INI_IND, /* Handle "INI" and "IND". */ 214 | INIR_INDR, /* Handle "INIR" and "INDR". */ 215 | 216 | OUT_N_A, 217 | OUT_C_R, /* Correctly handle undocumented "OUT (C), 0" 218 | * instruction. 219 | */ 220 | 221 | OUTI_OUTD, /* Handle "OUTI" and "OUTD".*/ 222 | OTIR_OTDR, /* Handle "OTIR" and "OTDR". */ 223 | 224 | /* Prefix group. */ 225 | 226 | CB_PREFIX, 227 | DD_PREFIX, 228 | FD_PREFIX, 229 | ED_PREFIX, 230 | 231 | /* Special instruction group. */ 232 | 233 | ED_UNDEFINED /* ED_UNDEFINED is used to catch undefined 234 | * 0xed prefixed opcodes. 235 | */ 236 | 237 | }; 238 | -------------------------------------------------------------------------------- /src/cpu/z80emu/zextest.c: -------------------------------------------------------------------------------- 1 | /* zextest.c 2 | * Example program using z80emu to run the zexall and zexdoc tests. This will 3 | * check if the Z80 is correctly emulated. 4 | * 5 | * Copyright (c) 2012 Lin Ke-Fong 6 | * Copyright (c) 2012 Chris Pressey 7 | * 8 | * This program is free, do whatever you want with it. 9 | */ 10 | 11 | #include 12 | #include 13 | #include "z80emu.h" 14 | #ifdef EMSCRIPTEN 15 | #include 16 | #endif 17 | #include 18 | 19 | 20 | #define Z80_CPU_SPEED 4000000 /* In Hz. */ 21 | #ifdef EMSCRIPTEN 22 | #define CYCLES_PER_STEP (Z80_CPU_SPEED) 23 | #else 24 | #define CYCLES_PER_STEP (Z80_CPU_SPEED / 50) 25 | #endif 26 | 27 | #define MAXIMUM_STRING_LENGTH 100 28 | 29 | unsigned char memory[1 << 16]; 30 | 31 | static void emulate (char *filename); 32 | 33 | int main (void) 34 | 35 | { 36 | emulate("testfiles/zexdoc.com"); 37 | emulate("testfiles/zexall.com"); 38 | return EXIT_SUCCESS; 39 | } 40 | 41 | /* Emulate "zexdoc.com" or "zexall.com". */ 42 | Z80_STATE state; 43 | double total; 44 | int stopped; 45 | 46 | void mainloop(void) { 47 | total += Z80Emulate(&state, CYCLES_PER_STEP); 48 | if (state.status & FLAG_STOP_EMULATION) 49 | #ifdef EMSCRIPTEN 50 | emscripten_cancel_main_loop(); 51 | #else 52 | stopped = 1; 53 | #endif 54 | 55 | } 56 | 57 | 58 | uint8_t readbyte(uint16_t addr) { 59 | return memory[addr]; 60 | } 61 | 62 | uint16_t readword(uint16_t addr) { 63 | return memory[addr]|memory[addr+1]<<8; 64 | } 65 | 66 | void writebyte(uint16_t addr, uint8_t data) { 67 | memory[addr]=data; 68 | } 69 | 70 | void writeword(uint16_t addr, uint16_t data) { 71 | memory[addr]=data; 72 | memory[addr+1]=data>>8; 73 | } 74 | 75 | static void emulate (char *filename) 76 | 77 | { 78 | FILE *file; 79 | long l; 80 | 81 | printf("Testing \"%s\"...\n", filename); 82 | 83 | if ((file = fopen(filename, "rb")) == NULL) { 84 | 85 | fprintf(stderr, "Can't open file!\n"); 86 | exit(EXIT_FAILURE); 87 | 88 | } 89 | 90 | fseek(file, 0, SEEK_END); 91 | l = ftell(file); 92 | 93 | fseek(file, 0, SEEK_SET); 94 | fread(memory + 0x100, 1, l, file); 95 | 96 | fclose(file); 97 | 98 | /* Give this CPU some RAM */ 99 | state.memory = memory; 100 | state.readbyte = readbyte; 101 | state.readword = readword; 102 | state.writeword = writeword; 103 | state.writebyte = writebyte; 104 | 105 | /* Patch memory of the program. Reset at 0x0000 is trapped by an OUT 106 | * which will stop emulation. CP/M bdos call 5 is trapped by an IN. See 107 | * Z80_INPUT_BYTE() and Z80_OUTPUT_BYTE() definitions in z80emu.h. 108 | */ 109 | 110 | memory[0] = 0xd3; /* OUT N, A */ 111 | memory[1] = 0x00; 112 | 113 | memory[5] = 0xdb; /* IN A, N */ 114 | memory[6] = 0x00; 115 | memory[7] = 0xc9; /* RET */ 116 | 117 | /* Emulate. */ 118 | 119 | Z80Reset(&state); 120 | state.pc = 0x100; 121 | total = 0.0; 122 | #ifndef EMSCRIPTEN 123 | stopped = 0; 124 | for ( ; ; ) { 125 | mainloop(); 126 | if(stopped == 1) 127 | break; 128 | } 129 | #else 130 | emscripten_set_main_loop(mainloop,0,1); 131 | #endif 132 | 133 | printf("\n%.0f cycle(s) emulated.\n" 134 | "For a Z80 running at %.2fMHz, " 135 | "that would be %d second(s) or %.2f hour(s).\n", 136 | total, 137 | Z80_CPU_SPEED / 1000000.0, 138 | (int) (total / Z80_CPU_SPEED), 139 | total / ((double) 3600 * Z80_CPU_SPEED)); 140 | } 141 | 142 | /* Emulate CP/M bdos call 5 functions 2 (output character on screen) and 9 143 | * (output $-terminated string to screen). 144 | */ 145 | 146 | void SystemCall (Z80_STATE *state) 147 | { 148 | if (state->registers.byte[Z80_C] == 2) 149 | 150 | printf("%c", state->registers.byte[Z80_E]); 151 | 152 | else if (state->registers.byte[Z80_C] == 9) { 153 | 154 | int i, c; 155 | 156 | for (i = state->registers.word[Z80_DE], c = 0; 157 | memory[i] != '$'; 158 | i++) { 159 | 160 | printf("%c", memory[i & 0xffff]); 161 | if (c++ > MAXIMUM_STRING_LENGTH) { 162 | 163 | fprintf(stderr, 164 | "String to print is too long!\n"); 165 | exit(EXIT_FAILURE); 166 | 167 | } 168 | 169 | } 170 | 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /src/cpu/z80emu/zextest.h: -------------------------------------------------------------------------------- 1 | /* zextest.h 2 | * Header for zextest example. 3 | * 4 | * Copyright (c) 2012 Lin Ke-Fong 5 | * 6 | * This program is free, do whatever you want with it. 7 | */ 8 | 9 | #ifndef __ZEXTEST_INCLUDED__ 10 | 11 | /* Additional Z80_STATE status flag to request emulation termination. */ 12 | 13 | #define FLAG_STOP_EMULATION (1 << 31) 14 | 15 | extern unsigned char memory[1 << 16]; 16 | 17 | extern void SystemCall (Z80_STATE *state); 18 | 19 | #define __ZEXTEST_INCLUDED__ 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/osdep/dummy.c: -------------------------------------------------------------------------------- 1 | /* dummy.c 2 | * 3 | * ZX Spectrum emulator 4 | * Copyright (c) 2016 MikeDX 5 | * 6 | * Cross platform ZX Spectrum emulator 7 | * 8 | * OSDEP file - DUMMY. 9 | */ 10 | #include "osdep.h" 11 | #include "zxem.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | ZX_main(argc, argv); 16 | return 0; 17 | } 18 | 19 | void OSD_Init(void) { 20 | printf("%s\n",__FUNCTION__); 21 | printf("Nothing to do\n"); 22 | } 23 | 24 | void OSD_Quit(void) { 25 | printf("%s\n",__FUNCTION__); 26 | } 27 | 28 | void OSD_SetVideoMode(int width, int height, int fullscreen) { 29 | printf("%s\n",__FUNCTION__); 30 | } 31 | 32 | void OSD_SetPalette(void) { 33 | printf("%s\n",__FUNCTION__); 34 | } 35 | 36 | void OSD_RenderScreen(void) { 37 | // printf("%s\n",__FUNCTION__); 38 | } 39 | 40 | void OSD_Input(void) { 41 | // printf("%s\n",__FUNCTION__); 42 | } 43 | -------------------------------------------------------------------------------- /src/osdep/osdep.h: -------------------------------------------------------------------------------- 1 | /* osdep.h 2 | * 3 | * ZX Spectrum emulator 4 | * Copyright (c) 2016 MikeDX 5 | * 6 | * Cross platform ZX Spectrum emulator 7 | * 8 | * A new port must supply these functions in order to operate 9 | */ 10 | 11 | #ifndef _OSDEP_H_ 12 | #define _OSDEP_H_ 13 | 14 | int main(int argc, char *argv[]); 15 | 16 | void OSD_Init(void); 17 | void OSD_Quit(void); 18 | 19 | void OSD_SetVideoMode(int width, int height, int fullscreen); 20 | void OSD_SetPalette(void); 21 | void OSD_RenderScreen(void); 22 | 23 | void OSD_Input(void); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/osdep/sdl1.2.c: -------------------------------------------------------------------------------- 1 | /* sdl1.2.c 2 | * 3 | * ZX Spectrum emulator 4 | * Copyright (c) 2016 MikeDX 5 | * 6 | * Cross platform ZX Spectrum emulator 7 | * 8 | * OSDEP file for SDL1.2 9 | */ 10 | #include 11 | #include "osdep.h" 12 | #include "zxem.h" 13 | 14 | 15 | uint8_t OSD_Keys[2048]; 16 | 17 | void OSD_KeyInit(void) { 18 | OSD_Keys[SDLK_LSHIFT]=ZX_KEY_SHIFT; 19 | OSD_Keys[SDLK_z]=ZX_KEY_Z; 20 | OSD_Keys[SDLK_x]=ZX_KEY_X; 21 | OSD_Keys[SDLK_c]=ZX_KEY_C; 22 | OSD_Keys[SDLK_v]=ZX_KEY_V; 23 | 24 | OSD_Keys[SDLK_a]=ZX_KEY_A; 25 | OSD_Keys[SDLK_s]=ZX_KEY_S; 26 | OSD_Keys[SDLK_d]=ZX_KEY_D; 27 | OSD_Keys[SDLK_f]=ZX_KEY_F; 28 | OSD_Keys[SDLK_g]=ZX_KEY_G; 29 | 30 | OSD_Keys[SDLK_q]=ZX_KEY_Q; 31 | OSD_Keys[SDLK_w]=ZX_KEY_W; 32 | OSD_Keys[SDLK_e]=ZX_KEY_E; 33 | OSD_Keys[SDLK_r]=ZX_KEY_R; 34 | OSD_Keys[SDLK_t]=ZX_KEY_T; 35 | 36 | OSD_Keys[SDLK_1]=ZX_KEY_1; 37 | OSD_Keys[SDLK_2]=ZX_KEY_2; 38 | OSD_Keys[SDLK_3]=ZX_KEY_3; 39 | OSD_Keys[SDLK_4]=ZX_KEY_4; 40 | OSD_Keys[SDLK_5]=ZX_KEY_5; 41 | 42 | OSD_Keys[SDLK_0]=ZX_KEY_0; 43 | OSD_Keys[SDLK_9]=ZX_KEY_9; 44 | OSD_Keys[SDLK_8]=ZX_KEY_8; 45 | OSD_Keys[SDLK_7]=ZX_KEY_7; 46 | OSD_Keys[SDLK_6]=ZX_KEY_6; 47 | 48 | OSD_Keys[SDLK_p]=ZX_KEY_P; 49 | OSD_Keys[SDLK_o]=ZX_KEY_O; 50 | OSD_Keys[SDLK_i]=ZX_KEY_I; 51 | OSD_Keys[SDLK_u]=ZX_KEY_U; 52 | OSD_Keys[SDLK_y]=ZX_KEY_Y; 53 | 54 | OSD_Keys[SDLK_RETURN]=ZX_KEY_ENTER; 55 | OSD_Keys[SDLK_l]=ZX_KEY_L; 56 | OSD_Keys[SDLK_k]=ZX_KEY_K; 57 | OSD_Keys[SDLK_j]=ZX_KEY_J; 58 | OSD_Keys[SDLK_h]=ZX_KEY_H; 59 | 60 | OSD_Keys[SDLK_SPACE]=ZX_KEY_SPACE; 61 | OSD_Keys[SDLK_LCTRL]=ZX_KEY_SYM; 62 | OSD_Keys[SDLK_m]=ZX_KEY_M; 63 | OSD_Keys[SDLK_n]=ZX_KEY_N; 64 | OSD_Keys[SDLK_b]=ZX_KEY_B; 65 | 66 | } 67 | 68 | SDL_Surface *screen; 69 | 70 | // Define program entry point 71 | // Just calling ZX_main is enough for most 72 | 73 | int main(int argc, char *argv[]) 74 | { 75 | ZX_main(argc, argv); 76 | return 0; 77 | } 78 | 79 | void OSD_Init(void) { 80 | // Initialise SDL 1.2 81 | SDL_Init(SDL_INIT_EVERYTHING); 82 | 83 | // Setup keybindings 84 | OSD_KeyInit(); 85 | } 86 | 87 | void OSD_Quit(void) { 88 | // TODO - Destroy stuff 89 | SDL_FreeSurface(screen); 90 | SDL_Quit(); 91 | } 92 | 93 | void OSD_SetVideoMode(int width, int height, int fullscreen) { 94 | screen = SDL_SetVideoMode(width, height, 8, SDL_SWSURFACE); 95 | } 96 | 97 | void OSD_SetPalette(void) { 98 | // convert colours to SDL colours 99 | SDL_Colour osd_colours[16]; 100 | int x=0; 101 | while(x<16) { 102 | osd_colours[x].r = colours[x].r; 103 | osd_colours[x].g = colours[x].g; 104 | osd_colours[x].b = colours[x].b; 105 | x++; 106 | } 107 | 108 | SDL_SetPalette(screen,SDL_LOGPAL|SDL_PHYSPAL,osd_colours,0,16); 109 | } 110 | 111 | void OSD_RenderScreen(void) { 112 | int y; 113 | SDL_LockSurface(screen); 114 | uint8_t *pixels = (uint8_t*)screen->pixels; 115 | for(y=0;y<192;y++) { 116 | memcpy(pixels,&screenbuf[y*256],256); 117 | pixels+=screen->pitch; 118 | } 119 | SDL_UnlockSurface(screen); 120 | SDL_Flip(screen); 121 | } 122 | 123 | void OSD_Input(void) { 124 | SDL_Event event; 125 | int keysym; 126 | while(SDL_PollEvent(&event)) { 127 | switch(event.type) { 128 | case SDL_KEYDOWN: 129 | keysym = event.key.keysym.sym; 130 | indata[keyaddr[OSD_Keys[keysym]]]&=~keybuf[OSD_Keys[keysym]]; 131 | 132 | if(event.key.keysym.sym == SDLK_ESCAPE) { 133 | debug = 1; 134 | } 135 | if(event.key.keysym.sym == SDLK_TAB) { 136 | debug = 0; 137 | } 138 | 139 | break; 140 | 141 | case SDL_KEYUP: 142 | keysym = event.key.keysym.sym; 143 | indata[keyaddr[OSD_Keys[keysym]]]|=keybuf[OSD_Keys[keysym]]; 144 | break; 145 | 146 | case SDL_QUIT: 147 | running=0; 148 | } 149 | } 150 | return; 151 | 152 | } 153 | -------------------------------------------------------------------------------- /src/osdep/sdl2.c: -------------------------------------------------------------------------------- 1 | /* sdl1.2.c 2 | * 3 | * ZX Spectrum emulator 4 | * Copyright (c) 2016 MikeDX 5 | * 6 | * Cross platform ZX Spectrum emulator 7 | * 8 | * OSDEP file for SDL2 9 | */ 10 | #include 11 | #include "osdep.h" 12 | #include "zxem.h" 13 | 14 | 15 | SDL_Renderer* renderer=NULL; 16 | SDL_Window* window=NULL; 17 | SDL_Surface* buffer8=NULL; 18 | SDL_Surface* buffer32=NULL; 19 | SDL_Texture* texture=NULL; 20 | char windowtitle[1024]; 21 | uint8_t OSD_Keys[2048]; 22 | 23 | void OSD_KeyInit(void) { 24 | 25 | // TODO - use scancode instead of keycode? 26 | OSD_Keys[SDLK_LSHIFT-0x3FFFFD1A]=ZX_KEY_SHIFT; 27 | OSD_Keys[SDLK_z]=ZX_KEY_Z; 28 | OSD_Keys[SDLK_x]=ZX_KEY_X; 29 | OSD_Keys[SDLK_c]=ZX_KEY_C; 30 | OSD_Keys[SDLK_v]=ZX_KEY_V; 31 | 32 | OSD_Keys[SDLK_a]=ZX_KEY_A; 33 | OSD_Keys[SDLK_s]=ZX_KEY_S; 34 | OSD_Keys[SDLK_d]=ZX_KEY_D; 35 | OSD_Keys[SDLK_f]=ZX_KEY_F; 36 | OSD_Keys[SDLK_g]=ZX_KEY_G; 37 | 38 | OSD_Keys[SDLK_q]=ZX_KEY_Q; 39 | OSD_Keys[SDLK_w]=ZX_KEY_W; 40 | OSD_Keys[SDLK_e]=ZX_KEY_E; 41 | OSD_Keys[SDLK_r]=ZX_KEY_R; 42 | OSD_Keys[SDLK_t]=ZX_KEY_T; 43 | 44 | OSD_Keys[SDLK_1]=ZX_KEY_1; 45 | OSD_Keys[SDLK_2]=ZX_KEY_2; 46 | OSD_Keys[SDLK_3]=ZX_KEY_3; 47 | OSD_Keys[SDLK_4]=ZX_KEY_4; 48 | OSD_Keys[SDLK_5]=ZX_KEY_5; 49 | 50 | OSD_Keys[SDLK_0]=ZX_KEY_0; 51 | OSD_Keys[SDLK_9]=ZX_KEY_9; 52 | OSD_Keys[SDLK_8]=ZX_KEY_8; 53 | OSD_Keys[SDLK_7]=ZX_KEY_7; 54 | OSD_Keys[SDLK_6]=ZX_KEY_6; 55 | 56 | OSD_Keys[SDLK_p]=ZX_KEY_P; 57 | OSD_Keys[SDLK_o]=ZX_KEY_O; 58 | OSD_Keys[SDLK_i]=ZX_KEY_I; 59 | OSD_Keys[SDLK_u]=ZX_KEY_U; 60 | OSD_Keys[SDLK_y]=ZX_KEY_Y; 61 | 62 | OSD_Keys[SDLK_RETURN]=ZX_KEY_ENTER; 63 | OSD_Keys[SDLK_l]=ZX_KEY_L; 64 | OSD_Keys[SDLK_k]=ZX_KEY_K; 65 | OSD_Keys[SDLK_j]=ZX_KEY_J; 66 | OSD_Keys[SDLK_h]=ZX_KEY_H; 67 | 68 | OSD_Keys[SDLK_SPACE]=ZX_KEY_SPACE; 69 | OSD_Keys[SDLK_LCTRL-0x3FFFFD1A]=ZX_KEY_SYM; 70 | OSD_Keys[SDLK_m]=ZX_KEY_M; 71 | OSD_Keys[SDLK_n]=ZX_KEY_N; 72 | OSD_Keys[SDLK_b]=ZX_KEY_B; 73 | 74 | } 75 | // Define program entry point 76 | // Just calling ZX_main is enough for most 77 | int main(int argc, char *argv[]) 78 | { 79 | ZX_main(argc, argv); 80 | return 0; 81 | } 82 | 83 | void OSD_Init(void) { 84 | // Initialise SDL2 85 | SDL_Init(SDL_INIT_EVERYTHING); 86 | 87 | // Setup keybindings 88 | OSD_KeyInit(); 89 | } 90 | 91 | void OSD_Quit(void) { 92 | // free resources 93 | SDL_DestroyRenderer(renderer); 94 | SDL_DestroyWindow(window); 95 | SDL_DestroyTexture(texture); 96 | SDL_FreeSurface(buffer32); 97 | SDL_FreeSurface(buffer8); 98 | 99 | SDL_Quit(); 100 | } 101 | 102 | void OSD_SetVideoMode(int width, int height, int fullscreen) { 103 | uint32_t rmask, gmask, bmask, amask; 104 | 105 | /* SDL interprets each pixel as a 32-bit number, so our masks must depend 106 | on the endianness (byte order) of the machine */ 107 | #if SDL_BYTEORDER == SDL_BIG_ENDIAN 108 | rmask = 0xff000000; 109 | gmask = 0x00ff0000; 110 | bmask = 0x0000ff00; 111 | amask = 0x000000ff; 112 | #else 113 | rmask = 0x000000ff; 114 | gmask = 0x0000ff00; 115 | bmask = 0x00ff0000; 116 | amask = 0xff000000; 117 | #endif 118 | 119 | SDL_CreateWindowAndRenderer(width, height, SDL_WINDOW_RESIZABLE, 120 | &window, &renderer); 121 | 122 | buffer8 = SDL_CreateRGBSurface(0, width, height, 8, 123 | 0,0,0,0); 124 | 125 | buffer32 = SDL_CreateRGBSurface(0, width, height, 32, 126 | 0,0,0,0); 127 | 128 | texture = SDL_CreateTextureFromSurface(renderer, buffer32); 129 | 130 | return; 131 | 132 | } 133 | 134 | void OSD_SetPalette(void) { 135 | // convert colours to SDL colours 136 | SDL_Colour osd_colours[16]; 137 | int x=0; 138 | while(x<16) { 139 | osd_colours[x].r = colours[x].r; 140 | osd_colours[x].g = colours[x].g; 141 | osd_colours[x].b = colours[x].b; 142 | x++; 143 | } 144 | 145 | SDL_SetPaletteColors(buffer8->format->palette, osd_colours, 0, 16); 146 | 147 | } 148 | 149 | void OSD_RenderScreen(void) { 150 | int y; 151 | SDL_LockSurface(buffer8); 152 | uint8_t *pixels = (uint8_t*)buffer8->pixels; 153 | for(y=0;y<192;y++) { 154 | memcpy(pixels,&screenbuf[y*256],256); 155 | pixels+=buffer8->pitch; 156 | } 157 | SDL_UnlockSurface(buffer8); 158 | 159 | SDL_BlitSurface(buffer8, NULL, buffer32, NULL); 160 | 161 | /* Modify the texture's pixels */ 162 | SDL_UpdateTexture(texture, NULL, buffer32->pixels, buffer32->pitch); 163 | 164 | /* Make the modified texture visible by rendering it */ 165 | SDL_RenderCopy(renderer, texture, NULL, NULL); 166 | 167 | SDL_RenderPresent(renderer); 168 | } 169 | 170 | void OSD_Input(void) { 171 | SDL_Event event; 172 | int keysym; 173 | 174 | while(SDL_PollEvent(&event)) { 175 | switch(event.type) { 176 | case SDL_KEYDOWN: 177 | keysym = event.key.keysym.sym<2048?event.key.keysym.sym:event.key.keysym.sym-0x3FFFFD1A; 178 | indata[keyaddr[OSD_Keys[keysym]]]&=~keybuf[OSD_Keys[keysym]]; 179 | 180 | if(event.key.keysym.sym == SDLK_ESCAPE) { 181 | debug = 1; 182 | } 183 | if(event.key.keysym.sym == SDLK_TAB) { 184 | debug = 0; 185 | } 186 | 187 | break; 188 | case SDL_KEYUP: 189 | keysym = event.key.keysym.sym<2048?event.key.keysym.sym:event.key.keysym.sym-0x3FFFFD1A; 190 | indata[keyaddr[OSD_Keys[keysym]]]|=keybuf[OSD_Keys[keysym]]; 191 | 192 | break; 193 | 194 | case SDL_QUIT: 195 | running=0; 196 | } 197 | } 198 | return; 199 | 200 | } 201 | 202 | -------------------------------------------------------------------------------- /src/zxem/zxem.c: -------------------------------------------------------------------------------- 1 | /* zxem.c 2 | * 3 | * ZX Spectrum emulator 4 | * Copyright (c) 2016 MikeDX 5 | * 6 | * Cross platform ZX Spectrum emulator 7 | * 8 | */ 9 | 10 | #define GLOBALS 11 | #include "zxem.h" 12 | #ifdef EMSCRIPTEN 13 | #include 14 | #endif 15 | 16 | double total; 17 | int stopped; 18 | 19 | FILE *scrf; 20 | int scri=0; 21 | 22 | void scrloop(void) { 23 | if(!feof(scrf)) { 24 | fread(&zxmem[16384+scri],1,1,scrf); 25 | cached[16384+scri]=1; 26 | scri++; 27 | if(!(scri&0xF)) { 28 | ZX_Draw(); 29 | // return; 30 | } 31 | } 32 | } 33 | 34 | int ZX_LoadSCR(char *path) { 35 | FILE *f; 36 | int i = 0; 37 | int j = 16384; 38 | 39 | // fill screen with cross hatch 40 | memset(&zxmem[16384],0xAA,6144); 41 | for(i=0;i<12;i++) { 42 | memset(&zxmem[j],0xAA,256); 43 | memset(&zxmem[j+256],0x55,256); 44 | j+=512; 45 | } 46 | for (i=0;i<768;i++) { 47 | zxmem[j+i]=i&127; 48 | } 49 | while(running) { 50 | ZX_Input(); 51 | ZX_Draw(); 52 | } 53 | running = 1; 54 | // memset(&zxmem[j],199,768); 55 | memset(&cached[16384],1,6912); 56 | // for(i=0;i<10;i++) { 57 | // memset(&cached[16384],1,6912); 58 | // for(j=0;j<6912;j++) { 59 | // zxmem[16384+j]=rand()%256; 60 | // } 61 | // ZX_Draw(); 62 | // } 63 | // memset(&zxmem[16384+6144],rand()%256/*64+7*/,32*24); 64 | if(!(f=fopen(path,"r"))) { 65 | printf("Failed to open screen\n"); 66 | return -1; 67 | } 68 | scri=0; 69 | scrf=f; 70 | #ifndef EMSCRIPTEN 71 | while(!feof(f) && running) { 72 | scrloop(); 73 | ZX_Input(); 74 | } 75 | fclose(f); 76 | #else 77 | emscripten_set_main_loop(scrloop,0,1); 78 | #endif 79 | return 1; 80 | 81 | } 82 | int ZX_LoadROM(void) { 83 | /* Load ZX Spectrum ROM into lower 16K mem */ 84 | FILE *f; 85 | 86 | if(!(f=fopen("roms/48k.rom","r"))) { 87 | // if(!(f=fopen("roms/JGH.ROM","r"))) { 88 | printf("Failed to open ROM\n"); 89 | return -1; 90 | } 91 | 92 | fread(zxmem,1,16384,f); 93 | 94 | return 1; 95 | } 96 | 97 | void ZX_End(void) { 98 | free(zxmem); 99 | free(cached); 100 | free(screenbuf); 101 | OSD_Quit(); 102 | } 103 | 104 | /* Handle Interrupt - called before each screen render */ 105 | void ZX_Int(void) { 106 | CPU_Interrupt(CPU_Handle); 107 | } 108 | 109 | int next_total = 0; 110 | 111 | void mainloop(void) { 112 | if(!debug) { 113 | total += CPU_Emulate(CPU_Handle, next_total-total); 114 | } else { 115 | total += CPU_Emulate(CPU_Handle, 1); 116 | // printf("PC: 0x%04X\n",zxcpu.pc); 117 | } 118 | if(total>=next_total) { 119 | next_total +=CYCLES_PER_STEP; 120 | ZX_Input(); 121 | ZX_Int(); 122 | ZX_Draw(); 123 | } 124 | } 125 | 126 | int ZX_main(int argc, char *argv[]) 127 | { 128 | int i =0; 129 | 130 | OSD_Init(); 131 | ZX_KeyInit(); 132 | 133 | /* Create 8 bit buffer */ 134 | /* Spectrum screen is 32*8 by 24*8 */ 135 | 136 | OSD_SetVideoMode(256,192,0); 137 | 138 | zxmem = (uint8_t *)malloc(65536); 139 | cached = (uint8_t *)malloc(65536); 140 | screenbuf = (uint8_t *)malloc(256*192); 141 | 142 | // Create a z80 cpu instance 143 | CPU_Handle = CPU_Create(); 144 | 145 | if(!zxmem || !cached) { 146 | printf("Failed to allocate RAM\n"); 147 | ZX_End(); 148 | } 149 | 150 | // Clear main memory 151 | memset(zxmem,0,65535); 152 | 153 | // Clear cached memory 154 | memset(cached,1,65535); 155 | 156 | // Attempt to load spectrum ROM 157 | if(!ZX_LoadROM()) { 158 | ZX_End(); 159 | } 160 | 161 | ZX_SetPalette(); 162 | 163 | if(argc>1) { 164 | running = 1; 165 | i = 0; 166 | while(++i 13 | #include 14 | #include 15 | #include 16 | 17 | // macro for global vars 18 | #ifndef GLOBALS 19 | #define GLOBAL extern 20 | #else 21 | #define GLOBAL 22 | #endif 23 | 24 | // Platform specific 25 | #include "osdep.h" 26 | 27 | // CPU interface 28 | #include "cpuintf.h" 29 | 30 | // ZX IO interface 31 | #include "zxio.h" 32 | 33 | // ZX Video Hardware 34 | #include "zxvid.h" 35 | 36 | #define Z80_CPU_SPEED 3500000 /* In Hz. */ 37 | #define CYCLES_PER_STEP 69888 38 | //(Z80_CPU_SPEED / 50) 39 | 40 | 41 | GLOBAL uint8_t *screenbuf; 42 | 43 | GLOBAL uint8_t running; 44 | GLOBAL uint8_t debug; 45 | GLOBAL uint8_t CPU_Handle; 46 | 47 | // Main entry point 48 | int ZX_main(int argc, char *argv[]); 49 | 50 | #endif // include once 51 | -------------------------------------------------------------------------------- /src/zxem/zxio.c: -------------------------------------------------------------------------------- 1 | #include "zxem.h" 2 | 3 | 4 | // Keyboard routines 5 | // Verbose for no reason. 6 | 7 | 8 | uint8_t readbyte(uint16_t addr) { 9 | return zxmem[addr]; 10 | } 11 | 12 | uint16_t readword(uint16_t addr) { 13 | return zxmem[addr] | zxmem[addr+1]<<8; 14 | } 15 | 16 | void writebyte(uint16_t addr, uint8_t data) { 17 | 18 | /* Don't allow writing to ROM */ 19 | if(addr>0x3FFF) { 20 | //printf("Writing 0x%X to 0x%X\n",data,addr); 21 | zxmem[addr]=data; 22 | } 23 | cached[addr]=1; 24 | } 25 | 26 | 27 | void writeword(uint16_t addr, uint16_t data) { 28 | if(addr>=0x4000) { 29 | // printf("Writing 0x%X to 0x%X\n",data,addr); 30 | zxmem[addr]=data; 31 | zxmem[addr+1]=data>>8; 32 | } 33 | cached[addr]=1; 34 | cached[addr+1]=1; 35 | 36 | } 37 | 38 | uint8_t zx_data =0; 39 | /* TODO: Fix IN routine */ 40 | uint8_t input(uint16_t port) { 41 | uint8_t regb = CPU_GetReg(CPU_Handle,"B"); 42 | // printf("Reading %02X\n",regb); 43 | uint8_t data = zx_data; 44 | switch(regb) { 45 | case 0xFE: 46 | case 0xFD: 47 | case 0xFB: 48 | case 0xF7: 49 | case 0xEF: 50 | case 0xDF: 51 | case 0xBF: 52 | case 0x7F: 53 | data = indata[regb]; 54 | // printf("Indata: %d\n",indata[regb]); 55 | return data; 56 | break; 57 | default: 58 | printf("Reading port 0x%02x:%02x\n",regb,port); 59 | printf("PC: %04X %d\n",CPU_GetReg(CPU_Handle, "PC"), CPU_GetReg(CPU_Handle,"PC")); 60 | break; 61 | } 62 | 63 | data |= (0xe0); /* Set bits 5-7 - as reset above */ 64 | data &= ~0x40; 65 | return data; 66 | } 67 | 68 | void output(uint16_t port, uint8_t data) { 69 | // indata[zxcpu.registers.byte[Z80_B]]=data; 70 | // uint8_t data = 0xff; 71 | printf("OUT %02X %02X %02X\n",CPU_GetReg(CPU_Handle,"B"),port,data); 72 | // zxcpu.r=data; 73 | // indata[zxcpu.registers.byte[Z80_B]]=data; 74 | zx_data = data; 75 | 76 | } 77 | // Setup keyboard array 78 | 79 | void ZX_KeyInit(void) { 80 | 81 | // 0xFEFE 82 | keyaddr[ZX_KEY_SHIFT]=0xFE; 83 | keyaddr[ZX_KEY_Z]=0xFE; 84 | keyaddr[ZX_KEY_X]=0xFE; 85 | keyaddr[ZX_KEY_C]=0xFE; 86 | keyaddr[ZX_KEY_V]=0xFE; 87 | 88 | keybuf[ZX_KEY_SHIFT]=1; 89 | keybuf[ZX_KEY_Z]=2; 90 | keybuf[ZX_KEY_X]=4; 91 | keybuf[ZX_KEY_C]=8; 92 | keybuf[ZX_KEY_V]=16; 93 | 94 | // 0xFDFE 95 | keyaddr[ZX_KEY_A]=0xFD; 96 | keyaddr[ZX_KEY_S]=0xFD; 97 | keyaddr[ZX_KEY_D]=0xFD; 98 | keyaddr[ZX_KEY_F]=0xFD; 99 | keyaddr[ZX_KEY_G]=0xFD; 100 | 101 | keybuf[ZX_KEY_A]=1; 102 | keybuf[ZX_KEY_S]=2; 103 | keybuf[ZX_KEY_D]=4; 104 | keybuf[ZX_KEY_F]=8; 105 | keybuf[ZX_KEY_G]=16; 106 | 107 | // 0xFBFE 108 | keyaddr[ZX_KEY_Q]=0xFB; 109 | keyaddr[ZX_KEY_W]=0xFB; 110 | keyaddr[ZX_KEY_E]=0xFB; 111 | keyaddr[ZX_KEY_R]=0xFB; 112 | keyaddr[ZX_KEY_T]=0xFB; 113 | 114 | keybuf[ZX_KEY_Q]=1; 115 | keybuf[ZX_KEY_W]=2; 116 | keybuf[ZX_KEY_E]=4; 117 | keybuf[ZX_KEY_R]=8; 118 | keybuf[ZX_KEY_T]=16; 119 | 120 | // 0xF7FE 121 | keyaddr[ZX_KEY_1]=0xF7; 122 | keyaddr[ZX_KEY_2]=0xF7; 123 | keyaddr[ZX_KEY_3]=0xF7; 124 | keyaddr[ZX_KEY_4]=0xF7; 125 | keyaddr[ZX_KEY_5]=0xF7; 126 | 127 | keybuf[ZX_KEY_1]=1; 128 | keybuf[ZX_KEY_2]=2; 129 | keybuf[ZX_KEY_3]=4; 130 | keybuf[ZX_KEY_4]=8; 131 | keybuf[ZX_KEY_5]=16; 132 | 133 | // 0xEFFE 134 | keyaddr[ZX_KEY_0]=0xEF; 135 | keyaddr[ZX_KEY_9]=0xEF; 136 | keyaddr[ZX_KEY_8]=0xEF; 137 | keyaddr[ZX_KEY_7]=0xEF; 138 | keyaddr[ZX_KEY_6]=0xEF; 139 | 140 | keybuf[ZX_KEY_0]=1; 141 | keybuf[ZX_KEY_9]=2; 142 | keybuf[ZX_KEY_8]=4; 143 | keybuf[ZX_KEY_7]=8; 144 | keybuf[ZX_KEY_6]=16; 145 | 146 | // 0xDFFE 147 | keyaddr[ZX_KEY_P]=0xDF; 148 | keyaddr[ZX_KEY_O]=0xDF; 149 | keyaddr[ZX_KEY_I]=0xDF; 150 | keyaddr[ZX_KEY_U]=0xDF; 151 | keyaddr[ZX_KEY_Y]=0xDF; 152 | 153 | keybuf[ZX_KEY_P]=1; 154 | keybuf[ZX_KEY_O]=2; 155 | keybuf[ZX_KEY_I]=4; 156 | keybuf[ZX_KEY_U]=8; 157 | keybuf[ZX_KEY_Y]=16; 158 | 159 | // 0xBFFE 160 | keyaddr[ZX_KEY_ENTER]=0xBF; 161 | keyaddr[ZX_KEY_L]=0xBF; 162 | keyaddr[ZX_KEY_K]=0xBF; 163 | keyaddr[ZX_KEY_J]=0xBF; 164 | keyaddr[ZX_KEY_H]=0xBF; 165 | 166 | keybuf[ZX_KEY_ENTER]=1; 167 | keybuf[ZX_KEY_L]=2; 168 | keybuf[ZX_KEY_K]=4; 169 | keybuf[ZX_KEY_J]=8; 170 | keybuf[ZX_KEY_H]=16; 171 | 172 | // 0x7FFE 173 | keyaddr[ZX_KEY_SPACE]=0x7F; 174 | keyaddr[ZX_KEY_SYM]=0x7F; 175 | keyaddr[ZX_KEY_M]=0x7F; 176 | keyaddr[ZX_KEY_N]=0x7F; 177 | keyaddr[ZX_KEY_B]=0x7F; 178 | 179 | keybuf[ZX_KEY_SPACE]=1; 180 | keybuf[ZX_KEY_SYM]=2; 181 | keybuf[ZX_KEY_M]=4; 182 | keybuf[ZX_KEY_N]=8; 183 | keybuf[ZX_KEY_B]=16; 184 | 185 | memset(indata,255,255); 186 | } 187 | 188 | 189 | void ZX_Input(void) { 190 | OSD_Input(); 191 | } 192 | 193 | -------------------------------------------------------------------------------- /src/zxem/zxio.h: -------------------------------------------------------------------------------- 1 | /* zxio.h 2 | 3 | */ 4 | 5 | #ifndef _ZXIO_H_ 6 | #define _ZXIO_H_ 7 | 8 | GLOBAL uint8_t *zxmem; 9 | GLOBAL uint8_t *cached; 10 | 11 | enum { 12 | ZX_KEY_SHIFT = 1, 13 | ZX_KEY_Z, 14 | ZX_KEY_X, 15 | ZX_KEY_C, 16 | ZX_KEY_V, 17 | 18 | ZX_KEY_A, 19 | ZX_KEY_S, 20 | ZX_KEY_D, 21 | ZX_KEY_F, 22 | ZX_KEY_G, 23 | 24 | ZX_KEY_Q, 25 | ZX_KEY_W, 26 | ZX_KEY_E, 27 | ZX_KEY_R, 28 | ZX_KEY_T, 29 | 30 | ZX_KEY_1, 31 | ZX_KEY_2, 32 | ZX_KEY_3, 33 | ZX_KEY_4, 34 | ZX_KEY_5, 35 | 36 | ZX_KEY_0, 37 | ZX_KEY_9, 38 | ZX_KEY_8, 39 | ZX_KEY_7, 40 | ZX_KEY_6, 41 | 42 | ZX_KEY_P, 43 | ZX_KEY_O, 44 | ZX_KEY_I, 45 | ZX_KEY_U, 46 | ZX_KEY_Y, 47 | 48 | ZX_KEY_ENTER, 49 | ZX_KEY_L, 50 | ZX_KEY_K, 51 | ZX_KEY_J, 52 | ZX_KEY_H, 53 | 54 | ZX_KEY_SPACE, 55 | ZX_KEY_SYM, 56 | ZX_KEY_M, 57 | ZX_KEY_N, 58 | ZX_KEY_B, 59 | 60 | ZX_KEY_LAST 61 | 62 | }; 63 | 64 | GLOBAL uint8_t indata[255]; 65 | GLOBAL uint8_t keyaddr[ZX_KEY_LAST]; 66 | GLOBAL uint8_t keybuf[ZX_KEY_LAST]; 67 | 68 | // ZX IO functions (zxio.c) 69 | // memory calls 70 | 71 | // memory handling 72 | uint8_t readbyte(uint16_t addr); 73 | uint16_t readword(uint16_t addr); 74 | void writebyte(uint16_t addr, uint8_t data); 75 | void writeword(uint16_t addr, uint16_t data); 76 | 77 | // IO 78 | uint8_t input(uint16_t port); 79 | void output(uint16_t port, uint8_t data); 80 | 81 | // Keyboard handling 82 | void ZX_KeyInit(void); 83 | void ZX_Input(void); 84 | 85 | #endif 86 | 87 | -------------------------------------------------------------------------------- /src/zxem/zxvid.c: -------------------------------------------------------------------------------- 1 | /* zxvid.c 2 | * 3 | * ZX Spectrum emulator 4 | * Copyright (c) 2016 MikeDX 5 | * 6 | * Cross platform ZX Spectrum emulator 7 | * 8 | * Video handling routines. 9 | */ 10 | 11 | #include "zxem.h" 12 | 13 | int ZX_SetPalette(void) { 14 | 15 | // colour table lookup 16 | uint8_t lookup[]={0,0,0, 0,0,1, 1,0,0, 1,0,1, 0,1,0, 0,1,1, 1,1,0, 1,1,1}; 17 | 18 | // Brightness. 0xD7 for normal and 0xFF for bright 19 | uint8_t bright[]={0xD7, 0xFF}; 20 | 21 | int i; 22 | int b; 23 | 24 | // bright and normal 25 | for(b=0;b<2;b++) { 26 | // 8 colours in each set 27 | for(i=0;i<8;i++) { 28 | // set rgb of each colour from lookup 29 | colours[i+b*8].r=lookup[i*3]*bright[b]; 30 | colours[i+b*8].g=lookup[i*3+1]*bright[b]; 31 | colours[i+b*8].b=lookup[i*3+2]*bright[b]; 32 | } 33 | } 34 | 35 | OSD_SetPalette(); 36 | 37 | return 1; 38 | 39 | } 40 | 41 | // TODO: 42 | // Updated video buffer on scaline beam 43 | 44 | void ZX_Draw(void) { 45 | /* Draw the screen */ 46 | static uint8_t flash_flip = 0; 47 | static uint8_t flash_count = 0; 48 | int x=0,y=0; 49 | int i=0; 50 | int j=0; 51 | uint8_t yp=0; 52 | 53 | uint8_t ink = 0; 54 | uint8_t paper = 0; 55 | uint8_t flash = 0; 56 | uint8_t bright = 0; 57 | uint8_t attrib = 0; 58 | 59 | uint16_t buf_addr = 0; 60 | uint16_t pixel_addr = 0; 61 | uint16_t attrib_addr = 0; 62 | 63 | uint8_t pix; 64 | 65 | attrib_addr = 16384+6144; 66 | // Each byte in spectrum memory draws 8 pixels 67 | // with an additional byte for attributes of each 8x8 pixel block. 68 | 69 | // Draw all rows 0 - 23 70 | for(y=0; y<24;y++) { 71 | 72 | // yp is y in pixels 73 | yp=y*8; 74 | 75 | // Calculate pixel address offset from the x/y 8x8 block we want to draw. 76 | pixel_addr = ((yp>>3)<<5)&0xFF; 77 | pixel_addr += ((yp&0x7)+(((yp>>6)&0x3)<<3))<<8; 78 | 79 | pixel_addr +=16384; // Start of screen memory 80 | 81 | // Draw each 8x8 block 0 - 31 82 | for ( x=0;x<32;x++ ) { 83 | 84 | // Buf Addr is the first pixel we want to draw on 85 | buf_addr = (y*8)*256+x*8; 86 | 87 | // Get Attribute 88 | attrib = zxmem[attrib_addr]; 89 | 90 | // Lower 3 bits are ink 91 | ink = attrib & 0x7; 92 | 93 | // bits 5-3 are paper 94 | paper = (attrib >> 3) &0x7; 95 | 96 | // bit 6 is brightness 97 | bright = (attrib >>6) & 0x1; 98 | 99 | if(bright) { 100 | ink+=8; 101 | paper+=8; 102 | } 103 | 104 | // bit 7 is flash 105 | 106 | // TODO - which is faster? 107 | // flash = (attrib >> 7); 108 | // flash = (attrib > 63); 109 | flash = (attrib & 0x80); 110 | 111 | if(flash && flash_flip) { 112 | // XOR trick for swapping ink / paper 113 | paper = paper ^ ink; 114 | ink = paper ^ ink; 115 | paper = paper ^ ink; 116 | } 117 | 118 | for(j=0;j<8;j++) { 119 | 120 | if(flash || cached[attrib_addr] || cached[pixel_addr+j*256]) { 121 | 122 | // Read spectrum ram where pixel data lives 123 | pix = zxmem[pixel_addr+j*256]; 124 | 125 | // plot each pixel as ink or paper 126 | for(i=7;i>=0;i--) { 127 | screenbuf[buf_addr]=(pix&1<16) { 151 | flash_flip = !flash_flip; 152 | flash_count = 0; 153 | } 154 | 155 | // Draw the screen 156 | OSD_RenderScreen(); 157 | } 158 | 159 | -------------------------------------------------------------------------------- /src/zxem/zxvid.h: -------------------------------------------------------------------------------- 1 | /* zxvid.h 2 | * 3 | * ZX Video Header file 4 | * 5 | */ 6 | 7 | #ifndef _ZXVID_H_ 8 | #define _ZXVID_H_ 9 | 10 | // Spectrum colours 11 | typedef struct _ZX_Pen { 12 | uint8_t r; 13 | uint8_t g; 14 | uint8_t b; 15 | } ZX_Pen; 16 | 17 | GLOBAL ZX_Pen colours[16]; 18 | 19 | int ZX_SetPalette(void); 20 | void ZX_Draw(void); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /testfiles/zexall.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeDX/z80emu/84db5e74d30464f09cbff610aee22ef98add7101/testfiles/zexall.com -------------------------------------------------------------------------------- /testfiles/zexdoc.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeDX/z80emu/84db5e74d30464f09cbff610aee22ef98add7101/testfiles/zexdoc.com -------------------------------------------------------------------------------- /tests/cputest.c: -------------------------------------------------------------------------------- 1 | // ZXTEST 2 | 3 | #include "../src/cpu/z80emu/z80emu.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | uint8_t *zxmem; 10 | 11 | Z80_STATE zxcpu; 12 | uint8_t writes[65536]; 13 | uint8_t reads[65536]; 14 | 15 | int total, running, debug; 16 | 17 | uint8_t readbyte(uint16_t addr) { 18 | // printf("Reading 0x%X\n",addr); 19 | printf("%4d MR %04X %2X\n",zxcpu.elapsed_cycles, addr, zxmem[addr]); 20 | 21 | // printf("Reads:\n"); 22 | // for(i=0;i<65535;i++) { 23 | // if(reads[i]>0) { 24 | // printf("MR %04X %d %02X\n",i,reads[i],zxmem[i]); 25 | // } 26 | // if(writes[i]>0) { 27 | // printf("MW %04X %d %02X\n",i,writes[i],zxmem[i]); 28 | // } 29 | // } 30 | 31 | reads[addr]++; 32 | return zxmem[addr]; 33 | } 34 | 35 | uint16_t readword(uint16_t addr) { 36 | // printf("Reading 0x%X\n",addr); 37 | printf("%4d MR %04X %02X\n",zxcpu.elapsed_cycles, addr+1, zxmem[addr+1]); 38 | printf("%4d MR %04X %02X\n",zxcpu.elapsed_cycles, addr, zxmem[addr]); 39 | reads[addr]++; 40 | reads[addr+1]++; 41 | return zxmem[addr] | zxmem[addr+1]<<8; 42 | } 43 | 44 | void writebyte(uint16_t addr, uint8_t data) { 45 | 46 | printf("%4d MW %04X %02X\n",zxcpu.elapsed_cycles, addr, data); 47 | 48 | /* Don't allow writing to ROM */ 49 | // if(addr>0x3FFF) { 50 | //printf("Writing 0x%X to 0x%X\n",data,addr); 51 | zxmem[addr]=data; 52 | writes[addr]++; 53 | // } 54 | //cached[addr]=1; 55 | } 56 | 57 | 58 | void writeword(uint16_t addr, uint16_t data) { 59 | printf("%4d MW %04X %02X\n",zxcpu.elapsed_cycles, addr+1, data>>8); 60 | printf("%4d MW %04X %02X\n",zxcpu.elapsed_cycles, addr, data&0x00FF); 61 | 62 | // if(addr>=0x4000) { 63 | // printf("Writing 0x%X to 0x%X\n",data,addr); 64 | zxmem[addr]=data; 65 | writes[addr]++; 66 | 67 | zxmem[addr+1]=data>>8; 68 | writes[addr+1]++; 69 | // } 70 | 71 | // cached[addr]=1; 72 | // cached[addr+1]=1; 73 | 74 | } 75 | 76 | uint8_t zx_data =0; 77 | /* TODO: Fix IN routine */ 78 | uint8_t input(uint16_t port) { 79 | /* uint8_t regb = zxcpu.registers.byte[Z80_B]; 80 | uint8_t data = zx_data; 81 | switch(regb) { 82 | case 0xFE: 83 | case 0xFD: 84 | case 0xFB: 85 | case 0xF7: 86 | case 0xEF: 87 | case 0xDF: 88 | case 0xBF: 89 | case 0x7F: 90 | data = indata[regb]; 91 | return data; 92 | break; 93 | default: 94 | printf("Reading port 0x%02x:%02x\n",regb,port); 95 | printf("PC: %04X %d\n",zxcpu.pc, zxcpu.pc); 96 | break; 97 | } 98 | 99 | data |= (0xe0); // Set bits 5-7 - as reset above 100 | // data &= ~0x40; 101 | // default 102 | 103 | */ 104 | return 255;//data;//indata[regb]; 105 | //zx_data; 106 | 107 | } 108 | 109 | void output(uint16_t port, uint8_t data) { 110 | // indata[zxcpu.registers.byte[Z80_B]]=data; 111 | // uint8_t data = 0xff; 112 | printf("OUT %02X %02X %02X\n",zxcpu.registers.byte[Z80_B],port,data); 113 | // zxcpu.r=data; 114 | // indata[zxcpu.registers.byte[Z80_B]]=data; 115 | // zx_data = data; 116 | 117 | } 118 | int main(int argc, char *argv[]) { 119 | FILE *in; 120 | FILE *out; 121 | char testid[255];//= 0; 122 | char testide[255]; 123 | int AF,BC,DE,HL,AF2,BC2,DE2,HL2,IX,IY,SP,PC; 124 | int I, R, IFF1, IFF2, IM, halted, tstates, etstates; 125 | int addr; 126 | int data; 127 | int i; 128 | // 00 00 0 0 0 0 1 129 | zxmem = (uint8_t*)malloc(65535); 130 | memset(zxmem,0,65535); 131 | 132 | zxcpu.im = Z80_INTERRUPT_MODE_0; 133 | zxcpu.memory = zxmem; 134 | zxcpu.readbyte = readbyte; 135 | zxcpu.readword = readword; 136 | zxcpu.writeword = writeword; 137 | zxcpu.writebyte = writebyte; 138 | zxcpu.input = input; 139 | zxcpu.output = output; 140 | total = 0; 141 | running = 1; 142 | debug = 0; 143 | 144 | in = fopen("tests.in","r"); 145 | 146 | out = fopen("tests.expected","r"); 147 | 148 | if(!in) { 149 | printf("Cannot open tests input file\n"); 150 | } 151 | 152 | while(!feof(in)) { 153 | // if(1) { 154 | memset(testid,0,255); 155 | memset(testide,0,255); 156 | 157 | memset(zxmem,0,65535); 158 | fscanf(in,"%s\n",testid); 159 | // printf("TEST ID: %s\n",testid); 160 | 161 | fscanf(in,"%x %x %x %x %x %x %x %x %x %x %x %x\n",&AF,&BC,&DE,&HL,&AF2,&BC2,&DE2,&HL2,&IX,&IY,&SP,&PC); 162 | 163 | fscanf(in,"%x %x %x %x %x %x %d\n",&I, &R, &IFF1, &IFF2, &IM, &halted, &tstates); 164 | 165 | while(1) { 166 | fscanf(in,"%x ", &addr); 167 | if(addr==-1) { 168 | break; 169 | } 170 | while(1) { 171 | fscanf(in,"%x ", &data); 172 | if(data==-1) { 173 | break; 174 | } 175 | // printf("%d %d\n",addr,data); 176 | zxmem[addr]=data; 177 | addr++; 178 | } 179 | } 180 | // RUN TEST 181 | 182 | Z80Reset(&zxcpu); 183 | 184 | zxcpu.registers.word[Z80_AF]=AF; 185 | zxcpu.alternates[Z80_AF]=AF2; 186 | zxcpu.registers.word[Z80_BC]=BC; 187 | zxcpu.alternates[Z80_BC]=BC2; 188 | zxcpu.registers.word[Z80_DE]=DE; 189 | zxcpu.alternates[Z80_DE]=DE2; 190 | zxcpu.registers.word[Z80_HL]=HL; 191 | zxcpu.alternates[Z80_HL]=HL2; 192 | 193 | zxcpu.registers.word[Z80_IX]=IX; 194 | zxcpu.registers.word[Z80_IY]=IY; 195 | 196 | zxcpu.registers.word[Z80_SP] = SP; 197 | zxcpu.pc = PC; 198 | zxcpu.elapsed_cycles = 0; 199 | 200 | zxcpu.i = I; 201 | memset(reads,0,65535); 202 | memset(writes,0,65535); 203 | 204 | tstates = Z80Emulate(&zxcpu, tstates); 205 | 206 | for(i=0;i<65535;i++) { 207 | // if(reads[i]>0) { 208 | // printf("MR %04X %d %02X\n",i,reads[i],zxmem[i]); 209 | // } 210 | if(writes[i]>0) { 211 | printf("%04X %02X\n",i,zxmem[i]); 212 | } 213 | } 214 | 215 | fscanf(out,"%s",testide); 216 | printf("TEST ID: [%s] [%s]\n",testid, testide); 217 | while(!feof(out)) { 218 | memset(testid,0,255); 219 | fgets(testid,255,out); 220 | // printf("%d, [%s]\n",testid[0],testid); 221 | if(testid[0]!=32 && testid[0]!=10) { 222 | fseek(out,-strlen(testid),SEEK_CUR); 223 | break; 224 | } 225 | } 226 | // fgets(testid,255,out); 227 | // printf("FIRST LINE: [%s]\n",testid); 228 | 229 | fscanf(out,"%x %x %x %x %x %x %x %x %x %x %x %x\n",&AF,&BC,&DE,&HL,&AF2,&BC2,&DE2,&HL2,&IX,&IY,&SP,&PC); 230 | 231 | // fscanf(out,"%x %x %x %x %x %x %x\n",&I, &R, &IFF1, &IFF2, &IM, &halted, &etstates); 232 | fscanf(out,"%x %x %x %x %x %d\n",&I, &R, &IFF1, &IFF2, &IM, &etstates); 233 | 234 | while(1) { 235 | fgets(testid,255,out); 236 | if(testid[0]=='\n') { 237 | break; 238 | } 239 | } 240 | if ( 241 | zxcpu.registers.word[Z80_AF]==AF && 242 | zxcpu.alternates[Z80_AF]==AF2 && 243 | zxcpu.registers.word[Z80_BC]==BC && 244 | zxcpu.alternates[Z80_BC]==BC2 && 245 | zxcpu.registers.word[Z80_DE]==DE && 246 | zxcpu.alternates[Z80_DE]==DE2 && 247 | zxcpu.registers.word[Z80_HL]==HL && 248 | zxcpu.alternates[Z80_HL]==HL2 && 249 | 250 | zxcpu.registers.word[Z80_IX]==IX && 251 | zxcpu.registers.word[Z80_IY]==IY && 252 | 253 | zxcpu.registers.word[Z80_SP] == SP && 254 | zxcpu.pc == PC 255 | ) { 256 | printf("PASSED\n"); 257 | } else { 258 | printf("FAILED\n"); 259 | printf("AF: %04X : %04X\n", zxcpu.registers.word[Z80_AF],AF); 260 | printf("AF': %04X : %04X\n", zxcpu.alternates[Z80_AF],AF2); 261 | printf("BC: %04X : %04X\n", zxcpu.registers.word[Z80_BC],BC); 262 | printf("BC': %04X : %04X\n", zxcpu.alternates[Z80_BC],BC2); 263 | printf("DE: %04X : %04X\n", zxcpu.registers.word[Z80_DE],DE); 264 | printf("DE': %04X : %04X\n", zxcpu.alternates[Z80_DE],DE2); 265 | printf("HL: %04X : %04X\n", zxcpu.registers.word[Z80_HL],HL); 266 | printf("HL': %04X : %04X\n", zxcpu.alternates[Z80_HL],HL2); 267 | 268 | printf("IX: %04X : %04X\n", zxcpu.registers.word[Z80_IX],IX); 269 | printf("IY: %04X : %04X\n", zxcpu.registers.word[Z80_IY],IY); 270 | printf("SP: %04X : %04X\n", zxcpu.registers.word[Z80_SP],SP); 271 | 272 | printf("PC: %04X : %04X\n", zxcpu.pc, PC); 273 | 274 | printf("TSTATES: %d : %d\n", etstates, tstates); 275 | 276 | break; 277 | } 278 | } 279 | fclose(in); 280 | fclose(out); 281 | printf("DONE\n"); 282 | 283 | free(zxmem); 284 | return 0; 285 | 286 | } 287 | --------------------------------------------------------------------------------