📄 grtry.c
字号:
/* 设定可见屏幕范围 */
DrawLeft = 0;
DrawTop = 0;
DrawWidth = COLS;
DrawHeight = ROWS;
/* 设定应该读取的文件Y范围 */
if ((Y > (DrawTop-Height)) && (Y < (DrawTop+DrawHeight))) /* 说明在图片显示在屏幕之内 */
{
/*
if (Y >= DrawTop)
{
if ((Y+Height) >= (DrawTop+DrawHeight))
{
FileDrawEndY = (DrawTop+DrawHeight)-Y;
DrawY = DrawTop+DrawHeight;
}
else
{
FileDrawEndY = Height-1;
DrawY = Y+Height-1;
}
FileDrawStartY = 0;
}
else
{
if ((Y+Height) >= (DrawTop+DrawHeight))
{
FileDrawEndY = (DrawTop+DrawHeight)-Y;
DrawY = DrawTop+DrawHeight;
}
else
{
FileDrawEndY = Height-1;
DrawY = Y+Height-1;
}
FileDrawStartY = DrawTop-Y;
}
*/
/* 整理 */
if ((Y+Height) >= (DrawTop+DrawHeight))
{
FileDrawEndY = (DrawTop+DrawHeight)-Y;
DrawY = DrawTop+DrawHeight;
}
else
{
FileDrawEndY = Height-1;
DrawY = Y+Height-1;
}
FileDrawStartY = (Y >= DrawTop) ? 0:(DrawTop-Y);
}
else
{
close(fp);
return ;
}
/* 设定应该读取的文件X范围 */
if ((X > (DrawLeft-Width)) && (X < (DrawLeft+DrawWidth))) /* 说明在图片显示在屏幕之内 */
{
if (X >= DrawLeft)
{
if ((X+Width) >= (DrawLeft+DrawWidth))
{
DrawBytes = (DrawLeft+DrawWidth)-X;
}
else
{
DrawBytes = Width;
}
DrawX = X;
FileDrawStartX = 0;
}
else
{
if ((X+Width) >= (DrawLeft+DrawWidth))
{
DrawBytes = DrawWidth;
}
else
{
DrawBytes = Width-(DrawLeft-X);
}
DrawX = DrawLeft;
FileDrawStartX = DrawLeft-X;
}
}
else
{
close(fp);
return ;
}
switch (COLS+ROWS)
{
case 320+200: SelectPage(0); break;
case 640+480: if (DrawY >= 409) SelectPage(4);
if ((DrawY < 409) && (DrawY >= 307)) SelectPage(3);
if ((DrawY < 307) && (DrawY >= 204)) SelectPage(2);
if ((DrawY < 204) && (DrawY >= 102)) SelectPage(1);
if (DrawY < 102) SelectPage(0);
break;
case 800+600: if (DrawY >= 573) SelectPage(7);
if ((DrawY < 573) && (DrawY >= 491)) SelectPage(6);
if ((DrawY < 491) && (DrawY >= 409)) SelectPage(5);
if ((DrawY < 409) && (DrawY >= 327)) SelectPage(4);
if ((DrawY < 327) && (DrawY >= 245)) SelectPage(3);
if ((DrawY < 245) && (DrawY >= 163)) SelectPage(2);
if ((DrawY < 163) && (DrawY >= 81)) SelectPage(1);
if (DrawY < 81) SelectPage(0);
break;
case 1024+768: SelectPage(DrawY/64); break;
}
/* 根据图片尺寸动态给读取Buffer开辟内存 */
Buffer = (UINT8 *)malloc(Linebytes);
lseek(fp, (long)(Height-1-FileDrawEndY)*Linebytes + 1078L, SEEK_SET);
for (i = FileDrawEndY; i >= FileDrawStartY; i--,DrawY--)
{
read(fp, Buffer, Linebytes);/* 一次读取一行 */
if ((COLS+ROWS) == (320+200))
{
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(320*DrawY)+DrawX), FP_OFF(VideoBuffer+(320*DrawY)+DrawX), DrawBytes);
}
/* ...... */
if ((COLS+ROWS) == (640+480))
{
switch (DrawY)
{
case 102:
if (DrawX < 256)
{
if ((DrawX+DrawBytes) > 256)
{
movedata(FP_SEG(Buffer+FileDrawStartX+(256-DrawX)), FP_OFF(Buffer+FileDrawStartX+(256-DrawX)), FP_SEG(VideoBuffer+(640*DrawY)+256), FP_OFF(VideoBuffer+(640*DrawY)+256), DrawBytes-(256-DrawX));
SelectPage(0);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(640*DrawY)+DrawX), FP_OFF(VideoBuffer+(640*DrawY)+DrawX), 256-DrawX);
}
else
{
SelectPage(0);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(640*DrawY)+DrawX), FP_OFF(VideoBuffer+(640*DrawY)+DrawX), DrawBytes);
}
}
else
{
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(640*DrawY)+DrawX), FP_OFF(VideoBuffer+(640*DrawY)+DrawX), DrawBytes);
SelectPage(0);
}
break;
case 204:
if (DrawX < 512)
{
if ((DrawX+DrawBytes) > 512)
{
movedata(FP_SEG(Buffer+FileDrawStartX+(512-DrawX)), FP_OFF(Buffer+FileDrawStartX+(512-DrawX)), FP_SEG(VideoBuffer+(640*DrawY)+512), FP_OFF(VideoBuffer+(640*DrawY)+512), DrawBytes-(512-DrawX));
SelectPage(1);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(640*DrawY)+DrawX), FP_OFF(VideoBuffer+(640*DrawY)+DrawX), 512-DrawX);
}
else
{
SelectPage(1);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(640*DrawY)+DrawX), FP_OFF(VideoBuffer+(640*DrawY)+DrawX), DrawBytes);
}
}
else
{
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(640*DrawY)+DrawX), FP_OFF(VideoBuffer+(640*DrawY)+DrawX), DrawBytes);
SelectPage(1);
}
break;
case 307:
if (DrawX < 128)
{
if ((DrawX+DrawBytes) > 128)
{
movedata(FP_SEG(Buffer+FileDrawStartX+(128-DrawX)), FP_OFF(Buffer+FileDrawStartX+(128-DrawX)), FP_SEG(VideoBuffer+(640*DrawY)+128), FP_OFF(VideoBuffer+(640*DrawY)+128), DrawBytes-(128-DrawX));
SelectPage(2);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(640*DrawY)+DrawX), FP_OFF(VideoBuffer+(640*DrawY)+DrawX), 128-DrawX);
}
else
{
SelectPage(2);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(640*DrawY)+DrawX), FP_OFF(VideoBuffer+(640*DrawY)+DrawX), DrawBytes);
}
}
else
{
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(640*DrawY)+DrawX), FP_OFF(VideoBuffer+(640*DrawY)+DrawX), DrawBytes);
SelectPage(2);
}
break;
case 409:
if (DrawX < 384)
{
if ((DrawX+DrawBytes) > 384)
{
movedata(FP_SEG(Buffer+FileDrawStartX+(384-DrawX)), FP_OFF(Buffer+FileDrawStartX+(384-DrawX)), FP_SEG(VideoBuffer+(640*DrawY)+384), FP_OFF(VideoBuffer+(640*DrawY)+384), DrawBytes-(384-DrawX));
SelectPage(3);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(640*DrawY)+DrawX), FP_OFF(VideoBuffer+(640*DrawY)+DrawX), 384-DrawX);
}
else
{
SelectPage(3);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(640*DrawY)+DrawX), FP_OFF(VideoBuffer+(640*DrawY)+DrawX), DrawBytes);
}
}
else
{
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(640*DrawY)+DrawX), FP_OFF(VideoBuffer+(640*DrawY)+DrawX), DrawBytes);
SelectPage(3);
}
break;
default:
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(640*DrawY)+DrawX), FP_OFF(VideoBuffer+(640*DrawY)+DrawX), DrawBytes);
}
}
if ((COLS+ROWS) == (800+600))
{
switch (DrawY)
{
case 81:
if (DrawX < 736)
{
if ((DrawX+DrawBytes) > 736)
{
movedata(FP_SEG(Buffer+FileDrawStartX+(736-DrawX)), FP_OFF(Buffer+FileDrawStartX+(736-DrawX)), FP_SEG(VideoBuffer+(800*DrawY)+736), FP_OFF(VideoBuffer+(800*DrawY)+736), DrawBytes-(736-DrawX));
SelectPage(0);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), 736-DrawX);
}
else
{
SelectPage(0);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
}
}
else
{
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
SelectPage(0);
}
break;
case 163:
if (DrawX < 672)
{
if ((DrawX+DrawBytes) > 672)
{
movedata(FP_SEG(Buffer+FileDrawStartX+(672-DrawX)), FP_OFF(Buffer+FileDrawStartX+(672-DrawX)), FP_SEG(VideoBuffer+(800*DrawY)+672), FP_OFF(VideoBuffer+(800*DrawY)+672), DrawBytes-(672-DrawX));
SelectPage(1);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), 672-DrawX);
}
else
{
SelectPage(1);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
}
}
else
{
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
SelectPage(1);
}
break;
case 245:
if (DrawX < 608)
{
if ((DrawX+DrawBytes) > 608)
{
movedata(FP_SEG(Buffer+FileDrawStartX+(608-DrawX)), FP_OFF(Buffer+FileDrawStartX+(608-DrawX)), FP_SEG(VideoBuffer+(800*DrawY)+608), FP_OFF(VideoBuffer+(800*DrawY)+608), DrawBytes-(608-DrawX));
SelectPage(2);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), 608-DrawX);
}
else
{
SelectPage(2);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
}
}
else
{
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
SelectPage(2);
}
break;
case 327:
if (DrawX < 544)
{
if ((DrawX+DrawBytes) > 544)
{
movedata(FP_SEG(Buffer+FileDrawStartX+(544-DrawX)), FP_OFF(Buffer+FileDrawStartX+(544-DrawX)), FP_SEG(VideoBuffer+(800*DrawY)+544), FP_OFF(VideoBuffer+(800*DrawY)+544), DrawBytes-(544-DrawX));
SelectPage(3);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), 544-DrawX);
}
else
{
SelectPage(3);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
}
}
else
{
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
SelectPage(3);
}
break;
case 409:
if (DrawX < 480)
{
if ((DrawX+DrawBytes) > 480)
{
movedata(FP_SEG(Buffer+FileDrawStartX+(480-DrawX)), FP_OFF(Buffer+FileDrawStartX+(480-DrawX)), FP_SEG(VideoBuffer+(800*DrawY)+480), FP_OFF(VideoBuffer+(800*DrawY)+480), DrawBytes-(480-DrawX));
SelectPage(4);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), 480-DrawX);
}
else
{
SelectPage(4);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
}
}
else
{
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
SelectPage(4);
}
break;
case 491:
if (DrawX < 416)
{
if ((DrawX+DrawBytes) > 416)
{
movedata(FP_SEG(Buffer+FileDrawStartX+(416-DrawX)), FP_OFF(Buffer+FileDrawStartX+(416-DrawX)), FP_SEG(VideoBuffer+(800*DrawY)+416), FP_OFF(VideoBuffer+(800*DrawY)+416), DrawBytes-(416-DrawX));
SelectPage(5);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), 416-DrawX);
}
else
{
SelectPage(5);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
}
}
else
{
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
SelectPage(5);
}
break;
case 573:
if (DrawX < 352)
{
if ((DrawX+DrawBytes) > 352)
{
movedata(FP_SEG(Buffer+FileDrawStartX+(352-DrawX)), FP_OFF(Buffer+FileDrawStartX+(352-DrawX)), FP_SEG(VideoBuffer+(800*DrawY)+352), FP_OFF(VideoBuffer+(800*DrawY)+352), DrawBytes-(352-DrawX));
SelectPage(6);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), 352-DrawX);
}
else
{
SelectPage(6);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
}
}
else
{
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
SelectPage(6);
}
break;
default:
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(800*DrawY)+DrawX), FP_OFF(VideoBuffer+(800*DrawY)+DrawX), DrawBytes);
}
}
if ((COLS+ROWS) == (1024+768))
{
if ((DrawY+1)%64 == 0) SelectPage(DrawY/64);
movedata(FP_SEG(Buffer+FileDrawStartX), FP_OFF(Buffer+FileDrawStartX), FP_SEG(VideoBuffer+(1024*DrawY)+DrawX), FP_OFF(VideoBuffer+(1024*DrawY)+DrawX), DrawBytes);
}
}
close(fp);
free(Buffer);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -