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