Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: STM32F3-Discovery
space_invaders.c@0:404dae88af71, 2016-03-01 (annotated)
- Committer:
- MartinJohnson
- Date:
- Tue Mar 01 02:40:19 2016 +0000
- Revision:
- 0:404dae88af71
space invaders game
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| MartinJohnson | 0:404dae88af71 | 1 | /*************************************************************************** |
| MartinJohnson | 0:404dae88af71 | 2 | * STM32 VGA demo |
| MartinJohnson | 0:404dae88af71 | 3 | * Copyright (C) 2012 Artekit Italy |
| MartinJohnson | 0:404dae88af71 | 4 | * http://www.artekit.eu |
| MartinJohnson | 0:404dae88af71 | 5 | * Written by Ruben H. Meleca |
| MartinJohnson | 0:404dae88af71 | 6 | |
| MartinJohnson | 0:404dae88af71 | 7 | ### space_invaders.c |
| MartinJohnson | 0:404dae88af71 | 8 | |
| MartinJohnson | 0:404dae88af71 | 9 | # This program is free software; you can redistribute it and/or modify |
| MartinJohnson | 0:404dae88af71 | 10 | # it under the terms of the GNU General Public License as published by |
| MartinJohnson | 0:404dae88af71 | 11 | # the Free Software Foundation; either version 2 of the License, or |
| MartinJohnson | 0:404dae88af71 | 12 | # (at your option) any later version. |
| MartinJohnson | 0:404dae88af71 | 13 | # |
| MartinJohnson | 0:404dae88af71 | 14 | # This program is distributed in the hope that it will be useful, |
| MartinJohnson | 0:404dae88af71 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MartinJohnson | 0:404dae88af71 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| MartinJohnson | 0:404dae88af71 | 17 | # GNU General Public License for more details. |
| MartinJohnson | 0:404dae88af71 | 18 | # |
| MartinJohnson | 0:404dae88af71 | 19 | # You should have received a copy of the GNU General Public License |
| MartinJohnson | 0:404dae88af71 | 20 | # along with this program; if not, write to the Free Software |
| MartinJohnson | 0:404dae88af71 | 21 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| MartinJohnson | 0:404dae88af71 | 22 | |
| MartinJohnson | 0:404dae88af71 | 23 | ***************************************************************************/ |
| MartinJohnson | 0:404dae88af71 | 24 | |
| MartinJohnson | 0:404dae88af71 | 25 | #include "stm32f30x.h" |
| MartinJohnson | 0:404dae88af71 | 26 | #include "sys.h" |
| MartinJohnson | 0:404dae88af71 | 27 | #include "video.h" |
| MartinJohnson | 0:404dae88af71 | 28 | #include "gdi.h" |
| MartinJohnson | 0:404dae88af71 | 29 | #include "space_invaders.h" |
| MartinJohnson | 0:404dae88af71 | 30 | //#include <string.h> |
| MartinJohnson | 0:404dae88af71 | 31 | //#include <stdio.h> |
| MartinJohnson | 0:404dae88af71 | 32 | //#include <stdlib.h> |
| MartinJohnson | 0:404dae88af71 | 33 | |
| MartinJohnson | 0:404dae88af71 | 34 | extern volatile u32 sysTicks; |
| MartinJohnson | 0:404dae88af71 | 35 | |
| MartinJohnson | 0:404dae88af71 | 36 | |
| MartinJohnson | 0:404dae88af71 | 37 | |
| MartinJohnson | 0:404dae88af71 | 38 | |
| MartinJohnson | 0:404dae88af71 | 39 | extern u8 siLogo[VID_VSIZE][VID_HSIZE]; |
| MartinJohnson | 0:404dae88af71 | 40 | |
| MartinJohnson | 0:404dae88af71 | 41 | //extern volatile u32 sysTicks; |
| MartinJohnson | 0:404dae88af71 | 42 | |
| MartinJohnson | 0:404dae88af71 | 43 | const u8 siBadBoys99[] = { 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 44 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 45 | 0x21, 0x08, |
| MartinJohnson | 0:404dae88af71 | 46 | 0x11, 0x10, |
| MartinJohnson | 0:404dae88af71 | 47 | 0x09, 0x20, |
| MartinJohnson | 0:404dae88af71 | 48 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 49 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 50 | 0x09, 0x20, |
| MartinJohnson | 0:404dae88af71 | 51 | 0x11, 0x10, |
| MartinJohnson | 0:404dae88af71 | 52 | 0x21, 0x08, |
| MartinJohnson | 0:404dae88af71 | 53 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 54 | 0x00, 0x00 }; |
| MartinJohnson | 0:404dae88af71 | 55 | |
| MartinJohnson | 0:404dae88af71 | 56 | const u8 siBadBoys00[] = { 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 57 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 58 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 59 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 60 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 61 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 62 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 63 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 64 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 65 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 66 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 67 | 0x00, 0x00 }; |
| MartinJohnson | 0:404dae88af71 | 68 | |
| MartinJohnson | 0:404dae88af71 | 69 | const u8 siBadBoys01[] = { 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 70 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 71 | 0x03, 0x80, |
| MartinJohnson | 0:404dae88af71 | 72 | 0x07, 0xc0, |
| MartinJohnson | 0:404dae88af71 | 73 | 0x0f, 0xe0, |
| MartinJohnson | 0:404dae88af71 | 74 | 0x1b, 0xb0, |
| MartinJohnson | 0:404dae88af71 | 75 | 0x1f, 0xf0, |
| MartinJohnson | 0:404dae88af71 | 76 | 0x04, 0x40, |
| MartinJohnson | 0:404dae88af71 | 77 | 0x0b, 0xa0, |
| MartinJohnson | 0:404dae88af71 | 78 | 0x14, 0x50, |
| MartinJohnson | 0:404dae88af71 | 79 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 80 | 0x00, 0x00 }; |
| MartinJohnson | 0:404dae88af71 | 81 | |
| MartinJohnson | 0:404dae88af71 | 82 | const u8 siBadBoys02[] = { 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 83 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 84 | 0x03, 0x80, |
| MartinJohnson | 0:404dae88af71 | 85 | 0x07, 0xc0, |
| MartinJohnson | 0:404dae88af71 | 86 | 0x0f, 0xe0, |
| MartinJohnson | 0:404dae88af71 | 87 | 0x1b, 0xb0, |
| MartinJohnson | 0:404dae88af71 | 88 | 0x1f, 0xf0, |
| MartinJohnson | 0:404dae88af71 | 89 | 0x04, 0x40, |
| MartinJohnson | 0:404dae88af71 | 90 | 0x0b, 0xa0, |
| MartinJohnson | 0:404dae88af71 | 91 | 0x08, 0x20, |
| MartinJohnson | 0:404dae88af71 | 92 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 93 | 0x00, 0x00 }; |
| MartinJohnson | 0:404dae88af71 | 94 | |
| MartinJohnson | 0:404dae88af71 | 95 | |
| MartinJohnson | 0:404dae88af71 | 96 | const u8 siBadBoys11[] = { 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 97 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 98 | 0x08, 0x20, |
| MartinJohnson | 0:404dae88af71 | 99 | 0x04, 0x40, |
| MartinJohnson | 0:404dae88af71 | 100 | 0x0f, 0xe0, |
| MartinJohnson | 0:404dae88af71 | 101 | 0x1b, 0xb0, |
| MartinJohnson | 0:404dae88af71 | 102 | 0x3f, 0xf8, |
| MartinJohnson | 0:404dae88af71 | 103 | 0x2f, 0xe8, |
| MartinJohnson | 0:404dae88af71 | 104 | 0x28, 0x28, |
| MartinJohnson | 0:404dae88af71 | 105 | 0x06, 0xc0, |
| MartinJohnson | 0:404dae88af71 | 106 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 107 | 0x00, 0x00 }; |
| MartinJohnson | 0:404dae88af71 | 108 | |
| MartinJohnson | 0:404dae88af71 | 109 | const u8 siBadBoys12[] = { 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 110 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 111 | 0x08, 0x20, |
| MartinJohnson | 0:404dae88af71 | 112 | 0x24, 0x48, |
| MartinJohnson | 0:404dae88af71 | 113 | 0x2f, 0xe8, |
| MartinJohnson | 0:404dae88af71 | 114 | 0x3b, 0xb8, |
| MartinJohnson | 0:404dae88af71 | 115 | 0x3f, 0xf8, |
| MartinJohnson | 0:404dae88af71 | 116 | 0x1f, 0xf0, |
| MartinJohnson | 0:404dae88af71 | 117 | 0x08, 0x20, |
| MartinJohnson | 0:404dae88af71 | 118 | 0x10, 0x10, |
| MartinJohnson | 0:404dae88af71 | 119 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 120 | 0x00, 0x00 }; |
| MartinJohnson | 0:404dae88af71 | 121 | |
| MartinJohnson | 0:404dae88af71 | 122 | const u8 siBadBoys21[] = { 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 123 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 124 | 0x07, 0xc0, |
| MartinJohnson | 0:404dae88af71 | 125 | 0x1f, 0xf0, |
| MartinJohnson | 0:404dae88af71 | 126 | 0x3f, 0xf8, |
| MartinJohnson | 0:404dae88af71 | 127 | 0x33, 0x98, |
| MartinJohnson | 0:404dae88af71 | 128 | 0x3f, 0xf8, |
| MartinJohnson | 0:404dae88af71 | 129 | 0x0c, 0x60, |
| MartinJohnson | 0:404dae88af71 | 130 | 0x1b, 0xb0, |
| MartinJohnson | 0:404dae88af71 | 131 | 0x30, 0x18, |
| MartinJohnson | 0:404dae88af71 | 132 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 133 | 0x00, 0x00 }; |
| MartinJohnson | 0:404dae88af71 | 134 | |
| MartinJohnson | 0:404dae88af71 | 135 | const u8 siBadBoys22[] = { 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 136 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 137 | 0x07, 0xc0, |
| MartinJohnson | 0:404dae88af71 | 138 | 0x1f, 0xf0, |
| MartinJohnson | 0:404dae88af71 | 139 | 0x3f, 0xf8, |
| MartinJohnson | 0:404dae88af71 | 140 | 0x33, 0x98, |
| MartinJohnson | 0:404dae88af71 | 141 | 0x3f, 0xf8, |
| MartinJohnson | 0:404dae88af71 | 142 | 0x0c, 0x60, |
| MartinJohnson | 0:404dae88af71 | 143 | 0x1b, 0xb0, |
| MartinJohnson | 0:404dae88af71 | 144 | 0x0c, 0x60, |
| MartinJohnson | 0:404dae88af71 | 145 | 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 146 | 0x00, 0x00 }; |
| MartinJohnson | 0:404dae88af71 | 147 | |
| MartinJohnson | 0:404dae88af71 | 148 | const u8 siGoodBoys[] = { 0x00, 0x18, 0x00, |
| MartinJohnson | 0:404dae88af71 | 149 | 0x00, 0x18, 0x00, |
| MartinJohnson | 0:404dae88af71 | 150 | 0x00, 0x3c, 0x00, |
| MartinJohnson | 0:404dae88af71 | 151 | 0x00, 0xff, 0x00, |
| MartinJohnson | 0:404dae88af71 | 152 | 0x0f, 0xff, 0xf0, |
| MartinJohnson | 0:404dae88af71 | 153 | 0x3f, 0xff, 0xfc, |
| MartinJohnson | 0:404dae88af71 | 154 | 0x3f, 0xff, 0xfc, |
| MartinJohnson | 0:404dae88af71 | 155 | 0x3f, 0xff, 0xfc, |
| MartinJohnson | 0:404dae88af71 | 156 | 0x3c, 0x00, 0x3c }; |
| MartinJohnson | 0:404dae88af71 | 157 | |
| MartinJohnson | 0:404dae88af71 | 158 | const u8 siGoodBoysBlk[] = { 0x00, 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 159 | 0x00, 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 160 | 0x00, 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 161 | 0x00, 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 162 | 0x00, 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 163 | 0x00, 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 164 | 0x00, 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 165 | 0x00, 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 166 | 0x00, 0x00, 0x00 }; |
| MartinJohnson | 0:404dae88af71 | 167 | |
| MartinJohnson | 0:404dae88af71 | 168 | const u8 siBadBomb00[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| MartinJohnson | 0:404dae88af71 | 169 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
| MartinJohnson | 0:404dae88af71 | 170 | const u8 siBadBomb01[] = { 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x40, |
| MartinJohnson | 0:404dae88af71 | 171 | 0x80, 0x40, 0x20, 0x40, 0x80, 0x40, 0x20 }; |
| MartinJohnson | 0:404dae88af71 | 172 | const u8 siBadBomb02[] = { 0x00, 0x00, 0x00, 0x20, 0x40, 0x80, 0x40, |
| MartinJohnson | 0:404dae88af71 | 173 | 0x20, 0x40, 0x80, 0x40, 0x20, 0x40, 0x80 }; |
| MartinJohnson | 0:404dae88af71 | 174 | |
| MartinJohnson | 0:404dae88af71 | 175 | const u8 siGoodBomb1[] = { 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00 }; |
| MartinJohnson | 0:404dae88af71 | 176 | const u8 siGoodBomb2[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
| MartinJohnson | 0:404dae88af71 | 177 | |
| MartinJohnson | 0:404dae88af71 | 178 | |
| MartinJohnson | 0:404dae88af71 | 179 | const u8 siDefs1[] = { 0xe0, 0xe0, 0xe0, 0xe0, 0xe0 }; |
| MartinJohnson | 0:404dae88af71 | 180 | const u8 siDefs2[] = { 0x00, 0x00, 0x00, 0x00, 0x00 }; |
| MartinJohnson | 0:404dae88af71 | 181 | |
| MartinJohnson | 0:404dae88af71 | 182 | void numtostr(char *buffer,int n); |
| MartinJohnson | 0:404dae88af71 | 183 | |
| MartinJohnson | 0:404dae88af71 | 184 | const pu8 siVesselPoints[] = { |
| MartinJohnson | 0:404dae88af71 | 185 | "= 30 POINTS", |
| MartinJohnson | 0:404dae88af71 | 186 | "= 20 POINTS", |
| MartinJohnson | 0:404dae88af71 | 187 | "= 10 POINTS" }; |
| MartinJohnson | 0:404dae88af71 | 188 | |
| MartinJohnson | 0:404dae88af71 | 189 | const pu8 siPressKey = "PRESS ANY BUTTON TO START GAME"; |
| MartinJohnson | 0:404dae88af71 | 190 | |
| MartinJohnson | 0:404dae88af71 | 191 | #define CCM __attribute__ ((section (".ccmram"))) static |
| MartinJohnson | 0:404dae88af71 | 192 | |
| MartinJohnson | 0:404dae88af71 | 193 | static SI_BADBOY sibb[SI_MAXBADBOYS_ROWS][SI_MAXBADBOYS_COLS]; |
| MartinJohnson | 0:404dae88af71 | 194 | static SI_BOMB siBomb[SI_MAXBADBOYSBOMB]; |
| MartinJohnson | 0:404dae88af71 | 195 | |
| MartinJohnson | 0:404dae88af71 | 196 | static SI_DEFENSE sidef1[SI_MAXDEFENSES_ROWS][SI_MAXDEFENSES_COLS]; |
| MartinJohnson | 0:404dae88af71 | 197 | static SI_DEFENSE sidef2[SI_MAXDEFENSES_ROWS][SI_MAXDEFENSES_COLS]; |
| MartinJohnson | 0:404dae88af71 | 198 | static SI_DEFENSE sidef3[SI_MAXDEFENSES_ROWS][SI_MAXDEFENSES_COLS]; |
| MartinJohnson | 0:404dae88af71 | 199 | static SI_DEFENSE sidef4[SI_MAXDEFENSES_ROWS][SI_MAXDEFENSES_COLS]; |
| MartinJohnson | 0:404dae88af71 | 200 | |
| MartinJohnson | 0:404dae88af71 | 201 | static i16 siXGoodBoy = SI_GOODBOYSTART_X; |
| MartinJohnson | 0:404dae88af71 | 202 | static i16 siYGoodBoy = SI_GOODBOYSTART_Y; |
| MartinJohnson | 0:404dae88af71 | 203 | |
| MartinJohnson | 0:404dae88af71 | 204 | static i16 siGoodBoyCount; |
| MartinJohnson | 0:404dae88af71 | 205 | static i16 siGoodBoyCountOld; |
| MartinJohnson | 0:404dae88af71 | 206 | |
| MartinJohnson | 0:404dae88af71 | 207 | static i16 siGoodBoysKeyDelay; |
| MartinJohnson | 0:404dae88af71 | 208 | static i16 siGoodBombDelay; |
| MartinJohnson | 0:404dae88af71 | 209 | static i16 siGoodBombActive; |
| MartinJohnson | 0:404dae88af71 | 210 | static i16 siGoodBombX; |
| MartinJohnson | 0:404dae88af71 | 211 | static i16 siGoodBombY; |
| MartinJohnson | 0:404dae88af71 | 212 | static i16 siGoodBombKeyState; |
| MartinJohnson | 0:404dae88af71 | 213 | |
| MartinJohnson | 0:404dae88af71 | 214 | static i16 siCurrentScore; |
| MartinJohnson | 0:404dae88af71 | 215 | static i16 siBakScore; |
| MartinJohnson | 0:404dae88af71 | 216 | static i16 siBestScore; |
| MartinJohnson | 0:404dae88af71 | 217 | |
| MartinJohnson | 0:404dae88af71 | 218 | static i16 siBadBoysDelay; |
| MartinJohnson | 0:404dae88af71 | 219 | static i16 siBadBoysShiftX; |
| MartinJohnson | 0:404dae88af71 | 220 | static i16 siBadBoysShiftY; |
| MartinJohnson | 0:404dae88af71 | 221 | static i16 siBadBoysMode; |
| MartinJohnson | 0:404dae88af71 | 222 | static i16 siBadBoysFlip; |
| MartinJohnson | 0:404dae88af71 | 223 | static i16 siBadBoysYCount; |
| MartinJohnson | 0:404dae88af71 | 224 | static i16 siBadBoysBombDelay; |
| MartinJohnson | 0:404dae88af71 | 225 | static i16 siBadBombMoveDelay; |
| MartinJohnson | 0:404dae88af71 | 226 | static i16 siBadBoysCount; // Count Bad Boys. If 0, you win |
| MartinJohnson | 0:404dae88af71 | 227 | static i16 siBadBoyBombOK = 1; // 1 = fire bombs, 0 = No |
| MartinJohnson | 0:404dae88af71 | 228 | |
| MartinJohnson | 0:404dae88af71 | 229 | static u8 siScore[24]; |
| MartinJohnson | 0:404dae88af71 | 230 | static float AccBuffer[3] = {0.0f}; |
| MartinJohnson | 0:404dae88af71 | 231 | |
| MartinJohnson | 0:404dae88af71 | 232 | |
| MartinJohnson | 0:404dae88af71 | 233 | //#undef static |
| MartinJohnson | 0:404dae88af71 | 234 | |
| MartinJohnson | 0:404dae88af71 | 235 | u8 siAnyButtonPressed(void) { |
| MartinJohnson | 0:404dae88af71 | 236 | |
| MartinJohnson | 0:404dae88af71 | 237 | u32 b; |
| MartinJohnson | 0:404dae88af71 | 238 | |
| MartinJohnson | 0:404dae88af71 | 239 | b = GPIOA->IDR; |
| MartinJohnson | 0:404dae88af71 | 240 | return (b&SI_FIRE_BUTTON); |
| MartinJohnson | 0:404dae88af71 | 241 | if ((b & 0x00000001) != (SI_FIRE_BUTTON/* | SI_LEFT_BUTTON | SI_RIGHT_BUTTON*/)) return(1); |
| MartinJohnson | 0:404dae88af71 | 242 | return(0); |
| MartinJohnson | 0:404dae88af71 | 243 | } |
| MartinJohnson | 0:404dae88af71 | 244 | |
| MartinJohnson | 0:404dae88af71 | 245 | void siYouWin(void) { |
| MartinJohnson | 0:404dae88af71 | 246 | |
| MartinJohnson | 0:404dae88af71 | 247 | vidClearScreen(); |
| MartinJohnson | 0:404dae88af71 | 248 | gdiRectangle(0,0,(VID_PIXELS_X - 1),VID_VSIZE - 1,0); |
| MartinJohnson | 0:404dae88af71 | 249 | |
| MartinJohnson | 0:404dae88af71 | 250 | gdiDrawTextEx(167,80,"* YOU WIN *",GDI_ROP_XOR); |
| MartinJohnson | 0:404dae88af71 | 251 | while(1) { |
| MartinJohnson | 0:404dae88af71 | 252 | if (siAnyButtonPressed()) return; |
| MartinJohnson | 0:404dae88af71 | 253 | gdiDrawTextEx(108,170,siPressKey,GDI_ROP_XOR); |
| MartinJohnson | 0:404dae88af71 | 254 | sysDelayMs(400); |
| MartinJohnson | 0:404dae88af71 | 255 | if (siAnyButtonPressed()) return; |
| MartinJohnson | 0:404dae88af71 | 256 | gdiDrawTextEx(108,170,siPressKey,GDI_ROP_XOR); |
| MartinJohnson | 0:404dae88af71 | 257 | if (siAnyButtonPressed()) return; |
| MartinJohnson | 0:404dae88af71 | 258 | sysDelayMs(200); |
| MartinJohnson | 0:404dae88af71 | 259 | }; |
| MartinJohnson | 0:404dae88af71 | 260 | } |
| MartinJohnson | 0:404dae88af71 | 261 | |
| MartinJohnson | 0:404dae88af71 | 262 | void siYouLose(void) { |
| MartinJohnson | 0:404dae88af71 | 263 | |
| MartinJohnson | 0:404dae88af71 | 264 | vidClearScreen(); |
| MartinJohnson | 0:404dae88af71 | 265 | gdiRectangle(0,0,(VID_PIXELS_X - 1),VID_VSIZE - 1,0); |
| MartinJohnson | 0:404dae88af71 | 266 | |
| MartinJohnson | 0:404dae88af71 | 267 | gdiDrawTextEx(164,80,"* YOU LOSE *",GDI_ROP_XOR); |
| MartinJohnson | 0:404dae88af71 | 268 | while(1) { |
| MartinJohnson | 0:404dae88af71 | 269 | if (siAnyButtonPressed()) return; |
| MartinJohnson | 0:404dae88af71 | 270 | gdiDrawTextEx(108,170,siPressKey,GDI_ROP_XOR); |
| MartinJohnson | 0:404dae88af71 | 271 | sysDelayMs(400); |
| MartinJohnson | 0:404dae88af71 | 272 | if (siAnyButtonPressed()) return; |
| MartinJohnson | 0:404dae88af71 | 273 | gdiDrawTextEx(108,170,siPressKey,GDI_ROP_XOR); |
| MartinJohnson | 0:404dae88af71 | 274 | if (siAnyButtonPressed()) return; |
| MartinJohnson | 0:404dae88af71 | 275 | sysDelayMs(200); |
| MartinJohnson | 0:404dae88af71 | 276 | }; |
| MartinJohnson | 0:404dae88af71 | 277 | |
| MartinJohnson | 0:404dae88af71 | 278 | } |
| MartinJohnson | 0:404dae88af71 | 279 | |
| MartinJohnson | 0:404dae88af71 | 280 | char * strcpy(char *dest, char *src) { |
| MartinJohnson | 0:404dae88af71 | 281 | while(*dest++=*src++); |
| MartinJohnson | 0:404dae88af71 | 282 | return dest; |
| MartinJohnson | 0:404dae88af71 | 283 | } |
| MartinJohnson | 0:404dae88af71 | 284 | |
| MartinJohnson | 0:404dae88af71 | 285 | int strlen(const char *str) |
| MartinJohnson | 0:404dae88af71 | 286 | { |
| MartinJohnson | 0:404dae88af71 | 287 | const char *s; |
| MartinJohnson | 0:404dae88af71 | 288 | for (s = str; *s; ++s) |
| MartinJohnson | 0:404dae88af71 | 289 | ; |
| MartinJohnson | 0:404dae88af71 | 290 | return (s - str); |
| MartinJohnson | 0:404dae88af71 | 291 | } |
| MartinJohnson | 0:404dae88af71 | 292 | |
| MartinJohnson | 0:404dae88af71 | 293 | void siInitialScreen(void) { |
| MartinJohnson | 0:404dae88af71 | 294 | |
| MartinJohnson | 0:404dae88af71 | 295 | u16 i, x, y, l, j; |
| MartinJohnson | 0:404dae88af71 | 296 | pu8 ptr = NULL; |
| MartinJohnson | 0:404dae88af71 | 297 | u8 buf[] = " "; |
| MartinJohnson | 0:404dae88af71 | 298 | |
| MartinJohnson | 0:404dae88af71 | 299 | vidClearScreen(); |
| MartinJohnson | 0:404dae88af71 | 300 | |
| MartinJohnson | 0:404dae88af71 | 301 | gdiRectangle(0,0,(VID_PIXELS_X - 1),VID_VSIZE - 1,0); |
| MartinJohnson | 0:404dae88af71 | 302 | |
| MartinJohnson | 0:404dae88af71 | 303 | gdiDrawTextEx(180, 40, "ARTEKIT", GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 304 | gdiDrawTextEx(156, 55, "SPACE INVADERS", GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 305 | gdiDrawTextEx(180, 70, "LEVEL I", GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 306 | |
| MartinJohnson | 0:404dae88af71 | 307 | sysDelayMs(1000); |
| MartinJohnson | 0:404dae88af71 | 308 | |
| MartinJohnson | 0:404dae88af71 | 309 | gdiDrawTextEx(130,110,"* SCORE ADVANCE TABLE *",GDI_ROP_XOR); |
| MartinJohnson | 0:404dae88af71 | 310 | sysDelayMs(400); |
| MartinJohnson | 0:404dae88af71 | 311 | y = 125; |
| MartinJohnson | 0:404dae88af71 | 312 | for (i = 0; i < 3; i++) { |
| MartinJohnson | 0:404dae88af71 | 313 | x = 155; |
| MartinJohnson | 0:404dae88af71 | 314 | switch(i) { |
| MartinJohnson | 0:404dae88af71 | 315 | case 0: ptr = (pu8) siBadBoys01; |
| MartinJohnson | 0:404dae88af71 | 316 | break; |
| MartinJohnson | 0:404dae88af71 | 317 | case 1: ptr = (pu8) siBadBoys11; |
| MartinJohnson | 0:404dae88af71 | 318 | break; |
| MartinJohnson | 0:404dae88af71 | 319 | case 2: ptr = (pu8) siBadBoys21; |
| MartinJohnson | 0:404dae88af71 | 320 | break; |
| MartinJohnson | 0:404dae88af71 | 321 | } |
| MartinJohnson | 0:404dae88af71 | 322 | gdiBitBlt(NULL,x,y,15,12,ptr,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 323 | x += 20; |
| MartinJohnson | 0:404dae88af71 | 324 | l = strlen((const char*)siVesselPoints[i]); |
| MartinJohnson | 0:404dae88af71 | 325 | ptr = siVesselPoints[i]; |
| MartinJohnson | 0:404dae88af71 | 326 | for (j = 0; j < l; j++) { |
| MartinJohnson | 0:404dae88af71 | 327 | sysDelayMs(25); |
| MartinJohnson | 0:404dae88af71 | 328 | buf[0] = *ptr++; |
| MartinJohnson | 0:404dae88af71 | 329 | gdiDrawTextEx(x,y + 2,buf,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 330 | x += 6; |
| MartinJohnson | 0:404dae88af71 | 331 | } |
| MartinJohnson | 0:404dae88af71 | 332 | y += 12; |
| MartinJohnson | 0:404dae88af71 | 333 | sysDelayMs(300); |
| MartinJohnson | 0:404dae88af71 | 334 | } |
| MartinJohnson | 0:404dae88af71 | 335 | while(1) { |
| MartinJohnson | 0:404dae88af71 | 336 | if (siAnyButtonPressed()) return; |
| MartinJohnson | 0:404dae88af71 | 337 | gdiDrawTextEx(108,170,siPressKey,GDI_ROP_XOR); |
| MartinJohnson | 0:404dae88af71 | 338 | sysDelayMs(400); |
| MartinJohnson | 0:404dae88af71 | 339 | if (siAnyButtonPressed()) return; |
| MartinJohnson | 0:404dae88af71 | 340 | gdiDrawTextEx(108,170,siPressKey,GDI_ROP_XOR); |
| MartinJohnson | 0:404dae88af71 | 341 | if (siAnyButtonPressed()) return; |
| MartinJohnson | 0:404dae88af71 | 342 | sysDelayMs(200); |
| MartinJohnson | 0:404dae88af71 | 343 | |
| MartinJohnson | 0:404dae88af71 | 344 | }; |
| MartinJohnson | 0:404dae88af71 | 345 | |
| MartinJohnson | 0:404dae88af71 | 346 | } |
| MartinJohnson | 0:404dae88af71 | 347 | int leftcol, rtcol, count, shiftdown=0; |
| MartinJohnson | 0:404dae88af71 | 348 | |
| MartinJohnson | 0:404dae88af71 | 349 | CCM void siShiftBadboys(void) { |
| MartinJohnson | 0:404dae88af71 | 350 | |
| MartinJohnson | 0:404dae88af71 | 351 | if(shiftdown>0) { |
| MartinJohnson | 0:404dae88af71 | 352 | siBadBoysShiftY += 2; |
| MartinJohnson | 0:404dae88af71 | 353 | shiftdown--; |
| MartinJohnson | 0:404dae88af71 | 354 | } else { |
| MartinJohnson | 0:404dae88af71 | 355 | if (!siBadBoysMode) { |
| MartinJohnson | 0:404dae88af71 | 356 | if (++siBadBoysShiftX+rtcol*20 >= 288) { |
| MartinJohnson | 0:404dae88af71 | 357 | siBadBoysMode = 1; |
| MartinJohnson | 0:404dae88af71 | 358 | siBadBoysShiftX -= 2; |
| MartinJohnson | 0:404dae88af71 | 359 | siBadBoysShiftY += 2; |
| MartinJohnson | 0:404dae88af71 | 360 | shiftdown=8; |
| MartinJohnson | 0:404dae88af71 | 361 | if (siBadBoysYCount < 459) siBadBoysYCount += SI_BADBOYSSPEEDCOUNT; |
| MartinJohnson | 0:404dae88af71 | 362 | } else { |
| MartinJohnson | 0:404dae88af71 | 363 | siBadBoysShiftX += 1; |
| MartinJohnson | 0:404dae88af71 | 364 | } |
| MartinJohnson | 0:404dae88af71 | 365 | } else { |
| MartinJohnson | 0:404dae88af71 | 366 | if ( --siBadBoysShiftX+leftcol*20 < -10) { |
| MartinJohnson | 0:404dae88af71 | 367 | siBadBoysMode = 0; |
| MartinJohnson | 0:404dae88af71 | 368 | siBadBoysShiftX += 2; |
| MartinJohnson | 0:404dae88af71 | 369 | siBadBoysShiftY += 2; |
| MartinJohnson | 0:404dae88af71 | 370 | shiftdown=8; |
| MartinJohnson | 0:404dae88af71 | 371 | if (siBadBoysYCount < 459) siBadBoysYCount += SI_BADBOYSSPEEDCOUNT; |
| MartinJohnson | 0:404dae88af71 | 372 | } else { |
| MartinJohnson | 0:404dae88af71 | 373 | siBadBoysShiftX -= 1; |
| MartinJohnson | 0:404dae88af71 | 374 | } |
| MartinJohnson | 0:404dae88af71 | 375 | } |
| MartinJohnson | 0:404dae88af71 | 376 | } |
| MartinJohnson | 0:404dae88af71 | 377 | |
| MartinJohnson | 0:404dae88af71 | 378 | (siBadBoysFlip == 0) ? (siBadBoysFlip = 1) : (siBadBoysFlip = 0); |
| MartinJohnson | 0:404dae88af71 | 379 | } |
| MartinJohnson | 0:404dae88af71 | 380 | |
| MartinJohnson | 0:404dae88af71 | 381 | |
| MartinJohnson | 0:404dae88af71 | 382 | CCM void siDrawBadboys(void) { |
| MartinJohnson | 0:404dae88af71 | 383 | |
| MartinJohnson | 0:404dae88af71 | 384 | u16 i, n; |
| MartinJohnson | 0:404dae88af71 | 385 | |
| MartinJohnson | 0:404dae88af71 | 386 | if (--siBadBoysDelay > 0) return; |
| MartinJohnson | 0:404dae88af71 | 387 | siBadBoysDelay = SI_BADBOYSSTARTDELAY - siBadBoysYCount; |
| MartinJohnson | 0:404dae88af71 | 388 | leftcol=110;rtcol=0;count=0; |
| MartinJohnson | 0:404dae88af71 | 389 | for (i = 0; i < SI_MAXBADBOYS_ROWS; i++) { |
| MartinJohnson | 0:404dae88af71 | 390 | for (n = 0; n < SI_MAXBADBOYS_COLS; n++) { |
| MartinJohnson | 0:404dae88af71 | 391 | if (sibb[i][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 392 | count++; |
| MartinJohnson | 0:404dae88af71 | 393 | if(n<leftcol) |
| MartinJohnson | 0:404dae88af71 | 394 | leftcol=n; |
| MartinJohnson | 0:404dae88af71 | 395 | if(n>rtcol) |
| MartinJohnson | 0:404dae88af71 | 396 | rtcol=n; |
| MartinJohnson | 0:404dae88af71 | 397 | if (!siBadBoysFlip) { |
| MartinJohnson | 0:404dae88af71 | 398 | gdiBitBlt(NULL,sibb[i][n].x + siBadBoysShiftX,sibb[i][n].y + siBadBoysShiftY,15,12,sibb[i][n].b1,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 399 | } else { |
| MartinJohnson | 0:404dae88af71 | 400 | gdiBitBlt(NULL,sibb[i][n].x + siBadBoysShiftX,sibb[i][n].y + siBadBoysShiftY,15,12,sibb[i][n].b2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 401 | } |
| MartinJohnson | 0:404dae88af71 | 402 | } else { |
| MartinJohnson | 0:404dae88af71 | 403 | if (sibb[i][n].mode == SI_DESTROYED) { |
| MartinJohnson | 0:404dae88af71 | 404 | sibb[i][n].mode = SI_CANCEL; |
| MartinJohnson | 0:404dae88af71 | 405 | gdiBitBlt(NULL,sibb[i][n].x + siBadBoysShiftX,sibb[i][n].y + siBadBoysShiftY,15,12,(pu8) siBadBoys99,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 406 | } else { |
| MartinJohnson | 0:404dae88af71 | 407 | if (sibb[i][n].mode == SI_CANCEL) { |
| MartinJohnson | 0:404dae88af71 | 408 | sibb[i][n].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 409 | gdiBitBlt(NULL,sibb[i][n].x + siBadBoysShiftX,sibb[i][n].y + siBadBoysShiftY,15,12,(pu8) siBadBoys00,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 410 | } |
| MartinJohnson | 0:404dae88af71 | 411 | } |
| MartinJohnson | 0:404dae88af71 | 412 | } |
| MartinJohnson | 0:404dae88af71 | 413 | } |
| MartinJohnson | 0:404dae88af71 | 414 | } |
| MartinJohnson | 0:404dae88af71 | 415 | siShiftBadboys(); |
| MartinJohnson | 0:404dae88af71 | 416 | siBadBoysDelay = count*10; |
| MartinJohnson | 0:404dae88af71 | 417 | } |
| MartinJohnson | 0:404dae88af71 | 418 | |
| MartinJohnson | 0:404dae88af71 | 419 | CCM void siShowDefenses(void) { |
| MartinJohnson | 0:404dae88af71 | 420 | |
| MartinJohnson | 0:404dae88af71 | 421 | u16 i, j, n; |
| MartinJohnson | 0:404dae88af71 | 422 | |
| MartinJohnson | 0:404dae88af71 | 423 | for (i = 0; i < 4; i++) { |
| MartinJohnson | 0:404dae88af71 | 424 | for (j = 0; j < SI_MAXDEFENSES_ROWS; j++) { |
| MartinJohnson | 0:404dae88af71 | 425 | for (n = 0; n < SI_MAXDEFENSES_COLS; n++) { |
| MartinJohnson | 0:404dae88af71 | 426 | switch(i) { |
| MartinJohnson | 0:404dae88af71 | 427 | case 0: if (sidef1[j][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 428 | gdiBitBlt(NULL,sidef1[j][n].x,sidef1[j][n].y,3,5,(pu8) siDefs1,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 429 | } else { |
| MartinJohnson | 0:404dae88af71 | 430 | gdiBitBlt(NULL,sidef1[j][n].x,sidef1[j][n].y,3,5,(pu8) siDefs2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 431 | } |
| MartinJohnson | 0:404dae88af71 | 432 | break; |
| MartinJohnson | 0:404dae88af71 | 433 | case 1: if (sidef2[j][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 434 | gdiBitBlt(NULL,sidef2[j][n].x,sidef2[j][n].y,3,5,(pu8) siDefs1,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 435 | } else { |
| MartinJohnson | 0:404dae88af71 | 436 | gdiBitBlt(NULL,sidef2[j][n].x,sidef2[j][n].y,3,5,(pu8) siDefs2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 437 | } |
| MartinJohnson | 0:404dae88af71 | 438 | break; |
| MartinJohnson | 0:404dae88af71 | 439 | case 2: if (sidef3[j][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 440 | gdiBitBlt(NULL,sidef3[j][n].x,sidef3[j][n].y,3,5,(pu8) siDefs1,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 441 | } else { |
| MartinJohnson | 0:404dae88af71 | 442 | gdiBitBlt(NULL,sidef3[j][n].x,sidef3[j][n].y,3,5,(pu8) siDefs2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 443 | } |
| MartinJohnson | 0:404dae88af71 | 444 | break; |
| MartinJohnson | 0:404dae88af71 | 445 | case 3: if (sidef4[j][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 446 | gdiBitBlt(NULL,sidef4[j][n].x,sidef4[j][n].y,3,5,(pu8) siDefs1,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 447 | } else { |
| MartinJohnson | 0:404dae88af71 | 448 | gdiBitBlt(NULL,sidef4[j][n].x,sidef4[j][n].y,3,5,(pu8) siDefs2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 449 | } |
| MartinJohnson | 0:404dae88af71 | 450 | break; |
| MartinJohnson | 0:404dae88af71 | 451 | |
| MartinJohnson | 0:404dae88af71 | 452 | |
| MartinJohnson | 0:404dae88af71 | 453 | } |
| MartinJohnson | 0:404dae88af71 | 454 | } |
| MartinJohnson | 0:404dae88af71 | 455 | } |
| MartinJohnson | 0:404dae88af71 | 456 | } |
| MartinJohnson | 0:404dae88af71 | 457 | } |
| MartinJohnson | 0:404dae88af71 | 458 | CCM void siMoveGoodBoys(void) { |
| MartinJohnson | 0:404dae88af71 | 459 | |
| MartinJohnson | 0:404dae88af71 | 460 | if (--siGoodBoysKeyDelay > 0) return; |
| MartinJohnson | 0:404dae88af71 | 461 | siGoodBoysKeyDelay = SI_GOODBOYSKEYDELAY; |
| MartinJohnson | 0:404dae88af71 | 462 | Demo_CompassReadAcc(AccBuffer); |
| MartinJohnson | 0:404dae88af71 | 463 | int x=(int)AccBuffer[0]; |
| MartinJohnson | 0:404dae88af71 | 464 | int y=(int)AccBuffer[1]; |
| MartinJohnson | 0:404dae88af71 | 465 | int z=(int)AccBuffer[2]; |
| MartinJohnson | 0:404dae88af71 | 466 | |
| MartinJohnson | 0:404dae88af71 | 467 | /* |
| MartinJohnson | 0:404dae88af71 | 468 | numtostr(siScore,x); |
| MartinJohnson | 0:404dae88af71 | 469 | gdiDrawTextEx(340,20,siScore,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 470 | numtostr(siScore,y); |
| MartinJohnson | 0:404dae88af71 | 471 | gdiDrawTextEx(340,40,siScore,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 472 | numtostr(siScore,z); |
| MartinJohnson | 0:404dae88af71 | 473 | gdiDrawTextEx(340,60,siScore,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 474 | */ |
| MartinJohnson | 0:404dae88af71 | 475 | |
| MartinJohnson | 0:404dae88af71 | 476 | // if ((GPIOA->IDR & SI_LEFT_BUTTON) == 0) { |
| MartinJohnson | 0:404dae88af71 | 477 | if (y<-100) { |
| MartinJohnson | 0:404dae88af71 | 478 | if (siXGoodBoy > 8) { |
| MartinJohnson | 0:404dae88af71 | 479 | siXGoodBoy -= 2; |
| MartinJohnson | 0:404dae88af71 | 480 | gdiBitBlt(NULL,siXGoodBoy,siYGoodBoy,24,9,(pu8) siGoodBoys,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 481 | } |
| MartinJohnson | 0:404dae88af71 | 482 | } |
| MartinJohnson | 0:404dae88af71 | 483 | // if ((GPIOA->IDR & SI_RIGHT_BUTTON) == 0) { |
| MartinJohnson | 0:404dae88af71 | 484 | if (y>100) { |
| MartinJohnson | 0:404dae88af71 | 485 | if (siXGoodBoy < 290) { |
| MartinJohnson | 0:404dae88af71 | 486 | siXGoodBoy += 2; |
| MartinJohnson | 0:404dae88af71 | 487 | gdiBitBlt(NULL,siXGoodBoy,siYGoodBoy,24,9,(pu8) siGoodBoys,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 488 | } |
| MartinJohnson | 0:404dae88af71 | 489 | } |
| MartinJohnson | 0:404dae88af71 | 490 | |
| MartinJohnson | 0:404dae88af71 | 491 | |
| MartinJohnson | 0:404dae88af71 | 492 | } |
| MartinJohnson | 0:404dae88af71 | 493 | |
| MartinJohnson | 0:404dae88af71 | 494 | CCM void siMoveGoodBomb(void) { |
| MartinJohnson | 0:404dae88af71 | 495 | |
| MartinJohnson | 0:404dae88af71 | 496 | i16 d, i, n; |
| MartinJohnson | 0:404dae88af71 | 497 | |
| MartinJohnson | 0:404dae88af71 | 498 | if (!siGoodBombActive) return; |
| MartinJohnson | 0:404dae88af71 | 499 | if (--siGoodBombDelay > 0) return; |
| MartinJohnson | 0:404dae88af71 | 500 | siGoodBombDelay = SI_GOODBOMBDELAY; |
| MartinJohnson | 0:404dae88af71 | 501 | |
| MartinJohnson | 0:404dae88af71 | 502 | gdiBitBlt(NULL,siGoodBombX,siGoodBombY,2,6,(pu8) siGoodBomb1,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 503 | |
| MartinJohnson | 0:404dae88af71 | 504 | // Test if bomb touch defenses |
| MartinJohnson | 0:404dae88af71 | 505 | |
| MartinJohnson | 0:404dae88af71 | 506 | for (d = 0; d < 4; d++) { |
| MartinJohnson | 0:404dae88af71 | 507 | for (i = 0; i < SI_MAXDEFENSES_ROWS; i++) { |
| MartinJohnson | 0:404dae88af71 | 508 | for (n = 0; n < SI_MAXDEFENSES_COLS; n++) { |
| MartinJohnson | 0:404dae88af71 | 509 | switch(d) { |
| MartinJohnson | 0:404dae88af71 | 510 | case 0: if (sidef1[i][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 511 | if (siGoodBombX >= sidef1[i][n].x && siGoodBombX <= (sidef1[i][n].x + 3)) { |
| MartinJohnson | 0:404dae88af71 | 512 | if (siGoodBombY <= (sidef1[i][n].y + 5) && siGoodBombY >= sidef1[i][n].y) { |
| MartinJohnson | 0:404dae88af71 | 513 | sidef1[i][n].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 514 | gdiBitBlt(NULL,sidef1[i][n].x,sidef1[i][n].y,3,5,(pu8) siDefs2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 515 | gdiBitBlt(NULL,siGoodBombX,siGoodBombY,2,6,(pu8) siGoodBomb2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 516 | siGoodBombActive = 0; |
| MartinJohnson | 0:404dae88af71 | 517 | // siShowDefenses(); |
| MartinJohnson | 0:404dae88af71 | 518 | return; |
| MartinJohnson | 0:404dae88af71 | 519 | } |
| MartinJohnson | 0:404dae88af71 | 520 | } |
| MartinJohnson | 0:404dae88af71 | 521 | } |
| MartinJohnson | 0:404dae88af71 | 522 | break; |
| MartinJohnson | 0:404dae88af71 | 523 | case 1: if (sidef2[i][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 524 | if (siGoodBombX >= sidef2[i][n].x && siGoodBombX <= (sidef2[i][n].x + 3)) { |
| MartinJohnson | 0:404dae88af71 | 525 | if (siGoodBombY <= (sidef2[i][n].y + 5) && siGoodBombY >= sidef2[i][n].y) { |
| MartinJohnson | 0:404dae88af71 | 526 | sidef2[i][n].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 527 | gdiBitBlt(NULL,sidef2[i][n].x,sidef2[i][n].y,3,5,(pu8) siDefs2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 528 | gdiBitBlt(NULL,siGoodBombX,siGoodBombY,2,6,(pu8) siGoodBomb2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 529 | siGoodBombActive = 0; |
| MartinJohnson | 0:404dae88af71 | 530 | // siShowDefenses(); |
| MartinJohnson | 0:404dae88af71 | 531 | return; |
| MartinJohnson | 0:404dae88af71 | 532 | } |
| MartinJohnson | 0:404dae88af71 | 533 | } |
| MartinJohnson | 0:404dae88af71 | 534 | } |
| MartinJohnson | 0:404dae88af71 | 535 | break; |
| MartinJohnson | 0:404dae88af71 | 536 | case 2: if (sidef3[i][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 537 | if (siGoodBombX >= sidef3[i][n].x && siGoodBombX <= (sidef3[i][n].x + 3)) { |
| MartinJohnson | 0:404dae88af71 | 538 | if (siGoodBombY <= (sidef3[i][n].y + 5) && siGoodBombY >= sidef3[i][n].y) { |
| MartinJohnson | 0:404dae88af71 | 539 | sidef3[i][n].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 540 | gdiBitBlt(NULL,sidef3[i][n].x,sidef3[i][n].y,3,5,(pu8) siDefs2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 541 | gdiBitBlt(NULL,siGoodBombX,siGoodBombY,2,6,(pu8) siGoodBomb2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 542 | siGoodBombActive = 0; |
| MartinJohnson | 0:404dae88af71 | 543 | // siShowDefenses(); |
| MartinJohnson | 0:404dae88af71 | 544 | return; |
| MartinJohnson | 0:404dae88af71 | 545 | } |
| MartinJohnson | 0:404dae88af71 | 546 | } |
| MartinJohnson | 0:404dae88af71 | 547 | } |
| MartinJohnson | 0:404dae88af71 | 548 | break; |
| MartinJohnson | 0:404dae88af71 | 549 | case 3: if (sidef4[i][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 550 | if (siGoodBombX >= sidef4[i][n].x && siGoodBombX <= (sidef4[i][n].x + 3)) { |
| MartinJohnson | 0:404dae88af71 | 551 | if (siGoodBombY <= (sidef4[i][n].y + 5) && siGoodBombY >= sidef4[i][n].y) { |
| MartinJohnson | 0:404dae88af71 | 552 | sidef4[i][n].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 553 | gdiBitBlt(NULL,sidef4[i][n].x,sidef4[i][n].y,3,5,(pu8) siDefs2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 554 | gdiBitBlt(NULL,siGoodBombX,siGoodBombY,2,6,(pu8) siGoodBomb2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 555 | siGoodBombActive = 0; |
| MartinJohnson | 0:404dae88af71 | 556 | // siShowDefenses(); |
| MartinJohnson | 0:404dae88af71 | 557 | return; |
| MartinJohnson | 0:404dae88af71 | 558 | } |
| MartinJohnson | 0:404dae88af71 | 559 | } |
| MartinJohnson | 0:404dae88af71 | 560 | } |
| MartinJohnson | 0:404dae88af71 | 561 | break; |
| MartinJohnson | 0:404dae88af71 | 562 | |
| MartinJohnson | 0:404dae88af71 | 563 | } |
| MartinJohnson | 0:404dae88af71 | 564 | } |
| MartinJohnson | 0:404dae88af71 | 565 | } |
| MartinJohnson | 0:404dae88af71 | 566 | } |
| MartinJohnson | 0:404dae88af71 | 567 | |
| MartinJohnson | 0:404dae88af71 | 568 | // Test if bomb touch any Bad Boy |
| MartinJohnson | 0:404dae88af71 | 569 | |
| MartinJohnson | 0:404dae88af71 | 570 | for (i = 0; i < SI_MAXBADBOYS_ROWS; i++) { |
| MartinJohnson | 0:404dae88af71 | 571 | for (n = 0; n < SI_MAXBADBOYS_COLS; n++) { |
| MartinJohnson | 0:404dae88af71 | 572 | if (sibb[i][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 573 | if (siGoodBombX >= (sibb[i][n].x + siBadBoysShiftX) && siGoodBombX <= (sibb[i][n].x + siBadBoysShiftX + 15)) { |
| MartinJohnson | 0:404dae88af71 | 574 | if (siGoodBombY <= (sibb[i][n].y + siBadBoysShiftY + 12) && siGoodBombY >= (sibb[i][n].y + siBadBoysShiftY)) { |
| MartinJohnson | 0:404dae88af71 | 575 | sibb[i][n].mode = SI_DESTROYED; |
| MartinJohnson | 0:404dae88af71 | 576 | // gdiBitBlt(NULL,sibb[i][n].x + siBadBoysShiftX,sibb[i][n].y + siBadBoysShiftY,15,12,(pu8) siBadBoys99,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 577 | gdiBitBlt(NULL,siGoodBombX,siGoodBombY,2,6,(pu8) siGoodBomb2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 578 | siGoodBombActive = 0; |
| MartinJohnson | 0:404dae88af71 | 579 | --siBadBoysCount; |
| MartinJohnson | 0:404dae88af71 | 580 | switch(i) { |
| MartinJohnson | 0:404dae88af71 | 581 | case 0: siCurrentScore += 30; break; |
| MartinJohnson | 0:404dae88af71 | 582 | case 1: siCurrentScore += 20; break; |
| MartinJohnson | 0:404dae88af71 | 583 | case 2: siCurrentScore += 20; break; |
| MartinJohnson | 0:404dae88af71 | 584 | case 3: siCurrentScore += 10; break; |
| MartinJohnson | 0:404dae88af71 | 585 | } |
| MartinJohnson | 0:404dae88af71 | 586 | return; |
| MartinJohnson | 0:404dae88af71 | 587 | } |
| MartinJohnson | 0:404dae88af71 | 588 | } |
| MartinJohnson | 0:404dae88af71 | 589 | } |
| MartinJohnson | 0:404dae88af71 | 590 | } |
| MartinJohnson | 0:404dae88af71 | 591 | } |
| MartinJohnson | 0:404dae88af71 | 592 | |
| MartinJohnson | 0:404dae88af71 | 593 | |
| MartinJohnson | 0:404dae88af71 | 594 | if (siGoodBombY < 5) { |
| MartinJohnson | 0:404dae88af71 | 595 | gdiBitBlt(NULL,siGoodBombX,siGoodBombY,2,6,(pu8) siGoodBomb2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 596 | siGoodBombActive = 0; |
| MartinJohnson | 0:404dae88af71 | 597 | } else { |
| MartinJohnson | 0:404dae88af71 | 598 | siGoodBombY -= 3; |
| MartinJohnson | 0:404dae88af71 | 599 | } |
| MartinJohnson | 0:404dae88af71 | 600 | } |
| MartinJohnson | 0:404dae88af71 | 601 | |
| MartinJohnson | 0:404dae88af71 | 602 | void siGoodBombStart(void) { |
| MartinJohnson | 0:404dae88af71 | 603 | |
| MartinJohnson | 0:404dae88af71 | 604 | if ((GPIOA->IDR & SI_FIRE_BUTTON) == 0) { |
| MartinJohnson | 0:404dae88af71 | 605 | if (siGoodBombKeyState == 0 && siGoodBombActive == 0) { |
| MartinJohnson | 0:404dae88af71 | 606 | siGoodBombX = siXGoodBoy + SI_GOODBOYSHOTPOINT; |
| MartinJohnson | 0:404dae88af71 | 607 | siGoodBombY = SI_GOODBOYSTART_Y - 6; |
| MartinJohnson | 0:404dae88af71 | 608 | siGoodBombActive = 1; |
| MartinJohnson | 0:404dae88af71 | 609 | siGoodBombKeyState = 1; |
| MartinJohnson | 0:404dae88af71 | 610 | } |
| MartinJohnson | 0:404dae88af71 | 611 | } else { |
| MartinJohnson | 0:404dae88af71 | 612 | siGoodBombKeyState = 0; |
| MartinJohnson | 0:404dae88af71 | 613 | } |
| MartinJohnson | 0:404dae88af71 | 614 | |
| MartinJohnson | 0:404dae88af71 | 615 | } |
| MartinJohnson | 0:404dae88af71 | 616 | |
| MartinJohnson | 0:404dae88af71 | 617 | CCM void siBadBoysFire(void) { |
| MartinJohnson | 0:404dae88af71 | 618 | |
| MartinJohnson | 0:404dae88af71 | 619 | i16 i, r, col = 0, row = 0,x; |
| MartinJohnson | 0:404dae88af71 | 620 | |
| MartinJohnson | 0:404dae88af71 | 621 | if (siBadBoyBombOK == 0) return; // Bomb disabled |
| MartinJohnson | 0:404dae88af71 | 622 | |
| MartinJohnson | 0:404dae88af71 | 623 | if (--siBadBoysBombDelay != 0) return; |
| MartinJohnson | 0:404dae88af71 | 624 | siBadBoysBombDelay = SI_BADBOYSBOMBDELAY; |
| MartinJohnson | 0:404dae88af71 | 625 | |
| MartinJohnson | 0:404dae88af71 | 626 | srand(sysTicks); |
| MartinJohnson | 0:404dae88af71 | 627 | r = rand(); |
| MartinJohnson | 0:404dae88af71 | 628 | if ((r & 0x03) == 0x01) { // Fire bomb |
| MartinJohnson | 0:404dae88af71 | 629 | |
| MartinJohnson | 0:404dae88af71 | 630 | // Select a random Bad Boy to fire bomb |
| MartinJohnson | 0:404dae88af71 | 631 | // Select a random Bad Boy to fire bomb |
| MartinJohnson | 0:404dae88af71 | 632 | for(x=0;x<20;x++) { |
| MartinJohnson | 0:404dae88af71 | 633 | col = rand() % SI_MAXBADBOYS_COLS; |
| MartinJohnson | 0:404dae88af71 | 634 | for (row = (SI_MAXBADBOYS_ROWS - 1); row >= 0; row--) { |
| MartinJohnson | 0:404dae88af71 | 635 | if (sibb[row][col].mode == SI_ALIVE){ |
| MartinJohnson | 0:404dae88af71 | 636 | for (i = 0; i < SI_MAXBADBOYSBOMB; i++) { |
| MartinJohnson | 0:404dae88af71 | 637 | if (siBomb[i].mode == SI_DEAD) { |
| MartinJohnson | 0:404dae88af71 | 638 | siBomb[i].x = sibb[row][col].x + 7 + siBadBoysShiftX; |
| MartinJohnson | 0:404dae88af71 | 639 | siBomb[i].y = sibb[row][col].y + 12 + siBadBoysShiftY; |
| MartinJohnson | 0:404dae88af71 | 640 | siBomb[i].mode = SI_ALIVE; |
| MartinJohnson | 0:404dae88af71 | 641 | return; |
| MartinJohnson | 0:404dae88af71 | 642 | } |
| MartinJohnson | 0:404dae88af71 | 643 | } |
| MartinJohnson | 0:404dae88af71 | 644 | } |
| MartinJohnson | 0:404dae88af71 | 645 | } |
| MartinJohnson | 0:404dae88af71 | 646 | } |
| MartinJohnson | 0:404dae88af71 | 647 | /* |
| MartinJohnson | 0:404dae88af71 | 648 | while(1) { |
| MartinJohnson | 0:404dae88af71 | 649 | col = rand() % SI_MAXBADBOYS_COLS; |
| MartinJohnson | 0:404dae88af71 | 650 | for (row = (SI_MAXBADBOYS_ROWS - 1); row >= 0; row--) { |
| MartinJohnson | 0:404dae88af71 | 651 | if (sibb[row][col].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 652 | for (i = 0; i < SI_MAXBADBOYSBOMB; i++) { |
| MartinJohnson | 0:404dae88af71 | 653 | if (siBomb[i].mode == SI_DEAD) { |
| MartinJohnson | 0:404dae88af71 | 654 | siBomb[i].x = sibb[row][col].x + 7 + siBadBoysShiftX; |
| MartinJohnson | 0:404dae88af71 | 655 | siBomb[i].y = sibb[row][col].y + 12 + siBadBoysShiftY; |
| MartinJohnson | 0:404dae88af71 | 656 | siBomb[i].mode = SI_ALIVE; |
| MartinJohnson | 0:404dae88af71 | 657 | return; |
| MartinJohnson | 0:404dae88af71 | 658 | } |
| MartinJohnson | 0:404dae88af71 | 659 | } |
| MartinJohnson | 0:404dae88af71 | 660 | } |
| MartinJohnson | 0:404dae88af71 | 661 | } |
| MartinJohnson | 0:404dae88af71 | 662 | } |
| MartinJohnson | 0:404dae88af71 | 663 | */ |
| MartinJohnson | 0:404dae88af71 | 664 | } |
| MartinJohnson | 0:404dae88af71 | 665 | |
| MartinJohnson | 0:404dae88af71 | 666 | } |
| MartinJohnson | 0:404dae88af71 | 667 | |
| MartinJohnson | 0:404dae88af71 | 668 | CCM i16 siDrawBadBoyBomb(void) { |
| MartinJohnson | 0:404dae88af71 | 669 | |
| MartinJohnson | 0:404dae88af71 | 670 | i16 i, v, d, n; |
| MartinJohnson | 0:404dae88af71 | 671 | i16 ret = 0; |
| MartinJohnson | 0:404dae88af71 | 672 | |
| MartinJohnson | 0:404dae88af71 | 673 | siBadBoysFire(); |
| MartinJohnson | 0:404dae88af71 | 674 | |
| MartinJohnson | 0:404dae88af71 | 675 | if (--siBadBombMoveDelay != 0) return(ret);; |
| MartinJohnson | 0:404dae88af71 | 676 | siBadBombMoveDelay = SI_BADBOMBMOVEDELAY; |
| MartinJohnson | 0:404dae88af71 | 677 | |
| MartinJohnson | 0:404dae88af71 | 678 | for (v = 0; v < SI_MAXBADBOYSBOMB; v++) { |
| MartinJohnson | 0:404dae88af71 | 679 | if (siBomb[v].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 680 | if (siBomb[v].flip == 0) { |
| MartinJohnson | 0:404dae88af71 | 681 | gdiBitBlt(NULL,siBomb[v].x,siBomb[v].y,3,14,(pu8) siBadBomb01,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 682 | siBomb[v].flip = 1; |
| MartinJohnson | 0:404dae88af71 | 683 | } else { |
| MartinJohnson | 0:404dae88af71 | 684 | gdiBitBlt(NULL,siBomb[v].x,siBomb[v].y,3,14,(pu8) siBadBomb02,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 685 | siBomb[v].flip = 0; |
| MartinJohnson | 0:404dae88af71 | 686 | } |
| MartinJohnson | 0:404dae88af71 | 687 | |
| MartinJohnson | 0:404dae88af71 | 688 | // See if Bad Boys bomb touch defenses |
| MartinJohnson | 0:404dae88af71 | 689 | |
| MartinJohnson | 0:404dae88af71 | 690 | for (d = 0; d < 4; d++) { |
| MartinJohnson | 0:404dae88af71 | 691 | for (i = 0; i < SI_MAXDEFENSES_ROWS; i++) { |
| MartinJohnson | 0:404dae88af71 | 692 | for (n = 0; n < SI_MAXDEFENSES_COLS; n++) { |
| MartinJohnson | 0:404dae88af71 | 693 | switch(d) { |
| MartinJohnson | 0:404dae88af71 | 694 | case 0: if (sidef1[i][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 695 | if (siBomb[v].x >= sidef1[i][n].x && siBomb[v].x <= (sidef1[i][n].x + 3)) { |
| MartinJohnson | 0:404dae88af71 | 696 | if ((siBomb[v].y + 12) >= sidef1[i][n].y && (siBomb[v].y + 12) <= (sidef1[i][n].y + 5)) { |
| MartinJohnson | 0:404dae88af71 | 697 | sidef1[i][n].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 698 | gdiBitBlt(NULL,sidef1[i][n].x,sidef1[i][n].y,3,5,(pu8) siDefs2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 699 | gdiBitBlt(NULL,siBomb[v].x,siBomb[v].y,3,14,(pu8) siBadBomb00,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 700 | siBomb[v].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 701 | } |
| MartinJohnson | 0:404dae88af71 | 702 | } |
| MartinJohnson | 0:404dae88af71 | 703 | } |
| MartinJohnson | 0:404dae88af71 | 704 | break; |
| MartinJohnson | 0:404dae88af71 | 705 | case 1: if (sidef2[i][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 706 | if (siBomb[v].x >= sidef2[i][n].x && siBomb[v].x <= (sidef2[i][n].x + 3)) { |
| MartinJohnson | 0:404dae88af71 | 707 | if ((siBomb[v].y + 12) >= sidef2[i][n].y && (siBomb[v].y + 12) <= (sidef2[i][n].y + 5)) { |
| MartinJohnson | 0:404dae88af71 | 708 | sidef2[i][n].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 709 | gdiBitBlt(NULL,sidef2[i][n].x,sidef2[i][n].y,3,5,(pu8) siDefs2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 710 | gdiBitBlt(NULL,siBomb[v].x,siBomb[v].y,3,14,(pu8) siBadBomb00,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 711 | siBomb[v].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 712 | } |
| MartinJohnson | 0:404dae88af71 | 713 | } |
| MartinJohnson | 0:404dae88af71 | 714 | } |
| MartinJohnson | 0:404dae88af71 | 715 | break; |
| MartinJohnson | 0:404dae88af71 | 716 | case 2: if (sidef3[i][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 717 | if (siBomb[v].x >= sidef3[i][n].x && siBomb[v].x <= (sidef3[i][n].x + 3)) { |
| MartinJohnson | 0:404dae88af71 | 718 | if ((siBomb[v].y + 12) >= sidef3[i][n].y && (siBomb[v].y + 12) <= (sidef3[i][n].y + 5)) { |
| MartinJohnson | 0:404dae88af71 | 719 | sidef3[i][n].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 720 | gdiBitBlt(NULL,sidef3[i][n].x,sidef3[i][n].y,3,5,(pu8) siDefs2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 721 | gdiBitBlt(NULL,siBomb[v].x,siBomb[v].y,3,14,(pu8) siBadBomb00,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 722 | siBomb[v].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 723 | } |
| MartinJohnson | 0:404dae88af71 | 724 | } |
| MartinJohnson | 0:404dae88af71 | 725 | } |
| MartinJohnson | 0:404dae88af71 | 726 | break; |
| MartinJohnson | 0:404dae88af71 | 727 | case 3: if (sidef4[i][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 728 | if (siBomb[v].x >= sidef4[i][n].x && siBomb[v].x <= (sidef4[i][n].x + 3)) { |
| MartinJohnson | 0:404dae88af71 | 729 | if ((siBomb[v].y + 12) >= sidef4[i][n].y && (siBomb[v].y + 12) <= (sidef4[i][n].y + 5)) { |
| MartinJohnson | 0:404dae88af71 | 730 | sidef4[i][n].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 731 | gdiBitBlt(NULL,sidef4[i][n].x,sidef4[i][n].y,3,5,(pu8) siDefs2,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 732 | gdiBitBlt(NULL,siBomb[v].x,siBomb[v].y,3,14,(pu8) siBadBomb00,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 733 | siBomb[v].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 734 | } |
| MartinJohnson | 0:404dae88af71 | 735 | } |
| MartinJohnson | 0:404dae88af71 | 736 | } |
| MartinJohnson | 0:404dae88af71 | 737 | break; |
| MartinJohnson | 0:404dae88af71 | 738 | } |
| MartinJohnson | 0:404dae88af71 | 739 | } |
| MartinJohnson | 0:404dae88af71 | 740 | } |
| MartinJohnson | 0:404dae88af71 | 741 | } |
| MartinJohnson | 0:404dae88af71 | 742 | |
| MartinJohnson | 0:404dae88af71 | 743 | // See if Bad Boys bomb touch Good Boy |
| MartinJohnson | 0:404dae88af71 | 744 | |
| MartinJohnson | 0:404dae88af71 | 745 | if (siBomb[v].x >= siXGoodBoy && siBomb[v].x <= (siXGoodBoy + 24)) { |
| MartinJohnson | 0:404dae88af71 | 746 | if ((siBomb[v].y + 12) >= siYGoodBoy && (siBomb[v].y + 12) <= (siYGoodBoy + 9)) { |
| MartinJohnson | 0:404dae88af71 | 747 | gdiBitBlt(NULL,siBomb[v].x,siBomb[v].y,3,14,(pu8) siBadBomb00,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 748 | gdiBitBlt(NULL,siXGoodBoy,SI_GOODBOYSTART_Y,24,9,(pu8) siGoodBoysBlk,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 749 | ret = 1; // Good Boy was killed |
| MartinJohnson | 0:404dae88af71 | 750 | } |
| MartinJohnson | 0:404dae88af71 | 751 | } |
| MartinJohnson | 0:404dae88af71 | 752 | |
| MartinJohnson | 0:404dae88af71 | 753 | // Touch nothing, go ahead |
| MartinJohnson | 0:404dae88af71 | 754 | |
| MartinJohnson | 0:404dae88af71 | 755 | if (siBomb[v].mode != SI_DEAD) { |
| MartinJohnson | 0:404dae88af71 | 756 | siBomb[v].y += 3; |
| MartinJohnson | 0:404dae88af71 | 757 | if (siBomb[v].y >= (VID_PIXELS_Y - 16)) { |
| MartinJohnson | 0:404dae88af71 | 758 | gdiBitBlt(NULL,siBomb[v].x,siBomb[v].y - 3,3,14,(pu8) siBadBomb00,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 759 | siBomb[v].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 760 | } |
| MartinJohnson | 0:404dae88af71 | 761 | } |
| MartinJohnson | 0:404dae88af71 | 762 | } |
| MartinJohnson | 0:404dae88af71 | 763 | } |
| MartinJohnson | 0:404dae88af71 | 764 | return(ret); |
| MartinJohnson | 0:404dae88af71 | 765 | } |
| MartinJohnson | 0:404dae88af71 | 766 | |
| MartinJohnson | 0:404dae88af71 | 767 | void siCancelAllBadBoms(void) { |
| MartinJohnson | 0:404dae88af71 | 768 | |
| MartinJohnson | 0:404dae88af71 | 769 | i16 i; |
| MartinJohnson | 0:404dae88af71 | 770 | |
| MartinJohnson | 0:404dae88af71 | 771 | for (i = 0; i < SI_MAXBADBOYSBOMB; i++) { |
| MartinJohnson | 0:404dae88af71 | 772 | if (siBomb[i].mode != SI_DEAD) { |
| MartinJohnson | 0:404dae88af71 | 773 | gdiBitBlt(NULL,siBomb[i].x,siBomb[i].y - 3,3,14,(pu8) siBadBomb00,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 774 | siBomb[i].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 775 | } |
| MartinJohnson | 0:404dae88af71 | 776 | } |
| MartinJohnson | 0:404dae88af71 | 777 | } |
| MartinJohnson | 0:404dae88af71 | 778 | |
| MartinJohnson | 0:404dae88af71 | 779 | void numtostr(char *buffer,int n) { |
| MartinJohnson | 0:404dae88af71 | 780 | int i = 0; |
| MartinJohnson | 0:404dae88af71 | 781 | int isNeg = n<0; |
| MartinJohnson | 0:404dae88af71 | 782 | unsigned int n1 = isNeg ? -n : n; |
| MartinJohnson | 0:404dae88af71 | 783 | int t; |
| MartinJohnson | 0:404dae88af71 | 784 | |
| MartinJohnson | 0:404dae88af71 | 785 | while(n1!=0) |
| MartinJohnson | 0:404dae88af71 | 786 | { |
| MartinJohnson | 0:404dae88af71 | 787 | buffer[i++] = n1%10+'0'; |
| MartinJohnson | 0:404dae88af71 | 788 | n1=n1/10; |
| MartinJohnson | 0:404dae88af71 | 789 | } |
| MartinJohnson | 0:404dae88af71 | 790 | |
| MartinJohnson | 0:404dae88af71 | 791 | if(isNeg) |
| MartinJohnson | 0:404dae88af71 | 792 | buffer[i++] = '-'; |
| MartinJohnson | 0:404dae88af71 | 793 | |
| MartinJohnson | 0:404dae88af71 | 794 | buffer[i] = '\0'; |
| MartinJohnson | 0:404dae88af71 | 795 | |
| MartinJohnson | 0:404dae88af71 | 796 | for(t = 0; t < i/2; t++) |
| MartinJohnson | 0:404dae88af71 | 797 | { |
| MartinJohnson | 0:404dae88af71 | 798 | buffer[t] ^= buffer[i-t-1]; |
| MartinJohnson | 0:404dae88af71 | 799 | buffer[i-t-1] ^= buffer[t]; |
| MartinJohnson | 0:404dae88af71 | 800 | buffer[t] ^= buffer[i-t-1]; |
| MartinJohnson | 0:404dae88af71 | 801 | } |
| MartinJohnson | 0:404dae88af71 | 802 | |
| MartinJohnson | 0:404dae88af71 | 803 | if(n == 0) |
| MartinJohnson | 0:404dae88af71 | 804 | { |
| MartinJohnson | 0:404dae88af71 | 805 | buffer[0] = '0'; |
| MartinJohnson | 0:404dae88af71 | 806 | buffer[1] = '\0'; |
| MartinJohnson | 0:404dae88af71 | 807 | } |
| MartinJohnson | 0:404dae88af71 | 808 | } |
| MartinJohnson | 0:404dae88af71 | 809 | |
| MartinJohnson | 0:404dae88af71 | 810 | CCM void siDrawGoodBoyLeft(void) { |
| MartinJohnson | 0:404dae88af71 | 811 | |
| MartinJohnson | 0:404dae88af71 | 812 | i16 i, x, t; |
| MartinJohnson | 0:404dae88af71 | 813 | |
| MartinJohnson | 0:404dae88af71 | 814 | if (siGoodBoyCount != siGoodBoyCountOld) { |
| MartinJohnson | 0:404dae88af71 | 815 | strcpy((char*) siScore,"LEFT: "); |
| MartinJohnson | 0:404dae88af71 | 816 | numtostr(siScore+6,siGoodBoyCount - 1); |
| MartinJohnson | 0:404dae88af71 | 817 | // sprintf((char*) siScore,"LEFT: %d",siGoodBoyCount - 1); |
| MartinJohnson | 0:404dae88af71 | 818 | gdiDrawTextEx(340,170,siScore,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 819 | |
| MartinJohnson | 0:404dae88af71 | 820 | siGoodBoyCountOld = siGoodBoyCount; |
| MartinJohnson | 0:404dae88af71 | 821 | for (t = 0; t < 4; t++) { |
| MartinJohnson | 0:404dae88af71 | 822 | x = 322; |
| MartinJohnson | 0:404dae88af71 | 823 | for (i = 1; i < SI_MAXGOODBOYS; i++) { |
| MartinJohnson | 0:404dae88af71 | 824 | gdiBitBlt(NULL,x,SI_GOODBOYSTART_Y,24,9,(pu8) siGoodBoysBlk,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 825 | x += 24; |
| MartinJohnson | 0:404dae88af71 | 826 | } |
| MartinJohnson | 0:404dae88af71 | 827 | sysDelayMs(200); |
| MartinJohnson | 0:404dae88af71 | 828 | x = 322; |
| MartinJohnson | 0:404dae88af71 | 829 | for (i = 1; i < SI_MAXGOODBOYS; i++) { |
| MartinJohnson | 0:404dae88af71 | 830 | if (i < siGoodBoyCount) { |
| MartinJohnson | 0:404dae88af71 | 831 | gdiBitBlt(NULL,x,SI_GOODBOYSTART_Y,24,9,(pu8) siGoodBoys,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 832 | } else { |
| MartinJohnson | 0:404dae88af71 | 833 | gdiBitBlt(NULL,x,SI_GOODBOYSTART_Y,24,9,(pu8) siGoodBoysBlk,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 834 | } |
| MartinJohnson | 0:404dae88af71 | 835 | x += 24; |
| MartinJohnson | 0:404dae88af71 | 836 | } |
| MartinJohnson | 0:404dae88af71 | 837 | sysDelayMs(300); |
| MartinJohnson | 0:404dae88af71 | 838 | } |
| MartinJohnson | 0:404dae88af71 | 839 | siXGoodBoy = SI_GOODBOYSTART_X; |
| MartinJohnson | 0:404dae88af71 | 840 | gdiBitBlt(NULL,siXGoodBoy,siYGoodBoy,24,9,(pu8) siGoodBoys,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 841 | } |
| MartinJohnson | 0:404dae88af71 | 842 | } |
| MartinJohnson | 0:404dae88af71 | 843 | |
| MartinJohnson | 0:404dae88af71 | 844 | // Test if Bad Boys are closed to defenses. 0 = No, 1 = Game Over |
| MartinJohnson | 0:404dae88af71 | 845 | |
| MartinJohnson | 0:404dae88af71 | 846 | i16 siBadBoysClosed(void) { |
| MartinJohnson | 0:404dae88af71 | 847 | |
| MartinJohnson | 0:404dae88af71 | 848 | int i, n; |
| MartinJohnson | 0:404dae88af71 | 849 | |
| MartinJohnson | 0:404dae88af71 | 850 | for (i = (SI_MAXBADBOYS_ROWS - 1); i >= 0; i--) { |
| MartinJohnson | 0:404dae88af71 | 851 | for (n = 0; n < SI_MAXBADBOYS_COLS; n++) { |
| MartinJohnson | 0:404dae88af71 | 852 | if (sibb[i][n].mode == SI_ALIVE) { |
| MartinJohnson | 0:404dae88af71 | 853 | if (sibb[i][n].y + siBadBoysShiftY + 12 >= SI_DEFSSTARTY) { |
| MartinJohnson | 0:404dae88af71 | 854 | return(1); |
| MartinJohnson | 0:404dae88af71 | 855 | } else { |
| MartinJohnson | 0:404dae88af71 | 856 | return(0); |
| MartinJohnson | 0:404dae88af71 | 857 | } |
| MartinJohnson | 0:404dae88af71 | 858 | } |
| MartinJohnson | 0:404dae88af71 | 859 | } |
| MartinJohnson | 0:404dae88af71 | 860 | } |
| MartinJohnson | 0:404dae88af71 | 861 | return(0); |
| MartinJohnson | 0:404dae88af71 | 862 | } |
| MartinJohnson | 0:404dae88af71 | 863 | |
| MartinJohnson | 0:404dae88af71 | 864 | // The game |
| MartinJohnson | 0:404dae88af71 | 865 | |
| MartinJohnson | 0:404dae88af71 | 866 | void siTheGame(void) { |
| MartinJohnson | 0:404dae88af71 | 867 | |
| MartinJohnson | 0:404dae88af71 | 868 | while(1) { |
| MartinJohnson | 0:404dae88af71 | 869 | |
| MartinJohnson | 0:404dae88af71 | 870 | sysDelayMs(1); |
| MartinJohnson | 0:404dae88af71 | 871 | |
| MartinJohnson | 0:404dae88af71 | 872 | siDrawGoodBoyLeft(); |
| MartinJohnson | 0:404dae88af71 | 873 | siMoveGoodBoys(); |
| MartinJohnson | 0:404dae88af71 | 874 | siGoodBombStart(); |
| MartinJohnson | 0:404dae88af71 | 875 | siMoveGoodBomb(); |
| MartinJohnson | 0:404dae88af71 | 876 | if (siBadBoysClosed() == 1) { |
| MartinJohnson | 0:404dae88af71 | 877 | siYouLose(); |
| MartinJohnson | 0:404dae88af71 | 878 | return; |
| MartinJohnson | 0:404dae88af71 | 879 | } |
| MartinJohnson | 0:404dae88af71 | 880 | if (siBadBoysCount > 0) { |
| MartinJohnson | 0:404dae88af71 | 881 | if (siDrawBadBoyBomb()) { // Good Boy was killed |
| MartinJohnson | 0:404dae88af71 | 882 | if (--siGoodBoyCount == 0) { // Game over |
| MartinJohnson | 0:404dae88af71 | 883 | siYouLose(); |
| MartinJohnson | 0:404dae88af71 | 884 | return; |
| MartinJohnson | 0:404dae88af71 | 885 | } else { |
| MartinJohnson | 0:404dae88af71 | 886 | siCancelAllBadBoms(); |
| MartinJohnson | 0:404dae88af71 | 887 | gdiBitBlt(NULL,siXGoodBoy,siYGoodBoy,24,9,(pu8) siGoodBoysBlk,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 888 | } |
| MartinJohnson | 0:404dae88af71 | 889 | } |
| MartinJohnson | 0:404dae88af71 | 890 | } else { |
| MartinJohnson | 0:404dae88af71 | 891 | siYouWin(); |
| MartinJohnson | 0:404dae88af71 | 892 | return; |
| MartinJohnson | 0:404dae88af71 | 893 | } |
| MartinJohnson | 0:404dae88af71 | 894 | siDrawBadboys(); |
| MartinJohnson | 0:404dae88af71 | 895 | if (siBakScore != siCurrentScore) { |
| MartinJohnson | 0:404dae88af71 | 896 | siBakScore = siCurrentScore; |
| MartinJohnson | 0:404dae88af71 | 897 | strcpy((char*) siScore,"SCORE: "); |
| MartinJohnson | 0:404dae88af71 | 898 | numtostr(siScore+7,siCurrentScore); |
| MartinJohnson | 0:404dae88af71 | 899 | |
| MartinJohnson | 0:404dae88af71 | 900 | // sprintf((char*) siScore,"SCORE: %04d",siCurrentScore); |
| MartinJohnson | 0:404dae88af71 | 901 | gdiDrawTextEx(328,20,siScore,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 902 | //sprintf((char*) siScore,"BEST: %04d",siBestScore); |
| MartinJohnson | 0:404dae88af71 | 903 | strcpy((char*) siScore,"BEST: "); |
| MartinJohnson | 0:404dae88af71 | 904 | numtostr(siScore+6,siBestScore); |
| MartinJohnson | 0:404dae88af71 | 905 | gdiDrawTextEx(328,29,siScore,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 906 | |
| MartinJohnson | 0:404dae88af71 | 907 | } |
| MartinJohnson | 0:404dae88af71 | 908 | } |
| MartinJohnson | 0:404dae88af71 | 909 | } |
| MartinJohnson | 0:404dae88af71 | 910 | |
| MartinJohnson | 0:404dae88af71 | 911 | //***************************************************************************** |
| MartinJohnson | 0:404dae88af71 | 912 | // Function siInit |
| MartinJohnson | 0:404dae88af71 | 913 | // |
| MartinJohnson | 0:404dae88af71 | 914 | // Init Space Invaders |
| MartinJohnson | 0:404dae88af71 | 915 | // |
| MartinJohnson | 0:404dae88af71 | 916 | // return none |
| MartinJohnson | 0:404dae88af71 | 917 | //***************************************************************************** |
| MartinJohnson | 0:404dae88af71 | 918 | void siInit(void) { |
| MartinJohnson | 0:404dae88af71 | 919 | |
| MartinJohnson | 0:404dae88af71 | 920 | GPIO_InitTypeDef GPIO_InitStructure; |
| MartinJohnson | 0:404dae88af71 | 921 | u16 i, n, j, x, y; |
| MartinJohnson | 0:404dae88af71 | 922 | |
| MartinJohnson | 0:404dae88af71 | 923 | // Configure button pins |
| MartinJohnson | 0:404dae88af71 | 924 | |
| MartinJohnson | 0:404dae88af71 | 925 | GPIO_InitStructure.GPIO_Pin = SI_FIRE_BUTTON | SI_LEFT_BUTTON | SI_RIGHT_BUTTON; |
| MartinJohnson | 0:404dae88af71 | 926 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; |
| MartinJohnson | 0:404dae88af71 | 927 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
| MartinJohnson | 0:404dae88af71 | 928 | GPIO_Init(GPIOA, &GPIO_InitStructure); |
| MartinJohnson | 0:404dae88af71 | 929 | |
| MartinJohnson | 0:404dae88af71 | 930 | gdiBitBlt(NULL,0,0,(VID_PIXELS_X - 1),232,(pu8) siLogo,0); |
| MartinJohnson | 0:404dae88af71 | 931 | sysDelayMs(5000); |
| MartinJohnson | 0:404dae88af71 | 932 | |
| MartinJohnson | 0:404dae88af71 | 933 | Demo_CompassConfig(); |
| MartinJohnson | 0:404dae88af71 | 934 | |
| MartinJohnson | 0:404dae88af71 | 935 | start: |
| MartinJohnson | 0:404dae88af71 | 936 | |
| MartinJohnson | 0:404dae88af71 | 937 | siInitialScreen(); |
| MartinJohnson | 0:404dae88af71 | 938 | |
| MartinJohnson | 0:404dae88af71 | 939 | vidClearScreen(); |
| MartinJohnson | 0:404dae88af71 | 940 | gdiRectangle(0,0,(VID_PIXELS_X - 1),VID_VSIZE - 1,0); |
| MartinJohnson | 0:404dae88af71 | 941 | gdiLine(NULL,320,0,320,VID_VSIZE,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 942 | |
| MartinJohnson | 0:404dae88af71 | 943 | // Preload Bad Boys |
| MartinJohnson | 0:404dae88af71 | 944 | siBadBoysShiftY=0; |
| MartinJohnson | 0:404dae88af71 | 945 | siBadBoysShiftX=0; |
| MartinJohnson | 0:404dae88af71 | 946 | |
| MartinJohnson | 0:404dae88af71 | 947 | for (i = 0; i < SI_MAXBADBOYS_ROWS; i++) { |
| MartinJohnson | 0:404dae88af71 | 948 | x = 15; |
| MartinJohnson | 0:404dae88af71 | 949 | y = SI_BADBOYS_START_Y + ((SI_MAXBADBOYS_ROWS + 12) * i); |
| MartinJohnson | 0:404dae88af71 | 950 | for (n = 0; n < SI_MAXBADBOYS_COLS; n++) { |
| MartinJohnson | 0:404dae88af71 | 951 | sibb[i][n].x = x; |
| MartinJohnson | 0:404dae88af71 | 952 | sibb[i][n].y = y; |
| MartinJohnson | 0:404dae88af71 | 953 | sibb[i][n].mode = SI_ALIVE; |
| MartinJohnson | 0:404dae88af71 | 954 | sibb[i][n].flip = 0; |
| MartinJohnson | 0:404dae88af71 | 955 | if (i == 0) { |
| MartinJohnson | 0:404dae88af71 | 956 | sibb[i][n].b1 = (pu8) siBadBoys01; |
| MartinJohnson | 0:404dae88af71 | 957 | sibb[i][n].b2 = (pu8) siBadBoys02; |
| MartinJohnson | 0:404dae88af71 | 958 | } |
| MartinJohnson | 0:404dae88af71 | 959 | if (i == 1 || i == 2) { |
| MartinJohnson | 0:404dae88af71 | 960 | sibb[i][n].b1 = (pu8) siBadBoys11; |
| MartinJohnson | 0:404dae88af71 | 961 | sibb[i][n].b2 = (pu8) siBadBoys12; |
| MartinJohnson | 0:404dae88af71 | 962 | } |
| MartinJohnson | 0:404dae88af71 | 963 | if (i >= 3) { |
| MartinJohnson | 0:404dae88af71 | 964 | sibb[i][n].b1 = (pu8) siBadBoys21; |
| MartinJohnson | 0:404dae88af71 | 965 | sibb[i][n].b2 = (pu8) siBadBoys22; |
| MartinJohnson | 0:404dae88af71 | 966 | } |
| MartinJohnson | 0:404dae88af71 | 967 | x += 20; |
| MartinJohnson | 0:404dae88af71 | 968 | } |
| MartinJohnson | 0:404dae88af71 | 969 | } |
| MartinJohnson | 0:404dae88af71 | 970 | |
| MartinJohnson | 0:404dae88af71 | 971 | // Preload defenses |
| MartinJohnson | 0:404dae88af71 | 972 | |
| MartinJohnson | 0:404dae88af71 | 973 | for (i = 0; i < 4; i++) { |
| MartinJohnson | 0:404dae88af71 | 974 | y = SI_DEFSSTARTY; |
| MartinJohnson | 0:404dae88af71 | 975 | for (j = 0; j < SI_MAXDEFENSES_ROWS; j++) { |
| MartinJohnson | 0:404dae88af71 | 976 | x = SI_DEFSSTARTX + (i * SI_DEFXSEPARATOR);; |
| MartinJohnson | 0:404dae88af71 | 977 | for (n = 0; n < SI_MAXDEFENSES_COLS; n++) { |
| MartinJohnson | 0:404dae88af71 | 978 | switch(i) { |
| MartinJohnson | 0:404dae88af71 | 979 | case 0: if (j == 0 || j == 1) { |
| MartinJohnson | 0:404dae88af71 | 980 | sidef1[j][n].x = x; |
| MartinJohnson | 0:404dae88af71 | 981 | sidef1[j][n].y = y; |
| MartinJohnson | 0:404dae88af71 | 982 | sidef1[j][n].mode = SI_ALIVE; |
| MartinJohnson | 0:404dae88af71 | 983 | } else { |
| MartinJohnson | 0:404dae88af71 | 984 | if (n == 0 || n == (SI_MAXDEFENSES_COLS - 1)) { |
| MartinJohnson | 0:404dae88af71 | 985 | sidef1[j][n].x = x; |
| MartinJohnson | 0:404dae88af71 | 986 | sidef1[j][n].y = y; |
| MartinJohnson | 0:404dae88af71 | 987 | sidef1[j][n].mode = SI_ALIVE; |
| MartinJohnson | 0:404dae88af71 | 988 | } else { |
| MartinJohnson | 0:404dae88af71 | 989 | sidef1[j][n].x = x; |
| MartinJohnson | 0:404dae88af71 | 990 | sidef1[j][n].y = y; |
| MartinJohnson | 0:404dae88af71 | 991 | sidef1[j][n].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 992 | } |
| MartinJohnson | 0:404dae88af71 | 993 | } |
| MartinJohnson | 0:404dae88af71 | 994 | x += 3; |
| MartinJohnson | 0:404dae88af71 | 995 | break; |
| MartinJohnson | 0:404dae88af71 | 996 | case 1: if (j == 0 || j == 1) { |
| MartinJohnson | 0:404dae88af71 | 997 | sidef2[j][n].x = x; |
| MartinJohnson | 0:404dae88af71 | 998 | sidef2[j][n].y = y; |
| MartinJohnson | 0:404dae88af71 | 999 | sidef2[j][n].mode = SI_ALIVE; |
| MartinJohnson | 0:404dae88af71 | 1000 | } else { |
| MartinJohnson | 0:404dae88af71 | 1001 | if (n == 0 || n == (SI_MAXDEFENSES_COLS - 1)) { |
| MartinJohnson | 0:404dae88af71 | 1002 | sidef2[j][n].x = x; |
| MartinJohnson | 0:404dae88af71 | 1003 | sidef2[j][n].y = y; |
| MartinJohnson | 0:404dae88af71 | 1004 | sidef2[j][n].mode = SI_ALIVE; |
| MartinJohnson | 0:404dae88af71 | 1005 | } else { |
| MartinJohnson | 0:404dae88af71 | 1006 | sidef2[j][n].x = x; |
| MartinJohnson | 0:404dae88af71 | 1007 | sidef2[j][n].y = y; |
| MartinJohnson | 0:404dae88af71 | 1008 | sidef2[j][n].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 1009 | } |
| MartinJohnson | 0:404dae88af71 | 1010 | } |
| MartinJohnson | 0:404dae88af71 | 1011 | x += 3; |
| MartinJohnson | 0:404dae88af71 | 1012 | break; |
| MartinJohnson | 0:404dae88af71 | 1013 | case 2: if (j == 0 || j == 1) { |
| MartinJohnson | 0:404dae88af71 | 1014 | sidef3[j][n].x = x; |
| MartinJohnson | 0:404dae88af71 | 1015 | sidef3[j][n].y = y; |
| MartinJohnson | 0:404dae88af71 | 1016 | sidef3[j][n].mode = SI_ALIVE; |
| MartinJohnson | 0:404dae88af71 | 1017 | } else { |
| MartinJohnson | 0:404dae88af71 | 1018 | if (n == 0 || n == (SI_MAXDEFENSES_COLS - 1)) { |
| MartinJohnson | 0:404dae88af71 | 1019 | sidef3[j][n].x = x; |
| MartinJohnson | 0:404dae88af71 | 1020 | sidef3[j][n].y = y; |
| MartinJohnson | 0:404dae88af71 | 1021 | sidef3[j][n].mode = SI_ALIVE; |
| MartinJohnson | 0:404dae88af71 | 1022 | } else { |
| MartinJohnson | 0:404dae88af71 | 1023 | sidef3[j][n].x = x; |
| MartinJohnson | 0:404dae88af71 | 1024 | sidef3[j][n].y = y; |
| MartinJohnson | 0:404dae88af71 | 1025 | sidef3[j][n].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 1026 | } |
| MartinJohnson | 0:404dae88af71 | 1027 | } |
| MartinJohnson | 0:404dae88af71 | 1028 | x += 3; |
| MartinJohnson | 0:404dae88af71 | 1029 | break; |
| MartinJohnson | 0:404dae88af71 | 1030 | case 3: if (j == 0 || j == 1) { |
| MartinJohnson | 0:404dae88af71 | 1031 | sidef4[j][n].x = x; |
| MartinJohnson | 0:404dae88af71 | 1032 | sidef4[j][n].y = y; |
| MartinJohnson | 0:404dae88af71 | 1033 | sidef4[j][n].mode = SI_ALIVE; |
| MartinJohnson | 0:404dae88af71 | 1034 | } else { |
| MartinJohnson | 0:404dae88af71 | 1035 | if (n == 0 || n == (SI_MAXDEFENSES_COLS - 1)) { |
| MartinJohnson | 0:404dae88af71 | 1036 | sidef4[j][n].x = x; |
| MartinJohnson | 0:404dae88af71 | 1037 | sidef4[j][n].y = y; |
| MartinJohnson | 0:404dae88af71 | 1038 | sidef4[j][n].mode = SI_ALIVE; |
| MartinJohnson | 0:404dae88af71 | 1039 | } else { |
| MartinJohnson | 0:404dae88af71 | 1040 | sidef4[j][n].x = x; |
| MartinJohnson | 0:404dae88af71 | 1041 | sidef4[j][n].y = y; |
| MartinJohnson | 0:404dae88af71 | 1042 | sidef4[j][n].mode = SI_DEAD; |
| MartinJohnson | 0:404dae88af71 | 1043 | } |
| MartinJohnson | 0:404dae88af71 | 1044 | } |
| MartinJohnson | 0:404dae88af71 | 1045 | x += 3; |
| MartinJohnson | 0:404dae88af71 | 1046 | break; |
| MartinJohnson | 0:404dae88af71 | 1047 | } |
| MartinJohnson | 0:404dae88af71 | 1048 | } |
| MartinJohnson | 0:404dae88af71 | 1049 | y += 5; |
| MartinJohnson | 0:404dae88af71 | 1050 | } |
| MartinJohnson | 0:404dae88af71 | 1051 | } |
| MartinJohnson | 0:404dae88af71 | 1052 | |
| MartinJohnson | 0:404dae88af71 | 1053 | // Init default variables |
| MartinJohnson | 0:404dae88af71 | 1054 | |
| MartinJohnson | 0:404dae88af71 | 1055 | siXGoodBoy = SI_GOODBOYSTART_X; |
| MartinJohnson | 0:404dae88af71 | 1056 | siYGoodBoy = SI_GOODBOYSTART_Y; |
| MartinJohnson | 0:404dae88af71 | 1057 | |
| MartinJohnson | 0:404dae88af71 | 1058 | siBadBoysDelay = SI_BADBOYSSTARTDELAY; |
| MartinJohnson | 0:404dae88af71 | 1059 | siBadBoysShiftX = 0; |
| MartinJohnson | 0:404dae88af71 | 1060 | siBadBoysShiftX = 0; |
| MartinJohnson | 0:404dae88af71 | 1061 | siBadBoysMode = 0; |
| MartinJohnson | 0:404dae88af71 | 1062 | siBadBoysFlip = 0; |
| MartinJohnson | 0:404dae88af71 | 1063 | siBadBoysYCount = 0; |
| MartinJohnson | 0:404dae88af71 | 1064 | siGoodBoysKeyDelay = SI_GOODBOYSKEYDELAY; |
| MartinJohnson | 0:404dae88af71 | 1065 | siGoodBombDelay = SI_GOODBOMBDELAY; |
| MartinJohnson | 0:404dae88af71 | 1066 | if (siCurrentScore > siBestScore) siBestScore = siCurrentScore; |
| MartinJohnson | 0:404dae88af71 | 1067 | siCurrentScore = 0; |
| MartinJohnson | 0:404dae88af71 | 1068 | siBadBoysBombDelay = SI_BADBOYSBOMBDELAY; |
| MartinJohnson | 0:404dae88af71 | 1069 | siBadBombMoveDelay = SI_BADBOMBMOVEDELAY; |
| MartinJohnson | 0:404dae88af71 | 1070 | siBadBoysCount = SI_MAXBADBOYS_COLS * SI_MAXBADBOYS_ROWS; |
| MartinJohnson | 0:404dae88af71 | 1071 | siBakScore = -1; |
| MartinJohnson | 0:404dae88af71 | 1072 | siGoodBoyCount = SI_MAXGOODBOYS; |
| MartinJohnson | 0:404dae88af71 | 1073 | siGoodBoyCountOld = 0; |
| MartinJohnson | 0:404dae88af71 | 1074 | |
| MartinJohnson | 0:404dae88af71 | 1075 | // Show Good Boy first time |
| MartinJohnson | 0:404dae88af71 | 1076 | |
| MartinJohnson | 0:404dae88af71 | 1077 | gdiBitBlt(NULL,siXGoodBoy,siYGoodBoy,24,9,(pu8) siGoodBoys,GDI_ROP_COPY); |
| MartinJohnson | 0:404dae88af71 | 1078 | |
| MartinJohnson | 0:404dae88af71 | 1079 | // Show Bad Boys first time |
| MartinJohnson | 0:404dae88af71 | 1080 | |
| MartinJohnson | 0:404dae88af71 | 1081 | siDrawBadboys(); |
| MartinJohnson | 0:404dae88af71 | 1082 | |
| MartinJohnson | 0:404dae88af71 | 1083 | // Show defenses first time |
| MartinJohnson | 0:404dae88af71 | 1084 | |
| MartinJohnson | 0:404dae88af71 | 1085 | siShowDefenses(); |
| MartinJohnson | 0:404dae88af71 | 1086 | |
| MartinJohnson | 0:404dae88af71 | 1087 | // Start Gane |
| MartinJohnson | 0:404dae88af71 | 1088 | |
| MartinJohnson | 0:404dae88af71 | 1089 | siTheGame(); |
| MartinJohnson | 0:404dae88af71 | 1090 | goto start; |
| MartinJohnson | 0:404dae88af71 | 1091 | } |
| MartinJohnson | 0:404dae88af71 | 1092 | |
| MartinJohnson | 0:404dae88af71 | 1093 |