1 /* 2 SDLPoP, a port/conversion of the DOS game Prince of Persia. 3 Copyright (C) 2013-2021 Dávid Nagy 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 <https://www.gnu.org/licenses/>. 17 18 The authors of this program may be contacted at https://forum.princed.org 19 */ 20 21 #ifndef TYPES_H 22 #define TYPES_H 23 24 #define STB_VORBIS_HEADER_ONLY 25 #include "stb_vorbis.c" 26 27 //#if !defined(_MSC_VER) 28 //# include <SDL2/SDL.h> 29 //# include <SDL2/SDL_image.h> 30 //#else 31 // These headers for SDL seem to be the pkgconfig/meson standard as per the 32 // latest versions. If the old ones should be used, the ifdef must be used 33 // to compare versions. 34 # include <SDL.h> 35 # include <SDL_image.h> 36 //#endif 37 38 #if SDL_BYTEORDER != SDL_LIL_ENDIAN 39 #error This program is not (yet) prepared for big endian CPUs, please contact the author. 40 #endif 41 42 // This macro is from SDL_types.h / SDL_stdinc.h . 43 // It used to be #undefined at the end of that file, but since some time in 2006 it's kept available. 44 // And SDL's definition changed in SDL 2.0.6, which caused a warning at this redefinition. 45 // So we should just use the macro from SDL and not define our own. 46 /* Make sure the types really have the right sizes */ 47 /* 48 #define SDL_COMPILE_TIME_ASSERT(name, x) \ 49 typedef int SDL_dummy_ ## name[(x) * 2 - 1] 50 */ 51 52 // "far" and "near" makes sense only for 16-bit 53 #define far 54 #define near 55 #define __pascal 56 #define malloc_near malloc 57 #define malloc_far malloc 58 #define free_near free 59 #define free_far free 60 #define memset_near memset 61 #define memset_far memset 62 #define memcpy_near memcpy 63 #define memcpy_far memcpy 64 65 typedef Uint8 byte; 66 typedef Sint8 sbyte; 67 typedef Uint16 word; 68 typedef Uint32 dword; 69 70 typedef struct rect_type { 71 short top,left,bottom,right; 72 } rect_type; 73 74 typedef struct piece { 75 byte base_id; 76 byte floor_left; 77 sbyte base_y; 78 byte right_id; 79 byte floor_right; 80 sbyte right_y; 81 byte stripe_id; 82 byte topright_id; 83 byte bottom_id; 84 byte fore_id; 85 byte fore_x; 86 sbyte fore_y; 87 } piece; 88 typedef struct tile_and_mod { 89 byte tiletype; 90 byte modifier; 91 } tile_and_mod; 92 93 typedef int __pascal far (*add_table_type)(short chtab_id, int id, sbyte xh, sbyte xl, int ybottom, int blit, byte peel); 94 95 typedef struct back_table_type { 96 sbyte xh; 97 sbyte xl; 98 short y; 99 byte chtab_id; 100 byte id; 101 int blit; 102 } back_table_type; 103 104 typedef struct midtable_type { 105 sbyte xh; 106 sbyte xl; 107 short y; 108 byte chtab_id; 109 byte id; 110 byte peel; 111 rect_type clip; 112 int blit; 113 } midtable_type; 114 115 typedef struct wipetable_type { 116 short left; 117 short bottom; 118 sbyte height; 119 short width; 120 sbyte color; 121 sbyte layer; 122 } wipetable_type; 123 124 enum soundflags { sfDigi=1, sfMidi=2, soundflags_4=4, sfLoop=0x80 }; 125 126 enum tiles { 127 tiles_0_empty = 0, 128 tiles_1_floor = 1, 129 tiles_2_spike = 2, 130 tiles_3_pillar = 3, 131 tiles_4_gate = 4, 132 tiles_5_stuck = 5, 133 tiles_6_closer = 6, // a.k.a. drop button 134 tiles_7_doortop_with_floor = 7, // a.k.a. tapestry 135 tiles_8_bigpillar_bottom = 8, 136 tiles_9_bigpillar_top = 9, 137 tiles_10_potion = 10, 138 tiles_11_loose = 11, 139 tiles_12_doortop = 12, // a.k.a. tapestry top 140 tiles_13_mirror = 13, 141 tiles_14_debris = 14, // a.k.a. broken floor 142 tiles_15_opener = 15, // a.k.a. raise button 143 tiles_16_level_door_left = 16, // a.k.a. exit door 144 tiles_17_level_door_right = 17, 145 tiles_18_chomper = 18, 146 tiles_19_torch = 19, 147 tiles_20_wall = 20, 148 tiles_21_skeleton = 21, 149 tiles_22_sword = 22, 150 tiles_23_balcony_left = 23, 151 tiles_24_balcony_right = 24, 152 tiles_25_lattice_pillar = 25, 153 tiles_26_lattice_down = 26, // a.k.a. lattice support 154 tiles_27_lattice_small = 27, 155 tiles_28_lattice_left = 28, 156 tiles_29_lattice_right = 29, 157 tiles_30_torch_with_debris = 30 158 }; 159 160 enum chtabs { 161 id_chtab_0_sword = 0, 162 id_chtab_1_flameswordpotion = 1, 163 id_chtab_2_kid = 2, 164 id_chtab_3_princessinstory = 3, 165 id_chtab_4_jaffarinstory_princessincutscenes = 4, 166 id_chtab_5_guard = 5, 167 id_chtab_6_environment = 6, 168 id_chtab_7_environmentwall = 7, 169 id_chtab_8_princessroom = 8, 170 id_chtab_9_princessbed = 9 171 }; 172 173 enum blitters { 174 blitters_0_no_transp = 0, 175 // It seems to me that the "or" blitter can be safely replaced with the "transparent" blitter. 176 blitters_2_or = 2, 177 blitters_3_xor = 3, // used for the shadow 178 blitters_white = 8, 179 blitters_9_black = 9, 180 blitters_10h_transp = 0x10, 181 /* 0x40..0x4F will draw a monochrome image with color 0..15 */ 182 blitters_40h_mono = 0x40, 183 blitters_46h_mono_6 = 0x46, // used for palace wall patterns 184 blitters_4Ch_mono_12 = 0x4C, // used for chomper blood 185 #ifdef USE_COLORED_TORCHES 186 blitters_colored_flame = 0x100, 187 blitters_colored_flame_last = 0x13F, 188 #endif 189 }; 190 191 enum full_image_id { 192 TITLE_MAIN = 0, 193 TITLE_PRESENTS, 194 TITLE_GAME, 195 TITLE_POP, 196 TITLE_MECHNER, 197 HOF_POP, 198 STORY_FRAME, 199 STORY_ABSENCE, 200 STORY_MARRY, 201 STORY_HAIL, 202 STORY_CREDITS, 203 MAX_FULL_IMAGES 204 }; 205 206 enum grmodes { 207 gmCga = 1, 208 gmHgaHerc = 2, 209 gmEga = 3, 210 gmTga = 4, 211 gmMcgaVga = 5 212 }; 213 214 enum sound_modes { 215 smAuto = 0, 216 smAdlib = 1, 217 smGblast = 2, 218 smSblast = 3, 219 smCovox = 4, 220 smIbmg = 5, 221 smTandy = 6 222 }; 223 224 #pragma pack(push,1) 225 typedef struct link_type { 226 byte left,right,up,down; 227 } link_type; 228 229 typedef struct level_type { 230 byte fg[720]; 231 byte bg[720]; 232 byte doorlinks1[256]; 233 byte doorlinks2[256]; 234 link_type roomlinks[24]; 235 byte used_rooms; 236 byte roomxs[24]; 237 byte roomys[24]; 238 byte fill_1[15]; 239 byte start_room; 240 byte start_pos; 241 sbyte start_dir; 242 byte fill_2[4]; 243 byte guards_tile[24]; 244 byte guards_dir[24]; 245 byte guards_x[24]; 246 byte guards_seq_lo[24]; 247 byte guards_skill[24]; 248 byte guards_seq_hi[24]; 249 byte guards_color[24]; 250 byte fill_3[18]; 251 } level_type; 252 SDL_COMPILE_TIME_ASSERT(level_size, sizeof(level_type) == 2305); 253 #pragma pack(pop) 254 255 typedef SDL_Surface surface_type; 256 typedef SDL_Surface image_type; 257 typedef struct peel_type { 258 SDL_Surface* peel; 259 rect_type rect; 260 } peel_type; 261 262 typedef struct chtab_type { 263 word n_images; 264 word chtab_palette_bits; 265 word has_palette_bits; 266 // This is a variable-size array, with n_images elements. 267 image_type* far images[]; 268 } chtab_type; 269 270 typedef struct full_image_type { 271 int id; 272 chtab_type** chtab; 273 enum blitters blitter; 274 int xpos, ypos; 275 } full_image_type; 276 277 #pragma pack(push,1) 278 typedef struct rgb_type { 279 byte r,g,b; 280 } rgb_type; 281 typedef struct dat_pal_type { 282 word row_bits; 283 byte n_colors; 284 rgb_type vga[16]; 285 byte cga[16]; 286 byte ega[32]; 287 } dat_pal_type; 288 typedef struct dat_shpl_type { 289 byte n_images; 290 dat_pal_type palette; 291 } dat_shpl_type; 292 SDL_COMPILE_TIME_ASSERT(dat_shpl_size, sizeof(dat_shpl_type) == 100); 293 #pragma pack(pop) 294 295 typedef struct char_type { 296 byte frame; 297 byte x; 298 byte y; 299 sbyte direction; 300 sbyte curr_col; 301 sbyte curr_row; 302 byte action; 303 sbyte fall_x; 304 sbyte fall_y; 305 byte room; 306 byte repeat; 307 byte charid; 308 byte sword; 309 sbyte alive; 310 word curr_seq; 311 } char_type; 312 313 enum charids { 314 charid_0_kid = 0, 315 charid_1_shadow = 1, 316 charid_2_guard = 2, 317 charid_3 = 3, 318 charid_4_skeleton = 4, 319 charid_5_princess = 5, 320 charid_6_vizier = 6, 321 charid_24_mouse = 0x18 322 }; 323 324 enum sword_status { 325 sword_0_sheathed = 0, 326 sword_2_drawn = 2 327 }; 328 329 typedef struct auto_move_type { 330 short time,move; 331 } auto_move_type; 332 333 /* obj_type: 334 0 = Kid, princess, vizier 335 1 = shadow 336 2 = Guard 337 3 = sword 338 4 = mirror image 339 5 = hurt splash 340 0x80 = loose floor 341 */ 342 typedef struct objtable_type { 343 sbyte xh; 344 sbyte xl; 345 short y; 346 byte chtab_id; 347 byte id; 348 sbyte direction; 349 byte obj_type; 350 rect_type clip; 351 byte tilepos; 352 } objtable_type; 353 354 typedef struct frame_type { 355 byte image; 356 357 // 0x3F: sword image 358 // 0xC0: chtab 359 byte sword; 360 361 sbyte dx; 362 sbyte dy; 363 364 // 0x1F: weight x 365 // 0x20: thin 366 // 0x40: needs floor 367 // 0x80: even/odd pixel 368 byte flags; 369 } frame_type; 370 371 enum frame_flags { 372 FRAME_WEIGHT_X = 0x1F, 373 FRAME_THIN = 0x20, 374 FRAME_NEEDS_FLOOR = 0x40, 375 FRAME_EVEN_ODD_PIXEL = 0x80, 376 }; 377 378 typedef struct trob_type { 379 byte tilepos; 380 byte room; 381 sbyte type; 382 } trob_type; 383 384 typedef struct mob_type { 385 byte xh; 386 byte y; 387 byte room; 388 sbyte speed; 389 byte type; 390 byte row; 391 } mob_type; 392 393 enum directions { 394 dir_0_right = 0x00, 395 dir_56_none = 0x56, 396 dir_FF_left = -1 397 }; 398 399 enum actions { 400 actions_0_stand = 0, 401 actions_1_run_jump = 1, 402 actions_2_hang_climb = 2, 403 actions_3_in_midair = 3, 404 actions_4_in_freefall = 4, 405 actions_5_bumped = 5, 406 actions_6_hang_straight = 6, 407 actions_7_turn = 7, 408 actions_99_hurt = 99, 409 }; 410 411 typedef struct sword_table_type { 412 byte id; 413 sbyte x; 414 sbyte y; 415 } sword_table_type; 416 417 #pragma pack(push,1) 418 typedef struct dat_header_type { 419 Uint32 table_offset; 420 Uint16 table_size; 421 } dat_header_type; 422 SDL_COMPILE_TIME_ASSERT(dat_header_size, sizeof(dat_header_type) == 6); 423 424 typedef struct dat_res_type { 425 Uint16 id; 426 Uint32 offset; 427 Uint16 size; 428 } dat_res_type; 429 SDL_COMPILE_TIME_ASSERT(dat_res_size, sizeof(dat_res_type) == 8); 430 431 typedef struct dat_table_type { 432 Uint16 res_count; 433 dat_res_type entries[]; 434 } dat_table_type; 435 SDL_COMPILE_TIME_ASSERT(dat_table_size, sizeof(dat_table_type) == 2); 436 437 typedef struct image_data_type { 438 Uint16 height; 439 Uint16 width; 440 Uint16 flags; 441 byte data[]; 442 } image_data_type; 443 SDL_COMPILE_TIME_ASSERT(image_data_size, sizeof(image_data_type) == 6); 444 #pragma pack(pop) 445 446 typedef struct dat_type { 447 struct dat_type* next_dat; 448 FILE* handle; 449 char filename[POP_MAX_PATH]; 450 dat_table_type* dat_table; 451 // handle and dat_table are NULL if the DAT is a directory. 452 } dat_type; 453 454 typedef void __pascal far (*cutscene_ptr_type)(); 455 456 #ifdef USE_FADE 457 typedef struct palette_fade_type { 458 word which_rows; 459 word wait_time; 460 word fade_pos; 461 rgb_type original_pal[256]; 462 rgb_type faded_pal[256]; 463 int __pascal far (*proc_fade_frame)(struct palette_fade_type far *palette_buffer); 464 void __pascal far (*proc_restore_free)(struct palette_fade_type far *palette_buffer); 465 } palette_fade_type; 466 #endif 467 468 #ifndef O_BINARY 469 #define O_BINARY 0 470 #endif 471 472 #ifdef USE_TEXT 473 typedef struct font_type { 474 byte first_char; 475 byte last_char; 476 short height_above_baseline; 477 short height_below_baseline; 478 short space_between_lines; 479 short space_between_chars; 480 chtab_type* chtab; 481 } font_type; 482 483 typedef struct textstate_type { 484 short current_x; 485 short current_y; 486 short textblit; 487 short textcolor; 488 font_type* ptr_font; 489 } textstate_type; 490 491 #pragma pack(push,1) 492 typedef struct rawfont_type { 493 byte first_char; 494 byte last_char; 495 short height_above_baseline; 496 short height_below_baseline; 497 short space_between_lines; 498 short space_between_chars; 499 word offsets[]; 500 } rawfont_type; 501 SDL_COMPILE_TIME_ASSERT(rawfont_type, sizeof(rawfont_type) == 10); 502 #pragma pack(pop) 503 504 #endif 505 506 typedef enum data_location { 507 data_none = 0, 508 data_DAT = 1, 509 data_directory = 2 510 } data_location; 511 512 enum sound_type { 513 sound_speaker = 0, 514 sound_digi = 1, 515 sound_midi = 2, 516 sound_chunk = 3, 517 sound_music = 4, 518 sound_ogg = 5, 519 sound_digi_converted = 6, 520 }; 521 #pragma pack(push,1) 522 typedef struct note_type { 523 word frequency; // 0x00 or 0x01 = rest, 0x12 = end 524 byte length; 525 } note_type; 526 SDL_COMPILE_TIME_ASSERT(note_type, sizeof(note_type) == 3); 527 typedef struct speaker_type { // IBM 528 word tempo; 529 note_type notes[]; 530 } speaker_type; 531 SDL_COMPILE_TIME_ASSERT(speaker_type, sizeof(speaker_type) == 2); 532 533 typedef struct digi_type { // wave in 1.0 and 1.1 534 word sample_rate; 535 word sample_count; 536 word unknown; 537 byte sample_size; // =8 538 byte samples[]; 539 } digi_type; 540 SDL_COMPILE_TIME_ASSERT(digi_type, sizeof(digi_type) == 7); 541 542 typedef struct digi_new_type { // wave in 1.3 and 1.4 (and PoP2) 543 word sample_rate; 544 byte sample_size; // =8 545 word sample_count; 546 word unknown; 547 word unknown2; 548 byte samples[]; 549 } digi_new_type; 550 SDL_COMPILE_TIME_ASSERT(digi_new_type, sizeof(digi_new_type) == 9); 551 552 typedef struct midi_type { 553 char chunk_type[4]; 554 dword chunk_length; 555 union { 556 struct { 557 word format; 558 word num_tracks; 559 word delta; 560 byte tracks[0]; 561 } header; 562 byte data[0]; 563 }; 564 565 } midi_type; 566 567 typedef struct ogg_type { 568 //byte sample_size; // =16 569 int total_length; 570 byte* file_contents; 571 stb_vorbis* decoder; 572 } ogg_type; 573 574 typedef struct converted_audio_type { 575 int length; 576 short samples[]; 577 } converted_audio_type; 578 579 typedef struct sound_buffer_type { 580 byte type; 581 union { 582 speaker_type speaker; 583 digi_type digi; 584 digi_new_type digi_new; 585 midi_type midi; 586 ogg_type ogg; 587 converted_audio_type converted; 588 }; 589 } sound_buffer_type; 590 591 592 typedef struct midi_raw_chunk_type { 593 char chunk_type[4]; 594 dword chunk_length; 595 union { 596 struct { 597 word format; 598 word num_tracks; 599 word time_division; 600 byte tracks[0]; 601 } header; 602 byte data[0]; 603 }; 604 605 } midi_raw_chunk_type; 606 607 typedef struct midi_event_type { 608 dword delta_time; 609 byte event_type; 610 union { 611 struct { 612 byte channel; 613 byte param1; 614 byte param2; 615 } channel; 616 struct { 617 dword length; 618 byte* data; 619 } sysex; 620 struct { 621 byte type; 622 dword length; 623 byte* data; 624 } meta; 625 }; 626 627 } midi_event_type; 628 629 typedef struct midi_track_type { 630 dword size; 631 int num_events; 632 midi_event_type* events; 633 int event_index; 634 int64_t next_pause_tick; 635 } midi_track_type; 636 637 typedef struct parsed_midi_type { 638 int num_tracks; 639 midi_track_type* tracks; 640 dword ticks_per_beat; 641 } parsed_midi_type; 642 643 #pragma pack(push, 1) 644 typedef struct operator_type { 645 byte mul; 646 byte ksl_tl; 647 byte a_d; 648 byte s_r; 649 byte waveform; 650 } operator_type; 651 652 typedef struct instrument_type { 653 byte blocknum_low; 654 byte blocknum_high; 655 byte FB_conn; 656 operator_type operators[2]; 657 byte percussion; 658 byte unknown[2]; 659 } instrument_type; 660 #pragma pack(pop) 661 662 struct dialog_type; // (declaration only) 663 typedef struct dialog_settings_type { 664 void (* method_1) (struct dialog_type *dialog); 665 void (* method_2_frame) (struct dialog_type *dialog); 666 short top_border; 667 short left_border; 668 short bottom_border; 669 short right_border; 670 short shadow_bottom; 671 short shadow_right; 672 short outer_border; 673 } dialog_settings_type; 674 675 typedef struct dialog_type { 676 dialog_settings_type* settings; 677 rect_type text_rect; 678 rect_type peel_rect; 679 word has_peel; 680 peel_type* peel; 681 } dialog_type; 682 683 #pragma pack(pop) 684 685 enum soundids { 686 sound_0_fell_to_death = 0, 687 sound_1_falling = 1, 688 sound_2_tile_crashing = 2, 689 sound_3_button_pressed = 3, 690 sound_4_gate_closing = 4, 691 sound_5_gate_opening = 5, 692 sound_6_gate_closing_fast = 6, 693 sound_7_gate_stop = 7, 694 sound_8_bumped = 8, 695 sound_9_grab = 9, 696 sound_10_sword_vs_sword = 10, 697 sound_11_sword_moving = 11, 698 sound_12_guard_hurt = 12, 699 sound_13_kid_hurt = 13, 700 sound_14_leveldoor_closing = 14, 701 sound_15_leveldoor_sliding = 15, 702 sound_16_medium_land = 16, 703 sound_17_soft_land = 17, 704 sound_18_drink = 18, 705 sound_19_draw_sword = 19, 706 sound_20_loose_shake_1 = 20, 707 sound_21_loose_shake_2 = 21, 708 sound_22_loose_shake_3 = 22, 709 sound_23_footstep = 23, 710 sound_24_death_regular = 24, 711 sound_25_presentation = 25, 712 sound_26_embrace = 26, 713 sound_27_cutscene_2_4_6_12 = 27, 714 sound_28_death_in_fight = 28, 715 sound_29_meet_Jaffar = 29, 716 sound_30_big_potion = 30, 717 //sound_31 = 31, 718 sound_32_shadow_music = 32, 719 sound_33_small_potion = 33, 720 //sound_34 = 34, 721 sound_35_cutscene_8_9 = 35, 722 sound_36_out_of_time = 36, 723 sound_37_victory = 37, 724 sound_38_blink = 38, 725 sound_39_low_weight = 39, 726 sound_40_cutscene_12_short_time = 40, 727 sound_41_end_level_music = 41, 728 //sound_42 = 42, 729 sound_43_victory_Jaffar = 43, 730 sound_44_skel_alive = 44, 731 sound_45_jump_through_mirror = 45, 732 sound_46_chomped = 46, 733 sound_47_chomper = 47, 734 sound_48_spiked = 48, 735 sound_49_spikes = 49, 736 sound_50_story_2_princess = 50, 737 sound_51_princess_door_opening = 51, 738 sound_52_story_4_Jaffar_leaves = 52, 739 sound_53_story_3_Jaffar_comes = 53, 740 sound_54_intro_music = 54, 741 sound_55_story_1_absence = 55, 742 sound_56_ending_music = 56, 743 }; 744 745 #define NUM_TIMERS 3 746 enum timerids { 747 timer_0 = 0, 748 timer_1 = 1, 749 timer_2 = 2, 750 }; 751 752 enum frameids { 753 frame_0 = 0, 754 frame_1_start_run = 1, 755 frame_2_start_run = 2, 756 frame_3_start_run = 3, 757 frame_4_start_run = 4, 758 frame_5_start_run = 5, 759 frame_6_start_run = 6, 760 frame_7_run = 7, 761 frame_8_run = 8, 762 frame_9_run = 9, 763 frame_10_run = 10, 764 frame_11_run = 11, 765 frame_12_run = 12, 766 frame_13_run = 13, 767 frame_14_run = 14, 768 frame_15_stand = 15, 769 frame_16_standing_jump_1 = 16, 770 frame_17_standing_jump_2 = 17, 771 frame_18_standing_jump_3 = 18, 772 frame_19_standing_jump_4 = 19, 773 frame_20_standing_jump_5 = 20, 774 frame_21_standing_jump_6 = 21, 775 frame_22_standing_jump_7 = 22, 776 frame_23_standing_jump_8 = 23, 777 frame_24_standing_jump_9 = 24, 778 frame_25_standing_jump_10 = 25, 779 frame_26_standing_jump_11 = 26, 780 frame_27_standing_jump_12 = 27, 781 frame_28_standing_jump_13 = 28, 782 frame_29_standing_jump_14 = 29, 783 frame_30_standing_jump_15 = 30, 784 frame_31_standing_jump_16 = 31, 785 frame_32_standing_jump_17 = 32, 786 frame_33_standing_jump_18 = 33, 787 frame_34_start_run_jump_1 = 34, 788 frame_35_start_run_jump_2 = 35, 789 frame_36_start_run_jump_3 = 36, 790 frame_37_start_run_jump_4 = 37, 791 frame_38_start_run_jump_5 = 38, 792 frame_39_start_run_jump_6 = 39, 793 frame_40_running_jump_1 = 40, 794 frame_41_running_jump_2 = 41, 795 frame_42_running_jump_3 = 42, 796 frame_43_running_jump_4 = 43, 797 frame_44_running_jump_5 = 44, 798 frame_45_turn = 45, 799 frame_46_turn = 46, 800 frame_47_turn = 47, 801 frame_48_turn = 48, 802 frame_49_turn = 49, 803 frame_50_turn = 50, 804 frame_51_turn = 51, 805 frame_52_turn = 52, 806 frame_53_runturn = 53, 807 frame_54_runturn = 54, 808 frame_55_runturn = 55, 809 frame_56_runturn = 56, 810 frame_57_runturn = 57, 811 frame_58_runturn = 58, 812 frame_59_runturn = 59, 813 frame_60_runturn = 60, 814 frame_61_runturn = 61, 815 frame_62_runturn = 62, 816 frame_63_runturn = 63, 817 frame_64_runturn = 64, 818 frame_65_runturn = 65, 819 frame_67_start_jump_up_1 = 67, 820 frame_68_start_jump_up_2 = 68, 821 frame_69_start_jump_up_3 = 69, 822 frame_70_jumphang = 70, 823 frame_71_jumphang = 71, 824 frame_72_jumphang = 72, 825 frame_73_jumphang = 73, 826 frame_74_jumphang = 74, 827 frame_75_jumphang = 75, 828 frame_76_jumphang = 76, 829 frame_77_jumphang = 77, 830 frame_78_jumphang = 78, 831 frame_79_jumphang = 79, 832 frame_80_jumphang = 80, 833 frame_81_hangdrop_1 = 81, 834 frame_82_hangdrop_2 = 82, 835 frame_83_hangdrop_3 = 83, 836 frame_84_hangdrop_4 = 84, 837 frame_85_hangdrop_5 = 85, 838 frame_86_test_foot = 86, 839 frame_87_hanging_1 = 87, 840 frame_88_hanging_2 = 88, 841 frame_89_hanging_3 = 89, 842 frame_90_hanging_4 = 90, 843 frame_91_hanging_5 = 91, 844 frame_92_hanging_6 = 92, 845 frame_93_hanging_7 = 93, 846 frame_94_hanging_8 = 94, 847 frame_95_hanging_9 = 95, 848 frame_96_hanging_10 = 96, 849 frame_97_hanging_11 = 97, 850 frame_98_hanging_12 = 98, 851 frame_99_hanging_13 = 99, 852 frame_102_start_fall_1 = 102, 853 frame_103_start_fall_2 = 103, 854 frame_104_start_fall_3 = 104, 855 frame_105_start_fall_4 = 105, 856 frame_106_fall = 106, 857 frame_107_fall_land_1 = 107, 858 frame_108_fall_land_2 = 108, 859 frame_109_crouch = 109, 860 frame_110_stand_up_from_crouch_1 = 110, 861 frame_111_stand_up_from_crouch_2 = 111, 862 frame_112_stand_up_from_crouch_3 = 112, 863 frame_113_stand_up_from_crouch_4 = 113, 864 frame_114_stand_up_from_crouch_5 = 114, 865 frame_115_stand_up_from_crouch_6 = 115, 866 frame_116_stand_up_from_crouch_7 = 116, 867 frame_117_stand_up_from_crouch_8 = 117, 868 frame_118_stand_up_from_crouch_9 = 118, 869 frame_119_stand_up_from_crouch_10 = 119, 870 frame_121_stepping_1 = 121, 871 frame_122_stepping_2 = 122, 872 frame_123_stepping_3 = 123, 873 frame_124_stepping_4 = 124, 874 frame_125_stepping_5 = 125, 875 frame_126_stepping_6 = 126, 876 frame_127_stepping_7 = 127, 877 frame_128_stepping_8 = 128, 878 frame_129_stepping_9 = 129, 879 frame_130_stepping_10 = 130, 880 frame_131_stepping_11 = 131, 881 frame_132_stepping_12 = 132, 882 frame_133_sheathe = 133, 883 frame_134_sheathe = 134, 884 frame_135_climbing_1 = 135, 885 frame_136_climbing_2 = 136, 886 frame_137_climbing_3 = 137, 887 frame_138_climbing_4 = 138, 888 frame_139_climbing_5 = 139, 889 frame_140_climbing_6 = 140, 890 frame_141_climbing_7 = 141, 891 frame_142_climbing_8 = 142, 892 frame_143_climbing_9 = 143, 893 frame_144_climbing_10 = 144, 894 frame_145_climbing_11 = 145, 895 frame_146_climbing_12 = 146, 896 frame_147_climbing_13 = 147, 897 frame_148_climbing_14 = 148, 898 frame_149_climbing_15 = 149, 899 frame_150_parry = 150, 900 frame_151_strike_1 = 151, 901 frame_152_strike_2 = 152, 902 frame_153_strike_3 = 153, 903 frame_154_poking = 154, 904 frame_155_guy_7 = 155, 905 frame_156_guy_8 = 156, 906 frame_157_walk_with_sword = 157, 907 frame_158_stand_with_sword = 158, 908 frame_159_fighting = 159, 909 frame_160_fighting = 160, 910 frame_161_parry = 161, 911 frame_162_block_to_strike = 162, 912 frame_163_fighting = 163, 913 frame_164_fighting = 164, 914 frame_165_walk_with_sword = 165, 915 frame_166_stand_inactive = 166, 916 frame_167_blocked = 167, 917 frame_168_back = 168, 918 frame_169_begin_block = 169, 919 frame_170_stand_with_sword = 170, 920 frame_171_stand_with_sword = 171, 921 frame_172_jumpfall_2 = 172, 922 frame_173_jumpfall_3 = 173, 923 frame_174_jumpfall_4 = 174, 924 frame_175_jumpfall_5 = 175, 925 frame_177_spiked = 177, 926 frame_178_chomped = 178, 927 frame_179_collapse_1 = 179, 928 frame_180_collapse_2 = 180, 929 frame_181_collapse_3 = 181, 930 frame_182_collapse_4 = 182, 931 frame_183_collapse_5 = 183, 932 frame_185_dead = 185, 933 frame_186_mouse_1 = 186, 934 frame_187_mouse_2 = 187, 935 frame_188_mouse_stand = 188, 936 frame_191_drink = 191, 937 frame_192_drink = 192, 938 frame_193_drink = 193, 939 frame_194_drink = 194, 940 frame_195_drink = 195, 941 frame_196_drink = 196, 942 frame_197_drink = 197, 943 frame_198_drink = 198, 944 frame_199_drink = 199, 945 frame_200_drink = 200, 946 frame_201_drink = 201, 947 frame_202_drink = 202, 948 frame_203_drink = 203, 949 frame_204_drink = 204, 950 frame_205_drink = 205, 951 frame_207_draw_1 = 207, 952 frame_208_draw_2 = 208, 953 frame_209_draw_3 = 209, 954 frame_210_draw_4 = 210, 955 frame_217_exit_stairs_1 = 217, 956 frame_218_exit_stairs_2 = 218, 957 frame_219_exit_stairs_3 = 219, 958 frame_220_exit_stairs_4 = 220, 959 frame_221_exit_stairs_5 = 221, 960 frame_222_exit_stairs_6 = 222, 961 frame_223_exit_stairs_7 = 223, 962 frame_224_exit_stairs_8 = 224, 963 frame_225_exit_stairs_9 = 225, 964 frame_226_exit_stairs_10 = 226, 965 frame_227_exit_stairs_11 = 227, 966 frame_228_exit_stairs_12 = 228, 967 frame_229_found_sword = 229, 968 frame_230_sheathe = 230, 969 frame_231_sheathe = 231, 970 frame_232_sheathe = 232, 971 frame_233_sheathe = 233, 972 frame_234_sheathe = 234, 973 frame_235_sheathe = 235, 974 frame_236_sheathe = 236, 975 frame_237_sheathe = 237, 976 frame_238_sheathe = 238, 977 frame_239_sheathe = 239, 978 frame_240_sheathe = 240, 979 }; 980 981 enum altset2ids { 982 alt2frame_54_Vstand = 54, 983 //... incomplete 984 }; 985 986 enum seqids { 987 seq_1_start_run = 1, 988 seq_2_stand = 2, 989 seq_3_standing_jump = 3, 990 seq_4_run_jump = 4, 991 seq_5_turn = 5, 992 seq_6_run_turn = 6, 993 seq_7_fall = 7, 994 seq_8_jump_up_and_grab_straight = 8, 995 seq_10_climb_up = 10, 996 seq_11_release_ledge_and_land = 11, 997 seq_13_stop_run = 13, 998 seq_14_jump_up_into_ceiling = 14, 999 seq_15_grab_ledge_midair = 15, 1000 seq_16_jump_up_and_grab = 16, 1001 seq_17_soft_land = 17, 1002 seq_18_fall_after_standing_jump = 18, 1003 seq_19_fall = 19, 1004 seq_20_medium_land = 20, 1005 seq_21_fall_after_running_jump = 21, 1006 seq_22_crushed = 22, 1007 seq_23_release_ledge_and_fall = 23, 1008 seq_24_jump_up_and_grab_forward = 24, 1009 seq_25_hang_against_wall = 25, 1010 seq_26_crouch_while_running = 26, 1011 seq_28_jump_up_with_nothing_above = 28, 1012 seq_29_safe_step_1 = 29, 1013 seq_30_safe_step_2 = 30, 1014 seq_31_safe_step_3 = 31, 1015 seq_32_safe_step_4 = 32, 1016 seq_33_safe_step_5 = 33, 1017 seq_34_safe_step_6 = 34, 1018 seq_35_safe_step_7 = 35, 1019 seq_36_safe_step_8 = 36, 1020 seq_37_safe_step_9 = 37, 1021 seq_38_safe_step_10 = 38, 1022 seq_39_safe_step_11 = 39, 1023 seq_40_safe_step_12 = 40, 1024 seq_41_safe_step_13 = 41, 1025 seq_42_safe_step_14 = 42, 1026 seq_43_start_run_after_turn = 43, 1027 seq_44_step_on_edge = 44, 1028 seq_45_bumpfall = 45, 1029 seq_46_hardbump = 46, 1030 seq_47_bump = 47, 1031 seq_49_stand_up_from_crouch = 49, 1032 seq_50_crouch = 50, 1033 seq_51_spiked = 51, 1034 seq_52_loose_floor_fell_on_kid = 52, 1035 seq_54_chomped = 54, 1036 seq_55_draw_sword = 55, 1037 seq_56_guard_forward_with_sword = 56, 1038 seq_57_back_with_sword = 57, 1039 seq_58_guard_strike = 58, 1040 seq_60_turn_with_sword = 60, 1041 seq_61_parry_after_strike = 61, 1042 seq_62_parry = 62, 1043 seq_63_guard_stand_active = 63, 1044 seq_64_pushed_back_with_sword = 64, 1045 seq_65_bump_forward_with_sword = 65, 1046 seq_66_strike_after_parry = 66, 1047 seq_68_climb_down = 68, 1048 seq_69_attack_was_parried = 69, 1049 seq_70_go_up_on_level_door = 70, 1050 seq_71_dying = 71, 1051 seq_73_climb_up_to_closed_gate = 73, 1052 seq_74_hit_by_sword = 74, 1053 seq_75_strike = 75, 1054 seq_77_guard_stand_inactive = 77, 1055 seq_78_drink = 78, 1056 seq_79_crouch_hop = 79, 1057 seq_80_stand_flipped = 80, 1058 seq_81_kid_pushed_off_ledge = 81, 1059 seq_82_guard_pushed_off_ledge = 82, 1060 seq_83_guard_fall = 83, 1061 seq_84_run = 84, 1062 seq_85_stabbed_to_death = 85, 1063 seq_86_forward_with_sword = 86, 1064 seq_87_guard_become_inactive = 87, 1065 seq_88_skel_wake_up = 88, 1066 seq_89_turn_draw_sword = 89, 1067 seq_90_en_garde = 90, 1068 seq_91_get_sword = 91, 1069 seq_92_put_sword_away = 92, 1070 seq_93_put_sword_away_fast = 93, 1071 seq_94_princess_stand_PV1 = 94, 1072 seq_95_Jaffar_stand_PV1 = 95, 1073 seq_101_mouse_stands_up = 101, 1074 seq_103_princess_lying_PV2 = 103, 1075 seq_104_start_fall_in_front_of_wall = 104, 1076 seq_105_mouse_forward = 105, 1077 seq_106_mouse = 106, 1078 seq_107_mouse_stand_up_and_go = 107, 1079 seq_108_princess_turn_and_hug = 108, 1080 seq_109_princess_stand_PV2 = 109, 1081 seq_110_princess_crouching_PV2 = 110, 1082 seq_111_princess_stand_up_PV2 = 111, 1083 seq_112_princess_crouch_down_PV2 = 112, 1084 seq_114_mouse_stand = 114, 1085 }; 1086 1087 enum seqtbl_instructions { 1088 SEQ_DX = 0xFB, 1089 SEQ_DY = 0xFA, 1090 SEQ_FLIP = 0xFE, 1091 SEQ_JMP_IF_FEATHER = 0xF7, 1092 SEQ_JMP = 0xFF, 1093 SEQ_UP = 0xFD, 1094 SEQ_DOWN = 0xFC, 1095 SEQ_ACTION = 0xF9, 1096 SEQ_SET_FALL = 0xF8, 1097 SEQ_KNOCK_UP = 0xF5, 1098 SEQ_KNOCK_DOWN = 0xF4, 1099 SEQ_SOUND = 0xF2, 1100 SEQ_END_LEVEL = 0xF1, 1101 SEQ_GET_ITEM = 0xF3, 1102 SEQ_DIE = 0xF6, 1103 }; 1104 1105 enum seqtbl_sounds { 1106 SND_SILENT = 0, 1107 SND_FOOTSTEP = 1, 1108 SND_BUMP = 2, 1109 SND_DRINK = 3, 1110 SND_LEVEL = 4, 1111 }; 1112 1113 enum colorids { 1114 color_0_black = 0, 1115 color_1_blue = 1, 1116 color_2_green = 2, 1117 color_3_cyan = 3, 1118 color_4_red = 4, 1119 color_5_magenta = 5, 1120 color_6_brown = 6, 1121 color_7_lightgray = 7, 1122 color_8_darkgray = 8, 1123 color_9_brightblue = 9, 1124 color_10_brightgreen = 10, 1125 color_11_brightcyan = 11, 1126 color_12_brightred = 12, 1127 color_13_brightmagenta = 13, 1128 color_14_brightyellow = 14, 1129 color_15_brightwhite = 15, 1130 }; 1131 1132 #ifdef USE_REPLAY 1133 enum replay_special_moves { 1134 MOVE_RESTART_LEVEL = 1, // player pressed Ctrl+A 1135 MOVE_EFFECT_END = 2, // music stops, causing the end of feather effect or level 1 crouch immobilization 1136 }; 1137 1138 enum replay_seek_targets { 1139 replay_seek_0_next_room = 0, 1140 replay_seek_1_next_level = 1, 1141 replay_seek_2_end = 2, 1142 }; 1143 #endif 1144 1145 #define COUNT(array) ((int) (sizeof(array)/sizeof(array[0])) ) 1146 1147 // These are or'ed with SDL_SCANCODE_* constants in last_key_scancode. 1148 enum key_modifiers { 1149 WITH_SHIFT = 0x8000, 1150 WITH_CTRL = 0x4000, 1151 WITH_ALT = 0x2000, 1152 }; 1153 1154 #define MAX_OPTION_VALUE_NAME_LENGTH 20 1155 typedef struct key_value_type { 1156 char key[MAX_OPTION_VALUE_NAME_LENGTH]; 1157 int value; 1158 } key_value_type; 1159 1160 typedef struct names_list_type { 1161 byte type; // 0 = names list, 1 = key/value pair list 1162 union { 1163 struct { 1164 const char (* data)[][MAX_OPTION_VALUE_NAME_LENGTH]; 1165 word count; 1166 } names; 1167 struct { 1168 key_value_type* data; 1169 word count; 1170 } kv_pairs; 1171 }; 1172 } names_list_type; 1173 1174 // Macros for declaring and initializing a names_list_type (for names lists and key/value pair lists). 1175 #define NAMES_LIST(listname, ...) const char listname[][MAX_OPTION_VALUE_NAME_LENGTH] = __VA_ARGS__; \ 1176 names_list_type listname##_list = {.type=0, .names = {&listname, COUNT(listname)}} 1177 1178 #define KEY_VALUE_LIST(listname, ...) const key_value_type listname[] = __VA_ARGS__; \ 1179 names_list_type listname##_list = {.type=1, .kv_pairs= {(key_value_type*)&listname, COUNT(listname)}} 1180 1181 #pragma pack(push,1) 1182 typedef struct fixes_options_type { 1183 byte enable_crouch_after_climbing; 1184 byte enable_freeze_time_during_end_music; 1185 byte enable_remember_guard_hp; 1186 byte fix_gate_sounds; 1187 byte fix_two_coll_bug; 1188 byte fix_infinite_down_bug; 1189 byte fix_gate_drawing_bug; 1190 byte fix_bigpillar_climb; 1191 byte fix_jump_distance_at_edge; 1192 byte fix_edge_distance_check_when_climbing; 1193 byte fix_painless_fall_on_guard; 1194 byte fix_wall_bump_triggers_tile_below; 1195 byte fix_stand_on_thin_air; 1196 byte fix_press_through_closed_gates; 1197 byte fix_grab_falling_speed; 1198 byte fix_skeleton_chomper_blood; 1199 byte fix_move_after_drink; 1200 byte fix_loose_left_of_potion; 1201 byte fix_guard_following_through_closed_gates; 1202 byte fix_safe_landing_on_spikes; 1203 byte fix_glide_through_wall; 1204 byte fix_drop_through_tapestry; 1205 byte fix_land_against_gate_or_tapestry; 1206 byte fix_unintended_sword_strike; 1207 byte fix_retreat_without_leaving_room; 1208 byte fix_running_jump_through_tapestry; 1209 byte fix_push_guard_into_wall; 1210 byte fix_jump_through_wall_above_gate; 1211 byte fix_chompers_not_starting; 1212 byte fix_feather_interrupted_by_leveldoor; 1213 byte fix_offscreen_guards_disappearing; 1214 byte fix_move_after_sheathe; 1215 byte fix_hidden_floors_during_flashing; 1216 byte fix_hang_on_teleport; 1217 byte fix_exit_door; 1218 byte fix_quicksave_during_feather; 1219 byte fix_caped_prince_sliding_through_gate; 1220 byte fix_doortop_disabling_guard; 1221 } fixes_options_type; 1222 1223 #define NUM_GUARD_SKILLS 12 1224 1225 typedef struct custom_options_type { 1226 word start_minutes_left; 1227 word start_ticks_left; 1228 word start_hitp; 1229 word max_hitp_allowed; 1230 word saving_allowed_first_level; 1231 word saving_allowed_last_level; 1232 byte start_upside_down; 1233 byte start_in_blind_mode; 1234 word copyprot_level; 1235 byte drawn_tile_top_level_edge; 1236 byte drawn_tile_left_level_edge; 1237 byte level_edge_hit_tile; 1238 byte allow_triggering_any_tile; 1239 byte enable_wda_in_palace; 1240 rgb_type vga_palette[16]; 1241 word first_level; 1242 byte skip_title; 1243 word shift_L_allowed_until_level; 1244 word shift_L_reduced_minutes; 1245 word shift_L_reduced_ticks; 1246 word demo_hitp; 1247 word demo_end_room; 1248 word intro_music_level; 1249 word have_sword_from_level; 1250 word checkpoint_level; 1251 sbyte checkpoint_respawn_dir; 1252 byte checkpoint_respawn_room; 1253 byte checkpoint_respawn_tilepos; 1254 byte checkpoint_clear_tile_room; 1255 byte checkpoint_clear_tile_col; 1256 byte checkpoint_clear_tile_row; 1257 word skeleton_level; 1258 byte skeleton_room; 1259 byte skeleton_trigger_column_1; 1260 byte skeleton_trigger_column_2; 1261 byte skeleton_column; 1262 byte skeleton_row; 1263 byte skeleton_require_open_level_door; 1264 byte skeleton_skill; 1265 byte skeleton_reappear_room; 1266 byte skeleton_reappear_x; 1267 byte skeleton_reappear_row; 1268 byte skeleton_reappear_dir; 1269 word mirror_level; 1270 byte mirror_room; 1271 byte mirror_column; 1272 byte mirror_row; 1273 byte mirror_tile; 1274 byte show_mirror_image; 1275 word falling_exit_level; 1276 byte falling_exit_room; 1277 word falling_entry_level; 1278 byte falling_entry_room; 1279 word mouse_level; 1280 byte mouse_room; 1281 word mouse_delay; 1282 byte mouse_object; 1283 byte mouse_start_x; 1284 word loose_tiles_level; 1285 byte loose_tiles_room_1; 1286 byte loose_tiles_room_2; 1287 byte loose_tiles_first_tile; 1288 byte loose_tiles_last_tile; 1289 word jaffar_victory_level; 1290 byte jaffar_victory_flash_time; 1291 word hide_level_number_from_level; 1292 byte level_13_level_number; 1293 word victory_stops_time_level; 1294 word win_level; 1295 byte win_room; 1296 byte loose_floor_delay; 1297 byte tbl_level_type[16]; 1298 word tbl_level_color[16]; 1299 short tbl_guard_type[16]; 1300 byte tbl_guard_hp[16]; 1301 byte tbl_cutscenes_by_index[16]; 1302 byte tbl_entry_pose[16]; 1303 sbyte tbl_seamless_exit[16]; 1304 1305 // guard skills 1306 word strikeprob [NUM_GUARD_SKILLS]; 1307 word restrikeprob [NUM_GUARD_SKILLS]; 1308 word blockprob [NUM_GUARD_SKILLS]; 1309 word impblockprob [NUM_GUARD_SKILLS]; 1310 word advprob [NUM_GUARD_SKILLS]; 1311 word refractimer [NUM_GUARD_SKILLS]; 1312 word extrastrength[NUM_GUARD_SKILLS]; 1313 1314 // shadow's starting positions 1315 byte init_shad_6[8]; 1316 byte init_shad_5[8]; 1317 byte init_shad_12[8]; 1318 // automatic moves 1319 auto_move_type demo_moves[25]; // prince on demo level 1320 auto_move_type shad_drink_move[8]; // shadow on level 5 1321 1322 // speeds 1323 byte base_speed; 1324 byte fight_speed; 1325 byte chomper_speed; 1326 1327 } custom_options_type; 1328 #pragma pack(pop) 1329 1330 typedef struct directory_listing_type directory_listing_type; 1331 1332 #define BASE_FPS 60 1333 1334 #define FEATHER_FALL_LENGTH 18.75 1335 1336 #endif 1337