├── Explosion3.wav ├── a1.bmp ├── a2.bmp ├── a3.bmp ├── a4.bmp ├── a5.bmp ├── a6.bmp ├── ackack1.wav ├── b1.bmp ├── b2.bmp ├── b3.bmp ├── b4.bmp ├── b5.bmp ├── b6.bmp ├── blast.bmp ├── blastmask.bmp ├── bubbles.wav ├── c1.bmp ├── c2.bmp ├── c3.bmp ├── c4.bmp ├── c5.bmp ├── c6.bmp ├── city.bmp ├── city1.bmp ├── city2.bmp ├── city3.bmp ├── city4.bmp ├── city5.bmp ├── city6.bmp ├── click.wav ├── cursor.bmp ├── d1.bmp ├── d2.bmp ├── d3.bmp ├── d4.bmp ├── d5.bmp ├── d6.bmp ├── display.d ├── empire.d ├── empire.def ├── empire.ico ├── empire.rc ├── empire2.BMP ├── eplayer.d ├── error.wav ├── explode.wav ├── explosi1.wav ├── f1.bmp ├── f2.bmp ├── f3.bmp ├── f4.bmp ├── f5.bmp ├── f6.bmp ├── flyby.wav ├── fs1.bmp ├── fs2.bmp ├── fs3.bmp ├── fs4.bmp ├── fs5.bmp ├── fs6.bmp ├── fuel.wav ├── gun_1.wav ├── gun_3.wav ├── help.txt ├── icon.BMP ├── init.d ├── intro.wav ├── land.bmp ├── machine1.wav ├── makefile ├── mapdata.d ├── maps.d ├── move.d ├── path.d ├── printf.d ├── r1.bmp ├── r2.bmp ├── r3.bmp ├── r4.bmp ├── r5.bmp ├── r6.bmp ├── s1.bmp ├── s2.bmp ├── s3.bmp ├── s4.bmp ├── s5.bmp ├── s6.bmp ├── sea.bmp ├── splash.wav ├── sub2.d ├── t1.bmp ├── t2.bmp ├── t3.bmp ├── t4.bmp ├── t5.bmp ├── t6.bmp ├── taps.wav ├── text.d ├── twin.d ├── unknown.bmp ├── unknown10.bmp ├── var.d ├── winemp.d ├── winemp.h └── winmain.d /Explosion3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/Explosion3.wav -------------------------------------------------------------------------------- /a1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/a1.bmp -------------------------------------------------------------------------------- /a2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/a2.bmp -------------------------------------------------------------------------------- /a3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/a3.bmp -------------------------------------------------------------------------------- /a4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/a4.bmp -------------------------------------------------------------------------------- /a5.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/a5.bmp -------------------------------------------------------------------------------- /a6.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/a6.bmp -------------------------------------------------------------------------------- /ackack1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/ackack1.wav -------------------------------------------------------------------------------- /b1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/b1.bmp -------------------------------------------------------------------------------- /b2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/b2.bmp -------------------------------------------------------------------------------- /b3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/b3.bmp -------------------------------------------------------------------------------- /b4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/b4.bmp -------------------------------------------------------------------------------- /b5.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/b5.bmp -------------------------------------------------------------------------------- /b6.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/b6.bmp -------------------------------------------------------------------------------- /blast.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/blast.bmp -------------------------------------------------------------------------------- /blastmask.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/blastmask.bmp -------------------------------------------------------------------------------- /bubbles.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/bubbles.wav -------------------------------------------------------------------------------- /c1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/c1.bmp -------------------------------------------------------------------------------- /c2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/c2.bmp -------------------------------------------------------------------------------- /c3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/c3.bmp -------------------------------------------------------------------------------- /c4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/c4.bmp -------------------------------------------------------------------------------- /c5.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/c5.bmp -------------------------------------------------------------------------------- /c6.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/c6.bmp -------------------------------------------------------------------------------- /city.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/city.bmp -------------------------------------------------------------------------------- /city1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/city1.bmp -------------------------------------------------------------------------------- /city2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/city2.bmp -------------------------------------------------------------------------------- /city3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/city3.bmp -------------------------------------------------------------------------------- /city4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/city4.bmp -------------------------------------------------------------------------------- /city5.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/city5.bmp -------------------------------------------------------------------------------- /city6.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/city6.bmp -------------------------------------------------------------------------------- /click.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/click.wav -------------------------------------------------------------------------------- /cursor.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/cursor.bmp -------------------------------------------------------------------------------- /d1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/d1.bmp -------------------------------------------------------------------------------- /d2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/d2.bmp -------------------------------------------------------------------------------- /d3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/d3.bmp -------------------------------------------------------------------------------- /d4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/d4.bmp -------------------------------------------------------------------------------- /d5.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/d5.bmp -------------------------------------------------------------------------------- /d6.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/d6.bmp -------------------------------------------------------------------------------- /display.d: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * This source is written in the D Programming Language. 12 | * See www.digitalmars.com/d/ for the D specification and compiler. 13 | * 14 | * Use entirely at your own risk. There is no warranty, expressed or implied. 15 | */ 16 | 17 | 18 | import std.c.stdlib; 19 | import std.c.time; 20 | 21 | import empire; 22 | import eplayer; 23 | import text; 24 | import winmain; 25 | import maps; 26 | import var; 27 | 28 | // For each display 29 | 30 | struct Display 31 | { 32 | Text text; 33 | int timeinterval; // 100ths of a second msg delay time 34 | uint maptab; // map values for the players 35 | 36 | int secbas; // position of upper left corner of sector 37 | uint Smin; // text row,col coordinates of upper left sector display 38 | uint Smax; // text row,col coordinates of lower right sector display 39 | 40 | /*********************************** 41 | * Clear the current sector that's showing. 42 | */ 43 | 44 | void clrsec() 45 | { 46 | Display *d = this; 47 | Text *t = &d.text; 48 | 49 | //t.cmes(d.Smin," "); // " " because of bug in BIOS 50 | //t.deleos(); // delete to end of screen 51 | 52 | d.secbas = -1; // indicate screen is blank 53 | } 54 | 55 | 56 | /*************************** 57 | * Print out map value at loc. 58 | */ 59 | 60 | void mapprt(loc_t loc) 61 | { int x; 62 | Display *d = this; 63 | Text *t = &d.text; 64 | 65 | if (!t.watch) return; 66 | assert(loc < MAPSIZE); 67 | if (!insect(loc,0)) return; // if not in current sector 68 | 69 | invalidateLoc(loc); 70 | } 71 | 72 | 73 | /*************************** 74 | * Return true if loc is in the current sector showing, 75 | * with a border of n spaces. If the sector edge lies on 76 | * a map edge, the n spaces do not apply for that edge. 77 | * Return false if secbas[] = -1. 78 | */ 79 | 80 | int insect(loc_t loc,uint n) 81 | { int br,bc,lr,lc; 82 | int x; 83 | int sb; 84 | Display *d = this; 85 | 86 | assert(loc < MAPSIZE && n < 100); 87 | sb = d.secbas; 88 | if (sb == -1) 89 | return false; 90 | br = sb / (Mcolmx + 1); 91 | bc = sb % (Mcolmx + 1); 92 | 93 | lr = loc / (Mcolmx + 1); 94 | lc = loc % (Mcolmx + 1); 95 | 96 | x = (br) ? br + n : br; // min row we can be on 97 | if (lr < x) return false; 98 | 99 | x = (bc) ? bc + n : bc; // min col we can be on 100 | if (lc < x) return false; 101 | 102 | br += (d.Smax - d.Smin) >> 8; 103 | bc += (d.Smax - d.Smin) & 0xFF; 104 | 105 | x = (br != Mrowmx) ? br - n : br; // max row we can be on 106 | if (lr > x) return false; 107 | 108 | x = (bc != Mcolmx) ? bc - n : bc; // max col we can be on 109 | return lc <= x; 110 | } 111 | 112 | /************************************ 113 | * Adjust loc so it makes a valid sector base. 114 | */ 115 | 116 | loc_t adjust(loc_t loc) 117 | { int row,col,size,rowsize,colsize; 118 | Display *d = this; 119 | 120 | row = ROW(loc); 121 | col = COL(loc); 122 | if (col == Mcolmx) // kludge to fix wrap-around 123 | { col = 0; 124 | row++; 125 | } 126 | size = d.Smax - d.Smin; // display size 127 | rowsize = size >> 8; // # of rows - 1 128 | colsize = size & 0xFF; 129 | if (row < 0) row = 0; 130 | if (row > Mrowmx - rowsize) row = Mrowmx - rowsize; 131 | if (col < 0) col = 0; 132 | if (col > Mcolmx - colsize) col = Mcolmx - colsize; 133 | return (row * (Mcolmx + 1) + col); // return adjusted value 134 | } 135 | 136 | void initialize() 137 | { 138 | memset(&text,0,text.sizeof); 139 | text.watch = DAnone; 140 | text.TTtyp = 0; 141 | text.cursor = 0; 142 | text.speaker = 1; 143 | text.Tmax = (23 << 8) + 78; 144 | 145 | text.narrow = 0; 146 | maptab = 0; 147 | timeinterval = 0; 148 | secbas = -1; 149 | Smin = 0x400; 150 | Smax = text.Tmax - ((1 << 8) + 2); 151 | 152 | version (Windows) 153 | { 154 | Smin = 0; 155 | Smax = 11 * 256 + 11; // 12*12 display 156 | } 157 | } 158 | 159 | int rusure() 160 | { 161 | return 1; 162 | /+ 163 | char s; 164 | 165 | text.cmes(text.DS(3),"Are you sure (Y or N)? N\1\b"); 166 | s = toupper(text.TTin()); 167 | text.output(s); // echo 168 | return s == 'Y'; 169 | +/ 170 | } 171 | 172 | void your() 173 | { 174 | text.smes(text.narrow ? "Yr " : "Your "); 175 | } 176 | 177 | 178 | void enemy() 179 | { 180 | text.smes(text.narrow ? "En " : "Enemy "); 181 | } 182 | 183 | /********************** 184 | */ 185 | 186 | void city_attackown() 187 | { 188 | Text *t = &text; 189 | 190 | t.cmes(text.DS(2), "Attacked your own city!\1\2"); 191 | t.cmes(text.DS(3),"\1"); 192 | if (t.watch) 193 | sound_gun(); 194 | t.cmes(text.DS(3),"Your army was executed.\1\2"); 195 | delay(1); 196 | } 197 | 198 | /***************** 199 | */ 200 | 201 | void city_repelled(loc_t loc) 202 | { 203 | Text *t = &text; 204 | 205 | if (t.watch) 206 | { t.TTcurs(text.DS(2)); 207 | t.vsmes("City under attack at %u,%u.",ROW(loc),COL(loc)); 208 | t.deleol(); // delete to end of line 209 | sound_subjugate(); 210 | t.cmes(text.DS(3),"Enemy invasion repelled.\1\2"); 211 | delay(1); 212 | } 213 | } 214 | 215 | /********** 216 | * Your city was conquered. 217 | */ 218 | 219 | void city_conquered(loc_t loc) 220 | { 221 | Text *t = &text; 222 | 223 | if (t.watch) 224 | { 225 | 226 | t.TTcurs(text.DS(2)); 227 | t.vsmes("City is under attack at %u,%u.",ROW(loc),COL(loc)); 228 | t.deleol(); // delete to end of line 229 | sound_crushed(); 230 | t.cmes(text.DS(3),"Your city was conquered!\1\2"); 231 | delay(1); 232 | } 233 | } 234 | 235 | /************************** 236 | */ 237 | 238 | void city_subjugated() 239 | { Text *t = &text; 240 | 241 | if (t.watch) 242 | { 243 | t.cmes(text.DS(2),"Attacking city!\1"); 244 | t.cmes(text.DS(3),"\1"); 245 | sound_subjugate(); 246 | if (t.narrow > 1) 247 | { 248 | t.cmes(text.DS(2),"City subjugated! Army\1"); 249 | t.cmes(text.DS(3),"enforces iron control.\1\2"); 250 | } 251 | else 252 | { 253 | t.cmes(text.DS(2),"The city has been subjugated! The army\1"); 254 | t.cmes(text.DS(3),"was dispersed to enforce iron control.\1\2"); 255 | } 256 | delay(1); 257 | } 258 | } 259 | 260 | /************************** 261 | */ 262 | 263 | void city_crushed() 264 | { Text *t = &text; 265 | 266 | if (t.watch) 267 | { 268 | t.cmes(text.DS(2),"Attacking city!\1"); 269 | t.cmes(text.DS(3),"\1"); 270 | sound_crushed(); 271 | if (t.narrow > 1) 272 | { 273 | t.cmes(text.DS(2), "Your assault crushed!\1"); 274 | t.cmes(text.DS(3), "Your army destroyed.\1\2"); 275 | } 276 | else 277 | { 278 | t.cmes(text.DS(2),text.narrow 279 | ? "The city crushed your assault!\1\2" 280 | : "The city's defenses crushed your assault!\1\2"); 281 | t.cmes(text.DS(3),"Your army destroyed.\1\2"); 282 | } 283 | delay(1); 284 | } 285 | } 286 | 287 | /********************** 288 | * Print number of units destroyed 289 | */ 290 | 291 | void killml(int type,int num) 292 | { 293 | Text *t = &text; 294 | if (t.watch) 295 | { 296 | t.curs(text.DS(3)); 297 | t.vsmes("%d %s destroyed.",num,nmes_p(type,num)); 298 | t.deleol(); 299 | delay(3); 300 | } 301 | } 302 | 303 | /************************************* 304 | * Overloaded T or C. 305 | */ 306 | 307 | void overloaded(loc_t loc,int typabd,int numdes) 308 | { Text *t = &text; 309 | 310 | if (t.watch) 311 | { 312 | t.curs(text.DS(2)); 313 | t.vsmes("Your ship is overloaded at %u,%u.",ROW(loc),COL(loc)); 314 | t.deleol(); 315 | killml(typabd,numdes); // print message 316 | sound_aground(); 317 | } 318 | } 319 | 320 | /************************************ 321 | * Type out the heading of the unit. 322 | */ 323 | 324 | void headng(Unit *u) 325 | { int type,abd; 326 | Text *t = &text; 327 | char *y; 328 | char buffer[100]; 329 | 330 | if (!t.watch) 331 | return; 332 | t.curs(text.DS(0)); 333 | if (u.typ == A) 334 | { 335 | sprintf(buffer,"Your army at %u,%u.", ROW(u.loc), COL(u.loc)); 336 | } 337 | else 338 | { 339 | char buf[10+1]; 340 | 341 | y = text.narrow ? "Yr" : "Your"; 342 | sprintf(buffer,"%s %s at %u,%u.",y,nmes_p(u.typ,1),ROW(u.loc),COL(u.loc)); 343 | 344 | if ((type = tcaf(u)) >= 0) // if we have a T or C 345 | { char buf[10]; 346 | 347 | abd = aboard(u); // # aboard 348 | sprintf(buf," %d ",abd); 349 | strcat(buffer,buf); 350 | strcat(buffer,nmes_p(type,abd)); 351 | strcat(buffer," aboard."); 352 | } 353 | if (u.typ == F) // if a fighter 354 | strcat(buffer," Range: "); 355 | else // else ship 356 | strcat(buffer," Hits: "); 357 | sprintf(buf,"%d",u.hit); 358 | strcat(buffer,buf); 359 | } 360 | t.smes(buffer); 361 | t.deleol(); 362 | t.curs(text.DS(1)); 363 | fncprt(u); // print function 364 | } 365 | 366 | 367 | /********************* 368 | * Type out unit message, plural or singular 369 | */ 370 | 371 | char *nmes_p(int type,int num) 372 | in 373 | { 374 | assert(0 <= type && type < TYPMAX); 375 | } 376 | body 377 | { 378 | static char *msg[8][2] = 379 | [ [ "army", "armies" ], 380 | [ "fighter", "fighters" ], 381 | [ "destroyer", "destroyers" ], 382 | [ "troop transport", "troop transports" ], 383 | [ "submarine", "submarines" ], 384 | [ "cruiser", "cruisers" ], 385 | [ "aircraft carrier", "aircraft carriers" ], 386 | [ "battleship", "battleships" ], 387 | ]; 388 | 389 | // For narrow displays 390 | static char msgn[8][2][3] = 391 | [ 392 | [ "A","As" ], 393 | [ "F","Fs" ], 394 | [ "D","Ds" ], 395 | [ "T","Ts" ], 396 | [ "S","Ss" ], 397 | [ "R","Rs" ], 398 | [ "C","Cs" ], 399 | [ "B","Bs" ], 400 | ]; 401 | 402 | if (text.narrow) 403 | return (num == 1) ? msgn[type][0] : msgn[type][1]; 404 | else 405 | return (num == 1) ? msg[type][0] : msg[type][1]; 406 | } 407 | 408 | 409 | void landing(Unit *u) 410 | { Text *t = &text; 411 | 412 | if (t.watch) 413 | { 414 | t.curs(text.DS(1)); 415 | t.vsmes("Landing confirmed at %u,%u.",ROW(u.loc),COL(u.loc)); 416 | t.deleol(); 417 | delay(2); 418 | } 419 | } 420 | 421 | void boarding(Unit *u) 422 | { Text *t = &text; 423 | 424 | if (t.watch) 425 | { 426 | t.curs(text.DS(1)); 427 | t.vsmes("Boarding confirmed at %u,%u.",ROW(u.loc),COL(u.loc)); 428 | t.deleol(); 429 | delay(2); 430 | } 431 | } 432 | 433 | void aground(Unit *u) 434 | { Text *t = &text; 435 | 436 | if (t.watch) 437 | { 438 | if (t.narrow > 1) 439 | t.cmes(text.DS(1),"Ship ran aground, sank.\1\2"); 440 | else 441 | t.cmes(text.DS(1),"Your ship ran aground and sank.\1\2"); 442 | sound_aground(); 443 | } 444 | } 445 | 446 | void armdes(Unit *u) 447 | { Text *t = &text; 448 | 449 | if (t.watch) 450 | t.cmes(text.DS(1),"Your army was destroyed.\1\2"); 451 | } 452 | 453 | void drown(Unit *u) 454 | { Text *t = &text; 455 | 456 | if (t.watch) 457 | { 458 | if (t.narrow > 1) 459 | { 460 | t.cmes(text.DS(1),"Army marched into sea!\1"); 461 | } 462 | else 463 | { 464 | t.curs(text.DS(1)); 465 | your(); 466 | t.vsmes("%s marched into the sea and drowned!",nmes_p(A,1)); 467 | t.imes("\1\2"); 468 | } 469 | sound_splash(); 470 | } 471 | } 472 | 473 | void shot_down(Unit *u) 474 | { Text *t = &text; 475 | 476 | if (t.watch) 477 | { 478 | t.cmes(text.DS(2),"Fighter attacks city!\1"); 479 | sound_flyby(); 480 | sound_ackack(); 481 | sound_ackack(); 482 | t.cmes(text.DS(3),"Fighter shot down!\1"); 483 | sound_fcrash(); 484 | } 485 | } 486 | 487 | void no_fuel(Unit *u) 488 | { Text *t = &text; 489 | 490 | if (t.watch) 491 | { 492 | t.cmes(text.DS(2), "Fighter ran out of fuel...\1\2"); 493 | sound_fuel(); 494 | t.cmes(text.DS(3), "...and crashed!\1\2"); 495 | sound_fcrash(); 496 | } 497 | } 498 | 499 | void docking(Unit *u, loc_t loc) 500 | { Text *t = &text; 501 | 502 | if (t.watch) 503 | { 504 | t.cmes(text.DS(1), "Ship docked at \1"); 505 | t.locdot(loc); 506 | t.deleol(); 507 | } 508 | } 509 | 510 | /*************************************** 511 | * Unit u is under attack. 512 | */ 513 | 514 | void underattack(Unit *u) 515 | { 516 | Text *t = &text; 517 | if (t.watch) 518 | { char *p; 519 | 520 | t.curs(text.DS(2)); 521 | p = text.narrow ? "Yr" : "Your"; 522 | t.vsmes("%s %s is under attack at %u,%u.", 523 | p,nmes_p(u.typ,1),ROW(u.loc),COL(u.loc)); 524 | t.deleol(); 525 | delay(2); 526 | } 527 | } 528 | 529 | 530 | /*************************************** 531 | * Perform battle. 532 | * Input: 533 | * pnum player number for this display 534 | * uwin winner 535 | * ulos loser 536 | */ 537 | 538 | void battle(Player *p,Unit *uwin,Unit *ulos) 539 | { 540 | char* p1; 541 | char* p2; 542 | Text* t = &text; 543 | 544 | if (t.watch) 545 | { int abd; 546 | 547 | t.curs(text.DS(2)); 548 | t.vsmes("%s%s destroyed.",youene_p(p,ulos.own),nmes_p(ulos.typ,1)); 549 | t.deleol(); 550 | abd = aboard(ulos); 551 | if (abd) 552 | killml(tcaf(ulos),abd); 553 | t.curs(text.DS(3)); 554 | if (uwin.typ != A && uwin.typ != F) 555 | { 556 | p1 = youene_p(p,uwin.own); 557 | p2 = nmes_p(uwin.typ,1); 558 | if (uwin.hit == 1) 559 | t.vsmes("%s%s has 1 hit left",p1,p2); 560 | else 561 | t.vsmes("%s%s has %d hits left",p1,p2,uwin.hit); 562 | } 563 | t.deleol(); 564 | t.flush(); 565 | 566 | ShowBlast(1, ulos.loc); 567 | switch (ulos.typ) 568 | { 569 | case A: 570 | sound_gun(); 571 | break; 572 | case F: 573 | sound_ackack(); 574 | break; 575 | default: 576 | sound_bang(); 577 | break; 578 | } 579 | ShowBlast(0, ulos.loc); 580 | } 581 | } 582 | 583 | /************************************* 584 | */ 585 | 586 | char *youene_p(Player *p,int num) 587 | { 588 | if (p.num == num) 589 | { 590 | return text.narrow ? "Yr " : "Your "; 591 | } 592 | else 593 | { 594 | return text.narrow ? "En " : "Enemy "; 595 | } 596 | } 597 | 598 | /****************************** 599 | * Notify player that pdef has been defeated. 600 | */ 601 | 602 | void plyrcrushed(Player *pdef) 603 | { 604 | Text *t = &text; 605 | if (t.watch) 606 | { 607 | t.cmes(text.DS(2),"Player "); 608 | t.decprt(pdef.num); 609 | t.imes(" has been crushed.\1\2"); 610 | t.curs(text.DS(3)); 611 | t.deleol(); 612 | sound_taps(); 613 | delay(4); 614 | } 615 | } 616 | 617 | /*********************************** 618 | * Notify player that he's lost. 619 | */ 620 | 621 | void lost() 622 | { 623 | Text *t = &text; 624 | if (t.watch) 625 | { t.cmes(text.DS(0),"The enemy has crushed your feeble forces!\1"); 626 | t.cmes(text.DS(1),"Your contemptible dreams of world\1"); 627 | t.cmes(text.DS(2),"Empire are finished!\1"); 628 | t.cmes(text.DS(3),"\1"); 629 | delay(10); 630 | } 631 | } 632 | 633 | /************************************** 634 | */ 635 | 636 | void produce(City *c) 637 | { 638 | Text *t = &text; 639 | if (t.watch) 640 | { char *p; 641 | 642 | t.curs(text.DS(0)); 643 | p = (c.phs == A || c.phs == C) ? "n" : ""; 644 | t.vsmes("City at %u,%u has completed a%s %s.", 645 | ROW(c.loc),COL(c.loc),p,nmes_p(c.phs,1)); 646 | t.imes("\1\2"); 647 | } 648 | } 649 | 650 | /************************************** 651 | */ 652 | 653 | void overpop(int flag) 654 | { 655 | if (text.watch) 656 | { 657 | //text.cmes(text.DS(2),flag ? "Overpop" : " "); 658 | } 659 | } 660 | 661 | /********************************** 662 | * Print function of unit. 663 | */ 664 | 665 | void fncprt(Unit *u) 666 | { static char dtab[9] = "DEWQAZXC"; // directions 667 | Player *p = Player.get(u.own); 668 | Text *t = &text; 669 | 670 | if (!t.watch) // if not watching this guy 671 | return; 672 | if (p.human) // if human player 673 | { 674 | if (u.ifo != fnAW) 675 | t.smes("Function: "); 676 | switch (u.ifo) 677 | { 678 | case fnAW: 679 | //t.smes("None"); 680 | break; 681 | case fnSE: 682 | t.smes("Sentry"); 683 | break; 684 | case fnRA: 685 | t.smes("Random"); 686 | break; 687 | case fnMO: 688 | t.smes("Move To "); 689 | t.locprt(u.ila); 690 | break; 691 | case fnDI: 692 | t.smes("Direction = "); 693 | t.output(dtab[u.ila]); 694 | break; 695 | case fnFI: 696 | t.smes("Load "); 697 | if (u.typ == T) 698 | t.smes("Armies"); 699 | else 700 | t.smes("Fighters"); 701 | break; 702 | default: 703 | assert(0); 704 | } 705 | 706 | } 707 | else /* else computer */ 708 | { t.smes("IFO: "); 709 | t.decprt(u.ifo); 710 | t.smes(" ILA: "); 711 | t.locdot(u.ila); 712 | } 713 | t.deleol(); 714 | } 715 | 716 | /************************************ 717 | */ 718 | 719 | void setdispsize(int rows,int cols) 720 | { 721 | //PRINTF("Display::setdispsize(rows=%d, cols=%d)\n",rows,cols); 722 | 723 | version (Windows) 724 | { 725 | version (0) 726 | { 727 | text.narrow = 0; 728 | if (global.cxClient < 75 * 10) 729 | text.narrow = 1; 730 | if (global.cxClient <= 12 * 10) 731 | text.narrow = 2; 732 | } 733 | else 734 | { 735 | text.narrow = (cols < 75); // use 40 column formatting 736 | text.narrow = 2; 737 | } 738 | text.Tmax = (rows - 1) * 256 + cols - 1; 739 | } 740 | else 741 | { 742 | text.narrow = (cols < 75); // use 40 column formatting 743 | if (text.narrow) 744 | Smin = (5 * 256) + 0; // u l edge of map 745 | else 746 | Smin = (4 * 256) + 0; 747 | 748 | text.Tmax = (rows - 1) * 256 + cols - 1; 749 | 750 | // Scale back if display is bigger than we can use 751 | if (cols > Mcolmx + 1 + 3 - 1) 752 | cols = Mcolmx + 1 + 3 - 1; 753 | if (rows > 4 + Mrowmx + 1 + 1) 754 | rows = 4 + Mrowmx + 1 + 1; 755 | 756 | Smax = (rows - 2) * 256 + cols - 3; 757 | } 758 | } 759 | 760 | 761 | /******************************** 762 | * Position cursor where loc is. 763 | */ 764 | 765 | void pcur(loc_t loc) 766 | { 767 | version (Windows) 768 | { 769 | loc_t oldloc; 770 | 771 | if (!text.watch) 772 | return; 773 | assert(loc < MAPSIZE); 774 | if (global.cursor == loc) 775 | return; 776 | 777 | oldloc = global.cursor; 778 | global.cursor = loc; 779 | if (adjSector(global.scalex, global.scaley)) 780 | InvalidateRect(global.hwnd, &global.sector, false); 781 | else 782 | { 783 | if (global.player.mode == mdTO) 784 | { 785 | invalidateLocRect(global.player.frmloc, oldloc); 786 | invalidateLocRect(global.player.frmloc, loc); 787 | } 788 | else if (global.player.mode == mdSURV) 789 | { 790 | InvalidateRect(global.hwnd, &global.sector, false); 791 | } 792 | else 793 | { 794 | invalidateLoc(oldloc); 795 | invalidateLoc(loc); 796 | } 797 | } 798 | } 799 | else 800 | { 801 | assert(loc < MAPSIZE); 802 | text.curs(rowcol(loc - secbas) + Smin); 803 | } 804 | } 805 | 806 | 807 | /********************************* 808 | * Remove any sticky messages. 809 | */ 810 | 811 | void remove_sticky() 812 | { 813 | Text *t = &text; 814 | 815 | if (t.watch) 816 | { t.curs(text.DS(1)); t.deleol(); 817 | t.curs(text.DS(2)); t.deleol(); 818 | t.curs(text.DS(3)); t.deleol(); 819 | } 820 | } 821 | 822 | /**************************** 823 | * Print out list of valid commands per mode. 824 | */ 825 | 826 | void valcmd(int mode) 827 | { static char *valmsg[] = 828 | [ "valcmd()", // just a place holder 829 | "QWEADZXC,FGHIKLNRSUVY<>,space", // Move 830 | "QWEADZXC,FGHIKLNPRSU<>,esc", // Survey 831 | "QWEADZXC,esc", // Dir 832 | "QWEADZXC,HKNT<>,esc", // From To 833 | "AFDTSRCB" // City Prod 834 | ]; 835 | Text *t = &text; 836 | 837 | t.curs(text.DS(3)); 838 | if (!text.narrow) 839 | t.smes("Valid commands: "); 840 | t.smes(valmsg[mode]); 841 | t.deleol(); 842 | sound_error(); 843 | } 844 | 845 | /************************************ 846 | */ 847 | 848 | void cityProdDemands() 849 | { 850 | Text *t = &text; 851 | t.cmes(t.DS(0),"City production demands: \1"); 852 | } 853 | 854 | void delay(int n) 855 | { Display *d = this; 856 | 857 | if (d.text.watch) 858 | { d.text.flush(); 859 | if (d.timeinterval) 860 | sleep(n * d.timeinterval); 861 | } 862 | } 863 | 864 | void wakeup() 865 | { 866 | text.cmes(text.DS(2),"Wakeup performed.\1\2"); 867 | } 868 | 869 | } 870 | 871 | /******************************* 872 | * Type data on a city. 873 | */ 874 | 875 | void typcit(Player *p,City *c) 876 | { 877 | Display *d = p.display; 878 | Text *t = &d.text; 879 | 880 | if (t.watch) 881 | { 882 | if (c.phs == -1) 883 | return; // invalid city phase 884 | t.cmes(t.DS(1),t.narrow ? "Prod: " : "Producing: "); 885 | t.vsmes("%s Completion: %d",d.nmes_p(c.phs,2),c.fnd); 886 | if (p.human && c.fipath) 887 | t.vsmes(" Fipath: %u,%u",ROW(c.fipath),COL(c.fipath)); 888 | t.deleol(); 889 | } 890 | } 891 | 892 | /*********************************** 893 | * Save game. 894 | */ 895 | 896 | void savgam() 897 | { 898 | Text *t = &var.player[plynum].display.text; 899 | 900 | t.cmes(t.DS(3),"Saving game...\1"); 901 | if (var_savgam("empire.dat")) 902 | { 903 | t.cmes(t.DS(3),"Error writing EMPIRE.DAT\1"); 904 | } 905 | else 906 | { 907 | t.cmes(t.DS(3),"Game saved.\1"); 908 | } 909 | } 910 | 911 | /****************************** 912 | * Type out values of strategy variables. 913 | */ 914 | 915 | void lstvar() 916 | { int i,j,k,ene; 917 | Player *p = Player.get(2); 918 | Text *t = &p.display.text; 919 | 920 | ene = 2; /* get computer player number */ 921 | p.display.clrsec(); // clear section of screen 922 | 923 | t.cmes(0x500,"TARGET\t"); 924 | for (i = 0; i < CITMAX; i++) /* loop thru cities */ 925 | { if (p.target[i]) /* if it's a target */ 926 | { t.locprt(city[i].loc); 927 | t.output('\t'); 928 | } 929 | } 930 | 931 | t.cmes(0x600,"NUMUNI\t"); 932 | for (i = 0; i < 8; i++) 933 | { t.decprt(p.numuni[i]); 934 | t.output('\t'); 935 | } 936 | 937 | t.cmes(0x700,"NUMPHS\t"); 938 | for (i = 0; i < 8; i++) 939 | { t.decprt(p.numphs[i]); 940 | t.output('\t'); 941 | } 942 | 943 | t.curs(0x800); 944 | t.smes("NUMOWN "); t.decprt(p.numown); 945 | t.smes(" NUMTAR "); t.decprt(p.numtar); 946 | 947 | t.imes("\n\rTROOPT\n\r"); 948 | for (i = 0; i < 6; i++) 949 | { for (k = 0; k < 5; k++) 950 | { t.locprt( p.troopt[i][k] ); 951 | t.output('\t'); 952 | } 953 | t.crlf(); 954 | } 955 | 956 | t.imes("LOCI\n\r"); 957 | for (i = 0; i < LOCMAX; i++) 958 | { t.locprt( p.loci[i] ); 959 | t.output('\t'); 960 | } 961 | t.crlf(); 962 | } 963 | 964 | -------------------------------------------------------------------------------- /empire.d: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * This source is written in the D Programming Language. 12 | * See www.digitalmars.com/d/ for the D specification and compiler. 13 | * 14 | * Use entirely at your own risk. There is no warranty, expressed or implied. 15 | */ 16 | 17 | module empire; 18 | 19 | import std.random; 20 | 21 | alias int dir_t; // direction 22 | alias uint loc_t; // location 23 | 24 | void setran() { std.random.rand_seed(37, 49); } 25 | uint random(uint p) { return std.random.rand() % p; } 26 | uint ranq() { return std.random.rand(); } 27 | 28 | const int ERRTERM = 1; 29 | 30 | /* Definitions for typ[MAPMAX] array (X=city, J=not unit or city) 31 | */ 32 | enum 33 | { 34 | J = -1, 35 | X = -2, 36 | A = 0, 37 | F = 1, 38 | D = 2, 39 | T = 3, 40 | S = 4, 41 | R = 5, 42 | C = 6, 43 | B = 7, 44 | } 45 | 46 | enum 47 | { 48 | mA = 0x80, 49 | mF = 0x40, 50 | mD = 0x20, 51 | mT = 0x10, 52 | mS = 0x08, 53 | mR = 0x04, 54 | mC = 0x02, 55 | mB = 0x01, 56 | } 57 | 58 | const int TYPMAX = 8; // number of types 59 | const int UNIMAX = 500; // max number of units 60 | //const int UNIMAX = 8; 61 | const int CITMAX = 70; // max number of cities 62 | const int MAPMAX = (4 + PLYMAX * 10); // number of map elements 63 | const int LOCMAX = 10; // size of loci array 64 | const int PLYMAX = 6; // number of players 65 | const int VERSION = 1; // version number 66 | const int NEW = 1; // new computer strategy 67 | 68 | debug 69 | { 70 | const int PLYMIN = 1; // minimum number of players 71 | } 72 | else 73 | { 74 | const int PLYMIN = 2; // minimum number of players 75 | } 76 | 77 | 78 | /* Some ascii characters */ 79 | enum 80 | { 81 | BEL = 7, 82 | BS = 8, 83 | TAB = 9, 84 | LF = 10, 85 | FF = 12, 86 | CR = 13, 87 | ESC = 27, 88 | SPC = 32, 89 | DEL = 127, 90 | } 91 | 92 | /* map row and column limits (0..Mrowmx,0..Mcolmx) */ 93 | const uint Mrowmx = 59; 94 | const int Mcolmx = 99; 95 | const int MAPSIZE = ((Mrowmx + 1) * (Mcolmx + 1)); 96 | 97 | int ROW(loc_t loc) { return loc / (Mcolmx + 1); } 98 | int COL(loc_t loc) { return loc % (Mcolmx + 1); } 99 | 100 | // Which maptab to use 101 | enum 102 | { 103 | MTmono = 0, // For the monochrome screen. 104 | MTcgacolor = 1, // For the color/graphics adapter with a color monitor. 105 | MTcgabw = 2, // For the color/graphics adapter with a b/w monitor. 106 | MTterm = 3, // For terminals. 107 | } 108 | 109 | /* Some display attributes (for watch[]) 110 | */ 111 | enum 112 | { 113 | DAnone = 0, // not watching this guy 114 | DAdisp = 1, // use disp package (IBM compatible displays) 115 | DAmsdos = 2, // talk thru MS-DOS 116 | DAcom1 = 3, // talk to com1: 117 | DAcom2 = 4, // talk to com2: 118 | DAconsole = 5, // Win32 console 119 | DAwindows = 6, // Win32 GUI app 120 | } 121 | 122 | ///////////////////////////////// 123 | // Map values 124 | 125 | enum 126 | { 127 | MAPunknown = 0, // ' ' 128 | MAPcity = 1, // '*' 129 | MAPsea = 2, // '.' 130 | MAPland = 3, // '+' 131 | } 132 | 133 | struct City 134 | { 135 | ubyte own; // who owns the city, 0 if nobody 136 | byte phs; // what the city is producing 137 | loc_t loc; // city location, or 0 138 | uint fnd; // completion round number 139 | 140 | // Human strategy 141 | loc_t fipath; // where to send fighter 142 | 143 | // Computer strategy 144 | uint round; // turn it was captured 145 | }; 146 | 147 | /* Ifo functions (same as in hmove.c): 148 | */ 149 | 150 | enum 151 | { 152 | fnAW = 0, 153 | fnSE = 1, 154 | fnRA = 2, 155 | fnMO = 3, 156 | fnDI = 4, 157 | fnFI = 5, 158 | } 159 | 160 | enum 161 | { 162 | IFOnone = 0, // no function assigned 163 | IFOgotoT = 1, // A: go to troop transport 164 | IFOdirkam = 2, // F: directional, kamikaze 165 | IFOdir = 3, // directional 166 | IFOtarkam = 4, // F: target, kamikaze 167 | IFOtar = 5, // target location 168 | IFOgotoC = 6, // F: goto carrier number 169 | IFOcity = 7, // F,ships: goto city location 170 | IFOdamaged = 8, // ships: damaged and going to port 171 | IFOstation = 9, // C: stationed 172 | IFOgstation = 10, // C: goto station 173 | IFOcitytar = 11, // ships: goto city target 174 | IFOescort = 12, // ships: escort TT number 175 | IFOshipexplor = 13, // ships: look at unexplored territory 176 | IFOloadarmy = 14, // T: load up armies 177 | IFOacitytar = 15, // A: city target 178 | IFOfolshore = 16, // A: follow shore 179 | IFOonboard = 17, // A: on board a T 180 | } 181 | 182 | struct Unit 183 | { 184 | loc_t loc; // location 185 | ubyte own; // owner 186 | ubyte typ; // type A..B 187 | ubyte ifo; // IFOxxxx ifo of unit function 188 | uint ila; // ila of unit function 189 | ubyte hit; // hits left, fuel left for fighter 190 | ubyte mov; // !=0 if unit has moved this turn 191 | 192 | void destroy() // destroy the unit 193 | { loc = 0; } 194 | 195 | // Human strategy 196 | 197 | // Computer strategy 198 | uint abd; // T,C: number of As (Fs) aboard (0 if not T (C)) 199 | int dir; // direction (1 or -1) 200 | int fuel; // F:range used for strategy selection 201 | }; 202 | 203 | // Describes unit type 204 | struct Type 205 | { 206 | ubyte prodtime; // production times 207 | ubyte phstart; // starting production times 208 | char unichr; // character representation for city phase purposes 209 | int hittab; // hits left (value for F is fuel, for A is 0 210 | // for computer strategy) 211 | }; 212 | 213 | enum 214 | { 215 | mdNONE = 0, 216 | mdMOVE = 1, 217 | mdSURV = 2, 218 | mdDIR = 3, 219 | mdTO = 4, 220 | mdPHAS = 5, 221 | } 222 | 223 | 224 | 225 | /* #define DS(x) ((x)*256+18) */ 226 | 227 | -------------------------------------------------------------------------------- /empire.def: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/empire.def -------------------------------------------------------------------------------- /empire.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/empire.ico -------------------------------------------------------------------------------- /empire.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * 12 | * Use entirely at your own risk. There is no warranty, expressed or implied. 13 | */ 14 | 15 | #include 16 | #include "winemp.h" 17 | 18 | 1 BITMAP unknown.bmp 19 | 2 BITMAP city.bmp 20 | 3 BITMAP sea.bmp 21 | 4 BITMAP land.bmp 22 | 23 | 5 BITMAP city1.bmp 24 | 6 BITMAP a1.bmp 25 | 7 BITMAP f1.bmp 26 | 8 BITMAP fs1.bmp 27 | 9 BITMAP d1.bmp 28 | 10 BITMAP t1.bmp 29 | 11 BITMAP s1.bmp 30 | 12 BITMAP r1.bmp 31 | 13 BITMAP c1.bmp 32 | 14 BITMAP b1.bmp 33 | 34 | 15 BITMAP city2.bmp 35 | 16 BITMAP a2.bmp 36 | 17 BITMAP f2.bmp 37 | 18 BITMAP fs2.bmp 38 | 19 BITMAP d2.bmp 39 | 20 BITMAP t2.bmp 40 | 21 BITMAP s2.bmp 41 | 22 BITMAP r2.bmp 42 | 23 BITMAP c2.bmp 43 | 24 BITMAP b2.bmp 44 | 45 | 25 BITMAP city3.bmp 46 | 26 BITMAP a3.bmp 47 | 27 BITMAP f3.bmp 48 | 28 BITMAP fs3.bmp 49 | 29 BITMAP d3.bmp 50 | 30 BITMAP t3.bmp 51 | 31 BITMAP s3.bmp 52 | 32 BITMAP r3.bmp 53 | 33 BITMAP c3.bmp 54 | 34 BITMAP b3.bmp 55 | 56 | 35 BITMAP city4.bmp 57 | 36 BITMAP a4.bmp 58 | 37 BITMAP f4.bmp 59 | 38 BITMAP fs4.bmp 60 | 39 BITMAP d4.bmp 61 | 40 BITMAP t4.bmp 62 | 41 BITMAP s4.bmp 63 | 42 BITMAP r4.bmp 64 | 43 BITMAP c4.bmp 65 | 44 BITMAP b4.bmp 66 | 67 | 45 BITMAP city5.bmp 68 | 46 BITMAP a5.bmp 69 | 47 BITMAP f5.bmp 70 | 48 BITMAP fs5.bmp 71 | 49 BITMAP d5.bmp 72 | 50 BITMAP t5.bmp 73 | 51 BITMAP s5.bmp 74 | 52 BITMAP r5.bmp 75 | 53 BITMAP c5.bmp 76 | 54 BITMAP b5.bmp 77 | 78 | 55 BITMAP city6.bmp 79 | 56 BITMAP a6.bmp 80 | 57 BITMAP f6.bmp 81 | 58 BITMAP fs6.bmp 82 | 59 BITMAP d6.bmp 83 | 60 BITMAP t6.bmp 84 | 61 BITMAP s6.bmp 85 | 62 BITMAP r6.bmp 86 | 63 BITMAP c6.bmp 87 | 64 BITMAP b6.bmp 88 | 89 | 90 | BMP_CURSOR BITMAP cursor.bmp 91 | BMP_SPLASH BITMAP empire2.bmp 92 | BMP_UNKNOWN10 BITMAP unknown10.bmp 93 | BMP_BLAST BITMAP blast.bmp 94 | BMP_BLASTMASK BITMAP blastmask.bmp 95 | 96 | About ICON empire.ico 97 | 98 | AboutBox DIALOG 20, 20, 160, 110 99 | STYLE WS_POPUP | WS_DLGFRAME 100 | { 101 | CTEXT "Empire 2.03" -1, 0, 12, 160, 8 102 | ICON "About" -1, 8, 8, 0, 0 103 | CTEXT "Wargame of the Century" -1, 0, 20, 160, 8 104 | CTEXT "(c) Walter Bright 1978-2004" -1, 0, 32, 160, 8 105 | CTEXT "All Rights Reserved" -1, 0, 40, 160, 8 106 | CTEXT "www.classicempire.com" -1, 0, 48, 160, 8 107 | CTEXT "powered by Digital Mars D" -1, 0, 64, 160, 8 108 | CTEXT "www.digitalmars.com/d/" -1, 0, 72, 160, 8 109 | DEFPUSHBUTTON "OK" IDOK, 64, 90, 32, 14, WS_GROUP 110 | } 111 | 112 | 113 | #define TABGRP (WS_TABSTOP | WS_GROUP) 114 | 115 | CitySelectBox DIALOG 20, 20, 134, 172 116 | STYLE WS_POPUP | WS_DLGFRAME 117 | { 118 | CTEXT "City Production Demands" -1, 4, 4, 140, 8 119 | CTEXT "" IDD_SENSOR 68, 18, 60, 60 120 | CTEXT "" IDD_TILE 68, 86, 60, 60 121 | GROUPBOX "" -1, 4, 14, 58, 112 122 | RADIOBUTTON "&Armies" IDD_ARMIES, 8, 24, 48, 12, TABGRP 123 | RADIOBUTTON "&Fighters" IDD_FIGHTERS, 8, 36, 48, 12 124 | RADIOBUTTON "&Destroyers" IDD_DESTROYERS, 8, 48, 48, 12 125 | RADIOBUTTON "&Transports" IDD_TRANSPORTS, 8, 60, 48, 12 126 | RADIOBUTTON "&Submarines" IDD_SUBMARINES, 8, 72, 48, 12 127 | RADIOBUTTON "C&ruisers" IDD_CRUISERS, 8, 84, 48, 12 128 | RADIOBUTTON "&Carriers" IDD_CARRIERS, 8, 96, 48, 12 129 | RADIOBUTTON "&Battleships" IDD_BATTLESHIPS,8, 108, 48, 12 130 | DEFPUSHBUTTON "OK" IDOK, 12, 132, 40, 14, WS_GROUP 131 | PUSHBUTTON "Cancel" IDCANCEL, 12, 152, 40, 14, WS_GROUP 132 | } 133 | 134 | InitBox DIALOG 20, 20, 68, 116 135 | STYLE WS_POPUP | WS_DLGFRAME 136 | { 137 | CTEXT "New Game" -1, 4, 4, 58, 8 138 | GROUPBOX "Num Enemies" -1, 4, 16, 58, 34 139 | RADIOBUTTON "&0" IDD_ONE, 8, 26, 16, 12, TABGRP 140 | RADIOBUTTON "&1" IDD_TWO, 26, 26, 16, 12 141 | RADIOBUTTON "&2" IDD_THREE, 44, 26, 16, 12 142 | RADIOBUTTON "&3" IDD_FOUR, 8, 36, 16, 12 143 | RADIOBUTTON "&4" IDD_FIVE, 26, 36, 16, 12 144 | RADIOBUTTON "&5" IDD_SIX, 44, 36, 16, 12 145 | RADIOBUTTON "&Demo" IDD_DEMO, 20, 58, 48, 12, WS_GROUP 146 | DEFPUSHBUTTON "OK" IDOK, 14, 76, 40, 14, WS_GROUP 147 | PUSHBUTTON "Cancel" IDCANCEL, 14, 96, 40, 14, WS_GROUP 148 | } 149 | 150 | PopMenu MENU 151 | { 152 | POPUP "" 153 | { 154 | MENUITEM "&New Game...", IDM_NEW 155 | MENUITEM "&Open Game...", IDM_OPEN 156 | MENUITEM "&Save Game...", IDM_SAVE 157 | MENUITEM "So&und on/off", IDM_SOUND 158 | MENUITEM "&About Empire...", IDM_ABOUT 159 | MENUITEM SEPARATOR 160 | MENUITEM "E&xit", IDM_CLOSE 161 | } 162 | } 163 | 164 | Empire MENU 165 | { 166 | POPUP "&File" 167 | { 168 | MENUITEM "&New Game...", IDM_NEW 169 | MENUITEM "&Open Game...", IDM_OPEN 170 | MENUITEM "&Save Game...", IDM_SAVE 171 | MENUITEM SEPARATOR 172 | MENUITEM "E&xit", IDM_CLOSE 173 | } 174 | 175 | POPUP "&View" 176 | { 177 | MENUITEM "+ Zoom in", IDM_ZOOMIN 178 | MENUITEM "- Zoom out", IDM_ZOOMOUT 179 | MENUITEM "N Center screen", IDM_N 180 | MENUITEM "O Change POV", IDM_POV 181 | } 182 | 183 | POPUP "&Cmd" 184 | { 185 | MENUITEM "F From To", IDM_F 186 | MENUITEM "G Goto city", IDM_G 187 | MENUITEM "H 20 free moves", IDM_H 188 | MENUITEM "I Direction", IDM_I 189 | MENUITEM "J Sound on/off", IDM_SOUND 190 | MENUITEM "K Wake up", IDM_K 191 | MENUITEM "L Load A/F", IDM_L 192 | MENUITEM "P City production", IDM_P 193 | MENUITEM "R Move randomly", IDM_R 194 | MENUITEM "S Sentry", IDM_S 195 | MENUITEM "U Wake up A/F", IDM_U 196 | MENUITEM "Y Survey", IDM_Y 197 | MENUITEM "Esc Exit mode", IDM_ESC 198 | MENUITEM "< Faster", IDM_FASTER 199 | MENUITEM "> Slower", IDM_SLOWER 200 | } 201 | 202 | POPUP "&Help" 203 | { 204 | MENUITEM "&Help", IDM_HELP 205 | MENUITEM "&About Empire...", IDM_ABOUT 206 | } 207 | } 208 | -------------------------------------------------------------------------------- /empire2.BMP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/empire2.BMP -------------------------------------------------------------------------------- /error.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/error.wav -------------------------------------------------------------------------------- /explode.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/explode.wav -------------------------------------------------------------------------------- /explosi1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/explosi1.wav -------------------------------------------------------------------------------- /f1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/f1.bmp -------------------------------------------------------------------------------- /f2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/f2.bmp -------------------------------------------------------------------------------- /f3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/f3.bmp -------------------------------------------------------------------------------- /f4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/f4.bmp -------------------------------------------------------------------------------- /f5.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/f5.bmp -------------------------------------------------------------------------------- /f6.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/f6.bmp -------------------------------------------------------------------------------- /flyby.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/flyby.wav -------------------------------------------------------------------------------- /fs1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/fs1.bmp -------------------------------------------------------------------------------- /fs2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/fs2.bmp -------------------------------------------------------------------------------- /fs3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/fs3.bmp -------------------------------------------------------------------------------- /fs4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/fs4.bmp -------------------------------------------------------------------------------- /fs5.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/fs5.bmp -------------------------------------------------------------------------------- /fs6.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/fs6.bmp -------------------------------------------------------------------------------- /fuel.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/fuel.wav -------------------------------------------------------------------------------- /gun_1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/gun_1.wav -------------------------------------------------------------------------------- /gun_3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/gun_3.wav -------------------------------------------------------------------------------- /help.txt: -------------------------------------------------------------------------------- 1 | EMPIRE 2 | 3 | (The Wargame of the Century) 4 | 5 | 6 | 7 | Written by Walter Bright 8 | Copyright (c) 1982-2002 by Walter Bright 9 | All Rights Reserved 10 | 11 | visit our web site at: 12 | www.classicempire.com 13 | 14 | 15 | This software is furnished under a license for use only by 16 | the purchaser. This software may not be copied or made 17 | available to any other persons. Title and ownership of the 18 | software shall remain at all times in Walter Bright. 19 | 20 | Walter Bright assumes no liability for the use or misuse 21 | of its software. Liability for any warranties implied or 22 | stated is limited to the replacement of the distribution 23 | media should it be determined to be defective within 24 | thirty days of its purchase. 25 | 26 | 27 | INTRODUCTION 28 | 29 | Congratulations! You have purchased one of the most popular 30 | games on mainframe computers, now made available on the 31 | personal computer. Empire was 32 | originally written by Walter Bright for a PDP-10 at Caltech. 33 | The game has since been converted to run on a DEC VAX, and 34 | has been played for years at Caltech, MIT and at VAX 35 | installations. Empire was rewritten from scratch to run on 36 | smaller computers. 37 | 38 | Empire is a simulation of a global conflict between two to 39 | three implacable foes. No compromise is possible, each must 40 | strive to annihilate the other. The war is conducted over a 41 | large map, with land, sea and cities on it. Each player 42 | manipulates his armies, fighters and ships to try and smash 43 | the others, to reach the goal of total domination of the 44 | world. Empire is not a video arcade-type game. It is a 45 | thinking man's game, as it requires strategy and tactics 46 | instead of hand-eye coordination. 47 | 48 | Warning: Empire has been known to be addictive. Typical games 49 | can take several hours. 50 | 51 | REQUIREMENTS 52 | 53 | Empire is designed to run on a Win32 system, which includes 54 | Windows XP, Windows 2000, Windows NT, etc. It will not 55 | run on 16 bit Windows such as Windows 3.1. 56 | 57 | INSTALLATION 58 | 59 | To install, follow these steps: 60 | 61 | 1) Open a console window. Under XP, this means click on 62 | [Start] followed by [Command Prompt]. 63 | 64 | 2) Switch to the root directory: 65 | 66 | cd \ 67 | 68 | 3) Create the Empire directory: 69 | 70 | md empire 71 | 72 | 4) Unzip the empire.zip file into the \empire directory using 73 | winzip, unzip, etc. 74 | 75 | 5) You may make as many backups as needed for your personal use. 76 | 77 | 78 | GETTING STARTED 79 | 80 | 1) Run Empire from either the command prompt or the Run dialog 81 | box. A window should appear with the Emperor directing an assault. 82 | 83 | 2) Click on the mouse button to bring up the main menu: 84 | 85 | New Game... Start a new game. 86 | Open Game... Continue existing saved game. 87 | Save Game... Save game in progress. 88 | Sound on/off Toggle sound on/off. 89 | About Empire Boring copyright notice. 90 | Exit Leave Empire. 91 | 92 | 3) Click on [New Game...]. This brings up the [New Game] dialog 93 | box. Select the number of computer driven enemy emperors to fight. 94 | 0 is a little boring, and 5 is more challenging. After that, pick 95 | [Demo] to watch the computer emperors fight themselves. Select 96 | [OK] when done, and the game begins. 97 | 98 | 4) A dialog box [City Production Demands] will appear. 99 | 100 | Pick one of the following demands for your initial city to produce: 101 | 102 | A: Armies 103 | F: Fighters 104 | D: Destroyers 105 | T: Troop transports 106 | S: Submarines 107 | R: Cruisers 108 | C: Aircraft carriers 109 | B: Battleships 110 | 111 | For your first game, pressing A for armies is recommended. 112 | 113 | GENERAL INFORMATION 114 | 115 | The game is played on a map of 60 rows by 100 columns. Row 116 | numbers are 0 to 59, column numbers are 0 to 99. Coordinates 117 | are shown as row,col. 118 | 119 | 120 | Each row,col is a tile. Tiles are: 121 | 122 | blank unknown territory 123 | blue sea 124 | green land 125 | * unconquered city 126 | 127 | Each player's pieces are their own colors. You'll be red. 128 | 129 | The entire map is unknown (blank) until you start to explore 130 | it. Beware, however, that you cannot detect enemy pieces 131 | unless you are right next to them. The actual map that you 132 | see on the display is a summary of all the most recent 133 | information that you have about the world. 134 | 135 | Each of your cities can be assigned to produce one of the 136 | pieces. A city is attacked by moving an 137 | army onto it. The army has a 50% chance of conquering it. 138 | Capturing cities is crucial to destroying your opponents. 139 | 140 | An enemy piece is attacked by moving one of your pieces onto 141 | it. Hits are traded off (at a 50% chance of landing on one 142 | piece or the other) until one piece is totally destroyed. 143 | Only one of the pieces will survive the conflict. Each piece 144 | can withstand only so many hits before it is destroyed. 145 | Damage sustained by a piece is cumulative until it is either 146 | destroyed or repaired. The number of hits that each piece can 147 | take are: 148 | 149 | army 1 150 | fighter 1 151 | destroyer 3 152 | troop transport 3 153 | submarine 2 154 | cruiser 8 155 | aircraft carrier 8 156 | battleship 12 157 | 158 | Ships can be repaired by moving them into one of your cities. 159 | 160 | PIECES 161 | 162 | 163 | 164 | Armies: 165 | 166 | Armies are of primary importance. Only armies can capture 167 | cities and take over continents. They move on land at a rate 168 | of 1 move per round. Movement across water is performed using 169 | a troop transport. To board a troop transport, just move your 170 | army onto it. Armies cannot move onto their own cities, they 171 | will be destroyed if they try. Armies drown when moving 172 | across water without the aid of a troop transport. 173 | 174 | Fighters: 175 | 176 | Fighters are airplanes that can move over land or sea at the 177 | rate of 4 moves per round. They have a limited range, 178 | however, of 20 moves before they must refuel. Fighters can 179 | refuel by landing in conquered cities or on one of your 180 | aircraft carriers. Attempting to land in cities that aren't 181 | yours is futile. 182 | 183 | Destroyers, Cruisers, Battleships: 184 | 185 | Ships can move on sea, or can dock in captured cities. They 186 | move at 2 moves per round like all ships, unless they're 187 | heavily damaged. In this case movement drops to 1 move per 188 | round. Ships can be repaired by docking them (moving them 189 | into one of your cities). These ships are normally used to 190 | protect your own troop transports or to menace the enemy's. 191 | Ships run aground and sink if you move them onto dry land. 192 | 193 | Submarines: 194 | 195 | Submarines are like the other ships except that if one should 196 | score a hit against an enemy ship, 3 hits worth of damage is 197 | done instead of 1 (enough to sink the smaller ships!). 198 | 199 | Troop Transports: 200 | 201 | Troop transports are used to carry armies from one continent 202 | to another. They can carry up to 6 armies, less if they're 203 | damaged. Troop transport captains are very short-tempered and 204 | tend to deal abruptly with armies should too many get aboard. 205 | 206 | Aircraft Carriers: 207 | 208 | Carriers can carry and refuel fighters. They can carry a 209 | maximum of 8, less if they're damaged. 210 | 211 | OPERATION 212 | 213 | The program will prompt you to move each piece. The prompt 214 | consists of a short message in the upper left corner of the 215 | screen, and the cursor will be positioned on the map. The 216 | message shows what mode you are in. The modes are: 217 | 218 | Move 219 | Survey 220 | Direction 221 | From To 222 | City Prod 223 | 224 | If no mode message is displayed, the program is not expecting 225 | a command. All commands consist of single keys. No carriage 226 | return is required. 227 | 228 | Direction keys: 229 | 230 | QWE 231 | A D This is the layout of the direction keys 232 | ZXC on a QWERTY keyboard. 233 | 234 | The letters QWEADZXC represent directions of movement, as if 235 | the cursor were situated on the letter S of your keyboard. 236 | For example, E means move upward and to the right. X means 237 | move straight down. The space bar indicates no movement. 238 | 239 | If you have an IBM PC keyboard, the arrow keys may be used 240 | instead. 241 | 242 | Each mode is explained below. 243 | 244 | MOVE MODE 245 | 246 | Most of the game will be spent in move mode. In fact, the 247 | entire game can be played without ever leaving it. In this 248 | mode, the cursor will be positioned over where the piece is, 249 | and the top line of the display will show what the piece is. 250 | You can enter either a move or a command. 251 | 252 | A move is entered by pressing one of the direction keys 253 | indicating the direction that you want the piece to go in. If 254 | you don't want the piece to move, press the space bar. 255 | 256 | The following commands are available in MOVE mode: 257 | 258 | F Set the piece to move towards a specified location. 259 | This will put you in the From To mode. See FUNCTIONS. 260 | 261 | G Set the piece (must be a fighter) moving towards the 262 | nearest owned city or aircraft carrier. 263 | 264 | H Give the enemy 20 free moves. Do this if you feel the 265 | enemy is doing poorly and is not giving you a 266 | sufficient challenge. 267 | 268 | I Set the piece to moving in a specified direction. This 269 | will put you in the Direction mode. See FUNCTIONS. 270 | 271 | J Turn the sound on/off. 272 | 273 | K Awaken the piece the cursor is on. See FUNCTIONS. 274 | 275 | L Set the piece (a troop transport or aircraft carrier) 276 | in the Load Armies or Load Fighters function. See 277 | FUNCTIONS. 278 | 279 | N Center the screen about the current position of the 280 | cursor. 281 | 282 | R Set the piece to moving at random. See FUNCTIONS. 283 | 284 | S Set the piece to be a sentry. See FUNCTIONS. 285 | 286 | U If the piece is a troop transport or an aircraft 287 | carrier, wake up all the armies or fighters that are 288 | aboard. 289 | 290 | V Save the game. The game will be saved in a file called 291 | EMPIRE.DAT on the default drive. The file will be 31000 292 | bytes long. If your disk is too full for it, you will 293 | get an error mesasge. If so, insert an empty (but 294 | formatted) disk in and try again. 295 | 296 | Y Enter SURVEY mode. 297 | 298 | Control Break This is used to exit the program and return 299 | to DOS. 300 | 301 | < Decrease delay time by 1/4 second. This delay time is 302 | the time that messages stay on the screen before the 303 | program moves on. The messages become redundant after a 304 | while, and can be speeded up with this command. 305 | 306 | > Increase delay time by 1/4 second. Use if the messages 307 | flash by too fast. 308 | 309 | 310 | SURVEY MODE 311 | 312 | This mode allows you to travel around and look at the map, 313 | alter the functions assigned to your pieces, change the 314 | production demands given to cities, etc. It is entered using 315 | the Y command from MOVE mode. 316 | 317 | The direction keys move the cursor around. Each time you move 318 | the cursor onto one of your pieces or cities, information on 319 | that piece or city will be displayed. Note that commands in 320 | SURVEY mode operate only on the piece displayed (for 321 | instance, you cannot operate on an army aboard a troop 322 | transport from the SURVEY mode). 323 | 324 | Most commands operate the same as in move mode. The 325 | differences are: 326 | 327 | G Using G when the cursor is on a city sets the FIPATH of 328 | that city to the nearest conquered city or aircraft 329 | carrier. See FIPATH. 330 | 331 | K Using K when the cursor is on a city disables the 332 | city's FIPATH if it has one. See FIPATH. 333 | 334 | P Assign new production demands to a city by putting you 335 | in the CITY PROD mode. 336 | 337 | U Using U when the cursor is on a city awakens all the 338 | pieces that may be in that city. 339 | 340 | V,Y Not available. 341 | 342 | esc Return to MOVE mode. 343 | 344 | DIR MODE 345 | 346 | This mode expects a direction key to be pressed. This will 347 | then assign the direction function to the piece that the 348 | cursor is on. See FUNCTIONS. 349 | 350 | Escape (the esc key) will abort this mode. 351 | 352 | 353 | City Production Demands 354 | 355 | This dialog box is for selecting production demands for a city. 356 | 357 | Production Time 358 | 359 | Key Start Continue 360 | armies A 6 5 361 | fighters F 12 10 362 | destroyers D 24 20 363 | troop transports T 36 30 364 | submarines S 30 25 365 | cruisers R 60 50 366 | aircraft carriers C 72 60 367 | battleships B 90 75 368 | 369 | The start time is the number of rounds required to produce a 370 | piece for the first time. The continuing time is the number 371 | of rounds required to produce subsequent pieces. If you 372 | change the production demands of a city before it has 373 | completed its piece, the partially completed piece will be 374 | discarded. 375 | 376 | FROM TO MODE 377 | 378 | This mode is used to assign the MOVE TO function to a piece. 379 | Move the cursor until it is on the location that you wish to 380 | move the piece to, and press T (as in FROM location TO 381 | location). 382 | 383 | Note: If you are giving the MOVE TO function to a fighter, 384 | the cursor's distance from the fighter cannot exceed 385 | the fighter's fuel remaining. This also applies to 386 | setting the FIPATH of a city. 387 | 388 | Escape will abort this mode. 389 | 390 | FUNCTIONS 391 | 392 | 393 | In order to relieve the tedium of moving each piece each 394 | round, your pieces can be assigned various functions, under 395 | which they move automatically. The functions are: 396 | 397 | NONE No function, or awake. You will be asked for 398 | a move each turn. 399 | 400 | SENTRY The piece will not move. 401 | 402 | RANDOM The piece will move at random subject to the 403 | following conditions: 404 | 405 | 1) The piece will not do anything to cause it 406 | to be destroyed. 407 | 408 | 2) If it is an army, it will board an 409 | unloaded troop transport and wake up if it is 410 | next to one. 411 | 412 | MOVE TO The piece is set to move towards a specified 413 | location. When it arrives, it will return to 414 | the NONE function. If something is in the 415 | way, you will be asked to move the piece 416 | around the obstacle (this is called 417 | temporarilly waking up). 418 | 419 | DIRECTION The piece will move in a specified direction. 420 | It will temporarilly wake up if something is 421 | in its way. 422 | 423 | LOAD ARMIES A troop transport can be assigned this 424 | function, in which case it will go on sentry 425 | duty until it is fully loaded with armies. 426 | 427 | LOAD FIGHTERS Same as LOAD ARMIES, but for aircraft 428 | carriers instead. 429 | 430 | In general, the following constraints apply: 431 | 432 | 1) When a fighter is 10 moves out, it will temporarilly wake 433 | up to give you a chance to return it to a city or carrier for 434 | refueling. The G command comes in handy here. 435 | 436 | 2) Armies always temporarilly wake up if they're next to an 437 | unconquered city. 438 | 439 | 3) All pieces wake up if they're next to an enemy piece. 440 | 441 | FIPATH 442 | 443 | Each of your cities can be assigned a FIPATH. This is a 444 | location, which when a fighter lands in that city, is 445 | assigned to that fighter. It shows up as a MOVE TO function 446 | for the fighter. FIPATHS are assigned to cities from the 447 | SURVEY mode using the F and T commands. Clear the FIPATH 448 | using the K command. FIPATHs are very useful when cities are 449 | producing fighters far from the front, the fighters can be 450 | 'chained' from city to city up to the front. 451 | 452 | 453 | MISCELLANEOUS 454 | 455 | Other players' moves are performed while the computer is 456 | waiting for a command from you. This can be entertaining at 457 | times, like when a piece is destroyed while you are trying to 458 | move it! In any case, there is a 10 to 20 round maximum 459 | spread between players. If you exceed this limit, no more 460 | commands will be accepted until the other players have caught 461 | up a bit. 462 | 463 | Watch out on the map displays. The locations of enemy pieces 464 | shown may not be accurate, as they probably moved since you 465 | detected them! Remember that the map displays only a history 466 | of what you have seen before. 467 | 468 | The computer operated players play by the same rules and 469 | under the same conditions that you do. It has no special 470 | advantages, though it may appear otherwise at times. 471 | 472 | When a new game is started, it may take 100 to 200 rounds of 473 | play before you discover the other players (or they discover 474 | you!). Be patient, it's a large map. 475 | 476 | Be careful of whether you are in MOVE mode or SURVEY mode. 477 | Entering many commands in MOVE mode when you thought you were 478 | in SURVEY mode can run ships aground and drown armies 479 | inadvertantly. 480 | 481 | When in MOVE mode, and the cursor is on a troop transport, 482 | the message at the top of the screen will show whether a 483 | transport is to be moved or an army that is aboard it. Moving 484 | the wrong one can run the transport aground or drown the 485 | army. 486 | 487 | DEMO MODE 488 | 489 | When running in Demo mode, where the computer emperors fight each 490 | other, your initial point of view will be for the Red player. 491 | To cycle through all the players' point of views, type the 'O' 492 | key, or select [View][Change POV]. 493 | -------------------------------------------------------------------------------- /icon.BMP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/icon.BMP -------------------------------------------------------------------------------- /init.d: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * This source is written in the D Programming Language. 12 | * See www.digitalmars.com/d/ for the D specification and compiler. 13 | * 14 | * Use entirely at your own risk. There is no warranty, expressed or implied. 15 | */ 16 | 17 | 18 | import std.string; 19 | 20 | import empire; 21 | import mapdata; 22 | import var; 23 | 24 | /***************************** 25 | * Initialize city variables. 26 | */ 27 | 28 | void citini() 29 | { int loc,i,j,k; 30 | 31 | for (i = CITMAX; i--;) 32 | { memset(&city[i],0,City.sizeof); 33 | city[i].loc = city[i].own = 0; 34 | city[i].phs = -1; // no phase 35 | } 36 | for (i = 0, loc = MAPSIZE; loc--;) 37 | if (typ[map[loc]] == X) 38 | city[i++].loc = loc; 39 | //printf("%d cities\n",i); 40 | assert(i <= CITMAX); 41 | 42 | /* shuffle cities around 43 | */ 44 | 45 | for (i = CITMAX / 2; i--;) 46 | { j = empire.random(CITMAX); 47 | k = empire.random(CITMAX); 48 | loc = city[j].loc; 49 | city[j].loc = city[k].loc; 50 | city[k].loc = loc; // swap city locs 51 | } 52 | } 53 | 54 | 55 | /***************************** 56 | * Select a map. 57 | * Returns: 58 | * 0 success 59 | * !=0 failure 60 | */ 61 | 62 | int selmap() 63 | { 64 | // Use internal maps 65 | int j; 66 | ubyte *d; 67 | int i,a,c,n; 68 | 69 | j = empire.random(5); 70 | d = cast(ubyte *)(*mapdata.mapdata[j]); 71 | i = MAPSIZE - 1; 72 | while ((c = *d) != 0) // 0 marks end of data 73 | { n = (c >> 2) & 63; // count of map values - 1 74 | a = c & 3; // bottom 2 bits 75 | if (a == 0 || // a must be 1,2,3 76 | c == -1 || // error reading file 77 | i - n < 0) // too much data 78 | { 79 | assert(0); 80 | } 81 | while (n-- >= 0) 82 | map[i--] = a; 83 | d++; 84 | } 85 | if (ranq() & 4) flip(); 86 | if (ranq() & 4) klip(); // random map rotations 87 | return 0; 88 | } 89 | 90 | 91 | /*********************** 92 | * Flip map corner to corner. 93 | */ 94 | 95 | void flip() 96 | { int i,j,c; 97 | 98 | i = j = MAPSIZE / 2; 99 | while (i--) 100 | { c = map[j]; 101 | map[j++] = map[i]; 102 | map[i] = c; 103 | } 104 | } 105 | 106 | 107 | /************************ 108 | * Flip map end to end. 109 | */ 110 | 111 | void klip() 112 | { int row,i,j,c; 113 | 114 | row = 0; 115 | while (row < MAPSIZE) 116 | { i = j = (Mcolmx + 1) / 2; 117 | while (i--) 118 | { c = map[row + j]; 119 | map[row + j++] = map[row + i]; 120 | map[row + i] = c; 121 | } 122 | row += Mcolmx + 1; 123 | } 124 | } 125 | 126 | 127 | -------------------------------------------------------------------------------- /intro.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/intro.wav -------------------------------------------------------------------------------- /land.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/land.bmp -------------------------------------------------------------------------------- /machine1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/machine1.wav -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | #_ makefile 2 | # Copyright (c) 1982-2004 by Walter Bright 3 | # All Rights Reserved 4 | # Digital Mars www.digitalmars.com 5 | # Build with the D Programming Language from www.digitalmars.com/d/ 6 | # www.classicempire.com 7 | 8 | DMROOT=\dm 9 | CC=\dmd\bin\dmd 10 | LIBNT=$(DMROOT)\lib 11 | SNN=$(DMROOT)\lib\snn 12 | PHOBOS=\dmd\lib\phobos.lib 13 | 14 | #DFLAGS=-g 15 | #LFLAGS=/co/map/noi 16 | DFLAGS=-O 17 | LFLAGS=/noi/exetype:nt/subsystem:windows:4.0 18 | 19 | HEADERS= winemp.h 20 | 21 | DFILES1= display.d empire.d init.d maps.d 22 | DFILES2= move.d path.d eplayer.d sub2.d text.d 23 | DFILES3= var.d winmain.d mapdata.d printf.d twin.d winemp.d 24 | 25 | DFILES= $(DFILES1) $(DFILES2) $(DFILES3) 26 | 27 | OBJ1= display.obj empire.obj init.obj 28 | OBJ2= maps.obj move.obj path.obj eplayer.obj sub2.obj printf.obj 29 | OBJ3= var.obj mapdata.obj 30 | WOBJ= winmain.obj text.obj twin.obj 31 | 32 | BMP1= city1.bmp a1.bmp f1.bmp fs1.bmp d1.bmp s1.bmp t1.bmp r1.bmp c1.bmp b1.bmp 33 | BMP2= city2.bmp a2.bmp f2.bmp fs2.bmp d2.bmp s2.bmp t2.bmp r2.bmp c2.bmp b2.bmp 34 | BMP3= city3.bmp a3.bmp f3.bmp fs3.bmp d3.bmp s3.bmp t3.bmp r3.bmp c3.bmp b3.bmp 35 | BMP4= city4.bmp a4.bmp f4.bmp fs4.bmp d4.bmp s4.bmp t4.bmp r4.bmp c4.bmp b4.bmp 36 | BMP5= city5.bmp a5.bmp f5.bmp fs5.bmp d5.bmp s5.bmp t5.bmp r5.bmp c5.bmp b5.bmp 37 | BMP6= city6.bmp a6.bmp f6.bmp fs6.bmp d6.bmp s6.bmp t6.bmp r6.bmp c6.bmp b6.bmp 38 | 39 | BMP7= blast.bmp blastmask.bmp icon.bmp empire2.bmp unknown.bmp unknown10.bmp \ 40 | land.bmp sea.bmp city.bmp cursor.bmp empire.ico 41 | 42 | BMP= $(BMP1) $(BMP2) $(BMP3) $(BMP4) $(BMP5) $(BMP6) $(BMP7) 43 | 44 | WAV1=intro.wav click.wav gun_1.wav explosi1.wav error.wav splash.wav bubbles.wav 45 | WAV2=machine1.wav gun_3.wav flyby.wav explode.wav fuel.wav explosion3.wav 46 | WAV3=taps.wav ackack1.wav 47 | 48 | WAV= $(WAV1) $(WAV2) $(WAV3) 49 | 50 | SOURCE= $(HEADERS) $(DFILES) $(BMP) $(WAV) makefile empire.rc empire.def help.txt 51 | 52 | # Makerules: 53 | .d.obj : 54 | $(CC) $(DFLAGS) -c $* 55 | 56 | targets: winemp.exe 57 | 58 | winemp.exe : $(OBJ1) $(OBJ2) $(OBJ3) $(WOBJ) winemp.lnk empire.res empire.def 59 | link @winemp.lnk 60 | 61 | winemp.lnk : makefile 62 | echo $(OBJ1)+ > $*.lnk 63 | echo $(OBJ2)+ >> $*.lnk 64 | echo $(OBJ3)+ >> $*.lnk 65 | echo $(WOBJ)$(LFLAGS) >> $*.lnk 66 | echo $* >> $*.lnk 67 | echo $* >> $*.lnk 68 | echo $(PHOBOS)+ >> $*.lnk 69 | echo $(SNN)+ >> $*.lnk 70 | echo winmm+comdlg32+gdi32+kernel32+user32 >> $*.lnk 71 | echo empire.def >> $*.lnk 72 | echo empire.res >> $*.lnk 73 | 74 | textwin.obj : textwin.d 75 | $(CC) -c -g textwin 76 | 77 | textwin.exe : textwin.obj textwin.def 78 | $(CC) -g textwin.obj winmm.lib comdlg32.lib gdi32.lib kernel32.lib user32.lib textwin.def 79 | 80 | empire.res : empire.rc winemp.h $(BMP) 81 | rc /r empire.rc 82 | 83 | clean: 84 | del empire.map 85 | del *.obj 86 | del empire.lnk 87 | 88 | display.obj: display.d empire.d 89 | mapdata.obj: mapdata.d empire.d 90 | empire.obj: empire.d 91 | init.obj: empire.d init.d 92 | maps.obj: empire.d maps.d 93 | move.obj: empire.d move.d 94 | path.obj: empire.d path.d 95 | eplayer.obj: eplayer.d 96 | printf.obj: printf.d 97 | sub2.obj: empire.d sub2.d 98 | winmain.obj: empire.d winemp.h printf.d winmain.d 99 | twin.obj: empire.d winemp.h twin.d 100 | text.obj: empire.d text.d 101 | var.obj: empire.d var.d 102 | 103 | zip: 104 | zip32 empire *.h *.d *.rc *.def makefile 105 | 106 | empirebin: winemp.exe help.html $(WAV1) $(WAV2) $(WAV3) 107 | del empirebin.zip 108 | zip32 empirebin winemp.exe help.txt 109 | zip32 empirebin $(WAV1) 110 | zip32 empirebin $(WAV2) 111 | zip32 empirebin $(WAV3) 112 | 113 | empiresrc: $(SOURCE) 114 | del empiresrc.zip 115 | zip32 empiresrc $(HEADERS) 116 | zip32 empiresrc $(DFILES1) 117 | zip32 empiresrc $(DFILES2) 118 | zip32 empiresrc $(DFILES3) 119 | zip32 empiresrc $(WAV1) 120 | zip32 empiresrc $(WAV2) 121 | zip32 empiresrc $(WAV3) 122 | zip32 empiresrc $(BMP1) 123 | zip32 empiresrc $(BMP2) 124 | zip32 empiresrc $(BMP3) 125 | zip32 empiresrc $(BMP4) 126 | zip32 empiresrc $(BMP5) 127 | zip32 empiresrc $(BMP6) 128 | zip32 empiresrc $(BMP7) 129 | zip32 empiresrc makefile empire.rc empire.def help.txt 130 | 131 | -------------------------------------------------------------------------------- /mapdata.d: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * This source is written in the D Programming Language. 12 | * See www.digitalmars.com/d/ for the D specification and compiler. 13 | * 14 | * Use entirely at your own risk. There is no warranty, expressed or implied. 15 | */ 16 | 17 | 18 | 19 | // a.map 20 | 21 | ubyte aDotMap[] = 22 | [ 23 | 0x1a,0x13,0x06,0x13,0x36,0x07,0x76,0x07, 24 | 0x06,0x1b,0x02,0x0f,0x66,0x2f,0xb2,0x2f, 25 | 0x01,0x0b,0x66,0x03,0x02,0x33,0x36,0x0f, 26 | 0x6a,0x2f,0x02,0x07,0x52,0x03,0x06,0x0f, 27 | 0x02,0x23,0x02,0x01,0x03,0x2e,0x0b,0x02, 28 | 0x0b,0x5e,0x3b,0x2e,0x07,0x22,0x1f,0x01, 29 | 0x1f,0x02,0x07,0x36,0x0f,0x0a,0x03,0x4a, 30 | 0x2b,0x02,0x17,0x2a,0x07,0x26,0x03,0x0a, 31 | 0x33,0x32,0x07,0x02,0x07,0x02,0x13,0x4a, 32 | 0x23,0x06,0x03,0x02,0x07,0x2e,0x0b,0x0e, 33 | 0x03,0x26,0x27,0x3e,0x0f,0x02,0x03,0x02, 34 | 0x0f,0x56,0x0f,0x42,0x03,0x01,0x06,0x0b, 35 | 0x02,0x0b,0x22,0x27,0x3e,0x0b,0x01,0x12, 36 | 0x0b,0x5e,0x07,0x3a,0x07,0x0a,0x03,0x06, 37 | 0x0f,0x26,0x17,0x42,0x1b,0x0e,0x07,0x01, 38 | 0x03,0x5a,0x01,0x03,0x32,0x07,0x01,0x27, 39 | 0x02,0x07,0x06,0x07,0x0a,0x0f,0x02,0x07, 40 | 0x46,0x0b,0x0a,0x03,0x0e,0x03,0x62,0x03, 41 | 0x36,0x1b,0x01,0x2b,0x0e,0x03,0x02,0x13, 42 | 0x46,0x07,0x3e,0x07,0x3e,0x01,0x0b,0x3e, 43 | 0x2f,0x0a,0x01,0x0a,0x0b,0x0e,0x03,0x42, 44 | 0x07,0x42,0x0f,0x36,0x0b,0x42,0x2f,0x16, 45 | 0x07,0xb2,0x13,0x26,0x0b,0x42,0x33,0x0a, 46 | 0x07,0x62,0x13,0x42,0x03,0x02,0x07,0x2e, 47 | 0x0f,0x3a,0x27,0x01,0x0b,0x6a,0x07,0x0a, 48 | 0x07,0x3e,0x01,0x0f,0x36,0x07,0x3e,0x3b, 49 | 0x5e,0x0b,0x0e,0x03,0x42,0x0b,0x01,0x03, 50 | 0x82,0x37,0x5e,0x0b,0x0a,0x07,0x3a,0x17, 51 | 0x6a,0x07,0x1a,0x01,0x0b,0x06,0x0b,0x4a, 52 | 0x03,0x12,0x27,0x3e,0x03,0x6e,0x0f,0x22, 53 | 0x07,0x62,0x07,0x02,0x17,0x01,0x13,0x01, 54 | 0xaa,0x17,0x8a,0x03,0x02,0x0f,0x02,0x03, 55 | 0x36,0x01,0x82,0x03,0x0a,0x0f,0x6a,0x0f, 56 | 0x0a,0x0b,0xd6,0x17,0x02,0x03,0x01,0x03, 57 | 0x66,0x01,0x13,0x0a,0x07,0x5a,0x03,0x02, 58 | 0x03,0x1e,0x03,0x46,0x23,0x6a,0x0b,0x0a, 59 | 0x0f,0x5e,0x0f,0x1e,0x03,0x3e,0x27,0x66, 60 | 0x0f,0x0a,0x07,0x6a,0x07,0x26,0x01,0x0b, 61 | 0x16,0x0b,0x0e,0x0b,0x01,0x13,0x62,0x07, 62 | 0x02,0x0f,0x06,0x07,0x66,0x03,0x01,0x2e, 63 | 0x03,0x26,0x37,0x3a,0x07,0x06,0x03,0x0e, 64 | 0x03,0x02,0x0f,0x6a,0x07,0x0a,0x03,0x26, 65 | 0x0f,0x01,0x07,0x2a,0x33,0x32,0x07,0x02, 66 | 0x07,0x06,0x03,0x5a,0x01,0x03,0x02,0x03, 67 | 0x12,0x03,0x0a,0x03,0x01,0x07,0x2a,0x03, 68 | 0x36,0x2f,0x1a,0x07,0x16,0x03,0x06,0x03, 69 | 0x0a,0x07,0x52,0x1f,0x06,0x1b,0x26,0x0b, 70 | 0x36,0x0b,0x02,0x17,0x16,0x1b,0x12,0x07, 71 | 0x02,0x17,0x0a,0x07,0x01,0x32,0x27,0x02, 72 | 0x07,0x02,0x07,0x26,0x07,0x32,0x07,0x02, 73 | 0x0f,0x2a,0x1f,0x16,0x1f,0x06,0x07,0x36, 74 | 0x03,0x06,0x07,0x02,0x1f,0x32,0x0b,0x01, 75 | 0x32,0x03,0x02,0x01,0x03,0x32,0x13,0x02, 76 | 0x07,0x0a,0x2f,0x42,0x0b,0x16,0x0f,0x0e, 77 | 0x03,0x62,0x07,0x02,0x03,0x2a,0x0b,0x01, 78 | 0x17,0x02,0x37,0x6a,0x07,0x02,0x17,0x5a, 79 | 0x0f,0x32,0x03,0x06,0x07,0x02,0x37,0x02, 80 | 0x03,0x02,0x03,0x62,0x0b,0x0a,0x0f,0x02, 81 | 0x01,0xa6,0x0b,0x0a,0x03,0x02,0x27,0x02, 82 | 0x0b,0x5a,0x07,0x01,0x03,0x0e,0x07,0x82, 83 | 0x03,0x2e,0x07,0x0e,0x2b,0x02,0x07,0x62, 84 | 0x03,0x86,0x03,0x01,0x12,0x07,0x22,0x07, 85 | 0x0e,0x0b,0x0a,0x23,0xa6,0x03,0x02,0x03, 86 | 0x3e,0x0b,0x0a,0x13,0x4e,0x17,0x76,0x0f, 87 | 0x22,0x0b,0x01,0x03,0x3a,0x0b,0x06,0x0b, 88 | 0x56,0x13,0x01,0x46,0x07,0x22,0x01,0x07, 89 | 0x02,0x03,0x01,0x22,0x0b,0x42,0x0b,0x02, 90 | 0x13,0xaa,0x03,0x02,0x0b,0x52,0x0f,0x4a, 91 | 0x0b,0xba,0x0b,0x02,0x07,0x16,0x07,0x32, 92 | 0x0b,0x01,0x4a,0x0b,0xb2,0x0b,0x02,0x03, 93 | 0x01,0x0b,0x0e,0x13,0x26,0x0b,0x2e,0x17, 94 | 0x06,0x03,0x06,0x07,0xae,0x03,0x02,0x0b, 95 | 0x1e,0x03,0x26,0x03,0x0e,0x03,0x1e,0x23, 96 | 0x0a,0x0b,0x01,0x06,0x03,0xa6,0x07,0x01, 97 | 0x06,0x03,0x1e,0x0f,0x06,0x07,0x06,0x03, 98 | 0x02,0x03,0x02,0x0b,0x16,0x27,0x12,0x13, 99 | 0xb2,0x03,0x2a,0x27,0x0a,0x03,0x02,0x01, 100 | 0x03,0x12,0x03,0x01,0x1f,0x0e,0x0f,0x02, 101 | 0x03,0x02,0x0b,0x5e,0x03,0x01,0x03,0x3a, 102 | 0x03,0x2a,0x0b,0x06,0x03,0x01,0x07,0x22, 103 | 0x37,0x01,0x0a,0x03,0x12,0x0f,0x2e,0x07, 104 | 0x06,0x03,0x16,0x0f,0x2e,0x0b,0x72,0x17, 105 | 0x01,0x23,0x02,0x07,0x16,0x03,0x36,0x0b, 106 | 0x1e,0x13,0x8e,0x03,0x1a,0x2f,0x16,0x03, 107 | 0x01,0x07,0x0a,0x03,0x42,0x0b,0x12,0x0b, 108 | 0x92,0x03,0x06,0x01,0x03,0x02,0x03,0x06, 109 | 0x2f,0x02,0x03,0x06,0x27,0x3a,0x0b,0x1e, 110 | 0x07,0x92,0x43,0x02,0x07,0x06,0x07,0x02, 111 | 0x37,0x32,0x07,0x01,0x02,0x03,0x12,0x03, 112 | 0x0a,0x07,0x26,0x03,0x52,0x1f,0x06,0x1b, 113 | 0x01,0x0a,0x3b,0x02,0x03,0x2a,0x1b,0x12, 114 | 0x0b,0x02,0x03,0x02,0x17,0x02,0x17,0x02, 115 | 0x03,0x46,0x01,0x07,0x16,0x01,0x17,0x0a, 116 | 0x2b,0x01,0x13,0x02,0x03,0x22,0x13,0x0a, 117 | 0x0f,0x0e,0x0b,0x01,0x13,0x02,0x07,0x06, 118 | 0x03,0x01,0x0b,0x4e,0x1b,0x1e,0x3b,0x02, 119 | 0x0f,0x26,0x17,0x26,0x07,0x02,0x13,0x02, 120 | 0x0f,0x02,0x07,0x02,0x07,0x6e,0x0f,0x0a, 121 | 0x3b,0x3a,0x03,0x01,0x0f,0x01,0x26,0x0f, 122 | 0x0a,0x23,0x6e,0x07,0x02,0x07,0x01,0x0b, 123 | 0x02,0x13,0x06,0x23,0x32,0x1f,0x1e,0x13, 124 | 0x0e,0x13,0x02,0x07,0x6a,0x0b,0x1a,0x0f, 125 | 0x02,0x0b,0x02,0x1f,0x32,0x17,0x26,0x13, 126 | 0x02,0x23,0x72,0x03,0x26,0x03,0x06,0x13, 127 | 0x0e,0x0f,0x32,0x0f,0x3a,0x07,0x02,0x1b, 128 | 0x01,0x03,0xae,0x03,0x01,0x07,0x0e,0x07, 129 | 0x02,0x07,0x01,0x07,0x22,0x13,0x2e,0x03, 130 | 0x02,0x03,0x02,0x1f,0x7a,0x03,0x42,0x03, 131 | 0x0a,0x07,0x0a,0x0f,0x22,0x1b,0x1a,0x13, 132 | 0x02,0x1b,0x01,0xfe,0x1e,0x1f,0x12,0x0b, 133 | 0x02,0x2f,0xfe,0x1a,0x00, 134 | ]; 135 | 136 | // b.map 137 | 138 | ubyte bDotMap[] = 139 | [ 140 | 0x13,0x02,0x43,0xba,0x03,0x06,0x03,0x22, 141 | 0x3b,0x06,0x13,0x02,0x3f,0x01,0xba,0x17, 142 | 0x1a,0x0f,0x02,0x23,0x06,0x0b,0x06,0x3f, 143 | 0x02,0x07,0x56,0x07,0x5a,0x0b,0x02,0x03, 144 | 0x0e,0x63,0x02,0x1f,0x01,0x1b,0x5a,0x01, 145 | 0x07,0x5a,0x0f,0x02,0x3f,0x01,0x0f,0x02, 146 | 0x03,0x01,0x03,0x02,0x03,0x02,0x03,0x0a, 147 | 0x37,0x5a,0x0b,0x62,0x01,0x0e,0x3f,0x0a, 148 | 0x03,0x02,0x13,0x06,0x37,0x02,0x07,0x46, 149 | 0x0b,0x02,0x0b,0x7a,0x01,0x2f,0x16,0x0f, 150 | 0x12,0x1f,0x01,0x2f,0x2e,0x07,0x02,0x17, 151 | 0x01,0x82,0x0f,0x0e,0x03,0x36,0x2b,0x02, 152 | 0x07,0x06,0x07,0x02,0x0f,0x2a,0x03,0x06, 153 | 0x07,0x02,0x0b,0x7e,0x0f,0x02,0x03,0x0e, 154 | 0x07,0x2e,0x1b,0x02,0x03,0x02,0x0f,0x02, 155 | 0x01,0x12,0x0b,0x3a,0x07,0x06,0x03,0x7a, 156 | 0x0b,0x06,0x03,0x4a,0x1b,0x06,0x0b,0x02, 157 | 0x07,0x1a,0x07,0xd2,0x13,0x52,0x03,0x0a, 158 | 0x07,0x02,0x03,0x0a,0x03,0x0e,0x13,0x3a, 159 | 0x07,0x02,0x03,0x06,0x07,0x7e,0x03,0x01, 160 | 0x03,0x56,0x0b,0x0a,0x0b,0x02,0x03,0x1a, 161 | 0x0b,0x2e,0x0b,0x06,0x13,0x01,0x03,0xde, 162 | 0x03,0x0a,0x17,0x4e,0x13,0x02,0x07,0x06, 163 | 0x0f,0xda,0x0b,0x02,0x03,0x01,0x07,0x5a, 164 | 0x03,0x02,0x03,0x01,0x02,0x07,0x0e,0x07, 165 | 0xde,0x17,0x3e,0x07,0x0a,0x53,0x56,0x03, 166 | 0x52,0x0b,0x12,0x03,0x02,0x07,0x46,0x17, 167 | 0x01,0x27,0x02,0x1b,0x01,0x03,0x4a,0x01, 168 | 0x03,0x02,0x0b,0x16,0x03,0x26,0x0b,0x76, 169 | 0x03,0x02,0x5b,0x3e,0x0f,0x0a,0x0b,0x0e, 170 | 0x07,0x22,0x03,0x02,0x07,0x22,0x03,0x52, 171 | 0x47,0x02,0x0f,0x42,0x13,0x26,0x03,0x1e, 172 | 0x03,0x02,0x07,0x02,0x03,0x1e,0x03,0x52, 173 | 0x03,0x02,0x03,0x06,0x01,0x2b,0x06,0x07, 174 | 0x56,0x03,0x06,0x03,0x0e,0x03,0x06,0x07, 175 | 0x16,0x03,0x01,0x13,0x22,0x03,0x52,0x07, 176 | 0x0a,0x3b,0x22,0x01,0x36,0x0f,0x0e,0x17, 177 | 0x0a,0x1f,0x22,0x07,0x4a,0x07,0x0a,0x03, 178 | 0x02,0x1b,0x06,0x0f,0x02,0x03,0x62,0x01, 179 | 0x07,0x0a,0x03,0x01,0x0f,0x02,0x07,0x1a, 180 | 0x03,0x16,0x0b,0x02,0x03,0x5e,0x13,0x01, 181 | 0x0f,0x06,0x07,0x82,0x23,0x26,0x07,0x02, 182 | 0x13,0x5e,0x03,0x02,0x2b,0x02,0x03,0x01, 183 | 0x86,0x1f,0x1a,0x0f,0x06,0x03,0x02,0x0b, 184 | 0x0a,0x07,0x4a,0x17,0x06,0x0f,0x02,0x07, 185 | 0x8a,0x0b,0x01,0x0b,0x26,0x0f,0x02,0x1b, 186 | 0x02,0x03,0x52,0x0b,0x0a,0x03,0x01,0x07, 187 | 0x06,0x03,0x42,0x03,0x46,0x0b,0x2e,0x13, 188 | 0x0a,0x01,0x0b,0x01,0x06,0x0b,0x22,0x07, 189 | 0x36,0x17,0x2e,0x1f,0x3a,0x07,0x42,0x01, 190 | 0x0a,0x1b,0x06,0x07,0x1a,0x07,0x06,0x07, 191 | 0x2e,0x03,0x02,0x03,0x2a,0x07,0x02,0x0b, 192 | 0x06,0x01,0x0b,0x02,0x0b,0x01,0x22,0x03, 193 | 0x56,0x1b,0x02,0x07,0x26,0x0f,0x02,0x03, 194 | 0x2e,0x03,0x01,0x07,0x22,0x01,0x07,0x16, 195 | 0x0f,0x02,0x03,0xe6,0x03,0x01,0x07,0x26, 196 | 0x13,0x1a,0x1f,0x02,0x0b,0x06,0x07,0xde, 197 | 0x1b,0x2e,0x03,0x26,0x0f,0x1e,0x03,0x1a, 198 | 0x03,0xa6,0x03,0x1a,0x0f,0x52,0x07,0x0a, 199 | 0x03,0x0a,0x07,0x01,0x0a,0x07,0x0e,0x13, 200 | 0x2a,0x0b,0x66,0x0b,0x02,0x03,0x02,0x0f, 201 | 0x56,0x13,0x12,0x17,0x02,0x03,0x16,0x03, 202 | 0x3a,0x07,0x66,0x0f,0x02,0x1b,0x4a,0x03, 203 | 0x0a,0x0f,0x0a,0x17,0x0e,0x01,0x0b,0x3e, 204 | 0x07,0x5a,0x07,0x06,0x2f,0x4a,0x03,0x02, 205 | 0x17,0x02,0x23,0x06,0x07,0x3e,0x07,0x01, 206 | 0x03,0x5e,0x3b,0x4a,0x07,0x16,0x03,0x02, 207 | 0x13,0x01,0x07,0x02,0x07,0x01,0x42,0x0b, 208 | 0x5a,0x43,0x6a,0x1f,0x02,0x0b,0x46,0x0b, 209 | 0x5a,0x2f,0x01,0x03,0x6a,0x27,0x0e,0x03, 210 | 0x4a,0x03,0x02,0x03,0x06,0x0b,0x3e,0x01, 211 | 0x03,0x02,0x2b,0x72,0x1b,0x01,0x03,0x4e, 212 | 0x0f,0x01,0x23,0x3e,0x0b,0x02,0x0f,0x82, 213 | 0x0f,0x01,0x13,0x3a,0x3f,0x02,0x07,0x22, 214 | 0x03,0x06,0x23,0x56,0x01,0x2a,0x13,0x06, 215 | 0x0f,0x3e,0x37,0x02,0x0b,0x26,0x0b,0x6e, 216 | 0x0f,0x26,0x07,0x02,0x03,0x12,0x03,0x3e, 217 | 0x07,0x01,0x07,0x02,0x33,0x02,0x01,0x22, 218 | 0x03,0x6e,0x17,0x26,0x03,0x5a,0x13,0x02, 219 | 0x03,0x02,0x2b,0x06,0x0b,0x8e,0x01,0x0f, 220 | 0x92,0x07,0x12,0x07,0x06,0x37,0xfe,0x0e, 221 | 0x0b,0x16,0x03,0x01,0x03,0x0e,0x3f,0xea, 222 | 0x07,0x16,0x03,0x02,0x01,0x26,0x01,0x02, 223 | 0x03,0x06,0x1b,0x02,0x0b,0x02,0x07,0xee, 224 | 0x07,0x0e,0x07,0x0a,0x01,0x26,0x0f,0x02, 225 | 0x03,0x1a,0x0f,0x02,0x01,0x66,0x0f,0x6a, 226 | 0x03,0x01,0x03,0x06,0x07,0x01,0x13,0x12, 227 | 0x0b,0x0a,0x17,0x22,0x03,0x4e,0x01,0x0b, 228 | 0x16,0x03,0x02,0x03,0x02,0x01,0x03,0x02, 229 | 0x03,0x4e,0x07,0x06,0x03,0x06,0x0b,0x06, 230 | 0x07,0x12,0x07,0x02,0x01,0x0b,0x02,0x0b, 231 | 0x2a,0x07,0x4a,0x17,0x0e,0x07,0x02,0x0b, 232 | 0x52,0x13,0x02,0x07,0x02,0x07,0x06,0x07, 233 | 0x2a,0x0f,0x2e,0x07,0x4e,0x07,0x06,0x1b, 234 | 0x12,0x07,0x4e,0x1f,0x82,0x03,0x56,0x07, 235 | 0x02,0x17,0x0e,0x07,0x01,0x4e,0x07,0x02, 236 | 0x0f,0x76,0x01,0x0b,0x5e,0x03,0x0a,0x07, 237 | 0x1a,0x07,0x0a,0x03,0x46,0x0b,0x82,0x03, 238 | 0x0e,0x07,0x01,0x03,0x42,0x13,0x1a,0x0b, 239 | 0x06,0x13,0x3a,0x03,0x02,0x03,0x82,0x03, 240 | 0x12,0x0b,0x42,0x13,0x22,0x01,0x23,0xbe, 241 | 0x07,0x1a,0x07,0x02,0x0b,0x46,0x03,0x1a, 242 | 0x23,0x02,0x03,0x12,0x07,0x3e,0x0f,0x0a, 243 | 0x0f,0x0e,0x07,0x02,0x07,0x0e,0x07,0x22, 244 | 0x17,0x5a,0x3b,0x01,0x0b,0x3e,0x03,0x0a, 245 | 0x03,0x06,0x03,0x0e,0x03,0x06,0x03,0x06, 246 | 0x03,0x06,0x03,0x0a,0x03,0x2a,0x03,0x01, 247 | 0x03,0x6a,0x43,0x42,0x0f,0x0a,0x0b,0x02, 248 | 0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x16, 249 | 0x03,0x02,0x03,0x16,0x07,0x72,0x3f,0x0a, 250 | 0x07,0x02,0x0b,0x01,0x0b,0x0a,0x03,0x0a, 251 | 0x03,0x1a,0x03,0x06,0x03,0x12,0x03,0x0a, 252 | 0x07,0x02,0x0f,0x16,0x0b,0x6e,0x1f,0x02, 253 | 0x03,0x02,0x1b,0x06,0x03,0x02,0x13,0x12, 254 | 0x0f,0x0a,0x0f,0x0a,0x03,0x12,0x03,0x06, 255 | 0x07,0x02,0x1b,0x0e,0x07,0x76,0x1b,0x06, 256 | 0x03,0x3a,0x03,0x6e,0x00, 257 | ]; 258 | 259 | 260 | // c.map 261 | 262 | ubyte cDotMap[] = 263 | [ 264 | 0x02,0x0b,0xc2,0x13,0x06,0x1f,0x02,0x07, 265 | 0x42,0x3f,0xc6,0x47,0x3a,0x3f,0xca,0x0f, 266 | 0x01,0x33,0x36,0x47,0xc6,0x1f,0x02,0x1f, 267 | 0x3e,0x07,0x01,0x3b,0x46,0x01,0x7a,0x23, 268 | 0x01,0x1f,0x3e,0x03,0x02,0x17,0x01,0x1b, 269 | 0x62,0x03,0x5a,0x2f,0x02,0x03,0x01,0x06, 270 | 0x07,0x42,0x0f,0x06,0x13,0x02,0x07,0x62, 271 | 0x07,0x62,0x17,0x06,0x1b,0x52,0x07,0x0a, 272 | 0x1f,0x4e,0x0b,0x02,0x07,0x5a,0x07,0x02, 273 | 0x0f,0x02,0x03,0x0a,0x03,0x02,0x07,0x56, 274 | 0x07,0x12,0x13,0x52,0x07,0x02,0x1b,0x01, 275 | 0x46,0x03,0x02,0x03,0x01,0x17,0x0a,0x01, 276 | 0x02,0x03,0x02,0x01,0x0b,0x6a,0x03,0x56, 277 | 0x2f,0x4e,0x1f,0x0e,0x0b,0xce,0x0b,0x02, 278 | 0x2b,0x4a,0x07,0x0e,0x03,0x5e,0x03,0x01, 279 | 0x5a,0x07,0x2a,0x0f,0x01,0x0f,0x01,0x52, 280 | 0x03,0x0a,0x03,0x01,0x5e,0x0f,0x86,0x03, 281 | 0x01,0x27,0xbe,0x1b,0x86,0x1f,0xd2,0x1f, 282 | 0x52,0x03,0x26,0x1f,0x52,0x07,0x0e,0x07, 283 | 0x06,0x03,0x52,0x0b,0x01,0x56,0x07,0x01, 284 | 0x26,0x07,0x01,0x0e,0x03,0x6e,0x0f,0x5a, 285 | 0x0b,0x02,0x0b,0x46,0x03,0x8e,0x03,0x02, 286 | 0x07,0x12,0x03,0x02,0x17,0x36,0x0f,0x0e, 287 | 0x17,0x4a,0x0b,0x7e,0x0b,0x02,0x01,0x1b, 288 | 0x06,0x07,0x22,0x03,0x1a,0x07,0x1a,0x1b, 289 | 0x3e,0x0b,0x2a,0x07,0x32,0x0f,0x01,0x02, 290 | 0x27,0x02,0x0b,0x06,0x0b,0x16,0x07,0x12, 291 | 0x07,0x1e,0x17,0x02,0x03,0x3e,0x13,0x12, 292 | 0x0f,0x32,0x03,0x02,0x01,0x13,0x02,0x07, 293 | 0x01,0x07,0x02,0x13,0x2a,0x17,0x0a,0x0f, 294 | 0x16,0x1b,0x3a,0x07,0x06,0x07,0x12,0x07, 295 | 0x0e,0x03,0x2a,0x07,0x06,0x23,0x02,0x0b, 296 | 0x32,0x13,0x12,0x0b,0x1e,0x0f,0x0a,0x07, 297 | 0x26,0x03,0x02,0x17,0x16,0x0b,0x01,0x07, 298 | 0x2a,0x0b,0x02,0x1f,0x0a,0x0f,0x2e,0x2b, 299 | 0x2a,0x03,0x0e,0x03,0x22,0x1f,0x01,0x03, 300 | 0x0e,0x17,0x2a,0x0b,0x0a,0x0f,0x16,0x17, 301 | 0x2a,0x2b,0x3a,0x0f,0x1e,0x27,0x06,0x0f, 302 | 0x4e,0x0f,0x1e,0x0b,0x36,0x07,0x01,0x0f, 303 | 0x46,0x07,0x32,0x0f,0x0a,0x07,0x3e,0x07, 304 | 0x01,0x03,0x0e,0x03,0x01,0x1e,0x07,0x3e, 305 | 0x13,0x01,0x32,0x03,0x06,0x01,0x07,0x46, 306 | 0x07,0x06,0x03,0x42,0x0f,0x36,0x03,0x32, 307 | 0x0f,0x06,0x07,0x2a,0x23,0x4a,0x0b,0x46, 308 | 0x0f,0x06,0x07,0x01,0x03,0x56,0x03,0x1a, 309 | 0x03,0x01,0x03,0x1e,0x23,0x4e,0x01,0x03, 310 | 0x4e,0x03,0x0e,0x0b,0x9e,0x27,0x01,0x5e, 311 | 0x0b,0x02,0x07,0x22,0x0f,0x02,0x13,0x9e, 312 | 0x27,0x6a,0x07,0x2a,0x23,0xa2,0x2b,0x02, 313 | 0x03,0x4a,0x0b,0x02,0x07,0x3a,0x17,0x32, 314 | 0x03,0x56,0x0b,0x02,0x03,0x06,0x33,0x42, 315 | 0x01,0x1f,0x01,0x26,0x1f,0x26,0x0f,0x5e, 316 | 0x07,0x02,0x3b,0x3a,0x1f,0x36,0x07,0x32, 317 | 0x1f,0x62,0x3b,0x42,0x27,0x66,0x13,0x1a, 318 | 0x07,0x02,0x0b,0x2e,0x37,0x66,0x07,0x5e, 319 | 0x03,0x01,0x1f,0x16,0x0f,0x06,0x07,0x26, 320 | 0x3b,0x46,0x03,0x7e,0x27,0x1a,0x07,0x02, 321 | 0x17,0x16,0x07,0x01,0x0f,0x02,0x23,0x3e, 322 | 0x01,0x03,0x02,0x07,0x7a,0x23,0x26,0x0b, 323 | 0x0a,0x0b,0x02,0x07,0x02,0x1f,0x02,0x0b, 324 | 0x01,0x46,0x03,0x8e,0x27,0x26,0x0f,0x0a, 325 | 0x07,0x0a,0x13,0x0e,0x07,0x4a,0x23,0x72, 326 | 0x1f,0x2e,0x0b,0x05,0x07,0x1a,0x07,0x66, 327 | 0x13,0x82,0x07,0x01,0x0f,0x2a,0x23,0x1e, 328 | 0x07,0x66,0x03,0x01,0x0b,0x82,0x17,0x32, 329 | 0x1b,0x1a,0x03,0x76,0x0b,0x3a,0x03,0x06, 330 | 0x07,0x32,0x13,0x36,0x17,0x9e,0x01,0x03, 331 | 0x36,0x03,0x01,0x0b,0x32,0x17,0x01,0x0b, 332 | 0x2e,0x07,0x01,0x07,0x01,0xda,0x13,0x46, 333 | 0x01,0x03,0x36,0x0b,0x02,0x07,0xda,0x1f, 334 | 0x36,0x0b,0x1a,0x03,0x0e,0x0f,0x0e,0x03, 335 | 0x06,0x03,0xbe,0x27,0x62,0x07,0x01,0x07, 336 | 0x1e,0x0b,0xc6,0x03,0x06,0x0f,0x66,0x0b, 337 | 0x3a,0x07,0xa6,0x01,0x12,0x17,0x42,0x03, 338 | 0x1e,0x0f,0x3a,0x07,0x9e,0x0b,0x0a,0x03, 339 | 0x01,0x0b,0x12,0x07,0x26,0x13,0x1e,0x07, 340 | 0x3a,0x0b,0x4a,0x03,0x01,0x0f,0x32,0x07, 341 | 0x0e,0x17,0x0e,0x07,0x2e,0x03,0x06,0x03, 342 | 0x1e,0x03,0x3e,0x0b,0x0a,0x03,0x36,0x1f, 343 | 0x06,0x0b,0x1e,0x03,0x02,0x07,0x02,0x0b, 344 | 0x02,0x0b,0x02,0x0f,0x1e,0x03,0x0a,0x01, 345 | 0x03,0x02,0x03,0x4a,0x0b,0x06,0x03,0x02, 346 | 0x0f,0x02,0x03,0x3a,0x0f,0x0a,0x0b,0x22, 347 | 0x0b,0x06,0x1f,0x01,0x0b,0x1e,0x0b,0x02, 348 | 0x07,0x01,0x03,0x4e,0x01,0x37,0x01,0x3e, 349 | 0x13,0x3e,0x03,0x01,0x02,0x27,0x1a,0x1f, 350 | 0x46,0x07,0x02,0x0b,0x05,0x23,0x36,0x1b, 351 | 0x3a,0x07,0x0a,0x17,0x2a,0x0f,0x02,0x03, 352 | 0x3e,0x13,0x02,0x03,0x01,0x2b,0x3a,0x07, 353 | 0x02,0x0b,0x01,0x07,0x06,0x0b,0x01,0x03, 354 | 0x16,0x07,0x0a,0x0f,0x3e,0x01,0x03,0x46, 355 | 0x0b,0x02,0x2b,0x01,0x0b,0x2e,0x0b,0x0a, 356 | 0x13,0x0a,0x01,0x0b,0x16,0x03,0x5a,0x0b, 357 | 0x4a,0x43,0x3a,0x0b,0x1a,0x23,0x56,0x03, 358 | 0x0a,0x0f,0x02,0x0f,0x36,0x03,0x02,0x37, 359 | 0x02,0x03,0x52,0x1b,0x06,0x0f,0x01,0x02, 360 | 0x07,0x3e,0x07,0x01,0x03,0x02,0x17,0x4a, 361 | 0x3f,0x6e,0x07,0x02,0x17,0x42,0x2f,0x4a, 362 | 0x2f,0x76,0x03,0x02,0x03,0x02,0x03,0x06, 363 | 0x07,0x42,0x07,0x02,0x23,0x52,0x1b,0x00, 364 | ]; 365 | 366 | 367 | // d.map 368 | 369 | ubyte dDotMap[] = 370 | [ 371 | 0xfe,0x16,0x07,0x4a,0x07,0x02,0x1b,0x16, 372 | 0x0b,0xee,0x1b,0x3a,0x17,0x02,0x03,0x1e, 373 | 0x0b,0xee,0x07,0x0e,0x03,0x32,0x03,0x02, 374 | 0x0b,0x01,0x0b,0x0e,0x0b,0x02,0x07,0xfe, 375 | 0x0b,0x3a,0x27,0x02,0x1b,0x02,0x03,0xee, 376 | 0x17,0x2e,0x3b,0x01,0x1b,0xee,0x0f,0x32, 377 | 0x57,0xf2,0x07,0x3e,0x63,0x02,0x03,0x02, 378 | 0x03,0xd2,0x03,0x22,0x0b,0x0e,0x01,0x5f, 379 | 0x02,0x13,0xca,0x0b,0x26,0x01,0x07,0x02, 380 | 0x0b,0x01,0x17,0x02,0x03,0x02,0x13,0x01, 381 | 0x33,0xca,0x07,0x2a,0x07,0x02,0x07,0x02, 382 | 0x17,0x01,0x23,0x02,0x0f,0x02,0x0f,0x7e, 383 | 0x03,0x42,0x03,0x02,0x17,0x42,0x13,0x06, 384 | 0x0b,0x02,0x0b,0x0a,0x07,0x0a,0x03,0x6a, 385 | 0x03,0x12,0x0b,0x2e,0x27,0x4e,0x07,0x16, 386 | 0x0f,0x02,0x0f,0x72,0x0f,0x12,0x07,0x2e, 387 | 0x03,0x01,0x27,0x6e,0x07,0x06,0x0f,0x5e, 388 | 0x03,0x01,0x02,0x1f,0x06,0x0f,0x2e,0x01, 389 | 0x23,0x72,0x07,0x02,0x0b,0x62,0x1b,0x02, 390 | 0x1b,0x06,0x03,0x01,0x03,0x16,0x01,0x03, 391 | 0x0a,0x17,0x01,0x0b,0x76,0x0b,0x22,0x01, 392 | 0x3e,0x1f,0x0a,0x07,0x0e,0x0b,0x0a,0x07, 393 | 0x01,0x02,0x03,0x0a,0x17,0x01,0x0b,0x6e, 394 | 0x17,0x5e,0x23,0x26,0x07,0x16,0x07,0x0e, 395 | 0x03,0x01,0x03,0x02,0x0f,0x76,0x03,0x02, 396 | 0x0f,0x5a,0x0b,0x01,0x1b,0x22,0x07,0x1a, 397 | 0x0f,0x02,0x07,0x7e,0x0b,0x0a,0x0b,0x02, 398 | 0x07,0x4a,0x03,0x01,0x1f,0x06,0x03,0x1e, 399 | 0x03,0x02,0x03,0x0a,0x03,0x0a,0x0f,0x02, 400 | 0x07,0x9a,0x0f,0x3e,0x2f,0x02,0x07,0x1a, 401 | 0x07,0x02,0x0b,0x02,0x07,0x06,0x0b,0x06, 402 | 0x07,0xa2,0x07,0x3e,0x07,0x06,0x1f,0x26, 403 | 0x0b,0x0a,0x13,0x16,0x01,0x1e,0x07,0x0a, 404 | 0x03,0x6a,0x0b,0x36,0x0b,0x06,0x07,0x02, 405 | 0x17,0x22,0x2f,0x2e,0x0f,0x0a,0x03,0x02, 406 | 0x01,0xaa,0x0b,0x12,0x1b,0x0a,0x03,0x16, 407 | 0x01,0x02,0x03,0x12,0x07,0x26,0x17,0x02, 408 | 0x17,0x5e,0x03,0x46,0x0b,0x1a,0x07,0x02, 409 | 0x01,0x0b,0x3e,0x07,0x22,0x0b,0x02,0x13, 410 | 0x01,0x0b,0x52,0x13,0x0e,0x03,0x01,0x2e, 411 | 0x03,0x3e,0x07,0x72,0x01,0x1b,0x52,0x2f, 412 | 0x22,0x0b,0x32,0x17,0x7a,0x03,0x02,0x0b, 413 | 0x52,0x27,0x02,0x07,0x1a,0x0f,0x2e,0x1b, 414 | 0x7e,0x03,0x06,0x03,0x4e,0x33,0x2a,0x03, 415 | 0x46,0x03,0x01,0x03,0x76,0x07,0x4e,0x17, 416 | 0x01,0x1b,0x66,0x0f,0x02,0x17,0x06,0x03, 417 | 0x5e,0x03,0x02,0x03,0x01,0x46,0x27,0x0a, 418 | 0x07,0x02,0x03,0x52,0x17,0x01,0x1f,0xbe, 419 | 0x13,0x02,0x07,0x12,0x0f,0x46,0x43,0xba, 420 | 0x03,0x06,0x0f,0x1e,0x0f,0x42,0x03,0x01, 421 | 0x07,0x06,0x0f,0x01,0x02,0x0b,0x7a,0x01, 422 | 0x3e,0x03,0x02,0x17,0x7e,0x03,0x0e,0x03, 423 | 0x06,0x03,0x7e,0x13,0x32,0x07,0x06,0x0b, 424 | 0x02,0x03,0x3e,0x03,0xe2,0x03,0x01,0x36, 425 | 0x0b,0x0e,0x07,0x46,0x07,0xe2,0x07,0x8a, 426 | 0x0f,0xde,0x03,0x01,0x0b,0x86,0x03,0x06, 427 | 0x0b,0x52,0x01,0x0b,0x7e,0x07,0x86,0x0b, 428 | 0x01,0x0f,0x06,0x07,0x3e,0x0b,0x86,0x03, 429 | 0x01,0x76,0x2b,0x02,0x01,0x03,0x3a,0x03, 430 | 0x06,0x0b,0x7e,0x0f,0x6e,0x1b,0x02,0x0f, 431 | 0x06,0x0b,0x32,0x17,0x7e,0x07,0x01,0x0b, 432 | 0x6a,0x03,0x01,0x07,0x0a,0x03,0x16,0x0b, 433 | 0x22,0x23,0x01,0x76,0x01,0x0f,0x01,0x03, 434 | 0x76,0x03,0x2e,0x07,0x22,0x07,0x0e,0x0b, 435 | 0x72,0x13,0x06,0x03,0x32,0x0f,0x62,0x0b, 436 | 0xba,0x13,0x02,0x03,0x2a,0x0b,0x02,0x0f, 437 | 0x56,0x07,0xc2,0x0b,0x1e,0x13,0x0e,0x03, 438 | 0x02,0x0f,0x4a,0x17,0xc6,0x0f,0x16,0x0f, 439 | 0x06,0x0b,0x02,0x01,0x0f,0x46,0x0b,0x02, 440 | 0x07,0xd2,0x0b,0x0e,0x0b,0x06,0x2f,0x3a, 441 | 0x23,0xd2,0x0f,0x02,0x47,0x42,0x23,0xce, 442 | 0x3f,0x02,0x13,0x02,0x01,0x2e,0x2f,0xda, 443 | 0x07,0x01,0x27,0x02,0x0b,0x01,0x13,0x2e, 444 | 0x01,0x1b,0xee,0x27,0x06,0x0b,0x3a,0x07, 445 | 0x01,0x1f,0xe6,0x1b,0x01,0x0f,0x02,0x13, 446 | 0x36,0x17,0x1a,0x07,0x01,0xd2,0x01,0x07, 447 | 0x01,0x33,0x36,0x03,0x02,0x03,0x0e,0x07, 448 | 0x0e,0x07,0xe2,0x01,0x33,0x3a,0x07,0x0e, 449 | 0x0f,0x02,0x03,0xe6,0x1f,0x01,0x13,0x46, 450 | 0x01,0x0e,0x13,0xe6,0x2f,0x02,0x03,0x02, 451 | 0x07,0x4a,0x0f,0x92,0x01,0x56,0x13,0x01, 452 | 0x13,0x01,0x27,0x3a,0x03,0x01,0x03,0xee, 453 | 0x1f,0x01,0x13,0x0a,0x17,0xfe,0x2a,0x2f, 454 | 0x02,0x0b,0x0a,0x0b,0x01,0x03,0xfe,0x2e, 455 | 0x01,0x33,0x0e,0x0b,0xfe,0x3e,0x03,0x0e, 456 | 0x0b,0x00, 457 | ]; 458 | 459 | 460 | // e.map 461 | 462 | ubyte eDotMap[] = 463 | [ 464 | 0x17,0x02,0x0b,0x02,0x0b,0xa6,0x4f,0x3e, 465 | 0x0b,0x02,0x13,0x01,0x17,0x02,0x07,0x46, 466 | 0x13,0x52,0x53,0x32,0x07,0x02,0x4f,0x46, 467 | 0x03,0x01,0x07,0x52,0x0b,0x01,0x3f,0x3a, 468 | 0x47,0x02,0x0b,0x4a,0x13,0x56,0x0f,0x01, 469 | 0x37,0x2e,0x57,0x56,0x07,0x5a,0x43,0x02, 470 | 0x07,0x26,0x1f,0x01,0x1f,0x01,0x0f,0x5a, 471 | 0x07,0x01,0x0b,0x46,0x43,0x4a,0x43,0x06, 472 | 0x03,0x4a,0x0f,0x01,0x03,0x42,0x0f,0x01, 473 | 0x2f,0x01,0x52,0x4f,0x46,0x01,0x13,0x12, 474 | 0x03,0x2e,0x43,0x5a,0x0f,0x02,0x13,0x02, 475 | 0x1b,0x4a,0x1b,0x01,0x13,0x22,0x27,0x0e, 476 | 0x07,0x2a,0x07,0x2a,0x07,0x01,0x06,0x2f, 477 | 0x02,0x07,0x01,0x3a,0x3b,0x1e,0x03,0x0e, 478 | 0x0b,0x06,0x03,0x3e,0x07,0x02,0x13,0x1a, 479 | 0x03,0x02,0x1b,0x02,0x07,0x02,0x03,0x62, 480 | 0x07,0x06,0x07,0x02,0x13,0x2a,0x03,0x01, 481 | 0x0b,0x02,0x03,0x16,0x03,0x0a,0x0b,0x0e, 482 | 0x2f,0x01,0x06,0x07,0x02,0x0f,0x06,0x03, 483 | 0x6e,0x33,0x2e,0x0f,0x2e,0x07,0x12,0x1f, 484 | 0x1e,0x0f,0x86,0x23,0x36,0x0b,0x36,0x0b, 485 | 0x06,0x1b,0xba,0x1f,0x7e,0x2f,0x12,0x03, 486 | 0xa2,0x0b,0x22,0x03,0x66,0x0b,0x06,0x27, 487 | 0x02,0x1b,0x42,0x01,0x46,0x13,0x26,0x0b, 488 | 0x6a,0x37,0x02,0x13,0x0a,0x03,0x7a,0x07, 489 | 0x02,0x03,0x36,0x0f,0x02,0x0b,0x4e,0x4b, 490 | 0x02,0x0b,0x7e,0x07,0x3e,0x0b,0x02,0x0f, 491 | 0x52,0x53,0xb6,0x0f,0x06,0x0b,0x01,0x03, 492 | 0x06,0x03,0x3a,0x4b,0x02,0x07,0x62,0x07, 493 | 0x4e,0x07,0x02,0x03,0x06,0x07,0x02,0x1f, 494 | 0x36,0x03,0x01,0x1b,0x01,0x1f,0x6e,0x0f, 495 | 0x4a,0x13,0x06,0x27,0x26,0x0f,0x06,0x0f, 496 | 0x02,0x27,0x76,0x1b,0x3a,0x0f,0x01,0x33, 497 | 0x1a,0x07,0x02,0x03,0x0a,0x03,0x06,0x03, 498 | 0x02,0x2f,0x3a,0x01,0x07,0x0a,0x07,0x02, 499 | 0x03,0x02,0x01,0x1f,0x06,0x0b,0x2a,0x57, 500 | 0x0a,0x07,0x06,0x17,0x06,0x33,0x32,0x0f, 501 | 0x02,0x13,0x02,0x1f,0x06,0x13,0x1e,0x4f, 502 | 0x06,0x03,0x01,0x07,0x06,0x0b,0x0e,0x0b, 503 | 0x0a,0x2b,0x3a,0x03,0x02,0x03,0x0a,0x0f, 504 | 0x02,0x1b,0x06,0x0f,0x22,0x4f,0x0a,0x07, 505 | 0x36,0x2f,0x3a,0x13,0x06,0x3b,0x1a,0x03, 506 | 0x0e,0x0b,0x06,0x07,0x06,0x2f,0x12,0x03, 507 | 0x2e,0x0b,0x06,0x17,0x36,0x17,0x0a,0x2b, 508 | 0x06,0x03,0x1a,0x07,0x1a,0x01,0x0b,0x0a, 509 | 0x33,0x06,0x03,0x02,0x07,0x2a,0x03,0x0a, 510 | 0x07,0x06,0x0f,0x22,0x1b,0x12,0x01,0x27, 511 | 0x1a,0x0b,0x02,0x07,0x1a,0x0f,0x16,0x2b, 512 | 0x06,0x07,0x4a,0x0f,0x26,0x03,0x02,0x13, 513 | 0x01,0x03,0x16,0x07,0x02,0x0b,0x1a,0x13, 514 | 0x02,0x03,0x1a,0x13,0x01,0x06,0x37,0x06, 515 | 0x03,0x52,0x0b,0x26,0x0b,0x01,0x13,0x4a, 516 | 0x03,0x02,0x0b,0x01,0x03,0x22,0x03,0x02, 517 | 0x03,0x06,0x0b,0x06,0x0f,0x02,0x0b,0x0e, 518 | 0x03,0x52,0x07,0x92,0x03,0x02,0x01,0x17, 519 | 0x06,0x03,0x16,0x03,0x06,0x13,0x02,0x23, 520 | 0xfe,0x02,0x1f,0x02,0x0f,0x22,0x27,0x01, 521 | 0x07,0x02,0x07,0xde,0x03,0x02,0x03,0x16, 522 | 0x27,0x36,0x03,0x01,0x17,0x02,0x01,0x02, 523 | 0x07,0xd2,0x07,0x02,0x03,0x16,0x1f,0x02, 524 | 0x03,0x46,0x07,0x06,0x03,0x8a,0x03,0x01, 525 | 0x03,0x46,0x07,0x02,0x07,0x1a,0x1b,0x06, 526 | 0x03,0x56,0x03,0x8a,0x07,0x42,0x01,0x0f, 527 | 0x1e,0x2b,0x01,0x06,0x01,0x03,0x06,0x0f, 528 | 0x8e,0x0b,0x1e,0x0b,0x2a,0x0f,0x02,0x07, 529 | 0x2e,0x1f,0x12,0x0f,0x06,0x03,0x92,0x07, 530 | 0x1a,0x0f,0x3a,0x0f,0x22,0x37,0x1e,0x07, 531 | 0x76,0x07,0x02,0x13,0x16,0x01,0x03,0x02, 532 | 0x03,0x36,0x07,0x02,0x03,0x26,0x2f,0x16, 533 | 0x03,0x0a,0x03,0x6a,0x03,0x01,0x27,0x12, 534 | 0x13,0x3a,0x03,0x01,0x22,0x0f,0x01,0x17, 535 | 0x12,0x03,0x02,0x0f,0x02,0x03,0x6e,0x3f, 536 | 0x01,0x07,0x02,0x03,0x5a,0x03,0x0e,0x1b, 537 | 0x0e,0x01,0x0a,0x0b,0x0a,0x07,0x01,0x66, 538 | 0x47,0x52,0x01,0x0b,0x02,0x07,0x06,0x07, 539 | 0x01,0x13,0x02,0x03,0x12,0x0f,0x7a,0x3b, 540 | 0x02,0x0b,0x5e,0x17,0x0a,0x0f,0x1a,0x03, 541 | 0x02,0x13,0x3a,0x07,0x32,0x2b,0x01,0x23, 542 | 0x4e,0x23,0x06,0x07,0x02,0x03,0x06,0x0b, 543 | 0x0e,0x0b,0x42,0x03,0x36,0x0f,0x01,0x3f, 544 | 0x4e,0x03,0x02,0x0f,0x26,0x0f,0x0e,0x07, 545 | 0x0a,0x03,0x36,0x03,0x3e,0x43,0x62,0x0f, 546 | 0x01,0x06,0x0b,0x06,0x43,0x2e,0x07,0x3a, 547 | 0x43,0x02,0x03,0x06,0x03,0x4e,0x13,0x06, 548 | 0x3f,0x02,0x1b,0x2a,0x07,0x32,0x4b,0x02, 549 | 0x0f,0x46,0x0b,0x02,0x07,0x0a,0x0b,0x02, 550 | 0x3b,0x06,0x03,0x2e,0x03,0x06,0x0f,0x22, 551 | 0x2b,0x02,0x0b,0x01,0x0b,0x06,0x03,0x52, 552 | 0x0b,0x0e,0x03,0x02,0x03,0x06,0x47,0x2e, 553 | 0x01,0x07,0x2e,0x0f,0x02,0x33,0x5e,0x01, 554 | 0x03,0x0e,0x53,0x01,0x07,0x32,0x0b,0x0a, 555 | 0x03,0x06,0x03,0x1a,0x07,0x06,0x0b,0x06, 556 | 0x0b,0x02,0x03,0x06,0x07,0x52,0x03,0x02, 557 | 0x03,0x06,0x67,0x01,0x0e,0x03,0x1a,0x07, 558 | 0x06,0x1b,0x1e,0x13,0x02,0x07,0x06,0x03, 559 | 0x06,0x0f,0x2a,0x13,0x26,0x2b,0x01,0x3b, 560 | 0x06,0x07,0x1a,0x07,0x06,0x03,0x05,0x1b, 561 | 0x1a,0x01,0x0f,0x22,0x03,0x32,0x0b,0x0e, 562 | 0x03,0x02,0x0b,0x0e,0x4b,0x01,0x03,0x02, 563 | 0x13,0x02,0x03,0x1a,0x27,0x01,0x13,0x7a, 564 | 0x0f,0x01,0x06,0x1f,0x01,0x06,0x4f,0x02, 565 | 0x1b,0x12,0x2f,0x0a,0x13,0x76,0x13,0x02, 566 | 0x1f,0x0a,0x53,0x02,0x03,0x2e,0x17,0x16, 567 | 0x07,0x06,0x0b,0x7a,0x03,0x01,0x23,0x16, 568 | 0x4f,0x42,0x03,0x1a,0x03,0x9e,0x03,0x0e, 569 | 0x0f,0x0e,0x01,0x1f,0x01,0x27,0x62,0x0f, 570 | 0xc2,0x0b,0x0a,0x2f,0x01,0x0b,0xfe,0x3a, 571 | 0x03,0x06,0x47,0xfe,0x36,0x07,0x02,0x0f, 572 | 0x02,0x27,0x02,0x07,0xa6,0x00, 573 | ]; 574 | 575 | ubyte[]*[] mapdata = 576 | [ 577 | &aDotMap, 578 | &bDotMap, 579 | &cDotMap, 580 | &dDotMap, 581 | &eDotMap, 582 | ]; 583 | -------------------------------------------------------------------------------- /maps.d: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * This source is written in the D Programming Language. 12 | * See www.digitalmars.com/d/ for the D specification and compiler. 13 | * 14 | * Use entirely at your own risk. There is no warranty, expressed or implied. 15 | */ 16 | 17 | module maps; 18 | 19 | import empire; 20 | import var; 21 | 22 | /*********************************** 23 | * Count how many As (Fs) are aboard a T (C). 24 | * Returns: 25 | * Number of As (Fs) are aboard. Returns 0 if unit is not a T (C). 26 | * Returns 0 if unit is in a city. 27 | */ 28 | 29 | int aboard(Unit *u) 30 | { int loc,type,i,total; 31 | 32 | loc = u.loc; 33 | if ((type = tcaf(u)) < 0) return 0; // if not a T or C 34 | if (typ[map[loc]] == X) return 0; // if in a city 35 | total = 0; // number aboard 36 | for (i = unitop; i--;) // loop thru units 37 | if (unit[i].loc == loc && // locations match 38 | unit[i].typ == type && // if it's the right type 39 | unit[i].own == u.own) 40 | total++; 41 | return total; 42 | } 43 | 44 | /************************************** 45 | * Look for troop transports or carriers. 46 | * Returns: 47 | * A if unit is a T 48 | * F if unit is a C 49 | * -1 else 50 | */ 51 | 52 | int tcaf(Unit *u) 53 | { // A F D T S R C B 54 | static int tcaftab[8] = [-1,-1,-1, A,-1,-1, F,-1]; 55 | 56 | return tcaftab[u.typ]; 57 | } 58 | 59 | 60 | /******************************* 61 | * Find and return distance between loc1 and loc2. 62 | */ 63 | 64 | int dist(loc_t loc1,loc_t loc2) 65 | { int r1,c1,r2,c2; 66 | 67 | assert(chkloc(loc1)); 68 | assert(chkloc(loc2)); 69 | 70 | r1 = ROW(loc1); 71 | c1 = COL(loc1); 72 | r2 = ROW(loc2); 73 | c2 = COL(loc2); 74 | 75 | return max(abs(r1-r2),abs(c1-c2)); 76 | } 77 | 78 | /****************************** 79 | * Find direction to go in to go from loc1 80 | * to loc2. 81 | */ 82 | 83 | int movdir(loc_t loc1,loc_t loc2) 84 | { static int mov[] = [3,4,5,2,-1,6,1,0,7]; 85 | int i = 0; 86 | int r1,c1,r2,c2; 87 | 88 | assert(chkloc(loc1)); 89 | assert(chkloc(loc2)); 90 | 91 | r1 = ROW(loc1); 92 | c1 = COL(loc1); 93 | r2 = ROW(loc2); 94 | c2 = COL(loc2); 95 | 96 | if (c2 > c1) i++; 97 | if (c2 >= c1) i++; 98 | i *= 3; /* i=0,3,6 for (3,4,5),(2,-1,6),(1,0,7) */ 99 | 100 | if (r2 > r1) i++; 101 | if (r2 >= r1) i++; 102 | 103 | return mov[i]; /* correct direction to move */ 104 | } 105 | 106 | /**************************** 107 | * Return true if we're on the edge. 108 | */ 109 | 110 | int border(loc_t loc) 111 | { int r1,c1; 112 | 113 | r1 = ROW(loc); 114 | c1 = COL(loc); 115 | return ((r1 == 0) || (r1 == Mrowmx) || (c1 == 0) || (c1 == Mcolmx)); 116 | } 117 | 118 | /********************************** 119 | * Convert location to row*256+col 120 | */ 121 | 122 | int rowcol(loc_t loc) 123 | { 124 | return (ROW(loc)<<8) + COL(loc); 125 | } 126 | 127 | /************************** 128 | * Total up amount of sea around loc and return it. 129 | */ 130 | 131 | int edger(loc_t loc) 132 | { int sum = 0; /* running total */ 133 | int i = 8; /* # of directions */ 134 | 135 | assert(chkloc(loc)); 136 | 137 | while (i--) /* continue till i = -1 */ 138 | if (sea[map[loc + arrow(i)]]) sum++; 139 | return sum; 140 | } 141 | 142 | /********************* 143 | * Check routines 144 | */ 145 | 146 | /************************** 147 | * Return true if loc is a valid location. 148 | */ 149 | 150 | int chkloc(loc_t loc) 151 | { 152 | return loc < MAPSIZE && !border(loc); 153 | } 154 | 155 | void chkmov(dir_t r2,int errnum) 156 | { 157 | assert(r2 >= -1 && r2 <= 7); 158 | } 159 | 160 | 161 | /* Miscellaneous 162 | */ 163 | 164 | int max(int a, int b) 165 | { 166 | return (a > b) ? a : b; 167 | } 168 | 169 | int abs(int a) 170 | { 171 | return (a < 0) ? -a : a; 172 | } 173 | 174 | 175 | -------------------------------------------------------------------------------- /move.d: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * This source is written in the D Programming Language. 12 | * See www.digitalmars.com/d/ for the D specification and compiler. 13 | * 14 | * Use entirely at your own risk. There is no warranty, expressed or implied. 15 | */ 16 | 17 | 18 | module move; 19 | 20 | import empire; 21 | import eplayer; 22 | import sub2; 23 | 24 | const int HYSTERESIS = 10; 25 | 26 | /*********************************** 27 | * Do a time slice. 28 | * Returns: 29 | * 0 continue 30 | * !=0 end program 31 | */ 32 | 33 | int slice() 34 | { 35 | int newnum; 36 | Player *p; 37 | 38 | switch (numply) 39 | { 40 | case 1: 41 | Player.get(1).tslice(); 42 | break; 43 | 44 | case 2: 45 | p = Player.get(plynum); 46 | 47 | p.tslice(); 48 | newnum = plynum ^ 3; // 2 -> 1; 1 -> 2 49 | plynum = (Player.get(newnum).round > p.round + HYSTERESIS) 50 | ? plynum : newnum; 51 | break; 52 | 53 | case 3: 54 | { static int e1[4] = [0,2,1,1]; // 0th element is a dummy 55 | static int e2[4] = [0,3,3,2]; 56 | 57 | // Only allow move if we're not HYSTERESIS moves ahead of the others. 58 | 59 | p = Player.get(plynum); 60 | if (Player.get(e1[plynum]).round + HYSTERESIS > p.round && 61 | Player.get(e2[plynum]).round + HYSTERESIS > p.round) 62 | p.tslice(); // move the player 63 | 64 | plynum = (plynum >= 3) ? 1 : plynum + 1; 65 | } 66 | break; 67 | 68 | default: 69 | { int r; 70 | int i; 71 | 72 | p = Player.get(plynum); 73 | r = p.round; 74 | for (i = 1; 1; i++) 75 | { 76 | if (i > numply) 77 | { p.tslice(); 78 | break; 79 | } 80 | if (i == plynum) 81 | continue; 82 | 83 | // Only allow move if we're not HYSTERESIS moves ahead of the others. 84 | if (r >= Player.get(i).round + HYSTERESIS) 85 | break; // too far ahead, next player 86 | } 87 | 88 | plynum = (plynum >= numply) ? 1 : plynum + 1; 89 | } 90 | break; 91 | } 92 | return 0; 93 | } 94 | 95 | 96 | 97 | /***************************** 98 | * Produce units in the cities and reset for next production. 99 | */ 100 | 101 | void hrdprd(Player *p) 102 | { uint i,wa; 103 | Unit *u; 104 | 105 | wa = p.watch; 106 | for (i = CITMAX; i--;) 107 | { City *c = &city[i]; 108 | 109 | if (c.own != p.num) 110 | continue; /* if we don't own the city */ 111 | if (!c.loc) 112 | continue; /* if the city doesn't exist */ 113 | //assert(!((c.phs & ~7) && c.phs != '\377')); 114 | p.sensor(c.loc); // keep map up to date 115 | if (c.fnd > p.round) /* if unit is not produced yet */ 116 | continue; 117 | if (newuni(&u,c.loc,c.phs,p.num)) // create new unit 118 | { 119 | c.fnd = p.round + typx[c.phs].prodtime; 120 | p.display.produce(c); 121 | 122 | if (overpop) 123 | p.display.overpop(false); 124 | overpop = false; /* no longer overpopulated */ 125 | } 126 | else /* else overpop */ 127 | { overpop = true; 128 | p.display.overpop(true); 129 | } 130 | } 131 | } 132 | 133 | 134 | /**************************** 135 | * See if anybody won or if computer concedes defeat. 136 | */ 137 | 138 | void chkwin() 139 | { int n[PLYMAX+1]; /* # of cities owned by plyr # */ 140 | int i,j; 141 | Text *t; 142 | Player *p; 143 | 144 | memset(n,0,n.sizeof); 145 | 146 | for (i = CITMAX; i--;) 147 | n[city[i].own]++; // inc number owned 148 | 149 | for (j = 1; j <= numply; j++) // loop thru the players 150 | { p = Player.get(j); 151 | if (n[j] != 0 || // player j hasn't lost yet 152 | p.defeat) // if already defeated 153 | continue; 154 | 155 | // If any armies, then player is not defeated 156 | for (i = unitop; i--;) 157 | { if (unit[i].loc && unit[i].own == j && unit[i].typ == A) 158 | goto L1; 159 | } 160 | 161 | p.defeat = true; // player is defeated 162 | numleft--; // number of players left 163 | for (i = 1; i <= numply; i++) 164 | { 165 | Player.get(i).notify_defeated(p); 166 | 167 | } 168 | 169 | if (numleft != 1) 170 | for (i = 1; i < numply; i++) 171 | { if (!Player.get(i).defeat && Player.get(i).watch) 172 | goto L1; 173 | } 174 | done(0); 175 | 176 | L1: 177 | ; 178 | } 179 | } 180 | 181 | 182 | /************************************** 183 | */ 184 | 185 | void done(int i) 186 | { 187 | version (Windows) 188 | { 189 | } 190 | else 191 | { 192 | printf("\n"); 193 | win32close(); 194 | exit(i); 195 | } 196 | } 197 | 198 | 199 | /************************************** 200 | */ 201 | 202 | void updlst(loc_t loc,int type) // update map value at loc 203 | { int ty = .typ[.map[loc]]; // what's there 204 | 205 | if ((ty != X) && // if not a city 206 | ((type != A) || (ty != T)) && // and not an A leaving a T 207 | ((type != F) || (ty != C)) ) // and not an F leaving a C 208 | updmap(loc); // then update the map 209 | } 210 | 211 | 212 | /************************************* 213 | * Change map to land or sea, depending on whether what's on it 214 | * is over land or sea (i.e. an 'A' would be changed to '+'). 215 | */ 216 | 217 | int updmap(loc_t loc) 218 | { return .map[loc] = (land[.map[loc]]) ? MAPland : MAPsea; 219 | } 220 | 221 | 222 | 223 | 224 | /************************************ 225 | * Find & return the unit number of the unit at loc. 226 | */ 227 | 228 | Unit *fnduni(loc_t loc) 229 | { int ab,n; 230 | ab = .map[loc]; 231 | 232 | chkloc(loc); 233 | assert(.typ[ab] >= 0); 234 | 235 | n = unitop; /* max unit # + 1 */ 236 | while (n--) 237 | { Unit *u = &unit[n]; 238 | 239 | if (u.loc == loc && .typ[ab] == u.typ) 240 | return u; 241 | } 242 | assert(0); 243 | return null; 244 | } 245 | 246 | 247 | /*********************** 248 | * Destroy a unit given unit number. If a T or C, destroy any 249 | * armies or fighters which may be aboard. 250 | * Watch out for destroying other pieces by mistake! 251 | */ 252 | 253 | void kill(Unit *u) 254 | { int i,loc,ty,ndes; 255 | Player *p = Player.get(u.own); 256 | 257 | loc = u.loc; // loc of unit 258 | ty = tcaf(u); 259 | p.notify_destroy(u); 260 | u.destroy(); // destroy unit 261 | if (ty == -1) // if not T or C 262 | return; 263 | 264 | if (.typ[.map[loc]] == X) // if in a city 265 | return; // assume A's & Fs are off ship 266 | 267 | ndes = 0; 268 | for (i = unitop; i--;) 269 | { if (unit[i].loc == loc && 270 | unit[i].typ == ty && 271 | unit[i].own == p.num) 272 | { 273 | p.notify_destroy(&unit[i]); 274 | unit[i].destroy(); // destroy it 275 | ndes++; // keep track of # destroyed 276 | } 277 | } 278 | } 279 | 280 | 281 | 282 | 283 | /********************************** 284 | * Select and return a random direction, 285 | * giving priority to moving diagonally. 286 | */ 287 | 288 | int randir() 289 | { int r2; 290 | 291 | r2 = empire.random(24); // r2 = 0..23 292 | if (r2 >= 8) // move diagonally (67%) 293 | { r2 &= 7; // convert to 0..7 294 | r2 |= 1; // pick a diagonal move 295 | } 296 | return r2; 297 | } 298 | 299 | 300 | 301 | /********************************** 302 | * Given a pointer to an array of locs, and the number of elements 303 | * in the array, search for one within range. If found, set ifo, 304 | * ila and return true. 305 | */ 306 | 307 | int fndtar(Unit *u,uint *p,uint n) 308 | { uint loc; 309 | 310 | loc = u.loc; 311 | assert(chkloc(loc)); 312 | for (; n--; p++) // look at n entries 313 | { if (!*p) continue; // 0 location 314 | assert(chkloc(*p)); 315 | if (dist(loc,*p) > u.fuel) // if too far 316 | continue; 317 | if (u.fuel == u.hit) // if kamikaze 318 | u.ifo = IFOtarkam; 319 | else 320 | u.ifo = IFOtar; 321 | u.ila = *p; // set location of target 322 | return true; 323 | } 324 | return false; 325 | } 326 | 327 | 328 | 329 | /********************************** 330 | * If unit is an A on a T, and is surrounded by water or friendly 331 | * stuff, return true. 332 | */ 333 | 334 | int sursea(Unit *u) 335 | { int loc,ac,i; 336 | 337 | loc = u.loc; 338 | if ((u.typ != A) || (typ[.map[loc]] != T)) 339 | return(false); 340 | for (i = 8; i--;) 341 | { ac = .map[loc + arrow(i)]; /* ltr map value */ 342 | if ((land[ac] || typ[ac] == X) && own[ac] != u.own) 343 | return(false); /* found land or unowned city */ 344 | } 345 | return(true); /* guess it must be so */ 346 | } 347 | 348 | 349 | 350 | /************************************* 351 | * Given unit number of a T (C), see if it is full. 352 | * Unit must not be in a city! 353 | * Use: 354 | * full(uninum) 355 | * Input: 356 | * uninum = unit # of T or C 357 | * Returns: 358 | * true if the T (C) is full. 359 | */ 360 | 361 | int full(Unit *u) 362 | { int max; 363 | 364 | max = u.hit; 365 | if (u.typ == T) 366 | max <<= 1; // *2 for transports 367 | return aboard(u) >= max; // check # aboard against max 368 | } 369 | 370 | 371 | /*********************************** 372 | * Return true if there aren't any '+'s around loc. 373 | * Input: 374 | * loc 375 | */ 376 | 377 | int Ecrowd(loc_t loc) 378 | { int i; 379 | 380 | for (i = 8; i--;) 381 | if (.map[loc + arrow(i)] == 3) // if '+' 382 | return false; 383 | return true; 384 | } 385 | 386 | 387 | 388 | -------------------------------------------------------------------------------- /path.d: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * This source is written in the D Programming Language. 12 | * See www.digitalmars.com/d/ for the D specification and compiler. 13 | * 14 | * Use entirely at your own risk. There is no warranty, expressed or implied. 15 | */ 16 | 17 | 18 | module path; 19 | 20 | import empire; 21 | import eplayer; 22 | 23 | /**************************************** 24 | * Find path from beg to end over 25 | * a) land including blanks (BLK) 26 | * b) if on same continent (CNT) 27 | * c) path over land excluding blanks (LND) 28 | * d) path over sea including blanks (SEA) 29 | * Returns: 30 | * true if path found 31 | */ 32 | 33 | static char tblinit; 34 | 35 | /* ,*,.,+,O,A,F,F,D,T,S,R,C,B, 36 | * o,a,f,f,d,t,s,r,c,b, 37 | * X,1,2,2,3,4,5,6,7,8 38 | */ 39 | byte 40 | okblk[MAPMAX] = [1,0,0,1,0,1,1,0,0,0,0,0,0,0, 41 | 0,1,1,0,0,0,0,0,0,0, 42 | 0,1,1,0,0,0,0,0,0,0, 43 | 0,1,1,0,0,0,0,0,0,0, 44 | 0,1,1,0,0,0,0,0,0,0]; 45 | byte 46 | okcnt[MAPMAX] = [0,0,0,1,1,1,1,0,0,0,0,0,0,0, 47 | 1,1,1,0,0,0,0,0,0,0, 48 | 1,1,1,0,0,0,0,0,0,0, 49 | 1,1,1,0,0,0,0,0,0,0, 50 | 1,1,1,0,0,0,0,0,0,0]; 51 | byte 52 | oklnd[MAPMAX] = [0,0,0,1,0,1,1,0,0,0,0,0,0,0, 53 | 0,1,1,0,0,0,0,0,0,0, 54 | 0,1,1,0,0,0,0,0,0,0, 55 | 0,1,1,0,0,0,0,0,0,0, 56 | 0,1,1,0,0,0,0,0,0,0]; 57 | byte 58 | oksea[MAPMAX] = [1,0,1,0,0,0,0,1,0,0,0,0,0,0, 59 | 0,0,0,1,0,0,0,0,0,0, 60 | 0,0,0,1,0,0,0,0,0,0, 61 | 0,0,0,1,0,0,0,0,0,0, 62 | 0,0,0,1,0,0,0,0,0,0]; 63 | 64 | void dotblinit() 65 | { int i; 66 | int j; 67 | int k; 68 | 69 | for (i = 4; i < (4 + 10); i++) 70 | { 71 | for (j = 1; j < PLYMAX; j++) 72 | { 73 | k = 4 + j * 10; 74 | assert(k < MAPMAX); 75 | okblk[k] = okblk[i]; 76 | okcnt[k] = okcnt[i]; 77 | oklnd[k] = oklnd[i]; 78 | oksea[k] = oksea[i]; 79 | } 80 | } 81 | tblinit++; 82 | } 83 | 84 | /***************************************** 85 | * Find path from beg to end. 86 | * Two entry points: 87 | * patho(): optimize path 88 | * pathn(): don't optimize path 89 | * Input: 90 | * beg beginning location 91 | * end ending location 92 | * dir 1 or -1, direction to turn in case of obstacle 93 | * ok[] array of map vals with yea or nay 94 | * *pr2 where we write the final move to (garbage if fail) 95 | * Output: 96 | * *pr2 97 | * Returns: 98 | * true if a path is found 99 | */ 100 | 101 | int path( 102 | Player *p, 103 | loc_t beg, /* beginning */ 104 | loc_t end, /* end */ 105 | int dir, /* direction to turn in obstacle */ 106 | byte *ok, /* array of ok map values */ 107 | dir_t *pr2, /* pointer to initial move */ 108 | int opt) /* if true then optimize */ 109 | in 110 | { 111 | assert(dir == 1 || dir == -1); 112 | assert(opt == 0 || opt == 1); 113 | assert(chkloc(beg)); 114 | assert(chkloc(end)); 115 | 116 | for (int i = 0; i < MAPMAX; i++) 117 | { 118 | //if (!(ok[i] == 0 || ok[i] == 1)) 119 | //printf("\nok[%d]=%d \n",i,ok[i]); 120 | assert(ok[i] == 0 || ok[i] == 1); 121 | } 122 | } 123 | body 124 | { int i; 125 | int movsav; 126 | int t; 127 | int curloc; /* current location */ 128 | int loc; /* trial move location */ 129 | int bakadr; /* ret from okmove */ 130 | int dir3; /* 3 * dir */ 131 | ubyte *mapb; /* base of map array */ 132 | int movnum; /* # of moves tried */ 133 | int movmax; /* max # of tries */ 134 | int trymov; /* trial move direction */ 135 | int begdir; /* dir that we started out with */ 136 | 137 | const int TRACKMAX = 100; 138 | int track[TRACKMAX]; /* list of locs where we stopped */ 139 | /* following the shore and went */ 140 | /* straight. This is necessary */ 141 | /* so we don't go around in circles */ 142 | 143 | // Given loc, return true if we can move there. 144 | int mapinm() { return ok[*(mapb+loc)] || loc==end; } 145 | 146 | // Same as armain(), but trymov is given. 147 | int armap() { return (loc=curloc+arrow(trymov)),mapinm(); } 148 | 149 | // See if we can move from curloc to end. Set trymov and loc 150 | int armain() { return (trymov=movdir(curloc,end)),armap(); } 151 | 152 | /* initialize 153 | */ 154 | 155 | if (!tblinit) 156 | dotblinit(); 157 | 158 | *pr2 = -1; // in case beg == end 159 | curloc = beg; 160 | dir3 = dir *3; 161 | begdir = dir; 162 | t = 0; 163 | movmax = movnum = 50 + 2 * dist(beg,end); // max # of tries 164 | mapb = p.map; // base addr of map 165 | 166 | /* move straight towards end 167 | */ 168 | 169 | strght: 170 | if (curloc == end) return true; /* if already there */ 171 | if (!armain()) /* if we can't move there */ 172 | goto folshr; /* try following shore */ 173 | 174 | okstr: 175 | bakadr = true; /* return to strght */ 176 | 177 | // The move trymov is legit and we will use it. 178 | 179 | okmove: 180 | if (curloc == beg) /* if at beginning */ 181 | *pr2 = trymov; /* set initial move */ 182 | curloc = loc; /* set current loc */ 183 | if (curloc == end) return true; 184 | if (!--movnum) /* if run out of moves */ 185 | goto trydir; /* try another direction */ 186 | if (bakadr) /* goto strght or chknxt */ 187 | goto strght; 188 | else 189 | { if (opt) /* attempt to optimize path */ 190 | { int move1 = movdir(beg,curloc); /* initial move */ 191 | 192 | loc = beg; 193 | while (loc != curloc) /* while we haven't arrived */ 194 | { loc += arrow(movdir(loc,curloc)); 195 | if (!mapinm()) /* if we can't move there */ 196 | goto chknxt; 197 | } 198 | *pr2 = move1; /* set initial move */ 199 | } 200 | goto chknxt; 201 | } 202 | 203 | trydir: 204 | dir3 = -dir3; /* try the other direction */ 205 | dir = -dir; 206 | if (dir == begdir) /* if already tried */ 207 | return false; /* then failed */ 208 | movnum = movmax; 209 | curloc = beg; 210 | t = 0; /* reset variables */ 211 | goto strght; /* and try again */ 212 | 213 | /* We've run into an obstacle. Follow the shore. 214 | */ 215 | 216 | folshr: 217 | trymov = (trymov - dir3) & 7; /* go back 3 */ 218 | if (armap()) /* if we can move there */ 219 | trymov = (trymov + dir3) & 7; /* then don't go back 3 */ 220 | for (i = 8; i; i--, trymov = (trymov + dir) & 7) 221 | { loc = curloc + arrow(trymov); 222 | if (!border(loc) && /* if location isn't on edge */ 223 | mapinm()) /* and we can move there */ 224 | { bakadr = false; /* return from okmove to chknxt */ 225 | goto okmove; /* the move is ok */ 226 | } 227 | } 228 | return false; // can't do anything 229 | 230 | /* See if we can break away from following the shore and go 231 | * straight. 232 | */ 233 | chknxt: 234 | movsav = movdir(curloc,end); /* move straight to end */ 235 | loc = curloc + arrow(movsav); 236 | if (!mapinm()) /* if we can't */ 237 | goto folshr; /* resume following the shore */ 238 | for (i = t; i--;) /* loop backwards thru track */ 239 | if (track[i] == loc) /* if we already tried this */ 240 | goto folshr; /* resume following shore */ 241 | track[t++] = loc; /* enter this try into track */ 242 | if (t == TRACKMAX) /* overflow array */ 243 | goto trydir; /* try other direction */ 244 | trymov = movsav; /* go straight */ 245 | goto okstr; /* all clear for going straight */ 246 | } 247 | -------------------------------------------------------------------------------- /printf.d: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * This source is written in the D Programming Language. 12 | * See www.digitalmars.com/d/ for the D specification and compiler. 13 | * 14 | * Use entirely at your own risk. There is no warranty, expressed or implied. 15 | */ 16 | 17 | 18 | /* This file implements printf for GUI apps that sends the output 19 | * to logfile rather than stdout. 20 | * The file is closed after each printf, so that it is complete even 21 | * if the program subsequently crashes. 22 | */ 23 | 24 | import std.c.stdio; 25 | import std.c.stdlib; 26 | import std.string; 27 | import std.file; 28 | 29 | alias void* va_list; 30 | 31 | const int LOG = 1; // disable logging by setting this to 0 32 | 33 | version (Windows) 34 | { 35 | char logfile[] = r"\empire.log"; 36 | } 37 | version (linux) 38 | { 39 | char logfile[] = "/var/log/empire.log"; 40 | } 41 | 42 | /********************************************* 43 | * Route printf() to a log file rather than stdio. 44 | */ 45 | 46 | enum Plog 47 | { 48 | TOBITBUCKET, 49 | TOLOGFILE, 50 | TOSTDOUT, 51 | }; 52 | 53 | Plog printf_logging = Plog.TOLOGFILE; 54 | 55 | void printf_tologfile() 56 | { 57 | printf_logging = Plog.TOLOGFILE; 58 | } 59 | 60 | void printf_tostdout() 61 | { 62 | printf_logging = Plog.TOSTDOUT; 63 | } 64 | 65 | void printf_tobitbucket() 66 | { 67 | printf_logging = Plog.TOBITBUCKET; 68 | } 69 | 70 | void LogfileAppend(char* buffer) 71 | { 72 | if (printf_logging == Plog.TOLOGFILE) 73 | std.file.append(logfile, buffer[0 .. strlen(buffer)]); 74 | else 75 | { 76 | fputs(buffer, stdout); 77 | fflush(stdout); 78 | } 79 | } 80 | 81 | extern (C) 82 | { 83 | 84 | int VPRINTF(char* format, va_list args) 85 | { 86 | if (printf_logging != Plog.TOBITBUCKET) 87 | { 88 | char buffer[128]; 89 | char* p; 90 | uint psize; 91 | int count; 92 | 93 | p = buffer; 94 | psize = buffer.length; 95 | for (;;) 96 | { 97 | version (linux) 98 | { 99 | count = vsnprintf(p,psize,format,args); 100 | if (count == -1) 101 | psize *= 2; 102 | else if (count >= cast(int)psize) 103 | psize = count + 1; 104 | else 105 | break; 106 | } 107 | else version (Windows) 108 | { 109 | count = _vsnprintf(p,psize,format,args); 110 | if (count != -1) 111 | break; 112 | psize *= 2; 113 | } 114 | else 115 | { 116 | static assert(0); // unsupported system 117 | } 118 | p = cast(char *) alloca(psize * buffer[0].sizeof); // buffer too small, try again with larger size 119 | } 120 | 121 | LogfileAppend(p); 122 | } 123 | return 0; 124 | } 125 | 126 | int PRINTF(char* format, ...) 127 | { 128 | int result = 0; 129 | 130 | if (printf_logging != Plog.TOBITBUCKET) 131 | { 132 | va_list ap; 133 | //va_start(ap, format); 134 | ap = cast(va_list)(cast(void*)format + format.sizeof); 135 | result = VPRINTF(format,ap); 136 | //va_end(ap); 137 | } 138 | return result; 139 | } 140 | 141 | } 142 | 143 | void _printf_assert(char* file, uint line) 144 | { 145 | PRINTF("assert fail: %s(%d)\n", file, line); 146 | *cast(char *)0 = 0; // seg fault to ensure it isn't overlooked 147 | exit(0); 148 | } 149 | 150 | 151 | -------------------------------------------------------------------------------- /r1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/r1.bmp -------------------------------------------------------------------------------- /r2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/r2.bmp -------------------------------------------------------------------------------- /r3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/r3.bmp -------------------------------------------------------------------------------- /r4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/r4.bmp -------------------------------------------------------------------------------- /r5.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/r5.bmp -------------------------------------------------------------------------------- /r6.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/r6.bmp -------------------------------------------------------------------------------- /s1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/s1.bmp -------------------------------------------------------------------------------- /s2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/s2.bmp -------------------------------------------------------------------------------- /s3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/s3.bmp -------------------------------------------------------------------------------- /s4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/s4.bmp -------------------------------------------------------------------------------- /s5.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/s5.bmp -------------------------------------------------------------------------------- /s6.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/s6.bmp -------------------------------------------------------------------------------- /sea.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/sea.bmp -------------------------------------------------------------------------------- /splash.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/splash.wav -------------------------------------------------------------------------------- /sub2.d: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * This source is written in the D Programming Language. 12 | * See www.digitalmars.com/d/ for the D specification and compiler. 13 | * 14 | * Use entirely at your own risk. There is no warranty, expressed or implied. 15 | */ 16 | 17 | 18 | module sub2; 19 | 20 | import std.string; 21 | 22 | import empire; 23 | import var; 24 | 25 | /********************************* 26 | * Return city number given city location. 27 | */ 28 | 29 | City *fndcit(loc_t loc) 30 | in 31 | { 32 | assert(chkloc(loc)); 33 | } 34 | body 35 | { int i; 36 | 37 | for (i = CITMAX; i--;) 38 | if (city[i].loc == loc) 39 | return &city[i]; // we found the city 40 | assert(0); 41 | return null; 42 | } 43 | 44 | 45 | /******************************* 46 | * Create a new unit, given it's loc and type. 47 | * Output: 48 | * unitop = max(unitop, uninum + 1) 49 | * Returns: 50 | * true if successful 51 | * false if overpopulation 52 | */ 53 | 54 | int newuni(Unit **pu,loc_t loc,uint ty,uint pn) 55 | in 56 | { 57 | assert(chkloc(loc)); 58 | assert(ty < TYPMAX); 59 | assert(pn <= PLYMAX); 60 | } 61 | body 62 | { int i; 63 | Unit *u; 64 | 65 | for (i = 0; i < UNIMAX; i++) 66 | { u = &unit[i]; 67 | 68 | if (!unit[i].loc) // if unit doesn't exist 69 | { if (i >= unitop) 70 | unitop = i + 1; // set unitop to 1 past max uninum 71 | memset(u,0,Unit.sizeof); 72 | u.loc = loc; 73 | u.own = pn; 74 | u.typ = ty; 75 | u.hit = typx[ty].hittab; 76 | u.dir = (i & 1) ? 1 : -1; 77 | *pu = u; // return unit # created 78 | return true; // successful 79 | } 80 | } 81 | return false; // overpopulation 82 | } 83 | -------------------------------------------------------------------------------- /t1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/t1.bmp -------------------------------------------------------------------------------- /t2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/t2.bmp -------------------------------------------------------------------------------- /t3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/t3.bmp -------------------------------------------------------------------------------- /t4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/t4.bmp -------------------------------------------------------------------------------- /t5.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/t5.bmp -------------------------------------------------------------------------------- /t6.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/t6.bmp -------------------------------------------------------------------------------- /taps.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/taps.wav -------------------------------------------------------------------------------- /text.d: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * This source is written in the D Programming Language. 12 | * See www.digitalmars.com/d/ for the D specification and compiler. 13 | * 14 | * Use entirely at your own risk. There is no warranty, expressed or implied. 15 | */ 16 | 17 | 18 | module text; 19 | 20 | import std.c.stdio; 21 | import std.ctype; 22 | 23 | import empire; 24 | import printf; 25 | 26 | extern (C) void win_flush(); 27 | extern (C) void sound_click(); 28 | 29 | const int VBUFROWS = 5; 30 | const int VBUFCOLS = 80; 31 | 32 | char vbuffer[5][80 + 1]; 33 | 34 | // For each text mode display, which can be either a tty or the 35 | // PC screen in text mode. 36 | 37 | struct Text 38 | { 39 | ubyte watch; // display attribute DAxxxx if non-zero 40 | int TTtyp; // terminal type 41 | uint cursor; // current cursor position 42 | uint Tmax; // terminal max display size 43 | ubyte speaker; // speaker on? 44 | ubyte narrow; // true if narrow screen 45 | int nrows; // total number of rows in display 46 | int ncols; // total number of columns in display 47 | int inbuf; // -1 if empty, otherwise next character to be read 48 | int anychanges; // !=0 if any changes since last flush() 49 | 50 | void deleol() // erase to end of line 51 | { 52 | if (watch) 53 | { 54 | int r, c; 55 | 56 | r = cursor >> 8; 57 | c = cursor & 0xFF; // get row & column in r,c 58 | for (; c < VBUFCOLS; c++) 59 | { if (vbuffer[r][c] != ' ') 60 | { anychanges = 1; 61 | vbuffer[r][c] = ' '; 62 | } 63 | } 64 | } 65 | } 66 | 67 | 68 | void deleos() // erase to end of screen 69 | { 70 | if (watch) 71 | { 72 | int r, c; 73 | 74 | r = cursor >> 8; 75 | c = cursor & 0xFF; // get row & column in r,c 76 | for (; r < VBUFROWS; r++) 77 | { 78 | for (; c < VBUFCOLS; c++) 79 | vbuffer[r][c] = ' '; 80 | c = 0; 81 | } 82 | anychanges = 1; 83 | } 84 | } 85 | 86 | void block_cursor() // set block cursor 87 | { 88 | } 89 | 90 | void clear() // clear screen 91 | { 92 | if (watch) 93 | { 94 | int r, c; 95 | 96 | for (r = 0; r < VBUFROWS; r++) 97 | { for (c = 0; c < VBUFCOLS; c++) 98 | vbuffer[r][c] = ' '; 99 | vbuffer[r][VBUFCOLS] = 0; 100 | } 101 | anychanges = 1; 102 | } 103 | } 104 | 105 | 106 | 107 | /********************************* 108 | * Send char to output device. 109 | */ 110 | 111 | void TTout(char c) 112 | { 113 | if (watch) 114 | { int row, col; 115 | 116 | row = cursor >> 8; 117 | col = cursor & 0xFF; 118 | if (row < VBUFROWS && col < VBUFCOLS) 119 | { 120 | if (vbuffer[row][col] != c) 121 | { anychanges = 1; 122 | vbuffer[row][col] = c; 123 | } 124 | } 125 | } 126 | } 127 | 128 | 129 | /***************************** 130 | * Get char from device. Wait until one is available. 131 | */ 132 | 133 | int TTin() 134 | { int c; 135 | 136 | c = TTinr(); 137 | return c; 138 | } 139 | 140 | 141 | /*************************** 142 | * Get char from device and return it. Return -1 143 | * if no char is available. Convert all chars to uc. 144 | * Do not echo character. 145 | */ 146 | 147 | int TTinr() 148 | { 149 | int c; 150 | 151 | if (watch == DAnone) 152 | return -1; 153 | 154 | c = inbuf; 155 | inbuf = -1; 156 | 157 | return std.ctype.toupper(cast(dchar)c); 158 | } 159 | 160 | void TTunget(int c) // put character c in input 161 | { 162 | inbuf = c; 163 | } 164 | 165 | /************************************** 166 | * Position cursor at r,c. 167 | */ 168 | 169 | void TTcurs(uint rc) 170 | { 171 | cursor = rc; 172 | } 173 | 174 | 175 | /****************************** 176 | * Position cursor at r,c. Use cursor[] to minimize chars sent out. 177 | * Cases considered: 178 | * 1. Use cursor addressing if we are to move backwards or up. 179 | * 2. Use cursor addressing if we are to move to 25th line. 180 | * 3. Use a CRLF if we start a new line. 181 | * 4. Do nothing if cursor is already there. 182 | * 5. Else use cursor addressing. 183 | */ 184 | 185 | void curs(int rc) 186 | { 187 | //PRINTF("Text::curs(%x)\n", rc); 188 | uint r,c,rp,cp; 189 | 190 | if (!watch) return; 191 | 192 | if (rc == cursor) return; // case 4 193 | r = rc >> 8; 194 | c = rc & 0xFF; // get row & column in r,c 195 | if (!(r <= (Tmax >> 8) && c <= (Tmax & 0xFF))) 196 | PRINTF("r = %d, c = %d, Tmax = %d,%d\n", r, c, Tmax >> 8, Tmax & 0xFF); 197 | assert(r <= (Tmax >> 8) && c <= (Tmax & 0xFF)); 198 | TTcurs(rc); 199 | } 200 | 201 | 202 | /************************************* 203 | * Ring the bell. 204 | */ 205 | 206 | void bell() 207 | { 208 | //MessageBeep(0); 209 | } 210 | 211 | 212 | /************************** 213 | * Output chars to display. Keep track of cursor 214 | * position. 215 | * Cases considered: 216 | * 1. CR 217 | * 2. LF 218 | * 3. 0 219 | * 4. printable char 220 | * 5. BS 221 | * 6. 1 (do a delete to end of line) 222 | * 7. 2 (do a delay(2)) 223 | */ 224 | 225 | void output(char chr) 226 | { 227 | int r,c; 228 | 229 | if (!watch) return; 230 | r = cursor >> 8; 231 | c = cursor & 0xFF; 232 | 233 | switch (chr) 234 | { case '\r': 235 | c = 0; 236 | break; 237 | case '\n': 238 | r++; 239 | r = (r > (Tmax >> 8)) ? r - 1 : r; 240 | break; 241 | case '\0': 242 | return; 243 | case 1: 244 | deleol(); 245 | return; 246 | case 2: 247 | //delay(2); 248 | flush(); 249 | return; 250 | case '\b': 251 | c = (c) ? c - 1 : c; 252 | break; 253 | default: /* printable char */ 254 | c++; 255 | c = (c > (Tmax & 0xFF)) ? c - 1 : c; 256 | break; 257 | } 258 | TTout(chr); // and send out the char 259 | cursor = (r << 8) + c; // save new cursor position 260 | } 261 | 262 | 263 | /*************************** 264 | * Take number in decimal and send it to output(). 265 | */ 266 | 267 | void decprt(int i) 268 | { 269 | if (watch) 270 | { 271 | if (i < 0) 272 | { output('-'); 273 | i = -i; // absolute value 274 | } 275 | if (i/10) 276 | decprt(i/10); 277 | output(i % 10 + '0'); 278 | } 279 | } 280 | 281 | 282 | /*************************** 283 | * Send string to output. 284 | */ 285 | 286 | void imes(char *p) 287 | { 288 | //printf("imes('%s')\n",p); 289 | if (watch) 290 | { 291 | while (*p) 292 | output(*p++); 293 | flush(); 294 | } 295 | } 296 | 297 | /*************************** 298 | * Send string to output. 299 | */ 300 | 301 | void smes(char *p) 302 | { 303 | //printf("smes('%s')\n",p); 304 | if (watch) 305 | { 306 | imes(p); 307 | } 308 | } 309 | 310 | 311 | /**************************** 312 | * Formatted print. 313 | */ 314 | 315 | void vsmes(char* format,...) 316 | { char buffer[100]; 317 | int count; 318 | 319 | count = _vsnprintf(buffer,buffer.sizeof,format,cast(va_list)(&format + 1)); 320 | smes(buffer); 321 | } 322 | 323 | /**************************** 324 | * Position cursor and type message. 325 | */ 326 | 327 | void cmes(int rc,char *p) 328 | { 329 | if (!watch) return; 330 | TTcurs(rc); 331 | imes(p); 332 | } 333 | 334 | 335 | /************************* 336 | * Initialize operating system 337 | * to have: 338 | * single character input 339 | * turn off echo 340 | */ 341 | 342 | void TTinit() 343 | { 344 | inbuf = -1; // no character in input 345 | //nrows = 160 / 10; 346 | //ncols = 120 / 10; 347 | nrows = VBUFROWS; 348 | ncols = VBUFCOLS; 349 | } 350 | 351 | 352 | /************************** 353 | * Restore operating system 354 | */ 355 | 356 | void TTdone() 357 | { 358 | } 359 | 360 | /*************************************** 361 | * Print out location in row,col format 362 | */ 363 | 364 | void locprt(loc_t loc) 365 | { 366 | vsmes("%u,%u",ROW(loc),COL(loc)); 367 | } 368 | 369 | void locdot(loc_t loc) 370 | { 371 | vsmes("%u,%u.",ROW(loc),COL(loc)); 372 | deleol(); 373 | } 374 | 375 | void space() 376 | { 377 | output(' '); 378 | } 379 | 380 | void crlf() 381 | { 382 | imes("\r\n"); 383 | } 384 | 385 | void put(uint rc,uint value) 386 | { 387 | if (watch) 388 | { 389 | curs(rc); 390 | output(value); 391 | } 392 | } 393 | 394 | void flush() 395 | { 396 | if (watch && anychanges) 397 | { 398 | win_flush(); 399 | anychanges = 0; 400 | } 401 | } 402 | 403 | 404 | /*************************************** 405 | * Put messages in different spots for 40 col or 80 col display 406 | * Returns: 407 | * cursor address of start of message 408 | */ 409 | 410 | int DS(int row) 411 | { 412 | if (narrow) // if 40 column display 413 | return (row << 8) + 0; 414 | else 415 | return (row << 8) + 20; 416 | } 417 | 418 | 419 | void speaker_click() // click speaker 420 | { 421 | if (watch && speaker) 422 | { 423 | sound_click(); 424 | } 425 | } 426 | } 427 | 428 | 429 | 430 | -------------------------------------------------------------------------------- /twin.d: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * This source is written in the D Programming Language. 12 | * See www.digitalmars.com/d/ for the D specification and compiler. 13 | * 14 | * Use entirely at your own risk. There is no warranty, expressed or implied. 15 | */ 16 | 17 | /*----------------------------------------------------- 18 | Adapted from: 19 | SYSMETS.C -- System Metrics Display Program (Final) 20 | (c) Charles Petzold, 1992 21 | -----------------------------------------------------*/ 22 | 23 | import std.c.windows.windows; 24 | import std.c.stdio; 25 | import std.c.stdlib; 26 | import std.file; 27 | 28 | int min(int a, int b) { return (a < b) ? a : b; } 29 | int max(int a, int b) { return (a > b) ? a : b; } 30 | 31 | int inhelp; 32 | char szAppName[] = "TextWin" ; 33 | 34 | void helpRegister(HANDLE hInstance) 35 | { 36 | WNDCLASS wndclass ; 37 | 38 | wndclass.style = CS_HREDRAW | CS_VREDRAW ; 39 | wndclass.lpfnWndProc = &TextWndProc ; 40 | wndclass.cbClsExtra = 0 ; 41 | wndclass.cbWndExtra = 0 ; 42 | wndclass.hInstance = hInstance ; 43 | wndclass.hIcon = LoadIconA(null, IDI_APPLICATION) ; 44 | wndclass.hCursor = LoadCursorA(null, IDC_ARROW) ; 45 | wndclass.hbrBackground = GetStockObject(WHITE_BRUSH) ; 46 | wndclass.lpszMenuName = null ; 47 | wndclass.lpszClassName = szAppName ; 48 | 49 | RegisterClassA(&wndclass) ; 50 | } 51 | 52 | void help(HANDLE hInstance) 53 | { 54 | HWND hwnd ; 55 | MSG msg ; 56 | WNDCLASS wndclass ; 57 | 58 | if (inhelp) 59 | return; 60 | inhelp++; 61 | hwnd = CreateWindowA (szAppName, "Empire Help", 62 | WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL, 63 | CW_USEDEFAULT, CW_USEDEFAULT, 64 | CW_USEDEFAULT, CW_USEDEFAULT, 65 | null, null, hInstance, null) ; 66 | 67 | ShowWindow(hwnd, SW_SHOWNORMAL) ; 68 | UpdateWindow(hwnd) ; 69 | } 70 | 71 | extern(Windows) LRESULT TextWndProc (HWND hwnd, UINT message, WPARAM wParam, 72 | LPARAM lParam) 73 | { 74 | static int cxChar, cxCaps, cyChar, cxClient, cyClient, nMaxWidth, 75 | nVscrollPos, nVscrollMax, nHscrollPos, nHscrollMax ; 76 | char szBuffer[10] ; 77 | HDC hdc ; 78 | int x, y, nPaintBeg, nPaintEnd, nVscrollInc, nHscrollInc ; 79 | PAINTSTRUCT ps ; 80 | TEXTMETRICA tm ; 81 | 82 | static char[] buffer; 83 | static int numlines; 84 | 85 | char *p; 86 | int i; 87 | 88 | switch (message) 89 | { 90 | case WM_CREATE: 91 | 92 | buffer = cast(char[])std.file.read("help.txt"); 93 | numlines = 0; 94 | nMaxWidth = 0; 95 | p = buffer; 96 | for (i = 0; i < buffer.length; i++) 97 | { 98 | if (buffer[i] == '\n') 99 | { 100 | int width = &buffer[i] - p; 101 | 102 | if (i && buffer[i - 1] == '\r') 103 | width--; 104 | if (width > nMaxWidth) 105 | nMaxWidth = width; 106 | numlines++; 107 | if (i + 1 < buffer.length) 108 | p = &buffer[i + 1]; 109 | } 110 | } 111 | 112 | hdc = GetDC (hwnd) ; 113 | 114 | SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT)); 115 | GetTextMetricsA(hdc, &tm) ; 116 | cxChar = tm.tmAveCharWidth ; 117 | cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2 ; 118 | cyChar = tm.tmHeight + tm.tmExternalLeading ; 119 | 120 | ReleaseDC (hwnd, hdc) ; 121 | 122 | nMaxWidth *= cxChar; 123 | return 0 ; 124 | 125 | case WM_SIZE: 126 | cxClient = LOWORD (lParam) ; 127 | cyClient = HIWORD (lParam) ; 128 | 129 | nVscrollMax = max (0, numlines + 2 - cyClient / cyChar) ; 130 | nVscrollPos = min (nVscrollPos, nVscrollMax) ; 131 | 132 | SetScrollRange (hwnd, SB_VERT, 0, nVscrollMax, false) ; 133 | SetScrollPos (hwnd, SB_VERT, nVscrollPos, true) ; 134 | 135 | nHscrollMax = max (0, 2 + (nMaxWidth - cxClient) / cxChar) ; 136 | nHscrollPos = min (nHscrollPos, nHscrollMax) ; 137 | 138 | SetScrollRange (hwnd, SB_HORZ, 0, nHscrollMax, false) ; 139 | SetScrollPos (hwnd, SB_HORZ, nHscrollPos, true) ; 140 | return 0 ; 141 | 142 | case WM_VSCROLL: 143 | switch (wParam) 144 | { 145 | case SB_TOP: 146 | nVscrollInc = -nVscrollPos ; 147 | break ; 148 | 149 | case SB_BOTTOM: 150 | nVscrollInc = nVscrollMax - nVscrollPos ; 151 | break ; 152 | 153 | case SB_LINEUP: 154 | nVscrollInc = -1 ; 155 | break ; 156 | 157 | case SB_LINEDOWN: 158 | nVscrollInc = 1 ; 159 | break ; 160 | 161 | case SB_PAGEUP: 162 | nVscrollInc = min (-1, -cyClient / cyChar) ; 163 | break ; 164 | 165 | case SB_PAGEDOWN: 166 | nVscrollInc = max (1, cyClient / cyChar) ; 167 | break ; 168 | 169 | case SB_THUMBTRACK: 170 | nVscrollInc = LOWORD (lParam) - nVscrollPos ; 171 | break ; 172 | 173 | default: 174 | nVscrollInc = 0 ; 175 | } 176 | nVscrollInc = max (-nVscrollPos, 177 | min (nVscrollInc, nVscrollMax - nVscrollPos)) ; 178 | 179 | if (nVscrollInc != 0) 180 | { 181 | nVscrollPos += nVscrollInc ; 182 | ScrollWindow (hwnd, 0, -cyChar * nVscrollInc, null, null) ; 183 | SetScrollPos (hwnd, SB_VERT, nVscrollPos, true) ; 184 | UpdateWindow (hwnd) ; 185 | } 186 | return 0 ; 187 | 188 | case WM_HSCROLL: 189 | switch (wParam) 190 | { 191 | case SB_LINEUP: 192 | nHscrollInc = -1 ; 193 | break ; 194 | 195 | case SB_LINEDOWN: 196 | nHscrollInc = 1 ; 197 | break ; 198 | 199 | case SB_PAGEUP: 200 | nHscrollInc = -8 ; 201 | break ; 202 | 203 | case SB_PAGEDOWN: 204 | nHscrollInc = 8 ; 205 | break ; 206 | 207 | case SB_THUMBPOSITION: 208 | nHscrollInc = LOWORD (lParam) - nHscrollPos ; 209 | break ; 210 | 211 | default: 212 | nHscrollInc = 0 ; 213 | } 214 | nHscrollInc = max (-nHscrollPos, 215 | min (nHscrollInc, nHscrollMax - nHscrollPos)) ; 216 | 217 | if (nHscrollInc != 0) 218 | { 219 | nHscrollPos += nHscrollInc ; 220 | ScrollWindow (hwnd, -cxChar * nHscrollInc, 0, null, null) ; 221 | SetScrollPos (hwnd, SB_HORZ, nHscrollPos, true) ; 222 | } 223 | return 0 ; 224 | 225 | case WM_KEYDOWN: 226 | switch (wParam) 227 | { 228 | case VK_HOME: 229 | SendMessageA (hwnd, WM_VSCROLL, SB_TOP, 0L) ; 230 | break ; 231 | 232 | case VK_END: 233 | SendMessageA (hwnd, WM_VSCROLL, SB_BOTTOM, 0L) ; 234 | break ; 235 | 236 | case VK_PRIOR: 237 | SendMessageA (hwnd, WM_VSCROLL, SB_PAGEUP, 0L) ; 238 | break ; 239 | 240 | case VK_NEXT: 241 | SendMessageA (hwnd, WM_VSCROLL, SB_PAGEDOWN, 0L) ; 242 | break ; 243 | 244 | case VK_UP: 245 | SendMessageA (hwnd, WM_VSCROLL, SB_LINEUP, 0L) ; 246 | break ; 247 | 248 | case VK_DOWN: 249 | SendMessageA (hwnd, WM_VSCROLL, SB_LINEDOWN, 0L) ; 250 | break ; 251 | 252 | case VK_LEFT: 253 | SendMessageA (hwnd, WM_HSCROLL, SB_PAGEUP, 0L) ; 254 | break ; 255 | 256 | case VK_RIGHT: 257 | SendMessageA (hwnd, WM_HSCROLL, SB_PAGEDOWN, 0L) ; 258 | break ; 259 | } 260 | return 0 ; 261 | 262 | case WM_PAINT: 263 | hdc = BeginPaint (hwnd, &ps) ; 264 | 265 | SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT)); 266 | 267 | nPaintBeg = max (0, nVscrollPos + ps.rcPaint.top / cyChar - 1) ; 268 | nPaintEnd = min (numlines, 269 | nVscrollPos + ps.rcPaint.bottom / cyChar) ; 270 | 271 | p = buffer; 272 | int linnum = 0; 273 | for (i = 0; i < buffer.length; i++) 274 | { 275 | if (buffer[i] == '\n') 276 | { 277 | if (nPaintBeg <= linnum && linnum < nPaintEnd) 278 | { 279 | x = cxChar * (1 - nHscrollPos) ; 280 | y = cyChar * (1 - nVscrollPos + linnum); 281 | 282 | int width = &buffer[i] - p; 283 | if (i && buffer[i - 1] == '\r') 284 | width--; 285 | 286 | TextOutA(hdc, x, y, p, width); 287 | } 288 | linnum++; 289 | if (i + 1 < buffer.length) 290 | p = &buffer[i + 1]; 291 | } 292 | } 293 | 294 | EndPaint (hwnd, &ps) ; 295 | return 0 ; 296 | 297 | case WM_DESTROY: 298 | //PostQuitMessage (0) ; 299 | inhelp--; 300 | return 0 ; 301 | 302 | default: 303 | break; 304 | } 305 | 306 | return DefWindowProcA(hwnd, message, wParam, lParam) ; 307 | } 308 | -------------------------------------------------------------------------------- /unknown.bmp: -------------------------------------------------------------------------------- 1 | BMv6( 2 | 3 | @@@ -------------------------------------------------------------------------------- /unknown10.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigitalMars/Empire-D/02234dbe3383ccad6c95be39f5c4ed156fad92b0/unknown10.bmp -------------------------------------------------------------------------------- /var.d: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * This source is written in the D Programming Language. 12 | * See www.digitalmars.com/d/ for the D specification and compiler. 13 | * 14 | * Use entirely at your own risk. There is no warranty, expressed or implied. 15 | */ 16 | 17 | 18 | module var; 19 | 20 | import std.c.stdio; 21 | 22 | import empire; 23 | import eplayer; 24 | 25 | /************************************** 26 | * Variables not saved across game saves. 27 | */ 28 | 29 | uint noflush = 0; /* if non-zero then don't flush */ 30 | 31 | Type typx[TYPMAX] = 32 | [ 33 | { 5, 6,'A', 0 }, 34 | { 10,12,'F',20 }, 35 | { 20,24,'D', 3 }, 36 | { 30,36,'T', 3 }, 37 | { 25,30,'S', 2 }, 38 | { 50,60,'R', 8 }, 39 | { 60,72,'C', 8 }, 40 | { 75,90,'B',12 }, 41 | ]; 42 | 43 | 44 | // These are fleshed out in init_var() 45 | // ,*,.,+,O,A,F,F,D,T,S,R,C,B 46 | int own [MAPMAX] = [0,0,0,0,1,1,1,1,1,1,1,1,1,1, // etc. 47 | 2,2,2,2,2,2,2,2,2,2]; 48 | int typ [MAPMAX] = [J,X,J,J,X,A,F,F,D,T,S,R,C,B, // etc. 49 | X,A,F,F,D,T,S,R,C,B]; 50 | int sea [MAPMAX] = [0,0,1,0,0,0,0,1,1,1,1,1,1,1, // etc. 51 | 0,0,0,1,1,1,1,1,1,1]; 52 | int land[MAPMAX] = [0,0,0,1,0,1,1,0,0,0,0,0,0,0, // etc. 53 | 0,1,1,0,0,0,0,0,0,0]; 54 | 55 | /* Mask table. Index is type (A..B). */ 56 | ubyte msk[8] = [mA,mF,mD,mT,mS,mR,mC,mB]; 57 | 58 | /* direction table, index is -1..7 59 | * 60 | * qwe 3 2 1 61 | * a d 4 -1 0 62 | * zxc 5 6 7 63 | */ 64 | 65 | int arrow(dir_t dir) 66 | in 67 | { 68 | assert(-1 <= dir && dir <= 7); 69 | } 70 | body 71 | { 72 | static int arrow[9] = 73 | [0,1,-Mcolmx,-Mcolmx-1,-Mcolmx-2,-1,Mcolmx,Mcolmx+1,Mcolmx+2]; 74 | 75 | return arrow[dir + 1]; 76 | } 77 | 78 | int mapgen = false; /* true if we're running MAPGEN.EXE */ 79 | int savegame = false; /* set to true if we're to save the game */ 80 | 81 | /************************************* 82 | * Variables saved across game saves. 83 | * All variables must be initialized, so they are in the same segment. 84 | */ 85 | 86 | ubyte savbeg = 0; /* start of variable save area */ 87 | 88 | 89 | /* 90 | * Map variables 91 | */ 92 | 93 | ubyte map[MAPSIZE] = [0,]; // reference map 94 | int empver = VERSION; // version number 95 | //static int mapbas = 0; // not used 96 | 97 | uint seedhi=0,seedlo=0; /* seeds for random() */ 98 | int overpop = false; /* true means unit arrays are full */ 99 | int tamper = false; /* true means prog has been tampered with */ 100 | 101 | /* 102 | * City variables. 103 | */ 104 | 105 | uint cittop = 0; /* actual number of cities */ 106 | City city[CITMAX]; 107 | 108 | /* 109 | * Unit variables. 110 | */ 111 | 112 | uint unitop = 0; /* unitop >= topmost unit number */ 113 | Unit unit[UNIMAX]; 114 | 115 | /* 116 | * Player variables. 117 | */ 118 | 119 | int numply = 0, /* default number of players playing */ 120 | plynum = 0, /* which player is playing, 1..numply */ 121 | concede = false, /* set to true if computer concedes game */ 122 | numleft = 0; /* number of players left in the game */ 123 | 124 | Player player[PLYMAX + 1]; 125 | 126 | ubyte savend = 0; /* so we can find end of variable space */ 127 | 128 | /************************************* 129 | * Initialize variables. 130 | */ 131 | 132 | void init_var() 133 | { 134 | int i,j; 135 | 136 | for (i = 0; i < PLYMAX; i++) 137 | { 138 | if (i && player[i].map) 139 | free(player[i].map); 140 | 141 | if (player[i].display) 142 | delete player[i].display; 143 | } 144 | 145 | memset(&savbeg, 0, &savend - &savbeg); 146 | memset(city, 0, city.sizeof); 147 | memset(unit, 0, unit.sizeof); 148 | memset(player, 0, player.sizeof); 149 | 150 | for (i = 1; i <= PLYMAX; i++) 151 | { 152 | for (j = 0; j < 10; j++) 153 | { // Fill in the etc. parts 154 | 155 | own [4 + (i - 1) * 10 + j] = i; 156 | typ [4 + (i - 1) * 10 + j] = typ [4 + j]; 157 | sea [4 + (i - 1) * 10 + j] = sea [4 + j]; 158 | land[4 + (i - 1) * 10 + j] = land[4 + j]; 159 | } 160 | } 161 | } 162 | 163 | /********************************* 164 | * Save the game in filename. 165 | * Returns: 166 | * 0 success 167 | * !=0 error 168 | */ 169 | 170 | int var_savgam(char* filename) 171 | { 172 | FILE *fp; 173 | char r; 174 | size_t n; 175 | int i; 176 | 177 | fp = fopen(filename,"wb"); 178 | if (fp == null) goto err; 179 | n = &savend - &savbeg; 180 | if (fwrite(&savbeg, 1, n, fp) != n) 181 | goto err2; 182 | n = CITMAX; 183 | if (fwrite(city, City.sizeof, n, fp) != n) 184 | goto err2; 185 | n = UNIMAX; 186 | if (fwrite(unit, Unit.sizeof, n, fp) != n) 187 | goto err2; 188 | n = PLYMAX + 1; 189 | if (fwrite(player, Player.sizeof, n, fp) != n) 190 | goto err2; 191 | 192 | player[0].map = .map; 193 | for (i = 1; i <= numply; i++) 194 | { 195 | n = MAPSIZE; 196 | if (fwrite(player[i].map, map[0].sizeof, n, fp) != n) 197 | goto err2; 198 | } 199 | 200 | if (fclose(fp) == -1) goto err; 201 | return 0; 202 | 203 | err2: 204 | fclose(fp); 205 | err: 206 | return 1; 207 | } 208 | 209 | 210 | /****************************** 211 | * Restore game from fp. 212 | * Returns: 213 | * 0 success 214 | * !=0 error 215 | */ 216 | 217 | int resgam(FILE* fp) 218 | { 219 | size_t n; 220 | int i; 221 | 222 | n = &savend - &savbeg; 223 | if (fread(&savbeg, 1, n, fp) != n) 224 | goto err2; 225 | n = CITMAX; 226 | if (fread(city, City.sizeof, n, fp) != n) 227 | goto err2; 228 | n = UNIMAX; 229 | if (fread(unit, Unit.sizeof, n, fp) != n) 230 | goto err2; 231 | n = PLYMAX + 1; 232 | if (fread(player, Player.sizeof, n, fp) != n) 233 | goto err2; 234 | 235 | player[0].map = .map; 236 | for (i = 1; i <= numply; i++) 237 | { 238 | n = MAPSIZE; 239 | player[i].map = cast(ubyte *)calloc(MAPSIZE, 1); 240 | if (fread(player[i].map, map[0].sizeof, n, fp) != n) 241 | goto err2; 242 | player[i].usv = null; 243 | } 244 | 245 | if (fclose(fp) == -1) goto err; 246 | 247 | return 0; 248 | 249 | err2: 250 | fclose(fp); 251 | err: 252 | return 1; 253 | } 254 | 255 | -------------------------------------------------------------------------------- /winemp.d: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * This source is written in the D Programming Language. 12 | * See www.digitalmars.com/d/ for the D specification and compiler. 13 | * 14 | * Use entirely at your own risk. There is no warranty, expressed or implied. 15 | */ 16 | 17 | /* winemp.d */ 18 | 19 | enum 20 | { 21 | 22 | BMP_CURSOR = 140, 23 | BMP_SPLASH = 141, 24 | BMP_UNKNOWN10 = 142, 25 | BMP_BLAST = 143, 26 | BMP_BLASTMASK = 144, 27 | 28 | IDD_ARMIES = 150, 29 | IDD_FIGHTERS = 151, 30 | IDD_DESTROYERS = 152, 31 | IDD_TRANSPORTS = 153, 32 | IDD_SUBMARINES = 154, 33 | IDD_CRUISERS = 155, 34 | IDD_CARRIERS = 156, 35 | IDD_BATTLESHIPS = 157, 36 | 37 | IDD_SENSOR = 158, 38 | IDD_TILE = 159, 39 | 40 | IDD_ONE = 161, 41 | IDD_TWO = 162, 42 | IDD_THREE = 163, 43 | IDD_FOUR = 164, 44 | IDD_FIVE = 165, 45 | IDD_SIX = 166, 46 | 47 | IDD_DEMO = 167, 48 | 49 | IDM_NEW = 170, 50 | IDM_OPEN = 171, 51 | IDM_SAVE = 172, 52 | IDM_ABOUT = 173, 53 | IDM_CLOSE = 174, 54 | IDM_SOUND = 175, 55 | IDM_F = 176, 56 | IDM_G = 177, 57 | IDM_H = 178, 58 | IDM_I = 179, 59 | IDM_K = 180, 60 | IDM_L = 181, 61 | IDM_N = 182, 62 | IDM_P = 183, 63 | IDM_R = 184, 64 | IDM_S = 185, 65 | IDM_U = 186, 66 | IDM_Y = 187, 67 | IDM_ESC = 188, 68 | IDM_FASTER = 189, 69 | IDM_SLOWER = 190, 70 | IDM_HELP = 191, 71 | IDM_ZOOMIN = 192, 72 | IDM_ZOOMOUT = 193, 73 | IDM_POV = 194, 74 | 75 | } 76 | -------------------------------------------------------------------------------- /winemp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Empire, the Wargame of the Century (tm) 3 | * Copyright (C) 1978-2004 by Walter Bright 4 | * All Rights Reserved 5 | * 6 | * You may use this source for personal use only. To use it commercially 7 | * or to distribute source or binaries of Empire, please contact 8 | * www.digitalmars.com. 9 | * 10 | * Written by Walter Bright. 11 | * 12 | * Use entirely at your own risk. There is no warranty, expressed or implied. 13 | */ 14 | 15 | /* winemp.h */ 16 | 17 | #define BMP_CURSOR 140 18 | #define BMP_SPLASH 141 19 | #define BMP_UNKNOWN10 142 20 | #define BMP_BLAST 143 21 | #define BMP_BLASTMASK 144 22 | 23 | #define IDD_ARMIES 150 24 | #define IDD_FIGHTERS 151 25 | #define IDD_DESTROYERS 152 26 | #define IDD_TRANSPORTS 153 27 | #define IDD_SUBMARINES 154 28 | #define IDD_CRUISERS 155 29 | #define IDD_CARRIERS 156 30 | #define IDD_BATTLESHIPS 157 31 | 32 | #define IDD_SENSOR 158 33 | #define IDD_TILE 159 34 | 35 | #define IDD_ONE 161 36 | #define IDD_TWO 162 37 | #define IDD_THREE 163 38 | #define IDD_FOUR 164 39 | #define IDD_FIVE 165 40 | #define IDD_SIX 166 41 | 42 | #define IDD_DEMO 167 43 | 44 | #define IDM_NEW 170 45 | #define IDM_OPEN 171 46 | #define IDM_SAVE 172 47 | #define IDM_ABOUT 173 48 | #define IDM_CLOSE 174 49 | #define IDM_SOUND 175 50 | #define IDM_F 176 51 | #define IDM_G 177 52 | #define IDM_H 178 53 | #define IDM_I 179 54 | #define IDM_K 180 55 | #define IDM_L 181 56 | #define IDM_N 182 57 | #define IDM_P 183 58 | #define IDM_R 184 59 | #define IDM_S 185 60 | #define IDM_U 186 61 | #define IDM_Y 187 62 | #define IDM_ESC 188 63 | #define IDM_FASTER 189 64 | #define IDM_SLOWER 190 65 | #define IDM_HELP 191 66 | #define IDM_ZOOMIN 192 67 | #define IDM_ZOOMOUT 193 68 | #define IDM_POV 194 69 | -------------------------------------------------------------------------------- /winmain.d: -------------------------------------------------------------------------------- 1 | //_ winmain.d Tue Nov 05 2002 */ 2 | // Copyright (c) 2002-2004 by Walter Bright 3 | // All Rights Reserved 4 | // Compile with Digital Mars compiler www.digitalmars.com 5 | // www.classicempire.com 6 | 7 | import std.c.stdlib; 8 | import std.c.windows.windows; 9 | 10 | import empire; 11 | import winemp; 12 | import eplayer; 13 | import display; 14 | import twin; 15 | import init; 16 | 17 | /********************************************************/ 18 | extern (C) void gc_init(); 19 | extern (C) void gc_term(); 20 | extern (C) void _minit(); 21 | extern (C) void _moduleCtor(); 22 | extern (C) void _moduleUnitTests(); 23 | 24 | extern (Windows) 25 | int WinMain(HINSTANCE hInstance, 26 | HINSTANCE hPrevInstance, 27 | LPSTR lpCmdLine, 28 | int nCmdShow) 29 | { 30 | int result; 31 | 32 | gc_init(); // initialize garbage collector 33 | _minit(); // initialize module constructor table 34 | 35 | try 36 | { 37 | _moduleCtor(); // call module constructors 38 | _moduleUnitTests(); // run unit tests (optional) 39 | 40 | // insert user code here 41 | result = doit(hInstance, hPrevInstance, lpCmdLine, nCmdShow); 42 | } 43 | 44 | catch (Object o) // catch any uncaught exceptions 45 | { 46 | MessageBoxA(null, cast(char *)o.toString(), "Error", 47 | MB_OK | MB_ICONEXCLAMATION); 48 | result = 0; // failed 49 | } 50 | 51 | gc_term(); // run finalizers; terminate garbage collector 52 | return result; 53 | } 54 | /********************************************************/ 55 | 56 | 57 | /* Collect all Windows static global data. 58 | */ 59 | 60 | extern (Windows) 61 | { 62 | alias int function(HANDLE, uint, uint, int) DLGPROC; 63 | } 64 | 65 | struct Global 66 | { 67 | HANDLE hinst; // instance of entire program program 68 | HWND hwnd; // handle of main window 69 | 70 | int inited; // !=0 means game is initialized 71 | HANDLE hSplash; // handle for splash screen .bmp 72 | 73 | // About 74 | DLGPROC lpfnAboutDlgProc ; 75 | 76 | // City Select 77 | int phase; 78 | int newphase; 79 | DLGPROC lpfnCitySelectDlgProc ; 80 | 81 | // Init 82 | int numplayers; 83 | int newnumplayers; 84 | int demo; 85 | DLGPROC lpfnInitDlgProc ; 86 | 87 | int speaker; // !=0 means sound is on 88 | 89 | // Menu 90 | HMENU hMenu; 91 | 92 | OPENFILENAMEA ofn; // save file 93 | 94 | double scalex; // zoom factor 95 | double scaley; // zoom factor 96 | 97 | // Font 98 | HFONT hFont; 99 | short cxChar, cxCaps, cyChar; 100 | 101 | // Pen 102 | HPEN hPen; 103 | 104 | // Bitmaps 105 | HANDLE mapvaltab[MAPMAX]; 106 | HANDLE unknown10; 107 | 108 | Player *player; // which player is being displayed 109 | ubyte *map; // which map is being displayed 110 | loc_t ulcorner; // upper left corner 111 | loc_t cursor; // location of cursor 112 | HANDLE hCursor; // bitmap of cursor 113 | int offsetx; 114 | int offsety; 115 | 116 | // Window size 117 | int cxClient, cyClient; 118 | 119 | // Clipping rectangles 120 | RECT sector; 121 | RECT text; 122 | 123 | HRGN sectorRegion; 124 | HRGN textRegion; 125 | 126 | // Sector size 127 | int pixelx; 128 | int pixely; 129 | 130 | // Blast 131 | HANDLE hBlast; // bitmap of blast 132 | HANDLE hBlastmask; // bitmap of blast 133 | int blastState; // !=0 means draw blast 134 | int blastx; 135 | int blasty; // location of blast 136 | }; 137 | 138 | Global global; 139 | 140 | 141 | int doit(HANDLE hInstance, HANDLE hPrevInstance, 142 | LPSTR lpszCmdLine, int nCmdShow) 143 | { 144 | static char szAppName [] = "Empire"; 145 | HWND hwnd; 146 | MSG msg; 147 | WNDCLASS wndclass; 148 | 149 | if (!hPrevInstance) 150 | { 151 | wndclass.style = CS_HREDRAW | CS_VREDRAW; 152 | wndclass.lpfnWndProc = &WndProc; 153 | wndclass.cbClsExtra = 0; 154 | wndclass.cbWndExtra = 0; 155 | wndclass.hInstance = hInstance; 156 | wndclass.hIcon = LoadIconA(hInstance, "About"); 157 | wndclass.hCursor = LoadCursorA (null, IDC_ARROW); 158 | wndclass.hbrBackground = GetStockObject (WHITE_BRUSH); 159 | wndclass.lpszMenuName = szAppName; 160 | wndclass.lpszClassName = szAppName; 161 | 162 | RegisterClassA(&wndclass); 163 | 164 | helpRegister(hInstance); 165 | } 166 | 167 | global.hinst = hInstance; 168 | 169 | version(none) 170 | { 171 | hwnd = CreateWindowA(szAppName, "Empire: Wargame of the Century", 172 | WS_OVERLAPPEDWINDOW, 173 | CW_USEDEFAULT, CW_USEDEFAULT, 174 | 124, 160 + 34 + 20, 175 | null, null, hInstance, null); 176 | } 177 | else 178 | { 179 | hwnd = CreateWindowA(szAppName, "Empire: Wargame of the Century", 180 | WS_OVERLAPPEDWINDOW, 181 | CW_USEDEFAULT, CW_USEDEFAULT, 182 | CW_USEDEFAULT, CW_USEDEFAULT, 183 | null, null, hInstance, null); 184 | } 185 | 186 | ShowWindow (hwnd, nCmdShow); 187 | UpdateWindow(hwnd); 188 | 189 | while (true) 190 | { 191 | if (PeekMessageA(&msg, null, 0, 0, PM_REMOVE)) 192 | { 193 | if (msg.message == WM_QUIT) 194 | break; 195 | TranslateMessage (&msg); 196 | DispatchMessageA (&msg); 197 | } 198 | else 199 | { 200 | // idle processing 201 | if (global.inited) 202 | slice(); 203 | } 204 | } 205 | return msg.wParam; 206 | } 207 | 208 | void DrawBitmap(HDC hdc, short xStart, short yStart, HBITMAP hBitmap, double scalex, double scaley, DWORD mode) 209 | { 210 | // Petzold pg. 631 has a different version 211 | 212 | BITMAP bm; 213 | HDC hMemDC; 214 | POINT pt; 215 | 216 | //PRINTF("scalex = %g, scaley = %g\n", scalex, scaley); 217 | hMemDC = CreateCompatibleDC(hdc); 218 | SelectObject(hMemDC, hBitmap); 219 | GetObjectA(hBitmap, BITMAP.sizeof, cast(LPSTR) &bm); 220 | pt.x = bm.bmWidth; 221 | pt.y = bm.bmHeight; 222 | 223 | //BitBlt (hdc, xStart, yStart, pt.x, pt.y, hMemDC, 0, 0, mode); 224 | StretchBlt(hdc, xStart, yStart, 225 | cast(int) (pt.x * scalex + .99), cast(int) (pt.y * scaley + .99), 226 | hMemDC, 0, 0, pt.x, pt.y, mode); 227 | 228 | DeleteDC(hMemDC); 229 | } 230 | 231 | extern (Windows) int WndProc(HWND hwnd, uint message, WPARAM wParam, 232 | LPARAM lParam) 233 | { 234 | HANDLE hBitmap; 235 | HDC hdc; 236 | PAINTSTRUCT ps; 237 | POINT point; 238 | TEXTMETRICA tm; 239 | int i; 240 | int j; 241 | int ch; 242 | static LOGFONTA logfont; 243 | double newscalex; 244 | double newscaley; 245 | 246 | // File dialog box 247 | static char szFileName [_MAX_PATH]; 248 | static char szTitleName[_MAX_FNAME + _MAX_EXT]; 249 | static char *szFilter[] = [ "Empire Files (*.EMP)", "*.emp", "" ]; 250 | 251 | switch (message) 252 | { 253 | case WM_CREATE: 254 | global.speaker = 1; 255 | 256 | global.cxClient = 120; 257 | global.cyClient = 160; 258 | 259 | global.pixelx = 120; 260 | global.pixely = 120; 261 | 262 | global.hwnd = hwnd; 263 | global.scalex = 1.0; 264 | global.scaley = 1.0; 265 | global.numplayers = IDD_FOUR; 266 | global.map = .map; 267 | global.offsetx = 0; 268 | global.offsety = 0; 269 | 270 | // Clipping rectangles 271 | global.text.left = 0; 272 | global.text.top = 0; 273 | global.text.right = global.pixelx; 274 | global.text.bottom = 40; 275 | 276 | global.sector.left = 0; 277 | global.sector.top = 40; 278 | global.sector.right = global.pixelx; 279 | global.sector.bottom = global.sector.top + global.pixely; 280 | 281 | global.sectorRegion = CreateRectRgn(global.sector.left, global.sector.top, global.sector.right, global.sector.bottom); 282 | global.textRegion = CreateRectRgn(global.text.left, global.text.top, global.text.right, global.text.bottom); 283 | 284 | // About dialog box 285 | //hInstance = ((LPCREATESTRUCT) lParam)->hInstance; 286 | 287 | version (0) 288 | { 289 | global.lpfnAboutDlgProc = cast(DLGPROC) &AboutDlgProc; 290 | global.lpfnCitySelectDlgProc = cast(DLGPROC) &CitySelectDlgProc; 291 | global.lpfnInitDlgProc = cast(DLGPROC) &InitDlgProc; 292 | } 293 | else 294 | { 295 | global.lpfnAboutDlgProc = cast(DLGPROC) MakeProcInstance (cast(FARPROC) AboutDlgProc, 296 | global.hinst); 297 | 298 | global.lpfnCitySelectDlgProc = cast(DLGPROC) MakeProcInstance (cast(FARPROC) CitySelectDlgProc, 299 | global.hinst); 300 | 301 | global.lpfnInitDlgProc = cast(DLGPROC) MakeProcInstance (cast(FARPROC) InitDlgProc, 302 | global.hinst) ; 303 | } 304 | 305 | // Menu 306 | global.hMenu = LoadMenuA(global.hinst, "PopMenu"); 307 | global.hMenu = GetSubMenu(global.hMenu, 0); 308 | 309 | // File dialog box 310 | global.ofn.lStructSize = OPENFILENAMEA.sizeof; 311 | global.ofn.hwndOwner = hwnd; 312 | global.ofn.lpstrFilter = szFilter[0]; 313 | global.ofn.lpstrFile = szFileName; 314 | global.ofn.nMaxFile = _MAX_PATH; 315 | global.ofn.lpstrFileTitle = szTitleName; 316 | global.ofn.nMaxFileTitle = _MAX_FNAME + _MAX_EXT; 317 | global.ofn.lpstrDefExt = "emp"; 318 | 319 | for (i = 0; i < MAPMAX; i++) 320 | { 321 | hBitmap = LoadBitmapA(global.hinst, MAKEINTRESOURCEA(i + 1)); 322 | global.mapvaltab[i] = hBitmap; 323 | } 324 | global.unknown10 = LoadBitmapA(global.hinst, MAKEINTRESOURCEA(BMP_UNKNOWN10)); 325 | global.hCursor = LoadBitmapA(global.hinst, MAKEINTRESOURCEA(BMP_CURSOR)); 326 | global.hSplash = LoadBitmapA(global.hinst, MAKEINTRESOURCEA(BMP_SPLASH)); 327 | global.hBlast = LoadBitmapA(global.hinst, MAKEINTRESOURCEA(BMP_BLAST)); 328 | global.hBlastmask = LoadBitmapA(global.hinst, MAKEINTRESOURCEA(BMP_BLASTMASK)); 329 | 330 | hdc = GetDC(hwnd); 331 | 332 | logfont.lfHeight = 10; 333 | logfont.lfWidth = 5; 334 | global.hFont = CreateFontIndirectA(&logfont); 335 | SelectObject(hdc, global.hFont); 336 | 337 | GetTextMetricsA(hdc, &tm); 338 | global.cxChar = tm.tmAveCharWidth; 339 | global.cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * global.cxChar / 2; 340 | global.cyChar = tm.tmHeight + tm.tmExternalLeading; 341 | 342 | ReleaseDC(hwnd, hdc); 343 | return 0; 344 | 345 | case WM_SIZE: 346 | global.cyClient = HIWORD(lParam); 347 | global.cxClient = LOWORD(lParam); 348 | //PRINTF("cxClient = %d, cyClient = %d\n", global.cxClient, global.cyClient); 349 | 350 | global.pixelx = global.cxClient; 351 | if (global.pixelx < 120) 352 | global.pixelx = 120; 353 | if (global.pixelx > (Mcolmx + 1) * 10) 354 | global.pixelx = (Mcolmx + 1) * 10; 355 | if (global.pixelx / cast(int)(10 * global.scalex) < 5) 356 | { 357 | global.scalex = global.pixelx / (10 * 5.0); 358 | global.scaley = global.scalex; 359 | } 360 | 361 | global.pixely = global.cyClient - 40; 362 | if (global.pixely < 120) 363 | global.pixely = 120; 364 | if (global.pixely > (Mrowmx + 1) * 10) 365 | global.pixely = (Mrowmx + 1) * 10; 366 | if (global.pixely / cast(int)(10 * global.scaley) < 5) 367 | { 368 | global.scaley = global.pixely / (10 * 5.0); 369 | global.scalex = global.scaley; 370 | } 371 | 372 | global.text.right = global.pixelx; 373 | global.sector.right = global.pixelx; 374 | global.sector.bottom = global.sector.top + global.pixely; 375 | 376 | SetRectRgn(global.sectorRegion, global.sector.left, global.sector.top, global.sector.right, global.sector.bottom); 377 | SetRectRgn(global.textRegion, global.text.left, global.text.top, global.text.right, global.text.bottom); 378 | 379 | if (global.inited && global.player) 380 | { Display *d = global.player.display; 381 | 382 | d.secbas = -1; 383 | d.setdispsize(d.text.nrows, d.text.ncols); 384 | d.text.clear(); 385 | adjSector(global.scalex, global.scaley); 386 | } 387 | 388 | return 0; 389 | 390 | //case WM_LBUTTONDOWN: 391 | case WM_RBUTTONDOWN: 392 | point.x = lParam & 0xFFFF; 393 | point.y = (lParam >> 16) & 0xFFFF; 394 | ClientToScreen(hwnd, &point); 395 | TrackPopupMenu(global.hMenu, 0, point.x, point.y, 0, hwnd, null); 396 | return 0; 397 | 398 | case WM_COMMAND: 399 | switch (wParam) 400 | { 401 | case IDM_NEW: // start new game 402 | DialogBoxParamA(global.hinst, "InitBox", hwnd, 403 | global.lpfnInitDlgProc, 0); 404 | init_var(); 405 | winSetup(); 406 | global.inited = 1; 407 | InvalidateRect(hwnd, null, true) ; 408 | return 0; 409 | 410 | case IDM_OPEN: // open saved game 411 | if (GetOpenFileNameA (&global.ofn)) 412 | { FILE *fp; 413 | 414 | fp = fopen(global.ofn.lpstrFile, "rb"); 415 | if (!fp) 416 | { 417 | MessageBoxA (hwnd, "Empire Restore", 418 | "Could not read EMP file", 419 | MB_ICONEXCLAMATION | MB_OK); 420 | } 421 | else 422 | { 423 | init_var(); 424 | if (resgam(fp)) 425 | { MessageBoxA (hwnd, "Empire Restore", 426 | "Corrupt EMP file", 427 | MB_ICONEXCLAMATION | MB_OK); 428 | winSetup(); 429 | } 430 | else 431 | winRestore(); 432 | global.inited = 1; 433 | InvalidateRect(hwnd, null, true) ; 434 | } 435 | } 436 | return 0; 437 | 438 | case IDM_SAVE: // save existing game 439 | if (GetOpenFileNameA (&global.ofn)) 440 | { 441 | if (var_savgam(global.ofn.lpstrFile)) 442 | { 443 | MessageBoxA (hwnd, "Empire Save", 444 | "Could not write EMP file", 445 | MB_ICONEXCLAMATION | MB_OK) ; 446 | } 447 | } 448 | return 0; 449 | 450 | case IDM_CLOSE: 451 | exit(0); 452 | return 0; 453 | 454 | case IDM_SOUND: 455 | global.speaker ^= 1; 456 | return 0; 457 | 458 | case IDM_ABOUT: 459 | DialogBoxParamA(global.hinst, "AboutBox", hwnd, 460 | global.lpfnAboutDlgProc, 0) ; 461 | return 0; 462 | 463 | case IDM_HELP: 464 | help(global.hinst); 465 | return 0; 466 | 467 | case IDM_ZOOMIN: 468 | goto Lzoomin; 469 | 470 | case IDM_ZOOMOUT: 471 | goto Lzoomout; 472 | 473 | case IDM_F: ch = 'F'; goto Linsert; 474 | case IDM_G: ch = 'G'; goto Linsert; 475 | case IDM_H: ch = 'H'; goto Linsert; 476 | case IDM_I: ch = 'I'; goto Linsert; 477 | case IDM_K: ch = 'K'; goto Linsert; 478 | case IDM_L: ch = 'L'; goto Linsert; 479 | case IDM_N: ch = 'N'; goto Linsert; 480 | case IDM_P: ch = 'P'; goto Linsert; 481 | case IDM_R: ch = 'R'; goto Linsert; 482 | case IDM_S: ch = 'S'; goto Linsert; 483 | case IDM_U: ch = 'U'; goto Linsert; 484 | case IDM_Y: ch = 'Y'; goto Linsert; 485 | case IDM_ESC: ch = ESC; goto Linsert; 486 | case IDM_FASTER: ch = '<'; goto Linsert; 487 | case IDM_SLOWER: ch = '>'; goto Linsert; 488 | case IDM_POV: ch = 'O'; goto Linsert; 489 | 490 | default: 491 | break; 492 | } 493 | break; 494 | 495 | case WM_CHAR: 496 | switch (wParam) 497 | { 498 | version(none) 499 | { 500 | case 'c': 501 | DialogBoxParamA(global.hinst, "CitySelectBox", hwnd, 502 | global.lpfnCitySelectDlgProc, 0) ; 503 | return 0; 504 | } 505 | 506 | case 'j': 507 | case 'J': 508 | global.speaker ^= 1; 509 | return 0; 510 | 511 | case 12: 512 | InvalidateRect(hwnd, null, true); 513 | break; 514 | 515 | default: 516 | ch = wParam; 517 | Linsert: 518 | // Insert into buffer of player we are watching 519 | Player *p; 520 | 521 | for (int i = 1; i <= numply; i++) 522 | { 523 | p = Player.get(i); 524 | if (p.watch) 525 | { 526 | p.display.text.TTunget(ch); 527 | break; 528 | } 529 | } 530 | break; 531 | } 532 | return 0; 533 | 534 | case WM_KEYDOWN: 535 | switch (wParam) 536 | { 537 | case VK_ADD: 538 | Lzoomin: 539 | newscalex = global.scalex * 1.125; 540 | newscaley = global.scaley * 1.125; 541 | if (global.pixelx / cast(int)(10 * newscalex) >= 5) 542 | { 543 | if (newscalex < newscaley) 544 | newscaley = global.scaley; 545 | else 546 | newscaley = newscalex; 547 | goto Lnew; 548 | } 549 | return 0; 550 | 551 | case VK_SUBTRACT: 552 | Lzoomout: 553 | newscalex = global.scalex / 1.125; 554 | newscaley = global.scaley / 1.125; 555 | if (global.pixelx / cast(int)(10 * newscalex) <= (Mcolmx + 1)) 556 | { 557 | if (global.pixely / cast(int)(10 * newscaley) > (Mrowmx + 1)) 558 | newscaley = global.scaley; 559 | //PRINTF("newscale x,y = %g, %g\n", newscalex, newscaley); 560 | Lnew: 561 | 562 | adjSector(newscalex, newscaley); 563 | 564 | InvalidateRect(hwnd, &global.sector, false); 565 | } 566 | return 0; 567 | 568 | case VK_PRIOR: // PgUp 569 | case VK_NEXT: // PgDn 570 | case VK_HOME: 571 | case VK_LEFT: 572 | case VK_RIGHT: 573 | case VK_UP: 574 | case VK_DOWN: 575 | return 0; 576 | 577 | default: 578 | break; 579 | } 580 | break; 581 | 582 | case WM_PAINT: 583 | //PRINTF("+WM_PAINT\n"); 584 | hdc = BeginPaint (hwnd, &ps); 585 | 586 | if (!global.inited || !global.player) 587 | { double sx, sy; 588 | 589 | version (none) 590 | { 591 | sx = global.cxClient / 240.0; 592 | if (sx < 1) 593 | sx = 1; 594 | sy = global.cyClient / 120.0; 595 | if (sy < 1) 596 | sy = 1; 597 | } 598 | else 599 | { 600 | sx = global.cxClient / 120.0; 601 | if (sx < 1) 602 | sx = 1; 603 | sy = global.cyClient / 160.0; 604 | if (sy < 1) 605 | sy = 1; 606 | } 607 | DrawBitmap(hdc, 0, 0, global.hSplash, 608 | sx, sy, 609 | SRCCOPY); 610 | static int intro; 611 | if (!intro++) 612 | PlaySoundA("intro.wav", null, SND_ASYNC | SND_FILENAME); 613 | } 614 | else 615 | { 616 | //PRINTF("WM_PAINT: ulcorner = %d, cursor = %d, offsetx = %d, offsety = %d\n", global.ulcorner, global.cursor, global.offsetx, global.offsety); 617 | int r, c; 618 | int dx; 619 | int dy; 620 | DWORD mode; 621 | RECT clipbox; 622 | 623 | GetClipBox(hdc, &clipbox); 624 | //PRINTF("sector : %2d,%2d %2d,%2d\n", global.sector.left, global.sector.top, global.sector.right, global.sector.bottom); 625 | //PRINTF("clipbox: %2d,%2d %2d,%2d\n", clipbox.left, clipbox.top, clipbox.right, clipbox.bottom); 626 | if (clipbox.bottom < global.sector.top) 627 | goto LpaintText; 628 | 629 | SelectClipRgn(hdc, global.sectorRegion); 630 | 631 | r = ROW(global.ulcorner); 632 | c = COL(global.ulcorner); 633 | int rmax, cmax; 634 | dx = cast(int)(10 * global.scalex); 635 | dy = cast(int)(10 * global.scaley); 636 | rmax = r + (global.offsety + global.pixely + dy - 1) / dy; 637 | cmax = c + (global.offsetx + global.pixelx + dx - 1) / dx; 638 | if (rmax > Mrowmx) 639 | rmax = Mrowmx + 1; 640 | if (cmax > Mcolmx) 641 | cmax = Mcolmx + 1; 642 | for (j = r; j < rmax; j++) 643 | { int y; 644 | 645 | y = global.sector.top + (j - r) * dy - global.offsety; 646 | if (y >= clipbox.bottom || 647 | y + dy < clipbox.top) 648 | continue; 649 | 650 | for (i = c; i < cmax; i++) 651 | { 652 | loc_t loc = j * (Mcolmx + 1) + i; 653 | HANDLE h; 654 | int x; 655 | 656 | x = (i - c) * dx - global.offsetx; 657 | if (x >= clipbox.right || 658 | x + dx < clipbox.left) 659 | continue; 660 | 661 | h = global.mapvaltab[global.map[loc]]; 662 | if ((j % 10) == 0 && (i % 10) == 0 && 663 | global.map[loc] == 0) 664 | h = global.unknown10; 665 | mode = SRCCOPY; 666 | if (loc == global.cursor && global.player.mode != mdSURV) 667 | { //h = global.hCursor; 668 | mode = NOTSRCCOPY; 669 | } 670 | DrawBitmap(hdc, x, y, h, 671 | global.scalex, global.scaley, mode); 672 | } 673 | } 674 | 675 | // Draw a rectangle around the map edge 676 | int x1,y1,x2,y2; 677 | x1 = -c * dx - global.offsetx; 678 | y1 = 40 - r * dx - global.offsety; 679 | x2 = x1 + (Mcolmx + 1) * dx - 1; 680 | y2 = y1 + (Mrowmx + 1) * dy - 1; 681 | global.hPen = CreatePen(PS_SOLID, dx/3+2, RGB(255, 0, 0)); 682 | SelectObject(hdc, global.hPen); 683 | MoveToEx(hdc, x1, y1, null); 684 | LineTo(hdc, x2, y1); 685 | LineTo(hdc, x2, y2); 686 | LineTo(hdc, x1, y2); 687 | LineTo(hdc, x1, y1); 688 | DeleteObject(global.hPen); 689 | 690 | // Do the blast graphic 691 | if (global.blastState) 692 | { 693 | DrawBitmap(hdc, global.blastx, global.blasty, global.hBlastmask, 1.0, 1.0, SRCAND); 694 | DrawBitmap(hdc, global.blastx, global.blasty, global.hBlast, 1.0, 1.0, SRCPAINT); 695 | } 696 | 697 | // Do the survey mode graphic 698 | if (global.player && global.player.mode == mdSURV) 699 | { HPEN hPen; 700 | int x1,y1,x2,y2; 701 | int cursorx, cursory; 702 | 703 | hPen = CreatePen(PS_DASH, 0, RGB(255, 255, 255)); 704 | SelectObject(hdc, hPen); 705 | 706 | cursorx = LocToX(global.player.curloc); 707 | cursory = LocToY(global.player.curloc); 708 | 709 | x1 = 0; 710 | y1 = cursory; 711 | x2 = cursorx - dx/2; 712 | y2 = y1; 713 | MoveToEx(hdc, x1, y1, null); 714 | LineTo(hdc, x2, y2); 715 | 716 | x1 = x2 + dx; 717 | x2 = global.pixelx; 718 | MoveToEx(hdc, x1, y1, null); 719 | LineTo(hdc, x2, y2); 720 | 721 | x1 = cursorx; 722 | y1 = 40; 723 | x2 = x1; 724 | y2 = cursory - dy/2; 725 | MoveToEx(hdc, x1, y1, null); 726 | LineTo(hdc, x2, y2); 727 | 728 | y1 = y2 + dy; 729 | y2 = 40 + global.pixely; 730 | MoveToEx(hdc, x1, y1, null); 731 | LineTo(hdc, x2, y2); 732 | 733 | DeleteObject(hPen); 734 | } 735 | 736 | // Do the direction mode graphic 737 | if (global.player && global.player.mode == mdDIR) 738 | { HPEN hPen; 739 | int x1,y1,x2,y2; 740 | int cursorx, cursory; 741 | 742 | hPen = CreatePen(PS_DASH, 0, RGB(255, 255, 255)); 743 | SelectObject(hdc, hPen); 744 | 745 | cursorx = LocToX(global.player.curloc); 746 | cursory = LocToY(global.player.curloc); 747 | 748 | /* -O */ 749 | x1 = cursorx - dx/2 - 2 * dx; 750 | y1 = cursory; 751 | x2 = cursorx - dx/2; 752 | y2 = y1; 753 | MoveToEx(hdc, x1, y1, null); 754 | LineTo(hdc, x2, y2); 755 | 756 | /* \ 757 | * O 758 | */ 759 | y1 -= 2 * dy + dy/2; 760 | y2 -= dy/2; 761 | MoveToEx(hdc, x1, y1, null); 762 | LineTo(hdc, x2, y2); 763 | 764 | /* O 765 | * / 766 | */ 767 | y1 += dy * 5; 768 | y2 += dy; 769 | MoveToEx(hdc, x1, y1, null); 770 | LineTo(hdc, x2, y2); 771 | 772 | /* O 773 | * | 774 | */ 775 | x1 = cursorx; 776 | x2 = x1; 777 | MoveToEx(hdc, x1, y1, null); 778 | LineTo(hdc, x2, y2); 779 | 780 | /* O 781 | * \ 782 | */ 783 | x1 += (dx - dx/2) + 2 * dx; 784 | x2 += (dx - dx/2); 785 | MoveToEx(hdc, x1, y1, null); 786 | LineTo(hdc, x2, y2); 787 | 788 | /* O- */ 789 | y1 = cursory; 790 | y2 = y1; 791 | MoveToEx(hdc, x1, y1, null); 792 | LineTo(hdc, x2, y2); 793 | 794 | /* / 795 | * O 796 | */ 797 | y1 -= dy/2 + 2 * dy; 798 | y2 -= dy/2; 799 | MoveToEx(hdc, x1, y1, null); 800 | LineTo(hdc, x2, y2); 801 | 802 | /* | 803 | * O 804 | */ 805 | x1 = cursorx; 806 | x2 = x1; 807 | MoveToEx(hdc, x1, y1, null); 808 | LineTo(hdc, x2, y2); 809 | 810 | DeleteObject(hPen); 811 | } 812 | 813 | // Do the move mode graphic 814 | if (global.player && global.player.mode == mdTO) 815 | { HPEN hPen; 816 | int x1,y1,x2,y2; 817 | 818 | hPen = CreatePen(PS_DASH, 0, RGB(255, 255, 255)); 819 | x1 = LocToX(global.player.frmloc); 820 | y1 = LocToY(global.player.frmloc); 821 | x2 = LocToX(global.player.curloc); 822 | y2 = LocToY(global.player.curloc); 823 | SelectObject(hdc, hPen); 824 | MoveToEx(hdc, x1, y1, null); 825 | if (x1 != x2 && y1 != y2) 826 | { int x, y; 827 | int ax, ay; 828 | 829 | ax = abs(x1 - x2); 830 | ay = abs(y1 - y2); 831 | if (ax < ay) 832 | { 833 | x = x2; 834 | if (y1 < y2) 835 | y = y1 + ax; 836 | else 837 | y = y1 - ax; 838 | } 839 | else 840 | { 841 | if (x1 < x2) 842 | x = x1 + ay; 843 | else 844 | x = x1 - ay; 845 | y = y2; 846 | } 847 | LineTo(hdc, x, y); 848 | } 849 | LineTo(hdc, x2, y2); 850 | DeleteObject(hPen); 851 | } 852 | 853 | LpaintText: 854 | if (clipbox.bottom > global.text.top && 855 | clipbox.top < global.text.bottom) 856 | { 857 | // Do the text box 858 | SelectClipRgn(hdc, global.textRegion); 859 | 860 | // Fill background 861 | FillRect(hdc, &global.text, GetStockObject(WHITE_BRUSH)); 862 | 863 | SelectObject(hdc, global.hFont); 864 | for (i = 0; i < 4; i++) 865 | { 866 | TextOutA(hdc, 0, global.cyChar * i, vbuffer[i], strlen(vbuffer[i])); 867 | } 868 | } 869 | } 870 | 871 | EndPaint (hwnd, &ps); 872 | //PRINTF("-WM_PAINT\n"); 873 | return 0; 874 | 875 | case WM_DESTROY: 876 | 877 | for (i = 0; i < MAPMAX; i++) 878 | { 879 | if (global.mapvaltab[i]) 880 | DeleteObject(global.mapvaltab[i]); 881 | } 882 | 883 | DeleteObject(global.unknown10); 884 | DeleteObject(global.hBlast); 885 | DeleteObject(global.hBlastmask); 886 | DeleteObject(global.hSplash); 887 | DeleteObject(global.hCursor); 888 | DeleteObject(global.hFont); 889 | DeleteObject(global.sectorRegion); 890 | DeleteObject(global.textRegion); 891 | 892 | PostQuitMessage (0); 893 | return 0; 894 | 895 | default: 896 | break; 897 | } 898 | return DefWindowProcA(hwnd, message, wParam, lParam); 899 | } 900 | 901 | 902 | /******************************************** 903 | * "About" dialog box. 904 | */ 905 | 906 | extern (Windows) BOOL AboutDlgProc (HWND hDlg, uint message, uint wParam, 907 | LONG lParam) 908 | { 909 | switch (message) 910 | { 911 | case WM_INITDIALOG: 912 | return true ; 913 | 914 | case WM_COMMAND: 915 | switch (wParam) 916 | { 917 | case IDOK: 918 | case IDCANCEL: 919 | EndDialog (hDlg, 0) ; 920 | return true ; 921 | } 922 | break ; 923 | 924 | default: 925 | break; 926 | } 927 | return false ; 928 | } 929 | 930 | /******************************************** 931 | * "City Select" dialog box. 932 | */ 933 | 934 | extern (Windows) BOOL CitySelectDlgProc(HWND hDlg, uint message, uint wParam, 935 | LONG lParam) 936 | { 937 | static HWND hSensor; 938 | static HWND hTile; 939 | BOOL result = false; 940 | 941 | HDC hDC; 942 | RECT rect; 943 | int r, c; 944 | int dx, dy; 945 | double scalex, scaley; 946 | int i, j; 947 | 948 | switch (message) 949 | { 950 | case WM_INITDIALOG: 951 | 952 | global.newphase = global.phase; 953 | CheckRadioButton(hDlg, IDD_ARMIES, IDD_BATTLESHIPS, global.newphase); 954 | 955 | hSensor = GetDlgItem(hDlg, IDD_SENSOR); 956 | hTile = GetDlgItem(hDlg, IDD_TILE); 957 | 958 | SetFocus(GetDlgItem(hDlg, global.newphase)); 959 | return true ; 960 | 961 | case WM_COMMAND: 962 | switch (wParam) 963 | { 964 | case IDOK: 965 | global.phase = global.newphase; 966 | EndDialog (hDlg, true); 967 | return true; 968 | 969 | case IDCANCEL: 970 | EndDialog (hDlg, false) ; 971 | return true ; 972 | 973 | case IDD_ARMIES: 974 | case IDD_FIGHTERS: 975 | case IDD_DESTROYERS: 976 | case IDD_TRANSPORTS: 977 | case IDD_SUBMARINES: 978 | case IDD_CRUISERS: 979 | case IDD_CARRIERS: 980 | case IDD_BATTLESHIPS: 981 | global.newphase = wParam; 982 | CheckRadioButton(hDlg, IDD_ARMIES, IDD_BATTLESHIPS, global.newphase); 983 | result = true; 984 | goto LpaintTile; 985 | 986 | default: 987 | break; 988 | } 989 | break ; 990 | 991 | case WM_PAINT: 992 | 993 | // Sensor probe 994 | InvalidateRect(hSensor, null, true); 995 | UpdateWindow(hSensor); 996 | 997 | hDC = GetDC(hSensor); 998 | GetClientRect(hSensor, &rect); 999 | 1000 | r = ROW(global.cursor) - 2; 1001 | if (r < 0) 1002 | r = 0; 1003 | if (r + 5 > Mrowmx) 1004 | r = Mrowmx - 5; 1005 | c = COL(global.cursor) - 2; 1006 | if (c < 0) 1007 | c = 0; 1008 | if (c + 5 > Mcolmx) 1009 | c = Mcolmx - 5; 1010 | 1011 | dx = (rect.right - rect.left) / 5; 1012 | dy = (rect.bottom - rect.top) / 5; 1013 | scalex = dx / cast(double)10; 1014 | scaley = dy / cast(double)10; 1015 | 1016 | for (j = 0; j < 5; j++) 1017 | { 1018 | for (i = 0; i < 5; i++) 1019 | { 1020 | loc_t loc = (r + j) * (Mcolmx + 1) + (c + i); 1021 | HANDLE h = global.mapvaltab[global.map[loc]]; 1022 | 1023 | DrawBitmap(hDC, rect.left + i * dx, rect.top + j * dy, 1024 | h, scalex, scaley, SRCCOPY); 1025 | } 1026 | } 1027 | 1028 | ReleaseDC(hSensor, hDC); 1029 | 1030 | LpaintTile: 1031 | // Sample Tile 1032 | 1033 | InvalidateRect(hTile, null, true); 1034 | UpdateWindow(hTile); 1035 | 1036 | hDC = GetDC(hTile); 1037 | GetClientRect(hTile, &rect); 1038 | 1039 | dx = rect.right - rect.left; 1040 | dy = rect.bottom - rect.top; 1041 | scalex = dx / cast(double)10; 1042 | scaley = dy / cast(double)10; 1043 | 1044 | { 1045 | int ab = global.newphase - IDD_ARMIES; 1046 | HANDLE h = global.mapvaltab[ab + ((ab <= F) ? 5 : 6)]; 1047 | 1048 | DrawBitmap(hDC, rect.left, rect.top, 1049 | h, scalex, scaley, SRCCOPY); 1050 | } 1051 | 1052 | ReleaseDC(hTile, hDC); 1053 | break; 1054 | 1055 | default: 1056 | break; 1057 | } 1058 | return result; 1059 | } 1060 | 1061 | 1062 | /******************************** 1063 | * Dialog box to get city phase. 1064 | * Returns: 1065 | * new phase 1066 | */ 1067 | 1068 | int dialogCitySelect(int oldphase) 1069 | { 1070 | //PRINTF("dialogCitySelect(oldphase = %d)\n", oldphase); 1071 | UpdateWindow(global.hwnd); 1072 | if (oldphase & ~7) 1073 | oldphase = 0; // default to armies 1074 | global.phase = oldphase + IDD_ARMIES; 1075 | 1076 | DialogBoxParamA(global.hinst, "CitySelectBox", global.hwnd, global.lpfnCitySelectDlgProc, 0) ; 1077 | 1078 | //PRINTF("dialogCitySelect() = %d\n", global.phase - IDD_ARMIES); 1079 | return global.phase - IDD_ARMIES; 1080 | } 1081 | 1082 | 1083 | /******************************************** 1084 | * "Init" dialog box. 1085 | */ 1086 | 1087 | extern (Windows) BOOL InitDlgProc (HWND hDlg, uint message, uint wParam, 1088 | LONG lParam) 1089 | { 1090 | switch (message) 1091 | { 1092 | case WM_INITDIALOG: 1093 | 1094 | global.newnumplayers = global.numplayers; 1095 | CheckRadioButton(hDlg, IDD_ONE, IDD_SIX, global.newnumplayers); 1096 | if (global.demo) 1097 | CheckRadioButton(hDlg, IDD_DEMO, IDD_DEMO, IDD_DEMO); 1098 | SetFocus(GetDlgItem(hDlg, global.newnumplayers)); 1099 | return true ; 1100 | 1101 | case WM_COMMAND: 1102 | switch (wParam) 1103 | { 1104 | case IDOK: 1105 | global.numplayers = global.newnumplayers; 1106 | EndDialog (hDlg, true); 1107 | return true; 1108 | 1109 | case IDCANCEL: 1110 | EndDialog (hDlg, false) ; 1111 | return true ; 1112 | 1113 | case IDD_ONE: 1114 | case IDD_TWO: 1115 | case IDD_THREE: 1116 | case IDD_FOUR: 1117 | case IDD_FIVE: 1118 | case IDD_SIX: 1119 | global.newnumplayers = wParam; 1120 | CheckRadioButton(hDlg, IDD_ONE, IDD_SIX, global.newnumplayers); 1121 | return true; 1122 | 1123 | case IDD_DEMO: 1124 | global.demo ^= 1; 1125 | CheckRadioButton(hDlg, IDD_DEMO, IDD_DEMO, global.demo ? IDD_DEMO : IDD_DEMO + 1); 1126 | return true; 1127 | 1128 | default: 1129 | break; 1130 | } 1131 | break ; 1132 | 1133 | default: 1134 | break; 1135 | } 1136 | return false ; 1137 | } 1138 | 1139 | 1140 | 1141 | 1142 | /****************************** 1143 | * Flush the display. 1144 | */ 1145 | 1146 | extern (C) void win_flush() 1147 | { 1148 | InvalidateRect(global.hwnd, &global.text, false); 1149 | UpdateWindow(global.hwnd); 1150 | } 1151 | 1152 | /****************************** 1153 | * Click the speaker. 1154 | */ 1155 | 1156 | extern (C) void sound_click() 1157 | { 1158 | UpdateWindow(global.hwnd); 1159 | if (global.speaker) 1160 | PlaySoundA("click.wav", null, SND_ASYNC | SND_FILENAME | SND_NOSTOP); 1161 | } 1162 | 1163 | void sound_gun() 1164 | { 1165 | UpdateWindow(global.hwnd); 1166 | if (global.speaker) 1167 | PlaySoundA("gun_1.wav", null, SND_SYNC | SND_FILENAME); 1168 | } 1169 | 1170 | void sound_bang() 1171 | { 1172 | UpdateWindow(global.hwnd); 1173 | if (global.speaker) 1174 | { PlaySoundA("explosi1.wav", null, SND_SYNC | SND_FILENAME); 1175 | PlaySoundA("bubbles.wav", null, SND_SYNC | SND_FILENAME); 1176 | } 1177 | } 1178 | 1179 | void sound_error() 1180 | { 1181 | UpdateWindow(global.hwnd); 1182 | if (global.speaker) 1183 | PlaySoundA("error.wav", null, SND_SYNC | SND_FILENAME); 1184 | } 1185 | 1186 | void sound_splash() 1187 | { 1188 | UpdateWindow(global.hwnd); 1189 | if (global.speaker) 1190 | PlaySoundA("splash.wav", null, SND_SYNC | SND_FILENAME); 1191 | } 1192 | 1193 | void sound_aground() 1194 | { 1195 | UpdateWindow(global.hwnd); 1196 | if (global.speaker) 1197 | PlaySoundA("bubbles.wav", null, SND_SYNC | SND_FILENAME); 1198 | } 1199 | 1200 | void sound_subjugate() 1201 | { 1202 | UpdateWindow(global.hwnd); 1203 | if (global.speaker) 1204 | PlaySoundA("machine1.wav", null, SND_SYNC | SND_FILENAME); 1205 | } 1206 | 1207 | void sound_crushed() 1208 | { 1209 | UpdateWindow(global.hwnd); 1210 | if (global.speaker) 1211 | PlaySoundA("gun_3.wav", null, SND_SYNC | SND_FILENAME); 1212 | } 1213 | 1214 | void sound_flyby() 1215 | { 1216 | UpdateWindow(global.hwnd); 1217 | if (global.speaker) 1218 | PlaySoundA("flyby.wav", null, SND_SYNC | SND_FILENAME); 1219 | } 1220 | 1221 | void sound_fcrash() 1222 | { 1223 | UpdateWindow(global.hwnd); 1224 | if (global.speaker) 1225 | PlaySoundA("explode.wav", null, SND_SYNC | SND_FILENAME); 1226 | } 1227 | 1228 | void sound_fuel() 1229 | { 1230 | UpdateWindow(global.hwnd); 1231 | if (global.speaker) 1232 | PlaySoundA("fuel.wav", null, SND_SYNC | SND_FILENAME); 1233 | } 1234 | 1235 | void sound_taps() 1236 | { 1237 | UpdateWindow(global.hwnd); 1238 | if (global.speaker) 1239 | PlaySoundA("taps.wav", null, SND_SYNC | SND_FILENAME); 1240 | } 1241 | 1242 | void sound_ackack() 1243 | { 1244 | UpdateWindow(global.hwnd); 1245 | if (global.speaker) 1246 | PlaySoundA("ackack1.wav", null, SND_SYNC | SND_FILENAME); 1247 | } 1248 | 1249 | /*********************************** 1250 | * Setup for Windows. 1251 | * Equivalent to main.setup(). 1252 | */ 1253 | 1254 | void winSetup() 1255 | { 1256 | //PRINTF("winSetup()\n"); 1257 | debug 1258 | { 1259 | // set random number generator to predictable value 1260 | setran(); 1261 | } 1262 | 1263 | Text *t = &player[0].display.text; 1264 | 1265 | //printf("Please wait seven days for creation of world...\n"); 1266 | selmap(); // read in map 1267 | citini(); // init city variables 1268 | 1269 | numply = global.numplayers - IDD_ONE + 1; 1270 | numleft = numply; 1271 | for (plynum = 0; plynum <= numply; plynum++) 1272 | { 1273 | //PRINTF("player %d\n", plynum); 1274 | Player *p = &player[plynum]; 1275 | p.display = new Display(); 1276 | Display *d = p.display; 1277 | d.initialize(); 1278 | 1279 | p.num = plynum; 1280 | p.map = (plynum == 0) ? .map : cast(ubyte *)calloc(MAPSIZE,1); 1281 | p.human = (plynum == 1 && !global.demo); 1282 | p.watch = DAnone; 1283 | 1284 | if (p.human) 1285 | { 1286 | d.timeinterval = 1; 1287 | } 1288 | else 1289 | { 1290 | } 1291 | 1292 | if (plynum == 1) 1293 | { 1294 | p.secflg = 1; 1295 | p.watch = DAwindows; 1296 | d.text.TTinit(); 1297 | d.text.watch = p.watch; 1298 | d.maptab = MTcgacolor; 1299 | d.setdispsize(d.text.nrows, d.text.ncols); 1300 | d.text.clear(); 1301 | d.text.block_cursor(); 1302 | } 1303 | if (plynum) 1304 | p.citsel(); // select city for each player 1305 | } 1306 | 1307 | plynum = 1; // get the default player 1308 | } 1309 | 1310 | void winRestore() 1311 | { 1312 | //PRINTF("winRestore()\n"); 1313 | debug 1314 | { 1315 | setran(); // seed random number generator 1316 | } 1317 | 1318 | Text *t = &player[0].display.text; 1319 | 1320 | t.TTinit(); 1321 | 1322 | for (plynum = 0; plynum <= numply; plynum++) 1323 | { Player *p = &player[plynum]; 1324 | Display *d = new Display(); 1325 | p.display = d; 1326 | d.initialize(); 1327 | 1328 | if (p.human) 1329 | { 1330 | d.timeinterval = 1; 1331 | } 1332 | else 1333 | { 1334 | } 1335 | 1336 | if (plynum == 1) 1337 | { 1338 | p.secflg = 1; 1339 | p.watch = DAwindows; 1340 | d.text.TTinit(); 1341 | d.text.watch = p.watch; 1342 | d.maptab = MTcgacolor; 1343 | d.setdispsize(d.text.nrows, d.text.ncols); 1344 | d.text.clear(); 1345 | d.text.block_cursor(); 1346 | } 1347 | } 1348 | plynum = 1; // get the default player 1349 | } 1350 | 1351 | /*************************************** 1352 | * Given new scale factors x,y, adjust sector location. 1353 | * Returns: 1354 | * !=0 if sector moved 1355 | */ 1356 | 1357 | int adjSector(double newscalex, double newscaley) 1358 | { 1359 | int cursorx; 1360 | int dx; 1361 | int ncols; 1362 | int scmin; 1363 | int scmax; 1364 | 1365 | int cursory; 1366 | int dy; 1367 | int nrows; 1368 | int srmin; 1369 | int srmax; 1370 | 1371 | int gap; 1372 | int n; 1373 | int width; 1374 | Display *d; 1375 | 1376 | int moved = 0; 1377 | int newval; 1378 | 1379 | if (!global.player) // if not initialized yet 1380 | return 0; 1381 | 1382 | //PRINTF("Before: ulcorner = %d\n", global.ulcorner); 1383 | ncols = COL(global.cursor) - COL(global.ulcorner); 1384 | //PRINTF("cursor = %d, diff = %d, ncols = %d\n", global.cursor, global.cursor - global.ulcorner, ncols); 1385 | dx = cast(int)(10 * global.scalex); 1386 | cursorx = ncols * dx + (dx / 2) - global.offsetx; 1387 | dx = cast(int)(10 * newscalex); 1388 | n = (cursorx - (dx / 2) + (dx - 1)) / dx; 1389 | //PRINTF("n = %d, cursorx = %d, dx = %d\n", n, cursorx, dx); 1390 | if (cursorx < dx + (dx / 2)) 1391 | { n = 1; 1392 | cursorx = n * dx + (dx / 2); 1393 | } 1394 | if (COL(global.cursor) < n) 1395 | { n = COL(global.cursor); 1396 | cursorx = n * dx + (dx / 2); 1397 | } 1398 | width = (global.pixelx + (dx - 1)) / dx; 1399 | //PRINTF("n = %d, width = %d\n", n, width); 1400 | 1401 | // Right justify right edge 1402 | gap = cursorx - dx/2 + 3 * dx - global.pixelx; 1403 | if (gap > 0) 1404 | { 1405 | cursorx -= gap; 1406 | n = (cursorx - (dx / 2) + (dx - 1)) / dx; 1407 | //PRINTF("1adj gap = %d\n", gap); 1408 | } 1409 | gap = global.pixelx - (((Mcolmx + 1) - COL(global.cursor)) * dx + cursorx - dx/2); 1410 | if (gap > 0) 1411 | { 1412 | cursorx += gap; 1413 | n = (cursorx - (dx / 2) + (dx - 1)) / dx; 1414 | //PRINTF("2adj gap = %d\n", gap); 1415 | if (COL(global.cursor) < n) 1416 | { n = COL(global.cursor); 1417 | cursorx = n * dx + (dx / 2); 1418 | } 1419 | } 1420 | 1421 | newval = dx * n + dx / 2 - cursorx; 1422 | if (newval != global.offsetx) 1423 | moved = 1; 1424 | global.offsetx = newval; 1425 | //PRINTF("offsetx = %d\n", global.offsetx); 1426 | scmin = COL(global.cursor) - n; 1427 | scmax = (width - 1); 1428 | //PRINTF("n = %d, width = %d, scmin = %d, COL(cursor) = %d\n", n, width, scmin, COL(global.cursor)); 1429 | assert(scmin <= COL(global.cursor)); 1430 | 1431 | nrows = ROW(global.cursor) - ROW(global.ulcorner); 1432 | //PRINTF("cursor = %d, diff = %d, nrows = %d\n", global.cursor, global.cursor - global.ulcorner, nrows); 1433 | dy = cast(int)(10 * global.scaley); 1434 | cursory = nrows * dy + (dy / 2) - global.offsety; 1435 | dy = cast(int)(10 * newscaley); 1436 | n = (cursory - (dy / 2) + (dy - 1)) / dy; 1437 | //PRINTF("n = %d, cursory = %d, dy = %d\n", n, cursory, dy); 1438 | if (cursory < dy + (dy / 2)) 1439 | { n = 1; 1440 | cursory = n * dy + (dy / 2); 1441 | } 1442 | if (ROW(global.cursor) < n) 1443 | { n = ROW(global.cursor); 1444 | cursory = n * dy + dy / 2; 1445 | //PRINTF("adjust top\n"); 1446 | } 1447 | width = (global.pixely + (dy - 1)) / dy; 1448 | 1449 | // Bottom justify bottom edge 1450 | gap = cursory - dy/2 + 3 * dy - global.pixely; 1451 | if (gap > 0) 1452 | { 1453 | cursory -= gap; 1454 | n = (cursory - (dy / 2) + (dy - 1)) / dy; 1455 | } 1456 | gap = global.pixely - (((Mrowmx + 1) - ROW(global.cursor)) * dy + cursory - dy/2); 1457 | if (gap > 0) 1458 | { 1459 | cursory += gap; 1460 | n = (cursory - (dy / 2) + (dy - 1)) / dy; 1461 | if (ROW(global.cursor) < n) 1462 | { n = ROW(global.cursor); 1463 | cursory = n * dy + dy / 2; 1464 | } 1465 | } 1466 | 1467 | newval = dy * n + dy / 2 - cursory; 1468 | if (newval != global.offsety) 1469 | moved = 1; 1470 | global.offsety = newval; 1471 | srmin = ROW(global.cursor) - n; 1472 | srmax = (width - 1); 1473 | //PRINTF("n = %d, height = %d, srmin = %d\n", n, width, srmin); 1474 | 1475 | d = global.player.display; 1476 | //d.Smin = srmin * 256 + scmin; 1477 | d.Smax = srmax * 256 + scmax; 1478 | 1479 | newval = srmin * (Mcolmx + 1) + scmin; 1480 | if (newval != global.ulcorner) 1481 | moved = 1; 1482 | global.ulcorner = newval; 1483 | d.secbas = global.ulcorner; 1484 | //PRINTF("offsetx = %d, offsety = %d\n", global.offsetx, global.offsety); 1485 | //PRINTF("After: ulcorner = %d, Smin = %x, Smax = %x\n", global.ulcorner, d.Smin, d.Smax); 1486 | 1487 | assert(global.ulcorner >= 0 && global.ulcorner < MAPSIZE); 1488 | assert(global.ulcorner <= global.cursor && global.cursor < MAPSIZE); 1489 | assert(COL(global.ulcorner) <= COL(global.cursor)); 1490 | assert(dx > 0 && dy > 0); 1491 | assert(global.offsetx >= 0 && global.offsetx < dx); 1492 | assert(global.offsety >= 0 && global.offsety < dy); 1493 | 1494 | global.scalex = newscalex; 1495 | global.scaley = newscaley; 1496 | 1497 | return moved; 1498 | } 1499 | 1500 | /************************************* 1501 | * Invalidate display of loc on the screen, so 1502 | * it will get updated. 1503 | */ 1504 | 1505 | void invalidateLoc(loc_t loc) 1506 | { 1507 | RECT rect; 1508 | int r, c; 1509 | int dx; 1510 | int dy; 1511 | DWORD mode; 1512 | 1513 | //PRINTF("invalidateLoc(loc = %d)\n", loc); 1514 | assert(loc < MAPSIZE); 1515 | 1516 | r = ROW(loc) - ROW(global.ulcorner); 1517 | c = COL(loc) - COL(global.ulcorner); 1518 | dx = cast(int)(10 * global.scalex); 1519 | dy = cast(int)(10 * global.scaley); 1520 | 1521 | rect.left = c * dx - global.offsetx; 1522 | rect.top = 40 + r * dy - global.offsety; 1523 | rect.right = rect.left + dx; 1524 | rect.bottom = rect.top + dy; 1525 | 1526 | InvalidateRect(global.hwnd, &rect, false); 1527 | } 1528 | 1529 | /************************************* 1530 | * Invalidate display of rectangle formed by corners loc1, loc2 1531 | * on the screen, so 1532 | * it will get updated. 1533 | */ 1534 | 1535 | void invalidateLocRect(loc_t loc1, loc_t loc2) 1536 | { 1537 | RECT rect; 1538 | int r1, c1; 1539 | int r2, c2; 1540 | int dx; 1541 | int dy; 1542 | DWORD mode; 1543 | 1544 | //PRINTF("invalidateLoc(loc = %d)\n", loc); 1545 | assert(loc1 < MAPSIZE); 1546 | assert(loc2 < MAPSIZE); 1547 | 1548 | r1 = ROW(loc1) - ROW(global.ulcorner); 1549 | c1 = COL(loc1) - COL(global.ulcorner); 1550 | r2 = ROW(loc2) - ROW(global.ulcorner); 1551 | c2 = COL(loc2) - COL(global.ulcorner); 1552 | 1553 | if (r1 > r2) 1554 | { int r; 1555 | r = r1; 1556 | r1 = r2; 1557 | r2 = r; 1558 | } 1559 | if (c1 > c2) 1560 | { int c; 1561 | c = c1; 1562 | c1 = c2; 1563 | c2 = c; 1564 | } 1565 | 1566 | dx = cast(int)(10 * global.scalex); 1567 | dy = cast(int)(10 * global.scaley); 1568 | 1569 | rect.left = c1 * dx - global.offsetx; 1570 | rect.top = 40 + r1 * dy - global.offsety; 1571 | rect.right = rect.left + dx * (c2 - c1 + 1); 1572 | rect.bottom = rect.top + dy * (r2 - r1 + 1); 1573 | 1574 | InvalidateRect(global.hwnd, &rect, false); 1575 | } 1576 | 1577 | /****************************************** 1578 | * Invalidate entire sector. 1579 | */ 1580 | 1581 | void invalidateSector() 1582 | { 1583 | InvalidateRect(global.hwnd, &global.sector, false); 1584 | } 1585 | 1586 | /****************************************** 1587 | * Convert loc to screen coordinate. 1588 | */ 1589 | 1590 | int LocToX(loc_t loc) 1591 | { 1592 | int dx; 1593 | int x; 1594 | int col; 1595 | 1596 | col = COL(loc) - COL(global.ulcorner); 1597 | dx = cast(int)(10 * global.scalex); 1598 | x = col * dx + dx / 2 - global.offsetx; 1599 | return x; 1600 | } 1601 | 1602 | int LocToY(loc_t loc) 1603 | { 1604 | int dy; 1605 | int y; 1606 | int row; 1607 | 1608 | row = ROW(loc) - ROW(global.ulcorner); 1609 | dy = cast(int)(10 * global.scaley); 1610 | y = 40 + row * dy + dy / 2 - global.offsety; 1611 | return y; 1612 | } 1613 | 1614 | /********************************************* 1615 | * Start/Stop blast graphic. 1616 | */ 1617 | 1618 | void ShowBlast(int state, loc_t loc) 1619 | { 1620 | RECT blastbox; 1621 | int x, y; 1622 | 1623 | x = LocToX(loc); 1624 | y = LocToY(loc); 1625 | blastbox.bottom = y + 5; 1626 | blastbox.top = blastbox.bottom - 20; 1627 | blastbox.left = x - 10; 1628 | blastbox.right = x + 10; 1629 | InvalidateRect(global.hwnd, &blastbox, false); 1630 | global.blastState = state; 1631 | global.blastx = blastbox.left; 1632 | global.blasty = blastbox.top; 1633 | if (state) 1634 | UpdateWindow(global.hwnd); 1635 | } 1636 | 1637 | --------------------------------------------------------------------------------