mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-18 23:57:32 +00:00
Megapatch: Updated to new OSystem interface and added CD audio.
svn-id: r3998
This commit is contained in:
parent
8a7ca8133c
commit
aa8f15a828
22
dc/Makefile
22
dc/Makefile
@ -1,12 +1,12 @@
|
||||
# $Header$
|
||||
|
||||
ronindir = /usr/local/ronin
|
||||
ronindir = /home/marcus/hack/dreamcast/libronin
|
||||
|
||||
VPATH = ..
|
||||
|
||||
CC = sh-elf-g++ -ml -m4-single-only
|
||||
CFLAGS = -O1 -Wno-multichar
|
||||
DEFINES = -D__DC__ -DNONSTANDARD_PORT -DUSE_ADLIB -DNONSTANDARD_SAVE
|
||||
DEFINES = -D__DC__ -DNONSTANDARD_PORT -DNONSTANDARD_SAVE
|
||||
LDFLAGS := -Wl,-Ttext,0x8c010000 -nostartfiles ronin/crt0.o
|
||||
INCLUDES:= -I./ -I../ -I../sound
|
||||
CPPFLAGS= $(DEFINES) $(INCLUDES)
|
||||
@ -17,8 +17,11 @@ INCS = scumm.h scummsys.h stdafx.h portdefs.h dc.h
|
||||
OBJS = actor.o boxes.o costume.o gfx.o object.o resource.o \
|
||||
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 \
|
||||
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
|
||||
|
||||
.cpp.o:
|
||||
@ -29,11 +32,20 @@ all: scummvm
|
||||
scummvm: $(OBJS) ronin
|
||||
$(CC) $(LDFLAGS) -o $(@) $(OBJS) $(LIBS)
|
||||
|
||||
$(OBJS): Makefile sound/.create ronin
|
||||
$(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:
|
||||
ln -s $(ronindir) $@
|
||||
|
||||
|
@ -9,7 +9,7 @@ you'll need the following:
|
||||
|
||||
* 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>
|
||||
* libronin-0.3 : <URL:http://peter.bortas.org/scumm/libronin-0.3.tar.gz>
|
||||
|
||||
* GNU make
|
||||
|
||||
|
28
dc/audio.cpp
28
dc/audio.cpp
@ -24,19 +24,32 @@
|
||||
#include "scumm.h"
|
||||
#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));
|
||||
do_sound_command(CMD_SET_FREQ_EXP(FREQ_22050_EXP));
|
||||
do_sound_command(CMD_SET_BUFFER(3));
|
||||
}
|
||||
|
||||
void checkSound(Scumm *s)
|
||||
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;
|
||||
int curr_ring_buffer_samples;
|
||||
@ -56,7 +69,8 @@ void checkSound(Scumm *s)
|
||||
if(n<100)
|
||||
return;
|
||||
|
||||
s->mixWaves((short*)temp_sound_buffer, n);
|
||||
_sound_proc(_sound_proc_param, (byte*)temp_sound_buffer,
|
||||
SAMPLES_TO_BYTES(n));
|
||||
|
||||
if(fillpos+n > curr_ring_buffer_samples) {
|
||||
int r = curr_ring_buffer_samples - fillpos;
|
||||
|
104
dc/dc.h
104
dc/dc.h
@ -1,8 +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 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 &);
|
||||
extern bool selectGame(GameDetector *d, char *&, char *&, class Icon &);
|
||||
|
||||
|
168
dc/dcmain.cpp
168
dc/dcmain.cpp
@ -22,33 +22,127 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "scumm.h"
|
||||
#include "gui.h"
|
||||
#include "mididrv.h"
|
||||
#include "gameDetector.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 */
|
||||
OSystem *OSystem_Dreamcast_create() {
|
||||
return OSystem_Dreamcast::create();
|
||||
}
|
||||
|
||||
void BoxTest(int num) {
|
||||
/* No debugger on the DC => stub function */
|
||||
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)
|
||||
{
|
||||
if(time<0)
|
||||
@ -62,26 +156,25 @@ void waitForTimer(Scumm *s, int time)
|
||||
while(((int)((t = Timer())-start))<time)
|
||||
if(((int)(t-devpoll))>0) {
|
||||
setimask(15);
|
||||
checkSound(s);
|
||||
checkSound();
|
||||
handleInput(locked_get_pads(), s->mouse.x, s->mouse.y,
|
||||
s->_leftBtnPressed, s->_rightBtnPressed, s->_keyPressed);
|
||||
setimask(mask);
|
||||
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;
|
||||
oldmousey = s->mouse.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
static char *argv[] = { "scummvm", NULL, NULL, NULL };
|
||||
static int argc = 3;
|
||||
|
||||
int main()
|
||||
int dc_setup(GameDetector &detector)
|
||||
{
|
||||
int delta,tmp;
|
||||
int last_time, new_time;
|
||||
static char *argv[] = { "scummvm", NULL, NULL, NULL };
|
||||
static int argc = 3;
|
||||
|
||||
#ifndef NOSERIAL
|
||||
serial_init(57600);
|
||||
@ -96,33 +189,10 @@ int main()
|
||||
|
||||
initSound();
|
||||
|
||||
if(!selectGame(&scumm, argv[2], argv[1], icon))
|
||||
if(!selectGame(&detector, argv[2], argv[1], icon))
|
||||
exit(0);
|
||||
|
||||
sound.initialize(&scumm, &snd_driv);
|
||||
// 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);
|
||||
detector.parseCommandLine(argc, argv);
|
||||
}
|
||||
|
119
dc/display.cpp
119
dc/display.cpp
@ -28,7 +28,6 @@
|
||||
#define SCREEN_H 200
|
||||
#define MOUSE_W 64
|
||||
#define MOUSE_H 64
|
||||
#define NUM_BUFFERS 4
|
||||
|
||||
#define TOP_OFFSET 40.0
|
||||
|
||||
@ -36,15 +35,6 @@
|
||||
#define QACR1 (*(volatile unsigned int *)(void *)0xff00003c)
|
||||
|
||||
|
||||
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++]; \
|
||||
d[n] = _tmp|(pal[*s++]<<16); \
|
||||
@ -100,38 +90,79 @@ void commit_dummy_transpoly()
|
||||
}
|
||||
|
||||
|
||||
void updatePalette(Scumm *s)
|
||||
void OSystem_Dreamcast::set_palette(const byte *colors, uint start, uint num)
|
||||
{
|
||||
int first = s->_palDirtyMin;
|
||||
int num = s->_palDirtyMax - first + 1;
|
||||
unsigned char *src = s->_currentPalette;
|
||||
unsigned short *dst = palette + first;
|
||||
src += first*3;
|
||||
unsigned short *dst = palette + start;
|
||||
if(num>0)
|
||||
while( num-- ) {
|
||||
*dst++ = ((src[0]<<7)&0x7c00)|
|
||||
((src[1]<<2)&0x03e0)|
|
||||
((src[2]>>3)&0x001f);
|
||||
src += 3;
|
||||
*dst++ = ((colors[0]<<7)&0x7c00)|
|
||||
((colors[1]<<2)&0x03e0)|
|
||||
((colors[2]>>3)&0x001f);
|
||||
colors += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void blitToScreen(Scumm *s, unsigned char *src, int x, int y, int w, int h)
|
||||
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, src, w);
|
||||
memcpy(dst, buf, w);
|
||||
dst += SCREEN_W;
|
||||
src += SCREEN_W;
|
||||
buf += pitch;
|
||||
} while (--h);
|
||||
}
|
||||
|
||||
void setShakePos(Scumm *s, int shake_pos)
|
||||
{
|
||||
shakePos = shake_pos;
|
||||
bool OSystem_Dreamcast::show_mouse(bool visible)
|
||||
{
|
||||
bool last = _ms_visible;
|
||||
_ms_visible = visible;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
void updateScreen(Scumm *s)
|
||||
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;
|
||||
struct packed_colour_vertex_list myvertex;
|
||||
@ -142,10 +173,6 @@ void updateScreen(Scumm *s)
|
||||
// while((*((volatile unsigned int *)(void*)0xa05f810c) & 0x3ff) != 200);
|
||||
// *((volatile unsigned int *)(void*)0xa05f8040) = 0xff0000;
|
||||
|
||||
if(s->_palDirtyMax != -1) {
|
||||
updatePalette(s);
|
||||
}
|
||||
|
||||
for( int y = 0; y<SCREEN_H; y++ )
|
||||
{
|
||||
texture_memcpy64_pal( dst, src, SCREEN_W>>5, palette );
|
||||
@ -179,7 +206,7 @@ void updateScreen(Scumm *s)
|
||||
myvertex.v = 0.0;
|
||||
|
||||
myvertex.x = 0.0;
|
||||
myvertex.y = shakePos*2.0+TOP_OFFSET;
|
||||
myvertex.y = _current_shake_pos*2.0+TOP_OFFSET;
|
||||
ta_commit_list(&myvertex);
|
||||
|
||||
myvertex.x = SCREEN_W*2.0;
|
||||
@ -199,7 +226,7 @@ void updateScreen(Scumm *s)
|
||||
|
||||
ta_commit_end();
|
||||
// *((volatile unsigned int *)(void*)0xa05f8040) = 0xffff00;
|
||||
s->drawMouse();
|
||||
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();
|
||||
|
||||
@ -208,8 +235,8 @@ void updateScreen(Scumm *s)
|
||||
// *((volatile unsigned int *)(void*)0xa05f8040) = 0x0;
|
||||
}
|
||||
|
||||
void drawMouse(int xdraw, int ydraw, int w, int h,
|
||||
unsigned char *buf, bool visible)
|
||||
void OSystem_Dreamcast::drawMouse(int xdraw, int ydraw, int w, int h,
|
||||
unsigned char *buf, bool visible)
|
||||
{
|
||||
struct polygon_list mypoly;
|
||||
struct packed_colour_vertex_list myvertex;
|
||||
@ -253,15 +280,15 @@ void drawMouse(int xdraw, int ydraw, int w, int h,
|
||||
myvertex.u = 0.0;
|
||||
myvertex.v = 0.0;
|
||||
|
||||
myvertex.x = xdraw*2.0;
|
||||
myvertex.y = (ydraw+shakePos)*2.0 + TOP_OFFSET;
|
||||
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);
|
||||
|
||||
myvertex.x += w*2.0;
|
||||
myvertex.u = w*(1.0/MOUSE_W);
|
||||
ta_commit_list(&myvertex);
|
||||
|
||||
myvertex.x = xdraw*2.0;
|
||||
myvertex.x = (xdraw-_ms_hotspot_y)*2.0;
|
||||
myvertex.y += h*2.0;
|
||||
myvertex.u = 0.0;
|
||||
myvertex.v = h*(1.0/MOUSE_H);
|
||||
@ -273,19 +300,3 @@ void drawMouse(int xdraw, int ydraw, int w, int h,
|
||||
ta_commit_list(&myvertex);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
64
dc/input.cpp
64
dc/input.cpp
@ -24,12 +24,13 @@
|
||||
#include "scumm.h"
|
||||
#include "dc.h"
|
||||
|
||||
void handleInput(struct mapledev *pad, int16 &mouse_x, int16 &mouse_y,
|
||||
byte &leftBtnPressed, byte &rightBtnPressed, int &keyPressed)
|
||||
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) {
|
||||
int buttons = pad->cond.controller.buttons;
|
||||
@ -68,8 +69,11 @@ void handleInput(struct mapledev *pad, int16 &mouse_x, int16 &mouse_y,
|
||||
int key = pad->cond.kbd.key[p];
|
||||
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+((shift & 0x22)? ('A'-4) : ('a'-4));
|
||||
newkey = key+('a'-4);
|
||||
else if(key >= 0x1e && key <= 0x26)
|
||||
newkey = key+((shift & 0x22)? ('!'-0x1e) : ('1'-0x1e));
|
||||
else if(key >= 0x59 && key <= 0x61)
|
||||
@ -106,28 +110,64 @@ void handleInput(struct mapledev *pad, int16 &mouse_x, int16 &mouse_y,
|
||||
}
|
||||
|
||||
if(lmb && !lastlmb) {
|
||||
leftBtnPressed |= msClicked|msDown;
|
||||
lastlmb = 1;
|
||||
return -OSystem::EVENT_LBUTTONDOWN;
|
||||
} else if(lastlmb && !lmb) {
|
||||
leftBtnPressed &= ~msDown;
|
||||
lastlmb = 0;
|
||||
return -OSystem::EVENT_LBUTTONUP;
|
||||
}
|
||||
if(rmb && !lastrmb) {
|
||||
rightBtnPressed |= msClicked|msDown;
|
||||
lastrmb = 1;
|
||||
return -OSystem::EVENT_RBUTTONDOWN;
|
||||
} else if(lastrmb && !rmb) {
|
||||
rightBtnPressed &= ~msDown;
|
||||
lastrmb = 0;
|
||||
return -OSystem::EVENT_RBUTTONUP;
|
||||
}
|
||||
|
||||
if(!newkey)
|
||||
lastkey = 0;
|
||||
else if(newkey != lastkey)
|
||||
keyPressed = lastkey = newkey;
|
||||
return 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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "scumm.h"
|
||||
#include "mididrv.h"
|
||||
#include "gameDetector.h"
|
||||
#include "dc.h"
|
||||
#include "icon.h"
|
||||
#include "label.h"
|
||||
@ -159,16 +161,27 @@ static bool isGame(const char *fn, char *base)
|
||||
return false;
|
||||
}
|
||||
|
||||
static void checkName(Scumm *s, Game &game)
|
||||
static void checkName(GameDetector *d, Game &game)
|
||||
{
|
||||
s->_exe_name = game.filename_base;
|
||||
if(s->detectGame()) {
|
||||
char *n = s->getGameName();
|
||||
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);
|
||||
s->_exe_name = NULL;
|
||||
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;
|
||||
}
|
||||
|
||||
static bool isIcon(const char *fn)
|
||||
@ -202,7 +215,7 @@ static void makeDefIcon(Icon &icon)
|
||||
icon.load(NULL, 0);
|
||||
}
|
||||
|
||||
static int findGames(Scumm *s, Game *games, int max)
|
||||
static int findGames(GameDetector *d, Game *games, int max)
|
||||
{
|
||||
Dir *dirs = new Dir[MAX_DIR];
|
||||
int curr_game = 0, curr_dir = 0, num_dirs = 1;
|
||||
@ -242,8 +255,10 @@ static int findGames(Scumm *s, Game *games, int max)
|
||||
games[curr_game].dir[i+1]='\0';
|
||||
#endif
|
||||
}
|
||||
if(checkExe(games[curr_game].dir, "loom"))
|
||||
strcpy(games[curr_game].filename_base, "loomcd");
|
||||
}
|
||||
checkName(s, games[curr_game]);
|
||||
checkName(d, games[curr_game]);
|
||||
#if 0
|
||||
printf("Registered game <%s> in <%s> <%s> because of <%s> <%s>\n",
|
||||
games[curr_game].text, games[curr_game].dir,
|
||||
@ -306,13 +321,12 @@ void waitForDisk()
|
||||
|
||||
ta_commit_frame();
|
||||
|
||||
int16 mousex = 0, mousey = 0;
|
||||
byte lmb=0, rmb=0;
|
||||
int key=0;
|
||||
int mousex = 0, mousey = 0;
|
||||
byte shiftFlags;
|
||||
|
||||
int mask = getimask();
|
||||
setimask(15);
|
||||
handleInput(locked_get_pads(), mousex, mousey, lmb, rmb, key);
|
||||
handleInput(locked_get_pads(), mousex, mousey, shiftFlags);
|
||||
setimask(mask);
|
||||
}
|
||||
}
|
||||
@ -329,7 +343,7 @@ static void drawGameLabel(Game &game, int pal, float x, float y,
|
||||
int gameMenu(Game *games, int num_games)
|
||||
{
|
||||
int top_game = 0, selector_pos = 0;
|
||||
int16 mousex = 0, mousey = 64;
|
||||
int mousex = 0, mousey = 0;
|
||||
|
||||
if(!num_games)
|
||||
return -1;
|
||||
@ -361,15 +375,15 @@ int gameMenu(Game *games, int num_games)
|
||||
|
||||
ta_commit_frame();
|
||||
|
||||
byte lmb=0, rmb=0;
|
||||
int key=0;
|
||||
byte shiftFlags;
|
||||
int event;
|
||||
|
||||
int mask = getimask();
|
||||
setimask(15);
|
||||
handleInput(locked_get_pads(), mousex, mousey, lmb, rmb, key);
|
||||
event = handleInput(locked_get_pads(), mousex, mousey, shiftFlags);
|
||||
setimask(mask);
|
||||
|
||||
if(lmb || key==13 || key==319) {
|
||||
if(event==-OSystem::EVENT_LBUTTONDOWN || event==13 || event==319) {
|
||||
int selected_game = top_game + selector_pos;
|
||||
|
||||
for(int fade=0; fade<=256; fade+=4) {
|
||||
@ -402,14 +416,14 @@ int gameMenu(Game *games, int num_games)
|
||||
return selected_game;
|
||||
}
|
||||
|
||||
if(mousey>=64+16) {
|
||||
if(mousey>=16) {
|
||||
if(selector_pos + top_game + 1 < num_games)
|
||||
if(++selector_pos >= 10) {
|
||||
--selector_pos;
|
||||
++top_game;
|
||||
}
|
||||
mousey -= 16;
|
||||
} else if(mousey<=64-16) {
|
||||
} else if(mousey<=-16) {
|
||||
if(selector_pos + top_game > 0)
|
||||
if(--selector_pos < 0) {
|
||||
++selector_pos;
|
||||
@ -420,7 +434,7 @@ int gameMenu(Game *games, int num_games)
|
||||
}
|
||||
}
|
||||
|
||||
bool selectGame(Scumm *s, char *&ret, char *&dir_ret, Icon &icon)
|
||||
bool selectGame(GameDetector *d, char *&ret, char *&dir_ret, Icon &icon)
|
||||
{
|
||||
Game *games = new Game[MAX_GAMES];
|
||||
int selected, num_games;
|
||||
@ -429,7 +443,7 @@ bool selectGame(Scumm *s, char *&ret, char *&dir_ret, Icon &icon)
|
||||
void *mark = ta_txmark();
|
||||
|
||||
for(;;) {
|
||||
num_games = findGames(s, games, MAX_GAMES);
|
||||
num_games = findGames(d, games, MAX_GAMES);
|
||||
|
||||
for(int i=0; i<num_games; i++) {
|
||||
games[i].icon.create_texture();
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "scumm.h"
|
||||
#include "mididrv.h"
|
||||
#include "gameDetector.h"
|
||||
#include "dc.h"
|
||||
#include "icon.h"
|
||||
|
||||
@ -42,7 +44,7 @@ enum vmsaveResult {
|
||||
|
||||
static int lastvm=-1;
|
||||
|
||||
static vmsaveResult trySave(Scumm *s, const char *data, int size,
|
||||
static vmsaveResult trySave(GameDetector *d, const char *data, int size,
|
||||
const char *filename, class Icon &icon, int vm)
|
||||
{
|
||||
struct vmsinfo info;
|
||||
@ -66,7 +68,7 @@ static vmsaveResult trySave(Scumm *s, const char *data, int size,
|
||||
|
||||
memset(&header, 0, sizeof(header));
|
||||
strncpy(header.shortdesc, "ScummVM savegame", 16);
|
||||
char *game_name = s->getGameName();
|
||||
char *game_name = d->getGameName();
|
||||
strncpy(header.longdesc, game_name, 32);
|
||||
free(game_name);
|
||||
strncpy(header.id, "ScummVM", 16);
|
||||
@ -125,17 +127,17 @@ static bool tryLoad(char *&buffer, int &size, const char *filename, int vm)
|
||||
return false;
|
||||
}
|
||||
|
||||
vmsaveResult writeSaveGame(Scumm *s, const char *data, int size,
|
||||
vmsaveResult writeSaveGame(GameDetector *d, const char *data, int size,
|
||||
const char *filename, class Icon &icon)
|
||||
{
|
||||
vmsaveResult r, res = VMSAVE_NOVM;
|
||||
|
||||
if(lastvm >= 0 &&
|
||||
(res = trySave(s, data, size, filename, icon, lastvm)) == VMSAVE_OK)
|
||||
(res = trySave(d, 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) {
|
||||
if((r = trySave(d, data, size, filename, icon, i)) == VMSAVE_OK) {
|
||||
lastvm = i;
|
||||
return r;
|
||||
} else if(r > res)
|
||||
@ -200,7 +202,7 @@ bool SerializerStream::fopen(const char *filename, const char *mode)
|
||||
|
||||
void SerializerStream::fclose()
|
||||
{
|
||||
extern Scumm scumm;
|
||||
extern GameDetector detector;
|
||||
extern Icon icon;
|
||||
|
||||
if(context) {
|
||||
@ -216,7 +218,7 @@ void SerializerStream::fclose()
|
||||
c->pos = destlen;
|
||||
} else delete compbuf;
|
||||
}
|
||||
writeSaveGame(&scumm, c->buffer, c->pos,
|
||||
writeSaveGame(&detector, c->buffer, c->pos,
|
||||
c->filename, icon);
|
||||
}
|
||||
delete c->buffer;
|
||||
|
Loading…
Reference in New Issue
Block a user