tVT_Char *chars = Buffer;\r
int pitch = gVesa_Modes[giVesaCurrentMode].pitch;\r
int depth = gVesa_Modes[giVesaCurrentMode].bpp;\r
+ int bytes_per_px = gVesa_Modes[giVesaCurrentMode].bpp / 8;\r
int widthInChars = gVesa_Modes[giVesaCurrentMode].width/giVT_CharWidth;\r
int heightInChars = gVesa_Modes[giVesaCurrentMode].height/giVT_CharHeight;\r
int x, y;\r
Length /= sizeof(tVT_Char);\r
Offset /= sizeof(tVT_Char);\r
\r
+ if( depth == 32 ) depth = 24; // Actually 24-colour bits\r
+ \r
LOG("gVesa_Modes[%i] = {height:%i, width:%i, pitch:%i}",\r
giVesaCurrentMode,\r
gVesa_Modes[giVesaCurrentMode].height,\r
LOG("(x,y) = (%i,%i) = [%i,%i]",\r
x,\r
y,\r
- x * giVT_CharWidth * depth / 8,\r
+ x * giVT_CharWidth * bytes_per_px,\r
y * giVT_CharHeight * pitch\r
);\r
LOG("(w,h) = (%i,%i) = [%i,%i]",\r
(int)(Length % widthInChars),\r
(int)(Length / widthInChars),\r
- (int)((Length % widthInChars) * giVT_CharWidth * depth / 8),\r
+ (int)((Length % widthInChars) * giVT_CharWidth * bytes_per_px),\r
(int)((Length / widthInChars) * giVT_CharHeight * pitch)\r
);\r
\r
for( i = 0; i < (int)Length; i++ )\r
{\r
if(\r
- !MM_GetPhysAddr( (tVAddr)dest + x*giVT_CharWidth*depth/8 )\r
+ !MM_GetPhysAddr( (tVAddr)dest + x*giVT_CharWidth*bytes_per_px )\r
// || !MM_GetPhysAddr( (tVAddr)dest + x*giVT_CharWidth*depth/8 + pitch*giVT_CharHeight-1)\r
)\r
{\r
\r
VT_Font_Render(\r
chars->Ch,\r
- dest + x*giVT_CharWidth*depth/8, depth, pitch,\r
+ dest + x*giVT_CharWidth*bytes_per_px, bytes_per_px*8, pitch,\r
VT_Colour12toN(chars->BGCol, depth),\r
VT_Colour12toN(chars->FGCol, depth)\r
);\r
\r
if(gVesa_Modes[i].width == data->width && gVesa_Modes[i].height == data->height)\r
{\r
- if( (data->bpp == 32 || data->bpp == 24)\r
- && (gVesa_Modes[i].bpp == 32 || gVesa_Modes[i].bpp == 24) )\r
+ //if( (data->bpp == 32 || data->bpp == 24)\r
+ // && (gVesa_Modes[i].bpp == 32 || gVesa_Modes[i].bpp == 24) )\r
+ if( data->bpp == gVesa_Modes[i].bpp )\r
{\r
LOG("Perfect!");\r
best = i;\r
tmp = gVesa_Modes[i].width * gVesa_Modes[i].height;\r
tmp -= data->width * data->height;\r
tmp = tmp < 0 ? -tmp : tmp;\r
- factor = tmp * 100 / (data->width * data->height);\r
+ factor = tmp * 1000 / (data->width * data->height);\r
+ \r
+ if( data->bpp == 8 && gVesa_Modes[i].bpp != 8 ) continue;\r
+ if( data->bpp == 16 && gVesa_Modes[i].bpp != 16 ) continue;\r
\r
if( (data->bpp == 32 || data->bpp == 24)\r
&& (gVesa_Modes[i].bpp == 32 || gVesa_Modes[i].bpp == 24) )\r
{\r
- \r
+ if( data->bpp == gVesa_Modes[i].bpp )\r
+ factor /= 2;\r
}\r
else {\r
- factor *= 10;\r
+ if( data->bpp != gVesa_Modes[i].bpp )\r
+ continue ;\r
}\r
\r
LOG("factor = %i", factor);\r