| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/main/hotspotmap.cpp $ |
| 21 | * $Revision: 19 $ |
| 22 | * $Date: 4/19/00 5:07p $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * Contains the code for the hotspotmap functions (used in TelCom) |
| 26 | * |
| 27 | * $Log: /DescentIII/main/hotspotmap.cpp $ |
| 28 | * |
| 29 | * 19 4/19/00 5:07p Matt |
| 30 | * From Duane for 1.4 |
| 31 | * Added checks, asserts, and fixes for bad return values |
| 32 | * |
| 33 | * 18 4/17/99 6:15p Samir |
| 34 | * replaced gr.h with grdefs.h and fixed resulting compile bugs. |
| 35 | * |
| 36 | * 17 4/14/99 2:50a Jeff |
| 37 | * fixed some case mismatched #includes |
| 38 | * |
| 39 | * 16 1/21/99 11:15p Jeff |
| 40 | * pulled out some structs and defines from header files and moved them |
| 41 | * into seperate header files so that multiplayer dlls don't require major |
| 42 | * game headers, just those new headers. Side effect is a shorter build |
| 43 | * time. Also cleaned up some header file #includes that weren't needed. |
| 44 | * This affected polymodel.h, object.h, player.h, vecmat.h, room.h, |
| 45 | * manage.h and multi.h |
| 46 | * |
| 47 | * 15 10/15/98 1:36p Jeff |
| 48 | * fixed bug vc6 caught |
| 49 | * |
| 50 | * 14 10/08/98 4:23p Kevin |
| 51 | * Changed code to comply with memory library usage. Always use mem_malloc |
| 52 | * , mem_free and mem_strdup |
| 53 | * |
| 54 | * 13 8/15/98 2:49p Matt |
| 55 | * Took out unneeded include |
| 56 | * |
| 57 | * 12 4/23/98 6:38p Jason |
| 58 | * made bitmaps use 1555 format |
| 59 | * |
| 60 | * 11 3/23/98 9:55a Jeff |
| 61 | * Made changes to remove old telcom |
| 62 | * |
| 63 | * 10 3/18/98 8:00p Jeff |
| 64 | * Added some functionality for text and using the monitor borders |
| 65 | * correctly in the new Telcom |
| 66 | * |
| 67 | * 9 3/12/98 3:32p Jeff |
| 68 | * Initial changes started for New TelCom |
| 69 | * |
| 70 | * 8 2/08/98 5:02p Samir |
| 71 | * Commented out use of Game_viewport code. |
| 72 | * |
| 73 | * 7 1/15/98 11:13a Jeff |
| 74 | * Got Telcom working again, switched from 2d to 3d |
| 75 | * |
| 76 | * 6 10/15/97 5:20p Jason |
| 77 | * did a HUGE overhaul of the bitmap system |
| 78 | * |
| 79 | * 5 8/15/97 12:24p Jeff |
| 80 | * Changed things around a bit, added code to handle the round corners |
| 81 | * |
| 82 | * 4 8/13/97 3:13p Jeff |
| 83 | * optimized for memory usage (removed the second background from being |
| 84 | * stored in memory) |
| 85 | * |
| 86 | * 3 8/04/97 7:23p Jeff |
| 87 | * |
| 88 | * 2 8/04/97 6:23p Jeff |
| 89 | * |
| 90 | * 1 8/04/97 6:23p Jeff |
| 91 | * |
| 92 | * 2 8/01/97 2:36p Jeff |
| 93 | * |
| 94 | * 1 8/01/97 2:35p Jeff |
| 95 | * |
| 96 | * 2 8/01/97 2:35p Jeff |
| 97 | * |
| 98 | * $NoKeywords: $ |
| 99 | */ |
| 100 | |
| 101 | #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/ |
| 102 | #include "renderer.h"cxx . . $ `<file>/lib/renderer.h`/ |
| 103 | #include "render.h"cxx . . $ `<file>/Descent3/render.h`/ |
| 104 | #include "grdefs.h"cxx . . $ `<file>/lib/grdefs.h`/ |
| 105 | #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/ |
| 106 | #include "descent.h"cxx . . $ `<file>/Descent3/descent.h`/ |
| 107 | #include "game.h"cxx . . $ `<file>/Descent3/game.h`/ |
| 108 | #include "cfile.h"cxx . . $ `<file>/cfile/cfile.h`/ |
| 109 | #include "application.h"cxx . . $ `<file>/lib/application.h`/ |
| 110 | #include <stdlib.h> |
| 111 | #include <string.h> |
| 112 | #include "hotspotmap.h"cxx . . $ `<file>/Descent3/hotspotmap.h`/ |
| 113 | #include "mem.h"cxx . . $ `<file>/mem/mem.h`/ |
| 114 | #include "bitmap.h"cxx . . $ `<file>/lib/bitmap.h`/ |
| 115 | #include "manage.h"cxx . . $ `<file>/lib/manage.h`/ |
| 116 | |
| 117 | static void makecornercxx . . $ makecorner(aa6cfca089dba86d).(int corner_bmp, int back_bmp, const char *tmap, int l, int t, int r, int b); |
| 118 | static int CreateHotSpotMapcxx . . $ CreateHotSpotMap(1c06fcac5451a5ba).(const char *map, int width, int height, hotspotmap_tcxx . . $ hotspotmap_t# *hsmap); |
| 119 | static void CreateWindowMapcxx . . $ CreateWindowMap(e71e6955f2433003).(const char *map, int width, int height, windowmap_tcxx . . $ windowmap_t# *wndmap); |
| 120 | |
| 121 | // just like the old bm_tga_translate_pixel function, but it stores the alpha in the alpha_value parameter |
| 122 | uint16_tcxx . . $ uint16_t# menutga_translate_pixelcxx . . $ menutga_translate_pixel(7e0c9d8322f04898).(int pixel, char *alpha_value) { |
| 123 | int red = ((pixel >> 16) & 0xFF); |
| 124 | int green = ((pixel >> 8) & 0xFF); |
| 125 | int blue = ((pixel) & 0xFF); |
| 126 | int alpha = ((pixel >> 24) & 0xFF); |
| 127 | |
| 128 | *alpha_value = alpha; |
| 129 | |
| 130 | int newred = red >> 3; |
| 131 | int newgreen = green >> 3; |
| 132 | int newblue = blue >> 3; |
| 133 | uint16_tcxx . . $ uint16_t# newpix = OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`! | (newred << 10) | (newgreen << 5) | (newblue); |
| 134 | if (alpha == 0) |
| 135 | newpix = NEW_TRANSPARENT_COLORcxx . . $ `lib/grdefs.h:71:9`!; |
| 136 | |
| 137 | return newpix; |
| 138 | } |
| 139 | |
| 140 | // This takes a char array filled with alphavalues from the TGA and fills in a hotspotmap_t struct with the |
| 141 | // scanline info |
| 142 | // returns the number of windows it found while making the hotspot map |
| 143 | #define HOTSPOT_THEREcxx . . $ `Descent3/hotspotmap.cpp:143:9`! 1 |
| 144 | #define WINDOW_THEREcxx . . $ `Descent3/hotspotmap.cpp:144:9`! 2 |
| 145 | #define NOTHING_THEREcxx . . $ `Descent3/hotspotmap.cpp:145:9`! 0 |
| 146 | |
| 147 | int CreateHotSpotMapcxx . . $ CreateHotSpotMap(1c06fcac5451a5ba).(const char *map, int width, int height, hotspotmap_tcxx . . $ hotspotmap_t# *hsmap) { |
| 148 | // make sure we have a clean struct to work with |
| 149 | if (hsmap->hscxx . . $ hotspotmap_t#hs.) { |
| 150 | FreeHotSpotMapInternalscxx . . $ FreeHotSpotMapInternals(40652d961f76803d).(hsmap); |
| 151 | } |
| 152 | |
| 153 | int curr_sl, x, y, count, num_hs = 0; |
| 154 | uint8_tcxx . . $ uint8_t# alpha; |
| 155 | char whats_there[256]; |
| 156 | int window_count; |
| 157 | |
| 158 | for (count = 0; count < 256; count++) |
| 159 | whats_there[count] = NOTHING_THEREcxx . . $ `Descent3/hotspotmap.cpp:145:9`!; |
| 160 | |
| 161 | // Get total number of hotspots (based on highest hotspot value) |
| 162 | for (y = 0; y < height; y++) { |
| 163 | for (x = 0; x < width; x++) { |
| 164 | alpha = (unsigned)map[y * width + x]; |
| 165 | if ((alpha != NO_ALPHAcxx . . $ `Descent3/hotspotmap.h:59:9`!) && (alpha != WRITEABLE_ALPHAcxx . . $ `Descent3/hotspotmap.h:60:9`!) && (whats_there[alpha] == NOTHING_THEREcxx . . $ `Descent3/hotspotmap.cpp:145:9`!)) { |
| 166 | if (alpha < MAX_HOTSPOTScxx . . $ `Descent3/hotspotmap.h:58:9`!) { |
| 167 | whats_there[alpha] = HOTSPOT_THEREcxx . . $ `Descent3/hotspotmap.cpp:143:9`!; |
| 168 | if (alpha >= num_hs) |
| 169 | num_hs = alpha + 1; |
| 170 | } else { |
| 171 | whats_there[alpha] = WINDOW_THEREcxx . . $ `Descent3/hotspotmap.cpp:144:9`!; |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | hsmap->num_of_hotspotscxx . . $ hotspotmap_t#num_of_hotspots. = num_hs; |
| 178 | if (!num_hs) |
| 179 | return -1; |
| 180 | |
| 181 | hsmap->hscxx . . $ hotspotmap_t#hs. = (hotspotcxx . . $ hotspot# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(hotspot) * num_hs); |
| 182 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(hsmap->hs); |
| 183 | for (count = 0; count < num_hs; count++) { |
| 184 | if (whats_there[count] == HOTSPOT_THEREcxx . . $ `Descent3/hotspotmap.cpp:143:9`!) { |
| 185 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].starting_ycxx . . $ hotspot#starting_y. = MAX_MAP_HEIGHTcxx . . $ `Descent3/hotspotmap.h:62:9`!; |
| 186 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].scanlinescxx . . $ hotspot#scanlines. = 0; |
| 187 | } else { |
| 188 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].starting_ycxx . . $ hotspot#starting_y. = 0; |
| 189 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].scanlinescxx . . $ hotspot#scanlines. = 0; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | scanlinecxx . . $ scanline# sl_x[MAX_MAP_HEIGHTcxx . . $ `Descent3/hotspotmap.h:62:9`!]; |
| 194 | int sl_count, last_y = -1; |
| 195 | |
| 196 | // this is to set the values of start and end initially |
| 197 | for (count = 0; count < MAX_MAP_HEIGHTcxx . . $ `Descent3/hotspotmap.h:62:9`!; count++) { |
| 198 | sl_x[count].startcxx . . $ scanline#start. = MAX_MAP_WIDTHcxx . . $ `Descent3/hotspotmap.h:61:9`!; |
| 199 | sl_x[count].endcxx . . $ scanline#end. = 0; |
| 200 | } |
| 201 | |
| 202 | // fill in hotspot info |
| 203 | // this is really nasty...MUST MAKE BETTER |
| 204 | for (count = 0; count < num_hs; count++) { |
| 205 | if (whats_there[count] == HOTSPOT_THEREcxx . . $ `Descent3/hotspotmap.cpp:143:9`!) { |
| 206 | sl_count = 0; |
| 207 | // Get start,end, scanlines and starting_y for each hotspot |
| 208 | for (y = 0; y < height; y++) { |
| 209 | for (x = 0; x < width; x++) { |
| 210 | if ((unsigned)map[y * width + x] == (uint8_tcxx . . $ uint8_t#)count) { |
| 211 | if (last_y != y) |
| 212 | sl_count++; |
| 213 | if (hsmap->hscxx . . $ hotspotmap_t#hs.[count].starting_ycxx . . $ hotspot#starting_y. > y) |
| 214 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].starting_ycxx . . $ hotspot#starting_y. = y; |
| 215 | if (sl_x[y].startcxx . . $ scanline#start. > x) |
| 216 | sl_x[y].startcxx . . $ scanline#start. = x; |
| 217 | if (sl_x[y].endcxx . . $ scanline#end. < x) |
| 218 | sl_x[y].endcxx . . $ scanline#end. = x; |
| 219 | last_y = y; |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | // fill in the struct with the start and end values for each scanline |
| 224 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].scanlinescxx . . $ hotspot#scanlines. = sl_count; |
| 225 | if (sl_count) { |
| 226 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].xcxx . . $ hotspot#x. = (scanlinecxx . . $ scanline# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(scanline) * sl_count); |
| 227 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(hsmap->hs[count].x); |
| 228 | memset(hsmap->hscxx . . $ hotspotmap_t#hs.[count].xcxx . . $ hotspot#x., 0, sizeof(scanlinecxx . . $ scanline#) * sl_count); |
| 229 | y = hsmap->hscxx . . $ hotspotmap_t#hs.[count].starting_ycxx . . $ hotspot#starting_y.; |
| 230 | for (curr_sl = 0; curr_sl < sl_count; curr_sl++) { |
| 231 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].xcxx . . $ hotspot#x.[curr_sl].startcxx . . $ scanline#start. = sl_x[y].startcxx . . $ scanline#start.; |
| 232 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].xcxx . . $ hotspot#x.[curr_sl].endcxx . . $ scanline#end. = sl_x[y].endcxx . . $ scanline#end.; |
| 233 | sl_x[y].startcxx . . $ scanline#start. = MAX_MAP_WIDTHcxx . . $ `Descent3/hotspotmap.h:61:9`!; |
| 234 | sl_x[y].endcxx . . $ scanline#end. = 0; |
| 235 | y++; |
| 236 | } // end for (curr_sl) |
| 237 | } // end if (sl_count) |
| 238 | } else { |
| 239 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].scanlinescxx . . $ hotspot#scanlines. = 0; |
| 240 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].starting_ycxx . . $ hotspot#starting_y. = 0; |
| 241 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].xcxx . . $ hotspot#x. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 242 | } // end ifelse (hotspot_there) |
| 243 | } // end for (count) |
| 244 | |
| 245 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Hunting down empty hotspots....\n"); |
| 246 | for (count = 0; count < num_hs; count++) { |
| 247 | if (whats_there[count] == NOTHING_THEREcxx . . $ `Descent3/hotspotmap.cpp:145:9`!) { |
| 248 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Notice: HotSpot %d is empty\n", count); |
| 249 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].scanlinescxx . . $ hotspot#scanlines. = 0; |
| 250 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].starting_ycxx . . $ hotspot#starting_y. = 0; |
| 251 | if (hsmap->hscxx . . $ hotspotmap_t#hs.[count].xcxx . . $ hotspot#x.) { |
| 252 | mem_freecxx . . $ `mem/mem.h:80:9`!(hsmap->hs[count].x); |
| 253 | } |
| 254 | hsmap->hscxx . . $ hotspotmap_t#hs.[count].xcxx . . $ hotspot#x. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Finding window count..."); |
| 259 | window_count = 0; |
| 260 | for (count = 0; count < 256; count++) { |
| 261 | if (whats_there[count] == WINDOW_THEREcxx . . $ `Descent3/hotspotmap.cpp:144:9`!) |
| 262 | window_count++; |
| 263 | } |
| 264 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "%d windows found\n", window_count); |
| 265 | return window_count; |
| 266 | } |
| 267 | |
| 268 | void CreateWindowMapcxx . . $ CreateWindowMap(e71e6955f2433003).(const char *map, int width, int height, windowmap_tcxx . . $ windowmap_t# *wndmap) { |
| 269 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Processing %d windows\n", wndmap->num_of_windows); |
| 270 | int x, y, count; |
| 271 | uint8_tcxx . . $ uint8_t# alpha; |
| 272 | bool newline = true; |
| 273 | |
| 274 | wndmap->wmcxx . . $ windowmap_t#wm. = (window_boxcxx . . $ window_box# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(window_box) * wndmap->num_of_windows); |
| 275 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(wndmap->wm); |
| 276 | |
| 277 | for (int index = 0; index < wndmap->num_of_windowscxx . . $ windowmap_t#num_of_windows.; index++) { |
| 278 | wndmap->wmcxx . . $ windowmap_t#wm.[index].ltcxx . . $ window_box#lt. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 279 | wndmap->wmcxx . . $ windowmap_t#wm.[index].rtcxx . . $ window_box#rt. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 280 | wndmap->wmcxx . . $ windowmap_t#wm.[index].lbcxx . . $ window_box#lb. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 281 | wndmap->wmcxx . . $ windowmap_t#wm.[index].rbcxx . . $ window_box#rb. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 282 | } |
| 283 | |
| 284 | for (count = 0; count < wndmap->num_of_windowscxx . . $ windowmap_t#num_of_windows.; count++) { |
| 285 | wndmap->wmcxx . . $ windowmap_t#wm.[count].xcxx . . $ window_box#x. = wndmap->wmcxx . . $ windowmap_t#wm.[count].ycxx . . $ window_box#y. = wndmap->wmcxx . . $ windowmap_t#wm.[count].widthcxx . . $ window_box#width. = wndmap->wmcxx . . $ windowmap_t#wm.[count].heightcxx . . $ window_box#height. = -1; |
| 286 | wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y. = wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y. = -1; |
| 287 | wndmap->wmcxx . . $ windowmap_t#wm.[count].t_bottom_ycxx . . $ window_box#t_bottom_y. = wndmap->wmcxx . . $ windowmap_t#wm.[count].b_bottom_ycxx . . $ window_box#b_bottom_y. = 0; |
| 288 | wndmap->wmcxx . . $ windowmap_t#wm.[count].l_start_xcxx . . $ window_box#l_start_x. = wndmap->wmcxx . . $ windowmap_t#wm.[count].r_start_xcxx . . $ window_box#r_start_x. = MAX_MAP_WIDTHcxx . . $ `Descent3/hotspotmap.h:61:9`!; |
| 289 | wndmap->wmcxx . . $ windowmap_t#wm.[count].l_end_xcxx . . $ window_box#l_end_x. = wndmap->wmcxx . . $ windowmap_t#wm.[count].r_end_xcxx . . $ window_box#r_end_x. = 0; |
| 290 | wndmap->wmcxx . . $ windowmap_t#wm.[count].on_leftcxx . . $ window_box#on_left. = wndmap->wmcxx . . $ windowmap_t#wm.[count].on_topcxx . . $ window_box#on_top. = true; |
| 291 | } |
| 292 | |
| 293 | int working_window = -1; |
| 294 | |
| 295 | for (y = 0; y < height; y++) { |
| 296 | newline = true; |
| 297 | working_window = -1; |
| 298 | for (x = 0; x < width; x++) { |
| 299 | alpha = (unsigned)map[y * width + x]; |
| 300 | if (alpha != 255) { |
| 301 | if (alpha >= 130) |
| 302 | alpha = alpha; |
| 303 | } |
| 304 | if ((alpha >= MAX_HOTSPOTScxx . . $ `Descent3/hotspotmap.h:58:9`!) && (alpha != NO_ALPHAcxx . . $ `Descent3/hotspotmap.h:59:9`!)) { |
| 305 | // set the working_window value (needed so we know which window to work with for the writeable |
| 306 | if (alpha != WRITEABLE_ALPHAcxx . . $ `Descent3/hotspotmap.h:60:9`!) { |
| 307 | working_window = alpha - MAX_HOTSPOTScxx . . $ `Descent3/hotspotmap.h:58:9`!; |
| 308 | } |
| 309 | |
| 310 | if (newline) { |
| 311 | int count; |
| 312 | for (count = 0; count < wndmap->num_of_windowscxx . . $ windowmap_t#num_of_windows.; count++) |
| 313 | wndmap->wmcxx . . $ windowmap_t#wm.[count].on_leftcxx . . $ window_box#on_left. = true; |
| 314 | newline = false; |
| 315 | } |
| 316 | |
| 317 | // Set an initial value for x and y of a window |
| 318 | if ((wndmap->wmcxx . . $ windowmap_t#wm.[working_window].xcxx . . $ window_box#x. == -1) && (alpha != WRITEABLE_ALPHAcxx . . $ `Descent3/hotspotmap.h:60:9`!)) { |
| 319 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].xcxx . . $ window_box#x. = x; |
| 320 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].ycxx . . $ window_box#y. = y; |
| 321 | } |
| 322 | |
| 323 | // Set an initial value for the write_x and write_y for a window |
| 324 | if ((alpha == WRITEABLE_ALPHAcxx . . $ `Descent3/hotspotmap.h:60:9`!) && (working_window >= 0)) { |
| 325 | if (wndmap->wmcxx . . $ windowmap_t#wm.[working_window].t_top_ycxx . . $ window_box#t_top_y. != -1) { |
| 326 | if (wndmap->wmcxx . . $ windowmap_t#wm.[working_window].l_end_xcxx . . $ window_box#l_end_x. < x - 1) { |
| 327 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].on_leftcxx . . $ window_box#on_left. = false; |
| 328 | } else { |
| 329 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].on_leftcxx . . $ window_box#on_left. = true; |
| 330 | } |
| 331 | |
| 332 | if (wndmap->wmcxx . . $ windowmap_t#wm.[working_window].t_bottom_ycxx . . $ window_box#t_bottom_y. < y - 1) { |
| 333 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].on_topcxx . . $ window_box#on_top. = false; |
| 334 | } else { |
| 335 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].on_topcxx . . $ window_box#on_top. = true; |
| 336 | } |
| 337 | } else { |
| 338 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].on_leftcxx . . $ window_box#on_left. = true; |
| 339 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].on_topcxx . . $ window_box#on_top. = true; |
| 340 | } |
| 341 | |
| 342 | // first time init |
| 343 | if ((wndmap->wmcxx . . $ windowmap_t#wm.[working_window].t_top_ycxx . . $ window_box#t_top_y. == -1) && (wndmap->wmcxx . . $ windowmap_t#wm.[working_window].on_topcxx . . $ window_box#on_top.)) { |
| 344 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].t_top_ycxx . . $ window_box#t_top_y. = y; |
| 345 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].t_bottom_ycxx . . $ window_box#t_bottom_y. = y; |
| 346 | } |
| 347 | if ((wndmap->wmcxx . . $ windowmap_t#wm.[working_window].b_top_ycxx . . $ window_box#b_top_y. == -1) && (!wndmap->wmcxx . . $ windowmap_t#wm.[working_window].on_topcxx . . $ window_box#on_top.)) { |
| 348 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].b_top_ycxx . . $ window_box#b_top_y. = y; |
| 349 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].b_bottom_ycxx . . $ window_box#b_bottom_y. = y; |
| 350 | } |
| 351 | |
| 352 | // adjust bottom |
| 353 | if (wndmap->wmcxx . . $ windowmap_t#wm.[working_window].on_topcxx . . $ window_box#on_top.) { |
| 354 | if (wndmap->wmcxx . . $ windowmap_t#wm.[working_window].t_bottom_ycxx . . $ window_box#t_bottom_y. < y) { |
| 355 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].t_bottom_ycxx . . $ window_box#t_bottom_y. = y; |
| 356 | } |
| 357 | } else { |
| 358 | if (wndmap->wmcxx . . $ windowmap_t#wm.[working_window].b_bottom_ycxx . . $ window_box#b_bottom_y. < y) { |
| 359 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].b_bottom_ycxx . . $ window_box#b_bottom_y. = y; |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | // adjust edges |
| 364 | if (wndmap->wmcxx . . $ windowmap_t#wm.[working_window].on_leftcxx . . $ window_box#on_left.) { |
| 365 | if (wndmap->wmcxx . . $ windowmap_t#wm.[working_window].l_start_xcxx . . $ window_box#l_start_x. > x) { |
| 366 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].l_start_xcxx . . $ window_box#l_start_x. = x; |
| 367 | } |
| 368 | if (wndmap->wmcxx . . $ windowmap_t#wm.[working_window].l_end_xcxx . . $ window_box#l_end_x. < x) { |
| 369 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].l_end_xcxx . . $ window_box#l_end_x. = x; |
| 370 | } |
| 371 | } else { |
| 372 | if (wndmap->wmcxx . . $ windowmap_t#wm.[working_window].r_start_xcxx . . $ window_box#r_start_x. > x) { |
| 373 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].r_start_xcxx . . $ window_box#r_start_x. = x; |
| 374 | } |
| 375 | if (wndmap->wmcxx . . $ windowmap_t#wm.[working_window].r_end_xcxx . . $ window_box#r_end_x. < x) { |
| 376 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].r_end_xcxx . . $ window_box#r_end_x. = x; |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | if (alpha != WRITEABLE_ALPHAcxx . . $ `Descent3/hotspotmap.h:60:9`!) { |
| 382 | // adjust width and height |
| 383 | if ((wndmap->wmcxx . . $ windowmap_t#wm.[working_window].xcxx . . $ window_box#x. != -1) && (x > wndmap->wmcxx . . $ windowmap_t#wm.[working_window].xcxx . . $ window_box#x.) && |
| 384 | (x - wndmap->wmcxx . . $ windowmap_t#wm.[working_window].xcxx . . $ window_box#x. > wndmap->wmcxx . . $ windowmap_t#wm.[working_window].widthcxx . . $ window_box#width.)) { |
| 385 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].widthcxx . . $ window_box#width. = x - wndmap->wmcxx . . $ windowmap_t#wm.[working_window].xcxx . . $ window_box#x.; |
| 386 | } |
| 387 | |
| 388 | if ((y - wndmap->wmcxx . . $ windowmap_t#wm.[working_window].ycxx . . $ window_box#y. != -1) && (y > y - wndmap->wmcxx . . $ windowmap_t#wm.[working_window].ycxx . . $ window_box#y.) && |
| 389 | (y - wndmap->wmcxx . . $ windowmap_t#wm.[working_window].ycxx . . $ window_box#y. > wndmap->wmcxx . . $ windowmap_t#wm.[working_window].heightcxx . . $ window_box#height.)) { |
| 390 | wndmap->wmcxx . . $ windowmap_t#wm.[working_window].heightcxx . . $ window_box#height. = y - wndmap->wmcxx . . $ windowmap_t#wm.[working_window].ycxx . . $ window_box#y.; |
| 391 | } |
| 392 | } |
| 393 | } // end if |
| 394 | } // end for x |
| 395 | } // end for y |
| 396 | |
| 397 | for (count = 0; count < wndmap->num_of_windowscxx . . $ windowmap_t#num_of_windows.; count++) { |
| 398 | int h, w; |
| 399 | int x, y, real_x, real_y; |
| 400 | int *left_x, *right_x, *top_y, *bottom_y; |
| 401 | char *array; |
| 402 | uint8_tcxx . . $ uint8_t# alpha; |
| 403 | |
| 404 | // left top |
| 405 | left_x = &wndmap->wmcxx . . $ windowmap_t#wm.[count].l_start_xcxx . . $ window_box#l_start_x.; |
| 406 | right_x = &wndmap->wmcxx . . $ windowmap_t#wm.[count].l_end_xcxx . . $ window_box#l_end_x.; |
| 407 | top_y = &wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y.; |
| 408 | bottom_y = &wndmap->wmcxx . . $ windowmap_t#wm.[count].t_bottom_ycxx . . $ window_box#t_bottom_y.; |
| 409 | |
| 410 | if (*top_y != -1) { |
| 411 | w = *right_x - *left_x; |
| 412 | h = *bottom_y - *top_y; |
| 413 | wndmap->wmcxx . . $ windowmap_t#wm.[count].ltcxx . . $ window_box#lt. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(w * h); |
| 414 | array = wndmap->wmcxx . . $ windowmap_t#wm.[count].ltcxx . . $ window_box#lt.; |
| 415 | for (real_y = *top_y, y = 0; real_y < *bottom_y; real_y++, y++) { |
| 416 | for (real_x = *left_x, x = 0; real_x < *right_x; real_x++, x++) { |
| 417 | alpha = (unsigned)map[real_y * width + real_x]; |
| 418 | if (alpha == WRITEABLE_ALPHAcxx . . $ `Descent3/hotspotmap.h:60:9`!) { |
| 419 | array[y * w + x] = true; |
| 420 | } else { |
| 421 | array[y * w + x] = false; |
| 422 | } |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | // right top |
| 427 | left_x = &wndmap->wmcxx . . $ windowmap_t#wm.[count].r_start_xcxx . . $ window_box#r_start_x.; |
| 428 | right_x = &wndmap->wmcxx . . $ windowmap_t#wm.[count].r_end_xcxx . . $ window_box#r_end_x.; |
| 429 | top_y = &wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y.; |
| 430 | bottom_y = &wndmap->wmcxx . . $ windowmap_t#wm.[count].t_bottom_ycxx . . $ window_box#t_bottom_y.; |
| 431 | |
| 432 | w = *right_x - *left_x; |
| 433 | h = *bottom_y - *top_y; |
| 434 | wndmap->wmcxx . . $ windowmap_t#wm.[count].rtcxx . . $ window_box#rt. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(w * h); |
| 435 | |
| 436 | array = wndmap->wmcxx . . $ windowmap_t#wm.[count].rtcxx . . $ window_box#rt.; |
| 437 | for (real_y = *top_y, y = 0; real_y < *bottom_y; real_y++, y++) { |
| 438 | for (real_x = *left_x, x = 0; real_x < *right_x; real_x++, x++) { |
| 439 | alpha = (unsigned)map[real_y * width + real_x]; |
| 440 | if (alpha == WRITEABLE_ALPHAcxx . . $ `Descent3/hotspotmap.h:60:9`!) { |
| 441 | array[y * w + x] = true; |
| 442 | } else { |
| 443 | array[y * w + x] = false; |
| 444 | } |
| 445 | } |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | // left bottom |
| 450 | left_x = &wndmap->wmcxx . . $ windowmap_t#wm.[count].l_start_xcxx . . $ window_box#l_start_x.; |
| 451 | right_x = &wndmap->wmcxx . . $ windowmap_t#wm.[count].l_end_xcxx . . $ window_box#l_end_x.; |
| 452 | top_y = &wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y.; |
| 453 | bottom_y = &wndmap->wmcxx . . $ windowmap_t#wm.[count].b_bottom_ycxx . . $ window_box#b_bottom_y.; |
| 454 | |
| 455 | if (*top_y != -1) { |
| 456 | w = *right_x - *left_x; |
| 457 | h = *bottom_y - *top_y; |
| 458 | wndmap->wmcxx . . $ windowmap_t#wm.[count].lbcxx . . $ window_box#lb. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(w * h); |
| 459 | array = wndmap->wmcxx . . $ windowmap_t#wm.[count].lbcxx . . $ window_box#lb.; |
| 460 | |
| 461 | for (real_y = *top_y, y = 0; real_y < *bottom_y; real_y++, y++) { |
| 462 | for (real_x = *left_x, x = 0; real_x < *right_x; real_x++, x++) { |
| 463 | alpha = (unsigned)map[real_y * width + real_x]; |
| 464 | if (alpha == WRITEABLE_ALPHAcxx . . $ `Descent3/hotspotmap.h:60:9`!) { |
| 465 | array[y * w + x] = true; |
| 466 | } else { |
| 467 | array[y * w + x] = false; |
| 468 | } |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | // right bottom |
| 473 | left_x = &wndmap->wmcxx . . $ windowmap_t#wm.[count].r_start_xcxx . . $ window_box#r_start_x.; |
| 474 | right_x = &wndmap->wmcxx . . $ windowmap_t#wm.[count].r_end_xcxx . . $ window_box#r_end_x.; |
| 475 | top_y = &wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y.; |
| 476 | bottom_y = &wndmap->wmcxx . . $ windowmap_t#wm.[count].b_bottom_ycxx . . $ window_box#b_bottom_y.; |
| 477 | |
| 478 | w = *right_x - *left_x; |
| 479 | h = *bottom_y - *top_y; |
| 480 | wndmap->wmcxx . . $ windowmap_t#wm.[count].rbcxx . . $ window_box#rb. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(w * h); |
| 481 | array = wndmap->wmcxx . . $ windowmap_t#wm.[count].rbcxx . . $ window_box#rb.; |
| 482 | for (real_y = *top_y, y = 0; real_y < *bottom_y; real_y++, y++) { |
| 483 | for (real_x = *left_x, x = 0; real_x < *right_x; real_x++, x++) { |
| 484 | alpha = (unsigned)map[real_y * width + real_x]; |
| 485 | if (alpha == WRITEABLE_ALPHAcxx . . $ `Descent3/hotspotmap.h:60:9`!) { |
| 486 | array[y * w + x] = true; |
| 487 | } else { |
| 488 | array[y * w + x] = false; |
| 489 | } |
| 490 | } |
| 491 | } |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | for (count = 0; count < wndmap->num_of_windowscxx . . $ windowmap_t#num_of_windows.; count++) { |
| 496 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Window #%d: Left/Top=(%d,%d) Width=%d Height=%d\n", count, wndmap->wm[count].x, wndmap->wm[count].y, |
| 497 | wndmap->wm[count].width, wndmap->wm[count].height); |
| 498 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "---L.T. (%d,%d)->(%d,%d)\n", wndmap->wm[count].l_start_x, wndmap->wm[count].t_top_y, |
| 499 | wndmap->wm[count].l_end_x, wndmap->wm[count].t_bottom_y); |
| 500 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "---R.T. (%d,%d)->(%d,%d)\n", wndmap->wm[count].r_start_x, wndmap->wm[count].t_top_y, |
| 501 | wndmap->wm[count].r_end_x, wndmap->wm[count].t_bottom_y); |
| 502 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "---L.B. (%d,%d)->(%d,%d)\n", wndmap->wm[count].l_start_x, wndmap->wm[count].b_top_y, |
| 503 | wndmap->wm[count].l_end_x, wndmap->wm[count].b_bottom_y); |
| 504 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "---R.B. (%d,%d)->(%d,%d)\n", wndmap->wm[count].r_start_x, wndmap->wm[count].b_top_y, |
| 505 | wndmap->wm[count].r_end_x, wndmap->wm[count].b_bottom_y); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | // TODO: MTS: only used in this file |
| 510 | // Loads a tga or ogf file into a bitmap...returns handle to bm or -1 on error, and fills in the alphamap |
| 511 | int menutga_alloc_filecxx . . $ menutga_alloc_file(aa5a3b94b7175785).(const char *name, char *hsmap[1], int *w, int *h) { |
| 512 | uint8_tcxx . . $ uint8_t# image_id_len, color_map_type, image_type, pixsize, descriptor; |
| 513 | uint8_tcxx . . $ uint8_t# upside_down = 0; |
| 514 | uint16_tcxx . . $ uint16_t# width, height; |
| 515 | uint32_tcxx . . $ uint32_t# pixel; |
| 516 | int i, t, n; |
| 517 | char alphavalue; |
| 518 | CFILEcxx . . $ CFILE# *infile; |
| 519 | |
| 520 | if (!cfexistcxx . . $ cfexist(293b0826c8d9cb54).(namecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) |
| 521 | return -1; |
| 522 | |
| 523 | infile = (CFILEcxx . . $ CFILE# *)cfopencxx . . $ cfopen(7c7b94e455f1ae56).(namecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "rb"); |
| 524 | if (!infile) { |
| 525 | Int3cxx . . $ `misc/pserror.h:247:9`!(); // get jeff! |
| 526 | } |
| 527 | |
| 528 | image_id_len = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 529 | color_map_type = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 530 | image_type = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 531 | |
| 532 | if (color_map_type != 0 || (image_type != 2)) { |
| 533 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "menutga: Can't read this type of TGA.\n"); |
| 534 | return -1; |
| 535 | } |
| 536 | |
| 537 | for (i = 0; i < 9; i++) // ingore next 9 bytes |
| 538 | cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 539 | |
| 540 | *w = width = cf_ReadShortcxx . . $ cf_ReadShort(30b00389b433b379).(infile); |
| 541 | *h = height = cf_ReadShortcxx . . $ cf_ReadShort(30b00389b433b379).(infile); |
| 542 | pixsize = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 543 | |
| 544 | hsmap[0] = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(width * height); |
| 545 | |
| 546 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(hsmap); |
| 547 | |
| 548 | if (pixsize != 32) { |
| 549 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "menutga: This file has a pixsize of field of %d, it should be 32. ", pixsize); |
| 550 | return -1; |
| 551 | } |
| 552 | |
| 553 | descriptor = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 554 | if ((descriptor & 0x0F) != 8) { |
| 555 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "menutga: Descriptor field & 0x0F must be 8, but this is %d.", descriptor & 0x0F); |
| 556 | return -1; |
| 557 | } |
| 558 | |
| 559 | for (i = 0; i < image_id_len; i++) |
| 560 | cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 561 | |
| 562 | n = bm_AllocBitmapcxx . . $ bm_AllocBitmap(2326284602b0bb2d).(width, height, 0); |
| 563 | |
| 564 | if (n < 0) { |
| 565 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "menutga: Failed to allocate memory.\n"); |
| 566 | Int3cxx . . $ `misc/pserror.h:247:9`!(); |
| 567 | } |
| 568 | |
| 569 | upside_down = (descriptor & 0x20) >> 5; |
| 570 | upside_down = 1 - upside_down; |
| 571 | |
| 572 | // Load the actual bitmap data in, converting it from 32 bit to 16 bit, and replacing |
| 573 | // that pesky transparency color without our replacement |
| 574 | |
| 575 | for (i = 0; i < height; i++) { |
| 576 | for (t = 0; t < width; t++) { |
| 577 | pixel = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 578 | |
| 579 | uint16_tcxx . . $ uint16_t# newpix = menutga_translate_pixelcxx . . $ menutga_translate_pixel(7e0c9d8322f04898).(pixel, &alphavalue); |
| 580 | |
| 581 | if (upside_down) { |
| 582 | GameBitmapscxx . . $ GameBitmaps.[n].data16cxx . . $ bms_bitmap#data16.[((height - 1) - i) * width + t] = newpix; |
| 583 | hsmap[0][((height - 1) - i) * width + t] = alphavalue; |
| 584 | } else { |
| 585 | GameBitmapscxx . . $ GameBitmaps.[n].data16cxx . . $ bms_bitmap#data16.[i * width + t] = newpix; |
| 586 | hsmap[0][i * width + t] = alphavalue; |
| 587 | } |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | cfclosecxx . . $ cfclose(3639e799710acb68).(infile); |
| 592 | return (n); |
| 593 | } |
| 594 | |
| 595 | // TODO: MTS: only used in this file |
| 596 | // Given a filename and a hotspotmap structure, it saves it to disk (.HSM) |
| 597 | void menutga_SaveHotSpotMapcxx . . $ menutga_SaveHotSpotMap(144612ff950e0346).(const stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# &filename, hotspotmap_tcxx . . $ hotspotmap_t# *hsmap, windowmap_tcxx . . $ windowmap_t# *wndmap) { |
| 598 | CFILEcxx . . $ CFILE# *file; |
| 599 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Saving HotSpotMap %s ", filename.u8string().c_str()); |
| 600 | file = (CFILEcxx . . $ CFILE# *)cfopencxx . . $ cfopen(7c7b94e455f1ae56).(filename, "wb"); |
| 601 | if (!file) { |
| 602 | Int3cxx . . $ `misc/pserror.h:247:9`!(); // get jeff! |
| 603 | return; |
| 604 | } |
| 605 | |
| 606 | int curr_hs, curr_sl; |
| 607 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Number of HotSpots=%d\n", hsmap->num_of_hotspots); |
| 608 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(file, hsmap->num_of_hotspotscxx . . $ hotspotmap_t#num_of_hotspots.); |
| 609 | |
| 610 | for (curr_hs = 0; curr_hs < hsmap->num_of_hotspotscxx . . $ hotspotmap_t#num_of_hotspots.; curr_hs++) { |
| 611 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].starting_ycxx . . $ hotspot#starting_y.); |
| 612 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].scanlinescxx . . $ hotspot#scanlines.); |
| 613 | for (curr_sl = 0; curr_sl < hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].scanlinescxx . . $ hotspot#scanlines.; curr_sl++) { |
| 614 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].xcxx . . $ hotspot#x.[curr_sl].startcxx . . $ scanline#start.); |
| 615 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].xcxx . . $ hotspot#x.[curr_sl].endcxx . . $ scanline#end.); |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | int count; |
| 620 | int index, size; |
| 621 | |
| 622 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, wndmap->num_of_windowscxx . . $ windowmap_t#num_of_windows.); |
| 623 | for (count = 0; count < wndmap->num_of_windowscxx . . $ windowmap_t#num_of_windows.; count++) { |
| 624 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].xcxx . . $ window_box#x.); |
| 625 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].ycxx . . $ window_box#y.); |
| 626 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].widthcxx . . $ window_box#width.); |
| 627 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].heightcxx . . $ window_box#height.); |
| 628 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].l_start_xcxx . . $ window_box#l_start_x.); |
| 629 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].l_end_xcxx . . $ window_box#l_end_x.); |
| 630 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].r_start_xcxx . . $ window_box#r_start_x.); |
| 631 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].r_end_xcxx . . $ window_box#r_end_x.); |
| 632 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y.); |
| 633 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].t_bottom_ycxx . . $ window_box#t_bottom_y.); |
| 634 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y.); |
| 635 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].b_bottom_ycxx . . $ window_box#b_bottom_y.); |
| 636 | |
| 637 | if (wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y. != -1) { |
| 638 | // left top |
| 639 | size = ((wndmap->wmcxx . . $ windowmap_t#wm.[count].l_end_xcxx . . $ window_box#l_end_x.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].l_start_xcxx . . $ window_box#l_start_x.)) * |
| 640 | ((wndmap->wmcxx . . $ windowmap_t#wm.[count].t_bottom_ycxx . . $ window_box#t_bottom_y.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y.)); |
| 641 | for (index = 0; index < size; index++) { |
| 642 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].ltcxx . . $ window_box#lt.[index]); |
| 643 | } |
| 644 | // right top |
| 645 | size = ((wndmap->wmcxx . . $ windowmap_t#wm.[count].r_end_xcxx . . $ window_box#r_end_x.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].r_start_xcxx . . $ window_box#r_start_x.)) * |
| 646 | ((wndmap->wmcxx . . $ windowmap_t#wm.[count].t_bottom_ycxx . . $ window_box#t_bottom_y.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y.)); |
| 647 | for (index = 0; index < size; index++) { |
| 648 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].rtcxx . . $ window_box#rt.[index]); |
| 649 | } |
| 650 | } |
| 651 | if (wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y. != -1) { |
| 652 | // left bottom |
| 653 | size = ((wndmap->wmcxx . . $ windowmap_t#wm.[count].l_end_xcxx . . $ window_box#l_end_x.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].l_start_xcxx . . $ window_box#l_start_x.)) * |
| 654 | ((wndmap->wmcxx . . $ windowmap_t#wm.[count].b_bottom_ycxx . . $ window_box#b_bottom_y.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y.)); |
| 655 | for (index = 0; index < size; index++) { |
| 656 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].lbcxx . . $ window_box#lb.[index]); |
| 657 | } |
| 658 | // right bottom |
| 659 | size = ((wndmap->wmcxx . . $ windowmap_t#wm.[count].r_end_xcxx . . $ window_box#r_end_x.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].r_start_xcxx . . $ window_box#r_start_x.)) * |
| 660 | ((wndmap->wmcxx . . $ windowmap_t#wm.[count].b_bottom_ycxx . . $ window_box#b_bottom_y.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y.)); |
| 661 | for (index = 0; index < size; index++) { |
| 662 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(file, wndmap->wmcxx . . $ windowmap_t#wm.[count].rbcxx . . $ window_box#rb.[index]); |
| 663 | } |
| 664 | } |
| 665 | } |
| 666 | cfclosecxx . . $ cfclose(3639e799710acb68).(file); |
| 667 | } |
| 668 | |
| 669 | // Given a filename and a hotspotmap structure, it loads the hotspot map (.HSM) |
| 670 | void menutga_LoadHotSpotMapcxx . . $ menutga_LoadHotSpotMap(b6655629de763852).(int back_bmp, const char *filename, hotspotmap_tcxx . . $ hotspotmap_t# *hsmap, windowmap_tcxx . . $ windowmap_t# *wndmap) { |
| 671 | // start with a clean struct |
| 672 | if (hsmap->hscxx . . $ hotspotmap_t#hs.) { |
| 673 | FreeHotSpotMapInternalscxx . . $ FreeHotSpotMapInternals(40652d961f76803d).(hsmap); |
| 674 | } |
| 675 | |
| 676 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Loading hotspotmap %s ", filename); |
| 677 | |
| 678 | CFILEcxx . . $ CFILE# *infile; |
| 679 | infile = (CFILEcxx . . $ CFILE# *)cfopencxx . . $ cfopen(7c7b94e455f1ae56).(filenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "rb"); |
| 680 | if (!infile) { |
| 681 | Int3cxx . . $ `misc/pserror.h:247:9`!(); // get Jeff |
| 682 | return; |
| 683 | } |
| 684 | |
| 685 | hsmap->num_of_hotspotscxx . . $ hotspotmap_t#num_of_hotspots. = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 686 | |
| 687 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Contains: (%d hotspots) ", hsmap->num_of_hotspots); |
| 688 | |
| 689 | int curr_hs, curr_sl, num_sl; |
| 690 | |
| 691 | hsmap->hscxx . . $ hotspotmap_t#hs. = (hotspotcxx . . $ hotspot# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(hotspot) * hsmap->num_of_hotspots); |
| 692 | memset(hsmap->hscxx . . $ hotspotmap_t#hs., 0, sizeof(hotspotcxx . . $ hotspot#) * hsmap->num_of_hotspotscxx . . $ hotspotmap_t#num_of_hotspots.); |
| 693 | for (curr_hs = 0; curr_hs < hsmap->num_of_hotspotscxx . . $ hotspotmap_t#num_of_hotspots.; curr_hs++) { |
| 694 | hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].starting_ycxx . . $ hotspot#starting_y. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 695 | num_sl = hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].scanlinescxx . . $ hotspot#scanlines. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 696 | if (num_sl) { |
| 697 | hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].xcxx . . $ hotspot#x. = (scanlinecxx . . $ scanline# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(scanline) * hsmap->hs[curr_hs].scanlines); |
| 698 | memset(hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].xcxx . . $ hotspot#x., 0, sizeof(scanlinecxx . . $ scanline#) * hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].scanlinescxx . . $ hotspot#scanlines.); |
| 699 | for (curr_sl = 0; curr_sl < hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].scanlinescxx . . $ hotspot#scanlines.; curr_sl++) { |
| 700 | hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].xcxx . . $ hotspot#x.[curr_sl].startcxx . . $ scanline#start. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 701 | hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].xcxx . . $ hotspot#x.[curr_sl].endcxx . . $ scanline#end. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 702 | } |
| 703 | } else { |
| 704 | hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].xcxx . . $ hotspot#x. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | int count, index, size; |
| 709 | wndmap->num_of_windowscxx . . $ windowmap_t#num_of_windows. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 710 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "(%d Windows)\n", wndmap->num_of_windows); |
| 711 | wndmap->wmcxx . . $ windowmap_t#wm. = (window_boxcxx . . $ window_box# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(window_box) * wndmap->num_of_windows); |
| 712 | for (count = 0; count < wndmap->num_of_windowscxx . . $ windowmap_t#num_of_windows.; count++) { |
| 713 | wndmap->wmcxx . . $ windowmap_t#wm.[count].xcxx . . $ window_box#x. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 714 | wndmap->wmcxx . . $ windowmap_t#wm.[count].ycxx . . $ window_box#y. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 715 | wndmap->wmcxx . . $ windowmap_t#wm.[count].widthcxx . . $ window_box#width. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 716 | wndmap->wmcxx . . $ windowmap_t#wm.[count].heightcxx . . $ window_box#height. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 717 | wndmap->wmcxx . . $ windowmap_t#wm.[count].l_start_xcxx . . $ window_box#l_start_x. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 718 | wndmap->wmcxx . . $ windowmap_t#wm.[count].l_end_xcxx . . $ window_box#l_end_x. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 719 | wndmap->wmcxx . . $ windowmap_t#wm.[count].r_start_xcxx . . $ window_box#r_start_x. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 720 | wndmap->wmcxx . . $ windowmap_t#wm.[count].r_end_xcxx . . $ window_box#r_end_x. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 721 | wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 722 | wndmap->wmcxx . . $ windowmap_t#wm.[count].t_bottom_ycxx . . $ window_box#t_bottom_y. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 723 | wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 724 | wndmap->wmcxx . . $ windowmap_t#wm.[count].b_bottom_ycxx . . $ window_box#b_bottom_y. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 725 | |
| 726 | if (wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y. != -1) { |
| 727 | // left top |
| 728 | size = ((wndmap->wmcxx . . $ windowmap_t#wm.[count].l_end_xcxx . . $ window_box#l_end_x.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].l_start_xcxx . . $ window_box#l_start_x.)) * |
| 729 | ((wndmap->wmcxx . . $ windowmap_t#wm.[count].t_bottom_ycxx . . $ window_box#t_bottom_y.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y.)); |
| 730 | wndmap->wmcxx . . $ windowmap_t#wm.[count].ltcxx . . $ window_box#lt. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(size); |
| 731 | for (index = 0; index < size; index++) { |
| 732 | wndmap->wmcxx . . $ windowmap_t#wm.[count].ltcxx . . $ window_box#lt.[index] = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 733 | } |
| 734 | |
| 735 | // right top |
| 736 | size = ((wndmap->wmcxx . . $ windowmap_t#wm.[count].r_end_xcxx . . $ window_box#r_end_x.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].r_start_xcxx . . $ window_box#r_start_x.)) * |
| 737 | ((wndmap->wmcxx . . $ windowmap_t#wm.[count].t_bottom_ycxx . . $ window_box#t_bottom_y.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y.)); |
| 738 | wndmap->wmcxx . . $ windowmap_t#wm.[count].rtcxx . . $ window_box#rt. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(size); |
| 739 | for (index = 0; index < size; index++) { |
| 740 | wndmap->wmcxx . . $ windowmap_t#wm.[count].rtcxx . . $ window_box#rt.[index] = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | if (wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y. != -1) { |
| 745 | // left bottom |
| 746 | size = ((wndmap->wmcxx . . $ windowmap_t#wm.[count].l_end_xcxx . . $ window_box#l_end_x.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].l_start_xcxx . . $ window_box#l_start_x.)) * |
| 747 | ((wndmap->wmcxx . . $ windowmap_t#wm.[count].b_bottom_ycxx . . $ window_box#b_bottom_y.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y.)); |
| 748 | wndmap->wmcxx . . $ windowmap_t#wm.[count].lbcxx . . $ window_box#lb. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(size); |
| 749 | for (index = 0; index < size; index++) { |
| 750 | wndmap->wmcxx . . $ windowmap_t#wm.[count].lbcxx . . $ window_box#lb.[index] = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 751 | } |
| 752 | // right bottom |
| 753 | size = ((wndmap->wmcxx . . $ windowmap_t#wm.[count].r_end_xcxx . . $ window_box#r_end_x.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].r_start_xcxx . . $ window_box#r_start_x.)) * |
| 754 | ((wndmap->wmcxx . . $ windowmap_t#wm.[count].b_bottom_ycxx . . $ window_box#b_bottom_y.) - (wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y.)); |
| 755 | wndmap->wmcxx . . $ windowmap_t#wm.[count].rbcxx . . $ window_box#rb. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(size); |
| 756 | for (index = 0; index < size; index++) { |
| 757 | wndmap->wmcxx . . $ windowmap_t#wm.[count].rbcxx . . $ window_box#rb.[index] = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 758 | } |
| 759 | } |
| 760 | } |
| 761 | cfclosecxx . . $ cfclose(3639e799710acb68).(infile); |
| 762 | |
| 763 | // make the corner bitmaps, with transparency |
| 764 | for (count = 0; count < wndmap->num_of_windowscxx . . $ windowmap_t#num_of_windows.; count++) { |
| 765 | if (wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y. != -1) { |
| 766 | // left top |
| 767 | wndmap->wmcxx . . $ windowmap_t#wm.[count].lt_bmpcxx . . $ window_box#lt_bmp. = bm_AllocBitmapcxx . . $ bm_AllocBitmap(2326284602b0bb2d).(wndmap->wmcxx . . $ windowmap_t#wm.[count].l_end_xcxx . . $ window_box#l_end_x. - wndmap->wmcxx . . $ windowmap_t#wm.[count].l_start_xcxx . . $ window_box#l_start_x., |
| 768 | wndmap->wmcxx . . $ windowmap_t#wm.[count].t_bottom_ycxx . . $ window_box#t_bottom_y. - wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y., 0); |
| 769 | makecornercxx . . $ makecorner(aa6cfca089dba86d).(wndmap->wmcxx . . $ windowmap_t#wm.[count].lt_bmpcxx . . $ window_box#lt_bmp., back_bmp, wndmap->wmcxx . . $ windowmap_t#wm.[count].ltcxx . . $ window_box#lt., wndmap->wmcxx . . $ windowmap_t#wm.[count].l_start_xcxx . . $ window_box#l_start_x., |
| 770 | wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y., wndmap->wmcxx . . $ windowmap_t#wm.[count].l_end_xcxx . . $ window_box#l_end_x., wndmap->wmcxx . . $ windowmap_t#wm.[count].t_bottom_ycxx . . $ window_box#t_bottom_y.); |
| 771 | |
| 772 | // right top |
| 773 | wndmap->wmcxx . . $ windowmap_t#wm.[count].rt_bmpcxx . . $ window_box#rt_bmp. = bm_AllocBitmapcxx . . $ bm_AllocBitmap(2326284602b0bb2d).(wndmap->wmcxx . . $ windowmap_t#wm.[count].r_end_xcxx . . $ window_box#r_end_x. - wndmap->wmcxx . . $ windowmap_t#wm.[count].r_start_xcxx . . $ window_box#r_start_x., |
| 774 | wndmap->wmcxx . . $ windowmap_t#wm.[count].t_bottom_ycxx . . $ window_box#t_bottom_y. - wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y., 0); |
| 775 | makecornercxx . . $ makecorner(aa6cfca089dba86d).(wndmap->wmcxx . . $ windowmap_t#wm.[count].rt_bmpcxx . . $ window_box#rt_bmp., back_bmp, wndmap->wmcxx . . $ windowmap_t#wm.[count].rtcxx . . $ window_box#rt., wndmap->wmcxx . . $ windowmap_t#wm.[count].r_start_xcxx . . $ window_box#r_start_x., |
| 776 | wndmap->wmcxx . . $ windowmap_t#wm.[count].t_top_ycxx . . $ window_box#t_top_y., wndmap->wmcxx . . $ windowmap_t#wm.[count].r_end_xcxx . . $ window_box#r_end_x., wndmap->wmcxx . . $ windowmap_t#wm.[count].t_bottom_ycxx . . $ window_box#t_bottom_y.); |
| 777 | if (wndmap->wmcxx . . $ windowmap_t#wm.[count].ltcxx . . $ window_box#lt.) |
| 778 | mem_freecxx . . $ `mem/mem.h:80:9`!(wndmap->wm[count].lt); |
| 779 | if (wndmap->wmcxx . . $ windowmap_t#wm.[count].rtcxx . . $ window_box#rt.) |
| 780 | mem_freecxx . . $ `mem/mem.h:80:9`!(wndmap->wm[count].rt); |
| 781 | } |
| 782 | |
| 783 | if (wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y. != -1) { |
| 784 | // left bottom |
| 785 | wndmap->wmcxx . . $ windowmap_t#wm.[count].lb_bmpcxx . . $ window_box#lb_bmp. = bm_AllocBitmapcxx . . $ bm_AllocBitmap(2326284602b0bb2d).(wndmap->wmcxx . . $ windowmap_t#wm.[count].l_end_xcxx . . $ window_box#l_end_x. - wndmap->wmcxx . . $ windowmap_t#wm.[count].l_start_xcxx . . $ window_box#l_start_x., |
| 786 | wndmap->wmcxx . . $ windowmap_t#wm.[count].b_bottom_ycxx . . $ window_box#b_bottom_y. - wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y., 0); |
| 787 | makecornercxx . . $ makecorner(aa6cfca089dba86d).(wndmap->wmcxx . . $ windowmap_t#wm.[count].lb_bmpcxx . . $ window_box#lb_bmp., back_bmp, wndmap->wmcxx . . $ windowmap_t#wm.[count].lbcxx . . $ window_box#lb., wndmap->wmcxx . . $ windowmap_t#wm.[count].l_start_xcxx . . $ window_box#l_start_x., |
| 788 | wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y., wndmap->wmcxx . . $ windowmap_t#wm.[count].l_end_xcxx . . $ window_box#l_end_x., wndmap->wmcxx . . $ windowmap_t#wm.[count].b_bottom_ycxx . . $ window_box#b_bottom_y.); |
| 789 | |
| 790 | // right bottom |
| 791 | wndmap->wmcxx . . $ windowmap_t#wm.[count].rb_bmpcxx . . $ window_box#rb_bmp. = bm_AllocBitmapcxx . . $ bm_AllocBitmap(2326284602b0bb2d).(wndmap->wmcxx . . $ windowmap_t#wm.[count].r_end_xcxx . . $ window_box#r_end_x. - wndmap->wmcxx . . $ windowmap_t#wm.[count].r_start_xcxx . . $ window_box#r_start_x., |
| 792 | wndmap->wmcxx . . $ windowmap_t#wm.[count].b_bottom_ycxx . . $ window_box#b_bottom_y. - wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y., 0); |
| 793 | makecornercxx . . $ makecorner(aa6cfca089dba86d).(wndmap->wmcxx . . $ windowmap_t#wm.[count].rb_bmpcxx . . $ window_box#rb_bmp., back_bmp, wndmap->wmcxx . . $ windowmap_t#wm.[count].rbcxx . . $ window_box#rb., wndmap->wmcxx . . $ windowmap_t#wm.[count].r_start_xcxx . . $ window_box#r_start_x., |
| 794 | wndmap->wmcxx . . $ windowmap_t#wm.[count].b_top_ycxx . . $ window_box#b_top_y., wndmap->wmcxx . . $ windowmap_t#wm.[count].r_end_xcxx . . $ window_box#r_end_x., wndmap->wmcxx . . $ windowmap_t#wm.[count].b_bottom_ycxx . . $ window_box#b_bottom_y.); |
| 795 | if (wndmap->wmcxx . . $ windowmap_t#wm.[count].lbcxx . . $ window_box#lb.) |
| 796 | mem_freecxx . . $ `mem/mem.h:80:9`!(wndmap->wm[count].lb); |
| 797 | if (wndmap->wmcxx . . $ windowmap_t#wm.[count].rbcxx . . $ window_box#rb.) |
| 798 | mem_freecxx . . $ `mem/mem.h:80:9`!(wndmap->wm[count].rb); |
| 799 | } |
| 800 | } |
| 801 | } |
| 802 | |
| 803 | void makecornercxx . . $ makecorner(aa6cfca089dba86d).(int corner_bmp, int back_bmp, const char *tmap, int l, int t, int r, int b) { |
| 804 | int real_x, real_y, awidth, ax, ay; |
| 805 | int16_t *backdata, *cornerdata; |
| 806 | int back_rowsize, corner_rowsize; |
| 807 | |
| 808 | awidth = r - l; |
| 809 | bm_ClearBitmapcxx . . $ bm_ClearBitmap(d4f767463ce0a6b3).(corner_bmp); |
| 810 | backdata = (int16_t *)bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(back_bmp, 0); |
| 811 | back_rowsize = bm_rowsizecxx . . $ bm_rowsize(9b79fb6aee4c0440).(back_bmp, 0); |
| 812 | cornerdata = (int16_t *)bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(corner_bmp, 0); |
| 813 | corner_rowsize = bm_rowsizecxx . . $ bm_rowsize(9b79fb6aee4c0440).(corner_bmp, 0); |
| 814 | |
| 815 | backdata += (t * (back_rowsize / 2)); |
| 816 | |
| 817 | for (real_y = t, ay = 0; real_y < b; real_y++, ay++) { |
| 818 | for (real_x = l, ax = 0; real_x < r; real_x++, ax++) { |
| 819 | if (!tmap[ay * awidth + ax]) { |
| 820 | // not transparent |
| 821 | cornerdata[ax] = backdata[real_x]; |
| 822 | } |
| 823 | } |
| 824 | cornerdata += (corner_rowsize / 2); |
| 825 | backdata += (back_rowsize / 2); |
| 826 | } |
| 827 | } |
| 828 | |
| 829 | // This function frees up the allocated memory within a hotspotmap struct. It does not free up the struct though. |
| 830 | void FreeHotSpotMapInternalscxx . . $ FreeHotSpotMapInternals(40652d961f76803d).(hotspotmap_tcxx . . $ hotspotmap_t# *hsmap) { |
| 831 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Freeing HSM internals\n"); |
| 832 | |
| 833 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(hsmap); |
| 834 | |
| 835 | if (!hsmap->hscxx . . $ hotspotmap_t#hs.) |
| 836 | return; |
| 837 | |
| 838 | int curr_hs; |
| 839 | int num_hs; |
| 840 | |
| 841 | num_hs = hsmap->num_of_hotspotscxx . . $ hotspotmap_t#num_of_hotspots.; |
| 842 | for (curr_hs = 0; curr_hs < num_hs; curr_hs++) { |
| 843 | if (hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].scanlinescxx . . $ hotspot#scanlines.) { |
| 844 | if (hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].xcxx . . $ hotspot#x.) { |
| 845 | mem_freecxx . . $ `mem/mem.h:80:9`!(hsmap->hs[curr_hs].x); |
| 846 | hsmap->hscxx . . $ hotspotmap_t#hs.[curr_hs].xcxx . . $ hotspot#x. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 847 | } |
| 848 | } |
| 849 | } |
| 850 | if (hsmap->hscxx . . $ hotspotmap_t#hs.) { |
| 851 | mem_freecxx . . $ `mem/mem.h:80:9`!(hsmap->hs); |
| 852 | hsmap->hscxx . . $ hotspotmap_t#hs. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 853 | } |
| 854 | } |
| 855 | |
| 856 | // This function (given a filename) loads a TGA file, extracts a hotspot map, and saves the hotspot map |
| 857 | bool menutga_ConvertTGAtoHSMcxx . . $ menutga_ConvertTGAtoHSM(c5f7da30cbc0f4e9).(const char *fpath) { |
| 858 | char path[255], filename[255], ext[8]; |
| 859 | ddio_SplitPathcxx . . $ ddio_SplitPath(b05ba7ab99603c07).(fpath, path, filename, ext); |
| 860 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Extracting hotspots from %s\n", filename); |
| 861 | |
| 862 | // strip file name |
| 863 | int index, width = 0, height = 0; |
| 864 | char *menu_filename; |
| 865 | hotspotmap_tcxx . . $ hotspotmap_t# hsmap; |
| 866 | windowmap_tcxx . . $ windowmap_t# wndmap; |
| 867 | |
| 868 | wndmap.num_of_windowscxx . . $ windowmap_t#num_of_windows. = 0; |
| 869 | wndmap.wmcxx . . $ windowmap_t#wm. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 870 | hsmap.hscxx . . $ hotspotmap_t#hs. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 871 | hsmap.num_of_hotspotscxx . . $ hotspotmap_t#num_of_hotspots. = 0; |
| 872 | |
| 873 | for (index = (signed)strlen(filename); index >= 0; index--) { |
| 874 | if (filename[index] == '.') { |
| 875 | filename[index] = '\0'; |
| 876 | index = -1; |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | int size = strlen(filename) + 5; |
| 881 | menu_filename = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(size); |
| 882 | strcpy(menu_filename, filename); |
| 883 | strcat(menu_filename, ".HSM"); // Hot Spot Map |
| 884 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "HSM=%s\n", menu_filename); |
| 885 | |
| 886 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# save_path = LocalManageGraphicsDircxx . . $ LocalManageGraphicsDir. /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). menu_filenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).; |
| 887 | |
| 888 | // now load up the tga and alloc it, then save it with the alpha hotspots |
| 889 | int bm_handle; |
| 890 | char *map[1]; |
| 891 | bm_handle = menutga_alloc_filecxx . . $ menutga_alloc_file(aa5a3b94b7175785).(fpath, map, &width, &height); |
| 892 | if (bm_handle == -1) |
| 893 | return false; |
| 894 | wndmap.num_of_windowscxx . . $ windowmap_t#num_of_windows. = CreateHotSpotMapcxx . . $ CreateHotSpotMap(1c06fcac5451a5ba).(map[0], width, height, &hsmap); |
| 895 | if (wndmap.num_of_windowscxx . . $ windowmap_t#num_of_windows. == -1) |
| 896 | return false; // DAJ -1FIX |
| 897 | CreateWindowMapcxx . . $ CreateWindowMap(e71e6955f2433003).(map[0], width, height, &wndmap); |
| 898 | menutga_SaveHotSpotMapcxx . . $ menutga_SaveHotSpotMap(144612ff950e0346).(save_path, &hsmap, &wndmap); |
| 899 | ExportHotSpotcxx . . $ ExportHotSpot(beb635a7fb038926).("C:\\hotspot.txt", &hsmap); |
| 900 | mem_freecxx . . $ `mem/mem.h:80:9`!(menu_filename); |
| 901 | mem_freecxx . . $ `mem/mem.h:80:9`!(map[0]); |
| 902 | FreeHotSpotMapInternalscxx . . $ FreeHotSpotMapInternals(40652d961f76803d).(&hsmap); |
| 903 | for (index = 0; index < wndmap.num_of_windowscxx . . $ windowmap_t#num_of_windows.; index++) { |
| 904 | if (wndmap.wmcxx . . $ windowmap_t#wm.[index].ltcxx . . $ window_box#lt.) |
| 905 | mem_freecxx . . $ `mem/mem.h:80:9`!(wndmap.wm[index].lt); |
| 906 | if (wndmap.wmcxx . . $ windowmap_t#wm.[index].rtcxx . . $ window_box#rt.) |
| 907 | mem_freecxx . . $ `mem/mem.h:80:9`!(wndmap.wm[index].rt); |
| 908 | if (wndmap.wmcxx . . $ windowmap_t#wm.[index].lbcxx . . $ window_box#lb.) |
| 909 | mem_freecxx . . $ `mem/mem.h:80:9`!(wndmap.wm[index].lb); |
| 910 | if (wndmap.wmcxx . . $ windowmap_t#wm.[index].rbcxx . . $ window_box#rb.) |
| 911 | mem_freecxx . . $ `mem/mem.h:80:9`!(wndmap.wm[index].rb); |
| 912 | } |
| 913 | if (wndmap.wmcxx . . $ windowmap_t#wm.) |
| 914 | mem_freecxx . . $ `mem/mem.h:80:9`!(wndmap.wm); |
| 915 | return true; |
| 916 | } |
| 917 | |
| 918 | // TODO: MTS: Unused? |
| 919 | // Given a hotspotmap structure, it draws the pretty hotspot map to the screen (blue areas are the hotspots) |
| 920 | void DisplayHotSpotscxx . . $ DisplayHotSpots(6b739274a49b7b38).(hotspotmap_tcxx . . $ hotspotmap_t# *hsmap, windowmap_tcxx . . $ windowmap_t# *wndmap) { |
| 921 | //@@ grSurface *cursurf; |
| 922 | //@@ int count,curr_y,scanline_count; |
| 923 | //@@ hotspot *curr_hotspot; |
| 924 | //@@ |
| 925 | //@@ |
| 926 | //@@ cursurf=Game_viewport->lock(); |
| 927 | //@@ for(count=0;count<hsmap->num_of_hotspots;count++) |
| 928 | //@@ { |
| 929 | //@@ curr_hotspot=&hsmap->hs[count]; |
| 930 | //@@ curr_y=curr_hotspot->starting_y; |
| 931 | //@@ for(scanline_count=0;scanline_count<curr_hotspot->scanlines;scanline_count++) |
| 932 | //@@ { |
| 933 | //@@ Game_viewport->hline(GR_RGB(0,0,255),curr_hotspot->x[scanline_count].start, |
| 934 | //@@ |
| 935 | // curr_hotspot->x[scanline_count].end,curr_y+scanline_count); |
| 936 | //@@ } |
| 937 | //@@ } |
| 938 | //@@ |
| 939 | //@@ for(count=0;count<wndmap->num_of_windows;count++) |
| 940 | //@@ { |
| 941 | //@@ for(scanline_count=0;scanline_count<curr_hotspot->scanlines;scanline_count++) |
| 942 | //@@ { |
| 943 | //@@ Game_viewport->fillrect(GR_RGB(255,0,0), wndmap->wm[count].x,wndmap->wm[count].y, |
| 944 | //@@ |
| 945 | // wndmap->wm[count].x+wndmap->wm[count].width-1,wndmap->wm[count].y+wndmap->wm[count].height-1); |
| 946 | //@@ //if there is a writeable area, display it |
| 947 | //@@ if(wndmap->wm[count].t_top_y!=-1) |
| 948 | //@@ { |
| 949 | //@@ Game_viewport->fillrect(GR_RGB(128,128,128), |
| 950 | // wndmap->wm[count].l_start_x,wndmap->wm[count].t_top_y, |
| 951 | //@@ wndmap->wm[count].l_end_x,wndmap->wm[count].t_bottom_y); |
| 952 | //@@ Game_viewport->fillrect(GR_RGB(128,128,128), |
| 953 | // wndmap->wm[count].r_start_x,wndmap->wm[count].t_top_y, |
| 954 | //@@ wndmap->wm[count].r_end_x,wndmap->wm[count].t_bottom_y); |
| 955 | //@@ } |
| 956 | //@@ if(wndmap->wm[count].b_top_y!=-1) |
| 957 | //@@ { |
| 958 | //@@ Game_viewport->fillrect(GR_RGB(128,128,128), |
| 959 | // wndmap->wm[count].l_start_x,wndmap->wm[count].b_top_y, |
| 960 | //@@ wndmap->wm[count].l_end_x,wndmap->wm[count].b_bottom_y); |
| 961 | //@@ Game_viewport->fillrect(GR_RGB(128,128,128), |
| 962 | // wndmap->wm[count].r_start_x,wndmap->wm[count].b_top_y, |
| 963 | //@@ wndmap->wm[count].r_end_x,wndmap->wm[count].b_bottom_y); |
| 964 | //@@ } |
| 965 | //@@ |
| 966 | //@@ } |
| 967 | //@@ } |
| 968 | //@@ |
| 969 | //@@ Game_viewport->unlock(); |
| 970 | //@@ Game_screen->flip(); |
| 971 | } |
| 972 | |
| 973 | // TODO: MTS: only used in this file |
| 974 | // Writes a hotspotmap_t struct to a text file |
| 975 | void ExportHotSpotcxx . . $ ExportHotSpot(beb635a7fb038926).(const char *filename, hotspotmap_tcxx . . $ hotspotmap_t# *hsmap) { |
| 976 | CFILEcxx . . $ CFILE# *file; |
| 977 | file = (CFILEcxx . . $ CFILE# *)cfopencxx . . $ cfopen(7c7b94e455f1ae56).(filenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "wt"); |
| 978 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(file); |
| 979 | char buffer[256]; |
| 980 | |
| 981 | int i, j; |
| 982 | snprintf(buffer, sizeof(buffer), "Number of HotSpots = %d", hsmap->num_of_hotspotscxx . . $ hotspotmap_t#num_of_hotspots.); |
| 983 | cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(file, buffer); |
| 984 | for (i = 0; i < hsmap->num_of_hotspotscxx . . $ hotspotmap_t#num_of_hotspots.; i++) { |
| 985 | snprintf(buffer, sizeof(buffer), "\n-%d-Scanlines = %d", i, hsmap->hscxx . . $ hotspotmap_t#hs.[i].scanlinescxx . . $ hotspot#scanlines.); |
| 986 | cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(file, buffer); |
| 987 | for (j = 0; j < hsmap->hscxx . . $ hotspotmap_t#hs.[i].scanlinescxx . . $ hotspot#scanlines.; j++) { |
| 988 | snprintf(buffer, sizeof(buffer), "----Y=%d StartX=%d EndX=%d", hsmap->hscxx . . $ hotspotmap_t#hs.[i].starting_ycxx . . $ hotspot#starting_y. + j, |
| 989 | hsmap->hscxx . . $ hotspotmap_t#hs.[i].xcxx . . $ hotspot#x.[j].startcxx . . $ scanline#start., hsmap->hscxx . . $ hotspotmap_t#hs.[i].xcxx . . $ hotspot#x.[j].endcxx . . $ scanline#end.); |
| 990 | cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(file, buffer); |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | cfclosecxx . . $ cfclose(3639e799710acb68).(file); |
| 995 | } |