annotate vm/vm.c @ 0:427b7da5cbdb src

first split of dvdread; it's just a copy of dvdnav still to be cleaned
author nicodvb
date Sun, 01 Jun 2008 08:39:07 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1 /*
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
2 * Copyright (C) 2000, 2001 Håkan Hjort
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
3 * Copyright (C) 2001 Rich Wareham <richwareham@users.sourceforge.net>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
4 * 2002-2004 the dvdnav project
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
5 *
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
6 * This file is part of libdvdnav, a DVD navigation library. It is modified
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
7 * from a file originally part of the Ogle DVD player.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
8 *
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
9 * libdvdnav is free software; you can redistribute it and/or modify
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
12 * (at your option) any later version.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
13 *
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
14 * libdvdnav is distributed in the hope that it will be useful,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
17 * GNU General Public License for more details.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
18 *
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
22 *
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
23 * $Id$
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
24 *
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
25 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
26
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
27 #ifdef HAVE_CONFIG_H
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
28 #include "config.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
29 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
30
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
31 #include <stdio.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
32 #include <string.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
33 #include <stdlib.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
34 #include <unistd.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
35 #include <inttypes.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
36 #include <limits.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
37 #include <assert.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
38 #include <sys/types.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
39 #include <sys/stat.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
40 #include <sys/time.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
41 #include <fcntl.h>
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
42
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
43 #include "nav_types.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
44 #include "ifo_types.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
45 #include "ifo_read.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
46 #include "dvd_types.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
47
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
48 #include "decoder.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
49 #include "remap.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
50 #include "vm.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
51 #include "dvdnav.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
52 #include "dvdnav_internal.h"
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
53
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
54 #ifdef _MSC_VER
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
55 #include <io.h> /* read() */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
56 #endif /* _MSC_VER */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
57
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
58 /*
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
59 #define STRICT
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
60 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
61
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
62 /* Local prototypes */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
63
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
64 /* get_XYZ returns a value.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
65 * set_XYZ sets state using passed parameters.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
66 * returns success/failure.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
67 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
68
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
69 /* Play */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
70 static link_t play_PGC(vm_t *vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
71 static link_t play_PGC_PG(vm_t *vm, int pgN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
72 static link_t play_PGC_post(vm_t *vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
73 static link_t play_PG(vm_t *vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
74 static link_t play_Cell(vm_t *vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
75 static link_t play_Cell_post(vm_t *vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
76
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
77 /* Process link - returns 1 if a hop has been performed */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
78 static int process_command(vm_t *vm,link_t link_values);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
79
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
80 /* Set */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
81 static int set_TT(vm_t *vm, int tt);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
82 static int set_PTT(vm_t *vm, int tt, int ptt);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
83 static int set_VTS_TT(vm_t *vm, int vtsN, int vts_ttn);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
84 static int set_VTS_PTT(vm_t *vm, int vtsN, int vts_ttn, int part);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
85 static int set_FP_PGC(vm_t *vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
86 static int set_MENU(vm_t *vm, int menu);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
87 static int set_PGCN(vm_t *vm, int pgcN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
88 static int set_PGN(vm_t *vm); /* Set PGN based on (vm->state).CellN */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
89 static void set_RSMinfo(vm_t *vm, int cellN, int blockN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
90
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
91 /* Get */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
92 static int get_TT(vm_t *vm, int vtsN, int vts_ttn);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
93 static int get_ID(vm_t *vm, int id);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
94 static int get_PGCN(vm_t *vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
95
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
96 static pgcit_t* get_MENU_PGCIT(vm_t *vm, ifo_handle_t *h, uint16_t lang);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
97 static pgcit_t* get_PGCIT(vm_t *vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
98
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
99
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
100 /* Helper functions */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
101
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
102 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
103 static void vm_print_current_domain_state(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
104 switch((vm->state).domain) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
105 case VTS_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
106 fprintf(MSG_OUT, "libdvdnav: Video Title Domain: -\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
107 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
108
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
109 case VTSM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
110 fprintf(MSG_OUT, "libdvdnav: Video Title Menu Domain: -\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
111 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
112
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
113 case VMGM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
114 fprintf(MSG_OUT, "libdvdnav: Video Manager Menu Domain: -\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
115 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
116
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
117 case FP_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
118 fprintf(MSG_OUT, "libdvdnav: First Play Domain: -\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
119 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
120
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
121 default:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
122 fprintf(MSG_OUT, "libdvdnav: Unknown Domain: -\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
123 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
124 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
125 fprintf(MSG_OUT, "libdvdnav: VTS:%d PGC:%d PG:%u CELL:%u BLOCK:%u VTS_TTN:%u TTN:%u TT_PGCN:%u\n",
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
126 (vm->state).vtsN,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
127 get_PGCN(vm),
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
128 (vm->state).pgN,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
129 (vm->state).cellN,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
130 (vm->state).blockN,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
131 (vm->state).VTS_TTN_REG,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
132 (vm->state).TTN_REG,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
133 (vm->state).TT_PGCN_REG);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
134 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
135 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
136
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
137 static void dvd_read_name(char *name, const char *device) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
138 /* Because we are compiling with _FILE_OFFSET_BITS=64
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
139 * all off_t are 64bit.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
140 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
141 off_t off;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
142 int fd, i;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
143 uint8_t data[DVD_VIDEO_LB_LEN];
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
144
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
145 /* Read DVD name */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
146 fd = open(device, O_RDONLY);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
147 if (fd > 0) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
148 off = lseek( fd, 32 * (off_t) DVD_VIDEO_LB_LEN, SEEK_SET );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
149 if( off == ( 32 * (off_t) DVD_VIDEO_LB_LEN ) ) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
150 off = read( fd, data, DVD_VIDEO_LB_LEN );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
151 close(fd);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
152 if (off == ( (off_t) DVD_VIDEO_LB_LEN )) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
153 fprintf(MSG_OUT, "libdvdnav: DVD Title: ");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
154 for(i=25; i < 73; i++ ) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
155 if((data[i] == 0)) break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
156 if((data[i] > 32) && (data[i] < 127)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
157 fprintf(MSG_OUT, "%c", data[i]);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
158 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
159 fprintf(MSG_OUT, " ");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
160 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
161 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
162 strncpy(name, &data[25], 48);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
163 name[48] = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
164 fprintf(MSG_OUT, "\nlibdvdnav: DVD Serial Number: ");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
165 for(i=73; i < 89; i++ ) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
166 if((data[i] == 0)) break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
167 if((data[i] > 32) && (data[i] < 127)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
168 fprintf(MSG_OUT, "%c", data[i]);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
169 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
170 fprintf(MSG_OUT, " ");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
171 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
172 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
173 fprintf(MSG_OUT, "\nlibdvdnav: DVD Title (Alternative): ");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
174 for(i=89; i < 128; i++ ) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
175 if((data[i] == 0)) break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
176 if((data[i] > 32) && (data[i] < 127)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
177 fprintf(MSG_OUT, "%c", data[i]);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
178 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
179 fprintf(MSG_OUT, " ");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
180 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
181 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
182 fprintf(MSG_OUT, "\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
183 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
184 fprintf(MSG_OUT, "libdvdnav: Can't read name block. Probably not a DVD-ROM device.\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
185 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
186 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
187 fprintf(MSG_OUT, "libdvdnav: Can't seek to block %u\n", 32 );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
188 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
189 close(fd);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
190 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
191 fprintf(MSG_OUT, "NAME OPEN FAILED\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
192 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
193 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
194
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
195 static int ifoOpenNewVTSI(vm_t *vm, dvd_reader_t *dvd, int vtsN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
196 if((vm->state).vtsN == vtsN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
197 return 1; /* We alread have it */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
198 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
199
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
200 if(vm->vtsi != NULL)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
201 ifoClose(vm->vtsi);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
202
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
203 vm->vtsi = ifoOpenVTSI(dvd, vtsN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
204 if(vm->vtsi == NULL) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
205 fprintf(MSG_OUT, "libdvdnav: ifoOpenVTSI failed\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
206 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
207 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
208 if(!ifoRead_VTS_PTT_SRPT(vm->vtsi)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
209 fprintf(MSG_OUT, "libdvdnav: ifoRead_VTS_PTT_SRPT failed\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
210 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
211 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
212 if(!ifoRead_PGCIT(vm->vtsi)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
213 fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCIT failed\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
214 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
215 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
216 if(!ifoRead_PGCI_UT(vm->vtsi)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
217 fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCI_UT failed\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
218 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
219 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
220 if(!ifoRead_VOBU_ADMAP(vm->vtsi)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
221 fprintf(MSG_OUT, "libdvdnav: ifoRead_VOBU_ADMAP vtsi failed\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
222 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
223 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
224 if(!ifoRead_TITLE_VOBU_ADMAP(vm->vtsi)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
225 fprintf(MSG_OUT, "libdvdnav: ifoRead_TITLE_VOBU_ADMAP vtsi failed\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
226 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
227 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
228 (vm->state).vtsN = vtsN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
229
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
230 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
231 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
232
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
233
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
234 /* Initialisation & Destruction */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
235
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
236 vm_t* vm_new_vm() {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
237 return (vm_t*)calloc(sizeof(vm_t), sizeof(char));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
238 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
239
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
240 void vm_free_vm(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
241 vm_stop(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
242 free(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
243 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
244
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
245
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
246 /* IFO Access */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
247
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
248 ifo_handle_t *vm_get_vmgi(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
249 return vm->vmgi;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
250 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
251
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
252 ifo_handle_t *vm_get_vtsi(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
253 return vm->vtsi;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
254 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
255
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
256
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
257 /* Reader Access */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
258
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
259 dvd_reader_t *vm_get_dvd_reader(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
260 return vm->dvd;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
261 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
262
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
263
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
264 /* Basic Handling */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
265
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
266 int vm_start(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
267 /* Set pgc to FP (First Play) pgc */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
268 set_FP_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
269 process_command(vm, play_PGC(vm));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
270 return !vm->stopped;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
271 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
272
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
273 void vm_stop(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
274 if(vm->vmgi) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
275 ifoClose(vm->vmgi);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
276 vm->vmgi=NULL;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
277 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
278 if(vm->vtsi) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
279 ifoClose(vm->vtsi);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
280 vm->vtsi=NULL;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
281 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
282 if(vm->dvd) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
283 DVDClose(vm->dvd);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
284 vm->dvd=NULL;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
285 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
286 vm->stopped = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
287 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
288
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
289 int vm_reset(vm_t *vm, const char *dvdroot) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
290 /* Setup State */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
291 memset((vm->state).registers.SPRM, 0, sizeof((vm->state).registers.SPRM));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
292 memset((vm->state).registers.GPRM, 0, sizeof((vm->state).registers.GPRM));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
293 memset((vm->state).registers.GPRM_mode, 0, sizeof((vm->state).registers.GPRM_mode));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
294 memset((vm->state).registers.GPRM_mode, 0, sizeof((vm->state).registers.GPRM_mode));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
295 memset((vm->state).registers.GPRM_time, 0, sizeof((vm->state).registers.GPRM_time));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
296 (vm->state).registers.SPRM[0] = ('e'<<8)|'n'; /* Player Menu Languange code */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
297 (vm->state).AST_REG = 15; /* 15 why? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
298 (vm->state).SPST_REG = 62; /* 62 why? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
299 (vm->state).AGL_REG = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
300 (vm->state).TTN_REG = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
301 (vm->state).VTS_TTN_REG = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
302 /* (vm->state).TT_PGCN_REG = 0 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
303 (vm->state).PTTN_REG = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
304 (vm->state).HL_BTNN_REG = 1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
305 (vm->state).PTL_REG = 15; /* Parental Level */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
306 (vm->state).registers.SPRM[12] = ('U'<<8)|'S'; /* Parental Management Country Code */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
307 (vm->state).registers.SPRM[16] = ('e'<<8)|'n'; /* Initial Language Code for Audio */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
308 (vm->state).registers.SPRM[18] = ('e'<<8)|'n'; /* Initial Language Code for Spu */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
309 (vm->state).registers.SPRM[20] = 0x1; /* Player Regional Code Mask. Region free! */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
310 (vm->state).registers.SPRM[14] = 0x100; /* Try Pan&Scan */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
311
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
312 (vm->state).pgN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
313 (vm->state).cellN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
314 (vm->state).cell_restart = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
315
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
316 (vm->state).domain = FP_DOMAIN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
317 (vm->state).rsm_vtsN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
318 (vm->state).rsm_cellN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
319 (vm->state).rsm_blockN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
320
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
321 (vm->state).vtsN = -1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
322
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
323 if (vm->dvd && dvdroot) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
324 /* a new dvd device has been requested */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
325 vm_stop(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
326 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
327 if (!vm->dvd) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
328 vm->dvd = DVDOpen(dvdroot);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
329 if(!vm->dvd) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
330 fprintf(MSG_OUT, "libdvdnav: vm: failed to open/read the DVD\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
331 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
332 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
333 dvd_read_name(vm->dvd_name, dvdroot);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
334 vm->map = remap_loadmap(vm->dvd_name);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
335 vm->vmgi = ifoOpenVMGI(vm->dvd);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
336 if(!vm->vmgi) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
337 fprintf(MSG_OUT, "libdvdnav: vm: failed to read VIDEO_TS.IFO\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
338 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
339 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
340 if(!ifoRead_FP_PGC(vm->vmgi)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
341 fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_FP_PGC failed\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
342 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
343 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
344 if(!ifoRead_TT_SRPT(vm->vmgi)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
345 fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_TT_SRPT failed\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
346 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
347 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
348 if(!ifoRead_PGCI_UT(vm->vmgi)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
349 fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_PGCI_UT failed\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
350 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
351 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
352 if(!ifoRead_PTL_MAIT(vm->vmgi)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
353 fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_PTL_MAIT failed\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
354 /* return 0; Not really used for now.. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
355 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
356 if(!ifoRead_VTS_ATRT(vm->vmgi)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
357 fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_VTS_ATRT failed\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
358 /* return 0; Not really used for now.. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
359 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
360 if(!ifoRead_VOBU_ADMAP(vm->vmgi)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
361 fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_VOBU_ADMAP vgmi failed\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
362 /* return 0; Not really used for now.. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
363 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
364 /* ifoRead_TXTDT_MGI(vmgi); Not implemented yet */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
365 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
366 if (vm->vmgi) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
367 int i, mask;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
368 fprintf(MSG_OUT, "libdvdnav: DVD disk reports itself with Region mask 0x%08x. Regions:",
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
369 vm->vmgi->vmgi_mat->vmg_category);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
370 for (i = 1, mask = 1; i <= 8; i++, mask <<= 1)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
371 if (((vm->vmgi->vmgi_mat->vmg_category >> 16) & mask) == 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
372 fprintf(MSG_OUT, " %d", i);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
373 fprintf(MSG_OUT, "\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
374 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
375 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
376 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
377
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
378
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
379 /* copying and merging */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
380
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
381 vm_t *vm_new_copy(vm_t *source) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
382 vm_t *target = vm_new_vm();
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
383 int vtsN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
384 int pgcN = get_PGCN(source);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
385 int pgN = (source->state).pgN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
386
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
387 assert(pgcN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
388
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
389 memcpy(target, source, sizeof(vm_t));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
390
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
391 /* open a new vtsi handle, because the copy might switch to another VTS */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
392 target->vtsi = NULL;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
393 vtsN = (target->state).vtsN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
394 if (vtsN > 0) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
395 (target->state).vtsN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
396 if (!ifoOpenNewVTSI(target, target->dvd, vtsN))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
397 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
398
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
399 /* restore pgc pointer into the new vtsi */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
400 if (!set_PGCN(target, pgcN))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
401 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
402 (target->state).pgN = pgN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
403 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
404
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
405 return target;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
406 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
407
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
408 void vm_merge(vm_t *target, vm_t *source) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
409 if(target->vtsi)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
410 ifoClose(target->vtsi);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
411 memcpy(target, source, sizeof(vm_t));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
412 memset(source, 0, sizeof(vm_t));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
413 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
414
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
415 void vm_free_copy(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
416 if(vm->vtsi)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
417 ifoClose(vm->vtsi);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
418 free(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
419 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
420
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
421
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
422 /* regular playback */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
423
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
424 void vm_position_get(vm_t *vm, vm_position_t *position) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
425 position->button = (vm->state).HL_BTNN_REG >> 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
426 position->vts = (vm->state).vtsN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
427 position->domain = (vm->state).domain;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
428 position->spu_channel = (vm->state).SPST_REG;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
429 position->audio_channel = (vm->state).AST_REG;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
430 position->angle_channel = (vm->state).AGL_REG;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
431 position->hop_channel = vm->hop_channel; /* Increases by one on each hop */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
432 position->cell = (vm->state).cellN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
433 position->cell_restart = (vm->state).cell_restart;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
434 position->cell_start = (vm->state).pgc->cell_playback[(vm->state).cellN - 1].first_sector;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
435 position->still = (vm->state).pgc->cell_playback[(vm->state).cellN - 1].still_time;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
436 position->block = (vm->state).blockN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
437
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
438 /* handle PGC stills at PGC end */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
439 if ((vm->state).cellN == (vm->state).pgc->nr_of_cells)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
440 position->still += (vm->state).pgc->still_time;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
441 /* still already determined */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
442 if (position->still)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
443 return;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
444 /* This is a rough fix for some strange still situations on some strange DVDs.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
445 * There are discs (like the German "Back to the Future" RC2) where the only
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
446 * indication of a still is a cell playback time higher than the time the frames
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
447 * in this cell actually take to play (like 1 frame with 1 minute playback time).
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
448 * On the said BTTF disc, for these cells last_sector and last_vobu_start_sector
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
449 * are equal and the cells are very short, so we abuse these conditions to
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
450 * detect such discs. I consider these discs broken, so the fix is somewhat
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
451 * broken, too. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
452 if (((vm->state).pgc->cell_playback[(vm->state).cellN - 1].last_sector ==
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
453 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].last_vobu_start_sector) &&
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
454 ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].last_sector -
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
455 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].first_sector < 1024)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
456 int time;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
457 int size = (vm->state).pgc->cell_playback[(vm->state).cellN - 1].last_sector -
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
458 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].first_sector;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
459 time = ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].playback_time.hour >> 4 ) * 36000;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
460 time += ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].playback_time.hour & 0x0f) * 3600;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
461 time += ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].playback_time.minute >> 4 ) * 600;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
462 time += ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].playback_time.minute & 0x0f) * 60;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
463 time += ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].playback_time.second >> 4 ) * 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
464 time += ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].playback_time.second & 0x0f) * 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
465 if (!time || size / time > 30)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
466 /* datarate is too high, it might be a very short, but regular cell */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
467 return;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
468 if (time > 0xff) time = 0xff;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
469 position->still = time;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
470 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
471 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
472
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
473 void vm_get_next_cell(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
474 process_command(vm, play_Cell_post(vm));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
475 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
476
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
477
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
478 /* Jumping */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
479
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
480 int vm_jump_pg(vm_t *vm, int pg) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
481 (vm->state).pgN = pg;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
482 process_command(vm, play_PG(vm));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
483 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
484 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
485
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
486 int vm_jump_cell_block(vm_t *vm, int cell, int block) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
487 (vm->state).cellN = cell;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
488 process_command(vm, play_Cell(vm));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
489 /* play_Cell can jump to a different cell in case of angles */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
490 if ((vm->state).cellN == cell)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
491 (vm->state).blockN = block;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
492 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
493 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
494
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
495 int vm_jump_title_part(vm_t *vm, int title, int part) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
496 link_t link;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
497
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
498 if(!set_PTT(vm, title, part))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
499 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
500 /* Some DVDs do not want us to jump directly into a title and have
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
501 * PGC pre commands taking us back to some menu. Since we do not like that,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
502 * we do not execute PGC pre commands that would do a jump. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
503 /* process_command(vm, play_PGC_PG(vm, (vm->state).pgN)); */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
504 link = play_PGC_PG(vm, (vm->state).pgN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
505 if (link.command != PlayThis)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
506 /* jump occured -> ignore it and play the PG anyway */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
507 process_command(vm, play_PG(vm));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
508 else
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
509 process_command(vm, link);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
510 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
511 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
512
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
513 int vm_jump_top_pg(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
514 process_command(vm, play_PG(vm));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
515 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
516 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
517
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
518 int vm_jump_next_pg(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
519 if((vm->state).pgN >= (vm->state).pgc->nr_of_programs) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
520 /* last program -> move to TailPGC */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
521 process_command(vm, play_PGC_post(vm));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
522 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
523 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
524 vm_jump_pg(vm, (vm->state).pgN + 1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
525 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
526 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
527 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
528
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
529 int vm_jump_prev_pg(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
530 if ((vm->state).pgN <= 1) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
531 /* first program -> move to last program of previous PGC */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
532 if ((vm->state).pgc->prev_pgc_nr && set_PGCN(vm, (vm->state).pgc->prev_pgc_nr)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
533 process_command(vm, play_PGC(vm));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
534 vm_jump_pg(vm, (vm->state).pgc->nr_of_programs);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
535 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
536 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
537 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
538 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
539 vm_jump_pg(vm, (vm->state).pgN - 1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
540 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
541 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
542 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
543
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
544 int vm_jump_up(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
545 if((vm->state).pgc->goup_pgc_nr && set_PGCN(vm, (vm->state).pgc->goup_pgc_nr)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
546 process_command(vm, play_PGC(vm));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
547 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
548 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
549 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
550 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
551
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
552 int vm_jump_menu(vm_t *vm, DVDMenuID_t menuid) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
553 domain_t old_domain = (vm->state).domain;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
554
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
555 switch ((vm->state).domain) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
556 case VTS_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
557 set_RSMinfo(vm, 0, (vm->state).blockN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
558 /* FALL THROUGH */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
559 case VTSM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
560 case VMGM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
561 switch(menuid) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
562 case DVD_MENU_Title:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
563 case DVD_MENU_Escape:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
564 (vm->state).domain = VMGM_DOMAIN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
565 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
566 case DVD_MENU_Root:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
567 case DVD_MENU_Subpicture:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
568 case DVD_MENU_Audio:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
569 case DVD_MENU_Angle:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
570 case DVD_MENU_Part:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
571 (vm->state).domain = VTSM_DOMAIN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
572 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
573 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
574 if(get_PGCIT(vm) && set_MENU(vm, menuid)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
575 process_command(vm, play_PGC(vm));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
576 return 1; /* Jump */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
577 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
578 (vm->state).domain = old_domain;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
579 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
580 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
581 case FP_DOMAIN: /* FIXME XXX $$$ What should we do here? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
582 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
583 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
584
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
585 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
586 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
587
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
588 int vm_jump_resume(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
589 link_t link_values = { LinkRSM, 0, 0, 0 };
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
590
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
591 if (!(vm->state).rsm_vtsN) /* Do we have resume info? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
592 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
593 if (!process_command(vm, link_values))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
594 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
595 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
596 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
597
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
598 int vm_exec_cmd(vm_t *vm, vm_cmd_t *cmd) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
599 link_t link_values;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
600
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
601 if(vmEval_CMD(cmd, 1, &(vm->state).registers, &link_values))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
602 return process_command(vm, link_values);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
603 else
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
604 return 0; /* It updated some state thats all... */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
605 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
606
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
607
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
608 /* getting information */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
609
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
610 int vm_get_current_menu(vm_t *vm, int *menuid) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
611 pgcit_t* pgcit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
612 int pgcn;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
613 pgcn = (vm->state).pgcN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
614 pgcit = get_PGCIT(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
615 if(pgcit==NULL) return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
616 *menuid = pgcit->pgci_srp[pgcn - 1].entry_id & 0xf ;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
617 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
618 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
619
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
620 int vm_get_current_title_part(vm_t *vm, int *title_result, int *part_result) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
621 vts_ptt_srpt_t *vts_ptt_srpt;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
622 int title, part = 0, vts_ttn;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
623 int found;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
624 int16_t pgcN, pgN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
625
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
626 vts_ptt_srpt = vm->vtsi->vts_ptt_srpt;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
627 pgcN = get_PGCN(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
628 pgN = vm->state.pgN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
629
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
630 found = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
631 for (vts_ttn = 0; (vts_ttn < vts_ptt_srpt->nr_of_srpts) && !found; vts_ttn++) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
632 for (part = 0; (part < vts_ptt_srpt->title[vts_ttn].nr_of_ptts) && !found; part++) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
633 if (vts_ptt_srpt->title[vts_ttn].ptt[part].pgcn == pgcN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
634 if (vts_ptt_srpt->title[vts_ttn].ptt[part].pgn == pgN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
635 found = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
636 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
637 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
638 if (part > 0 && vts_ptt_srpt->title[vts_ttn].ptt[part].pgn > pgN &&
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
639 vts_ptt_srpt->title[vts_ttn].ptt[part - 1].pgn < pgN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
640 part--;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
641 found = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
642 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
643 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
644 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
645 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
646 if (found) break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
647 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
648 vts_ttn++;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
649 part++;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
650
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
651 if (!found) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
652 fprintf(MSG_OUT, "libdvdnav: chapter NOT FOUND!\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
653 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
654 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
655
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
656 title = get_TT(vm, vm->state.vtsN, vts_ttn);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
657
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
658 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
659 if (title) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
660 fprintf(MSG_OUT, "libdvdnav: ************ this chapter FOUND!\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
661 fprintf(MSG_OUT, "libdvdnav: VTS_PTT_SRPT - Title %3i part %3i: PGC: %3i PG: %3i\n",
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
662 title, part,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
663 vts_ptt_srpt->title[vts_ttn-1].ptt[part-1].pgcn ,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
664 vts_ptt_srpt->title[vts_ttn-1].ptt[part-1].pgn );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
665 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
666 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
667 *title_result = title;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
668 *part_result = part;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
669 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
670 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
671
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
672 /* Return the substream id for 'logical' audio stream audioN.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
673 * 0 <= audioN < 8
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
674 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
675 int vm_get_audio_stream(vm_t *vm, int audioN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
676 int streamN = -1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
677
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
678 if((vm->state).domain != VTS_DOMAIN)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
679 audioN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
680
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
681 if(audioN < 8) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
682 /* Is there any control info for this logical stream */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
683 if((vm->state).pgc->audio_control[audioN] & (1<<15)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
684 streamN = ((vm->state).pgc->audio_control[audioN] >> 8) & 0x07;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
685 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
686 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
687
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
688 if((vm->state).domain != VTS_DOMAIN && streamN == -1)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
689 streamN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
690
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
691 /* FIXME: Should also check in vtsi/vmgi status what kind of stream
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
692 * it is (ac3/lpcm/dts/sdds...) to find the right (sub)stream id */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
693 return streamN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
694 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
695
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
696 /* Return the substream id for 'logical' subpicture stream subpN and given mode.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
697 * 0 <= subpN < 32
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
698 * mode == 0 - widescreen
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
699 * mode == 1 - letterbox
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
700 * mode == 2 - pan&scan
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
701 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
702 int vm_get_subp_stream(vm_t *vm, int subpN, int mode) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
703 int streamN = -1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
704 int source_aspect = vm_get_video_aspect(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
705
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
706 if((vm->state).domain != VTS_DOMAIN)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
707 subpN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
708
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
709 if(subpN < 32) { /* a valid logical stream */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
710 /* Is this logical stream present */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
711 if((vm->state).pgc->subp_control[subpN] & (1<<31)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
712 if(source_aspect == 0) /* 4:3 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
713 streamN = ((vm->state).pgc->subp_control[subpN] >> 24) & 0x1f;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
714 if(source_aspect == 3) /* 16:9 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
715 switch (mode) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
716 case 0:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
717 streamN = ((vm->state).pgc->subp_control[subpN] >> 16) & 0x1f;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
718 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
719 case 1:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
720 streamN = ((vm->state).pgc->subp_control[subpN] >> 8) & 0x1f;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
721 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
722 case 2:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
723 streamN = (vm->state).pgc->subp_control[subpN] & 0x1f;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
724 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
725 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
726 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
727
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
728 if((vm->state).domain != VTS_DOMAIN && streamN == -1)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
729 streamN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
730
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
731 /* FIXME: Should also check in vtsi/vmgi status what kind of stream it is. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
732 return streamN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
733 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
734
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
735 int vm_get_audio_active_stream(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
736 int audioN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
737 int streamN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
738 audioN = (vm->state).AST_REG ;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
739 streamN = vm_get_audio_stream(vm, audioN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
740
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
741 /* If no such stream, then select the first one that exists. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
742 if(streamN == -1) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
743 for(audioN = 0; audioN < 8; audioN++) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
744 if((vm->state).pgc->audio_control[audioN] & (1<<15)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
745 if ((streamN = vm_get_audio_stream(vm, audioN)) >= 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
746 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
747 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
748 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
749 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
750
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
751 return streamN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
752 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
753
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
754 int vm_get_subp_active_stream(vm_t *vm, int mode) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
755 int subpN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
756 int streamN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
757 subpN = (vm->state).SPST_REG & ~0x40;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
758 streamN = vm_get_subp_stream(vm, subpN, mode);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
759
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
760 /* If no such stream, then select the first one that exists. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
761 if(streamN == -1) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
762 for(subpN = 0; subpN < 32; subpN++) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
763 if((vm->state).pgc->subp_control[subpN] & (1<<31)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
764 if ((streamN = vm_get_subp_stream(vm, subpN, mode)) >= 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
765 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
766 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
767 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
768 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
769
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
770 if((vm->state).domain == VTS_DOMAIN && !((vm->state).SPST_REG & 0x40))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
771 /* Bit 7 set means hide, and only let Forced display show */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
772 return (streamN | 0x80);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
773 else
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
774 return streamN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
775 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
776
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
777 void vm_get_angle_info(vm_t *vm, int *current, int *num_avail) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
778 *num_avail = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
779 *current = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
780
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
781 if((vm->state).domain == VTS_DOMAIN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
782 title_info_t *title;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
783 /* TTN_REG does not allways point to the correct title.. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
784 if((vm->state).TTN_REG > vm->vmgi->tt_srpt->nr_of_srpts)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
785 return;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
786 title = &vm->vmgi->tt_srpt->title[(vm->state).TTN_REG - 1];
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
787 if(title->title_set_nr != (vm->state).vtsN ||
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
788 title->vts_ttn != (vm->state).VTS_TTN_REG)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
789 return;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
790 *num_avail = title->nr_of_angles;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
791 *current = (vm->state).AGL_REG;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
792 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
793 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
794
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
795 #if 0
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
796 /* currently unused */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
797 void vm_get_audio_info(vm_t *vm, int *current, int *num_avail) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
798 switch ((vm->state).domain) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
799 case VTS_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
800 *num_avail = vm->vtsi->vtsi_mat->nr_of_vts_audio_streams;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
801 *current = (vm->state).AST_REG;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
802 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
803 case VTSM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
804 *num_avail = vm->vtsi->vtsi_mat->nr_of_vtsm_audio_streams; /* 1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
805 *current = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
806 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
807 case VMGM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
808 case FP_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
809 *num_avail = vm->vmgi->vmgi_mat->nr_of_vmgm_audio_streams; /* 1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
810 *current = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
811 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
812 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
813 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
814
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
815 /* currently unused */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
816 void vm_get_subp_info(vm_t *vm, int *current, int *num_avail) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
817 switch ((vm->state).domain) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
818 case VTS_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
819 *num_avail = vm->vtsi->vtsi_mat->nr_of_vts_subp_streams;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
820 *current = (vm->state).SPST_REG;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
821 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
822 case VTSM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
823 *num_avail = vm->vtsi->vtsi_mat->nr_of_vtsm_subp_streams; /* 1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
824 *current = 0x41;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
825 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
826 case VMGM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
827 case FP_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
828 *num_avail = vm->vmgi->vmgi_mat->nr_of_vmgm_subp_streams; /* 1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
829 *current = 0x41;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
830 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
831 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
832 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
833
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
834 /* currently unused */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
835 void vm_get_video_res(vm_t *vm, int *width, int *height) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
836 video_attr_t attr = vm_get_video_attr(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
837
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
838 if(attr.video_format != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
839 *height = 576;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
840 else
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
841 *height = 480;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
842 switch(attr.picture_size) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
843 case 0:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
844 *width = 720;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
845 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
846 case 1:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
847 *width = 704;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
848 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
849 case 2:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
850 *width = 352;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
851 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
852 case 3:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
853 *width = 352;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
854 *height /= 2;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
855 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
856 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
857 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
858 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
859
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
860 int vm_get_video_aspect(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
861 int aspect = vm_get_video_attr(vm).display_aspect_ratio;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
862
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
863 assert(aspect == 0 || aspect == 3);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
864 (vm->state).registers.SPRM[14] &= ~(0x3 << 10);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
865 (vm->state).registers.SPRM[14] |= aspect << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
866
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
867 return aspect;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
868 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
869
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
870 int vm_get_video_scale_permission(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
871 return vm_get_video_attr(vm).permitted_df;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
872 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
873
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
874 video_attr_t vm_get_video_attr(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
875 switch ((vm->state).domain) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
876 case VTS_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
877 return vm->vtsi->vtsi_mat->vts_video_attr;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
878 case VTSM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
879 return vm->vtsi->vtsi_mat->vtsm_video_attr;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
880 case VMGM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
881 case FP_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
882 return vm->vmgi->vmgi_mat->vmgm_video_attr;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
883 default:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
884 abort();
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
885 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
886 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
887
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
888 audio_attr_t vm_get_audio_attr(vm_t *vm, int streamN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
889 switch ((vm->state).domain) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
890 case VTS_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
891 return vm->vtsi->vtsi_mat->vts_audio_attr[streamN];
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
892 case VTSM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
893 return vm->vtsi->vtsi_mat->vtsm_audio_attr;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
894 case VMGM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
895 case FP_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
896 return vm->vmgi->vmgi_mat->vmgm_audio_attr;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
897 default:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
898 abort();
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
899 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
900 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
901
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
902 subp_attr_t vm_get_subp_attr(vm_t *vm, int streamN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
903 switch ((vm->state).domain) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
904 case VTS_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
905 return vm->vtsi->vtsi_mat->vts_subp_attr[streamN];
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
906 case VTSM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
907 return vm->vtsi->vtsi_mat->vtsm_subp_attr;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
908 case VMGM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
909 case FP_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
910 return vm->vmgi->vmgi_mat->vmgm_subp_attr;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
911 default:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
912 abort();
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
913 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
914 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
915
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
916
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
917 /* Playback control */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
918
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
919 static link_t play_PGC(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
920 link_t link_values;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
921
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
922 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
923 fprintf(MSG_OUT, "libdvdnav: play_PGC:");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
924 if((vm->state).domain != FP_DOMAIN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
925 fprintf(MSG_OUT, " (vm->state).pgcN (%i)\n", get_PGCN(vm));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
926 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
927 fprintf(MSG_OUT, " first_play_pgc\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
928 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
929 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
930
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
931 /* This must be set before the pre-commands are executed because they
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
932 * might contain a CallSS that will save resume state */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
933
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
934 /* FIXME: This may be only a temporary fix for something... */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
935 (vm->state).pgN = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
936 (vm->state).cellN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
937 (vm->state).blockN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
938
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
939 /* eval -> updates the state and returns either
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
940 - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
941 - just play video i.e first PG
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
942 (This is what happens if you fall of the end of the pre_cmds)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
943 - or an error (are there more cases?) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
944 if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_pre) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
945 if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
946 (vm->state).pgc->command_tbl->nr_of_pre,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
947 &(vm->state).registers, &link_values)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
948 /* link_values contains the 'jump' return value */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
949 return link_values;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
950 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
951 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
952 fprintf(MSG_OUT, "libdvdnav: PGC pre commands didn't do a Jump, Link or Call\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
953 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
954 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
955 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
956 return play_PG(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
957 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
958
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
959 static link_t play_PGC_PG(vm_t *vm, int pgN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
960 link_t link_values;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
961
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
962 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
963 fprintf(MSG_OUT, "libdvdnav: play_PGC_PG:");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
964 if((vm->state).domain != FP_DOMAIN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
965 fprintf(MSG_OUT, " (vm->state).pgcN (%i)\n", get_PGCN(vm));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
966 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
967 fprintf(MSG_OUT, " first_play_pgc\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
968 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
969 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
970
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
971 /* This must be set before the pre-commands are executed because they
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
972 * might contain a CallSS that will save resume state */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
973
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
974 /* FIXME: This may be only a temporary fix for something... */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
975 (vm->state).pgN = pgN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
976 (vm->state).cellN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
977 (vm->state).blockN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
978
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
979 /* eval -> updates the state and returns either
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
980 - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
981 - just play video i.e first PG
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
982 (This is what happens if you fall of the end of the pre_cmds)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
983 - or an error (are there more cases?) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
984 if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_pre) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
985 if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
986 (vm->state).pgc->command_tbl->nr_of_pre,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
987 &(vm->state).registers, &link_values)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
988 /* link_values contains the 'jump' return value */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
989 return link_values;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
990 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
991 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
992 fprintf(MSG_OUT, "libdvdnav: PGC pre commands didn't do a Jump, Link or Call\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
993 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
994 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
995 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
996 return play_PG(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
997 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
998
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
999 static link_t play_PGC_post(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1000 link_t link_values;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1001
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1002 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1003 fprintf(MSG_OUT, "libdvdnav: play_PGC_post:\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1004 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1005
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1006 /* eval -> updates the state and returns either
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1007 - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1008 - just go to next PGC
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1009 (This is what happens if you fall of the end of the post_cmds)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1010 - or an error (are there more cases?) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1011 if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_post &&
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1012 vmEval_CMD((vm->state).pgc->command_tbl->post_cmds,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1013 (vm->state).pgc->command_tbl->nr_of_post,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1014 &(vm->state).registers, &link_values)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1015 return link_values;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1016 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1017
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1018 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1019 fprintf(MSG_OUT, "libdvdnav: ** Fell of the end of the pgc, continuing in NextPGC\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1020 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1021 /* Should end up in the STOP_DOMAIN if next_pgc is 0. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1022 if(!set_PGCN(vm, (vm->state).pgc->next_pgc_nr)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1023 link_values.command = Exit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1024 return link_values;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1025 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1026 return play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1027 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1028
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1029 static link_t play_PG(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1030 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1031 fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i)\n", (vm->state).pgN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1032 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1033
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1034 assert((vm->state).pgN > 0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1035 if((vm->state).pgN > (vm->state).pgc->nr_of_programs) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1036 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1037 fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i) > pgc->nr_of_programs (%i)\n",
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1038 (vm->state).pgN, (vm->state).pgc->nr_of_programs );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1039 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1040 assert((vm->state).pgN == (vm->state).pgc->nr_of_programs + 1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1041 return play_PGC_post(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1042 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1043
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1044 (vm->state).cellN = (vm->state).pgc->program_map[(vm->state).pgN - 1];
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1045
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1046 return play_Cell(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1047 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1048
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1049 static link_t play_Cell(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1050 static const link_t play_this = {PlayThis, /* Block in Cell */ 0, 0, 0};
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1051
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1052 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1053 fprintf(MSG_OUT, "libdvdnav: play_Cell: (vm->state).cellN (%i)\n", (vm->state).cellN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1054 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1055
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1056 assert((vm->state).cellN > 0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1057 if((vm->state).cellN > (vm->state).pgc->nr_of_cells) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1058 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1059 fprintf(MSG_OUT, "libdvdnav: (vm->state).cellN (%i) > pgc->nr_of_cells (%i)\n",
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1060 (vm->state).cellN, (vm->state).pgc->nr_of_cells );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1061 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1062 assert((vm->state).cellN == (vm->state).pgc->nr_of_cells + 1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1063 return play_PGC_post(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1064 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1065
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1066 /* Multi angle/Interleaved */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1067 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1068 case 0: /* Normal */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1069 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1070 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1071 case 1: /* The first cell in the block */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1072 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1073 case 0: /* Not part of a block */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1074 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1075 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1076 case 1: /* Angle block */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1077 /* Loop and check each cell instead? So we don't get outside the block? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1078 (vm->state).cellN += (vm->state).AGL_REG - 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1079 #ifdef STRICT
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1080 assert((vm->state).cellN <= (vm->state).pgc->nr_of_cells);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1081 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode != 0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1082 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1083 #else
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1084 if (!((vm->state).cellN <= (vm->state).pgc->nr_of_cells) ||
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1085 !((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode != 0) ||
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1086 !((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 1)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1087 fprintf(MSG_OUT, "libdvdnav: Invalid angle block\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1088 (vm->state).cellN -= (vm->state).AGL_REG - 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1089 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1090 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1091 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1092 case 2: /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1093 case 3: /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1094 default:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1095 fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n",
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1096 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1097 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1098 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1099 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1100 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1101 case 2: /* Cell in the block */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1102 case 3: /* Last cell in the block */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1103 /* These might perhaps happen for RSM or LinkC commands? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1104 default:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1105 fprintf(MSG_OUT, "libdvdnav: Cell is in block but did not enter at first cell!\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1106 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1107
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1108 /* Updates (vm->state).pgN and PTTN_REG */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1109 if(!set_PGN(vm)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1110 /* Should not happen */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1111 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1112 return play_PGC_post(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1113 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1114 (vm->state).cell_restart++;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1115 (vm->state).blockN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1116 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1117 fprintf(MSG_OUT, "libdvdnav: Cell should restart here\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1118 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1119 return play_this;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1120 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1121
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1122 static link_t play_Cell_post(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1123 cell_playback_t *cell;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1124
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1125 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1126 fprintf(MSG_OUT, "libdvdnav: play_Cell_post: (vm->state).cellN (%i)\n", (vm->state).cellN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1127 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1128
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1129 cell = &(vm->state).pgc->cell_playback[(vm->state).cellN - 1];
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1130
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1131 /* Still time is already taken care of before we get called. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1132
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1133 /* Deal with a Cell command, if any */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1134 if(cell->cell_cmd_nr != 0) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1135 link_t link_values;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1136
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1137 /* These asserts are now not needed.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1138 * Some DVDs have no cell commands listed in the PGC,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1139 * but the Cell itself points to a cell command that does not exist.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1140 * For this situation, just ignore the cell command and continue.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1141 *
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1142 * assert((vm->state).pgc->command_tbl != NULL);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1143 * assert((vm->state).pgc->command_tbl->nr_of_cell >= cell->cell_cmd_nr);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1144 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1145
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1146 if ((vm->state).pgc->command_tbl != NULL &&
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1147 (vm->state).pgc->command_tbl->nr_of_cell >= cell->cell_cmd_nr) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1148 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1149 fprintf(MSG_OUT, "libdvdnav: Cell command present, executing\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1150 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1151 if(vmEval_CMD(&(vm->state).pgc->command_tbl->cell_cmds[cell->cell_cmd_nr - 1], 1,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1152 &(vm->state).registers, &link_values)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1153 return link_values;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1154 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1155 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1156 fprintf(MSG_OUT, "libdvdnav: Cell command didn't do a Jump, Link or Call\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1157 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1158 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1159 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1160 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1161 fprintf(MSG_OUT, "libdvdnav: Invalid Cell command\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1162 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1163 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1164 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1165
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1166 /* Where to continue after playing the cell... */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1167 /* Multi angle/Interleaved */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1168 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1169 case 0: /* Normal */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1170 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1171 (vm->state).cellN++;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1172 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1173 case 1: /* The first cell in the block */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1174 case 2: /* A cell in the block */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1175 case 3: /* The last cell in the block */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1176 default:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1177 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1178 case 0: /* Not part of a block */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1179 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1180 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1181 case 1: /* Angle block */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1182 /* Skip the 'other' angles */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1183 (vm->state).cellN++;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1184 while((vm->state).cellN <= (vm->state).pgc->nr_of_cells &&
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1185 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode >= 2) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1186 (vm->state).cellN++;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1187 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1188 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1189 case 2: /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1190 case 3: /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1191 default:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1192 fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n",
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1193 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1194 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1195 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1196 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1197 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1198 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1199
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1200 /* Figure out the correct pgN for the new cell */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1201 if(!set_PGN(vm)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1202 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1203 fprintf(MSG_OUT, "libdvdnav: last cell in this PGC\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1204 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1205 return play_PGC_post(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1206 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1207 return play_Cell(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1208 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1209
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1210
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1211 /* link processing */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1212
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1213 static int process_command(vm_t *vm, link_t link_values) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1214
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1215 while(link_values.command != PlayThis) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1216
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1217 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1218 fprintf(MSG_OUT, "libdvdnav: Before printout starts:\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1219 vm_print_link(link_values);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1220 fprintf(MSG_OUT, "libdvdnav: Link values %i %i %i %i\n", link_values.command,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1221 link_values.data1, link_values.data2, link_values.data3);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1222 vm_print_current_domain_state(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1223 fprintf(MSG_OUT, "libdvdnav: Before printout ends.\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1224 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1225
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1226 switch(link_values.command) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1227 case LinkNoLink:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1228 /* BUTTON number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1229 if(link_values.data1 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1230 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1231 return 0; /* no actual jump */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1232
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1233 case LinkTopC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1234 /* Restart playing from the beginning of the current Cell. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1235 /* BUTTON number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1236 if(link_values.data1 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1237 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1238 link_values = play_Cell(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1239 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1240 case LinkNextC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1241 /* Link to Next Cell */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1242 /* BUTTON number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1243 if(link_values.data1 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1244 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1245 (vm->state).cellN += 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1246 link_values = play_Cell(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1247 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1248 case LinkPrevC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1249 /* Link to Previous Cell */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1250 /* BUTTON number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1251 if(link_values.data1 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1252 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1253 assert((vm->state).cellN > 1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1254 (vm->state).cellN -= 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1255 link_values = play_Cell(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1256 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1257
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1258 case LinkTopPG:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1259 /* Link to Top of current Program */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1260 /* BUTTON number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1261 if(link_values.data1 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1262 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1263 link_values = play_PG(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1264 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1265 case LinkNextPG:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1266 /* Link to Next Program */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1267 /* BUTTON number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1268 if(link_values.data1 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1269 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1270 (vm->state).pgN += 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1271 link_values = play_PG(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1272 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1273 case LinkPrevPG:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1274 /* Link to Previous Program */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1275 /* BUTTON number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1276 if(link_values.data1 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1277 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1278 assert((vm->state).pgN > 1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1279 (vm->state).pgN -= 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1280 link_values = play_PG(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1281 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1282
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1283 case LinkTopPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1284 /* Restart playing from beginning of current Program Chain */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1285 /* BUTTON number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1286 if(link_values.data1 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1287 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1288 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1289 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1290 case LinkNextPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1291 /* Link to Next Program Chain */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1292 /* BUTTON number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1293 if(link_values.data1 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1294 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1295 assert((vm->state).pgc->next_pgc_nr != 0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1296 if(set_PGCN(vm, (vm->state).pgc->next_pgc_nr))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1297 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1298 else
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1299 link_values.command = Exit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1300 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1301 case LinkPrevPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1302 /* Link to Previous Program Chain */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1303 /* BUTTON number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1304 if(link_values.data1 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1305 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1306 assert((vm->state).pgc->prev_pgc_nr != 0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1307 if(set_PGCN(vm, (vm->state).pgc->prev_pgc_nr))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1308 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1309 else
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1310 link_values.command = Exit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1311 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1312 case LinkGoUpPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1313 /* Link to GoUp Program Chain */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1314 /* BUTTON number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1315 if(link_values.data1 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1316 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1317 assert((vm->state).pgc->goup_pgc_nr != 0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1318 if(set_PGCN(vm, (vm->state).pgc->goup_pgc_nr))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1319 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1320 else
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1321 link_values.command = Exit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1322 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1323 case LinkTailPGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1324 /* Link to Tail of Program Chain */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1325 /* BUTTON number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1326 if(link_values.data1 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1327 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1328 link_values = play_PGC_post(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1329 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1330
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1331 case LinkRSM:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1332 {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1333 /* Link to Resume point */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1334 int i;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1335
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1336 /* Check and see if there is any rsm info!! */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1337 if (!(vm->state).rsm_vtsN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1338 fprintf(MSG_OUT, "libdvdnav: trying to resume without any resume info set\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1339 link_values.command = Exit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1340 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1341 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1342
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1343 (vm->state).domain = VTS_DOMAIN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1344 if (!ifoOpenNewVTSI(vm, vm->dvd, (vm->state).rsm_vtsN))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1345 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1346 set_PGCN(vm, (vm->state).rsm_pgcN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1347
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1348 /* These should never be set in SystemSpace and/or MenuSpace */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1349 /* (vm->state).TTN_REG = rsm_tt; ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1350 /* (vm->state).TT_PGCN_REG = (vm->state).rsm_pgcN; ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1351 for(i = 0; i < 5; i++) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1352 (vm->state).registers.SPRM[4 + i] = (vm->state).rsm_regs[i];
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1353 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1354
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1355 if(link_values.data1 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1356 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1357
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1358 if((vm->state).rsm_cellN == 0) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1359 assert((vm->state).cellN); /* Checking if this ever happens */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1360 (vm->state).pgN = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1361 link_values = play_PG(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1362 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1363 /* (vm->state).pgN = ?? this gets the right value in set_PGN() below */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1364 (vm->state).cellN = (vm->state).rsm_cellN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1365 link_values.command = PlayThis;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1366 link_values.data1 = (vm->state).rsm_blockN & 0xffff;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1367 link_values.data2 = (vm->state).rsm_blockN >> 16;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1368 if(!set_PGN(vm)) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1369 /* Were at the end of the PGC, should not happen for a RSM */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1370 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1371 link_values.command = LinkTailPGC;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1372 link_values.data1 = 0; /* No button */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1373 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1374 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1375 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1376 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1377 case LinkPGCN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1378 /* Link to Program Chain Number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1379 if(!set_PGCN(vm, link_values.data1))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1380 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1381 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1382 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1383 case LinkPTTN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1384 /* Link to Part of current Title Number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1385 /* BUTTON number:data2 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1386 /* PGC Pre-Commands are not executed */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1387 assert((vm->state).domain == VTS_DOMAIN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1388 if(link_values.data2 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1389 (vm->state).HL_BTNN_REG = link_values.data2 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1390 if(!set_VTS_PTT(vm, (vm->state).vtsN, (vm->state).VTS_TTN_REG, link_values.data1))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1391 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1392 link_values = play_PG(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1393 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1394 case LinkPGN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1395 /* Link to Program Number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1396 /* BUTTON number:data2 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1397 if(link_values.data2 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1398 (vm->state).HL_BTNN_REG = link_values.data2 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1399 /* Update any other state, PTTN perhaps? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1400 (vm->state).pgN = link_values.data1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1401 link_values = play_PG(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1402 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1403 case LinkCN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1404 /* Link to Cell Number:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1405 /* BUTTON number:data2 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1406 if(link_values.data2 != 0)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1407 (vm->state).HL_BTNN_REG = link_values.data2 << 10;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1408 /* Update any other state, pgN, PTTN perhaps? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1409 (vm->state).cellN = link_values.data1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1410 link_values = play_Cell(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1411 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1412
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1413 case Exit:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1414 vm->stopped = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1415 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1416
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1417 case JumpTT:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1418 /* Jump to VTS Title Domain */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1419 /* Only allowed from the First Play domain(PGC) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1420 /* or the Video Manager domain (VMG) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1421 /* Stop SPRM9 Timer */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1422 /* Set SPRM1 and SPRM2 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1423 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1424 if(set_TT(vm, link_values.data1))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1425 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1426 else
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1427 link_values.command = Exit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1428 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1429 case JumpVTS_TT:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1430 /* Jump to Title:data1 in same VTS Title Domain */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1431 /* Only allowed from the VTS Menu Domain(VTSM) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1432 /* or the Video Title Set Domain(VTS) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1433 /* Stop SPRM9 Timer */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1434 /* Set SPRM1 and SPRM2 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1435 assert((vm->state).domain == VTSM_DOMAIN || (vm->state).domain == VTS_DOMAIN); /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1436 if(!set_VTS_TT(vm, (vm->state).vtsN, link_values.data1))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1437 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1438 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1439 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1440 case JumpVTS_PTT:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1441 /* Jump to Part:data2 of Title:data1 in same VTS Title Domain */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1442 /* Only allowed from the VTS Menu Domain(VTSM) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1443 /* or the Video Title Set Domain(VTS) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1444 /* Stop SPRM9 Timer */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1445 /* Set SPRM1 and SPRM2 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1446 assert((vm->state).domain == VTSM_DOMAIN || (vm->state).domain == VTS_DOMAIN); /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1447 if(!set_VTS_PTT(vm, (vm->state).vtsN, link_values.data1, link_values.data2))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1448 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1449 link_values = play_PGC_PG(vm, (vm->state).pgN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1450 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1451
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1452 case JumpSS_FP:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1453 /* Jump to First Play Domain */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1454 /* Only allowed from the VTS Menu Domain(VTSM) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1455 /* or the Video Manager domain (VMG) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1456 /* Stop SPRM9 Timer and any GPRM counters */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1457 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == VTSM_DOMAIN); /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1458 if (!set_FP_PGC(vm))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1459 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1460 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1461 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1462 case JumpSS_VMGM_MENU:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1463 /* Jump to Video Manger domain - Title Menu:data1 or any PGC in VMG */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1464 /* Allowed from anywhere except the VTS Title domain */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1465 /* Stop SPRM9 Timer and any GPRM counters */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1466 assert((vm->state).domain != VTS_DOMAIN); /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1467 (vm->state).domain = VMGM_DOMAIN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1468 if(!set_MENU(vm, link_values.data1))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1469 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1470 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1471 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1472 case JumpSS_VTSM:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1473 /* Jump to a menu in Video Title domain, */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1474 /* or to a Menu is the current VTS */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1475 /* Stop SPRM9 Timer and any GPRM counters */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1476 /* ifoOpenNewVTSI:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1477 /* VTS_TTN_REG:data2 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1478 /* get_MENU:data3 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1479 if(link_values.data1 != 0) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1480 if (link_values.data1 != (vm->state).vtsN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1481 /* the normal case */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1482 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1483 (vm->state).domain = VTSM_DOMAIN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1484 if (!ifoOpenNewVTSI(vm, vm->dvd, link_values.data1)) /* Also sets (vm->state).vtsN */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1485 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1486 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1487 /* This happens on some discs like "Captain Scarlet & the Mysterons" or
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1488 * the German RC2 of "Anatomie" in VTSM. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1489 assert((vm->state).domain == VTSM_DOMAIN ||
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1490 (vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1491 (vm->state).domain = VTSM_DOMAIN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1492 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1493 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1494 /* This happens on 'The Fifth Element' region 2. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1495 assert((vm->state).domain == VTSM_DOMAIN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1496 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1497 /* I don't know what title is supposed to be used for. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1498 /* Alien or Aliens has this != 1, I think. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1499 /* assert(link_values.data2 == 1); */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1500 (vm->state).VTS_TTN_REG = link_values.data2;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1501 /* TTN_REG (SPRM4), VTS_TTN_REG (SPRM5), TT_PGCN_REG (SPRM6) are linked, */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1502 /* so if one changes, the others must change to match it. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1503 (vm->state).TTN_REG = get_TT(vm, (vm->state).vtsN, (vm->state).VTS_TTN_REG);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1504 if(!set_MENU(vm, link_values.data3))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1505 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1506 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1507 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1508 case JumpSS_VMGM_PGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1509 /* set_PGCN:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1510 /* Stop SPRM9 Timer and any GPRM counters */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1511 assert((vm->state).domain != VTS_DOMAIN); /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1512 (vm->state).domain = VMGM_DOMAIN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1513 if(!set_PGCN(vm, link_values.data1))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1514 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1515 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1516 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1517
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1518 case CallSS_FP:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1519 /* set_RSMinfo:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1520 assert((vm->state).domain == VTS_DOMAIN); /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1521 /* Must be called before domain is changed */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1522 set_RSMinfo(vm, link_values.data1, /* We dont have block info */ 0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1523 set_FP_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1524 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1525 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1526 case CallSS_VMGM_MENU:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1527 /* set_MENU:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1528 /* set_RSMinfo:data2 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1529 assert((vm->state).domain == VTS_DOMAIN); /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1530 /* Must be called before domain is changed */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1531 set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1532 (vm->state).domain = VMGM_DOMAIN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1533 if(!set_MENU(vm, link_values.data1))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1534 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1535 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1536 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1537 case CallSS_VTSM:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1538 /* set_MENU:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1539 /* set_RSMinfo:data2 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1540 assert((vm->state).domain == VTS_DOMAIN); /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1541 /* Must be called before domain is changed */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1542 set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1543 (vm->state).domain = VTSM_DOMAIN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1544 if(!set_MENU(vm, link_values.data1))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1545 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1546 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1547 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1548 case CallSS_VMGM_PGC:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1549 /* set_PGC:data1 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1550 /* set_RSMinfo:data2 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1551 assert((vm->state).domain == VTS_DOMAIN); /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1552 /* Must be called before domain is changed */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1553 set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1554 (vm->state).domain = VMGM_DOMAIN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1555 if(!set_PGCN(vm, link_values.data1))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1556 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1557 link_values = play_PGC(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1558 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1559 case PlayThis:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1560 /* Should never happen. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1561 assert(0);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1562 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1563 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1564
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1565 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1566 fprintf(MSG_OUT, "libdvdnav: After printout starts:\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1567 vm_print_current_domain_state(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1568 fprintf(MSG_OUT, "libdvdnav: After printout ends.\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1569 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1570
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1571 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1572 (vm->state).blockN = link_values.data1 | (link_values.data2 << 16);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1573 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1574 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1575
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1576
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1577 /* Set functions */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1578
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1579 static int set_TT(vm_t *vm, int tt) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1580 return set_PTT(vm, tt, 1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1581 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1582
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1583 static int set_PTT(vm_t *vm, int tt, int ptt) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1584 assert(tt <= vm->vmgi->tt_srpt->nr_of_srpts);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1585 return set_VTS_PTT(vm, vm->vmgi->tt_srpt->title[tt - 1].title_set_nr,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1586 vm->vmgi->tt_srpt->title[tt - 1].vts_ttn, ptt);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1587 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1588
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1589 static int set_VTS_TT(vm_t *vm, int vtsN, int vts_ttn) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1590 return set_VTS_PTT(vm, vtsN, vts_ttn, 1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1591 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1592
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1593 static int set_VTS_PTT(vm_t *vm, int vtsN, int vts_ttn, int part) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1594 int pgcN, pgN, res;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1595
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1596 (vm->state).domain = VTS_DOMAIN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1597
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1598 if (vtsN != (vm->state).vtsN)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1599 if (!ifoOpenNewVTSI(vm, vm->dvd, vtsN)) /* Also sets (vm->state).vtsN */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1600 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1601
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1602 if ((vts_ttn < 1) || (vts_ttn > vm->vtsi->vts_ptt_srpt->nr_of_srpts) ||
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1603 (part < 1) || (part > vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].nr_of_ptts) ) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1604 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1605 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1606
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1607 pgcN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgcn;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1608 pgN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgn;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1609
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1610 (vm->state).TT_PGCN_REG = pgcN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1611 (vm->state).PTTN_REG = part;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1612 (vm->state).TTN_REG = get_TT(vm, vtsN, vts_ttn);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1613 assert( (vm->state.TTN_REG) != 0 );
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1614 (vm->state).VTS_TTN_REG = vts_ttn;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1615 (vm->state).vtsN = vtsN; /* Not sure about this one. We can get to it easily from TTN_REG */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1616 /* Any other registers? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1617
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1618 res = set_PGCN(vm, pgcN); /* This clobber's state.pgN (sets it to 1), but we don't want clobbering here. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1619 (vm->state).pgN = pgN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1620 return res;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1621 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1622
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1623 static int set_FP_PGC(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1624 (vm->state).domain = FP_DOMAIN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1625 if (!vm->vmgi->first_play_pgc) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1626 return set_PGCN(vm, 1);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1627 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1628 (vm->state).pgc = vm->vmgi->first_play_pgc;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1629 (vm->state).pgcN = vm->vmgi->vmgi_mat->first_play_pgc;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1630 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1631 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1632
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1633
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1634 static int set_MENU(vm_t *vm, int menu) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1635 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == VTSM_DOMAIN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1636 return set_PGCN(vm, get_ID(vm, menu));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1637 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1638
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1639 static int set_PGCN(vm_t *vm, int pgcN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1640 pgcit_t *pgcit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1641
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1642 pgcit = get_PGCIT(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1643 assert(pgcit != NULL); /* ?? Make this return -1 instead */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1644
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1645 if(pgcN < 1 || pgcN > pgcit->nr_of_pgci_srp) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1646 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1647 fprintf(MSG_OUT, "libdvdnav: ** No such pgcN = %d\n", pgcN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1648 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1649 return 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1650 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1651
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1652 (vm->state).pgc = pgcit->pgci_srp[pgcN - 1].pgc;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1653 (vm->state).pgcN = pgcN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1654 (vm->state).pgN = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1655
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1656 if((vm->state).domain == VTS_DOMAIN)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1657 (vm->state).TT_PGCN_REG = pgcN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1658
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1659 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1660 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1661
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1662 /* Figure out the correct pgN from the cell and update (vm->state). */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1663 static int set_PGN(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1664 int new_pgN = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1665
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1666 while(new_pgN < (vm->state).pgc->nr_of_programs
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1667 && (vm->state).cellN >= (vm->state).pgc->program_map[new_pgN])
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1668 new_pgN++;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1669
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1670 if(new_pgN == (vm->state).pgc->nr_of_programs) /* We are at the last program */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1671 if((vm->state).cellN > (vm->state).pgc->nr_of_cells)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1672 return 0; /* We are past the last cell */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1673
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1674 (vm->state).pgN = new_pgN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1675
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1676 if((vm->state).domain == VTS_DOMAIN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1677 playback_type_t *pb_ty;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1678 if((vm->state).TTN_REG > vm->vmgi->tt_srpt->nr_of_srpts)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1679 return 0; /* ?? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1680 pb_ty = &vm->vmgi->tt_srpt->title[(vm->state).TTN_REG - 1].pb_ty;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1681 if(pb_ty->multi_or_random_pgc_title == /* One_Sequential_PGC_Title */ 0) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1682 int dummy, part;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1683 vm_get_current_title_part(vm, &dummy, &part);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1684 (vm->state).PTTN_REG = part;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1685 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1686 /* FIXME: Handle RANDOM or SHUFFLE titles. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1687 fprintf(MSG_OUT, "libdvdnav: RANDOM or SHUFFLE titles are NOT handled yet.\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1688 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1689 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1690 return 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1691 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1692
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1693 /* Must be called before domain is changed (set_PGCN()) */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1694 static void set_RSMinfo(vm_t *vm, int cellN, int blockN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1695 int i;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1696
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1697 if(cellN) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1698 (vm->state).rsm_cellN = cellN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1699 (vm->state).rsm_blockN = blockN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1700 } else {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1701 (vm->state).rsm_cellN = (vm->state).cellN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1702 (vm->state).rsm_blockN = blockN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1703 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1704 (vm->state).rsm_vtsN = (vm->state).vtsN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1705 (vm->state).rsm_pgcN = get_PGCN(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1706
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1707 /* assert((vm->state).rsm_pgcN == (vm->state).TT_PGCN_REG); for VTS_DOMAIN */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1708
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1709 for(i = 0; i < 5; i++) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1710 (vm->state).rsm_regs[i] = (vm->state).registers.SPRM[4 + i];
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1711 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1712 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1713
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1714
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1715 /* Get functions */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1716
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1717 /* Searches the TT tables, to find the current TT.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1718 * returns the current TT.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1719 * returns 0 if not found.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1720 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1721 static int get_TT(vm_t *vm, int vtsN, int vts_ttn) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1722 int i;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1723 int tt=0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1724
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1725 for(i = 1; i <= vm->vmgi->tt_srpt->nr_of_srpts; i++) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1726 if( vm->vmgi->tt_srpt->title[i - 1].title_set_nr == vtsN &&
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1727 vm->vmgi->tt_srpt->title[i - 1].vts_ttn == vts_ttn) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1728 tt=i;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1729 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1730 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1731 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1732 return tt;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1733 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1734
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1735 /* Search for entry_id match of the PGC Category in the current VTS PGCIT table.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1736 * Return pgcN based on entry_id match.
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1737 */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1738 static int get_ID(vm_t *vm, int id) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1739 int pgcN, i;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1740 pgcit_t *pgcit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1741
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1742 /* Relies on state to get the correct pgcit. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1743 pgcit = get_PGCIT(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1744 assert(pgcit != NULL);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1745 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1746 fprintf(MSG_OUT, "libdvdnav: ** Searching for menu (0x%x) entry PGC\n", id);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1747 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1748
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1749 /* Force high bit set. */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1750 id |=0x80;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1751
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1752 /* Get menu/title */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1753 for(i = 0; i < pgcit->nr_of_pgci_srp; i++) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1754 if( (pgcit->pgci_srp[i].entry_id) == id) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1755 pgcN = i + 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1756 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1757 fprintf(MSG_OUT, "libdvdnav: Found menu.\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1758 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1759 return pgcN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1760 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1761 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1762 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1763 fprintf(MSG_OUT, "libdvdnav: ** No such id/menu (0x%02x) entry PGC\n", id & 0x7f);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1764 for(i = 0; i < pgcit->nr_of_pgci_srp; i++) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1765 if ( (pgcit->pgci_srp[i].entry_id & 0x80) == 0x80) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1766 fprintf(MSG_OUT, "libdvdnav: Available menus: 0x%x\n",
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1767 pgcit->pgci_srp[i].entry_id & 0x7f);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1768 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1769 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1770 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1771 return 0; /* error */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1772 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1773
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1774 /* FIXME: we have a pgcN member in the vm's state now, so this should be obsolete */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1775 static int get_PGCN(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1776 pgcit_t *pgcit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1777 int pgcN = 1;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1778
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1779 pgcit = get_PGCIT(vm);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1780
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1781 if (pgcit) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1782 while(pgcN <= pgcit->nr_of_pgci_srp) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1783 if(pgcit->pgci_srp[pgcN - 1].pgc == (vm->state).pgc) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1784 assert((vm->state).pgcN == pgcN);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1785 return pgcN;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1786 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1787 pgcN++;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1788 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1789 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1790 fprintf(MSG_OUT, "libdvdnav: get_PGCN failed. Was trying to find pgcN in domain %d\n",
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1791 (vm->state).domain);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1792 return 0; /* error */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1793 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1794
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1795 static pgcit_t* get_MENU_PGCIT(vm_t *vm, ifo_handle_t *h, uint16_t lang) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1796 int i;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1797
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1798 if(h == NULL || h->pgci_ut == NULL) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1799 fprintf(MSG_OUT, "libdvdnav: *** pgci_ut handle is NULL ***\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1800 return NULL; /* error? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1801 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1802
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1803 i = 0;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1804 while(i < h->pgci_ut->nr_of_lus
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1805 && h->pgci_ut->lu[i].lang_code != lang)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1806 i++;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1807 if(i == h->pgci_ut->nr_of_lus) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1808 fprintf(MSG_OUT, "libdvdnav: Language '%c%c' not found, using '%c%c' instead\n",
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1809 (char)(lang >> 8), (char)(lang & 0xff),
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1810 (char)(h->pgci_ut->lu[0].lang_code >> 8),
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1811 (char)(h->pgci_ut->lu[0].lang_code & 0xff));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1812 fprintf(MSG_OUT, "libdvdnav: Menu Languages available: ");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1813 for(i = 0; i < h->pgci_ut->nr_of_lus; i++) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1814 fprintf(MSG_OUT, "%c%c ",
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1815 (char)(h->pgci_ut->lu[i].lang_code >> 8),
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1816 (char)(h->pgci_ut->lu[i].lang_code & 0xff));
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1817 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1818 fprintf(MSG_OUT, "\n");
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1819 i = 0; /* error? */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1820 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1821
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1822 return h->pgci_ut->lu[i].pgcit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1823 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1824
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1825 /* Uses state to decide what to return */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1826 static pgcit_t* get_PGCIT(vm_t *vm) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1827 pgcit_t *pgcit = NULL;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1828
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1829 switch ((vm->state).domain) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1830 case VTS_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1831 if(!vm->vtsi) return NULL;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1832 pgcit = vm->vtsi->vts_pgcit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1833 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1834 case VTSM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1835 if(!vm->vtsi) return NULL;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1836 pgcit = get_MENU_PGCIT(vm, vm->vtsi, (vm->state).registers.SPRM[0]);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1837 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1838 case VMGM_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1839 case FP_DOMAIN:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1840 pgcit = get_MENU_PGCIT(vm, vm->vmgi, (vm->state).registers.SPRM[0]);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1841 break;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1842 default:
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1843 abort();
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1844 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1845
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1846 return pgcit;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1847 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1848
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1849 //return the ifo_handle_t describing required title, used to
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1850 //identify chapters
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1851 ifo_handle_t *vm_get_title_ifo(vm_t *vm, uint32_t title)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1852 {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1853 ifo_handle_t *ifo = NULL;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1854 uint8_t titleset_nr;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1855 if((title < 1) || (title > vm->vmgi->tt_srpt->nr_of_srpts))
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1856 return NULL;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1857 titleset_nr = vm->vmgi->tt_srpt->title[title-1].title_set_nr;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1858 ifo = ifoOpen(vm->dvd, titleset_nr);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1859 return ifo;
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1860 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1861
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1862 void vm_ifo_close(ifo_handle_t *ifo)
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1863 {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1864 ifoClose(ifo);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1865 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1866
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1867 /* Debug functions */
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1868
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1869 #ifdef TRACE
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1870 void vm_position_print(vm_t *vm, vm_position_t *position) {
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1871 fprintf(MSG_OUT, "libdvdnav: But=%x Spu=%x Aud=%x Ang=%x Hop=%x vts=%x dom=%x cell=%x cell_restart=%x cell_start=%x still=%x block=%x\n",
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1872 position->button,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1873 position->spu_channel,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1874 position->audio_channel,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1875 position->angle_channel,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1876 position->hop_channel,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1877 position->vts,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1878 position->domain,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1879 position->cell,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1880 position->cell_restart,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1881 position->cell_start,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1882 position->still,
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1883 position->block);
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1884 }
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1885 #endif
427b7da5cbdb first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff changeset
1886