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