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
AcessNative - Fixing crashes
[tpg/acess2.git]
/
KernelLand
/
Kernel
/
drvutil.c
diff --git
a/KernelLand/Kernel/drvutil.c
b/KernelLand/Kernel/drvutil.c
index
d19a050
..
df4fac9
100644
(file)
--- a/
KernelLand/Kernel/drvutil.c
+++ b/
KernelLand/Kernel/drvutil.c
@@
-59,6
+59,9
@@
int DrvUtil_Video_2DStream(void *Ent, const void *Buffer, int Length,
const Uint8 *stream = Buffer;
int rem = Length;
int op;
const Uint8 *stream = Buffer;
int rem = Length;
int op;
+
+ Uint16 tmp[6];
+
while( rem )
{
rem --;
while( rem )
{
rem --;
@@
-84,7
+87,8
@@
int DrvUtil_Video_2DStream(void *Ent, const void *Buffer, int Length,
case VIDEO_2DOP_NOP: break;
case VIDEO_2DOP_FILL:
case VIDEO_2DOP_NOP: break;
case VIDEO_2DOP_FILL:
- if(rem < 10) return Length-rem;
+ if(rem < 12) return Length-rem;
+ memcpy(tmp, stream, 6*2);
if(!Handlers->Fill) {
Log_Warning("DrvUtil", "DrvUtil_Video_2DStream: Driver"
if(!Handlers->Fill) {
Log_Warning("DrvUtil", "DrvUtil_Video_2DStream: Driver"
@@
-93,10
+97,9
@@
int DrvUtil_Video_2DStream(void *Ent, const void *Buffer, int Length,
}
Handlers->Fill(
}
Handlers->Fill(
- Ent,
- ((const Uint16*)stream)[0], ((const Uint16*)stream)[1],
- ((const Uint16*)stream)[2], ((const Uint16*)stream)[3],
- ((const Uint32*)stream)[4]
+ Ent,
+ tmp[0], tmp[1], tmp[2], tmp[3],
+ tmp[4] | ((Uint32)tmp[5] << 16)
);
rem -= 10;
);
rem -= 10;
@@
-114,9
+117,8
@@
int DrvUtil_Video_2DStream(void *Ent, const void *Buffer, int Length,
Handlers->Blit(
Ent,
Handlers->Blit(
Ent,
- ((const Uint16*)stream)[0], ((const Uint16*)stream)[1],
- ((const Uint16*)stream)[2], ((const Uint16*)stream)[3],
- ((const Uint16*)stream)[4], ((const Uint16*)stream)[5]
+ tmp[0], tmp[1], tmp[2], tmp[3],
+ tmp[4], tmp[5]
);
rem -= 12;
);
rem -= 12;
@@
-136,7
+138,7
@@
int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t
int x, y;
int bytes_per_px = (FBInfo->Depth + 7) / 8;
ENTER("pFBInfo xOffset xLength pBuffer",
int x, y;
int bytes_per_px = (FBInfo->Depth + 7) / 8;
ENTER("pFBInfo xOffset xLength pBuffer",
-
Mode,
FBInfo, Offset, Length, Buffer);
+ FBInfo, Offset, Length, Buffer);
csr_x = FBInfo->CursorX;
csr_y = FBInfo->CursorY;
csr_x = FBInfo->CursorX;
csr_y = FBInfo->CursorY;
@@
-287,9
+289,12
@@
int DrvUtil_Video_SetCursor(tDrvUtil_Video_BufInfo *Buf, tVideo_IOCtl_Bitmap *Bi
int csrX = Buf->CursorX, csrY = Buf->CursorY;
size_t size;
int csrX = Buf->CursorX, csrY = Buf->CursorY;
size_t size;
+ ENTER("pBuf pBitmap", Buf, Bitmap);
+
// Clear old bitmap
if( Buf->CursorBitmap )
{
// Clear old bitmap
if( Buf->CursorBitmap )
{
+ LOG("Clearing old cursor");
DrvUtil_Video_RemoveCursor(Buf);
if( !Bitmap || Bitmap->W != Buf->CursorBitmap->W || Bitmap->H != Buf->CursorBitmap->H )
{
DrvUtil_Video_RemoveCursor(Buf);
if( !Bitmap || Bitmap->W != Buf->CursorBitmap->W || Bitmap->H != Buf->CursorBitmap->H )
{
@@
-306,24
+311,29
@@
int DrvUtil_Video_SetCursor(tDrvUtil_Video_BufInfo *Buf, tVideo_IOCtl_Bitmap *Bi
{
Buf->CursorX = -1;
Buf->CursorY = -1;
{
Buf->CursorX = -1;
Buf->CursorY = -1;
+ LEAVE('i', 0);
return 0;
}
// Sanity check the bitmap
return 0;
}
// Sanity check the bitmap
+ LOG("Sanity checking plox");
if( !CheckMem(Bitmap, sizeof(*Bitmap)) || !CheckMem(Bitmap->Data, Bitmap->W*Bitmap->H*sizeof(Uint32)) )
{
Log_Warning("DrvUtil", "DrvUtil_Video_SetCursor: Bitmap (%p) is in invalid memory", Bitmap);
errno = -EINVAL;
if( !CheckMem(Bitmap, sizeof(*Bitmap)) || !CheckMem(Bitmap->Data, Bitmap->W*Bitmap->H*sizeof(Uint32)) )
{
Log_Warning("DrvUtil", "DrvUtil_Video_SetCursor: Bitmap (%p) is in invalid memory", Bitmap);
errno = -EINVAL;
+ LEAVE('i', -1);
return -1;
}
// Don't take a copy of the DrvUtil provided cursor
if( Bitmap == &gDrvUtil_TextModeCursor )
{
return -1;
}
// Don't take a copy of the DrvUtil provided cursor
if( Bitmap == &gDrvUtil_TextModeCursor )
{
+ LOG("No copy (provided cursor)");
Buf->CursorBitmap = Bitmap;
}
else
{
Buf->CursorBitmap = Bitmap;
}
else
{
+ LOG("Make copy");
size = sizeof(tVideo_IOCtl_Bitmap) + Bitmap->W*Bitmap->H*4;
// Take a copy
size = sizeof(tVideo_IOCtl_Bitmap) + Bitmap->W*Bitmap->H*4;
// Take a copy
@@
-332,7
+342,9
@@
int DrvUtil_Video_SetCursor(tDrvUtil_Video_BufInfo *Buf, tVideo_IOCtl_Bitmap *Bi
}
// Restore cursor position
}
// Restore cursor position
+ LOG("Drawing");
DrvUtil_Video_DrawCursor(Buf, csrX, csrY);
DrvUtil_Video_DrawCursor(Buf, csrX, csrY);
+ LEAVE('i', 0);
return 0;
}
return 0;
}
@@
-340,24
+352,30
@@
void DrvUtil_Video_DrawCursor(tDrvUtil_Video_BufInfo *Buf, int X, int Y)
{
int render_ox=0, render_oy=0, render_w, render_h;
{
int render_ox=0, render_oy=0, render_w, render_h;
+ ENTER("pBuf iX iY", Buf, X, Y);
DrvUtil_Video_RemoveCursor(Buf);
// X < 0 disables the cursor
if( X < 0 ) {
Buf->CursorX = -1;
DrvUtil_Video_RemoveCursor(Buf);
// X < 0 disables the cursor
if( X < 0 ) {
Buf->CursorX = -1;
+ LEAVE('-');
return ;
}
// Sanity checking
return ;
}
// Sanity checking
- if( X < 0 || Y < 0 ) return;
- if( X >= Buf->Width || Y >= Buf->Height ) return;
+ if( X < 0 || Y < 0 || X >= Buf->Width || Y >= Buf->Height ) {
+ LEAVE('-');
+ return ;
+ }
// Ensure the cursor is enabled
// Ensure the cursor is enabled
- if( !Buf->CursorBitmap ) return ;
+ if( !Buf->CursorBitmap ) {
+ LEAVE('-');
+ return ;
+ }
// Save cursor position (for changing the bitmap)
Buf->CursorX = X; Buf->CursorY = Y;
// Save cursor position (for changing the bitmap)
Buf->CursorX = X; Buf->CursorY = Y;
-
// Apply cursor's center offset
X -= Buf->CursorBitmap->XOfs;
Y -= Buf->CursorBitmap->YOfs;
// Apply cursor's center offset
X -= Buf->CursorBitmap->XOfs;
Y -= Buf->CursorBitmap->YOfs;
@@
-375,8
+393,12
@@
void DrvUtil_Video_DrawCursor(tDrvUtil_Video_BufInfo *Buf, int X, int Y)
Buf->CursorDestX = X; Buf->CursorDestY = Y;
Buf->CursorReadX = render_ox; Buf->CursorReadY = render_oy;
Buf->CursorDestX = X; Buf->CursorDestY = Y;
Buf->CursorReadX = render_ox; Buf->CursorReadY = render_oy;
+ LOG("%ix%i at %i,%i offset %i,%i",
+ render_w, render_h, X, Y, render_ox, render_oy);
+
// Call render routine
DrvUtil_Video_RenderCursor(Buf);
// Call render routine
DrvUtil_Video_RenderCursor(Buf);
+ LEAVE('-');
}
void DrvUtil_Video_RenderCursor(tDrvUtil_Video_BufInfo *Buf)
}
void DrvUtil_Video_RenderCursor(tDrvUtil_Video_BufInfo *Buf)
@@
-393,10
+415,13
@@
void DrvUtil_Video_RenderCursor(tDrvUtil_Video_BufInfo *Buf)
dest = (Uint8*)Buf->Framebuffer + dest_y*Buf->Pitch + dest_x*bytes_per_px;
src = Buf->CursorBitmap->Data + src_y * Buf->CursorBitmap->W + src_x;
dest = (Uint8*)Buf->Framebuffer + dest_y*Buf->Pitch + dest_x*bytes_per_px;
src = Buf->CursorBitmap->Data + src_y * Buf->CursorBitmap->W + src_x;
+ LOG("dest = %p, src = %p", dest, src);
+
// Allocate save buffer if not already
if( !Buf->CursorSaveBuf )
Buf->CursorSaveBuf = malloc( Buf->CursorBitmap->W*Buf->CursorBitmap->H*bytes_per_px );
// Allocate save buffer if not already
if( !Buf->CursorSaveBuf )
Buf->CursorSaveBuf = malloc( Buf->CursorBitmap->W*Buf->CursorBitmap->H*bytes_per_px );
+ LOG("Saving back");
// Save behind the cursor
for( y = 0; y < render_h; y ++ )
memcpy(
// Save behind the cursor
for( y = 0; y < render_h; y ++ )
memcpy(
@@
-413,6
+438,7
@@
void DrvUtil_Video_RenderCursor(tDrvUtil_Video_BufInfo *Buf)
Log_Warning("DrvUtil", "TODO: Support 15/16 bpp modes in cursor draw");
break;
case 24:
Log_Warning("DrvUtil", "TODO: Support 15/16 bpp modes in cursor draw");
break;
case 24:
+ LOG("24-bit render");
for( y = 0; y < render_h; y ++ )
{
Uint8 *px;
for( y = 0; y < render_h; y ++ )
{
Uint8 *px;
@@
-435,6
+461,7
@@
void DrvUtil_Video_RenderCursor(tDrvUtil_Video_BufInfo *Buf)
}
break;
case 32:
}
break;
case 32:
+ LOG("32-bit render");
for( y = 0; y < render_h; y ++ )
{
Uint32 *px;
for( y = 0; y < render_h; y ++ )
{
Uint32 *px;
@@
-448,6
+475,7
@@
void DrvUtil_Video_RenderCursor(tDrvUtil_Video_BufInfo *Buf)
else
; // NOP, completely transparent
}
else
; // NOP, completely transparent
}
+ LOG("row %i/%i (%p-%P) done", y+1, render_h, dest, MM_GetPhysAddr(dest));
src += Buf->CursorBitmap->W;
dest = (Uint8*)dest + Buf->Pitch;
}
src += Buf->CursorBitmap->W;
dest = (Uint8*)dest + Buf->Pitch;
}
@@
-556,7
+584,7
@@
void DrvUtil_Video_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uin
// --- Disk Driver Helpers ---
Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer,
// --- Disk Driver Helpers ---
Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer,
- tDrvUtil_Read_Callback ReadBlocks, Uint64 BlockSize,
Uint
Argument)
+ tDrvUtil_Read_Callback ReadBlocks, Uint64 BlockSize,
void *
Argument)
{
Uint8 tmp[BlockSize]; // C99
Uint64 block = Start / BlockSize;
{
Uint8 tmp[BlockSize]; // C99
Uint64 block = Start / BlockSize;
@@
-566,7
+594,7
@@
Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer,
int tailings;
Uint64 ret;
int tailings;
Uint64 ret;
- ENTER("XStart XLength pBuffer pReadBlocks XBlockSize
x
Argument",
+ ENTER("XStart XLength pBuffer pReadBlocks XBlockSize
p
Argument",
Start, Length, Buffer, ReadBlocks, BlockSize, Argument);
// Non aligned start, let's fix that!
Start, Length, Buffer, ReadBlocks, BlockSize, Argument);
// Non aligned start, let's fix that!
@@
-627,7
+655,7
@@
Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer,
Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, const void *Buffer,
tDrvUtil_Read_Callback ReadBlocks, tDrvUtil_Write_Callback WriteBlocks,
Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, const void *Buffer,
tDrvUtil_Read_Callback ReadBlocks, tDrvUtil_Write_Callback WriteBlocks,
- Uint64 BlockSize,
Uint
Argument)
+ Uint64 BlockSize,
void *
Argument)
{
Uint8 tmp[BlockSize]; // C99
Uint64 block = Start / BlockSize;
{
Uint8 tmp[BlockSize]; // C99
Uint64 block = Start / BlockSize;
@@
-637,7
+665,7
@@
Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, const void *Buffer,
int tailings;
Uint64 ret;
int tailings;
Uint64 ret;
- ENTER("XStart XLength pBuffer pReadBlocks pWriteBlocks XBlockSize
x
Argument",
+ ENTER("XStart XLength pBuffer pReadBlocks pWriteBlocks XBlockSize
p
Argument",
Start, Length, Buffer, ReadBlocks, WriteBlocks, BlockSize, Argument);
// Non aligned start, let's fix that!
Start, Length, Buffer, ReadBlocks, WriteBlocks, BlockSize, Argument);
// Non aligned start, let's fix that!
UCC
git Repository :: git.ucc.asn.au