aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaroslav Hensl <emulator@emulace.cz>2024-08-25 12:52:59 +0200
committerJaroslav Hensl <emulator@emulace.cz>2024-08-25 12:52:59 +0200
commita31f4e91c1908b937e5d4f8421f0257043a89829 (patch)
tree2e0a29e891b465ac98e408932630fbe420959381
parent9bbfec33c0344a80fccee0b25a0887f22e2d9a73 (diff)
downloadvmdisp9x-a31f4e91c1908b937e5d4f8421f0257043a89829.tar.gz
Gamma support
-rw-r--r--3d_accel.h1
-rw-r--r--dibcall.c28
-rw-r--r--enable.c2
-rw-r--r--makefile5
-rw-r--r--pm16_calls.c68
-rw-r--r--vxd_fbhda.c89
-rw-r--r--vxd_gamma.h276
-rw-r--r--vxd_main.c12
-rw-r--r--vxd_svga.c120
-rw-r--r--vxd_svga_mem.c34
10 files changed, 565 insertions, 70 deletions
diff --git a/3d_accel.h b/3d_accel.h
index 46e6689..9de1464 100644
--- a/3d_accel.h
+++ b/3d_accel.h
@@ -176,6 +176,7 @@ void FBHDA_free();
#define FBHDA_ACCESS_RAW_BUFFERING 1
#define FBHDA_ACCESS_MOUSE_MOVE 2
+#define FBHDA_ACCESS_SURFACE_DIRTY 4
void FBHDA_access_begin(DWORD flags);
void FBHDA_access_end(DWORD flags);
diff --git a/dibcall.c b/dibcall.c
index 69d68cc..ccaa267 100644
--- a/dibcall.c
+++ b/dibcall.c
@@ -177,20 +177,22 @@ DWORD WINAPI __loadds ExtTextOut( LPDIBENGINE lpDestDev, WORD wDestXOrg, WORD wD
LPSTR lpString, int wCount, LPFONTINFO lpFontInfo, LPDRAWMODE lpDrawMode,
LPTEXTXFORM lpTextXForm, LPSHORT lpCharWidths, LPRECT lpOpaqueRect, WORD wOptions )
{
-/* if(wOptions & ETO_GLYPH_INDEX)
+ return DIB_ExtTextOut(lpDestDev, wDestXOrg, wDestYOrg, lpClipRect, lpString, wCount, lpFontInfo, lpDrawMode, lpTextXForm, lpCharWidths, lpOpaqueRect, wOptions);
+}
+
+BOOL WINAPI __loadds DDIGammaRamp(LPDIBENGINE lpDev, BOOL fGetSet, LPARAM lpGammaRamp)
+{
+ BOOL rc;
+ if(fGetSet)
{
- return 0x80000000UL;
- }*/
-
- /*if(wCount > 0)
+ rc = FBHDA_gamma_set((VOID FBPTR)lpGammaRamp, sizeof(WORD)*256*3);
+ dbg_printf("set the ramp: %d\n", rc);
+ }
+ else
{
- dbg_printf("ExtTextOut: ");
- for(i = 0; i < wCount; i++)
- {
- dbg_printf("%c", lpString[i]);
- }
- dbg_printf("(%X) %d\n", lpString[0], wCount);
- }*/
+ rc = FBHDA_gamma_get((VOID FBPTR)lpGammaRamp, sizeof(WORD)*256*3);
+ dbg_printf("get the ramp\n");
+ }
- return DIB_ExtTextOut(lpDestDev, wDestXOrg, wDestYOrg, lpClipRect, lpString, wCount, lpFontInfo, lpDrawMode, lpTextXForm, lpCharWidths, lpOpaqueRect, wOptions);
+ return rc;
}
diff --git a/enable.c b/enable.c
index eff94c8..9b0ee40 100644
--- a/enable.c
+++ b/enable.c
@@ -375,7 +375,7 @@ UINT WINAPI __loadds Enable( LPVOID lpDevice, UINT style, LPSTR lpDeviceType,
* Realistically, software rendering in a VM on a modern system is going to be a lot
* faster than most mid-1990s graphics cards.
*/
- lpInfo->dpCaps1 |= C1_COLORCURSOR | C1_REINIT_ABLE | C1_BYTE_PACKED | C1_GLYPH_INDEX; /* | C1_SLOW_CARD */;
+ lpInfo->dpCaps1 |= C1_COLORCURSOR | C1_REINIT_ABLE | C1_BYTE_PACKED | C1_GLYPH_INDEX | C1_GAMMA_RAMP; /* | C1_SLOW_CARD */;
lpInfo->dpText |= TC_CP_STROKE | TC_RA_ABLE;
#if 0
diff --git a/makefile b/makefile
index 5b8ca9f..b509e51 100644
--- a/makefile
+++ b/makefile
@@ -12,7 +12,7 @@ OBJS += &
INCS = -I$(%WATCOM)\h\win -Iddk -Ivmware
-VER_BUILD = 78
+VER_BUILD = 80
FLAGS = -DDRV_VER_BUILD=$(VER_BUILD)
@@ -277,6 +277,7 @@ export StretchDIBits.28
export SelectBitmap.29
export BitmapBits.30
export ReEnable.31
+export DDIGammaRamp.32
export Inquire.101
export SetCursor.102
export MoveCursor.103
@@ -344,6 +345,7 @@ export StretchDIBits.28
export SelectBitmap.29
export BitmapBits.30
export ReEnable.31
+export DDIGammaRamp.32
export Inquire.101
export SetCursor.102
export MoveCursor.103
@@ -411,6 +413,7 @@ export StretchDIBits.28
export SelectBitmap.29
export BitmapBits.30
export ReEnable.31
+export DDIGammaRamp.32
export Inquire.101
export SetCursor.102
export MoveCursor.103
diff --git a/pm16_calls.c b/pm16_calls.c
index c3a5d19..f9334b2 100644
--- a/pm16_calls.c
+++ b/pm16_calls.c
@@ -308,6 +308,74 @@ DWORD FBHDA_palette_get(unsigned char index)
return sRGB;
}
+BOOL FBHDA_gamma_get(VOID FBPTR ramp, DWORD buffer_size)
+{
+ static DWORD ramp_linear;
+ static DWORD ramp_size;
+ static unsigned short status;
+
+ ramp_linear = DPMI_GetSegBase(((DWORD)ramp) >> 16);
+ ramp_linear += ((DWORD)ramp) & 0xFFFFUL;
+
+ ramp_size = buffer_size;
+
+ _asm
+ {
+ .386
+ push eax
+ push edx
+ push ecx
+ push edi
+
+ mov edx, OP_FBHDA_GAMMA_GET
+ mov ecx, [buffer_size]
+ mov edi, [ramp_linear]
+ call dword ptr [VXD_VM]
+ mov [status],cx
+
+ pop edi
+ pop ecx
+ pop edx
+ pop eax
+ }
+
+ return status == 0 ? FALSE : TRUE;
+}
+
+BOOL FBHDA_gamma_set(VOID FBPTR ramp, DWORD buffer_size)
+{
+ static DWORD ramp_linear;
+ static DWORD ramp_size;
+ static unsigned short status;
+
+ ramp_linear = DPMI_GetSegBase(((DWORD)ramp) >> 16);
+ ramp_linear += ((DWORD)ramp) & 0xFFFFUL;
+
+ ramp_size = buffer_size;
+
+ _asm
+ {
+ .386
+ push eax
+ push edx
+ push ecx
+ push esi
+
+ mov edx, OP_FBHDA_GAMMA_SET
+ mov ecx, [buffer_size]
+ mov esi, [ramp_linear]
+ call dword ptr [VXD_VM]
+ mov [status],cx
+
+ pop esi
+ pop ecx
+ pop edx
+ pop eax
+ }
+
+ return status == 0 ? FALSE : TRUE;
+}
+
BOOL mouse_load()
{
static BOOL status;
diff --git a/vxd_fbhda.c b/vxd_fbhda.c
index ca20438..b879db1 100644
--- a/vxd_fbhda.c
+++ b/vxd_fbhda.c
@@ -31,6 +31,8 @@ THE SOFTWARE.
#include "code32.h"
+#include "vxd_gamma.h"
+
FBHDA_t *hda = NULL;
ULONG hda_sem = 0;
LONG fb_lock_cnt = 0;
@@ -48,6 +50,8 @@ BOOL FBHDA_init_hw()
hda->version = API_3DACCEL_VER;
hda->flags = 0;
+ hda->gamma = 1 << 16;
+
hda_sem = Create_Semaphore(1);
if(hda_sem == 0)
{
@@ -87,3 +91,88 @@ void FBHDA_clean()
memset(hda->vram_pm32, 0, hda->stride);
FBHDA_access_end(0);
}
+
+static WORD gamma_ramp[3][256];
+static BOOL gamma_ramp_init = FALSE;
+
+static void init_ramp()
+{
+ WORD i = 0;
+ for(i = 0; i < 256; i++)
+ {
+ gamma_ramp[0][i] = i << 8;
+ gamma_ramp[1][i] = i << 8;
+ gamma_ramp[2][i] = i << 8;
+ }
+
+ gamma_ramp_init = TRUE;
+}
+
+BOOL FBHDA_gamma_get(VOID FBPTR ramp, DWORD buffer_size)
+{
+ if(sizeof(gamma_ramp) == buffer_size)
+ {
+ if(!gamma_ramp_init)
+ init_ramp();
+
+ memcpy(ramp, &gamma_ramp[0][0], sizeof(gamma_ramp));
+ return TRUE;
+ }
+ else
+ {
+ dbg_printf("Wrong ramp size: %ld\n", buffer_size);
+ }
+
+ return FALSE;
+}
+
+
+
+BOOL FBHDA_gamma_set(VOID FBPTR ramp, DWORD buffer_size)
+{
+ if(sizeof(gamma_ramp) == buffer_size)
+ {
+ WORD *new_ramp = ramp;
+ DWORD gamma = (
+ gamma_table[(new_ramp[0*256 + 128] >> 8)] +
+ gamma_table[(new_ramp[1*256 + 128] >> 8)] +
+ gamma_table[(new_ramp[2*256 + 128] >> 8)]
+ ) / 3;
+
+ if(gamma >= 0x3000 && gamma < 0xFF0000) /* from ~0.2000 to 255.0000 */
+ {
+ hda->gamma = gamma;
+ hda->gamma_update++;
+
+ /* copy new ramp */
+ memcpy(&gamma_ramp[0][0], ramp, sizeof(gamma_ramp));
+ gamma_ramp_init = TRUE;
+
+ dbg_printf("gamma update to 0x%lX\n", hda->gamma);
+
+ return TRUE;
+ }
+ else
+ {
+ dbg_printf("Gamma out of reach: 0x%lX\n", gamma);
+ {
+ int i = 0;
+ dbg_printf("RAMP\n");
+ for(i = 0; i < 256; i++)
+ {
+ dbg_printf("%d: R: %X, G: %X, B: %X\n", i,
+ new_ramp[0*256 + i],
+ new_ramp[1*256 + i],
+ new_ramp[2*256 + i]);
+ }
+ }
+ }
+ }
+ else
+ {
+ dbg_printf("Wrong ramp size: %ld\n", buffer_size);
+ }
+
+ return FALSE;
+}
+
diff --git a/vxd_gamma.h b/vxd_gamma.h
new file mode 100644
index 0000000..77827f6
--- /dev/null
+++ b/vxd_gamma.h
@@ -0,0 +1,276 @@
+#ifndef __VXD_GAMMA_H__INCLUDED__
+#define __VXD_GAMMA_H__INCLUDED__
+
+/*
+ formula to compute gamma correction (g):
+ 1
+ g = --------
+ ln(c)
+ ------
+ ln(b)
+
+ c = chroma value (eg. color/255.f)
+ b = RGB base color value
+*/
+
+/* gamma table computed for chroma(128): */
+static const DWORD gamma_table[256] = {
+ 0x00000000, // 0 = 0.000000
+ 0x00001FD7, // 1 = 0.124382
+ 0x00002464, // 2 = 0.142165
+ 0x000027B7, // 3 = 0.155140
+ 0x00002A77, // 4 = 0.165882
+ 0x00002CE0, // 5 = 0.175296
+ 0x00002F0E, // 6 = 0.183820
+ 0x00003113, // 7 = 0.191701
+ 0x000032F7, // 8 = 0.199096
+ 0x000034C3, // 9 = 0.206108
+ 0x0000367A, // 10 = 0.212813
+ 0x00003821, // 11 = 0.219266
+ 0x000039BA, // 12 = 0.225508
+ 0x00003B48, // 13 = 0.231573
+ 0x00003CCB, // 14 = 0.237486
+ 0x00003E46, // 15 = 0.243269
+ 0x00003FBA, // 16 = 0.248940
+ 0x00004127, // 17 = 0.254513
+ 0x0000428F, // 18 = 0.260001
+ 0x000043F2, // 19 = 0.265414
+ 0x00004550, // 20 = 0.270762
+ 0x000046AB, // 21 = 0.276053
+ 0x00004802, // 22 = 0.281294
+ 0x00004957, // 23 = 0.286492
+ 0x00004AA9, // 24 = 0.291651
+ 0x00004BF9, // 25 = 0.296778
+ 0x00004D47, // 26 = 0.301876
+ 0x00004E94, // 27 = 0.306950
+ 0x00004FDF, // 28 = 0.312003
+ 0x00005129, // 29 = 0.317039
+ 0x00005272, // 30 = 0.322062
+ 0x000053BB, // 31 = 0.327073
+ 0x00005502, // 32 = 0.332076
+ 0x0000564A, // 33 = 0.337074
+ 0x00005791, // 34 = 0.342068
+ 0x000058D8, // 35 = 0.347061
+ 0x00005A20, // 36 = 0.352055
+ 0x00005B67, // 37 = 0.357052
+ 0x00005CAF, // 38 = 0.362054
+ 0x00005DF7, // 39 = 0.367062
+ 0x00005F40, // 40 = 0.372079
+ 0x0000608A, // 41 = 0.377106
+ 0x000061D4, // 42 = 0.382144
+ 0x0000631F, // 43 = 0.387196
+ 0x0000646B, // 44 = 0.392262
+ 0x000065B8, // 45 = 0.397344
+ 0x00006706, // 46 = 0.402443
+ 0x00006855, // 47 = 0.407561
+ 0x000069A6, // 48 = 0.412699
+ 0x00006AF8, // 49 = 0.417858
+ 0x00006C4C, // 50 = 0.423040
+ 0x00006DA1, // 51 = 0.428245
+ 0x00006EF8, // 52 = 0.433475
+ 0x00007050, // 53 = 0.438731
+ 0x000071AA, // 54 = 0.444014
+ 0x00007306, // 55 = 0.449325
+ 0x00007464, // 56 = 0.454666
+ 0x000075C4, // 57 = 0.460037
+ 0x00007727, // 58 = 0.465440
+ 0x0000788B, // 59 = 0.470876
+ 0x000079F1, // 60 = 0.476345
+ 0x00007B5A, // 61 = 0.481850
+ 0x00007CC5, // 62 = 0.487391
+ 0x00007E33, // 63 = 0.492968
+ 0x00007FA3, // 64 = 0.498584
+ 0x00008115, // 65 = 0.504240
+ 0x0000828B, // 66 = 0.509935
+ 0x00008403, // 67 = 0.515673
+ 0x0000857D, // 68 = 0.521453
+ 0x000086FB, // 69 = 0.527277
+ 0x0000887C, // 70 = 0.533145
+ 0x000089FF, // 71 = 0.539060
+ 0x00008B86, // 72 = 0.545022
+ 0x00008D10, // 73 = 0.551032
+ 0x00008E9D, // 74 = 0.557092
+ 0x0000902E, // 75 = 0.563202
+ 0x000091C1, // 76 = 0.569365
+ 0x00009359, // 77 = 0.575580
+ 0x000094F4, // 78 = 0.581850
+ 0x00009692, // 79 = 0.588176
+ 0x00009834, // 80 = 0.594558
+ 0x000099DB, // 81 = 0.600998
+ 0x00009B84, // 82 = 0.607498
+ 0x00009D32, // 83 = 0.614058
+ 0x00009EE4, // 84 = 0.620681
+ 0x0000A09B, // 85 = 0.627367
+ 0x0000A255, // 86 = 0.634118
+ 0x0000A414, // 87 = 0.640935
+ 0x0000A5D7, // 88 = 0.647820
+ 0x0000A79F, // 89 = 0.654774
+ 0x0000A96B, // 90 = 0.661799
+ 0x0000AB3C, // 91 = 0.668896
+ 0x0000AD12, // 92 = 0.676067
+ 0x0000AEED, // 93 = 0.683313
+ 0x0000B0CD, // 94 = 0.690636
+ 0x0000B2B2, // 95 = 0.698038
+ 0x0000B49C, // 96 = 0.705520
+ 0x0000B68C, // 97 = 0.713084
+ 0x0000B881, // 98 = 0.720732
+ 0x0000BA7C, // 99 = 0.728466
+ 0x0000BC7D, // 100 = 0.736287
+ 0x0000BE83, // 101 = 0.744197
+ 0x0000C090, // 102 = 0.752199
+ 0x0000C2A2, // 103 = 0.760295
+ 0x0000C4BB, // 104 = 0.768485
+ 0x0000C6DA, // 105 = 0.776773
+ 0x0000C900, // 106 = 0.785161
+ 0x0000CB2C, // 107 = 0.793650
+ 0x0000CD5F, // 108 = 0.802243
+ 0x0000CF99, // 109 = 0.810943
+ 0x0000D1DB, // 110 = 0.819752
+ 0x0000D423, // 111 = 0.828671
+ 0x0000D673, // 112 = 0.837704
+ 0x0000D8CB, // 113 = 0.846853
+ 0x0000DB2A, // 114 = 0.856121
+ 0x0000DD92, // 115 = 0.865511
+ 0x0000E001, // 116 = 0.875024
+ 0x0000E279, // 117 = 0.884665
+ 0x0000E4F9, // 118 = 0.894436
+ 0x0000E782, // 119 = 0.904339
+ 0x0000EA14, // 120 = 0.914379
+ 0x0000ECAF, // 121 = 0.924558
+ 0x0000EF54, // 122 = 0.934880
+ 0x0000F202, // 123 = 0.945348
+ 0x0000F4BA, // 124 = 0.955965
+ 0x0000F77B, // 125 = 0.966735
+ 0x0000FA48, // 126 = 0.977661
+ 0x0000FD1E, // 127 = 0.988748
+ 0x00010000, // 128 = 1.000000
+ 0x000102EC, // 129 = 1.011420
+ 0x000105E4, // 130 = 1.023012
+ 0x000108E7, // 131 = 1.034782
+ 0x00010BF6, // 132 = 1.046733
+ 0x00010F12, // 133 = 1.058869
+ 0x00011239, // 134 = 1.071197
+ 0x0001156E, // 135 = 1.083719
+ 0x000118B0, // 136 = 1.096443
+ 0x00011BFF, // 137 = 1.109372
+ 0x00011F5C, // 138 = 1.122512
+ 0x000122C8, // 139 = 1.135869
+ 0x00012642, // 140 = 1.149448
+ 0x000129CB, // 141 = 1.163256
+ 0x00012D63, // 142 = 1.177298
+ 0x0001310B, // 143 = 1.191582
+ 0x000134C3, // 144 = 1.206112
+ 0x0001388C, // 145 = 1.220898
+ 0x00013C66, // 146 = 1.235945
+ 0x00014052, // 147 = 1.251261
+ 0x00014450, // 148 = 1.266854
+ 0x00014861, // 149 = 1.282731
+ 0x00014C84, // 150 = 1.298900
+ 0x000150BC, // 151 = 1.315372
+ 0x00015507, // 152 = 1.332153
+ 0x00015968, // 153 = 1.349254
+ 0x00015DDE, // 154 = 1.366683
+ 0x0001626B, // 155 = 1.384452
+ 0x0001670E, // 156 = 1.402570
+ 0x00016BC9, // 157 = 1.421048
+ 0x0001709D, // 158 = 1.439897
+ 0x00017589, // 159 = 1.459129
+ 0x00017A8F, // 160 = 1.478757
+ 0x00017FB0, // 161 = 1.498792
+ 0x000184ED, // 162 = 1.519249
+ 0x00018A46, // 163 = 1.540140
+ 0x00018FBD, // 164 = 1.561481
+ 0x00019552, // 165 = 1.583287
+ 0x00019B06, // 166 = 1.605572
+ 0x0001A0DB, // 167 = 1.628355
+ 0x0001A6D2, // 168 = 1.651651
+ 0x0001ACEC, // 169 = 1.675479
+ 0x0001B329, // 170 = 1.699858
+ 0x0001B98D, // 171 = 1.724808
+ 0x0001C016, // 172 = 1.750349
+ 0x0001C6C8, // 173 = 1.776503
+ 0x0001CDA4, // 174 = 1.803293
+ 0x0001D4AB, // 175 = 1.830742
+ 0x0001DBDF, // 176 = 1.858876
+ 0x0001E341, // 177 = 1.887722
+ 0x0001EAD4, // 178 = 1.917306
+ 0x0001F299, // 179 = 1.947659
+ 0x0001FA93, // 180 = 1.978811
+ 0x000202C3, // 181 = 2.010795
+ 0x00020B2C, // 182 = 2.043645
+ 0x000213D0, // 183 = 2.077397
+ 0x00021CB1, // 184 = 2.112089
+ 0x000225D3, // 185 = 2.147762
+ 0x00022F38, // 186 = 2.184458
+ 0x000238E3, // 187 = 2.222223
+ 0x000242D7, // 188 = 2.261104
+ 0x00024D18, // 189 = 2.301153
+ 0x000257A9, // 190 = 2.342423
+ 0x0002628D, // 191 = 2.384972
+ 0x00026DC9, // 192 = 2.428860
+ 0x00027962, // 193 = 2.474154
+ 0x0002855B, // 194 = 2.520921
+ 0x000291B9, // 195 = 2.569235
+ 0x00029E82, // 196 = 2.619176
+ 0x0002ABBB, // 197 = 2.670828
+ 0x0002B96A, // 198 = 2.724280
+ 0x0002C795, // 199 = 2.779629
+ 0x0002D644, // 200 = 2.836979
+ 0x0002E57D, // 201 = 2.896442
+ 0x0002F548, // 202 = 2.958135
+ 0x000305AE, // 203 = 3.022190
+ 0x000316B7, // 204 = 3.088744
+ 0x0003286F, // 205 = 3.157947
+ 0x00033ADE, // 206 = 3.229963
+ 0x00034E12, // 207 = 3.304966
+ 0x00036215, // 208 = 3.383147
+ 0x000376F7, // 209 = 3.464715
+ 0x00038CC5, // 210 = 3.549894
+ 0x0003A391, // 211 = 3.638931
+ 0x0003BB6A, // 212 = 3.732096
+ 0x0003D466, // 213 = 3.829683
+ 0x0003EE98, // 214 = 3.932015
+ 0x00040A19, // 215 = 4.039450
+ 0x00042702, // 216 = 4.152379
+ 0x0004456F, // 217 = 4.271237
+ 0x00046581, // 218 = 4.396504
+ 0x00048759, // 219 = 4.528715
+ 0x0004AB20, // 220 = 4.668464
+ 0x0004D100, // 221 = 4.816417
+ 0x0004F92B, // 222 = 4.973320
+ 0x000523D7, // 223 = 5.140012
+ 0x00055143, // 224 = 5.317440
+ 0x000581B5, // 225 = 5.506679
+ 0x0005B57D, // 226 = 5.708950
+ 0x0005ECF7, // 227 = 5.925650
+ 0x0006288B, // 228 = 6.158382
+ 0x000668B3, // 229 = 6.408996
+ 0x0006ADFC, // 230 = 6.679637
+ 0x0006F90A, // 231 = 6.972811
+ 0x00074A9C, // 232 = 7.291454
+ 0x0007A398, // 233 = 7.639042
+ 0x0008050B, // 234 = 8.019709
+ 0x0008703C, // 235 = 8.438417
+ 0x0008E6B3, // 236 = 8.901173
+ 0x00096A52, // 237 = 9.415317
+ 0x0009FD6B, // 238 = 9.989920
+ 0x000AA2E5, // 239 = 10.636317
+ 0x000B5E6E, // 240 = 11.368867
+ 0x000C34BE, // 241 = 12.206032
+ 0x000D2C05, // 242 = 13.171954
+ 0x000E4C7F, // 243 = 14.298822
+ 0x000FA16A, // 244 = 15.630531
+ 0x00113A81, // 245 = 17.228534
+ 0x00132E7D, // 246 = 19.181596
+ 0x00159F73, // 247 = 21.622863
+ 0x0018C2F6, // 248 = 24.761568
+ 0x001CF249, // 249 = 28.946430
+ 0x0022CE1D, // 250 = 34.805143
+ 0x002B97D5, // 251 = 43.593097
+ 0x003A3D52, // 252 = 58.239533
+ 0x0057883C, // 253 = 87.532174
+ 0x00AF68DE, // 254 = 175.409644
+ 0x00FFFFFF, // 255 = 255.000000 (INF)
+};
+
+#endif /* __VXD_GAMMA_H__INCLUDED__ */
diff --git a/vxd_main.c b/vxd_main.c
index b4ca31f..cac0ea1 100644
--- a/vxd_main.c
+++ b/vxd_main.c
@@ -231,7 +231,7 @@ WORD __stdcall VXD_API_Proc(PCRS_32 state)
WORD rc = 0xFFFF;
WORD service = state->Client_EDX & 0xFFFF;
-// dbg_printf(dbg_vxd_api, service);
+ //dbg_printf(dbg_vxd_api, service);
Begin_Critical_Section(0);
switch(service)
@@ -288,6 +288,16 @@ WORD __stdcall VXD_API_Proc(PCRS_32 state)
rc = 1;
break;
}
+ case OP_FBHDA_GAMMA_GET:
+ dbg_printf("OP_FBHDA_GAMMA_GET\n");
+ state->Client_ECX = FBHDA_gamma_get((void *)state->Client_EDI, state->Client_ECX);
+ rc = 1;
+ break;
+ case OP_FBHDA_GAMMA_SET:
+ dbg_printf("OP_FBHDA_GAMMA_SET\n");
+ state->Client_ECX = FBHDA_gamma_set((void *)state->Client_ESI, state->Client_ECX);
+ rc = 1;
+ break;
/* mouse */
case OP_MOUSE_LOAD:
state->Client_ECX = mouse_load();
diff --git a/vxd_svga.c b/vxd_svga.c
index 1244788..550db46 100644
--- a/vxd_svga.c
+++ b/vxd_svga.c
@@ -579,7 +579,10 @@ BOOL SVGA_init_hw()
cache_enable(TRUE);
}
}
-
+
+ /* switch back to VGA mode, SVGA mode will be request by 16 bit driver later */
+ SVGA_HW_disable();
+
return TRUE;
}
@@ -1279,9 +1282,14 @@ void FBHDA_access_end(DWORD flags)
{
return;
}
-
+
Wait_Semaphore(hda_sem, 0);
-
+
+ if(flags & FBHDA_ACCESS_SURFACE_DIRTY)
+ {
+ surface_dirty = TRUE;
+ }
+
if(flags & FBHDA_ACCESS_MOUSE_MOVE)
{
DWORD l, t, r, b;
@@ -1297,26 +1305,28 @@ void FBHDA_access_end(DWORD flags)
if(fb_lock_cnt == 0)
{
+ DWORD w, h;
BOOL need_refresh = ((hda->bpp == 32) && (hda->system_surface == 0));
+ w = rect_right - rect_left;
+ h = rect_bottom - rect_top;
+
/* dbg_printf("FBHDA_access_end(%ld %ld %ld %ld)\n",
rect_left, rect_top, rect_right, rect_bottom);*/
- mouse_blit();
- if(hda->surface > 0)
+
+ if(w > 0 && h > 0)
{
- switch(hda->bpp)
+ check_dirty();
+ mouse_blit();
+ if(hda->surface > 0)
{
- case 32:
+ switch(hda->bpp)
{
- DWORD w, h;
- SVGAFifoCmdBlitGMRFBToScreen *gmrblit;
- DWORD cmd_offset = 0;
-
- w = rect_right - rect_left;
- h = rect_bottom - rect_top;
-
- if(w > 0 && h > 0)
+ case 32:
{
+ SVGAFifoCmdBlitGMRFBToScreen *gmrblit;
+ DWORD cmd_offset = 0;
+
wait_for_cmdbuf();
gmrblit = SVGA_cmd_ptr(cmdbuf, &cmd_offset, SVGA_CMD_BLIT_GMRFB_TO_SCREEN, sizeof(SVGAFifoCmdBlitGMRFBToScreen));
@@ -1329,47 +1339,51 @@ void FBHDA_access_end(DWORD flags)
gmrblit->destRect.bottom = rect_bottom;
gmrblit->destScreenId = 0;
-
+
submit_cmdbuf(cmd_offset, SVGA_CB_UPDATE, 0);
+ break;
}
- break;
- }
- case 16:
- blit16(
- ((BYTE*)hda->vram_pm32)+hda->surface, hda->pitch,
- hda->vram_pm32, SVGA_pitch(hda->width, 32),
- rect_left, rect_top,
- rect_right - rect_left, rect_bottom - rect_top
- );
- need_refresh = TRUE;
- break;
- case 8:
- blit8(
- ((BYTE*)hda->vram_pm32)+hda->surface, hda->pitch,
- hda->vram_pm32, SVGA_pitch(hda->width, 32),
- rect_left, rect_top,
- rect_right - rect_left, rect_bottom - rect_top
- );
- need_refresh = TRUE;
- break;
- } // switch
+ case 16:
+ blit16(
+ ((BYTE*)hda->vram_pm32)+hda->surface, hda->pitch,
+ hda->vram_pm32, SVGA_pitch(hda->width, 32),
+ rect_left, rect_top,
+ rect_right - rect_left, rect_bottom - rect_top
+ );
+ need_refresh = TRUE;
+ break;
+ case 8:
+ blit8(
+ ((BYTE*)hda->vram_pm32)+hda->surface, hda->pitch,
+ hda->vram_pm32, SVGA_pitch(hda->width, 32),
+ rect_left, rect_top,
+ rect_right - rect_left, rect_bottom - rect_top
+ );
+ need_refresh = TRUE;
+ break;
+ } // switch
+ }
+
+ if(need_refresh)
+ {
+ SVGAFifoCmdUpdate *cmd_update;
+ DWORD cmd_offset = 0;
+
+ wait_for_cmdbuf();
+
+ cmd_update = SVGA_cmd_ptr(cmdbuf, &cmd_offset, SVGA_CMD_UPDATE, sizeof(SVGAFifoCmdUpdate));
+ cmd_update->x = rect_left;
+ cmd_update->y = rect_top;
+ cmd_update->width = rect_right - rect_left;
+ cmd_update->height = rect_bottom - rect_top;
+
+ submit_cmdbuf(cmd_offset, SVGA_CB_UPDATE, 0);
+ }
}
-
- if(need_refresh)
- {
- SVGAFifoCmdUpdate *cmd_update;
- DWORD cmd_offset = 0;
-
- wait_for_cmdbuf();
-
- cmd_update = SVGA_cmd_ptr(cmdbuf, &cmd_offset, SVGA_CMD_UPDATE, sizeof(SVGAFifoCmdUpdate));
- cmd_update->x = rect_left;
- cmd_update->y = rect_top;
- cmd_update->width = rect_right - rect_left;
- cmd_update->height = rect_bottom - rect_top;
-
- submit_cmdbuf(cmd_offset, SVGA_CB_UPDATE, 0);
- }
+ else
+ {
+ mouse_blit(); /* in this case is mouse unvisible, but we need still switch visibility state */
+ } // w == 0 && h == 0
} // fb_lock_cnt == 0
Signal_Semaphore(hda_sem);
diff --git a/vxd_svga_mem.c b/vxd_svga_mem.c
index 727ced7..026da70 100644
--- a/vxd_svga_mem.c
+++ b/vxd_svga_mem.c
@@ -97,6 +97,10 @@ static svga_cache_state_t cache_state = {0, 0};
static BOOL cache_enabled = FALSE;
+#define PHY_CACHE_SIZE (8192 + 1024)
+static DWORD phycache[PHY_CACHE_SIZE];
+static DWORD phycache_starta = 0;
+static DWORD phycache_enda = 0;
/*
* globals
@@ -109,14 +113,40 @@ extern LONG fb_lock_cnt;
extern BOOL gb_support;
+static void cachePPN(DWORD virtualaddr, DWORD pages)
+{
+ DWORD i = 0;
+ if(pages > PHY_CACHE_SIZE)
+ {
+ pages = PHY_CACHE_SIZE;
+ }
+
+ _CopyPageTable(_PAGE(virtualaddr), pages, &phycache, 0);
+
+ for(i = 0; i < pages; i++)
+ {
+ phycache[i] = _PAGE(phycache[i]);
+ }
+
+ dbg_printf("cachePPN: %lX (size: %ld)\n", virtualaddr, pages);
+
+ phycache_starta = virtualaddr;
+ phycache_enda = virtualaddr + (pages << P_SHIFT);
+}
+
/**
* Return PPN (physical page number) to virtual address
*
**/
-
static DWORD getPPN(DWORD virtualaddr)
{
DWORD phy = 0;
+
+ if(virtualaddr >= phycache_starta && virtualaddr < phycache_enda)
+ {
+ return phycache[_PAGE(virtualaddr - phycache_starta)];
+ }
+
_CopyPageTable(_PAGE(virtualaddr), 1, &phy, 0);
return _PAGE(phy);
}
@@ -725,6 +755,8 @@ BOOL SVGA_region_create(SVGA_region_info_t *rinfo)
{
return FALSE;
}
+
+ cachePPN(maddr, nPages+pt_pages);
laddr = maddr + pt_pages*P_SIZE;