1 Unnamed Mindlapse DOS demo for Pentium 133
2 ------------------------------------------
3 The demo requires VESA Bios Extensions (VBE) 2.0. If your graphics card doesn't
4 support VBE 2.0 or greater, then make sure to load the `univbe` TSR first.
8 - src/ cross-platform demo framework and miscellaneous utility code
9 - src/scr/ demo screens (parts) and effects support code
10 - src/dos/ DOS platform code
11 - src/sdl/ SDL 1.x platform code (windows/UNIX version)
12 - libs/cgmath/ math library, header-file only
13 - libs/imago/ image loading library (includes libpng, zlib, libjpeg)
14 - libs/anim/ keyframe animation library
16 Building on DOS with Watcom
17 ---------------------------
18 NOTE: Don't. Watcom produces significantly worse code than GCC, and at the
19 moment watcom-compiled version of the demo crashes on 3D scenes for some reason
20 which I need to investigate at some point. Suspect either inline assembly with
21 missing "modify" part, or more likely some FPU optimization which fucks up the
24 Make sure you have Watcom or OpenWatcom installed, and the appropriate env-vars
25 set (the watcom installer automatically adds them to autoexec.bat by default).
27 Run wmake to build. Needs dos4gw.exe in current dir.
29 OpenWatcom cross-compilation on UNIX
30 ------------------------------------
31 source owdev script with contents (change WATCOM var as necessary):
33 export WATCOM=$HOME/devel/ow
34 export PATH=$WATCOM/binl:$PATH
35 export INCLUDE=$WATCOM/h:$INCLUDE
37 Run wmake to build. Needs dos4gw.exe and wstub.exe in current dir or PATH
39 Simply running ./demo.exe might invoke magic of the ancients to start wine,
40 which will in turn start dosbox, which will execute the DOS binary! If the gods
41 are slumbering in valhalla, just typing `dosbox demo.exe` should do the trick.
45 The DJGPP port of GCC is the recommended toolchain to use for building the demo,
46 either natively or cross-compiled on UNIX.
48 For native DOS builds add the DJGPP bin directory to the path (usually
49 `c:\djgpp\bin`) and set the DJGPP environment variable to point to the
52 For cross-compiling on UNIX simply source the `setenv` file which comes with
53 DJGPP, which will set the `PATH` and `DJDIR` variables as necessary.
55 In both cases, run `make -f Makefile.dj` to build. To run the resulting
56 `demo.exe` you'll need to copy `cwsdpmi.exe` to the same directory. You can find
57 it here: ftp://ftp.fu-berlin.de/pc/languages/djgpp/current/v2misc/csdpmi7b.zip
59 When building natively on an old computer, and encounter a huge amount of disk
60 swapping, and corresponding ridiculously long compile times, make sure to
61 disable any memory managers and try again. `EMM386` may interfere with
62 `CWSDPMI`'s ability to use more than 32mb of RAM, and modern versions of GCC
63 need way more than that. Disable the memory manager with `emm386 off`, and
64 verify the amount of usable RAM with `go32-v2`.
66 Another problem is the MS-DOS version of `HIMEM.SYS` which only reports up to
67 64mb. To use more than that, which is necessary for modern versions of GCC, you
68 can either disable `HIMEM.SYS` completely, or use the `HIMEM.SYS` driver that
69 comes with Windows 9x (DOS >= 7). Here's a copy in case you need it:
70 http://mutantstargoat.com/~nuclear/tmp/d7himem.sys
73 Building and running with the SDL backend
74 -----------------------------------------
75 Run make to build (assuming make on your system is GNU make), or use the visual
76 studio 2013 project on Windows.
78 The SDL backend will scale the framebuffer up, by the factor specified in the
79 `FBSCALE` environment variable. So run the demo as: `FBSCALE=3 ./demo` for
80 a 3x scale factor, or just export the `FBSCALE` env var in the shell you are
81 going to use for running the demo. The default scale factor is 2x.
85 The demo datafiles are in their own subversion repo. To checkout the data files
86 run the following in the demo root directory:
88 svn co svn://mutantstargoat.com/datadirs/dosdemo data
90 Random optimization details about the Pentium1 (p54c)
91 -----------------------------------------------------
92 Use cround64 (util.h) for float -> integer conversions, instead of casts.
94 Performance measurement with RDTSC:
97 perf_end(); /* result in perf_interval_count */
99 Cache organization (L1): 8kb data / 8kb instruction
100 128 sets of 2 cache lines, 32 bytes per cache line.
102 Addresses which are multiples of 4096 fall in the same set and can only have
103 two of them in cache at any time.
105 U/V pipe pairing rules:
106 - both instructions must be simple
107 - no read-after-write or write-after-write reg dependencies
108 - no displacement AND immediate in either instruction
109 - instr. with prefixes (except 0x0f) can only run on U pipe.
110 - prefixes are treated as separate 1-byte instructions (except 0x0f).
111 - branches can be paired if they are the second instr. of the pair only.
113 Simple instructions are:
114 - mov reg, reg/mem/imm
116 - alu reg, reg/mem/imm (alu: add/sub/cmp/and/or/xor)
128 U-only pairable instructions:
130 - shr, sar, shl, sal with immediate
131 - ror, rol, rcr, rcl with immediate=1
133 Notes about DJGPP & CWSDPMI
134 ---------------------------
135 Can't use the `hlt` instruction for waiting for interrupts, because we're
136 running in ring3 by default. I surrounded all the `hlt` instructions with a
137 `USE_HLT` conditional, which is undefined when building with DJGPP.
139 It's possible to arrange for our code to run on ring0 by changing the DPMI
140 provider from `cwsdpmi.exe` to `cwsdpr0.exe` by running:
141 `stubedit demo.exe dpmi=cwsdpr0.exe`, but I haven't tested under win9x to see if
142 it still works if we do that.
144 Our fucking segments don't start at 0 ... to access arbitrary parts of physical
145 memory we need to call `__djgpp_nearptr_enable()` and use the following macros I
146 defined in `cdpmi.h`:
148 #define virt_to_phys(v) ((v) + __djgpp_base_address)
149 #define phys_to_virt(p) ((p) - __djgpp_base_address)