Map.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. #include "stdafx.h"
  13. #include "LCDDrawing.h"
  14. extern BOOL map_bIsFirstEncounter;
  15. static CTextureObject atoIconsSE[13];
  16. static CTextureObject atoIconsFE[15];
  17. static CTextureObject _toPathDot;
  18. static CTextureObject _toMapBcgLDFE;
  19. static CTextureObject _toMapBcgLUFE;
  20. static CTextureObject _toMapBcgRDFE;
  21. static CTextureObject _toMapBcgRUFE;
  22. static CTextureObject _toMapBcgLDSE;
  23. static CTextureObject _toMapBcgLUSE;
  24. static CTextureObject _toMapBcgRDSE;
  25. static CTextureObject _toMapBcgRUSE;
  26. PIX aIconCoordsSE[][2] =
  27. {
  28. {0, 0}, // 00: Last Episode
  29. {168, 351}, // 01: Palenque 01
  30. {42, 345}, // 02: Palenque 02
  31. {41, 263}, // 03: Teotihuacan 01
  32. {113, 300}, // 04: Teotihuacan 02
  33. {334, 328}, // 05: Teotihuacan 03
  34. {371, 187}, // 06: Ziggurat
  35. {265, 111}, // 07: Atrium
  36. {119, 172}, // 08: Gilgamesh
  37. {0, 145}, // 09: Babel
  38. {90, 30}, // 10: Citadel
  39. {171, 11}, // 11: Land of Damned
  40. {376, 0}, // 12: Cathedral
  41. };
  42. PIX aIconCoordsFE[][2] =
  43. {
  44. {175,404}, // 00: Hatshepsut
  45. {60,381}, // 01: Sand Canyon
  46. {50,300}, // 02: Ramses
  47. {171,304}, // 03: Canyon
  48. {190,225}, // 04: Waterfall
  49. {303,305}, // 05: Oasis
  50. {361,296}, // 06: Dunes
  51. {362,222}, // 07: Suburbs
  52. {321,211}, // 08: Sewers
  53. {316,156}, // 09: Metropolis
  54. {194,157}, // 10: Sphynx
  55. {160,111}, // 11: Karnak
  56. {167,61}, // 12: Luxor
  57. {50,53}, // 13: Sacred
  58. {185,0}, // 14: Pyramid
  59. };
  60. #define LASTEPISODE_BIT 0
  61. #define PALENQUE01_BIT 1
  62. #define PALENQUE02_BIT 2
  63. #define TEOTIHUACAN01_BIT 3
  64. #define TEOTIHUACAN02_BIT 4
  65. #define TEOTIHUACAN03_BIT 5
  66. #define ZIGGURAT_BIT 6
  67. #define ATRIUM_BIT 7
  68. #define GILGAMESH_BIT 8
  69. #define BABEL_BIT 9
  70. #define CITADEL_BIT 10
  71. #define LOD_BIT 11
  72. #define CATHEDRAL_BIT 12
  73. #define HATSHEPSUT_BIT 0
  74. #define SAND_BIT 1
  75. #define RAMSES_BIT 2
  76. #define CANYON_BIT 3
  77. #define WATERFALL_BIT 4
  78. #define OASIS_BIT 5
  79. #define DUNES_BIT 6
  80. #define SUBURBS_BIT 7
  81. #define SEWERS_BIT 8
  82. #define METROPOLIS_BIT 9
  83. #define SPHYNX_BIT 10
  84. #define KARNAK_BIT 11
  85. #define LUXOR_BIT 12
  86. #define SACRED_BIT 13
  87. #define PYRAMID_BIT 14
  88. INDEX aPathPrevNextLevelsSE[][2] =
  89. {
  90. {LASTEPISODE_BIT, PALENQUE01_BIT}, // 00
  91. {PALENQUE01_BIT, PALENQUE02_BIT}, // 01
  92. {PALENQUE02_BIT, TEOTIHUACAN01_BIT }, // 02
  93. {TEOTIHUACAN01_BIT, TEOTIHUACAN02_BIT}, // 03
  94. {TEOTIHUACAN02_BIT, TEOTIHUACAN03_BIT}, // 04
  95. {TEOTIHUACAN03_BIT, ZIGGURAT_BIT}, // 05
  96. {ZIGGURAT_BIT, ATRIUM_BIT}, // 06
  97. {ATRIUM_BIT, GILGAMESH_BIT}, // 07
  98. {GILGAMESH_BIT, BABEL_BIT}, // 08
  99. {BABEL_BIT, CITADEL_BIT}, // 09
  100. {CITADEL_BIT, LOD_BIT}, // 10
  101. {LOD_BIT, CATHEDRAL_BIT}, // 11
  102. };
  103. INDEX aPathPrevNextLevelsFE[][2] =
  104. {
  105. {HATSHEPSUT_BIT, SAND_BIT}, // 00
  106. {SAND_BIT, RAMSES_BIT}, // 01
  107. {RAMSES_BIT, CANYON_BIT}, // 02
  108. {CANYON_BIT, WATERFALL_BIT}, // 03
  109. {CANYON_BIT, OASIS_BIT}, // 04
  110. {WATERFALL_BIT, OASIS_BIT}, // 05
  111. {OASIS_BIT, DUNES_BIT}, // 06
  112. {DUNES_BIT, SUBURBS_BIT}, // 07
  113. {SUBURBS_BIT, SEWERS_BIT}, // 08
  114. {SEWERS_BIT, METROPOLIS_BIT}, // 09
  115. {METROPOLIS_BIT, SPHYNX_BIT}, // 10
  116. {SPHYNX_BIT, KARNAK_BIT}, // 11
  117. {KARNAK_BIT, LUXOR_BIT}, // 12
  118. {LUXOR_BIT, SACRED_BIT}, // 13
  119. {SACRED_BIT, PYRAMID_BIT}, // 14
  120. {LUXOR_BIT, PYRAMID_BIT}, // 15
  121. };
  122. PIX aPathDotsSE[][10][2] =
  123. {
  124. // 00: Palenque01 - Palenque02
  125. {
  126. {-1,-1},
  127. },
  128. // 01: Palenque01 - Palenque02
  129. {
  130. {211,440},
  131. {193,447},
  132. {175,444},
  133. {163,434},
  134. {152,423},
  135. {139,418},
  136. {-1,-1},
  137. },
  138. // 02: Palenque02 - Teotihuacan01
  139. {
  140. {100,372},
  141. {102,363},
  142. {108,354},
  143. {113,345},
  144. {106,338},
  145. {-1,-1},
  146. },
  147. // 03: Teotihuacan01 - Teotihuacan02
  148. {
  149. {153,337},
  150. {166,341},
  151. {180,346},
  152. {194,342},
  153. {207,337},
  154. {-1,-1},
  155. },
  156. // 04: Teotihuacan02 - Teotihuacan03
  157. {
  158. {279,339},
  159. {287,347},
  160. {296,352},
  161. {307,365},
  162. {321,367},
  163. {335,362},
  164. {-1,-1},
  165. },
  166. // 05: Teotihuacan03 - Ziggurat
  167. {
  168. {-1,-1},
  169. },
  170. // 06: Ziggurat - Atrium
  171. {
  172. {412,285},
  173. {396,282},
  174. {383,273},
  175. {368,266},
  176. {354,264},
  177. {-1,-1},
  178. },
  179. // 07: Atrium - Gilgamesh
  180. {
  181. {276,255},
  182. {262,258},
  183. {248,253},
  184. {235,245},
  185. {222,240},
  186. {-1,-1},
  187. },
  188. // 08: Gilgamesh - Babel
  189. {
  190. {152,245},
  191. {136,248},
  192. {118,253},
  193. {100,251},
  194. {85,246},
  195. {69,243},
  196. {-1,-1},
  197. },
  198. // 09: Babel - Citadel
  199. {
  200. {-1,-1},
  201. },
  202. // 10: Citadel - Lod
  203. {
  204. {190,130},
  205. {204,126},
  206. {215,119},
  207. {232,116},
  208. {241,107},
  209. {-1,-1},
  210. },
  211. // 11: Lod - Cathedral
  212. {
  213. {330,108},
  214. {341,117},
  215. {353,126},
  216. {364,136},
  217. {377,146},
  218. {395,147},
  219. {-1,-1},
  220. },
  221. };
  222. PIX aPathDotsFE[][10][2] =
  223. {
  224. // 00: Hatshepsut - Sand
  225. {
  226. {207,435},
  227. {196,440},
  228. {184,444},
  229. {172,443},
  230. {162,439},
  231. {156,432},
  232. {-1,-1},
  233. },
  234. // 01: Sand - Ramses
  235. {
  236. {115,388},
  237. {121,382},
  238. {128,377},
  239. {136,371},
  240. {-1,-1},
  241. },
  242. // 02: Ramses - Canyon
  243. {
  244. {148,368},
  245. {159,370},
  246. {169,374},
  247. {177,379},
  248. {187,381},
  249. {200,380},
  250. {211,376},
  251. {-1,-1},
  252. },
  253. // 03: Canyon - Waterfall
  254. {
  255. {273,339},
  256. {276,331},
  257. {278,322},
  258. {280,313},
  259. {279,305},
  260. {273,298},
  261. {266,293},
  262. {260,288},
  263. {-1,-1},
  264. },
  265. // 04: Canyon - Oasis
  266. {
  267. {288,360},
  268. {295,355},
  269. {302,360},
  270. {310,364},
  271. {319,367},
  272. {328,368},
  273. {-1,-1},
  274. },
  275. // 05: Waterfall - Oasis
  276. {
  277. {294,279},
  278. {302,282},
  279. {310,287},
  280. {316,294},
  281. {320,302},
  282. {323,310},
  283. {327,318},
  284. {332,326},
  285. {337,333},
  286. {-1,-1},
  287. },
  288. // 06: Oasis - Dunes
  289. {
  290. {384,360},
  291. {394,358},
  292. {405,353},
  293. {414,347},
  294. {421,339},
  295. {426,329},
  296. {-1,-1},
  297. },
  298. // 07: Dunes - Suburbs
  299. {
  300. {439,305},
  301. {434,300},
  302. {429,293},
  303. {-1,-1},
  304. },
  305. // 08: Suburbs - Sewers
  306. {
  307. {403,250},
  308. {402,244},
  309. {401,238},
  310. {398,232},
  311. {-1,-1},
  312. },
  313. // 09: Sewers - Metropolis
  314. {
  315. {372,266},
  316. {371,221},
  317. {370,216},
  318. {-1,-1},
  319. },
  320. // 10: Metropolis - Alley
  321. {
  322. {317,211},
  323. {310,215},
  324. {302,219},
  325. {293,222},
  326. {283,222},
  327. {273,221},
  328. {265,218},
  329. {-1,-1},
  330. },
  331. // 11: Alley - Karnak
  332. {
  333. {260,189},
  334. {259,181},
  335. {255,174},
  336. {249,168},
  337. {241,165},
  338. {233,164},
  339. {-1,-1},
  340. },
  341. // 12: Karnak - Luxor
  342. {
  343. {228,143},
  344. {228,136},
  345. {226,129},
  346. {221,123},
  347. {-1,-1},
  348. },
  349. // 13: Luxor - Sacred
  350. {
  351. {175,101},
  352. {169,106},
  353. {162,111},
  354. {154,113},
  355. {145,113},
  356. {136,112},
  357. {-1,-1},
  358. },
  359. // 14: Sacred - Pyramid
  360. {
  361. {126,59},
  362. {134,55},
  363. {142,52},
  364. {151,49},
  365. {160,47},
  366. {170,47},
  367. {179,48},
  368. {188,51},
  369. {-1,-1},
  370. },
  371. // 15: Luxor - Pyramid
  372. {
  373. {212,71},
  374. {217,66},
  375. {225,63},
  376. {234,63},
  377. {244,63},
  378. {253,62},
  379. {261,59},
  380. {-1,-1},
  381. },
  382. };
  383. BOOL ObtainMapData(void)
  384. {
  385. try {
  386. // the second encounter
  387. atoIconsSE[ 0].SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\Book.tex"));
  388. atoIconsSE[ 1].SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\Level00.tex"));
  389. atoIconsSE[ 2].SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\Level01.tex"));
  390. atoIconsSE[ 3].SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\Level02.tex"));
  391. atoIconsSE[ 4].SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\Level03.tex"));
  392. atoIconsSE[ 5].SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\Level04.tex"));
  393. atoIconsSE[ 6].SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\Level05.tex"));
  394. atoIconsSE[ 7].SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\Level06.tex"));
  395. atoIconsSE[ 8].SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\Level07.tex"));
  396. atoIconsSE[ 9].SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\Level08.tex"));
  397. atoIconsSE[10].SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\Level09.tex"));
  398. atoIconsSE[11].SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\Level10.tex"));
  399. atoIconsSE[12].SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\Level11.tex"));
  400. _toPathDot .SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\PathDot.tex"));
  401. _toMapBcgLDSE .SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\MapBcgLD.tex"));
  402. _toMapBcgLUSE .SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\MapBcgLU.tex"));
  403. _toMapBcgRDSE .SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\MapBcgRD.tex"));
  404. _toMapBcgRUSE .SetData_t(CTFILENAME("TexturesMP\\Computer\\Map\\MapBcgRU.tex"));
  405. // force constant textures
  406. ((CTextureData*)atoIconsSE[ 0].GetData())->Force(TEX_CONSTANT);
  407. ((CTextureData*)atoIconsSE[ 1].GetData())->Force(TEX_CONSTANT);
  408. ((CTextureData*)atoIconsSE[ 2].GetData())->Force(TEX_CONSTANT);
  409. ((CTextureData*)atoIconsSE[ 3].GetData())->Force(TEX_CONSTANT);
  410. ((CTextureData*)atoIconsSE[ 4].GetData())->Force(TEX_CONSTANT);
  411. ((CTextureData*)atoIconsSE[ 5].GetData())->Force(TEX_CONSTANT);
  412. ((CTextureData*)atoIconsSE[ 6].GetData())->Force(TEX_CONSTANT);
  413. ((CTextureData*)atoIconsSE[ 7].GetData())->Force(TEX_CONSTANT);
  414. ((CTextureData*)atoIconsSE[ 8].GetData())->Force(TEX_CONSTANT);
  415. ((CTextureData*)atoIconsSE[ 9].GetData())->Force(TEX_CONSTANT);
  416. ((CTextureData*)atoIconsSE[10].GetData())->Force(TEX_CONSTANT);
  417. ((CTextureData*)atoIconsSE[11].GetData())->Force(TEX_CONSTANT);
  418. ((CTextureData*)atoIconsSE[12].GetData())->Force(TEX_CONSTANT);
  419. ((CTextureData*)_toPathDot .GetData())->Force(TEX_CONSTANT);
  420. ((CTextureData*)_toMapBcgLDSE .GetData())->Force(TEX_CONSTANT);
  421. ((CTextureData*)_toMapBcgLUSE .GetData())->Force(TEX_CONSTANT);
  422. ((CTextureData*)_toMapBcgRDSE .GetData())->Force(TEX_CONSTANT);
  423. ((CTextureData*)_toMapBcgRUSE .GetData())->Force(TEX_CONSTANT);
  424. // the first encounter
  425. atoIconsFE[ 0].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level00.tex"));
  426. atoIconsFE[ 1].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level01.tex"));
  427. atoIconsFE[ 2].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level02.tex"));
  428. atoIconsFE[ 3].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level03.tex"));
  429. atoIconsFE[ 4].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level04.tex"));
  430. atoIconsFE[ 5].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level05.tex"));
  431. atoIconsFE[ 6].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level06.tex"));
  432. atoIconsFE[ 7].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level07.tex"));
  433. atoIconsFE[ 8].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level08.tex"));
  434. atoIconsFE[ 9].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level09.tex"));
  435. atoIconsFE[10].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level10.tex"));
  436. atoIconsFE[11].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level11.tex"));
  437. atoIconsFE[12].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level12.tex"));
  438. atoIconsFE[13].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level13.tex"));
  439. atoIconsFE[14].SetData_t(CTFILENAME("Textures\\Computer\\Map\\Level14.tex"));
  440. _toMapBcgLDFE .SetData_t(CTFILENAME("Textures\\Computer\\Map\\MapBcgLD.tex"));
  441. _toMapBcgLUFE .SetData_t(CTFILENAME("Textures\\Computer\\Map\\MapBcgLU.tex"));
  442. _toMapBcgRDFE .SetData_t(CTFILENAME("Textures\\Computer\\Map\\MapBcgRD.tex"));
  443. _toMapBcgRUFE .SetData_t(CTFILENAME("Textures\\Computer\\Map\\MapBcgRU.tex"));
  444. // force constant textures
  445. ((CTextureData*)atoIconsFE[ 0].GetData())->Force(TEX_CONSTANT);
  446. ((CTextureData*)atoIconsFE[ 1].GetData())->Force(TEX_CONSTANT);
  447. ((CTextureData*)atoIconsFE[ 2].GetData())->Force(TEX_CONSTANT);
  448. ((CTextureData*)atoIconsFE[ 3].GetData())->Force(TEX_CONSTANT);
  449. ((CTextureData*)atoIconsFE[ 4].GetData())->Force(TEX_CONSTANT);
  450. ((CTextureData*)atoIconsFE[ 5].GetData())->Force(TEX_CONSTANT);
  451. ((CTextureData*)atoIconsFE[ 6].GetData())->Force(TEX_CONSTANT);
  452. ((CTextureData*)atoIconsFE[ 7].GetData())->Force(TEX_CONSTANT);
  453. ((CTextureData*)atoIconsFE[ 8].GetData())->Force(TEX_CONSTANT);
  454. ((CTextureData*)atoIconsFE[ 9].GetData())->Force(TEX_CONSTANT);
  455. ((CTextureData*)atoIconsFE[10].GetData())->Force(TEX_CONSTANT);
  456. ((CTextureData*)atoIconsFE[11].GetData())->Force(TEX_CONSTANT);
  457. ((CTextureData*)atoIconsFE[12].GetData())->Force(TEX_CONSTANT);
  458. ((CTextureData*)atoIconsFE[13].GetData())->Force(TEX_CONSTANT);
  459. ((CTextureData*)atoIconsFE[14].GetData())->Force(TEX_CONSTANT);
  460. ((CTextureData*)_toMapBcgLDFE .GetData())->Force(TEX_CONSTANT);
  461. ((CTextureData*)_toMapBcgLUFE .GetData())->Force(TEX_CONSTANT);
  462. ((CTextureData*)_toMapBcgRDFE .GetData())->Force(TEX_CONSTANT);
  463. ((CTextureData*)_toMapBcgRUFE .GetData())->Force(TEX_CONSTANT);
  464. }
  465. catch (char *strError) {
  466. CPrintF("%s\n", strError);
  467. return FALSE;
  468. }
  469. return TRUE;
  470. }
  471. void ReleaseMapData(void)
  472. {
  473. atoIconsSE[0].SetData(NULL);
  474. atoIconsSE[1].SetData(NULL);
  475. atoIconsSE[2].SetData(NULL);
  476. atoIconsSE[3].SetData(NULL);
  477. atoIconsSE[4].SetData(NULL);
  478. atoIconsSE[5].SetData(NULL);
  479. atoIconsSE[6].SetData(NULL);
  480. atoIconsSE[7].SetData(NULL);
  481. atoIconsSE[8].SetData(NULL);
  482. atoIconsSE[9].SetData(NULL);
  483. atoIconsSE[10].SetData(NULL);
  484. atoIconsSE[11].SetData(NULL);
  485. atoIconsSE[12].SetData(NULL);
  486. atoIconsFE[0].SetData(NULL);
  487. atoIconsFE[1].SetData(NULL);
  488. atoIconsFE[2].SetData(NULL);
  489. atoIconsFE[3].SetData(NULL);
  490. atoIconsFE[4].SetData(NULL);
  491. atoIconsFE[5].SetData(NULL);
  492. atoIconsFE[6].SetData(NULL);
  493. atoIconsFE[7].SetData(NULL);
  494. atoIconsFE[8].SetData(NULL);
  495. atoIconsFE[9].SetData(NULL);
  496. atoIconsFE[10].SetData(NULL);
  497. atoIconsFE[11].SetData(NULL);
  498. atoIconsFE[12].SetData(NULL);
  499. atoIconsFE[13].SetData(NULL);
  500. atoIconsFE[14].SetData(NULL);
  501. _toPathDot.SetData(NULL);
  502. _toMapBcgLDSE.SetData(NULL);
  503. _toMapBcgLUSE.SetData(NULL);
  504. _toMapBcgRDSE.SetData(NULL);
  505. _toMapBcgRUSE.SetData(NULL);
  506. _toMapBcgLDFE.SetData(NULL);
  507. _toMapBcgLUFE.SetData(NULL);
  508. _toMapBcgRDFE.SetData(NULL);
  509. _toMapBcgRUFE.SetData(NULL);
  510. }
  511. void RenderMap( CDrawPort *pdp, ULONG ulLevelMask, CProgressHookInfo *pphi)
  512. {
  513. if( !ObtainMapData())
  514. {
  515. ReleaseMapData();
  516. return;
  517. }
  518. PIX(*aIconCoords)[2] = map_bIsFirstEncounter ? aIconCoordsFE : aIconCoordsSE;
  519. CTextureObject* atoIcons = map_bIsFirstEncounter ? atoIconsFE : atoIconsSE;
  520. INDEX(*aPathPrevNextLevels)[2] = map_bIsFirstEncounter ? aPathPrevNextLevelsFE : aPathPrevNextLevelsSE;
  521. PIX(*aPathDots)[10][2] = map_bIsFirstEncounter ? aPathDotsFE : aPathDotsSE;
  522. INDEX ctLevels = map_bIsFirstEncounter ? ARRAYCOUNT(aIconCoordsFE) : ARRAYCOUNT(aIconCoordsSE);
  523. CTextureObject* _toMapBcgLD = &_toMapBcgLDSE;
  524. CTextureObject* _toMapBcgLU = &_toMapBcgLUSE;
  525. CTextureObject* _toMapBcgRD = &_toMapBcgRDSE;
  526. CTextureObject* _toMapBcgRU = &_toMapBcgRUSE;
  527. if(map_bIsFirstEncounter) {
  528. _toMapBcgLD = &_toMapBcgLDFE;
  529. _toMapBcgLU = &_toMapBcgLUFE;
  530. _toMapBcgRD = &_toMapBcgRDFE;
  531. _toMapBcgRU = &_toMapBcgRUFE;
  532. }
  533. PIX pixdpw = pdp->GetWidth();
  534. PIX pixdph = pdp->GetHeight();
  535. PIX imgw = 512;
  536. PIX imgh = 480;
  537. FLOAT fStretch = 0.25f;
  538. // determine max available picture stretch
  539. if( pixdpw>=imgw*2 && pixdph>=imgh*2) {
  540. fStretch = 2.0f;
  541. } else if(pixdpw>=imgw && pixdph>=imgh) {
  542. fStretch = 1.0f;
  543. } else if(pixdpw>=imgw/2 && pixdph>=imgh/2) {
  544. fStretch = 0.5f;
  545. }
  546. // calculate LU offset so picture would be centerd in dp
  547. PIX pixSX = (pixdpw-imgw*fStretch)/2;
  548. PIX pixSY = Max( PIX((pixdph-imgh*fStretch)/2), PIX(0));
  549. PIX pixC1S = pixSX; // column 1 start pixel
  550. PIX pixR1S = pixSY; // raw 1 start pixel
  551. PIX pixC1E = pixSX+256*fStretch; // column 1 end pixel
  552. PIX pixR1E = pixSY+256*fStretch; // raw 1 end pixel
  553. PIX pixC2S = pixC1E-fStretch; // column 2 start pixel
  554. PIX pixR2S = pixR1E-fStretch; // raw 2 start pixel
  555. PIX pixC2E = pixC2S+256*fStretch; // column 2 end pixel
  556. PIX pixR2E = pixR2S+256*fStretch; // raw 2 end pixel
  557. if (ulLevelMask == 0x00000001 && !map_bIsFirstEncounter) {
  558. // render the book
  559. PIX pixX = aIconCoords[0][0]*fStretch+pixC1S;
  560. PIX pixY = aIconCoords[0][1]*fStretch+pixR1S;
  561. CTextureObject *pto = &atoIcons[0];
  562. pdp->PutTexture( pto, PIXaabbox2D( PIX2D(pixC1S,pixR1S), PIX2D(pixC2E,pixR2E)), C_WHITE|255);
  563. } else {
  564. // render pale map bcg
  565. pdp->PutTexture( _toMapBcgLU, PIXaabbox2D( PIX2D(pixC1S,pixR1S), PIX2D(pixC1E,pixR1E)), C_WHITE|255);
  566. pdp->PutTexture( _toMapBcgRU, PIXaabbox2D( PIX2D(pixC2S,pixR1S), PIX2D(pixC2E,pixR1E)), C_WHITE|255);
  567. pdp->PutTexture( _toMapBcgLD, PIXaabbox2D( PIX2D(pixC1S,pixR2S), PIX2D(pixC1E,pixR2E)), C_WHITE|255);
  568. pdp->PutTexture( _toMapBcgRD, PIXaabbox2D( PIX2D(pixC2S,pixR2S), PIX2D(pixC2E,pixR2E)), C_WHITE|255);
  569. // render icons
  570. for( INDEX iIcon=(!map_bIsFirstEncounter); iIcon<ctLevels; iIcon++)
  571. {
  572. // if level's icon should be rendered
  573. if( ulLevelMask & (1UL<<iIcon))
  574. {
  575. PIX pixX = aIconCoords[iIcon][0]*fStretch+pixC1S;
  576. PIX pixY = aIconCoords[iIcon][1]*fStretch+pixR1S;
  577. CTextureObject *pto = &atoIcons[iIcon];
  578. PIX pixImgW = ((CTextureData *)pto->GetData())->GetPixWidth()*fStretch;
  579. PIX pixImgH = ((CTextureData *)pto->GetData())->GetPixHeight()*fStretch;
  580. pdp->PutTexture( pto, PIXaabbox2D( PIX2D(pixX, pixY), PIX2D(pixX+pixImgW, pixY+pixImgH)), C_WHITE|255);
  581. }
  582. }
  583. }
  584. // render paths
  585. for( INDEX iPath=0; iPath<ctLevels; iPath++)
  586. {
  587. INDEX iPrevLevelBit = aPathPrevNextLevels[iPath][0];
  588. INDEX iNextLevelBit = aPathPrevNextLevels[iPath][1];
  589. // if path dots should be rendered:
  590. // if path src and dst levels were discovered and secret level isn't inbetween or hasn't been discovered
  591. if( ulLevelMask&(1UL<<iPrevLevelBit) &&
  592. ulLevelMask&(1UL<<iNextLevelBit) &&
  593. ((iNextLevelBit-iPrevLevelBit)==1 || !(ulLevelMask&(1UL<<(iNextLevelBit-1)))))
  594. {
  595. for( INDEX iDot=0; iDot<10; iDot++)
  596. {
  597. PIX pixDotX=pixC1S+aPathDots[iPath][iDot][0]*fStretch;
  598. PIX pixDotY=pixR1S+aPathDots[iPath][iDot][1]*fStretch;
  599. if(aPathDots[iPath][iDot][0]==-1) break;
  600. pdp->PutTexture( &_toPathDot, PIXaabbox2D( PIX2D(pixDotX, pixDotY), PIX2D(pixDotX+8*fStretch, pixDotY+8*fStretch)),
  601. (map_bIsFirstEncounter ? C_WHITE : C_BLACK)|255);
  602. }
  603. }
  604. }
  605. if( pphi != NULL)
  606. {
  607. // set font
  608. pdp->SetFont( _pfdDisplayFont);
  609. pdp->SetTextScaling( fStretch);
  610. pdp->SetTextAspect( 1.0f);
  611. INDEX iPosX, iPosY;
  612. COLOR colText = RGBToColor(200,128,56)|CT_OPAQUE;
  613. if(!map_bIsFirstEncounter) {
  614. // set coordinates and dot colors
  615. if (ulLevelMask == 0x00000001) {
  616. iPosX = 200;
  617. iPosY = 330;
  618. colText = 0x5c6a9aff;
  619. } else {
  620. iPosX = 395;
  621. iPosY = 403;
  622. colText = 0xc87832ff;
  623. }
  624. }
  625. PIX pixhtcx = pixC1S+iPosX*fStretch;
  626. PIX pixhtcy = pixR1S+iPosY*fStretch;
  627. if(map_bIsFirstEncounter) {
  628. pixhtcx = pixC1S+116*fStretch;
  629. pixhtcy = pixR1S+220*fStretch;
  630. }
  631. pdp->PutTextC( pphi->phi_strDescription, pixhtcx, pixhtcy, colText);
  632. for( INDEX iProgresDot=0; iProgresDot<16; iProgresDot+=1)
  633. {
  634. if(map_bIsFirstEncounter) {
  635. PIX pixDotX=pixC1S+(48+iProgresDot*8)*fStretch;
  636. PIX pixDotY=pixR1S+249*fStretch;
  637. COLOR colDot = C_WHITE|255;
  638. if(iProgresDot>pphi->phi_fCompleted*16) {
  639. colDot = C_WHITE|64;
  640. }
  641. pdp->PutTexture( &_toPathDot, PIXaabbox2D( PIX2D(pixDotX, pixDotY),
  642. PIX2D(pixDotX+8*fStretch, pixDotY+8*fStretch)), colDot);
  643. } else {
  644. PIX pixDotX=pixC1S+((iPosX-68)+iProgresDot*8)*fStretch;
  645. PIX pixDotY=pixR1S+(iPosY+19)*fStretch;
  646. COLOR colDot = colText|255;
  647. if(iProgresDot>pphi->phi_fCompleted*16) {
  648. colDot = C_BLACK|64;
  649. }
  650. pdp->PutTexture( &_toPathDot, PIXaabbox2D( PIX2D(pixDotX, pixDotY),
  651. PIX2D(pixDotX+2+8*fStretch, pixDotY+2+8*fStretch)), C_BLACK|255);
  652. pdp->PutTexture( &_toPathDot, PIXaabbox2D( PIX2D(pixDotX, pixDotY),
  653. PIX2D(pixDotX+8*fStretch, pixDotY+8*fStretch)), colDot);
  654. }
  655. }
  656. }
  657. // free textures used in map rendering
  658. ReleaseMapData();
  659. }