Fixed compatibility of output.
[AROS.git] / arch / .unmaintained / m68k-pp-native / Drivers / display.hidd / displayhw.c
blobabf151c4bb697e3aab5eb180fe1c2521a738632b
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Display Inside...
6 Lang: English.
7 */
9 /*
10 NOTE: This file is mostly based on XFree86 vgaWH.c sources
13 /****************************************************************************************/
15 #include <proto/exec.h>
16 #include <oop/oop.h>
17 #include "displayhw.h"
18 #include "displayclass.h"
19 #include "bitmap.h"
20 #include <asm/registers.h>
22 /****************************************************************************************/
24 /****************************************************************************************/
26 #define min(a,b) ((a) < (b) ? (a) : (b))
27 #define max(a,b) ((a) > (b) ? (a) : (b))
29 /****************************************************************************************/
33 ** Load specified palette, if NULL load default
35 void DisplayLoadPalette(struct DisplayHWRec *regs, unsigned char *pal)
39 /****************************************************************************************/
43 ** displayHWSaveScreen
44 ** perform a sequencer reset.
46 void DisplaySaveScreen(int start)
50 /****************************************************************************************/
53 ** Blank the screen.
55 int DisplayBlankScreen(int on)
57 return TRUE;
60 /****************************************************************************************/
62 #define DisplayIOBase 0x3d0
64 /****************************************************************************************/
67 ** displayRestore --
68 ** restore a video mode
70 void DisplayRestore(struct displayHWRec *restore, BOOL onlyDac)
74 /****************************************************************************************/
77 ** displaySave --
78 ** save the current video mode
80 void * DisplaySave(struct displayHWRec *save)
83 return ((void *) save);
86 /****************************************************************************************/
89 ** Init VGA registers for given displaymode
91 int DisplayInitMode(struct DisplayModeDesc *mode, struct displayHWRec *regs)
93 return TRUE;
96 /****************************************************************************************/
98 void DisplayRefreshArea(struct bitmap_data *bmap, int num, struct Box *pbox)
100 int width, height, FBPitch, left, right, i, j, SRCPitch, phase;
101 register unsigned long m;
102 unsigned char s1, s2, s3, s4;
103 unsigned long *src, *srcPtr;
104 unsigned char *dst, *dstPtr;
106 FBPitch = RREG_B(LVPW) * 2;
107 SRCPitch = bmap->width / 4;
109 left = pbox->x1 & ~7;
110 right = (pbox->x2 & ~7) + 7;
112 while(num--)
114 width = (right - left + 1) >> 3;
115 height = pbox->y2 - pbox->y1 + 1;
116 src = (unsigned long*)(bmap->VideoData + (pbox->y1 * SRCPitch * 4) + left);
117 dst = (unsigned char*)(RREG_L(LSSA) + (pbox->y1 * FBPitch) + (left / 8));
119 if((phase = ((long)dst & 3L)))
121 phase = 4 - phase;
122 if(phase > width) phase = width;
123 width -= phase;
126 while(height--)
128 dstPtr = dst;
129 srcPtr = src;
130 i = width;
131 j = phase;
133 //#define MERGE (m >> 24) | (m >> 15) | (m >> 6) | (m << 3)
134 #define MERGE (m >> 21) | (m >> 14) | (m >> 7) | m
136 while(j--)
138 m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101) << 4);
139 *dstPtr++ = MERGE;
140 srcPtr += 2;
143 while(i >= 4)
145 m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101) << 4);
146 s1 = MERGE;
147 m = (srcPtr[3] & 0x01010101) | ((srcPtr[2] & 0x01010101) << 4);
148 s2 = MERGE;
149 m = (srcPtr[5] & 0x01010101) | ((srcPtr[4] & 0x01010101) << 4);
150 s3 = MERGE;
151 m = (srcPtr[7] & 0x01010101) | ((srcPtr[6] & 0x01010101) << 4);
152 s4 = MERGE;
153 *((unsigned long*)dstPtr) = s4 | (s3 << 8) | (s2 << 16) | (s1 << 24);
154 srcPtr += 8;
155 dstPtr += 4;
156 i -= 4;
159 while(i--)
161 m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101) << 4);
162 *dstPtr++ = MERGE;
163 srcPtr += 2;
166 dst += FBPitch;
167 src += SRCPitch;
169 } /* while(height--) */
170 pbox++;
172 } /* while(num--) */
176 /****************************************************************************************/