Subversion Repositories Games.Prince of Persia

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2. SDLPoP, a port/conversion of the DOS game Prince of Persia.
  3. Copyright (C) 2013-2018  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 <http://www.gnu.org/licenses/>.
  17.  
  18. The authors of this program may be contacted at http://forum.princed.org
  19. */
  20.  
  21. #ifndef TYPES_H
  22. #define TYPES_H
  23.  
  24. #if !defined(_MSC_VER)
  25. # include <SDL2/SDL.h>
  26. # include <SDL2_image/SDL_image.h>
  27. # ifdef USE_MIXER
  28. # include <SDL2_mixer/SDL_mixer.h>
  29. # endif
  30. #else
  31. # include <SDL.h>
  32. # include <SDL_image.h>
  33. # ifdef USE_MIXER
  34. # include <SDL_mixer.h>
  35. # endif
  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, byte 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.         byte 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.         byte 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_9_black = 9,
  179.         blitters_10h_transp = 0x10,
  180.         /* 0x40..0x4F will draw a monochrome image with color 0..15 */
  181.         blitters_40h_mono = 0x40,
  182.         blitters_46h_mono_6 = 0x46, // used for palace wall patterns
  183.         blitters_4Ch_mono_12 = 0x4C // used for chomper blood
  184. };
  185.  
  186. enum grmodes {
  187.         gmCga = 1,
  188.         gmHgaHerc = 2,
  189.         gmEga = 3,
  190.         gmTga = 4,
  191.         gmMcgaVga = 5
  192. };
  193.  
  194. enum sound_modes {
  195.         smAuto = 0,
  196.         smAdlib = 1,
  197.         smGblast = 2,
  198.         smSblast = 3,
  199.         smCovox = 4,
  200.         smIbmg = 5,
  201.         smTandy = 6
  202. };
  203.  
  204. #pragma pack(push,1)
  205. typedef struct link_type {
  206.         byte left,right,up,down;
  207. } link_type;
  208.  
  209. typedef struct level_type {
  210.         byte fg[720];
  211.         byte bg[720];
  212.         byte doorlinks1[256];
  213.         byte doorlinks2[256];
  214.         link_type roomlinks[24];
  215.         byte used_rooms;
  216.         byte roomxs[24];
  217.         byte roomys[24];
  218.         byte fill_1[15];
  219.         byte start_room;
  220.         byte start_pos;
  221.         sbyte start_dir;
  222.         byte fill_2[4];
  223.         byte guards_tile[24];
  224.         byte guards_dir[24];
  225.         byte guards_x[24];
  226.         byte guards_seq_lo[24];
  227.         byte guards_skill[24];
  228.         byte guards_seq_hi[24];
  229.         byte guards_color[24];
  230.         byte fill_3[18];
  231. } level_type;
  232. SDL_COMPILE_TIME_ASSERT(level_size, sizeof(level_type) == 2305);
  233. #pragma pack(pop)
  234.  
  235. typedef SDL_Surface surface_type;
  236. typedef SDL_Surface image_type;
  237. typedef struct peel_type {
  238.         SDL_Surface* peel;
  239.         rect_type rect;
  240. } peel_type;
  241.  
  242. typedef struct chtab_type {
  243.         word n_images;
  244.         word chtab_palette_bits;
  245.         word has_palette_bits;
  246.         // This is a variable-size array, with n_images elements.
  247.         image_type* far images[0];
  248. } chtab_type;
  249.  
  250. #pragma pack(push,1)
  251. typedef struct rgb_type {
  252.         byte r,g,b;
  253. } rgb_type;
  254. typedef struct dat_pal_type {
  255.         word row_bits;
  256.         byte n_colors;
  257.         rgb_type vga[16];
  258.         byte cga[16];
  259.         byte ega[32];
  260. } dat_pal_type;
  261. typedef struct dat_shpl_type {
  262.         byte n_images;
  263.         dat_pal_type palette;
  264. } dat_shpl_type;
  265. SDL_COMPILE_TIME_ASSERT(dat_shpl_size, sizeof(dat_shpl_type) == 100);
  266. #pragma pack(pop)
  267.  
  268. typedef struct char_type {
  269.         byte frame;
  270.         byte x;
  271.         byte y;
  272.         sbyte direction;
  273.         sbyte curr_col;
  274.         sbyte curr_row;
  275.         byte action;
  276.         sbyte fall_x;
  277.         sbyte fall_y;
  278.         byte room;
  279.         byte repeat;
  280.         byte charid;
  281.         byte sword;
  282.         sbyte alive;
  283.         word curr_seq;
  284. } char_type;
  285.  
  286. enum charids {
  287.         charid_0_kid      = 0,
  288.         charid_1_shadow   = 1,
  289.         charid_2_guard    = 2,
  290.         charid_3          = 3,
  291.         charid_4_skeleton = 4,
  292.         charid_5_princess = 5,
  293.         charid_6_vizier   = 6,
  294.         charid_24_mouse   = 0x18
  295. };
  296.  
  297. enum sword_status {
  298.         sword_0_sheathed = 0,
  299.         sword_2_drawn = 2
  300. };
  301.  
  302. typedef struct auto_move_type {
  303.         short time,move;
  304. } auto_move_type;
  305.  
  306. /* obj_type:
  307.         0 = Kid, princess, vizier
  308.         1 = shadow
  309.         2 = Guard
  310.         3 = sword
  311.         4 = mirror image
  312.         5 = hurt splash
  313.         0x80 = loose floor
  314. */
  315. typedef struct objtable_type {
  316.         sbyte xh;
  317.         sbyte xl;
  318.         short y;
  319.         byte chtab_id;
  320.         byte id;
  321.         sbyte direction;
  322.         byte obj_type;
  323.         rect_type clip;
  324.         byte tilepos;
  325. } objtable_type;
  326.  
  327. typedef struct frame_type {
  328.         byte image;
  329.  
  330.         // 0x3F: sword image
  331.         // 0xC0: chtab
  332.         byte sword;
  333.  
  334.         sbyte dx;
  335.         sbyte dy;
  336.  
  337.         // 0x1F: weight x
  338.         // 0x20: thin
  339.         // 0x40: needs floor
  340.         // 0x80: even/odd pixel
  341.         byte flags;
  342. } frame_type;
  343.  
  344. enum frame_flags {
  345.         FRAME_WEIGHT_X = 0x1F,
  346.         FRAME_THIN = 0x20,
  347.         FRAME_NEEDS_FLOOR = 0x40,
  348.         FRAME_EVEN_ODD_PIXEL = 0x80,
  349. };
  350.  
  351. typedef struct trob_type {
  352.         byte tilepos;
  353.         byte room;
  354.         sbyte type;
  355. } trob_type;
  356.  
  357. typedef struct mob_type {
  358.         byte xh;
  359.         byte y;
  360.         byte room;
  361.         sbyte speed;
  362.         byte type;
  363.         byte row;
  364. } mob_type;
  365.  
  366. enum directions {
  367.         dir_0_right = 0x00,
  368.         dir_56_none = 0x56,
  369.         dir_FF_left = -1
  370. };
  371.  
  372. enum actions {
  373.         actions_0_stand         = 0,
  374.         actions_1_run_jump      = 1,
  375.         actions_2_hang_climb    = 2,
  376.         actions_3_in_midair     = 3,
  377.         actions_4_in_freefall   = 4,
  378.         actions_5_bumped        = 5,
  379.         actions_6_hang_straight = 6,
  380.         actions_7_turn          = 7,
  381.         actions_99_hurt         = 99,
  382. };
  383.  
  384. typedef struct sword_table_type {
  385.         byte id;
  386.         sbyte x;
  387.         sbyte y;
  388. } sword_table_type;
  389.  
  390. #pragma pack(push,1)
  391. typedef struct dat_header_type {
  392.         Uint32 table_offset;
  393.         Uint16 table_size;
  394. } dat_header_type;
  395. SDL_COMPILE_TIME_ASSERT(dat_header_size, sizeof(dat_header_type) == 6);
  396.  
  397. typedef struct dat_res_type {
  398.         Uint16 id;
  399.         Uint32 offset;
  400.         Uint16 size;
  401. } dat_res_type;
  402. SDL_COMPILE_TIME_ASSERT(dat_res_size, sizeof(dat_res_type) == 8);
  403.  
  404. typedef struct dat_table_type {
  405.         Uint16 res_count;
  406.         dat_res_type entries[0];
  407. } dat_table_type;
  408. SDL_COMPILE_TIME_ASSERT(dat_table_size, sizeof(dat_table_type) == 2);
  409.  
  410. typedef struct image_data_type {
  411.         Uint16 height;
  412.         Uint16 width;
  413.         Uint16 flags;
  414.         byte data[0];
  415. } image_data_type;
  416. SDL_COMPILE_TIME_ASSERT(image_data_size, sizeof(image_data_type) == 6);
  417. #pragma pack(pop)
  418.  
  419. typedef struct dat_type {
  420.         struct dat_type* next_dat;
  421.         FILE* handle;
  422.         char filename[POP_MAX_PATH];
  423.         dat_table_type* dat_table;
  424.         // handle and dat_table are NULL if the DAT is a directory.
  425. } dat_type;
  426.  
  427. typedef void __pascal far (*cutscene_ptr_type)();
  428.  
  429. #ifdef USE_FADE
  430. typedef struct palette_fade_type {
  431.         word which_rows;
  432.         word wait_time;
  433.         word fade_pos;
  434.         rgb_type original_pal[256];
  435.         rgb_type faded_pal[256];
  436.         int __pascal far (*proc_fade_frame)(struct palette_fade_type far *palette_buffer);
  437.         void __pascal far (*proc_restore_free)(struct palette_fade_type far *palette_buffer);
  438. } palette_fade_type;
  439. #endif
  440.  
  441. #ifndef O_BINARY
  442. #define O_BINARY 0
  443. #endif
  444.  
  445. #ifdef USE_TEXT
  446. typedef struct font_type {
  447.         byte first_char;
  448.         byte last_char;
  449.         short height_above_baseline;
  450.         short height_below_baseline;
  451.         short space_between_lines;
  452.         short space_between_chars;
  453.         chtab_type* chtab;
  454. } font_type;
  455.  
  456. typedef struct textstate_type {
  457.         short current_x;
  458.         short current_y;
  459.         short textblit;
  460.         short textcolor;
  461.         font_type* ptr_font;
  462. } textstate_type;
  463.  
  464. #pragma pack(push,1)
  465. typedef struct rawfont_type {
  466.         byte first_char;
  467.         byte last_char;
  468.         short height_above_baseline;
  469.         short height_below_baseline;
  470.         short space_between_lines;
  471.         short space_between_chars;
  472.         word offsets[0];
  473. } rawfont_type;
  474. SDL_COMPILE_TIME_ASSERT(rawfont_type, sizeof(rawfont_type) == 10);
  475. #pragma pack(pop)
  476.  
  477. #endif
  478.  
  479. typedef enum data_location {
  480.         data_none = 0,
  481.         data_DAT = 1,
  482.         data_directory = 2
  483. } data_location;
  484.  
  485. enum sound_type {
  486. #ifdef USE_MIXER
  487.         sound_chunk = 3,
  488.         sound_music = 4,
  489. #endif
  490.         sound_speaker = 0,
  491.         sound_digi = 1,
  492.         sound_midi = 2
  493. };
  494. #pragma pack(push,1)
  495. typedef struct note_type {
  496.         word frequency; // 0x00 or 0x01 = rest, 0x12 = end
  497.         byte length;
  498. } note_type;
  499. SDL_COMPILE_TIME_ASSERT(note_type, sizeof(note_type) == 3);
  500. typedef struct speaker_type { // IBM
  501.         word tempo;
  502.         note_type notes[0];
  503. } speaker_type;
  504. SDL_COMPILE_TIME_ASSERT(speaker_type, sizeof(speaker_type) == 2);
  505.  
  506. typedef struct digi_type { // wave in 1.0 and 1.1
  507.         word sample_rate;
  508.         word sample_count;
  509.         word unknown;
  510.         byte sample_size; // =8
  511.         byte samples[0];
  512. } digi_type;
  513. SDL_COMPILE_TIME_ASSERT(digi_type, sizeof(digi_type) == 7);
  514.  
  515. typedef struct digi_new_type { // wave in 1.3 and 1.4 (and PoP2)
  516.         word sample_rate;
  517.         byte sample_size; // =8
  518.         word sample_count;
  519.         word unknown;
  520.         word unknown2;
  521.         byte samples[0];
  522. } digi_new_type;
  523. SDL_COMPILE_TIME_ASSERT(digi_new_type, sizeof(digi_new_type) == 9);
  524.  
  525. typedef struct midi_type {
  526.         byte data[0];
  527. } midi_type;
  528.  
  529. typedef struct sound_buffer_type {
  530.         byte type;
  531.         union {
  532.                 speaker_type speaker;
  533.                 digi_type digi;
  534.                 digi_new_type digi_new;
  535.                 midi_type midi;
  536. #ifdef USE_MIXER
  537.                 Mix_Chunk *chunk;
  538.                 Mix_Music *music;
  539. #endif
  540.         };
  541. } sound_buffer_type;
  542.  
  543. #ifdef USE_MIXER
  544. typedef struct WAV_header_type {
  545.         Uint32 ChunkID; // fourcc
  546.         Uint32 ChunkSize;
  547.         Uint32 Format; // fourcc
  548.         Uint32 Subchunk1ID; // fourcc
  549.         Uint32 Subchunk1Size;
  550.         Uint16 AudioFormat;
  551.         Uint16 NumChannels;
  552.         Uint32 SampleRate;
  553.         Uint32 ByteRate;
  554.         Uint16 BlockAlign;
  555.         Uint16 BitsPerSample;
  556.         Uint32 Subchunk2ID; // fourcc
  557.         Uint32 Subchunk2Size;
  558.         byte Data[0];
  559. } WAV_header_type;
  560. #endif
  561.  
  562. struct dialog_type; // (declaration only)
  563. typedef struct dialog_settings_type {
  564.         void (* method_1) (struct dialog_type *dialog);
  565.         void (* method_2_frame) (struct dialog_type *dialog);
  566.         short top_border;
  567.         short left_border;
  568.         short bottom_border;
  569.         short right_border;
  570.         short shadow_bottom;
  571.         short shadow_right;
  572.         short outer_border;
  573. } dialog_settings_type;
  574.  
  575. typedef struct dialog_type {
  576.         dialog_settings_type* settings;
  577.         rect_type text_rect;
  578.         rect_type peel_rect;
  579.         word has_peel;
  580.         peel_type* peel;
  581. } dialog_type;
  582.  
  583. #pragma pack(pop)
  584.  
  585. enum soundids {
  586.         sound_0_fell_to_death = 0,
  587.         sound_1_falling = 1,
  588.         sound_2_tile_crashing = 2,
  589.         sound_3_button_pressed = 3,
  590.         sound_4_gate_closing = 4,
  591.         sound_5_gate_opening = 5,
  592.         sound_6_gate_closing_fast = 6,
  593.         sound_7_gate_stop = 7,
  594.         sound_8_bumped = 8,
  595.         sound_9_grab = 9,
  596.         sound_10_sword_vs_sword = 10,
  597.         sound_11_sword_moving = 11,
  598.         sound_12_guard_hurt = 12,
  599.         sound_13_kid_hurt = 13,
  600.         sound_14_leveldoor_closing = 14,
  601.         sound_15_leveldoor_sliding = 15,
  602.         sound_16_medium_land = 16,
  603.         sound_17_soft_land = 17,
  604.         sound_18_drink = 18,
  605.         sound_19_draw_sword = 19,
  606.         sound_20_loose_shake_1 = 20,
  607.         sound_21_loose_shake_2 = 21,
  608.         sound_22_loose_shake_3 = 22,
  609.         sound_23_footstep = 23,
  610.         sound_24_death_regular = 24,
  611.         sound_25_presentation = 25,
  612.         sound_26_embrace = 26,
  613.         sound_27_cutscene_2_4_6_12 = 27,
  614.         sound_28_death_in_fight = 28,
  615.         sound_29_meet_Jaffar = 29,
  616.         sound_30_big_potion = 30,
  617.         //sound_31 = 31,
  618.         sound_32_shadow_music = 32,
  619.         sound_33_small_potion = 33,
  620.         //sound_34 = 34,
  621.         sound_35_cutscene_8_9 = 35,
  622.         sound_36_out_of_time = 36,
  623.         sound_37_victory = 37,
  624.         sound_38_blink = 38,
  625.         sound_39_low_weight = 39,
  626.         sound_40_cutscene_12_short_time = 40,
  627.         sound_41_end_level_music = 41,
  628.         //sound_42 = 42,
  629.         sound_43_victory_Jaffar = 43,
  630.         sound_44_skel_alive = 44,
  631.         sound_45_jump_through_mirror = 45,
  632.         sound_46_chomped = 46,
  633.         sound_47_chomper = 47,
  634.         sound_48_spiked = 48,
  635.         sound_49_spikes = 49,
  636.         sound_50_story_2_princess = 50,
  637.         sound_51_princess_door_opening = 51,
  638.         sound_52_story_4_Jaffar_leaves = 52,
  639.         sound_53_story_3_Jaffar_comes = 53,
  640.         sound_54_intro_music = 54,
  641.         sound_55_story_1_absence = 55,
  642.         sound_56_ending_music = 56,
  643. };
  644.  
  645. enum timerids {
  646.         timer_0 = 0,
  647.         timer_1 = 1,
  648. };
  649.  
  650. enum frameids {
  651.         frame_0 = 0,
  652.         frame_1_start_run = 1,
  653.         frame_2_start_run = 2,
  654.         frame_3_start_run = 3,
  655.         frame_4_start_run = 4,
  656.         frame_5_start_run = 5,
  657.         frame_6_start_run = 6,
  658.         frame_7_run = 7,
  659.         frame_8_run = 8,
  660.         frame_9_run = 9,
  661.         frame_10_run = 10,
  662.         frame_11_run = 11,
  663.         frame_12_run = 12,
  664.         frame_13_run = 13,
  665.         frame_14_run = 14,
  666.         frame_15_stand = 15,
  667.         frame_16_standing_jump_1 = 16,
  668.         frame_17_standing_jump_2 = 17,
  669.         frame_18_standing_jump_3 = 18,
  670.         frame_19_standing_jump_4 = 19,
  671.         frame_20_standing_jump_5 = 20,
  672.         frame_21_standing_jump_6 = 21,
  673.         frame_22_standing_jump_7 = 22,
  674.         frame_23_standing_jump_8 = 23,
  675.         frame_24_standing_jump_9 = 24,
  676.         frame_25_standing_jump_10 = 25,
  677.         frame_26_standing_jump_11 = 26,
  678.         frame_27_standing_jump_12 = 27,
  679.         frame_28_standing_jump_13 = 28,
  680.         frame_29_standing_jump_14 = 29,
  681.         frame_30_standing_jump_15 = 30,
  682.         frame_31_standing_jump_16 = 31,
  683.         frame_32_standing_jump_17 = 32,
  684.         frame_33_standing_jump_18 = 33,
  685.         frame_34_start_run_jump_1 = 34,
  686.         frame_35_start_run_jump_2 = 35,
  687.         frame_36_start_run_jump_3 = 36,
  688.         frame_37_start_run_jump_4 = 37,
  689.         frame_38_start_run_jump_5 = 38,
  690.         frame_39_start_run_jump_6 = 39,
  691.         frame_40_running_jump_1 = 40,
  692.         frame_41_running_jump_2 = 41,
  693.         frame_42_running_jump_3 = 42,
  694.         frame_43_running_jump_4 = 43,
  695.         frame_44_running_jump_5 = 44,
  696.         frame_45_turn = 45,
  697.         frame_46_turn = 46,
  698.         frame_47_turn = 47,
  699.         frame_48_turn = 48,
  700.         frame_49_turn = 49,
  701.         frame_50_turn = 50,
  702.         frame_51_turn = 51,
  703.         frame_52_turn = 52,
  704.         frame_53_runturn = 53,
  705.         frame_54_runturn = 54,
  706.         frame_55_runturn = 55,
  707.         frame_56_runturn = 56,
  708.         frame_57_runturn = 57,
  709.         frame_58_runturn = 58,
  710.         frame_59_runturn = 59,
  711.         frame_60_runturn = 60,
  712.         frame_61_runturn = 61,
  713.         frame_62_runturn = 62,
  714.         frame_63_runturn = 63,
  715.         frame_64_runturn = 64,
  716.         frame_65_runturn = 65,
  717.         frame_67_start_jump_up_1 = 67,
  718.         frame_68_start_jump_up_2 = 68,
  719.         frame_69_start_jump_up_3 = 69,
  720.         frame_70_jumphang = 70,
  721.         frame_71_jumphang = 71,
  722.         frame_72_jumphang = 72,
  723.         frame_73_jumphang = 73,
  724.         frame_74_jumphang = 74,
  725.         frame_75_jumphang = 75,
  726.         frame_76_jumphang = 76,
  727.         frame_77_jumphang = 77,
  728.         frame_78_jumphang = 78,
  729.         frame_79_jumphang = 79,
  730.         frame_80_jumphang = 80,
  731.         frame_81_hangdrop_1 = 81,
  732.         frame_82_hangdrop_2 = 82,
  733.         frame_83_hangdrop_3 = 83,
  734.         frame_84_hangdrop_4 = 84,
  735.         frame_85_hangdrop_5 = 85,
  736.         frame_86_test_foot = 86,
  737.         frame_87_hanging_1 = 87,
  738.         frame_88_hanging_2 = 88,
  739.         frame_89_hanging_3 = 89,
  740.         frame_90_hanging_4 = 90,
  741.         frame_91_hanging_5 = 91,
  742.         frame_92_hanging_6 = 92,
  743.         frame_93_hanging_7 = 93,
  744.         frame_94_hanging_8 = 94,
  745.         frame_95_hanging_9 = 95,
  746.         frame_96_hanging_10 = 96,
  747.         frame_97_hanging_11 = 97,
  748.         frame_98_hanging_12 = 98,
  749.         frame_99_hanging_13 = 99,
  750.         frame_102_start_fall_1 = 102,
  751.         frame_103_start_fall_2 = 103,
  752.         frame_104_start_fall_3 = 104,
  753.         frame_105_start_fall_4 = 105,
  754.         frame_106_fall = 106,
  755.         frame_107_fall_land_1 = 107,
  756.         frame_108_fall_land_2 = 108,
  757.         frame_109_crouch = 109,
  758.         frame_110_stand_up_from_crouch_1 = 110,
  759.         frame_111_stand_up_from_crouch_2 = 111,
  760.         frame_112_stand_up_from_crouch_3 = 112,
  761.         frame_113_stand_up_from_crouch_4 = 113,
  762.         frame_114_stand_up_from_crouch_5 = 114,
  763.         frame_115_stand_up_from_crouch_6 = 115,
  764.         frame_116_stand_up_from_crouch_7 = 116,
  765.         frame_117_stand_up_from_crouch_8 = 117,
  766.         frame_118_stand_up_from_crouch_9 = 118,
  767.         frame_119_stand_up_from_crouch_10 = 119,
  768.         frame_121_stepping_1 = 121,
  769.         frame_122_stepping_2 = 122,
  770.         frame_123_stepping_3 = 123,
  771.         frame_124_stepping_4 = 124,
  772.         frame_125_stepping_5 = 125,
  773.         frame_126_stepping_6 = 126,
  774.         frame_127_stepping_7 = 127,
  775.         frame_128_stepping_8 = 128,
  776.         frame_129_stepping_9 = 129,
  777.         frame_130_stepping_10 = 130,
  778.         frame_131_stepping_11 = 131,
  779.         frame_132_stepping_12 = 132,
  780.         frame_133_sheathe = 133,
  781.         frame_134_sheathe = 134,
  782.         frame_135_climbing_1 = 135,
  783.         frame_136_climbing_2 = 136,
  784.         frame_137_climbing_3 = 137,
  785.         frame_138_climbing_4 = 138,
  786.         frame_139_climbing_5 = 139,
  787.         frame_140_climbing_6 = 140,
  788.         frame_141_climbing_7 = 141,
  789.         frame_142_climbing_8 = 142,
  790.         frame_143_climbing_9 = 143,
  791.         frame_144_climbing_10 = 144,
  792.         frame_145_climbing_11 = 145,
  793.         frame_146_climbing_12 = 146,
  794.         frame_147_climbing_13 = 147,
  795.         frame_148_climbing_14 = 148,
  796.         frame_149_climbing_15 = 149,
  797.         frame_150_parry = 150,
  798.         frame_151_strike_1 = 151,
  799.         frame_152_strike_2 = 152,
  800.         frame_153_strike_3 = 153,
  801.         frame_154_poking = 154,
  802.         frame_155_guy_7 = 155,
  803.         frame_156_guy_8 = 156,
  804.         frame_157_walk_with_sword = 157,
  805.         frame_158_stand_with_sword = 158,
  806.         frame_159_fighting = 159,
  807.         frame_160_fighting = 160,
  808.         frame_161_parry = 161,
  809.         frame_162_block_to_strike = 162,
  810.         frame_163_fighting = 163,
  811.         frame_164_fighting = 164,
  812.         frame_165_walk_with_sword = 165,
  813.         frame_166_stand_inactive = 166,
  814.         frame_167_blocked = 167,
  815.         frame_168_back = 168,
  816.         frame_169_begin_block = 169,
  817.         frame_170_stand_with_sword = 170,
  818.         frame_171_stand_with_sword = 171,
  819.         frame_172_jumpfall_2 = 172,
  820.         frame_173_jumpfall_3 = 173,
  821.         frame_174_jumpfall_4 = 174,
  822.         frame_175_jumpfall_5 = 175,
  823.         frame_177_spiked = 177,
  824.         frame_178_chomped = 178,
  825.         frame_179_collapse_1 = 179,
  826.         frame_180_collapse_2 = 180,
  827.         frame_181_collapse_3 = 181,
  828.         frame_182_collapse_4 = 182,
  829.         frame_183_collapse_5 = 183,
  830.         frame_185_dead = 185,
  831.         frame_186_mouse_1 = 186,
  832.         frame_187_mouse_2 = 187,
  833.         frame_188_mouse_stand = 188,
  834.         frame_191_drink = 191,
  835.         frame_192_drink = 192,
  836.         frame_193_drink = 193,
  837.         frame_194_drink = 194,
  838.         frame_195_drink = 195,
  839.         frame_196_drink = 196,
  840.         frame_197_drink = 197,
  841.         frame_198_drink = 198,
  842.         frame_199_drink = 199,
  843.         frame_200_drink = 200,
  844.         frame_201_drink = 201,
  845.         frame_202_drink = 202,
  846.         frame_203_drink = 203,
  847.         frame_204_drink = 204,
  848.         frame_205_drink = 205,
  849.         frame_207_draw_1 = 207,
  850.         frame_208_draw_2 = 208,
  851.         frame_209_draw_3 = 209,
  852.         frame_210_draw_4 = 210,
  853.         frame_217_exit_stairs_1 = 217,
  854.         frame_218_exit_stairs_2 = 218,
  855.         frame_219_exit_stairs_3 = 219,
  856.         frame_220_exit_stairs_4 = 220,
  857.         frame_221_exit_stairs_5 = 221,
  858.         frame_222_exit_stairs_6 = 222,
  859.         frame_223_exit_stairs_7 = 223,
  860.         frame_224_exit_stairs_8 = 224,
  861.         frame_225_exit_stairs_9 = 225,
  862.         frame_226_exit_stairs_10 = 226,
  863.         frame_227_exit_stairs_11 = 227,
  864.         frame_228_exit_stairs_12 = 228,
  865.         frame_229_found_sword = 229,
  866.         frame_230_sheathe = 230,
  867.         frame_231_sheathe = 231,
  868.         frame_232_sheathe = 232,
  869.         frame_233_sheathe = 233,
  870.         frame_234_sheathe = 234,
  871.         frame_235_sheathe = 235,
  872.         frame_236_sheathe = 236,
  873.         frame_237_sheathe = 237,
  874.         frame_238_sheathe = 238,
  875.         frame_239_sheathe = 239,
  876.         frame_240_sheathe = 240,
  877. };
  878.  
  879. enum altset2ids {
  880.         alt2frame_54_Vstand = 54,
  881.         //... incomplete
  882. };
  883.  
  884. enum seqids {
  885.         seq_1_start_run = 1,
  886.         seq_2_stand = 2,
  887.         seq_3_standing_jump = 3,
  888.         seq_4_run_jump = 4,
  889.         seq_5_turn = 5,
  890.         seq_6_run_turn = 6,
  891.         seq_7_fall = 7,
  892.         seq_8_jump_up_and_grab_straight = 8,
  893.         seq_10_climb_up = 10,
  894.         seq_11_release_ledge_and_land = 11,
  895.         seq_13_stop_run = 13,
  896.         seq_14_jump_up_into_ceiling = 14,
  897.         seq_15_grab_ledge_midair = 15,
  898.         seq_16_jump_up_and_grab = 16,
  899.         seq_17_soft_land = 17,
  900.         seq_18_fall_after_standing_jump = 18,
  901.         seq_19_fall = 19,
  902.         seq_20_medium_land = 20,
  903.         seq_21_fall_after_running_jump = 21,
  904.         seq_22_crushed = 22,
  905.         seq_23_release_ledge_and_fall = 23,
  906.         seq_24_jump_up_and_grab_forward = 24,
  907.         seq_25_hang_against_wall = 25,
  908.         seq_26_crouch_while_running = 26,
  909.         seq_28_jump_up_with_nothing_above = 28,
  910.         seq_29_safe_step_1 = 29,
  911.         seq_30_safe_step_2 = 30,
  912.         seq_31_safe_step_3 = 31,
  913.         seq_32_safe_step_4 = 32,
  914.         seq_33_safe_step_5 = 33,
  915.         seq_34_safe_step_6 = 34,
  916.         seq_35_safe_step_7 = 35,
  917.         seq_36_safe_step_8 = 36,
  918.         seq_37_safe_step_9 = 37,
  919.         seq_38_safe_step_10 = 38,
  920.         seq_39_safe_step_11 = 39,
  921.         seq_40_safe_step_12 = 40,
  922.         seq_41_safe_step_13 = 41,
  923.         seq_42_safe_step_14 = 42,
  924.         seq_43_start_run_after_turn = 43,
  925.         seq_44_step_on_edge = 44,
  926.         seq_45_bumpfall = 45,
  927.         seq_46_hardbump = 46,
  928.         seq_47_bump = 47,
  929.         seq_49_stand_up_from_crouch = 49,
  930.         seq_50_crouch = 50,
  931.         seq_51_spiked = 51,
  932.         seq_52_loose_floor_fell_on_kid = 52,
  933.         seq_54_chomped = 54,
  934.         seq_55_draw_sword = 55,
  935.         seq_56_guard_forward_with_sword = 56,
  936.         seq_57_back_with_sword = 57,
  937.         seq_58_guard_strike = 58,
  938.         seq_60_turn_with_sword = 60,
  939.         seq_61_parry_after_strike = 61,
  940.         seq_62_parry = 62,
  941.         seq_63_guard_stand_active = 63,
  942.         seq_64_pushed_back_with_sword = 64,
  943.         seq_65_bump_forward_with_sword = 65,
  944.         seq_66_strike_after_parry = 66,
  945.         seq_68_climb_down = 68,
  946.         seq_69_attack_was_parried = 69,
  947.         seq_70_go_up_on_level_door = 70,
  948.         seq_71_dying = 71,
  949.         seq_73_climb_up_to_closed_gate = 73,
  950.         seq_74_hit_by_sword = 74,
  951.         seq_75_strike = 75,
  952.         seq_77_guard_stand_inactive = 77,
  953.         seq_78_drink = 78,
  954.         seq_79_crouch_hop = 79,
  955.         seq_80_stand_flipped = 80,
  956.         seq_81_kid_pushed_off_ledge = 81,
  957.         seq_82_guard_pushed_off_ledge = 82,
  958.         seq_83_guard_fall = 83,
  959.         seq_84_run = 84,
  960.         seq_85_stabbed_to_death = 85,
  961.         seq_86_forward_with_sword = 86,
  962.         seq_87_guard_become_inactive = 87,
  963.         seq_88_skel_wake_up = 88,
  964.         seq_89_turn_draw_sword = 89,
  965.         seq_90_en_garde = 90,
  966.         seq_91_get_sword = 91,
  967.         seq_92_put_sword_away = 92,
  968.         seq_93_put_sword_away_fast = 93,
  969.         seq_94_princess_stand_PV1 = 94,
  970.         seq_95_Jaffar_stand_PV1 = 95,
  971.         seq_101_mouse_stands_up = 101,
  972.         seq_103_princess_lying_PV2 = 103,
  973.         seq_104_start_fall_in_front_of_wall = 104,
  974.         seq_105_mouse_forward = 105,
  975.         seq_106_mouse = 106,
  976.         seq_107_mouse_stand_up_and_go = 107,
  977.         seq_108_princess_turn_and_hug = 108,
  978.         seq_109_princess_stand_PV2 = 109,
  979.         seq_110_princess_crouching_PV2 = 110,
  980.         seq_111_princess_stand_up_PV2 = 111,
  981.         seq_112_princess_crouch_down_PV2 = 112,
  982.         seq_114_mouse_stand = 114,
  983. };
  984.  
  985. enum seqtbl_instructions {
  986.         SEQ_DX = 0xFB,
  987.         SEQ_DY = 0xFA,
  988.         SEQ_FLIP = 0xFE,
  989.         SEQ_JMP_IF_FEATHER = 0xF7,
  990.         SEQ_JMP = 0xFF,
  991.         SEQ_UP = 0xFD,
  992.         SEQ_DOWN = 0xFC,
  993.         SEQ_ACTION = 0xF9,
  994.         SEQ_SET_FALL = 0xF8,
  995.         SEQ_KNOCK_UP = 0xF5,
  996.         SEQ_KNOCK_DOWN = 0xF4,
  997.         SEQ_SOUND = 0xF2,
  998.         SEQ_END_LEVEL = 0xF1,
  999.         SEQ_GET_ITEM = 0xF3,
  1000.         SEQ_DIE = 0xF6,
  1001. };
  1002.  
  1003. enum seqtbl_sounds {
  1004.         SND_SILENT = 0,
  1005.         SND_FOOTSTEP = 1,
  1006.         SND_BUMP = 2,
  1007.         SND_DRINK = 3,
  1008.         SND_LEVEL = 4,
  1009. };
  1010.  
  1011. enum colorids {
  1012.         color_0_black = 0,
  1013.         color_1_blue = 1,
  1014.         color_2_green = 2,
  1015.         color_3_cyan = 3,
  1016.         color_4_red = 4,
  1017.         color_5_magenta = 5,
  1018.         color_6_brown = 6,
  1019.         color_7_lightgray = 7,
  1020.         color_8_darkgray = 8,
  1021.         color_9_brightblue = 9,
  1022.         color_10_brightgreen = 10,
  1023.         color_11_brightcyan = 11,
  1024.         color_12_brightred = 12,
  1025.         color_13_brightmagenta = 13,
  1026.         color_14_brightyellow = 14,
  1027.         color_15_brightwhite = 15,
  1028. };
  1029.  
  1030. #ifdef USE_REPLAY
  1031. enum replay_special_moves {
  1032.         MOVE_RESTART_LEVEL = 1, // player pressed Ctrl+A
  1033.         MOVE_EFFECT_END = 2,    // music stops, causing the end of feather effect or level 1 crouch immobilization
  1034. };
  1035.  
  1036. enum replay_seek_targets {
  1037.         replay_seek_0_next_room = 0,
  1038.         replay_seek_1_next_level = 1,
  1039.         replay_seek_2_end = 2,
  1040. };
  1041. #endif
  1042.  
  1043. #define COUNT(array) (sizeof(array)/sizeof(array[0]))
  1044.  
  1045. // These are or'ed with SDL_SCANCODE_* constants in last_key_scancode.
  1046. enum key_modifiers {
  1047.         WITH_SHIFT = 0x8000,
  1048.         WITH_CTRL  = 0x4000,
  1049.         WITH_ALT   = 0x2000,
  1050. };
  1051.  
  1052. #endif
  1053.