summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornlanza <nlanza@c06c8d41-db1a-0410-9941-cceddc491573>2006-09-21 01:26:32 +0000
committernlanza <nlanza@c06c8d41-db1a-0410-9941-cceddc491573>2006-09-21 01:26:32 +0000
commit8cef627a50af8ccf420a131c239f749fc3e1b996 (patch)
treed886071424e22ce011ef04ecc36a20509dde2cbf
parent4027abf7955a0d7f35059a78384df46b177fde6b (diff)
downloadcrawl-ref-8cef627a50af8ccf420a131c239f749fc3e1b996.tar.gz
crawl-ref-8cef627a50af8ccf420a131c239f749fc3e1b996.zip
Clean out the crufty old pre-OSX Mac build -- the modern build uses Xcode
and is based on the standard UNIX build, so it doesn't need pretty much any of the special support. All of the MAC/macintosh defines should now be gone. If you need to tell whether crawl is building on a mac, check for 'OSX' instead. Also, overhaul makefile.osx to call into xcodebuild -- there's no sense in having two parallel OS X build systems when you need Xcode installed to get gcc anyway. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup@59 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/mac/68K_Stub.r144
-rw-r--r--crawl-ref/mac/Crawl.r303
-rw-r--r--crawl-ref/mac/Crawl4.mcpbin211299 -> 0 bytes
-rw-r--r--crawl-ref/mac/Precomp (Common).h75
-rw-r--r--crawl-ref/mac/Precomp (Mac-D).pch++16
-rw-r--r--crawl-ref/mac/Precomp (Mac-R).pch++19
-rw-r--r--crawl-ref/mac/Precomp (Posix-D).pch++17
-rw-r--r--crawl-ref/mac/Precomp (Posix-R).pch++18
-rw-r--r--crawl-ref/source/AppHdr.h9
-rw-r--r--crawl-ref/source/Crawl.xcodeproj/project.pbxproj10
-rw-r--r--crawl-ref/source/MacString.cc199
-rw-r--r--crawl-ref/source/MacString.h71
-rw-r--r--crawl-ref/source/acr.cc10
-rw-r--r--crawl-ref/source/chardump.cc4
-rw-r--r--crawl-ref/source/debug.cc21
-rw-r--r--crawl-ref/source/defines.h3
-rw-r--r--crawl-ref/source/describe.cc4
-rw-r--r--crawl-ref/source/files.h2
-rw-r--r--crawl-ref/source/libmac.cc2116
-rw-r--r--crawl-ref/source/libmac.h86
-rw-r--r--crawl-ref/source/libutil.cc4
-rw-r--r--crawl-ref/source/machdr.h185
-rw-r--r--crawl-ref/source/makefile.osx77
-rw-r--r--crawl-ref/source/newgame.cc9
-rw-r--r--crawl-ref/source/randart.cc2
-rw-r--r--crawl-ref/source/stuff.cc4
-rw-r--r--crawl-ref/source/view.cc2
27 files changed, 42 insertions, 3368 deletions
diff --git a/crawl-ref/mac/68K_Stub.r b/crawl-ref/mac/68K_Stub.r
deleted file mode 100644
index 391dda2ad6..0000000000
--- a/crawl-ref/mac/68K_Stub.r
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * File: 68K_Stub.r
- * Summary: Mac resources
- * Written by: Jesse Jones
- *
- * Change History (most recent first):
- *
- * <1> 3/30/99 JDJ Created
- */
-
-#include <Types.r>
-
-
-// ============================================================================
-// Resources
-// These resources create a tiny 68K app that pops up an
-// alert telling the user that the app will not run and
-// exits when the user dismisses the alert. This
-// file should only be added to PPC builds.
-// ============================================================================
-resource 'ALRT' (30000) {
- {84, 122, 174, 486},
- 30000,
- {
- OK, visible, silent,
- OK, visible, silent,
- OK, visible, silent,
- OK, visible, silent
- },
- alertPositionMainScreen
-};
-
-resource 'DITL' (30000) {
- {
- {60, 280, 80, 338},
- Button {
- enabled,
- "Quit"
- },
-
- {10, 60, 46, 360},
- StaticText {
- disabled,
- "This program requires a PowerPC processor and will"
- "not run on your Macintosh."
- }
- }
-};
-
-data 'CODE' (1, "Sources", locked, protected, preload) {
- $"0000 0001 9DCE 598F 2F3C 434F 4445 4267" /* ....'Y/<CODEBg */
- $"A9A0 2017 6700 011E 2040 2050 2E18 2C10" /* .g... @P..,. */
- $"A9A3 7000 204D 91C6 6002 10C0 B1CD 6DFA" /* p.M`..mT */
- $"41ED 0028 43F5 7800 6002 10C0 B1C9 6DFA" /* A.(Czx.`..SmT */
- $"598F 2F3C 4441 5441 4267 A9A0 2057 2008" /* Y/<DATABg W . */
- $"6700 00E2 2F0D 2050 4868 0004 4EBA 00DC" /* g..'/PHh..N?. */
- $"508F 43FA FF9C 2B49 FF12 224D 4EBA 0244" /* PCT+I."MN?.D */
- $"226D FF12 4EBA 023C A9A3 4EBA 02C2 422D" /* "m.N?.<N?.B- */
- $"FF17 303C A89F A746 2F08 303C A198 A346" /* .0<F/.0<F */
- $"B1DF 670A 1B7C 0001 FF17 7001 A198 303C" /* g..|...p.0< */
- $"A9F0 A746 2B48 FF0E 303C A9F1 A746 2B48" /* .F+H.0<F+H */
- $"FF0A 303C A9F4 A746 2B48 FF06 303C A9F0" /* .0<F+H.0<. */
- $"41FA 0284 A647 303C A9F1 41FA 0338 A647" /* AT.ѶG0<AT.8G */
- $"303C A9F4 41FA 003C A647 4EB9 0000 0492" /* 0<AT.<GN... */
- $"4EB9 0000 04B8 487A 004E 4A2D FFFF 6702" /* N...Hz.NJ-g. */
- $"4267 4267 4EB9 0000 04E4 5C8F 4A2D FFFF" /* BgBgN..."\J- */
- $"6702 548F 202D FF2C 6704 2040 4E90 4EBA" /* g.T -,g.@NN? */
- $"0384 2A78 0904 303C A9F4 206D FF06 A647" /* .*x.0<m.G */
- $"303C A9F0 206D FF0E A647 303C A9F1 206D" /* 0<.m.G0< m */
- $"FF0A A647 A9F4 0000 0000 48E7 1C30 594F" /* .G....H.0YO */
- $"266F 001C 7800 6000 00E4 1E9B 1F5B 0001" /* &o..x.`.."..[.. */
- $"1F5B 0002 1F5B 0003 246F 0020 D5D7 161B" /* .[...[..$o. '.. */
- $"4883 3003 0240 0080 670E 0243 007F 14DB" /* H0..@.g..C... */
- $"5343 4A43 6CF8 60E6 3003 0240 0040 670E" /* SCJCl`0..@.@g. */
- $"3003 0240 003F 5240 48C0 D5C0 60D0 3003" /* 0..@.?R@H'`-0. */
- $"0240 0020 670A 0243 001F 5243 1A1B 600E" /* .@.g..C..RC..`. */
- $"3003 0240 0010 6710 0243 000F 7AFF 14C5" /* 0..@..g..C..z.? */
- $"5343 4A43 6CF8 60A6 3003 0C40 0004 6264" /* SCJCl`0..@..bd */
- $"D040 303B 0006 4EFB 0002 0060 000A 001C" /* -@0;..Ns...`.... */
- $"002C 0042 588A 14FC FFFF 14FC FFFF 14DB" /* .,.BX... */
- $"14DB 6000 FF7A 588A 14FC FFFF 14DB 14DB" /* .`.zX... */
- $"14DB 6000 FF6A 14FC FFA9 14FC FFF0 548A" /* .`.j...T */
- $"14DB 14DB 528A 14DB 6000 FF54 14FC FFA9" /* ..R.`.T. */
- $"14FC FFF0 528A 14DB 14DB 14DB 528A 14DB" /* ..R...R. */
- $"6000 FF3C 3F3C 000F A9C9 5244 0C44 0003" /* `.<?<..SRD.D.. */
- $"6D00 FF18 204B 584F 4CDF 0C38 4E75 2F05" /* m..KXOL.8Nu/. */
- $"594F 226F 000C 1E99 1F59 0001 1F59 0002" /* YO"o....Y...Y.. */
- $"1F59 0003 2A17 7400 604C 1219 1001 0240" /* .Y..*.t.`L.....@ */
- $"0080 670C D201 1001 4880 48C0 D480 6028" /* .g."...HH'`( */
- $"1E81 1F59 0001 1001 0240 0040 670C 3017" /* ..Y.....@.@g.0. */
- $"E548 E240 48C0 D480 600E 1F59 0002 1F59" /* H'@H'`..Y...Y */
- $"0003 2417 E58A E282 206F 0010 202F 0014" /* ..$.'o.. /.. */
- $"D1B0 2800 5385 4A85 6EB0 2049 584F 2A1F" /* -f(.SJnfIXO*. */
- $"4E75 2F0A 2449 2F0D 2F0A 2F08 4EBA FF80" /* Nu/.$I//./.N? */
- $"2F2D FF12 2F0A 2F08 4EBA FF74 2F0A 2F0A" /* /-././.N?t/./. */
- $"2F08 4EBA FF6A 4FEF 0024 245F 4E75 2F0A" /* /.N?jO.$$_Nu/. */
- $"2449 2F0D 4497 2F0A 2F08 4EBA FF52 2F2D" /* $I/D/./.N?R/- */
- $"FF12 4497 2F0A 2F08 4EBA FF44 2F0A 4497" /* .D/./.N?D/.D */
- $"2F0A 2F08 4EBA FF38 4FEF 0024 245F 4E75" /* /./.N?8O.$$_Nu */
- $"BBFA 0028 6602 4E75 48E7 0084 2A7A 001C" /* T.(f.NuH.*z.. */
- $"206D FF0E 4A6F 000C 6604 206D FF0A 2F48" /* m.Jo..f.m./H */
- $"000A 4CDF 2100 544F 4E75 0000 0000 41FA" /* ..L!.TONu....AT */
- $"FFFA 208D 4E75 3F3C 0001 4EBA FFC4 544F" /* TNu?<..N?YTO */
- $"48E7 E0E0 55AF 0018 246F 0018 202D FF18" /* HU..$o.. -. */
- $"670A 2040 3F2A 0006 4E90 548F 50F8 0A5E" /* g.@?*..NTP.^ */
- $"598F 2F3C 434F 4445 3F2A 0006 A9A0 2017" /* Y/<CODE?*.. . */
- $"6616 202D FF24 6604 700F A9C9 2040 3F2A" /* f.-$f.p.S @?* */
- $"0006 4E90 548F 60DA 4A38 0BB2 6704 2040" /* ..NT`ZJ8.g. @ */
- $"A064 2057 A029 205F 2050 2008 A055 2040" /* d W) _ P.U @ */
- $"2F08 2248 D1E8 0008 4EBA FEF8 205F 224D" /* /."H-..N?o _"M */
- $"D3E8 0004 3028 0002 2208 600C 337C 4EF9" /* "..0(..".`.3|N~ */
- $"0000 D3A9 0002 5089 51C8 FFF2 4A2D FF17" /* .."..PQJ-. */
- $"6704 7001 A198 202D FF1C 670A 2040 3F2A" /* g.p.-.g. @?* */
- $"0006 4E90 548F 4CDF 0707 4A38 012D 6702" /* ..NTL..J8.-g. */
- $"A9FF 4E75 3F3C 0000 4EBA FF06 544F 2F0A" /* Nu?<..N?.TO/. */
- $"246F 0008 0C6A 4EF9 0000 6670 0C6A 0002" /* $o...jN~..fp.j.. */
- $"0006 6D68 598F 2F3C 434F 4445 3F2A 0006" /* ..mhY/<CODE?*.. */
- $"A9A0 2017 6604 588F 6052 2040 2050 2248" /* .f.X`R@ P"H */
- $"D1E8 0008 4EBA FE98 2057 2050 224D D3E8" /* -..N?o WP"M" */
- $"0004 3028 0002 2208 600C 337C A9F0 0000" /* ..0(..".`.3|... */
- $"93A9 0002 5089 51C8 FFF2 2057 A02A 205F" /* ..PQW* _ */
- $"A049 4A2D FF17 6704 7001 A198 202D FF20" /* IJ-.g.p. - */
- $"670A 2040 3F2A 0006 4E90 548F 245F 2E9F" /* g.@?*..NT$_. */
- $"4E75 4E75 2F0A 6014 2B52 FF28 3F3C FFFF" /* NuNu/.`.+R(?< */
- $"2F2A 0008 206A 0004 4E90 5C4F 246D FF28" /* /*.. j..N\O$m( */
- $"200A 66E4 245F 4E75 4E75 4E56 0000 486D" /* .f"$_NuNuNV..Hm */
- $"FFFA A86E A8FE A912 A930 A9CC 42A7 A97B" /* Tno.0Bߩ{ */
- $"A850 4E5E 4E75 8B49 6E69 7454 6F6F 6C62" /* PN^NuInitToolb */
- $"6F78 0000 4E56 0000 4EBA FFD0 554F 3F3C" /* ox..NV..N?-UO?< */
- $"7530 42A7 A986 301F 4E5E 4E75 846D 6169" /* u0Bߩ0.N^Numai */
- $"6E00 0000" /* n... */
-};
-
-data 'CODE' (0, purgeable, protected) {
- $"0000 0030 0000 0100 0000 0008 0000 0020" /* ...0........... */
- $"0000 3F3C 0001 A9F0" /* ..?<... */
-};
-
-data 'DATA' (0, purgeable, protected) {
- $"0000 0020 FFFF FFFF 4000 0000 0028 0000" /* ... @....(.. */
- $"0000 2800 0000 0000 0000 0000 0000 0000" /* ..(............. */
- $"0000 0000 0000 0003 406E 838A 0000 0000" /* ........@n.... */
-};
-
diff --git a/crawl-ref/mac/Crawl.r b/crawl-ref/mac/Crawl.r
deleted file mode 100644
index 86fa65c8d6..0000000000
--- a/crawl-ref/mac/Crawl.r
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * File: Crawl.r
- * Summary: Mac resources
- * Written by: Jesse Jones
- *
- * Change History (most recent first):
- *
- * <2> 5/25/02 JDJ Added some Carbon resources
- * <1> 3/26/99 JDJ Created
- */
-
-#include <BalloonTypes.r>
-#include <Types.r>
-
-
-// ============================================================================
-// Carbon Resources
-// ============================================================================
-data 'carb' (0) {
-};
-
-// $$$ is this only for bundled apps?
-resource 'plst' (0) {
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<!DOCTYPE plist SYSTEM\n\"file://localhost/System/Library/DTDs/PropertyList.dtd\">\n"
- "<plist version=\"4.0\">\n"
- "<dict>\n"
- "<key>CFBundleInfoDictionaryVersion</key>\n"
- "<string>4.0</string>\n"
- "<key>CFBundleIdentifier</key>\n"
- "<string>Crawl4</string>\n"
- "<key>CFBundleVersion</key>\n"
- "<string>4.0</string>\n"
- "<key>CFBundleDevelopmentRegion</key>\n"
- "<string>English</string>\n"
- "<key>CFBundleName</key>\n"
- "<string>Crawl</string>\n"
- "<key>CFBundlePackageType</key>\n"
- "<string>APPL</string>\n"
- "<key>CFBundleSignature</key>\n"
- "<string>????</string>\n"
- "</dict>\n"
- "</plist>"
-};
-
-
-// ============================================================================
-// Finder Icon Help Message
-// ============================================================================
-resource 'hfdr' (-5696, "Finder Help") {
- HelpMgrVersion,
- hmDefaultOptions,
- 0, 0,
-
- {
- HMStringItem {
- "Crawl is a fun game in the grand tradition of games like Rogue, Hack and Moria."
- },
- }
-};
-
-
-// ============================================================================
-// Get Info String
-// ============================================================================
-type 'Crwl' {pstring;};
-
-data 'Crwl' (0, "Owner resource") {
- "Crawl 3.3 1997 -1999 by Linley Henzell (Mac Port by Jesse Jones)"
-};
-
-
-// ============================================================================
-// Derezed Resources
-// ============================================================================
-
-resource 'BNDL' (128) {
- 'Crwl',
- 0,
- {
- /* [1] */
- 'FREF',
- { /* array IDArray: 2 elements */
- /* [1] */
- 0, 128,
- /* [2] */
- 1, 129
- },
- /* [2] */
- 'ICN#',
- {
- /* [1] */
- 0, 0,
- /* [2] */
- 1, 0
- }
- }
-};
-
-resource 'FREF' (128) {
- 'CrlF',
- 0,
- ""
-};
-
-resource 'FREF' (129) {
- 'APPL',
- 1,
- ""
-};
-
-resource 'DITL' (129) {
- {
- /* [1] */
- {45, 353, 65, 411},
- Button {
- enabled,
- "OK"
- },
- /* [2] */
- {19, 68, 90, 339},
- StaticText {
- disabled,
- "^0"
- },
- /* [3] */
- {38, 21, 70, 53},
- Icon {
- disabled,
- 128
- }
- }
-};
-
-resource 'DITL' (130) {
- {
- /* [1] */
- {81, 136, 101, 194},
- Button {
- enabled,
- "No"
- },
- /* [2] */
- {81, 37, 101, 95},
- Button {
- enabled,
- "Yes"
- },
- /* [3] */
- {24, 43, 56, 188},
- StaticText {
- disabled,
- "Do you really want to quit without savin"
- "g?"
- }
- }
-};
-
-resource 'DITL' (256, "About", purgeable) {
- {
- /* [1] */
- {70, 220, 90, 280},
- Button {
- enabled,
- "OK"
- },
- /* [2] */
- {10, 70, 64, 279},
- StaticText {
- disabled,
- "Crawl 3.3 \n 1997-1999 by Linley Henzell"
- "\nMac Port by Jesse Jones"
- },
- /* [3] */
- {10, 20, 42, 52},
- Icon {
- disabled,
- 1
- }
- }
-};
-
-resource 'DITL' (131, purgeable) {
- {
- /* [1] */
- {71, 288, 91, 348},
- Button {
- enabled,
- "Save"
- },
- /* [2] */
- {71, 215, 91, 275},
- Button {
- enabled,
- "Cancel"
- },
- /* [3] */
- {71, 75, 91, 159},
- Button {
- enabled,
- "Don't Save"
- },
- /* [4] */
- {10, 75, 58, 348},
- StaticText {
- disabled,
- "Do you want to save your game before qui"
- "tting?"
- }
- }
-};
-
-data 'ALRT' (129) {
-$"0028 0028 0096 01D7 0081 5555" /*.(.(...UU */
-};
-
-data 'ALRT' (130) {
- $"0090 009A 011B 0180 0082 5555" /* ......UU */
-};
-
-resource 'ALRT' (256, "About", purgeable) {
- {88, 85, 184, 378},
- 256,
- {
- /* [1] */
- OK, visible, silent,
- /* [2] */
- OK, visible, silent,
- /* [3] */
- OK, visible, silent,
- /* [4] */
- OK, visible, silent
- },
- alertPositionMainScreen
-};
-
-resource 'ALRT' (131, "Save Changes", purgeable) {
- {104, 130, 205, 488},
- 131,
- {
- /* [1] */
- OK, visible, silent,
- /* [2] */
- OK, visible, silent,
- /* [3] */
- OK, visible, silent,
- /* [4] */
- OK, visible, silent
- },
- alertPositionParentWindowScreen
-};
-
-resource 'clut' (256) {
- {
- // [0] // DOS colors crayon colors
- 0xFFFF, 0xFFFF, 0xFFFF, // white
-
- // [1]
- 0x0000, 0x3333, 0xCCCC, // blue
-
- // [2]
- 0x0000, 0x6666, 0x3333, // green pine
-
- // [3]
- 0x6666, 0xCCCC, 0xCCCC, // cyan fog
-
- // [4]
- 0xFFFF, 0x0000, 0x3333, // red
-
- // [5]
- 0xCCCC, 0x6666, 0xCCCC, // magenta orchid
-
- // [6]
- 0x9999, 0x6666, 0x3333, // brown dirt
-
- // [7]
- 0x9999, 0x9999, 0x9999, // light grey granite
-
- // [8]
- 0x3333, 0x3333, 0x3333, // drag grey gabbro
-
- // [9]
- 0x6666, 0x9999, 0xFFFF, // light blue sky blue
-
- // [10]
- 0x3333, 0x9999, 0x3333, // light green clover
-
- // [11]
- 0x6666, 0xCCCC, 0x9999, // light cyan ocean green
-
- // [12]
- 0xFFFF, 0x6666, 0x0000, // light red fire
-
- // [13]
- 0xFFFF, 0x9999, 0x0000, // light magenta orange
-
- // [14]
- 0xFFFF, 0xFFFF, 0x0000, // yellow lemon
-
- // [15]
- 0x0000, 0x0000, 0x0000 // black
- }
-};
diff --git a/crawl-ref/mac/Crawl4.mcp b/crawl-ref/mac/Crawl4.mcp
deleted file mode 100644
index d59edd3cd3..0000000000
--- a/crawl-ref/mac/Crawl4.mcp
+++ /dev/null
Binary files differ
diff --git a/crawl-ref/mac/Precomp (Common).h b/crawl-ref/mac/Precomp (Common).h
deleted file mode 100644
index f4f9450d05..0000000000
--- a/crawl-ref/mac/Precomp (Common).h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * File: Precomp (Common).h
- * Summary: The header included by the CodeWarrior precompiled header files.
- * Written by: Jesse Jones
- *
- * Change History (most recent first):
- *
- * <1> 5/25/02 JDJ Created
- */
-
-// In order for precompiled headers to work on MSVC this header must be included
-// before *anything* else.
-#if _MSC_VER >= 1100
- #pragma message("Compiling Precomp (Common).h (this message should only appear once per project)")
-#endif
-
-#ifndef PRECOMP_COMMON_H
-#define PRECOMP_COMMON_H
-
-
-// ===================================================================================
-// Debug Macros
-// ===================================================================================
-#ifdef _DEBUG
- #define DEBUG 1
- #define RELEASE 0
-
- #if __MWERKS__
- #define MSIPL_DEBUG_MODE
- #endif
-#else
- #define DEBUG 0
-
- #if __profile__
- #define RELEASE 0
- #else
- #define RELEASE 0
- #endif
-
- #if !defined(NDEBUG)
- #define NDEBUG // used by <assert.h>
- #endif
-#endif
-
-
-// ===================================================================================
-// Misc Macros
-// ===================================================================================
-#if MAC
- #define TARGET_API_MAC_CARBON 1
- #define __CF_USE_FRAMEWORK_INCLUDES__
-#endif
-
-#if MAC && !defined(macintosh) // macintosh isn't defined for MACH-O
- #define macintosh 1
-#endif
-
-#include <mslconfig>
-
-
-// ===================================================================================
-// C++ Includes
-// ===================================================================================
-#include <algorithm>
-#include <cstdio>
-#include <iostream>
-#include <limits>
-#include <list>
-#include <map>
-#include <set>
-#include <string>
-#include <vector>
-
-
-#endif // PRECOMP_COMMON_H \ No newline at end of file
diff --git a/crawl-ref/mac/Precomp (Mac-D).pch++ b/crawl-ref/mac/Precomp (Mac-D).pch++
deleted file mode 100644
index 32d0b7a246..0000000000
--- a/crawl-ref/mac/Precomp (Mac-D).pch++
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * File: Precomp (Mac-D).pch++
- * Summary: Precompiled header for Mac debug builds.
- * Written by: Jesse Jones
- *
- * Change History (most recent first):
- *
- * <1> 5/25/02 JDJ Created
- */
-
-#pragma precompile_target "Precomp (Mac-D)"
-
-#define MAC 1
-#define _DEBUG // this is how we know a build is a debug build on Windows so we'll use the same mechanism on the Mac
-
-#include "Precomp (Common).h"
diff --git a/crawl-ref/mac/Precomp (Mac-R).pch++ b/crawl-ref/mac/Precomp (Mac-R).pch++
deleted file mode 100644
index e72da8198e..0000000000
--- a/crawl-ref/mac/Precomp (Mac-R).pch++
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * File: Precomp (Mac-R).pch++
- * Summary: Precompiled header for Mac release builds.
- * Written by: Jesse Jones
- *
- * Change History (most recent first):
- *
- * <1> 5/25/02 JDJ Created
- */
-
-#if __profile__
- #pragma precompile_target "Precomp (Mac-P)"
-#else
- #pragma precompile_target "Precomp (Mac-R)"
-#endif
-
-#define MAC 1
-
-#include "Precomp (Common).h"
diff --git a/crawl-ref/mac/Precomp (Posix-D).pch++ b/crawl-ref/mac/Precomp (Posix-D).pch++
deleted file mode 100644
index 313f4a33bc..0000000000
--- a/crawl-ref/mac/Precomp (Posix-D).pch++
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * File: Precomp (Posix-D).pch++
- * Summary: Precompiled header for Posix debug builds.
- * Written by: Jesse Jones
- *
- * Change History (most recent first):
- *
- * <1> 5/25/02 JDJ Created
- */
-
-#pragma precompile_target "Precomp (Posix-D)"
-
-#define UNIX 1
-#define BSD 1
-#define _DEBUG // this is how we know a build is a debug build on Windows so we'll use the same mechanism on the Mac
-
-#include "Precomp (Common).h"
diff --git a/crawl-ref/mac/Precomp (Posix-R).pch++ b/crawl-ref/mac/Precomp (Posix-R).pch++
deleted file mode 100644
index f6d249a5f4..0000000000
--- a/crawl-ref/mac/Precomp (Posix-R).pch++
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * File: Precomp (Posix-R).pch++
- * Summary: Precompiled header for Posix release builds.
- * Written by: Jesse Jones
- *
- * Copyright 2002 Jesse Jones.
- *
- * Change History (most recent first):
- *
- * <1> 5/25/02 JDJ Created
- */
-
-#pragma precompile_target "Precomp (Posix-R)"
-
-#define UNIX 1
-#define BSD 1
-
-#include "Precomp (Common).h"
diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h
index a781a2b6b3..2989851dfc 100644
--- a/crawl-ref/source/AppHdr.h
+++ b/crawl-ref/source/AppHdr.h
@@ -159,15 +159,6 @@
#error MSVC is not supported yet
#define CHARACTER_SET A_ALTCHARSET
-// macintosh is predefined on all the common Mac compilers
-#elif defined(macintosh)
- #define PLAIN_TERM
- #define HAS_NAMESPACES 1
- #define EOL "\r"
- #define CHARACTER_SET A_ALTCHARSET
- #include <string>
- #include "libmac.h"
-
#elif defined(DOS)
#define DOS_TERM
#define SHORT_FILE_NAMES
diff --git a/crawl-ref/source/Crawl.xcodeproj/project.pbxproj b/crawl-ref/source/Crawl.xcodeproj/project.pbxproj
index 17b504e3a0..b58a6b38d3 100644
--- a/crawl-ref/source/Crawl.xcodeproj/project.pbxproj
+++ b/crawl-ref/source/Crawl.xcodeproj/project.pbxproj
@@ -145,6 +145,8 @@
7B237F150A8ECD2E00580F30 /* libncurses.5.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B237F140A8ECD2E00580F30 /* libncurses.5.dylib */; };
7BC222E70ABBB286003A7D9A /* itemprop.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BC222E50ABBB286003A7D9A /* itemprop.cc */; };
7BC222E80ABBB286003A7D9A /* itemprop.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7BC222E60ABBB286003A7D9A /* itemprop.h */; };
+ 7BD75A350AC214A200B74F6E /* notes.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BD75A330AC214A200B74F6E /* notes.cc */; };
+ 7BD75A360AC214A200B74F6E /* notes.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7BD75A340AC214A200B74F6E /* notes.h */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -222,6 +224,7 @@
7B237EF00A8EC9D000580F30 /* mt19937ar.h in CopyFiles */,
7B237EF20A8EC9D000580F30 /* mstuff2.h in CopyFiles */,
7BC222E80ABBB286003A7D9A /* itemprop.h in CopyFiles */,
+ 7BD75A360AC214A200B74F6E /* notes.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 1;
};
@@ -366,7 +369,9 @@
7B237F140A8ECD2E00580F30 /* libncurses.5.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libncurses.5.dylib; path = /usr/lib/libncurses.5.dylib; sourceTree = "<absolute>"; };
7BC222E50ABBB286003A7D9A /* itemprop.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = itemprop.cc; sourceTree = "<group>"; };
7BC222E60ABBB286003A7D9A /* itemprop.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = itemprop.h; sourceTree = "<group>"; };
- 8DD76FB20486AB0100D96B5E /* crawl */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = crawl; sourceTree = BUILT_PRODUCTS_DIR; };
+ 7BD75A330AC214A200B74F6E /* notes.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = notes.cc; sourceTree = "<group>"; };
+ 7BD75A340AC214A200B74F6E /* notes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = notes.h; sourceTree = "<group>"; };
+ 8DD76FB20486AB0100D96B5E /* crawl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = crawl; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -486,6 +491,8 @@
7B237DFA0A8EC9D000580F30 /* mutation.h */,
7B237DF90A8EC9D000580F30 /* newgame.cc */,
7B237E340A8EC9D000580F30 /* newgame.h */,
+ 7BD75A330AC214A200B74F6E /* notes.cc */,
+ 7BD75A340AC214A200B74F6E /* notes.h */,
7B237E330A8EC9D000580F30 /* ouch.cc */,
7B237E320A8EC9D000580F30 /* ouch.h */,
7B237E310A8EC9D000580F30 /* output.cc */,
@@ -669,6 +676,7 @@
7B237EEF0A8EC9D000580F30 /* debug.cc in Sources */,
7B237EF10A8EC9D000580F30 /* mt19937ar.cc in Sources */,
7BC222E70ABBB286003A7D9A /* itemprop.cc in Sources */,
+ 7BD75A350AC214A200B74F6E /* notes.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/crawl-ref/source/MacString.cc b/crawl-ref/source/MacString.cc
deleted file mode 100644
index 2d5c14442e..0000000000
--- a/crawl-ref/source/MacString.cc
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * File: MacString.cc
- * Summary: Wrapper around an immutable CFString.
- * Written by: Jesse Jones (jesjones@mindspring.com)
- *
- * Change History (most recent first):
- *
- * <1> 6/04/02 JDJ Created
- */
-
-#include "AppHdr.h"
-#include "MacString.h"
-
-#if macintosh
-
-#include <CoreFoundation/CFString.h>
-
-#include "debug.h"
-
-
-// ========================================================================
-// Internal Functions
-// ========================================================================
-
-//---------------------------------------------------------------
-//
-// ThrowIf
-//
-//---------------------------------------------------------------
-static void ThrowIf(bool predicate, const std::string& text)
-{
- if (predicate)
- throw std::runtime_error(text);
-}
-
-#if __MWERKS__
-#pragma mark -
-#endif
-
-// ============================================================================
-// class MacString
-// ============================================================================
-
-//---------------------------------------------------------------
-//
-// MacString::~MacString
-//
-//---------------------------------------------------------------
-MacString::~MacString()
-{
- CFRelease(mString);
-}
-
-
-//---------------------------------------------------------------
-//
-// MacString::MacString ()
-//
-//---------------------------------------------------------------
-MacString::MacString()
-{
- mString = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, NULL, 0);
- ThrowIf(mString == NULL, "Couldn't create the CFString");
-}
-
-
-//---------------------------------------------------------------
-//
-// MacString::MacString (unsigned char*)
-//
-//---------------------------------------------------------------
-MacString::MacString(const unsigned char* str)
-{
- ASSERT(str != NULL);
-
- CFStringEncoding encoding = CFStringGetSystemEncoding();
- mString = CFStringCreateWithPascalString(kCFAllocatorSystemDefault, str, encoding);
- ThrowIf(mString == NULL, "Couldn't create the CFString");
-}
-
-
-//---------------------------------------------------------------
-//
-// MacString::MacString (char*)
-//
-//---------------------------------------------------------------
-MacString::MacString(const char* str)
-{
- ASSERT(str != NULL);
-
- CFStringEncoding encoding = CFStringGetSystemEncoding();
- mString = CFStringCreateWithCString(kCFAllocatorSystemDefault, str, encoding);
- ThrowIf(mString == NULL, "Couldn't create the CFString");
-}
-
-
-//---------------------------------------------------------------
-//
-// MacString::MacString (CFStringRef)
-//
-//---------------------------------------------------------------
-MacString::MacString(CFStringRef str)
-{
- ASSERT(str != NULL);
-
- mString = str;
- CFRetain(mString);
-}
-
-
-//---------------------------------------------------------------
-//
-// MacString::MacString (CFMutableStringRef)
-//
-//---------------------------------------------------------------
-MacString::MacString(CFMutableStringRef str)
-{
- ASSERT(str != NULL);
-
- mString = CFStringCreateCopy(kCFAllocatorSystemDefault, str);
- ThrowIf(mString == NULL, "Couldn't create the CFString");
-}
-
-
-//---------------------------------------------------------------
-//
-// MacString::MacString (int)
-//
-//---------------------------------------------------------------
-MacString::MacString(int value)
-{
- char buffer[32];
- sprintf(buffer, "%d", value);
-
- CFStringEncoding encoding = CFStringGetSystemEncoding();
- mString = CFStringCreateWithCString(kCFAllocatorSystemDefault, buffer, encoding);
- ThrowIf(mString == NULL, "Couldn't create the CFString");
-}
-
-
-//---------------------------------------------------------------
-//
-// MacString::MacString (MacString)
-//
-//---------------------------------------------------------------
-MacString::MacString(const MacString& str)
-{
- mString = str.mString; // immutable so we can refcount
- CFRetain(mString);
-}
-
-
-//---------------------------------------------------------------
-//
-// MacString::operator= (MacString)
-//
-//---------------------------------------------------------------
-MacString& MacString::operator=(const MacString& rhs)
-{
- if (this != &rhs)
- {
- CFRelease(mString);
-
- mString = rhs.mString; // immutable so we can refcount
- CFRetain(mString);
- }
-
- return *this;
-}
-
-
-//---------------------------------------------------------------
-//
-// MacString::length
-//
-//---------------------------------------------------------------
-size_t MacString::length() const
-{
- size_t len = (size_t) CFStringGetLength(mString);
-
- return len;
-}
-
-
-//---------------------------------------------------------------
-//
-// MacString::CopyTo
-//
-//---------------------------------------------------------------
-void MacString::CopyTo(unsigned char* buffer, CFIndex bytes)
-{
- ASSERT(buffer != NULL || bytes == 0);
-
- bool converted = CFStringGetPascalString(mString, buffer, bytes, CFStringGetSystemEncoding());
- ThrowIf(!converted, "Couldn't convert the CFString into a Pascal string");
-}
-
-
-#endif // macintosh
diff --git a/crawl-ref/source/MacString.h b/crawl-ref/source/MacString.h
deleted file mode 100644
index d2cad4b1be..0000000000
--- a/crawl-ref/source/MacString.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * File: MacString.h
- * Summary: Wrapper around an immutable CFString.
- * Written by: Jesse Jones (jesjones@mindspring.com)
- *
- * Change History (most recent first):
- *
- * <1> 6/04/02 JDJ Created
- */
-
-#ifndef MAC_STRING_H
-#define MAC_STRING_H
-
-#if macintosh
-
-#include <CoreFoundation/CFBase.h>
-
-
-// ============================================================================
-// class MacString
-//! Wrapper around an immutable CFString.
-// ============================================================================
-class MacString {
-
-//-----------------------------------
-// Initialization/Destruction
-//
-public:
- ~MacString();
-
- MacString();
-
- MacString(const char* str);
- MacString(const unsigned char* str);
- /**< Uses default system encoding. */
-
- MacString(CFStringRef str);
- /**< Bumps the ref count. */
-
- MacString(CFMutableStringRef str);
- /**< Makes a copy. */
-
- explicit MacString(int value);
-
- MacString(const MacString& str);
- MacString& operator=(const MacString& rhs);
-
-//-----------------------------------
-// API
-//
-public:
- // ----- Size -----
- size_t length() const;
- size_t size() const {return this->length();}
- bool empty() const {return this->length() == 0;}
-
- // ----- Access -----
- void CopyTo(unsigned char* buffer, CFIndex bytes);
-
- operator CFStringRef() const {return mString;}
-
-//-----------------------------------
-// Member Data
-//
-private:
- CFStringRef mString;
-};
-
-
-#endif // macintosh
-#endif // MAC_STRING_H
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 51da4597d0..7f32acb932 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -39,7 +39,7 @@
#include <string>
// I don't seem to need values.h for VACPP..
-#if !defined(__IBMCPP__) && !defined(MAC)
+#if !defined(__IBMCPP__)
#include <limits.h>
#endif
@@ -247,10 +247,6 @@ int main( int argc, char *argv[] )
unixcurses_startup();
#endif
-#ifdef MAC
- init_mac();
-#endif
-
#ifdef WIN32CONSOLE
init_libw32c();
#endif
@@ -349,10 +345,6 @@ int main( int argc, char *argv[] )
unixcurses_shutdown();
#endif
-#ifdef MAC
- deinit_mac();
-#endif
-
#ifdef USE_EMX
deinit_emx();
#endif
diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc
index 2eb3fd8c47..843a5cb86d 100644
--- a/crawl-ref/source/chardump.cc
+++ b/crawl-ref/source/chardump.cc
@@ -1007,10 +1007,6 @@ static void dump_mutations( std::string & text )
}
} // end dump_mutations()
-#if MAC
-#pragma mark -
-#endif
-
// ========================================================================
// Public Functions
// ========================================================================
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index cd0dcdee43..12fdae7acb 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -84,18 +84,6 @@ static void BreakStrToDebugger(const char *mesg)
// raise(SIGINT); // this is what DebugStr() does on OS X according to Tech Note 2030
int* p = NULL; // but this gives us a stack crawl...
*p = 0;
-#elif MAC
- unsigned char s[50];
-
- int len = strlen(mesg);
-
- if (len > 255)
- len = 255;
-
- s[0] = (Byte) len;
- BlockMoveData(mesg, s + 1, len);
-
- DebugStr(s);
#elif WIN
MSG msg; // remove pending quit messages so the message box displays
@@ -314,10 +302,6 @@ static void TraceString(const char *mesg)
}
#endif
-#if MAC
-#pragma mark -
-#endif
-
// ========================================================================
// Global Functions
// ========================================================================
@@ -332,10 +316,6 @@ void AssertFailed(const char *expr, const char *file, int line)
{
char mesg[512];
-#if MAC
- sprintf(mesg, "ASSERT(%s) in %s at line %d failed.", expr, file, line);
-
-#else
const char *fileName = file + strlen(file); // strip off path
while (fileName > file && fileName[-1] != '\\')
@@ -343,7 +323,6 @@ void AssertFailed(const char *expr, const char *file, int line)
sprintf(mesg, "ASSERT(%s) in '%s' at line %d failed.", expr, fileName,
line);
-#endif
BreakStrToDebugger(mesg);
}
diff --git a/crawl-ref/source/defines.h b/crawl-ref/source/defines.h
index f1156eec76..bd6a7166f9 100644
--- a/crawl-ref/source/defines.h
+++ b/crawl-ref/source/defines.h
@@ -25,8 +25,7 @@
#define ESCAPE '\x1b' // most ansi-friendly way I can think of defining this.
// there's got to be a better way...
-#ifdef _LIBUNIX_IMPLEMENTATION
-#elif macintosh
+#ifndef _LIBUNIX_IMPLEMENTATION
#else
#ifndef TRUE
#define TRUE 1
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 8179802ae9..031ca5f60d 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -3136,10 +3136,6 @@ static std::string describe_misc_item( const item_def &item )
return (description);
}
-#if MAC
-#pragma mark -
-#endif
-
// ========================================================================
// Public Functions
// ========================================================================
diff --git a/crawl-ref/source/files.h b/crawl-ref/source/files.h
index a2d357cac8..6543168065 100644
--- a/crawl-ref/source/files.h
+++ b/crawl-ref/source/files.h
@@ -47,7 +47,7 @@ void load( unsigned char stair_taken, int load_mode, bool was_a_labyrinth,
// last updated 12may2000 {dlb}
/* ***********************************************************************
- * called from: acr - libmac - misc
+ * called from: acr - misc
* *********************************************************************** */
void save_game(bool leave_game);
diff --git a/crawl-ref/source/libmac.cc b/crawl-ref/source/libmac.cc
deleted file mode 100644
index 35e2055344..0000000000
--- a/crawl-ref/source/libmac.cc
+++ /dev/null
@@ -1,2116 +0,0 @@
-/*
- * File: libmac.cc
- * Summary: Mac specific routines used by Crawl.
- * Written by: Jesse Jones (jesjones@mindspring.com)
- *
- * Modified for Crawl Reference by $Author$ on $Date$
- *
- * Change History (most recent first):
- *
- * <5> 5/25/02 JDJ Rewrote to use Carbon Events and Mach-O.
- * <4> 9/25/99 CDL linuxlib -> liblinux
- *
- * <3> 5/30/99 JDJ Quit only pops up save changes dialog if game_has_started is true.
- * <2> 4/24/99 JDJ HandleMenu calls save_game instead of returning a 'S'
- * character ('S' now prompts). kTermHeight is now initialized
- * to NUMBER_OF_LINES.
- * <2> 4/24/99 JDJ getstr only adds printable characters to the buffer.
- * <1> 3/23/99 JDJ Created
- */
-
-#include "AppHdr.h"
-#include "libmac.h"
-
-#if macintosh
-
-#include <cstdarg>
-#include <ctype.h>
-#include <string.h>
-#include <vector.h>
-
-#include <CarbonCore/StringCompare.h>
-#include <HIToolbox/CarbonEvents.h>
-#include <HIToolbox/Dialogs.h>
-
-#include "debug.h"
-#include "defines.h"
-#include "files.h"
-#include "MacString.h"
-#include "version.h"
-
-
-//-----------------------------------
-// Forward References
-//
-class CApplication;
-
-
-//-----------------------------------
-// Constants
-//
-const int kTermWidth = 80;
-const int kTermHeight = MAC_NUMBER_OF_LINES;
-
-const int kLeftArrowKey = 0x7B;
-const int kUpArrowKey = 0x7E;
-const int kRightArrowKey = 0x7C;
-const int kDownArrowKey = 0x7D;
-
-const int kNumPad0Key = 0x52;
-const int kNumPad1Key = 0x53;
-const int kNumPad2Key = 0x54;
-const int kNumPad3Key = 0x55;
-const int kNumPad4Key = 0x56;
-const int kNumPad5Key = 0x57;
-const int kNumPad6Key = 0x58;
-const int kNumPad7Key = 0x59;
-const int kNumPad8Key = 0x5B;
-const int kNumPad9Key = 0x5C;
-
-const int kNumPadMultKey = 0x43;
-const int kNumPadAddKey = 0x45;
-const int kNumPadSubKey = 0x4E;
-const int kNumPadDecimalKey = 0x41;
-const int kNumPadDivideKey = 0x4B;
-
-const char kEnterChar = 0x03;
-const short kEscapeKey = 0x35;
-const char kCheckMarkChar = 0x12;
-const char kNoMarkChar = 0x00;
-
-const short kSaveBtn = 1;
-const short kCancelBtn = 2;
-const short kDontSaveBtn = 3;
-
-const Rect kBigRect = {0, 0, 32000, 32000};
-
-const RGBColor kBlack = {0, 0, 0};
-const RGBColor kWhite = {65535, 65535, 65535};
-
-enum EAskSaveResult
-{
- kSaveChanges = 1,
- kCancelSave = 2,
- kDontSave = 3
-};
-
-
-//-----------------------------------
-// Variables
-//
-static CApplication* sApp = NULL;
-static CTabHandle sColors = NULL;
-
-static bool sInDialog = false;
-
-extern bool game_has_started;
-
-
-// ========================================================================
-// Internal Functions
-// ========================================================================
-
-//---------------------------------------------------------------
-//
-// CreateSpec
-//
-//---------------------------------------------------------------
-static EventTypeSpec CreateSpec(UInt32 c, UInt32 k)
-{
- EventTypeSpec spec;
-
- spec.eventClass = c;
- spec.eventKind = k;
-
- return spec;
-}
-
-
-//---------------------------------------------------------------
-//
-// DrawChar
-//
-//---------------------------------------------------------------
-inline void DrawChar(short x, short y, char ch)
-{
- MoveTo(x, y);
- DrawText(&ch, 0, 1);
-}
-
-
-//---------------------------------------------------------------
-//
-// ThrowIf
-//
-//---------------------------------------------------------------
-static void ThrowIf(bool predicate, const std::string& text)
-{
- if (predicate)
- throw std::runtime_error(text);
-}
-
-
-//---------------------------------------------------------------
-//
-// ThrowIfOSErr
-//
-//---------------------------------------------------------------
-static void ThrowIfOSErr(OSErr err, const std::string& text)
-{
- if (err != noErr)
- {
- char buffer[256];
- sprintf(buffer, "%s (%d)", text.c_str(), err);
-
- throw std::runtime_error(buffer);
- }
-}
-
-
-//---------------------------------------------------------------
-//
-// FlashButton
-//
-//---------------------------------------------------------------
-static void FlashButton(DialogPtr dialog, short item)
-{
- ASSERT(dialog != nil);
- ASSERT(item >= 1 && item <= CountDITL(dialog));
-
- ControlRef control;
- (void) GetDialogItemAsControl(dialog, item, &control);
-
- HiliteControl(control, 1);
-// QDAddRectToDirtyRegion(GetDialogPort(dialog), &kBigRect);
- QDFlushPortBuffer(GetDialogPort(dialog), NULL);
-
- unsigned long ticks;
- Delay(8, &ticks);
-
- HiliteControl(control, 0);
-// QDAddRectToDirtyRegion(GetDialogPort(dialog), &kBigRect);
- QDFlushPortBuffer(GetDialogPort(dialog), NULL);
-}
-
-
-//---------------------------------------------------------------
-//
-// WarnUser
-//
-// Pops up an error dialog.
-//
-//---------------------------------------------------------------
-static void WarnUser(const char* message)
-{
- int len = strlen(message);
- if (len > 250)
- len = 250;
-
- Str255 text;
- for (int i = 0; i < len; i++)
- text[i + 1] = message[i];
- text[0] = len;
-
- AlertStdAlertParamRec params;
- params.movable = true;
- params.helpButton = false;
- params.filterProc = NULL;
- params.defaultText = (StringPtr) -1L; // use default (ie "OK")
- params.cancelText = NULL;
- params.otherText = NULL;
- params.defaultButton = 1;
- params.cancelButton = 0;
- params.position = kWindowAlertPositionParentWindowScreen;
-
- short item;
- sInDialog = true;
- OSErr err = StandardAlert(kAlertCautionAlert, text, "\p", &params, &item);
- ASSERT(err == noErr); // seems kind of pointless to throw
- sInDialog = false;
-}
-
-
-//---------------------------------------------------------------
-//
-// SaveChangesFilter
-//
-//---------------------------------------------------------------
-static pascal Boolean SaveChangesFilter(DialogPtr dptr, EventRecord* event, short* item)
-{
- bool handled = false;
-
- if (event->what == keyDown)
- {
- char ch = (char) toupper((char) (event->message & charCodeMask));
- short key = (short) ((event->message & keyCodeMask) >> 8);
-
- if (ch == 'S')
- {
- *item = 1;
- handled = true;
- }
- else if (ch == 'D')
- {
- *item = 3;
- handled = true;
- }
- else if (ch == '\r' || ch == kEnterChar)
- {
- *item = 1;
- handled = true;
- }
- else if (key == kEscapeKey)
- {
- *item = 2;
- handled = true;
- }
-
- if (handled)
- FlashButton(dptr, *item);
- }
-
- return handled;
-}
-
-
-//---------------------------------------------------------------
-//
-// AskSaveChanges
-//
-//---------------------------------------------------------------
-static EAskSaveResult AskSaveChanges()
-{
-#if 1
- static ModalFilterUPP filterProc = NewModalFilterUPP(SaveChangesFilter);
-
- AlertStdAlertParamRec params;
- params.movable = true;
- params.helpButton = false;
- params.filterProc = filterProc;
- params.defaultText = "\pSave";
- params.cancelText = "\pCancel";
- params.otherText = "\pDon't Save";
- params.defaultButton = kSaveBtn;
- params.cancelButton = kCancelBtn;
- params.position = kWindowAlertPositionParentWindowScreen;
-
- short item = kSaveBtn;
- sInDialog = true;
- OSErr err = StandardAlert(kAlertStopAlert, "\pDo you want to save your game before quitting?", "\p", &params, &item);
- ASSERT(err == noErr); // seems kind of pointless to throw
- sInDialog = false;
-
- EAskSaveResult result;
- if (item == kSaveBtn)
- result = kSaveChanges;
- else if (item == kDontSaveBtn)
- result = kDontSave;
- else
- result = kCancelSave;
-
- return result;
-
-#else
- NavDialogOptions options;
- OSStatus err = NavGetDefaultDialogOptions(&options);
- ASSERT(err == noErr); // seems kind of pointless to throw
-
- NavAskSaveChangesResult reply = kSaveChanges;
- if (err == noErr)
- {
- std::string name = "foobar";
- UInt32 length = std::min(name.size(), sizeof(options.savedFileName) - 1);
- BlockMoveData(name.c_str(), options.savedFileName + 1, length);
- options.savedFileName[0] = length;
-
- err = NavAskSaveChanges(&options,
- action,
- &reply,
- NULL,
- 0UL);
- ASSERT(err == noErr); // seems kind of pointless to throw
- }
-
- return (EAskSaveResult) reply;
-#endif
-}
-
-
-//---------------------------------------------------------------
-//
-// ConvertColor
-//
-//---------------------------------------------------------------
-static RGBColor ConvertColor(int c)
-{
- ASSERT(c >= 0);
- ASSERT(c < 16);
-
- RGBColor color;
-
- if (c == BLACK)
- color = (**sColors).ctTable[15].rgb; // QD likes black and white swapped from DOS indices
-
- else if (c == WHITE)
- color = (**sColors).ctTable[0].rgb;
- else
- color = (**sColors).ctTable[c].rgb;
-
- return color;
-}
-
-#if __MWERKS__
-#pragma mark -
-#endif
-
-// ============================================================================
-// class CApplication
-// ============================================================================
-class CApplication {
-
-//-----------------------------------
-// Initialization/Destruction
-//
-public:
- ~CApplication();
- CApplication();
-
-//-----------------------------------
-// API
-//
-public:
- void Quit();
-
- char GetChar();
- // Block until a key is pressed.
-
- bool PeekChar();
- // Return true if a key event is on the event queue.
-
- void Clear();
- void SetCursor(int x, int y);
- Point GetCursor() const {return mCursor;}
- void SetChar(unsigned char ch);
- void Print(const char* buffer);
- void ShowCursor(bool show) {mShowCursor = show;}
-
- void SetForeColor(const RGBColor& color);
- void SetBackColor(const RGBColor& color);
-
- void SetFont(const unsigned char *name) {this->DoSetFont(name, mPointSize);}
- void SetFontSize(int size) {this->DoSetFont(mFontName, size);}
-
-//-----------------------------------
-// Internal Types
-//
-private:
- struct SCell {
- unsigned char ch;
- RGBColor color;
-
- SCell()
- {
- ch = ' ';
- color.red = color.green = color.blue = 65535;
- }
- };
-
- typedef vector<SCell> Line;
-
-//-----------------------------------
-// Internal API
-//
-private:
- void DoAbout();
- void DoClearToEOL();
- void DoDrawCell(const Rect& area, const SCell& cell);
- OSStatus DoEnableCommand(MenuRef menuH, MenuCommand command, MenuItemIndex index);
- OSStatus DoHandleCommand(MenuCommand command);
- void DoInitMenus();
- void DoInitWindows();
- char DoMungeChar(char inChar, UInt32 inKey, UInt32 modifiers) const;
- OSStatus DoOpenMenu(MenuRef menuH);
- void DoReadPrefs();
- void DoRender();
- void DoScroll();
- void DoSetChar(unsigned char ch);
- void DoSetFont(const unsigned char* name, int size);
- void DoWritePrefs();
-
- static pascal OSStatus DoKeyDown(EventHandlerCallRef handler, EventRef event, void* refCon);
- static pascal OSStatus DoMenuEvent(EventHandlerCallRef handler, EventRef event, void* refCon);
- static pascal OSErr DoQuit(const AppleEvent* event, AppleEvent* reply, SInt32 refCon);
- static pascal OSStatus DoWindowEvent(EventHandlerCallRef handler, EventRef event, void* refCon);
-
-//-----------------------------------
-// Member Data
-//
-private:
- WindowRef mWindow;
- vector<Line> mLines;
- char mChar;
-
- Point mCursor;
- bool mShowCursor;
-
- RGBColor mForeColor;
- RGBColor mBackColor;
-
- Str255 mFontName;
- int mPointSize;
- UInt32 mNumFonts;
- MenuRef mFontMenu;
-
- short mFontNum;
- int mAscent;
- int mCellHeight;
- int mCellWidth;
-};
-
-//---------------------------------------------------------------
-//
-// CApplication::~CApplication
-//
-//---------------------------------------------------------------
-CApplication::~CApplication()
-{
- this->DoWritePrefs();
-
- DisposeWindow(mWindow);
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::CApplication
-//
-//---------------------------------------------------------------
-CApplication::CApplication()
-{
- InitCursor();
-
- mCursor.h = 0;
- mCursor.v = 0;
- mShowCursor = false;
- mChar = 0;
-
- mNumFonts = 0;
- mFontName[0] = '\0';
- mFontNum = -2;
- mPointSize = 0;
- mAscent = 0;
- mCellHeight = 0;
- mCellWidth = 0;
- mFontMenu = NULL;
-
- mForeColor = kWhite;
- mBackColor = kBlack;
-
- try
- {
- // install a handler for the quit apple event
- OSStatus err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP(DoQuit), 0, false);
- ThrowIfOSErr(err, "Couldn't install the quit handler!");
-
- // install a custom key handler
- std::vector<EventTypeSpec> specs;
- specs.push_back(CreateSpec(kEventClassKeyboard, kEventRawKeyDown));
- specs.push_back(CreateSpec(kEventClassKeyboard, kEventRawKeyRepeat));
-
- err = InstallApplicationEventHandler(NewEventHandlerUPP(DoKeyDown), specs.size(), &specs[0], this, NULL);
- ThrowIfOSErr(err, "Couldn't install the key handler!");
-
- // create the window
- this->DoInitWindows();
-
- // init the menus
- this->DoInitMenus();
-
- // update some state
- this->DoReadPrefs();
-
- this->Clear();
-
- // show the window
- ShowWindow(mWindow);
- }
- catch (const std::exception& e)
- {
- WarnUser(e.what());
- ExitToShell();
- }
- catch (...)
- {
- WarnUser("Couldn't initialize the application.");
- ExitToShell();
- }
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::Quit
-//
-//---------------------------------------------------------------
-void CApplication::Quit()
-{
- if (game_has_started)
- {
- EAskSaveResult answer = AskSaveChanges();
-
- if (answer == kSaveChanges)
- {
- save_game(true);
- }
- else if (answer == kDontSave)
- {
- deinit_mac();
- ExitToShell();
- }
- }
- else
- {
- deinit_mac();
- ExitToShell();
- }
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::Clear
-//
-//---------------------------------------------------------------
-void CApplication::Clear()
-{
- mLines.resize(kTermHeight);
-
- for (int y = 0; y < mLines.size(); ++y)
- {
- Line& line = mLines[y];
- line.resize(kTermWidth);
-
- for (int x = 0; x < line.size(); ++x)
- {
- SCell& cell = line[x];
-
- cell.ch = ' ';
- cell.color = kWhite;
- }
- }
-
- mCursor.h = 0;
- mCursor.v = 0;
-
- (void) InvalWindowRect(mWindow, &kBigRect);
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::SetCursor
-//
-//---------------------------------------------------------------
-void CApplication::SetCursor(int x, int y)
-{
- ASSERT(x >= 0);
- ASSERT(x < kTermWidth);
- ASSERT(y >= 0);
- ASSERT(y < kTermHeight);
-
- if (x != mCursor.h || y != mCursor.v)
- {
- if (mShowCursor)
- {
- Rect area;
- area.top = mCursor.v * mCellHeight;
- area.bottom = area.top + mCellHeight;
- area.left = mCursor.h * mCellWidth;
- area.right = area.left + mCellWidth;
-
- (void) InvalWindowRect(mWindow, &area);
- }
-
- mCursor.h = x;
- mCursor.v = y;
-
- if (mShowCursor)
- {
- Rect area;
- area.top = mCursor.v * mCellHeight;
- area.bottom = area.top + mCellHeight;
- area.left = mCursor.h * mCellWidth;
- area.right = area.left + mCellWidth;
-
- (void) InvalWindowRect(mWindow, &area);
- }
- }
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::SetChar
-//
-//---------------------------------------------------------------
-void CApplication::SetChar(unsigned char ch)
-{
- ASSERT(ch != '\t');
- ASSERT(mLines.size() == kTermHeight);
-
- const int TABSIZE = 8;
-
- int x = mCursor.h; // this is from the ncurses source
- int y = mCursor.v;
-
- switch (ch) {
- case '\t':
- x += (TABSIZE - (x % TABSIZE));
-
- // Space-fill the tab on the bottom line so that we'll get the
- // "correct" cursor position.
- if (x < kTermWidth)
- {
- char blank = ' ';
-
- while (mCursor.h < x)
- this->DoSetChar(blank);
- break;
-
- }
- else
- {
- this->DoClearToEOL();
- if (++y >= kTermHeight)
- {
- x = kTermWidth - 1;
- y--;
- this->DoScroll();
- x = 0;
- }
- else
- x = 0;
- }
- break;
-
-#if 1
- case '\n':
- case '\r':
- this->DoClearToEOL();
- if (++y >= kTermHeight)
- {
- y--;
- this->DoScroll();
- }
- x = 0;
- break;
-
-#else
- case '\n':
- this->DoClearToEOL();
- if (++y >= kTermHeight)
- {
- y--;
- this->DoScroll();
- }
- /* FALLTHRU */
-
- case '\r':
- x = 0;
- break;
-#endif
-
- case '\b':
- if (x == 0)
- return;
- mCursor.h--;
- this->DoSetChar(' ');
- x--;
- break;
-
- case 159:
- case 176:
- case 177:
- case 220:
- case 239:
- case 240:
- case 247:
- case 249:
- case 250:
- case 206:
- case 254:
- this->DoSetChar(ch);
- return;
- break;
-
- default:
- if (ch == '\0')
- ch = ' ';
-
-// ASSERT(ch >= ' ');
-// ASSERT(ch <= '~');
-
- if (ch >= ' ' && ch <= '~')
- this->DoSetChar(ch);
- else
- this->DoSetChar('');
- return;
- }
-
- mCursor.h = x;
- mCursor.v = y;
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::Print
-//
-//---------------------------------------------------------------
-void CApplication::Print(const char* buffer)
-{
- ASSERT(buffer != NULL);
-
- const char* p = buffer;
-
- while (*p != '\0')
- {
- char ch = *p++;
-
- this->SetChar(ch);
- }
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::SetForeColor
-//
-//---------------------------------------------------------------
-void CApplication::SetForeColor(const RGBColor & color)
-{
- if (color.red != mForeColor.red || color.green != mForeColor.green || color.blue != mForeColor.blue)
- {
- mForeColor = color;
-
- (void) InvalWindowRect(mWindow, &kBigRect);
- }
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::SetBackColor
-//
-//---------------------------------------------------------------
-void CApplication::SetBackColor(const RGBColor & color)
-{
- if (color.red != mBackColor.red || color.green != mBackColor.green || color.blue != mBackColor.blue)
- {
- mBackColor = color;
-
- (void) InvalWindowRect(mWindow, &kBigRect);
- }
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::GetChar
-//
-//---------------------------------------------------------------
-char CApplication::GetChar()
-{
- mChar = 0;
- RunApplicationEventLoop();
-
- (void) InvalWindowRect(mWindow, &kBigRect);
-
- return mChar;
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::PeekChar
-//
-//---------------------------------------------------------------
-bool CApplication::PeekChar()
-{
- EventTypeSpec specs[2];
- specs[0] = CreateSpec(kEventClassKeyboard, kEventRawKeyDown);
- specs[1] = CreateSpec(kEventClassKeyboard, kEventRawKeyRepeat);
-
- EventRef event = NULL;
- OSStatus err = ReceiveNextEvent(2, specs, kEventDurationNoWait, false, &event);
-
- return err == noErr;
-}
-
-#if __MWERKS__
-#pragma mark ~
-#endif
-
-//---------------------------------------------------------------
-//
-// CApplication::DoAbout
-//
-//---------------------------------------------------------------
-void CApplication::DoAbout()
-{
- AlertStdAlertParamRec params;
- params.movable = true;
- params.helpButton = false;
- params.filterProc = NULL;
- params.defaultText = (StringPtr) -1L; // use default (ie "OK") VERSION
- params.cancelText = NULL;
- params.otherText = NULL;
- params.defaultButton = 1;
- params.cancelButton = 0;
- params.position = kWindowAlertPositionParentWindowScreen;
-
- short item;
- sInDialog = true;
- OSErr err = StandardAlert(kAlertNoteAlert, "\p Crawl " VERSION, "\p 1997-2002 by Linley Henzell\nMac Port by Jesse Jones", &params, &item);
- ASSERT(err == noErr); // seems kind of pointless to throw
- sInDialog = false;
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoClearToEOL
-//
-//---------------------------------------------------------------
-void CApplication::DoClearToEOL()
-{
- ASSERT(mCursor.h < kTermWidth);
- ASSERT(mCursor.v < kTermHeight);
-
- Line& line = mLines[mCursor.v];
- for (int x = mCursor.h; x < kTermWidth; ++x)
- {
- SCell& cell = line[x];
- cell.ch = ' ';
- }
-
- Rect area;
- area.top = mCursor.v * mCellHeight;
- area.bottom = area.top + mCellHeight;
- area.left = mCursor.h * mCellWidth;
- area.right = 16000;
-
- (void) InvalWindowRect(mWindow, &kBigRect);
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoDrawCell
-//
-//---------------------------------------------------------------
-void CApplication::DoDrawCell(const Rect& area, const SCell& cell)
-{
- RGBForeColor(&cell.color);
-
- switch (cell.ch) {
- case 159: // fountain
- DrawChar(area.left, area.top + mAscent, '');
- break;
-
- case 177: // wall
- case 176:
- PaintRect(&area);
- break;
-
- case 247: // water/lava
- PaintRect(&area);
- break;
-
- case 249: // floor
- case 250: // undiscovered trap?
-// FillRect(&area, &qd.gray);
- DrawChar(area.left, area.top + mAscent, '.');
- break;
-
- case 206:
- case 254: // door
- {
- Rect temp = area;
- InsetRect(&temp, 2, 2);
- PaintRect(&temp);
- }
- break;
-
- case 220: // altar
- DrawChar(area.left, area.top + mAscent, '');
- break;
-
- case 239: // staircase to hell
- case 240: // branch staircase
- DrawChar(area.left, area.top + mAscent, '');
- break;
-
- default:
- DrawChar(area.left, area.top + mAscent, cell.ch);
- }
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoEnableCommand
-//
-//---------------------------------------------------------------
-OSStatus CApplication::DoEnableCommand(MenuRef menuH, MenuCommand command, MenuItemIndex index)
-{
- OSStatus err = noErr;
-
- if (command == 'Abut')
- {
- EnableMenuItem(menuH, index);
- }
- else if (command == 'Save')
- {
- if (game_has_started)
- EnableMenuItem(menuH, index);
- else
- DisableMenuItem(menuH, index);
- }
- else if (command >= 'Size' && command <= 'Size'+128)
- {
- if (mPointSize == command - 'Size')
- SetItemMark(menuH, index, kCheckMarkChar);
- else
- SetItemMark(menuH, index, kNoMarkChar);
- }
- else if (command >= 'Font' && command <= 'Font'+128)
- {
- Str255 name;
- GetMenuItemText(menuH, index, name);
-
- if (EqualString(mFontName, name, true, true))
- SetItemMark(menuH, index, kCheckMarkChar);
- else
- SetItemMark(menuH, index, noMark);
- }
- else
- err = eventNotHandledErr;
-
- return err;
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoHandleCommand
-//
-//---------------------------------------------------------------
-OSStatus CApplication::DoHandleCommand(MenuCommand command)
-{
- OSStatus err = noErr;
-
- if (command == 'Abut')
- {
- this->DoAbout();
- }
- else if (command == 'Save')
- {
- save_game(false);
- }
- else if (command >= 'Size' && command <= 'Size'+128)
- {
- int size = command - 'Size';
-
- this->SetFontSize(size);
- }
- else if (command >= 'Font' && command <= 'Font'+128)
- {
- int index = command - 'Font';
-
- Str255 name;
- GetMenuItemText(mFontMenu, index, name);
-
- this->SetFont(name);
- }
- else if (command == kHICommandQuit)
- {
- this->Quit();
- }
- else
- err = eventNotHandledErr;
-
- return err;
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoInitMenus
-//
-//---------------------------------------------------------------
-void CApplication::DoInitMenus()
-{
- const int kFileMenu = 257;
- const int kFontMenu = 258;
- const int kSizeMenu = 259;
-
- // add the About menu item
- MenuRef menuH = NewMenu(0, "\p");
-
- OSStatus err = InsertMenuItemTextWithCFString(menuH, MacString("About Crawl"), 0, kMenuItemAttrIgnoreMeta, 'Abut');
- ThrowIfOSErr(err, "Couldn't add the about menu item!");
-
- InsertMenu(menuH, 0);
-
- // create the File menu
- err = CreateNewMenu(kFileMenu, kMenuAttrAutoDisable, &menuH);
- ThrowIfOSErr(err, "Couldn't create the file menu!");
-
- err = SetMenuTitleWithCFString(menuH, MacString("File"));
- ThrowIfOSErr(err, "Couldn't set the file menu name!");
-
- InsertMenu(menuH, 0);
-
- // add the File menu items
- err = AppendMenuItemTextWithCFString(menuH, MacString("Save"), kMenuItemAttrIgnoreMeta, 'Save', NULL);
- ThrowIfOSErr(err, "Couldn't add the save menu item!");
-
- err = SetMenuItemCommandKey(menuH, 1, false, 'S');
- ThrowIfOSErr(err, "Couldn't set the save menu item's command key!");
-
- // create the Font menu
- err = CreateNewMenu(kFontMenu, kMenuAttrAutoDisable, &mFontMenu);
- ThrowIfOSErr(err, "Couldn't create the font menu!");
-
- err = CreateStandardFontMenu(mFontMenu, 0, 0, kNilOptions, &mNumFonts);
- ThrowIfOSErr(err, "Couldn't initialize the font menu!");
-
- err = SetMenuTitleWithCFString(mFontMenu, MacString("Font"));
- ThrowIfOSErr(err, "Couldn't set the font menu name!");
-
- UInt16 numItems = CountMenuItems(mFontMenu);
- for (UInt16 index = 1; index <= numItems; ++index)
- {
- // set the font for each menu item so we're WYSIWYG
- Str255 fontName;
- GetMenuItemText(mFontMenu, index, fontName);
-
- short fontNum;
- GetFNum(fontName, &fontNum);
-
- SetMenuItemFontID(mFontMenu, index, fontNum);
-
- // set the command id so we can process the items (CreateStandardFontMenu
- // leaves all of these at 0)
- err = SetMenuItemCommandID(mFontMenu, index, 'Font' + index);
- ThrowIfOSErr(err, "Couldn't set the font menu item's command ids!");
- }
-
- InsertMenu(mFontMenu, 0);
-
- // create the Size menu
- err = CreateNewMenu(kSizeMenu, kMenuAttrAutoDisable, &menuH);
- ThrowIfOSErr(err, "Couldn't create the size menu!");
-
- err = SetMenuTitleWithCFString(menuH, MacString("Size"));
- ThrowIfOSErr(err, "Couldn't set the size menu name!");
-
- InsertMenu(menuH, 0);
-
- // add the Size menu items
- const char* items[] = {"9", "10", "12", "16", "18", "20", "32", "48", "64", NULL};
- int sizes[] = {9, 10, 12, 16, 18, 20, 32, 48, 64};
- for (int i = 0; items[i] != NULL; ++i)
- {
- err = AppendMenuItemTextWithCFString(menuH, MacString(items[i]), kMenuItemAttrIgnoreMeta, 'Size' + sizes[i], NULL);
- ThrowIfOSErr(err, "Couldn't add a size menu item!");
- }
-
- // install a custom menu handler
- std::vector<EventTypeSpec> specs;
- specs.push_back(CreateSpec(kEventClassCommand, kEventCommandProcess));
- specs.push_back(CreateSpec(kEventClassCommand, kEventCommandUpdateStatus));
- specs.push_back(CreateSpec(kEventClassMenu, kEventMenuOpening));
-
- err = InstallApplicationEventHandler(NewEventHandlerUPP(DoMenuEvent), specs.size(), &specs[0], this, NULL);
- ThrowIfOSErr(err, "Couldn't install the menu handlers!");
-
- // draw the new menubar
- DrawMenuBar();
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoInitWindows
-//
-//---------------------------------------------------------------
-void CApplication::DoInitWindows()
-{
- // create the window
- Rect bounds = {32, 32, 64, 64}; // we position properly later
-
- WindowAttributes attrs = kWindowCollapseBoxAttribute | kWindowStandardHandlerAttribute;
- OSStatus err = CreateNewWindow(kDocumentWindowClass, attrs, &bounds, &mWindow);
- ThrowIfOSErr(err, "Couldn't create the window!");
-
- // install a custom window handler
- std::vector<EventTypeSpec> specs;
- specs.push_back(CreateSpec(kEventClassWindow, kEventWindowDrawContent));
-
- err = InstallWindowEventHandler(mWindow, NewEventHandlerUPP(DoWindowEvent), specs.size(), &specs[0], this, NULL);
- ThrowIfOSErr(err, "Couldn't install the window event handler!");
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoKeyDown [static]
-//
-//---------------------------------------------------------------
-pascal OSStatus CApplication::DoKeyDown(EventHandlerCallRef handler, EventRef event, void* refCon)
-{
- OSStatus err = eventNotHandledErr;
-
- if (!sInDialog)
- {
- CApplication* thisPtr = static_cast<CApplication*>(refCon);
-
- try
- {
- char ch;
- (void) GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(ch), NULL, &ch);
-
- UInt32 key;
- (void) GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(key), NULL, &key);
-
- UInt32 modifiers;
- (void) GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifiers), NULL, &modifiers);
-
- if ((modifiers & cmdKey) == 0)
- thisPtr->mChar = thisPtr->DoMungeChar(ch, key, modifiers);
-
- if (thisPtr->mChar != 0)
- QuitApplicationEventLoop();
-
- err = noErr;
- }
- catch (const std::exception& e)
- {
- DEBUGSTR((std::string("Couldn't complete the operation (") + e.what() + ").").c_str());
- err = eventNotHandledErr;
- }
- catch (...)
- {
- DEBUGSTR("Couldn't complete the operation.");
- err = eventNotHandledErr;
- }
- }
-
- return err;
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoMenuEvent [static]
-//
-//---------------------------------------------------------------
-pascal OSStatus CApplication::DoMenuEvent(EventHandlerCallRef handler, EventRef event, void* refCon)
-{
- OSStatus err = noErr;
- CApplication* thisPtr = static_cast<CApplication*>(refCon);
-
- UInt32 kind = GetEventKind(event);
- try
- {
- HICommand command;
-
- if (kind == kEventCommandUpdateStatus)
- {
- err = GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(command), NULL, &command);
- ThrowIfOSErr(err, "Couldn't get the direct object in DoMenuEvent");
-
- err = thisPtr->DoEnableCommand(command.menu.menuRef, command.commandID, command.menu.menuItemIndex);
- }
- else if (kind == kEventCommandProcess)
- {
- err = GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(command), NULL, &command);
- ThrowIfOSErr(err, "Couldn't get the direct object in DoMenuEvent");
-
- err = thisPtr->DoHandleCommand(command.commandID);
- }
- else if (kind == kEventMenuOpening)
- {
- Boolean firstTime;
- err = GetEventParameter(event, kEventParamMenuFirstOpen, typeBoolean, NULL, sizeof(firstTime), NULL, &firstTime);
- ThrowIfOSErr(err, "Couldn't get the first open flag in DoMenuEvent");
-
- if (firstTime) // only call the callbacks the first time we open the menu (during this drag)
- {
- MenuRef menuH;
- err = GetEventParameter(event, kEventParamDirectObject, typeMenuRef, NULL, sizeof(MenuRef), NULL, &menuH);
- ThrowIfOSErr(err, "Couldn't get the direct object in DoMenuEvent");
-
- err = thisPtr->DoOpenMenu(menuH);
- }
- }
- else
- err = eventNotHandledErr;
- }
- catch (const std::exception& e)
- {
- DEBUGSTR((std::string("Couldn't complete the operation (") + e.what() + ").").c_str());
- err = eventNotHandledErr;
- }
- catch (...)
- {
- DEBUGSTR("Couldn't complete the operation.");
- err = eventNotHandledErr;
- }
-
- if (kind == kEventCommandProcess)
- HiliteMenu(0);
-
- return err;
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoMungeChar
-//
-//---------------------------------------------------------------
-char CApplication::DoMungeChar(char ch, UInt32 key, UInt32 modifiers) const
-{
- switch (key) {
- case kNumPad1Key:
- if (modifiers & shiftKey)
- ch = 'B';
- else if (modifiers & controlKey)
- ch = 2;
- else
- ch = 'b';
- break;
-
- case kNumPad2Key:
- case kDownArrowKey:
- if (modifiers & shiftKey)
- ch = 'J';
- else if (modifiers & controlKey)
- ch = 10;
- else
- ch = 'j';
- break;
-
- case kNumPad3Key:
- if (modifiers & shiftKey)
- ch = 'N';
- else if (modifiers & controlKey)
- ch = 14;
- else
- ch = 'n';
- break;
-
- case kNumPad4Key:
- case kLeftArrowKey:
- if (modifiers & shiftKey)
- ch = 'H';
- else if (modifiers & controlKey)
- ch = 8;
- else
- ch = 'h';
- break;
-
- case kNumPad5Key:
- if (modifiers & shiftKey)
- ch = '5';
- else
- ch = '.';
- break;
-
- case kNumPad6Key:
- case kRightArrowKey:
- if (modifiers & shiftKey)
- ch = 'L';
- else if (modifiers & controlKey)
- ch = 12;
- else
- ch = 'l';
- break;
-
- case kNumPad7Key:
- if (modifiers & shiftKey)
- ch = 'Y';
- else if (modifiers & controlKey)
- ch = 25;
- else
- ch = 'y';
- break;
-
- case kNumPad8Key:
- case kUpArrowKey:
- if (modifiers & shiftKey)
- ch = 'K';
- else if (modifiers & controlKey)
- ch = 11;
- else
- ch = 'k';
- break;
-
- case kNumPad9Key:
- if (modifiers & shiftKey)
- ch = 'U';
- else if (modifiers & controlKey)
- ch = 21;
- else
- ch = 'u';
- break;
- }
-
- return ch;
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoOpenMenu
-//
-//---------------------------------------------------------------
-OSStatus CApplication::DoOpenMenu(MenuRef menuH)
-{
- // select the curret font
-
- return noErr;
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoQuit [static]
-//
-//---------------------------------------------------------------
-pascal OSErr CApplication::DoQuit(const AppleEvent* event, AppleEvent* reply, SInt32 refCon)
-{
- CApplication* thisPtr = reinterpret_cast<CApplication*>(refCon);
- thisPtr->Quit();
-
- return noErr;
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoReadPrefs
-//
-//---------------------------------------------------------------
-void CApplication::DoReadPrefs()
-{
- MacString appID("Crawl4");
-
- // window location
- Rect bounds;
-
- MacString name("window_x");
- Boolean existsX = false;
- bounds.left = CFPreferencesGetAppIntegerValue(name, appID, &existsX);
-
- name = MacString("window_y");
- Boolean existsY = false;
- bounds.top = CFPreferencesGetAppIntegerValue(name, appID, &existsY);
-
- if (existsX && existsY)
- {
- bounds.right = bounds.left + 32; // DoSetFont will reset the window dimensions
- bounds.bottom = bounds.top + 32;
-
- OSStatus err = SetWindowBounds(mWindow, kWindowStructureRgn, &bounds);
- ASSERT(err == noErr);
- }
- else
- {
- OSStatus err = RepositionWindow(mWindow, NULL, kWindowCenterOnMainScreen);
- ASSERT(err == noErr);
- }
-
- // mFontName
- name = MacString("font_name");
-
- CFTypeRef dataRef = CFPreferencesCopyAppValue(name, appID);
- if (dataRef != NULL && CFGetTypeID(dataRef) == CFStringGetTypeID())
- {
- MacString data(static_cast<CFStringRef>(dataRef));
-
- Str255 fontName;
- data.CopyTo(fontName, sizeof(fontName));
- CFRelease(dataRef);
-
- // mPointSize
- name = MacString("font_size");
- CFIndex fontSize = CFPreferencesGetAppIntegerValue(name, appID, NULL);
- if (fontSize > 0)
- this->DoSetFont(fontName, fontSize);
- else
- this->DoSetFont(fontName, 12);
- }
- else
- this->DoSetFont("\pMonaco", 12);
-
- // make sure the window isn't off-screen
- Rect area;
- OSStatus err = GetWindowGreatestAreaDevice(mWindow, kWindowStructureRgn, NULL, &area);
- if (err == noErr)
- {
- err = GetWindowBounds(mWindow, kWindowDragRgn, &bounds);
- if (err == noErr)
- {
- SectRect(&area, &bounds, &bounds);
-
- int pixels = (bounds.right - bounds.left)*(bounds.bottom - bounds.top);
- if (pixels < 64) // only move the window if there are fewer than 64 draggable pixels
- {
- err = ConstrainWindowToScreen(mWindow, kWindowStructureRgn, kWindowConstrainStandardOptions, NULL, NULL);
- ASSERT(err == noErr);
- }
- }
- }
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoRender
-//
-//---------------------------------------------------------------
-void CApplication::DoRender()
-{
- ASSERT(mLines.size() == kTermHeight);
-
- SetPortWindowPort(mWindow);
-
- TextFont(mFontNum);
- TextSize(mPointSize);
-
- RGBBackColor(&mBackColor);
- EraseRect(&kBigRect);
-
- Rect area;
- for (int y = 0; y < mLines.size(); ++y)
- {
- area.top = y*mCellHeight;
- area.bottom = area.top + mCellHeight;
- area.left = 0;
- area.right = area.left + mCellWidth;
-
- const Line& line = mLines[y];
- ASSERT(line.size() == kTermWidth);
-
- for (int x = 0; x < line.size(); ++x)
- {
- const SCell& cell = line[x];
-
- this->DoDrawCell(area, cell);
-
- if (x == mCursor.h && y == mCursor.v && mShowCursor)
- {
- ::RGBForeColor(&kWhite);
- ::MoveTo(area.left + 1, area.top + mAscent);
- ::Line(area.right - area.left - 2, 0);
- }
-
- area.left += mCellWidth;
- area.right += mCellWidth;
- }
- }
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoSetChar
-//
-//---------------------------------------------------------------
-void CApplication::DoSetChar(unsigned char ch)
-{
- ASSERT(mCursor.h < kTermWidth);
- ASSERT(mCursor.v < kTermHeight);
- ASSERT(mCursor.h >= 0);
- ASSERT(mCursor.v >= 0);
-
- int x = mCursor.h;
-
- Line& line = mLines[mCursor.v];
- ASSERT(line.size() == kTermWidth);
-
- SCell& cell = line[x++];
- cell.ch = ch;
- cell.color = mForeColor;
-
- Rect area;
- area.top = mCursor.v * mCellHeight;
- area.bottom = area.top + mCellHeight;
- area.left = mCursor.h * mCellWidth;
- area.right = area.left + mCellWidth;
-
- (void) InvalWindowRect(mWindow, &kBigRect);
-
- if (x >= kTermWidth)
- {
- if (++mCursor.v >= kTermHeight)
- {
- mCursor.v = kTermHeight - 1;
- mCursor.h = kTermWidth - 1;
- this->DoScroll();
- }
- x = 0;
- }
-
- mCursor.h = x;
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoScroll
-//
-//---------------------------------------------------------------
-void CApplication::DoScroll()
-{
- mLines.erase(mLines.begin());
-
- mLines.push_back(Line());
- mLines.back().resize(kTermWidth);
-
- (void) InvalWindowRect(mWindow, &kBigRect);
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoSetFont
-//
-//---------------------------------------------------------------
-void CApplication::DoSetFont(const unsigned char* name, int size)
-{
- ASSERT(name != NULL);
- ASSERT(size > 0);
-
- short fontNum;
- GetFNum(name, &fontNum);
-
- if (fontNum != mFontNum || size != mPointSize)
- {
- BlockMoveData(name, mFontName, name[0] + 1);
-
- mFontNum = fontNum;
- mPointSize = size;
-
- SetPortWindowPort(mWindow);
- TextFont(mFontNum);
- TextSize(mPointSize);
-
- FontInfo info;
- GetFontInfo(&info);
-
- mCellHeight = info.ascent + info.descent;
- mAscent = info.ascent;
-
- short width = StringWidth("\pMMMMM"); // widMax is usually much too wide so we'll compute this ourselves...
- mCellWidth = width/5 + 1;
-
- Rect bounds;
- bounds.top = 0;
- bounds.left = 0;
- bounds.bottom = mCellHeight * kTermHeight;
- bounds.right = mCellWidth * kTermWidth;
- SizeWindow(mWindow, bounds.right, bounds.bottom, false);
-
- (void) InvalWindowRect(mWindow, &kBigRect);
- }
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoWindowEvent [static]
-//
-//---------------------------------------------------------------
-pascal OSStatus CApplication::DoWindowEvent(EventHandlerCallRef handler, EventRef event, void* refCon)
-{
- OSStatus err = noErr;
- CApplication* thisPtr = static_cast<CApplication*>(refCon);
-
- try
- {
- WindowRef window = NULL;
- (void) GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(window), NULL, &window);
- ASSERT(window == thisPtr->mWindow);
-
- UInt32 kind = GetEventKind(event);
- switch (kind) {
-// case kEventWindowBoundsChanging:
-// thisPtr->DoConstrainWindow(event);
-// break;
-
- case kEventWindowDrawContent:
- thisPtr->DoRender();
- break;
-
-// case kEventWindowGetIdealSize:
-// case kEventWindowGetMaximumSize:
-// {
-// ::Point maxSize = thisPtr->OnGetMaxSize();
-// SetEventParameter(event, kEventParamDimensions, &maxSize);
-// }
-// break;
-
-// case kEventWindowGetMinimumSize:
-// {
-// ::Point minSize = thisPtr->OnGetMinSize();
-// SetEventParameter(event, kEventParamDimensions, &minSize);
-// }
-// break;
-
- default:
- err = eventNotHandledErr;
- }
- }
- catch (const std::exception& e)
- {
- DEBUGSTR((std::string("Couldn't complete the operation (") + e.what() + ").").c_str());
- err = eventNotHandledErr;
- }
- catch (...)
- {
- DEBUGSTR("Couldn't complete the operation.");
- err = eventNotHandledErr;
- }
-
- return err;
-}
-
-
-//---------------------------------------------------------------
-//
-// CApplication::DoWritePrefs , , mWindow->location
-//
-//---------------------------------------------------------------
-void CApplication::DoWritePrefs()
-{
- MacString appID("Crawl4");
-
- // mFontName
- MacString name("font_name");
- MacString data(mFontName);
- CFPreferencesSetAppValue(name, data, appID);
-
- // mPointSize
- name = MacString("font_size");
- data = MacString(mPointSize);
- CFPreferencesSetAppValue(name, data, appID);
-
- // window location
- Rect bounds;
- OSStatus err = GetWindowBounds(mWindow, kWindowStructureRgn, &bounds);
- if (err == noErr)
- {
- name = MacString("window_x");
- data = MacString(bounds.left);
- CFPreferencesSetAppValue(name, data, appID);
-
- name = MacString("window_y");
- data = MacString(bounds.top);
- CFPreferencesSetAppValue(name, data, appID);
- }
-
- // flush
- VERIFY(CFPreferencesAppSynchronize(appID));
-}
-
-#if __MWERKS__
-#pragma mark -
-#endif
-
-// ========================================================================
-// Non-ANSI Functions
-// ========================================================================
-
-//---------------------------------------------------------------
-//
-// stricmp
-//
-// Case insensitive string comparison (code is from MSL which
-// is why it looks so dorky).
-//
-//---------------------------------------------------------------
-int stricmp(const char* lhs, const char* rhs)
-{
- ASSERT(lhs != NULL);
- ASSERT(rhs != NULL);
-
- const unsigned char* p1 = (unsigned char*) lhs - 1;
- const unsigned char* p2 = (unsigned char*) rhs - 1;
- unsigned long c1, c2;
-
- while ((c1 = tolower(*++p1)) == (c2 = tolower(*++p2)))
- if (c1 == '\0')
- return (0);
-
- return c1 - c2;
-}
-
-
-//---------------------------------------------------------------
-//
-// strlwr
-//
-// In place conversion to lower case.
-//
-//---------------------------------------------------------------
-char* strlwr(char* str)
-{
- ASSERT(str != NULL);
-
- for (int i = 0; i < strlen(str); ++i)
- str[i] = tolower(str[i]);
-
- return str;
-}
-
-
-//---------------------------------------------------------------
-//
-// itoa
-//
-// Converts an integer to a string (after libunix.cc).
-//
-//---------------------------------------------------------------
-void itoa(int value, char* buffer, int radix)
-{
- ASSERT(buffer != NULL);
- ASSERT(radix == 10 || radix == 2);
-
- if (radix == 10)
- sprintf(buffer, "%i", value);
-
- if (radix == 2)
- { /* int to "binary string" */
- unsigned int bitmask = 32768;
- int ctr = 0;
- int startflag = 0;
-
- while (bitmask)
- {
- if (value & bitmask)
- {
- startflag = 1;
- sprintf(buffer + ctr, "1");
-
- }
- else
- {
- if (startflag)
- sprintf(buffer + ctr, "0");
- }
-
- bitmask = bitmask >> 1;
- if (startflag)
- ctr++;
- }
-
- if (!startflag) /* Special case if value == 0 */
- sprintf((buffer + ctr++), "0");
- buffer[ctr] = (char) NULL;
- }
-}
-
-#if __MWERKS__
-#pragma mark -
-#endif
-
-// ========================================================================
-// Curses(?) Functions
-// ========================================================================
-
-//---------------------------------------------------------------
-//
-// window
-//
-//---------------------------------------------------------------
-void window(int x, int y, int lx, int ly)
-{
- ASSERT(lx == kTermWidth); // window size is hard-coded
- ASSERT(ly == kTermHeight);
-
- gotoxy(x, y);
-}
-
-
-//---------------------------------------------------------------
-//
-// clrscr
-//
-//---------------------------------------------------------------
-void clrscr()
-{
- ASSERT(sApp != NULL);
-
- sApp->Clear();
-}
-
-
-//---------------------------------------------------------------
-//
-// textcolor
-//
-//---------------------------------------------------------------
-void textcolor(int c)
-{
- ASSERT(c >= 0);
- ASSERT(c < 16);
- ASSERT(sApp != NULL);
-
- RGBColor color = ConvertColor(c);
- sApp->SetForeColor(color);
-}
-
-
-//---------------------------------------------------------------
-//
-// textbackground
-//
-//---------------------------------------------------------------
-void textbackground(int c)
-{
- ASSERT(c >= 0);
- ASSERT(c < 16);
- ASSERT(sApp != NULL);
-
- RGBColor color = ConvertColor(c);
- sApp->SetBackColor(color);
-}
-
-
-//---------------------------------------------------------------
-//
-// gotoxy
-//
-//---------------------------------------------------------------
-void gotoxy(int x, int y)
-{
- ASSERT(x >= 1);
- ASSERT(y >= 1);
- ASSERT(sApp != NULL);
-
- sApp->SetCursor(x - 1, y - 1);
-}
-
-
-//---------------------------------------------------------------
-//
-// wherex
-//
-//---------------------------------------------------------------
-int wherex()
-{
- ASSERT(sApp != NULL);
-
- Point pos = sApp->GetCursor();
-
- return pos.h + 1;
-}
-
-
-//---------------------------------------------------------------
-//
-// wherey
-//
-//---------------------------------------------------------------
-int wherey()
-{
- ASSERT(sApp != NULL);
-
- Point pos = sApp->GetCursor();
-
- return pos.v + 1;
-}
-
-
-//---------------------------------------------------------------
-//
-// putch
-//
-//---------------------------------------------------------------
-void putch(char ch)
-{
- ASSERT(sApp != NULL);
-
- char buffer[2];
-
- buffer[0] = ch;
- buffer[1] = '\0';
-
- sApp->SetChar(ch);
-// sApp->Print(buffer);
-}
-
-
-//---------------------------------------------------------------
-//
-// cprintf
-//
-//---------------------------------------------------------------
-void cprintf(const char* format,...)
-{
- ASSERT(sApp != NULL);
-
- char buffer[2048];
-
- va_list argp;
-
- va_start(argp, format);
- vsprintf(buffer, format, argp);
- va_end(argp);
-
- sApp->Print(buffer);
-}
-
-
-//---------------------------------------------------------------
-//
-// kbhit
-//
-//---------------------------------------------------------------
-int kbhit()
-{
- return sApp->PeekChar();
-}
-
-
-//---------------------------------------------------------------
-//
-// getche
-//
-//---------------------------------------------------------------
-char getche()
-{
- char ch = getch();
-
- if (ch != '\r')
- putch(ch);
-
- return ch;
-}
-
-
-//---------------------------------------------------------------
-//
-// getstr
-//
-//---------------------------------------------------------------
-void getstr(char* buffer, int bufferSize)
-{
- ASSERT(buffer != NULL);
- ASSERT(bufferSize > 1);
-
- int index = 0;
-
- while (index < bufferSize - 1)
- {
- char ch = getche();
-
- if (ch == '\r')
- break;
- else if (ch == '\b' && index > 0)
- --index;
- else if (isprint(ch))
- buffer[index++] = ch;
- }
-
- buffer[index] = '\0';
-}
-
-
-//---------------------------------------------------------------
-//
-// _setcursortype
-//
-//---------------------------------------------------------------
-void _setcursortype(int curstype)
-{
- ASSERT(curstype == _NORMALCURSOR || curstype == _NOCURSOR);
- ASSERT(sApp != NULL);
-
- sApp->ShowCursor(curstype == _NORMALCURSOR);
-}
-
-
-//---------------------------------------------------------------
-//
-// getch
-//
-//---------------------------------------------------------------
-int getch()
-{
- ASSERT(sApp != NULL);
-
- return sApp->GetChar();
-}
-
-#if __MWERKS__
-#pragma mark -
-#endif
-
-// ========================================================================
-// Misc Functions
-// ========================================================================
-
-//---------------------------------------------------------------
-//
-// delay
-//
-//---------------------------------------------------------------
-void delay(int ms)
-{
- ASSERT(ms >= 0);
-
- usleep(1000*ms);
-}
-
-
-//---------------------------------------------------------------
-//
-// init_mac
-//
-//---------------------------------------------------------------
-void init_mac()
-{
- ASSERT(sApp == NULL);
-
- // Read in the color table
- sColors = GetCTable(256);
- if (sColors == NULL)
- {
- WarnUser("Couldn't load the colour table!");
- ExitToShell();
- }
-
- // Create the application object
- sApp = new CApplication;
-}
-
-
-//---------------------------------------------------------------
-//
-// deinit_mac
-//
-//---------------------------------------------------------------
-void deinit_mac()
-{
- delete sApp;
- sApp = NULL;
-}
-
-
-#endif // macintosh
diff --git a/crawl-ref/source/libmac.h b/crawl-ref/source/libmac.h
deleted file mode 100644
index 8b7e3903d6..0000000000
--- a/crawl-ref/source/libmac.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * File: libmac.h
- * Summary: Mac specific routines used by Crawl.
- * Written by: Jesse Jones
- *
- * Change History (most recent first):
- *
- * <2> 5/25/02 JDJ Updated for Mach-O targets
- * <1> 3/23/99 JDJ Created
- */
-
-#ifndef LIBMAC_H
-#define LIBMAC_H
-
-#if macintosh
-
-#ifdef _BSD_SIZE_T_ // $$$ is there a better way to test for OS X?
- #define OSX 1
-#else
- #define OS9 1
-#endif
-
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if OSX
- #include <unistd.h>
-#endif
-
-#define MAC_NUMBER_OF_LINES 30
-
-// constants
-const int _NORMALCURSOR = 1;
-const int _NOCURSOR = 0;
-
-
-// non-ANSI functions
-int stricmp(const char* lhs, const char* rhs);
-char* strlwr(char* str);
-void itoa(int n, char* buffer, int radix);
-
-#if !OSX
- inline void srandom(unsigned int seed)
- {
- srand(seed);
- }
-
- int open(const char* path, int openFlags, int permissions);
- int open(const char* path, int openFlags, int permissions, int mysteryFlags);
- int close(int desc);
- int read(int desc, void *buffer, unsigned int bytes);
- int write(int desc, const void *buffer, unsigned int bytes);
- int unlink(const char* path);
-#endif
-
-
-// curses(?) functions
-void clrscr();
-void gotoxy(int x, int y);
-void textcolor(int c);
-void cprintf(const char* format,...);
-
-void window(int x, int y, int lx, int ly);
-int wherex();
-int wherey();
-void putch(char c);
-int kbhit();
-
-char getche();
-int getch();
-void getstr(char* buffer, int bufferSize);
-
-void textbackground(int c);
-void _setcursortype(int curstype);
-
-
-// misc functions
-void delay(int ms);
-
-void init_mac();
-void deinit_mac();
-
-
-#endif // macintosh
-#endif // LIBMAC_H
diff --git a/crawl-ref/source/libutil.cc b/crawl-ref/source/libutil.cc
index 7a3a9db7e5..b4ec7ab2fa 100644
--- a/crawl-ref/source/libutil.cc
+++ b/crawl-ref/source/libutil.cc
@@ -75,8 +75,8 @@ void get_input_line( char *const buff, int len )
#if defined(UNIX)
get_input_line_from_curses( buff, len ); // implemented in libunix.cc
-#elif defined(MAC) || defined(WIN32CONSOLE)
- getstr( buff, len ); // implemented in libmac.cc
+#elif defined(WIN32CONSOLE)
+ getstr( buff, len );
#else
fgets( buff, len, stdin ); // much safer than gets()
#endif
diff --git a/crawl-ref/source/machdr.h b/crawl-ref/source/machdr.h
deleted file mode 100644
index 5bad24eab7..0000000000
--- a/crawl-ref/source/machdr.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * File: MacHdr.h
- * Summary: OS specific stuff for inclusion into AppHdr.h.
- * Written by: Jesse Jones
- *
- * Copyright 1999 Jesse Jones.
- *
- * Change History (most recent first):
- *
- * <1> 5/30/99 JDJ Created.
- */
-#ifndef MACHDR_H
-#define MACHDR_H
-
-#pragma check_header_flags on
-
-
-// ===================================================================================
-// MSL Defines
-// ===================================================================================
-#include <ansi_parms.h>
-
-#ifndef __dest_os
-#define __dest_os __mac_os
-#endif
-
-#ifndef __MSL_LONGLONG_SUPPORT__
-#define __MSL_LONGLONG_SUPPORT__
-#endif
-
-#ifndef MSIPL_DEF_EXPLICIT
-#define MSIPL_DEF_EXPLICIT // prevent explicit from being defined away
-#endif
-
-#if __MWERKS__ >= 0x2000
-#define MSIPL_TEMPL_NEWSPEC 1 // enable null_template
-#endif
-
-
-// ===================================================================================
-// Universal headers
-// ===================================================================================
-#define OLDROUTINENAMES 0
-#define OLDROUTINELOCATIONS 0
-
-#define STRICT_WINDOWS 0
-#define STRICT_CONTROLS 0
-#define STRICT_LISTS 0
-#define STRICT_MENUS 0
-
-#define USE_OLD_INPUT_SPROCKET_LABELS 0
-#define USE_OLD_ISPNEED_STRUCT 0
-
-#if 1
-// #include <ADSP.h>
-// #include <AEObjects.h>
-// #include <AEPackObject.h>
-// #include <AERegistry.h>
-// #include <AEUserTermTypes.h>
-// #include <AIFF.h>
-#include <Aliases.h>
-#include <AppleEvents.h>
-// #include <AppleGuide.h>
-// #include <AppleScript.h>
-// #include <AppleTalk.h>
-// #include <ASDebugging.h>
-// #include <ASRegistry.h>
-#include <Balloons.h>
-// #include <CMApplication.h>
-// #include <CMComponent.h>
-// #include <CodeFragments.h>
-#include <ColorPicker.h>
-// #include <CommResources.h>
-// #include <Components.h>
-#include <ConditionalMacros.h>
-// #include <Connections.h>
-// #include <ConnectionTools.h>
-#include <Controls.h>
-// #include <ControlStrip.h>
-// #include <CRMSerialDevices.h>
-// #include <CTBUtilities.h>
-// #include <CursorCtl.h>
-// #include <CursorDevices.h>
-// #include <DatabaseAccess.h>
-// #include <DeskBus.h>
-#include <Devices.h>
-#include <Dialogs.h>
-// #include <Dictionary.h>
-// #include <DisAsmLookup.h>
-// #include <Disassembler.h>
-#include <DiskInit.h>
-// #include <Disks.h>
-#include <Displays.h>
-#include <Drag.h>
-// #include <Editions.h>
-// #include <ENET.h>
-// #include <EPPC.h>
-// #include <ErrMgr.h>
-#include <Errors.h>
-#include <Events.h>
-// #include <fenv.h>
-#include <Files.h>
-// #include <FileTransfers.h>
-// #include <FileTransferTools.h>
-// #include <FileTypesAndCreators.h>
-#include <Finder.h>
-// #include <FixMath.h>
-#include <Folders.h>
-#include <Fonts.h>
-// #include <fp.h>
-// #include <FragLoad.h>
-// #include <FSM.h>
-#include <Gestalt.h>
-// #include <HyperXCmd.h>
-// #include <Icons.h>
-// #include <ImageCodec.h>
-// #include <ImageCompression.h>
-// #include <IntlResources.h>
-// #include <Language.h>
-// #include <Lists.h>
-#include <LowMem.h>
-// #include <MachineExceptions.h>
-// #include <MacTCP.h>
-// #include <MediaHandlers.h>
-#include <Memory.h>
-#include <Menus.h>
-// #include <MIDI.h>
-#include <MixedMode.h>
-// #include <Movies.h>
-// #include <MoviesFormat.h>
-// #include <Notification.h>
-// #include <OSA.h>
-// #include <OSAComp.h>
-// #include <OSAGeneric.h>
-#include <OSUtils.h>
-#include <Packages.h>
-#include <Palettes.h>
-// #include <PictUtil.h>
-// #include <PictUtils.h>
-#include <PLStringFuncs.h>
-// #include <Power.h>
-// #include <PPCToolbox.h>
-#include <Printing.h>
-#include <Processes.h>
-#include <QDOffscreen.h>
-#include <Quickdraw.h>
-#include <QuickdrawText.h>
-// #include <QuickTimeComponents.h>
-#include <Resources.h>
-// #include <Retrace.h>
-// #include <ROMDefs.h>
-#include <Scrap.h>
-// #include <Script.h>
-// #include <SCSI.h>
-#include <SegLoad.h>
-// #include <Serial.h>
-// #include <ShutDown.h>
-// #include <Slots.h>
-// #include <Sound.h>
-// #include <SoundComponents.h>
-// #include <SoundInput.h>
-// #include <Speech.h>
-#include <StandardFile.h>
-// #include <Start.h>
-#include <Strings.h>
-// #include <Terminals.h>
-// #include <TerminalTools.h>
-#include <TextEdit.h>
-// #include <TextServices.h>
-#include <TextUtils.h>
-// #include <Threads.h>
-// #include <Timer.h>
-#include <ToolUtils.h>
-// #include <Translation.h>
-// #include <TranslationExtensions.h>
-#include <Traps.h>
-// #include <TSMTE.h>
-#include <Types.h>
-// #include <Unmangler.h>
-// #include <Video.h>
-#include <Windows.h>
-// #include <WorldScript.h>
-#endif // PRECOMPILE_SYSTEM_HEADERS
-
-#endif
diff --git a/crawl-ref/source/makefile.osx b/crawl-ref/source/makefile.osx
index 7cee7c3452..e9c16a9029 100644
--- a/crawl-ref/source/makefile.osx
+++ b/crawl-ref/source/makefile.osx
@@ -4,58 +4,35 @@
# Modified for Crawl Reference by $Author$ on $Date$
#
-GAME = crawl
-
-# this file contains a list of the libraries.
-# it will make a variable called OBJECTS that contains all the libraries
-include makefile.obj
-
-OBJECTS += libunix.o
-
-CXX = g++
-DELETE = rm -f
-COPY = cp
-OS_TYPE = OSX
-
-CFLAGS = -Wall -Werror -D$(OS_TYPE) $(EXTRA_FLAGS)
-
-MCHMOD = 711
-INSTALLDIR = /tmp/CRAWLTEST/testdev
-LIB = -lncurses -lstdc++
+PROJECT = Crawl.xcodeproj
+GAME = Crawl
all: $(GAME)
-install: $(GAME)
- $(COPY) $(GAME) ${INSTALLDIR}
- ${MCHMOD} ${INSTALLDIR}/$(GAME)
+# Xcode handles dependencies, so install does _not_ have to depend on building.
+install:
+ xcodebuild -project $(PROJECT) -target $(GAME) -configuration Release install
clean:
- $(DELETE) *.o
-
-distclean:
- $(DELETE) *.o
- $(DELETE) bones.*
- $(DELETE) morgue.txt
- $(DELETE) scores
- $(DELETE) $(GAME)
- $(DELETE) *.sav
- $(DELETE) core
- $(DELETE) *.0*
- $(DELETE) *.lab
-
-
-$(GAME): $(OBJECTS)
- ${CXX} ${LDFLAGS} $(INCLUDES) $(CFLAGS) $(OBJECTS) -o $(GAME) $(LIB)
-
-debug: $(OBJECTS)
- ${CXX} ${LDFLAGS} $(INCLUDES) $(CFLAGS) $(OBJECTS) -o $(GAME) $(LIB)
-
-profile: $(OBJECTS)
- ${CXX} -g -p ${LDFLAGS} $(INCLUDES) $(CFLAGS) $(OBJECTS) -o $(GAME) $(LIB)
-
-.cc.o:
- ${CXX} ${CFLAGS} $(INCLUDES) -c $< ${INCLUDE}
-
-.h.cc:
- touch $@
-
+ xcodebuild -project $(PROJECT) -target $(GAME) -configuration Release clean
+ xcodebuild -project $(PROJECT) -target $(GAME) -configuration Debug clean
+ xcodebuild -project $(PROJECT) -target $(GAME) -configuration Wizard clean
+
+distclean: clean
+ rm -f bones.*
+ rm -f morgue.txt
+ rm -f scores
+ rm -f $(GAME)
+ rm -f *.sav
+ rm -f core
+ rm -f *.0*
+ rm -f *.lab
+
+$(GAME):
+ xcodebuild -project $(PROJECT) -target $(GAME) -configuration Release build
+
+debug:
+ xcodebuild -project $(PROJECT) -target $(GAME) -configuration Debug build
+
+wizard:
+ xcodebuild -project $(PROJECT) -target $(GAME) -configuration Wizard build
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index fe504b8198..9fea70bfac 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -2143,14 +2143,6 @@ bool verifyPlayerName(void)
const size_t len = strlen( you.your_name );
for (unsigned int i = 0; i < len; i++)
{
-#if MAC
- // the only bad character on Macs is the path seperator
- if (you.your_name[i] == ':')
- {
- cprintf(EOL "No colons, please." EOL);
- return (false);
- }
-#else
// Note that this includes systems which may be using the
// packaging system. The packaging system is very simple
// and doesn't take the time to escape every characters that
@@ -2161,7 +2153,6 @@ bool verifyPlayerName(void)
cprintf( EOL "Alpha-numerics and underscores only, please." EOL );
return (false);
}
-#endif
}
#ifdef SAVE_DIR_PATH
diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc
index 5d2ef93188..0c43b16c7a 100644
--- a/crawl-ref/source/randart.cc
+++ b/crawl-ref/source/randart.cc
@@ -609,7 +609,7 @@ const char *rand_armour_names[] = {
not randart.h because they're only used in this code module.
*/
-#if defined(MAC) || defined(__IBMCPP__) || defined(__BCPLUSPLUS__)
+#if defined(__IBMCPP__) || defined(__BCPLUSPLUS__)
#define PACKED
#else
#ifndef PACKED
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index e15a2e66bc..0a8a95f2b2 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -466,10 +466,6 @@ void end(int end_arg)
unixcurses_shutdown();
#endif
-#ifdef MAC
- deinit_mac();
-#endif
-
#ifdef WIN32CONSOLE
deinit_libw32c();
#endif
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index e3e7564453..6d44d82b7d 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -105,8 +105,6 @@ int get_number_of_lines(void)
{
#ifdef UNIX
return (get_number_of_lines_from_curses());
-#elif MAC
- return (MAC_NUMBER_OF_LINES);
#else
return (25);
#endif