annotate vm.c @ 11:1f479a99339c src

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