Revision f8259022 main.c

View differences:

main.c
120 120
	// init player
121 121
	player[0].score = 0;
122 122
	player[0].gameAreaStart = 0;
123
	player[0].gameAreaEnd = 43;
123
	player[0].gameAreaEnd = 17;
124 124
	player[0].sprite.owner = (player_t*)&player[0];
125 125
	setNewSprite((sprite_t*)&(player[0].sprite));
126 126
	player[0].mirrored = 0;
......
128 128
	player[0].controllerOffset = 4;
129 129
	// next one
130 130
	player[1].score = 0;
131
	player[1].gameAreaStart = 46;
132
	player[1].gameAreaEnd = 89;
131
	player[1].gameAreaStart = 26;
132
	player[1].gameAreaEnd = 44;
133 133
	player[1].sprite.owner = (player_t*)&player[1];
134 134
	setNewSprite((sprite_t*)&(player[1].sprite));
135 135
	player[1].mirrored = 1;
......
179 179
	}
180 180
}
181 181

  
182
inline void printYellowBar(void){
183
	yellowDot();
184
}
185

  
186
inline void printGreenBar(void){
187
	greenDot();
188
}
189

  
190
inline void printRedBar(void){
191
	redDot();
192
}
193

  
194
inline void printEmptyBar(void){
195
	noDot();
196
}
197

  
182 198
static inline void drawGameArea(player_t player[NUMBER_OF_PLAYERS]){
183
	for(uint8_t round = 0; round < 16; round++){
184
		for(uint8_t playerNumber = 0; playerNumber < NUMBER_OF_PLAYERS; playerNumber++){
185
			if(player[playerNumber].mirrored){
186
				drawScore((uint16_t*)&(player[playerNumber].score), round); // don't mirror the score, so it's easier to compare
187
				for(int16_t line = player[playerNumber].gameAreaEnd; line >= player[playerNumber].gameAreaStart; line--){
188
					printLine(line, 15-round, (sprite_t*)&(player[playerNumber].sprite));
189
				}
199
	PORT(ADDRESS_PORT) = 0;
200
	for(uint8_t round = 0; round < 16; /*round++*/){
201
		for(int16_t line = player[1].gameAreaStart; line <= player[1].gameAreaEnd; line++){
202
			printLine(line, 15-round/2, (sprite_t*)&(player[1].sprite));
203
		}
204
		printGreenBar();
205
		for(int16_t line = 0; line < 7 ; line++){ //player[1].gameAreaEnd; line < player[0].gameAreaStart; line--){
206
			//printLine(line, 15-round, (sprite_t*)&(player[1].sprite));
207
			if(round == 5){
208
				printYellowBar();
190 209
			}
191 210
			else{
192
				for(int16_t line = player[playerNumber].gameAreaStart; line <= player[playerNumber].gameAreaEnd; line++){
193
					printLine(line, round, (sprite_t*)&(player[playerNumber].sprite));
194
				}
195
				drawScore((uint16_t*)&(player[playerNumber].score), round);
211
				printEmptyBar();
212
			}
213
		}
214
		printYellowBar();
215
		for(int16_t line = 0; line < 7 ; line++){
216
			if(round == 10){
217
				printYellowBar();
196 218
			}
219
			else{
220
				printEmptyBar();
221
			}
222
		}
223
		printRedBar();
224
		for(int16_t line = player[0].gameAreaEnd; line >= player[0].gameAreaStart; line--){
225
			printLine(line, 15-round/2, (sprite_t*)&(player[0].sprite));
197 226
		}
227

  
198 228
		OE();
199 229
		_delay_us(80);
200 230
		ODE();
201
		_delay_us(1); // avoid ghosting
202
		PORT(ADDRESS_PORT) = round+1;
231
		round++;
232
		PORT(ADDRESS_PORT) = round;
233
		_delay_us(10); // avoid ghosting
203 234
	}
204 235
}
205 236

  
206 237
inline void printLine(int16_t line, uint8_t round, sprite_t* sprite){
207 238
	if((1<<round) & lines[line]){
208 239
		yellowDot();
240
		yellowDot();
209 241
	}
210 242
	else{
211 243
		if((*sprite).yLowerPos <= line && (*sprite).yLowerPos+4 > line){
212 244
			if((1<<round) & (*sprite).block[line-(*sprite).yLowerPos]){
213 245
				greenDot();
246
				greenDot();
214 247
			}
215 248
			else{
216 249
				noDot();
250
				noDot();
217 251
			}
218 252
		}
219 253
		else{
220 254
			noDot();
255
			noDot();
221 256
		}
222 257
	}
223 258
}

Also available in: Unified diff