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