aboutsummaryrefslogtreecommitdiff
path: root/backends/dc
diff options
context:
space:
mode:
authorMarcus Comstedt2003-05-04 19:08:21 +0000
committerMarcus Comstedt2003-05-04 19:08:21 +0000
commitab1d0a69e16d2f29fe21a6754f21e368faaeb7df (patch)
tree81476202bc4afad431ebe5f4e11d5c3ec229634f /backends/dc
parent93264aea7867428f2df712efd4b46ddf0aae25e0 (diff)
downloadscummvm-rg350-ab1d0a69e16d2f29fe21a6754f21e368faaeb7df.tar.gz
scummvm-rg350-ab1d0a69e16d2f29fe21a6754f21e368faaeb7df.tar.bz2
scummvm-rg350-ab1d0a69e16d2f29fe21a6754f21e368faaeb7df.zip
Support hires mode (CoMI).
svn-id: r7326
Diffstat (limited to 'backends/dc')
-rw-r--r--backends/dc/dc.h2
-rw-r--r--backends/dc/display.cpp91
-rw-r--r--backends/dc/input.cpp11
3 files changed, 60 insertions, 44 deletions
diff --git a/backends/dc/dc.h b/backends/dc/dc.h
index 8291bc7c34..7b9f6a0d86 100644
--- a/backends/dc/dc.h
+++ b/backends/dc/dc.h
@@ -97,11 +97,13 @@ class OSystem_Dreamcast : public OSystem {
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, _screen_w, _screen_h;
+ int _overlay_x, _overlay_y;
unsigned char *_ms_buf;
SoundProc *_sound_proc;
void *_sound_proc_param;
bool _overlay_visible, _overlay_dirty, _screen_dirty;
int _screen_buffer, _overlay_buffer, _mouse_buffer;
+ bool _hires;
float _overlay_fade;
uint32 _timer_duration, _timer_next_expiry;
diff --git a/backends/dc/display.cpp b/backends/dc/display.cpp
index aabdbdd87b..e2e4122bb3 100644
--- a/backends/dc/display.cpp
+++ b/backends/dc/display.cpp
@@ -25,15 +25,16 @@
#include <common/engine.h>
#include "dc.h"
-#define SCREEN_W 320
-#define SCREEN_H 240
+#define SCREEN_W 640
+#define SCREEN_H 480
#define MOUSE_W 64
#define MOUSE_H 64
#define OVL_W 320
-#define OVL_H 240
+#define OVL_H 200
+#define OVL_TXSTRIDE 512
-#define TOP_OFFSET (240.0-_screen_h)
+#define TOP_OFFSET (240.0+(_hires? _current_shake_pos-(_screen_h>>1):2*_current_shake_pos-_screen_h))
#define QACR0 (*(volatile unsigned int *)(void *)0xff000038)
#define QACR1 (*(volatile unsigned int *)(void *)0xff00003c)
@@ -142,12 +143,17 @@ void OSystem_Dreamcast::set_palette(const byte *colors, uint start, uint num)
void OSystem_Dreamcast::init_size(uint w, uint h)
{
- assert(w == SCREEN_W && h <= SCREEN_H);
+ assert(w <= SCREEN_W && h <= SCREEN_H);
_overlay_visible = false;
_overlay_fade = 0.0;
_screen_w = w;
_screen_h = h;
+ _hires = w > 400;
+ _overlay_x = (w-OVL_W)/2;
+ _overlay_y = (h-OVL_H)/2;
+ if(_overlay_x<0) _overlay_x = 0;
+ if(_overlay_y<0) _overlay_y = 0;
ta_sync();
if(!screen)
screen = new unsigned char[SCREEN_W*SCREEN_H];
@@ -161,7 +167,7 @@ void OSystem_Dreamcast::init_size(uint w, uint h)
mouse_tx[i] = ta_txalloc(MOUSE_W*MOUSE_H*2);
for(int i=0; i<NUM_BUFFERS; i++)
if(!ovl_tx[i])
- ovl_tx[i] = ta_txalloc(OVL_W*OVL_H*2);
+ ovl_tx[i] = ta_txalloc(OVL_TXSTRIDE*OVL_H*2);
_screen_buffer = 0;
_mouse_buffer = 0;
_overlay_buffer = 0;
@@ -194,24 +200,24 @@ void OSystem_Dreamcast::move_screen(int dx, int dy, int height) {
// move down
// copy from bottom to top
for (int y = height - 1; y >= dy; y--)
- copy_rect(screen + SCREEN_W * (y - dy), SCREEN_W, 0, y, SCREEN_W, 1);
+ copy_rect(screen + SCREEN_W * (y - dy), SCREEN_W, 0, y, _screen_w, 1);
} else {
// move up
// copy from top to bottom
for (int y = 0; y < height + dx; y++)
- copy_rect(screen + SCREEN_W * (y - dy), SCREEN_W, 0, y, SCREEN_W, 1);
+ copy_rect(screen + SCREEN_W * (y - dy), SCREEN_W, 0, y, _screen_w, 1);
}
} else if (dy == 0) {
// horizontal movement
if (dx > 0) {
// move right
// copy from right to left
- for (int x = SCREEN_W - 1; x >= dx; x--)
+ for (int x = _screen_w - 1; x >= dx; x--)
copy_rect(screen + x - dx, SCREEN_W, x, 0, 1, height);
} else {
// move left
// copy from left to right
- for (int x = 0; x < SCREEN_W; x++)
+ for (int x = 0; x < _screen_w; x++)
copy_rect(screen + x - dx, SCREEN_W, x, 0, 1, height);
}
} else {
@@ -233,14 +239,17 @@ bool OSystem_Dreamcast::show_mouse(bool visible)
void OSystem_Dreamcast::set_mouse_pos(int x, int y)
{
- _ms_cur_x = x;
- _ms_cur_y = y;
+ if (_overlay_visible) {
+ x += _overlay_x;
+ y += _overlay_y;
+ }
+ _ms_cur_x = (_hires? (x>>1):x);
+ _ms_cur_y = (_hires? (y>>1):y);
}
void OSystem_Dreamcast::warp_mouse(int x, int y)
{
- _ms_cur_x = x;
- _ms_cur_y = y;
+ set_mouse_pos(x, y);
}
void OSystem_Dreamcast::set_mouse_cursor(const byte *buf, uint w, uint h,
@@ -278,7 +287,7 @@ void OSystem_Dreamcast::update_screen(void)
for( int y = 0; y<_screen_h; y++ )
{
- texture_memcpy64_pal( dst, src, SCREEN_W>>5, palette );
+ texture_memcpy64_pal( dst, src, _screen_w>>5, palette );
src += SCREEN_W;
dst += SCREEN_W;
}
@@ -294,11 +303,11 @@ void OSystem_Dreamcast::update_screen(void)
unsigned short *dst = (unsigned short *)ovl_tx[_overlay_buffer];
unsigned short *src = overlay;
- for( int y = 0; y<_screen_h; y++ )
+ for( int y = 0; y<OVL_H; y++ )
{
texture_memcpy64( dst, src, OVL_W>>5 );
src += OVL_W;
- dst += OVL_W;
+ dst += OVL_TXSTRIDE;
}
_overlay_dirty = false;
@@ -312,7 +321,7 @@ void OSystem_Dreamcast::update_screen(void)
mypoly.mode1 = TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE;
mypoly.mode2 =
TA_POLYMODE2_BLEND_SRC|TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_TEXTURE_REPLACE|
- TA_POLYMODE2_U_SIZE_512|TA_POLYMODE2_V_SIZE_512;
+ TA_POLYMODE2_U_SIZE_1024|TA_POLYMODE2_V_SIZE_1024;
mypoly.texture = TA_TEXTUREMODE_ARGB1555|TA_TEXTUREMODE_NON_TWIDDLED|
TA_TEXTUREMODE_STRIDE|TA_TEXTUREMODE_ADDRESS(screen_tx[_screen_buffer]);
@@ -330,21 +339,21 @@ void OSystem_Dreamcast::update_screen(void)
myvertex.v = 0.0;
myvertex.x = 0.0;
- myvertex.y = _current_shake_pos*2.0+TOP_OFFSET;
+ myvertex.y = TOP_OFFSET;
ta_commit_list(&myvertex);
- myvertex.x = _screen_w*2.0;
- myvertex.u = _screen_w*(1/512.0);
+ myvertex.x = (_hires? _screen_w:_screen_w*2.0);
+ myvertex.u = _screen_w*(1/1024.0);
ta_commit_list(&myvertex);
myvertex.x = 0.0;
- myvertex.y += _screen_h*2.0;
+ myvertex.y += (_hires? _screen_h:_screen_h*2.0);
myvertex.u = 0.0;
- myvertex.v = _screen_h*(1/512.0);
+ myvertex.v = _screen_h*(1/1024.0);
ta_commit_list(&myvertex);
- myvertex.x = _screen_w*2.0;
- myvertex.u = _screen_w*(1/512.0);
+ myvertex.x = (_hires? _screen_w:_screen_w*2.0);
+ myvertex.u = _screen_w*(1/1024.0);
myvertex.cmd |= TA_CMD_VERTEX_EOS;
ta_commit_list(&myvertex);
@@ -370,7 +379,7 @@ void OSystem_Dreamcast::update_screen(void)
TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_TEXTURE_MODULATE_ALPHA|
TA_POLYMODE2_U_SIZE_512|TA_POLYMODE2_V_SIZE_512;
mypoly.texture = TA_TEXTUREMODE_RGB565|TA_TEXTUREMODE_NON_TWIDDLED|
- TA_TEXTUREMODE_STRIDE|TA_TEXTUREMODE_ADDRESS(ovl_tx[_overlay_buffer]);
+ TA_TEXTUREMODE_ADDRESS(ovl_tx[_overlay_buffer]);
mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0.0;
@@ -384,22 +393,22 @@ void OSystem_Dreamcast::update_screen(void)
myvertex.u = 0.0;
myvertex.v = 0.0;
- myvertex.x = 0.0;
- myvertex.y = _current_shake_pos*2.0+TOP_OFFSET;
+ myvertex.x = (_hires? _overlay_x:_overlay_x*2.0);
+ myvertex.y = (_hires? _overlay_y:_overlay_y*2.0)+TOP_OFFSET;
ta_commit_list(&myvertex);
- myvertex.x = _screen_w*2.0;
- myvertex.u = _screen_w*(1.0/512.0);
+ myvertex.x += (_hires? OVL_W:OVL_W*2.0);
+ myvertex.u = OVL_W*(1.0/512.0);
ta_commit_list(&myvertex);
- myvertex.x = 0.0;
- myvertex.y += _screen_h*2.0;
+ myvertex.x -= (_hires? OVL_W:OVL_W*2.0);
+ myvertex.y += (_hires? OVL_H:OVL_H*2.0);
myvertex.u = 0.0;
- myvertex.v = _screen_h*(1.0/512.0);
+ myvertex.v = OVL_H*(1.0/512.0);
ta_commit_list(&myvertex);
- myvertex.x = _screen_w*2.0;
- myvertex.u = _screen_w*(1.0/512.0);
+ myvertex.x += (_hires? OVL_W:OVL_W*2.0);
+ myvertex.u = OVL_W*(1.0/512.0);
myvertex.cmd |= TA_CMD_VERTEX_EOS;
ta_commit_list(&myvertex);
}
@@ -461,7 +470,7 @@ void OSystem_Dreamcast::drawMouse(int xdraw, int ydraw, int w, int h,
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;
+ myvertex.y = (ydraw-_ms_hotspot_x)*2.0 + TOP_OFFSET;
ta_commit_list(&myvertex);
myvertex.x += w*2.0;
@@ -497,11 +506,11 @@ void OSystem_Dreamcast::clear_overlay()
if(!_overlay_visible)
return;
- unsigned char *src = screen;
+ unsigned char *src = screen+_overlay_x+_overlay_y*SCREEN_W;
unsigned short *dst = overlay;
- for(int y=0; y<_screen_h; y++) {
- for(int x=0; x<_screen_w; x++) {
+ for(int y=0; y<OVL_H; y++) {
+ for(int x=0; x<OVL_W; x++) {
short pix = palette[src[x]];
dst[x] = ((pix&0x7fe0)<<1)|((pix&0x0200)>>4)|(pix&0x1f);
}
@@ -513,10 +522,10 @@ void OSystem_Dreamcast::clear_overlay()
void OSystem_Dreamcast::grab_overlay(int16 *buf, int pitch)
{
- int h = _screen_h;
+ int h = OVL_H;
unsigned short *src = overlay;
do {
- memcpy(buf, src, _screen_w*sizeof(int16));
+ memcpy(buf, src, OVL_W*sizeof(int16));
src += OVL_W;
buf += pitch;
} while (--h);
diff --git a/backends/dc/input.cpp b/backends/dc/input.cpp
index f491c07869..57530579b5 100644
--- a/backends/dc/input.cpp
+++ b/backends/dc/input.cpp
@@ -160,9 +160,14 @@ bool OSystem_Dreamcast::poll_event(Event *event)
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>=_screen_h) _ms_cur_y=_screen_h-1;
- event->mouse.x = _ms_cur_x;
- event->mouse.y = _ms_cur_y;
+ if (_ms_cur_y>=(_hires? (_screen_h>>1):_screen_h))
+ _ms_cur_y=(_hires? (_screen_h>>1):_screen_h)-1;
+ event->mouse.x = (_hires? (_ms_cur_x<<1):_ms_cur_x);
+ event->mouse.y = (_hires? (_ms_cur_y<<1):_ms_cur_y);
+ if (_overlay_visible) {
+ event->mouse.x -= _overlay_x;
+ event->mouse.y -= _overlay_y;
+ }
event->kbd.ascii = event->kbd.keycode = 0;
if(e<0) {
event->event_code = -e;