annotate vm/decoder.c @ 0:427b7da5cbdb src

first split of dvdread; it's just a copy of dvdnav still to be cleaned
author nicodvb
date Sun, 01 Jun 2008 08:39:07 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1 /*
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
2 * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
3 * 2002-2004 the dvdnav project
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
4 *
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
5 * This file is part of libdvdnav, a DVD navigation library. It is modified
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
6 * from a file originally part of the Ogle DVD player.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
7 *
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
8 * libdvdnav is free software; you can redistribute it and/or modify
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
11 * (at your option) any later version.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
12 *
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
13 * libdvdnav is distributed in the hope that it will be useful,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
16 * GNU General Public License for more details.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
17 *
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
21 *
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
22 * $Id$
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
23 *
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
24 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
25
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
26 #ifdef HAVE_CONFIG_H
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
27 #include "config.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
28 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
29
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
30 #include <stdio.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
31 #include <stdlib.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
32 #include <inttypes.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
33 #include <limits.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
34 #include <string.h> /* For memset */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
35 #include <sys/time.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
36 #include "nav_types.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
37 #include "ifo_types.h" /* vm_cmd_t */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
38
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
39 #include "dvd_types.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
40 #include "remap.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
41 #include "decoder.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
42 #include "vm.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
43 #include "vmcmd.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
44 #include "dvdnav.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
45 #include "dvdnav_internal.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
46
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
47 uint32_t vm_getbits(command_t *command, int32_t start, int32_t count) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
48 uint64_t result = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
49 uint64_t bit_mask = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
50 uint64_t examining = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
51 int32_t bits;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
52
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
53 if (count == 0) return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
54
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
55 if ( ((start - count) < -1) ||
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
56 (count > 32) ||
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
57 (start > 63) ||
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
58 (count < 0) ||
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
59 (start < 0) ) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
60 fprintf(MSG_OUT, "libdvdnav: Bad call to vm_getbits. Parameter out of range\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
61 abort();
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
62 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
63 /* all ones, please */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
64 bit_mask = ~bit_mask;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
65 bit_mask >>= 63 - start;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
66 bits = start + 1 - count;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
67 examining = ((bit_mask >> bits) << bits );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
68 command->examined |= examining;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
69 result = (command->instruction & bit_mask) >> bits;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
70 return (uint32_t) result;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
71 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
72
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
73 static uint16_t get_GPRM(registers_t* registers, uint8_t reg) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
74 if (registers->GPRM_mode[reg] & 0x01) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
75 struct timeval current_time, time_offset;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
76 uint16_t result;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
77 /* Counter mode */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
78 /* fprintf(MSG_OUT, "libdvdnav: Getting counter %d\n",reg);*/
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
79 gettimeofday(&current_time, NULL);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
80 time_offset.tv_sec = current_time.tv_sec - registers->GPRM_time[reg].tv_sec;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
81 time_offset.tv_usec = current_time.tv_usec - registers->GPRM_time[reg].tv_usec;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
82 if (time_offset.tv_usec < 0) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
83 time_offset.tv_sec--;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
84 time_offset.tv_usec += 1000000;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
85 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
86 result = (uint16_t) (time_offset.tv_sec & 0xffff);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
87 registers->GPRM[reg]=result;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
88 return result;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
89
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
90 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
91 /* Register mode */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
92 return registers->GPRM[reg];
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
93 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
94
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
95 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
96
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
97 static void set_GPRM(registers_t* registers, uint8_t reg, uint16_t value) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
98 if (registers->GPRM_mode[reg] & 0x01) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
99 struct timeval current_time;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
100 /* Counter mode */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
101 /* fprintf(MSG_OUT, "libdvdnav: Setting counter %d\n",reg); */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
102 gettimeofday(&current_time, NULL);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
103 registers->GPRM_time[reg] = current_time;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
104 registers->GPRM_time[reg].tv_sec -= value;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
105 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
106 registers->GPRM[reg] = value;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
107 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
108
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
109 /* Eval register code, can either be system or general register.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
110 SXXX_XXXX, where S is 1 if it is system register. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
111 static uint16_t eval_reg(command_t* command, uint8_t reg) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
112 if(reg & 0x80) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
113 if ((reg & 0x1f) == 20) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
114 fprintf(MSG_OUT, "libdvdnav: Suspected RCE Region Protection!!!\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
115 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
116 return command->registers->SPRM[reg & 0x1f]; /* FIXME max 24 not 32 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
117 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
118 return get_GPRM(command->registers, reg & 0x0f) ;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
119 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
120 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
121
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
122 /* Eval register or immediate data.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
123 AAAA_AAAA BBBB_BBBB, if immediate use all 16 bits for data else use
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
124 lower eight bits for the system or general purpose register. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
125 static uint16_t eval_reg_or_data(command_t* command, int32_t imm, int32_t start) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
126 if(imm) { /* immediate */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
127 return vm_getbits(command, start, 16);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
128 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
129 return eval_reg(command, vm_getbits(command, (start - 8), 8));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
130 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
131 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
132
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
133 /* Eval register or immediate data.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
134 xBBB_BBBB, if immediate use all 7 bits for data else use
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
135 lower four bits for the general purpose register number. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
136 /* Evaluates gprm or data depending on bit, data is in byte n */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
137 static uint16_t eval_reg_or_data_2(command_t* command,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
138 int32_t imm, int32_t start) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
139 if(imm) /* immediate */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
140 return vm_getbits(command, (start - 1), 7);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
141 else
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
142 return get_GPRM(command->registers, (vm_getbits(command, (start - 4), 4)) );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
143 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
144
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
145
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
146 /* Compare data using operation, return result from comparison.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
147 Helper function for the different if functions. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
148 static int32_t eval_compare(uint8_t operation, uint16_t data1, uint16_t data2) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
149 switch(operation) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
150 case 1:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
151 return data1 & data2;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
152 case 2:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
153 return data1 == data2;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
154 case 3:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
155 return data1 != data2;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
156 case 4:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
157 return data1 >= data2;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
158 case 5:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
159 return data1 > data2;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
160 case 6:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
161 return data1 <= data2;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
162 case 7:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
163 return data1 < data2;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
164 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
165 fprintf(MSG_OUT, "libdvdnav: eval_compare: Invalid comparison code\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
166 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
167 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
168
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
169
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
170 /* Evaluate if version 1.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
171 Has comparison data in byte 3 and 4-5 (immediate or register) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
172 static int32_t eval_if_version_1(command_t* command) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
173 uint8_t op = vm_getbits(command, 54, 3);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
174 if(op) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
175 return eval_compare(op, eval_reg(command, vm_getbits(command, 39, 8)),
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
176 eval_reg_or_data(command, vm_getbits(command, 55, 1), 31));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
177 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
178 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
179 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
180
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
181 /* Evaluate if version 2.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
182 This version only compares register which are in byte 6 and 7 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
183 static int32_t eval_if_version_2(command_t* command) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
184 uint8_t op = vm_getbits(command, 54, 3);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
185 if(op) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
186 return eval_compare(op, eval_reg(command, vm_getbits(command, 15, 8)),
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
187 eval_reg(command, vm_getbits(command, 7, 8)));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
188 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
189 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
190 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
191
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
192 /* Evaluate if version 3.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
193 Has comparison data in byte 2 and 6-7 (immediate or register) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
194 static int32_t eval_if_version_3(command_t* command) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
195 uint8_t op = vm_getbits(command, 54, 3);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
196 if(op) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
197 return eval_compare(op, eval_reg(command, vm_getbits(command, 47, 8)),
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
198 eval_reg_or_data(command, vm_getbits(command, 55, 1), 15));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
199 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
200 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
201 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
202
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
203 /* Evaluate if version 4.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
204 Has comparison data in byte 1 and 4-5 (immediate or register)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
205 The register in byte 1 is only the lowe nibble (4 bits) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
206 static int32_t eval_if_version_4(command_t* command) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
207 uint8_t op = vm_getbits(command, 54, 3);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
208 if(op) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
209 return eval_compare(op, eval_reg(command, vm_getbits(command, 51, 4)),
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
210 eval_reg_or_data(command, vm_getbits(command, 55, 1), 31));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
211 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
212 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
213 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
214
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
215 /* Evaluate special instruction.... returns the new row/line number,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
216 0 if no new row and 256 if Break. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
217 static int32_t eval_special_instruction(command_t* command, int32_t cond) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
218 int32_t line, level;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
219
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
220 switch(vm_getbits(command, 51, 4)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
221 case 0: /* NOP */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
222 line = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
223 return cond ? line : 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
224 case 1: /* Goto line */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
225 line = vm_getbits(command, 7, 8);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
226 return cond ? line : 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
227 case 2: /* Break */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
228 /* max number of rows < 256, so we will end this set */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
229 line = 256;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
230 return cond ? 256 : 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
231 case 3: /* Set temporary parental level and goto */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
232 line = vm_getbits(command, 7, 8);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
233 level = vm_getbits(command, 11, 4);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
234 if(cond) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
235 /* This always succeeds now, if we want real parental protection */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
236 /* we need to ask the user and have passwords and stuff. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
237 command->registers->SPRM[13] = level;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
238 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
239 return cond ? line : 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
240 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
241 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
242 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
243
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
244 /* Evaluate link by subinstruction.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
245 Return 1 if link, or 0 if no link
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
246 Actual link instruction is in return_values parameter */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
247 static int32_t eval_link_subins(command_t* command, int32_t cond, link_t *return_values) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
248 uint16_t button = vm_getbits(command, 15, 6);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
249 uint8_t linkop = vm_getbits(command, 4, 5);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
250
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
251 if(linkop > 0x10)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
252 return 0; /* Unknown Link by Sub-Instruction command */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
253
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
254 /* Assumes that the link_cmd_t enum has the same values as the LinkSIns codes */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
255 return_values->command = linkop;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
256 return_values->data1 = button;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
257 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
258 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
259
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
260
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
261 /* Evaluate link instruction.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
262 Return 1 if link, or 0 if no link
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
263 Actual link instruction is in return_values parameter */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
264 static int32_t eval_link_instruction(command_t* command, int32_t cond, link_t *return_values) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
265 uint8_t op = vm_getbits(command, 51, 4);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
266
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
267 switch(op) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
268 case 1:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
269 return eval_link_subins(command, cond, return_values);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
270 case 4:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
271 return_values->command = LinkPGCN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
272 return_values->data1 = vm_getbits(command, 14, 15);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
273 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
274 case 5:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
275 return_values->command = LinkPTTN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
276 return_values->data1 = vm_getbits(command, 9, 10);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
277 return_values->data2 = vm_getbits(command, 15, 6);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
278 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
279 case 6:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
280 return_values->command = LinkPGN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
281 return_values->data1 = vm_getbits(command, 6, 7);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
282 return_values->data2 = vm_getbits(command, 15, 6);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
283 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
284 case 7:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
285 return_values->command = LinkCN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
286 return_values->data1 = vm_getbits(command, 7, 8);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
287 return_values->data2 = vm_getbits(command, 15, 6);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
288 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
289 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
290 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
291 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
292
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
293
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
294 /* Evaluate a jump instruction.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
295 returns 1 if jump or 0 if no jump
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
296 actual jump instruction is in return_values parameter */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
297 static int32_t eval_jump_instruction(command_t* command, int32_t cond, link_t *return_values) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
298
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
299 switch(vm_getbits(command, 51, 4)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
300 case 1:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
301 return_values->command = Exit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
302 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
303 case 2:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
304 return_values->command = JumpTT;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
305 return_values->data1 = vm_getbits(command, 22, 7);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
306 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
307 case 3:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
308 return_values->command = JumpVTS_TT;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
309 return_values->data1 = vm_getbits(command, 22, 7);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
310 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
311 case 5:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
312 return_values->command = JumpVTS_PTT;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
313 return_values->data1 = vm_getbits(command, 22, 7);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
314 return_values->data2 = vm_getbits(command, 41, 10);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
315 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
316 case 6:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
317 switch(vm_getbits(command, 23, 2)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
318 case 0:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
319 return_values->command = JumpSS_FP;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
320 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
321 case 1:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
322 return_values->command = JumpSS_VMGM_MENU;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
323 return_values->data1 = vm_getbits(command, 19, 4);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
324 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
325 case 2:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
326 return_values->command = JumpSS_VTSM;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
327 return_values->data1 = vm_getbits(command, 31, 8);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
328 return_values->data2 = vm_getbits(command, 39, 8);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
329 return_values->data3 = vm_getbits(command, 19, 4);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
330 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
331 case 3:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
332 return_values->command = JumpSS_VMGM_PGC;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
333 return_values->data1 = vm_getbits(command, 46, 15);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
334 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
335 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
336 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
337 case 8:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
338 switch(vm_getbits(command, 23, 2)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
339 case 0:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
340 return_values->command = CallSS_FP;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
341 return_values->data1 = vm_getbits(command, 31, 8);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
342 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
343 case 1:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
344 return_values->command = CallSS_VMGM_MENU;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
345 return_values->data1 = vm_getbits(command, 19, 4);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
346 return_values->data2 = vm_getbits(command, 31, 8);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
347 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
348 case 2:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
349 return_values->command = CallSS_VTSM;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
350 return_values->data1 = vm_getbits(command, 19, 4);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
351 return_values->data2 = vm_getbits(command, 31, 8);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
352 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
353 case 3:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
354 return_values->command = CallSS_VMGM_PGC;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
355 return_values->data1 = vm_getbits(command, 46, 15);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
356 return_values->data2 = vm_getbits(command, 31, 8);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
357 return cond;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
358 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
359 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
360 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
361 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
362 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
363
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
364 /* Evaluate a set sytem register instruction
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
365 May contain a link so return the same as eval_link */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
366 static int32_t eval_system_set(command_t* command, int32_t cond, link_t *return_values) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
367 int32_t i;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
368 uint16_t data, data2;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
369
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
370 switch(vm_getbits(command, 59, 4)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
371 case 1: /* Set system reg 1 &| 2 &| 3 (Audio, Subp. Angle) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
372 for(i = 1; i <= 3; i++) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
373 if(vm_getbits(command, 63 - ((2 + i)*8), 1)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
374 data = eval_reg_or_data_2(command, vm_getbits(command, 60, 1), (47 - (i*8)));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
375 if(cond) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
376 command->registers->SPRM[i] = data;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
377 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
378 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
379 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
380 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
381 case 2: /* Set system reg 9 & 10 (Navigation timer, Title PGC number) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
382 data = eval_reg_or_data(command, vm_getbits(command, 60, 1), 47);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
383 data2 = vm_getbits(command, 23, 8); /* ?? size */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
384 if(cond) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
385 command->registers->SPRM[9] = data; /* time */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
386 command->registers->SPRM[10] = data2; /* pgcN */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
387 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
388 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
389 case 3: /* Mode: Counter / Register + Set */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
390 data = eval_reg_or_data(command, vm_getbits(command, 60, 1), 47);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
391 data2 = vm_getbits(command, 19, 4);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
392 if(vm_getbits(command, 23, 1)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
393 command->registers->GPRM_mode[data2] |= 1; /* Set bit 0 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
394 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
395 command->registers->GPRM_mode[data2] &= ~ 0x01; /* Reset bit 0 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
396 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
397 if(cond) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
398 set_GPRM(command->registers, data2, data);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
399 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
400 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
401 case 6: /* Set system reg 8 (Highlighted button) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
402 data = eval_reg_or_data(command, vm_getbits(command, 60, 1), 31); /* Not system reg!! */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
403 if(cond) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
404 command->registers->SPRM[8] = data;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
405 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
406 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
407 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
408 if(vm_getbits(command, 51, 4)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
409 return eval_link_instruction(command, cond, return_values);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
410 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
411 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
412 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
413
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
414
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
415 /* Evaluate set operation
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
416 Sets the register given to the value indicated by op and data.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
417 For the swap case the contents of reg is stored in reg2.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
418 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
419 static void eval_set_op(command_t* command, int32_t op, int32_t reg, int32_t reg2, int32_t data) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
420 static const int32_t shortmax = 0xffff;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
421 int32_t tmp;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
422 switch(op) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
423 case 1:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
424 set_GPRM(command->registers, reg, data);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
425 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
426 case 2: /* SPECIAL CASE - SWAP! */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
427 set_GPRM(command->registers, reg2, get_GPRM(command->registers, reg));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
428 set_GPRM(command->registers, reg, data);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
429 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
430 case 3:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
431 tmp = get_GPRM(command->registers, reg) + data;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
432 if(tmp > shortmax) tmp = shortmax;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
433 set_GPRM(command->registers, reg, (uint16_t)tmp);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
434 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
435 case 4:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
436 tmp = get_GPRM(command->registers, reg) - data;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
437 if(tmp < 0) tmp = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
438 set_GPRM(command->registers, reg, (uint16_t)tmp);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
439 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
440 case 5:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
441 tmp = get_GPRM(command->registers, reg) * data;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
442 if(tmp > shortmax) tmp = shortmax;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
443 set_GPRM(command->registers, reg, (uint16_t)tmp);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
444 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
445 case 6:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
446 if (data != 0) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
447 set_GPRM(command->registers, reg, (get_GPRM(command->registers, reg) / data) );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
448 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
449 set_GPRM(command->registers, reg, 0xffff); /* Avoid that divide by zero! */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
450 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
451 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
452 case 7:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
453 if (data != 0) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
454 set_GPRM(command->registers, reg, (get_GPRM(command->registers, reg) % data) );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
455 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
456 set_GPRM(command->registers, reg, 0xffff); /* Avoid that divide by zero! */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
457 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
458 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
459 case 8: /* SPECIAL CASE - RND! Return numbers between 1 and data. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
460 set_GPRM(command->registers, reg, 1 + ((uint16_t) ((float) data * rand()/(RAND_MAX+1.0))) );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
461 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
462 case 9:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
463 set_GPRM(command->registers, reg, (get_GPRM(command->registers, reg) & data) );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
464 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
465 case 10:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
466 set_GPRM(command->registers, reg, (get_GPRM(command->registers, reg) | data) );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
467 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
468 case 11:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
469 set_GPRM(command->registers, reg, (get_GPRM(command->registers, reg) ^ data) );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
470 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
471 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
472 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
473
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
474 /* Evaluate set instruction, combined with either Link or Compare. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
475 static void eval_set_version_1(command_t* command, int32_t cond) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
476 uint8_t op = vm_getbits(command, 59, 4);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
477 uint8_t reg = vm_getbits(command, 35, 4); /* FIXME: This is different from vmcmd.c!!! */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
478 uint8_t reg2 = vm_getbits(command, 19, 4);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
479 uint16_t data = eval_reg_or_data(command, vm_getbits(command, 60, 1), 31);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
480
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
481 if(cond) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
482 eval_set_op(command, op, reg, reg2, data);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
483 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
484 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
485
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
486
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
487 /* Evaluate set instruction, combined with both Link and Compare. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
488 static void eval_set_version_2(command_t* command, int32_t cond) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
489 uint8_t op = vm_getbits(command, 59, 4);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
490 uint8_t reg = vm_getbits(command, 51, 4);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
491 uint8_t reg2 = vm_getbits(command, 35, 4); /* FIXME: This is different from vmcmd.c!!! */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
492 uint16_t data = eval_reg_or_data(command, vm_getbits(command, 60, 1), 47);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
493
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
494 if(cond) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
495 eval_set_op(command, op, reg, reg2, data);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
496 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
497 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
498
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
499
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
500 /* Evaluate a command
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
501 returns row number of goto, 0 if no goto, -1 if link.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
502 Link command in return_values */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
503 static int32_t eval_command(uint8_t *bytes, registers_t* registers, link_t *return_values) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
504 int32_t cond, res = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
505 command_t command;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
506 command.instruction =( (uint64_t) bytes[0] << 56 ) |
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
507 ( (uint64_t) bytes[1] << 48 ) |
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
508 ( (uint64_t) bytes[2] << 40 ) |
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
509 ( (uint64_t) bytes[3] << 32 ) |
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
510 ( (uint64_t) bytes[4] << 24 ) |
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
511 ( (uint64_t) bytes[5] << 16 ) |
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
512 ( (uint64_t) bytes[6] << 8 ) |
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
513 (uint64_t) bytes[7] ;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
514 command.examined = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
515 command.registers = registers;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
516 memset(return_values, 0, sizeof(link_t));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
517
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
518 switch(vm_getbits(&command, 63, 3)) { /* three first old_bits */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
519 case 0: /* Special instructions */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
520 cond = eval_if_version_1(&command);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
521 res = eval_special_instruction(&command, cond);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
522 if(res == -1) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
523 fprintf(MSG_OUT, "libdvdnav: Unknown Instruction!\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
524 abort();
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
525 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
526 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
527 case 1: /* Link/jump instructions */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
528 if(vm_getbits(&command, 60, 1)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
529 cond = eval_if_version_2(&command);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
530 res = eval_jump_instruction(&command, cond, return_values);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
531 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
532 cond = eval_if_version_1(&command);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
533 res = eval_link_instruction(&command, cond, return_values);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
534 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
535 if(res)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
536 res = -1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
537 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
538 case 2: /* System set instructions */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
539 cond = eval_if_version_2(&command);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
540 res = eval_system_set(&command, cond, return_values);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
541 if(res)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
542 res = -1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
543 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
544 case 3: /* Set instructions, either Compare or Link may be used */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
545 cond = eval_if_version_3(&command);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
546 eval_set_version_1(&command, cond);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
547 if(vm_getbits(&command, 51, 4)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
548 res = eval_link_instruction(&command, cond, return_values);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
549 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
550 if(res)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
551 res = -1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
552 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
553 case 4: /* Set, Compare -> Link Sub-Instruction */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
554 eval_set_version_2(&command, /*True*/ 1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
555 cond = eval_if_version_4(&command);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
556 res = eval_link_subins(&command, cond, return_values);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
557 if(res)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
558 res = -1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
559 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
560 case 5: /* Compare -> (Set and Link Sub-Instruction) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
561 /* FIXME: These are wrong. Need to be updated from vmcmd.c */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
562 cond = eval_if_version_4(&command);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
563 eval_set_version_2(&command, cond);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
564 res = eval_link_subins(&command, cond, return_values);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
565 if(res)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
566 res = -1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
567 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
568 case 6: /* Compare -> Set, allways Link Sub-Instruction */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
569 /* FIXME: These are wrong. Need to be updated from vmcmd.c */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
570 cond = eval_if_version_4(&command);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
571 eval_set_version_2(&command, cond);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
572 res = eval_link_subins(&command, /*True*/ 1, return_values);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
573 if(res)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
574 res = -1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
575 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
576 default: /* Unknown command */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
577 fprintf(MSG_OUT, "libdvdnav: WARNING: Unknown Command=%x\n", vm_getbits(&command, 63, 3));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
578 abort();
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
579 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
580 /* Check if there are bits not yet examined */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
581
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
582 if(command.instruction & ~ command.examined) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
583 fprintf(MSG_OUT, "libdvdnav: decoder.c: [WARNING, unknown bits:");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
584 fprintf(MSG_OUT, " %08"PRIx64, (command.instruction & ~ command.examined) );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
585 fprintf(MSG_OUT, "]\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
586 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
587
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
588 return res;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
589 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
590
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
591 /* Evaluate a set of commands in the given register set (which is modified) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
592 int32_t vmEval_CMD(vm_cmd_t commands[], int32_t num_commands,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
593 registers_t *registers, link_t *return_values) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
594 int32_t i = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
595 int32_t total = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
596
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
597 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
598 /* DEBUG */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
599 fprintf(MSG_OUT, "libdvdnav: Registers before transaction\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
600 vm_print_registers( registers );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
601 fprintf(MSG_OUT, "libdvdnav: Full list of commands to execute\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
602 for(i = 0; i < num_commands; i++)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
603 vm_print_cmd(i, &commands[i]);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
604 fprintf(MSG_OUT, "libdvdnav: --------------------------------------------\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
605 fprintf(MSG_OUT, "libdvdnav: Single stepping commands\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
606 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
607
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
608 i = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
609 while(i < num_commands && total < 100000) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
610 int32_t line;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
611
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
612 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
613 vm_print_cmd(i, &commands[i]);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
614 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
615
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
616 line = eval_command(&commands[i].bytes[0], registers, return_values);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
617
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
618 if (line < 0) { /* Link command */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
619 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
620 fprintf(MSG_OUT, "libdvdnav: Registers after transaction\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
621 vm_print_registers( registers );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
622 fprintf(MSG_OUT, "libdvdnav: eval: Doing Link/Jump/Call\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
623 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
624 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
625 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
626
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
627 if (line > 0) /* Goto command */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
628 i = line - 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
629 else /* Just continue on the next line */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
630 i++;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
631
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
632 total++;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
633 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
634
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
635 memset(return_values, 0, sizeof(link_t));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
636 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
637 fprintf(MSG_OUT, "libdvdnav: Registers after transaction\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
638 vm_print_registers( registers );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
639 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
640 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
641 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
642
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
643 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
644
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
645 static char *linkcmd2str(link_cmd_t cmd) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
646 switch(cmd) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
647 case LinkNoLink:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
648 return "LinkNoLink";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
649 case LinkTopC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
650 return "LinkTopC";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
651 case LinkNextC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
652 return "LinkNextC";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
653 case LinkPrevC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
654 return "LinkPrevC";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
655 case LinkTopPG:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
656 return "LinkTopPG";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
657 case LinkNextPG:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
658 return "LinkNextPG";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
659 case LinkPrevPG:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
660 return "LinkPrevPG";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
661 case LinkTopPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
662 return "LinkTopPGC";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
663 case LinkNextPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
664 return "LinkNextPGC";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
665 case LinkPrevPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
666 return "LinkPrevPGC";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
667 case LinkGoUpPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
668 return "LinkGoUpPGC";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
669 case LinkTailPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
670 return "LinkTailPGC";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
671 case LinkRSM:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
672 return "LinkRSM";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
673 case LinkPGCN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
674 return "LinkPGCN";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
675 case LinkPTTN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
676 return "LinkPTTN";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
677 case LinkPGN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
678 return "LinkPGN";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
679 case LinkCN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
680 return "LinkCN";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
681 case Exit:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
682 return "Exit";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
683 case JumpTT:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
684 return "JumpTT";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
685 case JumpVTS_TT:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
686 return "JumpVTS_TT";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
687 case JumpVTS_PTT:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
688 return "JumpVTS_PTT";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
689 case JumpSS_FP:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
690 return "JumpSS_FP";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
691 case JumpSS_VMGM_MENU:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
692 return "JumpSS_VMGM_MENU";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
693 case JumpSS_VTSM:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
694 return "JumpSS_VTSM";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
695 case JumpSS_VMGM_PGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
696 return "JumpSS_VMGM_PGC";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
697 case CallSS_FP:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
698 return "CallSS_FP";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
699 case CallSS_VMGM_MENU:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
700 return "CallSS_VMGM_MENU";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
701 case CallSS_VTSM:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
702 return "CallSS_VTSM";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
703 case CallSS_VMGM_PGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
704 return "CallSS_VMGM_PGC";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
705 case PlayThis:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
706 return "PlayThis";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
707 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
708 return "*** (bug)";
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
709 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
710
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
711 void vm_print_link(link_t value) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
712 char *cmd = linkcmd2str(value.command);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
713
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
714 switch(value.command) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
715 case LinkNoLink:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
716 case LinkTopC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
717 case LinkNextC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
718 case LinkPrevC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
719 case LinkTopPG:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
720 case LinkNextPG:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
721 case LinkPrevPG:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
722 case LinkTopPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
723 case LinkNextPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
724 case LinkPrevPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
725 case LinkGoUpPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
726 case LinkTailPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
727 case LinkRSM:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
728 fprintf(MSG_OUT, "libdvdnav: %s (button %d)\n", cmd, value.data1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
729 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
730 case LinkPGCN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
731 case JumpTT:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
732 case JumpVTS_TT:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
733 case JumpSS_VMGM_MENU: /* == 2 -> Title Menu */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
734 case JumpSS_VMGM_PGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
735 fprintf(MSG_OUT, "libdvdnav: %s %d\n", cmd, value.data1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
736 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
737 case LinkPTTN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
738 case LinkPGN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
739 case LinkCN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
740 fprintf(MSG_OUT, "libdvdnav: %s %d (button %d)\n", cmd, value.data1, value.data2);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
741 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
742 case Exit:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
743 case JumpSS_FP:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
744 case PlayThis: /* Humm.. should we have this at all.. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
745 fprintf(MSG_OUT, "libdvdnav: %s\n", cmd);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
746 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
747 case JumpVTS_PTT:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
748 fprintf(MSG_OUT, "libdvdnav: %s %d:%d\n", cmd, value.data1, value.data2);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
749 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
750 case JumpSS_VTSM:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
751 fprintf(MSG_OUT, "libdvdnav: %s vts %d title %d menu %d\n",
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
752 cmd, value.data1, value.data2, value.data3);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
753 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
754 case CallSS_FP:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
755 fprintf(MSG_OUT, "libdvdnav: %s resume cell %d\n", cmd, value.data1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
756 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
757 case CallSS_VMGM_MENU: /* == 2 -> Title Menu */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
758 case CallSS_VTSM:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
759 fprintf(MSG_OUT, "libdvdnav: %s %d resume cell %d\n", cmd, value.data1, value.data2);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
760 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
761 case CallSS_VMGM_PGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
762 fprintf(MSG_OUT, "libdvdnav: %s %d resume cell %d\n", cmd, value.data1, value.data2);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
763 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
764 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
765 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
766
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
767 void vm_print_registers( registers_t *registers ) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
768 int32_t i;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
769 fprintf(MSG_OUT, "libdvdnav: # ");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
770 for(i = 0; i < 24; i++)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
771 fprintf(MSG_OUT, " %2d |", i);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
772 fprintf(MSG_OUT, "\nlibdvdnav: SRPMS: ");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
773 for(i = 0; i < 24; i++)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
774 fprintf(MSG_OUT, "%04x|", registers->SPRM[i]);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
775 fprintf(MSG_OUT, "\nlibdvdnav: GRPMS: ");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
776 for(i = 0; i < 16; i++)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
777 fprintf(MSG_OUT, "%04x|", get_GPRM(registers, i) );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
778 fprintf(MSG_OUT, "\nlibdvdnav: Gmode: ");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
779 for(i = 0; i < 16; i++)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
780 fprintf(MSG_OUT, "%04x|", registers->GPRM_mode[i]);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
781 fprintf(MSG_OUT, "\nlibdvdnav: Gtime: ");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
782 for(i = 0; i < 16; i++)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
783 fprintf(MSG_OUT, "%04lx|", registers->GPRM_time[i].tv_sec & 0xffff);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
784 fprintf(MSG_OUT, "\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
785 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
786
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
787 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
788