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