annotate vm/vmcmd.c @ 285:52877d182e96 src

moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
author nicodvb
date Fri, 20 Apr 2007 23:24:59 +0000
parents 130c10495b66
children 54b6a000f6da
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>
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
33
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
34 #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
35 #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
36 #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
37 #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
38 #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
39 #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
40 #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
41 #include "dvdnav.h"
225
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
42 #include "dvdnav_internal.h"
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
43
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
44 /* freebsd compatibility */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
45 #ifndef PRIu8
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
46 #define PRIu8 "d"
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
47 #endif
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
48
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
49 /* freebsd compatibility */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
50 #ifndef PRIu16
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
51 #define PRIu16 "d"
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
52 #endif
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
53
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
54 static const char *cmp_op_table[] = {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
55 NULL, "&", "==", "!=", ">=", ">", "<=", "<"
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
56 };
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
57 static const char *set_op_table[] = {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
58 NULL, "=", "<->", "+=", "-=", "*=", "/=", "%=", "rnd", "&=", "|=", "^="
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
59 };
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
60
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
61 static const char *link_table[] = {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
62 "LinkNoLink", "LinkTopC", "LinkNextC", "LinkPrevC",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
63 NULL, "LinkTopPG", "LinkNextPG", "LinkPrevPG",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
64 NULL, "LinkTopPGC", "LinkNextPGC", "LinkPrevPGC",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
65 "LinkGoUpPGC", "LinkTailPGC", NULL, NULL,
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
66 "RSM"
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
67 };
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
68
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
69 static const char *system_reg_table[] = {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
70 "Menu Description Language Code",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
71 "Audio Stream Number",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
72 "Sub-picture Stream Number",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
73 "Angle Number",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
74 "Title Track Number",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
75 "VTS Title Track Number",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
76 "VTS PGC Number",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
77 "PTT Number for One_Sequential_PGC_Title",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
78 "Highlighted Button Number",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
79 "Navigation Timer",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
80 "Title PGC Number for Navigation Timer",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
81 "Audio Mixing Mode for Karaoke",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
82 "Country Code for Parental Management",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
83 "Parental Level",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
84 "Player Configurations for Video",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
85 "Player Configurations for Audio",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
86 "Initial Language Code for Audio",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
87 "Initial Language Code Extension for Audio",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
88 "Initial Language Code for Sub-picture",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
89 "Initial Language Code Extension for Sub-picture",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
90 "Player Regional Code",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
91 "Reserved 21",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
92 "Reserved 22",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
93 "Reserved 23"
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
94 };
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
95
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
96 static const char *system_reg_abbr_table[] = {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
97 NULL,
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
98 "ASTN",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
99 "SPSTN",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
100 "AGLN",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
101 "TTN",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
102 "VTS_TTN",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
103 "TT_PGCN",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
104 "PTTN",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
105 "HL_BTNN",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
106 "NVTMR",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
107 "NV_PGCN",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
108 NULL,
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
109 "CC_PLT",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
110 "PLT",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
111 NULL,
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 };
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
122
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
123 static void print_system_reg(uint16_t reg) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
124 if(reg < sizeof(system_reg_abbr_table) / sizeof(char *))
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
125 fprintf(MSG_OUT, "%s (SRPM:%d)", system_reg_table[reg], reg);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
126 else
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
127 fprintf(MSG_OUT, " WARNING: Unknown system register ( reg=%d ) ", reg);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
128 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
129
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
130 static void print_g_reg(uint8_t reg) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
131 if(reg < 16)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
132 fprintf(MSG_OUT, "g[%" PRIu8 "]", reg);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
133 else
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
134 fprintf(MSG_OUT, " WARNING: Unknown general register ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
135 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
136
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
137 static void print_reg(uint8_t reg) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
138 if(reg & 0x80)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
139 print_system_reg(reg & 0x7f);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
140 else
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
141 print_g_reg(reg & 0x7f);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
142 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
143
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
144 static void print_cmp_op(uint8_t op) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
145 if(op < sizeof(cmp_op_table) / sizeof(char *) && cmp_op_table[op] != NULL)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
146 fprintf(MSG_OUT, " %s ", cmp_op_table[op]);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
147 else
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
148 fprintf(MSG_OUT, " WARNING: Unknown compare op ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
149 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
150
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
151 static void print_set_op(uint8_t op) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
152 if(op < sizeof(set_op_table) / sizeof(char *) && set_op_table[op] != NULL)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
153 fprintf(MSG_OUT, " %s ", set_op_table[op]);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
154 else
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
155 fprintf(MSG_OUT, " WARNING: Unknown set op ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
156 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
157
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
158 static void print_reg_or_data(command_t* command, int immediate, int start) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
159 if(immediate) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
160 uint32_t i = vm_getbits(command, start, 16);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
161
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
162 fprintf(MSG_OUT, "0x%x", i);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
163 if(isprint(i & 0xff) && isprint((i>>8) & 0xff))
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
164 fprintf(MSG_OUT, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
165 } else {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
166 print_reg(vm_getbits(command, start - 8, 8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
167 }
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 static void print_reg_or_data_2(command_t* command, int immediate, int start) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
171 if(immediate)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
172 fprintf(MSG_OUT, "0x%x", vm_getbits(command, start - 1, 7));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
173 else
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
174 fprintf(MSG_OUT, "g[%" PRIu8 "]", vm_getbits(command, start - 4, 4));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
175 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
176
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
177 static void print_reg_or_data_3(command_t* command, int immediate, int start) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
178 if(immediate) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
179 uint32_t i = vm_getbits(command, start, 16);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
180
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
181 fprintf(MSG_OUT, "0x%x", i);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
182 if(isprint(i & 0xff) && isprint((i>>8) & 0xff))
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
183 fprintf(MSG_OUT, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
184 } else {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
185 print_reg(vm_getbits(command, start, 8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
186 }
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 static void print_if_version_1(command_t* command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
191 uint8_t op = vm_getbits(command, 54, 3);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
192
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
193 if(op) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
194 fprintf(MSG_OUT, "if (");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
195 print_g_reg(vm_getbits(command,39,8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
196 print_cmp_op(op);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
197 print_reg_or_data(command, vm_getbits(command, 55,1), 31);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
198 fprintf(MSG_OUT, ") ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
199 }
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 static void print_if_version_2(command_t* command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
203 uint8_t op = vm_getbits(command, 54, 3);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
204
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
205 if(op) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
206 fprintf(MSG_OUT, "if (");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
207 print_reg(vm_getbits(command, 15, 8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
208 print_cmp_op(op);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
209 print_reg(vm_getbits(command, 7, 8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
210 fprintf(MSG_OUT, ") ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
211 }
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 static void print_if_version_3(command_t* command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
215 uint8_t op = vm_getbits(command, 54, 3);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
216
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
217 if(op) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
218 fprintf(MSG_OUT, "if (");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
219 print_g_reg(vm_getbits(command, 43, 4));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
220 print_cmp_op(op);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
221 print_reg_or_data(command, vm_getbits(command, 55, 1), 15);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
222 fprintf(MSG_OUT, ") ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
223 }
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 static void print_if_version_4(command_t* command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
227 uint8_t op = vm_getbits(command, 54, 3);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
228
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
229 if(op) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
230 fprintf(MSG_OUT, "if (");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
231 print_g_reg(vm_getbits(command, 51, 4));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
232 print_cmp_op(op);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
233 print_reg_or_data(command, vm_getbits(command, 55, 1), 31);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
234 fprintf(MSG_OUT, ") ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
235 }
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 static void print_if_version_5(command_t* command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
239 uint8_t op = vm_getbits(command, 54, 3);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
240 int set_immediate = vm_getbits(command, 60, 1);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
241
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
242 if(op) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
243 if (set_immediate) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
244 fprintf(MSG_OUT, "if (");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
245 print_g_reg(vm_getbits(command, 31, 8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
246 print_cmp_op(op);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
247 print_reg(vm_getbits(command, 23, 8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
248 fprintf(MSG_OUT, ") ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
249 } else {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
250 fprintf(MSG_OUT, "if (");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
251 print_g_reg(vm_getbits(command, 39, 8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
252 print_cmp_op(op);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
253 print_reg_or_data(command, vm_getbits(command, 55, 1), 31);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
254 fprintf(MSG_OUT, ") ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
255 }
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 static void print_special_instruction(command_t* command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
260 uint8_t op = vm_getbits(command, 51, 4);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
261
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
262 switch(op) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
263 case 0: /* NOP */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
264 fprintf(MSG_OUT, "Nop");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
265 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
266 case 1: /* Goto line */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
267 fprintf(MSG_OUT, "Goto %" PRIu8, vm_getbits(command, 7, 8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
268 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
269 case 2: /* Break */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
270 fprintf(MSG_OUT, "Break");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
271 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
272 case 3: /* Parental level */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
273 fprintf(MSG_OUT, "SetTmpPML %" PRIu8 ", Goto %" PRIu8,
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
274 vm_getbits(command, 11, 4), vm_getbits(command, 7, 8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
275 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
276 default:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
277 fprintf(MSG_OUT, "WARNING: Unknown special instruction (%i)",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
278 vm_getbits(command, 51, 4));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
279 }
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 static void print_linksub_instruction(command_t* command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
283 uint32_t linkop = vm_getbits(command, 7, 8);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
284 uint32_t button = vm_getbits(command, 15, 6);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
285
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
286 if(linkop < sizeof(link_table)/sizeof(char *) && link_table[linkop] != NULL)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
287 fprintf(MSG_OUT, "%s (button %" PRIu8 ")", link_table[linkop], button);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
288 else
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
289 fprintf(MSG_OUT, "WARNING: Unknown linksub instruction (%i)", linkop);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
290 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
291
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
292 static void print_link_instruction(command_t* command, int optional) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
293 uint8_t op = vm_getbits(command, 51, 4);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
294
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
295 if(optional && op)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
296 fprintf(MSG_OUT, ", ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
297
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
298 switch(op) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
299 case 0:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
300 if(!optional)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
301 fprintf(MSG_OUT, "WARNING: NOP (link)!");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
302 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
303 case 1:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
304 print_linksub_instruction(command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
305 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
306 case 4:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
307 fprintf(MSG_OUT, "LinkPGCN %" PRIu16, vm_getbits(command, 14, 15));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
308 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
309 case 5:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
310 fprintf(MSG_OUT, "LinkPTT %" PRIu16 " (button %" PRIu8 ")",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
311 vm_getbits(command, 9, 10), vm_getbits(command, 15, 6));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
312 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
313 case 6:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
314 fprintf(MSG_OUT, "LinkPGN %" PRIu8 " (button %" PRIu8 ")",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
315 vm_getbits(command, 6, 7), vm_getbits(command, 15, 6));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
316 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
317 case 7:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
318 fprintf(MSG_OUT, "LinkCN %" PRIu8 " (button %" PRIu8 ")",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
319 vm_getbits(command, 7, 8), vm_getbits(command, 15, 6));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
320 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
321 default:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
322 fprintf(MSG_OUT, "WARNING: Unknown link instruction");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
323 }
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 static void print_jump_instruction(command_t* command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
327 switch(vm_getbits(command, 51, 4)) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
328 case 1:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
329 fprintf(MSG_OUT, "Exit");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
330 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
331 case 2:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
332 fprintf(MSG_OUT, "JumpTT %" PRIu8, vm_getbits(command, 22, 7));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
333 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
334 case 3:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
335 fprintf(MSG_OUT, "JumpVTS_TT %" PRIu8, vm_getbits(command, 22, 7));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
336 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
337 case 5:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
338 fprintf(MSG_OUT, "JumpVTS_PTT %" PRIu8 ":%" PRIu16,
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
339 vm_getbits(command, 22, 7), vm_getbits(command, 41, 10));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
340 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
341 case 6:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
342 switch(vm_getbits(command, 23, 2)) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
343 case 0:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
344 fprintf(MSG_OUT, "JumpSS FP");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
345 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
346 case 1:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
347 fprintf(MSG_OUT, "JumpSS VMGM (menu %" PRIu8 ")", vm_getbits(command, 19, 4));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
348 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
349 case 2:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
350 fprintf(MSG_OUT, "JumpSS VTSM (vts %" PRIu8 ", title %" PRIu8
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
351 ", 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
352 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
353 case 3:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
354 fprintf(MSG_OUT, "JumpSS VMGM (pgc %" PRIu8 ")", vm_getbits(command, 46, 15));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
355 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
356 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
357 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
358 case 8:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
359 switch(vm_getbits(command, 23, 2)) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
360 case 0:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
361 fprintf(MSG_OUT, "CallSS FP (rsm_cell %" PRIu8 ")",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
362 vm_getbits(command, 31, 8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
363 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
364 case 1:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
365 fprintf(MSG_OUT, "CallSS VMGM (menu %" PRIu8
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
366 ", rsm_cell %" PRIu8 ")", vm_getbits(command, 19, 4), vm_getbits(command, 31, 8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
367 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
368 case 2:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
369 fprintf(MSG_OUT, "CallSS VTSM (menu %" PRIu8
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
370 ", rsm_cell %" PRIu8 ")", vm_getbits(command, 19, 4), vm_getbits(command, 31, 8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
371 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
372 case 3:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
373 fprintf(MSG_OUT, "CallSS VMGM (pgc %" PRIu8 ", rsm_cell %" PRIu8 ")",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
374 vm_getbits(command, 46, 15), vm_getbits(command, 31, 8));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
375 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
376 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
377 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
378 default:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
379 fprintf(MSG_OUT, "WARNING: Unknown Jump/Call instruction");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
380 }
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 static void print_system_set(command_t* command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
384 int i;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
385 /* FIXME: What about SPRM11 ? Karaoke */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
386 /* Surely there must be some system set command for that ? */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
387
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
388 switch(vm_getbits(command, 59, 4)) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
389 case 1: /* Set system reg 1 &| 2 &| 3 (Audio, Subp. Angle) */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
390 for(i = 1; i <= 3; i++) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
391 if(vm_getbits(command, 47 - (i*8), 1)) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
392 print_system_reg(i);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
393 fprintf(MSG_OUT, " = ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
394 print_reg_or_data_2(command, vm_getbits(command, 60, 1), 47 - (i*8) );
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
395 fprintf(MSG_OUT, " ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
396 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
397 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
398 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
399 case 2: /* Set system reg 9 & 10 (Navigation timer, Title PGC number) */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
400 print_system_reg(9);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
401 fprintf(MSG_OUT, " = ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
402 print_reg_or_data(command, vm_getbits(command, 60, 1), 47);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
403 fprintf(MSG_OUT, " ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
404 print_system_reg(10);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
405 fprintf(MSG_OUT, " = %" PRIu16, vm_getbits(command, 30, 15)); /* ?? */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
406 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
407 case 3: /* Mode: Counter / Register + Set */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
408 fprintf(MSG_OUT, "SetMode ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
409 if(vm_getbits(command, 23, 1))
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
410 fprintf(MSG_OUT, "Counter ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
411 else
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
412 fprintf(MSG_OUT, "Register ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
413 print_g_reg(vm_getbits(command, 19, 4));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
414 print_set_op(0x1); /* '=' */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
415 print_reg_or_data(command, vm_getbits(command, 60, 1), 47);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
416 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
417 case 6: /* Set system reg 8 (Highlighted button) */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
418 print_system_reg(8);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
419 if(vm_getbits(command, 60, 1)) /* immediate */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
420 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
421 else
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
422 fprintf(MSG_OUT, " = g[%" PRIu8 "]", vm_getbits(command, 19, 4));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
423 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
424 default:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
425 fprintf(MSG_OUT, "WARNING: Unknown system set instruction (%i)",
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
426 vm_getbits(command, 59, 4));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
427 }
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 static void print_set_version_1(command_t* command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
431 uint8_t set_op = vm_getbits(command, 59, 4);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
432
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
433 if(set_op) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
434 print_g_reg(vm_getbits(command, 35, 4));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
435 print_set_op(set_op);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
436 print_reg_or_data(command, vm_getbits(command, 60, 1), 31);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
437 } else {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
438 fprintf(MSG_OUT, "NOP");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
439 }
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 static void print_set_version_2(command_t* command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
443 uint8_t set_op = vm_getbits(command, 59, 4);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
444
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
445 if(set_op) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
446 print_g_reg(vm_getbits(command, 51, 4));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
447 print_set_op(set_op);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
448 print_reg_or_data(command, vm_getbits(command, 60, 1), 47);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
449 } else {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
450 fprintf(MSG_OUT, "NOP");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
451 }
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 static void print_set_version_3(command_t* command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
455 uint8_t set_op = vm_getbits(command, 59, 4);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
456
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
457 if(set_op) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
458 print_g_reg(vm_getbits(command, 51, 4));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
459 print_set_op(set_op);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
460 print_reg_or_data_3(command, vm_getbits(command, 60, 1), 47);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
461 } else {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
462 fprintf(MSG_OUT, "NOP");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
463 }
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 void vm_print_mnemonic(vm_cmd_t *vm_command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
468 command_t command;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
469 command.instruction =( (uint64_t) vm_command->bytes[0] << 56 ) |
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
470 ( (uint64_t) vm_command->bytes[1] << 48 ) |
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
471 ( (uint64_t) vm_command->bytes[2] << 40 ) |
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
472 ( (uint64_t) vm_command->bytes[3] << 32 ) |
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
473 ( (uint64_t) vm_command->bytes[4] << 24 ) |
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
474 ( (uint64_t) vm_command->bytes[5] << 16 ) |
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
475 ( (uint64_t) vm_command->bytes[6] << 8 ) |
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
476 (uint64_t) vm_command->bytes[7] ;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
477 command.examined = 0;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
478
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
479 switch(vm_getbits(&command,63,3)) { /* three first bits */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
480 case 0: /* Special instructions */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
481 print_if_version_1(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
482 print_special_instruction(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
483 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
484 case 1: /* Jump/Call or Link instructions */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
485 if(vm_getbits(&command,60,1)) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
486 print_if_version_2(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
487 print_jump_instruction(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
488 } else {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
489 print_if_version_1(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
490 print_link_instruction(&command, 0); /* must be pressent */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
491 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
492 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
493 case 2: /* Set System Parameters instructions */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
494 print_if_version_2(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
495 print_system_set(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
496 print_link_instruction(&command, 1); /* either 'if' or 'link' */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
497 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
498 case 3: /* Set General Parameters instructions */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
499 print_if_version_3(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
500 print_set_version_1(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
501 print_link_instruction(&command, 1); /* either 'if' or 'link' */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
502 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
503 case 4: /* Set, Compare -> LinkSub instructions */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
504 print_set_version_2(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
505 fprintf(MSG_OUT, ", ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
506 print_if_version_4(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
507 print_linksub_instruction(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
508 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
509 case 5: /* Compare -> (Set and LinkSub) instructions */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
510 print_if_version_5(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
511 fprintf(MSG_OUT, "{ ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
512 print_set_version_3(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
513 fprintf(MSG_OUT, ", ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
514 print_linksub_instruction(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
515 fprintf(MSG_OUT, " }");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
516 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
517 case 6: /* Compare -> Set, always LinkSub instructions */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
518 print_if_version_5(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
519 fprintf(MSG_OUT, "{ ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
520 print_set_version_3(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
521 fprintf(MSG_OUT, " } ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
522 print_linksub_instruction(&command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
523 break;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
524 default:
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
525 fprintf(MSG_OUT, "WARNING: Unknown instruction type (%i)", vm_getbits(&command, 63, 3));
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
526 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
527 /* Check if there still are bits set that were not examined */
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
528
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
529 if(command.instruction & ~ command.examined) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
530 fprintf(MSG_OUT, " libdvdnav: vmcmd.c: [WARNING, unknown bits:");
279
130c10495b66 replaced 08llx with PRIx64; patch by Diego Petteno'
nicodvb
parents: 243
diff changeset
531 fprintf(MSG_OUT, " %08"PRIx64, (command.instruction & ~ command.examined) );
225
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
532 fprintf(MSG_OUT, "]");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
533 }
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 void vm_print_cmd(int row, vm_cmd_t *vm_command) {
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
537 int i;
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
538
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
539 fprintf(MSG_OUT, "(%03d) ", row + 1);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
540 for(i = 0; i < 8; i++)
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
541 fprintf(MSG_OUT, "%02x ", vm_command->bytes[i]);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
542 fprintf(MSG_OUT, "| ");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
543
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
544 vm_print_mnemonic(vm_command);
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
545 fprintf(MSG_OUT, "\n");
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
546 }
9b1b740e3fc9 big build system changes
mroi
parents:
diff changeset
547