[Scummvm-cvs-logs] CVS: scummvm/backends/dc dc.h,1.23,1.24 dcmain.cpp,1.24,1.25 display.cpp,1.19,1.20 input.cpp,1.16,1.17
Marcus Comstedt
marcus_c at users.sourceforge.net
Sat Mar 13 09:42:02 CET 2004
Update of /cvsroot/scummvm/scummvm/backends/dc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28720
Modified Files:
dc.h dcmain.cpp display.cpp input.cpp
Log Message:
Reworked scaling logic, and added kFeatureAspectRatioCorrection support.
Index: dc.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/dc/dc.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- dc.h 13 Mar 2004 15:18:22 -0000 1.23
+++ dc.h 13 Mar 2004 17:32:28 -0000 1.24
@@ -153,8 +153,8 @@
void *_sound_proc_param;
bool _overlay_visible, _overlay_dirty, _screen_dirty;
int _screen_buffer, _overlay_buffer, _mouse_buffer;
- bool _hires, _hires_mouse;
- float _overlay_fade;
+ bool _aspect_stretch;
+ float _overlay_fade, _xscale, _yscale, _top_offset;
uint32 _timer_duration, _timer_next_expiry;
bool _timer_active;
@@ -175,6 +175,7 @@
void drawMouse(int xdraw, int ydraw, int w, int h,
unsigned char *buf, bool visible);
+ void setScaling();
};
extern int handleInput(struct mapledev *pad,
Index: dcmain.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/dc/dcmain.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- dcmain.cpp 13 Mar 2004 15:17:13 -0000 1.24
+++ dcmain.cpp 13 Mar 2004 17:32:28 -0000 1.25
@@ -46,11 +46,12 @@
OSystem_Dreamcast::OSystem_Dreamcast()
: screen(NULL), mouse(NULL), overlay(NULL), _ms_buf(NULL),
- _sound_proc(NULL), _timer_active(false), _current_shake_pos(0)
+ _sound_proc(NULL), _timer_active(false), _current_shake_pos(0),
+ _aspect_stretch(false)
{
memset(screen_tx, 0, sizeof(screen_tx));
- memset(mouse_tx, 0, sizeof(screen_tx));
- memset(ovl_tx, 0, sizeof(screen_tx));
+ memset(mouse_tx, 0, sizeof(mouse_tx));
+ memset(ovl_tx, 0, sizeof(ovl_tx));
}
@@ -159,7 +160,9 @@
{
switch(f) {
case kFeatureAspectRatioCorrection:
- /* FIXME */
+ _aspect_stretch = enable;
+ if(screen)
+ setScaling();
break;
case kFeatureVirtualKeyboard:
/* FIXME */
@@ -173,8 +176,7 @@
{
switch(f) {
case kFeatureAspectRatioCorrection:
- /* FIXME */
- return false;
+ return _aspect_stretch;
case kFeatureVirtualKeyboard:
/* FIXME */
return false;
Index: display.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/dc/display.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- display.cpp 13 Mar 2004 15:18:22 -0000 1.19
+++ display.cpp 13 Mar 2004 17:32:28 -0000 1.20
@@ -34,7 +34,7 @@
#define OVL_H 200
#define OVL_TXSTRIDE 512
-#define TOP_OFFSET (240.0+(_hires? _current_shake_pos-(_screen_h>>1):2*_current_shake_pos-_screen_h))
+#define TOP_OFFSET (_top_offset+_yscale*_current_shake_pos)
#define QACR0 (*(volatile unsigned int *)(void *)0xff000038)
#define QACR1 (*(volatile unsigned int *)(void *)0xff00003c)
@@ -141,6 +141,21 @@
_screen_dirty = true;
}
+void OSystem_Dreamcast::setScaling()
+{
+ if(_screen_w > 400) {
+ _xscale = _yscale = 1.0;
+ _top_offset = (SCREEN_H-_screen_h)>>1;
+ } else if(_aspect_stretch && _screen_w == 320 && _screen_h == 200) {
+ _xscale = SCREEN_W/320.0;
+ _yscale = SCREEN_H/200.0;
+ _top_offset = 0;
+ } else {
+ _xscale = _yscale = 2.0;
+ _top_offset = (SCREEN_H>>1)-_screen_h;
+ }
+}
+
void OSystem_Dreamcast::initSize(uint w, uint h)
{
assert(w <= SCREEN_W && h <= SCREEN_H);
@@ -149,12 +164,11 @@
_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;
- _hires_mouse = _hires;
+ setScaling();
ta_sync();
if(!screen)
screen = new unsigned char[SCREEN_W*SCREEN_H];
@@ -240,12 +254,8 @@
void OSystem_Dreamcast::warp_mouse(int x, int y)
{
- if (_overlay_visible) {
- x += _overlay_x;
- y += _overlay_y;
- }
- _ms_cur_x = (_hires? (x>>1):x);
- _ms_cur_y = (_hires? (y>>1):y);
+ _ms_cur_x = x;
+ _ms_cur_y = y;
}
void OSystem_Dreamcast::set_mouse_cursor(const byte *buf, uint w, uint h,
@@ -338,17 +348,17 @@
myvertex.y = TOP_OFFSET;
ta_commit_list(&myvertex);
- myvertex.x = (_hires? _screen_w:_screen_w*2.0);
+ myvertex.x = _screen_w*_xscale;
myvertex.u = _screen_w*(1/1024.0);
ta_commit_list(&myvertex);
myvertex.x = 0.0;
- myvertex.y += (_hires? _screen_h:_screen_h*2.0);
+ myvertex.y += _screen_h*_yscale;
myvertex.u = 0.0;
myvertex.v = _screen_h*(1/1024.0);
ta_commit_list(&myvertex);
- myvertex.x = (_hires? _screen_w:_screen_w*2.0);
+ myvertex.x = _screen_w*_xscale;
myvertex.u = _screen_w*(1/1024.0);
myvertex.cmd |= TA_CMD_VERTEX_EOS;
ta_commit_list(&myvertex);
@@ -389,21 +399,21 @@
myvertex.u = 0.0;
myvertex.v = 0.0;
- myvertex.x = (_hires? _overlay_x:_overlay_x*2.0);
- myvertex.y = (_hires? _overlay_y:_overlay_y*2.0)+TOP_OFFSET;
+ myvertex.x = _overlay_x*_xscale;
+ myvertex.y = _overlay_y*_yscale+TOP_OFFSET;
ta_commit_list(&myvertex);
- myvertex.x += (_hires? OVL_W:OVL_W*2.0);
+ myvertex.x += OVL_W*_xscale;
myvertex.u = OVL_W*(1.0/512.0);
ta_commit_list(&myvertex);
- myvertex.x -= (_hires? OVL_W:OVL_W*2.0);
- myvertex.y += (_hires? OVL_H:OVL_H*2.0);
+ myvertex.x = _overlay_x*_xscale;
+ myvertex.y += OVL_H*_yscale;
myvertex.u = 0.0;
myvertex.v = OVL_H*(1.0/512.0);
ta_commit_list(&myvertex);
- myvertex.x += (_hires? OVL_W:OVL_W*2.0);
+ myvertex.x += OVL_W*_xscale;
myvertex.u = OVL_W*(1.0/512.0);
myvertex.cmd |= TA_CMD_VERTEX_EOS;
ta_commit_list(&myvertex);
@@ -467,49 +477,24 @@
myvertex.u = 0.0;
myvertex.v = 0.0;
- if(_hires_mouse) {
-
- myvertex.x = xdraw*2.0-_ms_hotspot_x;
- myvertex.y = ydraw*2.0-_ms_hotspot_y + TOP_OFFSET;
- ta_commit_list(&myvertex);
-
- myvertex.x += w;
- myvertex.u = w*(1.0/MOUSE_W);
- ta_commit_list(&myvertex);
-
- myvertex.x = xdraw*2.0-_ms_hotspot_x;
- myvertex.y += h;
- myvertex.u = 0.0;
- myvertex.v = h*(1.0/MOUSE_H);
- ta_commit_list(&myvertex);
-
- myvertex.x += w;
- myvertex.u = w*(1.0/MOUSE_W);
- myvertex.cmd |= TA_CMD_VERTEX_EOS;
- ta_commit_list(&myvertex);
-
- } else {
-
- myvertex.x = (xdraw-_ms_hotspot_x)*2.0;
- myvertex.y = (ydraw-_ms_hotspot_y)*2.0 + TOP_OFFSET;
- ta_commit_list(&myvertex);
+ myvertex.x = (xdraw-_ms_hotspot_x)*_xscale;
+ myvertex.y = (ydraw-_ms_hotspot_y)*_yscale + TOP_OFFSET;
+ ta_commit_list(&myvertex);
- myvertex.x += w*2.0;
- myvertex.u = w*(1.0/MOUSE_W);
- ta_commit_list(&myvertex);
+ myvertex.x += w*_xscale;
+ myvertex.u = w*(1.0/MOUSE_W);
+ ta_commit_list(&myvertex);
- myvertex.x = (xdraw-_ms_hotspot_x)*2.0;
- myvertex.y += h*2.0;
- myvertex.u = 0.0;
- myvertex.v = h*(1.0/MOUSE_H);
- ta_commit_list(&myvertex);
+ myvertex.x -= w*_xscale;
+ myvertex.y += h*_yscale;
+ myvertex.u = 0.0;
+ myvertex.v = h*(1.0/MOUSE_H);
+ ta_commit_list(&myvertex);
- myvertex.x += w*2.0;
- myvertex.u = w*(1.0/MOUSE_W);
- myvertex.cmd |= TA_CMD_VERTEX_EOS;
- ta_commit_list(&myvertex);
-
- }
+ myvertex.x += w*_xscale;
+ myvertex.u = w*(1.0/MOUSE_W);
+ myvertex.cmd |= TA_CMD_VERTEX_EOS;
+ ta_commit_list(&myvertex);
}
Index: input.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/dc/input.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- input.cpp 13 Mar 2004 13:41:50 -0000 1.16
+++ input.cpp 13 Mar 2004 17:32:28 -0000 1.17
@@ -171,12 +171,11 @@
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_x>=_screen_w) _ms_cur_x=_screen_w-1;
if (_ms_cur_y<0) _ms_cur_y=0;
- 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 (_ms_cur_y>=_screen_h) _ms_cur_y=_screen_h-1;
+ event->mouse.x = _ms_cur_x;
+ event->mouse.y = _ms_cur_y;
if (_overlay_visible) {
event->mouse.x -= _overlay_x;
event->mouse.y -= _overlay_y;
@@ -196,7 +195,6 @@
event->event_code = EVENT_MOUSEMOVE;
_ms_old_x = _ms_cur_x;
_ms_old_y = _ms_cur_y;
- warp_mouse(event->mouse.x, event->mouse.y);
return true;
} else {
event->event_code = (EventCode)0;
More information about the Scummvm-git-logs
mailing list