annotate vm/vmcmd.c @ 392:0a5a6f03b029 src

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