|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 17790 (0x457e)
Types: TextFile
Names: »B«
└─⟦85b835f43⟧ Bits:30000549 8mm tape, Rational 1000, Xlib rev 6.00
└─⟦0c20f784e⟧ »DATA«
└─⟦1abbe589f⟧
└─⟦306851c02⟧
└─⟦this⟧
with Text_Io;
with Main;
use Main;
with Tile_Bits;
use Tile_Bits;
with Xlbt_Arithmetic;
use Xlbt_Arithmetic;
with Xlbt_Image;
use Xlbt_Image;
with Xlbp_Graphics;
use Xlbp_Graphics;
with Xlbp_Image;
use Xlbp_Image;
package body Tile is
------------------------------------------------------------------------------
-- Dragon - a version of Mah-Jongg for X Windows
--
-- Author: Gary E. Barnes March 1989
--
-- tile.c - Deals with the individual Mah-Jongg tiles.
------------------------------------------------------------------------------
-- 05/30/90 GEB - Translate to Ada
------------------------------------------------------------------------------
Tile_X11 : S_Short := 28 / 2; -- one column
Tile_X21 : S_Short := 28 / 3; -- two columns
Tile_X22 : S_Short := 28 * 2 / 3;
Tile_X31 : S_Short := 28 / 4; -- three columns
Tile_X32 : S_Short := 28 * 2 / 4;
Tile_X33 : S_Short := 28 * 3 / 4;
Tile_Y11 : S_Short := 32 / 2; -- one row
Tile_Y21 : S_Short := 32 / 3; -- two rows
Tile_Y22 : S_Short := 32 * 2 / 3;
Tile_Y31 : S_Short := 32 / 5; -- three rows
Tile_Y32 : S_Short := 32 * 2 / 5;
Tile_Y33 : S_Short := 32 * 3 / 5;
Number_X : S_Short := 28 - 7;
Number_Y : S_Short := 0;
Subtile_X : S_Short := 7 / 2;
Subtile_Y : S_Short := 8 / 2;
--\f
procedure Configure_Tiles (Size : S_Long) is
------------------------------------------------------------------------------
-- size - Specifies the tile size to use; 1..5
--
-- Called when the Board receives a ConfigureNotify event. We check to see if
-- the size of the board/tiles have changed. If so then we reconfigure the
-- images of the tiles.
------------------------------------------------------------------------------
W : S_Short;
H : S_Short;
begin
----Make sure that our caller is rational.
if Size < 1 or else Size > 5 then
Text_Io.Put_Line ("Bad size given to Configure_Tiles in tile.c [" &
S_Long'Image (Size) & "].");
Configure_Tiles (1);
return;
end if;
----Set up all of the various images.
Setup_Images (Natural (Size) - 1);
----Set up the sub-tile positions.
W := S_Short (Spring.Width);
H := S_Short (Spring.Height);
Tile_X11 := W / 2; -- one column
Tile_X21 := W / 3; -- two columns
Tile_X22 := W - Tile_X21;
Tile_X31 := W / 4; -- three columns
while Tile_X31 + S_Short (Bam.Width / 2 + Bam.Width * 2) >=
S_Short (Spring.Width) loop
Tile_X31 := Tile_X31 - 1;
end loop;
Tile_X32 := Tile_X31 + S_Short (Bam.Width);
Tile_X33 := Tile_X32 + S_Short (Bam.Width);
Tile_Y11 := H / 2; -- one row
Tile_Y21 := H / 3; -- two rows
Tile_Y22 := H - Tile_Y21;
Tile_Y31 := H * 2 / 5; -- three rows
while Tile_Y31 + S_Short (Bam.Height / 2 + Bam.Height * 2) >=
S_Short (Spring.Height) loop
Tile_Y31 := Tile_Y31 - 1;
end loop;
Tile_Y32 := Tile_Y31 + S_Short (Bam.Height);
Tile_Y33 := Tile_Y32 + S_Short (Bam.Height);
Number_X := W - S_Short (One.Width) - 1;
Number_Y := 1;
Subtile_X := S_Short (Bam.Width) / 2;
Subtile_Y := S_Short (Bam.Height) / 2;
end Configure_Tiles;
--\f
procedure Draw_Image (Image : X_Image;
X : S_Short;
Y : S_Short) is
------------------------------------------------------------------------------
-- Do an XPutImage on the image.
------------------------------------------------------------------------------
begin
X_Put_Image (Dpy, Board.Drawable, Normal_Gc, Image,
0, 0, X, Y, Image.Width, Image.Height);
end Draw_Image;
--\f
procedure Draw_Blank (X : S_Short; Y : S_Short) is
------------------------------------------------------------------------------
-- Draw an empty tile; our caller will fill it in with little images.
------------------------------------------------------------------------------
begin
X_Fill_Rectangle (Dpy, Board.Drawable, Reverse_Gc, X,
Y, Spring.Width, Spring.Height);
end Draw_Blank;
--\f
procedure Draw_Number (Image : X_Image; X : S_Short; Y : S_Short) is
------------------------------------------------------------------------------
-- Called to draw the number in the upper right corner of a numbered tile.
------------------------------------------------------------------------------
begin
X_Put_Image (Dpy, Board.Drawable, Xor_Gc, Image, 0, 0, X + Number_X,
Y + Number_Y, Image.Width, Image.Height);
end Draw_Number;
--\f
procedure Draw_Spring (X : S_Short; Y : S_Short) is
begin
Draw_Image (Spring, X, Y);
end Draw_Spring;
procedure Draw_Summer (X : S_Short; Y : S_Short) is
begin
Draw_Image (Summer, X, Y);
end Draw_Summer;
procedure Draw_Fall (X : S_Short; Y : S_Short) is
begin
Draw_Image (Fall, X, Y);
end Draw_Fall;
procedure Draw_Winter (X : S_Short; Y : S_Short) is
begin
Draw_Image (Winter, X, Y);
end Draw_Winter;
--\f
procedure Draw_Bamboo (X : S_Short; Y : S_Short) is
begin
Draw_Image (Bamboo, X, Y);
end Draw_Bamboo;
procedure Draw_Mum (X : S_Short; Y : S_Short) is
begin
Draw_Image (Mum, X, Y);
end Draw_Mum;
procedure Draw_Orchid (X : S_Short; Y : S_Short) is
begin
Draw_Image (Orchid, X, Y);
end Draw_Orchid;
procedure Draw_Plum (X : S_Short; Y : S_Short) is
begin
Draw_Image (Plum, X, Y);
end Draw_Plum;
--\f
procedure Draw_Gdragon (X : S_Short; Y : S_Short) is
begin
Draw_Image (Gdragon, X, Y);
end Draw_Gdragon;
procedure Draw_Rdragon (X : S_Short; Y : S_Short) is
begin
Draw_Image (Rdragon, X, Y);
end Draw_Rdragon;
procedure Draw_Wdragon (X : S_Short; Y : S_Short) is
begin
Draw_Image (Wdragon, X, Y);
end Draw_Wdragon;
---\f
procedure Draw_East (X : S_Short; Y : S_Short) is
begin
Draw_Image (East, X, Y);
end Draw_East;
procedure Draw_West (X : S_Short; Y : S_Short) is
begin
Draw_Image (West, X, Y);
end Draw_West;
procedure Draw_North (X : S_Short; Y : S_Short) is
begin
Draw_Image (North, X, Y);
end Draw_North;
procedure Draw_South (X : S_Short; Y : S_Short) is
begin
Draw_Image (South, X, Y);
end Draw_South;
--\f
procedure Draw_Bam1 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Bam, Bx + Tile_X11, By + Tile_Y11);
Draw_Number (One, X, Y);
end Draw_Bam1;
procedure Draw_Bam2 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Bam, Bx + Tile_X11, By + Tile_Y21);
Draw_Image (Bam, Bx + Tile_X11, By + Tile_Y22);
Draw_Number (Two, X, Y);
end Draw_Bam2;
procedure Draw_Bam3 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Bam, Bx + Tile_X11, By + Tile_Y21);
Draw_Image (Bam, Bx + Tile_X21, By + Tile_Y22);
Draw_Image (Bam, Bx + Tile_X22, By + Tile_Y22);
Draw_Number (Three, X, Y);
end Draw_Bam3;
procedure Draw_Bam4 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Bam, Bx + Tile_X21, By + Tile_Y21);
Draw_Image (Bam, Bx + Tile_X22, By + Tile_Y21);
Draw_Image (Bam, Bx + Tile_X21, By + Tile_Y22);
Draw_Image (Bam, Bx + Tile_X22, By + Tile_Y22);
Draw_Number (Four, X, Y);
end Draw_Bam4;
procedure Draw_Bam5 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Bam, Bx + Tile_X11, By + Tile_Y31);
Draw_Image (Bam, Bx + Tile_X21, By + Tile_Y32);
Draw_Image (Bam, Bx + Tile_X22, By + Tile_Y32);
Draw_Image (Bam, Bx + Tile_X21, By + Tile_Y33);
Draw_Image (Bam, Bx + Tile_X22, By + Tile_Y33);
Draw_Number (Five, X, Y);
end Draw_Bam5;
procedure Draw_Bam6 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Bam, Bx + Tile_X21, By + Tile_Y31);
Draw_Image (Bam, Bx + Tile_X22, By + Tile_Y31);
Draw_Image (Bam, Bx + Tile_X21, By + Tile_Y32);
Draw_Image (Bam, Bx + Tile_X22, By + Tile_Y32);
Draw_Image (Bam, Bx + Tile_X21, By + Tile_Y33);
Draw_Image (Bam, Bx + Tile_X22, By + Tile_Y33);
Draw_Number (Six, X, Y);
end Draw_Bam6;
procedure Draw_Bam7 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Bam, Bx + Tile_X21, By + Tile_Y31);
Draw_Image (Bam, Bx + Tile_X22, By + Tile_Y31);
Draw_Image (Bam, Bx + Tile_X21, By + Tile_Y32);
Draw_Image (Bam, Bx + Tile_X22, By + Tile_Y32);
Draw_Image (Bam, Bx + Tile_X31, By + Tile_Y33);
Draw_Image (Bam, Bx + Tile_X32, By + Tile_Y33);
Draw_Image (Bam, Bx + Tile_X33, By + Tile_Y33);
Draw_Number (Seven, X, Y);
end Draw_Bam7;
procedure Draw_Bam8 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Bam, Bx + Tile_X21, By + Tile_Y31);
Draw_Image (Bam, Bx + Tile_X22, By + Tile_Y31);
Draw_Image (Bam, Bx + Tile_X31, By + Tile_Y32);
Draw_Image (Bam, Bx + Tile_X32, By + Tile_Y32);
Draw_Image (Bam, Bx + Tile_X33, By + Tile_Y32);
Draw_Image (Bam, Bx + Tile_X31, By + Tile_Y33);
Draw_Image (Bam, Bx + Tile_X32, By + Tile_Y33);
Draw_Image (Bam, Bx + Tile_X33, By + Tile_Y33);
Draw_Number (Eight, X, Y);
end Draw_Bam8;
procedure Draw_Bam9 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Bam, Bx + Tile_X31, By + Tile_Y31);
Draw_Image (Bam, Bx + Tile_X32, By + Tile_Y31);
Draw_Image (Bam, Bx + Tile_X33, By + Tile_Y31);
Draw_Image (Bam, Bx + Tile_X31, By + Tile_Y32);
Draw_Image (Bam, Bx + Tile_X32, By + Tile_Y32);
Draw_Image (Bam, Bx + Tile_X33, By + Tile_Y32);
Draw_Image (Bam, Bx + Tile_X31, By + Tile_Y33);
Draw_Image (Bam, Bx + Tile_X32, By + Tile_Y33);
Draw_Image (Bam, Bx + Tile_X33, By + Tile_Y33);
Draw_Number (Nine, X, Y);
end Draw_Bam9;
--\f
procedure Draw_Dot1 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Dot, Bx + Tile_X11, By + Tile_Y11);
Draw_Number (One, X, Y);
end Draw_Dot1;
procedure Draw_Dot2 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Dot, Bx + Tile_X11, By + Tile_Y21);
Draw_Image (Dot, Bx + Tile_X11, By + Tile_Y22);
Draw_Number (Two, X, Y);
end Draw_Dot2;
procedure Draw_Dot3 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Dot, Bx + Tile_X11, By + Tile_Y21);
Draw_Image (Dot, Bx + Tile_X21, By + Tile_Y22);
Draw_Image (Dot, Bx + Tile_X22, By + Tile_Y22);
Draw_Number (Three, X, Y);
end Draw_Dot3;
procedure Draw_Dot4 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Dot, Bx + Tile_X21, By + Tile_Y21);
Draw_Image (Dot, Bx + Tile_X22, By + Tile_Y21);
Draw_Image (Dot, Bx + Tile_X21, By + Tile_Y22);
Draw_Image (Dot, Bx + Tile_X22, By + Tile_Y22);
Draw_Number (Four, X, Y);
end Draw_Dot4;
procedure Draw_Dot5 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Dot, Bx + Tile_X11, By + Tile_Y31);
Draw_Image (Dot, Bx + Tile_X21, By + Tile_Y32);
Draw_Image (Dot, Bx + Tile_X22, By + Tile_Y32);
Draw_Image (Dot, Bx + Tile_X21, By + Tile_Y33);
Draw_Image (Dot, Bx + Tile_X22, By + Tile_Y33);
Draw_Number (Five, X, Y);
end Draw_Dot5;
procedure Draw_Dot6 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Dot, Bx + Tile_X21, By + Tile_Y31);
Draw_Image (Dot, Bx + Tile_X22, By + Tile_Y31);
Draw_Image (Dot, Bx + Tile_X21, By + Tile_Y32);
Draw_Image (Dot, Bx + Tile_X22, By + Tile_Y32);
Draw_Image (Dot, Bx + Tile_X21, By + Tile_Y33);
Draw_Image (Dot, Bx + Tile_X22, By + Tile_Y33);
Draw_Number (Six, X, Y);
end Draw_Dot6;
procedure Draw_Dot7 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Dot, Bx + Tile_X21, By + Tile_Y31);
Draw_Image (Dot, Bx + Tile_X22, By + Tile_Y31);
Draw_Image (Dot, Bx + Tile_X21, By + Tile_Y32);
Draw_Image (Dot, Bx + Tile_X22, By + Tile_Y32);
Draw_Image (Dot, Bx + Tile_X31, By + Tile_Y33);
Draw_Image (Dot, Bx + Tile_X32, By + Tile_Y33);
Draw_Image (Dot, Bx + Tile_X33, By + Tile_Y33);
Draw_Number (Seven, X, Y);
end Draw_Dot7;
procedure Draw_Dot8 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Dot, Bx + Tile_X21, By + Tile_Y31);
Draw_Image (Dot, Bx + Tile_X22, By + Tile_Y31);
Draw_Image (Dot, Bx + Tile_X31, By + Tile_Y32);
Draw_Image (Dot, Bx + Tile_X32, By + Tile_Y32);
Draw_Image (Dot, Bx + Tile_X33, By + Tile_Y32);
Draw_Image (Dot, Bx + Tile_X31, By + Tile_Y33);
Draw_Image (Dot, Bx + Tile_X32, By + Tile_Y33);
Draw_Image (Dot, Bx + Tile_X33, By + Tile_Y33);
Draw_Number (Eight, X, Y);
end Draw_Dot8;
procedure Draw_Dot9 (X : S_Short; Y : S_Short) is
Bx : S_Short := X - Subtile_X;
By : S_Short := Y - Subtile_Y;
begin
Draw_Blank (X, Y);
Draw_Image (Dot, Bx + Tile_X31, By + Tile_Y31);
Draw_Image (Dot, Bx + Tile_X32, By + Tile_Y31);
Draw_Image (Dot, Bx + Tile_X33, By + Tile_Y31);
Draw_Image (Dot, Bx + Tile_X31, By + Tile_Y32);
Draw_Image (Dot, Bx + Tile_X32, By + Tile_Y32);
Draw_Image (Dot, Bx + Tile_X33, By + Tile_Y32);
Draw_Image (Dot, Bx + Tile_X31, By + Tile_Y33);
Draw_Image (Dot, Bx + Tile_X32, By + Tile_Y33);
Draw_Image (Dot, Bx + Tile_X33, By + Tile_Y33);
Draw_Number (Nine, X, Y);
end Draw_Dot9;
--\f
procedure Draw_Crak1 (X : S_Short; Y : S_Short) is
begin
Draw_Image (Crak, X, Y);
Draw_Number (One, X, Y);
end Draw_Crak1;
procedure Draw_Crak2 (X : S_Short; Y : S_Short) is
begin
Draw_Image (Crak, X, Y);
Draw_Number (Two, X, Y);
end Draw_Crak2;
procedure Draw_Crak3 (X : S_Short; Y : S_Short) is
begin
Draw_Image (Crak, X, Y);
Draw_Number (Three, X, Y);
end Draw_Crak3;
procedure Draw_Crak4 (X : S_Short; Y : S_Short) is
begin
Draw_Image (Crak, X, Y);
Draw_Number (Four, X, Y);
end Draw_Crak4;
procedure Draw_Crak5 (X : S_Short; Y : S_Short) is
begin
Draw_Image (Crak, X, Y);
Draw_Number (Five, X, Y);
end Draw_Crak5;
procedure Draw_Crak6 (X : S_Short; Y : S_Short) is
begin
Draw_Image (Crak, X, Y);
Draw_Number (Six, X, Y);
end Draw_Crak6;
procedure Draw_Crak7 (X : S_Short; Y : S_Short) is
begin
Draw_Image (Crak, X, Y);
Draw_Number (Seven, X, Y);
end Draw_Crak7;
procedure Draw_Crak8 (X : S_Short; Y : S_Short) is
begin
Draw_Image (Crak, X, Y);
Draw_Number (Eight, X, Y);
end Draw_Crak8;
procedure Draw_Crak9 (X : S_Short; Y : S_Short) is
begin
Draw_Image (Crak, X, Y);
Draw_Number (Nine, X, Y);
end Draw_Crak9;
end Tile;