deepstone
changeset 35:1870c4ef8b76
added visual studio project
moved the dosemu directory
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 23 Sep 2013 07:41:05 +0300 |
parents | c6406e4aa0fb |
children | e234f2a4b6fa |
files | .hgignore GNUmakefile README deepstone.sln deepstone.vcproj dosemu/conio.h dosemu/dosemu.c src/dosemu/conio.h src/dosemu/dosemu.c src/inttypes.h src/palman.c |
diffstat | 11 files changed, 732 insertions(+), 358 deletions(-) [+] |
line diff
1.1 --- a/.hgignore Mon Sep 23 05:58:24 2013 +0300 1.2 +++ b/.hgignore Mon Sep 23 07:41:05 2013 +0300 1.3 @@ -7,3 +7,10 @@ 1.4 \.exe$ 1.5 \.EXE$ 1.6 ^OBJECTS.LNK$ 1.7 +\.suo$ 1.8 +\.ncb$ 1.9 +\.user$ 1.10 +\.dll$ 1.11 +Debug/ 1.12 +Release/ 1.13 +dosbox/
2.1 --- a/GNUmakefile Mon Sep 23 05:58:24 2013 +0300 2.2 +++ b/GNUmakefile Mon Sep 23 07:41:05 2013 +0300 2.3 @@ -2,13 +2,18 @@ 2.4 src/mingl.o src/mglrast.o src/mglclip.o src/mglgen.o \ 2.5 src/texture.o src/palman.o \ 2.6 src/scene.o src/cvec.o src/fixedp.o \ 2.7 - dosemu/dosemu.o 2.8 + src/dosemu/dosemu.o 2.9 dep = $(obj:.o=.d) 2.10 bin = deepstone 2.11 2.12 +dbg = -g 2.13 +#opt = -O3 -ffast-math 2.14 + 2.15 CC = gcc 2.16 -CFLAGS = -pedantic -Wall -g `pkg-config --cflags sdl` -Isrc -Idosemu $(add_cflags) -DRAST_FLOAT -DDBG_USE_FLOAT 2.17 +CFLAGS = -pedantic -Wall $(dbg) $(opt) `pkg-config --cflags sdl` -Isrc -Idosemu $(add_cflags) -DRAST_FLOAT -DDBG_USE_FLOAT 2.18 LDFLAGS = `pkg-config --libs sdl` -lm 2.19 +#LDFLAGS = -Llib64 -Wl,-rpath=./lib64 -lSDL -lm 2.20 +#LDFLAGS = -m32 -Llib32 -Wl,-rpath=./lib32 -lSDL-1.2 -lm 2.21 2.22 ifeq ($(shell uname -s), Darwin) 2.23 add_cflags = -Dmain=SDL_main
3.1 --- a/README Mon Sep 23 05:58:24 2013 +0300 3.2 +++ b/README Mon Sep 23 07:41:05 2013 +0300 3.3 @@ -1,17 +1,62 @@ 3.4 -A short trip back in time in the days of 16bit graphics programming for MS-DOS 3.5 -in VGA mode 13h. 3.6 +Deepstone (unfinished) 3.7 +---------------------- 3.8 +This would/will be a dungeon crawler if I ever finish it. 3.9 3.10 -Copyright (C) 2011 John Tsiombikas <nuclear@member.fsf.org> 3.11 +Copyright (C) 2013 John Tsiombikas <nuclear@member.fsf.org> 3.12 Feel free to use, modify and redistribute this code under the terms of the GNU 3.13 General Public License version 3 (or at your option any later version published 3.14 by the free software foundation). See COPYING for details. 3.15 3.16 -interesting source code files: 3.17 -- mingl.c: quick & dirty 256-color renderer with a vaguely GL-like interface. 3.18 -- vga.c: denthoresque vga mode 13h driver. 3.19 -- timer.c: DOS timer and 8254 code. 3.20 +Usage 3.21 +----- 3.22 +Just start it, walk around with WASD and look around by moving the mouse. 3.23 +Nothing else to do at the moment :) 3.24 3.25 -To compile this you need Borland C, any version should do. Just type make. 3.26 +Precompiled binaries included in the archive: 3.27 + * deepston.exe MS-DOS version (32bit, requires included dos4gw.exe) 3.28 + * deepstone-win32.exe 32bit Windows version 3.29 + * deepstone-linux32 32bit GNU/Linux version 3.30 + * deepstone-linux64 64bit GNU/Linux version 3.31 3.32 -Special thanks to the vim project for providing a DOS version of vim, without it 3.33 -this would be much less enjoyable. 3.34 +The GNU/Linux binaries require libSDL which depends on a shitload of libraries 3.35 +on my system, so you probably won't be able to run it without first installing 3.36 +all the dependencies. It might be easier to just compile it yourself, just type 3.37 +make and run ./deepstone 3.38 + 3.39 +Running with DOSBOX 3.40 +------------------- 3.41 +I've included a dosbox.conf which automatically runs the "game", as well as a 3.42 +copy of dosbox.exe for windows. So just change into the dosbox/ subdirectory and 3.43 +run dosbox. 3.44 +NOTE: you might need to click in the dosbox window first before you can use 3.45 +mouse control. 3.46 + 3.47 +Running on actual MS-DOS 3.48 +------------------------ 3.49 +Just copy deepston.exe, dos4gw.exe and the data directory to your DOS machine, 3.50 +and run it. The mouse driver must be installed first! (mouse.com or whatever). 3.51 + 3.52 +Build on MS-DOS 3.53 +--------------- 3.54 + * You need the Watcom 32bit compiler and assorted utilities. 3.55 + * Type make 3.56 + * Profit (run deepston.exe) 3.57 + 3.58 +Build on GNU/Linux 3.59 +------------------ 3.60 + * Install SDL (libsdl-1.2-dev or whatever). 3.61 + * Type make 3.62 + * Profit (run ./deepstone) 3.63 + 3.64 +Build on MS-Windows 3.65 +------------------- 3.66 + * Install SDL 3.67 + * Open deepstone.sln with visual studio >= 2008 3.68 + * Make sure visual studio knows where to find your copy of SDL (so configure 3.69 + include and library paths... ugh, windows programming.. icky). 3.70 + * Press build solution or whatever it's called this way. 3.71 + * Profit (find the bloody thing and run it, or click the happy little play button). 3.72 + 3.73 +Contact 3.74 +------- 3.75 +Feel free to tell me how much I rule, by sending email to nuclear@member.fsf.org
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/deepstone.sln Mon Sep 23 07:41:05 2013 +0300 4.3 @@ -0,0 +1,20 @@ 4.4 + 4.5 +Microsoft Visual Studio Solution File, Format Version 10.00 4.6 +# Visual Studio 2008 4.7 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "deepstone", "deepstone.vcproj", "{7CBC96FF-B324-4904-9FD5-A95075F292BB}" 4.8 +EndProject 4.9 +Global 4.10 + GlobalSection(SolutionConfigurationPlatforms) = preSolution 4.11 + Debug|Win32 = Debug|Win32 4.12 + Release|Win32 = Release|Win32 4.13 + EndGlobalSection 4.14 + GlobalSection(ProjectConfigurationPlatforms) = postSolution 4.15 + {7CBC96FF-B324-4904-9FD5-A95075F292BB}.Debug|Win32.ActiveCfg = Debug|Win32 4.16 + {7CBC96FF-B324-4904-9FD5-A95075F292BB}.Debug|Win32.Build.0 = Debug|Win32 4.17 + {7CBC96FF-B324-4904-9FD5-A95075F292BB}.Release|Win32.ActiveCfg = Release|Win32 4.18 + {7CBC96FF-B324-4904-9FD5-A95075F292BB}.Release|Win32.Build.0 = Release|Win32 4.19 + EndGlobalSection 4.20 + GlobalSection(SolutionProperties) = preSolution 4.21 + HideSolutionNode = FALSE 4.22 + EndGlobalSection 4.23 +EndGlobal
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/deepstone.vcproj Mon Sep 23 07:41:05 2013 +0300 5.3 @@ -0,0 +1,291 @@ 5.4 +<?xml version="1.0" encoding="windows-1253"?> 5.5 +<VisualStudioProject 5.6 + ProjectType="Visual C++" 5.7 + Version="9,00" 5.8 + Name="deepstone" 5.9 + ProjectGUID="{7CBC96FF-B324-4904-9FD5-A95075F292BB}" 5.10 + RootNamespace="deepstone" 5.11 + Keyword="Win32Proj" 5.12 + TargetFrameworkVersion="196613" 5.13 + > 5.14 + <Platforms> 5.15 + <Platform 5.16 + Name="Win32" 5.17 + /> 5.18 + </Platforms> 5.19 + <ToolFiles> 5.20 + </ToolFiles> 5.21 + <Configurations> 5.22 + <Configuration 5.23 + Name="Debug|Win32" 5.24 + OutputDirectory="$(SolutionDir)$(ConfigurationName)" 5.25 + IntermediateDirectory="$(ConfigurationName)" 5.26 + ConfigurationType="1" 5.27 + CharacterSet="1" 5.28 + > 5.29 + <Tool 5.30 + Name="VCPreBuildEventTool" 5.31 + /> 5.32 + <Tool 5.33 + Name="VCCustomBuildTool" 5.34 + /> 5.35 + <Tool 5.36 + Name="VCXMLDataGeneratorTool" 5.37 + /> 5.38 + <Tool 5.39 + Name="VCWebServiceProxyGeneratorTool" 5.40 + /> 5.41 + <Tool 5.42 + Name="VCMIDLTool" 5.43 + /> 5.44 + <Tool 5.45 + Name="VCCLCompilerTool" 5.46 + Optimization="0" 5.47 + AdditionalIncludeDirectories="$(SolutionDir)\src" 5.48 + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;RAST_FLOAT;DBG_USE_FLOAT" 5.49 + MinimalRebuild="true" 5.50 + BasicRuntimeChecks="3" 5.51 + RuntimeLibrary="3" 5.52 + UsePrecompiledHeader="0" 5.53 + WarningLevel="3" 5.54 + DebugInformationFormat="4" 5.55 + DisableSpecificWarnings="4305;4244;4996" 5.56 + /> 5.57 + <Tool 5.58 + Name="VCManagedResourceCompilerTool" 5.59 + /> 5.60 + <Tool 5.61 + Name="VCResourceCompilerTool" 5.62 + /> 5.63 + <Tool 5.64 + Name="VCPreLinkEventTool" 5.65 + /> 5.66 + <Tool 5.67 + Name="VCLinkerTool" 5.68 + AdditionalDependencies="SDL.lib SDLmain.lib" 5.69 + LinkIncremental="2" 5.70 + GenerateDebugInformation="true" 5.71 + SubSystem="1" 5.72 + TargetMachine="1" 5.73 + /> 5.74 + <Tool 5.75 + Name="VCALinkTool" 5.76 + /> 5.77 + <Tool 5.78 + Name="VCManifestTool" 5.79 + /> 5.80 + <Tool 5.81 + Name="VCXDCMakeTool" 5.82 + /> 5.83 + <Tool 5.84 + Name="VCBscMakeTool" 5.85 + /> 5.86 + <Tool 5.87 + Name="VCFxCopTool" 5.88 + /> 5.89 + <Tool 5.90 + Name="VCAppVerifierTool" 5.91 + /> 5.92 + <Tool 5.93 + Name="VCPostBuildEventTool" 5.94 + /> 5.95 + </Configuration> 5.96 + <Configuration 5.97 + Name="Release|Win32" 5.98 + OutputDirectory="$(SolutionDir)$(ConfigurationName)" 5.99 + IntermediateDirectory="$(ConfigurationName)" 5.100 + ConfigurationType="1" 5.101 + CharacterSet="1" 5.102 + WholeProgramOptimization="1" 5.103 + > 5.104 + <Tool 5.105 + Name="VCPreBuildEventTool" 5.106 + /> 5.107 + <Tool 5.108 + Name="VCCustomBuildTool" 5.109 + /> 5.110 + <Tool 5.111 + Name="VCXMLDataGeneratorTool" 5.112 + /> 5.113 + <Tool 5.114 + Name="VCWebServiceProxyGeneratorTool" 5.115 + /> 5.116 + <Tool 5.117 + Name="VCMIDLTool" 5.118 + /> 5.119 + <Tool 5.120 + Name="VCCLCompilerTool" 5.121 + Optimization="2" 5.122 + EnableIntrinsicFunctions="true" 5.123 + AdditionalIncludeDirectories="$(SolutionDir)\src" 5.124 + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;RAST_FLOAT;DBG_USE_FLOAT" 5.125 + RuntimeLibrary="2" 5.126 + EnableFunctionLevelLinking="true" 5.127 + UsePrecompiledHeader="0" 5.128 + WarningLevel="3" 5.129 + DebugInformationFormat="3" 5.130 + DisableSpecificWarnings="4305;4244;4996" 5.131 + /> 5.132 + <Tool 5.133 + Name="VCManagedResourceCompilerTool" 5.134 + /> 5.135 + <Tool 5.136 + Name="VCResourceCompilerTool" 5.137 + /> 5.138 + <Tool 5.139 + Name="VCPreLinkEventTool" 5.140 + /> 5.141 + <Tool 5.142 + Name="VCLinkerTool" 5.143 + AdditionalDependencies="SDL.lib SDLmain.lib" 5.144 + LinkIncremental="1" 5.145 + GenerateDebugInformation="true" 5.146 + SubSystem="1" 5.147 + OptimizeReferences="2" 5.148 + EnableCOMDATFolding="2" 5.149 + TargetMachine="1" 5.150 + /> 5.151 + <Tool 5.152 + Name="VCALinkTool" 5.153 + /> 5.154 + <Tool 5.155 + Name="VCManifestTool" 5.156 + /> 5.157 + <Tool 5.158 + Name="VCXDCMakeTool" 5.159 + /> 5.160 + <Tool 5.161 + Name="VCBscMakeTool" 5.162 + /> 5.163 + <Tool 5.164 + Name="VCFxCopTool" 5.165 + /> 5.166 + <Tool 5.167 + Name="VCAppVerifierTool" 5.168 + /> 5.169 + <Tool 5.170 + Name="VCPostBuildEventTool" 5.171 + /> 5.172 + </Configuration> 5.173 + </Configurations> 5.174 + <References> 5.175 + </References> 5.176 + <Files> 5.177 + <Filter 5.178 + Name="src" 5.179 + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" 5.180 + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" 5.181 + > 5.182 + <File 5.183 + RelativePath=".\src\cvec.c" 5.184 + > 5.185 + </File> 5.186 + <File 5.187 + RelativePath=".\src\cvec.h" 5.188 + > 5.189 + </File> 5.190 + <File 5.191 + RelativePath=".\src\fixedp.c" 5.192 + > 5.193 + </File> 5.194 + <File 5.195 + RelativePath=".\src\fixedp.h" 5.196 + > 5.197 + </File> 5.198 + <File 5.199 + RelativePath=".\src\inttypes.h" 5.200 + > 5.201 + </File> 5.202 + <File 5.203 + RelativePath=".\src\keyb.h" 5.204 + > 5.205 + </File> 5.206 + <File 5.207 + RelativePath=".\src\main.c" 5.208 + > 5.209 + </File> 5.210 + <File 5.211 + RelativePath=".\src\mglclip.c" 5.212 + > 5.213 + </File> 5.214 + <File 5.215 + RelativePath=".\src\mglgen.c" 5.216 + > 5.217 + </File> 5.218 + <File 5.219 + RelativePath=".\src\mglimpl.h" 5.220 + > 5.221 + </File> 5.222 + <File 5.223 + RelativePath=".\src\mglrast.c" 5.224 + > 5.225 + </File> 5.226 + <File 5.227 + RelativePath=".\src\mingl.c" 5.228 + > 5.229 + </File> 5.230 + <File 5.231 + RelativePath=".\src\mingl.h" 5.232 + > 5.233 + </File> 5.234 + <File 5.235 + RelativePath=".\src\mouse.h" 5.236 + > 5.237 + </File> 5.238 + <File 5.239 + RelativePath=".\src\palman.c" 5.240 + > 5.241 + </File> 5.242 + <File 5.243 + RelativePath=".\src\palman.h" 5.244 + > 5.245 + </File> 5.246 + <File 5.247 + RelativePath=".\src\scantmpl.h" 5.248 + > 5.249 + </File> 5.250 + <File 5.251 + RelativePath=".\src\scene.c" 5.252 + > 5.253 + </File> 5.254 + <File 5.255 + RelativePath=".\src\scene.h" 5.256 + > 5.257 + </File> 5.258 + <File 5.259 + RelativePath=".\src\texture.c" 5.260 + > 5.261 + </File> 5.262 + <File 5.263 + RelativePath=".\src\texture.h" 5.264 + > 5.265 + </File> 5.266 + <File 5.267 + RelativePath=".\src\timer.h" 5.268 + > 5.269 + </File> 5.270 + <File 5.271 + RelativePath=".\src\vmath.h" 5.272 + > 5.273 + </File> 5.274 + <File 5.275 + RelativePath=".\src\wvga.h" 5.276 + > 5.277 + </File> 5.278 + <Filter 5.279 + Name="dosemu" 5.280 + > 5.281 + <File 5.282 + RelativePath=".\src\dosemu\conio.h" 5.283 + > 5.284 + </File> 5.285 + <File 5.286 + RelativePath=".\src\dosemu\dosemu.c" 5.287 + > 5.288 + </File> 5.289 + </Filter> 5.290 + </Filter> 5.291 + </Files> 5.292 + <Globals> 5.293 + </Globals> 5.294 +</VisualStudioProject>
6.1 --- a/dosemu/conio.h Mon Sep 23 05:58:24 2013 +0300 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,7 +0,0 @@ 6.4 -#ifndef CONIO_H_ 6.5 -#define CONIO_H_ 6.6 - 6.7 -int kbhit(void); 6.8 -int getch(void); 6.9 - 6.10 -#endif /* CONIO_H_ */
7.1 --- a/dosemu/dosemu.c Mon Sep 23 05:58:24 2013 +0300 7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 7.3 @@ -1,336 +0,0 @@ 7.4 -/* This file implements all calls made to dos-specific code using SDL 7.5 - * Don't ask why ... 7.6 - */ 7.7 - 7.8 -#include <stdlib.h> 7.9 -#include <assert.h> 7.10 -#include <SDL.h> 7.11 -#include "wvga.h" 7.12 -#include "conio.h" 7.13 -#include "mouse.h" 7.14 -#include "keyb.h" 7.15 -#include "timer.h" 7.16 - 7.17 -static void proc_events(void); 7.18 - 7.19 -static void init_sdl() 7.20 -{ 7.21 - if(!SDL_WasInit(SDL_INIT_EVERYTHING)) { 7.22 - SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER); 7.23 - } 7.24 -} 7.25 - 7.26 -/* ----- graphics (wvga.c implementation) ----- */ 7.27 -static SDL_Surface *fbsurf; 7.28 -static int scale = 1; 7.29 - 7.30 -int set_video_mode(int mode) 7.31 -{ 7.32 - int resx = 320, resy = 200; 7.33 - unsigned int sdl_flags = SDL_HWPALETTE; 7.34 - char *env; 7.35 - 7.36 - if(getenv("DOSEMU_DOUBLESIZE")) { 7.37 - scale = 2; 7.38 - } 7.39 - 7.40 - if((env = getenv("DOSEMU_SCALE"))) { 7.41 - int n = atoi(env); 7.42 - if(n > 0) { 7.43 - scale = n; 7.44 - } 7.45 - } 7.46 - resx *= scale; 7.47 - resy *= scale; 7.48 - 7.49 - if(getenv("DOSEMU_FULLSCREEN")) { 7.50 - sdl_flags |= SDL_FULLSCREEN; 7.51 - } 7.52 - 7.53 - init_sdl(); 7.54 - 7.55 - switch(mode) { 7.56 - case 0x13: 7.57 - if(!(fbsurf = SDL_SetVideoMode(resx, resy, 8, sdl_flags))) { 7.58 - fprintf(stderr, "failed to set video mode\n"); 7.59 - abort(); 7.60 - } 7.61 - SDL_WM_SetCaption("Deepstone", 0); 7.62 - /*SDL_ShowCursor(0);*/ 7.63 - /*SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);*/ 7.64 - break; 7.65 - 7.66 - case 3: 7.67 - SDL_ShowCursor(1); 7.68 - SDL_EnableKeyRepeat(0, 0); 7.69 - SDL_Quit(); 7.70 - break; 7.71 - 7.72 - default: 7.73 - break; 7.74 - } 7.75 - 7.76 - return 0; 7.77 -} 7.78 - 7.79 -void set_palette(int idx, int *col, int count) 7.80 -{ 7.81 - int i; 7.82 - 7.83 - for(i=0; i<count; i++) { 7.84 - set_pal_entry(idx + i, col[0], col[1], col[2]); 7.85 - col += 3; 7.86 - } 7.87 -} 7.88 - 7.89 -void set_pal_entry(int idx, int r, int g, int b) 7.90 -{ 7.91 - SDL_Color col; 7.92 - col.r = r; 7.93 - col.g = g; 7.94 - col.b = b; 7.95 - 7.96 - if(SDL_SetPalette(fbsurf, SDL_LOGPAL | SDL_PHYSPAL, &col, idx, 1) != 1) { 7.97 - fprintf(stderr, "set_palette failed to set the required color\n"); 7.98 - } 7.99 -} 7.100 - 7.101 -void copy_frame(void *pixels) 7.102 -{ 7.103 - unsigned char *frame = (unsigned char*)pixels; 7.104 - 7.105 - if(SDL_MUSTLOCK(fbsurf)) { 7.106 - SDL_LockSurface(fbsurf); 7.107 - } 7.108 - 7.109 - if(scale > 1) { 7.110 - int i, j, xsz, ysz; 7.111 - unsigned char *dest = fbsurf->pixels; 7.112 - 7.113 - xsz = 320 * scale; 7.114 - ysz = 200 * scale; 7.115 - 7.116 - for(i=0; i<ysz; i++) { 7.117 - for(j=0; j<xsz; j++) { 7.118 - *dest++ = frame[(i / scale) * 320 + (j / scale)]; 7.119 - } 7.120 - } 7.121 - } else { 7.122 - memcpy(fbsurf->pixels, frame, 64000); 7.123 - } 7.124 - 7.125 - if(SDL_MUSTLOCK(fbsurf)) { 7.126 - SDL_UnlockSurface(fbsurf); 7.127 - } 7.128 - SDL_Flip(fbsurf); 7.129 - 7.130 - 7.131 - /* also print fps every second ... */ 7.132 - { 7.133 - static long prev_fps, num_frames; 7.134 - long msec, dt; 7.135 - 7.136 - msec = get_msec(); 7.137 - dt = msec - prev_fps; 7.138 - if(dt >= 1000) { 7.139 - float fps = (float)num_frames / ((float)dt / 1000.0f); 7.140 - printf("framerate: %.1f \r", fps); 7.141 - fflush(stdout); 7.142 - num_frames = 0; 7.143 - prev_fps = msec; 7.144 - } else { 7.145 - num_frames++; 7.146 - } 7.147 - } 7.148 -} 7.149 - 7.150 -void wait_vsync(void) 7.151 -{ 7.152 -} 7.153 - 7.154 -/* ----- event handling (conio.h) ----- */ 7.155 -static SDL_Event *keybev; 7.156 -static int mousex, mousey, bnmask; 7.157 - 7.158 -static int keystate[256]; 7.159 -static int num_pressed; 7.160 - 7.161 -int kbhit(void) 7.162 -{ 7.163 - if(!keybev) { 7.164 - proc_events(); 7.165 - } 7.166 - return keybev != 0; 7.167 -} 7.168 - 7.169 -int getch(void) 7.170 -{ 7.171 - int res; 7.172 - 7.173 - while(!keybev) { 7.174 - SDL_Event ev; 7.175 - SDL_WaitEvent(&ev); 7.176 - SDL_PushEvent(&ev); 7.177 - proc_events(); 7.178 - } 7.179 - res = keybev->key.keysym.sym; 7.180 - keybev = 0; 7.181 - return res; 7.182 -} 7.183 - 7.184 -/* ----- improved event handling (keyb.h) ---- */ 7.185 - 7.186 -int kb_init(int bufsz) 7.187 -{ 7.188 - init_sdl(); 7.189 - 7.190 - return 0; 7.191 -} 7.192 - 7.193 -void kb_shutdown(void) 7.194 -{ 7.195 -} 7.196 - 7.197 -int kb_getkey(void) 7.198 -{ 7.199 - int res = -1; 7.200 - 7.201 - proc_events(); 7.202 - if(keybev) { 7.203 - res = keybev->key.keysym.sym; 7.204 - keybev = 0; 7.205 - } 7.206 - return res; 7.207 -} 7.208 - 7.209 -int kb_isdown(int key) 7.210 -{ 7.211 - if(key == KB_ANY) { 7.212 - return num_pressed; 7.213 - } 7.214 - return keystate[key]; 7.215 -} 7.216 - 7.217 -/* mouse handling (mouse.c implementation) */ 7.218 -static unsigned long last_mouse_hide_time; 7.219 - 7.220 -int have_mouse(void) 7.221 -{ 7.222 - return 1; 7.223 -} 7.224 - 7.225 -void set_mouse(int x, int y) 7.226 -{ 7.227 - SDL_ShowCursor(0); 7.228 - last_mouse_hide_time = get_msec(); 7.229 - 7.230 - SDL_WarpMouse(x * scale, y * scale); 7.231 - mousex = x; 7.232 - mousey = y; 7.233 -} 7.234 - 7.235 -int read_mouse(int *xp, int *yp) 7.236 -{ 7.237 - if(xp) *xp = mousex; 7.238 - if(yp) *yp = mousey; 7.239 - return bnmask; 7.240 -} 7.241 - 7.242 -static void proc_events(void) 7.243 -{ 7.244 - static SDL_Event ev; 7.245 - 7.246 - if(last_mouse_hide_time > 0 && get_msec() - last_mouse_hide_time > 3000) { 7.247 - last_mouse_hide_time = 0; 7.248 - SDL_ShowCursor(1); 7.249 - } 7.250 - 7.251 - while(SDL_PollEvent(&ev)) { 7.252 - switch(ev.type) { 7.253 - case SDL_KEYDOWN: 7.254 - { 7.255 - int key = ev.key.keysym.sym; 7.256 - 7.257 - if(!keybev) { 7.258 - keybev = &ev; 7.259 - } 7.260 - 7.261 - if(!keystate[key]) { 7.262 - keystate[key] = 1; 7.263 - num_pressed++; 7.264 - } 7.265 - } 7.266 - break; 7.267 - 7.268 - case SDL_KEYUP: 7.269 - { 7.270 - int key = ev.key.keysym.sym; 7.271 - 7.272 - if(keystate[key]) { 7.273 - keystate[key] = 0; 7.274 - if(--num_pressed < 0) { 7.275 - num_pressed = 0; 7.276 - } 7.277 - } 7.278 - } 7.279 - break; 7.280 - 7.281 - case SDL_MOUSEMOTION: 7.282 - mousex = ev.motion.x / scale; 7.283 - mousey = ev.motion.y / scale; 7.284 - break; 7.285 - 7.286 - case SDL_MOUSEBUTTONDOWN: 7.287 - case SDL_MOUSEBUTTONUP: 7.288 - { 7.289 - int mask = 0; 7.290 - switch(ev.button.button) { 7.291 - case SDL_BUTTON_LEFT: 7.292 - mask = MOUSE_LEFT; 7.293 - break; 7.294 - case SDL_BUTTON_MIDDLE: 7.295 - mask = MOUSE_MIDDLE; 7.296 - break; 7.297 - case SDL_BUTTON_RIGHT: 7.298 - mask = MOUSE_RIGHT; 7.299 - default: 7.300 - break; 7.301 - } 7.302 - if(!mask) { 7.303 - break; 7.304 - } 7.305 - 7.306 - if(ev.button.state == SDL_PRESSED) { 7.307 - bnmask |= mask; 7.308 - } else { 7.309 - bnmask &= ~mask; 7.310 - } 7.311 - } 7.312 - break; 7.313 - 7.314 - default: 7.315 - break; 7.316 - } 7.317 - } 7.318 -} 7.319 - 7.320 -/* ---- timer.c implementation ---- */ 7.321 -static Uint32 start_time; 7.322 - 7.323 -void init_timer(int res_hz) 7.324 -{ 7.325 - init_sdl(); 7.326 - reset_timer(); 7.327 -} 7.328 - 7.329 -void reset_timer(void) 7.330 -{ 7.331 - start_time = SDL_GetTicks(); 7.332 - printf("resetting timer: %u, %lu\n", start_time, get_msec()); 7.333 -} 7.334 - 7.335 -unsigned long get_msec(void) 7.336 -{ 7.337 - Uint32 ticks = SDL_GetTicks(); 7.338 - return (unsigned long)(ticks - start_time); 7.339 -}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/src/dosemu/conio.h Mon Sep 23 07:41:05 2013 +0300 8.3 @@ -0,0 +1,7 @@ 8.4 +#ifndef CONIO_H_ 8.5 +#define CONIO_H_ 8.6 + 8.7 +int kbhit(void); 8.8 +int getch(void); 8.9 + 8.10 +#endif /* CONIO_H_ */
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/src/dosemu/dosemu.c Mon Sep 23 07:41:05 2013 +0300 9.3 @@ -0,0 +1,342 @@ 9.4 +/* This file implements all calls made to dos-specific code using SDL 9.5 + * Don't ask why ... 9.6 + */ 9.7 + 9.8 +#include <stdlib.h> 9.9 +#include <assert.h> 9.10 +#include <SDL.h> 9.11 +#include "wvga.h" 9.12 +#include "conio.h" 9.13 +#include "mouse.h" 9.14 +#include "keyb.h" 9.15 +#include "timer.h" 9.16 + 9.17 +static void proc_events(void); 9.18 + 9.19 +static void init_sdl() 9.20 +{ 9.21 + const SDL_version *ver; 9.22 + 9.23 + if(!SDL_WasInit(SDL_INIT_EVERYTHING)) { 9.24 + SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER); 9.25 + 9.26 + if((ver = SDL_Linked_Version())) { 9.27 + printf("SDL %d.%d.%d initialized\n", ver->major, ver->minor, ver->patch); 9.28 + } 9.29 + } 9.30 +} 9.31 + 9.32 +/* ----- graphics (wvga.c implementation) ----- */ 9.33 +static SDL_Surface *fbsurf; 9.34 +static int scale = 3; 9.35 + 9.36 +int set_video_mode(int mode) 9.37 +{ 9.38 + int resx = 320, resy = 200; 9.39 + unsigned int sdl_flags = SDL_HWPALETTE; 9.40 + char *env; 9.41 + 9.42 + if(getenv("DOSEMU_DOUBLESIZE")) { 9.43 + scale = 2; 9.44 + } 9.45 + 9.46 + if((env = getenv("DOSEMU_SCALE"))) { 9.47 + int n = atoi(env); 9.48 + if(n > 0) { 9.49 + scale = n; 9.50 + } 9.51 + } 9.52 + resx *= scale; 9.53 + resy *= scale; 9.54 + 9.55 + if(getenv("DOSEMU_FULLSCREEN")) { 9.56 + sdl_flags |= SDL_FULLSCREEN; 9.57 + } 9.58 + 9.59 + init_sdl(); 9.60 + 9.61 + switch(mode) { 9.62 + case 0x13: 9.63 + if(!(fbsurf = SDL_SetVideoMode(resx, resy, 8, sdl_flags))) { 9.64 + fprintf(stderr, "failed to set video mode\n"); 9.65 + abort(); 9.66 + } 9.67 + SDL_WM_SetCaption("Deepstone", 0); 9.68 + /*SDL_ShowCursor(0);*/ 9.69 + /*SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);*/ 9.70 + break; 9.71 + 9.72 + case 3: 9.73 + SDL_ShowCursor(1); 9.74 + SDL_EnableKeyRepeat(0, 0); 9.75 + SDL_Quit(); 9.76 + break; 9.77 + 9.78 + default: 9.79 + break; 9.80 + } 9.81 + 9.82 + return 0; 9.83 +} 9.84 + 9.85 +void set_palette(int idx, int *col, int count) 9.86 +{ 9.87 + int i; 9.88 + 9.89 + for(i=0; i<count; i++) { 9.90 + set_pal_entry(idx + i, col[0], col[1], col[2]); 9.91 + col += 3; 9.92 + } 9.93 +} 9.94 + 9.95 +void set_pal_entry(int idx, int r, int g, int b) 9.96 +{ 9.97 + SDL_Color col; 9.98 + col.r = r; 9.99 + col.g = g; 9.100 + col.b = b; 9.101 + 9.102 + if(SDL_SetPalette(fbsurf, SDL_LOGPAL | SDL_PHYSPAL, &col, idx, 1) != 1) { 9.103 + fprintf(stderr, "set_palette failed to set the required color\n"); 9.104 + } 9.105 +} 9.106 + 9.107 +void copy_frame(void *pixels) 9.108 +{ 9.109 + unsigned char *frame = (unsigned char*)pixels; 9.110 + 9.111 + if(SDL_MUSTLOCK(fbsurf)) { 9.112 + SDL_LockSurface(fbsurf); 9.113 + } 9.114 + 9.115 + if(scale > 1) { 9.116 + int i, j, xsz, ysz; 9.117 + unsigned char *dest = fbsurf->pixels; 9.118 + 9.119 + xsz = 320 * scale; 9.120 + ysz = 200 * scale; 9.121 + 9.122 + for(i=0; i<ysz; i++) { 9.123 + for(j=0; j<xsz; j++) { 9.124 + *dest++ = frame[(i / scale) * 320 + (j / scale)]; 9.125 + } 9.126 + } 9.127 + } else { 9.128 + memcpy(fbsurf->pixels, frame, 64000); 9.129 + } 9.130 + 9.131 + if(SDL_MUSTLOCK(fbsurf)) { 9.132 + SDL_UnlockSurface(fbsurf); 9.133 + } 9.134 + SDL_Flip(fbsurf); 9.135 + 9.136 + 9.137 + /* also print fps every second ... */ 9.138 + { 9.139 + static long prev_fps, num_frames; 9.140 + long msec, dt; 9.141 + 9.142 + msec = get_msec(); 9.143 + dt = msec - prev_fps; 9.144 + if(dt >= 1000) { 9.145 + float fps = (float)num_frames / ((float)dt / 1000.0f); 9.146 + printf("framerate: %.1f \r", fps); 9.147 + fflush(stdout); 9.148 + num_frames = 0; 9.149 + prev_fps = msec; 9.150 + } else { 9.151 + num_frames++; 9.152 + } 9.153 + } 9.154 +} 9.155 + 9.156 +void wait_vsync(void) 9.157 +{ 9.158 +} 9.159 + 9.160 +/* ----- event handling (conio.h) ----- */ 9.161 +static SDL_Event *keybev; 9.162 +static int mousex, mousey, bnmask; 9.163 + 9.164 +static int keystate[256]; 9.165 +static int num_pressed; 9.166 + 9.167 +int kbhit(void) 9.168 +{ 9.169 + if(!keybev) { 9.170 + proc_events(); 9.171 + } 9.172 + return keybev != 0; 9.173 +} 9.174 + 9.175 +int getch(void) 9.176 +{ 9.177 + int res; 9.178 + 9.179 + while(!keybev) { 9.180 + SDL_Event ev; 9.181 + SDL_WaitEvent(&ev); 9.182 + SDL_PushEvent(&ev); 9.183 + proc_events(); 9.184 + } 9.185 + res = keybev->key.keysym.sym; 9.186 + keybev = 0; 9.187 + return res; 9.188 +} 9.189 + 9.190 +/* ----- improved event handling (keyb.h) ---- */ 9.191 + 9.192 +int kb_init(int bufsz) 9.193 +{ 9.194 + init_sdl(); 9.195 + 9.196 + return 0; 9.197 +} 9.198 + 9.199 +void kb_shutdown(void) 9.200 +{ 9.201 +} 9.202 + 9.203 +int kb_getkey(void) 9.204 +{ 9.205 + int res = -1; 9.206 + 9.207 + proc_events(); 9.208 + if(keybev) { 9.209 + res = keybev->key.keysym.sym; 9.210 + keybev = 0; 9.211 + } 9.212 + return res; 9.213 +} 9.214 + 9.215 +int kb_isdown(int key) 9.216 +{ 9.217 + if(key == KB_ANY) { 9.218 + return num_pressed; 9.219 + } 9.220 + return keystate[key]; 9.221 +} 9.222 + 9.223 +/* mouse handling (mouse.c implementation) */ 9.224 +static unsigned long last_mouse_hide_time; 9.225 + 9.226 +int have_mouse(void) 9.227 +{ 9.228 + return 1; 9.229 +} 9.230 + 9.231 +void set_mouse(int x, int y) 9.232 +{ 9.233 + /*SDL_ShowCursor(0); 9.234 + last_mouse_hide_time = get_msec();*/ 9.235 + 9.236 + SDL_WarpMouse(x * scale, y * scale); 9.237 + mousex = x; 9.238 + mousey = y; 9.239 +} 9.240 + 9.241 +int read_mouse(int *xp, int *yp) 9.242 +{ 9.243 + if(xp) *xp = mousex; 9.244 + if(yp) *yp = mousey; 9.245 + return bnmask; 9.246 +} 9.247 + 9.248 +static void proc_events(void) 9.249 +{ 9.250 + static SDL_Event ev; 9.251 + 9.252 + if(last_mouse_hide_time > 0 && get_msec() - last_mouse_hide_time > 3000) { 9.253 + last_mouse_hide_time = 0; 9.254 + SDL_ShowCursor(1); 9.255 + } 9.256 + 9.257 + while(SDL_PollEvent(&ev)) { 9.258 + switch(ev.type) { 9.259 + case SDL_KEYDOWN: 9.260 + { 9.261 + int key = ev.key.keysym.sym; 9.262 + 9.263 + if(!keybev) { 9.264 + keybev = &ev; 9.265 + } 9.266 + 9.267 + if(!keystate[key]) { 9.268 + keystate[key] = 1; 9.269 + num_pressed++; 9.270 + } 9.271 + } 9.272 + break; 9.273 + 9.274 + case SDL_KEYUP: 9.275 + { 9.276 + int key = ev.key.keysym.sym; 9.277 + 9.278 + if(keystate[key]) { 9.279 + keystate[key] = 0; 9.280 + if(--num_pressed < 0) { 9.281 + num_pressed = 0; 9.282 + } 9.283 + } 9.284 + } 9.285 + break; 9.286 + 9.287 + case SDL_MOUSEMOTION: 9.288 + mousex = ev.motion.x / scale; 9.289 + mousey = ev.motion.y / scale; 9.290 + break; 9.291 + 9.292 + case SDL_MOUSEBUTTONDOWN: 9.293 + case SDL_MOUSEBUTTONUP: 9.294 + { 9.295 + int mask = 0; 9.296 + switch(ev.button.button) { 9.297 + case SDL_BUTTON_LEFT: 9.298 + mask = MOUSE_LEFT; 9.299 + break; 9.300 + case SDL_BUTTON_MIDDLE: 9.301 + mask = MOUSE_MIDDLE; 9.302 + break; 9.303 + case SDL_BUTTON_RIGHT: 9.304 + mask = MOUSE_RIGHT; 9.305 + default: 9.306 + break; 9.307 + } 9.308 + if(!mask) { 9.309 + break; 9.310 + } 9.311 + 9.312 + if(ev.button.state == SDL_PRESSED) { 9.313 + bnmask |= mask; 9.314 + } else { 9.315 + bnmask &= ~mask; 9.316 + } 9.317 + } 9.318 + break; 9.319 + 9.320 + default: 9.321 + break; 9.322 + } 9.323 + } 9.324 +} 9.325 + 9.326 +/* ---- timer.c implementation ---- */ 9.327 +static Uint32 start_time; 9.328 + 9.329 +void init_timer(int res_hz) 9.330 +{ 9.331 + init_sdl(); 9.332 + reset_timer(); 9.333 +} 9.334 + 9.335 +void reset_timer(void) 9.336 +{ 9.337 + start_time = SDL_GetTicks(); 9.338 + printf("resetting timer: %u, %lu\n", start_time, get_msec()); 9.339 +} 9.340 + 9.341 +unsigned long get_msec(void) 9.342 +{ 9.343 + Uint32 ticks = SDL_GetTicks(); 9.344 + return (unsigned long)(ticks - start_time); 9.345 +}
10.1 --- a/src/inttypes.h Mon Sep 23 05:58:24 2013 +0300 10.2 +++ b/src/inttypes.h Mon Sep 23 07:41:05 2013 +0300 10.3 @@ -1,7 +1,7 @@ 10.4 #ifndef INT_TYPES_H_ 10.5 #define INT_TYPES_H_ 10.6 10.7 -#ifdef __DOS__ 10.8 +#if defined(__DOS__) || defined(WIN32) 10.9 typedef char int8_t; 10.10 typedef short int16_t; 10.11 typedef long int32_t;
11.1 --- a/src/palman.c Mon Sep 23 05:58:24 2013 +0300 11.2 +++ b/src/palman.c Mon Sep 23 07:41:05 2013 +0300 11.3 @@ -48,7 +48,7 @@ 11.4 { 11.5 int i; 11.6 11.7 - for(i=0; i<ncol; i++) { 11.8 + for(i=0; i<(int)ncol; i++) { 11.9 if(colors[i].r == r && colors[i].g == g && colors[i].b == b) { 11.10 return i; 11.11 } 11.12 @@ -74,7 +74,7 @@ 11.13 } 11.14 pcol = 0; 11.15 11.16 - for(i=0; i<ncol; i++) { 11.17 + for(i=0; i<(int)ncol; i++) { 11.18 unsigned short r, g, b, dr, dg, db; 11.19 11.20 base_index[i] = pcol;