git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Fixed `make install` issues, bugs with VESA
[tpg/acess2.git]
/
Modules
/
Display
/
VESA
/
main.c
diff --git
a/Modules/Display/VESA/main.c
b/Modules/Display/VESA/main.c
index
1cd6a91
..
9929c35
100644
(file)
--- a/
Modules/Display/VESA/main.c
+++ b/
Modules/Display/VESA/main.c
@@
-127,7
+127,7
@@
int Vesa_Install(char **Arguments)
{
\r
gVesa_Modes[i].flags |= FLAG_LFB;
\r
gVesa_Modes[i].framebuffer = modeinfo->physbase;
\r
- gVesa_Modes[i].fbSize = modeinfo->
Xres*modeinfo->Yres*modeinfo->bpp/8
;
\r
+ gVesa_Modes[i].fbSize = modeinfo->
Yres*modeinfo->pitch
;
\r
} else {
\r
gVesa_Modes[i].framebuffer = 0;
\r
gVesa_Modes[i].fbSize = 0;
\r
@@
-233,24
+233,35
@@
Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
case VIDEO_BUFFMT_TEXT:
\r
{
\r
tVT_Char *chars = Buffer;
\r
- int pitch = gVesa_Modes[giVesaCurrentMode].width;
\r
+ int pitch = gVesa_Modes[giVesaCurrentMode].pitch;
\r
+ int depth = gVesa_Modes[giVesaCurrentMode].bpp;
\r
int widthInChars = gVesa_Modes[giVesaCurrentMode].width/giVT_CharWidth;
\r
int heightInChars = gVesa_Modes[giVesaCurrentMode].height/giVT_CharHeight;
\r
int x, y;
\r
- Uint
32
*dest = (void*)gpVesa_Framebuffer;
\r
+ Uint
8
*dest = (void*)gpVesa_Framebuffer;
\r
int i;
\r
\r
Length /= sizeof(tVT_Char);
\r
Offset /= sizeof(tVT_Char);
\r
\r
- LOG("gVesa_Modes[%i].width = %i", giVesaCurrentMode, gVesa_Modes[giVesaCurrentMode].width);
\r
+ LOG("gVesa_Modes[%i] = {height:%i, width:%i, pitch:%i}",
\r
+ giVesaCurrentMode,
\r
+ gVesa_Modes[giVesaCurrentMode].height,
\r
+ gVesa_Modes[giVesaCurrentMode].width,
\r
+ gVesa_Modes[giVesaCurrentMode].pitch
\r
+ );
\r
x = Offset % widthInChars;
\r
y = Offset / widthInChars;
\r
- LOG("(x,y) = (%i,%i) = [%i,%i]", x, y, x * giVT_CharWidth, y * giVT_CharHeight * pitch);
\r
+ LOG("(x,y) = (%i,%i) = [%i,%i]",
\r
+ x,
\r
+ y,
\r
+ x * giVT_CharWidth * depth / 8,
\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),
\r
+ (int)((Length % widthInChars) * giVT_CharWidth
* depth / 8
),
\r
(int)((Length / widthInChars) * giVT_CharHeight * pitch)
\r
);
\r
\r
@@
-273,28
+284,42
@@
Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
}
\r
\r
dest += y * giVT_CharHeight * pitch;
\r
- dest += x * giVT_CharWidth;
\r
\r
LOG("dest = %p", dest);
\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*depth/8 + pitch*giVT_CharHeight-1)
\r
+ )
\r
+ {
\r
+ Log_Notice("VESA", "Stopped at %i, not mapped", i);
\r
+ break;
\r
+ }
\r
+ if( y >= heightInChars )
\r
+ {
\r
+ Log_Notice("VESA", "Stopped at %i", i);
\r
+ break;
\r
+ }
\r
+
\r
VT_Font_Render(
\r
chars->Ch,
\r
- dest + x*giVT_CharWidth, pitch,
\r
- VT_Colour12to
24(chars->BGCol
),
\r
- VT_Colour12to
24(chars->FGCol
)
\r
+ dest + x*giVT_CharWidth
*depth/8, depth
, pitch,
\r
+ VT_Colour12to
N(chars->BGCol, depth
),
\r
+ VT_Colour12to
N(chars->FGCol, depth
)
\r
);
\r
\r
chars ++;
\r
x ++;
\r
- if( x >= widthInChars ) {
\r
+ if( x >= widthInChars )
\r
+ {
\r
x = 0;
\r
y ++;
\r
dest += pitch*giVT_CharHeight;
\r
}
\r
}
\r
- Length
*=
sizeof(tVT_Char);
\r
+ Length
= i *
sizeof(tVT_Char);
\r
}
\r
break;
\r
\r
@@
-312,6
+337,7
@@
Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
LOG("buffer = %p", Buffer);
\r
LOG("Updating Framebuffer (%p to %p)", destBuf, destBuf + (Uint)Length);
\r
\r
+ //TODO: Handle non 32-bpp framebuffer modes
\r
\r
// Copy to Frambuffer
\r
memcpy(destBuf, Buffer, Length);
\r
@@
-411,11
+437,15
@@
int Vesa_Ioctl(tVFS_Node *Node, int ID, void *Data)
* \brief Updates the video mode
\r
*/
\r
int Vesa_Int_SetMode(int mode)
\r
-{
\r
- Log_Log("VESA", "Setting mode to %i", mode);
\r
-
\r
+{
\r
// Sanity Check values
\r
if(mode < 0 || mode > giVesaModeCount) return -1;
\r
+
\r
+ Log_Log("VESA", "Setting mode to %i (%ix%i %ibpp)",
\r
+ mode,
\r
+ gVesa_Modes[mode].width, gVesa_Modes[mode].height,
\r
+ gVesa_Modes[mode].bpp
\r
+ );
\r
\r
// Check for fast return
\r
if(mode == giVesaCurrentMode) return 1;
\r
@@
-441,8
+471,8
@@
int Vesa_Int_SetMode(int mode)
giVesaPageCount = (gVesa_Modes[mode].fbSize + 0xFFF) >> 12;
\r
gpVesa_Framebuffer = (void*)MM_MapHWPages(gVesa_Modes[mode].framebuffer, giVesaPageCount);
\r
\r
- Log_Log("VESA", "Framebuffer (Phys) = 0x%x
", gVesa_Modes[mode].framebuffer);
\r
-
Log_Log("VESA", "Framebuffer (Virt) = 0x%x", gpVesa_Framebuffer
);
\r
+ Log_Log("VESA", "Framebuffer (Phys) = 0x%x
, (Virt) = 0x%x, Size = 0x%x",
\r
+
gVesa_Modes[mode].framebuffer, gpVesa_Framebuffer, giVesaPageCount << 12
);
\r
\r
// Record Mode Set
\r
giVesaCurrentMode = mode;
\r
@@
-465,13
+495,15
@@
int Vesa_Int_FindMode(tVideo_IOCtl_Mode *data)
{
\r
LOG("Mode %i (%ix%ix%i)", i, gVesa_Modes[i].width, gVesa_Modes[i].height, gVesa_Modes[i].bpp);
\r
\r
- if(gVesa_Modes[i].width == data->width
\r
- && gVesa_Modes[i].height == data->height
\r
- && gVesa_Modes[i].bpp == data->bpp)
\r
+ if(gVesa_Modes[i].width == data->width && gVesa_Modes[i].height == data->height)
\r
{
\r
- LOG("Perfect!");
\r
- best = i;
\r
- break;
\r
+ if( (data->bpp == 32 || data->bpp == 24)
\r
+ && (gVesa_Modes[i].bpp == 32 || gVesa_Modes[i].bpp == 24) )
\r
+ {
\r
+ LOG("Perfect!");
\r
+ best = i;
\r
+ break;
\r
+ }
\r
}
\r
\r
tmp = gVesa_Modes[i].width * gVesa_Modes[i].height;
\r
@@
-519,26
+551,58
@@
int Vesa_Int_ModeInfo(tVideo_IOCtl_Mode *data)
*/
\r
void Vesa_FlipCursor(void *Arg)
\r
{
\r
- int pitch = gpVesaCurMode->pitch/4;
\r
+ int pitch = gpVesaCurMode->pitch;
\r
+ int bytes_per_px = (gpVesaCurMode->bpp + 7) / 8;
\r
int x = giVesaCursorX*giVT_CharWidth;
\r
int y = giVesaCursorY*giVT_CharHeight;
\r
int i;
\r
- Uint
32
*fb = (void*)gpVesa_Framebuffer;
\r
+ Uint
8
*fb = (void*)gpVesa_Framebuffer;
\r
\r
//Debug("Cursor flip");
\r
\r
// Sanity check
\r
if(giVesaCursorX < 0 || giVesaCursorY < 0
\r
- || y*pitch + x + (giVT_CharHeight-1)*pitch > (int)gpVesaCurMode->fbSize
/4
) {
\r
+ || y*pitch + x + (giVT_CharHeight-1)*pitch > (int)gpVesaCurMode->fbSize) {
\r
Log_Notice("VESA", "Cursor OOB (%i,%i)", x, y);
\r
giVesaCursorTimer = -1;
\r
return;
\r
}
\r
\r
// Draw cursor
\r
- fb += (y+1)*pitch + x;
\r
- for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch )
\r
- *fb = ~*fb;
\r
+ fb += (y+1)*pitch + x*bytes_per_px;
\r
+
\r
+ switch(bytes_per_px)
\r
+ {
\r
+ case 1:
\r
+ for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch )
\r
+ *fb = ~*fb;
\r
+ break;
\r
+ case 2:
\r
+ for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch ) {
\r
+ fb[0] = ~fb[0];
\r
+ fb[1] = ~fb[1];
\r
+ }
\r
+ break;
\r
+ case 3:
\r
+ for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch ) {
\r
+ fb[0] = ~fb[0];
\r
+ fb[1] = ~fb[1];
\r
+ fb[2] = ~fb[2];
\r
+ }
\r
+ break;
\r
+ case 4:
\r
+ for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch ) {
\r
+ fb[0] = ~fb[0];
\r
+ fb[1] = ~fb[1];
\r
+ fb[2] = ~fb[2];
\r
+ fb[3] = ~fb[3];
\r
+ }
\r
+ break;
\r
+ default:
\r
+ Log_Error("VESA", "Vesa_FlipCursor - Bug Report, unknown bytes_per_px (%i)", bytes_per_px);
\r
+ giVesaCursorTimer = -1;
\r
+ return ;
\r
+ }
\r
\r
#if BLINKING_CURSOR
\r
giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, Arg);
\r
@@
-550,6
+614,7
@@
void Vesa_FlipCursor(void *Arg)
// ------------------------
\r
void Vesa_2D_Fill(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour)
\r
{
\r
+ // TODO: Handle non-32bit modes
\r
int pitch = gpVesaCurMode->pitch/4;
\r
Uint32 *buf = (Uint32*)gpVesa_Framebuffer + Y*pitch + X;
\r
while( H -- ) {
\r
@@
-560,7
+625,8
@@
void Vesa_2D_Fill(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colo
\r
void Vesa_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H)
\r
{
\r
- int scrnpitch = gVesa_Modes[giVesaCurrentMode].pitch;
\r
+ int scrnpitch = gpVesaCurMode->pitch;
\r
+ int bytes_per_px = (gpVesaCurMode->bpp + 7) / 8;
\r
int dst = DstY*scrnpitch + DstX;
\r
int src = SrcY*scrnpitch + SrcX;
\r
int tmp;
\r
@@
-568,14
+634,14
@@
void Vesa_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uint16 SrcY,
//Log("Vesa_2D_Blit: (Ent=%p, DstX=%i, DstY=%i, SrcX=%i, SrcY=%i, W=%i, H=%i)",
\r
// Ent, DstX, DstY, SrcX, SrcY, W, H);
\r
\r
- if(SrcX + W > g
Vesa_Modes[giVesaCurrentMode].
width)
\r
- W = g
Vesa_Modes[giVesaCurrentMode].
width - SrcX;
\r
- if(DstX + W > g
Vesa_Modes[giVesaCurrentMode].
width)
\r
- W = g
Vesa_Modes[giVesaCurrentMode].
width - DstX;
\r
- if(SrcY + H > g
Vesa_Modes[giVesaCurrentMode].
height)
\r
- H = g
Vesa_Modes[giVesaCurrentMode].
height - SrcY;
\r
- if(DstY + H > g
Vesa_Modes[giVesaCurrentMode].
height)
\r
- H = g
Vesa_Modes[giVesaCurrentMode].
height - DstY;
\r
+ if(SrcX + W > g
pVesaCurMode->
width)
\r
+ W = g
pVesaCurMode->
width - SrcX;
\r
+ if(DstX + W > g
pVesaCurMode->
width)
\r
+ W = g
pVesaCurMode->
width - DstX;
\r
+ if(SrcY + H > g
pVesaCurMode->
height)
\r
+ H = g
pVesaCurMode->
height - SrcY;
\r
+ if(DstY + H > g
pVesaCurMode->
height)
\r
+ H = g
pVesaCurMode->
height - DstY;
\r
\r
//Debug("W = %i, H = %i", W, H);
\r
\r
@@
-586,18
+652,19
@@
void Vesa_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uint16 SrcY,
while( H -- ) {
\r
dst -= scrnpitch;
\r
src -= scrnpitch;
\r
- tmp = W;
\r
+ tmp = W
*bytes_per_px
;
\r
for( tmp = W; tmp --; ) {
\r
- *(Uint
32*)(gpVesa_Framebuffer + dst + tmp) = *(Uint32
*)(gpVesa_Framebuffer + src + tmp);
\r
+ *(Uint
8*)(gpVesa_Framebuffer + dst + tmp) = *(Uint8
*)(gpVesa_Framebuffer + src + tmp);
\r
}
\r
}
\r
}
\r
else {
\r
// Normal copy is OK
\r
while( H -- ) {
\r
- memcpy((void*)gpVesa_Framebuffer + dst, (void*)gpVesa_Framebuffer + src, W*
sizeof(Uint32)
);
\r
+ memcpy((void*)gpVesa_Framebuffer + dst, (void*)gpVesa_Framebuffer + src, W*
bytes_per_px
);
\r
dst += scrnpitch;
\r
src += scrnpitch;
\r
}
\r
}
\r
+ //Log("Vesa_2D_Blit: RETURN");
\r
}
\r
UCC
git Repository :: git.ucc.asn.au