--- a/src/dvdnav_internal.h
+++ b/src/dvdnav_internal.h
@@ -1,66 +1,43 @@
-/*
- * Copyright (C) 2001-2004 Rich Wareham <richwareham@users.sourceforge.net>
- *
+/* 
+ * Copyright (C) 2001 Rich Wareham <richwareham@users.sourceforge.net>
+ * 
  * This file is part of libdvdnav, a DVD navigation library.
- *
+ * 
  * libdvdnav is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- *
+ * 
  * libdvdnav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
  *
- * You should have received a copy of the GNU General Public License along
- * with libdvdnav; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * $Id$
+ *
  */
 
-#ifndef LIBDVDNAV_DVDNAV_INTERNAL_H
-#define LIBDVDNAV_DVDNAV_INTERNAL_H
+#ifndef DVDNAV_INTERNAL_H_INCLUDED
+#define DVDNAV_INTERNAL_H_INCLUDED
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include "dvdnav.h"
+#include "vm.h"
 
-#ifdef WIN32
-
-/* pthread_mutex_* wrapper for win32 */
-#include <windows.h>
-#include <process.h>
-typedef CRITICAL_SECTION pthread_mutex_t;
-#define pthread_mutex_init(a, b) InitializeCriticalSection(a)
-#define pthread_mutex_lock(a)    EnterCriticalSection(a)
-#define pthread_mutex_unlock(a)  LeaveCriticalSection(a)
-#define pthread_mutex_destroy(a)
-
-#ifndef HAVE_GETTIMEOFDAY
-/* replacement gettimeofday implementation */
-#include <sys/timeb.h>
-static inline int _private_gettimeofday( struct timeval *tv, void *tz )
-{
-  struct timeb t;
-  ftime( &t );
-  tv->tv_sec = t.time;
-  tv->tv_usec = t.millitm * 1000;
-  return 0;
-}
-#define gettimeofday(TV, TZ) _private_gettimeofday((TV), (TZ))
-#endif
-
-#include <io.h> /* read() */
-#define lseek64 _lseeki64
-
-#else
-
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <limits.h>
+#include <string.h>
 #include <pthread.h>
 
-#endif /* WIN32 */
+#include <dvdread/dvd_reader.h>
+#include <dvdread/ifo_read.h>
+#include <dvdread/ifo_types.h>
 
-/* where should libdvdnav write its messages (stdout/stderr) */
-#define MSG_OUT stdout
 
 /* Maximum length of an error string */
 #define MAX_ERR_LEN 255
@@ -69,18 +46,16 @@
 #ifdef PATH_MAX
 #define MAX_PATH_LEN PATH_MAX
 #else
-#define MAX_PATH_LEN 255 /* Arbitrary */
+#define MAX_PATH_LEN 255 /* Arbitary */
 #endif
 
 #ifndef DVD_VIDEO_LB_LEN
 #define DVD_VIDEO_LB_LEN 2048
 #endif
 
-typedef struct read_cache_s read_cache_t;
-
 /*
  * These are defined here because they are
- * not in ifo_types.h, they maybe one day
+ * not in ifo_types.h, they maybe one day 
  */
 
 #ifndef audio_status_t
@@ -93,7 +68,7 @@
 #else
   uint8_t zero2;
   unsigned int stream_number : 3;
-  unsigned int zero1         : 4;
+  unsigned int zero1         : 4;  
   unsigned int available     : 1;
 #endif
 } ATTRIBUTE_PACKED audio_status_t;
@@ -125,71 +100,75 @@
 } ATTRIBUTE_PACKED spu_status_t;
 #endif
 
-typedef struct dvdnav_vobu_s {
-  int32_t vobu_start;  /* Logical Absolute. MAX needed is 0x300000 */
-  int32_t vobu_length;
-  int32_t blockN;      /* Relative offset */
-  int32_t vobu_next;   /* Relative offset */
-} dvdnav_vobu_t;
-
-/** The main DVDNAV type **/
+/* The main DVDNAV type */
 
 struct dvdnav_s {
   /* General data */
-  char        path[MAX_PATH_LEN]; /* Path to DVD device/dir */
+  char path[MAX_PATH_LEN];        /* Path to DVD device/dir */
   dvd_file_t *file;               /* Currently opened file */
-
+  int open_vtsN;                  /* The domain and number of the... */
+  int open_domain;                /* ..currently opened VOB */
+ 
   /* Position data */
-  vm_position_t position_next;
-  vm_position_t position_current;
-  dvdnav_vobu_t vobu;
+  uint32_t vobu_start;
+  uint32_t vobu_length;
+  uint32_t blockN;
+  uint32_t next_vobu;
+  cell_playback_t *cell;
+  uint32_t jmp_blockN;
+  uint32_t jmp_vobu_start;
+  uint32_t seekto_block;
 
   /* NAV data */
   pci_t pci;
   dsi_t dsi;
-  uint32_t last_cmd_nav_lbn;      /* detects when a command is issued on an already left NAV */
-
+  
   /* Flags */
-  int skip_still;                 /* Set when skipping a still */
-  int sync_wait;                  /* applications should wait till they are in sync with us */
-  int sync_wait_skip;             /* Set when skipping wait state */
-  int spu_clut_changed;           /* The SPU CLUT changed */
-  int started;                    /* vm_start has been called? */
-  int use_read_ahead;             /* 1 - use read-ahead cache, 0 - don't */
-  int pgc_based;                  /* positioning works PGC based instead of PG based */
-  int cur_cell_time;              /* time expired since the beginning of the current cell, read from the dsi */
-
+  int expecting_nav_packet;
+  int at_soc;      /* Are we at the start of a cell? */
+  int still_frame; /* >=0 send still frame event with len still_frame
+                    * -1 don't send event. */
+  int jumping;     /* non-zero if we are in the process of jumping */
+  int seeking;     /* non-zero if we are in the process of seeking */
+  int stop;        /* Are we stopped? (note not paused, actually stopped) */
+  int highlight_changed; /* The highlight changed */
+  int spu_clut_changed; /* The SPU CLUT changed */ 
+  int spu_stream_changed; /* The SPU STREAM changed */ 
+  int audio_stream_changed; /* The AUDIO STREAM changed */ 
+  int started; /* vm_start has been called? */
+  int use_read_ahead; /* 1 - use read-ahead cache, 0 - don't */
   /* VM */
-  vm_t *vm;
+  vm_t* vm;
   pthread_mutex_t vm_lock;
 
-  /* Read-ahead cache */
-  read_cache_t *cache;
-
+  /* Highlight */
+  int hli_state;  /* State of highlight 0 - disabled, 1 - selected,
+		 2 - activated */
+  uint16_t hli_bbox[4]; /* Highlight bounding box */
+  uint32_t hli_clut; /* Highlight palette */
+  uint32_t hli_pts;  /* Highlight PTS for matching with SPU packet. */
+  uint32_t hli_buttonN;  /* Button number for SPU decoder. */
+  /* Read-ahead cache. */
+  uint8_t      *cache_buffer;
+  int32_t      cache_start_sector; /* -1 means cache invalid */
+  size_t       cache_block_count;
+  size_t       cache_malloc_size;
+  int          cache_valid;
+  
   /* Errors */
   char err_str[MAX_ERR_LEN];
 };
 
-/** HELPER FUNCTIONS **/
-
-/* converts a dvd_time_t to PTS ticks */
-int64_t dvdnav_convert_time(dvd_time_t *time);
+/* Common things we do everytime we do a jump */
+void dvdnav_do_post_jump(dvdnav_t *self);
 
 /** USEFUL MACROS **/
 
-#ifdef __GNUC__
-#define printerrf(format, args...) \
-	do { if (this) snprintf(this->err_str, MAX_ERR_LEN, format, ## args); } while (0)
-#else
-#ifdef _MSC_VER
-#define printerrf(str) \
-	do { if (this) snprintf(this->err_str, MAX_ERR_LEN, str); } while (0)
-#else
-#define printerrf(...) \
-	do { if (this) snprintf(this->err_str, MAX_ERR_LEN, __VA_ARGS__); } while (0)
-#endif /* WIN32 */
-#endif
-#define printerr(str) \
-	do { if (this) strncpy(this->err_str, str, MAX_ERR_LEN - 1); } while (0)
+#define printerrf(format, args...) snprintf(self->err_str, MAX_ERR_LEN, format, ## args);
+#define printerr(str) strncpy(self->err_str, str, MAX_ERR_LEN);
+/* Save my typing */
 
-#endif /* LIBDVDNAV_DVDNAV_INTERNAL_H */
+#define S_ERR DVDNAV_STATUS_ERR
+#define S_OK  DVDNAV_STATUS_OK
+
+#endif /* DVDNAV_INTERNAL_H_INCLUDED */