Mercurial > libdvdnav.hg
annotate vmcmd.c @ 191:dbea22936623 src
when a command has been issued to leave a menu, filter all further commands
for this menu
author | mroi |
---|---|
date | Tue, 06 May 2003 14:11:44 +0000 |
parents | f050b83857c9 |
children | a3d7b149cc0f |
rev | line source |
---|---|
0 | 1 /* |
189 | 2 * This program is free software; you can redistribute it and/or modify |
0 | 3 * it under the terms of the GNU General Public License as published by |
4 * the Free Software Foundation; either version 2 of the License, or | |
5 * (at your option) any later version. | |
6 * | |
189 | 7 * This program is distributed in the hope that it will be useful, |
0 | 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
10 * GNU General Public License for more details. | |
11 * | |
12 * You should have received a copy of the GNU General Public License | |
13 * along with this program; if not, write to the Free Software | |
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
15 * | |
16 * $Id$ | |
17 * | |
18 */ | |
19 | |
20 #ifdef HAVE_CONFIG_H | |
21 #include "config.h" | |
22 #endif | |
23 | |
24 #include <stdio.h> | |
25 #include <ctype.h> | |
26 #include <inttypes.h> | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
27 #include <assert.h> |
0 | 28 |
189 | 29 #ifdef _MSC_VER |
30 #include <timer.h> /* struct timeval */ | |
31 #endif | |
0 | 32 |
189 | 33 #include "vmcmd.h" |
0 | 34 |
114 | 35 |
0 | 36 /* freebsd compatibility */ |
37 #ifndef PRIu8 | |
38 #define PRIu8 "d" | |
39 #endif | |
40 | |
41 /* freebsd compatibility */ | |
42 #ifndef PRIu16 | |
43 #define PRIu16 "d" | |
44 #endif | |
45 | |
46 static const char *cmp_op_table[] = { | |
47 NULL, "&", "==", "!=", ">=", ">", "<=", "<" | |
48 }; | |
49 static const char *set_op_table[] = { | |
50 NULL, "=", "<->", "+=", "-=", "*=", "/=", "%=", "rnd", "&=", "|=", "^=" | |
51 }; | |
52 | |
53 static const char *link_table[] = { | |
54 "LinkNoLink", "LinkTopC", "LinkNextC", "LinkPrevC", | |
55 NULL, "LinkTopPG", "LinkNextPG", "LinkPrevPG", | |
56 NULL, "LinkTopPGC", "LinkNextPGC", "LinkPrevPGC", | |
57 "LinkGoUpPGC", "LinkTailPGC", NULL, NULL, | |
58 "RSM" | |
59 }; | |
60 | |
61 static const char *system_reg_table[] = { | |
62 "Menu Description Language Code", | |
63 "Audio Stream Number", | |
64 "Sub-picture Stream Number", | |
65 "Angle Number", | |
66 "Title Track Number", | |
67 "VTS Title Track Number", | |
68 "VTS PGC Number", | |
69 "PTT Number for One_Sequential_PGC_Title", | |
70 "Highlighted Button Number", | |
71 "Navigation Timer", | |
72 "Title PGC Number for Navigation Timer", | |
73 "Audio Mixing Mode for Karaoke", | |
74 "Country Code for Parental Management", | |
75 "Parental Level", | |
76 "Player Configurations for Video", | |
77 "Player Configurations for Audio", | |
78 "Initial Language Code for Audio", | |
79 "Initial Language Code Extension for Audio", | |
80 "Initial Language Code for Sub-picture", | |
81 "Initial Language Code Extension for Sub-picture", | |
82 "Player Regional Code", | |
83 "Reserved 21", | |
84 "Reserved 22", | |
85 "Reserved 23" | |
86 }; | |
87 | |
88 static const char *system_reg_abbr_table[] = { | |
89 NULL, | |
90 "ASTN", | |
91 "SPSTN", | |
92 "AGLN", | |
93 "TTN", | |
94 "VTS_TTN", | |
95 "TT_PGCN", | |
96 "PTTN", | |
97 "HL_BTNN", | |
98 "NVTMR", | |
99 "NV_PGCN", | |
100 NULL, | |
101 "CC_PLT", | |
102 "PLT", | |
103 NULL, | |
104 NULL, | |
105 NULL, | |
106 NULL, | |
107 NULL, | |
108 NULL, | |
109 NULL, | |
110 NULL, | |
111 NULL, | |
112 NULL, | |
113 }; | |
148 | 114 |
189 | 115 typedef struct { |
116 uint16_t SPRM[24]; | |
117 uint16_t GPRM[16]; | |
118 uint8_t GPRM_mode[16]; /* Need to have some thing to indicate normal/counter mode for every | |
119 GPRM */ | |
120 struct timeval GPRM_time[16]; /* For counter mode */ | |
121 } registers_t; | |
122 | |
123 typedef struct | |
124 { | |
125 uint64_t instruction; | |
126 uint64_t examined; | |
127 registers_t *registers; | |
128 } command_t; | |
129 | |
130 uint32_t vm_getbits(command_t *command, int start, int count) { | |
131 uint64_t result = 0; | |
132 uint64_t bit_mask=~0; /* I could put -1 instead */ | |
133 uint64_t examining = 0; | |
134 int32_t bits; | |
135 if (count == 0) return 0; | |
136 | |
137 if ( ((start - count) < -1) || | |
138 (count > 32) || | |
139 (start > 63) || | |
140 (count < 0) || | |
141 (start < 0) ){ | |
142 fprintf(stderr, "Bad call to vm_getbits. Parameter out of range\n"); | |
143 assert(0); | |
144 } | |
145 bit_mask >>= 63 - start; | |
146 bits = start + 1 - count; | |
147 examining = ((bit_mask >> bits) << bits ); | |
148 command->examined |= examining; | |
149 result = (command->instruction & bit_mask) >> bits; | |
150 return (uint32_t) result; | |
151 } | |
152 | |
0 | 153 static void print_system_reg(uint16_t reg) { |
154 if(reg < sizeof(system_reg_abbr_table) / sizeof(char *)) | |
148 | 155 fprintf(MSG_OUT, "%s (SRPM:%d)", system_reg_table[reg], reg); |
0 | 156 else |
76 | 157 fprintf(MSG_OUT, " WARNING: Unknown system register ( reg=%d ) ", reg); |
0 | 158 } |
159 | |
148 | 160 static void print_g_reg(uint8_t reg) { |
161 if(reg < 16) | |
162 fprintf(MSG_OUT, "g[%" PRIu8 "]", reg); | |
163 else | |
164 fprintf(MSG_OUT, " WARNING: Unknown general register "); | |
165 } | |
166 | |
0 | 167 static void print_reg(uint8_t reg) { |
168 if(reg & 0x80) | |
169 print_system_reg(reg & 0x7f); | |
170 else | |
148 | 171 print_g_reg(reg & 0x7f); |
0 | 172 } |
173 | |
174 static void print_cmp_op(uint8_t op) { | |
175 if(op < sizeof(cmp_op_table) / sizeof(char *) && cmp_op_table[op] != NULL) | |
76 | 176 fprintf(MSG_OUT, " %s ", cmp_op_table[op]); |
0 | 177 else |
76 | 178 fprintf(MSG_OUT, " WARNING: Unknown compare op "); |
0 | 179 } |
180 | |
181 static void print_set_op(uint8_t op) { | |
182 if(op < sizeof(set_op_table) / sizeof(char *) && set_op_table[op] != NULL) | |
76 | 183 fprintf(MSG_OUT, " %s ", set_op_table[op]); |
0 | 184 else |
76 | 185 fprintf(MSG_OUT, " WARNING: Unknown set op "); |
0 | 186 } |
187 | |
148 | 188 static void print_reg_or_data(command_t* command, int immediate, int start) { |
0 | 189 if(immediate) { |
189 | 190 uint32_t i = vm_getbits(command, start, 16); |
0 | 191 |
76 | 192 fprintf(MSG_OUT, "0x%x", i); |
0 | 193 if(isprint(i & 0xff) && isprint((i>>8) & 0xff)) |
76 | 194 fprintf(MSG_OUT, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff)); |
0 | 195 } else { |
148 | 196 print_reg(vm_getbits(command, start - 8, 8)); |
0 | 197 } |
198 } | |
199 | |
148 | 200 static void print_reg_or_data_2(command_t* command, int immediate, int start) { |
0 | 201 if(immediate) |
152
3a1659f4a6c3
Remove byte references. Convert them to bit references.
jcdutton
parents:
148
diff
changeset
|
202 fprintf(MSG_OUT, "0x%x", vm_getbits(command, start - 1, 7)); |
0 | 203 else |
148 | 204 fprintf(MSG_OUT, "g[%" PRIu8 "]", vm_getbits(command, start - 4, 4)); |
0 | 205 } |
206 | |
148 | 207 static void print_reg_or_data_3(command_t* command, int immediate, int start) { |
208 if(immediate) { | |
189 | 209 uint32_t i = vm_getbits(command, start, 16); |
148 | 210 |
211 fprintf(MSG_OUT, "0x%x", i); | |
212 if(isprint(i & 0xff) && isprint((i>>8) & 0xff)) | |
213 fprintf(MSG_OUT, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff)); | |
214 } else { | |
215 print_reg(vm_getbits(command, start, 8)); | |
216 } | |
217 } | |
218 | |
219 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
220 static void print_if_version_1(command_t* command) { |
148 | 221 uint8_t op = vm_getbits(command, 54, 3); |
0 | 222 |
223 if(op) { | |
76 | 224 fprintf(MSG_OUT, "if ("); |
155 | 225 print_g_reg(vm_getbits(command,39,8)); |
0 | 226 print_cmp_op(op); |
148 | 227 print_reg_or_data(command, vm_getbits(command, 55,1), 31); |
76 | 228 fprintf(MSG_OUT, ") "); |
0 | 229 } |
230 } | |
231 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
232 static void print_if_version_2(command_t* command) { |
148 | 233 uint8_t op = vm_getbits(command, 54, 3); |
0 | 234 |
235 if(op) { | |
76 | 236 fprintf(MSG_OUT, "if ("); |
148 | 237 print_reg(vm_getbits(command, 15, 8)); |
0 | 238 print_cmp_op(op); |
148 | 239 print_reg(vm_getbits(command, 7, 8)); |
76 | 240 fprintf(MSG_OUT, ") "); |
0 | 241 } |
242 } | |
243 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
244 static void print_if_version_3(command_t* command) { |
148 | 245 uint8_t op = vm_getbits(command, 54, 3); |
0 | 246 |
247 if(op) { | |
76 | 248 fprintf(MSG_OUT, "if ("); |
155 | 249 print_g_reg(vm_getbits(command, 43, 4)); |
0 | 250 print_cmp_op(op); |
148 | 251 print_reg_or_data(command, vm_getbits(command, 55, 1), 15); |
76 | 252 fprintf(MSG_OUT, ") "); |
0 | 253 } |
254 } | |
255 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
256 static void print_if_version_4(command_t* command) { |
148 | 257 uint8_t op = vm_getbits(command, 54, 3); |
258 | |
0 | 259 if(op) { |
76 | 260 fprintf(MSG_OUT, "if ("); |
148 | 261 print_g_reg(vm_getbits(command, 51, 4)); |
0 | 262 print_cmp_op(op); |
148 | 263 print_reg_or_data(command, vm_getbits(command, 55, 1), 31); |
76 | 264 fprintf(MSG_OUT, ") "); |
0 | 265 } |
266 } | |
267 | |
148 | 268 static void print_if_version_5(command_t* command) { |
269 uint8_t op = vm_getbits(command, 54, 3); | |
270 int set_immediate = vm_getbits(command, 60, 1); | |
271 | |
272 if(op) { | |
273 if (set_immediate) { | |
274 fprintf(MSG_OUT, "if ("); | |
275 print_g_reg(vm_getbits(command, 31, 8)); | |
276 print_cmp_op(op); | |
277 print_reg(vm_getbits(command, 23, 8)); | |
278 fprintf(MSG_OUT, ") "); | |
279 } else { | |
280 fprintf(MSG_OUT, "if ("); | |
281 print_g_reg(vm_getbits(command, 39, 8)); | |
282 print_cmp_op(op); | |
283 print_reg_or_data(command, vm_getbits(command, 55, 1), 31); | |
284 fprintf(MSG_OUT, ") "); | |
285 } | |
286 } | |
287 } | |
288 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
289 static void print_special_instruction(command_t* command) { |
148 | 290 uint8_t op = vm_getbits(command, 51, 4); |
0 | 291 |
292 switch(op) { | |
293 case 0: /* NOP */ | |
76 | 294 fprintf(MSG_OUT, "Nop"); |
0 | 295 break; |
296 case 1: /* Goto line */ | |
148 | 297 fprintf(MSG_OUT, "Goto %" PRIu8, vm_getbits(command, 7, 8)); |
0 | 298 break; |
299 case 2: /* Break */ | |
76 | 300 fprintf(MSG_OUT, "Break"); |
0 | 301 break; |
302 case 3: /* Parental level */ | |
76 | 303 fprintf(MSG_OUT, "SetTmpPML %" PRIu8 ", Goto %" PRIu8, |
148 | 304 vm_getbits(command, 11, 4), vm_getbits(command, 7, 8)); |
0 | 305 break; |
306 default: | |
76 | 307 fprintf(MSG_OUT, "WARNING: Unknown special instruction (%i)", |
148 | 308 vm_getbits(command, 51, 4)); |
0 | 309 } |
310 } | |
311 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
312 static void print_linksub_instruction(command_t* command) { |
189 | 313 uint32_t linkop = vm_getbits(command, 7, 8); |
314 uint32_t button = vm_getbits(command, 15, 6); | |
0 | 315 |
316 if(linkop < sizeof(link_table)/sizeof(char *) && link_table[linkop] != NULL) | |
76 | 317 fprintf(MSG_OUT, "%s (button %" PRIu8 ")", link_table[linkop], button); |
0 | 318 else |
76 | 319 fprintf(MSG_OUT, "WARNING: Unknown linksub instruction (%i)", linkop); |
0 | 320 } |
321 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
322 static void print_link_instruction(command_t* command, int optional) { |
148 | 323 uint8_t op = vm_getbits(command, 51, 4); |
0 | 324 |
325 if(optional && op) | |
76 | 326 fprintf(MSG_OUT, ", "); |
0 | 327 |
328 switch(op) { | |
329 case 0: | |
330 if(!optional) | |
76 | 331 fprintf(MSG_OUT, "WARNING: NOP (link)!"); |
0 | 332 break; |
333 case 1: | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
334 print_linksub_instruction(command); |
0 | 335 break; |
336 case 4: | |
148 | 337 fprintf(MSG_OUT, "LinkPGCN %" PRIu16, vm_getbits(command, 14, 15)); |
0 | 338 break; |
339 case 5: | |
76 | 340 fprintf(MSG_OUT, "LinkPTT %" PRIu16 " (button %" PRIu8 ")", |
148 | 341 vm_getbits(command, 9, 10), vm_getbits(command, 15, 6)); |
0 | 342 break; |
343 case 6: | |
76 | 344 fprintf(MSG_OUT, "LinkPGN %" PRIu8 " (button %" PRIu8 ")", |
148 | 345 vm_getbits(command, 6, 7), vm_getbits(command, 15, 6)); |
0 | 346 break; |
347 case 7: | |
76 | 348 fprintf(MSG_OUT, "LinkCN %" PRIu8 " (button %" PRIu8 ")", |
148 | 349 vm_getbits(command, 7, 8), vm_getbits(command, 15, 6)); |
0 | 350 break; |
351 default: | |
76 | 352 fprintf(MSG_OUT, "WARNING: Unknown link instruction"); |
0 | 353 } |
354 } | |
355 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
356 static void print_jump_instruction(command_t* command) { |
148 | 357 switch(vm_getbits(command, 51, 4)) { |
0 | 358 case 1: |
76 | 359 fprintf(MSG_OUT, "Exit"); |
0 | 360 break; |
361 case 2: | |
148 | 362 fprintf(MSG_OUT, "JumpTT %" PRIu8, vm_getbits(command, 22, 7)); |
0 | 363 break; |
364 case 3: | |
148 | 365 fprintf(MSG_OUT, "JumpVTS_TT %" PRIu8, vm_getbits(command, 22, 7)); |
0 | 366 break; |
367 case 5: | |
76 | 368 fprintf(MSG_OUT, "JumpVTS_PTT %" PRIu8 ":%" PRIu16, |
148 | 369 vm_getbits(command, 22, 7), vm_getbits(command, 41, 10)); |
0 | 370 break; |
371 case 6: | |
148 | 372 switch(vm_getbits(command, 23, 2)) { |
0 | 373 case 0: |
76 | 374 fprintf(MSG_OUT, "JumpSS FP"); |
0 | 375 break; |
376 case 1: | |
148 | 377 fprintf(MSG_OUT, "JumpSS VMGM (menu %" PRIu8 ")", vm_getbits(command, 19, 4)); |
0 | 378 break; |
379 case 2: | |
76 | 380 fprintf(MSG_OUT, "JumpSS VTSM (vts %" PRIu8 ", title %" PRIu8 |
155 | 381 ", menu %" PRIu8 ")", vm_getbits(command, 30, 7), vm_getbits(command, 38, 7), vm_getbits(command, 19, 4)); |
0 | 382 break; |
383 case 3: | |
148 | 384 fprintf(MSG_OUT, "JumpSS VMGM (pgc %" PRIu8 ")", vm_getbits(command, 46, 15)); |
0 | 385 break; |
386 } | |
387 break; | |
388 case 8: | |
148 | 389 switch(vm_getbits(command, 23, 2)) { |
0 | 390 case 0: |
76 | 391 fprintf(MSG_OUT, "CallSS FP (rsm_cell %" PRIu8 ")", |
148 | 392 vm_getbits(command, 31, 8)); |
0 | 393 break; |
394 case 1: | |
76 | 395 fprintf(MSG_OUT, "CallSS VMGM (menu %" PRIu8 |
148 | 396 ", rsm_cell %" PRIu8 ")", vm_getbits(command, 19, 4), vm_getbits(command, 31, 8)); |
0 | 397 break; |
398 case 2: | |
76 | 399 fprintf(MSG_OUT, "CallSS VTSM (menu %" PRIu8 |
148 | 400 ", rsm_cell %" PRIu8 ")", vm_getbits(command, 19, 4), vm_getbits(command, 31, 8)); |
0 | 401 break; |
402 case 3: | |
76 | 403 fprintf(MSG_OUT, "CallSS VMGM (pgc %" PRIu8 ", rsm_cell %" PRIu8 ")", |
148 | 404 vm_getbits(command, 46, 15), vm_getbits(command, 31, 8)); |
0 | 405 break; |
406 } | |
407 break; | |
408 default: | |
76 | 409 fprintf(MSG_OUT, "WARNING: Unknown Jump/Call instruction"); |
0 | 410 } |
411 } | |
412 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
413 static void print_system_set(command_t* command) { |
0 | 414 int i; |
155 | 415 /* FIXME: What about SPRM11 ? Karaoke */ |
416 /* Surely there must be some system set command for that ? */ | |
0 | 417 |
148 | 418 switch(vm_getbits(command, 59, 4)) { |
0 | 419 case 1: /* Set system reg 1 &| 2 &| 3 (Audio, Subp. Angle) */ |
420 for(i = 1; i <= 3; i++) { | |
155 | 421 if(vm_getbits(command, 47 - (i*8), 1)) { |
0 | 422 print_system_reg(i); |
76 | 423 fprintf(MSG_OUT, " = "); |
148 | 424 print_reg_or_data_2(command, vm_getbits(command, 60, 1), 47 - (i*8) ); |
76 | 425 fprintf(MSG_OUT, " "); |
0 | 426 } |
427 } | |
428 break; | |
429 case 2: /* Set system reg 9 & 10 (Navigation timer, Title PGC number) */ | |
430 print_system_reg(9); | |
76 | 431 fprintf(MSG_OUT, " = "); |
148 | 432 print_reg_or_data(command, vm_getbits(command, 60, 1), 47); |
76 | 433 fprintf(MSG_OUT, " "); |
0 | 434 print_system_reg(10); |
155 | 435 fprintf(MSG_OUT, " = %" PRIu16, vm_getbits(command, 30, 15)); /* ?? */ |
0 | 436 break; |
437 case 3: /* Mode: Counter / Register + Set */ | |
76 | 438 fprintf(MSG_OUT, "SetMode "); |
148 | 439 if(vm_getbits(command, 23, 1)) |
76 | 440 fprintf(MSG_OUT, "Counter "); |
0 | 441 else |
76 | 442 fprintf(MSG_OUT, "Register "); |
155 | 443 print_g_reg(vm_getbits(command, 19, 4)); |
0 | 444 print_set_op(0x1); /* '=' */ |
148 | 445 print_reg_or_data(command, vm_getbits(command, 60, 1), 47); |
0 | 446 break; |
447 case 6: /* Set system reg 8 (Highlighted button) */ | |
448 print_system_reg(8); | |
148 | 449 if(vm_getbits(command, 60, 1)) /* immediate */ |
450 fprintf(MSG_OUT, " = 0x%x (button no %d)", vm_getbits(command, 31, 16), vm_getbits(command, 31, 6)); | |
0 | 451 else |
148 | 452 fprintf(MSG_OUT, " = g[%" PRIu8 "]", vm_getbits(command, 19, 4)); |
0 | 453 break; |
454 default: | |
76 | 455 fprintf(MSG_OUT, "WARNING: Unknown system set instruction (%i)", |
148 | 456 vm_getbits(command, 59, 4)); |
0 | 457 } |
458 } | |
459 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
460 static void print_set_version_1(command_t* command) { |
148 | 461 uint8_t set_op = vm_getbits(command, 59, 4); |
0 | 462 |
463 if(set_op) { | |
155 | 464 print_g_reg(vm_getbits(command, 35, 4)); |
0 | 465 print_set_op(set_op); |
148 | 466 print_reg_or_data(command, vm_getbits(command, 60, 1), 31); |
0 | 467 } else { |
76 | 468 fprintf(MSG_OUT, "NOP"); |
0 | 469 } |
470 } | |
471 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
472 static void print_set_version_2(command_t* command) { |
148 | 473 uint8_t set_op = vm_getbits(command, 59, 4); |
0 | 474 |
475 if(set_op) { | |
155 | 476 print_g_reg(vm_getbits(command, 51, 4)); |
0 | 477 print_set_op(set_op); |
148 | 478 print_reg_or_data(command, vm_getbits(command, 60, 1), 47); |
0 | 479 } else { |
76 | 480 fprintf(MSG_OUT, "NOP"); |
0 | 481 } |
482 } | |
483 | |
148 | 484 static void print_set_version_3(command_t* command) { |
485 uint8_t set_op = vm_getbits(command, 59, 4); | |
486 | |
487 if(set_op) { | |
155 | 488 print_g_reg(vm_getbits(command, 51, 4)); |
148 | 489 print_set_op(set_op); |
490 print_reg_or_data_3(command, vm_getbits(command, 60, 1), 47); | |
491 } else { | |
492 fprintf(MSG_OUT, "NOP"); | |
493 } | |
494 } | |
495 | |
496 | |
497 void vm_print_mnemonic(vm_cmd_t *vm_command) { | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
498 command_t command; |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
499 command.instruction =( (uint64_t) vm_command->bytes[0] << 56 ) | |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
500 ( (uint64_t) vm_command->bytes[1] << 48 ) | |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
501 ( (uint64_t) vm_command->bytes[2] << 40 ) | |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
502 ( (uint64_t) vm_command->bytes[3] << 32 ) | |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
503 ( (uint64_t) vm_command->bytes[4] << 24 ) | |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
504 ( (uint64_t) vm_command->bytes[5] << 16 ) | |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
505 ( (uint64_t) vm_command->bytes[6] << 8 ) | |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
506 (uint64_t) vm_command->bytes[7] ; |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
507 command.examined = 0; |
0 | 508 |
148 | 509 switch(vm_getbits(&command,63,3)) { /* three first bits */ |
0 | 510 case 0: /* Special instructions */ |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
511 print_if_version_1(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
512 print_special_instruction(&command); |
0 | 513 break; |
514 case 1: /* Jump/Call or Link instructions */ | |
148 | 515 if(vm_getbits(&command,60,1)) { |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
516 print_if_version_2(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
517 print_jump_instruction(&command); |
0 | 518 } else { |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
519 print_if_version_1(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
520 print_link_instruction(&command, 0); /* must be pressent */ |
0 | 521 } |
522 break; | |
523 case 2: /* Set System Parameters instructions */ | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
524 print_if_version_2(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
525 print_system_set(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
526 print_link_instruction(&command, 1); /* either 'if' or 'link' */ |
0 | 527 break; |
528 case 3: /* Set General Parameters instructions */ | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
529 print_if_version_3(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
530 print_set_version_1(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
531 print_link_instruction(&command, 1); /* either 'if' or 'link' */ |
0 | 532 break; |
533 case 4: /* Set, Compare -> LinkSub instructions */ | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
534 print_set_version_2(&command); |
76 | 535 fprintf(MSG_OUT, ", "); |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
536 print_if_version_4(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
537 print_linksub_instruction(&command); |
0 | 538 break; |
539 case 5: /* Compare -> (Set and LinkSub) instructions */ | |
148 | 540 print_if_version_5(&command); |
76 | 541 fprintf(MSG_OUT, "{ "); |
148 | 542 print_set_version_3(&command); |
76 | 543 fprintf(MSG_OUT, ", "); |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
544 print_linksub_instruction(&command); |
76 | 545 fprintf(MSG_OUT, " }"); |
0 | 546 break; |
547 case 6: /* Compare -> Set, always LinkSub instructions */ | |
148 | 548 print_if_version_5(&command); |
76 | 549 fprintf(MSG_OUT, "{ "); |
148 | 550 print_set_version_3(&command); |
76 | 551 fprintf(MSG_OUT, " } "); |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
552 print_linksub_instruction(&command); |
0 | 553 break; |
554 default: | |
148 | 555 fprintf(MSG_OUT, "WARNING: Unknown instruction type (%i)", vm_getbits(&command, 63, 3)); |
0 | 556 } |
557 /* Check if there still are bits set that were not examined */ | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
558 |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
559 if(command.instruction & ~ command.examined) { |
76 | 560 fprintf(MSG_OUT, " libdvdnav: vmcmd.c: [WARNING, unknown bits:"); |
561 fprintf(MSG_OUT, " %08llx", (command.instruction & ~ command.examined) ); | |
562 fprintf(MSG_OUT, "]"); | |
0 | 563 } |
564 } | |
565 | |
153 | 566 void vm_print_cmd(int row, vm_cmd_t *vm_command) { |
0 | 567 int i; |
568 | |
76 | 569 fprintf(MSG_OUT, "(%03d) ", row + 1); |
0 | 570 for(i = 0; i < 8; i++) |
76 | 571 fprintf(MSG_OUT, "%02x ", vm_command->bytes[i]); |
572 fprintf(MSG_OUT, "| "); | |
0 | 573 |
153 | 574 vm_print_mnemonic(vm_command); |
76 | 575 fprintf(MSG_OUT, "\n"); |
0 | 576 } |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
0
diff
changeset
|
577 |
189 | 578 /* |
579 * $Log$ | |
580 * Revision 1.14 2003/05/05 00:25:11 tchamp | |
581 * Changed the linkage for msvc | |
582 * | |
583 * Revision 1.12 2003/05/01 16:44:43 tchamp | |
584 * ifo_dump should now build with msvc version of libdvdnav | |
585 * | |
586 * Revision 1.11 2003/04/28 15:17:18 jcdutton | |
587 * Update ifodump to work with new libdvdnav cvs, instead of needing libdvdread. | |
588 * | |
589 * Revision 1.10 2003/04/05 16:31:53 jcdutton | |
590 * Some minor changes and updates. | |
591 * | |
592 * Revision 1.9 2003/04/05 15:23:07 jcdutton | |
593 * Minor updates | |
594 * | |
595 * Revision 1.8 2003/04/05 13:03:49 jcdutton | |
596 * Small updates. | |
597 * | |
598 * Revision 1.7 2003/04/05 12:45:47 jcdutton | |
599 * Use MSG_OUT instead of stdout. | |
600 * | |
601 * Revision 1.6 2003/04/05 09:15:43 jcdutton | |
602 * Minor fix | |
603 * | |
604 * Revision 1.5 2003/04/03 11:05:20 jcdutton | |
605 * Tidy up. | |
606 * | |
607 * Revision 1.4 2003/04/03 11:01:36 jcdutton | |
608 * Change byte references to bits. | |
609 * | |
610 * Revision 1.3 2003/04/03 10:51:28 jcdutton | |
611 * Change getbits start param to actually start at the right bit. | |
612 * e.g. lowest bit in a 64 bit number bit 0 and represents value of 1 | |
613 * next bit is a 64 bit number is bit 1 and represents a value of 2 | |
614 * next bit is a 64 bit number is bit 2 and represents a value of 4 | |
615 * | |
616 * Before, a start value of 0 would represent bit 63, and a start value of 63 would represent bit 0. | |
617 * | |
618 * So, I changed it to be more common sense. | |
619 * | |
620 * Revision 1.2 2003/04/02 13:58:19 jcdutton | |
621 * Fix some instruction printouts. | |
622 * | |
623 * Revision 1.1.1.1 2002/08/28 09:48:35 jcdutton | |
624 * Initial import into CVS. | |
625 * | |
626 * | |
627 * | |
628 */ |