annotate vm/vmcmd.c @ 389:d3c273ced49c src

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