annotate vm/vmcmd.c @ 395:9c5aef10d165 src

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