Revision 65352f3f

View differences:

main.c
72 72
	volatile uint8_t mirrored;
73 73
	volatile uint8_t controllerOffset;
74 74
	volatile uint8_t controllerInputMask;
75
	volatile sprite_t nextSprite;
75 76
	} player_t;
76 77

  
77 78
int main(void);
......
94 95
inline void printLine(int16_t line, uint8_t round, sprite_t* sprite);
95 96
static inline void drawGameArea(player_t player[NUMBER_OF_PLAYERS]);
96 97
void gameOver(player_t* player);
97
void setNewSprite(sprite_t* sprite);
98
void setNewSprite(volatile sprite_t* sprite);
98 99
void drawScore(uint16_t* score, uint8_t round);
99 100

  
100 101
volatile uint16_t lines[90] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
......
126 127
	player[0].mirrored = 0;
127 128
	player[0].controllerInputMask = (1<<CONTROLLER0_LEFT) | (1<<CONTROLLER0_DOWN) | (1<<CONTROLLER0_RIGHT) | (1<<CONTROLLER0_ROTATE);
128 129
	player[0].controllerOffset = 4;
130
	player[0].nextSprite.owner = (player_t*)&player[0];
131
	setNewSprite((sprite_t*)&(player[0].nextSprite));
129 132
	// next one
130 133
	player[1].score = 0;
131 134
	player[1].gameAreaStart = 26;
......
135 138
	player[1].mirrored = 1;
136 139
	player[1].controllerInputMask = (1<<CONTROLLER1_LEFT) | (1<<CONTROLLER1_DOWN) | (1<<CONTROLLER1_RIGHT) | (1<<CONTROLLER1_ROTATE);
137 140
	player[1].controllerOffset = 0;
141
	player[1].nextSprite.owner = (player_t*)&player[1];
142
	setNewSprite((sprite_t*)&(player[1].nextSprite));
138 143
	while(1){
139 144
		for(uint8_t delay = 0; delay < TICKS; delay++){
140 145
			drawGameArea((player_t*)player);
......
154 159
	}
155 160
}
156 161

  
157
void setNewSprite(sprite_t* sprite){
162
void setNewSprite(volatile sprite_t* sprite){
158 163
	(*sprite).yLowerPos = (*((*sprite).owner)).gameAreaEnd-2;
159 164
	(*sprite).raw = pgm_read_word(bricks+(keypressCounter%(sizeof(bricks)/sizeof(uint16_t))));
160 165
	(*sprite).offset = 10;
......
208 213
				printYellowBar();
209 214
			}
210 215
			else{
211
				printEmptyBar();
216
				if(round < 4){
217
					if(((line >= 2 && line <= 5)) && (player[1].nextSprite.block[line-2] & (1<<(14-round)))){
218
						yellowDot();
219
					}
220
					else{
221
						noDot();
222
					}
223
				}
224
				else{
225
					noDot();
226
				}
212 227
			}
213 228
		}
214 229
		printYellowBar();
......
217 232
				printYellowBar();
218 233
			}
219 234
			else{
220
				printEmptyBar();
235
				if(round > 11){
236
					if(((line >= 2 && line <= 5)) && (player[0].nextSprite.block[5-line] & (1<<(25-round)))){
237
						yellowDot();
238
					}
239
					else{
240
						noDot();
241
					}
242
				}
243
				else{
244
					noDot();
245
				}
221 246
			}
222 247
		}
223 248
		printRedBar();
......
397 422
			return;
398 423
		}
399 424
		moveSpriteToLines(sprite);
400
		setNewSprite(sprite);
425
		*sprite = (((player_t*)(*sprite).owner)->nextSprite);
426
		setNewSprite(&(*sprite).owner->nextSprite);
401 427
		return;
402 428
	}
403 429
	(*sprite).yLowerPos--;
404 430
	if((*sprite).yLowerPos <= 0 && ((*sprite).block[-1*(*sprite).yLowerPos] != 0x00)){
405 431
		moveSpriteToLines(sprite);
406
		setNewSprite(sprite);
432
		*sprite = (((player_t*)(*sprite).owner)->nextSprite);
433
		setNewSprite(&(*sprite).owner->nextSprite);
407 434
	}
408 435
}
409 436

  

Also available in: Unified diff