Dependencies: Led-libary TextLCD mbed
main.cpp@10:f635972952e0, 2016-03-13 (annotated)
- Committer:
- ladner
- Date:
- Sun Mar 13 00:18:29 2016 +0000
- Revision:
- 10:f635972952e0
- Parent:
- 9:cb931ad9731d
- Child:
- 11:caa67a0ab7bd
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ladner | 0:e97a6a69fe4b | 1 | #include "mbed.h" |
ladner | 1:0eaa7682f7e1 | 2 | #include "WS2812B.h" |
ladner | 5:31d406df862a | 3 | #include "TextLCD.h" |
ladner | 0:e97a6a69fe4b | 4 | |
ladner | 0:e97a6a69fe4b | 5 | I2C i2c(P0_5,P0_4); |
ladner | 0:e97a6a69fe4b | 6 | Serial port(P0_19,P0_18); |
ladner | 0:e97a6a69fe4b | 7 | BusOut myled(P1_8,P1_9,P1_10,P1_11,P1_0,P1_1,P1_3,P1_4,P1_6,P1_7,P1_12,P1_13); |
ladner | 0:e97a6a69fe4b | 8 | AnalogIn ldr(P0_12); |
ladner | 0:e97a6a69fe4b | 9 | AnalogIn poti(P0_11); |
ladner | 1:0eaa7682f7e1 | 10 | //BusOut rgb(P0_9,P1_15,P0_21); |
ladner | 1:0eaa7682f7e1 | 11 | //BusIn btn(P1_16,P0_23,P0_10,P0_15); |
ladner | 1:0eaa7682f7e1 | 12 | |
ladner | 1:0eaa7682f7e1 | 13 | RGBOut rgb(P0_21,P0_9,P1_15); |
ladner | 5:31d406df862a | 14 | //Old: P0_13 |
ladner | 5:31d406df862a | 15 | LedOut Feld (P1_23);//P1_23 ->14 |
ladner | 5:31d406df862a | 16 | LedOut Home (P1_20);//P1_20->13 |
ladner | 5:31d406df862a | 17 | LedOut Dice (P1_21);//P1_21->12 |
ladner | 5:31d406df862a | 18 | //-> Würfel (ersten 3 LED in Binär-4. LED für 7. Zustand), Spieler, Start, Ziel, Referenz(auch RGB am board) |
ladner | 1:0eaa7682f7e1 | 19 | // übrige 8 LED für zeit-Anzeige des Zuges einer KI |
ladner | 1:0eaa7682f7e1 | 20 | |
ladner | 1:0eaa7682f7e1 | 21 | InterruptIn Button0(P0_1); |
ladner | 0:e97a6a69fe4b | 22 | InterruptIn Button1(P1_16); |
ladner | 0:e97a6a69fe4b | 23 | InterruptIn Button2(P0_23); |
ladner | 1:0eaa7682f7e1 | 24 | InterruptIn Button3(P0_10); |
ladner | 1:0eaa7682f7e1 | 25 | InterruptIn Button4(P0_15); |
ladner | 0:e97a6a69fe4b | 26 | |
ladner | 1:0eaa7682f7e1 | 27 | Timer Random; |
ladner | 5:31d406df862a | 28 | Timer RandomDice; |
ladner | 1:0eaa7682f7e1 | 29 | |
ladner | 1:0eaa7682f7e1 | 30 | Ticker DiceAnim; |
ladner | 1:0eaa7682f7e1 | 31 | void DiceStart(); |
ladner | 1:0eaa7682f7e1 | 32 | void DiceStop(); |
ladner | 1:0eaa7682f7e1 | 33 | void DiceRun(); |
ladner | 1:0eaa7682f7e1 | 34 | void setDice(char number); |
ladner | 1:0eaa7682f7e1 | 35 | void DicePrint(); |
ladner | 10:f635972952e0 | 36 | void DiceCal(); //umrechning des 7.Zustands in eine Zahl zwischen 1 & 6 |
ladner | 1:0eaa7682f7e1 | 37 | char dicePos = 0; |
ladner | 1:0eaa7682f7e1 | 38 | char diceEn = 0; |
ladner | 1:0eaa7682f7e1 | 39 | char diceTick = 0; |
ladner | 1:0eaa7682f7e1 | 40 | char diceNum = 0; |
ladner | 1:0eaa7682f7e1 | 41 | int16_t diceDecode [7]= {0x1,0x88,0x89,0xAA,0xAB,0x1BA,0x154}; |
ladner | 1:0eaa7682f7e1 | 42 | |
ladner | 1:0eaa7682f7e1 | 43 | #define Feldgrose 10 |
ladner | 1:0eaa7682f7e1 | 44 | #define Spieler 4 |
ladner | 1:0eaa7682f7e1 | 45 | #define Steine 4 |
ladner | 1:0eaa7682f7e1 | 46 | |
ladner | 1:0eaa7682f7e1 | 47 | char PlayPos[Spieler*Steine]; //Zahl zwischen 0 & 47 ((0xC0 -> Spieler)>>2 / 0x03 -> Stein) |
ladner | 5:31d406df862a | 48 | char Start[Spieler*Steine]; //Enthält den Index für PlayPos (nur das 'normale' Spielfend) |
ladner | 5:31d406df862a | 49 | char Ziel[Spieler*Steine]; //Enthält den Index für PlayPos (nur das 'normale' Spielfend) |
ladner | 1:0eaa7682f7e1 | 50 | char Drann; //Spieler, der drann ist |
ladner | 1:0eaa7682f7e1 | 51 | char count; //Für 6er & mehrfaches Würfeln beim Ansetzen |
ladner | 1:0eaa7682f7e1 | 52 | char last[Spieler]; //zuletzt benutzte Spielstein, der zuletzt benutzt wurde |
ladner | 1:0eaa7682f7e1 | 53 | char moglich[Steine]; |
ladner | 1:0eaa7682f7e1 | 54 | char selected; //der aktuell ausgewählte Zug |
ladner | 1:0eaa7682f7e1 | 55 | char Field[Spieler*Feldgrose]; //Enthält den Index für PlayPos (nur das 'normale' Spielfend) |
ladner | 1:0eaa7682f7e1 | 56 | uint32_t Farben[Spieler]; //Berechnete Hellichkeiten der Speiler fertig zur Ausgabe... |
ladner | 7:6b4048a2b9ff | 57 | uint32_t Background = 0; //Hintergrund (Leerfeld) |
ladner | 7:6b4048a2b9ff | 58 | uint32_t DiseC = 0x00FF00; //Würfelfarbe |
ladner | 1:0eaa7682f7e1 | 59 | void FieldPrint(); //Ausgabe auf Com-Port |
ladner | 1:0eaa7682f7e1 | 60 | void FieldGenerate(); //Berechnung von PlayPos auf Start, Ziel, Field |
ladner | 1:0eaa7682f7e1 | 61 | void FeldPrint(); //Ausgabe von Field auf den Led-Streifen (Feld) der Farben |
ladner | 1:0eaa7682f7e1 | 62 | void GameCal(); |
ladner | 1:0eaa7682f7e1 | 63 | void moveNext(); |
ladner | 1:0eaa7682f7e1 | 64 | void moveLast(); |
ladner | 1:0eaa7682f7e1 | 65 | Ticker MoveAnim; |
ladner | 1:0eaa7682f7e1 | 66 | void MoveRun(); |
ladner | 1:0eaa7682f7e1 | 67 | char MoveShow; |
ladner | 1:0eaa7682f7e1 | 68 | void MoveDo(); |
ladner | 4:2acb70f9cd22 | 69 | void ColorPrint(uint32_t color); |
ladner | 1:0eaa7682f7e1 | 70 | |
ladner | 5:31d406df862a | 71 | char AnimField[Spieler*Feldgrose]; |
ladner | 5:31d406df862a | 72 | char AnimStart[Spieler*Steine]; |
ladner | 5:31d406df862a | 73 | char AnimZiel[Spieler*Steine]; |
ladner | 6:ca3d431f2daf | 74 | char AnimPos[Spieler*Steine]; |
ladner | 6:ca3d431f2daf | 75 | char AnimDo; //Feld_Animieren,Start Animieren, Ziel Animierenw |
ladner | 5:31d406df862a | 76 | void AnimCal(); |
ladner | 10:f635972952e0 | 77 | void reset(); |
ladner | 5:31d406df862a | 78 | |
ladner | 1:0eaa7682f7e1 | 79 | void reset() |
ladner | 1:0eaa7682f7e1 | 80 | { |
ladner | 1:0eaa7682f7e1 | 81 | MoveAnim.detach(); |
ladner | 1:0eaa7682f7e1 | 82 | DiceAnim.detach(); |
ladner | 1:0eaa7682f7e1 | 83 | for(char i = 0;i<Spieler*Steine;i++) |
ladner | 1:0eaa7682f7e1 | 84 | PlayPos[i]=i%4; |
ladner | 5:31d406df862a | 85 | for (char i = 0; i < Spieler; i++) |
ladner | 5:31d406df862a | 86 | last[i]=0; |
ladner | 1:0eaa7682f7e1 | 87 | Drann=0; |
ladner | 1:0eaa7682f7e1 | 88 | diceEn=0; |
ladner | 2:3a90b20958ff | 89 | myled = myled&0xF0F; |
ladner | 1:0eaa7682f7e1 | 90 | DicePrint(); |
ladner | 1:0eaa7682f7e1 | 91 | rgb.set_RGB(0); |
ladner | 1:0eaa7682f7e1 | 92 | FieldGenerate(); |
ladner | 1:0eaa7682f7e1 | 93 | FieldPrint(); |
ladner | 1:0eaa7682f7e1 | 94 | FeldPrint(); |
ladner | 1:0eaa7682f7e1 | 95 | } |
ladner | 1:0eaa7682f7e1 | 96 | |
ladner | 1:0eaa7682f7e1 | 97 | void btn2() |
ladner | 1:0eaa7682f7e1 | 98 | { |
ladner | 5:31d406df862a | 99 | for(char i = 0;i<Spieler;i++) |
ladner | 9:cb931ad9731d | 100 | { |
ladner | 9:cb931ad9731d | 101 | PlayPos[i*Spieler]=Steine+Spieler*Feldgrose; |
ladner | 9:cb931ad9731d | 102 | PlayPos[i*Spieler+1]=Steine+Spieler*Feldgrose+1; |
ladner | 9:cb931ad9731d | 103 | PlayPos[i*Spieler+2]=Spieler*Feldgrose + 2; |
ladner | 9:cb931ad9731d | 104 | PlayPos[i*Spieler+3]=Steine+Spieler*Feldgrose+3; |
ladner | 9:cb931ad9731d | 105 | } |
ladner | 5:31d406df862a | 106 | FieldGenerate(); |
ladner | 5:31d406df862a | 107 | FieldPrint(); |
ladner | 5:31d406df862a | 108 | FeldPrint(); |
ladner | 5:31d406df862a | 109 | /* |
ladner | 5:31d406df862a | 110 | for(char i = 0; i<Spieler;i++) |
ladner | 5:31d406df862a | 111 | for(char j = 0; j<Steine;j++) |
ladner | 5:31d406df862a | 112 | Start[(i<<2)|j] = ((i<<2)|j)+1; |
ladner | 5:31d406df862a | 113 | for(char i = 0; i<Spieler;i++) |
ladner | 5:31d406df862a | 114 | for(char j = 0; j<Steine;j++) |
ladner | 5:31d406df862a | 115 | Ziel[(i<<2)|j] = ((i<<2)|j)+1; |
ladner | 5:31d406df862a | 116 | FeldPrint(); |
ladner | 5:31d406df862a | 117 | */ |
ladner | 5:31d406df862a | 118 | /* |
ladner | 2:3a90b20958ff | 119 | Drann = 0; |
ladner | 2:3a90b20958ff | 120 | PlayPos[1]=Steine+Feldgrose*Spieler; |
ladner | 4:2acb70f9cd22 | 121 | //PlayPos[2]=Steine+Feldgrose*Spieler+1; |
ladner | 4:2acb70f9cd22 | 122 | PlayPos[3]=Steine+Feldgrose*Spieler+2; |
ladner | 4:2acb70f9cd22 | 123 | PlayPos[0]=Steine+Feldgrose*Spieler-1; |
ladner | 1:0eaa7682f7e1 | 124 | FieldGenerate(); |
ladner | 1:0eaa7682f7e1 | 125 | FieldPrint(); |
ladner | 5:31d406df862a | 126 | FeldPrint(); |
ladner | 5:31d406df862a | 127 | */ |
ladner | 1:0eaa7682f7e1 | 128 | } |
ladner | 5:31d406df862a | 129 | |
ladner | 1:0eaa7682f7e1 | 130 | void btn3() |
ladner | 0:e97a6a69fe4b | 131 | { |
ladner | 4:2acb70f9cd22 | 132 | /* |
ladner | 1:0eaa7682f7e1 | 133 | diceNum=2; |
ladner | 1:0eaa7682f7e1 | 134 | diceEn=2; |
ladner | 1:0eaa7682f7e1 | 135 | Drann = 1; |
ladner | 1:0eaa7682f7e1 | 136 | PlayPos[(1<<2)+0]=5; |
ladner | 1:0eaa7682f7e1 | 137 | PlayPos[(1<<2)+1]=7; |
ladner | 1:0eaa7682f7e1 | 138 | PlayPos[(1<<2)+2]=10; |
ladner | 1:0eaa7682f7e1 | 139 | PlayPos[(1<<2)+3]=12; |
ladner | 4:2acb70f9cd22 | 140 | DicePrint(); |
ladner | 1:0eaa7682f7e1 | 141 | FieldGenerate(); |
ladner | 1:0eaa7682f7e1 | 142 | FieldPrint(); |
ladner | 1:0eaa7682f7e1 | 143 | FeldPrint(); |
ladner | 1:0eaa7682f7e1 | 144 | GameCal(); |
ladner | 4:2acb70f9cd22 | 145 | */ |
ladner | 10:f635972952e0 | 146 | /* |
ladner | 4:2acb70f9cd22 | 147 | port.printf("W%c%c\n",27+0x3E,27+0x7); |
ladner | 4:2acb70f9cd22 | 148 | for(char i=0;i<Spieler;i++) |
ladner | 4:2acb70f9cd22 | 149 | { |
ladner | 4:2acb70f9cd22 | 150 | port.printf("w"); |
ladner | 4:2acb70f9cd22 | 151 | ColorPrint(Farben[i]); |
ladner | 4:2acb70f9cd22 | 152 | wait(1); |
ladner | 4:2acb70f9cd22 | 153 | } |
ladner | 10:f635972952e0 | 154 | */ |
ladner | 10:f635972952e0 | 155 | diceEn=5; |
ladner | 1:0eaa7682f7e1 | 156 | } |
ladner | 5:31d406df862a | 157 | |
ladner | 1:0eaa7682f7e1 | 158 | void btn4() |
ladner | 1:0eaa7682f7e1 | 159 | { |
ladner | 1:0eaa7682f7e1 | 160 | /* |
ladner | 1:0eaa7682f7e1 | 161 | for(char i = 0;i<Spieler;i++) |
ladner | 1:0eaa7682f7e1 | 162 | PlayPos[i<<2]=4; |
ladner | 1:0eaa7682f7e1 | 163 | FieldGenerate(); |
ladner | 1:0eaa7682f7e1 | 164 | FieldPrint(); |
ladner | 1:0eaa7682f7e1 | 165 | */ |
ladner | 1:0eaa7682f7e1 | 166 | myled = 0; |
ladner | 1:0eaa7682f7e1 | 167 | rgb.set(0,0,0); |
ladner | 1:0eaa7682f7e1 | 168 | port.printf("LBtn 4 Pressed\n"); |
ladner | 1:0eaa7682f7e1 | 169 | } |
ladner | 1:0eaa7682f7e1 | 170 | |
ladner | 1:0eaa7682f7e1 | 171 | void btn4_() |
ladner | 1:0eaa7682f7e1 | 172 | { |
ladner | 1:0eaa7682f7e1 | 173 | port.printf("LBtn 4 Released\n"); |
ladner | 1:0eaa7682f7e1 | 174 | } |
ladner | 1:0eaa7682f7e1 | 175 | |
ladner | 1:0eaa7682f7e1 | 176 | void Control() |
ladner | 1:0eaa7682f7e1 | 177 | { |
ladner | 1:0eaa7682f7e1 | 178 | while(port.readable ()) |
ladner | 0:e97a6a69fe4b | 179 | { |
ladner | 1:0eaa7682f7e1 | 180 | char message = port.getc(); |
ladner | 1:0eaa7682f7e1 | 181 | switch(message) |
ladner | 1:0eaa7682f7e1 | 182 | { |
ladner | 1:0eaa7682f7e1 | 183 | case '1': |
ladner | 1:0eaa7682f7e1 | 184 | setDice(1); |
ladner | 1:0eaa7682f7e1 | 185 | break; |
ladner | 1:0eaa7682f7e1 | 186 | case '2': |
ladner | 1:0eaa7682f7e1 | 187 | setDice(2); |
ladner | 1:0eaa7682f7e1 | 188 | break; |
ladner | 1:0eaa7682f7e1 | 189 | case '3': |
ladner | 1:0eaa7682f7e1 | 190 | setDice(3); |
ladner | 1:0eaa7682f7e1 | 191 | break; |
ladner | 1:0eaa7682f7e1 | 192 | case '4': |
ladner | 1:0eaa7682f7e1 | 193 | setDice(4); |
ladner | 1:0eaa7682f7e1 | 194 | break; |
ladner | 1:0eaa7682f7e1 | 195 | case '5': |
ladner | 1:0eaa7682f7e1 | 196 | setDice(5); |
ladner | 1:0eaa7682f7e1 | 197 | break; |
ladner | 1:0eaa7682f7e1 | 198 | case '6': |
ladner | 1:0eaa7682f7e1 | 199 | setDice(6); |
ladner | 1:0eaa7682f7e1 | 200 | break; |
ladner | 1:0eaa7682f7e1 | 201 | case '7': |
ladner | 1:0eaa7682f7e1 | 202 | setDice(7); |
ladner | 1:0eaa7682f7e1 | 203 | break; |
ladner | 1:0eaa7682f7e1 | 204 | case 'A': |
ladner | 1:0eaa7682f7e1 | 205 | DiceStart(); |
ladner | 1:0eaa7682f7e1 | 206 | break; |
ladner | 1:0eaa7682f7e1 | 207 | case 'a': |
ladner | 1:0eaa7682f7e1 | 208 | DiceStop(); |
ladner | 1:0eaa7682f7e1 | 209 | break; |
ladner | 1:0eaa7682f7e1 | 210 | case 'B': |
ladner | 1:0eaa7682f7e1 | 211 | moveNext(); |
ladner | 1:0eaa7682f7e1 | 212 | break; |
ladner | 1:0eaa7682f7e1 | 213 | case 'C': |
ladner | 1:0eaa7682f7e1 | 214 | moveLast(); |
ladner | 1:0eaa7682f7e1 | 215 | break; |
ladner | 1:0eaa7682f7e1 | 216 | case 'D': |
ladner | 1:0eaa7682f7e1 | 217 | MoveDo(); |
ladner | 1:0eaa7682f7e1 | 218 | break; |
ladner | 1:0eaa7682f7e1 | 219 | case 'I': |
ladner | 1:0eaa7682f7e1 | 220 | reset(); |
ladner | 1:0eaa7682f7e1 | 221 | break; |
ladner | 1:0eaa7682f7e1 | 222 | } |
ladner | 0:e97a6a69fe4b | 223 | } |
ladner | 0:e97a6a69fe4b | 224 | } |
ladner | 0:e97a6a69fe4b | 225 | |
ladner | 1:0eaa7682f7e1 | 226 | int main() |
ladner | 0:e97a6a69fe4b | 227 | { |
ladner | 1:0eaa7682f7e1 | 228 | Random.start(); |
ladner | 1:0eaa7682f7e1 | 229 | //Random.stop(); |
ladner | 1:0eaa7682f7e1 | 230 | //Random.read_us(); |
ladner | 1:0eaa7682f7e1 | 231 | |
ladner | 1:0eaa7682f7e1 | 232 | //Ticker: |
ladner | 1:0eaa7682f7e1 | 233 | //.attach(&main,[sek]); |
ladner | 1:0eaa7682f7e1 | 234 | //.attach_us(&main,[micro-sec]); |
ladner | 1:0eaa7682f7e1 | 235 | //.detach(); |
ladner | 5:31d406df862a | 236 | wait(0.01); |
ladner | 9:cb931ad9731d | 237 | |
ladner | 1:0eaa7682f7e1 | 238 | Button0.rise(&reset); |
ladner | 1:0eaa7682f7e1 | 239 | Button1.rise(&DiceStart); |
ladner | 1:0eaa7682f7e1 | 240 | Button1.fall(&DiceStop); |
ladner | 1:0eaa7682f7e1 | 241 | Button2.rise(&btn2); |
ladner | 1:0eaa7682f7e1 | 242 | Button3.rise(&btn3); |
ladner | 1:0eaa7682f7e1 | 243 | Button4.rise(&btn4); |
ladner | 1:0eaa7682f7e1 | 244 | Button4.fall(&btn4_); |
ladner | 9:cb931ad9731d | 245 | |
ladner | 1:0eaa7682f7e1 | 246 | //myled = 0xFFF; |
ladner | 1:0eaa7682f7e1 | 247 | port.baud(76800); |
ladner | 1:0eaa7682f7e1 | 248 | port.format(8,Serial::None, 1); |
ladner | 1:0eaa7682f7e1 | 249 | port.attach(&Control); |
ladner | 8:8feae8c8ec8a | 250 | /* |
ladner | 7:6b4048a2b9ff | 251 | Farben[0]=0x00FF00;//Rot |
ladner | 7:6b4048a2b9ff | 252 | Farben[1]=0xFF0000;//Blau |
ladner | 7:6b4048a2b9ff | 253 | Farben[2]=0x0000FF;//Grun |
ladner | 4:2acb70f9cd22 | 254 | Farben[3]=0x00FFFF;//Gelb |
ladner | 7:6b4048a2b9ff | 255 | Background = 0; //Schwarz |
ladner | 7:6b4048a2b9ff | 256 | DiseC = 0x00FF00; //Rot |
ladner | 8:8feae8c8ec8a | 257 | */ |
ladner | 8:8feae8c8ec8a | 258 | Farben[0]=0x000800;//Rot |
ladner | 8:8feae8c8ec8a | 259 | Farben[1]=0x080000;//Blau |
ladner | 8:8feae8c8ec8a | 260 | Farben[2]=0x000008;//Grun |
ladner | 8:8feae8c8ec8a | 261 | Farben[3]=0x000808;//Gelb |
ladner | 8:8feae8c8ec8a | 262 | Background = 0; //Schwarz |
ladner | 8:8feae8c8ec8a | 263 | DiseC = 0x000800; //Rot |
ladner | 8:8feae8c8ec8a | 264 | /* |
ladner | 8:8feae8c8ec8a | 265 | Farben[0]=0xFFFFFF;//Weiß |
ladner | 8:8feae8c8ec8a | 266 | Farben[1]=0xFFFFFF;//Weiß |
ladner | 8:8feae8c8ec8a | 267 | Farben[2]=0xFFFFFF;//Weiß |
ladner | 8:8feae8c8ec8a | 268 | Farben[3]=0xFFFFFF;//Weiß |
ladner | 8:8feae8c8ec8a | 269 | Background = 0xFFFFFF;//Weiß |
ladner | 8:8feae8c8ec8a | 270 | DiseC = 0xFFFFFF; //Weiß |
ladner | 8:8feae8c8ec8a | 271 | */ |
ladner | 7:6b4048a2b9ff | 272 | |
ladner | 1:0eaa7682f7e1 | 273 | __disable_irq(); |
ladner | 1:0eaa7682f7e1 | 274 | for(char i = 0;i<Spieler;i++) |
ladner | 1:0eaa7682f7e1 | 275 | { |
ladner | 1:0eaa7682f7e1 | 276 | Feld.WriteLed(Farben[i]); |
ladner | 1:0eaa7682f7e1 | 277 | for(char j = 0;j<Feldgrose-1;j++) |
ladner | 5:31d406df862a | 278 | if((j==(Feldgrose-2))&(i==(Spieler-1))) |
ladner | 5:31d406df862a | 279 | Feld.WriteLed(0xFFFFFF); |
ladner | 5:31d406df862a | 280 | else |
ladner | 7:6b4048a2b9ff | 281 | Feld.WriteLed(Background); |
ladner | 1:0eaa7682f7e1 | 282 | } |
ladner | 1:0eaa7682f7e1 | 283 | __enable_irq(); |
ladner | 5:31d406df862a | 284 | //reset(); |
ladner | 1:0eaa7682f7e1 | 285 | while(1) ; |
ladner | 0:e97a6a69fe4b | 286 | } |
ladner | 0:e97a6a69fe4b | 287 | |
ladner | 1:0eaa7682f7e1 | 288 | void DiceStart() |
ladner | 1:0eaa7682f7e1 | 289 | { |
ladner | 1:0eaa7682f7e1 | 290 | if(diceEn==0) |
ladner | 1:0eaa7682f7e1 | 291 | { |
ladner | 5:31d406df862a | 292 | RandomDice.start(); |
ladner | 1:0eaa7682f7e1 | 293 | DiceAnim.attach(&DiceRun,0.1); |
ladner | 1:0eaa7682f7e1 | 294 | diceEn = 1; |
ladner | 1:0eaa7682f7e1 | 295 | diceTick = 1; |
ladner | 1:0eaa7682f7e1 | 296 | DicePrint(); |
ladner | 1:0eaa7682f7e1 | 297 | } |
ladner | 1:0eaa7682f7e1 | 298 | } |
ladner | 5:31d406df862a | 299 | |
ladner | 1:0eaa7682f7e1 | 300 | void DiceStop() |
ladner | 0:e97a6a69fe4b | 301 | { |
ladner | 1:0eaa7682f7e1 | 302 | if(diceEn==1) |
ladner | 1:0eaa7682f7e1 | 303 | { |
ladner | 5:31d406df862a | 304 | if(RandomDice.read_us()> 200) |
ladner | 1:0eaa7682f7e1 | 305 | { |
ladner | 1:0eaa7682f7e1 | 306 | DiceAnim.detach(); |
ladner | 1:0eaa7682f7e1 | 307 | diceEn = 2; |
ladner | 1:0eaa7682f7e1 | 308 | diceTick = 0; |
ladner | 1:0eaa7682f7e1 | 309 | diceNum = Random.read_us()%7; |
ladner | 5:31d406df862a | 310 | diceNum = (RandomDice.read_us()+diceNum)%7+1; |
ladner | 5:31d406df862a | 311 | RandomDice.stop(); |
ladner | 5:31d406df862a | 312 | RandomDice.reset(); |
ladner | 10:f635972952e0 | 313 | if(diceNum>=7) |
ladner | 10:f635972952e0 | 314 | DiceCal(); |
ladner | 10:f635972952e0 | 315 | //port.printf("LDiceNum:%d\n",diceNum); |
ladner | 1:0eaa7682f7e1 | 316 | DicePrint(); |
ladner | 1:0eaa7682f7e1 | 317 | GameCal(); |
ladner | 1:0eaa7682f7e1 | 318 | } |
ladner | 1:0eaa7682f7e1 | 319 | } |
ladner | 1:0eaa7682f7e1 | 320 | } |
ladner | 5:31d406df862a | 321 | |
ladner | 10:f635972952e0 | 322 | void DiceCal() |
ladner | 1:0eaa7682f7e1 | 323 | { |
ladner | 1:0eaa7682f7e1 | 324 | if(diceNum>7) |
ladner | 1:0eaa7682f7e1 | 325 | diceNum=7; |
ladner | 1:0eaa7682f7e1 | 326 | if(diceNum==7) |
ladner | 1:0eaa7682f7e1 | 327 | { |
ladner | 1:0eaa7682f7e1 | 328 | diceEn=3; |
ladner | 1:0eaa7682f7e1 | 329 | for(char i = 0;i<Steine;i++) |
ladner | 1:0eaa7682f7e1 | 330 | if((PlayPos[(Drann<<2)|i]>3)&&(PlayPos[(Drann<<2)|i] < 44)) |
ladner | 1:0eaa7682f7e1 | 331 | for(char j = 1;j<=6;j++) |
ladner | 1:0eaa7682f7e1 | 332 | { |
ladner | 1:0eaa7682f7e1 | 333 | char temp = Field[(PlayPos[(Drann<<2)|i]- Steine + Feldgrose * Drann+j) % (Feldgrose*Steine)]; |
ladner | 1:0eaa7682f7e1 | 334 | if(temp>0) |
ladner | 1:0eaa7682f7e1 | 335 | { |
ladner | 1:0eaa7682f7e1 | 336 | temp--; //(Spieler<<2)|Stein |
ladner | 1:0eaa7682f7e1 | 337 | temp = (temp&0xC)>>2;//Spieler |
ladner | 1:0eaa7682f7e1 | 338 | if(temp!=Drann) |
ladner | 1:0eaa7682f7e1 | 339 | if(j<diceNum) |
ladner | 1:0eaa7682f7e1 | 340 | diceNum=j; |
ladner | 1:0eaa7682f7e1 | 341 | } |
ladner | 1:0eaa7682f7e1 | 342 | } |
ladner | 1:0eaa7682f7e1 | 343 | //PlayPos[(Drann<<2)|i] im Feld suchen, weiter setzen, wenn treffer, der kleiner als diceNum ->setzen von diceNum |
ladner | 1:0eaa7682f7e1 | 344 | }//DiceNum == 7 |
ladner | 1:0eaa7682f7e1 | 345 | if(diceNum==7) |
ladner | 1:0eaa7682f7e1 | 346 | diceNum=6; |
ladner | 10:f635972952e0 | 347 | port.printf("LdiceNum:%d\n",diceNum); |
ladner | 10:f635972952e0 | 348 | } |
ladner | 10:f635972952e0 | 349 | |
ladner | 10:f635972952e0 | 350 | void setDice(char number) |
ladner | 10:f635972952e0 | 351 | { |
ladner | 10:f635972952e0 | 352 | if(diceEn==4) |
ladner | 10:f635972952e0 | 353 | { |
ladner | 10:f635972952e0 | 354 | port.printf("LWarning: diceEn:%d -> Game over\n",diceEn); |
ladner | 10:f635972952e0 | 355 | } |
ladner | 10:f635972952e0 | 356 | else |
ladner | 10:f635972952e0 | 357 | { |
ladner | 10:f635972952e0 | 358 | if(diceEn>3) |
ladner | 10:f635972952e0 | 359 | port.printf("LWarning: diceEn:%d\n",diceEn); |
ladner | 10:f635972952e0 | 360 | else |
ladner | 10:f635972952e0 | 361 | port.printf("LdiceEn:%d\n",diceEn); |
ladner | 10:f635972952e0 | 362 | if(diceEn==1) |
ladner | 10:f635972952e0 | 363 | { |
ladner | 10:f635972952e0 | 364 | DiceAnim.detach(); |
ladner | 10:f635972952e0 | 365 | diceTick = 0; |
ladner | 10:f635972952e0 | 366 | RandomDice.stop(); |
ladner | 10:f635972952e0 | 367 | RandomDice.reset(); |
ladner | 10:f635972952e0 | 368 | } |
ladner | 10:f635972952e0 | 369 | diceEn = 2; |
ladner | 10:f635972952e0 | 370 | diceNum = number; |
ladner | 10:f635972952e0 | 371 | if(diceNum>=7) |
ladner | 10:f635972952e0 | 372 | DiceCal(); |
ladner | 10:f635972952e0 | 373 | //port.printf("LForceDice:%d\n",diceNum); |
ladner | 10:f635972952e0 | 374 | DicePrint(); |
ladner | 10:f635972952e0 | 375 | GameCal(); |
ladner | 10:f635972952e0 | 376 | } |
ladner | 1:0eaa7682f7e1 | 377 | } |
ladner | 5:31d406df862a | 378 | |
ladner | 1:0eaa7682f7e1 | 379 | void DiceRun() |
ladner | 1:0eaa7682f7e1 | 380 | { |
ladner | 1:0eaa7682f7e1 | 381 | if(diceTick) |
ladner | 1:0eaa7682f7e1 | 382 | { |
ladner | 1:0eaa7682f7e1 | 383 | diceTick=0; |
ladner | 1:0eaa7682f7e1 | 384 | if(dicePos<7) |
ladner | 1:0eaa7682f7e1 | 385 | dicePos++; |
ladner | 1:0eaa7682f7e1 | 386 | else |
ladner | 1:0eaa7682f7e1 | 387 | dicePos=0; |
ladner | 1:0eaa7682f7e1 | 388 | } |
ladner | 1:0eaa7682f7e1 | 389 | else |
ladner | 1:0eaa7682f7e1 | 390 | diceTick=1; |
ladner | 1:0eaa7682f7e1 | 391 | DicePrint(); |
ladner | 0:e97a6a69fe4b | 392 | } |
ladner | 0:e97a6a69fe4b | 393 | |
ladner | 1:0eaa7682f7e1 | 394 | void DicePrint() |
ladner | 0:e97a6a69fe4b | 395 | { |
ladner | 1:0eaa7682f7e1 | 396 | switch(diceEn) |
ladner | 1:0eaa7682f7e1 | 397 | { |
ladner | 8:8feae8c8ec8a | 398 | case 0: //Schwarz & Drann überschreiben... |
ladner | 1:0eaa7682f7e1 | 399 | myled=(myled&0xFF0); |
ladner | 1:0eaa7682f7e1 | 400 | port.printf("W%c%c\n",27,27); |
ladner | 1:0eaa7682f7e1 | 401 | break; |
ladner | 8:8feae8c8ec8a | 402 | case 1: //Animation |
ladner | 1:0eaa7682f7e1 | 403 | char dice_help = 0xFF-(1<<dicePos); |
ladner | 1:0eaa7682f7e1 | 404 | myled=(myled&0xFF0)|(5)|(diceTick<<1); |
ladner | 1:0eaa7682f7e1 | 405 | //myled = (myled&0xF)|(dice_help<<4); |
ladner | 1:0eaa7682f7e1 | 406 | |
ladner | 1:0eaa7682f7e1 | 407 | port.printf("W%c%c\n" , 27 + diceTick+((dice_help&0x1F)<<1),27 + ((dice_help& 0xE0)>>5)); |
ladner | 1:0eaa7682f7e1 | 408 | break; |
ladner | 8:8feae8c8ec8a | 409 | case 2://Case 3 = Case 2 ->Anzeigen |
ladner | 1:0eaa7682f7e1 | 410 | myled=(myled&0xFF0)|(diceNum); |
ladner | 1:0eaa7682f7e1 | 411 | //myled=myled|0xFF0; |
ladner | 1:0eaa7682f7e1 | 412 | |
ladner | 1:0eaa7682f7e1 | 413 | port.printf("W%c%c\n" , 27 +(diceDecode[diceNum-1]&0x3F),27 + ((diceDecode[diceNum-1]&0x1C0)>>6)); |
ladner | 1:0eaa7682f7e1 | 414 | break; |
ladner | 1:0eaa7682f7e1 | 415 | case 3: |
ladner | 1:0eaa7682f7e1 | 416 | myled=(myled&0xFF0)|(diceNum)|8; |
ladner | 1:0eaa7682f7e1 | 417 | //myled=myled|0xFF0; |
ladner | 1:0eaa7682f7e1 | 418 | |
ladner | 1:0eaa7682f7e1 | 419 | port.printf("W%c%c\n" , 27 +(diceDecode[diceNum-1]&0x3F),27 + ((diceDecode[diceNum-1]&0x1C0)>>6)); |
ladner | 1:0eaa7682f7e1 | 420 | break; |
ladner | 8:8feae8c8ec8a | 421 | case 4://Spiel beendet! Animation? |
ladner | 8:8feae8c8ec8a | 422 | myled=(myled&0xFF0); |
ladner | 8:8feae8c8ec8a | 423 | port.printf("W%c%c\n",27,27); |
ladner | 8:8feae8c8ec8a | 424 | break; |
ladner | 1:0eaa7682f7e1 | 425 | } |
ladner | 0:e97a6a69fe4b | 426 | } |
ladner | 1:0eaa7682f7e1 | 427 | |
ladner | 1:0eaa7682f7e1 | 428 | void FieldGenerate() |
ladner | 1:0eaa7682f7e1 | 429 | { |
ladner | 1:0eaa7682f7e1 | 430 | for(char i = 0; i<Spieler*Feldgrose;i++) |
ladner | 1:0eaa7682f7e1 | 431 | Field[i]=0; //Feld zurücksetzen |
ladner | 5:31d406df862a | 432 | for (char i = 0; i < Spieler*Steine; i++) |
ladner | 5:31d406df862a | 433 | { |
ladner | 5:31d406df862a | 434 | Ziel[i]=0; |
ladner | 5:31d406df862a | 435 | Start[i]=0; |
ladner | 5:31d406df862a | 436 | } |
ladner | 1:0eaa7682f7e1 | 437 | |
ladner | 1:0eaa7682f7e1 | 438 | for(char i = 0; i<Spieler;i++) |
ladner | 1:0eaa7682f7e1 | 439 | for(char j = 0; j<Steine;j++) |
ladner | 1:0eaa7682f7e1 | 440 | { |
ladner | 1:0eaa7682f7e1 | 441 | if (PlayPos[(i<<2)|j] >= Steine) |
ladner | 1:0eaa7682f7e1 | 442 | { |
ladner | 5:31d406df862a | 443 | if (PlayPos[(i<<2)|j] >= (Spieler * Feldgrose + Steine)) |
ladner | 1:0eaa7682f7e1 | 444 | { |
ladner | 5:31d406df862a | 445 | //if (PlayPos[(i<<2)|j] < Steine * Feldgrose+Steine*2) |
ladner | 5:31d406df862a | 446 | Ziel[(PlayPos[(i<<2)|j] - (Spieler * Feldgrose + Steine))|(i<<2)] = ((i<<2)|j) + 1; |
ladner | 1:0eaa7682f7e1 | 447 | //Ziel PlayPos[(i<<2)|j] - 44 |
ladner | 1:0eaa7682f7e1 | 448 | } |
ladner | 1:0eaa7682f7e1 | 449 | else |
ladner | 1:0eaa7682f7e1 | 450 | Field[(PlayPos[(i<<2)|j]- Steine + Feldgrose * i) % (Steine * Feldgrose)] = ((i<<2)|j) + 1; |
ladner | 1:0eaa7682f7e1 | 451 | //Feld (PlayPos[(i<<2)|j]- 4 + 10 * i) % 40 |
ladner | 1:0eaa7682f7e1 | 452 | } |
ladner | 1:0eaa7682f7e1 | 453 | else |
ladner | 5:31d406df862a | 454 | Start[PlayPos[(i<<2)|j]|(i<<2)] = ((i<<2)|j)+1; |
ladner | 1:0eaa7682f7e1 | 455 | //start PlayPos[(i<<2)|j] |
ladner | 1:0eaa7682f7e1 | 456 | } |
ladner | 1:0eaa7682f7e1 | 457 | } |
ladner | 1:0eaa7682f7e1 | 458 | |
ladner | 1:0eaa7682f7e1 | 459 | void FieldPrint() |
ladner | 1:0eaa7682f7e1 | 460 | { |
ladner | 1:0eaa7682f7e1 | 461 | port.printf("F"); |
ladner | 1:0eaa7682f7e1 | 462 | for(char i = 0;i<Spieler*Steine;i++) |
ladner | 1:0eaa7682f7e1 | 463 | { |
ladner | 1:0eaa7682f7e1 | 464 | port.printf("%c",27+PlayPos[i]); |
ladner | 1:0eaa7682f7e1 | 465 | } |
ladner | 1:0eaa7682f7e1 | 466 | port.printf("\n"); |
ladner | 1:0eaa7682f7e1 | 467 | } |
ladner | 1:0eaa7682f7e1 | 468 | |
ladner | 1:0eaa7682f7e1 | 469 | void FeldPrint() |
ladner | 1:0eaa7682f7e1 | 470 | { |
ladner | 1:0eaa7682f7e1 | 471 | __disable_irq(); |
ladner | 1:0eaa7682f7e1 | 472 | for(char i = 0;i<Spieler*Feldgrose;i++) |
ladner | 1:0eaa7682f7e1 | 473 | if(Field[i]>0) |
ladner | 1:0eaa7682f7e1 | 474 | Feld.WriteLed(Farben[((Field[i]- 1)&0x0C)>>2]); |
ladner | 1:0eaa7682f7e1 | 475 | else |
ladner | 7:6b4048a2b9ff | 476 | Feld.WriteLed(Background); |
ladner | 5:31d406df862a | 477 | //char Start[Spieler]; |
ladner | 5:31d406df862a | 478 | //char Ziel[Spieler]; |
ladner | 5:31d406df862a | 479 | char i = 0; |
ladner | 5:31d406df862a | 480 | char j = 0; |
ladner | 5:31d406df862a | 481 | while(i < Steine*Spieler) |
ladner | 5:31d406df862a | 482 | { |
ladner | 5:31d406df862a | 483 | if(Start[i]>0) |
ladner | 5:31d406df862a | 484 | Home.WriteLed(Farben[((Start[i]- 1)&0x0C)>>2]); |
ladner | 5:31d406df862a | 485 | else |
ladner | 7:6b4048a2b9ff | 486 | Home.WriteLed(Background); |
ladner | 5:31d406df862a | 487 | i++; |
ladner | 5:31d406df862a | 488 | } |
ladner | 5:31d406df862a | 489 | do |
ladner | 5:31d406df862a | 490 | { |
ladner | 5:31d406df862a | 491 | if(Ziel[j]>0) |
ladner | 5:31d406df862a | 492 | Home.WriteLed(Farben[((Ziel[j]- 1)&0x0C)>>2]); |
ladner | 5:31d406df862a | 493 | else |
ladner | 7:6b4048a2b9ff | 494 | Home.WriteLed(Background); |
ladner | 5:31d406df862a | 495 | j++; |
ladner | 5:31d406df862a | 496 | }while(j < Steine*Spieler); |
ladner | 1:0eaa7682f7e1 | 497 | __enable_irq(); |
ladner | 0:e97a6a69fe4b | 498 | } |
ladner | 1:0eaa7682f7e1 | 499 | |
ladner | 6:ca3d431f2daf | 500 | void AnimCal() |
ladner | 6:ca3d431f2daf | 501 | { |
ladner | 6:ca3d431f2daf | 502 | for(char i = 0; i<Spieler*Feldgrose;i++) |
ladner | 6:ca3d431f2daf | 503 | AnimField[i]=0; //Feld zurücksetzen |
ladner | 6:ca3d431f2daf | 504 | for (char i = 0; i < Spieler*Steine; i++) |
ladner | 6:ca3d431f2daf | 505 | { |
ladner | 6:ca3d431f2daf | 506 | AnimZiel[i]=0; |
ladner | 6:ca3d431f2daf | 507 | AnimStart[i]=0; |
ladner | 6:ca3d431f2daf | 508 | } |
ladner | 6:ca3d431f2daf | 509 | AnimDo=0;//Feld_Animieren,Start Animieren, Ziel Animieren |
ladner | 6:ca3d431f2daf | 510 | |
ladner | 6:ca3d431f2daf | 511 | //char AnimDo; //Feld_Animieren,Start Animieren, Ziel Animierenw |
ladner | 6:ca3d431f2daf | 512 | |
ladner | 6:ca3d431f2daf | 513 | for (char i = 0; i < Spieler*Steine; i++) //Hauptschleife |
ladner | 6:ca3d431f2daf | 514 | if(i==((Drann<<2)|selected)) |
ladner | 6:ca3d431f2daf | 515 | { |
ladner | 6:ca3d431f2daf | 516 | if(moglich[selected]==1) |
ladner | 6:ca3d431f2daf | 517 | { |
ladner | 6:ca3d431f2daf | 518 | if(PlayPos[i]<Steine) //nicht Draußsen |
ladner | 6:ca3d431f2daf | 519 | { |
ladner | 6:ca3d431f2daf | 520 | AnimDo = AnimDo|3;//Feld&Start |
ladner | 6:ca3d431f2daf | 521 | AnimPos[i] = Steine; //Ausfahren |
ladner | 6:ca3d431f2daf | 522 | char temp = Field[Drann*Feldgrose]; //Ansetzfeld wird analysiert |
ladner | 6:ca3d431f2daf | 523 | if(temp>0) |
ladner | 6:ca3d431f2daf | 524 | { |
ladner | 6:ca3d431f2daf | 525 | //myled = myled|temp<<8; |
ladner | 6:ca3d431f2daf | 526 | temp--; //(Spieler<<2)|Stein |
ladner | 6:ca3d431f2daf | 527 | AnimPos[temp] = (temp & 0x03); //rücksetzung des Feldes... |
ladner | 6:ca3d431f2daf | 528 | } |
ladner | 6:ca3d431f2daf | 529 | } |
ladner | 6:ca3d431f2daf | 530 | else //Draußen |
ladner | 6:ca3d431f2daf | 531 | { |
ladner | 6:ca3d431f2daf | 532 | AnimDo = AnimDo|1; //Feld |
ladner | 6:ca3d431f2daf | 533 | AnimPos[i] = PlayPos[i]+diceNum;; //Weitersetzen |
ladner | 6:ca3d431f2daf | 534 | //PlayPos[(Drann<<2)|selected] |
ladner | 6:ca3d431f2daf | 535 | if(AnimPos[i]<Steine+Spieler*Feldgrose) //noch nicht drinnen |
ladner | 6:ca3d431f2daf | 536 | { |
ladner | 6:ca3d431f2daf | 537 | //Field>0 |
ladner | 6:ca3d431f2daf | 538 | char temp = Field[ (AnimPos[i]-Steine+Feldgrose*Drann) % (Feldgrose*Steine) ]; |
ladner | 6:ca3d431f2daf | 539 | if(temp>0) |
ladner | 6:ca3d431f2daf | 540 | { |
ladner | 6:ca3d431f2daf | 541 | AnimDo = AnimDo|3;//Feld&Start |
ladner | 6:ca3d431f2daf | 542 | //myled = myled|temp<<8; |
ladner | 6:ca3d431f2daf | 543 | temp--; //(Spieler<<2)|Stein |
ladner | 6:ca3d431f2daf | 544 | AnimPos[temp] = (temp & 0x03); //rücksetzung des Feldes... |
ladner | 6:ca3d431f2daf | 545 | } |
ladner | 6:ca3d431f2daf | 546 | } |
ladner | 6:ca3d431f2daf | 547 | else |
ladner | 6:ca3d431f2daf | 548 | AnimDo=AnimDo|7;//Feld&Ziel (Start auch wegen Hardware) |
ladner | 6:ca3d431f2daf | 549 | } |
ladner | 6:ca3d431f2daf | 550 | } |
ladner | 6:ca3d431f2daf | 551 | else |
ladner | 6:ca3d431f2daf | 552 | AnimPos[i] = PlayPos[i]; //Spieler-pos Kopieren, weil es nicht möglich ist... |
ladner | 6:ca3d431f2daf | 553 | } |
ladner | 6:ca3d431f2daf | 554 | else |
ladner | 6:ca3d431f2daf | 555 | AnimPos[i] = PlayPos[i]; //Spieler-pos Kopieren |
ladner | 6:ca3d431f2daf | 556 | //FieldGenerate -> Anim... |
ladner | 6:ca3d431f2daf | 557 | for(char i = 0; i<Spieler;i++) |
ladner | 6:ca3d431f2daf | 558 | for(char j = 0; j<Steine;j++) |
ladner | 6:ca3d431f2daf | 559 | { |
ladner | 6:ca3d431f2daf | 560 | if (AnimPos[(i<<2)|j] >= Steine) |
ladner | 6:ca3d431f2daf | 561 | { |
ladner | 6:ca3d431f2daf | 562 | if (AnimPos[(i<<2)|j] >= (Spieler * Feldgrose + Steine)) |
ladner | 6:ca3d431f2daf | 563 | { |
ladner | 6:ca3d431f2daf | 564 | //if (AnimPos[(i<<2)|j] < Steine * Feldgrose+Steine*2) |
ladner | 6:ca3d431f2daf | 565 | AnimZiel[(AnimPos[(i<<2)|j] - (Spieler * Feldgrose + Steine))|(i<<2)] = ((i<<2)|j) + 1; |
ladner | 6:ca3d431f2daf | 566 | //AnimZiel AnimPos[(i<<2)|j] - 44 |
ladner | 6:ca3d431f2daf | 567 | } |
ladner | 6:ca3d431f2daf | 568 | else |
ladner | 6:ca3d431f2daf | 569 | AnimField[(AnimPos[(i<<2)|j]- Steine + Feldgrose * i) % (Steine * Feldgrose)] = ((i<<2)|j) + 1; |
ladner | 6:ca3d431f2daf | 570 | //Feld (AnimPos[(i<<2)|j]- 4 + 10 * i) % 40 |
ladner | 6:ca3d431f2daf | 571 | } |
ladner | 6:ca3d431f2daf | 572 | else |
ladner | 6:ca3d431f2daf | 573 | AnimStart[AnimPos[(i<<2)|j]|(i<<2)] = ((i<<2)|j)+1; |
ladner | 6:ca3d431f2daf | 574 | //start AnimPos[(i<<2)|j] |
ladner | 6:ca3d431f2daf | 575 | } |
ladner | 6:ca3d431f2daf | 576 | } |
ladner | 6:ca3d431f2daf | 577 | |
ladner | 5:31d406df862a | 578 | void MoveRun() //Animation (zyklisch) |
ladner | 0:e97a6a69fe4b | 579 | { |
ladner | 1:0eaa7682f7e1 | 580 | if(MoveShow) |
ladner | 6:ca3d431f2daf | 581 | MoveShow = 0; |
ladner | 1:0eaa7682f7e1 | 582 | else |
ladner | 1:0eaa7682f7e1 | 583 | MoveShow = 1; |
ladner | 5:31d406df862a | 584 | |
ladner | 1:0eaa7682f7e1 | 585 | if(MoveShow>0) |
ladner | 0:e97a6a69fe4b | 586 | { |
ladner | 1:0eaa7682f7e1 | 587 | port.printf("F"); |
ladner | 1:0eaa7682f7e1 | 588 | for(char i = 0;i<Spieler*Steine;i++) |
ladner | 6:ca3d431f2daf | 589 | { |
ladner | 6:ca3d431f2daf | 590 | port.printf("%c",27+AnimPos[i]); |
ladner | 6:ca3d431f2daf | 591 | } |
ladner | 6:ca3d431f2daf | 592 | port.printf("\n"); |
ladner | 6:ca3d431f2daf | 593 | |
ladner | 6:ca3d431f2daf | 594 | __disable_irq(); |
ladner | 6:ca3d431f2daf | 595 | if((AnimDo&1)>0) |
ladner | 6:ca3d431f2daf | 596 | { |
ladner | 6:ca3d431f2daf | 597 | for(char i = 0;i<Spieler*Feldgrose;i++) |
ladner | 6:ca3d431f2daf | 598 | if(AnimField[i]>0) |
ladner | 6:ca3d431f2daf | 599 | Feld.WriteLed(Farben[((AnimField[i]- 1)&0x0C)>>2]); |
ladner | 6:ca3d431f2daf | 600 | else |
ladner | 7:6b4048a2b9ff | 601 | Feld.WriteLed(Background); |
ladner | 6:ca3d431f2daf | 602 | } |
ladner | 6:ca3d431f2daf | 603 | //char Start[Spieler]; |
ladner | 6:ca3d431f2daf | 604 | //char Ziel[Spieler]; |
ladner | 6:ca3d431f2daf | 605 | char i = 0; |
ladner | 6:ca3d431f2daf | 606 | char j = 0; |
ladner | 6:ca3d431f2daf | 607 | if((AnimDo&2)>0) |
ladner | 6:ca3d431f2daf | 608 | { |
ladner | 6:ca3d431f2daf | 609 | while(i < Steine*Spieler) |
ladner | 1:0eaa7682f7e1 | 610 | { |
ladner | 6:ca3d431f2daf | 611 | if(AnimStart[i]>0) |
ladner | 6:ca3d431f2daf | 612 | Home.WriteLed(Farben[((AnimStart[i]- 1)&0x0C)>>2]); |
ladner | 1:0eaa7682f7e1 | 613 | else |
ladner | 7:6b4048a2b9ff | 614 | Home.WriteLed(Background); |
ladner | 6:ca3d431f2daf | 615 | i++; |
ladner | 1:0eaa7682f7e1 | 616 | } |
ladner | 6:ca3d431f2daf | 617 | } |
ladner | 6:ca3d431f2daf | 618 | if((AnimDo&4)>0) |
ladner | 6:ca3d431f2daf | 619 | { |
ladner | 6:ca3d431f2daf | 620 | do |
ladner | 6:ca3d431f2daf | 621 | { |
ladner | 6:ca3d431f2daf | 622 | if(AnimZiel[j]>0) |
ladner | 6:ca3d431f2daf | 623 | Home.WriteLed(Farben[((AnimZiel[j]- 1)&0x0C)>>2]); |
ladner | 6:ca3d431f2daf | 624 | else |
ladner | 7:6b4048a2b9ff | 625 | Home.WriteLed(Background); |
ladner | 6:ca3d431f2daf | 626 | j++; |
ladner | 6:ca3d431f2daf | 627 | }while(j < Steine*Spieler); |
ladner | 6:ca3d431f2daf | 628 | } |
ladner | 1:0eaa7682f7e1 | 629 | __enable_irq(); |
ladner | 1:0eaa7682f7e1 | 630 | } |
ladner | 1:0eaa7682f7e1 | 631 | else |
ladner | 5:31d406df862a | 632 | { |
ladner | 1:0eaa7682f7e1 | 633 | FieldPrint(); |
ladner | 6:ca3d431f2daf | 634 | __disable_irq(); |
ladner | 6:ca3d431f2daf | 635 | if((AnimDo&1)>0) |
ladner | 6:ca3d431f2daf | 636 | { |
ladner | 6:ca3d431f2daf | 637 | for(char i = 0;i<Spieler*Feldgrose;i++) |
ladner | 6:ca3d431f2daf | 638 | if(Field[i]>0) |
ladner | 6:ca3d431f2daf | 639 | Feld.WriteLed(Farben[((Field[i]- 1)&0x0C)>>2]); |
ladner | 6:ca3d431f2daf | 640 | else |
ladner | 7:6b4048a2b9ff | 641 | Feld.WriteLed(Background); |
ladner | 6:ca3d431f2daf | 642 | } |
ladner | 6:ca3d431f2daf | 643 | //char Start[Spieler]; |
ladner | 6:ca3d431f2daf | 644 | //char Ziel[Spieler]; |
ladner | 6:ca3d431f2daf | 645 | char i = 0; |
ladner | 6:ca3d431f2daf | 646 | char j = 0; |
ladner | 6:ca3d431f2daf | 647 | if((AnimDo&2)>0) |
ladner | 6:ca3d431f2daf | 648 | { |
ladner | 6:ca3d431f2daf | 649 | while(i < Steine*Spieler) |
ladner | 6:ca3d431f2daf | 650 | { |
ladner | 6:ca3d431f2daf | 651 | if(Start[i]>0) |
ladner | 6:ca3d431f2daf | 652 | Home.WriteLed(Farben[((Start[i]- 1)&0x0C)>>2]); |
ladner | 6:ca3d431f2daf | 653 | else |
ladner | 7:6b4048a2b9ff | 654 | Home.WriteLed(Background); |
ladner | 6:ca3d431f2daf | 655 | i++; |
ladner | 6:ca3d431f2daf | 656 | } |
ladner | 6:ca3d431f2daf | 657 | } |
ladner | 6:ca3d431f2daf | 658 | if((AnimDo&4)>0) |
ladner | 6:ca3d431f2daf | 659 | { |
ladner | 6:ca3d431f2daf | 660 | do |
ladner | 6:ca3d431f2daf | 661 | { |
ladner | 6:ca3d431f2daf | 662 | if(Ziel[j]>0) |
ladner | 6:ca3d431f2daf | 663 | Home.WriteLed(Farben[((Ziel[j]- 1)&0x0C)>>2]); |
ladner | 6:ca3d431f2daf | 664 | else |
ladner | 7:6b4048a2b9ff | 665 | Home.WriteLed(Background); |
ladner | 6:ca3d431f2daf | 666 | j++; |
ladner | 6:ca3d431f2daf | 667 | }while(j < Steine*Spieler); |
ladner | 6:ca3d431f2daf | 668 | } |
ladner | 6:ca3d431f2daf | 669 | __enable_irq(); |
ladner | 5:31d406df862a | 670 | } |
ladner | 1:0eaa7682f7e1 | 671 | } |
ladner | 1:0eaa7682f7e1 | 672 | |
ladner | 1:0eaa7682f7e1 | 673 | void moveNext() |
ladner | 1:0eaa7682f7e1 | 674 | { |
ladner | 1:0eaa7682f7e1 | 675 | selected = (selected+1)%Steine; |
ladner | 1:0eaa7682f7e1 | 676 | for(char i = 0;i<Steine;i++) |
ladner | 1:0eaa7682f7e1 | 677 | if(moglich[selected]>0) |
ladner | 1:0eaa7682f7e1 | 678 | break; |
ladner | 1:0eaa7682f7e1 | 679 | else |
ladner | 1:0eaa7682f7e1 | 680 | selected = (selected+1)%Steine; |
ladner | 6:ca3d431f2daf | 681 | AnimCal(); |
ladner | 1:0eaa7682f7e1 | 682 | } |
ladner | 1:0eaa7682f7e1 | 683 | |
ladner | 1:0eaa7682f7e1 | 684 | void moveLast() |
ladner | 1:0eaa7682f7e1 | 685 | { |
ladner | 1:0eaa7682f7e1 | 686 | selected = (selected+3)%Steine; |
ladner | 1:0eaa7682f7e1 | 687 | for(char i = 0;i<Steine;i++) |
ladner | 1:0eaa7682f7e1 | 688 | if(moglich[selected]>0) |
ladner | 1:0eaa7682f7e1 | 689 | break; |
ladner | 1:0eaa7682f7e1 | 690 | else |
ladner | 1:0eaa7682f7e1 | 691 | selected = (selected+3)%Steine; |
ladner | 6:ca3d431f2daf | 692 | AnimCal(); |
ladner | 1:0eaa7682f7e1 | 693 | } |
ladner | 1:0eaa7682f7e1 | 694 | |
ladner | 1:0eaa7682f7e1 | 695 | void GameCal() |
ladner | 1:0eaa7682f7e1 | 696 | { |
ladner | 1:0eaa7682f7e1 | 697 | char drausen = 0; //Ziel |
ladner | 1:0eaa7682f7e1 | 698 | char feld = 0; |
ladner | 1:0eaa7682f7e1 | 699 | char drinnen = 0; //start |
ladner | 2:3a90b20958ff | 700 | char moglichAny = 1; |
ladner | 1:0eaa7682f7e1 | 701 | for(char i = 0;i<Steine;i++) |
ladner | 1:0eaa7682f7e1 | 702 | { |
ladner | 8:8feae8c8ec8a | 703 | if(PlayPos[(Drann<<2)|i]>=Steine) |
ladner | 0:e97a6a69fe4b | 704 | { |
ladner | 8:8feae8c8ec8a | 705 | if(PlayPos[(Drann<<2)|i] >= (Steine+Spieler*Feldgrose)) |
ladner | 1:0eaa7682f7e1 | 706 | drausen++; |
ladner | 1:0eaa7682f7e1 | 707 | else |
ladner | 1:0eaa7682f7e1 | 708 | feld++; |
ladner | 0:e97a6a69fe4b | 709 | } |
ladner | 1:0eaa7682f7e1 | 710 | else |
ladner | 1:0eaa7682f7e1 | 711 | drinnen++; |
ladner | 1:0eaa7682f7e1 | 712 | moglich[i]=0; |
ladner | 1:0eaa7682f7e1 | 713 | } |
ladner | 1:0eaa7682f7e1 | 714 | //Berechnung |
ladner | 2:3a90b20958ff | 715 | //Ausfahren: |
ladner | 2:3a90b20958ff | 716 | //drinnen >0 (Noch Spieler drinnen?) |
ladner | 2:3a90b20958ff | 717 | //Startfeld ist von Spieler belegt |
ladner | 2:3a90b20958ff | 718 | //Ziel ist frei |
ladner | 2:3a90b20958ff | 719 | if((drinnen>0)&&(moglichAny)) |
ladner | 2:3a90b20958ff | 720 | { |
ladner | 4:2acb70f9cd22 | 721 | //port.printf("LDrinnen\n"); |
ladner | 2:3a90b20958ff | 722 | if(((((Field[Feldgrose*Drann]-1) &0x0C) >>2)==Drann)&&(Field[Feldgrose*Drann]>0)) |
ladner | 2:3a90b20958ff | 723 | { |
ladner | 4:2acb70f9cd22 | 724 | //port.printf("LAusfahrt Belegt\n"); |
ladner | 2:3a90b20958ff | 725 | if(((((Field[(Feldgrose*Drann+diceNum)%(Feldgrose*Spieler)]-1) &0x0C) >>2)!=Drann)||(Field[(Feldgrose*Drann+diceNum)%(Feldgrose*Spieler)]==0)) |
ladner | 2:3a90b20958ff | 726 | { |
ladner | 4:2acb70f9cd22 | 727 | //port.printf("LZiel frei (Done)\n"); |
ladner | 2:3a90b20958ff | 728 | moglich[(Field[Feldgrose*Drann]-1) &0x03] = 1; |
ladner | 2:3a90b20958ff | 729 | moglichAny=0; |
ladner | 2:3a90b20958ff | 730 | } |
ladner | 2:3a90b20958ff | 731 | } |
ladner | 0:e97a6a69fe4b | 732 | } |
ladner | 2:3a90b20958ff | 733 | |
ladner | 2:3a90b20958ff | 734 | //Ansetzen |
ladner | 2:3a90b20958ff | 735 | // 6 gewürfelt |
ladner | 2:3a90b20958ff | 736 | //drinnen>0 |
ladner | 2:3a90b20958ff | 737 | //Start-feld ist nicht von Spieler belegt |
ladner | 2:3a90b20958ff | 738 | if((drinnen>0)&&(moglichAny)&&(diceNum==6)) |
ladner | 0:e97a6a69fe4b | 739 | { |
ladner | 4:2acb70f9cd22 | 740 | //port.printf("LDrinnen & 6 \n"); |
ladner | 2:3a90b20958ff | 741 | if(((((Field[Feldgrose*Drann]-1) &0x0C) >>2)!=Drann)||(Field[Feldgrose*Drann]==0)) |
ladner | 1:0eaa7682f7e1 | 742 | { |
ladner | 4:2acb70f9cd22 | 743 | //port.printf("LAusfahrt frei (Done...Schleife)\n"); |
ladner | 2:3a90b20958ff | 744 | moglichAny=0; |
ladner | 1:0eaa7682f7e1 | 745 | for(char i = 0;i<Steine;i++) |
ladner | 1:0eaa7682f7e1 | 746 | if(PlayPos[(Drann<<2)|i]<Steine) |
ladner | 1:0eaa7682f7e1 | 747 | moglich[i]=1; |
ladner | 1:0eaa7682f7e1 | 748 | } |
ladner | 2:3a90b20958ff | 749 | } |
ladner | 2:3a90b20958ff | 750 | |
ladner | 2:3a90b20958ff | 751 | //Fahren |
ladner | 2:3a90b20958ff | 752 | if(moglichAny) |
ladner | 2:3a90b20958ff | 753 | { |
ladner | 4:2acb70f9cd22 | 754 | //port.printf("LNormal...\n"); |
ladner | 2:3a90b20958ff | 755 | for(char i = 0;i<Steine;i++) |
ladner | 0:e97a6a69fe4b | 756 | { |
ladner | 9:cb931ad9731d | 757 | if(PlayPos[(Drann<<2)|i]>=Spieler) //Drausen |
ladner | 1:0eaa7682f7e1 | 758 | { |
ladner | 9:cb931ad9731d | 759 | if((PlayPos[(Drann<<2)|i]+diceNum) < (Steine+Feldgrose*Spieler))//Zeil noch am Feld |
ladner | 1:0eaa7682f7e1 | 760 | { |
ladner | 2:3a90b20958ff | 761 | char temp = Field[(PlayPos[(Drann<<2)|i]- Steine + Feldgrose * Drann+diceNum) % (Feldgrose*Steine)]; //zielfeld |
ladner | 1:0eaa7682f7e1 | 762 | if(temp>0) |
ladner | 1:0eaa7682f7e1 | 763 | { |
ladner | 1:0eaa7682f7e1 | 764 | //myled = myled|temp<<8; |
ladner | 1:0eaa7682f7e1 | 765 | temp--; //(Spieler<<2)|Stein |
ladner | 1:0eaa7682f7e1 | 766 | temp = (temp&0xC)>>2;//Spieler |
ladner | 2:3a90b20958ff | 767 | if(temp!=Drann) //zielfeld ist nicht ich |
ladner | 1:0eaa7682f7e1 | 768 | moglich[i]=1; |
ladner | 1:0eaa7682f7e1 | 769 | } |
ladner | 2:3a90b20958ff | 770 | else//Feld ist leer |
ladner | 1:0eaa7682f7e1 | 771 | moglich[i]=1; |
ladner | 1:0eaa7682f7e1 | 772 | } |
ladner | 2:3a90b20958ff | 773 | else |
ladner | 2:3a90b20958ff | 774 | {//Kollisionsberechnung ins Ziel... |
ladner | 4:2acb70f9cd22 | 775 | if((PlayPos[(Drann<<2)|i]+diceNum)<(Steine*2+ Feldgrose*Spieler))//Schiest nicht über das Ziel hinaus... |
ladner | 9:cb931ad9731d | 776 | if(Ziel[(PlayPos[(Drann<<2)|i]-(Steine+Feldgrose*Spieler)+diceNum)|(Drann<<2)]==0)//Zielfeld ist leer (enthält ja nur mich) |
ladner | 4:2acb70f9cd22 | 777 | moglich[i]=1; |
ladner | 2:3a90b20958ff | 778 | } |
ladner | 1:0eaa7682f7e1 | 779 | } |
ladner | 1:0eaa7682f7e1 | 780 | } |
ladner | 1:0eaa7682f7e1 | 781 | } |
ladner | 2:3a90b20958ff | 782 | |
ladner | 8:8feae8c8ec8a | 783 | |
ladner | 8:8feae8c8ec8a | 784 | //Anzeigen der Möglichkeiten & überhaupt möglich? |
ladner | 2:3a90b20958ff | 785 | moglichAny=0; |
ladner | 1:0eaa7682f7e1 | 786 | myled = myled&0xF0F; |
ladner | 1:0eaa7682f7e1 | 787 | for(char i = 0;i<Steine;i++) |
ladner | 2:3a90b20958ff | 788 | { |
ladner | 1:0eaa7682f7e1 | 789 | myled = myled|(moglich[i]<<i+4); |
ladner | 1:0eaa7682f7e1 | 790 | moglichAny = moglichAny | moglich[i]; |
ladner | 2:3a90b20958ff | 791 | } |
ladner | 8:8feae8c8ec8a | 792 | |
ladner | 8:8feae8c8ec8a | 793 | if(moglichAny) //Fahren möglich |
ladner | 1:0eaa7682f7e1 | 794 | { |
ladner | 1:0eaa7682f7e1 | 795 | selected = (last[Drann]+Steine-1)%Steine; |
ladner | 1:0eaa7682f7e1 | 796 | moveNext(); |
ladner | 1:0eaa7682f7e1 | 797 | MoveAnim.attach(&MoveRun,0.3); |
ladner | 1:0eaa7682f7e1 | 798 | } |
ladner | 8:8feae8c8ec8a | 799 | else //Fahren nicht möglich |
ladner | 1:0eaa7682f7e1 | 800 | { |
ladner | 8:8feae8c8ec8a | 801 | if(feld<=0) //keine am Feld |
ladner | 1:0eaa7682f7e1 | 802 | { |
ladner | 5:31d406df862a | 803 | if(count<2) |
ladner | 4:2acb70f9cd22 | 804 | { |
ladner | 4:2acb70f9cd22 | 805 | diceEn=0; |
ladner | 4:2acb70f9cd22 | 806 | count++; |
ladner | 9:cb931ad9731d | 807 | port.printf("LCount: %d\n",count); |
ladner | 4:2acb70f9cd22 | 808 | } |
ladner | 0:e97a6a69fe4b | 809 | } |
ladner | 1:0eaa7682f7e1 | 810 | } |
ladner | 1:0eaa7682f7e1 | 811 | } |
ladner | 1:0eaa7682f7e1 | 812 | |
ladner | 1:0eaa7682f7e1 | 813 | void MoveDo() |
ladner | 1:0eaa7682f7e1 | 814 | { |
ladner | 8:8feae8c8ec8a | 815 | if((diceEn>1)&(diceEn<4)) |
ladner | 1:0eaa7682f7e1 | 816 | { |
ladner | 5:31d406df862a | 817 | if(moglich[selected]==1) |
ladner | 1:0eaa7682f7e1 | 818 | { |
ladner | 6:ca3d431f2daf | 819 | if(PlayPos[(Drann<<2)|selected]<Steine) //nicht Draußsen |
ladner | 1:0eaa7682f7e1 | 820 | { |
ladner | 6:ca3d431f2daf | 821 | PlayPos[(Drann<<2)|selected] = Steine; //Ausfahren |
ladner | 6:ca3d431f2daf | 822 | char temp = Field[Drann*Feldgrose]; //Ansetzfeld wird analysiert |
ladner | 1:0eaa7682f7e1 | 823 | if(temp>0) |
ladner | 1:0eaa7682f7e1 | 824 | { |
ladner | 1:0eaa7682f7e1 | 825 | //myled = myled|temp<<8; |
ladner | 1:0eaa7682f7e1 | 826 | temp--; //(Spieler<<2)|Stein |
ladner | 1:0eaa7682f7e1 | 827 | PlayPos[temp] = (temp & 0x03); //rücksetzung des Feldes... |
ladner | 1:0eaa7682f7e1 | 828 | } |
ladner | 1:0eaa7682f7e1 | 829 | } |
ladner | 6:ca3d431f2daf | 830 | else //Draußen |
ladner | 5:31d406df862a | 831 | { |
ladner | 6:ca3d431f2daf | 832 | PlayPos[(Drann<<2)|selected] += diceNum; //Weitersetzen |
ladner | 5:31d406df862a | 833 | //PlayPos[(Drann<<2)|selected] |
ladner | 6:ca3d431f2daf | 834 | if(PlayPos[(Drann<<2)|selected]<Steine+Spieler*Feldgrose) //noch nicht drinnen |
ladner | 5:31d406df862a | 835 | { |
ladner | 5:31d406df862a | 836 | //Field>0 |
ladner | 5:31d406df862a | 837 | char temp = Field[ ( PlayPos[(Drann<<2)|selected] - Steine + (Feldgrose * Drann) ) % (Feldgrose*Steine) ]; |
ladner | 5:31d406df862a | 838 | if(temp>0) |
ladner | 5:31d406df862a | 839 | { |
ladner | 5:31d406df862a | 840 | //myled = myled|temp<<8; |
ladner | 5:31d406df862a | 841 | temp--; //(Spieler<<2)|Stein |
ladner | 5:31d406df862a | 842 | PlayPos[temp] = (temp & 0x03); //rücksetzung des Feldes... |
ladner | 5:31d406df862a | 843 | } |
ladner | 5:31d406df862a | 844 | } |
ladner | 5:31d406df862a | 845 | } |
ladner | 5:31d406df862a | 846 | //else //nicht möglich |
ladner | 5:31d406df862a | 847 | |
ladner | 0:e97a6a69fe4b | 848 | } |
ladner | 1:0eaa7682f7e1 | 849 | MoveAnim.detach(); |
ladner | 1:0eaa7682f7e1 | 850 | last[Drann]=selected; |
ladner | 8:8feae8c8ec8a | 851 | myled = myled&0xF0F; |
ladner | 8:8feae8c8ec8a | 852 | count = 0; |
ladner | 8:8feae8c8ec8a | 853 | FieldGenerate(); |
ladner | 8:8feae8c8ec8a | 854 | //Check for Win! |
ladner | 8:8feae8c8ec8a | 855 | char temp = 0; |
ladner | 8:8feae8c8ec8a | 856 | char j = 0; |
ladner | 8:8feae8c8ec8a | 857 | char running = 1; |
ladner | 8:8feae8c8ec8a | 858 | do |
ladner | 1:0eaa7682f7e1 | 859 | { |
ladner | 9:cb931ad9731d | 860 | temp = 0; |
ladner | 8:8feae8c8ec8a | 861 | for (char i = 0; i < Steine; i++) |
ladner | 8:8feae8c8ec8a | 862 | if (Ziel[(Drann<<2)|i]>0) |
ladner | 8:8feae8c8ec8a | 863 | temp++; |
ladner | 8:8feae8c8ec8a | 864 | if((temp==4)&(diceEn>1)) |
ladner | 8:8feae8c8ec8a | 865 | port.printf("LSpieler %d hat das Spiel beendet!\n",Drann); |
ladner | 8:8feae8c8ec8a | 866 | if(temp==4) |
ladner | 8:8feae8c8ec8a | 867 | Drann = (Drann+1)%Spieler; |
ladner | 8:8feae8c8ec8a | 868 | else |
ladner | 8:8feae8c8ec8a | 869 | { |
ladner | 9:cb931ad9731d | 870 | if(j==0) |
ladner | 9:cb931ad9731d | 871 | { |
ladner | 9:cb931ad9731d | 872 | if(diceNum<6) |
ladner | 9:cb931ad9731d | 873 | Drann = (Drann+1)%Spieler; |
ladner | 9:cb931ad9731d | 874 | else |
ladner | 9:cb931ad9731d | 875 | running = 0; |
ladner | 9:cb931ad9731d | 876 | } |
ladner | 9:cb931ad9731d | 877 | else |
ladner | 9:cb931ad9731d | 878 | running = 0; |
ladner | 9:cb931ad9731d | 879 | |
ladner | 8:8feae8c8ec8a | 880 | } |
ladner | 8:8feae8c8ec8a | 881 | diceEn = 0; |
ladner | 8:8feae8c8ec8a | 882 | j++; |
ladner | 9:cb931ad9731d | 883 | }while((j<=Spieler)&(running>0)); |
ladner | 8:8feae8c8ec8a | 884 | if(running==1) |
ladner | 8:8feae8c8ec8a | 885 | { |
ladner | 8:8feae8c8ec8a | 886 | port.printf("LSpiel beendet!\n"); |
ladner | 8:8feae8c8ec8a | 887 | diceEn = 4; |
ladner | 1:0eaa7682f7e1 | 888 | } |
ladner | 1:0eaa7682f7e1 | 889 | DicePrint(); |
ladner | 1:0eaa7682f7e1 | 890 | FieldPrint(); |
ladner | 1:0eaa7682f7e1 | 891 | FeldPrint(); |
ladner | 9:cb931ad9731d | 892 | port.printf("LDrann:%d\n",Drann); |
ladner | 1:0eaa7682f7e1 | 893 | } |
ladner | 4:2acb70f9cd22 | 894 | } |
ladner | 5:31d406df862a | 895 | |
ladner | 4:2acb70f9cd22 | 896 | void ColorPrint(uint32_t color) |
ladner | 4:2acb70f9cd22 | 897 | { |
ladner | 4:2acb70f9cd22 | 898 | port.printf("%c%c%c%c\n",27+((color&0xFC0000)>>18),27+((color&0x03f000)>>12),27+((color&0x000FC0)>>6),27+(color&0x00003F)); |
ladner | 5:31d406df862a | 899 | } |
ladner | 9:cb931ad9731d | 900 | |
ladner | 9:cb931ad9731d | 901 | //http://www.repairfaq.org/REPAIR/F_SNES.html |