annotate vm/vmcmd.c @ 290:54b6a000f6da src

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