2
* video_blit.h - Video/graphics emulation, blitters
4
* Basilisk II (C) 1997-2002 Christian Bauer
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
# error "Undefined screen depth"
25
#if !defined(FB_BLIT_1) && (FB_DEPTH <= 16)
26
# error "Undefined 16-bit word blit function"
29
#if !defined(FB_BLIT_2)
30
# error "Undefined 32-bit word blit function"
33
#if !defined(FB_BLIT_4)
34
# error "Undefined 64-bit word blit function"
37
static void FB_FUNC_NAME(uint8 * dest, const uint8 * source, uint32 length)
39
#define DEREF_WORD_PTR(ptr, ofs) (((uint16 *)(ptr))[(ofs)])
40
#define DEREF_LONG_PTR(ptr, ofs) (((uint32 *)(ptr))[(ofs)])
41
#define DEREF_QUAD_PTR(ptr, ofs) (((uint64 *)(ptr))[(ofs)])
43
#ifndef UNALIGNED_PROFITABLE
45
// Align source and dest to 16-bit word boundaries
46
if (((unsigned long) source) & 1) {
53
// Align source and dest to 32-bit word boundaries
54
if (((unsigned long) source) & 2) {
55
FB_BLIT_1(DEREF_WORD_PTR(dest, 0), DEREF_WORD_PTR(source, 0));
56
dest += 2; source += 2;
64
const int remainder = (length / 8) % 8;
65
source += remainder * 8;
66
dest += remainder * 8;
68
int n = ((length / 8) + 7) / 8;
71
dest += 64; source += 64;
72
FB_BLIT_4(DEREF_QUAD_PTR(dest, -8), DEREF_QUAD_PTR(source, -8));
73
case 7: FB_BLIT_4(DEREF_QUAD_PTR(dest, -7), DEREF_QUAD_PTR(source, -7));
74
case 6: FB_BLIT_4(DEREF_QUAD_PTR(dest, -6), DEREF_QUAD_PTR(source, -6));
75
case 5: FB_BLIT_4(DEREF_QUAD_PTR(dest, -5), DEREF_QUAD_PTR(source, -5));
76
case 4: FB_BLIT_4(DEREF_QUAD_PTR(dest, -4), DEREF_QUAD_PTR(source, -4));
77
case 3: FB_BLIT_4(DEREF_QUAD_PTR(dest, -3), DEREF_QUAD_PTR(source, -3));
78
case 2: FB_BLIT_4(DEREF_QUAD_PTR(dest, -2), DEREF_QUAD_PTR(source, -2));
79
case 1: FB_BLIT_4(DEREF_QUAD_PTR(dest, -1), DEREF_QUAD_PTR(source, -1));
84
// There could be one long left to blit
86
FB_BLIT_2(DEREF_LONG_PTR(dest, 0), DEREF_LONG_PTR(source, 0));
94
// There could be one word left to blit
96
FB_BLIT_1(DEREF_WORD_PTR(dest, 0), DEREF_WORD_PTR(source, 0));
105
// There could be one byte left to blit
110
#undef DEREF_LONG_PTR
111
#undef DEREF_WORD_PTR