Support hires mode (CoMI).

svn-id: r7326
This commit is contained in:
Marcus Comstedt 2003-05-04 19:08:21 +00:00
parent 93264aea78
commit ab1d0a69e1
3 changed files with 60 additions and 44 deletions

View file

@ -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_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 _ms_hotspot_x, _ms_hotspot_y, _ms_visible, _devpoll;
int _current_shake_pos, _screen_w, _screen_h; int _current_shake_pos, _screen_w, _screen_h;
int _overlay_x, _overlay_y;
unsigned char *_ms_buf; unsigned char *_ms_buf;
SoundProc *_sound_proc; SoundProc *_sound_proc;
void *_sound_proc_param; void *_sound_proc_param;
bool _overlay_visible, _overlay_dirty, _screen_dirty; bool _overlay_visible, _overlay_dirty, _screen_dirty;
int _screen_buffer, _overlay_buffer, _mouse_buffer; int _screen_buffer, _overlay_buffer, _mouse_buffer;
bool _hires;
float _overlay_fade; float _overlay_fade;
uint32 _timer_duration, _timer_next_expiry; uint32 _timer_duration, _timer_next_expiry;

View file

@ -25,15 +25,16 @@
#include <common/engine.h> #include <common/engine.h>
#include "dc.h" #include "dc.h"
#define SCREEN_W 320 #define SCREEN_W 640
#define SCREEN_H 240 #define SCREEN_H 480
#define MOUSE_W 64 #define MOUSE_W 64
#define MOUSE_H 64 #define MOUSE_H 64
#define OVL_W 320 #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 QACR0 (*(volatile unsigned int *)(void *)0xff000038)
#define QACR1 (*(volatile unsigned int *)(void *)0xff00003c) #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) 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_visible = false;
_overlay_fade = 0.0; _overlay_fade = 0.0;
_screen_w = w; _screen_w = w;
_screen_h = h; _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(); ta_sync();
if(!screen) if(!screen)
screen = new unsigned char[SCREEN_W*SCREEN_H]; 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); mouse_tx[i] = ta_txalloc(MOUSE_W*MOUSE_H*2);
for(int i=0; i<NUM_BUFFERS; i++) for(int i=0; i<NUM_BUFFERS; i++)
if(!ovl_tx[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; _screen_buffer = 0;
_mouse_buffer = 0; _mouse_buffer = 0;
_overlay_buffer = 0; _overlay_buffer = 0;
@ -194,24 +200,24 @@ void OSystem_Dreamcast::move_screen(int dx, int dy, int height) {
// move down // move down
// copy from bottom to top // copy from bottom to top
for (int y = height - 1; y >= dy; y--) 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 { } else {
// move up // move up
// copy from top to bottom // copy from top to bottom
for (int y = 0; y < height + dx; y++) 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) { } else if (dy == 0) {
// horizontal movement // horizontal movement
if (dx > 0) { if (dx > 0) {
// move right // move right
// copy from right to left // 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); copy_rect(screen + x - dx, SCREEN_W, x, 0, 1, height);
} else { } else {
// move left // move left
// copy from left to right // 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); copy_rect(screen + x - dx, SCREEN_W, x, 0, 1, height);
} }
} else { } else {
@ -233,14 +239,17 @@ bool OSystem_Dreamcast::show_mouse(bool visible)
void OSystem_Dreamcast::set_mouse_pos(int x, int y) void OSystem_Dreamcast::set_mouse_pos(int x, int y)
{ {
_ms_cur_x = x; if (_overlay_visible) {
_ms_cur_y = y; 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) void OSystem_Dreamcast::warp_mouse(int x, int y)
{ {
_ms_cur_x = x; set_mouse_pos(x, y);
_ms_cur_y = y;
} }
void OSystem_Dreamcast::set_mouse_cursor(const byte *buf, uint w, uint h, 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++ ) 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; src += SCREEN_W;
dst += 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 *dst = (unsigned short *)ovl_tx[_overlay_buffer];
unsigned short *src = overlay; 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 ); texture_memcpy64( dst, src, OVL_W>>5 );
src += OVL_W; src += OVL_W;
dst += OVL_W; dst += OVL_TXSTRIDE;
} }
_overlay_dirty = false; _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.mode1 = TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE;
mypoly.mode2 = mypoly.mode2 =
TA_POLYMODE2_BLEND_SRC|TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_TEXTURE_REPLACE| 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| mypoly.texture = TA_TEXTUREMODE_ARGB1555|TA_TEXTUREMODE_NON_TWIDDLED|
TA_TEXTUREMODE_STRIDE|TA_TEXTUREMODE_ADDRESS(screen_tx[_screen_buffer]); 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.v = 0.0;
myvertex.x = 0.0; myvertex.x = 0.0;
myvertex.y = _current_shake_pos*2.0+TOP_OFFSET; myvertex.y = TOP_OFFSET;
ta_commit_list(&myvertex); ta_commit_list(&myvertex);
myvertex.x = _screen_w*2.0; myvertex.x = (_hires? _screen_w:_screen_w*2.0);
myvertex.u = _screen_w*(1/512.0); myvertex.u = _screen_w*(1/1024.0);
ta_commit_list(&myvertex); ta_commit_list(&myvertex);
myvertex.x = 0.0; myvertex.x = 0.0;
myvertex.y += _screen_h*2.0; myvertex.y += (_hires? _screen_h:_screen_h*2.0);
myvertex.u = 0.0; myvertex.u = 0.0;
myvertex.v = _screen_h*(1/512.0); myvertex.v = _screen_h*(1/1024.0);
ta_commit_list(&myvertex); ta_commit_list(&myvertex);
myvertex.x = _screen_w*2.0; myvertex.x = (_hires? _screen_w:_screen_w*2.0);
myvertex.u = _screen_w*(1/512.0); myvertex.u = _screen_w*(1/1024.0);
myvertex.cmd |= TA_CMD_VERTEX_EOS; myvertex.cmd |= TA_CMD_VERTEX_EOS;
ta_commit_list(&myvertex); 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_FOG_DISABLED|TA_POLYMODE2_TEXTURE_MODULATE_ALPHA|
TA_POLYMODE2_U_SIZE_512|TA_POLYMODE2_V_SIZE_512; TA_POLYMODE2_U_SIZE_512|TA_POLYMODE2_V_SIZE_512;
mypoly.texture = TA_TEXTUREMODE_RGB565|TA_TEXTUREMODE_NON_TWIDDLED| 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; 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.u = 0.0;
myvertex.v = 0.0; myvertex.v = 0.0;
myvertex.x = 0.0; myvertex.x = (_hires? _overlay_x:_overlay_x*2.0);
myvertex.y = _current_shake_pos*2.0+TOP_OFFSET; myvertex.y = (_hires? _overlay_y:_overlay_y*2.0)+TOP_OFFSET;
ta_commit_list(&myvertex); ta_commit_list(&myvertex);
myvertex.x = _screen_w*2.0; myvertex.x += (_hires? OVL_W:OVL_W*2.0);
myvertex.u = _screen_w*(1.0/512.0); myvertex.u = OVL_W*(1.0/512.0);
ta_commit_list(&myvertex); ta_commit_list(&myvertex);
myvertex.x = 0.0; myvertex.x -= (_hires? OVL_W:OVL_W*2.0);
myvertex.y += _screen_h*2.0; myvertex.y += (_hires? OVL_H:OVL_H*2.0);
myvertex.u = 0.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); ta_commit_list(&myvertex);
myvertex.x = _screen_w*2.0; myvertex.x += (_hires? OVL_W:OVL_W*2.0);
myvertex.u = _screen_w*(1.0/512.0); myvertex.u = OVL_W*(1.0/512.0);
myvertex.cmd |= TA_CMD_VERTEX_EOS; myvertex.cmd |= TA_CMD_VERTEX_EOS;
ta_commit_list(&myvertex); 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.v = 0.0;
myvertex.x = (xdraw-_ms_hotspot_y)*2.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); ta_commit_list(&myvertex);
myvertex.x += w*2.0; myvertex.x += w*2.0;
@ -497,11 +506,11 @@ void OSystem_Dreamcast::clear_overlay()
if(!_overlay_visible) if(!_overlay_visible)
return; return;
unsigned char *src = screen; unsigned char *src = screen+_overlay_x+_overlay_y*SCREEN_W;
unsigned short *dst = overlay; unsigned short *dst = overlay;
for(int y=0; y<_screen_h; y++) { for(int y=0; y<OVL_H; y++) {
for(int x=0; x<_screen_w; x++) { for(int x=0; x<OVL_W; x++) {
short pix = palette[src[x]]; short pix = palette[src[x]];
dst[x] = ((pix&0x7fe0)<<1)|((pix&0x0200)>>4)|(pix&0x1f); 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) void OSystem_Dreamcast::grab_overlay(int16 *buf, int pitch)
{ {
int h = _screen_h; int h = OVL_H;
unsigned short *src = overlay; unsigned short *src = overlay;
do { do {
memcpy(buf, src, _screen_w*sizeof(int16)); memcpy(buf, src, OVL_W*sizeof(int16));
src += OVL_W; src += OVL_W;
buf += pitch; buf += pitch;
} while (--h); } while (--h);

View file

@ -160,9 +160,14 @@ bool OSystem_Dreamcast::poll_event(Event *event)
if (_ms_cur_x<0) _ms_cur_x=0; if (_ms_cur_x<0) _ms_cur_x=0;
if (_ms_cur_x>319) _ms_cur_x=319; if (_ms_cur_x>319) _ms_cur_x=319;
if (_ms_cur_y<0) _ms_cur_y=0; if (_ms_cur_y<0) _ms_cur_y=0;
if (_ms_cur_y>=_screen_h) _ms_cur_y=_screen_h-1; if (_ms_cur_y>=(_hires? (_screen_h>>1):_screen_h))
event->mouse.x = _ms_cur_x; _ms_cur_y=(_hires? (_screen_h>>1):_screen_h)-1;
event->mouse.y = _ms_cur_y; 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; event->kbd.ascii = event->kbd.keycode = 0;
if(e<0) { if(e<0) {
event->event_code = -e; event->event_code = -e;