disabled dep-files when building on dos, because it goes into an infinite loop
[dosdemo] / README.md
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 run the `univbe` TSR first, or
5 the demo will fail to find a usable LFB video mode.
6
7 Building on DOS with Watcom
8 ---------------------------
9 NOTE: Don't. Watcom produces significantly worse code than GCC, and at the
10 moment watcom-compiled version of the demo crashes on 3D scenes for some reason
11 which I need to investigate at some point. Suspect either inline assembly with
12 missing "modify" part, or more likely some FPU optimization which fucks up the
13 clipper.
14
15 Make sure you have Watcom or OpenWatcom installed, and the appropriate env-vars
16 set (the watcom installer automatically adds them to autoexec.bat by default).
17
18 Run wmake to build. Needs dos4gw.exe in current dir.
19
20 OpenWatcom cross-compilation on UNIX
21 ------------------------------------
22 source owdev script with contents (change WATCOM var as necessary):
23
24   export WATCOM=$HOME/devel/ow
25   export PATH=$WATCOM/binl:$PATH
26   export INCLUDE=$WATCOM/h:$INCLUDE
27
28 Run wmake to build. Needs dos4gw.exe and wstub.exe in current dir or PATH
29
30 Simply running ./demo.exe might invoke magic of the ancients to start wine,
31 which will in turn start dosbox, which will execute the DOS binary! If the gods
32 are slumbering in valhalla, just typing `dosbox demo.exe` should do the trick.
33
34 Building with DJGPP
35 -------------------
36 The DJGPP port of GCC is the recommended toolchain to use for building the demo,
37 either natively or cross-compiled on UNIX.
38
39 For native DOS builds add the DJGPP bin directory to the path (usually
40 `c:\djgpp\bin`) and set the DJGPP environment variable to point to the
41 `djgpp.env` file.
42
43 For cross-compiling on UNIX simply source the `setenv` file which comes with
44 DJGPP, which will set the `PATH` and `DJDIR` variables as necessary.
45
46 In both cases, run `make -f Makefile.dj` to build. To run the resulting
47 `demo.exe` you'll need to copy `cwsdpmi.exe` to the same directory. You can find
48 it here: ftp://ftp.fu-berlin.de/pc/languages/djgpp/current/v2misc/csdpmi7b.zip
49
50 When building natively on an old computer, and encounter a huge amount of disk
51 swapping, and corresponding ridiculously long compile times, make sure to
52 disable any memory managers and try again. `EMM386` may interfere with
53 `CWSDPMI`'s ability to use more than 32mb of RAM, and modern versions of GCC
54 need way more than that. Disable the memory manager with `emm386 off`, and
55 verify the amount of usable RAM with `go32-v2`.
56
57 Another problem is the MS-DOS version of `HIMEM.SYS` which only reports up to
58 64mb. To use more than that, which is necessary for modern versions of GCC, you
59 can either disable `HIMEM.SYS` completely, or use the `HIMEM.SYS` driver that
60 comes with Windows 9x (DOS >= 7). Here's a copy in case you need it:
61 http://mutantstargoat.com/~nuclear/tmp/d7himem.sys
62
63
64 Building and running with the SDL backend
65 -----------------------------------------
66 Run make to build (assuming make on your system is GNU make), or use the visual
67 studio 2013 project on Windows.
68
69 The SDL backend will scale the framebuffer up, by the factor specified in the
70 `FBSCALE` environment variable. So run the demo as: `FBSCALE=3 ./demo` for
71 a 3x scale factor, or just export the `FBSCALE` env var in the shell you are
72 going to use for running the demo. The default scale factor is 2x.
73
74 Datafiles
75 ---------
76 The demo datafiles are in their own subversion repo. To checkout the data files
77 run the following in the demo root directory:
78
79   svn co svn://mutantstargoat.com/datadirs/dosdemo data
80
81 Random optimization details about the Pentium1 (p54c)
82 -----------------------------------------------------
83 Use cround64 (util.h) for float -> integer conversions, instead of casts.
84
85 Performance measurement with RDTSC:
86     perf_start();
87     /* code under test */
88     perf_end(); /* result in perf_interval_count */
89
90 Cache organization (L1): 8kb data / 8kb instruction
91 128 sets of 2 cache lines, 32 bytes per cache line.
92
93 Addresses which are multiples of 4096 fall in the same set and can only have
94 two of them in cache at any time.
95
96 U/V pipe pairing rules:
97  - both instructions must be simple
98  - no read-after-write or write-after-write reg dependencies
99  - no displacement AND immediate in either instruction
100  - instr. with prefixes (except 0x0f) can only run on U pipe.
101  - prefixes are treated as separate 1-byte instructions (except 0x0f).
102  - branches can be paired if they are the second instr. of the pair only.
103
104 Simple instructions are:
105  - mov reg, reg/mem/imm
106  - mov mem, reg/imm
107  - alu reg, reg/mem/imm (alu: add/sub/cmp/and/or/xor)
108  - alu mem, reg/imm
109  - inc reg/mem
110  - dec reg/mem
111  - push reg/mem
112  - pop reg
113  - lea reg,mem
114  - jmp/call/jcc near
115  - nop
116  - test reg,reg/mem
117  - test acc,imm
118
119 U-only pairable instructions:
120  - adc, sbb
121  - shr, sar, shl, sal with immediate
122  - ror, rol, rcr, rcl with immediate=1