aboutsummaryrefslogtreecommitdiffstats
path: root/drawlevel.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2003-03-24 16:31:19 +0000
committerH. Peter Anvin <hpa@zytor.com>2003-03-24 16:31:19 +0000
commit1128ad360b5cccb1b82de092505e5ca1c4dbed8d (patch)
tree89c7ebe649b47fa1b901872d646a2183df023c8d /drawlevel.c
downloadgrv-1128ad360b5cccb1b82de092505e5ca1c4dbed8d.tar.gz
grv-1128ad360b5cccb1b82de092505e5ca1c4dbed8d.tar.xz
grv-1128ad360b5cccb1b82de092505e5ca1c4dbed8d.zip
Port of "gr鋠ning" to C/SDL, started 2003-03-22
Diffstat (limited to 'drawlevel.c')
-rw-r--r--drawlevel.c968
1 files changed, 968 insertions, 0 deletions
diff --git a/drawlevel.c b/drawlevel.c
new file mode 100644
index 0000000..4112114
--- /dev/null
+++ b/drawlevel.c
@@ -0,0 +1,968 @@
+/*
+ * drawlevel.c
+ *
+ * Code to draw the playing field, status indicators etc.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <stdarg.h>
+#include "graphics.h"
+#include "grv.h"
+
+/* Color scheme */
+#define CCYCLMAX 14 /* Length of color cycle */
+struct mycolors {
+ int main;
+ int anti;
+};
+const struct mycolors colors[CCYCLMAX] = {
+ {1,6},{4,7},{5,2},{2,5},{6,3},{3,1},{7,4},{6,3},{1,6},
+ {5,2},{7,4},{4,7},{2,5},{3,1}
+};
+
+/* Macros to get "unbusy" locations */
+#define unbusy(i,j) do { (i) = irnd(22)+2; (j) = irnd(40)+1; } while ( busy((i),(j)) )
+#define unbusy2(i,j) do { (i) = irnd(21)+2; (j) = irnd(40)+1; } while ( busy((i),(j)) || busy((i)+1,(j)) )
+
+/* Different possible placements of ghosts */
+static const struct xy *Ghosts;
+
+
+/* Draw a standard frame around the level */
+static void level_frame(void)
+{
+ int e;
+
+ color(0,0);
+ lprint(2,1," ");
+ for ( e = 3 ; e <= 22 ; e++ ) {
+ lprint(e,1," ");
+ lprint(e,40," ");
+ }
+ lprint(23,1," ");
+
+ color(0,gp.c);
+}
+
+/* Level 01-05: Basic plain level */
+static void level_plain(void)
+{
+ level_frame();
+}
+
+/* Level 06-10: Crosswall level */
+static void level_crosswall(void)
+{
+ lprint(13,2,"北北北北北鞍氨北北北北北卑鞍北北北北北");
+
+ level_frame();
+}
+
+/* Level 11-15: Wheeling walls */
+static void level_wheel(void)
+{
+ int e;
+
+ lprint(8,2,"北北北北北北北北北北北北鞍");
+ lprint(15,14,"鞍北北北北北北北北北北北北");
+
+ for ( e = 3 ; e <= 14 ; e++ )
+ lprint(e,28,(e > 13) ? "" : "");
+ for ( e = 9 ; e <= 22 ; e++ )
+ lprint(e,13,(e < 11) ? "" : "");
+
+ level_frame();
+}
+
+/* Level 16-19: + walls */
+static void level_cross(void)
+{
+ int e;
+
+ for ( e = 3 ; e <= 22 ; e++ )
+ lprint(e,20,"");
+
+ lprint(13,2,"北北北北北北北北北北北北北北北北北北北");
+
+ level_frame();
+}
+
+/* Level 20-24: Hole I */
+static void level_hole1(void)
+{
+ int e;
+
+ color(0,0);
+ lprint(8,11," ");
+ lprint(13,1," ");
+ lprint(13,31," ");
+ lprint(15,11," ");
+
+ for ( e = 9 ; e <= 14 ; e++ ) {
+ if ( e != 13 ) {
+ lprint(e,11," ");
+ lprint(e,30," ");
+ }
+ }
+
+ for ( e = 17 ; e <= 22 ; e++ )
+ lprint(e,21," ");
+
+ color(0,gp.c2);
+ for ( e = 9 ; e <= 14 ; e++ )
+ lprint(e,12," ");
+
+ level_frame();
+}
+
+/* Level 25-29: Bunker */
+static void level_bunker(void)
+{
+ int e;
+
+ lprint(8,6,"北北北北北 北北北北北北");
+ lprint(20,6,"北北北北北 北北北北北北");
+
+ for ( e = 9 ; e <= 19 ; e++ ) {
+ lprint(e,6," ");
+ }
+
+ color(0,gp.c2);
+ for ( e = 9 ; e <= 19 ; e++ ) {
+ lprint(e,7," ");
+ lprint(e,25," ");
+ }
+
+ gp.Bar = 4;
+ lprint(10,8,"");
+ lprint(10,33,"");
+ lprint(18,8,"");
+ lprint(18,33,"");
+
+ color(14,0);
+ lprint(14,7," ");
+ lprint(14,25," ");
+
+ for ( e = 18 ; e <= 22 ; e++ )
+ lprint(e,20," ");
+
+ color(25,gp.c);
+ lprint(14,20,"");
+ addaction(14, 20, 180.0*rnd(), act_bomb);
+
+ level_frame();
+}
+
+/* Level 30-35: Fredrik I */
+static void level_fred1(void)
+{
+ int i;
+
+ color(0,gp.c2);
+ for ( i = 9 ; i <= 16 ; i++ ) {
+ lprint(i,12," ");
+ }
+
+ color(0,gp.c);
+ for ( i = 3 ; i <= 22 ; i++ ) {
+ lprint(i,20,"北");
+ }
+ lprint(8,11,"北北鞍北北北北鞍北北");
+ lprint(17,11,"北北北北北北北北北北");
+ lprint(5,20,"鞍");
+ lprint(20,20,"鞍");
+ lprint(13,20,"鞍");
+
+ for ( i = 8 ; i <= 17 ; i++ ) {
+ lprint(i,11,"");
+ lprint(i,30,"");
+ }
+
+ lprint(13,2,"北北氨北");
+ lprint(13,31,"北北氨北");
+
+ color(0,gp.c2);
+ lprint(13,13," ");
+ lprint(13,23," ");
+ gp.Bar = 4;
+
+ level_frame();
+}
+
+/* Level 36-40: # walls */
+static void level_hash(void)
+{
+ int e;
+
+ for ( e = 3 ; e <= 22 ; e++ ) {
+ lprint(e,14,"");
+ lprint(e,27,"");
+ }
+
+ lprint(15,2,"北北北北北北北北北鞍北北北北北北北北北");
+ lprint( 8,2,"北北北北北北北北北鞍北北北北北北北北北");
+
+ color(0,gp.c2);
+ for ( e = 9 ; e <= 14 ; e++ ) {
+ lprint(e,15," ");
+ }
+
+ level_frame();
+}
+
+/* Level 41-45: Carl-David I */
+static void level_cdw1(void)
+{
+ static const struct xy Ghost4[] = {{2,1},{2,40},{23,1},{23,40},{13,20},{-1,-1}};
+ static const struct xy cherries[] = {
+ {2,3},{3,1},{2,38},{3,40},{22,1},{23,3},{22,40},{23,38},{12,17},{13,17},{12,24},{13,24},
+ {-1,-1}
+ }, *cp;
+ static const struct { int x, y, t; } doors[] = {
+ {10,17,30},{10,16,30},{10,15,30},{15,17,40},{15,16,40},{15,15,40},
+ {15,24,50},{15,25,50},{15,26,50},{10,24,60},{10,25,60},{10,26,60},
+ {-1,-1,-1}
+ }, *dp;
+
+ int x;
+
+ Ghosts = Ghost4;
+
+ lprint(12,1,"北北北北北北北北北北北北北北北北北北北北");
+ lprint(13,1,"北北北北北北北北北北北北北北北北北北北北");
+
+ for ( x = 3 ; x <= 23 ; x++ )
+ lprint(x,20,"北");
+
+ for ( cp = cherries ; cp->x != -1 ; cp++ ) {
+ lprint(cp->x,cp->y,"");
+ gp.Bar++;
+ }
+
+ color(gp.c,0);
+
+ for ( x = 0 ; x <= 19 ; x++ ) {
+ int a = (int)((double)x*22.0/39.0 + 0.5);
+ lprint(2+a,x+1," ");
+ lprint(23-a,x+1," ");
+ lprint(2+a,39-x," ");
+ lprint(23-a,39-x," ");
+ }
+
+ lprint(2,9," ");
+
+ for ( dp = doors ; dp->x != -1 ; dp++ ) {
+ lprint(dp->x,dp->y,"");
+ addaction(dp->x,dp->y,dp->t,act_door);
+ }
+}
+
+/* Level 46-49: Fredrik II */
+static void level_fred2(void)
+{
+ static const struct xy Ghost2[] = {{23,1},{23,40},{23,20},{23,21},{7,20},{-1,-1}};
+ int e;
+
+ Ghosts = Ghost2;
+
+ color(0,gp.c2);
+
+ for ( e = 8 ; e <= 17 ; e++ )
+ lprint(e,12," ");
+
+ color(0,gp.c);
+ gp.Bar = 4;
+ lprint(13,2,"北北北北卑北北北北腚北北北北氨北北北北");
+ lprint(12,20,"腚");
+
+ for ( e = 9 ; e <= 16 ; e++ ) {
+ lprint(e,18,"北");
+ lprint(e,22,"北");
+ }
+
+ lprint(11,20," ");
+ lprint(14,20," ");
+ lprint(10,20,"鞍");
+ lprint(15,20,"鞍");
+ color(0,0);
+ lprint(7,11," ");
+ lprint(18,11," ");
+
+ for ( e = 8 ; e <= 17 ; e++ ) {
+ if ( e != 13 ) {
+ lprint(e,11," ");
+ lprint(e,30," ");
+ }
+ }
+
+ lprint(8,20," ");
+ lprint(9,20," ");
+ lprint(16,20," ");
+ lprint(17,20," ");
+
+ level_frame();
+}
+
+/* Level 50-56: Breakout */
+static void level_breakout(void)
+{
+ static const struct xy Ghost1[] = {{12,1},{12,40},{10,10},{23,20},{10,31},{-1,-1}};
+ int e;
+
+ Ghosts = Ghost1;
+
+ lprint(6, 10, "北北北北北北北北北北北");
+ lprint(18, 10, "北北北北北北北北北北北");
+
+ for ( e = 7 ; e <= 17 ; e++ ) {
+ lprint(e, 10, "");
+ lprint(e, 31, "");
+ }
+
+ for ( e = 7 ; e <= 22 ; e++ ) {
+ lprint(e, 20, "");
+ }
+
+ color(0,0);
+ lprint(10, 7, " ");
+ lprint(10, 28, " ");
+ lprint(14, 7, " ");
+ lprint(14, 28, " ");
+
+ for ( e = 11 ; e <= 13 ; e++ ) {
+ lprint(e, 7, " ");
+ lprint(e, 13, " ");
+ lprint(e, 28, " ");
+ lprint(e, 34, " ");
+ }
+
+ color(0,gp.c2);
+ for ( e = 11 ; e <= 13 ; e++ ) {
+ lprint(e, 8, " ");
+ lprint(e, 29, " ");
+ }
+
+ lprint(12, 9, "腚");
+ lprint(12, 30, "腚");
+ gp.Bar = 6;
+
+ level_frame();
+}
+
+/* Level 57-62: Arch */
+static void level_arch(void)
+{
+ static const struct xy Ghost3[] = {{12,1},{12,40},{15,14},{15,27},{23,20},{-1,-1}};
+ int x, y;
+
+ Ghosts = Ghost3;
+
+ color(0,gp.c2);
+ for ( x = 12 ; x <= 21 ; x++ )
+ lprint(x, 11, " ");
+
+ color(gp.c,0);
+ for ( x = 3 ; x <= 10 ; x++ )
+ lprint(x, 19, " ");
+
+ lprint(9, 5, " ");
+
+ for ( x = 10 ; x <= 15 ; x++ ) {
+ lprint(x, 5, " ");
+ lprint(x, 36, " ");
+ }
+
+ lprint(12, 14, " ");
+
+ for ( x = 13 ; x <= 15 ; x++ ) {
+ lprint(x, 14, " ");
+ lprint(x, 25, " ");
+ }
+
+ for ( y = 19 ; y <= 22 ; y++ ) {
+ lprint(11, y, "");
+ addaction(11, y, 20, act_door);
+ }
+
+ color(0, gp.c);
+ lprint(7, 3, "北北北北北北北北鞍鞍北北北北北北北北");
+ lprint(11, 10, "北北北北");
+ lprint(11, 23, "北北北北");
+ lprint(22, 10, "北北北北北北北北北北北");
+
+ for ( x = 8 ; x <= 22 ; x++ ) {
+ lprint(x, 3, "");
+ lprint(x, 38, "");
+ }
+
+ for ( x = 12 ; x <= 21 ; x++ ) {
+ lprint(x, 10, "");
+ lprint(x, 31, "");
+ }
+
+ level_frame();
+}
+
+/* Level 63-67: Macke I */
+static void level_macke1(void)
+{
+ static const struct xy Ghost1[] = {{12,1},{12,40},{10,10},{23,20},{10,31},{-1,-1}};
+ int e;
+
+ Ghosts = Ghost1;
+
+ lprint(13, 2, "北北北北北北北北北北北北北北北北北北北");
+
+ color(0,0);
+
+ for ( e = 8 ; e <= 15 ; e++ ) {
+ lprint(e, 10, " ");
+ }
+ for ( e = 16 ; e <= 22 ; e++ ) {
+ lprint(e, 17, " ");
+ lprint(e, 24, " ");
+ }
+
+ color(0,gp.c);
+ for ( e = 3 ; e <= 22 ; e++ ) {
+ lprint(e, 16, "");
+ lprint(e, 25, "");
+ }
+
+ lprint(12, 16, "");
+ lprint(12, 25, "");
+ lprint(13, 16, "");
+ lprint(13, 25, "");
+
+ color(0,gp.c2);
+ for ( e = 16 ; e <= 22 ; e++ ) {
+ lprint(e, 18, " ");
+ }
+ lprint(17, 18, "");
+ lprint(17, 23, "");
+ lprint(22, 19, " ");
+ gp.Bar = 4;
+
+ level_frame();
+}
+
+/* Level 68-71: Carl-David II */
+static void level_cdw2(void)
+{
+ static const struct xy Ghost5[] = {{23,4},{23,37},{23,20},{17,20},{13,20},{-1,-1}};
+ int x;
+
+ Ghosts = Ghost5;
+
+ color(0,gp.c2);
+ for ( x = 5 ; x <= 18 ; x++ ) {
+ lprint(x, 14, " ");
+ }
+
+ color(gp.c,0);
+ lprint(2, 1, " ");
+ lprint(3, 1, " ");
+ lprint(4,13, " ");
+
+ for ( x = 5 ; x <= 23 ; x++ ) {
+ lprint(x, 1, " ");
+ lprint(x, 33, " ");
+ }
+ for ( x = 5 ; x <= 19 ; x++ ) {
+ lprint(x, 13, " ");
+ lprint(x, 28, " ");
+ }
+
+ lprint(19, 13, " ");
+ lprint(7, 15, " ");
+ lprint(17, 15, " ");
+
+ for ( x = 7 ; x <= 16 ; x++ ) {
+ lprint(x, 15, " ");
+ lprint(x, 26, " ");
+ }
+ for ( x = 9 ; x <= 14 ; x++ ) {
+ lprint(x, 18, " ");
+ }
+ for ( x = 20 ; x <= 23 ; x++ ) {
+ lprint(x, 20, " ");
+ }
+
+ for ( x = 1 ; x <= 8 ; x++ ) {
+ lprint(4, x, "");
+ addaction(4, x, 25, act_door);
+ lprint(4, 41-x, "");
+ addaction(4, 41-x, 25, act_door);
+ }
+
+ color(0, gp.c);
+ for ( x = 9 ; x <= 11 ; x++ ) {
+ lprint(4, x, "");
+ addaction(4, x, 25, act_door);
+ lprint(4, 41-x, "");
+ addaction(4, 41-x, 25, act_door);
+ }
+ for ( x = 4 ; x <= 23 ; x++ ) {
+ lprint(x, 12, "");
+ lprint(x, 29, "");
+ }
+
+ for ( x = 5 ; x <= 19 ; x++ ) {
+ if ( x & 3 ) {
+ lprint(x, 1, " ");
+ lprint(x, 5, " ");
+ lprint(x, 34, " ");
+ lprint(x, 38, " ");
+ }
+ }
+
+ lprint(22, 1, " ");
+ lprint(22, 39, " ");
+ lprint(23, 1, " ");
+ lprint(23, 39, " ");
+ lprint(11, 20, "腚");
+ lprint(12, 20, "腚");
+ gp.Bar = 6;
+}
+
+/* Level 72-74: Full */
+static void level_full(void)
+{
+ int i;
+
+ for ( i = 3 ; i <= 22 ; i++ ) {
+ lprint(i, 2, "腚腚腚腚腚腚腚腚腚腚腚腚腚腚腚腚腚腚腚");
+ gp.Bar += 32;
+ }
+
+ color(0,gp.c2);
+ for ( i = 8 ; i <= 17 ; i++ ) {
+ lprint(i, 11, " ");
+ gp.Bar -= 20;
+ }
+
+ level_frame();
+}
+
+/* Level 75: Finale */
+static void level_finale(void)
+{
+ int i, j, e;
+ int nw;
+
+ gp.nextwhite = 0;
+ nw = 0;
+#define ADDW(i,j) ( gp.whitecherrylist[nw].x = (i), \
+ gp.whitecherrylist[nw].y = (j), \
+ lprint((i),(j),""), \
+ nw++ )
+
+ color(15, gp.c);
+ for ( i = 3 ; i <= 22 ; i += 2 ) {
+ ADDW(i,2);
+ ADDW(i,6);
+ ADDW(i,10);
+ ADDW(i,14);
+ ADDW(i,18);
+ ADDW(i,22);
+ ADDW(i,26);
+ ADDW(i,30);
+ ADDW(i,34);
+ ADDW(i,38);
+
+ ADDW(i+1,4);
+ ADDW(i+1,8);
+ ADDW(i+1,12);
+ ADDW(i+1,16);
+ ADDW(i+1,20);
+ ADDW(i+1,24);
+ ADDW(i+1,28);
+ ADDW(i+1,32);
+ ADDW(i+1,36);
+ }
+ gp.Bar = gp.nwhite = nw;
+
+ /* Shuffle the white cherry list */
+ for ( i = nw-1 ; i >= 0 ; i-- ) {
+ struct xy tmp;
+ j = irnd(i+1);
+
+ tmp = gp.whitecherrylist[i];
+ gp.whitecherrylist[i] = gp.whitecherrylist[j];
+ gp.whitecherrylist[j] = tmp;
+ }
+
+ for ( e = 1 ; e <= 5 ; e++ ) {
+ white2black();
+ }
+
+ if ( gp.ZLevel < 0 ) {
+ gp.ZLevel = ELev - 1; /* Shouldn't this be zero? */
+ }
+
+ if ( gp.ZLevel > 0 ) {
+ lprintf(25, 2, "JUMP TO %d", gp.ZLevel + 1);
+ addaction(0, 0, 10, act_droplevel); /* drop 1 reentry level */
+ }
+
+ color(16, gp.c); /* Color 16 for spaces? */
+ lprint(24, 20, " ");
+
+ level_frame();
+}
+
+/* Draw level hyperspace */
+static void draw_hyper(void)
+{
+ int i, j, e, z;
+ static const char *hyper[] = {"H","Y","P","E","R"};
+
+ /* Never skip the last level */
+ z = min((ELev-2)-gp.Level,5);
+
+ for ( e = 0 ; e < z ; e++ ) {
+ unbusy(i,j);
+
+ color(15,bg(i,j));
+ lprint(i,j,hyper[e]);
+ }
+}
+
+/* Draw "standard" cherries */
+static void draw_cherries(void)
+{
+ int bar;
+ int e, i, j;
+
+ bar = 3*gp.Level + 6;
+ bar = min(bar,50);
+
+ gp.Bar += bar;
+
+ for ( e = 0 ; e < bar ; e++ ) {
+ unbusy(i,j);
+
+ color(0,bg(i,j));
+ lprint(i,j,"\xeb");
+ }
+}
+
+/* Draw bombs */
+static void draw_bombs(void)
+{
+ int i, j, e, z, xbg;
+
+ z = gp.Level/10;
+
+ for ( e = 0 ; e < z ; e++ ) {
+ unbusy(i,j);
+
+ xbg = bg(i,j);
+ color(25, xbg);
+ lprint(i,j,"\xe5");
+ addaction(i,j,180.0*rnd(),act_bomb);
+ }
+}
+
+/* Draw shots */
+static void draw_shots(void)
+{
+ int i, j, e, z, xbg;
+
+ z = 1 + (gp.Level > 9) + (gp.Level > 14) + (gp.Level > 24);
+
+ for ( e = 0 ; e < z ; e++ ) {
+ unbusy(i,j);
+
+ xbg = bg(i,j);
+ color(0, xbg);
+ lprint(i,j,"\xec");
+ }
+}
+
+/* Draw cluster bombs */
+static void draw_cluster(void)
+{
+ int i, j, e, z, xbg;
+
+ z = (int)(gp.Level/10.0+rnd());
+
+ for ( e = 0 ; e < z ; e++ ) {
+ unbusy(i,j);
+
+ xbg = bg(i,j);
+ color(28, xbg);
+ lprint(i,j,"\x0f");
+ }
+}
+
+/* Draw mystery ?'s */
+static void draw_mystery(void)
+{
+ int i, j, e, z, xbg;
+
+ z = (gp.Level > 11) + (gp.Level > 19) + (gp.Level > 24);
+
+ for ( e = 0 ; e < z ; e++ ) {
+ unbusy(i,j);
+
+ xbg = bg(i,j);
+ color((xbg >= 2) ? 30 : 26, xbg);
+ lprint(i,j,"?");
+ }
+}
+
+/* Draw apples */
+static void draw_apples(void)
+{
+ int i, j, e, z, xbg;
+
+ z = min(gp.Level+2,20);
+
+ for ( e = 0 ; e < z ; e++ ) {
+ unbusy2(i,j);
+
+ xbg = bg(i,j);
+ color((xbg==4)?0:4, xbg);
+ lprint(i,j,"\xfe");
+ }
+}
+
+/* Draw rocks */
+static void draw_rocks(void)
+{
+ int i, j, e, z;
+
+ z = min(gp.Level+2,17);
+
+ color(8,0);
+ for ( e = 0 ; e < z ; e++ ) {
+ unbusy2(i,j);
+
+ lprint(i,j,"\x04");
+ }
+}
+
+/* Draw bonus dots */
+static void draw_bonus(void)
+{
+ int i, j, e;
+
+ for ( e = 0 ; e < 3 ; e++ ) {
+ unbusy(i,j);
+
+ color(16,bg(i,j));
+ lprint(i,j,"\xf9");
+ }
+ addaction(0, 0, 90.0*rnd(), act_bonus_on);
+}
+
+/* Draw player */
+static void draw_player(void)
+{
+ color(14,0);
+ gp.x = 2; gp.y = 20;
+ lprint(gp.x, gp.y, "\x01");
+}
+
+/* Draw ghosts */
+static void draw_ghosts(void)
+{
+ int e;
+
+ color(9,0);
+ for ( e = 0 ; e < MAXGHOST ; e++ ) {
+ if ( Ghosts->x < 0 ) {
+ ghost[e].x = ghost[e].y = 0;
+ ghost[e].dead = 1;
+ } else {
+ ghost[e].x = Ghosts->x;
+ ghost[e].y = Ghosts->y;
+ ghost[e].dead = 0;
+ lprint(Ghosts->x, Ghosts->y, "\x02");
+ Ghosts++;
+ }
+ }
+}
+
+/* Set up a blank screen appropriate for the current gp.Level */
+void levelscreen(void)
+{
+ gp.c = colors[gp.Level % CCYCLMAX].main;
+ gp.c2 = colors[gp.Level % CCYCLMAX].anti;
+ color(0, gp.c);
+ initscreen(40);
+}
+
+/* Main level-drawing function */
+void drawlevel(void)
+{
+ static const struct xy DefaultGhosts[] = {{12,1},{12,40},{23,1},{23,20},{23,40},{-1,-1}};
+ int level = gp.Level;
+ int e;
+
+ levelscreen();
+ lprintf(1,1,"SCORE:% lld", gp.Sc);
+
+ locate(1,18);
+ color(14,gp.c);
+ for ( e = 1 ; e <= gp.Life ; e++ ) {
+ print("\x01 ");
+ }
+
+ color(0,gp.c);
+ lprintf(1,31,"LEVEL: %d", gp.Level+1);
+
+ Ghosts = DefaultGhosts;
+ gp.Bar = gp.nwhite = 0;
+
+ switch ( level+1 ) {
+ case 1: case 2: case 3: case 4: case 5:
+ level_plain();
+ break;
+ case 6: case 7: case 8: case 9: case 10:
+ level_crosswall();
+ break;
+ case 11: case 12: case 13: case 14: case 15:
+ level_wheel();
+ break;
+ case 16: case 17: case 18: case 19:
+ level_cross();
+ break;
+ case 20: case 21: case 22: case 23: case 24:
+ level_hole1();
+ break;
+ case 25: case 26: case 27: case 28: case 29:
+ level_bunker();
+ break;
+ case 30: case 31: case 32: case 33: case 34: case 35:
+ level_fred1();
+ break;
+ case 36: case 37: case 38: case 39: case 40:
+ level_hash();
+ break;
+ case 41: case 42: case 43: case 44: case 45:
+ level_cdw1();
+ break;
+ case 46: case 47: case 48: case 49:
+ level_fred2();
+ break;
+ case 50: case 51: case 52: case 53: case 54: case 55: case 56:
+ level_breakout();
+ break;
+ case 57: case 58: case 59: case 60: case 61: case 62:
+ level_arch();
+ break;
+ case 63: case 64: case 65: case 66: case 67:
+ level_macke1();
+ break;
+ case 68: case 69: case 70: case 71:
+ level_cdw2();
+ break;
+ case 72: case 73: case 74:
+ level_full();
+ break;
+ case 75:
+ level_finale();
+ break;
+ default:
+ abort();
+ }
+
+ draw_player();
+ draw_ghosts();
+
+ if ( level == ELev-1 ) {
+ /* Very plain level */
+ } else {
+ /* Common level code */
+
+ draw_cherries();
+
+ if ( level >= 29 )
+ draw_bombs();
+
+ if ( gp.Lvf >= 4 ) {
+ draw_hyper();
+ gp.Lvf = 0;
+ }
+
+ draw_cluster();
+
+ draw_shots();
+
+ if ( level < 70 )
+ draw_rocks();
+
+ if ( level >= 12 )
+ draw_mystery();
+
+ if ( level < 29 )
+ draw_apples();
+
+ if ( level >= 24 )
+ draw_bonus();
+ }
+
+ update_shots();
+ update_power();
+}
+
+/*
+ * This is called during gameplay to update the score, shots,
+ * and power displays
+ */
+
+void update_score(void)
+{
+ color(0,gp.c);
+ lprintf(1,7,"%- 11lld",gp.Sc);
+}
+
+void update_shots(void)
+{
+ if ( gp.KulSpr > 0 ) {
+ color(0,gp.c2);
+ lprintf(25,9," SHOTS %2d ", gp.KulSpr);
+ color(0,gp.c);
+ } else {
+ color(0,gp.c);
+ lprint(25,9," ");
+ }
+}
+
+void update_power(void)
+{
+ color(0,gp.c);
+ lprintf(25,20,"POWER %-4d", gp.GkCh);
+}
+
+/*
+ * This is called during gameplay to display a message on line 24
+ */
+void message(int col, const char *fmt, ...)
+{
+ char buffer[4096];
+ char msgbuf[41];
+ int len;
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsprintf(buffer, fmt, ap);
+ va_end(ap);
+
+ len = strlen(buffer);
+ msgbuf[40] = '\0';
+
+ if ( len > 40 ) {
+ memcpy(msgbuf, buffer, 40);
+ } else {
+ memset(msgbuf, ' ', 40);
+ memcpy(msgbuf+(40-len)/2, buffer, len);
+ }
+
+ color(col,gp.c);
+ lprint(24,1,msgbuf);
+}