Reworked scaling logic, and added kFeatureAspectRatioCorrection support.

svn-id: r13259
This commit is contained in:
Marcus Comstedt 2004-03-13 17:32:28 +00:00
parent 7db5cc0a9c
commit fae98dec52
4 changed files with 58 additions and 72 deletions

View File

@ -153,8 +153,8 @@ class OSystem_Dreamcast : public OSystem {
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 @@ class OSystem_Dreamcast : public OSystem {
void drawMouse(int xdraw, int ydraw, int w, int h,
unsigned char *buf, bool visible);
void setScaling();
};
extern int handleInput(struct mapledev *pad,

View File

@ -46,11 +46,12 @@ OSystem *OSystem_Dreamcast::create() {
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 @@ void OSystem_Dreamcast::setFeatureState(Feature f, bool enable)
{
switch(f) {
case kFeatureAspectRatioCorrection:
/* FIXME */
_aspect_stretch = enable;
if(screen)
setScaling();
break;
case kFeatureVirtualKeyboard:
/* FIXME */
@ -173,8 +176,7 @@ bool OSystem_Dreamcast::getFeatureState(Feature f)
{
switch(f) {
case kFeatureAspectRatioCorrection:
/* FIXME */
return false;
return _aspect_stretch;
case kFeatureVirtualKeyboard:
/* FIXME */
return false;

View File

@ -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 @@ void OSystem_Dreamcast::setPalette(const byte *colors, uint start, uint num)
_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 @@ void OSystem_Dreamcast::initSize(uint w, uint h)
_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 @@ bool OSystem_Dreamcast::show_mouse(bool visible)
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 @@ void OSystem_Dreamcast::updateScreen(void)
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 @@ void OSystem_Dreamcast::updateScreen(void)
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 @@ void OSystem_Dreamcast::drawMouse(int xdraw, int ydraw, int w, int h,
myvertex.u = 0.0;
myvertex.v = 0.0;
if(_hires_mouse) {
myvertex.x = (xdraw-_ms_hotspot_x)*_xscale;
myvertex.y = (ydraw-_ms_hotspot_y)*_yscale + TOP_OFFSET;
ta_commit_list(&myvertex);
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*_xscale;
myvertex.u = w*(1.0/MOUSE_W);
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*_xscale;
myvertex.y += h*_yscale;
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 += w*2.0;
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*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);
}

View File

@ -171,12 +171,11 @@ bool OSystem_Dreamcast::poll_event(Event *event)
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 @@ bool OSystem_Dreamcast::poll_event(Event *event)
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;