2000-09-22 17:15:27 +00:00
|
|
|
/*
|
|
|
|
* video_blit.h - Video/graphics emulation, blitters
|
|
|
|
*
|
2008-01-01 09:40:36 +00:00
|
|
|
* Basilisk II (C) 1997-2008 Christian Bauer
|
2000-09-22 17:15:27 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2004-06-23 14:30:48 +00:00
|
|
|
#ifndef DEFINE_VIDEO_BLITTERS
|
|
|
|
|
|
|
|
#ifndef VIDEO_BLIT_H
|
|
|
|
#define VIDEO_BLIT_H
|
|
|
|
|
|
|
|
// Format of the target visual
|
|
|
|
struct VisualFormat {
|
2005-03-28 16:14:25 +00:00
|
|
|
bool fullscreen; // Full screen mode?
|
2004-06-23 14:30:48 +00:00
|
|
|
int depth; // Screen depth
|
|
|
|
uint32 Rmask, Gmask, Bmask; // RGB mask values
|
|
|
|
uint32 Rshift, Gshift, Bshift; // RGB shift values
|
|
|
|
};
|
|
|
|
|
2004-06-24 15:19:56 +00:00
|
|
|
// Prototypes
|
2004-06-23 14:30:48 +00:00
|
|
|
extern void (*Screen_blit)(uint8 * dest, const uint8 * source, uint32 length);
|
|
|
|
extern bool Screen_blitter_init(VisualFormat const & visual_format, bool native_byte_order, int mac_depth);
|
|
|
|
extern uint32 ExpandMap[256];
|
|
|
|
|
2004-06-24 15:19:56 +00:00
|
|
|
// Glue for SheepShaver and BasiliskII
|
|
|
|
#ifdef SHEEPSHAVER
|
|
|
|
enum {
|
|
|
|
VIDEO_DEPTH_1BIT = APPLE_1_BIT,
|
|
|
|
VIDEO_DEPTH_2BIT = APPLE_2_BIT,
|
|
|
|
VIDEO_DEPTH_4BIT = APPLE_4_BIT,
|
|
|
|
VIDEO_DEPTH_8BIT = APPLE_8_BIT,
|
|
|
|
VIDEO_DEPTH_16BIT = APPLE_16_BIT,
|
|
|
|
VIDEO_DEPTH_32BIT = APPLE_32_BIT
|
|
|
|
};
|
|
|
|
#define VIDEO_MODE VideoInfo
|
|
|
|
#define VIDEO_MODE_INIT VideoInfo const & mode = VModes[cur_mode]
|
2004-06-26 17:20:35 +00:00
|
|
|
#define VIDEO_MODE_INIT_MONITOR VIDEO_MODE_INIT
|
2004-06-24 15:19:56 +00:00
|
|
|
#define VIDEO_MODE_ROW_BYTES mode.viRowBytes
|
|
|
|
#define VIDEO_MODE_X mode.viXsize
|
|
|
|
#define VIDEO_MODE_Y mode.viYsize
|
|
|
|
#define VIDEO_MODE_RESOLUTION mode.viAppleID
|
|
|
|
#define VIDEO_MODE_DEPTH mode.viAppleMode
|
|
|
|
#else
|
|
|
|
enum {
|
|
|
|
VIDEO_DEPTH_1BIT = VDEPTH_1BIT,
|
|
|
|
VIDEO_DEPTH_2BIT = VDEPTH_2BIT,
|
|
|
|
VIDEO_DEPTH_4BIT = VDEPTH_4BIT,
|
|
|
|
VIDEO_DEPTH_8BIT = VDEPTH_8BIT,
|
|
|
|
VIDEO_DEPTH_16BIT = VDEPTH_16BIT,
|
|
|
|
VIDEO_DEPTH_32BIT = VDEPTH_32BIT
|
|
|
|
};
|
|
|
|
#define VIDEO_MODE video_mode
|
|
|
|
#define VIDEO_MODE_INIT video_mode const & mode = drv->mode
|
2004-06-26 17:20:35 +00:00
|
|
|
#define VIDEO_MODE_INIT_MONITOR video_mode const & mode = monitor.get_current_mode()
|
2004-06-24 15:19:56 +00:00
|
|
|
#define VIDEO_MODE_ROW_BYTES mode.bytes_per_row
|
|
|
|
#define VIDEO_MODE_X mode.x
|
|
|
|
#define VIDEO_MODE_Y mode.y
|
|
|
|
#define VIDEO_MODE_RESOLUTION mode.resolution_id
|
2004-06-29 21:50:23 +00:00
|
|
|
#define VIDEO_MODE_DEPTH mode.depth
|
2004-06-24 15:19:56 +00:00
|
|
|
#endif
|
|
|
|
|
2004-06-23 14:30:48 +00:00
|
|
|
#endif /* VIDEO_BLIT_H */
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2001-01-28 14:05:19 +00:00
|
|
|
#ifndef FB_DEPTH
|
|
|
|
# error "Undefined screen depth"
|
2000-09-22 17:15:27 +00:00
|
|
|
#endif
|
|
|
|
|
2001-01-28 14:05:19 +00:00
|
|
|
#if !defined(FB_BLIT_1) && (FB_DEPTH <= 16)
|
|
|
|
# error "Undefined 16-bit word blit function"
|
2000-09-22 17:15:27 +00:00
|
|
|
#endif
|
|
|
|
|
2001-01-28 14:05:19 +00:00
|
|
|
#if !defined(FB_BLIT_2)
|
|
|
|
# error "Undefined 32-bit word blit function"
|
2000-09-22 17:15:27 +00:00
|
|
|
#endif
|
|
|
|
|
2001-08-19 17:38:11 +00:00
|
|
|
#if !defined(FB_BLIT_4)
|
|
|
|
# error "Undefined 64-bit word blit function"
|
|
|
|
#endif
|
|
|
|
|
2000-09-22 17:15:27 +00:00
|
|
|
static void FB_FUNC_NAME(uint8 * dest, const uint8 * source, uint32 length)
|
|
|
|
{
|
2001-01-28 14:05:19 +00:00
|
|
|
#define DEREF_WORD_PTR(ptr, ofs) (((uint16 *)(ptr))[(ofs)])
|
2001-08-19 17:38:11 +00:00
|
|
|
#define DEREF_LONG_PTR(ptr, ofs) (((uint32 *)(ptr))[(ofs)])
|
|
|
|
#define DEREF_QUAD_PTR(ptr, ofs) (((uint64 *)(ptr))[(ofs)])
|
2000-09-23 08:39:55 +00:00
|
|
|
|
2001-01-28 14:05:19 +00:00
|
|
|
#ifndef UNALIGNED_PROFITABLE
|
2000-09-22 17:15:27 +00:00
|
|
|
#if FB_DEPTH <= 8
|
|
|
|
// Align source and dest to 16-bit word boundaries
|
2001-01-28 14:05:19 +00:00
|
|
|
if (((unsigned long) source) & 1) {
|
|
|
|
*dest++ = *source++;
|
2000-09-22 17:15:27 +00:00
|
|
|
length -= 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if FB_DEPTH <= 16
|
|
|
|
// Align source and dest to 32-bit word boundaries
|
|
|
|
if (((unsigned long) source) & 2) {
|
2001-01-28 14:05:19 +00:00
|
|
|
FB_BLIT_1(DEREF_WORD_PTR(dest, 0), DEREF_WORD_PTR(source, 0));
|
|
|
|
dest += 2; source += 2;
|
2000-09-22 17:15:27 +00:00
|
|
|
length -= 2;
|
|
|
|
}
|
2001-01-28 14:05:19 +00:00
|
|
|
#endif
|
2000-09-22 17:15:27 +00:00
|
|
|
#endif
|
|
|
|
|
2001-08-19 17:38:11 +00:00
|
|
|
// Blit 8-byte words
|
|
|
|
if (length >= 8) {
|
|
|
|
const int remainder = (length / 8) % 8;
|
|
|
|
source += remainder * 8;
|
|
|
|
dest += remainder * 8;
|
2000-09-22 17:15:27 +00:00
|
|
|
|
2001-08-19 17:38:11 +00:00
|
|
|
int n = ((length / 8) + 7) / 8;
|
2000-09-22 17:15:27 +00:00
|
|
|
switch (remainder) {
|
|
|
|
case 0: do {
|
2001-08-19 17:38:11 +00:00
|
|
|
dest += 64; source += 64;
|
|
|
|
FB_BLIT_4(DEREF_QUAD_PTR(dest, -8), DEREF_QUAD_PTR(source, -8));
|
|
|
|
case 7: FB_BLIT_4(DEREF_QUAD_PTR(dest, -7), DEREF_QUAD_PTR(source, -7));
|
|
|
|
case 6: FB_BLIT_4(DEREF_QUAD_PTR(dest, -6), DEREF_QUAD_PTR(source, -6));
|
|
|
|
case 5: FB_BLIT_4(DEREF_QUAD_PTR(dest, -5), DEREF_QUAD_PTR(source, -5));
|
|
|
|
case 4: FB_BLIT_4(DEREF_QUAD_PTR(dest, -4), DEREF_QUAD_PTR(source, -4));
|
|
|
|
case 3: FB_BLIT_4(DEREF_QUAD_PTR(dest, -3), DEREF_QUAD_PTR(source, -3));
|
|
|
|
case 2: FB_BLIT_4(DEREF_QUAD_PTR(dest, -2), DEREF_QUAD_PTR(source, -2));
|
|
|
|
case 1: FB_BLIT_4(DEREF_QUAD_PTR(dest, -1), DEREF_QUAD_PTR(source, -1));
|
2000-09-22 17:15:27 +00:00
|
|
|
} while (--n > 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-19 17:38:11 +00:00
|
|
|
// There could be one long left to blit
|
|
|
|
if (length & 4) {
|
|
|
|
FB_BLIT_2(DEREF_LONG_PTR(dest, 0), DEREF_LONG_PTR(source, 0));
|
|
|
|
#if FB_DEPTH <= 16
|
|
|
|
dest += 4;
|
|
|
|
source += 4;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2000-09-22 17:15:27 +00:00
|
|
|
#if FB_DEPTH <= 16
|
2001-01-28 14:05:19 +00:00
|
|
|
// There could be one word left to blit
|
2000-09-22 17:15:27 +00:00
|
|
|
if (length & 2) {
|
2001-01-28 14:05:19 +00:00
|
|
|
FB_BLIT_1(DEREF_WORD_PTR(dest, 0), DEREF_WORD_PTR(source, 0));
|
2000-09-23 08:39:55 +00:00
|
|
|
#if FB_DEPTH <= 8
|
2001-01-28 14:05:19 +00:00
|
|
|
dest += 2;
|
|
|
|
source += 2;
|
2000-09-23 08:39:55 +00:00
|
|
|
#endif
|
2000-09-22 17:15:27 +00:00
|
|
|
}
|
|
|
|
#endif
|
2000-09-23 06:51:46 +00:00
|
|
|
|
|
|
|
#if FB_DEPTH <= 8
|
2001-01-28 14:05:19 +00:00
|
|
|
// There could be one byte left to blit
|
2000-09-23 08:39:55 +00:00
|
|
|
if (length & 1)
|
2001-01-28 14:05:19 +00:00
|
|
|
*dest = *source;
|
2000-09-23 06:51:46 +00:00
|
|
|
#endif
|
2001-01-28 14:05:19 +00:00
|
|
|
|
2005-04-02 09:56:12 +00:00
|
|
|
#undef DEREF_QUAD_PTR
|
2001-01-28 14:05:19 +00:00
|
|
|
#undef DEREF_LONG_PTR
|
|
|
|
#undef DEREF_WORD_PTR
|
2000-09-22 17:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef FB_FUNC_NAME
|
|
|
|
|
|
|
|
#ifdef FB_BLIT_1
|
|
|
|
#undef FB_BLIT_1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FB_BLIT_2
|
|
|
|
#undef FB_BLIT_2
|
|
|
|
#endif
|
|
|
|
|
2001-08-19 17:38:11 +00:00
|
|
|
#ifdef FB_BLIT_4
|
|
|
|
#undef FB_BLIT_4
|
|
|
|
#endif
|
|
|
|
|
2000-09-22 17:15:27 +00:00
|
|
|
#ifdef FB_DEPTH
|
|
|
|
#undef FB_DEPTH
|
|
|
|
#endif
|
2004-06-23 14:30:48 +00:00
|
|
|
|
|
|
|
#endif /* DEFINE_VIDEO_BLITTERS */
|