#include <video.h>
#include <wm.h>
#include <string.h>
+#include "include/lowlevel.h"
// === IMPORTS ===
extern int giTerminalFD_Input;
}
giScreenWidth = dims.PW;
giScreenHeight = dims.PH;
+ if( giScreenWidth < 640 || giScreenHeight < 480 ) {
+ Video_int_SetBufFmt(PTYBUFFMT_TEXT);
+ _SysDebug("Resoltion too small, 640x480 reqd but %ix%i avail",
+ giScreenWidth, giScreenHeight);
+ exit(-1);
+ }
_SysDebug("AxWin3 running at %ix%i", dims.PW, dims.PH);
giVideo_LastDirtyLine = giScreenHeight;
// Create local framebuffer (back buffer)
gpScreenBuffer = malloc( giScreenWidth*giScreenHeight*4 );
+ //gpScreenBuffer = _SysMemMap( giTerminalFD, 0, giScreenWidth*giScreenHeight*4, NULL);
// Set cursor position and bitmap
- // TODO: This will require using the 2DCMD buffer format
- //_SysIOCtl(giTerminalFD, TERM_IOCTL_SETCURSORBITMAP, &cCursorBitmap);
+ {
+ Video_int_SetBufFmt(PTYBUFFMT_2DCMD);
+ struct ptycmd_header hdr = {PTY2D_CMD_SETCURSORBMP,0,0};
+ size_t size = sizeof(hdr) + sizeof(cCursorBitmap) + cCursorBitmap.W*cCursorBitmap.H*4;
+ hdr.len_low = size / 4;
+ hdr.len_hi = size / (256*4);
+ _SysWrite(giTerminalFD, &hdr, sizeof(hdr));
+ _SysDebug("size = %i (%04x:%02x * 4)", size, hdr.len_hi, hdr.len_low);
+ _SysWrite(giTerminalFD, &cCursorBitmap, size-sizeof(hdr));
+ }
Video_SetCursorPos( giScreenWidth/2, giScreenHeight/2 );
}
void Video_SetCursorPos(short X, short Y)
{
struct ptycmd_setcursorpos cmd;
- cmd.cmd = PTY2D_CMD_SETCURSORPOS;
+ cmd.hdr.cmd = PTY2D_CMD_SETCURSORPOS;
+ cmd.hdr.len_low = sizeof(cmd)/4;
+ cmd.hdr.len_hi = 0;
cmd.x = giVideo_CursorX = X;
cmd.y = giVideo_CursorY = Y;
void Video_FillRect(int X, int Y, int W, int H, uint32_t Colour)
{
- uint32_t *dest;
- int i;
-
if(X < 0 || Y < 0) return;
+ if(W < 0 || H < 0) return;
if(W >= giScreenWidth) return;
if(H >= giScreenHeight) return;
if(X + W >= giScreenWidth) W = giScreenWidth - W;
if(Y + H >= giScreenHeight) W = giScreenHeight - H;
- dest = gpScreenBuffer + Y * giScreenWidth + X;
+ uint32_t *dest = gpScreenBuffer + Y * giScreenWidth + X;
while(H --)
{
- for( i = W; i --; dest ++ ) *dest = Colour;
+ for( int i = W; i --; dest ++ ) *dest = Colour;
dest += giScreenWidth - W;
}
}