Tank battle game.
{$A+,B+,D+,E-,F-,G+,I+,L+,N+,O-,P-,Q-,R-,S+,T-,V+,X+,Y+}
{$M 16384, 0, 300000}
Program Graphics_Editor;
Uses
crt, graph, dos, globals, general, mouse, service, buttons, menus;
Function GetHighestCap( Table : Pointer; Modes : Word; Size : Integer ) : Integer;
near; assembler;
asm
XOR AX,AX
LES DI, Table
@@1:
MOV SI, Modes
ADD SI, Size
ADD SI, Size
MOV BX, ES:[DI]
CMP BX, 0FFFFH
JE @@4
INC DI
INC DI
MOV CX,Size
@@2:
CMP BX,[SI]
JZ @@3
DEC SI
DEC SI
LOOP @@2
@@3:
CMP AX,CX
JA @@1
MOV AX,CX
JMP @@1
@@4:
end;
function DetectVesa16 : Integer; far; assembler;
var
VesaInfo : array [ 0..255 ] of Byte;
asm
MOV AX, SS
MOV ES, AX
LEA DI, VesaInfo
MOV AX, 4F00H
INT 10H
CMP AX, 004FH
MOV AX, grError
JNZ @@Exit
CMP ES : [ DI ].VgaInfoBlock.VESASignature.Word[0], 'EV'
JNZ @@Exit
CMP ES : [ DI ].VgaInfoBlock.VESASignature.Word[2], 'AS'
JNZ @@Exit
LES DI, ES : [ DI ].VgaInfoBlock.VideoModePtr
PUSH ES
PUSH DI
MOV AX, OFFSET Vesa16Modes
PUSH AX
MOV AX, 3
PUSH AX
CALL GetHighestCap
@@Exit:
end;
Procedure SVGAinitialize;
Var
PathToDriver : String; {Stores the DOS path to *.BGI & *.CHR}
begin
PathToDriver := '';
VESA16 := InstallUserDriver( 'VESA', @DetectVesa16 );
GD := IBM8514;
GM := IBM8514Hi;
GD := Detect; {Use autodetection}
InitGraph( GD, GM, PathToDriver );
end; {SVGA initialize }
{- Main ---------------------------------------------------------------------}
Begin
SVGAinitialize; { *** Init video *** }
SetGraphMode( 3 );{ *** Set graphics mode by 800x600 pixels, 8 bit color *** }
VERSION_NUMBER := 1;
iSizeX := 7;
iSizeY := 11;
ImagesByX := {512 div iSizeX}10;
ImagesByY := {256 div iSizeY}10;
Color.Foreground := 15;
Color.Background := 0;
Trigger.Grid := False;
Grid.GridColor := 31;
NewProjectFlag := True;
{ Get dinamic memory for operations }
for AxisY := 0 to ImagesByY do
for AxisX := 0 to ImagesByX do
New( Image[ AxisX, AxisY ].Data );
New( MainPalette );
New( Clipboard );
if MouseInit( MouseFlag) then { Verify mouse }
begin
MouseSetXRange( 0, 799 );
MouseSetYRange( 0, 599 );
MouseSetPos( 400, 300 );
InitMouseCursor( 'arrow.crf' ); { Read mouse cursor from file }
MouseShow;
DrawDesktop; { Draw desktop }
end;
repeat
Old_m_X_coord := m_X_coord;
Old_m_Y_coord := m_Y_coord;
MouseRead( m_X_coord, m_Y_coord, m_BUTTON );
{ Show current image element }
if MouseMove then
if (( m_X_coord > 9 ) and ( m_X_coord< 9 + iSizeX * iBit.BitSize ))
and (( m_Y_coord > 57 ) and (m_Y_coord< 57 + iSizeY * iBit.BitSize ))
and Image[ SelectImX,SelectImY ].Flag then ShowCurrentImageBit
else BarDeluxe( 222, 35, 38, 6, 1, COLOR_2 );
{----------------------------------------------------------------------------}
{ *** LEFT MOUSE BUTTON *** }
if m_BUTTON = 1 then
begin
{ Edit current image }
if (( m_X_coord > 10 ) and ( m_X_coord < 10 + iSizeX * iBit.BitSize ))
and (( m_Y_coord > 58 ) and ( m_Y_coord < 58 + iSizeY * iBit.BitSize ))
and Image[ SelectImX, SelectImY ].Flag then EditImage( Color.Foreground );
if not disableLMB then
begin
disableLMB:=True;
if (( m_X_coord > 276 ) and ( m_X_coord < 768 ))
and (( m_Y_coord > 58 ) and ( m_Y_coord < 326 + iSizeY * iBit.BitSize ))
then LMBOpsWithImages;
{ Get color from main palette }
if MouseAction( 10, 324, 230, 544 ) then Color.Foreground := GetMainColor;
end;
end else disableLMB:=False;
{----------------------------------------------------------------------------}
{ *** RIGHT MOUSE BUTTON *** }
if m_BUTTON = 2 then
begin
if (( m_X_coord > 276 ) and ( m_X_coord < 276 + ImagesByX * iSizeX ))
and (( m_Y_coord > 58 ) and ( m_Y_coord < 58 + ImagesByY * iSizeY )) then
RMBOpsWithImages;
{ Edit current image }
if (( m_X_coord > 10 ) and ( m_X_coord < 10 + iSizeX * iBit.BitSize ))
and (( m_Y_coord > 58 ) and ( m_Y_coord < 58 + iSizeY * iBit.BitSize ))
and Image[ SelectImX, SelectImY ].Flag then EditImage( Color.Background );
if not DisableRMB then
begin
disableRMB := True;
{ Get color from main palette }
if MouseAction( 10, 324, 230, 544 ) then Color.Background := GetMainColor;
end; { Disable RMB after click }
end else disableRMB:=False;
{ Draw mouse cursor }
if ( m_X_coord <> Old_m_X_coord ) or ( m_Y_coord <> Old_m_Y_coord ) then
begin
mousedraw;
bardeluxe( 400, 500, 50, 20, 1, 25 );
outtextxy( 405, 505, Inttostr( m_X_coord ) );
outtextxy( 430, 505, Inttostr( m_Y_coord ) );
end;
{ Keyboard control }
if KeyPressed then
begin
Key := ReadKey;
if Key = #27 then
begin
for AxisY := 0 to ImagesByY do
for AxisX := 0 to ImagesByX do
Dispose( Image[ AxisX, AxisY ].Data );
Dispose( MainPalette );
Dispose( Clipboard );
closegraph;
exit;
end;
if Key = #0 then
begin
Key := ReadKey;
case Key of
F1 : exit;
F2 : SaveImage;
F3 : LoadImage;
end; { of case }
end;
end;
until False;
End.{ Written by Sergeant Skeleton at 26.03.99 }