Mercurial > libdvdnav.hg
annotate vmcmd.c @ 217:eb503714e1c2 src
these variables are not needed any more
author | mroi |
---|---|
date | Wed, 31 Dec 2003 16:56:12 +0000 |
parents | a3d7b149cc0f |
children | 993dc61d2c4f |
rev | line source |
---|---|
0 | 1 /* |
192
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
2 * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort |
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
3 * |
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
4 * This file is part of libdvdnav, a DVD navigation library. It is modified |
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
5 * from a file originally part of the Ogle DVD player. |
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
6 * |
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
7 * libdvdnav is free software; you can redistribute it and/or modify |
0 | 8 * it under the terms of the GNU General Public License as published by |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
192
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
12 * libdvdnav is distributed in the hope that it will be useful, |
0 | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
20 * | |
21 * $Id$ | |
22 * | |
23 */ | |
24 | |
25 #ifdef HAVE_CONFIG_H | |
26 #include "config.h" | |
27 #endif | |
28 | |
29 #include <stdio.h> | |
30 #include <ctype.h> | |
31 #include <inttypes.h> | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
32 #include <assert.h> |
0 | 33 |
192
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
34 #include "dvdnav_internal.h" |
0 | 35 |
36 | |
192
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
37 #ifdef TRACE |
114 | 38 |
0 | 39 /* freebsd compatibility */ |
40 #ifndef PRIu8 | |
41 #define PRIu8 "d" | |
42 #endif | |
43 | |
44 /* freebsd compatibility */ | |
45 #ifndef PRIu16 | |
46 #define PRIu16 "d" | |
47 #endif | |
48 | |
49 static const char *cmp_op_table[] = { | |
50 NULL, "&", "==", "!=", ">=", ">", "<=", "<" | |
51 }; | |
52 static const char *set_op_table[] = { | |
53 NULL, "=", "<->", "+=", "-=", "*=", "/=", "%=", "rnd", "&=", "|=", "^=" | |
54 }; | |
55 | |
56 static const char *link_table[] = { | |
57 "LinkNoLink", "LinkTopC", "LinkNextC", "LinkPrevC", | |
58 NULL, "LinkTopPG", "LinkNextPG", "LinkPrevPG", | |
59 NULL, "LinkTopPGC", "LinkNextPGC", "LinkPrevPGC", | |
60 "LinkGoUpPGC", "LinkTailPGC", NULL, NULL, | |
61 "RSM" | |
62 }; | |
63 | |
64 static const char *system_reg_table[] = { | |
65 "Menu Description Language Code", | |
66 "Audio Stream Number", | |
67 "Sub-picture Stream Number", | |
68 "Angle Number", | |
69 "Title Track Number", | |
70 "VTS Title Track Number", | |
71 "VTS PGC Number", | |
72 "PTT Number for One_Sequential_PGC_Title", | |
73 "Highlighted Button Number", | |
74 "Navigation Timer", | |
75 "Title PGC Number for Navigation Timer", | |
76 "Audio Mixing Mode for Karaoke", | |
77 "Country Code for Parental Management", | |
78 "Parental Level", | |
79 "Player Configurations for Video", | |
80 "Player Configurations for Audio", | |
81 "Initial Language Code for Audio", | |
82 "Initial Language Code Extension for Audio", | |
83 "Initial Language Code for Sub-picture", | |
84 "Initial Language Code Extension for Sub-picture", | |
85 "Player Regional Code", | |
86 "Reserved 21", | |
87 "Reserved 22", | |
88 "Reserved 23" | |
89 }; | |
90 | |
91 static const char *system_reg_abbr_table[] = { | |
92 NULL, | |
93 "ASTN", | |
94 "SPSTN", | |
95 "AGLN", | |
96 "TTN", | |
97 "VTS_TTN", | |
98 "TT_PGCN", | |
99 "PTTN", | |
100 "HL_BTNN", | |
101 "NVTMR", | |
102 "NV_PGCN", | |
103 NULL, | |
104 "CC_PLT", | |
105 "PLT", | |
106 NULL, | |
107 NULL, | |
108 NULL, | |
109 NULL, | |
110 NULL, | |
111 NULL, | |
112 NULL, | |
113 NULL, | |
114 NULL, | |
115 NULL, | |
116 }; | |
148 | 117 |
0 | 118 static void print_system_reg(uint16_t reg) { |
119 if(reg < sizeof(system_reg_abbr_table) / sizeof(char *)) | |
148 | 120 fprintf(MSG_OUT, "%s (SRPM:%d)", system_reg_table[reg], reg); |
0 | 121 else |
76 | 122 fprintf(MSG_OUT, " WARNING: Unknown system register ( reg=%d ) ", reg); |
0 | 123 } |
124 | |
148 | 125 static void print_g_reg(uint8_t reg) { |
126 if(reg < 16) | |
127 fprintf(MSG_OUT, "g[%" PRIu8 "]", reg); | |
128 else | |
129 fprintf(MSG_OUT, " WARNING: Unknown general register "); | |
130 } | |
131 | |
0 | 132 static void print_reg(uint8_t reg) { |
133 if(reg & 0x80) | |
134 print_system_reg(reg & 0x7f); | |
135 else | |
148 | 136 print_g_reg(reg & 0x7f); |
0 | 137 } |
138 | |
139 static void print_cmp_op(uint8_t op) { | |
140 if(op < sizeof(cmp_op_table) / sizeof(char *) && cmp_op_table[op] != NULL) | |
76 | 141 fprintf(MSG_OUT, " %s ", cmp_op_table[op]); |
0 | 142 else |
76 | 143 fprintf(MSG_OUT, " WARNING: Unknown compare op "); |
0 | 144 } |
145 | |
146 static void print_set_op(uint8_t op) { | |
147 if(op < sizeof(set_op_table) / sizeof(char *) && set_op_table[op] != NULL) | |
76 | 148 fprintf(MSG_OUT, " %s ", set_op_table[op]); |
0 | 149 else |
76 | 150 fprintf(MSG_OUT, " WARNING: Unknown set op "); |
0 | 151 } |
152 | |
148 | 153 static void print_reg_or_data(command_t* command, int immediate, int start) { |
0 | 154 if(immediate) { |
192
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
155 int i = vm_getbits(command, start, 16); |
0 | 156 |
76 | 157 fprintf(MSG_OUT, "0x%x", i); |
0 | 158 if(isprint(i & 0xff) && isprint((i>>8) & 0xff)) |
76 | 159 fprintf(MSG_OUT, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff)); |
0 | 160 } else { |
148 | 161 print_reg(vm_getbits(command, start - 8, 8)); |
0 | 162 } |
163 } | |
164 | |
148 | 165 static void print_reg_or_data_2(command_t* command, int immediate, int start) { |
0 | 166 if(immediate) |
152
3a1659f4a6c3
Remove byte references. Convert them to bit references.
jcdutton
parents:
148
diff
changeset
|
167 fprintf(MSG_OUT, "0x%x", vm_getbits(command, start - 1, 7)); |
0 | 168 else |
148 | 169 fprintf(MSG_OUT, "g[%" PRIu8 "]", vm_getbits(command, start - 4, 4)); |
0 | 170 } |
171 | |
148 | 172 static void print_reg_or_data_3(command_t* command, int immediate, int start) { |
173 if(immediate) { | |
192
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
174 int i = vm_getbits(command, start, 16); |
148 | 175 |
176 fprintf(MSG_OUT, "0x%x", i); | |
177 if(isprint(i & 0xff) && isprint((i>>8) & 0xff)) | |
178 fprintf(MSG_OUT, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff)); | |
179 } else { | |
180 print_reg(vm_getbits(command, start, 8)); | |
181 } | |
182 } | |
183 | |
184 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
185 static void print_if_version_1(command_t* command) { |
148 | 186 uint8_t op = vm_getbits(command, 54, 3); |
0 | 187 |
188 if(op) { | |
76 | 189 fprintf(MSG_OUT, "if ("); |
155 | 190 print_g_reg(vm_getbits(command,39,8)); |
0 | 191 print_cmp_op(op); |
148 | 192 print_reg_or_data(command, vm_getbits(command, 55,1), 31); |
76 | 193 fprintf(MSG_OUT, ") "); |
0 | 194 } |
195 } | |
196 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
197 static void print_if_version_2(command_t* command) { |
148 | 198 uint8_t op = vm_getbits(command, 54, 3); |
0 | 199 |
200 if(op) { | |
76 | 201 fprintf(MSG_OUT, "if ("); |
148 | 202 print_reg(vm_getbits(command, 15, 8)); |
0 | 203 print_cmp_op(op); |
148 | 204 print_reg(vm_getbits(command, 7, 8)); |
76 | 205 fprintf(MSG_OUT, ") "); |
0 | 206 } |
207 } | |
208 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
209 static void print_if_version_3(command_t* command) { |
148 | 210 uint8_t op = vm_getbits(command, 54, 3); |
0 | 211 |
212 if(op) { | |
76 | 213 fprintf(MSG_OUT, "if ("); |
155 | 214 print_g_reg(vm_getbits(command, 43, 4)); |
0 | 215 print_cmp_op(op); |
148 | 216 print_reg_or_data(command, vm_getbits(command, 55, 1), 15); |
76 | 217 fprintf(MSG_OUT, ") "); |
0 | 218 } |
219 } | |
220 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
221 static void print_if_version_4(command_t* command) { |
148 | 222 uint8_t op = vm_getbits(command, 54, 3); |
223 | |
0 | 224 if(op) { |
76 | 225 fprintf(MSG_OUT, "if ("); |
148 | 226 print_g_reg(vm_getbits(command, 51, 4)); |
0 | 227 print_cmp_op(op); |
148 | 228 print_reg_or_data(command, vm_getbits(command, 55, 1), 31); |
76 | 229 fprintf(MSG_OUT, ") "); |
0 | 230 } |
231 } | |
232 | |
148 | 233 static void print_if_version_5(command_t* command) { |
234 uint8_t op = vm_getbits(command, 54, 3); | |
235 int set_immediate = vm_getbits(command, 60, 1); | |
236 | |
237 if(op) { | |
238 if (set_immediate) { | |
239 fprintf(MSG_OUT, "if ("); | |
240 print_g_reg(vm_getbits(command, 31, 8)); | |
241 print_cmp_op(op); | |
242 print_reg(vm_getbits(command, 23, 8)); | |
243 fprintf(MSG_OUT, ") "); | |
244 } else { | |
245 fprintf(MSG_OUT, "if ("); | |
246 print_g_reg(vm_getbits(command, 39, 8)); | |
247 print_cmp_op(op); | |
248 print_reg_or_data(command, vm_getbits(command, 55, 1), 31); | |
249 fprintf(MSG_OUT, ") "); | |
250 } | |
251 } | |
252 } | |
253 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
254 static void print_special_instruction(command_t* command) { |
148 | 255 uint8_t op = vm_getbits(command, 51, 4); |
0 | 256 |
257 switch(op) { | |
258 case 0: /* NOP */ | |
76 | 259 fprintf(MSG_OUT, "Nop"); |
0 | 260 break; |
261 case 1: /* Goto line */ | |
148 | 262 fprintf(MSG_OUT, "Goto %" PRIu8, vm_getbits(command, 7, 8)); |
0 | 263 break; |
264 case 2: /* Break */ | |
76 | 265 fprintf(MSG_OUT, "Break"); |
0 | 266 break; |
267 case 3: /* Parental level */ | |
76 | 268 fprintf(MSG_OUT, "SetTmpPML %" PRIu8 ", Goto %" PRIu8, |
148 | 269 vm_getbits(command, 11, 4), vm_getbits(command, 7, 8)); |
0 | 270 break; |
271 default: | |
76 | 272 fprintf(MSG_OUT, "WARNING: Unknown special instruction (%i)", |
148 | 273 vm_getbits(command, 51, 4)); |
0 | 274 } |
275 } | |
276 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
277 static void print_linksub_instruction(command_t* command) { |
192
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
278 int linkop = vm_getbits(command, 7, 8); |
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
279 int button = vm_getbits(command, 15, 6); |
0 | 280 |
281 if(linkop < sizeof(link_table)/sizeof(char *) && link_table[linkop] != NULL) | |
76 | 282 fprintf(MSG_OUT, "%s (button %" PRIu8 ")", link_table[linkop], button); |
0 | 283 else |
76 | 284 fprintf(MSG_OUT, "WARNING: Unknown linksub instruction (%i)", linkop); |
0 | 285 } |
286 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
287 static void print_link_instruction(command_t* command, int optional) { |
148 | 288 uint8_t op = vm_getbits(command, 51, 4); |
0 | 289 |
290 if(optional && op) | |
76 | 291 fprintf(MSG_OUT, ", "); |
0 | 292 |
293 switch(op) { | |
294 case 0: | |
295 if(!optional) | |
76 | 296 fprintf(MSG_OUT, "WARNING: NOP (link)!"); |
0 | 297 break; |
298 case 1: | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
299 print_linksub_instruction(command); |
0 | 300 break; |
301 case 4: | |
148 | 302 fprintf(MSG_OUT, "LinkPGCN %" PRIu16, vm_getbits(command, 14, 15)); |
0 | 303 break; |
304 case 5: | |
76 | 305 fprintf(MSG_OUT, "LinkPTT %" PRIu16 " (button %" PRIu8 ")", |
148 | 306 vm_getbits(command, 9, 10), vm_getbits(command, 15, 6)); |
0 | 307 break; |
308 case 6: | |
76 | 309 fprintf(MSG_OUT, "LinkPGN %" PRIu8 " (button %" PRIu8 ")", |
148 | 310 vm_getbits(command, 6, 7), vm_getbits(command, 15, 6)); |
0 | 311 break; |
312 case 7: | |
76 | 313 fprintf(MSG_OUT, "LinkCN %" PRIu8 " (button %" PRIu8 ")", |
148 | 314 vm_getbits(command, 7, 8), vm_getbits(command, 15, 6)); |
0 | 315 break; |
316 default: | |
76 | 317 fprintf(MSG_OUT, "WARNING: Unknown link instruction"); |
0 | 318 } |
319 } | |
320 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
321 static void print_jump_instruction(command_t* command) { |
148 | 322 switch(vm_getbits(command, 51, 4)) { |
0 | 323 case 1: |
76 | 324 fprintf(MSG_OUT, "Exit"); |
0 | 325 break; |
326 case 2: | |
148 | 327 fprintf(MSG_OUT, "JumpTT %" PRIu8, vm_getbits(command, 22, 7)); |
0 | 328 break; |
329 case 3: | |
148 | 330 fprintf(MSG_OUT, "JumpVTS_TT %" PRIu8, vm_getbits(command, 22, 7)); |
0 | 331 break; |
332 case 5: | |
76 | 333 fprintf(MSG_OUT, "JumpVTS_PTT %" PRIu8 ":%" PRIu16, |
148 | 334 vm_getbits(command, 22, 7), vm_getbits(command, 41, 10)); |
0 | 335 break; |
336 case 6: | |
148 | 337 switch(vm_getbits(command, 23, 2)) { |
0 | 338 case 0: |
76 | 339 fprintf(MSG_OUT, "JumpSS FP"); |
0 | 340 break; |
341 case 1: | |
148 | 342 fprintf(MSG_OUT, "JumpSS VMGM (menu %" PRIu8 ")", vm_getbits(command, 19, 4)); |
0 | 343 break; |
344 case 2: | |
76 | 345 fprintf(MSG_OUT, "JumpSS VTSM (vts %" PRIu8 ", title %" PRIu8 |
155 | 346 ", menu %" PRIu8 ")", vm_getbits(command, 30, 7), vm_getbits(command, 38, 7), vm_getbits(command, 19, 4)); |
0 | 347 break; |
348 case 3: | |
148 | 349 fprintf(MSG_OUT, "JumpSS VMGM (pgc %" PRIu8 ")", vm_getbits(command, 46, 15)); |
0 | 350 break; |
351 } | |
352 break; | |
353 case 8: | |
148 | 354 switch(vm_getbits(command, 23, 2)) { |
0 | 355 case 0: |
76 | 356 fprintf(MSG_OUT, "CallSS FP (rsm_cell %" PRIu8 ")", |
148 | 357 vm_getbits(command, 31, 8)); |
0 | 358 break; |
359 case 1: | |
76 | 360 fprintf(MSG_OUT, "CallSS VMGM (menu %" PRIu8 |
148 | 361 ", rsm_cell %" PRIu8 ")", vm_getbits(command, 19, 4), vm_getbits(command, 31, 8)); |
0 | 362 break; |
363 case 2: | |
76 | 364 fprintf(MSG_OUT, "CallSS VTSM (menu %" PRIu8 |
148 | 365 ", rsm_cell %" PRIu8 ")", vm_getbits(command, 19, 4), vm_getbits(command, 31, 8)); |
0 | 366 break; |
367 case 3: | |
76 | 368 fprintf(MSG_OUT, "CallSS VMGM (pgc %" PRIu8 ", rsm_cell %" PRIu8 ")", |
148 | 369 vm_getbits(command, 46, 15), vm_getbits(command, 31, 8)); |
0 | 370 break; |
371 } | |
372 break; | |
373 default: | |
76 | 374 fprintf(MSG_OUT, "WARNING: Unknown Jump/Call instruction"); |
0 | 375 } |
376 } | |
377 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
378 static void print_system_set(command_t* command) { |
0 | 379 int i; |
155 | 380 /* FIXME: What about SPRM11 ? Karaoke */ |
381 /* Surely there must be some system set command for that ? */ | |
0 | 382 |
148 | 383 switch(vm_getbits(command, 59, 4)) { |
0 | 384 case 1: /* Set system reg 1 &| 2 &| 3 (Audio, Subp. Angle) */ |
385 for(i = 1; i <= 3; i++) { | |
155 | 386 if(vm_getbits(command, 47 - (i*8), 1)) { |
0 | 387 print_system_reg(i); |
76 | 388 fprintf(MSG_OUT, " = "); |
148 | 389 print_reg_or_data_2(command, vm_getbits(command, 60, 1), 47 - (i*8) ); |
76 | 390 fprintf(MSG_OUT, " "); |
0 | 391 } |
392 } | |
393 break; | |
394 case 2: /* Set system reg 9 & 10 (Navigation timer, Title PGC number) */ | |
395 print_system_reg(9); | |
76 | 396 fprintf(MSG_OUT, " = "); |
148 | 397 print_reg_or_data(command, vm_getbits(command, 60, 1), 47); |
76 | 398 fprintf(MSG_OUT, " "); |
0 | 399 print_system_reg(10); |
155 | 400 fprintf(MSG_OUT, " = %" PRIu16, vm_getbits(command, 30, 15)); /* ?? */ |
0 | 401 break; |
402 case 3: /* Mode: Counter / Register + Set */ | |
76 | 403 fprintf(MSG_OUT, "SetMode "); |
148 | 404 if(vm_getbits(command, 23, 1)) |
76 | 405 fprintf(MSG_OUT, "Counter "); |
0 | 406 else |
76 | 407 fprintf(MSG_OUT, "Register "); |
155 | 408 print_g_reg(vm_getbits(command, 19, 4)); |
0 | 409 print_set_op(0x1); /* '=' */ |
148 | 410 print_reg_or_data(command, vm_getbits(command, 60, 1), 47); |
0 | 411 break; |
412 case 6: /* Set system reg 8 (Highlighted button) */ | |
413 print_system_reg(8); | |
148 | 414 if(vm_getbits(command, 60, 1)) /* immediate */ |
415 fprintf(MSG_OUT, " = 0x%x (button no %d)", vm_getbits(command, 31, 16), vm_getbits(command, 31, 6)); | |
0 | 416 else |
148 | 417 fprintf(MSG_OUT, " = g[%" PRIu8 "]", vm_getbits(command, 19, 4)); |
0 | 418 break; |
419 default: | |
76 | 420 fprintf(MSG_OUT, "WARNING: Unknown system set instruction (%i)", |
148 | 421 vm_getbits(command, 59, 4)); |
0 | 422 } |
423 } | |
424 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
425 static void print_set_version_1(command_t* command) { |
148 | 426 uint8_t set_op = vm_getbits(command, 59, 4); |
0 | 427 |
428 if(set_op) { | |
155 | 429 print_g_reg(vm_getbits(command, 35, 4)); |
0 | 430 print_set_op(set_op); |
148 | 431 print_reg_or_data(command, vm_getbits(command, 60, 1), 31); |
0 | 432 } else { |
76 | 433 fprintf(MSG_OUT, "NOP"); |
0 | 434 } |
435 } | |
436 | |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
437 static void print_set_version_2(command_t* command) { |
148 | 438 uint8_t set_op = vm_getbits(command, 59, 4); |
0 | 439 |
440 if(set_op) { | |
155 | 441 print_g_reg(vm_getbits(command, 51, 4)); |
0 | 442 print_set_op(set_op); |
148 | 443 print_reg_or_data(command, vm_getbits(command, 60, 1), 47); |
0 | 444 } else { |
76 | 445 fprintf(MSG_OUT, "NOP"); |
0 | 446 } |
447 } | |
448 | |
148 | 449 static void print_set_version_3(command_t* command) { |
450 uint8_t set_op = vm_getbits(command, 59, 4); | |
451 | |
452 if(set_op) { | |
155 | 453 print_g_reg(vm_getbits(command, 51, 4)); |
148 | 454 print_set_op(set_op); |
455 print_reg_or_data_3(command, vm_getbits(command, 60, 1), 47); | |
456 } else { | |
457 fprintf(MSG_OUT, "NOP"); | |
458 } | |
459 } | |
460 | |
461 | |
462 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
|
463 command_t command; |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
464 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
|
465 ( (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
|
466 ( (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
|
467 ( (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
|
468 ( (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
|
469 ( (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
|
470 ( (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
|
471 (uint64_t) vm_command->bytes[7] ; |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
472 command.examined = 0; |
0 | 473 |
148 | 474 switch(vm_getbits(&command,63,3)) { /* three first bits */ |
0 | 475 case 0: /* Special instructions */ |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
476 print_if_version_1(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
477 print_special_instruction(&command); |
0 | 478 break; |
479 case 1: /* Jump/Call or Link instructions */ | |
148 | 480 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
|
481 print_if_version_2(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
482 print_jump_instruction(&command); |
0 | 483 } else { |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
484 print_if_version_1(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
485 print_link_instruction(&command, 0); /* must be pressent */ |
0 | 486 } |
487 break; | |
488 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
|
489 print_if_version_2(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
490 print_system_set(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
491 print_link_instruction(&command, 1); /* either 'if' or 'link' */ |
0 | 492 break; |
493 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
|
494 print_if_version_3(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
495 print_set_version_1(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
496 print_link_instruction(&command, 1); /* either 'if' or 'link' */ |
0 | 497 break; |
498 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
|
499 print_set_version_2(&command); |
76 | 500 fprintf(MSG_OUT, ", "); |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
501 print_if_version_4(&command); |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
502 print_linksub_instruction(&command); |
0 | 503 break; |
504 case 5: /* Compare -> (Set and LinkSub) instructions */ | |
148 | 505 print_if_version_5(&command); |
76 | 506 fprintf(MSG_OUT, "{ "); |
148 | 507 print_set_version_3(&command); |
76 | 508 fprintf(MSG_OUT, ", "); |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
509 print_linksub_instruction(&command); |
76 | 510 fprintf(MSG_OUT, " }"); |
0 | 511 break; |
512 case 6: /* Compare -> Set, always LinkSub instructions */ | |
148 | 513 print_if_version_5(&command); |
76 | 514 fprintf(MSG_OUT, "{ "); |
148 | 515 print_set_version_3(&command); |
76 | 516 fprintf(MSG_OUT, " } "); |
11
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
517 print_linksub_instruction(&command); |
0 | 518 break; |
519 default: | |
148 | 520 fprintf(MSG_OUT, "WARNING: Unknown instruction type (%i)", vm_getbits(&command, 63, 3)); |
0 | 521 } |
522 /* 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
|
523 |
1f479a99339c
Change the bits function so that there are no global variables left.
jcdutton
parents:
10
diff
changeset
|
524 if(command.instruction & ~ command.examined) { |
76 | 525 fprintf(MSG_OUT, " libdvdnav: vmcmd.c: [WARNING, unknown bits:"); |
526 fprintf(MSG_OUT, " %08llx", (command.instruction & ~ command.examined) ); | |
527 fprintf(MSG_OUT, "]"); | |
0 | 528 } |
529 } | |
530 | |
153 | 531 void vm_print_cmd(int row, vm_cmd_t *vm_command) { |
0 | 532 int i; |
533 | |
76 | 534 fprintf(MSG_OUT, "(%03d) ", row + 1); |
0 | 535 for(i = 0; i < 8; i++) |
76 | 536 fprintf(MSG_OUT, "%02x ", vm_command->bytes[i]); |
537 fprintf(MSG_OUT, "| "); | |
0 | 538 |
153 | 539 vm_print_mnemonic(vm_command); |
76 | 540 fprintf(MSG_OUT, "\n"); |
0 | 541 } |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
0
diff
changeset
|
542 |
192
a3d7b149cc0f
revert strange changes from Tim that broke compilation
mroi
parents:
189
diff
changeset
|
543 #endif |