Package: invaders / 1.0.0-13

04-change-colors.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Author: Fabian Greffrath <fabian+debian@greffrath.com>
Description: Use PgUp and PgDown to toggle through the color palette
 and use a secret key to toggle "psychedelic mode". ;)

--- invaders-1.0.0.orig/game.c
+++ invaders-1.0.0/game.c
@@ -10,6 +10,8 @@ struct shot_t {
 #define NUMSHOTS 5
 static struct shot_t shots[NUMSHOTS];
 static int8 ship,shipmove;
+static int8 shotcolor=4,shipcolor=5,aliencolor=3;
+static bool psychedelic=false;
 
 struct alien_t {
   int8 x,y; // x==-1 -> dead alien
@@ -27,6 +29,19 @@ inline void reboot()
   outb(0xfe,0x64);
 };
 
+void changecolors(int c)
+{
+        shotcolor+=c;
+        if (shotcolor>15) shotcolor=1;
+        else if (shotcolor<1) shotcolor=15;
+        shipcolor+=c;
+        if (shipcolor>15) shipcolor=1;
+        else if (shipcolor<1) shipcolor=15;
+        aliencolor+=c;
+        if (aliencolor>15) aliencolor=1;
+        else if (aliencolor<1) aliencolor=15;
+}
+
 void resetgame()
 {
   gameover=false;
@@ -59,7 +74,7 @@ void display()
   // display shots
   {
     uint8 i;
-    video_usecolor(4,0);
+    video_usecolor(shotcolor,0);
     for (i=0;i<NUMSHOTS;++i) {
       if (shots[i].x!=-1) {
 	video_putchar(shots[i].x,shots[i].y,'|');
@@ -69,7 +84,7 @@ void display()
 
   // display ship
   {
-    video_usecolor(5,0);
+    video_usecolor(shipcolor,0);
     video_putchar(ship-1,24,'/');
     video_putchar(ship,23,'_');
     video_putchar(ship+1,24,'\\');
@@ -78,7 +93,7 @@ void display()
   // display aliens
   {
     uint8 i;
-    video_usecolor(3,0);
+    video_usecolor(aliencolor,0);
     for (i=0;i<NUMALIENS;++i) {
       if (aliens[i].x!=-1) {
 	video_putchar(aliens[i].x-1,aliens[i].y,'-');
@@ -133,6 +148,25 @@ void keywork()
         reboot();
       }
       break;
+    case 'u':
+      if (pressed) {
+        changecolors(+1);
+      }
+      break;
+    case 'd':
+      if (pressed) {
+        changecolors(-1);
+      }
+      break;
+    case '0':
+      if (pressed) {
+        if (psychedelic==false) psychedelic=true;
+        else {
+          psychedelic=false;
+          shotcolor=4,shipcolor=5,aliencolor=3;
+        }
+      }
+      break;
     };
   };
 };
@@ -233,6 +267,7 @@ void game()
       sounder();
       keywork();
       calculate();
+      if (psychedelic==true) changecolors(+1);
     };
 
     displaygameover();
--- invaders-1.0.0.orig/keyboard.c
+++ invaders-1.0.0/keyboard.c
@@ -31,6 +31,8 @@ void key_decode(uint8 *key, bool *presse
     if (c==0x4b) *key='<';
     if (c==0x48) *key='^';
     if (c==0x50) *key='v';
+    if (c==0x49) *key='u';
+    if (c==0x51) *key='d';
   }else{
     *pressed = ((c&0x80) == 0) ? true : false;
     c &= ~0x80;