uctools.h

Go to the documentation of this file.
00001 #ifndef UCTOOLS_H
00002 #define UCTOOLS_H
00003 
00004 // Opcode flags
00005 // Just a 16bit word
00006 #define IMMED         0
00007 // Will print a part of data string as comment
00008 #define DATA_STRING       1
00009 // Will add command offset before printing
00010 #define RELATIVE_JUMP     2
00011 // Will print third byte as decimal after comma
00012 #define CALL          3
00013 // Will print in square brackets
00014 #define VARREF          4
00015 // Will print in square brackets with "flag:" prefix
00016 #define FLGREF          5
00017 // Call of usecode function using extern table
00018 #define EXTCALL         6
00019 // An immediate op. and then a rel. jmp address:  JSF
00020 #define IMMED_AND_RELATIVE_JUMP     7
00021 // Just x bytes
00022 #define PUSH          8
00023 // Just a byte
00024 #define BYTE          9
00025 // variable + relative jump (for the 'sloop')
00026 #define SLOOP   10
00027 #define POP 11
00028 #define IMMED32 12
00029 #define DATA_STRING32 13
00030 #define RELATIVE_JUMP32 14
00031 #define IMMED_RELJUMP32 15
00032 #define SLOOP32 16
00033 
00034 // Opcode descriptor
00035 typedef struct _opcode_desc
00036 {
00037   // Mnemonic - NULL if not known yet
00038   const char* mnemonic;
00039   // Number of operand bytes
00040   int nbytes;
00041   // Type flags
00042   unsigned int type;
00043 } opcode_desc;
00044 
00045 // Opcode table
00046 static opcode_desc opcode_table[] =
00047 {
00048   { NULL, 0, 0 },           // 00
00049   { NULL, 0, 0 },           // 01
00050   { "loop", 10, SLOOP },    // 02
00051   { NULL, 0, 0 },           // 03
00052   { "startconv", 2, RELATIVE_JUMP },  // 04
00053   { "jne", 2, RELATIVE_JUMP },        // 05
00054   { "jmp", 2, RELATIVE_JUMP },        // 06
00055   { "cmps", 4, IMMED_AND_RELATIVE_JUMP },     // 07 JSF
00056   { NULL, 0, 0 },           // 08
00057   { "add", 0, 0 },          // 09
00058   { "sub", 0, 0 },          // 0a
00059   { "div", 0, 0 },          // 0b
00060   { "mul", 0, 0 },          // 0c
00061   { "mod", 0, 0 },          // 0d
00062   { "and", 0, 0 },          // 0e
00063   { "or", 0, 0 },           // 0f
00064   { "not", 0, 0 },          // 10
00065   { NULL, 0, 0 },           // 11
00066   { "pop", 2, VARREF },         // 12
00067   { "push\ttrue", 0, 0 },         // 13
00068   { "push\tfalse", 0, 0 },        // 14
00069   { NULL, 0, 0 },           // 15
00070   { "cmpgt", 0, 0 },          // 16
00071   { "cmpl", 0, 0 },         // 17
00072   { "cmpge", 0, 0 },          // 18
00073   { "cmple", 0, 0 },          // 19
00074   { "cmpne", 0, 0 },          // 1a
00075   { NULL, 0, 0 },           // 1b
00076   { "addsi", 2, DATA_STRING },        // 1c
00077   { "pushs", 2, DATA_STRING },        // 1d
00078   { "arrc", 2, IMMED },         // 1e
00079   { "pushi", 2, IMMED },          // 1f
00080   { NULL, 0, 0 },           // 20
00081   { "push", 2, VARREF },          // 21
00082   { "cmpeq", 0, 0 },          // 22
00083   { NULL, 0, 0 },           // 23
00084   { "call", 2, EXTCALL },         // 24
00085   { "ret", 0, 0 },          // 25
00086   { "aidx", 2, VARREF },          // 26
00087   { NULL, 0, 0 },           // 27
00088   { NULL, 0, 0 },           // 28
00089   { NULL, 0, 0 },           // 29
00090   { NULL, 0, 0 },           // 2a
00091   { NULL, 0, 0 },           // 2b
00092   { "ret2", 0, 0 },         // 2c
00093   { "setr", 0, 0 },         // 2d
00094   { "initloop", 0, 0 },       // 2e
00095   { "addsv", 2, VARREF },       // 2f
00096   { "in", 0, 0 },           // 30
00097   { "conv_something", 4, IMMED_AND_RELATIVE_JUMP },     // 31
00098   { "rts", 0, 0 },          // 32
00099   { "say", 0, 0 },          // 33
00100   { NULL, 0, 0 },           // 34
00101   { NULL, 0, 0 },           // 35
00102   { NULL, 0, 0 },           // 36
00103   { NULL, 0, 0 },           // 37
00104   { "callis", 3, CALL },          // 38
00105   { "calli", 3, CALL },         // 39
00106   { NULL, 0, 0 },           // 3a
00107   { NULL, 0, 0 },           // 3b
00108   { NULL, 0, 0 },           // 3c
00109   { NULL, 0, 0 },           // 3d
00110   { "push\titemref", 0, 0 },        // 3e
00111   { "abrt", 0, 0 },         // 3f
00112   { "endconv", 0, 0 },          // 40
00113   { NULL, 0, 0 },           // 41
00114   { "pushf", 2, FLGREF },         // 42
00115   { "popf", 2, FLGREF },          // 43
00116   { "pushw", 1, BYTE },         // 44
00117   { NULL, 0, 0 },           // 45
00118   { "setarrayelem", 2, IMMED },     // 46
00119   { "calle",2,IMMED },          // 47
00120   { "push\teventid", 0, 0 },        // 48
00121   { NULL, 0, 0 },           // 49
00122   { "arra", 0, 0 },         // 4a
00123   { "pop\teventid", 0, 0 },         // 4b
00124   { "line",2,IMMED },         // 4c
00125   { "func",4,DATA_STRING },     // 4d
00126   { NULL, 0, 0 }, { NULL, 0, 0 },     // 4e - 4f
00127   { "push\tstatic", 2, VARREF },      // 50
00128   { "pop\tstatic", 2, VARREF },     // 51
00129   { "callo",2,IMMED },        // 52
00130   { NULL, 0, 0 },         // 53
00131   { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, // 54-57
00132   { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, // 58-5B
00133   { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, // 5C-5F
00134   { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, // 60-63
00135   { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, // 64-67
00136   { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, // 68-6B
00137   { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, // 6C-6F
00138   { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, // 70-73
00139   { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, // 74-77
00140   { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, // 78-7B
00141   { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, { NULL, 0, 0 }, // 7C-7F
00142   { NULL, 0, 0 },           // 80
00143   { NULL, 0, 0 },           // 81
00144   { "sloop_iter32", 12, SLOOP32 },    // 82
00145   { NULL, 0, 0 },           // 83
00146   { "startconv32", 4, RELATIVE_JUMP32 },  // 84
00147   { "jne32", 4, RELATIVE_JUMP32 },    // 85
00148   { "jmp32", 4, RELATIVE_JUMP32 },    // 86
00149   { "cmps32", 6, IMMED_RELJUMP32 }, // 87
00150   { NULL, 0, 0 },           // 88
00151   { NULL, 0, 0 },         // 89
00152   { NULL, 0, 0 },         // 8a
00153   { NULL, 0, 0 },         // 8b
00154   { NULL, 0, 0 },         // 8c
00155   { NULL, 0, 0 },         // 8d
00156   { NULL, 0, 0 },         // 8e
00157   { NULL, 0, 0 },           // 8f
00158   { NULL, 0, 0 },         // 90
00159   { NULL, 0, 0 },           // 91
00160   { NULL, 0, 0 },       // 92
00161   { NULL, 0, 0 },       // 93
00162   { NULL, 0, 0 },     // 94
00163   { NULL, 0, 0 },           // 95
00164   { NULL, 0, 0 },         // 96
00165   { NULL, 0, 0 },         // 97
00166   { NULL, 0, 0 },         // 98
00167   { NULL, 0, 0 },         // 99
00168   { NULL, 0, 0 },         // 9a
00169   { NULL, 0, 0 },           // 9b
00170   { "addsi32", 4, DATA_STRING32 },    // 9c
00171   { "pushs32", 4, DATA_STRING32 },    // 9d
00172   { NULL, 0, 0 },       // 9e
00173   { "pushi32", 4, IMMED32 },        // 9f
00174   { NULL, 0, 0 },           // a0
00175   { NULL, 0, 0 },       // a1
00176   { NULL, 0, 0 },         // a2
00177   { NULL, 0, 0 },           // a3
00178   { NULL, 0, 0 },       // a4
00179   { NULL, 0, 0 },         // a5
00180   { NULL, 0, 0 },       // a6
00181   { NULL, 0, 0 },           // a7
00182   { NULL, 0, 0 },           // a8
00183   { NULL, 0, 0 },           // a9
00184   { NULL, 0, 0 },           // aa
00185   { NULL, 0, 0 },           // ab
00186   { NULL, 0, 0 },         // ac
00187   { NULL, 0, 0 },         // ad
00188   { "sloop32", 13, SLOOP32 },       // ae
00189   { NULL, 0, 0 },       // af
00190   { NULL, 0, 0 },           // b0
00191   { "conv_something32", 6, IMMED_RELJUMP32 },     // b1
00192   { NULL, 0, 0 },         // b2
00193   { NULL, 0, 0 },         // b3
00194   { NULL, 0, 0 },           // b4
00195   { NULL, 0, 0 },           // b5
00196   { NULL, 0, 0 },           // b6
00197   { NULL, 0, 0 },           // b7
00198   { NULL, 0, 0 },         // b8
00199   { NULL, 0, 0 },         // b9
00200   { NULL, 0, 0 },           // ba
00201   { NULL, 0, 0 },           // bb
00202   { NULL, 0, 0 },           // bc
00203   { NULL, 0, 0 },           // bd
00204   { NULL, 0, 0 },       // be
00205   { NULL, 0, 0 },         // bf
00206   { NULL, 0, 0 },         // c0
00207   { NULL, 0, 0 },           // c1
00208   { NULL, 0, 0 },         // c2
00209   { NULL, 0, 0 },         // c3
00210   { NULL, 0, 0 },         // c4
00211   { NULL, 0, 0 },           // c5
00212   { NULL, 0, 0 },     // c6
00213   { NULL, 0, 0 },         // c7
00214   { NULL, 0, 0 },       // c8
00215   { NULL, 0, 0 },           // c9
00216   { NULL, 0, 0 },         // ca
00217   { NULL, 0, 0 },         // cb
00218   { NULL, 0, 0 },         // cc
00219   { "func32",8,DATA_STRING32 }      // cd
00220 
00221 };
00222 
00223 
00224 
00225 // Embedded function table
00226 
00227 /*
00228  *  Tables of usecode intrinsics:
00229  */
00230 #define USECODE_INTRINSIC_PTR(NAME) #NAME
00231 
00232 const char *bg_intrinsic_table[] =
00233   {
00234 #include "bgintrinsics.h"
00235   };
00236 const int bg_intrinsic_size = sizeof(bg_intrinsic_table)/sizeof(char*);
00237 const char *si_intrinsic_table[] = 
00238   {
00239 #include "siintrinsics.h"
00240   };
00241 const int si_intrinsic_size = sizeof(si_intrinsic_table)/sizeof(char*);
00242 
00243 
00244 
00245 #if 0
00246 const char* func_table[] = 
00247 {
00248   "get_random",           // 0
00249   "execute_usecode_array",        // 1
00250   "delayed_execute_usecode_array",      // 2
00251   "show_npc_face",          // 3
00252   "hide_npc_face",          // 4
00253   "add_answer",           // 5
00254   "remove_answer",          // 6
00255   "push_answers",           // 7
00256   "pop_answers",            // 8
00257   "clear_answers",          // 9
00258   "select_from_menu",         // a
00259   "select_from_menu2",          // b
00260   "input_numeric_value",          // c
00261   "set_item_shape",         // d
00262   "find_nearest",           // e
00263   "play_sound_effect",          // f
00264   "die_roll",           // 10
00265   "get_item_shape",         // 11
00266   "get_item_frame",         // 12
00267   "set_item_frame",         // 13
00268   "get_item_quality",         // 14
00269   "set_item_quality",         // 15
00270   "get_item_quantity",          // 16
00271   "set_item_quantity",          // 17
00272   "get_object_position",          // 18
00273   "get_distance",           // 19
00274   "find_direction",         // 1a
00275   "get_npc_object",         // 1b
00276   "get_schedule_type",          // 1c
00277   "set_schedule_type",          // 1d
00278   "add_to_party",           // 1e
00279   "remove_from_party",          // 1f
00280   "get_npc_property",         // 20
00281   "set_npc_property",         // 21
00282   "get_avatar_ref",         // 22
00283   "get_party_list",         // 23
00284   "create_new_object",          // 24
00285   "set_last_created",         // 25
00286   "update_last_created",          // 26
00287   "get_npc_name",           // 27
00288   "count_objects",          // 28
00289   "take_from_owner",          // 29
00290   "get_container_items",          // 2a
00291   "remove_party_items",         // 2b
00292   "add_party_items",          // 2c
00293   NULL,             // 2d
00294   "play_music",           // 2e
00295   "npc_nearby",           // 2f
00296   "find_nearby_avatar",         // 30
00297   "is_npc",           // 31
00298   "display_runes",          // 32
00299   "click_on_item",          // 33
00300   NULL,             // 34
00301   "find_nearby",            // 35
00302   "give_last_created",          // 36
00303   "is_dead",            // 37
00304   "game_hour",            // 38
00305   "game_minute",            // 39
00306   "get_npc_number",         // 3a
00307   "part_of_day",            // 3b
00308   "get_alignment",          // 3c
00309   "set_alignment",          // 3d
00310   "move_object",            // 3e
00311   NULL,             // 3f
00312   "item_say",           // 40
00313   "projectile_effect",          // 41
00314   "get_lift",           // 42
00315   "set_lift",           // 43
00316   NULL,             // 44
00317   NULL,             // 45
00318   "sit_down",           // 46
00319   NULL,             // 47
00320   "display_map",            // 48
00321   "kill_npc",           // 49
00322   NULL,             // 4a
00323   "set_npc_attack_mode",          // 4b
00324   "set_target_npc_to_attack",       // 4c
00325   "clone_npc",            // 4d
00326   NULL,             // 4e
00327   "show_crystal_ball",          // 4f
00328   "show_wizard_eye",          // 50
00329   "resurrect_npc",          // 51
00330   "add_spell",            // 52
00331   "sprite_effect",          // 53
00332   NULL,             // 54
00333   "book_mode",            // 55
00334   "stop_time",            // 56
00335   "cause_light",            // 57
00336   "get_barge",            // 58
00337   "earthquake",           // 59
00338   "is_player_female",         // 5a
00339   "armageddon",           // 5b
00340   "halt_scheduled",         // 5c
00341   "cause_blackout",         // 5d
00342   "get_array_size",         // 5e
00343   "mark_stone",           // 5f
00344   "recall_stone",           // 60
00345   NULL,             // 61
00346   "is_pc_inside",           // 62
00347   "set_orrery_state",         // 63
00348   NULL,             // 64
00349   "get_timer",            // 65
00350   "set_timer",            // 66
00351   NULL,             // 67
00352   "mouse_exists",           // 68
00353   NULL,             // 69
00354   "flash_mouse",            // 6a
00355   NULL,             // 6b
00356   NULL,             // 6c
00357   NULL,             // 6d
00358   "get_container",          // 6e
00359   "remove_item",            // 6f
00360   NULL,             // 70
00361   NULL,             // 71
00362   "get_equipment_list",         // 72
00363   NULL,             // 73
00364   NULL,             // 74
00365   "start_endgame",          // 75
00366   "fire_cannon",            // 76
00367   "nap_time",           // 77
00368   "advance_time",           // 78
00369   "in_usecode",           // 79
00370   NULL,             // 7a
00371   NULL,             // 7b
00372   NULL,             // 7c
00373   "path_run_usecode",         // 7d
00374   "close_gumps",            // 7e
00375   "item_say",           // 7f
00376   NULL,             // 80
00377   "in_gump_mode",           // 81
00378   NULL,             // 82
00379   NULL,             // 83
00380   NULL,             // 84
00381   "is_not_blocked",         // 85
00382   NULL,             // 86
00383   "direction_from",         // 87
00384   "get_npc_flag",           // 88
00385   "set_npc_flag",           // 89
00386   "clear_npc_flag",         // 8a
00387   "run_usecode",            // 8b
00388   "fade_palette",           // 8c
00389   "get_party_list2",          // 8d
00390   "in_combat",            // 8e
00391   NULL,             // 8f
00392   NULL,             // 90
00393   NULL,             // 91
00394   NULL,             // 92
00395   NULL,             // 93
00396   NULL,             // 94
00397   NULL,             // 95
00398   NULL              // 96
00399 };
00400 #endif
00401 
00402 #endif

Generated on Mon Jul 9 14:42:51 2007 for ExultEngine by  doxygen 1.5.1