For DOS Protected Mode version of sensor core software
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

262 lines
4.7 KiB

//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright © 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: SCREEN.CPP
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of SCREEN.CPP
//----------------------------------------------------------------------------
#include <alloc.h>
#include <math.h>
#include "screen.h"
#include "detector.h"
//#include "..\LgLib\version.h"
#ifdef DEBUG_GRAPH_SCREEN
CScreen g_Screen;
BYTE huge* CScreen::s_pVideoMem = (BYTE huge* )0xA0000000L;
CScreen::CScreen()
{
}
CScreen::~CScreen()
{
Destroy();
}
BOOL CScreen::Create()
{
asm
{
mov ax, 0x13
int 0x10
}
return TRUE;
}
void CScreen::Destroy()
{
asm
{
mov ax, 0x3
int 0x10
}
}
void CScreen::Clear()
{
for( LONG i = 0; i < 320L*200; i++ )
s_pVideoMem[i] = 0;
}
static BYTE g_pNumbers[] =
{
// 0x00
0x00,0x0F,0x0F,0x00,
0x0F,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x0F,
0x00,0x0F,0x0F,0x00,
// 0x0F
0x00,0x00,0x00,0x0F,
0x00,0x00,0x00,0x0F,
0x00,0x00,0x0F,0x0F,
0x00,0x00,0x00,0x0F,
0x00,0x00,0x00,0x0F,
0x00,0x00,0x00,0x0F,
0x00,0x00,0x00,0x0F,
// 2
0x00,0x0F,0x0F,0x00,
0x0F,0x00,0x00,0x0F,
0x00,0x00,0x00,0x0F,
0x00,0x00,0x00,0x0F,
0x00,0x00,0x0F,0x00,
0x00,0x0F,0x00,0x00,
0x0F,0x0F,0x0F,0x0F,
// 3
0x00,0x0F,0x0F,0x00,
0x0F,0x00,0x00,0x0F,
0x00,0x00,0x00,0x0F,
0x00,0x00,0x0F,0x00,
0x00,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x0F,
0x00,0x0F,0x0F,0x00,
// 4
0x0F,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x0F,
0x0F,0x0F,0x0F,0x0F,
0x00,0x00,0x00,0x0F,
0x00,0x00,0x00,0x0F,
0x00,0x00,0x00,0x0F,
// 5
0x0F,0x0F,0x0F,0x0F,
0x0F,0x00,0x00,0x00,
0x0F,0x0F,0x0F,0x00,
0x0F,0x00,0x00,0x0F,
0x00,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x0F,
0x00,0x0F,0x0F,0x00,
// 6
0x00,0x0F,0x0F,0x00,
0x0F,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x00,
0x0F,0x0F,0x0F,0x0F,
0x0F,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x0F,
0x00,0x0F,0x0F,0x00,
// 7
0x0F,0x0F,0x0F,0x0F,
0x00,0x00,0x00,0x0F,
0x00,0x00,0x00,0x0F,
0x00,0x00,0x0F,0x00,
0x00,0x0F,0x00,0x00,
0x00,0x0F,0x00,0x00,
0x00,0x0F,0x00,0x00,
// 8
0x00,0x0F,0x0F,0x00,
0x0F,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x0F,
0x00,0x0F,0x0F,0x00,
0x0F,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x0F,
0x00,0x0F,0x0F,0x00,
// 9
0x00,0x0F,0x0F,0x00,
0x0F,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x0F,
0x00,0x0F,0x0F,0x0F,
0x00,0x00,0x00,0x0F,
0x0F,0x00,0x00,0x0F,
0x00,0x0F,0x0F,0x00,
};
void CScreen::OutInteger( LONG nShift, INT nValue )
{
INT nCount = 0;
BYTE pSymbol[10];
// convert to string
do
{
pSymbol[ nCount++ ] = nValue % 10;
nValue /= 10;
}
while( nValue );
BYTE huge *pScreen = s_pVideoMem + nShift;
for( INT i = nCount - 1; i >= 0; i-- )
{
INT nBit = pSymbol[i] * 28;
BYTE huge * pScr = pScreen;
for( INT y = 0; y < 7; y ++ )
{
for( INT x = 0; x < 4; x ++ )
pScr[x] = g_pNumbers[ nBit++ ];
pScr += 320;
}
pScreen += 5;
}
}
#endif //DEBUG_GRAPH_SCREEN
#ifdef DEBUG_CRT_SCREEN
CCRT g_CRT;
void CCRT::TextOut( INT x, INT y, LPCTSTR pText, INT nText )
{
BYTE huge *pVideo = m_lpVideo + (y << 7) + (y << 5) + (x << 1);
for( INT i = 0 ; i < nText; i++ )
{
*pVideo++ = *pText++;
*pVideo++ = 15; // white color on black background
}
}
void CCRT::IntOut( INT x, INT y, INT nValue )
{
asm
{
// m_lpVideo + (y << 7) + (y << 5) + (x << 1)
push 0xB800
pop es
mov si, x
shl si, 1 // si = x << 1
mov bx, y
mov ax, bx
shl ax, 5
add si, ax // si = (x << 1) + (y << 5)
mov ax, bx
shl ax, 7
add si, ax // si = (x << 1) + (y << 5) + (y << 7)
add si, 4*2 // si = (x << 1) + (y << 5) + (y << 7) + 4*2
// convertion circle
mov ax, nValue // DX:AX <- nValue
mov bx, 10 // divider
mov cx, 5
@lNextDigit:
xor dx, dx
div bx
add dl, '0' // place character
mov dh, 15 // place attribute
mov [es:si], dx
dec si
dec si
loop @lNextDigit
}
}
void CCRT::HexOut( INT x, INT y, INT nValue )
{
static BYTE pHexTable[] = "0123456789ABCDEF";
asm
{
// m_lpVideo + (y << 7) + (y << 5) + (x << 1)
push 0xB800
pop es
mov si, x
shl si, 1 // si = x << 1
mov bx, y
mov ax, bx
shl ax, 5
add si, ax // si = (x << 1) + (y << 5)
mov ax, bx
shl ax, 7
add si, ax // si = (x << 1) + (y << 5) + (y << 7)
add si, 3*2 // si = (x << 1) + (y << 5) + (y << 7) + 3*2
// convertion circle
mov ax, nValue // DX:AX <- nValue
mov cx, 4
@lNextDigit:
mov bx, ax
and bx, 0x000F;
mov dl, pHexTable[bx] // character
mov dh, 15 // attribute
mov [es:si], dx
dec si
dec si
shr ax, 4
loop @lNextDigit
}
}
#endif // DEBUG_CRT_SCREEN