Mercurial > libdvdnav.hg
annotate decoder.c @ 10:6f0fb88d1463 src
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
| author | jcdutton |
|---|---|
| date | Tue, 09 Apr 2002 15:19:07 +0000 |
| parents | 5f319e02e333 |
| children | 1a214a94a80d |
| 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 <inttypes.h> | |
| 31 #include <string.h> /* For memset */ | |
| 32 #include <dvdread/ifo_types.h> /* vm_cmd_t */ | |
| 6 | 33 #include <assert.h> |
| 0 | 34 #include "vmcmd.h" |
| 35 #include "decoder.h" | |
| 36 | |
| 37 #ifndef bool | |
| 38 typedef int bool; | |
| 39 #endif | |
| 40 | |
| 41 typedef struct | |
| 42 { | |
| 43 uint8_t bits[8]; | |
| 44 uint8_t examined[8]; | |
| 45 } cmd_t; | |
| 46 | |
| 47 /* Fix theses two.. pass as parameters instead. */ | |
| 48 static cmd_t cmd; | |
| 49 static registers_t *state; | |
| 50 | |
| 51 /* Get count bits of command from byte and bit position. */ | |
| 52 static uint32_t bits(int byte, int bit, int count) { | |
| 53 uint32_t val = 0; | |
|
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
54 uint8_t bit_mask; |
| 0 | 55 |
| 56 while(count--) { | |
| 57 if(bit > 7) { | |
| 58 bit = 0; | |
| 59 byte++; | |
| 60 } | |
| 61 bit_mask = 0x01 << (7 - bit); | |
| 62 val <<= 1; | |
| 63 if(cmd.bits[byte] & bit_mask) | |
| 64 val |= 1; | |
| 65 cmd.examined[byte] |= bit_mask; | |
| 66 bit++; | |
| 67 } | |
| 68 return val; | |
| 69 } | |
| 70 | |
| 71 | |
| 72 /* Eval register code, can either be system or general register. | |
| 73 SXXX_XXXX, where S is 1 if it is system register. */ | |
| 74 static uint16_t eval_reg(uint8_t reg) { | |
| 75 if(reg & 0x80) { | |
| 76 return state->SPRM[reg & 0x1f]; /* FIXME max 24 not 32 */ | |
| 77 } else { | |
| 78 return state->GPRM[reg & 0x0f]; | |
| 79 } | |
| 80 } | |
| 81 | |
| 82 /* Eval register or immediate data. | |
| 83 AAAA_AAAA BBBB_BBBB, if immediate use all 16 bits for data else use | |
| 84 lower eight bits for the system or general purpose register. */ | |
| 85 static uint16_t eval_reg_or_data(int imm, int byte) { | |
| 86 if(imm) { /* immediate */ | |
| 87 return bits(byte, 0, 16); | |
| 88 } else { | |
| 89 return eval_reg(bits(byte + 1, 0, 8)); | |
| 90 } | |
| 91 } | |
| 92 | |
| 93 /* Eval register or immediate data. | |
| 94 xBBB_BBBB, if immediate use all 7 bits for data else use | |
| 95 lower four bits for the general purpose register number. */ | |
| 96 /* Evaluates gprm or data depending on bit, data is in byte n */ | |
| 97 uint16_t eval_reg_or_data_2(int imm, int byte) { | |
| 98 if(imm) /* immediate */ | |
| 99 return bits(byte, 1, 7); | |
| 100 else | |
| 101 return state->GPRM[bits(byte, 4, 4)]; | |
| 102 } | |
| 103 | |
| 104 | |
| 105 /* Compare data using operation, return result from comparison. | |
| 106 Helper function for the different if functions. */ | |
| 107 static bool eval_compare(uint8_t operation, uint16_t data1, uint16_t data2) { | |
| 108 switch(operation) { | |
| 109 case 1: | |
| 110 return data1 & data2; | |
| 111 case 2: | |
| 112 return data1 == data2; | |
| 113 case 3: | |
| 114 return data1 != data2; | |
| 115 case 4: | |
| 116 return data1 >= data2; | |
| 117 case 5: | |
| 118 return data1 > data2; | |
| 119 case 6: | |
| 120 return data1 <= data2; | |
| 121 case 7: | |
| 122 return data1 < data2; | |
| 123 } | |
| 124 fprintf(stderr,"eval_compare: Invalid comparison code\n"); | |
| 125 return 0; | |
| 126 } | |
| 127 | |
| 128 | |
| 129 /* Evaluate if version 1. | |
| 130 Has comparison data in byte 3 and 4-5 (immediate or register) */ | |
| 131 static bool eval_if_version_1(void) { | |
| 132 uint8_t op = bits(1, 1, 3); | |
| 133 if(op) { | |
| 134 return eval_compare(op, eval_reg(bits(3, 0, 8)), | |
| 135 eval_reg_or_data(bits(1, 0, 1), 4)); | |
| 136 } | |
| 137 return 1; | |
| 138 } | |
| 139 | |
| 140 /* Evaluate if version 2. | |
| 141 This version only compares register which are in byte 6 and 7 */ | |
| 142 static bool eval_if_version_2(void) { | |
| 143 uint8_t op = bits(1, 1, 3); | |
| 144 if(op) { | |
| 145 return eval_compare(op, eval_reg(bits(6, 0, 8)), | |
| 146 eval_reg(bits(7, 0, 8))); | |
| 147 } | |
| 148 return 1; | |
| 149 } | |
| 150 | |
| 151 /* Evaluate if version 3. | |
| 152 Has comparison data in byte 2 and 6-7 (immediate or register) */ | |
| 153 static bool eval_if_version_3(void) { | |
| 154 uint8_t op = bits(1, 1, 3); | |
| 155 if(op) { | |
| 156 return eval_compare(op, eval_reg(bits(2, 0, 8)), | |
| 157 eval_reg_or_data(bits(1, 0, 1), 6)); | |
| 158 } | |
| 159 return 1; | |
| 160 } | |
| 161 | |
| 162 /* Evaluate if version 4. | |
| 163 Has comparison data in byte 1 and 4-5 (immediate or register) | |
| 164 The register in byte 1 is only the lowe nibble (4bits) */ | |
| 165 static bool eval_if_version_4(void) { | |
| 166 uint8_t op = bits(1, 1, 3); | |
| 167 if(op) { | |
| 168 return eval_compare(op, eval_reg(bits(1, 4, 4)), | |
| 169 eval_reg_or_data(bits(1, 0, 1), 4)); | |
| 170 } | |
| 171 return 1; | |
| 172 } | |
| 173 | |
| 174 /* Evaluate special instruction.... returns the new row/line number, | |
| 175 0 if no new row and 256 if Break. */ | |
| 176 static int eval_special_instruction(bool cond) { | |
| 177 int line, level; | |
| 178 | |
| 179 switch(bits(1, 4, 4)) { | |
| 180 case 0: /* NOP */ | |
| 181 line = 0; | |
| 182 return cond ? line : 0; | |
| 183 case 1: /* Goto line */ | |
| 184 line = bits(7, 0, 8); | |
| 185 return cond ? line : 0; | |
| 186 case 2: /* Break */ | |
| 187 /* max number of rows < 256, so we will end this set */ | |
| 188 line = 256; | |
| 189 return cond ? 256 : 0; | |
| 190 case 3: /* Set temporary parental level and goto */ | |
| 191 line = bits(7, 0, 8); | |
| 192 level = bits(6, 4, 4); | |
| 193 if(cond) { | |
| 194 /* This always succeeds now, if we want real parental protection */ | |
| 195 /* we need to ask the user and have passwords and stuff. */ | |
| 196 state->SPRM[13] = level; | |
| 197 } | |
| 198 return cond ? line : 0; | |
| 199 } | |
| 200 return 0; | |
| 201 } | |
| 202 | |
| 203 /* Evaluate link by subinstruction. | |
| 204 Return 1 if link, or 0 if no link | |
| 205 Actual link instruction is in return_values parameter */ | |
| 206 static bool eval_link_subins(bool cond, link_t *return_values) { | |
| 207 uint16_t button = bits(6, 0, 6); | |
| 208 uint8_t linkop = bits(7, 3, 5); | |
| 209 | |
| 210 if(linkop > 0x10) | |
| 211 return 0; /* Unknown Link by Sub-Instruction command */ | |
| 212 | |
| 213 /* Assumes that the link_cmd_t enum has the same values as the LinkSIns codes */ | |
| 214 return_values->command = linkop; | |
| 215 return_values->data1 = button; | |
| 216 return cond; | |
| 217 } | |
| 218 | |
| 219 | |
| 220 /* Evaluate link instruction. | |
| 221 Return 1 if link, or 0 if no link | |
| 222 Actual link instruction is in return_values parameter */ | |
| 223 static bool eval_link_instruction(bool cond, link_t *return_values) { | |
| 224 uint8_t op = bits(1, 4, 4); | |
| 225 | |
| 226 switch(op) { | |
| 227 case 1: | |
| 228 return eval_link_subins(cond, return_values); | |
| 229 case 4: | |
| 230 return_values->command = LinkPGCN; | |
| 231 return_values->data1 = bits(6, 1, 15); | |
| 232 return cond; | |
| 233 case 5: | |
| 234 return_values->command = LinkPTTN; | |
| 235 return_values->data1 = bits(6, 6, 10); | |
| 236 return_values->data2 = bits(6, 0, 6); | |
| 237 return cond; | |
| 238 case 6: | |
| 239 return_values->command = LinkPGN; | |
| 240 return_values->data1 = bits(7, 1, 7); | |
| 241 return_values->data2 = bits(6, 0, 6); | |
| 242 return cond; | |
| 243 case 7: | |
| 244 return_values->command = LinkCN; | |
| 245 return_values->data1 = bits(7, 0, 8); | |
| 246 return_values->data2 = bits(6, 0, 6); | |
| 247 return cond; | |
| 248 } | |
| 249 return 0; | |
| 250 } | |
| 251 | |
| 252 | |
| 253 /* Evaluate a jump instruction. | |
| 254 returns 1 if jump or 0 if no jump | |
| 255 actual jump instruction is in return_values parameter */ | |
| 256 static bool eval_jump_instruction(bool cond, link_t *return_values) { | |
| 257 | |
| 258 switch(bits(1, 4, 4)) { | |
| 259 case 1: | |
| 260 return_values->command = Exit; | |
| 261 return cond; | |
| 262 case 2: | |
| 263 return_values->command = JumpTT; | |
| 264 return_values->data1 = bits(5, 1, 7); | |
| 265 return cond; | |
| 266 case 3: | |
| 267 return_values->command = JumpVTS_TT; | |
| 268 return_values->data1 = bits(5, 1, 7); | |
| 269 return cond; | |
| 270 case 5: | |
| 271 return_values->command = JumpVTS_PTT; | |
| 272 return_values->data1 = bits(5, 1, 7); | |
| 273 return_values->data2 = bits(2, 6, 10); | |
| 274 return cond; | |
| 275 case 6: | |
| 276 switch(bits(5,0,2)) { | |
| 277 case 0: | |
| 278 return_values->command = JumpSS_FP; | |
| 279 return cond; | |
| 280 case 1: | |
| 281 return_values->command = JumpSS_VMGM_MENU; | |
| 282 return_values->data1 = bits(5, 4, 4); | |
| 283 return cond; | |
| 284 case 2: | |
| 285 return_values->command = JumpSS_VTSM; | |
| 286 return_values->data1 = bits(4, 0, 8); | |
| 287 return_values->data2 = bits(3, 0, 8); | |
| 288 return_values->data3 = bits(5, 4, 4); | |
| 289 return cond; | |
| 290 case 3: | |
| 291 return_values->command = JumpSS_VMGM_PGC; | |
| 292 return_values->data1 = bits(2, 1, 15); | |
| 293 return cond; | |
| 294 } | |
| 295 break; | |
| 296 case 8: | |
| 297 switch(bits(5,0,2)) { | |
| 298 case 0: | |
| 299 return_values->command = CallSS_FP; | |
| 300 return_values->data1 = bits(4, 0, 8); | |
| 301 return cond; | |
| 302 case 1: | |
| 303 return_values->command = CallSS_VMGM_MENU; | |
| 304 return_values->data1 = bits(5, 4, 4); | |
| 305 return_values->data2 = bits(4, 0 ,8); | |
| 306 return cond; | |
| 307 case 2: | |
| 308 return_values->command = CallSS_VTSM; | |
| 309 return_values->data1 = bits(5, 4, 4); | |
| 310 return_values->data2 = bits(4, 0, 8); | |
| 311 return cond; | |
| 312 case 3: | |
| 313 return_values->command = CallSS_VMGM_PGC; | |
| 314 return_values->data1 = bits(2, 1, 15); | |
| 315 return_values->data2 = bits(4, 0, 8); | |
| 316 return cond; | |
| 317 } | |
| 318 break; | |
| 319 } | |
| 320 return 0; | |
| 321 } | |
| 322 | |
| 323 /* Evaluate a set sytem register instruction | |
| 324 May contain a link so return the same as eval_link */ | |
| 325 static bool eval_system_set(int cond, link_t *return_values) { | |
| 326 int i; | |
| 327 uint16_t data, data2; | |
| 328 | |
| 329 switch(bits(0, 4, 4)) { | |
| 330 case 1: /* Set system reg 1 &| 2 &| 3 (Audio, Subp. Angle) */ | |
| 331 for(i = 1; i <= 3; i++) { | |
| 332 if(bits(2 + i, 0, 1)) { | |
| 333 data = eval_reg_or_data_2(bits(0, 3, 1), 2 + i); | |
| 334 if(cond) { | |
| 335 state->SPRM[i] = data; | |
| 336 } | |
| 337 } | |
| 338 } | |
| 339 break; | |
| 340 case 2: /* Set system reg 9 & 10 (Navigation timer, Title PGC number) */ | |
| 341 data = eval_reg_or_data(bits(0, 3, 1), 2); | |
| 342 data2 = bits(5, 0, 8); /* ?? size */ | |
| 343 if(cond) { | |
| 344 state->SPRM[9] = data; /* time */ | |
| 345 state->SPRM[10] = data2; /* pgcN */ | |
| 346 } | |
| 347 break; | |
| 348 case 3: /* Mode: Counter / Register + Set */ | |
| 349 data = eval_reg_or_data(bits(0, 3, 1), 2); | |
| 350 data2 = bits(5, 4, 4); | |
| 351 if(bits(5, 0, 1)) { | |
| 352 fprintf(stderr, "Detected SetGPRMMD Counter!! This is unsupported.\n"); | |
|
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
353 state->GPRM_mode[data2] = 1; |
| 0 | 354 } else { |
|
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
355 fprintf(stderr, "Detected ResetGPRMMD Counter!! This is unsupported.\n"); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
356 state->GPRM_mode[data2] = 0; |
| 0 | 357 } |
| 358 if(cond) { | |
| 359 state->GPRM[data2] = data; | |
| 360 } | |
| 361 break; | |
| 362 case 6: /* Set system reg 8 (Highlighted button) */ | |
| 363 data = eval_reg_or_data(bits(0, 3, 1), 4); /* Not system reg!! */ | |
| 364 if(cond) { | |
| 365 state->SPRM[8] = data; | |
| 366 } | |
| 367 break; | |
| 368 } | |
| 369 if(bits(1, 4, 4)) { | |
| 370 return eval_link_instruction(cond, return_values); | |
| 371 } | |
| 372 return 0; | |
| 373 } | |
| 374 | |
| 375 | |
| 376 /* Evaluate set operation | |
| 377 Sets the register given to the value indicated by op and data. | |
| 378 For the swap case the contents of reg is stored in reg2. | |
| 379 */ | |
| 380 static void eval_set_op(int op, int reg, int reg2, int data) { | |
| 381 switch(op) { | |
| 382 case 1: | |
| 383 state->GPRM[reg] = data; | |
| 384 break; | |
| 385 case 2: /* SPECIAL CASE - SWAP! */ | |
| 386 state->GPRM[reg2] = state->GPRM[reg]; | |
| 387 state->GPRM[reg] = data; | |
| 388 break; | |
| 389 case 3: | |
| 390 state->GPRM[reg] += data; | |
| 391 break; | |
| 392 case 4: | |
| 393 state->GPRM[reg] -= data; | |
| 394 break; | |
| 395 case 5: | |
| 396 state->GPRM[reg] *= data; | |
| 397 break; | |
| 398 case 6: | |
| 399 state->GPRM[reg] /= data; | |
| 400 break; | |
| 401 case 7: | |
| 402 state->GPRM[reg] %= data; | |
| 403 break; | |
| 404 case 8: /* SPECIAL CASE - RND! */ | |
| 405 state->GPRM[reg] += data; /* TODO FIXME */ | |
| 406 break; | |
| 407 case 9: | |
| 408 state->GPRM[reg] &= data; | |
| 409 break; | |
| 410 case 10: | |
| 411 state->GPRM[reg] |= data; | |
| 412 break; | |
| 413 case 11: | |
| 414 state->GPRM[reg] ^= data; | |
| 415 break; | |
| 416 } | |
| 417 } | |
| 418 | |
| 419 /* Evaluate set instruction, combined with either Link or Compare. */ | |
| 420 static void eval_set_version_1(int cond) { | |
| 421 uint8_t op = bits(0, 4, 4); | |
| 422 uint8_t reg = bits(3, 4, 4); /* Erhumm.. */ | |
| 423 uint8_t reg2 = bits(5, 4, 4); | |
| 424 uint16_t data = eval_reg_or_data(bits(0, 3, 1), 4); | |
| 425 | |
| 426 if(cond) { | |
| 427 eval_set_op(op, reg, reg2, data); | |
| 428 } | |
| 429 } | |
| 430 | |
| 431 | |
| 432 /* Evaluate set instruction, combined with both Link and Compare. */ | |
| 433 static void eval_set_version_2(int cond) { | |
| 434 uint8_t op = bits(0, 4, 4); | |
| 435 uint8_t reg = bits(1, 4, 4); | |
| 436 uint8_t reg2 = bits(3, 4, 4); /* Erhumm.. */ | |
| 437 uint16_t data = eval_reg_or_data(bits(0, 3, 1), 2); | |
| 438 | |
| 439 if(cond) { | |
| 440 eval_set_op(op, reg, reg2, data); | |
| 441 } | |
| 442 } | |
| 443 | |
| 444 | |
| 445 /* Evaluate a command | |
| 446 returns row number of goto, 0 if no goto, -1 if link. | |
| 447 Link command in return_values */ | |
| 448 static int eval_command(uint8_t *bytes, link_t *return_values) { | |
| 449 int i, extra_bits; | |
| 450 int cond, res = 0; | |
| 451 | |
| 452 for(i = 0; i < 8; i++) { | |
| 453 cmd.bits[i] = bytes[i]; | |
| 454 cmd.examined[i] = 0; | |
| 455 } | |
| 456 memset(return_values, 0, sizeof(link_t)); | |
| 457 | |
| 458 switch(bits(0, 0, 3)) { /* three first bits */ | |
| 459 case 0: /* Special instructions */ | |
| 460 cond = eval_if_version_1(); | |
| 461 res = eval_special_instruction(cond); | |
| 462 if(res == -1) { | |
| 463 fprintf(stderr, "Unknown Instruction!\n"); | |
| 6 | 464 assert(0); |
| 0 | 465 } |
| 466 break; | |
| 467 case 1: /* Link/jump instructions */ | |
| 468 if(bits(0, 3, 1)) { | |
| 469 cond = eval_if_version_2(); | |
| 470 res = eval_jump_instruction(cond, return_values); | |
| 471 } else { | |
| 472 cond = eval_if_version_1(); | |
| 473 res = eval_link_instruction(cond, return_values); | |
| 474 } | |
| 475 if(res) | |
| 476 res = -1; | |
| 477 break; | |
| 478 case 2: /* System set instructions */ | |
| 479 cond = eval_if_version_2(); | |
| 480 res = eval_system_set(cond, return_values); | |
| 481 if(res) | |
| 482 res = -1; | |
| 483 break; | |
| 484 case 3: /* Set instructions, either Compare or Link may be used */ | |
| 485 cond = eval_if_version_3(); | |
| 486 eval_set_version_1(cond); | |
| 487 if(bits(1, 4, 4)) { | |
| 488 res = eval_link_instruction(cond, return_values); | |
| 489 } | |
| 490 if(res) | |
| 491 res = -1; | |
| 492 break; | |
| 493 case 4: /* Set, Compare -> Link Sub-Instruction */ | |
| 494 eval_set_version_2(/*True*/ 1); | |
| 495 cond = eval_if_version_4(); | |
| 496 res = eval_link_subins(cond, return_values); | |
| 497 if(res) | |
| 498 res = -1; | |
| 499 break; | |
| 500 case 5: /* Compare -> (Set and Link Sub-Instruction) */ | |
| 501 cond = eval_if_version_4(); | |
| 502 eval_set_version_2(cond); | |
| 503 res = eval_link_subins(cond, return_values); | |
| 504 if(res) | |
| 505 res = -1; | |
| 506 break; | |
| 507 case 6: /* Compare -> Set, allways Link Sub-Instruction */ | |
| 508 cond = eval_if_version_4(); | |
| 509 eval_set_version_2(cond); | |
| 510 res = eval_link_subins(/*True*/ 1, return_values); | |
| 511 if(res) | |
| 512 res = -1; | |
| 513 break; | |
| 514 } | |
| 515 /* Check if there are bits not yet examined */ | |
| 516 | |
| 517 extra_bits = 0; | |
| 518 for(i = 0; i < 8; i++) | |
| 519 if(cmd.bits [i] & ~cmd.examined [i]) { | |
| 520 extra_bits = 1; | |
| 521 break; | |
| 522 } | |
| 523 if(extra_bits) { | |
| 524 fprintf(stderr, "[WARNING, unknown bits:"); | |
| 525 for(i = 0; i < 8; i++) | |
| 526 fprintf(stderr, " %02x", cmd.bits [i] & ~cmd.examined [i]); | |
| 527 fprintf(stderr, "]\n"); | |
| 528 } | |
| 529 | |
| 530 return res; | |
| 531 } | |
| 532 | |
| 533 /* Evaluate a set of commands in the given register set (which is | |
| 534 * modified */ | |
| 535 int vmEval_CMD(vm_cmd_t commands[], int num_commands, | |
| 536 registers_t *registers, link_t *return_values) { | |
| 537 int i = 0; | |
| 538 int total = 0; | |
| 539 | |
| 540 state = registers; /* TODO FIXME */ | |
| 541 | |
| 542 #ifdef TRACE | |
| 543 /* DEBUG */ | |
|
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
544 fprintf(stderr, "libdvdnav: Registers before transaction\n"); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
545 vmPrint_registers( registers ); |
| 0 | 546 if(1) { |
| 547 int i; | |
|
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
548 fprintf(stderr, "libdvdnav: Full list of commands to execute\n"); |
| 0 | 549 for(i = 0; i < num_commands; i++) |
| 550 vmPrint_CMD(i, &commands[i]); | |
| 551 fprintf(stderr, "--------------------------------------------\n"); | |
| 552 } /* end DEBUG */ | |
|
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
553 if (1) { |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
554 fprintf(stderr, "libdvdnav: Single stepping commands\n"); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
555 } |
| 0 | 556 #endif |
| 557 | |
| 558 while(i < num_commands && total < 100000) { | |
| 559 int line; | |
| 560 | |
|
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
561 #ifdef TRACE |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
562 if(1) vmPrint_CMD(i, &commands[i]); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
563 #endif |
| 0 | 564 line = eval_command(&commands[i].bytes[0], return_values); |
| 565 | |
| 566 if (line < 0) { /* Link command */ | |
|
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
567 #ifdef TRACE |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
568 fprintf(stderr, "libdvdnav: Registers after transaction\n"); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
569 vmPrint_registers( registers ); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
570 #endif |
| 0 | 571 fprintf(stderr, "eval: Doing Link/Jump/Call\n"); |
| 572 return 1; | |
| 573 } | |
| 574 | |
| 575 if (line > 0) /* Goto command */ | |
| 576 i = line - 1; | |
| 577 else /* Just continue on the next line */ | |
| 578 i++; | |
| 579 | |
| 580 total++; | |
| 581 } | |
| 582 | |
| 583 memset(return_values, 0, sizeof(link_t)); | |
|
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
584 #ifdef TRACE |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
585 fprintf(stderr, "libdvdnav: Registers after transaction\n"); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
586 vmPrint_registers( registers ); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
587 #endif |
| 0 | 588 return 0; |
| 589 } | |
| 590 | |
| 591 static char *linkcmd2str(link_cmd_t cmd) { | |
| 592 switch(cmd) { | |
| 593 case LinkNoLink: | |
| 594 return "LinkNoLink"; | |
| 595 case LinkTopC: | |
| 596 return "LinkTopC"; | |
| 597 case LinkNextC: | |
| 598 return "LinkNextC"; | |
| 599 case LinkPrevC: | |
| 600 return "LinkPrevC"; | |
| 601 case LinkTopPG: | |
| 602 return "LinkTopPG"; | |
| 603 case LinkNextPG: | |
| 604 return "LinkNextPG"; | |
| 605 case LinkPrevPG: | |
| 606 return "LinkPrevPG"; | |
| 607 case LinkTopPGC: | |
| 608 return "LinkTopPGC"; | |
| 609 case LinkNextPGC: | |
| 610 return "LinkNextPGC"; | |
| 611 case LinkPrevPGC: | |
| 612 return "LinkPrevPGC"; | |
| 613 case LinkGoUpPGC: | |
| 614 return "LinkGoUpPGC"; | |
| 615 case LinkTailPGC: | |
| 616 return "LinkTailPGC"; | |
| 617 case LinkRSM: | |
| 618 return "LinkRSM"; | |
| 619 case LinkPGCN: | |
| 620 return "LinkPGCN"; | |
| 621 case LinkPTTN: | |
| 622 return "LinkPTTN"; | |
| 623 case LinkPGN: | |
| 624 return "LinkPGN"; | |
| 625 case LinkCN: | |
| 626 return "LinkCN"; | |
| 627 case Exit: | |
| 628 return "Exit"; | |
| 629 case JumpTT: | |
| 630 return "JumpTT"; | |
| 631 case JumpVTS_TT: | |
| 632 return "JumpVTS_TT"; | |
| 633 case JumpVTS_PTT: | |
| 634 return "JumpVTS_PTT"; | |
| 635 case JumpSS_FP: | |
| 636 return "JumpSS_FP"; | |
| 637 case JumpSS_VMGM_MENU: | |
| 638 return "JumpSS_VMGM_MENU"; | |
| 639 case JumpSS_VTSM: | |
| 640 return "JumpSS_VTSM"; | |
| 641 case JumpSS_VMGM_PGC: | |
| 642 return "JumpSS_VMGM_PGC"; | |
| 643 case CallSS_FP: | |
| 644 return "CallSS_FP"; | |
| 645 case CallSS_VMGM_MENU: | |
| 646 return "CallSS_VMGM_MENU"; | |
| 647 case CallSS_VTSM: | |
| 648 return "CallSS_VTSM"; | |
| 649 case CallSS_VMGM_PGC: | |
| 650 return "CallSS_VMGM_PGC"; | |
| 651 case PlayThis: | |
| 652 return "PlayThis"; | |
| 653 } | |
| 654 return "*** (bug)"; | |
| 655 } | |
| 656 | |
| 657 void vmPrint_LINK(link_t value) { | |
| 658 char *cmd = linkcmd2str(value.command); | |
| 659 | |
| 660 switch(value.command) { | |
| 661 case LinkNoLink: | |
| 662 case LinkTopC: | |
| 663 case LinkNextC: | |
| 664 case LinkPrevC: | |
| 665 case LinkTopPG: | |
| 666 case LinkNextPG: | |
| 667 case LinkPrevPG: | |
| 668 case LinkTopPGC: | |
| 669 case LinkNextPGC: | |
| 670 case LinkPrevPGC: | |
| 671 case LinkGoUpPGC: | |
| 672 case LinkTailPGC: | |
| 673 case LinkRSM: | |
| 674 fprintf(stderr, "%s (button %d)\n", cmd, value.data1); | |
| 675 break; | |
| 676 case LinkPGCN: | |
| 677 case JumpTT: | |
| 678 case JumpVTS_TT: | |
| 679 case JumpSS_VMGM_MENU: /* == 2 -> Title Menu */ | |
| 680 case JumpSS_VMGM_PGC: | |
| 681 fprintf(stderr, "%s %d\n", cmd, value.data1); | |
| 682 break; | |
| 683 case LinkPTTN: | |
| 684 case LinkPGN: | |
| 685 case LinkCN: | |
| 686 fprintf(stderr, "%s %d (button %d)\n", cmd, value.data1, value.data2); | |
| 687 break; | |
| 688 case Exit: | |
| 689 case JumpSS_FP: | |
| 690 case PlayThis: /* Humm.. should we have this at all.. */ | |
| 691 fprintf(stderr, "%s\n", cmd); | |
| 692 break; | |
| 693 case JumpVTS_PTT: | |
| 694 fprintf(stderr, "%s %d:%d\n", cmd, value.data1, value.data2); | |
| 695 break; | |
| 696 case JumpSS_VTSM: | |
| 697 fprintf(stderr, "%s vts %d title %d menu %d\n", | |
| 698 cmd, value.data1, value.data2, value.data3); | |
| 699 break; | |
| 700 case CallSS_FP: | |
| 701 fprintf(stderr, "%s resume cell %d\n", cmd, value.data1); | |
| 702 break; | |
| 703 case CallSS_VMGM_MENU: /* == 2 -> Title Menu */ | |
| 704 case CallSS_VTSM: | |
| 705 fprintf(stderr, "%s %d resume cell %d\n", cmd, value.data1, value.data2); | |
| 706 break; | |
| 707 case CallSS_VMGM_PGC: | |
| 708 fprintf(stderr, "%s %d resume cell %d\n", cmd, value.data1, value.data2); | |
| 709 break; | |
| 710 } | |
| 711 } | |
|
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
712 |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
713 void vmPrint_registers( registers_t *registers ) { |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
714 int i; |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
715 fprintf(stderr, " # "); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
716 for(i = 0; i < 24; i++) |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
717 fprintf(stderr, " %2d |", i); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
718 fprintf(stderr, "\nSRPMS: "); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
719 for(i = 0; i < 24; i++) |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
720 fprintf(stderr, "%04x|", registers->SPRM[i]); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
721 fprintf(stderr, "\nGRPMS: "); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
722 for(i = 0; i < 16; i++) |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
723 fprintf(stderr, "%04x|", registers->GPRM[i]); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
724 fprintf(stderr, "\nGmode: "); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
725 for(i = 0; i < 16; i++) |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
726 fprintf(stderr, "%04x|", registers->GPRM_mode[i]); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
727 fprintf(stderr, "\n"); |
|
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
6
diff
changeset
|
728 } |
