From 58b60d1455a6670cbfb1572257460065fe7e6207 Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 13 May 2020 20:25:51 +0000 Subject: Builds (just) and runs. --- CLEVELS/-1 | 16 + CLEVELS/-2 | 16 + CLEVELS/1 | 15 + CLEVELS/10 | 46 + CLEVELS/11 | 80 ++ CLEVELS/12 | 36 + CLEVELS/2 | 30 + CLEVELS/3 | 36 + CLEVELS/4 | 38 + CLEVELS/5 | 27 + CLEVELS/6 | 18 + CLEVELS/7 | 24 + CLEVELS/8 | 25 + CLEVELS/9 | 61 + CLEVELS/NO | 1 + CLEVELS/README | 50 + CLEVELS/TEST | 33 + CLEVELS/template | 20 + GFX16/amoeba | 6 + GFX16/butterfly | 6 + GFX16/butterflygen | 6 + GFX16/chaser | 6 + GFX16/chasergen | 6 + GFX16/diamond | 6 + GFX16/earth | 6 + GFX16/exit | 6 + GFX16/filter | 6 + GFX16/miner | 6 + GFX16/oneup | 6 + GFX16/rock | 6 + GFX16/rockgen | 6 + GFX16/rockswitch | 6 + GFX16/space | 6 + GFX16/tuffwall | 6 + GFX16/wall | 6 + GFX16COL/amoeba | Bin 0 -> 271 bytes GFX16COL/butterfly | Bin 0 -> 271 bytes GFX16COL/butterflygen | Bin 0 -> 271 bytes GFX16COL/chaser | Bin 0 -> 271 bytes GFX16COL/chasergen | Bin 0 -> 271 bytes GFX16COL/colormap | Bin 0 -> 1536 bytes GFX16COL/diamond | Bin 0 -> 271 bytes GFX16COL/earth | Bin 0 -> 271 bytes GFX16COL/exit | Bin 0 -> 271 bytes GFX16COL/filter | Bin 0 -> 271 bytes GFX16COL/miner | Bin 0 -> 271 bytes GFX16COL/oneup | Bin 0 -> 271 bytes GFX16COL/rock | Bin 0 -> 271 bytes GFX16COL/rockgen | Bin 0 -> 271 bytes GFX16COL/rockswitch | Bin 0 -> 271 bytes GFX16COL/space | Bin 0 -> 271 bytes GFX16COL/tuffwall | Bin 0 -> 271 bytes GFX16COL/wall | Bin 0 -> 271 bytes GFX8/amoeba | 4 + GFX8/butterfly | 4 + GFX8/butterflygen | 4 + GFX8/chaser | 4 + GFX8/chasergen | 4 + GFX8/diamond | 4 + GFX8/earth | 4 + GFX8/exit | 4 + GFX8/filter | 4 + GFX8/miner | 4 + GFX8/oneup | 4 + GFX8/rock | 4 + GFX8/rockgen | 4 + GFX8/rockswitch | 4 + GFX8/space | 4 + GFX8/tuffwall | 4 + GFX8/wall | 4 + GFX8COL/amoeba | Bin 0 -> 79 bytes GFX8COL/butterfly | Bin 0 -> 79 bytes GFX8COL/butterflygen | Bin 0 -> 79 bytes GFX8COL/chaser | Bin 0 -> 79 bytes GFX8COL/chasergen | Bin 0 -> 79 bytes GFX8COL/colormap | Bin 0 -> 1536 bytes GFX8COL/diamond | Bin 0 -> 79 bytes GFX8COL/earth | Bin 0 -> 79 bytes GFX8COL/exit | Bin 0 -> 79 bytes GFX8COL/filter | Bin 0 -> 79 bytes GFX8COL/miner | Bin 0 -> 79 bytes GFX8COL/oneup | Bin 0 -> 79 bytes GFX8COL/rock | Bin 0 -> 79 bytes GFX8COL/rockgen | Bin 0 -> 79 bytes GFX8COL/rockswitch | Bin 0 -> 79 bytes GFX8COL/space | Bin 0 -> 79 bytes GFX8COL/tuffwall | Bin 0 -> 79 bytes GFX8COL/wall | Bin 0 -> 79 bytes Makefile | 41 + README | 143 +++ XLEVELS/-1 | 16 + XLEVELS/-2 | 16 + XLEVELS/1 | 15 + XLEVELS/10 | 46 + XLEVELS/11 | 80 ++ XLEVELS/12 | 36 + XLEVELS/2 | 30 + XLEVELS/3 | 36 + XLEVELS/4 | 38 + XLEVELS/5 | 27 + XLEVELS/6 | 18 + XLEVELS/7 | 24 + XLEVELS/8 | 25 + XLEVELS/9 | 61 + XLEVELS/DEBUGLEV | 35 + XLEVELS/NO | 1 + XLEVELS/README | 50 + XLEVELS/TEST | 33 + XLEVELS/template | 20 + Xbit.c | 1877 +++++++++++++++++++++++++++ Xbit.h | 596 +++++++++ dash.c | 3400 +++++++++++++++++++++++++++++++++++++++++++++++++ fontset.h | 2020 +++++++++++++++++++++++++++++ icon.bmp | 27 + spred.c | 1264 ++++++++++++++++++ 115 files changed, 10717 insertions(+) create mode 100644 CLEVELS/-1 create mode 100644 CLEVELS/-2 create mode 100644 CLEVELS/1 create mode 100644 CLEVELS/10 create mode 100644 CLEVELS/11 create mode 100644 CLEVELS/12 create mode 100644 CLEVELS/2 create mode 100644 CLEVELS/3 create mode 100644 CLEVELS/4 create mode 100644 CLEVELS/5 create mode 100644 CLEVELS/6 create mode 100644 CLEVELS/7 create mode 100644 CLEVELS/8 create mode 100644 CLEVELS/9 create mode 100644 CLEVELS/NO create mode 100644 CLEVELS/README create mode 100644 CLEVELS/TEST create mode 100644 CLEVELS/template create mode 100644 GFX16/amoeba create mode 100644 GFX16/butterfly create mode 100644 GFX16/butterflygen create mode 100644 GFX16/chaser create mode 100644 GFX16/chasergen create mode 100644 GFX16/diamond create mode 100644 GFX16/earth create mode 100644 GFX16/exit create mode 100644 GFX16/filter create mode 100644 GFX16/miner create mode 100644 GFX16/oneup create mode 100644 GFX16/rock create mode 100644 GFX16/rockgen create mode 100644 GFX16/rockswitch create mode 100644 GFX16/space create mode 100644 GFX16/tuffwall create mode 100644 GFX16/wall create mode 100644 GFX16COL/amoeba create mode 100644 GFX16COL/butterfly create mode 100644 GFX16COL/butterflygen create mode 100644 GFX16COL/chaser create mode 100644 GFX16COL/chasergen create mode 100644 GFX16COL/colormap create mode 100644 GFX16COL/diamond create mode 100644 GFX16COL/earth create mode 100644 GFX16COL/exit create mode 100644 GFX16COL/filter create mode 100644 GFX16COL/miner create mode 100644 GFX16COL/oneup create mode 100644 GFX16COL/rock create mode 100644 GFX16COL/rockgen create mode 100644 GFX16COL/rockswitch create mode 100644 GFX16COL/space create mode 100644 GFX16COL/tuffwall create mode 100644 GFX16COL/wall create mode 100644 GFX8/amoeba create mode 100644 GFX8/butterfly create mode 100644 GFX8/butterflygen create mode 100644 GFX8/chaser create mode 100644 GFX8/chasergen create mode 100644 GFX8/diamond create mode 100644 GFX8/earth create mode 100644 GFX8/exit create mode 100644 GFX8/filter create mode 100644 GFX8/miner create mode 100644 GFX8/oneup create mode 100644 GFX8/rock create mode 100644 GFX8/rockgen create mode 100644 GFX8/rockswitch create mode 100644 GFX8/space create mode 100644 GFX8/tuffwall create mode 100644 GFX8/wall create mode 100644 GFX8COL/amoeba create mode 100644 GFX8COL/butterfly create mode 100644 GFX8COL/butterflygen create mode 100644 GFX8COL/chaser create mode 100644 GFX8COL/chasergen create mode 100644 GFX8COL/colormap create mode 100644 GFX8COL/diamond create mode 100644 GFX8COL/earth create mode 100644 GFX8COL/exit create mode 100644 GFX8COL/filter create mode 100644 GFX8COL/miner create mode 100644 GFX8COL/oneup create mode 100644 GFX8COL/rock create mode 100644 GFX8COL/rockgen create mode 100644 GFX8COL/rockswitch create mode 100644 GFX8COL/space create mode 100644 GFX8COL/tuffwall create mode 100644 GFX8COL/wall create mode 100644 Makefile create mode 100644 README create mode 100644 XLEVELS/-1 create mode 100644 XLEVELS/-2 create mode 100644 XLEVELS/1 create mode 100644 XLEVELS/10 create mode 100644 XLEVELS/11 create mode 100644 XLEVELS/12 create mode 100644 XLEVELS/2 create mode 100644 XLEVELS/3 create mode 100644 XLEVELS/4 create mode 100644 XLEVELS/5 create mode 100644 XLEVELS/6 create mode 100644 XLEVELS/7 create mode 100644 XLEVELS/8 create mode 100644 XLEVELS/9 create mode 100644 XLEVELS/DEBUGLEV create mode 100644 XLEVELS/NO create mode 100644 XLEVELS/README create mode 100644 XLEVELS/TEST create mode 100644 XLEVELS/template create mode 100644 Xbit.c create mode 100644 Xbit.h create mode 100644 dash.c create mode 100644 fontset.h create mode 100644 icon.bmp create mode 100644 spred.c diff --git a/CLEVELS/-1 b/CLEVELS/-1 new file mode 100644 index 0000000..c1a3988 --- /dev/null +++ b/CLEVELS/-1 @@ -0,0 +1,16 @@ +Well Done +0,0 +0 +9999 +60,10 +R##########################################################E +#..........................................................# +#......*...*...................****........................# +#......*...*.****.*....*.......*...*..**..*..*.****........# +#......*...*.*....*....*.......*...*.*..*.**.*.*...........# +#......*.*.*.***..*....*.......*...*.*..*.*.**.***.........# +#......*.*.*.*....*....*.......*...*.*..*.*..*.*...........# +#.......*.*..****.****.****....****...**..*..*.****........# +#..........................................................# +############################################################ + diff --git a/CLEVELS/-2 b/CLEVELS/-2 new file mode 100644 index 0000000..87775c5 --- /dev/null +++ b/CLEVELS/-2 @@ -0,0 +1,16 @@ +Try again +0,0 +0 +9999 +60,10 +R##########################################################E +#..........................................................# +#......@@@@@...............@@@.............................# +#........@...@@@..@...@...@...@..@@@...@@..@@@.@..@........# +#........@...@..@..@.@....@...@.@.....@..@..@..@@.@........# +#........@...@@@....@.....@@@@@.@.@@..@@@@..@..@.@@........# +#........@...@..@...@.....@...@.@..@..@..@..@..@..@........# +#........@...@..@...@.....@...@..@@@..@..@.@@@.@..@........# +#..........................................................# +############################################################ + diff --git a/CLEVELS/1 b/CLEVELS/1 new file mode 100644 index 0000000..587ea04 --- /dev/null +++ b/CLEVELS/1 @@ -0,0 +1,15 @@ +Nice and easy +0,0 +10 +50 +39,9 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%.*........*..........................% +%. ......@....*......@................% +%. ....*......*......*......@@@@@@@@@.% +%. ........@........*................E% +%. ....*...*........*.......@.........% +%. ...................................% +%R.......@............................% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/CLEVELS/10 b/CLEVELS/10 new file mode 100644 index 0000000..47e81f2 --- /dev/null +++ b/CLEVELS/10 @@ -0,0 +1,46 @@ +It's aMAZEing!!!! +0,0 +1 +200 +10,10 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R...............%%......................%%.............%%.............%%...............% +%%%%%%%%%%%%%%.%%%%%%%.%%%%%%%%%%%.%%%%%%%%%%%%%%%.%%%%%%%%%%%%%.%%%%%%%%%%%%%%.%%%%%%..% +%............................................%...........%%.............%%..............% +%%%%%.%%%%%.%%%%%%%%%%%%%%%%%.%%%%%%%%.%%%%%.%%%%.%%%%%%%%%%%%%%%%%.%%%%%%.%%%%%%%%%%%%%% +%%..%.%...%.%............%...........%.%.....%..................%....%.%.%..%...........% +%...........%.%%%%%%%%%%.%.%%%%%%%%%%%.%.%%%.%.%%%%%%%%%%%%%%%%%%.%%%%...%..%.%%%%%%%%%.% +%.%%%%%%%%%%%.%..........%.............%.%.%.%......%....%...%..............%.%.......%.% +%.............%.%.%%%.%%%%.%%%%.%%%%%%%%.%.%.%.%%%%%%..%...%...%...%..%%.%..%.%.%%%%%.%.% +%%%%.%%%%%%%....%.....%....%.................%......%..%%%%%%%%%%.%%%%%..%..%.%.%.....%.% +%..........%..%.%%%%%.%.%%%%.%%%%%%%%%%%%%%%%%.%%%%%%...........%..%....%%..%.%.%%%%%%%.% +%.%%%%%%.%.%..%...............%.....................%..%%%%%%%%.%.....%%.%..%.%.........% +%.%......%.%..%%%%%%%%%%%%%%%%%.%%%%%.%%%%%%%%%%%%.%%.........%.%%.%%%%..%..%.%.%%%%%%%%% +%.%.%%%%%%.%..%...%...%...%...%.%.....%..........%....%%%.%%%.%..........%..%.%.%.%...%%% +%...............%...%...%...%...%.%%.%%.%%%%%%%%.%.%%%%...%.%.%%%%.%%%%%%%..%.%.%.%.%...% +%.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%.%%....%...%....%.%....%%%.%...............%.%.%...%%%.% +%.%...................%.%%%.....%.%%%%%%%.%.%.%%%%.%.%%%%...%%%%%%%%%%%%%%%%%.%.%.%%%...% +%.%.%%%.%%%%%%%%.%.%%.%...%.%.%.%.........%.%...%.........%..............%..%.%.%.%.%.%%% +%.%.%.%.%......%.%..%.%%%.%%%.%.%%%%%%.%%%%.%%%.%.%%%%.%%%%.%%%%.%%%%.%%%%%.%.%.%.%.%...% +%.%.%.%.%.%%%%.%.%..%.........%.%.............%.%...........%......%........%.%.%.%.%%%.% +%.%.%.%.%.%..%.%.%%%%.%%%%%%%.%%%.%%%%%%%%%%%%%%%.%%%%%%%%%%%%%%%%%%%%%%%%%.%.%.%.%.%...% +%.%.%.%%%.%..%.%..%...%...%.....%.........................%...%...%...%...%.%.%.%.%.%.%%% +%.%.%.....%..%.%%.%.%%%.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%..%...%...%...%...%.%.%...% +%.%.%.%%%%%..%..%.%.%.%.%..............%...%...%...%...%.....%..%%%%%%%%%%%%%%..%.%.%%%.% +%.%.%.%......%%%%.%.%.%.%.%%%%%%%%%%%%.%.%...%...%...%...%.%.%...........%.%.%%...%.%...% +%.%.%.%.%%%%..%.%.%.%.%.%.%..........%.%.%%%%%%%%%%%%%%%%%%%.%%%..%%%%%.%%.%..%%..%.%.%%% +%.%.%.%....%%...%.%.%.%.%.%.%%%%%%%%.%.%...................%.%%..%%...%....%%..%%...%...% +%.%.%.%%%.%%%%%%%.%.%.%.%.%.%......%.%.%%%%%%%%%%%%%%%%%%%.%.%........%%%%..%%..%%..%%%.% +%.%%%.............%.%.%.%.%.%.%%%%.%.%.%...................%.%..%%%%%%%..%..%%%..%%.%...% +%.%...%%%.%%%%%%%%%.%...%.%.%.%..%.%.%.%.%%%%%%%%%%%%%%%%%%%.%..%...................%.%%% +%.%.%...%%%.........%.%.%.%.%.%.%%.%.%.%...................%.%..%%%%%%%%%%%%%%.%%%%.%...% +%.%.%.%.....%%%%%%..%.%.%.%.%.%....%.%.%%%%%%%%%%%%%%%%%%%.%.%......%...%%%..%....%%%%%.% +%.%.%.%%%%%%%....%.%%%%.%.%.%.%%%%%%.%.%...................%.%.%%%..%...%....%%%..%.....% +%.%.%..%......%%%%.%..%.%.%.%........%.%.%%%%%%%%%%%%%%%%%%%.%........%.%.%....%%%%.%%%.% +%.%.%%%%%%%%..%....%....%.%.%%%%%%%%%%.%..................%..%...%%%%.%......%....%.%...% +%.%.....%..%.%%.%%%%..%.%.%............%...%.....%.%.%%%%%%..%%%%%%%%%%%%%%%%%%%%.%.%.%.% +%.%.%%.....%....%.....%.%.%%%%%%%%%%%%%%...%.....%.%......%%...%...%...%...%..%E%%%.%.%.% +%.%.%..%%%%%..%.%%.%..%.%...%...%...%...%%%%.%%%%%.%.%%%%%%%.%.%.%.%.%.%.%.%..%*%%..%%%.% +%...%......%..%....%..%...%...%...%...%......%.....%.........%...%...%...%....%.........% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/CLEVELS/11 b/CLEVELS/11 new file mode 100644 index 0000000..ae4e79d --- /dev/null +++ b/CLEVELS/11 @@ -0,0 +1,80 @@ +Look Out. +0,0 +150 +150 +1,1 +%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R % %##############################################################% %**************************************************************% % E% +% % %##############################################################% %**************************************************************% % % +% % %############################################################ % %**************************************************************% % % +% % %##################################################### % %**************************************************************% % % +% % %############################################## % % ################################################### % % % +% % %################################### % % % % % +% % %########################### % % % % % +% % %################### % % % % % +% % %########### % % % % % +% % %######## % % % % % +% % %#### % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % $ $ $ $ % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% %%%%%%%%%%%% %%%%%%%% %%%%%%%%%%%% % +% ! A% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/CLEVELS/12 b/CLEVELS/12 new file mode 100644 index 0000000..1c7c3e0 --- /dev/null +++ b/CLEVELS/12 @@ -0,0 +1,36 @@ +A little bit of everything +0,0 +81 +150 +10,10 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %@@@@@% % +% .%@@@%. ######### % +% ..%@%.. #*******# % +% ..%@%.. B #*****# % +% ...@%.. #***# % +% ...@%.. #*# % +% ..%%%.. #*# % +% ........ ........#*# % +%....@@@@@........ ........... % +%@@@@@@@@@........ ......... % +%@@@@@@@@@........ .. % % +%@@@@@@@@@... .. % % +%%%%%%%%%%... .. % % +%*********%.. % % +%**********%.. %%%%%%%% R % +%***********%. % +%*******%%%**%.% % +%%%%%%%% ***%$%@ @ @ % +%............%@%............................. % +%............%.%............................. % +% %%%%%% % +% % E% % +% % @ % +% @@ %. % +% ....%%%%%%@ % +% .. % +%C ............ % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/CLEVELS/2 b/CLEVELS/2 new file mode 100644 index 0000000..e8512a7 --- /dev/null +++ b/CLEVELS/2 @@ -0,0 +1,30 @@ +Chain Reactions +0,0 +60 +300 +60,24 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R ############# % +% ############# % +% ! ############# % +% ############# % +% % +% ################################ % +% . . % +% . B B B B B . % +% . . % +% . . % +% . B B B B B . % +% . . % +% . . % +% . . % +% . B B B B B . % +% . . % +% . . % +% . . % +% . B B B B B . % +% . . % +% . . % +% . . E% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/CLEVELS/3 b/CLEVELS/3 new file mode 100644 index 0000000..bfbb4d4 --- /dev/null +++ b/CLEVELS/3 @@ -0,0 +1,36 @@ +Let's Rock +0,0 +15 +200 +70,30 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%C R % +%% %% +%.................................***###.............................% +%..............................***####...............................% +%..............................#####.................................% +%..............................@###..................................% +%....................%%.......@@@.#..................................% +%...................%%.......@*@.....................................% +%...................%%......@@@......................................% +%..................%%......@*@.......................................% +%..................%%.....@@@........................................% +%.................%%%%...@*@.........................................% +%.................%%%%%%@@@..........................................% +%................%%%%%%@@@...........................................% +%...............%%%%%*%%@%....%......................................% +%..............%%%%%%%*%%%%..%%......................................% +%............%%%%%%*%%%*%%%%%%.......................................% +%...........%%%%%%%%*%%%%%%%%........................................% +%..........%%%%%%*%%%*%%%%%..........................................% +%..........%%%%%%%*%%%%%%%...........................................% +%...........%%%%%%%*%%%%%............................................% +%...........%%%%%%%%%%%%.............................................% +%............%%%%%%%%@%%.............................................% +%.............%%%%%%%%%..............................................% +%..............%%%%%@%%..............................................% +%...............%%%%%%...............................................% +%.................%%%..............@..........................%@@@@@@% +% C* C*****E% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/CLEVELS/4 b/CLEVELS/4 new file mode 100644 index 0000000..caab3bd --- /dev/null +++ b/CLEVELS/4 @@ -0,0 +1,38 @@ +The Plug Hole... +0,0 +0 +255 +70,32 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R @@@ #*********# #*******E% +%########### #*******# #*******% +%*********## #*****# #******% +%********## #***# #*****% +%*******## #*# #@@@@% +%******## C #*# #@@@% +%*****## #*# #@@% +%****## #*# #.% +%***## #*# # % +%**## #*# # % +%*## #*# # % +%*# ... # % +%*# ## # # % +%*# # # # % +%*# B # ## # % +%*# # # # % +%*# ## # # % +%*# # # # % +%*# # ## # % +%*# # # # % +%*# B C ## # # % +%*# # # # % +%*# #&## # % +%*# # # # % +%*# ##### ## # % +%*# ##*****## # # % +%*# #*******# # ## % +%*# #**@@@**# # # % +%*# #*******# ## # % +%* .*******. ## % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/CLEVELS/5 b/CLEVELS/5 new file mode 100644 index 0000000..832772a --- /dev/null +++ b/CLEVELS/5 @@ -0,0 +1,27 @@ +It's all in the timing... +0,0 +30 +300 +200,94 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%E.....................................R% +%.......................................% +%.......................................% +%.......................................% +%.......................................% +%.........********************..........% +%.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.% +%.......................................% +% % +% % +% % +% % +% % +% % +% % +% % +% % +% A % +% AAA % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/CLEVELS/6 b/CLEVELS/6 new file mode 100644 index 0000000..0917b84 --- /dev/null +++ b/CLEVELS/6 @@ -0,0 +1,18 @@ +Run Like Hell!!! +0,0 +1 +35 +0,0 +%%%%%%%%%%%%%%%%%%%% +% % R % % % E% +% % % % % % % % % @% +% % % % % % % % %..% +% % % % % % % % %% % +% % % % % % % % %% % +% % % % % % % % %% % +% % % % % % % % %% % +% % % % % % % % %% % +% % % % % % % % %% % +%B% % % % % +%%%%%%%%%%%%%%%%%%%% + diff --git a/CLEVELS/7 b/CLEVELS/7 new file mode 100644 index 0000000..3c0c5e8 --- /dev/null +++ b/CLEVELS/7 @@ -0,0 +1,24 @@ +Safe Cracker +0,0 +45 +150 +20,70 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R.........................................................% +%..........................................................% +%.......@..........@ ...................................% % +%...##### ......%%%%% ...................................% % +%...# @ # ......%***# ...........%%%%....%..%.%..%.......% % +%...# # ......%***# ...........%@@%....%..%.%..%.......% % +%...# # ......%***% ...........%@@%....%%%%.%..%.......% % +%...# A # ....B.%***% ...........%..%....%..%.%..........% % +%...# # .... .%***% ...........%..%....%..%.%..%.......% % +%...# # .... .%***% ...........%..%....................% % +%...# # .... .%***% ..............%....................% % +%...##### .%%%%%B...........%$$%....................% % +%.................... ...........%..%....................%C% +%.................... ..............%....................% % +%.................... ...........%%%%....................% % +%.................... ...................................%E% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/CLEVELS/8 b/CLEVELS/8 new file mode 100644 index 0000000..a76225d --- /dev/null +++ b/CLEVELS/8 @@ -0,0 +1,25 @@ +Raindrops +0,0 +100 +200 +0,0 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R %rrrrrrrrrrrrrrrrrr% rrrrr % +% % % % +% % % % +% % b b b % % +% % % % +% % % % +% % % % % +% % % % % % +% % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % +% % % % % % % % % % % +% % % % +% % +% % +% E% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/CLEVELS/9 b/CLEVELS/9 new file mode 100644 index 0000000..01a959e --- /dev/null +++ b/CLEVELS/9 @@ -0,0 +1,61 @@ +Around the bend.. +0,0 +125 +200 +10,10 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R %% %*******%........................................%*******% +%%%%%%%%%%%%%%%%%%%%%%% %% %%%%%%%%%% %*******%........................................%*******% +% % %% % %*******%........................................%*******% +%%%%%%%%%%%%%%%%%%%%%%% %% % %%%%%%%%%%%%%%..%%........................................%%%%%..%% +% %% % %*******....%C %..................................... ....% +% %%%%%%%%%%%%%%%%%%%%%%%%% % %********...% ...................................... % +% % %%%%%%%%%% %%%%%%..................................... % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % +%.................................................................................................% +%.................................................................................................% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % + % C % + % % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % +%@@@@@@@@............ ................. ...................... ...................% +%@@@@@@@@............ ................. ...................... ...................% +%@@@@@@@@............ ................. ...................... ...................% +%.@@@@@@@............ ................. ...................... ...................% +%..@@@@@.............C .................C ......................C ...........********% +%...@@@..%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%........% %%%%%%%%%%%%%%%%%% +% % %E...............% +%@@@@@. % %%%%%%%%%%..%%%%%% +%.@@@@. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%..%%%%%%%%%%%% +%..@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..........% +%...@@. ..............................................................................% +%....@. ......***.........***.............***.............***...........***...........% +%...... ..............................................................................% +% ..%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%% ..% + % ...... ..% + %******..... ..% + %%%%%%%%%%%%%%%....% + %....% + %....% +%%%%%%%%%%%%%%%%%%%%%%%....%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%**********************....***************************% +%***********************..****************************% +%*****************************************************% +%**..................................................*% +%**. .*% +%**. .*% +%**. .*% +%**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*% +%**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*% +%**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*% +%**..................................................*% +%**..................................................*% +%**. .*% +%**. .*% +%**. .*% +%**..................................................*% +%&****************************************************% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/CLEVELS/NO b/CLEVELS/NO new file mode 100644 index 0000000..48082f7 --- /dev/null +++ b/CLEVELS/NO @@ -0,0 +1 @@ +12 diff --git a/CLEVELS/README b/CLEVELS/README new file mode 100644 index 0000000..1e91140 --- /dev/null +++ b/CLEVELS/README @@ -0,0 +1,50 @@ +Files +----- + +These files must exist here to allow dash to run: + +NO - The number of levels in the directory. Just an ASCII file with + the number in it. +-1 - A special level used for successfully completing a level +-2 - A special level used for failing to complete a level +1,2,3.. - The level files themselves. + + +Map Design +---------- + +ENSURE THERE IS UNBREAKABLE WALL ALL AROUND THE LEVEL!!!!!! + +Title +Start screen position (x,y) +No of diamonds (0 == All) +Timer (1 tick == 10 game cylces) +Max size of amoeba,Chance of amoeba move (as %) [must be present if no amoeba] + + + + +Map characters :- + +R - Miner +E - Exit +% - Unbreakable Wall +# - Explodable Wall +. - Earth +@ - Rock +* - Gem +B - Butterfly +C - Chaser +! - Swapper (swaps rocks and breakable walls around) +& - Extra life +$ - Indestructible Filter (changes falling rocks to diamonds and + visa versa if there is a space on the other side). +A - Ameoba (fills surrounding spaces and earth and changes to + rocks or diamonds depending on whether it runs out of room or + gets contained first. Note : Multiple glyphs are taken to be + part of the same amoeba - even if space seperates them) +r - Indestructible Rock generator - drops rocks out of it +b - Indestructible Butterfly generator - generates butterflys in + 4 compass directions if there is space +c - Indestructible Butterfly generator - generates butterflys in + 4 compass directions if there is space diff --git a/CLEVELS/TEST b/CLEVELS/TEST new file mode 100644 index 0000000..33a72ce --- /dev/null +++ b/CLEVELS/TEST @@ -0,0 +1,33 @@ +Test New Features +0,0 +0 +-1 +500,0 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R...................................................................% +%......@.............................................................% +%....... ............................................................% +%....... ............................................................% +%....... ............................................................% +%....... .@@@@@@@@...................................................% +%....... ............................................................% +%....... .*....@.....................................................% +%......$$$$$$$$$$$$..................................................% +%....... .. ...................................................% +%....... .. ...................................................% +%....................................................................% +%......$$$$$$$$$$$$.....@@@@@@@@.....................................% +%...... ....@... ....@....................................% +%...... ...@..........@...................................% +%......$$$$$$$$$$$$...@.. @ ...@...................................% +%...... .. .. ...@...................................% +%...... ...@.. AA ...@...................................% +%......$$$$$$$$$$$$...@.. AA . .@...................................% +%.....................@......*...@...................................% +%......................@........@....................................% +%.......................@@@@@@@@.....................................% +%....................................................................% +%....................................................................% +%............................................*......................E% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/CLEVELS/template b/CLEVELS/template new file mode 100644 index 0000000..ae5654f --- /dev/null +++ b/CLEVELS/template @@ -0,0 +1,20 @@ +title +screen_x,screen_y +diamonds +timer +max_ameoba_size,ameoba_move_chance +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R.........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%.........................................................E% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/GFX16/amoeba b/GFX16/amoeba new file mode 100644 index 0000000..e77303d --- /dev/null +++ b/GFX16/amoeba @@ -0,0 +1,6 @@ +#define amoeba_width 16 +#define amoeba_height 16 +static char amoeba_bits[] = { + 0x73, 0xce, 0xad, 0xb1, 0xdd, 0xbf, 0xfd, 0xdd, 0xdd, 0xda, 0xad, 0xbd, + 0xdb, 0xbf, 0xfb, 0xbf, 0x7b, 0x77, 0xbb, 0x6a, 0x7b, 0x77, 0xf7, 0x7f, + 0xfb, 0x7f, 0x3d, 0xb9, 0xcd, 0xb6, 0xf3, 0xcf}; diff --git a/GFX16/butterfly b/GFX16/butterfly new file mode 100644 index 0000000..a2876cf --- /dev/null +++ b/GFX16/butterfly @@ -0,0 +1,6 @@ +#define butterfly_width 16 +#define butterfly_height 16 +static char butterfly_bits[] = { + 0xb3, 0xcd, 0xad, 0xb5, 0x5e, 0x7a, 0x56, 0x6a, 0x5a, 0x5a, 0x5a, 0x5a, + 0x6a, 0x56, 0x2a, 0x54, 0x2a, 0x54, 0x6a, 0x56, 0x5a, 0x5a, 0x5a, 0x5a, + 0x56, 0x6a, 0x5e, 0x7a, 0xed, 0xb7, 0xf3, 0xcf}; diff --git a/GFX16/butterflygen b/GFX16/butterflygen new file mode 100644 index 0000000..eea2401 --- /dev/null +++ b/GFX16/butterflygen @@ -0,0 +1,6 @@ +#define butterflygen_width 16 +#define butterflygen_height 16 +static char butterflygen_bits[] = { + 0x00, 0x00, 0xfe, 0x7f, 0xba, 0x7f, 0x92, 0x7f, 0x92, 0x7f, 0xba, 0x7d, + 0xfe, 0x78, 0xfe, 0x7d, 0xbe, 0x6d, 0x1e, 0x40, 0xbe, 0x6d, 0xfe, 0x7d, + 0xfe, 0x78, 0xfe, 0x7d, 0xfe, 0x7f, 0x00, 0x00}; diff --git a/GFX16/chaser b/GFX16/chaser new file mode 100644 index 0000000..230bdc5 --- /dev/null +++ b/GFX16/chaser @@ -0,0 +1,6 @@ +#define chaser_width 16 +#define chaser_height 16 +static char chaser_bits[] = { + 0x07, 0xe0, 0xfb, 0xdf, 0xfd, 0xbf, 0xc6, 0x63, 0x86, 0x61, 0xfe, 0x7f, + 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x6f, 0x0e, 0x70, 0xf6, 0x7f, 0xfe, 0x7f, + 0x3e, 0x7c, 0xdd, 0xbb, 0xed, 0xb7, 0xf3, 0xcf}; diff --git a/GFX16/chasergen b/GFX16/chasergen new file mode 100644 index 0000000..1a14efa --- /dev/null +++ b/GFX16/chasergen @@ -0,0 +1,6 @@ +#define chasergen_width 16 +#define chasergen_height 16 +static char chasergen_bits[] = { + 0x00, 0x00, 0xfe, 0x7f, 0xc6, 0x7f, 0xaa, 0x7f, 0x92, 0x7f, 0x82, 0x7d, + 0x92, 0x78, 0xfe, 0x7d, 0xbe, 0x6d, 0x1e, 0x40, 0xbe, 0x6d, 0xfe, 0x7d, + 0xfe, 0x78, 0xfe, 0x7d, 0xfe, 0x7f, 0x00, 0x00}; diff --git a/GFX16/diamond b/GFX16/diamond new file mode 100644 index 0000000..997829c --- /dev/null +++ b/GFX16/diamond @@ -0,0 +1,6 @@ +#define diamond_width 16 +#define diamond_height 16 +static char diamond_bits[] = { + 0xff, 0xff, 0x7f, 0xfe, 0x3f, 0xfd, 0x5f, 0xfb, 0x6f, 0xf7, 0xf7, 0xee, + 0xfb, 0xde, 0xfd, 0xbe, 0xe1, 0x86, 0x1b, 0xd8, 0xf7, 0xee, 0xef, 0xf6, + 0xdf, 0xfa, 0x3f, 0xfc, 0x7f, 0xfe, 0xff, 0xff}; diff --git a/GFX16/earth b/GFX16/earth new file mode 100644 index 0000000..7f05a78 --- /dev/null +++ b/GFX16/earth @@ -0,0 +1,6 @@ +#define earth_width 16 +#define earth_height 16 +static char earth_bits[] = { + 0xdf, 0xf7, 0xc5, 0x92, 0x75, 0xf0, 0x9d, 0x27, 0x8a, 0xe1, 0x7f, 0x3f, + 0x8e, 0x5b, 0xde, 0xff, 0x43, 0x89, 0xe8, 0xcf, 0x89, 0xd2, 0xe5, 0x93, + 0x79, 0x9d, 0xf1, 0x7a, 0x99, 0x4d, 0xb5, 0xbb}; diff --git a/GFX16/exit b/GFX16/exit new file mode 100644 index 0000000..8921c70 --- /dev/null +++ b/GFX16/exit @@ -0,0 +1,6 @@ +#define exit_width 16 +#define exit_height 16 +static char exit_bits[] = { + 0xff, 0xff, 0x01, 0x80, 0xfd, 0xbf, 0x7d, 0xbe, 0x3d, 0xbc, 0x1d, 0xb8, + 0x1d, 0xb8, 0x3d, 0xbc, 0x7d, 0xbe, 0x7d, 0xbe, 0x7d, 0xbe, 0x3d, 0xbc, + 0x1d, 0xb8, 0xfd, 0xbf, 0x01, 0x80, 0xff, 0xff}; diff --git a/GFX16/filter b/GFX16/filter new file mode 100644 index 0000000..ad2db3a --- /dev/null +++ b/GFX16/filter @@ -0,0 +1,6 @@ +#define filter_width 16 +#define filter_height 16 +static char filter_bits[] = { + 0x00, 0x00, 0xfe, 0x7f, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, + 0x7e, 0x7e, 0x7e, 0x7e, 0x02, 0x40, 0x06, 0x60, 0x0e, 0x70, 0x1e, 0x78, + 0x3e, 0x7c, 0x7e, 0x7e, 0xfe, 0x7f, 0x00, 0x00}; diff --git a/GFX16/miner b/GFX16/miner new file mode 100644 index 0000000..7b435fe --- /dev/null +++ b/GFX16/miner @@ -0,0 +1,6 @@ +#define miner_width 16 +#define miner_height 16 +static char miner_bits[] = { + 0x3f, 0xfe, 0x3f, 0xfe, 0x7f, 0xff, 0x0f, 0xf8, 0x07, 0xf0, 0xf3, 0xe7, + 0x1b, 0xec, 0x1b, 0xec, 0x3b, 0xee, 0xff, 0xff, 0xdf, 0xfd, 0xff, 0xff, + 0xdf, 0xfd, 0xff, 0xff, 0xcf, 0xf9, 0xc3, 0xe1}; diff --git a/GFX16/oneup b/GFX16/oneup new file mode 100644 index 0000000..fb72d0a --- /dev/null +++ b/GFX16/oneup @@ -0,0 +1,6 @@ +#define oneup_width 16 +#define oneup_height 16 +static char oneup_bits[] = { + 0x00, 0x00, 0xfe, 0x7f, 0x7e, 0x7e, 0x3e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, + 0x3e, 0x7c, 0xfe, 0x7f, 0x92, 0x61, 0x92, 0x49, 0x92, 0x49, 0x92, 0x61, + 0x92, 0x79, 0xc6, 0x79, 0xfe, 0x7f, 0x00, 0x00}; diff --git a/GFX16/rock b/GFX16/rock new file mode 100644 index 0000000..4bb0a84 --- /dev/null +++ b/GFX16/rock @@ -0,0 +1,6 @@ +#define rock_width 16 +#define rock_height 16 +static char rock_bits[] = { + 0x0f, 0xf0, 0x03, 0xc0, 0x39, 0x80, 0x3c, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x1f, 0xf8}; diff --git a/GFX16/rockgen b/GFX16/rockgen new file mode 100644 index 0000000..d2c2828 --- /dev/null +++ b/GFX16/rockgen @@ -0,0 +1,6 @@ +#define rockgen_width 16 +#define rockgen_height 16 +static char rockgen_bits[] = { + 0x00, 0x00, 0xfe, 0x7f, 0xc6, 0x7f, 0x92, 0x7f, 0x8a, 0x7f, 0x82, 0x7f, + 0xc6, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7d, 0xfe, 0x7d, + 0xfe, 0x78, 0xfe, 0x7d, 0xfe, 0x7f, 0x00, 0x00}; diff --git a/GFX16/rockswitch b/GFX16/rockswitch new file mode 100644 index 0000000..bedf5db --- /dev/null +++ b/GFX16/rockswitch @@ -0,0 +1,6 @@ +#define rockswitch_width 16 +#define rockswitch_height 16 +static char rockswitch_bits[] = { + 0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xee, 0x7e, 0xde, 0x7d, + 0xbe, 0x7b, 0x6e, 0x77, 0xde, 0x60, 0xbe, 0x6e, 0x7e, 0x6e, 0xfe, 0x60, + 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00}; diff --git a/GFX16/space b/GFX16/space new file mode 100644 index 0000000..7263dcb --- /dev/null +++ b/GFX16/space @@ -0,0 +1,6 @@ +#define space_width 16 +#define space_height 16 +static char space_bits[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; diff --git a/GFX16/tuffwall b/GFX16/tuffwall new file mode 100644 index 0000000..71513e3 --- /dev/null +++ b/GFX16/tuffwall @@ -0,0 +1,6 @@ +#define tuffwall_width 16 +#define tuffwall_height 16 +static char tuffwall_bits[] = { + 0xff, 0xff, 0x83, 0xc0, 0x05, 0xa1, 0x89, 0x90, 0xf1, 0x8f, 0x31, 0x8c, + 0x51, 0x8a, 0x9b, 0xa9, 0x95, 0xd9, 0x51, 0x8a, 0x31, 0x8c, 0xf1, 0x8f, + 0x09, 0x91, 0x85, 0xa0, 0x03, 0xc1, 0xff, 0xff}; diff --git a/GFX16/wall b/GFX16/wall new file mode 100644 index 0000000..b12172f --- /dev/null +++ b/GFX16/wall @@ -0,0 +1,6 @@ +#define wall_width 16 +#define wall_height 16 +static char wall_bits[] = { + 0x00, 0x00, 0xfe, 0x7f, 0xea, 0x57, 0xfe, 0x7f, 0xea, 0x57, 0xfe, 0x7f, + 0x3e, 0x7d, 0xfe, 0x7d, 0xbe, 0x7f, 0xbe, 0x7c, 0xfe, 0x7f, 0xea, 0x57, + 0xfe, 0x7f, 0xea, 0x57, 0xfe, 0x7f, 0x00, 0x00}; diff --git a/GFX16COL/amoeba b/GFX16COL/amoeba new file mode 100644 index 0000000..115f3c8 Binary files /dev/null and b/GFX16COL/amoeba differ diff --git a/GFX16COL/butterfly b/GFX16COL/butterfly new file mode 100644 index 0000000..597a73d Binary files /dev/null and b/GFX16COL/butterfly differ diff --git a/GFX16COL/butterflygen b/GFX16COL/butterflygen new file mode 100644 index 0000000..139f06b Binary files /dev/null and b/GFX16COL/butterflygen differ diff --git a/GFX16COL/chaser b/GFX16COL/chaser new file mode 100644 index 0000000..4663c75 Binary files /dev/null and b/GFX16COL/chaser differ diff --git a/GFX16COL/chasergen b/GFX16COL/chasergen new file mode 100644 index 0000000..90d37ba Binary files /dev/null and b/GFX16COL/chasergen differ diff --git a/GFX16COL/colormap b/GFX16COL/colormap new file mode 100644 index 0000000..3121add Binary files /dev/null and b/GFX16COL/colormap differ diff --git a/GFX16COL/diamond b/GFX16COL/diamond new file mode 100644 index 0000000..7a47d62 Binary files /dev/null and b/GFX16COL/diamond differ diff --git a/GFX16COL/earth b/GFX16COL/earth new file mode 100644 index 0000000..c20a1b3 Binary files /dev/null and b/GFX16COL/earth differ diff --git a/GFX16COL/exit b/GFX16COL/exit new file mode 100644 index 0000000..792e4a4 Binary files /dev/null and b/GFX16COL/exit differ diff --git a/GFX16COL/filter b/GFX16COL/filter new file mode 100644 index 0000000..ca823d2 Binary files /dev/null and b/GFX16COL/filter differ diff --git a/GFX16COL/miner b/GFX16COL/miner new file mode 100644 index 0000000..4da26e4 Binary files /dev/null and b/GFX16COL/miner differ diff --git a/GFX16COL/oneup b/GFX16COL/oneup new file mode 100644 index 0000000..8da9fd4 Binary files /dev/null and b/GFX16COL/oneup differ diff --git a/GFX16COL/rock b/GFX16COL/rock new file mode 100644 index 0000000..4b137a4 Binary files /dev/null and b/GFX16COL/rock differ diff --git a/GFX16COL/rockgen b/GFX16COL/rockgen new file mode 100644 index 0000000..fc61e20 Binary files /dev/null and b/GFX16COL/rockgen differ diff --git a/GFX16COL/rockswitch b/GFX16COL/rockswitch new file mode 100644 index 0000000..b036d5d Binary files /dev/null and b/GFX16COL/rockswitch differ diff --git a/GFX16COL/space b/GFX16COL/space new file mode 100644 index 0000000..ec4cc40 Binary files /dev/null and b/GFX16COL/space differ diff --git a/GFX16COL/tuffwall b/GFX16COL/tuffwall new file mode 100644 index 0000000..39fa67a Binary files /dev/null and b/GFX16COL/tuffwall differ diff --git a/GFX16COL/wall b/GFX16COL/wall new file mode 100644 index 0000000..1631378 Binary files /dev/null and b/GFX16COL/wall differ diff --git a/GFX8/amoeba b/GFX8/amoeba new file mode 100644 index 0000000..39b61c9 --- /dev/null +++ b/GFX8/amoeba @@ -0,0 +1,4 @@ +#define amoeba_width 8 +#define amoeba_height 8 +static char amoeba_bits[] = { + 0x9f, 0x69, 0xb5, 0xbe, 0xa6, 0xbd, 0xdb, 0xe7}; diff --git a/GFX8/butterfly b/GFX8/butterfly new file mode 100644 index 0000000..ad1c363 --- /dev/null +++ b/GFX8/butterfly @@ -0,0 +1,4 @@ +#define butterfly_width 8 +#define butterfly_height 8 +static char butterfly_bits[] = { + 0x3c, 0x5a, 0x66, 0x7e, 0x7e, 0x66, 0x5a, 0x3c}; diff --git a/GFX8/butterflygen b/GFX8/butterflygen new file mode 100644 index 0000000..b013f41 --- /dev/null +++ b/GFX8/butterflygen @@ -0,0 +1,4 @@ +#define butterflygen_width 8 +#define butterflygen_height 8 +static char butterflygen_bits[] = { + 0xff, 0x81, 0xa5, 0xbd, 0xbd, 0xa5, 0x81, 0xff}; diff --git a/GFX8/chaser b/GFX8/chaser new file mode 100644 index 0000000..c701378 --- /dev/null +++ b/GFX8/chaser @@ -0,0 +1,4 @@ +#define chaser_width 8 +#define chaser_height 8 +static char chaser_bits[] = { + 0xc3, 0xbd, 0x5a, 0x7e, 0x42, 0x7e, 0x00, 0x99}; diff --git a/GFX8/chasergen b/GFX8/chasergen new file mode 100644 index 0000000..6113cfb --- /dev/null +++ b/GFX8/chasergen @@ -0,0 +1,4 @@ +#define chasergen_width 8 +#define chasergen_height 8 +static char chasergen_bits[] = { + 0xff, 0x81, 0x99, 0xa5, 0xbd, 0xbd, 0x81, 0xff}; diff --git a/GFX8/diamond b/GFX8/diamond new file mode 100644 index 0000000..c4c3823 --- /dev/null +++ b/GFX8/diamond @@ -0,0 +1,4 @@ +#define diamond_width 8 +#define diamond_height 8 +static char diamond_bits[] = { + 0xe7, 0xdb, 0xb5, 0x62, 0x76, 0xbd, 0xdb, 0xe7}; diff --git a/GFX8/earth b/GFX8/earth new file mode 100644 index 0000000..3be8848 --- /dev/null +++ b/GFX8/earth @@ -0,0 +1,4 @@ +#define earth_width 8 +#define earth_height 8 +static char earth_bits[] = { + 0x77, 0xdd, 0xff, 0x7f, 0xeb, 0xfe, 0xdf, 0xf5}; diff --git a/GFX8/exit b/GFX8/exit new file mode 100644 index 0000000..8d8b4b8 --- /dev/null +++ b/GFX8/exit @@ -0,0 +1,4 @@ +#define exit_width 8 +#define exit_height 8 +static char exit_bits[] = { + 0xff, 0x81, 0x99, 0xbd, 0x99, 0x99, 0x81, 0xff}; diff --git a/GFX8/filter b/GFX8/filter new file mode 100644 index 0000000..c5638e4 --- /dev/null +++ b/GFX8/filter @@ -0,0 +1,4 @@ +#define filter_width 8 +#define filter_height 8 +static char filter_bits[] = { + 0x00, 0x66, 0x66, 0x66, 0x00, 0x42, 0x66, 0x00}; diff --git a/GFX8/miner b/GFX8/miner new file mode 100644 index 0000000..10b1a81 --- /dev/null +++ b/GFX8/miner @@ -0,0 +1,4 @@ +#define miner_width 8 +#define miner_height 8 +static char miner_bits[] = { + 0xe3, 0xe3, 0xf7, 0xc1, 0xf7, 0xeb, 0xeb, 0xc9}; diff --git a/GFX8/oneup b/GFX8/oneup new file mode 100644 index 0000000..7257999 --- /dev/null +++ b/GFX8/oneup @@ -0,0 +1,4 @@ +#define oneup_width 8 +#define oneup_height 8 +static char oneup_bits[] = { + 0xc3, 0xbd, 0x6e, 0x66, 0x6e, 0x6e, 0xbd, 0xc3}; diff --git a/GFX8/rock b/GFX8/rock new file mode 100644 index 0000000..a692cff --- /dev/null +++ b/GFX8/rock @@ -0,0 +1,4 @@ +#define rock_width 8 +#define rock_height 8 +static char rock_bits[] = { + 0x81, 0x04, 0x20, 0x00, 0x42, 0x00, 0x08, 0x81}; diff --git a/GFX8/rockgen b/GFX8/rockgen new file mode 100644 index 0000000..2dd0d41 --- /dev/null +++ b/GFX8/rockgen @@ -0,0 +1,4 @@ +#define rockgen_width 8 +#define rockgen_height 8 +static char rockgen_bits[] = { + 0xff, 0x81, 0x99, 0xb5, 0xbd, 0x99, 0x81, 0xff}; diff --git a/GFX8/rockswitch b/GFX8/rockswitch new file mode 100644 index 0000000..cc04d49 --- /dev/null +++ b/GFX8/rockswitch @@ -0,0 +1,4 @@ +#define rockswitch_width 8 +#define rockswitch_height 8 +static char rockswitch_bits[] = { + 0x00, 0x7e, 0x7e, 0x6a, 0x56, 0x4e, 0x7e, 0x00}; diff --git a/GFX8/space b/GFX8/space new file mode 100644 index 0000000..c2efb9d --- /dev/null +++ b/GFX8/space @@ -0,0 +1,4 @@ +#define space_width 8 +#define space_height 8 +static char space_bits[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; diff --git a/GFX8/tuffwall b/GFX8/tuffwall new file mode 100644 index 0000000..0e2360a --- /dev/null +++ b/GFX8/tuffwall @@ -0,0 +1,4 @@ +#define tuffwall_width 8 +#define tuffwall_height 8 +static char tuffwall_bits[] = { + 0x00, 0x3c, 0x5a, 0x66, 0x66, 0x5a, 0x3c, 0x00}; diff --git a/GFX8/wall b/GFX8/wall new file mode 100644 index 0000000..54372ab --- /dev/null +++ b/GFX8/wall @@ -0,0 +1,4 @@ +#define wall_width 8 +#define wall_height 8 +static char wall_bits[] = { + 0xff, 0x89, 0xff, 0xa5, 0xa5, 0xff, 0x91, 0xff}; diff --git a/GFX8COL/amoeba b/GFX8COL/amoeba new file mode 100644 index 0000000..1910a5a Binary files /dev/null and b/GFX8COL/amoeba differ diff --git a/GFX8COL/butterfly b/GFX8COL/butterfly new file mode 100644 index 0000000..2ea6282 Binary files /dev/null and b/GFX8COL/butterfly differ diff --git a/GFX8COL/butterflygen b/GFX8COL/butterflygen new file mode 100644 index 0000000..b67a064 Binary files /dev/null and b/GFX8COL/butterflygen differ diff --git a/GFX8COL/chaser b/GFX8COL/chaser new file mode 100644 index 0000000..5022161 Binary files /dev/null and b/GFX8COL/chaser differ diff --git a/GFX8COL/chasergen b/GFX8COL/chasergen new file mode 100644 index 0000000..48a405a Binary files /dev/null and b/GFX8COL/chasergen differ diff --git a/GFX8COL/colormap b/GFX8COL/colormap new file mode 100644 index 0000000..3121add Binary files /dev/null and b/GFX8COL/colormap differ diff --git a/GFX8COL/diamond b/GFX8COL/diamond new file mode 100644 index 0000000..7b32f46 Binary files /dev/null and b/GFX8COL/diamond differ diff --git a/GFX8COL/earth b/GFX8COL/earth new file mode 100644 index 0000000..7c71df8 Binary files /dev/null and b/GFX8COL/earth differ diff --git a/GFX8COL/exit b/GFX8COL/exit new file mode 100644 index 0000000..682ef18 Binary files /dev/null and b/GFX8COL/exit differ diff --git a/GFX8COL/filter b/GFX8COL/filter new file mode 100644 index 0000000..0be00a4 Binary files /dev/null and b/GFX8COL/filter differ diff --git a/GFX8COL/miner b/GFX8COL/miner new file mode 100644 index 0000000..6e3f935 Binary files /dev/null and b/GFX8COL/miner differ diff --git a/GFX8COL/oneup b/GFX8COL/oneup new file mode 100644 index 0000000..aa2844d Binary files /dev/null and b/GFX8COL/oneup differ diff --git a/GFX8COL/rock b/GFX8COL/rock new file mode 100644 index 0000000..1412e74 Binary files /dev/null and b/GFX8COL/rock differ diff --git a/GFX8COL/rockgen b/GFX8COL/rockgen new file mode 100644 index 0000000..4ffe2ac Binary files /dev/null and b/GFX8COL/rockgen differ diff --git a/GFX8COL/rockswitch b/GFX8COL/rockswitch new file mode 100644 index 0000000..0f3120a Binary files /dev/null and b/GFX8COL/rockswitch differ diff --git a/GFX8COL/space b/GFX8COL/space new file mode 100644 index 0000000..1db6b03 Binary files /dev/null and b/GFX8COL/space differ diff --git a/GFX8COL/tuffwall b/GFX8COL/tuffwall new file mode 100644 index 0000000..4adf2ab Binary files /dev/null and b/GFX8COL/tuffwall differ diff --git a/GFX8COL/wall b/GFX8COL/wall new file mode 100644 index 0000000..6f71a03 Binary files /dev/null and b/GFX8COL/wall differ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8927c67 --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +# Makfile +# + +OPTIM=-g +OBJ=dash +CC=cc + +# Uncomment the following line if your system does not support usleep() +# +# USLEEP=-DNOUSLEEP + +# For Suns - edit if your system is awkward too +# +INCLUDE_PATH=-I/usr/openwin/include -I/usr/5include +LIB_PATH=-L/usr/openwin/lib -L/usr/5lib + +# Shouldn't need to edit below here +# +OPTS=$(OPTIM) $(USLEEP) + +ALL=dash spred + +all: $(ALL) + +$(OBJ): Xbit.o $(OBJ).o + $(CC) $(OPTS) $(LIB_PATH) -o $(OBJ) $(OBJ).o Xbit.o -lXext -lX11 -lm -lcurses -ltermcap + +Xbit.o: Xbit.c Xbit.h + $(CC) $(OPTS) $(INCLUDE_PATH) -c Xbit.c + +$(OBJ).o: Xbit.h $(OBJ).c + $(CC) $(OPTS) $(INCLUDE_PATH) -c $(OBJ).c + +spred: Xbit.o spred.o + $(CC) $(OPTS) $(LIB_PATH) -o spred spred.o Xbit.o -lXext -lX11 -lm + +spred.o: Xbit.h spred.c + $(CC) $(OPTS) $(INCLUDE_PATH) -c spred.c + +clean: + rm -f $(ALL) *.o core diff --git a/README b/README new file mode 100644 index 0000000..6eed935 --- /dev/null +++ b/README @@ -0,0 +1,143 @@ + DASH 1.2 + Preseneted by Noddybox 97 + +You should find in the archive : + +README This file +Makefile Simple bog standard make file for dash and spred. +dash.c Main code +Xbit.[ch] Library routines for easy X11 Xlib access +spred.c Simple sprite editor +CLEVELS/* Curses Level files. See CLEVELS/README for info. +XLEVELS/* X11 Level files. See XLEVELS/README for info. +lib/* Library files. Used for hiscore table +GFX8/* X11 Bitmap format files for use in 8x8 B&W version +GFX16/* X11 Bitmap format files for use in 16x16 B&W version +GFX8COL/* spred generated sprite files for use in 8x8 colour + version. +GFX16COL/* spred generated sprite files for use in 16x16 colour + version. + +Note that the reason the level files have been split into 2 directories (even +though currently in the distribution they have the same contents) is that the +curses mode does not give the same degree of control as the X11 version, so in +that mode certain levels could become very unplayable. + + +BUILD INSTRUCTIONS +------------------ + +Though written primarily on SunOS, this should work on most flavours of unix. +The only thing to look out for is to include the -DUSLEEP line in the makfile +if your system does not support the call 'usleep(int usec)'. If your system +doesn't support select() either, the implementation of LocalUsleep() using +poll() is left as an exercise for the reader :-) + +Try and ignore any incompatible pointer warnings. Unless they make it not +work... :-) + + +USAGE +----- + +dash [switches] +-s Use small version +-b Use black and white sprites +-d delay usleep() by delay for fast servers (eg, 90000 on Sun4) +-l lev start from level lev +-c use curses on tty (not yet perfect) +-h Dump hi-score table + + +X11 KEYS +-------- + +Escape Quit (from title page) +Cursor Keys Move +SHIFT + Cursor Keys Dig/Pick up/Push in direction +P Pause +Space Un-pause +Q Suicide (for if you get stuck in a rockfall!) + + +CURSES KEYS +----------- + +^C Quit (from title page) +Cursor Keys Move +A,D,W,X Dig/Pick up/Push in direction +P Pause +Space Un-pause +Q Suicide (for if you get stuck in a rockfall!) + + +INSTRUCTIONS +------------ + +The object of the game is to collect a certain number of gems (as indicated at +the top of the screen) and once collected make your way to the exit before the +time limit expires. + +As you dig around the level to collect gems, boulders will fall as you dig the +ground out from under them. Letting a boulder or gem fall on your head will +kill you. + +As well as these basic mechanics they are extra objects that are waiting to +cause you trouble... + +Butterflys These move around empty spaces, and will explode into a number + of gems if a boulder or gem is dropped on top of them. Note + that if they hit a wall, they like to turn to the right if + at all possible... This _could_ be handy to remember. + +Chasers They move slowly, but always towards you. Getting touched by + one of these ghosts is fatal! They explode into a number of + boulders if a boulder or gem falls on top of them. + +Ameoba This green blob grows outwards into any available space. If + sealed in (so it can grow no more) it will die and leave behind + gems. If it is allowed to grow too large it will also die, + leaving behind boulders! + +Filter This swallows falling boulders and gems, and if there is space + on the other side spits out a gem for a boulder and visa versa. + +Rock switch This switch swaps all the breakable walls and boulders around + in the level. + +Generators There are 3 flavours of generators. Rock generators will drop + out a rock downwards if there is room, while butterfly and + chaser generators produce the appropriate monster in all 4 + compass directions if there is room. + +Exit This is where you have to get too!!! Make sure you can still + get to it at the end of the level! + + +The line at the top of the screen contains : + +SCORE NO OF GEMS TO COLLECT NO OF GEMS GOT LIVES TIME LEFT + + +NOTES +----- + +dash switches off auto repeat to enhance the keyboard reading when run in X11 +mode. Auto repeat is re-enabled while the game is paused and when you exit +the game cleanly from the title page. + +If you kill it mid-game, auto repeat will still be off. It can be re-enabled +from the shell with 'xset r on'. + + + +Have Fun. + + + + +email ianc@noddybox.demon.co.uk +URL http://www.noddybox.demon.co.uk + + +Release 1.2 Wed Nov 12 11:21:21 GMT 1997 diff --git a/XLEVELS/-1 b/XLEVELS/-1 new file mode 100644 index 0000000..c1a3988 --- /dev/null +++ b/XLEVELS/-1 @@ -0,0 +1,16 @@ +Well Done +0,0 +0 +9999 +60,10 +R##########################################################E +#..........................................................# +#......*...*...................****........................# +#......*...*.****.*....*.......*...*..**..*..*.****........# +#......*...*.*....*....*.......*...*.*..*.**.*.*...........# +#......*.*.*.***..*....*.......*...*.*..*.*.**.***.........# +#......*.*.*.*....*....*.......*...*.*..*.*..*.*...........# +#.......*.*..****.****.****....****...**..*..*.****........# +#..........................................................# +############################################################ + diff --git a/XLEVELS/-2 b/XLEVELS/-2 new file mode 100644 index 0000000..87775c5 --- /dev/null +++ b/XLEVELS/-2 @@ -0,0 +1,16 @@ +Try again +0,0 +0 +9999 +60,10 +R##########################################################E +#..........................................................# +#......@@@@@...............@@@.............................# +#........@...@@@..@...@...@...@..@@@...@@..@@@.@..@........# +#........@...@..@..@.@....@...@.@.....@..@..@..@@.@........# +#........@...@@@....@.....@@@@@.@.@@..@@@@..@..@.@@........# +#........@...@..@...@.....@...@.@..@..@..@..@..@..@........# +#........@...@..@...@.....@...@..@@@..@..@.@@@.@..@........# +#..........................................................# +############################################################ + diff --git a/XLEVELS/1 b/XLEVELS/1 new file mode 100644 index 0000000..587ea04 --- /dev/null +++ b/XLEVELS/1 @@ -0,0 +1,15 @@ +Nice and easy +0,0 +10 +50 +39,9 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%.*........*..........................% +%. ......@....*......@................% +%. ....*......*......*......@@@@@@@@@.% +%. ........@........*................E% +%. ....*...*........*.......@.........% +%. ...................................% +%R.......@............................% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/10 b/XLEVELS/10 new file mode 100644 index 0000000..47e81f2 --- /dev/null +++ b/XLEVELS/10 @@ -0,0 +1,46 @@ +It's aMAZEing!!!! +0,0 +1 +200 +10,10 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R...............%%......................%%.............%%.............%%...............% +%%%%%%%%%%%%%%.%%%%%%%.%%%%%%%%%%%.%%%%%%%%%%%%%%%.%%%%%%%%%%%%%.%%%%%%%%%%%%%%.%%%%%%..% +%............................................%...........%%.............%%..............% +%%%%%.%%%%%.%%%%%%%%%%%%%%%%%.%%%%%%%%.%%%%%.%%%%.%%%%%%%%%%%%%%%%%.%%%%%%.%%%%%%%%%%%%%% +%%..%.%...%.%............%...........%.%.....%..................%....%.%.%..%...........% +%...........%.%%%%%%%%%%.%.%%%%%%%%%%%.%.%%%.%.%%%%%%%%%%%%%%%%%%.%%%%...%..%.%%%%%%%%%.% +%.%%%%%%%%%%%.%..........%.............%.%.%.%......%....%...%..............%.%.......%.% +%.............%.%.%%%.%%%%.%%%%.%%%%%%%%.%.%.%.%%%%%%..%...%...%...%..%%.%..%.%.%%%%%.%.% +%%%%.%%%%%%%....%.....%....%.................%......%..%%%%%%%%%%.%%%%%..%..%.%.%.....%.% +%..........%..%.%%%%%.%.%%%%.%%%%%%%%%%%%%%%%%.%%%%%%...........%..%....%%..%.%.%%%%%%%.% +%.%%%%%%.%.%..%...............%.....................%..%%%%%%%%.%.....%%.%..%.%.........% +%.%......%.%..%%%%%%%%%%%%%%%%%.%%%%%.%%%%%%%%%%%%.%%.........%.%%.%%%%..%..%.%.%%%%%%%%% +%.%.%%%%%%.%..%...%...%...%...%.%.....%..........%....%%%.%%%.%..........%..%.%.%.%...%%% +%...............%...%...%...%...%.%%.%%.%%%%%%%%.%.%%%%...%.%.%%%%.%%%%%%%..%.%.%.%.%...% +%.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%.%%....%...%....%.%....%%%.%...............%.%.%...%%%.% +%.%...................%.%%%.....%.%%%%%%%.%.%.%%%%.%.%%%%...%%%%%%%%%%%%%%%%%.%.%.%%%...% +%.%.%%%.%%%%%%%%.%.%%.%...%.%.%.%.........%.%...%.........%..............%..%.%.%.%.%.%%% +%.%.%.%.%......%.%..%.%%%.%%%.%.%%%%%%.%%%%.%%%.%.%%%%.%%%%.%%%%.%%%%.%%%%%.%.%.%.%.%...% +%.%.%.%.%.%%%%.%.%..%.........%.%.............%.%...........%......%........%.%.%.%.%%%.% +%.%.%.%.%.%..%.%.%%%%.%%%%%%%.%%%.%%%%%%%%%%%%%%%.%%%%%%%%%%%%%%%%%%%%%%%%%.%.%.%.%.%...% +%.%.%.%%%.%..%.%..%...%...%.....%.........................%...%...%...%...%.%.%.%.%.%.%%% +%.%.%.....%..%.%%.%.%%%.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%..%...%...%...%...%.%.%...% +%.%.%.%%%%%..%..%.%.%.%.%..............%...%...%...%...%.....%..%%%%%%%%%%%%%%..%.%.%%%.% +%.%.%.%......%%%%.%.%.%.%.%%%%%%%%%%%%.%.%...%...%...%...%.%.%...........%.%.%%...%.%...% +%.%.%.%.%%%%..%.%.%.%.%.%.%..........%.%.%%%%%%%%%%%%%%%%%%%.%%%..%%%%%.%%.%..%%..%.%.%%% +%.%.%.%....%%...%.%.%.%.%.%.%%%%%%%%.%.%...................%.%%..%%...%....%%..%%...%...% +%.%.%.%%%.%%%%%%%.%.%.%.%.%.%......%.%.%%%%%%%%%%%%%%%%%%%.%.%........%%%%..%%..%%..%%%.% +%.%%%.............%.%.%.%.%.%.%%%%.%.%.%...................%.%..%%%%%%%..%..%%%..%%.%...% +%.%...%%%.%%%%%%%%%.%...%.%.%.%..%.%.%.%.%%%%%%%%%%%%%%%%%%%.%..%...................%.%%% +%.%.%...%%%.........%.%.%.%.%.%.%%.%.%.%...................%.%..%%%%%%%%%%%%%%.%%%%.%...% +%.%.%.%.....%%%%%%..%.%.%.%.%.%....%.%.%%%%%%%%%%%%%%%%%%%.%.%......%...%%%..%....%%%%%.% +%.%.%.%%%%%%%....%.%%%%.%.%.%.%%%%%%.%.%...................%.%.%%%..%...%....%%%..%.....% +%.%.%..%......%%%%.%..%.%.%.%........%.%.%%%%%%%%%%%%%%%%%%%.%........%.%.%....%%%%.%%%.% +%.%.%%%%%%%%..%....%....%.%.%%%%%%%%%%.%..................%..%...%%%%.%......%....%.%...% +%.%.....%..%.%%.%%%%..%.%.%............%...%.....%.%.%%%%%%..%%%%%%%%%%%%%%%%%%%%.%.%.%.% +%.%.%%.....%....%.....%.%.%%%%%%%%%%%%%%...%.....%.%......%%...%...%...%...%..%E%%%.%.%.% +%.%.%..%%%%%..%.%%.%..%.%...%...%...%...%%%%.%%%%%.%.%%%%%%%.%.%.%.%.%.%.%.%..%*%%..%%%.% +%...%......%..%....%..%...%...%...%...%......%.....%.........%...%...%...%....%.........% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/11 b/XLEVELS/11 new file mode 100644 index 0000000..ae4e79d --- /dev/null +++ b/XLEVELS/11 @@ -0,0 +1,80 @@ +Look Out. +0,0 +150 +150 +1,1 +%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R % %##############################################################% %**************************************************************% % E% +% % %##############################################################% %**************************************************************% % % +% % %############################################################ % %**************************************************************% % % +% % %##################################################### % %**************************************************************% % % +% % %############################################## % % ################################################### % % % +% % %################################### % % % % % +% % %########################### % % % % % +% % %################### % % % % % +% % %########### % % % % % +% % %######## % % % % % +% % %#### % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % $ $ $ $ % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % % % +% %%%%%%%%%%%% %%%%%%%% %%%%%%%%%%%% % +% ! A% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/12 b/XLEVELS/12 new file mode 100644 index 0000000..1c7c3e0 --- /dev/null +++ b/XLEVELS/12 @@ -0,0 +1,36 @@ +A little bit of everything +0,0 +81 +150 +10,10 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %@@@@@% % +% .%@@@%. ######### % +% ..%@%.. #*******# % +% ..%@%.. B #*****# % +% ...@%.. #***# % +% ...@%.. #*# % +% ..%%%.. #*# % +% ........ ........#*# % +%....@@@@@........ ........... % +%@@@@@@@@@........ ......... % +%@@@@@@@@@........ .. % % +%@@@@@@@@@... .. % % +%%%%%%%%%%... .. % % +%*********%.. % % +%**********%.. %%%%%%%% R % +%***********%. % +%*******%%%**%.% % +%%%%%%%% ***%$%@ @ @ % +%............%@%............................. % +%............%.%............................. % +% %%%%%% % +% % E% % +% % @ % +% @@ %. % +% ....%%%%%%@ % +% .. % +%C ............ % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/2 b/XLEVELS/2 new file mode 100644 index 0000000..e8512a7 --- /dev/null +++ b/XLEVELS/2 @@ -0,0 +1,30 @@ +Chain Reactions +0,0 +60 +300 +60,24 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R ############# % +% ############# % +% ! ############# % +% ############# % +% % +% ################################ % +% . . % +% . B B B B B . % +% . . % +% . . % +% . B B B B B . % +% . . % +% . . % +% . . % +% . B B B B B . % +% . . % +% . . % +% . . % +% . B B B B B . % +% . . % +% . . % +% . . E% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/3 b/XLEVELS/3 new file mode 100644 index 0000000..bfbb4d4 --- /dev/null +++ b/XLEVELS/3 @@ -0,0 +1,36 @@ +Let's Rock +0,0 +15 +200 +70,30 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%C R % +%% %% +%.................................***###.............................% +%..............................***####...............................% +%..............................#####.................................% +%..............................@###..................................% +%....................%%.......@@@.#..................................% +%...................%%.......@*@.....................................% +%...................%%......@@@......................................% +%..................%%......@*@.......................................% +%..................%%.....@@@........................................% +%.................%%%%...@*@.........................................% +%.................%%%%%%@@@..........................................% +%................%%%%%%@@@...........................................% +%...............%%%%%*%%@%....%......................................% +%..............%%%%%%%*%%%%..%%......................................% +%............%%%%%%*%%%*%%%%%%.......................................% +%...........%%%%%%%%*%%%%%%%%........................................% +%..........%%%%%%*%%%*%%%%%..........................................% +%..........%%%%%%%*%%%%%%%...........................................% +%...........%%%%%%%*%%%%%............................................% +%...........%%%%%%%%%%%%.............................................% +%............%%%%%%%%@%%.............................................% +%.............%%%%%%%%%..............................................% +%..............%%%%%@%%..............................................% +%...............%%%%%%...............................................% +%.................%%%..............@..........................%@@@@@@% +% C* C*****E% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/4 b/XLEVELS/4 new file mode 100644 index 0000000..caab3bd --- /dev/null +++ b/XLEVELS/4 @@ -0,0 +1,38 @@ +The Plug Hole... +0,0 +0 +255 +70,32 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R @@@ #*********# #*******E% +%########### #*******# #*******% +%*********## #*****# #******% +%********## #***# #*****% +%*******## #*# #@@@@% +%******## C #*# #@@@% +%*****## #*# #@@% +%****## #*# #.% +%***## #*# # % +%**## #*# # % +%*## #*# # % +%*# ... # % +%*# ## # # % +%*# # # # % +%*# B # ## # % +%*# # # # % +%*# ## # # % +%*# # # # % +%*# # ## # % +%*# # # # % +%*# B C ## # # % +%*# # # # % +%*# #&## # % +%*# # # # % +%*# ##### ## # % +%*# ##*****## # # % +%*# #*******# # ## % +%*# #**@@@**# # # % +%*# #*******# ## # % +%* .*******. ## % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/5 b/XLEVELS/5 new file mode 100644 index 0000000..832772a --- /dev/null +++ b/XLEVELS/5 @@ -0,0 +1,27 @@ +It's all in the timing... +0,0 +30 +300 +200,94 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%E.....................................R% +%.......................................% +%.......................................% +%.......................................% +%.......................................% +%.........********************..........% +%.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.% +%.......................................% +% % +% % +% % +% % +% % +% % +% % +% % +% % +% A % +% AAA % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/6 b/XLEVELS/6 new file mode 100644 index 0000000..0917b84 --- /dev/null +++ b/XLEVELS/6 @@ -0,0 +1,18 @@ +Run Like Hell!!! +0,0 +1 +35 +0,0 +%%%%%%%%%%%%%%%%%%%% +% % R % % % E% +% % % % % % % % % @% +% % % % % % % % %..% +% % % % % % % % %% % +% % % % % % % % %% % +% % % % % % % % %% % +% % % % % % % % %% % +% % % % % % % % %% % +% % % % % % % % %% % +%B% % % % % +%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/7 b/XLEVELS/7 new file mode 100644 index 0000000..3c0c5e8 --- /dev/null +++ b/XLEVELS/7 @@ -0,0 +1,24 @@ +Safe Cracker +0,0 +45 +150 +20,70 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R.........................................................% +%..........................................................% +%.......@..........@ ...................................% % +%...##### ......%%%%% ...................................% % +%...# @ # ......%***# ...........%%%%....%..%.%..%.......% % +%...# # ......%***# ...........%@@%....%..%.%..%.......% % +%...# # ......%***% ...........%@@%....%%%%.%..%.......% % +%...# A # ....B.%***% ...........%..%....%..%.%..........% % +%...# # .... .%***% ...........%..%....%..%.%..%.......% % +%...# # .... .%***% ...........%..%....................% % +%...# # .... .%***% ..............%....................% % +%...##### .%%%%%B...........%$$%....................% % +%.................... ...........%..%....................%C% +%.................... ..............%....................% % +%.................... ...........%%%%....................% % +%.................... ...................................%E% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/8 b/XLEVELS/8 new file mode 100644 index 0000000..a76225d --- /dev/null +++ b/XLEVELS/8 @@ -0,0 +1,25 @@ +Raindrops +0,0 +100 +200 +0,0 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R %rrrrrrrrrrrrrrrrrr% rrrrr % +% % % % +% % % % +% % b b b % % +% % % % +% % % % +% % % % % +% % % % % % +% % % % % % +% % % % % % % % +% % % % % % % % +% % % % % % +% % % % % % % % % % % +% % % % +% % +% % +% E% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/9 b/XLEVELS/9 new file mode 100644 index 0000000..01a959e --- /dev/null +++ b/XLEVELS/9 @@ -0,0 +1,61 @@ +Around the bend.. +0,0 +125 +200 +10,10 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R %% %*******%........................................%*******% +%%%%%%%%%%%%%%%%%%%%%%% %% %%%%%%%%%% %*******%........................................%*******% +% % %% % %*******%........................................%*******% +%%%%%%%%%%%%%%%%%%%%%%% %% % %%%%%%%%%%%%%%..%%........................................%%%%%..%% +% %% % %*******....%C %..................................... ....% +% %%%%%%%%%%%%%%%%%%%%%%%%% % %********...% ...................................... % +% % %%%%%%%%%% %%%%%%..................................... % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % +%.................................................................................................% +%.................................................................................................% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % + % C % + % % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % +%@@@@@@@@............ ................. ...................... ...................% +%@@@@@@@@............ ................. ...................... ...................% +%@@@@@@@@............ ................. ...................... ...................% +%.@@@@@@@............ ................. ...................... ...................% +%..@@@@@.............C .................C ......................C ...........********% +%...@@@..%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%........% %%%%%%%%%%%%%%%%%% +% % %E...............% +%@@@@@. % %%%%%%%%%%..%%%%%% +%.@@@@. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%..%%%%%%%%%%%% +%..@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..........% +%...@@. ..............................................................................% +%....@. ......***.........***.............***.............***...........***...........% +%...... ..............................................................................% +% ..%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%% ..% + % ...... ..% + %******..... ..% + %%%%%%%%%%%%%%%....% + %....% + %....% +%%%%%%%%%%%%%%%%%%%%%%%....%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%**********************....***************************% +%***********************..****************************% +%*****************************************************% +%**..................................................*% +%**. .*% +%**. .*% +%**. .*% +%**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*% +%**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*% +%**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*% +%**..................................................*% +%**..................................................*% +%**. .*% +%**. .*% +%**. .*% +%**..................................................*% +%&****************************************************% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/DEBUGLEV b/XLEVELS/DEBUGLEV new file mode 100644 index 0000000..7112171 --- /dev/null +++ b/XLEVELS/DEBUGLEV @@ -0,0 +1,35 @@ +DEBUG LEVEL +0,0 +10 +50 +39,29 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% r #rrrrrr#rrrrrr# E% +% # # # % +% # # # % +% # # # % +% # # # % +% # # # % +% #$# # % +% # # # % +% # # # % +% # # # % +% # # # % +% # # # % +% # # # % +% % +% # # # % +% # # # % +% # # # % +% # # # % +% # # # % +% # # # % +% # # # % +% # # # % +% # # # % +% # # # % +% # # # % +% #$#$# % +%R ##### % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/NO b/XLEVELS/NO new file mode 100644 index 0000000..48082f7 --- /dev/null +++ b/XLEVELS/NO @@ -0,0 +1 @@ +12 diff --git a/XLEVELS/README b/XLEVELS/README new file mode 100644 index 0000000..1e91140 --- /dev/null +++ b/XLEVELS/README @@ -0,0 +1,50 @@ +Files +----- + +These files must exist here to allow dash to run: + +NO - The number of levels in the directory. Just an ASCII file with + the number in it. +-1 - A special level used for successfully completing a level +-2 - A special level used for failing to complete a level +1,2,3.. - The level files themselves. + + +Map Design +---------- + +ENSURE THERE IS UNBREAKABLE WALL ALL AROUND THE LEVEL!!!!!! + +Title +Start screen position (x,y) +No of diamonds (0 == All) +Timer (1 tick == 10 game cylces) +Max size of amoeba,Chance of amoeba move (as %) [must be present if no amoeba] + + + + +Map characters :- + +R - Miner +E - Exit +% - Unbreakable Wall +# - Explodable Wall +. - Earth +@ - Rock +* - Gem +B - Butterfly +C - Chaser +! - Swapper (swaps rocks and breakable walls around) +& - Extra life +$ - Indestructible Filter (changes falling rocks to diamonds and + visa versa if there is a space on the other side). +A - Ameoba (fills surrounding spaces and earth and changes to + rocks or diamonds depending on whether it runs out of room or + gets contained first. Note : Multiple glyphs are taken to be + part of the same amoeba - even if space seperates them) +r - Indestructible Rock generator - drops rocks out of it +b - Indestructible Butterfly generator - generates butterflys in + 4 compass directions if there is space +c - Indestructible Butterfly generator - generates butterflys in + 4 compass directions if there is space diff --git a/XLEVELS/TEST b/XLEVELS/TEST new file mode 100644 index 0000000..33a72ce --- /dev/null +++ b/XLEVELS/TEST @@ -0,0 +1,33 @@ +Test New Features +0,0 +0 +-1 +500,0 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R...................................................................% +%......@.............................................................% +%....... ............................................................% +%....... ............................................................% +%....... ............................................................% +%....... .@@@@@@@@...................................................% +%....... ............................................................% +%....... .*....@.....................................................% +%......$$$$$$$$$$$$..................................................% +%....... .. ...................................................% +%....... .. ...................................................% +%....................................................................% +%......$$$$$$$$$$$$.....@@@@@@@@.....................................% +%...... ....@... ....@....................................% +%...... ...@..........@...................................% +%......$$$$$$$$$$$$...@.. @ ...@...................................% +%...... .. .. ...@...................................% +%...... ...@.. AA ...@...................................% +%......$$$$$$$$$$$$...@.. AA . .@...................................% +%.....................@......*...@...................................% +%......................@........@....................................% +%.......................@@@@@@@@.....................................% +%....................................................................% +%....................................................................% +%............................................*......................E% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/XLEVELS/template b/XLEVELS/template new file mode 100644 index 0000000..ae5654f --- /dev/null +++ b/XLEVELS/template @@ -0,0 +1,20 @@ +title +screen_x,screen_y +diamonds +timer +max_ameoba_size,ameoba_move_chance +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%R.........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%..........................................................% +%.........................................................E% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/Xbit.c b/Xbit.c new file mode 100644 index 0000000..83fdb3c --- /dev/null +++ b/Xbit.c @@ -0,0 +1,1877 @@ +/* + + Xbit - Simple xlib interface + + Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------- + + This is a bit messy as it based on very old K&R code. + +*/ +static char rcs_id[]="$Id: Xbit.c 11 2006-05-02 19:02:49Z ianc $"; + +#include +#include +#include +#include + +#include + +/* #include */ +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "Xbit.h" + +#include "icon.bmp" + +#define WARN(x) fprintf(stderr,"%s(%d) : Warning:%s\n",__FILE__,__LINE__,x); +#define WARN1(x,y) fprintf(stderr,"%s(%d) : Warning:%s %s\n",__FILE__,__LINE__,x,y); + + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#define ABS(x) ((x) < 0 ? (-(x)) : (x)) + + +/* GLOBALS +*/ + +#define MAXPM 256 + +typedef struct WEntry +{ + Window w; + Pixmap pm[MAXPM]; + int used_MIT_SHM; + XShmSegmentInfo + shm_info; + int pmi; + int buffer; + int use_pm; + int multi; + int multino; + ulong multicls; + GC gc; + int ox; + int oy; + int ww; + int wh; + int pw; + int ph; + int func; + int lastuserfunc; + ulong lastfg; + int spline_thresh; + struct WEntry *next; +} WEntry; + + +static WEntry *whead=NULL; +static WEntry *wtail=NULL; + +static WEntry *current=NULL; + +static WEntry *stack[128]; +static int sttop; + +static Display *display=NULL; +static XVisualInfo vinfo; +static int screen; + +static int use_shm=True; + +static ulong xb_black; +static ulong xb_white; + +/* Buffer for Xprintf() and XIprintf() +*/ +static char prbuf[1024]; + +/* Definitions for XImage 8x8 charset +*/ +#include "fontset.h" + + +/* Put globals +*/ +static int no_plots; +static XPoint points[MAX_PUTPLOTS]; + + +/* Set write mode +*/ +#define WM(c) do {if ((c)!=current->func) { \ + XSetFunction(display,current->gc,c); \ + current->func=c; } } while(0) + + +/* Set foreground funcrion +*/ +#define FG(c) do {if ((c)!=current->lastfg) { \ + XSetForeground(display,current->gc,c); \ + current->lastfg=c; } } while(0) + + +/* Stack current windows +*/ +#define PUSHW do {stack[sttop++]=current;} while(0) +#define POPW do {current=stack[--sttop];} while(0) + + +/* ------------- FUNCTIONS ------------- */ + +static void CreateWEntry(Window w, GC g, int ww, int wh) +{ + WEntry *new; + + if (!(new=malloc(sizeof(WEntry)))) + { + fprintf(stderr,"%s(%d) : FATAL:%s\n",__FILE__,__LINE__, + "Couldn't malloc() WEntry"); + exit(1); + } + + if (!whead) + { + whead=new; + wtail=new; + } + else + { + wtail->next=new; + wtail=new; + } + + new->next=NULL; + + new->w=w; + new->gc=g; + + new->pm[0]=0; + new->pm[1]=0; + new->pmi=0; + new->buffer=True; + new->use_pm=True; + new->multi=False; + new->ox=0; + new->oy=0; + new->ww=ww; + new->wh=wh; + new->pw=0; + new->ph=0; + new->func=GXcopy; + new->lastuserfunc=GXcopy; + new->lastfg=-1; + new->spline_thresh=1; + new->used_MIT_SHM=False; +} + + +XImage *CreateXImage(void) +{ + XImage *img; + char *p; + + if (!use_shm) + { + switch(vinfo.depth) + { + case 8: + p=malloc(current->pw*current->ph*1); + break; + case 16: + p=malloc(current->pw*current->ph*2); + break; + default: + p=malloc(current->pw*current->ph*4); + break; + } + + if (!p) + { + fprintf(stderr,"%s(%d) : FATAL:%s\n",__FILE__,__LINE__, + "Couldn't malloc() XImage data"); + exit(1); + } + + img=XCreateImage + (display, + vinfo.visual, + vinfo.depth, /* Image depth */ + ZPixmap, /* Image format */ + 0, /* Offset */ + p, /* Data */ + current->pw, /* Width */ + current->ph, /* Height */ + 8, /* Bitmap pad */ + 0); + } + else + { + img=XShmCreateImage(display, + vinfo.visual, + vinfo.depth, + ZPixmap, + NULL, + &(current->shm_info), + current->pw, + current->ph); + + if (!img) + return(NULL); + + current->used_MIT_SHM=True; + + /* Get shared memory for image + */ + current->shm_info.shmid=shmget(IPC_PRIVATE, + img->bytes_per_line*img->height, + IPC_CREAT|0777); + + if (current->shm_info.shmid<0) + { + WARN("Couldn't get MITSHM mem"); + exit(1); + } + + current->shm_info.shmaddr=shmat(current->shm_info.shmid,0,0); + img->data=current->shm_info.shmaddr; + + current->shm_info.readOnly=False; + + /* Try and attached shared memory + */ + if (!XShmAttach(display,&(current->shm_info))) + { + WARN("Failed to attach MITSHM block"); + exit(1); + } + + XSync(display,False); + } + + ClsXImage(img); + return img; +} + + +void ClsXImage(XImage *img) +{ + memset(img->data,0,img->bytes_per_line*img->height); +} + + +void DestroyXImage(XImage *img) +{ + if (current->used_MIT_SHM) + { + XShmDetach(display,&(current->shm_info)); + + if (current->shm_info.shmaddr) + shmdt(current->shm_info.shmaddr); + + if (current->shm_info.shmid>=0) + shmctl(current->shm_info.shmid,IPC_RMID,0); + + current->used_MIT_SHM=False; + } + + XDestroyImage(img); + XSync(display,False); +} + + +void SetCurrentWin(Window w) +{ + WEntry *l; + + l=whead; + + while(l) + { + if (l->w==w) + { + current=l; + return; + } + + l=l->next; + } + + WARN("Asked for non-existant window"); +} + + +int GetVisualDepth(void) +{ + return vinfo.depth; +} + + +Window OpenWin (int argc, + char **argv, + char *title, + int wx, int wy, int ww, int wh, + int pw, int ph, + unsigned long ev, + XSizeHints *hints, + ulong *black, ulong *white) +{ + Window window; + GC gc; + char *display_name=NULL; + Pixmap icon_pixmap; + int i,j,k; + + if (!display) + { + if ((display=XOpenDisplay(display_name))==NULL) + { + fprintf(stderr,"%s: can't connect to %s\n", + argv[0], XDisplayName(display_name)); + exit(-1); + } + + /* Try and find shared memory extension + */ + use_shm=XQueryExtension(display,"MIT-SHM",&i,&j,&k); + + /* Find a nice 8-bit visual for us to use... + */ + if (!XMatchVisualInfo(display,DefaultScreen(display),8, + PseudoColor,&vinfo)) + if (!XMatchVisualInfo(display,DefaultScreen(display),16, + TrueColor,&vinfo)) + if (!XMatchVisualInfo(display,DefaultScreen(display),24, + TrueColor,&vinfo)) + if (!XMatchVisualInfo(display,DefaultScreen(display),32, + TrueColor,&vinfo)) + { + WARN("no visual found!\n"); + exit(1); + } + } + + screen=DefaultScreen(display); + + xb_black=BlackPixel(display,screen); + xb_white=WhitePixel(display,screen); + *black=xb_black; + *white=xb_white; + + window=XCreateWindow(display, + RootWindow(display,screen), + wx,wy,ww,wh,1, + vinfo.depth, + InputOutput, + vinfo.visual, + 0,NULL); + + icon_pixmap=XCreateBitmapFromData( + display, + window, + icon_bits, + icon_width,icon_height); + + XSetStandardProperties( + display, + window, + title, + title, + icon_pixmap, + argv,argc, + hints); + + XSelectInput (display,window,ev); + + gc=XCreateGC(display,window,0,NULL); + + XSetForeground(display,gc,*black); + XSetBackground(display,gc,*white); + XSetPlaneMask(display,gc,AllPlanes); + XSetGraphicsExposures(display,gc,False); + + XMapWindow (display,window); + + CreateWEntry(window,gc,ww,wh); + SetCurrentWin(window); + + Resize(pw,ph); + + return window; +} + + +Window OpenRootWin (ulong *black,ulong *white,int *w,int *h,int pw,int ph) +{ + Window window; + GC gc; + char *display_name=NULL; + int i,j,k; + + if (!display) + { + int depth; + + if ((display=XOpenDisplay(display_name))==NULL) + { + fprintf(stderr,"can't connect to %s\n",XDisplayName(display_name)); + exit(-1); + } + + screen=DefaultScreen(display); + + depth=DefaultDepth(display,screen); + + /* Try and find shared memory extension + */ + use_shm=XQueryExtension(display,"MIT-SHM",&i,&j,&k); + + /* Find a visual for us to use... + */ + if (!XMatchVisualInfo(display,DefaultScreen(display),depth, + depth==8 ? PseudoColor:TrueColor,&vinfo)) + { + WARN("no visual to match the root window!"); + exit(1); + } + } + + xb_black=BlackPixel(display,screen); + xb_white=WhitePixel(display,screen); + *black=xb_black; + *white=xb_white; + + window=RootWindow(display,screen); + + gc=XCreateGC(display,window,0,NULL); + + XSetForeground(display,gc,*black); + XSetBackground(display,gc,*white); + XSetPlaneMask(display,gc,AllPlanes); + + XMapWindow (display,window); + + *w=DisplayWidth(display,screen); + *h=DisplayHeight(display,screen); + + CreateWEntry(window,gc,*w,*h); + SetCurrentWin(window); + + Resize(pw,ph); + + return window; +} + + +XFontStruct *XUseFont(const char *n) +{ + XFontStruct *ft; + + if (ft=XLoadQueryFont(display,n)) + XSetFont(display,current->gc,ft->fid); + else + WARN1("couldn't load font:",n); + + return ft; +} + + +void XUseCursor(const char *bm, const char *mask, XColor fg, XColor bg) +{ + Pixmap b,m; + Cursor curs; + int bmw,bmh,bmx,bmy; + int maskw,maskh,maskx,masky; + + if (XReadBitmapFile(display,current->w,bm,&bmw,&bmh,&b,&bmx,&bmy) + ==BitmapOpenFailed) + { + WARN1("Couldn't read in cursor file:",bm); + return; + } + + if (XReadBitmapFile(display,current->w,mask,&maskw,&maskh,&m,&maskx,&masky) + ==BitmapOpenFailed) + { + WARN1("Couldn't read in mask file:",bm); + return; + } + + curs=XCreatePixmapCursor(display,b,m,&fg,&bg,bmx,bmy); + + XDefineCursor(display,current->w,curs); + + XFreePixmap(display,b); + XFreePixmap(display,m); +} + + +void LoadBitmap(const char *fn,int x,int y, int resize) +{ + Pixmap bm; + int w,h,hx,hy; + int cw,ch; + + if (!current->use_pm) + { + WARN("Need pixmaps to load in bitmap"); + } + + if (XReadBitmapFile(display,current->w,fn,&w,&h,&bm,&hx,&hy) + ==BitmapOpenFailed) + { + WARN1("Couldn't read in bitmap file:",fn); + return; + } + + if ((w!=current->pw)||(h!=current->ph)) + { + if (resize) + { + Resize(w+x,h+y); + cw=w; + ch=h; + } + else + { + cw=current->pw-x; + ch=current->ph-y; + } + } + + XCopyPlane(display,bm,current->pm[current->pmi], + current->gc,0,0,cw,ch,x,y,1L); + + XFreePixmap(display,bm); +} + + +Pixmap GetBitmap(const char *fn, int *w, int *h, int *hx, int *hy) +{ + Pixmap bm,ret; + + if (XReadBitmapFile(display,current->w,fn,w,h,&bm,hx,hy) + ==BitmapOpenFailed) + { + WARN1("Couldn't read in bitmap file:",fn); + return(0); + } + + ret=XCreatePixmap(display,current->w,*w,*h,vinfo.depth); + + XCopyPlane(display,bm,ret,current->gc,0,0,*w,*h,0,0,1L); + + XFreePixmap(display,bm); + + return ret; +} + + +void DrawXImage(XImage *img) +{ + if (use_shm) + XShmPutImage (display, + current->pm[0], + current->gc, + img, + 0,0, + 0,0, + current->pw,current->ph, + False); + else + XPutImage (display, + current->pm[0], + current->gc, + img, + 0,0, + 0,0, + current->pw,current->ph); +} + + +void Resize(int w,int h) +{ + int f; + + if (www) + w=current->ww; + + if (hwh) + h=current->wh; + + current->pw=w; + current->ph=h; + + if (!current->use_pm) + return; + + if (current->multi) + { + WM(GXcopy); + FG(current->multicls); + for(f=0;fmultino;f++) + { + XFreePixmap(display,current->pm[f]); + current->pm[f]=XCreatePixmap(display,current->w,w,h,vinfo.depth); + XFillRectangle(display,current->pm[f], + current->gc,0,0,current->pw,current->ph); + } + WM(current->lastuserfunc); + return; + } + + if (current->pm[0]) + { + XFreePixmap(display,current->pm[0]); + + if (current->buffer) + XFreePixmap(display,current->pm[1]); + } + + current->pmi=0; + + current->pm[0]=XCreatePixmap(display,current->w,w,h,vinfo.depth); + + if (current->buffer) + current->pm[1]=XCreatePixmap(display,current->w,w,h,vinfo.depth); +} + + +void Redraw(int x,int y) +{ + if ((x+current->ww)>current->pw) + x=current->pw-current->ww; + + if ((y+current->wh)>current->ph) + y=current->ph-current->wh; + + current->ox=x; + current->oy=y; + + if (!current->use_pm) + { + XSync(display,False); + return; + } + + WM(GXcopy); + + if (current->buffer) + { + XCopyArea(display,current->pm[current->pmi^1],current->w, + current->gc,x,y,current->ww,current->wh,0,0); + XSync(display,False); + } + else + { + XCopyArea(display,current->pm[current->pmi],current->w, + current->gc,x,y,current->ww,current->wh,0,0); + XSync(display,False); + } + + WM(current->lastuserfunc); +} + + +Pixmap GetCurrentPixmap(void) + +{ + if (!current->use_pm) + return(0); + + return current->pm[current->pmi]; +} + +GC GetCurrentGC(void) + +{ + return current->gc; +} + + +void DisableDoubleBuffer(void) + +{ + current->pmi=0; + XFreePixmap(display,current->pm[1]); + current->buffer=False; +} + + +void DisablePixmap(void) + +{ + current->pmi=0; + + if (current->use_pm) + XFreePixmap(display,current->pm[0]); + + if (current->buffer) + XFreePixmap(display,current->pm[1]); + + current->buffer=False; + current->use_pm=False; + current->pm[0]=current->w; +} + + +void DisableShm(void) +{ + use_shm=False; +} + + +void EnableBuffers(int no, ulong clscol) +{ + int f; + + current->pmi=0; + + if (current->use_pm) + XFreePixmap(display,current->pm[0]); + + if (current->buffer) + XFreePixmap(display,current->pm[1]); + + current->buffer=False; + current->use_pm=True; + current->multi=True; + + if (no>MAXPM) + current->multino=MAXPM; + else + current->multino=no; + + current->multicls=clscol; + + WM(GXcopy); + FG(current->multicls); + for(f=0;fmultino;f++) + { + current->pm[f]=XCreatePixmap(display,current->w,current->ww,current->wh, + vinfo.depth); + XFillRectangle(display,current->pm[f], + current->gc,0,0,current->pw,current->ph); + } + + WM(current->lastuserfunc); +} + + +void Pageflip(void) +{ + if (current->buffer) + current->pmi=current->pmi^1; + + if (current->multi) + if ((++current->pmi)>=current->multino) + current->pmi=0; +} + + +void SetAsBackdrop(void) +{ + XSetWindowBackgroundPixmap (display, current->w, current->pm[current->pmi]); + XSync(display,False); +} + + +void XUseFunction(int f) +{ + WM(f); + current->lastuserfunc=f; +} + + +void XSetLineStyle(unsigned int w, int ls, int cs, int js) +{ + XSetLineAttributes(display,current->gc,w,ls,cs,js); +} + + +void XCls(ulong c) +{ + if (current->use_pm) + { + WM(GXcopy); + FG(c); + XFillRectangle(display,current->pm[current->pmi], + current->gc,0,0,current->pw,current->ph); + WM(current->lastuserfunc); + } + else + { + /* + XSetBackground(display,current->gc,c); + XClearWindow(display,current->pm[0]); + */ + WM(GXcopy); + FG(c); + XFillRectangle(display,current->pm[current->pmi], + current->gc,0,0,current->pw,current->ph); + WM(current->lastuserfunc); + } +} + + +void XPlot(int x,int y, ulong c) +{ + FG(c); + XDrawPoint(display,current->pm[current->pmi],current->gc,x,y); +} + + +void XLine(int x1,int y1,int x2,int y2, ulong c) +{ + FG(c); + XDrawLine(display,current->pm[current->pmi],current->gc,x1,y1,x2,y2); +} + + +void SetSplineThresh(int t) +{ + current->spline_thresh=t; +} + + +static void XDoSpline(int x0,int y0,int x1,int y1,int x2,int y2,ulong c) +{ + int xa, ya, xb, yb, xc, yc, xp, yp; + + if ((x0==x1==x2)&&(y0==y1==y2)) + { + XPlot(x0,y0,c); + return; + } + + if ((x0==x1)&&(y0==y1)) + { + XLine(x1,y1,x2,y2,c); + return; + } + + if ((x0==x2)&&(y0==y2)) + { + XLine(x0,y0,x1,y1,c); + return; + } + + if ((x1==x2)&&(y1==y2)) + { + XLine(x0,y0,x2,y2,c); + return; + } + + xa = ( x0 + x1 ) / 2; + ya = ( y0 + y1 ) / 2; + xc = ( x1 + x2 ) / 2; + yc = ( y1 + y2 ) / 2; + xb = ( xa + xc ) / 2; + yb = ( ya + yc ) / 2; + + xp = ( x0 + xb ) / 2; + yp = ( y0 + yb ) / 2; + + if ( ABS( xa - xp ) + ABS( ya - yp ) > current->spline_thresh ) + XDoSpline(x0,y0,xa,ya,xb,yb,c); + else + XDrawLine(display,current->pm[current->pmi],current->gc,x0,y0,xb,yb); + + xp = ( x2 + xb ) / 2; + yp = ( y2 + yb ) / 2; + if ( ABS( xc - xp ) + ABS( yc - yp ) > current->spline_thresh ) + XDoSpline(xb,yb,xc,yc,x2,y2,c); + else + XDrawLine(display,current->pm[current->pmi],current->gc,xb,yb,x2,y2); +} + + +void XSpline(int x1,int y1,int x2,int y2,int x3,int y3,ulong c) +{ + FG(c); + + if ((x1==x2==x3)&&(y1==y2==y3)) + { + XPlot(x1,y1,c); + return; + } + + if ((x1==x2)&&(y1==y2)) + { + XLine(x2,y2,x3,y3,c); + return; + } + + if ((x1==x3)&&(y1==y3)) + { + XLine(x1,y1,x2,y2,c); + return; + } + + if ((x2==x3)&&(y2==y3)) + { + XLine(x1,y1,x3,y3,c); + return; + } + + XDoSpline(x1,y1,x2,y2,x3,y3,c); +} + + +void XPrint(int x,int y, const char *s, ulong c) + +{ + FG(c); + XDrawString(display,current->pm[current->pmi],current->gc,x,y,s,strlen(s)); +} + + +void Xprintf(int x, int y, ulong colour, const char *fmt, ...) +{ + va_list va; + + va_start(va,fmt); + vsprintf(prbuf,fmt,va); + va_end(va); + + FG(colour); + XDrawString(display,current->pm[current->pmi],current->gc, + x,y,prbuf,strlen(prbuf)); +} + + +void XISetFont(XImageFont n) +{ + switch(n) + { + case XI_FONT1: + xifont=xifont1; + break; + case XI_FONT2: + xifont=xifont2; + break; + } +} + + +static void XIPlot(XImage *img,int x,int y, ulong c) +{ + if ((y<0)||(y>=img->height)||(x<0)||(x>=img->width)) + return; + + XPutPixel(img,x,y,c); +} + + +void XIprintf(XImage *img, int x, int y, int sx, int sy, ulong col, + const char *fmt, ...) +{ + int f,px,py,psx,psy,ch; + char *data; + va_list arg; + + va_start(arg,fmt); + vsprintf(prbuf,fmt,arg); + va_end(arg); + + if ((sx==1)&&(sy==1)) + { + for(f=0;f=0)&&(y+pyheight)) + for(px=0;px=0)&&(x+pxwidth)) + if (xifont[ch].data[py][px]) + XPutPixel(img,x+px,y+py,col); + + x+=XIFONTW; + } + } + else + { + for(f=0;fpm[current->pmi],current->gc,x,y,w,h); +} + + +void XFillBox(int x,int y,int w,int h,ulong c) +{ + FG(c); + XFillRectangle(display,current->pm[current->pmi],current->gc,x,y,w,h); +} + + +void XCircle(int x,int y,int rx,int ry,int a1,int a2,ulong c) +{ + FG(c); + XDrawArc(display,current->pm[current->pmi],current->gc,x,y,rx,ry,a1,a2); +} + + +void XFillCircle(int x,int y,int rx,int ry,int a1,int a2,ulong c) +{ + FG(c); + XFillArc(display,current->pm[current->pmi],current->gc,x,y,rx,ry,a1,a2); +} + + +void XStartPlots(void) +{ + no_plots=0; +} + + +void XAddPlot(int x,int y) +{ + points[no_plots].x=x; + points[no_plots].y=y; + + no_plots++; +} + + +void XPutPlots(ulong c) +{ + FG(c); + XDrawPoints(display,current->pm[current->pmi],current->gc, + points,no_plots,CoordModeOrigin); +} + + +void XPutPlotsAsLines(ulong c) +{ + FG(c); + XDrawLines(display,current->pm[current->pmi],current->gc, + points,no_plots,CoordModeOrigin); +} + + +void XFillPoly(XPoint *xp,int n,int shape,ulong c) +{ + FG(c); + XFillPolygon(display,current->pm[current->pmi],current->gc,xp,n, + shape,CoordModeOrigin); +} + + +void XScroll(int dx,int dy) +{ + int destx,desty,srcx,srcy; + int w,h; + + if (dx>=0) + { + destx=0; + srcx=dx; + w=current->pw-dx; + } + + if (dx<0) + { + destx=-(dx); + srcx=0; + w=current->pw+dx; + } + + if (dy>=0) + { + desty=0; + srcy=dy; + h=current->ph-dy; + } + + if (dy<0) + { + desty=-(dy); + srcy=0; + h=current->ph+dy; + } + + WM(GXcopy); + XCopyArea(display,current->pm[current->pmi],current->pm[current->pmi], + current->gc,srcx,srcy,current->pw-dx,current->ph,destx,desty); + WM(current->lastuserfunc); +} + + +void XCopy(int sx,int sy,int w,int h,int dx,int dy) +{ + WM(GXcopy); + XCopyArea(display,current->pm[current->pmi],current->pm[current->pmi], + current->gc,sx,sy,current->pw,current->ph,dx,dy); + WM(current->lastuserfunc); +} + + +void XPut(Pixmap spm,int sx,int sy,int w,int h,int dx,int dy) +{ + WM(GXcopy); + XCopyArea(display,spm,current->pm[current->pmi], + current->gc,sx,sy,w,h,dx,dy); + WM(current->lastuserfunc); +} + + +void XGet(Pixmap dpm,int sx,int sy,int w,int h,int dx,int dy) +{ + WM(GXcopy); + XCopyArea(display,dpm,current->pm[current->pmi], + current->gc,sx,sy,w,h,dx,dy); + WM(current->lastuserfunc); +} + + +void ScreenCopy(void) +{ + if (current->buffer) + { + WM(GXcopy); + XCopyArea(display,current->pm[current->pmi^1], + current->pm[current->pmi],current->gc,0,0, + current->pw,current->ph,0,0); + WM(current->lastuserfunc); + } +} + + +Display *GetDisplay(void) +{ + return display; +} + + + +void XFinished(void) +{ + XCloseDisplay(display); +} + + +void XDoTillButtonPress(XVoidCallback func) +{ + XEvent event; + int ignore=True; + + while (True) + if (XPending(display)) + { + XNextEvent(display,&event); + + switch (event.type) + { + case Expose: + if (event.xexpose.count) + break; + Redraw(current->ox,current->oy); + break; + + case ButtonPress: + if (event.xbutton.button) + if (!ignore) + return; + break; + } + } + else + if (func) + switch (func()) + { + case XFUNCCONT: + ignore=False; + break; + + case XFUNCIGNORE: + ignore=True; + break; + + case XFUNCSTOP: + return; + break; + } + +} + + +void XDoMouse(XButtonCallback button, XMoveCallBack move, XVoidCallback process) +{ + XEvent event; + + while (True) + if ((XPending(display))||(!process)) + { + XNextEvent(display,&event); + + switch (event.type) + { + case Expose: + if (event.xexpose.count) + break; + Redraw(current->ox,current->oy); + break; + + case MotionNotify: + if (move) + switch(move(event.xmotion.window, + event.xmotion.x,event.xmotion.y)) + { + case XFUNCSTOP: + return; + break; + } + break; + + case ButtonPress: + if (button) + switch(button(event.xbutton.window,XPRESS, + event.xbutton.button, + event.xbutton.x,event.xbutton.y)) + { + case XFUNCSTOP: + return; + break; + } + break; + } + } + else + if (process) + switch (process()) + { + case XFUNCCONT: + case XFUNCIGNORE: + break; + + case XFUNCSTOP: + return; + break; + } + +} + + +static int IsMoveWin(Window w, XWindowMoveCallBack call[] ,int *i) +{ + int f; + + if (!call) + { + return(False); + } + + f=0; + + while(call[f].w) + { + if (call[f].w==w) + { + *i=f; + return call[f].func ? True:False; + } + else + { + f++; + } + } + + return False; +} + + +static int IsButtonWin(Window w, XWindowButtonCallback call[] ,int *i) +{ + int f; + + if (!call) + { + return(False); + } + + f=0; + + while(call[f].w) + { + if (call[f].w==w) + { + *i=f; + return call[f].func ? True:False; + } + else + { + f++; + } + } + + return False; +} + + +static int IsKeyWin(Window w, XWindowKeyCallback call[] ,int *i) +{ + int f; + + if (!call) + { + return(False); + } + + f=0; + + while(call[f].w) + { + if (call[f].w==w) + { + *i=f; + return call[f].func ? True:False; + } + else + { + f++; + } + } + + return False; +} + + +void XDoWindows(XWindowButtonCallback button[], + XWindowMoveCallBack move[], + XWindowKeyCallback key[], + XVoidCallback process) +{ + int i; + XEvent event; + + while (True) + if ((XPending(display))||(!process)) + { + XNextEvent(display,&event); + + switch (event.type) + { + case Expose: + if (event.xexpose.count) + break; + + PUSHW; + SetCurrentWin(event.xexpose.window); + Redraw(current->ox,current->oy); + POPW; + + break; + + case MotionNotify: + if (IsMoveWin(event.xmotion.window,move,&i)) + { + switch(move[i].func(event.xmotion.window, + event.xmotion.x, + event.xmotion.y)) + { + case XFUNCSTOP: + return; + break; + } + } + break; + + case ButtonPress: + if (IsButtonWin(event.xbutton.window,button,&i)) + { + switch(button[i].func + (event.xbutton.window, + XPRESS, + event.xbutton.button, + event.xbutton.x,event.xbutton.y)) + { + case XFUNCSTOP: + return; + break; + } + } + break; + + case ButtonRelease: + if (IsButtonWin(event.xbutton.window,button,&i)) + { + switch(button[i].func + (event.xbutton.window, + XRELEASE, + event.xbutton.button, + event.xbutton.x,event.xbutton.y)) + { + case XFUNCSTOP: + return; + break; + } + } + break; + + case KeyPress: + if (IsKeyWin(event.xkey.window,key,&i)) + { + switch(key[i].func(event.xkey.window, + XPRESS, + &event)) + { + case XFUNCSTOP: + return; + break; + } + } + break; + + case KeyRelease: + if (IsKeyWin(event.xkey.window,key,&i)) + { + switch(key[i].func(event.xkey.window, + XRELEASE, + &event)) + { + case XFUNCSTOP: + return; + break; + } + } + break; + + default: + break; + } + } + else + if (process) + { + switch (process()) + { + case XFUNCCONT: + case XFUNCIGNORE: + break; + + case XFUNCSTOP: + return; + break; + } + } +} + + +/* Sprite routines */ +void LoadSprite(const char *fn, XSprite *spr, const XColor xc[256]) +{ + Pixmap piximg,pixmask,pixsave; + int fd,x,y; + char magic[11]; + unsigned char *data,*p; + unsigned short us; + GC gc; + + if ((fd=open(fn,O_RDONLY))==-1) + { + WARN1("Couldn't open sprite file",fn); + return; + } + + read(fd,magic,11); + + if (strncmp(magic,"XbitSprite",10)) + { + WARN1(fn,"is not a sprite file!"); + close(fd); + return; + } + + spr->x=spr->y=0; + + read(fd,&us,sizeof(unsigned short)); + spr->w=ntohs(us); + read(fd,&us,sizeof(unsigned short)); + spr->h=ntohs(us); + + if (!(data=malloc(spr->w*spr->h))) + { + WARN("Couldn't grab memory for sprite image"); + close(fd); + return; + } + + if (read(fd,data,spr->w*spr->h)!=spr->w*spr->h) + { + WARN("Couldn't load sprite image"); + close(fd); + free(data); + return; + } + + close(fd); + + gc=XCreateGC(display,current->w,0,NULL); + + XSetPlaneMask(display,gc,AllPlanes); + XSetGraphicsExposures(display,gc,False); + + piximg=XCreatePixmap(display,current->w,spr->w,spr->h,vinfo.depth); + pixmask=XCreatePixmap(display,current->w,spr->w,spr->h,vinfo.depth); + pixsave=XCreatePixmap(display,current->w,spr->w,spr->h,vinfo.depth); + + p=data; + + for(y=0;yh;y++) + { + for(x=0;xw;x++) + { + XSetForeground(display,gc,xc[*p].pixel); + XDrawPoint(display,piximg,gc,x,y); + + if (*p) + XSetForeground(display,gc,xb_white); + else + XSetForeground(display,gc,xb_black); + + XDrawPoint(display,pixmask,gc,x,y); + + p++; + } + } + + spr->data=piximg; + spr->mask=pixmask; + spr->save=pixsave; + + free(data); +} + + +void XDrawSprites(XSprite *spr[],int no, XSpriteControl ctl) +{ + int f; + + WM(GXcopy); + + if (!(ctl&XSPRNOSAVE)) + for(f=0;fbuffer) + { + spr[f]->lx=spr[f]->x; + spr[f]->ly=spr[f]->y; + XCopyArea(display,current->pm[current->pmi^1], + spr[f]->save,current->gc,spr[f]->x,spr[f]->y, + spr[f]->w,spr[f]->h,0,0); + } + else + { + spr[f]->lx=spr[f]->x; + spr[f]->ly=spr[f]->y; + XCopyArea(display,current->pm[current->pmi], + spr[f]->save,current->gc,spr[f]->x,spr[f]->y, + spr[f]->w,spr[f]->h,0,0); + } + + WM(GXand); + for(f=0;fbuffer) + XCopyArea(display,spr[f]->mask,current->pm[current->pmi^1], + current->gc,0,0, + spr[f]->w,spr[f]->h,spr[f]->x,spr[f]->y); + else + XCopyArea(display,spr[f]->mask,current->pm[current->pmi], + current->gc,0,0, + spr[f]->w,spr[f]->h,spr[f]->x,spr[f]->y); + + WM(GXor); + for(f=0;fbuffer) + XCopyArea(display,spr[f]->data,current->pm[current->pmi^1], + current->gc,0,0, + spr[f]->w,spr[f]->h,spr[f]->x,spr[f]->y); + else + XCopyArea(display,spr[f]->data,current->pm[current->pmi], + current->gc,0,0, + spr[f]->w,spr[f]->h,spr[f]->x,spr[f]->y); + + WM(current->lastuserfunc); +} + + +void XEraseSprites(XSprite *spr[],int no) +{ + int f; + + WM(GXcopy); + + for(f=0;fbuffer) + XCopyArea(display,spr[f]->save,current->pm[current->pmi^1], + current->gc,0,0, + spr[f]->w,spr[f]->h,spr[f]->lx,spr[f]->ly); + else + XCopyArea(display,spr[f]->save,current->pm[current->pmi], + current->gc,0,0, + spr[f]->w,spr[f]->h,spr[f]->lx,spr[f]->ly); + + WM(current->lastuserfunc); +} + + +void LoadColormap(const char *fn, XColor xc[256]) +{ + int fd,f; + unsigned short us; + + if ((fd=open(fn,O_RDONLY))==-1) + { + WARN1("Couldn't open cmap",fn); + return; + } + + for(f=0;f<256;f++) + { + xc[f].flags=DoRed|DoGreen|DoBlue; + read(fd,&us,sizeof(unsigned short)); + xc[f].red=ntohs(us); + read(fd,&us,sizeof(unsigned short)); + xc[f].green=ntohs(us); + read(fd,&us,sizeof(unsigned short)); + xc[f].blue=ntohs(us); + + XAllocColor(display,DefaultColormap(display,screen),xc + f); + } +} + + +void AllocColors(int no,ulong pix[],const char *name[]) +{ + int f,col; + XColor xc; + + for(f=0;f(0x8000*3)) + { + WARN("defaulting to white"); + pix[f]=WhitePixel(display,screen); + } + else + { + WARN("defaulting to black"); + pix[f]=BlackPixel(display,screen); + } + } + } + else + { + WARN1("not a color ",name[f]); + pix[f]=WhitePixel(display,screen); + } + } +} + + +void AllocColorsRGB(int no, ulong pix[], const Colour col[]) +{ + int f; + XColor xc; + + for(f=0;f(0x8000*3)) + { + WARN("defaulting to white"); + pix[f]=WhitePixel(display,screen); + } + else + { + WARN("defaulting to black"); + pix[f]=BlackPixel(display,screen); + } + } + } +} + + +void LoadSpriteDataSet (const char *cmapfn, + const char *sprfn[], + SpriteDataSet *set) +{ + int f,r,fd; + char magic[11]; + XColor xcol[256]; + Colour col[256]; + SpriteData *spr; + int no; + int used[256]; + unsigned short us; + unsigned char byte; + + + /* Allocate referenced table + */ + for(f=0;f<256;f++) + used[f]=-1; + + /* Count and allocate referenced sprites + */ + no=0; + while(sprfn[no]) + no++; + + /* Load in colourmap + */ + LoadColormap(cmapfn,xcol); + + set->no_col=0; + set->no_spr=no; + + /* Load in sprites and sort out colour usage + */ + spr=malloc(sizeof(SpriteData)*no); + + for(f=0;fno_col].r=xcol[byte].red; + col[set->no_col].g=xcol[byte].green; + col[set->no_col].b=xcol[byte].blue; + + used[byte]=set->no_col++; + } + + spr[f].data[r]=used[byte]; + } + + close(fd); + } + + /* Got all sprites - allocate and remap colours + */ + AllocColoursRGB(set->no_col,set->pix,col); + + /* Remap sprites + */ + for(f=0;fpix[spr[f].data[r]]; + + /* Set up return, all done + */ + set->spr=spr; +} + + +/* END OF FILE */ diff --git a/Xbit.h b/Xbit.h new file mode 100644 index 0000000..bfb1ab9 --- /dev/null +++ b/Xbit.h @@ -0,0 +1,596 @@ +/* + + lunar - Simple X11 Lunar Lander + + Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------- + +*/ + +#ifndef XBIT_H +#define XBIT_H "$Id: Xbit.h 7 2005-05-13 01:01:08Z ianc $" + + +/* + Version 2 of the Bitmap manipulation library for X + + Now supports : + + Multiple windows + Pixmaps bigger than the window + Mutiple pixmap buffers (upto a maxim of 256 per window) + XImage print routines + Better XImage support, defaulting to shared memory usage. + + IMPORTANT NOTES ON MIT-SHM SUPPORT : + + 1. Only call CreateXImage() ONCE per window. + + 2. If you wish resources to be freed properly on completion, it + is important that DestroyXImage() is called before exiting + with the window the XImage was created in relation to set + as the current window. + + 3. Allow the user to toggle MIT-SHM from a switch, as if the + server supports it, but using it is failing for some other + reason, then your program will be unable to run. + +*/ +#include +#include + + +/* Just as I'm a lazy typer +*/ +typedef unsigned char uchar; +typedef unsigned long ulong; + + +/* Maximums for PutPlots() +*/ +#define MAX_PUTPLOTS 4096 + + +/* Types and constants +*/ +#define MIN_ANG 0 +#define MAX_ANG 23040 + +typedef enum +{ + XFUNCCONT, + XFUNCIGNORE, + XFUNCSTOP +} XFuncControl; + +typedef struct +{ + int x,y; + unsigned short w,h; + int lx,ly; /* This field is 'private' */ + Pixmap data; /* This field is 'private' */ + Pixmap mask; /* This field is 'private' */ + Pixmap save; /* This field is 'private' */ +} XSprite; + +typedef enum +{ + XSPRSAVE, + XSPRNOSAVE +} XSpriteControl; + + +typedef struct +{ + int r,g,b; +} Colour; + +typedef Colour Color; + + +typedef enum +{ + XPRESS, + XRELEASE +} XPressRelease; + + +typedef XFuncControl (*XVoidCallback)(void); +typedef XFuncControl (*XMoveCallBack)(Window w, int x, int y); +typedef XFuncControl (*XButtonCallback)(Window w, XPressRelease mode, + int button, int x, int y); +typedef XFuncControl (*XKeyCallback)(Window w, XPressRelease mode, + XEvent *event); + +typedef struct +{ + Window w; + XMoveCallBack func; +} XWindowMoveCallBack; + +typedef struct +{ + Window w; + XButtonCallback func; +} XWindowButtonCallback; + +typedef struct +{ + Window w; + XKeyCallback func; +} XWindowKeyCallback; + + +/* XImage font defs +*/ +typedef enum +{ + XI_FONT1, + XI_FONT2 +} XImageFont; + + +/* Portable sprite data definitions - allows sprite data and colormap data to + be read from a list of files, returning + an array of RGB triplets defining the + colormap, and array of pixels + corresponding to those colours and a + series of sprite images with converted + pixel values. This means you can use + data normally read in just for the + XSprite routines on any format of display + mechanism. +*/ +#define SPRD_AT(spr,x,y) (*(spr.data+(x)+((y)*(spr.w)))) + +typedef struct +{ + int w,h; /* Width, height */ + ulong *data; /* Data */ +} SpriteData; + +typedef struct +{ + int no_col; /* No of colours used by sprites */ + ulong pix[256]; /* Array of pixel values */ + int no_spr; + SpriteData *spr; /* Array of sprite data */ +} SpriteDataSet; + + +/* Function Prototypes +*/ + +Window OpenWin + ( + int argc, + char *argv[], + char *title, + int Win_X, + int Win_Y, + int Win_Width, + int Win_Height, + int Pix_Width, + int Pix_Height, + unsigned long event_mask, + XSizeHints *hints, + ulong *black, + ulong *white + ); + +Window OpenRootWin + ( + ulong *black, ulong *white, + int *w, int *h, int Pix_Width, int Pix_Height + ); + +void SetCurrentWin + ( + Window w + ); + +int GetVisualDepth(void); + +XImage *CreateXImage(void); + +void ClsXImage + ( + XImage *img + ); + +void DestroyXImage + ( + XImage *img + ); + +XFontStruct + *XUseFont + ( + const char *font_name + ); + +void XUseCursor + ( + const char *bitmap_filename, + const char *mask_filename, + XColor fg, + XColor bg + ); + +void SetAsBackdrop(void); + +void DisableDoubleBuffer(void); + +void DisablePixmap(void); + +void DisableShm(void); + +void EnableBuffers + ( + int no, + ulong clscol + ); + +void LoadBitmap + ( + const char *fn, + int x, + int y, + int resize + ); + +Pixmap GetBitmap + ( + const char *fn, + int *width, + int *height, + int *hot_x, + int *hot_y + ); + +/* These 2 are for manipulating your own XImage structures +*/ +Pixmap GetCurrentPixmap(void); +GC GetCurrentGC(void); + +void Redraw + ( + int off_x, + int off_y + ); + +void DrawXImage + ( + XImage *img + ); + +/* Note that if this used with EnableBuffers() on, this will move to the next + buffer +*/ +void Pageflip(void); + +void Resize + ( + int pix_w, + int pix_h + ); + +void XSetLineStyle + ( + unsigned int line_width, + int line_style, + int cap_style, + int join_style + ); + +void XUseFunction + ( + int GC_function + ); + +void XCls + ( + ulong colour + ); + +void XPlot + ( + int x, + int y, + ulong colour + ); + +void XLine + ( + int x1, + int y1, + int x2, + int y2, + ulong colour + ); + +void SetSplineThresh + ( + int thresh + ); + +void XSpline + ( + int x1, + int y1, + int x2, + int y2, + int x3, + int y3, + ulong colour + ); + +void XPrint + ( + int x, + int y, + const char *string, + ulong colour + ); + +void Xprintf + ( + int x, + int y, + ulong colour, + const char *fmt, + ... + ); + +void XISetFont + ( + XImageFont font_no + ); + +void XIprintf + ( + XImage *img, + int x, + int y, + int scale_x, + int scale_y, + ulong colour, + const char *fmt, + ... + ); + +void XBox + ( + int x, + int y, + int w, + int h, + ulong colour + ); + +void XFillBox + ( + int x, + int y, + int w, + int h, + ulong colour + ); + +void XCircle + ( + int x, + int y, + int rx, + int ry, + int ang1, + int ang2, + ulong colour + ); + +void XFillCircle + ( + int x, + int y, + int rx, + int ry, + int ang1, + int ang2, + ulong colour + ); + +void XStartPlots(void); + +void XAddPlot + ( + int x, + int y + ); + +void XPutPlots + ( + ulong col + ); + +void XPutPlotsAsLines + ( + ulong col + ); + +void XFillPoly + ( + XPoint xp[], + int no_points, + int shape, + ulong col + ); + +void XScroll + ( + int dx, + int dy + ); + +void XCopy + ( + int srcx, + int srcy, + int w, + int h, + int destx, + int desty + ); + +void XPut + ( + Pixmap src, + int srcx, + int srcy, + int w, + int h, + int destx, + int desty + ); + +void XGet + ( + Pixmap dest, + int srcx, + int srcy, + int w, + int h, + int destx, + int desty + ); + +void ScreenCopy(void); + +Display *GetDisplay(void); + +void XFinished(void); + +/* The following event routines expect mouse events to be set in the + event mask */ + +void XDoTillButtonPress + ( + XVoidCallback func + ); + +void XDoMouse + ( + XButtonCallback mouse_button, + XMoveCallBack mouse_movement, + XVoidCallback process + ); + +void XDoWindows + ( + XWindowButtonCallback mouse_button[], + XWindowMoveCallBack mouse_movement[], + XWindowKeyCallback key_press[], + XFuncControl (*process) () + ); + + +/* Sprite routines */ +void LoadSprite + ( + const char *filename, + XSprite *sprite, + const XColor xc[256] + ); + + +void XDrawSprites + ( + XSprite *sprites[], + int no, + XSpriteControl control + ); + +void XEraseSprites + ( + XSprite *sprites[], + int no + ); + +void LoadColormap + ( + const char *filename, + XColor xc[256] + ); + +#define AllocColors AllocColours +void AllocColours + ( + int no, + ulong pixels[], + const char *colname[] + ); + +#define AllocColorsRGB AllocColoursRGB +void AllocColoursRGB + ( + int no, + ulong pixels[], + const Colour cols[] + ); + +void LoadSpriteDataSet + ( + const char *cmap_filename, + const char *sprite_filenames[], + SpriteDataSet *set + ); + + +/* + + File Formats: + + NB: all ushorts are stored in network format. See ntohs(3). + + Colormap: + + red.ushort - Red component color 0 + green.ushort - Red component color 0 + blue.ushort - Red component color 0 + ... + ... + red.ushort - Red component color 255 + green.ushort - Red component color 255 + blue.ushort - Red component color 255 + + + Sprite: + + "XbitSprite" - Magic string (NULL terminated) + width.ushort - width of sprite + height.ushort - height of sprite + byte.uchar - Pixel value for (0,0) + byte.uchar - Pixel value for (1,0) + ... + ... + byte.uchar - Pixel value for (width-1,height-1) + +*/ + +#endif + +/* END OF FILE */ diff --git a/dash.c b/dash.c new file mode 100644 index 0000000..0c124ce --- /dev/null +++ b/dash.c @@ -0,0 +1,3400 @@ +/* + + Simple boulder dash clone for X11/xlib/curses + + Needs a fast-ish machine - uses quite a few raster scans of the level + on each game cycle. + + ...And the curses/X pointer code could be neater and better thought out... + + ... It is only a hack though :-) ... + +*/ + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "Xbit.h" + +#define WINX 100 +#define WINY 100 +#define WINW 640 +#define WINH 400 + +#define RND(x) ((rand())%(x)) + +/* Slightly roundabout, but allows us to test the op +*/ +#ifdef NOUSLEEP +# define USLEEP(x) LocalUsleep(x) +#else +# define USLEEP(x) usleep(x) +#endif + +XSizeHints size_hints; +ulong black,white; +Display *disp; +Window window; +Colormap cm; +XFontStruct *font; + +char *GetPath(), + *GetFXPath(), + *GetLevelPath(), + *GetLibPath(); + +#define SPACESPRNAME "space" +#define EARTHSPRNAME "earth" +#define ROCKSPRNAME "rock" +#define ROCKFALLSPRNAME ROCKSPRNAME +#define TUFFWALLSPRNAME "tuffwall" +#define WALLSPRNAME "wall" +#define GEMSPRNAME "diamond" +#define GEMFALLSPRNAME GEMSPRNAME +#define HEROSPRNAME "miner" +#define EXITSPRNAME "exit" +#define BUTTSPRNAME "butterfly" +#define CHSRSPRNAME "chaser" +#define ROCKSWSPRNAME "rockswitch" +#define ONEUPSPRNAME "oneup" +#define FILTERSPRNAME "filter" +#define AMOEBASPRNAME "amoeba" +#define ROCKGENSPRNAME "rockgen" +#define BUTTGENSPRNAME "butterflygen" +#define CHSRGENSPRNAME "chasergen" + +#define SPACEGLY ' ' +#define EARTHGLY '.' +#define ROCKGLY '@' +#define TUFFWALLGLY '%' +#define WALLGLY '#' +#define GEMGLY '*' +#define HEROGLY 'R' +#define EXITGLY 'E' +#define BUTTGLY 'B' +#define CHSRGLY 'C' +#define ROCKSWGLY '!' +#define ONEUPGLY '&' +#define FILTERGLY '$' +#define AMOEBAGLY 'A' +#define ROCKGENGLY 'r' +#define BUTTGENGLY 'b' +#define CHSRGENGLY 'c' + +#define SPACESPR 0 +#define EARTHSPR 1 +#define ROCKSPR 2 +#define TUFFWALLSPR 3 +#define WALLSPR 4 +#define GEMSPR 5 +#define HEROSPR 6 +#define EXITSPR 7 +#define ROCKFALLSPR 8 +#define GEMFALLSPR 9 +#define BUTTSPR 10 +#define CHSRSPR 11 +#define ROCKSWSPR 12 +#define ONEUPSPR 13 +#define FILTERSPR 14 +#define AMOEBASPR 15 +#define ROCKGENSPR 16 +#define BUTTGENSPR 17 +#define CHSRGENSPR 18 +#define NOSPR 19 + +#define VOIDSPR -1 + +#define X(x) ((x)*chsz) +#define Y(y) ((y)*chsz) + +#define SCRX 40 +#define SCRY 24 + +typedef struct + { + char *name; + Pixmap p; + } sprite; + +sprite spr[NOSPR]= + { + {SPACESPRNAME,0}, + {EARTHSPRNAME,0}, + {ROCKSPRNAME,0}, + {TUFFWALLSPRNAME,0}, + {WALLSPRNAME,0}, + {GEMSPRNAME,0}, + {HEROSPRNAME,0}, + {EXITSPRNAME,0}, + {ROCKFALLSPRNAME,0}, + {GEMFALLSPRNAME,0}, + {BUTTSPRNAME,0}, + {CHSRSPRNAME,0}, + {ROCKSWSPRNAME,0}, + {ONEUPSPRNAME,0}, + {FILTERSPRNAME,0}, + {AMOEBASPRNAME,0}, + {ROCKGENSPRNAME,0}, + {BUTTGENSPRNAME,0}, + {CHSRGENSPRNAME,0} + }; + +char glyph_map[NOSPR]= + { + /* SPACESPR */ ' ', + /* EARTHSPR */ '.', + /* ROCKSPR */ '@', + /* TUFFWALLSPR */ '#', + /* WALLSPR */ '+', + /* GEMSPR */ '*', + /* HEROSPR */ '&', + /* EXITSPR */ 'E', + /* ROCKFALLSPR */ '@', + /* GEMFALLSPR */ '*', + /* BUTTSPR */ '%', + /* CHSRSPR */ '"', + /* ROCKSWSPR */ '^', + /* ONEUPSPR */ '$', + /* FILTERSPR */ '=', + /* AMOEBASPR */ '~', + /* ROCKGENSPR */ '+', + /* BUTTGENSPR */ '+', + /* CHSRGENSPR */ '+' + }; + +#define MAX_ENEMY 2000 +#define MAX_GENERATOR 100 + +typedef struct + { + int alive; + int type; + int x,y; + int dir; + int moved; + } Enemy; + +typedef struct + { + int cycle; + int type; + int x,y; + } Generator; + +Enemy enemy[MAX_ENEMY]; +Generator generator[MAX_GENERATOR]; +int no_enemy; +int no_generator; + + +#define AMOEBA_COUNT 5 + +typedef struct + { + int alive; + int count; + int size; + int could_move; + } Amoeba; + +Amoeba amoeba; +int max_amoeba_size; +int amoeba_move_chance; + + +#define WELLDONELEV -1 +#define TRYAGAINLEV -2 + +typedef struct + { + int sx,sy; + int ex,ey; + int x,y; + int time; + int no; + int toget; + int w,h; + char *name; + char *data; + } Level; + + +#define NONE -1 +#define UP 0 +#define RIGHT 1 +#define DOWN 2 +#define LEFT 3 + +#define ROT_RIGHT(d) ((((d)+1)>LEFT) ? (UP) : ((d)+1)) +#define ROT_LEFT(d) ((((d)-1)0) + while(lev.time) + { + lev.time--; + score+=5; + DrawScore(); + (*Update)(); + } + + for(f=0;f-1) + (*Show)(LevelNotOk,True,False); + } + } while ((lives>-1)&&(level<=no_levels)); + + (*Cls)(black); + + if (lives==-1) + (*GameLost)(); + else + (*GameWon)(); + + if(score>hisc[MAX_HISCORE-1].score) + EnterHiscore(); + + (*Cls)(black); + title_fr=True; + (*Show)(TitlePage,False,True); + } + + AutoOn(); + + (*EndWindowing)(); +} + + +void IntrHandler() +{ + if (EndWindowing) + (*EndWindowing)(); + + AutoOn(); + + exit(0); +} + +/* --------------------------------------------------------------------- */ + + +AutoOff() + +{ + if (!cursesmode) + { + XAutoRepeatOff(disp); + (*Update)(); + } +} + + +AutoOn() + +{ + if (!cursesmode) + { + XAutoRepeatOn(disp); + (*Update)(); + } +} + + +/* --------------------------------------------------------------------- */ + +char *GetPath() +{ + static char *env=NULL; + char *p; + + if (!env) + { + if (p=getenv("DASHPATH")) + { + env=malloc(strlen(p)+5); + + strcpy(env,p); + + if (env[strlen(env)-1]!='/') + strcat(env,"/"); + } + else + env=strdup("./"); + } + + return(env); +} + + +char *GetFXPath(s) +char *s; + +{ + static char r[256]; + char *p; + + strcpy(r,GetPath()); + + if (bw) + { + if (chsz==16) + strcat(r,"GFX16/"); + else + strcat(r,"GFX8/"); + } + else + { + if (chsz==16) + strcat(r,"GFX16COL/"); + else + strcat(r,"GFX8COL/"); + } + + strcat(r,s); + + return(r); +} + + +char *GetLevelPath(s) +char *s; + +{ + static char r[256]; + char *p; + + strcpy(r,GetPath()); + + if (cursesmode) + strcat(r,"CLEVELS/"); + else + strcat(r,"XLEVELS/"); + + strcat(r,s); + + return(r); +} + + +char *GetLibPath(s) +char *s; + +{ + static char r[256]; + char *p; + + strcpy(r,GetPath()); + + strcat(r,"lib/"); + + strcat(r,s); + + return(r); +} + + +LoadScores() + +{ + int fd,f; + + if ((fd=open(GetLibPath("score"),O_RDONLY))==-1) + return; + + for(f=0;fMAX_ENEMY) + { + fprintf(stderr,"Error! To many enemies level file!\n"); + AutoOn(); + Exit(1); + } + break; + case CHSRGLY: + AT(x,y)=CHSRSPR; + enemy[no_enemy].alive=True; + enemy[no_enemy].type=CHSRSPR; + enemy[no_enemy].x=x; + enemy[no_enemy].y=y; + enemy[no_enemy].dir=UP; + enemy[no_enemy].moved=False; + if ((++no_enemy)>MAX_ENEMY) + { + fprintf(stderr,"Error! To many enemies level file!\n"); + AutoOn(); + Exit(1); + } + break; + case ROCKSWGLY: + AT(x,y)=ROCKSWSPR; + break; + case ONEUPGLY: + AT(x,y)=ONEUPSPR; + break; + case FILTERGLY: + AT(x,y)=FILTERSPR; + break; + case AMOEBAGLY: + AT(x,y)=AMOEBASPR; + if (amoeba.alive) + { + amoeba.size++; + } + else + { + amoeba.alive=True; + amoeba.size=1; + amoeba.count=AMOEBA_COUNT; + amoeba.could_move=False; + } + break; + case ROCKGENGLY: + AT(x,y)=ROCKGENSPR; + generator[no_generator].cycle=0; + generator[no_generator].type=ROCKGENSPR; + generator[no_generator].x=x; + generator[no_generator].y=y; + if ((++no_generator)>MAX_GENERATOR) + { + fprintf(stderr,"Error! To many generators!\n"); + AutoOn(); + Exit(1); + } + break; + case BUTTGENGLY: + AT(x,y)=BUTTGENSPR; + generator[no_generator].cycle=0; + generator[no_generator].type=BUTTGENSPR; + generator[no_generator].x=x; + generator[no_generator].y=y; + if ((++no_generator)>MAX_GENERATOR) + { + fprintf(stderr,"Error! To many generators!\n"); + AutoOn(); + Exit(1); + } + break; + case CHSRGENGLY: + AT(x,y)=CHSRGENSPR; + generator[no_generator].cycle=0; + generator[no_generator].type=CHSRGENSPR; + generator[no_generator].x=x; + generator[no_generator].y=y; + if ((++no_generator)>MAX_GENERATOR) + { + fprintf(stderr,"Error! To many generators!\n"); + AutoOn(); + Exit(1); + } + break; + default: + break; + } + + fgets(s,256,fp); + } + + if ((lev.sx==-1)) + { + fprintf(stderr,"Error! No miner in level file!\n"); + AutoOn(); + Exit(1); + } + + if ((lev.ex==-1)) + { + fprintf(stderr,"Error! No exit in level file!\n"); + AutoOn(); + Exit(1); + } +} + +PutX(x,y,n) + +{ + XPut(spr[n].p,0,0,chsz,chsz,X(x),Y(y)); +} + +XCentre(s,y,c) +char *s; +int y,c; + +{ + XPrint(X(SCRX)/2-strlen(s)*((font->max_bounds.width)>>1),y,s,c); +} + + +CursesCentre(s,y,c) +char *s; +int y,c; + +{ + /* mvaddstr(y,SCRX/2-strlen(s)/2,s); */ + mvaddstr(y,COLS/2-strlen(s)/2,s); +} + + +DoTillPress(f,s,qf) +int (*f)(); +int s,qf; + +{ + XEvent e; + + if(XPending(disp)) + XNextEvent(disp,&e); + + while(1) + { + if ((slp>-1)&&(s)) + USLEEP(slp); + + if(XPending(disp)) + { + XNextEvent(disp,&e); + + switch(e.type) + { + case KeyPress: + switch(XLookupKeysym((XKeyEvent *)&e,ShiftMapIndex)) + { + case XK_space: + return; + break; + + case XK_Escape: + if (qf) + { + quit=True; + return; + } + break; + + default: + break; + } + break; + + case ButtonPress: + return; + break; + default: + break; + } + } + + (*f)(); + } +} + +/* --------------------------------------------------------------------- */ + +#define TITLEBLKS 44 +#define TBX(x1,x2) (14+(x1*4)+x2) +#define TBY(y) (5+(y)) + +static struct + { + int x,y; + } title_bl[TITLEBLKS]= + { + {TBX(0,0), TBY(4)}, /* D */ + {TBX(0,1), TBY(4)}, /* D */ + {TBX(0,0), TBY(3)}, /* D */ + {TBX(0,2), TBY(3)}, /* D */ + {TBX(0,0), TBY(2)}, /* D */ + {TBX(0,2), TBY(2)}, /* D */ + {TBX(0,0), TBY(1)}, /* D */ + {TBX(0,2), TBY(1)}, /* D */ + {TBX(0,0), TBY(0)}, /* D */ + {TBX(0,1), TBY(0)}, /* D */ + + {TBX(1,0), TBY(4)}, /* A */ + {TBX(1,2), TBY(4)}, /* A */ + {TBX(1,0), TBY(3)}, /* A */ + {TBX(1,2), TBY(3)}, /* A */ + {TBX(1,0), TBY(2)}, /* A */ + {TBX(1,1), TBY(2)}, /* A */ + {TBX(1,2), TBY(2)}, /* A */ + {TBX(1,0), TBY(1)}, /* A */ + {TBX(1,2), TBY(1)}, /* A */ + {TBX(1,0), TBY(0)}, /* A */ + {TBX(1,1), TBY(0)}, /* A */ + {TBX(1,2), TBY(0)}, /* A */ + + {TBX(2,0), TBY(4)}, /* S */ + {TBX(2,1), TBY(4)}, /* S */ + {TBX(2,2), TBY(4)}, /* S */ + {TBX(2,2), TBY(3)}, /* S */ + {TBX(2,2), TBY(2)}, /* S */ + {TBX(2,1), TBY(2)}, /* S */ + {TBX(2,0), TBY(2)}, /* S */ + {TBX(2,0), TBY(1)}, /* S */ + {TBX(2,0), TBY(0)}, /* S */ + {TBX(2,1), TBY(0)}, /* S */ + {TBX(2,2), TBY(0)}, /* S */ + + {TBX(3,0), TBY(4)}, /* H */ + {TBX(3,2), TBY(4)}, /* H */ + {TBX(3,0), TBY(3)}, /* H */ + {TBX(3,2), TBY(3)}, /* H */ + {TBX(3,0), TBY(2)}, /* H */ + {TBX(3,1), TBY(2)}, /* H */ + {TBX(3,2), TBY(2)}, /* H */ + {TBX(3,0), TBY(1)}, /* H */ + {TBX(3,2), TBY(1)}, /* H */ + {TBX(3,0), TBY(0)}, /* H */ + {TBX(3,2), TBY(0)} /* H */ + }; + + +int XTitle() + +{ + static int fr=True; + static int bln=0; + static int x=0; + static int y=0; + static int sc=0; + static int sct=0; + char s[128]; + int f; + + if (title_fr) + { + x=title_bl[0].x; + y=0; + title_fr=False; + LoadScores(); + + sc=0; + bln=0; + sct=0; + + (*Centre)("ALL TIME DASHERS",Y(12),white); + + if (!cursesmode) + { + (*Printf)(0,Y(13),white,"%3s %7s %-*s %3s", + "Pos","Score",HINAMELEN,"Name","Level"); + + (*Centre)("Press Escape to quit",Y(SCRY-4),white); + } + else + (*Centre)("^C to quit",Y(SCRY-4),white); + + (*Centre)("Press Space to continue",Y(SCRY-2),white); + } + + if (!cursesmode) + { + XFillBox(0,Y(14),X(SCRX),Y(3),black); + + (*Printf)(0,Y(15),white,"%3d %7d %-*s %3d", + sc+1,hisc[sc].score,HINAMELEN,hisc[sc].name,hisc[sc].level); + } + else + { + (*Printf)(0,Y(15),white,"Pos : %-2d",sc+1); + (*Printf)(0,Y(16),white,"Name : %-*s",HINAMELEN,hisc[sc].name); + (*Printf)(0,Y(17),white,"Score : %-7d",hisc[sc].score); + (*Printf)(0,Y(18),white,"Level : %-3d",hisc[sc].level); + } + + if (sct++==100) + { + sct=0; + if (++sc==MAX_HISCORE) + sc=0; + } + + if (y>=title_bl[bln].y) + if (++blnY(SCRY)) + { + ispr[f].x=X(RND(SCRX)); + ispr[f].y=-chsz; + } + } + + sprintf(s,"Level %d",level); + (*Centre)(s,Y(3),white); + + sprintf(s,"'%s'",lev.name); + (*Centre)(s,Y(5),white); + + (*Centre)("Press Space to continue",Y(SCRY-2),white); + + (*Update)(); + + return(XFUNCCONT); +} + +/* --------------------------------------------------------------------- */ + +int LevelOk() + +{ + static int ix=1; + int x,y; + + if (fr_flag) + { + fr_flag=False; + + LoadLevel(WELLDONELEV); + + ix=1; + + (*Cls)(black); + (*Repaint)(True); + } + else + (*Repaint)(False); + + lev.x+=ix; + + if ((lev.x==0)||(lev.x==lev.w-SCRX)) + { + ix=-ix; + + for(x=0;x=80) + (*Printf)(0,0,white, + "Score %7d Collect %3d Got %3d Lives %2d Time %4d", + score,lev.toget,lev.no,lives,lev.time); + else + (*Printf)(0,0,white,"S:%-7d C:%-3d G:%-3d L:%-2d T:%-4d", + score,lev.toget,lev.no,lives,lev.time); +} + + +XUpdate() + +{ + Redraw(0,0); +} + + +XRepaint(full) + +{ + static char scr[SCRX][SCRY]; + static int lx,ly; + int x,y,px,py; + + if (full) + { + lx=lev.x; + ly=lev.y; + + for(y=0;y0;x--) + for(y=0;y0;y--) + scr[x][y]=scr[x][y-1]; + + for(x=0;x-1)&&(py>-1)) + { + if (scr[x][y]!=AT(px,py)) + { + (*Put)(x,y,AT(px,py)); + scr[x][y]=AT(px,py); + } + } + else + if (scr[x][y]!=SPACESPR) + { + (*Put)(x,y,SPACESPR); + scr[x][y]=SPACESPR; + } + } + + lx=lev.x; + ly=lev.y; +} + +/* --------------------------------------------------------------------- */ +#define MOVE_AMOEBA(x,y) ((AT(x,y)==SPACESPR)||(AT(x,y)==EARTHSPR)) + +CheckAmoebaMove(x,y) + +{ + int r=False; + + if (MOVE_AMOEBA(x-1,y)) + { + r=True; + if (RND(100)>amoeba_move_chance) + { + AT(x-1,y)=AMOEBASPR; + amoeba.size++; + } + } + + if (MOVE_AMOEBA(x+1,y)) + { + r=True; + if (RND(100)>amoeba_move_chance) + { + AT(x+1,y)=AMOEBASPR; + amoeba.size++; + } + } + + if (MOVE_AMOEBA(x,y-1)) + { + r=True; + if (RND(100)>amoeba_move_chance) + { + AT(x,y-1)=AMOEBASPR; + amoeba.size++; + } + } + + if (MOVE_AMOEBA(x,y+1)) + { + r=True; + if (RND(100)>amoeba_move_chance) + { + AT(x,y+1)=AMOEBASPR; + amoeba.size++; + } + } + + return(r); +} + +HandleAmoeba() + +{ + int f,x,y,d; + + if (amoeba.alive) + if (!(--amoeba.count)) + { + amoeba.count=AMOEBA_COUNT; + amoeba.could_move=False; + + for(y=0;ymax_amoeba_size) + { + for(y=0;yx,g->y)=g->type; /* Make generators 'indestructible' */ + + if (!((g->cycle++)%20)) + switch(g->type) + { + case ROCKGENSPR: + if (AT(g->x,g->y+1)==SPACESPR) + AT(g->x,g->y+1)=ROCKFALLSPR; + break; + + case BUTTGENSPR: + GenerateMonsters(g->x,g->y,BUTTSPR); + break; + + case CHSRGENSPR: + GenerateMonsters(g->x,g->y,CHSRSPR); + break; + + default: + break; + } + } +} + + +/* --------------------------------------------------------------------- */ + +CheckEnemyMove(e,d) +Enemy *e; +int d; + +{ + switch(AT((e)->x+move_tbl[(d)].x,(e)->y+move_tbl[(d)].y)) + { + case SPACESPR: + case HEROSPR: + return(True); + break; + default: + return(False); + break; + } +} + +#define ISDESTRUCT(c) \ + ((c==SPACESPR)|| \ + (c==EARTHSPR)|| \ + (c==ROCKSPR)|| \ + (c==WALLSPR)|| \ + (c==GEMSPR)|| \ + (c==HEROSPR)|| \ + (c==ROCKFALLSPR)|| \ + (c==GEMFALLSPR)|| \ + (c==BUTTSPR)|| \ + (c==CHSRSPR)) + +HandleEnemies() + +{ + int f; + + for(f=0;fx,e->y)) + { + case ROCKFALLSPR: + case GEMFALLSPR: + e->alive=False; + score+=20; + for(x=-1;x<2;x++) + for(y=-1;y<2;y++) + if (ISDESTRUCT(AT(e->x+x,e->y+y))) + AT(e->x+x,e->y+y)=GEMFALLSPR; + return; + break; + + default: + AT(e->x,e->y)=SPACESPR; + + if (CheckEnemyMove(e,e->dir)) + { + e->x+=move_tbl[e->dir].x; + e->y+=move_tbl[e->dir].y; + } + else + { + if (CheckEnemyMove(e,ROT_RIGHT(e->dir))) + e->dir=ROT_RIGHT(e->dir); + else + e->dir=ROT_LEFT(e->dir); + } + AT(e->x,e->y)=BUTTSPR; + } +} + + +HandleChsr(e) +Enemy *e; + +{ + int x,y,f,od,md; + + switch (AT(e->x,e->y)) + { + case ROCKFALLSPR: + case GEMFALLSPR: + e->alive=False; + score+=20; + for(x=-1;x<2;x++) + for(y=-1;y<2;y++) + if (ISDESTRUCT(AT(e->x+x,e->y+y))) + AT(e->x+x,e->y+y)=ROCKFALLSPR; + return; + break; + + default: + AT(e->x,e->y)=SPACESPR; + + if ((od=e->dir)==NONE) + { + od=UP; + e->moved=False; + } + + if (e->dir!=NONE) + if(!CheckEnemyMove(e,e->dir)) + { + e->dir=NONE; + e->moved=False; + } + + if(e->moved) + { + md=e->dir; + e->dir=NONE; + } + else + md=NONE; + + /* Try moving in the X plane towards the sprite */ + if (e->dir==NONE) + { + x=lev.sx-e->x; + + if (x<0) + e->dir=LEFT; + else + e->dir=RIGHT; + + if (e->dir!=NONE) + if(!CheckEnemyMove(e,e->dir)) + e->dir=NONE; + } + + if (md!=NONE) + if (md==ROT_FLIP(e->dir)) + e->dir=NONE; + + /* Try moving in the Y plane towards the sprite */ + if (e->dir==NONE) + { + y=lev.sy-e->y; + + if (y<0) + e->dir=UP; + else + e->dir=LEFT; + + if (e->dir!=NONE) + if(!CheckEnemyMove(e,e->dir)) + e->dir=NONE; + } + + if (md!=NONE) + if (md==ROT_FLIP(e->dir)) + { + e->dir=md; + e->moved=True; + } + + /* Try any other direction */ + if (e->dir==NONE) + { + if (CheckEnemyMove(e,ROT_RIGHT(od))) + { + e->dir=ROT_RIGHT(od); + e->moved=True; + } + + if (e->dir==NONE) + if (CheckEnemyMove(e,ROT_LEFT(od))) + { + e->dir=ROT_LEFT(od); + e->moved=True; + } + + if (e->dir==NONE) + if (CheckEnemyMove(e,ROT_FLIP(od))) + { + e->dir=ROT_LEFT(od); + e->moved=True; + } + } + + if (e->dir!=NONE) + { + e->x+=move_tbl[e->dir].x; + e->y+=move_tbl[e->dir].y; + } + + AT(e->x,e->y)=CHSRSPR; + break; + } +} + + +HandleChsr_V2(e) +Enemy *e; + +{ + int x,y,b; + + switch (AT(e->x,e->y)) + { + case ROCKFALLSPR: + case GEMFALLSPR: + e->alive=False; + score+=20; + for(x=-1;x<2;x++) + for(y=-1;y<2;y++) + if (AT(e->x+x,e->y+y)!=TUFFWALLSPR) + AT(e->x+x,e->y+y)=ROCKFALLSPR; + return; + break; + + default: + + if (e->moved) + { + e->moved--; + return; + } + + e->moved=3; + + AT(e->x,e->y)=SPACESPR; + + e->dir=NONE; + + if (lev.syy) + e->dir=UP; + else + if (lev.sy>e->y) + e->dir=DOWN; + + if (e->dir!=NONE) + { + b=AT(e->x+move_tbl[e->dir].x,e->y+move_tbl[e->dir].y); + + if ((b!=SPACESPR)&&(b!=HEROSPR)) + e->dir=NONE; + } + + if (e->dir==NONE) + { + if (lev.sxx) + e->dir=LEFT; + else + if (lev.sx>e->x) + e->dir=RIGHT; + + if (e->dir!=NONE) + { + b=AT(e->x+move_tbl[e->dir].x,e->y+move_tbl[e->dir].y); + + if ((b!=SPACESPR)&&(b!=HEROSPR)) + e->dir=NONE; + } + } + + if (e->dir!=NONE) + { + e->x+=move_tbl[e->dir].x; + e->y+=move_tbl[e->dir].y; + } + + AT(e->x,e->y)=CHSRSPR; + } +} + + +HandleChsr_V1(e) +Enemy *e; + +{ + switch (AT(e->x,e->y)) + { + case ROCKFALLSPR: + case GEMFALLSPR: + e->alive=False; + score+=20; + return; + break; + + default: + AT(e->x,e->y)=SPACESPR; + + e->x+=move_tbl[e->dir].x; + e->y+=move_tbl[e->dir].y; + + if ((AT(e->x,e->y)!=SPACESPR)&&(AT(e->x,e->y)!=HEROSPR)) + { + e->x-=move_tbl[e->dir].x; + e->y-=move_tbl[e->dir].y; + + if ((++e->dir)>LEFT) + e->dir=UP; + } + AT(e->x,e->y)=CHSRSPR; + } +} + + +/* --------------------------------------------------------------------- */ + +CanMove(d) + +{ + if (d==NONE) + return(False); + + switch(AT(lev.sx+move_tbl[d].x,lev.sy+move_tbl[d].y)) + { + case ROCKSPR: + if ((d==LEFT)||(d==RIGHT)) + { + if (AT(lev.sx+move_tbl[d].x*2,lev.sy+move_tbl[d].y*2)==SPACESPR) + { + AT(lev.sx+move_tbl[d].x*2,lev.sy+move_tbl[d].y*2)=ROCKSPR; + AT(lev.sx+move_tbl[d].x,lev.sy+move_tbl[d].y)=SPACESPR; + } + else + return(False); + } + else + return(False); + break; + + case TUFFWALLSPR: + case WALLSPR: + case ROCKFALLSPR: + case GEMFALLSPR: + case AMOEBASPR: + case FILTERSPR: + case ROCKGENSPR: + case BUTTGENSPR: + case CHSRGENSPR: + return(False); + break; + + case EXITSPR: + if (lev.no>=lev.toget) + return(True); + else + return(False); + + + default: + return(True); + break; + } +} + + +CheckEnemies() + +{ + int f,x,y; + + for(f=0;f-1;y--) + for(x=0;x-1) + USLEEP(slp); + + for(f=0;f<4;f++) + if (released[f]) + { + pressed[f]=0; + released[f]=False; + + if (f==dir) + dir=NONE; + } + + if (dir==NONE) + { + kp=-1; + kpm=0; + + for(f=0;f<4;f++) + if (pressed[f]>kpm) + { + kpm=pressed[f]; + kp=f; + } + + if (kp!=-1) + dir=kp; + } + + if (shiftrelease) + { + shiftmode=False; + shiftrelease=False; + } + + while(XPending(disp)) + { + XNextEvent(disp,&e); + + switch(e.type) + { + case KeyPress: + switch(XLookupKeysym((XKeyEvent *)&e,ShiftMapIndex)) + { + case XK_Shift_L: + case XK_Shift_R: + shiftmode=True; + break; + + case XK_Up: + for(f=0;f<4;f++) + if (pressed[f]>0) + pressed[f]++; + + pressed[UP]=1; + dir=UP; + break; + + case XK_Left: + for(f=0;f<4;f++) + if (pressed[f]>0) + pressed[f]++; + + pressed[LEFT]=1; + dir=LEFT; + break; + + case XK_Down: + for(f=0;f<4;f++) + if (pressed[f]>0) + pressed[f]++; + + pressed[DOWN]=1; + dir=DOWN; + break; + + case XK_Right: + for(f=0;f<4;f++) + if (pressed[f]>0) + pressed[f]++; + + pressed[RIGHT]=1; + dir=RIGHT; + break; + + case XK_Q: + case XK_q: + dir=NONE; + return(False); + break; + + case XK_P: + case XK_p: + DoPause(); + (*Repaint)(True); + break; + + default: + dir=NONE; + } + break; + + case KeyRelease: + switch(XLookupKeysym((XKeyEvent *)&e,ShiftMapIndex)) + { + case XK_Shift_L: + case XK_Shift_R: + shiftrelease=True; + break; + + case XK_Up: + released[UP]=True; + break; + + case XK_Left: + released[LEFT]=True; + break; + + case XK_Down: + released[DOWN]=True; + break; + + case XK_Right: + released[RIGHT]=True; + break; + + default: + break; + } + break; + + default: + break; + } + } + + if (ok) + { + ok=CheckEnemies(); + + if ((shiftmode)&&(dir!=NONE)) + { + ok=HandlePush(dir,lev.sx+move_tbl[dir].x, + lev.sy+move_tbl[dir].y); + if (ok) + ok=Handle(AT(lev.sx,lev.sy)); + } + else + { + if(CanMove(dir)) + { + if (AT(lev.sx,lev.sy)==HEROSPR) + AT(lev.sx,lev.sy)=SPACESPR; + + lev.sx+=move_tbl[dir].x; + lev.sy+=move_tbl[dir].y; + ok=Handle(AT(lev.sx,lev.sy)); + AT(lev.sx,lev.sy)=HEROSPR; + } + else + ok=Handle(AT(lev.sx,lev.sy)); + } + } + + x=lev.sx-lev.x; + y=lev.sy-lev.y; + + if (x<10) + if (lev.x) + lev.x--; + + if (x>SCRX-10) + if (lev.x(SCRY-10)) + if (lev.y<(lev.h-SCRY+1)) + lev.y++; + + HandleGenerators(); + HandleEnemies(); + HandleAmoeba(); + + Gravity(); + + if (ok) + ok=Handle(AT(lev.sx,lev.sy)); + + (*Repaint)(False); + DrawScore(); + (*Update)(); + + if (!ok) + { + if ((lev.sx==lev.ex)&&(lev.sy==lev.ey)) + dt=0; + else + dt--; + } + else + { + if (++ti==10) + { + ti=0; + if (!(--lev.time)) + { + ok=False; + dt=40; + + for(x=0;x359) + a-=360; + } + + if ((gw_ang+=1)>359) + gw_ang-=360; + + if ((gw_cast_x+=gw_cast_inc) > X(SCRX)+X(NO_GW_SPR*2)) + { + gw_cast_x=0; + gw_intro_no=RND(NO_GW_INTRO); + if (++gw_cast_no==NO_GW_CAST) + gw_cast_no=0; + } + + (*Update)(); + + return(XFUNCCONT); +} + + +DoXGameOverWonLargeScale() + +{ + static int la=0; + static char s[100]; + int a; + double dx,dy; + int f; + + XFillBox(0,Y(2),X(SCRX),Y(2),black); + XFillBox(0,Y(SCRY-2),X(SCRX),Y(2),black); + + a=la; + for(f=0;f359) + a-=360; + } + + (*Centre)(gw_text[gw_text_no],Y(3),white); + + if (++gw_text_ti==100) + { + gw_text_ti=0; + if (++gw_text_no==NO_GW_LINES) + gw_text_no=0; + } + + sprintf(s,"%s %s",gw_intro[gw_intro_no],gw_cast[gw_cast_no].name); + (*Centre)(s,Y(SCRY-1),white); + + la=a=gw_ang; + for(f=0;f359) + a-=360; + } + + if ((gw_ang+=1)>359) + gw_ang-=360; + + if (++gw_cast_x==100) + { + gw_cast_x=0; + gw_intro_no=RND(NO_GW_INTRO); + if (++gw_cast_no==NO_GW_CAST) + gw_cast_no=0; + } + + (*Update)(); + + return(XFUNCCONT); +} + + +XGameOverWon() + +{ + score+=lives*2000; + + gw_cast_no=0; + gw_cast_x=0; + gw_intro_no=RND(NO_GW_INTRO); + gw_ang=0; + + gw_text_no=0; + gw_text_ti=0; + + if (chsz==8) + { + NO_GW_SPR=20; + gw_cast_inc=1; + (*Show)(DoXGameOverWonSmallScale,False); + } + else + { + NO_GW_SPR=5; + gw_cast_inc=3; + (*Show)(DoXGameOverWonLargeScale,False); + } +} + +XEndWindowing() +{ + /* X11 cleans up on exit anyway... */ +} + +/* --------------------------------------------------------------------- */ + +int CmpHi(a,b) +hiscore *a,*b; + +{ + int f; + + (*Cls)(black); + + (*Centre)("YOU GOT A HISCORE!!!!!!",Y(1),white); + + (*Printf)(0,Y(3),white,"%3s %7s %-*s %3s", + "Pos","Score",HINAMELEN,"Name","Level"); + + for(f=0;fscore-a->score); +} + + +int ShowTable() + +{ + int f; + + (*Cls)(black); + + (*Centre)("YOU GOT A HISCORE!!!!!!",Y(1),white); + + (*Printf)(0,Y(3),white,"%3s %7s %-*s %3s", + "Pos","Score",HINAMELEN,"Name","Level"); + + for(f=0;fpw_name,HINAMELEN); + hisc[MAX_HISCORE-1].score=score; + hisc[MAX_HISCORE-1].level=level; + + qsort(hisc,MAX_HISCORE,sizeof(hiscore),CmpHi); + + SaveScores(); + + (*Show)(ShowTable,False); +} + +/* --------------------------------------------------------------------- */ + +int CursesCls(c) +int c; +{ + erase(); +} + + +int CursesPut(x,y,c) +int x,y,c; +{ + mvaddch(y,x,glyph_map[c]); +} + + +int CursesRedraw() +{ + move(LINES-1,COLS-1); + refresh(); +} + + +int CursesRepaint(full) +int full; + +{ + int x,y,px,py; + + if (full) + for(x=0;x-1)&&(py>-1)) + mvaddch(y,x,glyph_map[AT(px,py)]); + else + mvaddch(y,x,glyph_map[SPACESPR]); + } +} + + +int CursesPrintf(int x, int y, int c, const char *fmt, ...) +{ + char s[128]; + va_list l; + + va_start(l, fmt); + + vsprintf(s,fmt,l); + + mvaddstr(y,x,s); + + va_end(l); +} + + +int CursesIntroLevel() +{ + char s[128]; + + (*Cls)(black); + + sprintf(s,"Level %d",level); + (*Centre)(s,Y(3),white); + + sprintf(s,"'%s'",lev.name); + (*Centre)(s,Y(5),white); + + (*Centre)("Press Space to continue",Y(SCRY-2),white); + + (*Update)(); + + return(XFUNCCONT); +} + + +int CursesPlayLevel() +{ + int dir=NONE; + int x,y,ok,ls,kp,kpm,dt,ti; + int f,r; + int shiftmode; + + AT(lev.sx,lev.sy)=HEROSPR; + (*Cls)(black); + (*Repaint)(True); + DrawScore(); + (*Update)(); + + ok=True; + dt=20; + ti=0; + + while(dt) + { + if (slp>-1) + USLEEP(slp); + + shiftmode=False; + + switch(getch()) + { + case KEY_DOWN: + dir=DOWN; + shiftmode=False; + break; + case KEY_UP: + dir=UP; + shiftmode=False; + break; + case KEY_LEFT: + dir=LEFT; + shiftmode=False; + break; + case KEY_RIGHT: + dir=RIGHT; + shiftmode=False; + break; + + case 'X': + case 'x': + dir=DOWN; + shiftmode=True; + break; + case 'W': + case 'w': + dir=UP; + shiftmode=True; + break; + case 'A': + case 'a': + dir=LEFT; + shiftmode=True; + break; + case 'D': + case 'd': + dir=RIGHT; + shiftmode=True; + break; + + case 'p': + case 'P': + DoPause(); + break; + case 'q': + case 'Q': + return(False); + break; + default: + dir=NONE; + } + flushinp(); + + if (ok) + { + ok=CheckEnemies(); + + if (shiftmode) + { + if (dir!=NONE) + { + ok=HandlePush(dir,lev.sx+move_tbl[dir].x, + lev.sy+move_tbl[dir].y); + if (ok) + ok=Handle(AT(lev.sx,lev.sy)); + } + } + else + { + if(CanMove(dir)) + { + if (AT(lev.sx,lev.sy)==HEROSPR) + AT(lev.sx,lev.sy)=SPACESPR; + + lev.sx+=move_tbl[dir].x; + lev.sy+=move_tbl[dir].y; + ok=Handle(AT(lev.sx,lev.sy)); + AT(lev.sx,lev.sy)=HEROSPR; + } + else + ok=Handle(AT(lev.sx,lev.sy)); + } + } + + x=lev.sx-lev.x; + y=lev.sy-lev.y; + + if (x<10) + if (lev.x) + lev.x--; + + if (x>SCRX-10) + if (lev.x(SCRY-10)) + if (lev.y<(lev.h-SCRY+1)) + lev.y++; + + HandleGenerators(); + HandleEnemies(); + HandleAmoeba(); + + Gravity(); + + if (ok) + ok=Handle(AT(lev.sx,lev.sy)); + + (*Repaint)(False); + DrawScore(); + (*Update)(); + + if (!ok) + { + if ((lev.sx==lev.ex)&&(lev.sy==lev.ey)) + dt=0; + else + dt--; + } + else + { + if (++ti==10) + { + ti=0; + if (!(--lev.time)) + { + ok=False; + dt=40; + + for(x=0;x +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "Xbit.h" + +#define WINX 270 +#define WINY 25 +#define WINW 700 +#define WINH 800 + +#define RND(x) (rand()%(x)) + +#define RAD(x) (M_PI/180.0*(double)(x)) + +#define ABS(x) ((x)<0 ? (-(x)) : (x)) +#define SGN(x) ((x) ? ((x)/ABS(x)) : (0)) + +XSizeHints size_hints; +int black,white; +Display *disp; +Window window; +Colormap cm; +XFontStruct *font; + + +#define CMAP_R 4 +#define CMAP_N (256/CMAP_R) +#define CMAP_X 0 +#define CMAP_Y 760 +#define CMAP_W (640/CMAP_N) +#define CMAP_H 10 + +#define MAX_SPR_W 48 +#define MAX_SPR_H 48 + +#define GRID_X 0 +#define GRID_Y 100 +#define SETGW(w,h) (12+((w-h)/3)) + +#define SPR_X 640 +#define SPR_Y 100 + +#define STR_Y 80 + +#define PLOT 0 +#define FILL 1 +#define LINE 2 +#define RECT 3 +#define BOX 4 +#define CIRCLE 5 +#define OVAL 6 +#define ENDMODE 7 + +#define PLOT_TXT "Plot" +#define FILL_TXT "Fill" +#define LINE_TXT "Line" +#define RECT_TXT "Rect" +#define BOX_TXT "Box" +#define CIRCLE_TXT "Circle" +#define OVAL_TXT "Oval" +#define ENDMODE_TXT "Bug?" + +#define W_MAX 1 +#define W_MIN 40 +#define R_MAX 41 +#define R_MIN 80 +#define B_MAX 81 +#define B_MIN 120 +#define G_MAX 121 +#define G_MIN 160 +#define RG_MAX 161 +#define RG_MIN 180 +#define RB_MAX 181 +#define RB_MIN 200 +#define BG_MAX 201 +#define BG_MIN 220 +#define RND_MAX 221 +#define RND_MIN 255 + + +typedef struct + { + int x,y,w,h; + char *text; + int (*redraw)(); + int (*callback)(); + } Button; + +int RdCmapBut(),CmapBut(); +int RdSprSaveBut(),SprSaveBut(); +int RdSprLoadBut(),SprLoadBut(); +int RdSetCol(),SetCol(); +int RdSpreadBut(),SpreadBut(); +int RdLoadCmapBut(),LoadCmapBut(); +int RdDrawMode(),DrawMode(); +int RdClearToBut(),ClearToBut(); +int RdClearBut(),ClearBut(); +int RdSetSprBut(),SetSprBut(); +int RdQuitBut(),QuitBut(); + +#define NO_BUT 11 +Button butlist[NO_BUT]= + { + {1,10,90,20, + "Save Cmap", + RdCmapBut, + CmapBut}, + {101,10,90,20, + "Save Sprite", + RdSprSaveBut, + SprSaveBut}, + {201,10,90,20, + "Load Sprite", + RdSprLoadBut, + SprLoadBut}, + {301,10,90,20, + "Set Color", + RdSetCol, + SetCol}, + {401,10,90,20, + "Spread", + RdSpreadBut, + SpreadBut}, + {1,35,90,20, + "Load Cmap", + RdLoadCmapBut, + LoadCmapBut}, + {101,35,90,20, + "DrawMode", + RdDrawMode, + DrawMode}, + {201,35,90,20, + "Clear To", + RdClearToBut, + ClearToBut}, + {301,35,90,20, + "Clear", + RdClearBut, + ClearBut}, + {401,35,90,20, + "Set Size", + RdSetSprBut, + SetSprBut}, + {501,10,90,20, + "Quit", + RdQuitBut, + QuitBut} + }; + +#define MAXSTRLEN 64 + +int quit=False; +int selcol; +int range=False; +int width=1; +int drawmode=PLOT; +int last_x=-1,last_y=-1; +XColor xc[256]; +int namelen=0; +char name[MAXSTRLEN]; +int SPR_W=MAX_SPR_W; +int SPR_H=MAX_SPR_H; +int GRID_W=SETGW(MAX_SPR_W,MAX_SPR_H); +unsigned char sprite[MAX_SPR_W][MAX_SPR_H]; + + +int main(argc,argv) +int argc; +char *argv[]; + +{ + XEvent event; + unsigned long evmask; + XFuncControl Process(); + int f; + + size_hints.flags=PPosition|PSize|PMinSize|PMaxSize; + size_hints.x=WINX; + size_hints.y=WINY; + size_hints.width=size_hints.min_width=WINW; + size_hints.height=size_hints.min_height=WINH; + size_hints.max_width=WINW; + size_hints.max_height=WINH; + + evmask=ExposureMask|ButtonPressMask|StructureNotifyMask|KeyPressMask; + + window=OpenWin(argc,argv,argv[0], + WINX,WINY,WINW,WINH,0,0, + evmask, + &size_hints,&black,&white); + + DisableDoubleBuffer(); + + disp=GetDisplay(); + + cm=XCreateColormap(disp,window,DefaultVisual(disp,0),AllocAll); + XSetWindowColormap(disp,window,cm); + + font=XUseFont("fixed"); + + SetCmFade(W_MAX,W_MIN,xc,DoRed|DoBlue|DoGreen); + SetCmFade(R_MAX,R_MIN,xc,DoRed); + SetCmFade(B_MAX,B_MIN,xc,DoBlue); + SetCmFade(G_MAX,G_MIN,xc,DoGreen); + SetCmFade(RG_MAX,RG_MIN,xc,DoRed|DoGreen); + SetCmFade(RB_MAX,RB_MIN,xc,DoRed|DoBlue); + SetCmFade(BG_MAX,BG_MIN,xc,DoBlue|DoGreen); + + for(f=RND_MAX;f<=RND_MIN;f++) + { + xc[f].pixel=f; + xc[f].flags=DoRed|DoBlue|DoGreen; + xc[f].red=RND(0xff)*0xff; + xc[f].green=RND(0xff)*0xff; + xc[f].blue=RND(0xff)*0xff; + } + + black=1; + white=0; + selcol=white; + + xc[black].pixel=black; + xc[black].flags=DoRed|DoBlue|DoGreen; + xc[black].red=xc[black].blue=xc[black].green=0; + + xc[white].pixel=white; + xc[white].flags=DoRed|DoBlue|DoGreen; + xc[white].red=xc[white].blue=xc[white].green=0xffff; + + XStoreColors(disp,cm,xc,256); + + MainLoop(argc,argv); +} + + +SetCmFade(c1,c2,xc,fl) +int c1,c2; +XColor xc[]; +int fl; + +{ + int f,n,r; + + n=(c2-c1)+1; + n=0xff/n; + + for(f=c1,r=0xff;f<=c2;f++,r-=n) + { + xc[f].pixel=f; + xc[f].flags=DoRed|DoBlue|DoGreen; + + if (fl&DoRed) + xc[f].red=r*0xff; + else + xc[f].red=0; + + if (fl&DoGreen) + xc[f].green=r*0xff; + else + xc[f].green=0; + + if (fl&DoBlue) + xc[f].blue=r*0xff; + else + xc[f].blue=0; + + } +} + +/* Main Loop */ + +MainLoop(argc,argv) +int argc; +char *argv[]; + +{ + XEvent e; + KeySym ks; + char keybuf[10]; + int f,x,y; + + name[0]=NULL; + + for(x=0;x1) + { + strcpy(name,argv[1]); + namelen=strlen(name); + } + + RedrawButs(); + RedrawCmap(); + RedrawSel(); + RedrawStr(); + RedrawSpr(); + Redraw(0,0); + + while(!quit) + { + if(XPending(disp)) + { + XNextEvent(disp,&e); + + switch(e.type) + { + case KeyPress: + XLookupString(&e,keybuf,10,&ks,NULL); + + switch(ks) + { + case XK_Delete: + case XK_BackSpace: + if (namelen) + { + name[--namelen]=NULL; + RedrawStr(); + Redraw(0,0); + } + break; + + default: + switch(keybuf[0]) + { + case '': + name[namelen=0]=NULL; + RedrawStr(); + Redraw(0,0); + break; + + case '\n': + case '\r': + case '\t': + break; + + default: + if (namelenmax_bounds.ascent,WINW,font->max_bounds.ascent+2,black); + + Xprintf(0,CMAP_Y-5,white,"Colour selected : %4d",selcol); + + XBox(CMAP_X+(selcol%CMAP_N)*CMAP_W,CMAP_Y+(selcol/CMAP_N)*CMAP_H, + CMAP_W,CMAP_H,white); +} + + +RedrawStr() + +{ + char s[MAXSTRLEN+1]; + int f; + + for(f=0;fmax_bounds.ascent,WINW,font->max_bounds.ascent+2,black); + Xprintf(0,STR_Y,white,"Name : %s",s); +} + + +RedrawSpr() + +{ + int x,y,f,r; + + for(f=0,x=GRID_X;f<=SPR_W;f++,x+=GRID_W) + XLine(x,GRID_Y,x,GRID_Y+GRID_W*SPR_H,white); + + for(r=0,y=GRID_Y;r<=SPR_H;r++,y+=GRID_W) + XLine(GRID_X,y,GRID_X+GRID_W*SPR_W,y,white); + + for(x=0;x=SPR_W)||(y<0)||(y>=SPR_H)) + return; + + if(b==2) + { + selcol=sprite[x][y]; + RedrawCmap(); + RedrawSel(); + } + else + switch(drawmode) + { + case PLOT: + SprSet(x,y,c); + break; + + case FILL: + if (sprite[x][y]!=c) + SprFill(x,y,c,sprite[x][y]); + break; + + case LINE: + if (last_x==-1) + { + last_x=x; + last_y=y; + SprPlot(x,y,sprite[x][y]^255); + } + else + { + SprLine(x,y,last_x,last_y,selcol); + + last_x=-1; + last_y=-1; + } + break; + + case RECT: + if (last_x==-1) + { + last_x=x; + last_y=y; + SprPlot(x,y,sprite[x][y]^255); + } + else + { + if (x>last_x) + { + dx=last_x; + last_x=x; + x=dx; + } + + if (y>last_y) + { + dy=last_y; + last_y=y; + y=dy; + } + + for(dx=x;dx<=last_x;dx++) + { + SprSet(dx,y,selcol); + SprSet(dx,last_y,selcol); + } + + for(dy=y;dy<=last_y;dy++) + { + SprSet(x,dy,selcol); + SprSet(last_x,dy,selcol); + } + + last_x=-1; + last_y=-1; + } + break; + + case BOX: + if (last_x==-1) + { + last_x=x; + last_y=y; + SprPlot(x,y,sprite[x][y]^255); + } + else + { + if (x>last_x) + { + dx=last_x; + last_x=x; + x=dx; + } + + if (y>last_y) + { + dy=last_y; + last_y=y; + y=dy; + } + + for(dx=x;dx<=last_x;dx++) + for(dy=y;dy<=last_y;dy++) + SprSet(dx,dy,selcol); + + last_x=-1; + last_y=-1; + } + break; + + case CIRCLE: + if (last_x==-1) + { + last_x=x; + last_y=y; + SprPlot(x,y,sprite[x][y]^255); + } + else + { + if (ABS(last_x-x)dx) + { + ymode=True; + d=dx*2-dy; + incrE=dx*2; + incrNE=(dx-dy)*2; + } + else + { + ymode=False; + d=dy*2-dx; + incrE=dy*2; + incrNE=(dy-dx)*2; + } + + x=p1x; + y=p1y; + + SprSet(x,y,c); + + if (ymode) + while(y!=p2y) + { + if (d<=0) + { + d+=incrE; + y+=iy; + } + else + { + d+=incrNE; + y+=iy; + x+=ix; + } + + SprSet(x,y,c); + } + else + while(x!=p2x) + { + if (d<=0) + { + d+=incrE; + x+=ix; + } + else + { + d+=incrNE; + y+=iy; + x+=ix; + } + + SprSet(x,y,c); + } +} + + +SprSet(x,y,c) +int x,y,c; + +{ + if ((x<0)||(x>=SPR_W)||(y<0)||(y>=SPR_H)) + return; + + sprite[x][y]=c; + SprPlot(x,y,c); +} + + +SprPlot(x,y,c) +int x,y,c; + +{ + XPlot(SPR_X+x,SPR_Y+y,c); + + x=GRID_X+(x*GRID_W)+1; + y=GRID_Y+(y*GRID_W)+1; + + XFillBox(x,y,GRID_W-1,GRID_W-1,c); +} + + +SprFill(x,y,c,bc) +int x,y,c,bc; + +{ + if ((x<0)||(x>=SPR_W)||(y<0)||(y>=SPR_H)||(sprite[x][y]==c)|| + (sprite[x][y]!=bc)) + return; + + SprSet(x,y,c); + + SprFill(x-1,y,c,bc); + SprFill(x+1,y,c,bc); + SprFill(x,y-1,c,bc); + SprFill(x,y+1,c,bc); +} + + +ColPress(x,y,c) +int x,y,*c; + +{ + int lc; + + x-=CMAP_X; + x/=CMAP_W; + y-=CMAP_Y; + y/=CMAP_H; + + lc=y*CMAP_N+x; + + if ((lc<0)||(lc>255)) + return(False); + else + { + *c=lc; + return(True); + } +} + + +RangeCols(a,b) +int a,b; + +{ + int f,n,rc,gc,bc; + + if (a>b) + { + f=a; + a=b; + b=f; + } + + n=(b-a); + + rc=((int)xc[b].red-(int)xc[a].red)/n; + gc=((int)xc[b].green-(int)xc[a].green)/n; + bc=((int)xc[b].blue-(int)xc[a].blue)/n; + + for(f=1;f=bx)&&(x<=bx+bw)&&(y>=by)&&(y<=by+bh)) + return(True); + else + return(False); +} + +ButtonPoll(b,n,x,y) +Button b[]; +int n; +int x,y; + +{ + int f; + + for(f=0;fx,b->y,b->w,b->h,black); + XBox(b->x,b->y,b->w,b->h,white); + Xprintf( + (b->x)+(b->w/2)-(strlen(b->text))*(font->max_bounds.width/2), + (b->y)+(b->h/2)+(font->max_bounds.descent/2), + white,"%s",b->text); +} + + +ButtonRedraw(b) +Button *b; + +{ + XBox(b->x,b->y,b->w,b->h,white); + + if (b->redraw) + (*b->redraw)(b); +} + +/* Button Callbacks and redraws */ + +int RdCmapBut(b) +Button *b; + +{ + ButtonText(b); +} + + +int CmapBut() + +{ + unsigned short us; + int fd,f; + + if ((fd=open(name,O_WRONLY|O_CREAT|O_TRUNC,0666))==-1) + { + fprintf(stderr,"Couldn't save colormap to %s!\n",name); + return; + } + + for(f=0;f<256;f++) + { + us=htons(xc[f].red); + write(fd,&us,sizeof(unsigned short)); + us=htons(xc[f].green); + write(fd,&us,sizeof(unsigned short)); + us=htons(xc[f].blue); + write(fd,&us,sizeof(unsigned short)); + } + + close(fd); +} + + +int RdLoadCmapBut(b) +Button *b; + +{ + ButtonText(b); +} + + +int LoadCmapBut() + +{ + unsigned short us; + int fd,f; + + if ((fd=open(name,O_RDONLY))==-1) + { + fprintf(stderr,"Couldn't read colormap from %s!\n",name); + return; + } + + for(f=0;f<256;f++) + { + read(fd,&us,sizeof(unsigned short)); + xc[f].red=ntohs(us); + read(fd,&us,sizeof(unsigned short)); + xc[f].green=ntohs(us); + read(fd,&us,sizeof(unsigned short)); + xc[f].blue=ntohs(us); + } + + close(fd); + + XStoreColors(disp,cm,xc,256); +} + + +int RdSprSaveBut(b) +Button *b; + +{ + ButtonText(b); +} + + +int SprSaveBut() + +{ + int fd,x,y; + unsigned short s; + + if ((fd=open(name,O_WRONLY|O_CREAT,0666))==-1) + { + fprintf(stderr,"Couldn't save sprite to %s!\n",name); + return; + } + + write(fd,"XbitSprite",11); + + s=htons(SPR_W); + write(fd,&s,sizeof(unsigned short)); + + s=htons(SPR_H); + write(fd,&s,sizeof(unsigned short)); + + for(y=0;ytext=PLOT_TXT; + break; + + case FILL: + b->text=FILL_TXT; + break; + + case LINE: + b->text=LINE_TXT; + break; + + case RECT: + b->text=RECT_TXT; + break; + + case BOX: + b->text=BOX_TXT; + break; + + case CIRCLE: + b->text=CIRCLE_TXT; + break; + + case OVAL: + b->text=OVAL_TXT; + break; + + default: + b->text=ENDMODE_TXT; + break; + } + ButtonText(b); +} + + +int DrawMode() + +{ + if(++drawmode==ENDMODE) + drawmode=PLOT; + + if (last_x!=-1) + RedrawSpr(); + + last_x=last_y=-1; +} + + +int RdSpreadBut(b) +Button *b; + +{ + ButtonText(b); +} + + +int SpreadBut() + +{ + range=True; +} + + +int RdClearToBut(b) +Button *b; + +{ + ButtonText(b); +} + + +int ClearToBut() + +{ + int x,y; + + for(x=0;xMAX_SPR_W) + n=MAX_SPR_W; + + SPR_W=n; + SPR_H=n; + + GRID_W=SETGW(MAX_SPR_W,n); + + NullStr(); + + RedrawAll(); +} + + +int RdQuitBut(b) +Button *b; + +{ + ButtonText(b); +} + + +int QuitBut() + +{ + quit=True; +} -- cgit v1.2.3