3 * Video BIOS Extensions (Vesa) Driver
\r
6 #define VERSION 0x100
\r
10 #include <tpl_drv_video.h>
\r
11 #include <fs_devfs.h>
\r
12 #include <modules.h>
\r
16 // === CONSTANTS ===
\r
17 #define FLAG_LFB 0x1
\r
18 #define VESA_DEFAULT_FRAMEBUFFER (KERNEL_BASE|0xA0000)
\r
19 #define BLINKING_CURSOR 1
\r
21 # define VESA_CURSOR_PERIOD 1000
\r
24 // === PROTOTYPES ===
\r
25 int Vesa_Install(char **Arguments);
\r
26 Uint64 Vesa_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
\r
27 Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
\r
28 int Vesa_Ioctl(tVFS_Node *Node, int ID, void *Data);
\r
29 int Vesa_Int_SetMode(int Mode);
\r
30 int Vesa_Int_FindMode(tVideo_IOCtl_Mode *data);
\r
31 int Vesa_Int_ModeInfo(tVideo_IOCtl_Mode *data);
\r
32 void Vesa_FlipCursor(void *Arg);
\r
33 // --- 2D Acceleration Functions --
\r
34 void Vesa_2D_Fill(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour);
\r
35 void Vesa_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H);
\r
38 MODULE_DEFINE(0, VERSION, Vesa, Vesa_Install, NULL, "PCI", "VM8086", NULL);
\r
39 tDevFS_Driver gVesa_DriverStruct = {
\r
43 .Write = Vesa_Write,
\r
48 tVM8086 *gpVesa_BiosState;
\r
49 int giVesaDriverId = -1;
\r
50 // --- Video Modes ---
\r
51 int giVesaCurrentMode = 0;
\r
52 int giVesaCurrentFormat = VIDEO_BUFFMT_TEXT;
\r
53 tVesa_Mode *gVesa_Modes;
\r
54 tVesa_Mode *gpVesaCurMode;
\r
55 int giVesaModeCount = 0;
\r
56 // --- Framebuffer ---
\r
57 char *gpVesa_Framebuffer = (void*)VESA_DEFAULT_FRAMEBUFFER;
\r
58 int giVesaPageCount = 0; //!< Framebuffer size in pages
\r
59 // --- Cursor Control ---
\r
60 int giVesaCursorX = -1;
\r
61 int giVesaCursorY = -1;
\r
62 int giVesaCursorTimer = -1; // Invalid timer
\r
63 // --- 2D Video Stream Handlers ---
\r
64 tDrvUtil_Video_2DHandlers gVesa_2DFunctions = {
\r
71 int Vesa_Install(char **Arguments)
\r
73 tVesa_CallInfo *info;
\r
75 tVesa_CallModeInfo *modeinfo;
\r
76 tFarPtr modeinfoPtr;
\r
80 // Allocate Info Block
\r
81 gpVesa_BiosState = VM8086_Init();
\r
82 info = VM8086_Allocate(gpVesa_BiosState, 512, &infoPtr.seg, &infoPtr.ofs);
\r
83 modeinfo = VM8086_Allocate(gpVesa_BiosState, 512, &modeinfoPtr.seg, &modeinfoPtr.ofs);
\r
84 // Set Requested Version
\r
85 memcpy(info->signature, "VBE2", 4);
\r
87 gpVesa_BiosState->AX = 0x4F00;
\r
88 gpVesa_BiosState->ES = infoPtr.seg; gpVesa_BiosState->DI = infoPtr.ofs;
\r
90 VM8086_Int(gpVesa_BiosState, 0x10);
\r
91 if(gpVesa_BiosState->AX != 0x004F) {
\r
92 Log_Warning("VESA", "Vesa_Install - VESA/VBE Unsupported (AX = 0x%x)", gpVesa_BiosState->AX);
\r
93 return MODULE_ERR_NOTNEEDED;
\r
96 //Log_Debug("VESA", "info->VideoModes = %04x:%04x", info->VideoModes.seg, info->VideoModes.ofs);
\r
97 modes = (Uint16 *) VM8086_GetPointer(gpVesa_BiosState, info->VideoModes.seg, info->VideoModes.ofs);
\r
100 for( giVesaModeCount = 0; modes[giVesaModeCount] != 0xFFFF; giVesaModeCount++ );
\r
101 gVesa_Modes = (tVesa_Mode *)malloc( giVesaModeCount * sizeof(tVesa_Mode) );
\r
103 Log_Debug("VESA", "%i Modes", giVesaModeCount);
\r
105 // Insert Text Mode
\r
106 gVesa_Modes[0].width = 80;
\r
107 gVesa_Modes[0].height = 25;
\r
108 gVesa_Modes[0].bpp = 12;
\r
109 gVesa_Modes[0].code = 0x3;
\r
110 gVesa_Modes[0].flags = 1;
\r
111 gVesa_Modes[0].fbSize = 80*25*2;
\r
112 gVesa_Modes[0].framebuffer = 0xB8000;
\r
114 for( i = 1; i < giVesaModeCount; i++ )
\r
116 gVesa_Modes[i].code = modes[i];
\r
118 gpVesa_BiosState->AX = 0x4F01;
\r
119 gpVesa_BiosState->CX = gVesa_Modes[i].code;
\r
120 gpVesa_BiosState->ES = modeinfoPtr.seg;
\r
121 gpVesa_BiosState->DI = modeinfoPtr.ofs;
\r
122 VM8086_Int(gpVesa_BiosState, 0x10);
\r
125 gVesa_Modes[i].flags = 0;
\r
126 if ( (modeinfo->attributes & 0x90) == 0x90 )
\r
128 gVesa_Modes[i].flags |= FLAG_LFB;
\r
129 gVesa_Modes[i].framebuffer = modeinfo->physbase;
\r
130 gVesa_Modes[i].fbSize = modeinfo->Yres*modeinfo->pitch;
\r
132 gVesa_Modes[i].framebuffer = 0;
\r
133 gVesa_Modes[i].fbSize = 0;
\r
136 gVesa_Modes[i].pitch = modeinfo->pitch;
\r
137 gVesa_Modes[i].width = modeinfo->Xres;
\r
138 gVesa_Modes[i].height = modeinfo->Yres;
\r
139 gVesa_Modes[i].bpp = modeinfo->bpp;
\r
142 Log_Log("VESA", "0x%x - %ix%ix%i",
\r
143 gVesa_Modes[i].code, gVesa_Modes[i].width, gVesa_Modes[i].height, gVesa_Modes[i].bpp);
\r
149 giVesaDriverId = DevFS_AddDevice( &gVesa_DriverStruct );
\r
150 if(giVesaDriverId == -1) return MODULE_ERR_MISC;
\r
152 return MODULE_ERR_OK;
\r
155 /* Read from the framebuffer
\r
157 Uint64 Vesa_Read(tVFS_Node *Node, Uint64 off, Uint64 len, void *buffer)
\r
160 Log("Vesa_Read: () - NULL\n");
\r
166 * \brief Write to the framebuffer
\r
168 Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
\r
170 ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
\r
172 if(Buffer == NULL) {
\r
177 // Default Text mode
\r
178 if( giVesaCurrentMode == 0 )
\r
180 Uint16 *fb = (Uint16*)(KERNEL_BASE|0xB8000);
\r
181 tVT_Char *chars = Buffer;
\r
184 Length /= sizeof(tVT_Char);
\r
185 Offset /= sizeof(tVT_Char);
\r
187 if( giVesaCurrentFormat != VIDEO_BUFFMT_TEXT ) {
\r
188 Log_Warning("VESA", "Vesa_Write - Mode 0 is not framebuffer");
\r
193 if( Offset + Length > 25*80 ) {
\r
194 Log_Warning("VESA", "Vesa_Write - Framebuffer Overflow");
\r
200 LOG("fb = %p", fb);
\r
201 for(rem = Length; rem --; fb ++, chars++)
\r
203 if( chars->Ch < 0x80 )
\r
204 *fb = chars->Ch & 0x7F;
\r
208 *fb |= (chars->FGCol & 0x888) == 0x888 ? 0x8 : 0;
\r
209 *fb |= (chars->FGCol & 0x700) > 0x300 ? 0x4 : 0;
\r
210 *fb |= (chars->FGCol & 0x070) > 0x030 ? 0x2 : 0;
\r
211 *fb |= (chars->FGCol & 0x007) > 0x003 ? 0x1 : 0;
\r
212 *fb |= (chars->BGCol & 0x888) == 0x888 ? 0x80 : 0;
\r
213 *fb |= (chars->BGCol & 0x700) > 0x300 ? 0x40 : 0;
\r
214 *fb |= (chars->BGCol & 0x070) > 0x030 ? 0x20 : 0;
\r
215 *fb |= (chars->BGCol & 0x007) > 0x003 ? 0x10 : 0;
\r
216 //LOG("%08x (%03x,%03x) = %04x",
\r
217 // chars->Ch, chars->BGCol, chars->FGCol, *fb);
\r
219 Length *= sizeof(tVT_Char);
\r
220 LEAVE('X', Length);
\r
224 if( gVesa_Modes[giVesaCurrentMode].framebuffer == 0 ) {
\r
225 Log_Warning("VESA", "Vesa_Write - Non-LFB Modes not yet supported.");
\r
231 switch( giVesaCurrentFormat )
\r
233 case VIDEO_BUFFMT_TEXT:
\r
235 tVT_Char *chars = Buffer;
\r
236 int pitch = gVesa_Modes[giVesaCurrentMode].pitch;
\r
237 int depth = gVesa_Modes[giVesaCurrentMode].bpp;
\r
238 int bytes_per_px = gVesa_Modes[giVesaCurrentMode].bpp / 8;
\r
239 int widthInChars = gVesa_Modes[giVesaCurrentMode].width/giVT_CharWidth;
\r
240 int heightInChars = gVesa_Modes[giVesaCurrentMode].height/giVT_CharHeight;
\r
242 Uint8 *dest = (void*)gpVesa_Framebuffer;
\r
245 Length /= sizeof(tVT_Char);
\r
246 Offset /= sizeof(tVT_Char);
\r
248 if( depth == 32 ) depth = 24; // Actually 24-colour bits
\r
250 LOG("gVesa_Modes[%i] = {height:%i, width:%i, pitch:%i}",
\r
252 gVesa_Modes[giVesaCurrentMode].height,
\r
253 gVesa_Modes[giVesaCurrentMode].width,
\r
254 gVesa_Modes[giVesaCurrentMode].pitch
\r
256 x = Offset % widthInChars;
\r
257 y = Offset / widthInChars;
\r
258 LOG("(x,y) = (%i,%i) = [%i,%i]",
\r
261 x * giVT_CharWidth * bytes_per_px,
\r
262 y * giVT_CharHeight * pitch
\r
264 LOG("(w,h) = (%i,%i) = [%i,%i]",
\r
265 (int)(Length % widthInChars),
\r
266 (int)(Length / widthInChars),
\r
267 (int)((Length % widthInChars) * giVT_CharWidth * bytes_per_px),
\r
268 (int)((Length / widthInChars) * giVT_CharHeight * pitch)
\r
272 if( Offset > (Uint64)(heightInChars*widthInChars) ) {
\r
276 if(y >= heightInChars) {
\r
282 if( (int)Offset + (int)Length > heightInChars*widthInChars ) {
\r
283 Log_Debug("VESA", "%i + %i > %i*%i (%i)",
\r
284 (int)Offset, (int)Length, heightInChars, widthInChars, heightInChars*widthInChars);
\r
285 Length = heightInChars*widthInChars - Offset;
\r
286 Log_Notice("VESA", "Clipping write size to %i characters", (int)Length);
\r
289 dest += y * giVT_CharHeight * pitch;
\r
291 LOG("dest = %p", dest);
\r
293 for( i = 0; i < (int)Length; i++ )
\r
296 !MM_GetPhysAddr( (tVAddr)dest + x*giVT_CharWidth*bytes_per_px )
\r
297 // || !MM_GetPhysAddr( (tVAddr)dest + x*giVT_CharWidth*depth/8 + pitch*giVT_CharHeight-1)
\r
300 Log_Notice("VESA", "Stopped at %i, not mapped", i);
\r
303 if( y >= heightInChars )
\r
305 Log_Notice("VESA", "Stopped at %i", i);
\r
311 dest + x*giVT_CharWidth*bytes_per_px, bytes_per_px*8, pitch,
\r
312 VT_Colour12toN(chars->BGCol, depth),
\r
313 VT_Colour12toN(chars->FGCol, depth)
\r
318 if( x >= widthInChars )
\r
322 dest += pitch*giVT_CharHeight;
\r
325 Length = i * sizeof(tVT_Char);
\r
329 case VIDEO_BUFFMT_FRAMEBUFFER:
\r
331 Uint8 *destBuf = (Uint8*) ((Uint)gpVesa_Framebuffer + (Uint)Offset);
\r
333 if(gVesa_Modes[giVesaCurrentMode].fbSize < Offset+Length)
\r
335 Log_Warning("VESA", "Vesa_Write - Framebuffer Overflow");
\r
340 LOG("buffer = %p", Buffer);
\r
341 LOG("Updating Framebuffer (%p to %p)", destBuf, destBuf + (Uint)Length);
\r
343 //TODO: Handle non 32-bpp framebuffer modes
\r
345 // Copy to Frambuffer
\r
346 memcpy(destBuf, Buffer, Length);
\r
348 LOG("BGA Framebuffer updated");
\r
352 case VIDEO_BUFFMT_2DSTREAM:
\r
353 Length = DrvUtil_Video_2DStream(
\r
354 NULL, // Single framebuffer, so Ent is unused
\r
355 Buffer, Length, &gVesa_2DFunctions, sizeof(gVesa_2DFunctions)
\r
364 LEAVE('X', Length);
\r
369 * \fn int Vesa_Ioctl(vfs_node *node, int id, void *data)
\r
370 * \brief Handle messages to the device
\r
372 int Vesa_Ioctl(tVFS_Node *Node, int ID, void *Data)
\r
375 //Log_Debug("VESA", "Vesa_Ioctl: (Node=%p, ID=%i, Data=%p)", Node, ID, Data);
\r
378 case DRV_IOCTL_TYPE: return DRV_TYPE_VIDEO;
\r
379 case DRV_IOCTL_IDENT: memcpy("VESA", Data, 4); return 1;
\r
380 case DRV_IOCTL_VERSION: return VERSION;
\r
382 case VIDEO_IOCTL_GETSETMODE:
\r
383 if( !Data ) return giVesaCurrentMode;
\r
384 return Vesa_Int_SetMode( *(int*)Data );
\r
386 case VIDEO_IOCTL_FINDMODE:
\r
387 return Vesa_Int_FindMode((tVideo_IOCtl_Mode*)Data);
\r
388 case VIDEO_IOCTL_MODEINFO:
\r
389 return Vesa_Int_ModeInfo((tVideo_IOCtl_Mode*)Data);
\r
391 case VIDEO_IOCTL_SETBUFFORMAT:
\r
392 ret = giVesaCurrentFormat;
\r
394 //Log_Log("VESA", "Buffer mode to %i", *(int*)Data);
\r
395 giVesaCurrentFormat = *(int*)Data;
\r
399 case VIDEO_IOCTL_SETCURSOR: // Set cursor position
\r
400 #if !BLINKING_CURSOR
\r
401 if(giVesaCursorX > 0)
\r
402 Vesa_FlipCursor(Node);
\r
404 giVesaCursorX = ((tVideo_IOCtl_Pos*)Data)->x;
\r
405 giVesaCursorY = ((tVideo_IOCtl_Pos*)Data)->y;
\r
406 //Log_Debug("VESA", "Cursor position (%i,%i)", giVesaCursorX, giVesaCursorY);
\r
408 giVesaCursorX < 0 || giVesaCursorY < 0
\r
409 || giVesaCursorX >= gpVesaCurMode->width/giVT_CharWidth
\r
410 || giVesaCursorY >= gpVesaCurMode->height/giVT_CharHeight)
\r
412 #if BLINKING_CURSOR
\r
413 if(giVesaCursorTimer != -1) {
\r
414 Time_RemoveTimer(giVesaCursorTimer);
\r
415 giVesaCursorTimer = -1;
\r
418 giVesaCursorX = -1;
\r
419 giVesaCursorY = -1;
\r
422 #if BLINKING_CURSOR
\r
423 // Log_Debug("VESA", "Updating timer %i?", giVesaCursorTimer);
\r
424 if(giVesaCursorTimer == -1)
\r
425 giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, Node);
\r
427 Vesa_FlipCursor(Node);
\r
430 //Log_Debug("VESA", "Cursor position (%i,%i) Timer %i", giVesaCursorX, giVesaCursorY, giVesaCursorTimer);
\r
433 case VIDEO_IOCTL_REQLFB: // Request Linear Framebuffer
\r
440 * \brief Updates the video mode
\r
442 int Vesa_Int_SetMode(int mode)
\r
444 // Sanity Check values
\r
445 if(mode < 0 || mode > giVesaModeCount) return -1;
\r
447 Log_Log("VESA", "Setting mode to %i (%ix%i %ibpp)",
\r
449 gVesa_Modes[mode].width, gVesa_Modes[mode].height,
\r
450 gVesa_Modes[mode].bpp
\r
453 // Check for fast return
\r
454 if(mode == giVesaCurrentMode) return 1;
\r
456 Time_RemoveTimer(giVesaCursorTimer);
\r
457 giVesaCursorTimer = -1;
\r
459 Mutex_Acquire( &glVesa_Lock );
\r
461 gpVesa_BiosState->AX = 0x4F02;
\r
462 gpVesa_BiosState->BX = gVesa_Modes[mode].code;
\r
463 if(gVesa_Modes[mode].flags & FLAG_LFB) {
\r
464 Log_Log("VESA", "Using LFB");
\r
465 gpVesa_BiosState->BX |= 0x4000; // Bit 14 - Use LFB
\r
469 VM8086_Int(gpVesa_BiosState, 0x10);
\r
472 if( (tVAddr)gpVesa_Framebuffer != VESA_DEFAULT_FRAMEBUFFER )
\r
473 MM_UnmapHWPages((tVAddr)gpVesa_Framebuffer, giVesaPageCount);
\r
474 giVesaPageCount = (gVesa_Modes[mode].fbSize + 0xFFF) >> 12;
\r
475 gpVesa_Framebuffer = (void*)MM_MapHWPages(gVesa_Modes[mode].framebuffer, giVesaPageCount);
\r
477 Log_Log("VESA", "Framebuffer (Phys) = 0x%x, (Virt) = 0x%x, Size = 0x%x",
\r
478 gVesa_Modes[mode].framebuffer, gpVesa_Framebuffer, giVesaPageCount << 12);
\r
481 giVesaCurrentMode = mode;
\r
482 gpVesaCurMode = &gVesa_Modes[giVesaCurrentMode];
\r
484 Mutex_Release( &glVesa_Lock );
\r
489 int Vesa_Int_FindMode(tVideo_IOCtl_Mode *data)
\r
492 int best = -1, bestFactor = 1000;
\r
495 ENTER("idata->width idata->height idata->bpp", data->width, data->height, data->bpp);
\r
497 for(i=0;i<giVesaModeCount;i++)
\r
499 LOG("Mode %i (%ix%ix%i)", i, gVesa_Modes[i].width, gVesa_Modes[i].height, gVesa_Modes[i].bpp);
\r
501 if(gVesa_Modes[i].width == data->width && gVesa_Modes[i].height == data->height)
\r
503 //if( (data->bpp == 32 || data->bpp == 24)
\r
504 // && (gVesa_Modes[i].bpp == 32 || gVesa_Modes[i].bpp == 24) )
\r
505 if( data->bpp == gVesa_Modes[i].bpp )
\r
513 tmp = gVesa_Modes[i].width * gVesa_Modes[i].height;
\r
514 tmp -= data->width * data->height;
\r
515 tmp = tmp < 0 ? -tmp : tmp;
\r
516 factor = tmp * 1000 / (data->width * data->height);
\r
518 if( data->bpp == 8 && gVesa_Modes[i].bpp != 8 ) continue;
\r
519 if( data->bpp == 16 && gVesa_Modes[i].bpp != 16 ) continue;
\r
521 if( (data->bpp == 32 || data->bpp == 24)
\r
522 && (gVesa_Modes[i].bpp == 32 || gVesa_Modes[i].bpp == 24) )
\r
524 if( data->bpp == gVesa_Modes[i].bpp )
\r
528 if( data->bpp != gVesa_Modes[i].bpp )
\r
532 LOG("factor = %i", factor);
\r
534 if(factor < bestFactor)
\r
536 bestFactor = factor;
\r
541 data->width = gVesa_Modes[best].width;
\r
542 data->height = gVesa_Modes[best].height;
\r
543 data->bpp = gVesa_Modes[best].bpp;
\r
548 int Vesa_Int_ModeInfo(tVideo_IOCtl_Mode *data)
\r
550 if(data->id < 0 || data->id > giVesaModeCount) return -1;
\r
551 data->width = gVesa_Modes[data->id].width;
\r
552 data->height = gVesa_Modes[data->id].height;
\r
553 data->bpp = gVesa_Modes[data->id].bpp;
\r
558 * \brief Updates the state of the text cursor
\r
559 * \note Just does a bitwise not on the cursor region
\r
561 void Vesa_FlipCursor(void *Arg)
\r
563 int pitch = gpVesaCurMode->pitch;
\r
564 int bytes_per_px = (gpVesaCurMode->bpp + 7) / 8;
\r
565 int x = giVesaCursorX*giVT_CharWidth;
\r
566 int y = giVesaCursorY*giVT_CharHeight;
\r
568 Uint8 *fb = (void*)gpVesa_Framebuffer;
\r
570 //Debug("Cursor flip");
\r
573 if(giVesaCursorX < 0 || giVesaCursorY < 0
\r
574 || y*pitch + x + (giVT_CharHeight-1)*pitch > (int)gpVesaCurMode->fbSize) {
\r
575 Log_Notice("VESA", "Cursor OOB (%i,%i)", x, y);
\r
576 giVesaCursorTimer = -1;
\r
581 fb += (y+1)*pitch + x*bytes_per_px;
\r
583 switch(bytes_per_px)
\r
586 for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch )
\r
590 for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch ) {
\r
596 for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch ) {
\r
603 for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch ) {
\r
611 Log_Error("VESA", "Vesa_FlipCursor - Bug Report, unknown bytes_per_px (%i)", bytes_per_px);
\r
612 giVesaCursorTimer = -1;
\r
616 #if BLINKING_CURSOR
\r
617 giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, Arg);
\r
621 // ------------------------
\r
622 // --- 2D Accelleration ---
\r
623 // ------------------------
\r
624 void Vesa_2D_Fill(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour)
\r
626 // TODO: Handle non-32bit modes
\r
627 int pitch = gpVesaCurMode->pitch/4;
\r
628 Uint32 *buf = (Uint32*)gpVesa_Framebuffer + Y*pitch + X;
\r
630 memsetd(buf, Colour, W);
\r
635 void Vesa_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H)
\r
637 int scrnpitch = gpVesaCurMode->pitch;
\r
638 int bytes_per_px = (gpVesaCurMode->bpp + 7) / 8;
\r
639 int dst = DstY*scrnpitch + DstX;
\r
640 int src = SrcY*scrnpitch + SrcX;
\r
643 //Log("Vesa_2D_Blit: (Ent=%p, DstX=%i, DstY=%i, SrcX=%i, SrcY=%i, W=%i, H=%i)",
\r
644 // Ent, DstX, DstY, SrcX, SrcY, W, H);
\r
646 if(SrcX + W > gpVesaCurMode->width)
\r
647 W = gpVesaCurMode->width - SrcX;
\r
648 if(DstX + W > gpVesaCurMode->width)
\r
649 W = gpVesaCurMode->width - DstX;
\r
650 if(SrcY + H > gpVesaCurMode->height)
\r
651 H = gpVesaCurMode->height - SrcY;
\r
652 if(DstY + H > gpVesaCurMode->height)
\r
653 H = gpVesaCurMode->height - DstY;
\r
655 //Debug("W = %i, H = %i", W, H);
\r
659 dst += H*scrnpitch;
\r
660 src += H*scrnpitch;
\r
664 tmp = W*bytes_per_px;
\r
665 for( tmp = W; tmp --; ) {
\r
666 *(Uint8*)(gpVesa_Framebuffer + dst + tmp) = *(Uint8*)(gpVesa_Framebuffer + src + tmp);
\r
671 // Normal copy is OK
\r
673 memcpy((void*)gpVesa_Framebuffer + dst, (void*)gpVesa_Framebuffer + src, W*bytes_per_px);
\r
678 //Log("Vesa_2D_Blit: RETURN");
\r