[Scummvm-cvs-logs] CVS: scummvm/dc Makefile,1.4,1.5 README,1.1,1.2 audio.cpp,1.3,1.4 dc.h,1.4,1.5 dcmain.cpp,1.8,1.9 display.cpp,1.5,1.6 input.cpp,1.5,1.6 selector.cpp,1.9,1.10 vmsave.cpp,1.2,1.3

Marcus Comstedt marcus_c at users.sourceforge.net
Thu Apr 18 16:23:08 CEST 2002


Update of /cvsroot/scummvm/scummvm/dc
In directory usw-pr-cvs1:/tmp/cvs-serv20063

Modified Files:
	Makefile README audio.cpp dc.h dcmain.cpp display.cpp 
	input.cpp selector.cpp vmsave.cpp 
Log Message:
Megapatch: Updated to new OSystem interface and added CD audio.

Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/scummvm/dc/Makefile,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Makefile	16 Mar 2002 18:09:01 -0000	1.4
--- Makefile	18 Apr 2002 23:21:40 -0000	1.5
***************
*** 1,5 ****
  # $Header$
  
! ronindir = /usr/local/ronin
  
  VPATH = ..
--- 1,5 ----
  # $Header$
  
! ronindir = /home/marcus/hack/dreamcast/libronin
  
  VPATH = ..
***************
*** 7,11 ****
  CC      = sh-elf-g++ -ml -m4-single-only
  CFLAGS  = -O1 -Wno-multichar
! DEFINES = -D__DC__ -DNONSTANDARD_PORT -DUSE_ADLIB -DNONSTANDARD_SAVE
  LDFLAGS := -Wl,-Ttext,0x8c010000 -nostartfiles ronin/crt0.o
  INCLUDES:= -I./ -I../ -I../sound
--- 7,11 ----
  CC      = sh-elf-g++ -ml -m4-single-only
  CFLAGS  = -O1 -Wno-multichar
! DEFINES = -D__DC__ -DNONSTANDARD_PORT -DNONSTANDARD_SAVE
  LDFLAGS := -Wl,-Ttext,0x8c010000 -nostartfiles ronin/crt0.o
  INCLUDES:= -I./ -I../ -I../sound
***************
*** 18,23 ****
  	saveload.o script.o scummvm.o sound.o string.o \
  	sys.o verbs.o script_v1.o script_v2.o debug.o gui.o \
! 	sound/imuse.o sound/fmopl.o sound/adlib.o insane.o debugrl.o \
! 	akos.o vars.o dcmain.o display.o audio.o input.o selector.o icon.o \
  	label.o vmsave.o
  
--- 18,26 ----
  	saveload.o script.o scummvm.o sound.o string.o \
  	sys.o verbs.o script_v1.o script_v2.o debug.o gui.o \
! 	sound/imuse.o sound/fmopl.o sound/mixer.o debugrl.o \
! 	akos.o vars.o insane.o  gameDetector.o init.o mp3_cd.o \
! 	v3/resource_v3.o v4/resource_v4.o main.o \
! 	simon/midi.o simon/simon.o simon/simonsys.o sound/mididrv.o \
! 	dcmain.o display.o audio.o input.o selector.o icon.o \
  	label.o vmsave.o
  
***************
*** 30,37 ****
  	$(CC) $(LDFLAGS) -o $(@) $(OBJS) $(LIBS)
  
! $(OBJS): Makefile sound/.create ronin
  
  sound/.create:
  	mkdir sound && touch $@
  
  ronin:
--- 33,49 ----
  	$(CC) $(LDFLAGS) -o $(@) $(OBJS) $(LIBS)
  
! $(OBJS): Makefile sound/.create simon/.create v3/.create v4/.create ronin
  
  sound/.create:
  	mkdir sound && touch $@
+ 
+ simon/.create:
+ 	mkdir simon && touch $@
+ 
+ v3/.create:
+ 	mkdir v3 && touch $@
+ 
+ v4/.create:
+ 	mkdir v4 && touch $@
  
  ronin:

Index: README
===================================================================
RCS file: /cvsroot/scummvm/scummvm/dc/README,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** README	27 Feb 2002 01:12:49 -0000	1.1
--- README	18 Apr 2002 23:21:40 -0000	1.2
***************
*** 10,14 ****
  * newlib for sh-elf : <URL:http://mc.pp.se/dc/files/newlib-1.9.0.tar.gz>
  
! * libronin-0.2 : <URL:http://peter.bortas.org/scumm/libronin-0.2.tar.gz>
  
  * GNU make
--- 10,14 ----
  * newlib for sh-elf : <URL:http://mc.pp.se/dc/files/newlib-1.9.0.tar.gz>
  
! * libronin-0.3 : <URL:http://peter.bortas.org/scumm/libronin-0.3.tar.gz>
  
  * GNU make

Index: audio.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/dc/audio.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** audio.cpp	18 Feb 2002 18:58:15 -0000	1.3
--- audio.cpp	18 Apr 2002 23:21:40 -0000	1.4
***************
*** 25,41 ****
  #include "dc.h"
  
- #include <ronin/soundcommon.h>
- 
  EXTERN_C void *memcpy4(void *s1, const void *s2, unsigned int n);
- short temp_sound_buffer[RING_BUFFER_SAMPLES];
  
  void initSound()
  {
    stop_sound();
!   do_sound_command(CMD_SET_FREQ(0));
!   do_sound_command(CMD_SET_BUFFER(0));
  }
  
! void checkSound(Scumm *s)
  {
    int n;
--- 25,54 ----
  #include "dc.h"
  
  EXTERN_C void *memcpy4(void *s1, const void *s2, unsigned int n);
  
  void initSound()
  {
    stop_sound();
!   do_sound_command(CMD_SET_FREQ_EXP(FREQ_22050_EXP));
!   do_sound_command(CMD_SET_BUFFER(3));
  }
  
! bool OSystem_Dreamcast::set_sound_proc(void *param, SoundProc *proc,
! 				       byte format)
! {
! #if SAMPLE_MODE == 0
!   assert(format == SOUND_16BIT);
! #elif SAMPLE_MODE == 1
!   assert(format == SOUND_8BIT);
! #else
! #error Invalid SAMPLE_MODE
! #endif
!   _sound_proc_param = param;
!   _sound_proc = proc;
! 
!   return true;
! }
! 
! void OSystem_Dreamcast::checkSound()
  {
    int n;
***************
*** 57,61 ****
      return;
  
!   s->mixWaves((short*)temp_sound_buffer, n);
  
    if(fillpos+n > curr_ring_buffer_samples) {
--- 70,75 ----
      return;
  
!   _sound_proc(_sound_proc_param, (byte*)temp_sound_buffer,
! 	      SAMPLES_TO_BYTES(n));
  
    if(fillpos+n > curr_ring_buffer_samples) {

Index: dc.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/dc/dc.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** dc.h	16 Mar 2002 18:13:30 -0000	1.4
--- dc.h	18 Apr 2002 23:21:40 -0000	1.5
***************
*** 1,8 ****
  
  extern void initSound();
! extern void checkSound(Scumm *s);
! extern void handleInput(struct mapledev *pad, int16 &mouse_x, int16 &mouse_y,
! 			byte &leftBtnPressed, byte &rightBtnPressed,
! 			int &keyPressed);
! extern bool selectGame(Scumm *s, char *&, char *&, class Icon &);
  
--- 1,102 ----
+ #include <ronin/soundcommon.h>
+ 
+ #define NUM_BUFFERS 4
+ 
+ class OSystem_Dreamcast : public OSystem {
+ 
+  public:
+   // Set colors of the palette
+   void set_palette(const byte *colors, uint start, uint num);
+ 
+   // Set the size of the video bitmap.
+   // Typically, 320x200
+   void init_size(uint w, uint h);
+ 
+   // Draw a bitmap to screen.
+   // The screen will not be updated to reflect the new bitmap
+   void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h);
+ 
+   // Update the dirty areas of the screen
+   void update_screen();
+ 
+   // Either show or hide the mouse cursor
+   bool show_mouse(bool visible);
+   
+   // Set the position of the mouse cursor
+   void set_mouse_pos(int x, int y);
+   
+   // Set the bitmap that's used when drawing the cursor.
+   void set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y);
+   
+   // Shaking is used in SCUMM. Set current shake position.
+   void set_shake_pos(int shake_pos);
+ 
+   // Get the number of milliseconds since the program was started.
+   uint32 get_msecs();
+   
+   // Delay for a specified amount of milliseconds
+   void delay_msecs(uint msecs);
+   
+   // Create a thread
+   void *create_thread(ThreadProc *proc, void *param);
+ 	
+   // Get the next event.
+   // Returns true if an event was retrieved.	
+   bool poll_event(Event *event);
+   
+   // Set function that generates samples 
+   bool set_sound_proc(void *param, SoundProc *proc, byte sound);
+ 		
+   // Poll cdrom status
+   // Returns true if cd audio is playing
+   bool poll_cdrom();
  
+   // Play cdrom audio track
+   void play_cdrom(int track, int num_loops, int start_frame, int end_frame);
+   
+   // Stop cdrom audio track
+   void stop_cdrom();
+ 
+   // Update cdrom audio status
+   void update_cdrom();
+ 
+   // Quit
+   void quit();
+ 
+   // Set a parameter
+   uint32 property(int param, uint32 value);
+ 
+   static OSystem *create();
+ 
+ 
+  private:
+ 
+   int _ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_old_x, _ms_old_y;
+   int _ms_hotspot_x, _ms_hotspot_y, _ms_visible, _devpoll;
+   int _current_shake_pos;
+   unsigned char *_ms_buf;
+   SoundProc *_sound_proc;
+   void *_sound_proc_param;
+ 
+   unsigned char *screen;
+   unsigned short *mouse;
+   void *screen_tx[NUM_BUFFERS];
+   void *mouse_tx[NUM_BUFFERS];
+   int current_buffer;
+   unsigned short palette[256];
+ 
+   short temp_sound_buffer[RING_BUFFER_SAMPLES];
+ 
+   void checkSound();
+ 
+   void drawMouse(int xdraw, int ydraw, int w, int h,
+ 		 unsigned char *buf, bool visible);
+ 
+ };
+ 
+ extern int handleInput(struct mapledev *pad,
+ 		       int &mouse_x, int &mouse_y,
+ 		       byte &shiftFlags);
  extern void initSound();
! extern bool selectGame(GameDetector *d, char *&, char *&, class Icon &);
  

Index: dcmain.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/dc/dcmain.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** dcmain.cpp	14 Apr 2002 18:13:07 -0000	1.8
--- dcmain.cpp	18 Apr 2002 23:21:40 -0000	1.9
***************
*** 23,53 ****
  #include "stdafx.h"
  #include "scumm.h"
! #include "gui.h"
  #include "dc.h"
  #include "icon.h"
  
  
- Scumm scumm;
- ScummDebugger debugger;
- Gui gui;
  Icon icon;
  
- IMuse sound;
- SOUND_DRIVER_TYPE snd_driv;
  
! /* CD Audio stubs */
! void cd_playtrack(int track, int offset, int delay) {;}
! void cd_play(int track, int num_loops, int start_frame) {;}
! void cd_stop() {;}
! int cd_is_running() {return 0;}
  
! void launcherLoop() {
!   /* No launcher on DC yet => stub function */
  }
  
! void BoxTest(int num) {
!   /* No debugger on the DC => stub function */
  }
  
  void waitForTimer(Scumm *s, int time)
  {
--- 23,147 ----
  #include "stdafx.h"
  #include "scumm.h"
! #include "mididrv.h"
! #include "gameDetector.h"
  #include "dc.h"
  #include "icon.h"
  
  
  Icon icon;
  
  
! OSystem *OSystem_Dreamcast_create() {
! 	return OSystem_Dreamcast::create();
! }
  
! OSystem *OSystem_Dreamcast::create() {
! 	OSystem_Dreamcast *syst = new OSystem_Dreamcast();
! 	return syst;
  }
  
! /* CD Audio */
! static bool find_track(int track, int &first_sec, int &last_sec)
! {
!   struct TOC *toc = cdfs_gettoc();
!   if(!toc)
!     return false;
!   int i, first, last;
!   first = TOC_TRACK(toc->first);
!   last = TOC_TRACK(toc->last);
!   if(first < 1 || last > 99 || first > last)
!     return false;
!   for(i=last; i>=first; --i)
!     if(!(TOC_CTRL(toc->entry[i-1])&4))
!       if(track==1) {
! 	first_sec = TOC_LBA(toc->entry[i-1]);
! 	last_sec = TOC_LBA(toc->entry[i]);
! 	return true;
!       } else
! 	--track;
!   return false;
! }
! 
! void OSystem_Dreamcast::play_cdrom(int track, int num_loops,
! 				   int start_frame, int end_frame)
! {
!   int first_sec, last_sec;
! #if 1
!   if(num_loops)
!     --num_loops;
! #endif
!   if(num_loops>14) num_loops=14;
!   else if(num_loops<0) num_loops=15; // infinity
!   if(!find_track(track, first_sec, last_sec))
!     return;
!   if(end_frame)
!     last_sec = first_sec + start_frame + end_frame;
!   first_sec += start_frame;
!   play_cdda_sectors(first_sec, last_sec, num_loops);
! }
! 
! void OSystem_Dreamcast::stop_cdrom()
! {
!   stop_cdda();
! }
! 
! bool OSystem_Dreamcast::poll_cdrom()
! {
!   extern int getCdState();
!   return getCdState() == 3;
! }
! 
! void OSystem_Dreamcast::update_cdrom()
! {
!   // Dummy.  The CD drive takes care of itself.
! }
! 
! uint32 OSystem_Dreamcast::property(int param, uint32 value)
! {
!   switch(param) {
! 
!   case PROP_GET_SAMPLE_RATE:
!     return 22050;
! 
!   }
!   
!   return 0;
! }
! 
! void OSystem_Dreamcast::quit() {
!   exit(0);
! }
! 
! void *OSystem_Dreamcast::create_thread(ThreadProc *proc, void *param) {
!   warning("Creating a thread! (not supported.)\n");
! }
! 
! uint32 OSystem_Dreamcast::get_msecs()
! {
!   static uint32 msecs=0;
!   static unsigned int t0=0;
! 
!   unsigned int t = Timer();
!   unsigned int dm, dt = t - t0;
! 
!   t0 = t;
!   dm = (dt << 6)/3125U;
!   dt -= (dm * 3125U)>>6;
!   t0 -= dt;
! 
!   return msecs += dm;
  }
  
+ void OSystem_Dreamcast::delay_msecs(uint msecs)
+ {
+   get_msecs();
+   unsigned int t, start = Timer();
+   int time = (((unsigned int)msecs)*100000U)>>11;
+   while(((int)((t = Timer())-start))<time)
+     checkSound();
+   get_msecs();
+ }
+ 
+ /*
  void waitForTimer(Scumm *s, int time)
  {
***************
*** 63,67 ****
      if(((int)(t-devpoll))>0) {
        setimask(15);
!       checkSound(s);
        handleInput(locked_get_pads(), s->mouse.x, s->mouse.y,
  		  s->_leftBtnPressed, s->_rightBtnPressed, s->_keyPressed);
--- 157,161 ----
      if(((int)(t-devpoll))>0) {
        setimask(15);
!       checkSound();
        handleInput(locked_get_pads(), s->mouse.x, s->mouse.y,
  		  s->_leftBtnPressed, s->_rightBtnPressed, s->_keyPressed);
***************
*** 69,72 ****
--- 163,167 ----
        devpoll += USEC_TO_TIMER(17000);
        if(s->mouse.x != oldmousex || s->mouse.y != oldmousey) {
+ 	extern void updateScreen(Scumm *s);
  	updateScreen(s);
  	oldmousex = s->mouse.x;
***************
*** 75,86 ****
      }
  }
  
! static char *argv[] = { "scummvm", NULL, NULL, NULL };
! static int argc = 3;
! 
! int main()
  {
!   int delta,tmp;
!   int last_time, new_time;
  
  #ifndef NOSERIAL
--- 170,179 ----
      }
  }
+ */
  
! int dc_setup(GameDetector &detector)
  {
!   static char *argv[] = { "scummvm", NULL, NULL, NULL };
!   static int argc = 3;
  
  #ifndef NOSERIAL
***************
*** 97,128 ****
    initSound();
  
!   if(!selectGame(&scumm, argv[2], argv[1], icon))
      exit(0);
  
!   sound.initialize(&scumm, &snd_driv);
! 
!   scumm._gui = &gui;
!   scumm.scummMain(argc, argv);
! 
!   gui.init(&scumm);
! 
!   last_time = Timer();
!   delta = 0;
!   do {
!     updateScreen(&scumm);
! 
!     new_time = Timer();
!     waitForTimer(&scumm, delta * 15 - ((new_time - last_time)<<11)/100000);
!     last_time = Timer();
  
!     if (gui._active) {
!       gui.loop();
!       delta = 5;
!     } else {
!       delta = scumm.scummLoop(delta);
!     }
!   } while(1);
!   
!   /* NOTREACHED */
!   exit(0);
  }
--- 190,198 ----
    initSound();
  
!   if(!selectGame(&detector, argv[2], argv[1], icon))
      exit(0);
  
!   //  sound.initialize(&scumm, &snd_driv);
  
!   detector.parseCommandLine(argc, argv);
  }

Index: display.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/dc/display.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** display.cpp	12 Apr 2002 21:26:35 -0000	1.5
--- display.cpp	18 Apr 2002 23:21:40 -0000	1.6
***************
*** 29,33 ****
  #define MOUSE_W 64
  #define MOUSE_H 64
- #define NUM_BUFFERS 4
  
  #define TOP_OFFSET 40.0
--- 29,32 ----
***************
*** 37,49 ****
  
  
- static unsigned char *screen = NULL;
- static unsigned short *mouse = NULL;
- static void *screen_tx[NUM_BUFFERS] = { NULL, };
- static void *mouse_tx[NUM_BUFFERS] = { NULL, };
- static int current_buffer = 0;
- static int shakePos = 0;
- unsigned short palette[256];
- 
- 
  #define COPYPIXEL(n) do {			\
    unsigned short _tmp = pal[*s++];		\
--- 36,39 ----
***************
*** 101,136 ****
  
  
! void updatePalette(Scumm *s)
  {
!   int first = s->_palDirtyMin;
!   int num = s->_palDirtyMax - first + 1;
!   unsigned char *src = s->_currentPalette;
!   unsigned short *dst = palette + first;
!   src += first*3;
    if(num>0)
      while( num-- ) {
!       *dst++ = ((src[0]<<7)&0x7c00)|
! 	((src[1]<<2)&0x03e0)|
! 	((src[2]>>3)&0x001f);
!       src += 3;
      }
  }
  
! void blitToScreen(Scumm *s, unsigned char *src, int x, int y, int w, int h)
  {
    unsigned char *dst = screen + y*SCREEN_W + x;
    do {
!     memcpy(dst, src, w);
      dst += SCREEN_W;
!     src += SCREEN_W;
    } while (--h);
  }
  
! void setShakePos(Scumm *s, int shake_pos)
  {
!   shakePos = shake_pos;
  }
  
! void updateScreen(Scumm *s)
  {
    struct polygon_list mypoly;
--- 91,167 ----
  
  
! void OSystem_Dreamcast::set_palette(const byte *colors, uint start, uint num)
  {
!   unsigned short *dst = palette + start;
    if(num>0)
      while( num-- ) {
!       *dst++ = ((colors[0]<<7)&0x7c00)|
! 	((colors[1]<<2)&0x03e0)|
! 	((colors[2]>>3)&0x001f);
!       colors += 4;
      }
  }
  
! void OSystem_Dreamcast::init_size(uint w, uint h)
! {
!   assert(w == SCREEN_W && h == SCREEN_H);
! 
!   ta_sync();
!   if(!screen)
!     screen = new unsigned char[SCREEN_W*SCREEN_H];
!   for(int i=0; i<NUM_BUFFERS; i++)
!     if(!screen_tx[i])
!       screen_tx[i] = ta_txalloc(SCREEN_W*SCREEN_H*2);
!   for(int i=0; i<NUM_BUFFERS; i++)
!     if(!mouse_tx[i])
!       mouse_tx[i] = ta_txalloc(MOUSE_W*MOUSE_H*2);
!   current_buffer = 0;
!   *(volatile unsigned int *)(0xa05f80e4) = SCREEN_W/32; //stride
!   //  dc_reset_screen(0, 0);
! }
! 
! void OSystem_Dreamcast::copy_rect(const byte *buf, int pitch, int x, int y,
! 				  int w, int h)
  {
    unsigned char *dst = screen + y*SCREEN_W + x;
    do {
!     memcpy(dst, buf, w);
      dst += SCREEN_W;
!     buf += pitch;
    } while (--h);
  }
  
! bool OSystem_Dreamcast::show_mouse(bool visible)
! {	
!   bool last = _ms_visible;
!   _ms_visible = visible;
! 
!   return last;
! }
! 
! void OSystem_Dreamcast::set_mouse_pos(int x, int y)
  {
!   _ms_cur_x = x;
!   _ms_cur_y = y;
  }
  
! void OSystem_Dreamcast::set_mouse_cursor(const byte *buf, uint w, uint h,
! 					 int hotspot_x, int hotspot_y)
! {
!   _ms_cur_w = w;
!   _ms_cur_h = h;
!   
!   _ms_hotspot_x = hotspot_x;
!   _ms_hotspot_y = hotspot_y;
!   
!   _ms_buf = (byte*)buf;
! }
! 
! void OSystem_Dreamcast::set_shake_pos(int shake_pos)
! {
!   _current_shake_pos = shake_pos;
! }
! 
! void OSystem_Dreamcast::update_screen(void)
  {
    struct polygon_list mypoly;
***************
*** 143,150 ****
    // *((volatile unsigned int *)(void*)0xa05f8040) = 0xff0000;
    
-   if(s->_palDirtyMax != -1) {
-     updatePalette(s);
-   }
- 
    for( int y = 0; y<SCREEN_H; y++ )
    {
--- 174,177 ----
***************
*** 180,184 ****
  
    myvertex.x = 0.0;
!   myvertex.y = shakePos*2.0+TOP_OFFSET;
    ta_commit_list(&myvertex);
  
--- 207,211 ----
  
    myvertex.x = 0.0;
!   myvertex.y = _current_shake_pos*2.0+TOP_OFFSET;
    ta_commit_list(&myvertex);
  
***************
*** 200,204 ****
    ta_commit_end();
    // *((volatile unsigned int *)(void*)0xa05f8040) = 0xffff00;
!   s->drawMouse();
    // *((volatile unsigned int *)(void*)0xa05f8040) = 0xff00ff;
    ta_commit_frame();
--- 227,231 ----
    ta_commit_end();
    // *((volatile unsigned int *)(void*)0xa05f8040) = 0xffff00;
!   drawMouse(_ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_buf, _ms_visible);
    // *((volatile unsigned int *)(void*)0xa05f8040) = 0xff00ff;
    ta_commit_frame();
***************
*** 209,214 ****
  }
  
! void drawMouse(int xdraw, int ydraw, int w, int h,
! 	       unsigned char *buf, bool visible)
  {
    struct polygon_list mypoly;
--- 236,241 ----
  }
  
! void OSystem_Dreamcast::drawMouse(int xdraw, int ydraw, int w, int h,
! 				  unsigned char *buf, bool visible)
  {
    struct polygon_list mypoly;
***************
*** 254,259 ****
    myvertex.v = 0.0;
  
!   myvertex.x = xdraw*2.0;
!   myvertex.y = (ydraw+shakePos)*2.0 + TOP_OFFSET;
    ta_commit_list(&myvertex);
  
--- 281,286 ----
    myvertex.v = 0.0;
  
!   myvertex.x = (xdraw-_ms_hotspot_y)*2.0;
!   myvertex.y = (ydraw+_current_shake_pos-_ms_hotspot_x)*2.0 + TOP_OFFSET;
    ta_commit_list(&myvertex);
  
***************
*** 262,266 ****
    ta_commit_list(&myvertex);
  
!   myvertex.x = xdraw*2.0;
    myvertex.y += h*2.0;
    myvertex.u = 0.0;
--- 289,293 ----
    ta_commit_list(&myvertex);
  
!   myvertex.x = (xdraw-_ms_hotspot_y)*2.0;
    myvertex.y += h*2.0;
    myvertex.u = 0.0;
***************
*** 274,291 ****
  }
  
- void initGraphics(Scumm *s, bool fullScreen, unsigned int scaleFactor)
- {
-   ta_sync();
-   if(!screen)
-     screen = new unsigned char[SCREEN_W*SCREEN_H];
-   for(int i=0; i<NUM_BUFFERS; i++)
-     if(!screen_tx[i])
-       screen_tx[i] = ta_txalloc(SCREEN_W*SCREEN_H*2);
-   for(int i=0; i<NUM_BUFFERS; i++)
-     if(!mouse_tx[i])
-       mouse_tx[i] = ta_txalloc(MOUSE_W*MOUSE_H*2);
-   current_buffer = 0;
-   shakePos = 0;
-   *(volatile unsigned int *)(0xa05f80e4) = SCREEN_W/32; //stride
-   //  dc_reset_screen(0, 0);
- }
--- 301,302 ----

Index: input.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/dc/input.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** input.cpp	3 Feb 2002 14:54:11 -0000	1.5
--- input.cpp	18 Apr 2002 23:21:40 -0000	1.6
***************
*** 25,34 ****
  #include "dc.h"
  
! void handleInput(struct mapledev *pad, int16 &mouse_x, int16 &mouse_y,
! 		 byte &leftBtnPressed, byte &rightBtnPressed, int &keyPressed)
  {
    int lmb=0, rmb=0, newkey=0;
    static int lastkey = 0;
    static byte lastlmb = 0, lastrmb = 0;
    for(int i=0; i<4; i++, pad++)
      if(pad->func & MAPLE_FUNC_CONTROLLER) {
--- 25,35 ----
  #include "dc.h"
  
! int handleInput(struct mapledev *pad, int &mouse_x, int &mouse_y,
! 		byte &shiftFlags)
  {
    int lmb=0, rmb=0, newkey=0;
    static int lastkey = 0;
    static byte lastlmb = 0, lastrmb = 0;
+   shiftFlags = 0;
    for(int i=0; i<4; i++, pad++)
      if(pad->func & MAPLE_FUNC_CONTROLLER) {
***************
*** 69,74 ****
  	if(shift & 0x08) lmb++;
  	if(shift & 0x80) rmb++;
  	if(key >= 4 && key <= 0x1d)
! 	  newkey = key+((shift & 0x22)? ('A'-4) : ('a'-4));
  	else if(key >= 0x1e && key <= 0x26)
  	  newkey = key+((shift & 0x22)? ('!'-0x1e) : ('1'-0x1e));
--- 70,78 ----
  	if(shift & 0x08) lmb++;
  	if(shift & 0x80) rmb++;
+ 	if(shift & 0x11) shiftFlags |= OSystem::KBD_CTRL;
+ 	if(shift & 0x44) shiftFlags |= OSystem::KBD_ALT;
+ 	if(shift & 0x22) shiftFlags |= OSystem::KBD_SHIFT;
  	if(key >= 4 && key <= 0x1d)
! 	  newkey = key+('a'-4);
  	else if(key >= 0x1e && key <= 0x26)
  	  newkey = key+((shift & 0x22)? ('!'-0x1e) : ('1'-0x1e));
***************
*** 107,122 ****
  
    if(lmb && !lastlmb) {
-     leftBtnPressed |= msClicked|msDown;
      lastlmb = 1;
    } else if(lastlmb && !lmb) {
-     leftBtnPressed &= ~msDown;
      lastlmb = 0;
    }
    if(rmb && !lastrmb) {
-     rightBtnPressed |= msClicked|msDown;
      lastrmb = 1;
    } else if(lastrmb && !rmb) {
-     rightBtnPressed &= ~msDown;    
      lastrmb = 0;
    }
  
--- 111,126 ----
  
    if(lmb && !lastlmb) {
      lastlmb = 1;
+     return -OSystem::EVENT_LBUTTONDOWN;
    } else if(lastlmb && !lmb) {
      lastlmb = 0;
+     return -OSystem::EVENT_LBUTTONUP;
    }
    if(rmb && !lastrmb) {
      lastrmb = 1;
+     return -OSystem::EVENT_RBUTTONDOWN;
    } else if(lastrmb && !rmb) {
      lastrmb = 0;
+     return -OSystem::EVENT_RBUTTONUP;
    }
  
***************
*** 124,133 ****
      lastkey = 0;
    else if(newkey != lastkey)
!     keyPressed = lastkey = newkey;
  
!   if (mouse_x<0) mouse_x=0;
!   if (mouse_x>319) mouse_x=319;
!   if (mouse_y<0) mouse_y=0;
!   if (mouse_y>199) mouse_y=199;
  }
  
--- 128,173 ----
      lastkey = 0;
    else if(newkey != lastkey)
!     return lastkey = newkey;
  
!   return 0;
! }
! 
! bool OSystem_Dreamcast::poll_event(Event *event)
! {
!   unsigned int t = Timer();
!   if(((int)(t-_devpoll))<0)
!     return false;
!   _devpoll += USEC_TO_TIMER(17000);
!   int mask = getimask();
!   setimask(15);
!   checkSound();
!   int e = handleInput(locked_get_pads(), _ms_cur_x, _ms_cur_y,
! 		      event->kbd.flags);
!   setimask(mask);
!   if (_ms_cur_x<0) _ms_cur_x=0;
!   if (_ms_cur_x>319) _ms_cur_x=319;
!   if (_ms_cur_y<0) _ms_cur_y=0;
!   if (_ms_cur_y>199) _ms_cur_y=199;
!   event->mouse.x = _ms_cur_x;
!   event->mouse.y = _ms_cur_y;
!   event->kbd.ascii = event->kbd.keycode = 0;
!   if(e<0) {
!     event->event_code = -e;
!     return true;
!   } else if(e>0) {
!     event->event_code = EVENT_KEYDOWN;
!     event->kbd.keycode = e;
!     event->kbd.ascii = (e>='a' && e<='z' && (event->kbd.flags & KBD_SHIFT)?
! 			e &~ 0x20 : e);
!     return true;
!   } else if(_ms_cur_x != _ms_old_x || _ms_cur_y != _ms_old_y) {
!     event->event_code = EVENT_MOUSEMOVE;
!     _ms_old_x = _ms_cur_x;
!     _ms_old_y = _ms_cur_y;
!     return true;
!   } else {
!     event->event_code = 0;
!     return false;
!   }
  }
  

Index: selector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/dc/selector.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** selector.cpp	16 Mar 2002 18:42:28 -0000	1.9
--- selector.cpp	18 Apr 2002 23:21:40 -0000	1.10
***************
*** 23,26 ****
--- 23,28 ----
  #include "stdafx.h"
  #include "scumm.h"
+ #include "mididrv.h"
+ #include "gameDetector.h"
  #include "dc.h"
  #include "icon.h"
***************
*** 160,173 ****
  }
  
! static void checkName(Scumm *s, Game &game)
  {
!   s->_exe_name = game.filename_base;
!   if(s->detectGame()) {
!     char *n = s->getGameName();
      strcpy(game.text, n);
      free(n);
    } else
      strcpy(game.text, game.filename_base);
!   s->_exe_name = NULL;
  }
  
--- 162,186 ----
  }
  
! static void checkName(GameDetector *d, Game &game)
  {
!   d->_exe_name = game.filename_base;
!   if(d->detectGame()) {
!     char *n = d->getGameName();
      strcpy(game.text, n);
      free(n);
    } else
      strcpy(game.text, game.filename_base);
!   d->_exe_name = NULL;
! }
! 
! static bool checkExe(const char *dir, const char *f)
! {
!   char fn[520];
!   int fd;
!   sprintf(fn, "%s%s.EXE", dir, f);
!   if((fd = open(fn, O_RDONLY))<0)
!     return false;
!   close(fd);
!   return true;
  }
  
***************
*** 203,207 ****
  }
  
! static int findGames(Scumm *s, Game *games, int max)
  {
    Dir *dirs = new Dir[MAX_DIR];
--- 216,220 ----
  }
  
! static int findGames(GameDetector *d, Game *games, int max)
  {
    Dir *dirs = new Dir[MAX_DIR];
***************
*** 243,248 ****
  #endif
  	      }
  	    }
! 	    checkName(s, games[curr_game]);
  #if 0
  	    printf("Registered game <%s> in <%s> <%s> because of <%s> <%s>\n",
--- 256,263 ----
  #endif
  	      }
+ 	      if(checkExe(games[curr_game].dir, "loom"))
+ 		strcpy(games[curr_game].filename_base, "loomcd");
  	    }
! 	    checkName(d, games[curr_game]);
  #if 0
  	    printf("Registered game <%s> in <%s> <%s> because of <%s> <%s>\n",
***************
*** 307,317 ****
      ta_commit_frame();
  
!     int16 mousex = 0, mousey = 0;
!     byte lmb=0, rmb=0;
!     int key=0;
  
      int mask = getimask();
      setimask(15);
!     handleInput(locked_get_pads(), mousex, mousey, lmb, rmb, key);
      setimask(mask);
    }
--- 322,331 ----
      ta_commit_frame();
  
!     int mousex = 0, mousey = 0;
!     byte shiftFlags;
  
      int mask = getimask();
      setimask(15);
!     handleInput(locked_get_pads(), mousex, mousey, shiftFlags);
      setimask(mask);
    }
***************
*** 330,334 ****
  {
    int top_game = 0, selector_pos = 0;
!   int16 mousex = 0, mousey = 64;
  
    if(!num_games)
--- 344,348 ----
  {
    int top_game = 0, selector_pos = 0;
!   int mousex = 0, mousey = 0;
  
    if(!num_games)
***************
*** 362,374 ****
      ta_commit_frame();
  
!     byte lmb=0, rmb=0;
!     int key=0;
  
      int mask = getimask();
      setimask(15);
!     handleInput(locked_get_pads(), mousex, mousey, lmb, rmb, key);
      setimask(mask);
      
!     if(lmb || key==13 || key==319) {
        int selected_game = top_game + selector_pos;
  
--- 376,388 ----
      ta_commit_frame();
  
!     byte shiftFlags;
!     int event;
  
      int mask = getimask();
      setimask(15);
!     event = handleInput(locked_get_pads(), mousex, mousey, shiftFlags);
      setimask(mask);
      
!     if(event==-OSystem::EVENT_LBUTTONDOWN || event==13 || event==319) {
        int selected_game = top_game + selector_pos;
  
***************
*** 403,407 ****
      }
  
!     if(mousey>=64+16) {
        if(selector_pos + top_game + 1 < num_games)
  	if(++selector_pos >= 10) {
--- 417,421 ----
      }
  
!     if(mousey>=16) {
        if(selector_pos + top_game + 1 < num_games)
  	if(++selector_pos >= 10) {
***************
*** 410,414 ****
  	}
        mousey -= 16;
!     } else if(mousey<=64-16) {
        if(selector_pos + top_game > 0)
  	if(--selector_pos < 0) {
--- 424,428 ----
  	}
        mousey -= 16;
!     } else if(mousey<=-16) {
        if(selector_pos + top_game > 0)
  	if(--selector_pos < 0) {
***************
*** 421,425 ****
  }
  
! bool selectGame(Scumm *s, char *&ret, char *&dir_ret, Icon &icon)
  {
    Game *games = new Game[MAX_GAMES];
--- 435,439 ----
  }
  
! bool selectGame(GameDetector *d, char *&ret, char *&dir_ret, Icon &icon)
  {
    Game *games = new Game[MAX_GAMES];
***************
*** 430,434 ****
  
    for(;;) {
!     num_games = findGames(s, games, MAX_GAMES);
  
      for(int i=0; i<num_games; i++) {
--- 444,448 ----
  
    for(;;) {
!     num_games = findGames(d, games, MAX_GAMES);
  
      for(int i=0; i<num_games; i++) {

Index: vmsave.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/dc/vmsave.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** vmsave.cpp	27 Feb 2002 01:02:16 -0000	1.2
--- vmsave.cpp	18 Apr 2002 23:21:40 -0000	1.3
***************
*** 23,26 ****
--- 23,28 ----
  #include "stdafx.h"
  #include "scumm.h"
+ #include "mididrv.h"
+ #include "gameDetector.h"
  #include "dc.h"
  #include "icon.h"
***************
*** 43,47 ****
  static int lastvm=-1;
  
! static vmsaveResult trySave(Scumm *s, const char *data, int size,
  			    const char *filename, class Icon &icon, int vm)
  {
--- 45,49 ----
  static int lastvm=-1;
  
! static vmsaveResult trySave(GameDetector *d, const char *data, int size,
  			    const char *filename, class Icon &icon, int vm)
  {
***************
*** 67,71 ****
    memset(&header, 0, sizeof(header));
    strncpy(header.shortdesc, "ScummVM savegame", 16);
!   char *game_name = s->getGameName();
    strncpy(header.longdesc, game_name, 32);
    free(game_name);
--- 69,73 ----
    memset(&header, 0, sizeof(header));
    strncpy(header.shortdesc, "ScummVM savegame", 16);
!   char *game_name = d->getGameName();
    strncpy(header.longdesc, game_name, 32);
    free(game_name);
***************
*** 126,130 ****
  }
  
! vmsaveResult writeSaveGame(Scumm *s, const char *data, int size,
  			   const char *filename, class Icon &icon)
  {
--- 128,132 ----
  }
  
! vmsaveResult writeSaveGame(GameDetector *d, const char *data, int size,
  			   const char *filename, class Icon &icon)
  {
***************
*** 132,140 ****
  
    if(lastvm >= 0 &&
!      (res = trySave(s, data, size, filename, icon, lastvm)) == VMSAVE_OK)
      return res;
  
    for(int i=0; i<24; i++)
!     if((r = trySave(s, data, size, filename, icon, i)) == VMSAVE_OK) {
        lastvm = i;
        return r;
--- 134,142 ----
  
    if(lastvm >= 0 &&
!      (res = trySave(d, data, size, filename, icon, lastvm)) == VMSAVE_OK)
      return res;
  
    for(int i=0; i<24; i++)
!     if((r = trySave(d, data, size, filename, icon, i)) == VMSAVE_OK) {
        lastvm = i;
        return r;
***************
*** 201,205 ****
  void SerializerStream::fclose()
  {
!   extern Scumm scumm;
    extern Icon icon;
  
--- 203,207 ----
  void SerializerStream::fclose()
  {
!   extern GameDetector detector;
    extern Icon icon;
  
***************
*** 217,221 ****
  	} else delete compbuf;
        }
!       writeSaveGame(&scumm, c->buffer, c->pos,
  		    c->filename, icon);
      }
--- 219,223 ----
  	} else delete compbuf;
        }
!       writeSaveGame(&detector, c->buffer, c->pos,
  		    c->filename, icon);
      }





More information about the Scummvm-git-logs mailing list