Mercurial > libdvdnav.hg
annotate vm.c @ 15:74aee0b81da0 src
only one bits function now.
author | jcdutton |
---|---|
date | Wed, 10 Apr 2002 13:33:12 +0000 |
parents | ebf344d11bde |
children | 46fbd218a689 |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright (C) 2000, 2001 Håkan Hjort | |
3 * Copyright (C) 2001 Rich Wareham <richwareham@users.sourceforge.net> | |
4 * | |
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. | |
7 * | |
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. | |
12 * | |
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. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
21 * | |
22 * $Id$ | |
23 * | |
24 */ | |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 #include "config.h" | |
28 #endif | |
29 | |
30 #include <stdio.h> | |
31 #include <string.h> | |
32 #include <stdlib.h> | |
33 #include <unistd.h> | |
34 #include <inttypes.h> | |
35 #include <assert.h> | |
36 | |
37 #include <dvdread/ifo_types.h> | |
38 #include <dvdread/ifo_read.h> | |
39 | |
40 #include "decoder.h" | |
41 #include "vmcmd.h" | |
42 #include "vm.h" | |
43 | |
44 /* Local prototypes */ | |
45 | |
6 | 46 static void saveRSMinfo(vm_t *vm,int cellN, int blockN); |
47 static int set_PGN(vm_t *vm); | |
48 static link_t play_PGC(vm_t *vm); | |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
49 static link_t play_PGC_post(vm_t *vm); |
6 | 50 static link_t play_PG(vm_t *vm); |
51 static link_t play_Cell(vm_t *vm); | |
52 static link_t play_Cell_post(vm_t *vm); | |
53 static link_t process_command(vm_t *vm,link_t link_values); | |
0 | 54 |
6 | 55 static void ifoOpenNewVTSI(vm_t *vm,dvd_reader_t *dvd, int vtsN); |
56 static pgcit_t* get_PGCIT(vm_t *vm); | |
57 static int get_video_aspect(vm_t *vm); | |
0 | 58 |
59 /* Can only be called when in VTS_DOMAIN */ | |
6 | 60 static int get_TT(vm_t *vm,int tt); |
61 static int get_VTS_TT(vm_t *vm,int vtsN, int vts_ttn); | |
62 static int get_VTS_PTT(vm_t *vm,int vtsN, int vts_ttn, int part); | |
14 | 63 static int find_TT(vm_t *vm, int vtsN, int vts_ttn); |
0 | 64 |
6 | 65 static int get_MENU(vm_t *vm,int menu); /* VTSM & VMGM */ |
66 static int get_FP_PGC(vm_t *vm); /* FP */ | |
0 | 67 |
68 /* Called in any domain */ | |
6 | 69 static int get_ID(vm_t *vm,int id); |
70 static int get_PGC(vm_t *vm,int pgcN); | |
71 static int get_PGCN(vm_t *vm); | |
0 | 72 |
73 /* Initialisation */ | |
74 | |
75 vm_t* vm_new_vm() { | |
76 vm_t *vm = (vm_t*)calloc(sizeof(vm_t), sizeof(char)); | |
77 | |
78 return vm; | |
79 } | |
80 | |
6 | 81 static void vm_print_current_domain_state(vm_t *vm) { |
82 switch((vm->state).domain) { | |
0 | 83 case VTS_DOMAIN: |
84 fprintf(stderr, "Video Title Domain: -\n"); | |
85 break; | |
86 | |
87 case VTSM_DOMAIN: | |
88 fprintf(stderr, "Video Title Menu Domain: -\n"); | |
89 break; | |
90 | |
91 case VMGM_DOMAIN: | |
92 fprintf(stderr, "Video Manager Menu Domain: -\n"); | |
93 break; | |
94 | |
95 case FP_DOMAIN: | |
96 fprintf(stderr, "First Play Domain: -\n"); | |
97 break; | |
98 | |
99 default: | |
100 fprintf(stderr, "Unknown Domain: -\n"); | |
101 break; | |
102 } | |
103 fprintf(stderr, "VTS:%d PG:%u CELL:%u BLOCK:%u VTS_TTN:%u TTN:%u TT_PGCN:%u\n", | |
6 | 104 (vm->state).vtsN, |
105 (vm->state).pgN, | |
106 (vm->state).cellN, | |
107 (vm->state).blockN, | |
108 (vm->state).VTS_TTN_REG, | |
109 (vm->state).TTN_REG, | |
110 (vm->state).TT_PGCN_REG); | |
0 | 111 } |
112 | |
6 | 113 void vm_stop(vm_t *vm) { |
114 if(!vm) | |
0 | 115 return; |
116 | |
6 | 117 if(vm->vmgi) { |
118 ifoClose(vm->vmgi); | |
119 vm->vmgi=NULL; | |
0 | 120 } |
121 | |
6 | 122 if(vm->vtsi) { |
123 ifoClose(vm->vtsi); | |
124 vm->vmgi=NULL; | |
0 | 125 } |
126 | |
6 | 127 if(vm->dvd) { |
128 DVDClose(vm->dvd); | |
129 vm->dvd=NULL; | |
0 | 130 } |
131 } | |
132 | |
6 | 133 void vm_free_vm(vm_t *vm) { |
134 if(vm) { | |
135 vm_stop(vm); | |
136 free(vm); | |
0 | 137 } |
138 } | |
139 | |
140 /* IFO Access */ | |
141 | |
6 | 142 ifo_handle_t *vm_get_vmgi(vm_t *vm) { |
143 if(!vm) | |
0 | 144 return NULL; |
145 | |
6 | 146 return vm->vmgi; |
0 | 147 } |
148 | |
6 | 149 ifo_handle_t *vm_get_vtsi(vm_t *vm) { |
150 if(!vm) | |
0 | 151 return NULL; |
152 | |
6 | 153 return vm->vtsi; |
0 | 154 } |
155 | |
156 /* Reader Access */ | |
157 | |
6 | 158 dvd_reader_t *vm_get_dvd_reader(vm_t *vm) { |
159 if(!vm) | |
0 | 160 return NULL; |
161 | |
6 | 162 return vm->dvd; |
0 | 163 } |
164 | |
6 | 165 int vm_reset(vm_t *vm, char *dvdroot) /* , register_t regs) */ { |
0 | 166 /* Setup State */ |
6 | 167 memset((vm->state).registers.SPRM, 0, sizeof(uint16_t)*24); |
168 memset((vm->state).registers.GPRM, 0, sizeof((vm->state).registers.GPRM)); | |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
169 memset((vm->state).registers.GPRM_mode, 0, sizeof((vm->state).registers.GPRM_mode)); |
6 | 170 (vm->state).registers.SPRM[0] = ('e'<<8)|'n'; /* Player Menu Languange code */ |
171 (vm->state).AST_REG = 15; /* 15 why? */ | |
172 (vm->state).SPST_REG = 62; /* 62 why? */ | |
173 (vm->state).AGL_REG = 1; | |
174 (vm->state).TTN_REG = 1; | |
175 (vm->state).VTS_TTN_REG = 1; | |
176 /* (vm->state).TT_PGCN_REG = 0 */ | |
177 (vm->state).PTTN_REG = 1; | |
178 (vm->state).HL_BTNN_REG = 1 << 10; | |
0 | 179 |
6 | 180 (vm->state).PTL_REG = 15; /* Parental Level */ |
181 (vm->state).registers.SPRM[12] = ('U'<<8)|'S'; /* Parental Management Country Code */ | |
182 (vm->state).registers.SPRM[16] = ('e'<<8)|'n'; /* Initial Language Code for Audio */ | |
183 (vm->state).registers.SPRM[18] = ('e'<<8)|'n'; /* Initial Language Code for Spu */ | |
0 | 184 /* Player Regional Code Mask. |
185 * bit0 = Region 1 | |
186 * bit1 = Region 2 | |
187 */ | |
6 | 188 (vm->state).registers.SPRM[20] = 0x1; /* Player Regional Code Mask. Region free! */ |
189 (vm->state).registers.SPRM[14] = 0x100; /* Try Pan&Scan */ | |
0 | 190 |
6 | 191 (vm->state).pgN = 0; |
192 (vm->state).cellN = 0; | |
0 | 193 |
6 | 194 (vm->state).domain = FP_DOMAIN; |
195 (vm->state).rsm_vtsN = 0; | |
196 (vm->state).rsm_cellN = 0; | |
197 (vm->state).rsm_blockN = 0; | |
0 | 198 |
6 | 199 (vm->state).vtsN = -1; |
0 | 200 |
6 | 201 if (vm->dvd && dvdroot) { |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
202 // a new dvd device has been requested |
6 | 203 vm_stop(vm); |
0 | 204 } |
6 | 205 if (!vm->dvd) { |
206 vm->dvd = DVDOpen(dvdroot); | |
207 if(!vm->dvd) { | |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
208 fprintf(stderr, "vm: faild to open/read the DVD\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
209 return -1; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
210 } |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
211 |
6 | 212 vm->vmgi = ifoOpenVMGI(vm->dvd); |
213 if(!vm->vmgi) { | |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
214 fprintf(stderr, "vm: faild to read VIDEO_TS.IFO\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
215 return -1; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
216 } |
6 | 217 if(!ifoRead_FP_PGC(vm->vmgi)) { |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
218 fprintf(stderr, "vm: ifoRead_FP_PGC failed\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
219 return -1; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
220 } |
6 | 221 if(!ifoRead_TT_SRPT(vm->vmgi)) { |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
222 fprintf(stderr, "vm: ifoRead_TT_SRPT failed\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
223 return -1; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
224 } |
6 | 225 if(!ifoRead_PGCI_UT(vm->vmgi)) { |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
226 fprintf(stderr, "vm: ifoRead_PGCI_UT failed\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
227 return -1; |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
228 } |
6 | 229 if(!ifoRead_PTL_MAIT(vm->vmgi)) { |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
230 fprintf(stderr, "vm: ifoRead_PTL_MAIT failed\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
231 ; /* return -1; Not really used for now.. */ |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
232 } |
6 | 233 if(!ifoRead_VTS_ATRT(vm->vmgi)) { |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
234 fprintf(stderr, "vm: ifoRead_VTS_ATRT failed\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
235 ; /* return -1; Not really used for now.. */ |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
236 } |
6 | 237 if(!ifoRead_VOBU_ADMAP(vm->vmgi)) { |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
238 fprintf(stderr, "vm: ifoRead_VOBU_ADMAP vgmi failed\n"); |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
239 ; /* return -1; Not really used for now.. */ |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
240 } |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
241 /* ifoRead_TXTDT_MGI(vmgi); Not implemented yet */ |
0 | 242 } |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
243 else fprintf(stderr, "vm: reset\n"); |
0 | 244 |
245 return 0; | |
246 } | |
247 | |
248 /* FIXME TODO XXX $$$ Handle error condition too... */ | |
6 | 249 int vm_start(vm_t *vm) |
0 | 250 { |
251 link_t link_values; | |
252 | |
9 | 253 /* Set pgc to FP(First Play) pgc */ |
6 | 254 get_FP_PGC(vm); |
255 link_values = play_PGC(vm); | |
256 link_values = process_command(vm,link_values); | |
0 | 257 assert(link_values.command == PlayThis); |
6 | 258 (vm->state).blockN = link_values.data1; |
0 | 259 |
260 return 0; /* ?? */ | |
261 } | |
262 | |
6 | 263 int vm_start_title(vm_t *vm, int tt) { |
0 | 264 link_t link_values; |
265 | |
6 | 266 get_TT(vm, tt); |
267 link_values = play_PGC(vm); | |
268 link_values = process_command(vm, link_values); | |
0 | 269 assert(link_values.command == PlayThis); |
6 | 270 (vm->state).blockN = link_values.data1; |
0 | 271 |
272 return 0; /* ?? */ | |
273 } | |
274 | |
6 | 275 int vm_jump_prog(vm_t *vm, int pr) { |
0 | 276 link_t link_values; |
277 | |
6 | 278 (vm->state).pgN = pr; /* ?? */ |
0 | 279 |
6 | 280 get_PGC(vm, get_PGCN(vm)); |
281 link_values = play_PG(vm); | |
282 link_values = process_command(vm, link_values); | |
0 | 283 assert(link_values.command == PlayThis); |
6 | 284 (vm->state).blockN = link_values.data1; |
0 | 285 |
286 return 0; /* ?? */ | |
287 } | |
288 | |
6 | 289 int vm_eval_cmd(vm_t *vm, vm_cmd_t *cmd) |
0 | 290 { |
291 link_t link_values; | |
292 | |
6 | 293 if(vmEval_CMD(cmd, 1, &(vm->state).registers, &link_values)) { |
294 link_values = process_command(vm, link_values); | |
0 | 295 assert(link_values.command == PlayThis); |
6 | 296 (vm->state).blockN = link_values.data1; |
0 | 297 return 1; /* Something changed, Jump */ |
298 } else { | |
299 return 0; /* It updated some state thats all... */ | |
300 } | |
301 } | |
302 | |
6 | 303 int vm_get_next_cell(vm_t *vm) |
0 | 304 { |
305 link_t link_values; | |
6 | 306 link_values = play_Cell_post(vm); |
307 link_values = process_command(vm,link_values); | |
0 | 308 assert(link_values.command == PlayThis); |
6 | 309 (vm->state).blockN = link_values.data1; |
0 | 310 |
311 return 0; /* ?? */ | |
312 } | |
313 | |
6 | 314 int vm_top_pg(vm_t *vm) |
0 | 315 { |
316 link_t link_values; | |
6 | 317 link_values = play_PG(vm); |
318 link_values = process_command(vm,link_values); | |
0 | 319 assert(link_values.command == PlayThis); |
6 | 320 (vm->state).blockN = link_values.data1; |
0 | 321 |
322 return 1; /* Jump */ | |
323 } | |
324 | |
6 | 325 int vm_go_up(vm_t *vm) |
0 | 326 { |
327 link_t link_values; | |
328 | |
6 | 329 if(get_PGC(vm, (vm->state).pgc->goup_pgc_nr)) |
0 | 330 assert(0); |
331 | |
6 | 332 link_values = play_PGC(vm); |
333 link_values = process_command(vm,link_values); | |
0 | 334 assert(link_values.command == PlayThis); |
6 | 335 (vm->state).blockN = link_values.data1; |
0 | 336 |
337 return 1; /* Jump */ | |
338 } | |
339 | |
6 | 340 int vm_next_pg(vm_t *vm) |
0 | 341 { |
342 /* Do we need to get a updated pgN value first? */ | |
6 | 343 (vm->state).pgN += 1; |
344 return vm_top_pg(vm); | |
0 | 345 } |
346 | |
6 | 347 int vm_prev_pg(vm_t *vm) |
0 | 348 { |
349 /* Do we need to get a updated pgN value first? */ | |
6 | 350 (vm->state).pgN -= 1; |
351 if((vm->state).pgN == 0) { | |
0 | 352 /* Check for previous PGCN ? */ |
6 | 353 (vm->state).pgN = 1; |
0 | 354 /* return 0; */ |
355 } | |
6 | 356 return vm_top_pg(vm); |
0 | 357 } |
358 | |
359 | |
360 static domain_t menuid2domain(DVDMenuID_t menuid) | |
361 { | |
362 domain_t result = VTSM_DOMAIN; /* Really shouldn't have to.. */ | |
363 | |
364 switch(menuid) { | |
365 case DVD_MENU_Title: | |
366 result = VMGM_DOMAIN; | |
367 break; | |
368 case DVD_MENU_Root: | |
369 case DVD_MENU_Subpicture: | |
370 case DVD_MENU_Audio: | |
371 case DVD_MENU_Angle: | |
372 case DVD_MENU_Part: | |
373 result = VTSM_DOMAIN; | |
374 break; | |
375 } | |
376 | |
377 return result; | |
378 } | |
379 | |
6 | 380 int vm_menu_call(vm_t *vm, DVDMenuID_t menuid, int block) |
0 | 381 { |
382 domain_t old_domain; | |
383 link_t link_values; | |
384 | |
385 /* Should check if we are allowed/can acces this menu */ | |
386 | |
387 | |
388 /* FIXME XXX $$$ How much state needs to be restored | |
389 * when we fail to find a menu? */ | |
390 | |
6 | 391 old_domain = (vm->state).domain; |
0 | 392 |
6 | 393 switch((vm->state).domain) { |
0 | 394 case VTS_DOMAIN: |
6 | 395 saveRSMinfo(vm, 0, block); |
0 | 396 /* FALL THROUGH */ |
397 case VTSM_DOMAIN: | |
398 case VMGM_DOMAIN: | |
6 | 399 (vm->state).domain = menuid2domain(menuid); |
400 if(get_PGCIT(vm) != NULL && get_MENU(vm, menuid) != -1) { | |
401 link_values = play_PGC(vm); | |
402 link_values = process_command(vm, link_values); | |
0 | 403 assert(link_values.command == PlayThis); |
6 | 404 (vm->state).blockN = link_values.data1; |
0 | 405 return 1; /* Jump */ |
406 } else { | |
6 | 407 (vm->state).domain = old_domain; |
0 | 408 } |
409 break; | |
410 case FP_DOMAIN: /* FIXME XXX $$$ What should we do here? */ | |
411 break; | |
412 } | |
413 | |
414 return 0; | |
415 } | |
416 | |
417 | |
6 | 418 int vm_resume(vm_t *vm) |
0 | 419 { |
420 int i; | |
421 link_t link_values; | |
422 | |
423 /* Check and see if there is any rsm info!! */ | |
6 | 424 if((vm->state).rsm_vtsN == 0) { |
0 | 425 return 0; |
426 } | |
427 | |
6 | 428 (vm->state).domain = VTS_DOMAIN; |
429 ifoOpenNewVTSI(vm, vm->dvd, (vm->state).rsm_vtsN); | |
430 get_PGC(vm, (vm->state).rsm_pgcN); | |
0 | 431 |
432 /* These should never be set in SystemSpace and/or MenuSpace */ | |
6 | 433 /* (vm->state).TTN_REG = (vm->state).rsm_tt; */ |
434 /* (vm->state).TT_PGCN_REG = (vm->state).rsm_pgcN; */ | |
435 /* (vm->state).HL_BTNN_REG = (vm->state).rsm_btnn; */ | |
0 | 436 for(i = 0; i < 5; i++) { |
6 | 437 (vm->state).registers.SPRM[4 + i] = (vm->state).rsm_regs[i]; |
0 | 438 } |
439 | |
6 | 440 if((vm->state).rsm_cellN == 0) { |
441 assert((vm->state).cellN); /* Checking if this ever happens */ | |
442 (vm->state).pgN = 1; | |
443 link_values = play_PG(vm); | |
444 link_values = process_command(vm, link_values); | |
0 | 445 assert(link_values.command == PlayThis); |
6 | 446 (vm->state).blockN = link_values.data1; |
0 | 447 } else { |
6 | 448 (vm->state).cellN = (vm->state).rsm_cellN; |
449 (vm->state).blockN = (vm->state).rsm_blockN; | |
450 /* (vm->state).pgN = ?? does this gets the righ value in play_Cell, no! */ | |
451 if(set_PGN(vm)) { | |
0 | 452 /* Were at or past the end of the PGC, should not happen for a RSM */ |
453 assert(0); | |
6 | 454 play_PGC_post(vm); |
0 | 455 } |
456 } | |
457 | |
458 return 1; /* Jump */ | |
459 } | |
460 | |
461 /** | |
462 * Return the substream id for 'logical' audio stream audioN. | |
463 * 0 <= audioN < 8 | |
464 */ | |
6 | 465 int vm_get_audio_stream(vm_t *vm, int audioN) |
0 | 466 { |
467 int streamN = -1; | |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
468 fprintf(stderr,"dvdnav:vm.c:get_audio_stream audioN=%d\n",audioN); |
6 | 469 if((vm->state).domain == VTSM_DOMAIN |
470 || (vm->state).domain == VMGM_DOMAIN | |
471 || (vm->state).domain == FP_DOMAIN) { | |
0 | 472 audioN = 0; |
473 } | |
474 | |
475 if(audioN < 8) { | |
476 /* Is there any contol info for this logical stream */ | |
6 | 477 if((vm->state).pgc->audio_control[audioN] & (1<<15)) { |
478 streamN = ((vm->state).pgc->audio_control[audioN] >> 8) & 0x07; | |
0 | 479 } |
480 } | |
481 | |
6 | 482 if((vm->state).domain == VTSM_DOMAIN |
483 || (vm->state).domain == VMGM_DOMAIN | |
484 || (vm->state).domain == FP_DOMAIN) { | |
0 | 485 if(streamN == -1) |
486 streamN = 0; | |
487 } | |
488 | |
489 /* Should also check in vtsi/vmgi status that what kind of stream | |
490 * it is (ac3/lpcm/dts/sdds...) to find the right (sub)stream id */ | |
491 return streamN; | |
492 } | |
493 | |
494 /** | |
495 * Return the substream id for 'logical' subpicture stream subpN. | |
496 * 0 <= subpN < 32 | |
497 */ | |
6 | 498 int vm_get_subp_stream(vm_t *vm, int subpN) |
0 | 499 { |
500 int streamN = -1; | |
6 | 501 int source_aspect = get_video_aspect(vm); |
0 | 502 |
6 | 503 if((vm->state).domain == VTSM_DOMAIN |
504 || (vm->state).domain == VMGM_DOMAIN | |
505 || (vm->state).domain == FP_DOMAIN) { | |
0 | 506 subpN = 0; |
507 } | |
508 | |
509 if(subpN < 32) { /* a valid logical stream */ | |
510 /* Is this logical stream present */ | |
6 | 511 if((vm->state).pgc->subp_control[subpN] & (1<<31)) { |
0 | 512 if(source_aspect == 0) /* 4:3 */ |
6 | 513 streamN = ((vm->state).pgc->subp_control[subpN] >> 24) & 0x1f; |
0 | 514 if(source_aspect == 3) /* 16:9 */ |
6 | 515 streamN = ((vm->state).pgc->subp_control[subpN] >> 16) & 0x1f; |
0 | 516 } |
517 } | |
518 | |
519 /* Paranoia.. if no stream select 0 anyway */ | |
520 /* I am not paranoid */ | |
6 | 521 /* if((vm->state).domain == VTSM_DOMAIN |
522 || (vm->state).domain == VMGM_DOMAIN | |
523 || (vm->state).domain == FP_DOMAIN) { | |
0 | 524 if(streamN == -1) |
525 streamN = 0; | |
526 } | |
527 */ | |
528 /* Should also check in vtsi/vmgi status that what kind of stream it is. */ | |
529 return streamN; | |
530 } | |
531 | |
6 | 532 int vm_get_subp_active_stream(vm_t *vm) |
0 | 533 { |
534 int subpN; | |
535 int streamN; | |
6 | 536 subpN = (vm->state).SPST_REG & ~0x40; |
537 streamN = vm_get_subp_stream(vm, subpN); | |
0 | 538 |
539 /* If no such stream, then select the first one that exists. */ | |
540 if(streamN == -1) { | |
541 for(subpN = 0; subpN < 32; subpN++) { | |
6 | 542 if((vm->state).pgc->subp_control[subpN] & (1<<31)) { |
0 | 543 |
6 | 544 streamN = vm_get_subp_stream(vm, subpN); |
0 | 545 break; |
546 } | |
547 } | |
548 } | |
549 | |
550 /* We should instead send the on/off status to the spudecoder / mixer */ | |
551 /* If we are in the title domain see if the spu mixing is on */ | |
6 | 552 if((vm->state).domain == VTS_DOMAIN && !((vm->state).SPST_REG & 0x40)) { |
0 | 553 /* Bit 7 set means hide, and only let Forced display show */ |
554 return (streamN | 0x80); | |
555 } else { | |
556 return streamN; | |
557 } | |
558 } | |
559 | |
6 | 560 int vm_get_audio_active_stream(vm_t *vm) |
0 | 561 { |
562 int audioN; | |
563 int streamN; | |
6 | 564 audioN = (vm->state).AST_REG ; |
565 streamN = vm_get_audio_stream(vm, audioN); | |
0 | 566 |
567 /* If no such stream, then select the first one that exists. */ | |
568 if(streamN == -1) { | |
569 for(audioN = 0; audioN < 8; audioN++) { | |
6 | 570 if((vm->state).pgc->audio_control[audioN] & (1<<15)) { |
571 streamN = vm_get_audio_stream(vm, audioN); | |
0 | 572 break; |
573 } | |
574 } | |
575 } | |
576 | |
577 return streamN; | |
578 } | |
579 | |
580 | |
6 | 581 void vm_get_angle_info(vm_t *vm, int *num_avail, int *current) |
0 | 582 { |
583 *num_avail = 1; | |
584 *current = 1; | |
585 | |
6 | 586 if((vm->state).domain == VTS_DOMAIN) { |
0 | 587 /* TTN_REG does not allways point to the correct title.. */ |
588 title_info_t *title; | |
6 | 589 if((vm->state).TTN_REG > vm->vmgi->tt_srpt->nr_of_srpts) |
0 | 590 return; |
6 | 591 title = &vm->vmgi->tt_srpt->title[(vm->state).TTN_REG - 1]; |
592 if(title->title_set_nr != (vm->state).vtsN || | |
593 title->vts_ttn != (vm->state).VTS_TTN_REG) | |
0 | 594 return; |
595 *num_avail = title->nr_of_angles; | |
6 | 596 *current = (vm->state).AGL_REG; |
0 | 597 if(*current > *num_avail) /* Is this really a good idea? */ |
598 *current = *num_avail; | |
599 } | |
600 } | |
601 | |
602 | |
6 | 603 void vm_get_audio_info(vm_t *vm, int *num_avail, int *current) |
0 | 604 { |
6 | 605 if((vm->state).domain == VTS_DOMAIN) { |
606 *num_avail = vm->vtsi->vtsi_mat->nr_of_vts_audio_streams; | |
607 *current = (vm->state).AST_REG; | |
608 } else if((vm->state).domain == VTSM_DOMAIN) { | |
609 *num_avail = vm->vtsi->vtsi_mat->nr_of_vtsm_audio_streams; /* 1 */ | |
0 | 610 *current = 1; |
6 | 611 } else if((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN) { |
612 *num_avail = vm->vmgi->vmgi_mat->nr_of_vmgm_audio_streams; /* 1 */ | |
0 | 613 *current = 1; |
614 } | |
615 } | |
616 | |
6 | 617 void vm_get_subp_info(vm_t *vm, int *num_avail, int *current) |
0 | 618 { |
6 | 619 if((vm->state).domain == VTS_DOMAIN) { |
620 *num_avail = vm->vtsi->vtsi_mat->nr_of_vts_subp_streams; | |
621 *current = (vm->state).SPST_REG; | |
622 } else if((vm->state).domain == VTSM_DOMAIN) { | |
623 *num_avail = vm->vtsi->vtsi_mat->nr_of_vtsm_subp_streams; /* 1 */ | |
0 | 624 *current = 0x41; |
6 | 625 } else if((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN) { |
626 *num_avail = vm->vmgi->vmgi_mat->nr_of_vmgm_subp_streams; /* 1 */ | |
0 | 627 *current = 0x41; |
628 } | |
629 } | |
630 | |
6 | 631 subp_attr_t vm_get_subp_attr(vm_t *vm, int streamN) |
0 | 632 { |
633 subp_attr_t attr; | |
634 | |
6 | 635 if((vm->state).domain == VTS_DOMAIN) { |
636 attr = vm->vtsi->vtsi_mat->vts_subp_attr[streamN]; | |
637 } else if((vm->state).domain == VTSM_DOMAIN) { | |
638 attr = vm->vtsi->vtsi_mat->vtsm_subp_attr; | |
639 } else if((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN) { | |
640 attr = vm->vmgi->vmgi_mat->vmgm_subp_attr; | |
0 | 641 } |
642 return attr; | |
643 } | |
644 | |
6 | 645 audio_attr_t vm_get_audio_attr(vm_t *vm, int streamN) |
0 | 646 { |
647 audio_attr_t attr; | |
648 | |
6 | 649 if((vm->state).domain == VTS_DOMAIN) { |
650 attr = vm->vtsi->vtsi_mat->vts_audio_attr[streamN]; | |
651 } else if((vm->state).domain == VTSM_DOMAIN) { | |
652 attr = vm->vtsi->vtsi_mat->vtsm_audio_attr; | |
653 } else if((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN) { | |
654 attr = vm->vmgi->vmgi_mat->vmgm_audio_attr; | |
0 | 655 } |
656 return attr; | |
657 } | |
658 | |
6 | 659 video_attr_t vm_get_video_attr(vm_t *vm) |
0 | 660 { |
661 video_attr_t attr; | |
662 | |
6 | 663 if((vm->state).domain == VTS_DOMAIN) { |
664 attr = vm->vtsi->vtsi_mat->vts_video_attr; | |
665 } else if((vm->state).domain == VTSM_DOMAIN) { | |
666 attr = vm->vtsi->vtsi_mat->vtsm_video_attr; | |
667 } else if((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN) { | |
668 attr = vm->vmgi->vmgi_mat->vmgm_video_attr; | |
0 | 669 } |
670 return attr; | |
671 } | |
672 | |
6 | 673 void vm_get_video_res(vm_t *vm, int *width, int *height) |
0 | 674 { |
675 video_attr_t attr; | |
676 | |
6 | 677 attr = vm_get_video_attr(vm); |
0 | 678 |
679 if(attr.video_format != 0) | |
680 *height = 576; | |
681 else | |
682 *height = 480; | |
683 switch(attr.picture_size) { | |
684 case 0: | |
685 *width = 720; | |
686 break; | |
687 case 1: | |
688 *width = 704; | |
689 break; | |
690 case 2: | |
691 *width = 352; | |
692 break; | |
693 case 3: | |
694 *width = 352; | |
695 *height /= 2; | |
696 break; | |
697 } | |
698 } | |
699 | |
700 /* Must be called before domain is changed (get_PGCN()) */ | |
6 | 701 static void saveRSMinfo(vm_t *vm, int cellN, int blockN) |
0 | 702 { |
703 int i; | |
704 | |
705 if(cellN != 0) { | |
6 | 706 (vm->state).rsm_cellN = cellN; |
707 (vm->state).rsm_blockN = 0; | |
0 | 708 } else { |
6 | 709 (vm->state).rsm_cellN = (vm->state).cellN; |
710 (vm->state).rsm_blockN = blockN; | |
0 | 711 } |
6 | 712 (vm->state).rsm_vtsN = (vm->state).vtsN; |
713 (vm->state).rsm_pgcN = get_PGCN(vm); | |
0 | 714 |
6 | 715 /* assert((vm->state).rsm_pgcN == (vm->state).TT_PGCN_REG); // for VTS_DOMAIN */ |
0 | 716 |
717 for(i = 0; i < 5; i++) { | |
6 | 718 (vm->state).rsm_regs[i] = (vm->state).registers.SPRM[4 + i]; |
0 | 719 } |
720 } | |
721 | |
722 | |
723 | |
6 | 724 /* Figure out the correct pgN from the cell and update (vm->state). */ |
725 static int set_PGN(vm_t *vm) { | |
0 | 726 int new_pgN = 0; |
727 | |
6 | 728 while(new_pgN < (vm->state).pgc->nr_of_programs |
729 && (vm->state).cellN >= (vm->state).pgc->program_map[new_pgN]) | |
0 | 730 new_pgN++; |
731 | |
6 | 732 if(new_pgN == (vm->state).pgc->nr_of_programs) /* We are at the last program */ |
733 if((vm->state).cellN > (vm->state).pgc->nr_of_cells) | |
0 | 734 return 1; /* We are past the last cell */ |
735 | |
6 | 736 (vm->state).pgN = new_pgN; |
0 | 737 |
6 | 738 if((vm->state).domain == VTS_DOMAIN) { |
0 | 739 playback_type_t *pb_ty; |
6 | 740 if((vm->state).TTN_REG > vm->vmgi->tt_srpt->nr_of_srpts) |
0 | 741 return 0; /* ?? */ |
6 | 742 pb_ty = &vm->vmgi->tt_srpt->title[(vm->state).TTN_REG - 1].pb_ty; |
0 | 743 if(pb_ty->multi_or_random_pgc_title == /* One_Sequential_PGC_Title */ 0) { |
744 #if 0 /* TTN_REG can't be trusted to have a correct value here... */ | |
745 vts_ptt_srpt_t *ptt_srpt = vtsi->vts_ptt_srpt; | |
6 | 746 assert((vm->state).VTS_TTN_REG <= ptt_srpt->nr_of_srpts); |
747 assert(get_PGCN() == ptt_srpt->title[(vm->state).VTS_TTN_REG - 1].ptt[0].pgcn); | |
748 assert(1 == ptt_srpt->title[(vm->state).VTS_TTN_REG - 1].ptt[0].pgn); | |
0 | 749 #endif |
6 | 750 (vm->state).PTTN_REG = (vm->state).pgN; |
0 | 751 } |
752 } | |
753 | |
754 return 0; | |
755 } | |
756 | |
6 | 757 static link_t play_PGC(vm_t *vm) |
0 | 758 { |
759 link_t link_values; | |
760 | |
761 fprintf(stderr, "vm: play_PGC:"); | |
6 | 762 if((vm->state).domain != FP_DOMAIN) |
763 fprintf(stderr, " (vm->state).pgcN (%i)\n", get_PGCN(vm)); | |
0 | 764 else |
765 fprintf(stderr, " first_play_pgc\n"); | |
766 | |
767 /* This must be set before the pre-commands are executed because they */ | |
768 /* might contain a CallSS that will save resume state */ | |
6 | 769 (vm->state).pgN = 1; |
770 (vm->state).cellN = 0; | |
0 | 771 |
772 /* eval -> updates the state and returns either | |
773 - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN) | |
774 - just play video i.e first PG | |
775 (This is what happens if you fall of the end of the pre_cmds) | |
776 - or a error (are there more cases?) */ | |
6 | 777 if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_pre) { |
778 if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds, | |
779 (vm->state).pgc->command_tbl->nr_of_pre, | |
780 &(vm->state).registers, &link_values)) { | |
0 | 781 /* link_values contains the 'jump' return value */ |
782 return link_values; | |
783 } else { | |
784 fprintf(stderr, "PGC pre commands didn't do a Jump, Link or Call\n"); | |
785 } | |
786 } | |
6 | 787 return play_PG(vm); |
0 | 788 } |
789 | |
790 | |
6 | 791 static link_t play_PG(vm_t *vm) |
0 | 792 { |
6 | 793 fprintf(stderr, "play_PG: (vm->state).pgN (%i)\n", (vm->state).pgN); |
0 | 794 |
6 | 795 assert((vm->state).pgN > 0); |
796 if((vm->state).pgN > (vm->state).pgc->nr_of_programs) { | |
797 fprintf(stderr, "(vm->state).pgN (%i) == pgc->nr_of_programs + 1 (%i)\n", | |
798 (vm->state).pgN, (vm->state).pgc->nr_of_programs + 1); | |
799 assert((vm->state).pgN == (vm->state).pgc->nr_of_programs + 1); | |
800 return play_PGC_post(vm); | |
0 | 801 } |
802 | |
6 | 803 (vm->state).cellN = (vm->state).pgc->program_map[(vm->state).pgN - 1]; |
0 | 804 |
6 | 805 return play_Cell(vm); |
0 | 806 } |
807 | |
808 | |
6 | 809 static link_t play_Cell(vm_t *vm) |
0 | 810 { |
6 | 811 fprintf(stderr, "play_Cell: (vm->state).cellN (%i)\n", (vm->state).cellN); |
0 | 812 |
6 | 813 assert((vm->state).cellN > 0); |
814 if((vm->state).cellN > (vm->state).pgc->nr_of_cells) { | |
815 fprintf(stderr, "(vm->state).cellN (%i) == pgc->nr_of_cells + 1 (%i)\n", | |
816 (vm->state).cellN, (vm->state).pgc->nr_of_cells + 1); | |
817 assert((vm->state).cellN == (vm->state).pgc->nr_of_cells + 1); | |
818 return play_PGC_post(vm); | |
0 | 819 } |
820 | |
821 | |
822 /* Multi angle/Interleaved */ | |
6 | 823 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode) { |
0 | 824 case 0: /* Normal */ |
6 | 825 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 0); |
0 | 826 break; |
827 case 1: /* The first cell in the block */ | |
6 | 828 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type) { |
0 | 829 case 0: /* Not part of a block */ |
830 assert(0); | |
831 case 1: /* Angle block */ | |
832 /* Loop and check each cell instead? So we don't get outsid the block. */ | |
6 | 833 (vm->state).cellN += (vm->state).AGL_REG - 1; |
834 assert((vm->state).cellN <= (vm->state).pgc->nr_of_cells); | |
835 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode != 0); | |
836 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 1); | |
0 | 837 break; |
838 case 2: /* ?? */ | |
839 case 3: /* ?? */ | |
840 default: | |
841 fprintf(stderr, "Invalid? Cell block_mode (%d), block_type (%d)\n", | |
6 | 842 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode, |
843 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type); | |
0 | 844 } |
845 break; | |
846 case 2: /* Cell in the block */ | |
847 case 3: /* Last cell in the block */ | |
848 /* These might perhaps happen for RSM or LinkC commands? */ | |
849 default: | |
850 fprintf(stderr, "Cell is in block but did not enter at first cell!\n"); | |
851 } | |
852 | |
6 | 853 /* Updates (vm->state).pgN and PTTN_REG */ |
854 if(set_PGN(vm)) { | |
0 | 855 /* Should not happen */ |
856 link_t tmp = {LinkTailPGC, /* No Button */ 0, 0, 0}; | |
857 assert(0); | |
858 return tmp; | |
859 } | |
860 | |
861 { | |
862 link_t tmp = {PlayThis, /* Block in Cell */ 0, 0, 0}; | |
863 return tmp; | |
864 } | |
865 | |
866 } | |
867 | |
6 | 868 static link_t play_Cell_post(vm_t *vm) |
0 | 869 { |
870 cell_playback_t *cell; | |
871 | |
6 | 872 fprintf(stderr, "play_Cell_post: (vm->state).cellN (%i)\n", (vm->state).cellN); |
0 | 873 |
6 | 874 cell = &(vm->state).pgc->cell_playback[(vm->state).cellN - 1]; |
0 | 875 |
876 /* Still time is already taken care of before we get called. */ | |
877 | |
878 /* Deal with a Cell command, if any */ | |
879 if(cell->cell_cmd_nr != 0) { | |
880 link_t link_values; | |
881 | |
6 | 882 assert((vm->state).pgc->command_tbl != NULL); |
883 assert((vm->state).pgc->command_tbl->nr_of_cell >= cell->cell_cmd_nr); | |
0 | 884 fprintf(stderr, "Cell command pressent, executing\n"); |
6 | 885 if(vmEval_CMD(&(vm->state).pgc->command_tbl->cell_cmds[cell->cell_cmd_nr - 1], 1, |
886 &(vm->state).registers, &link_values)) { | |
0 | 887 return link_values; |
888 } else { | |
889 fprintf(stderr, "Cell command didn't do a Jump, Link or Call\n"); | |
890 /* Error ?? goto tail? goto next PG? or what? just continue? */ | |
891 } | |
892 } | |
893 | |
894 | |
895 /* Where to continue after playing the cell... */ | |
896 /* Multi angle/Interleaved */ | |
6 | 897 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode) { |
0 | 898 case 0: /* Normal */ |
6 | 899 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 0); |
900 (vm->state).cellN++; | |
0 | 901 break; |
902 case 1: /* The first cell in the block */ | |
903 case 2: /* A cell in the block */ | |
904 case 3: /* The last cell in the block */ | |
905 default: | |
6 | 906 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type) { |
0 | 907 case 0: /* Not part of a block */ |
908 assert(0); | |
909 case 1: /* Angle block */ | |
910 /* Skip the 'other' angles */ | |
6 | 911 (vm->state).cellN++; |
912 while((vm->state).cellN <= (vm->state).pgc->nr_of_cells | |
913 && (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode >= 2) { | |
914 (vm->state).cellN++; | |
0 | 915 } |
916 break; | |
917 case 2: /* ?? */ | |
918 case 3: /* ?? */ | |
919 default: | |
920 fprintf(stderr, "Invalid? Cell block_mode (%d), block_type (%d)\n", | |
6 | 921 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode, |
922 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type); | |
0 | 923 } |
924 break; | |
925 } | |
926 | |
927 | |
928 /* Figure out the correct pgN for the new cell */ | |
6 | 929 if(set_PGN(vm)) { |
0 | 930 fprintf(stderr, "last cell in this PGC\n"); |
6 | 931 return play_PGC_post(vm); |
0 | 932 } |
933 | |
6 | 934 return play_Cell(vm); |
0 | 935 } |
936 | |
937 | |
6 | 938 static link_t play_PGC_post(vm_t *vm) |
0 | 939 { |
940 link_t link_values; | |
941 | |
942 fprintf(stderr, "play_PGC_post:\n"); | |
943 | |
6 | 944 assert((vm->state).pgc->still_time == 0); /* FIXME $$$ */ |
0 | 945 |
946 /* eval -> updates the state and returns either | |
947 - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN) | |
948 - or a error (are there more cases?) | |
949 - if you got to the end of the post_cmds, then what ?? */ | |
6 | 950 if((vm->state).pgc->command_tbl && |
951 vmEval_CMD((vm->state).pgc->command_tbl->post_cmds, | |
952 (vm->state).pgc->command_tbl->nr_of_post, | |
953 &(vm->state).registers, &link_values)) { | |
0 | 954 return link_values; |
955 } | |
956 | |
957 /* Or perhaps handle it here? */ | |
958 { | |
959 link_t link_next_pgc = {LinkNextPGC, 0, 0, 0}; | |
960 fprintf(stderr, "** Fell of the end of the pgc, continuing in NextPGC\n"); | |
6 | 961 assert((vm->state).pgc->next_pgc_nr != 0); |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
962 /* Should end up in the STOP_DOMAIN if next_pgc is 0. */ |
0 | 963 return link_next_pgc; |
964 } | |
965 } | |
966 | |
967 | |
6 | 968 static link_t process_command(vm_t *vm, link_t link_values) |
0 | 969 { |
970 /* FIXME $$$ Move this to a separate function? */ | |
6 | 971 vm->badness_counter++; |
972 if (vm->badness_counter > 1) fprintf(stderr, "**** process_command re-entered %d*****\n",vm->badness_counter); | |
0 | 973 while(link_values.command != PlayThis) { |
974 | |
975 vmPrint_LINK(link_values); | |
976 | |
977 fprintf(stderr, "Link values %i %i %i %i\n", link_values.command, | |
978 link_values.data1, link_values.data2, link_values.data3); | |
979 | |
980 fprintf(stderr, "Before:"); | |
6 | 981 vm_print_current_domain_state(vm); |
0 | 982 |
983 switch(link_values.command) { | |
984 case LinkNoLink: | |
985 /* No Link */ | |
9 | 986 /* BUTTON number:data1 */ |
0 | 987 if(link_values.data1 != 0) |
6 | 988 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
989 fprintf(stderr, "libdvdnav: FIXME: in trouble...LinkNoLink - CRASHING!!!\n"); |
6 | 990 assert(0); |
0 | 991 |
992 case LinkTopC: | |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
993 /* Link to Top?? Cell. What is TopC */ |
9 | 994 /* BUTTON number:data1 */ |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
995 fprintf(stderr, "libdvdnav: FIXME: LinkTopC. What is LinkTopC?\n"); |
0 | 996 if(link_values.data1 != 0) |
6 | 997 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
998 link_values = play_Cell(vm); | |
0 | 999 break; |
1000 case LinkNextC: | |
1001 /* Link to Next Cell */ | |
9 | 1002 /* BUTTON number:data1 */ |
0 | 1003 if(link_values.data1 != 0) |
6 | 1004 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
1005 (vm->state).cellN += 1; /* if cellN becomes > nr_of_cells? it is handled in play_Cell() */ |
6 | 1006 link_values = play_Cell(vm); |
0 | 1007 break; |
1008 case LinkPrevC: | |
1009 /* Link to Previous Cell */ | |
9 | 1010 /* BUTTON number:data1 */ |
0 | 1011 if(link_values.data1 != 0) |
6 | 1012 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
1013 (vm->state).cellN -= 1; /* If cellN becomes < 1? it is handled in play_Cell() */ |
6 | 1014 link_values = play_Cell(vm); |
0 | 1015 break; |
1016 | |
1017 case LinkTopPG: | |
1018 /* Link to Top Program */ | |
9 | 1019 /* BUTTON number:data1 */ |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
1020 fprintf(stderr, "libdvdnav: FIXME: LinkTopPG. What is LinkTopPG?\n"); |
0 | 1021 if(link_values.data1 != 0) |
6 | 1022 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
0 | 1023 /* Does pgN always contain the current value? */ |
6 | 1024 link_values = play_PG(vm); |
0 | 1025 break; |
1026 case LinkNextPG: | |
1027 /* Link to Next Program */ | |
9 | 1028 /* BUTTON number:data1 */ |
0 | 1029 if(link_values.data1 != 0) |
6 | 1030 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
0 | 1031 /* Does pgN always contain the current value? */ |
6 | 1032 (vm->state).pgN += 1; /* FIXME: What if pgN becomes > pgc.nr_of_programs? */ |
1033 link_values = play_PG(vm); | |
0 | 1034 break; |
1035 case LinkPrevPG: | |
1036 /* Link to Previous Program */ | |
9 | 1037 /* BUTTON number:data1 */ |
0 | 1038 if(link_values.data1 != 0) |
6 | 1039 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
0 | 1040 /* Does pgN always contain the current value? */ |
9 | 1041 assert((vm->state).pgN > 1); |
6 | 1042 (vm->state).pgN -= 1; /* FIXME: What if pgN becomes < 1? */ |
1043 link_values = play_PG(vm); | |
0 | 1044 break; |
1045 | |
1046 case LinkTopPGC: | |
1047 /* Link to Top Program Chain */ | |
9 | 1048 /* BUTTON number:data1 */ |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
1049 fprintf(stderr, "libdvdnav: FIXME: LinkTopPGC. What is LinkTopPGC?\n"); |
0 | 1050 if(link_values.data1 != 0) |
6 | 1051 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
1052 link_values = play_PGC(vm); | |
0 | 1053 break; |
1054 case LinkNextPGC: | |
1055 /* Link to Next Program Chain */ | |
9 | 1056 /* BUTTON number:data1 */ |
0 | 1057 if(link_values.data1 != 0) |
6 | 1058 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
1059 assert((vm->state).pgc->next_pgc_nr != 0); | |
1060 if(get_PGC(vm, (vm->state).pgc->next_pgc_nr)) | |
0 | 1061 assert(0); |
6 | 1062 link_values = play_PGC(vm); |
0 | 1063 break; |
1064 case LinkPrevPGC: | |
1065 /* Link to Previous Program Chain */ | |
9 | 1066 /* BUTTON number:data1 */ |
0 | 1067 if(link_values.data1 != 0) |
6 | 1068 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
1069 assert((vm->state).pgc->prev_pgc_nr != 0); | |
1070 if(get_PGC(vm, (vm->state).pgc->prev_pgc_nr)) | |
0 | 1071 assert(0); |
6 | 1072 link_values = play_PGC(vm); |
0 | 1073 break; |
1074 case LinkGoUpPGC: | |
1075 /* Link to GoUp??? Program Chain */ | |
9 | 1076 /* BUTTON number:data1 */ |
0 | 1077 if(link_values.data1 != 0) |
6 | 1078 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
1079 assert((vm->state).pgc->goup_pgc_nr != 0); | |
1080 if(get_PGC(vm, (vm->state).pgc->goup_pgc_nr)) | |
0 | 1081 assert(0); |
6 | 1082 link_values = play_PGC(vm); |
0 | 1083 break; |
1084 case LinkTailPGC: | |
1085 /* Link to Tail??? Program Chain */ | |
9 | 1086 /* BUTTON number:data1 */ |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
1087 fprintf(stderr, "libdvdnav: FIXME: LinkTailPGC. What is LinkTailPGC?\n"); |
0 | 1088 if(link_values.data1 != 0) |
6 | 1089 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
1090 link_values = play_PGC_post(vm); | |
0 | 1091 break; |
1092 | |
1093 case LinkRSM: | |
1094 { | |
1095 /* Link to Resume */ | |
1096 int i; | |
1097 /* Check and see if there is any rsm info!! */ | |
6 | 1098 (vm->state).domain = VTS_DOMAIN; |
1099 ifoOpenNewVTSI(vm, vm->dvd, (vm->state).rsm_vtsN); | |
1100 get_PGC(vm, (vm->state).rsm_pgcN); | |
0 | 1101 |
1102 /* These should never be set in SystemSpace and/or MenuSpace */ | |
6 | 1103 /* (vm->state).TTN_REG = rsm_tt; ?? */ |
1104 /* (vm->state).TT_PGCN_REG = (vm->state).rsm_pgcN; ?? */ | |
0 | 1105 for(i = 0; i < 5; i++) { |
6 | 1106 (vm->state).registers.SPRM[4 + i] = (vm->state).rsm_regs[i]; |
0 | 1107 } |
1108 | |
1109 if(link_values.data1 != 0) | |
6 | 1110 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
0 | 1111 |
6 | 1112 if((vm->state).rsm_cellN == 0) { |
1113 assert((vm->state).cellN); /* Checking if this ever happens */ | |
0 | 1114 /* assert( time/block/vobu is 0 ); */ |
6 | 1115 (vm->state).pgN = 1; |
1116 link_values = play_PG(vm); | |
0 | 1117 } else { |
1118 /* assert( time/block/vobu is _not_ 0 ); */ | |
1119 /* play_Cell_at_time */ | |
6 | 1120 /* (vm->state).pgN = ?? this gets the righ value in play_Cell */ |
1121 (vm->state).cellN = (vm->state).rsm_cellN; | |
0 | 1122 link_values.command = PlayThis; |
6 | 1123 link_values.data1 = (vm->state).rsm_blockN; |
1124 if(set_PGN(vm)) { | |
0 | 1125 /* Were at the end of the PGC, should not happen for a RSM */ |
1126 assert(0); | |
1127 link_values.command = LinkTailPGC; | |
1128 link_values.data1 = 0; /* No button */ | |
1129 } | |
1130 } | |
1131 } | |
1132 break; | |
1133 case LinkPGCN: | |
1134 /* Link to Program Chain Number:data1 */ | |
6 | 1135 if(get_PGC(vm, link_values.data1)) |
0 | 1136 assert(0); |
6 | 1137 link_values = play_PGC(vm); |
0 | 1138 break; |
1139 case LinkPTTN: | |
1140 /* Link to Part of this Title Number:data1 */ | |
9 | 1141 /* BUTTON number:data2 */ |
6 | 1142 assert((vm->state).domain == VTS_DOMAIN); |
0 | 1143 if(link_values.data2 != 0) |
6 | 1144 (vm->state).HL_BTNN_REG = link_values.data2 << 10; |
1145 if(get_VTS_PTT(vm, (vm->state).vtsN, (vm->state).VTS_TTN_REG, link_values.data1) == -1) | |
0 | 1146 assert(0); |
6 | 1147 link_values = play_PG(vm); |
0 | 1148 break; |
1149 case LinkPGN: | |
1150 /* Link to Program Number:data1 */ | |
9 | 1151 /* BUTTON number:data2 */ |
0 | 1152 if(link_values.data2 != 0) |
6 | 1153 (vm->state).HL_BTNN_REG = link_values.data2 << 10; |
0 | 1154 /* Update any other state, PTTN perhaps? */ |
6 | 1155 (vm->state).pgN = link_values.data1; |
1156 link_values = play_PG(vm); | |
0 | 1157 break; |
1158 case LinkCN: | |
1159 /* Link to Cell Number:data1 */ | |
9 | 1160 /* BUTTON number:data2 */ |
0 | 1161 if(link_values.data2 != 0) |
6 | 1162 (vm->state).HL_BTNN_REG = link_values.data2 << 10; |
0 | 1163 /* Update any other state, pgN, PTTN perhaps? */ |
6 | 1164 (vm->state).cellN = link_values.data1; |
1165 link_values = play_Cell(vm); | |
0 | 1166 break; |
1167 | |
1168 case Exit: | |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
1169 fprintf(stderr, "libdvdnav: FIXME:in trouble...Link Exit - CRASHING!!!\n"); |
6 | 1170 assert(0); /* What should we do here?? */ |
0 | 1171 |
1172 case JumpTT: | |
1173 /* Jump to VTS Title Domain */ | |
1174 /* Only allowed from the First Play domain(PGC) */ | |
1175 /* or the Video Manager domain (VMG) */ | |
1176 //fprintf(stderr,"****** JumpTT is Broken, please fix me!!! ****\n"); | |
6 | 1177 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */ |
1178 if(get_TT(vm,link_values.data1) == -1) | |
0 | 1179 assert(0); |
6 | 1180 link_values = play_PGC(vm); |
0 | 1181 break; |
1182 case JumpVTS_TT: | |
1183 /* Jump to Title:data1 in same VTS Title Domain */ | |
1184 /* Only allowed from the VTS Menu Domain(VTSM) */ | |
1185 /* or the Video Title Set Domain(VTS) */ | |
6 | 1186 assert((vm->state).domain == VTSM_DOMAIN || (vm->state).domain == VTS_DOMAIN); /* ?? */ |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
1187 fprintf(stderr, "libdvdnav: FIXME: Should be able to use get_VTS_PTT here.\n"); |
6 | 1188 if(get_VTS_TT(vm,(vm->state).vtsN, link_values.data1) == -1) |
0 | 1189 assert(0); |
6 | 1190 link_values = play_PGC(vm); |
0 | 1191 break; |
1192 case JumpVTS_PTT: | |
1193 /* Jump to Part:data2 of Title:data1 in same VTS Title Domain */ | |
1194 /* Only allowed from the VTS Menu Domain(VTSM) */ | |
1195 /* or the Video Title Set Domain(VTS) */ | |
6 | 1196 assert((vm->state).domain == VTSM_DOMAIN || (vm->state).domain == VTS_DOMAIN); /* ?? */ |
1197 if(get_VTS_PTT(vm,(vm->state).vtsN, link_values.data1, link_values.data2) == -1) | |
0 | 1198 assert(0); |
6 | 1199 link_values = play_PG(vm); |
0 | 1200 break; |
1201 | |
1202 case JumpSS_FP: | |
1203 /* Jump to First Play Domain */ | |
1204 /* Only allowed from the VTS Menu Domain(VTSM) */ | |
1205 /* or the Video Manager domain (VMG) */ | |
6 | 1206 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == VTSM_DOMAIN); /* ?? */ |
1207 get_FP_PGC(vm); | |
1208 link_values = play_PGC(vm); | |
0 | 1209 break; |
1210 case JumpSS_VMGM_MENU: | |
1211 /* Jump to Video Manger domain - Title Menu:data1 or any PGC in VMG */ | |
1212 /* Allowed from anywhere except the VTS Title domain */ | |
6 | 1213 assert((vm->state).domain == VMGM_DOMAIN || |
1214 (vm->state).domain == VTSM_DOMAIN || | |
1215 (vm->state).domain == FP_DOMAIN); /* ?? */ | |
1216 (vm->state).domain = VMGM_DOMAIN; | |
1217 if(get_MENU(vm,link_values.data1) == -1) | |
0 | 1218 assert(0); |
6 | 1219 link_values = play_PGC(vm); |
0 | 1220 break; |
1221 case JumpSS_VTSM: | |
1222 /* Jump to a menu in Video Title domain, */ | |
1223 /* or to a Menu is the current VTS */ | |
1224 /* FIXME: This goes badly wrong for some DVDs. */ | |
1225 /* FIXME: Keep in touch with ogle people regarding what to do here */ | |
9 | 1226 /* ifoOpenNewVTSI:data1 */ |
1227 /* VTS_TTN_REG:data2 */ | |
1228 /* get_MENU:data3 */ | |
0 | 1229 fprintf(stderr, "dvdnav: BUG TRACKING *******************************************************************\n"); |
1230 fprintf(stderr, "dvdnav: If you see this message, please report these values to the dvd-devel mailing list.\n"); | |
1231 fprintf(stderr, " data1=%u data2=%u data3=%u\n", | |
1232 link_values.data1, | |
1233 link_values.data2, | |
1234 link_values.data3); | |
1235 fprintf(stderr, "dvdnav: *******************************************************************\n"); | |
1236 | |
1237 if(link_values.data1 !=0) { | |
6 | 1238 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */ |
1239 (vm->state).domain = VTSM_DOMAIN; | |
1240 ifoOpenNewVTSI(vm, vm->dvd, link_values.data1); /* Also sets (vm->state).vtsN */ | |
0 | 1241 } else { |
1242 /* This happens on 'The Fifth Element' region 2. */ | |
6 | 1243 assert((vm->state).domain == VTSM_DOMAIN); |
0 | 1244 } |
1245 /* I don't know what title is supposed to be used for. */ | |
1246 /* Alien or Aliens has this != 1, I think. */ | |
1247 /* assert(link_values.data2 == 1); */ | |
6 | 1248 (vm->state).VTS_TTN_REG = link_values.data2; |
1249 if(get_MENU(vm, link_values.data3) == -1) | |
0 | 1250 assert(0); |
6 | 1251 link_values = play_PGC(vm); |
0 | 1252 break; |
1253 case JumpSS_VMGM_PGC: | |
9 | 1254 /* get_PGC:data1 */ |
6 | 1255 assert((vm->state).domain == VMGM_DOMAIN || |
1256 (vm->state).domain == VTSM_DOMAIN || | |
1257 (vm->state).domain == FP_DOMAIN); /* ?? */ | |
1258 (vm->state).domain = VMGM_DOMAIN; | |
1259 if(get_PGC(vm,link_values.data1) == -1) | |
0 | 1260 assert(0); |
6 | 1261 link_values = play_PGC(vm); |
0 | 1262 break; |
1263 | |
1264 case CallSS_FP: | |
9 | 1265 /* saveRSMinfo:data1 */ |
6 | 1266 assert((vm->state).domain == VTS_DOMAIN); /* ?? */ |
0 | 1267 /* Must be called before domain is changed */ |
6 | 1268 saveRSMinfo(vm, link_values.data1, /* We dont have block info */ 0); |
1269 get_FP_PGC(vm); | |
1270 link_values = play_PGC(vm); | |
0 | 1271 break; |
1272 case CallSS_VMGM_MENU: | |
9 | 1273 /* get_MENU:data1 */ |
1274 /* saveRSMinfo:data2 */ | |
6 | 1275 assert((vm->state).domain == VTS_DOMAIN); /* ?? */ |
0 | 1276 /* Must be called before domain is changed */ |
6 | 1277 saveRSMinfo(vm,link_values.data2, /* We dont have block info */ 0); |
1278 (vm->state).domain = VMGM_DOMAIN; | |
1279 if(get_MENU(vm,link_values.data1) == -1) | |
0 | 1280 assert(0); |
6 | 1281 link_values = play_PGC(vm); |
0 | 1282 break; |
1283 case CallSS_VTSM: | |
9 | 1284 /* get_MENU:data1 */ |
1285 /* saveRSMinfo:data2 */ | |
6 | 1286 assert((vm->state).domain == VTS_DOMAIN); /* ?? */ |
0 | 1287 /* Must be called before domain is changed */ |
6 | 1288 saveRSMinfo(vm,link_values.data2, /* We dont have block info */ 0); |
1289 (vm->state).domain = VTSM_DOMAIN; | |
1290 if(get_MENU(vm,link_values.data1) == -1) | |
0 | 1291 assert(0); |
6 | 1292 link_values = play_PGC(vm); |
0 | 1293 break; |
1294 case CallSS_VMGM_PGC: | |
9 | 1295 /* get_PGC:data1 */ |
1296 /* saveRSMinfo:data2 */ | |
6 | 1297 assert((vm->state).domain == VTS_DOMAIN); /* ?? */ |
0 | 1298 /* Must be called before domain is changed */ |
6 | 1299 saveRSMinfo(vm,link_values.data2, /* We dont have block info */ 0); |
1300 (vm->state).domain = VMGM_DOMAIN; | |
1301 if(get_PGC(vm,link_values.data1) == -1) | |
0 | 1302 assert(0); |
6 | 1303 link_values = play_PGC(vm); |
0 | 1304 break; |
1305 case PlayThis: | |
1306 /* Should never happen. */ | |
9 | 1307 assert(0); |
0 | 1308 break; |
1309 } | |
1310 fprintf(stderr, "After:"); | |
6 | 1311 vm_print_current_domain_state(vm); |
0 | 1312 |
1313 } | |
6 | 1314 vm->badness_counter--; |
0 | 1315 return link_values; |
1316 } | |
1317 | |
14 | 1318 /* Searches the TT tables, to find the current TT. |
1319 * returns the current TT. | |
1320 * returns 0 if not found. | |
1321 */ | |
1322 static int find_TT(vm_t *vm, int vtsN, int vts_ttn) { | |
1323 int i; | |
1324 int tt=0; | |
1325 for(i = 1; i <= vm->vmgi->tt_srpt->nr_of_srpts; i++) { | |
1326 if( vm->vmgi->tt_srpt->title[i - 1].title_set_nr == vtsN && | |
1327 vm->vmgi->tt_srpt->title[i - 1].vts_ttn == vts_ttn) { | |
1328 tt=i; | |
1329 break; | |
1330 } | |
1331 } | |
1332 return tt; | |
1333 } | |
1334 | |
6 | 1335 static int get_TT(vm_t *vm, int tt) |
0 | 1336 { |
1337 //fprintf(stderr,"****** get_TT is Broken, please fix me!!! ****\n"); | |
6 | 1338 assert(tt <= vm->vmgi->tt_srpt->nr_of_srpts); |
0 | 1339 |
6 | 1340 (vm->state).TTN_REG = tt; |
0 | 1341 |
6 | 1342 return get_VTS_TT(vm, vm->vmgi->tt_srpt->title[tt - 1].title_set_nr, |
1343 vm->vmgi->tt_srpt->title[tt - 1].vts_ttn); | |
0 | 1344 } |
1345 | |
1346 | |
6 | 1347 static int get_VTS_TT(vm_t *vm, int vtsN, int vts_ttn) |
0 | 1348 { |
14 | 1349 fprintf(stderr, "get_VTS_TT called, testing!!! vtsN=%d, vts_ttn=%d\n", vtsN, vts_ttn); |
1350 return get_VTS_PTT(vm, vtsN, vts_ttn, 1); | |
1351 //pgcN = get_ID(vm, vts_ttn); /* This might return -1 */ | |
1352 //assert(pgcN != -1); | |
0 | 1353 |
14 | 1354 //(vm->state).TTN_REG = find_TT(*vm, vtsN, vts_ttn); |
1355 //(vm->state).VTS_TTN_REG = vts_ttn; | |
1356 //(vm->state).vtsN = | |
0 | 1357 /* Any other registers? */ |
1358 | |
14 | 1359 //return get_PGC(vm, pgcN); |
0 | 1360 } |
1361 | |
1362 | |
6 | 1363 static int get_VTS_PTT(vm_t *vm, int vtsN, int /* is this really */ vts_ttn, int part) |
0 | 1364 { |
1365 int pgcN, pgN; | |
1366 | |
6 | 1367 (vm->state).domain = VTS_DOMAIN; |
1368 if(vtsN != (vm->state).vtsN) | |
1369 ifoOpenNewVTSI(vm, vm->dvd, vtsN); /* Also sets (vm->state).vtsN */ | |
0 | 1370 |
6 | 1371 assert(vts_ttn <= vm->vtsi->vts_ptt_srpt->nr_of_srpts); |
1372 assert(part <= vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].nr_of_ptts); | |
0 | 1373 |
6 | 1374 pgcN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgcn; |
1375 pgN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgn; | |
14 | 1376 |
1377 (vm->state).TT_PGCN_REG = pgcN; | |
1378 (vm->state).PTTN_REG = pgN; | |
1379 | |
1380 (vm->state).TTN_REG = find_TT(vm, vtsN, vts_ttn); | |
1381 assert( (vm->state.TTN_REG) != 0 ); | |
6 | 1382 (vm->state).VTS_TTN_REG = vts_ttn; |
14 | 1383 (vm->state).vtsN = vtsN; /* Not sure about this one. We can get to it easily from TTN_REG */ |
0 | 1384 /* Any other registers? */ |
1385 | |
6 | 1386 (vm->state).pgN = pgN; /* ?? */ |
0 | 1387 |
6 | 1388 return get_PGC(vm, pgcN); |
0 | 1389 } |
1390 | |
1391 | |
1392 | |
6 | 1393 static int get_FP_PGC(vm_t *vm) |
0 | 1394 { |
6 | 1395 (vm->state).domain = FP_DOMAIN; |
0 | 1396 |
6 | 1397 (vm->state).pgc = vm->vmgi->first_play_pgc; |
0 | 1398 |
1399 return 0; | |
1400 } | |
1401 | |
1402 | |
6 | 1403 static int get_MENU(vm_t *vm, int menu) |
0 | 1404 { |
6 | 1405 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == VTSM_DOMAIN); |
1406 return get_PGC(vm, get_ID(vm, menu)); | |
0 | 1407 } |
1408 | |
6 | 1409 static int get_ID(vm_t *vm, int id) |
0 | 1410 { |
1411 int pgcN, i; | |
1412 pgcit_t *pgcit; | |
1413 | |
1414 /* Relies on state to get the correct pgcit. */ | |
6 | 1415 pgcit = get_PGCIT(vm); |
0 | 1416 assert(pgcit != NULL); |
1417 | |
1418 /* Get menu/title */ | |
1419 for(i = 0; i < pgcit->nr_of_pgci_srp; i++) { | |
1420 if((pgcit->pgci_srp[i].entry_id & 0x7f) == id) { | |
1421 assert((pgcit->pgci_srp[i].entry_id & 0x80) == 0x80); | |
1422 pgcN = i + 1; | |
1423 return pgcN; | |
1424 } | |
1425 } | |
1426 fprintf(stderr, "** No such id/menu (%d) entry PGC\n", id); | |
1427 return -1; /* error */ | |
1428 } | |
1429 | |
1430 | |
1431 | |
6 | 1432 static int get_PGC(vm_t *vm, int pgcN) |
0 | 1433 { |
1434 /* FIXME: Keep this up to date with the ogle people */ | |
1435 pgcit_t *pgcit; | |
1436 | |
6 | 1437 pgcit = get_PGCIT(vm); |
0 | 1438 |
1439 assert(pgcit != NULL); /* ?? Make this return -1 instead */ | |
1440 if(pgcN < 1 || pgcN > pgcit->nr_of_pgci_srp) { | |
1441 /* if(pgcit->nr_of_pgci_srp != 1) */ | |
1442 return -1; /* error */ | |
1443 /* pgcN = 1; */ | |
1444 } | |
1445 | |
6 | 1446 /* (vm->state).pgcN = pgcN; */ |
1447 (vm->state).pgc = pgcit->pgci_srp[pgcN - 1].pgc; | |
0 | 1448 |
6 | 1449 if((vm->state).domain == VTS_DOMAIN) |
1450 (vm->state).TT_PGCN_REG = pgcN; | |
0 | 1451 |
1452 return 0; | |
1453 } | |
1454 | |
6 | 1455 static int get_PGCN(vm_t *vm) |
0 | 1456 { |
1457 pgcit_t *pgcit; | |
1458 int pgcN = 1; | |
1459 | |
6 | 1460 pgcit = get_PGCIT(vm); |
0 | 1461 |
1462 assert(pgcit != NULL); | |
1463 | |
1464 while(pgcN <= pgcit->nr_of_pgci_srp) { | |
6 | 1465 if(pgcit->pgci_srp[pgcN - 1].pgc == (vm->state).pgc) |
0 | 1466 return pgcN; |
1467 pgcN++; | |
1468 } | |
1469 | |
1470 return -1; /* error */ | |
1471 } | |
1472 | |
6 | 1473 static int get_video_aspect(vm_t *vm) |
0 | 1474 { |
1475 int aspect = 0; | |
1476 | |
6 | 1477 if((vm->state).domain == VTS_DOMAIN) { |
1478 aspect = vm->vtsi->vtsi_mat->vts_video_attr.display_aspect_ratio; | |
1479 } else if((vm->state).domain == VTSM_DOMAIN) { | |
1480 aspect = vm->vtsi->vtsi_mat->vtsm_video_attr.display_aspect_ratio; | |
1481 } else if((vm->state).domain == VMGM_DOMAIN) { | |
1482 aspect = vm->vmgi->vmgi_mat->vmgm_video_attr.display_aspect_ratio; | |
0 | 1483 } |
1484 fprintf(stderr, "dvdnav:get_video_aspect:aspect=%d\n",aspect); | |
1485 assert(aspect == 0 || aspect == 3); | |
6 | 1486 (vm->state).registers.SPRM[14] &= ~(0x3 << 10); |
1487 (vm->state).registers.SPRM[14] |= aspect << 10; | |
0 | 1488 |
1489 return aspect; | |
1490 } | |
1491 | |
6 | 1492 static void ifoOpenNewVTSI(vm_t *vm, dvd_reader_t *dvd, int vtsN) |
0 | 1493 { |
6 | 1494 if((vm->state).vtsN == vtsN) { |
0 | 1495 return; /* We alread have it */ |
1496 } | |
1497 | |
6 | 1498 if(vm->vtsi != NULL) |
1499 ifoClose(vm->vtsi); | |
0 | 1500 |
6 | 1501 vm->vtsi = ifoOpenVTSI(dvd, vtsN); |
1502 if(vm->vtsi == NULL) { | |
1503 fprintf(stderr, "ifoOpenVTSI failed - CRASHING!!!\n"); | |
1504 assert(0); | |
0 | 1505 } |
6 | 1506 if(!ifoRead_VTS_PTT_SRPT(vm->vtsi)) { |
1507 fprintf(stderr, "ifoRead_VTS_PTT_SRPT failed - CRASHING!!!\n"); | |
1508 assert(0); | |
0 | 1509 } |
6 | 1510 if(!ifoRead_PGCIT(vm->vtsi)) { |
1511 fprintf(stderr, "ifoRead_PGCIT failed - CRASHING!!!\n"); | |
1512 assert(0); | |
0 | 1513 } |
6 | 1514 if(!ifoRead_PGCI_UT(vm->vtsi)) { |
1515 fprintf(stderr, "ifoRead_PGCI_UT failed - CRASHING!!!\n"); | |
1516 assert(0); | |
0 | 1517 } |
6 | 1518 if(!ifoRead_VOBU_ADMAP(vm->vtsi)) { |
1519 fprintf(stderr, "ifoRead_VOBU_ADMAP vtsi failed - CRASHING\n"); | |
1520 assert(0); | |
0 | 1521 } |
6 | 1522 if(!ifoRead_TITLE_VOBU_ADMAP(vm->vtsi)) { |
1523 fprintf(stderr, "ifoRead_TITLE_VOBU_ADMAP vtsi failed - CRASHING\n"); | |
1524 assert(0); | |
0 | 1525 } |
6 | 1526 (vm->state).vtsN = vtsN; |
0 | 1527 } |
1528 | |
6 | 1529 static pgcit_t* get_MENU_PGCIT(vm_t *vm, ifo_handle_t *h, uint16_t lang) |
0 | 1530 { |
1531 int i; | |
1532 | |
1533 if(h == NULL || h->pgci_ut == NULL) { | |
1534 fprintf(stderr, "*** pgci_ut handle is NULL ***\n"); | |
1535 return NULL; /* error? */ | |
1536 } | |
1537 | |
1538 i = 0; | |
1539 while(i < h->pgci_ut->nr_of_lus | |
1540 && h->pgci_ut->lu[i].lang_code != lang) | |
1541 i++; | |
1542 if(i == h->pgci_ut->nr_of_lus) { | |
1543 fprintf(stderr, "Language '%c%c' not found, using '%c%c' instead\n", | |
1544 (char)(lang >> 8), (char)(lang & 0xff), | |
1545 (char)(h->pgci_ut->lu[0].lang_code >> 8), | |
1546 (char)(h->pgci_ut->lu[0].lang_code & 0xff)); | |
1547 i = 0; /* error? */ | |
1548 } | |
1549 | |
1550 return h->pgci_ut->lu[i].pgcit; | |
1551 } | |
1552 | |
1553 /* Uses state to decide what to return */ | |
6 | 1554 static pgcit_t* get_PGCIT(vm_t *vm) { |
0 | 1555 pgcit_t *pgcit; |
1556 | |
6 | 1557 if((vm->state).domain == VTS_DOMAIN) { |
1558 pgcit = vm->vtsi->vts_pgcit; | |
1559 } else if((vm->state).domain == VTSM_DOMAIN) { | |
1560 pgcit = get_MENU_PGCIT(vm, vm->vtsi, (vm->state).registers.SPRM[0]); | |
1561 } else if((vm->state).domain == VMGM_DOMAIN) { | |
1562 pgcit = get_MENU_PGCIT(vm, vm->vmgi, (vm->state).registers.SPRM[0]); | |
0 | 1563 } else { |
1564 pgcit = NULL; /* Should never hapen */ | |
1565 } | |
1566 | |
1567 return pgcit; | |
1568 } | |
1569 | |
1570 /* | |
1571 * $Log$ | |
14 | 1572 * Revision 1.7 2002/04/10 13:09:40 jcdutton |
1573 * Some improvements to decoder.c | |
1574 * Registers should be updated correctly now, but still needs checking. | |
1575 * | |
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
1576 * Revision 1.6 2002/04/09 15:19:07 jcdutton |
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
1577 * Added some debug info, to hopefully help in tracking bugs in libdvdnav. |
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
1578 * |
9 | 1579 * Revision 1.5 2002/04/07 19:35:54 jcdutton |
1580 * Added some comments into the code. | |
1581 * | |
6 | 1582 * Revision 1.4 2002/04/06 18:31:50 jcdutton |
1583 * Some cleaning up. | |
1584 * changed exit(1) to assert(0) so they actually get seen by the user so that it helps developers more. | |
1585 * | |
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
1586 * Revision 1.3 2002/04/02 18:22:27 richwareham |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
1587 * Added reset patch from Kees Cook <kees@outflux.net> |
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
1588 * |
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
1589 * Revision 1.2 2002/04/01 18:56:28 richwareham |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
1590 * Added initial example programs directory and make sure all debug/error output goes to stderr. |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
1591 * |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
1592 * Revision 1.1.1.1 2002/03/12 19:45:55 richwareham |
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
1593 * Initial import |
0 | 1594 * |
1595 * Revision 1.18 2002/01/22 16:56:49 jcdutton | |
1596 * Fix clut after seeking. | |
6 | 1597 * Add a few virtual machine debug messages, to help diagnose problems with "Deep Purple - Total Abandon" DVD as I don't have the DVD itvm. |
0 | 1598 * Fix a few debug messages, so they do not say FIXME. |
1599 * Move the FIXME debug messages to comments in the code. | |
1600 * | |
1601 * Revision 1.17 2002/01/21 01:16:30 jcdutton | |
1602 * Added some debug messages, to hopefully get info from users. | |
1603 * | |
1604 * Revision 1.16 2002/01/20 21:40:46 jcdutton | |
1605 * Start to fix some assert failures. | |
1606 * | |
1607 * Revision 1.15 2002/01/19 20:24:38 jcdutton | |
1608 * Just some FIXME notes added. | |
1609 * | |
1610 * Revision 1.14 2002/01/13 22:17:57 jcdutton | |
1611 * Change logging. | |
1612 * | |
1613 * | |
1614 */ |