Atomizer, aka «Studio2D». Graphic raster editor. AGI is my own «Atomizer Generated Image» file format.
{$A+,B+,D+,E-,F-,G+,I+,L+,N+,O-,P-,Q-,R-,S+,T-,V+,X+,Y+}
{$M 16384,0,600000}
Program Cursor_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 }
Var
CurSizeX : Byte;
CurSizeY : Byte;
Cursor : array [ 0..99, 0..99 ] of Byte;
CurBitX : Byte;
CurBitY : Byte;
CurBitSize : Byte;
procedure savecursor;
var
tmpx : integer;
tmpy : integer;
filename : string;
begin
ReadLn( filename );
Assign( f, filename + '.crf' );
Rewrite( f, 1 );
blockwrite( f, cursizex, 1 );
blockwrite( f, cursizey, 1 );
for tmpy := 0 to cursizey - 1 do
for tmpx := 0 to cursizex - 1 do
blockwrite( f, cursor[ tmpx, tmpy ], 1 );
close( f );
end;
Procedure RefreshCursor;
Var
AxisX : Integer;
AxisY : Integer;
begin
for AxisY := 0 to CurSizeY - 1 do
for AxisX := 0 to CurSizeX - 1 do
begin
if Cursor[ AxisX, AxisY ] = 255 then
BarDeluxe( 10 + AxisX*( CurBitSize + 2 ), 10 + AxisY*( CurBitSize + 2 ),
CurBitSize, CurBitSize, PhantomColorStyle, PhantomColor )
else
BarDeluxe( 10 + AxisX*( CurBitSize + 2 ), 10 + AxisY*( CurBitSize + 2 ),
CurBitSize, CurBitSize, 1, Cursor[ AxisX, AxisY ] );
PutPixel( 50 + CurSizeX * ( CurBitSize + 2 ) + CurBitX, 20 + CurBitY , Cursor[ CurBitX, CurBitY ]);
end;
end;
Procedure LoadCursor;
Var
AxisX : Integer;
AxisY : Integer;
filename : string;
begin
ReadLn( FileName );
Assign( F, FileName + '.crf' );
Reset( F, 1 );
BlockRead( F, CurSizeX, 1 );
BlockRead( F, CurSizeY, 1 );
for AxisY := 0 to CurSizeY - 1 do
for AxisX := 0 to CurSizeX - 1 do
BlockRead( F, Cursor[ AxisX, AxisY ], 1 );
Close( F );
RefreshCursor;
end;
{- Main ---------------------------------------------------------------------}
Begin
SVGAinitialize; { *** Init video *** }
SetGraphMode( 3 );{ *** Set graphics mode by 800x600 pixels, 8 bit color *** }
Color.Foreground := 15;
Color.Background := 0;
cursizex := 23;
cursizey := 23;
curbitsize := 8;
{ for AxisY := 0 to ImagesByY do
for AxisX := 0 to ImagesByX do New( Image[ AxisX, AxisY ].Data );
}
New( MainPalette );
for AxisY := 0 to 15 do
for AxisX := 0 to 15 do
MainPalette^[ AxisX, AxisY ] := AxisX + 16 * AxisY;
MainPalette^[7,15] := 22;
MainPalette^[8,15]:=23;
MainPalette^[9,15]:=24;
MainPalette^[10,15]:=25;
MainPalette^[11,15]:=26;
MainPalette^[12,15]:=COLOR_2;
MainPalette^[13,15]:=28;
MainPalette^[14,15]:=29;
MainPalette^[15,15]:=PhantomColorNum;
for AxisY:=0 to 15 do { *** Draw palette box *** }
for AxisX:=0 to 15 do
Panel(10+AxisX*14,324+AxisY*14,12,12,22,MainPalette^[AxisX,AxisY],31);
for axisy := 0 to cursizey-1 do { *** Draw palette box *** }
for axisx := 0 to cursizex-1 do
cursor[ axisx, axisy ] := 0;
if MouseInit( MouseFlag) then { *** Verify mouse *** }
begin
MouseSetXRange( 0, 799 );
MouseSetYRange( 0, 599 );
MouseSetPos( 400, 300 );
InitMouseCursor( 'a.crf' );{ *** Read mouse cursor from file *** }
MouseShow;
end;
SetColor( 27 );
Rectangle( 8, 8, 8 + CurSizeX * ( CurBitSize + 2 ) + 2, 8 + CurSizeY * ( CurBitSize + 2 ) + 2 );
OutTextXY( 10, 10, 'Screen resolution: ' + inttostr( getmaxx+1 ) + ' x ' + inttostr( getmaxy+1 ) + ' pixels' );
OutTextXY( 10, 30, 'Edit area' );
repeat { *** Global cycle *** }
Old_m_X_coord := m_X_coord;
Old_m_Y_coord := m_Y_coord;
MouseRead( m_X_coord, m_Y_coord, m_BUTTON );
{ *** LEFT MOUSE BUTTON *** }
if m_BUTTON = 1 then
begin
CurBitX := ( m_X_coord - 10 ) div ( CurBitSize + 2 );
CurBitY := ( m_Y_coord - 10 ) div ( CurBitSize + 2 );
if MouseAction( 10, 10, 8 + CurSizeX * (CurBitSize + 2), 8 + CurSizeY * (CurBitSize+2)) then
begin
Cursor[ CurBitX, CurBitY ] := Color.Foreground;
if Color.Foreground = 255 then
BarDeluxe( 10 + CurBitX*( CurBitSize + 2 ), 10 + CurBitY*( CurBitSize + 2 ),
CurBitSize, CurBitSize, PhantomColorStyle, PhantomColor )
else
BarDeluxe( 10 + CurBitX*( CurBitSize + 2 ), 10 + CurBitY*( CurBitSize + 2 ),
CurBitSize, CurBitSize, 1, Cursor[ CurBitX, CurBitY ] );
PutPixel( 50 + CurSizeX * ( CurBitSize + 2 ) + CurBitX, 20 + CurBitY , Cursor[ CurBitX, CurBitY ]);
end;
{ if (( m_X_coord > 10 ) and ( m_X_coord < 10 + iSizeX * iBit.BitSize ))
and (( m_Y_coord > 48 ) and ( m_Y_coord < 48 + iSizeY * iBit.BitSize ))
and Image[ SelectImX, SelectImY ].Flag then EditImage( Color.Foreground );
}
{ Get color from main palette }
if (( m_X_coord > 10 ) and ( m_X_coord < 310 )) and (( m_Y_coord > 324 ) and ( m_Y_coord < 544 )) then
Color.Foreground := GetMainColor;
end;
(*{----------------------------------------------------------------------------}
{ *** RIGHT MOUSE BUTTON *** }
if m_BUTTON = 2 then
begin
{ *** Edit current image *** }
if (( m_X_coord > 11 ) and ( m_X_coord < 11 + iSizeX * iBit.BitSize ))
and (( m_Y_coord > 48 ) and ( m_Y_coord < 48 + iSizeY * iBit.BitSize )) then EditImage( Color.Background );
if not DisableRIGHT then
begin
DisableRIGHT := True;
{ *** Get color from main palette *** }
if (( m_X_coord > 10 ) and ( m_X_coord < 266 )) and (( m_Y_coord > 310 ) and ( m_Y_coord < 568 )) then
Color.Background := GetMainColor;
end;
end else DisableRight:=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 );
SetTextStyle( 2, 0, 0 );
Outtextxy( 405, 505, Inttostr(m_X_coord));
Outtextxy( 430, 505, Inttostr(m_Y_coord));
end;
if KeyPressed then
begin
Key := ReadKey;
if Key = #27 then
begin
closegraph;
exit;
end;
if Key = #0 then
begin
Key := ReadKey;
case Key of
F1 : RefreshCursor;
F2 : SaveCursor;
F3 : LoadCursor;
end;{ of case }
end;
end;
until False;
End.{ Written by Sergeant Skeleton at 26.03.99 }