level and speed up stuff
This commit is contained in:
parent
ac4801c7cf
commit
ff95034605
@ -12,12 +12,13 @@
|
|||||||
#include "buttons.h"
|
#include "buttons.h"
|
||||||
|
|
||||||
|
|
||||||
#define GAME_CYCLE_TIME 100
|
#define GAME_CYCLE_TIME 50
|
||||||
#define GAMEOVER_DELAY 10
|
#define GAMEOVER_DELAY 10
|
||||||
|
#define MAX_LEVEL 20
|
||||||
|
|
||||||
|
|
||||||
static uint8_t delayFactor(uint8_t level) {
|
static uint8_t delayFactor(uint8_t level) {
|
||||||
return 11 - level;
|
return MAX_LEVEL + 1 - level;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -36,6 +37,7 @@ void gameExec(void *handle) {
|
|||||||
static uint8_t rowIndex;
|
static uint8_t rowIndex;
|
||||||
static uint8_t proceedDelay;
|
static uint8_t proceedDelay;
|
||||||
static uint8_t level;
|
static uint8_t level;
|
||||||
|
static uint16_t filledLines;
|
||||||
static uint16_t score;
|
static uint16_t score;
|
||||||
static bool newHighScoreAchieved;
|
static bool newHighScoreAchieved;
|
||||||
|
|
||||||
@ -46,6 +48,7 @@ void gameExec(void *handle) {
|
|||||||
canvasClear();
|
canvasClear();
|
||||||
soundCtrl(SOUND_START);
|
soundCtrl(SOUND_START);
|
||||||
level = 1;
|
level = 1;
|
||||||
|
filledLines = 0;
|
||||||
score = 0;
|
score = 0;
|
||||||
newHighScoreAchieved = false;
|
newHighScoreAchieved = false;
|
||||||
phase = e_Phase_Game;
|
phase = e_Phase_Game;
|
||||||
@ -118,9 +121,9 @@ void gameExec(void *handle) {
|
|||||||
}
|
}
|
||||||
// --- engine end ---------------------------------------------------------
|
// --- engine end ---------------------------------------------------------
|
||||||
|
|
||||||
|
bool wipedLines = false;
|
||||||
canvasShow();
|
canvasShow();
|
||||||
if (phase == e_Phase_Game) {
|
if (phase == e_Phase_Game) {
|
||||||
uint8_t wipeCnt = 0;
|
|
||||||
for (uint8_t r = 0; r < CANVAS_HEIGHT; r++) {
|
for (uint8_t r = 0; r < CANVAS_HEIGHT; r++) {
|
||||||
if (canvasIsRowFilled(r)) {
|
if (canvasIsRowFilled(r)) {
|
||||||
score += level;
|
score += level;
|
||||||
@ -131,14 +134,24 @@ void gameExec(void *handle) {
|
|||||||
displaySetValue(score);
|
displaySetValue(score);
|
||||||
canvasWipeRow(r);
|
canvasWipeRow(r);
|
||||||
canvasShow();
|
canvasShow();
|
||||||
wipeCnt += 1;
|
wipedLines = true;
|
||||||
|
filledLines += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wipeCnt != 0) {
|
|
||||||
soundCtrl(SOUND_FANFARE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wipedLines) {
|
||||||
|
soundCtrl(SOUND_PLING);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wipedLines && (filledLines > 0) && ((filledLines % 10) == 0)) {
|
||||||
|
if (level < MAX_LEVEL) {
|
||||||
|
level += 1;
|
||||||
|
}
|
||||||
|
soundCtrl(SOUND_FANFARE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isGameActive()) {
|
if (isGameActive()) {
|
||||||
displaySetValue(score);
|
displaySetValue(score);
|
||||||
} else {
|
} else {
|
||||||
|
@ -13,7 +13,7 @@ CFLAGS+= -g3 -ggdb -gdwarf-2
|
|||||||
|
|
||||||
LDFLAGS=-mmcu=$(MCU) -L $(TOOLCHAIN_PREFIX)/include
|
LDFLAGS=-mmcu=$(MCU) -L $(TOOLCHAIN_PREFIX)/include
|
||||||
|
|
||||||
$(ARTIFACT).elf: main.o scheduler.o spi.o spi_init.o sequencer.o melody_tetris.o melody_tusch1.o psg.o mute.o
|
$(ARTIFACT).elf: main.o scheduler.o spi.o spi_init.o sequencer.o melody_tetris.o melody_tusch1.o psg.o mute.o melody_pling.o
|
||||||
$(CC) -o $@ $(LDFLAGS) $^
|
$(CC) -o $@ $(LDFLAGS) $^
|
||||||
$(OBJDUMP) -D $(ARTIFACT).elf > $(ARTIFACT).txt
|
$(OBJDUMP) -D $(ARTIFACT).elf > $(ARTIFACT).txt
|
||||||
|
|
||||||
|
29
sound-driver/melody_pling.c
Normal file
29
sound-driver/melody_pling.c
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include "psg.h"
|
||||||
|
#include "sequencer.h"
|
||||||
|
#include "scheduler.h"
|
||||||
|
|
||||||
|
const t_tone plingVoice1[] = {
|
||||||
|
{ .octave = e_O_5, .note = e_C, .length = e_L_1_4, .legato = false, .staccato = true },
|
||||||
|
{ .octave = e_O_5, .note = e_G, .length = e_L_1_4, .legato = false, .staccato = true },
|
||||||
|
|
||||||
|
{ .octave = e_O_Null, .note = e_Null, .length = e_L_SyncMark,.legato = false, .staccato = false },
|
||||||
|
{ .octave = e_O_Null, .note = e_Null, .length = e_L_StopMark,.legato = false, .staccato = false },
|
||||||
|
|
||||||
|
{ .octave = e_O_Null, .note = e_Null, .length = e_L_EndMark, .legato = false, .staccato = false },
|
||||||
|
};
|
||||||
|
|
||||||
|
t_melodies pling = {
|
||||||
|
.melodies = { { .chip = 1, .amplitude = 12, .tones = plingVoice1 } },
|
||||||
|
.numOfMelodies = 1,
|
||||||
|
.pace = 200,
|
||||||
|
.slotMask = 0x02
|
||||||
|
};
|
||||||
|
|
||||||
|
void playPling() {
|
||||||
|
sequencerPlayMelodies(&pling);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
8
sound-driver/melody_pling.h
Normal file
8
sound-driver/melody_pling.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef _MELODY_PLING_H_
|
||||||
|
#define _MELODY_PLING_H_
|
||||||
|
|
||||||
|
|
||||||
|
void playPling();
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _MELODY_PLING_H_
|
@ -930,11 +930,18 @@ t_melodies tetrisTheme = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void playMelodyTetris() {
|
void playMelodyTetris() {
|
||||||
|
tetrisTheme.pace = 160; // reset to start value each time
|
||||||
sequencerPlayMelodies(&tetrisTheme);
|
sequencerPlayMelodies(&tetrisTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void playMelodyTetrisFaster() {
|
||||||
|
tetrisTheme.pace += 10;
|
||||||
|
sequencerChangePace(&tetrisTheme);
|
||||||
|
}
|
||||||
|
|
||||||
void stopMelodyTetris() {
|
void stopMelodyTetris() {
|
||||||
sequencerStopMelodies(&tetrisTheme);
|
sequencerStopMelodies(&tetrisTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
void playMelodyTetris();
|
void playMelodyTetris();
|
||||||
void stopMelodyTetris();
|
void stopMelodyTetris();
|
||||||
|
void playMelodyTetrisFaster();
|
||||||
|
|
||||||
#endif // _MELODY_TETRIS_H_
|
#endif // _MELODY_TETRIS_H_
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "psg.h"
|
#include "psg.h"
|
||||||
#include "sequencer.h"
|
#include "sequencer.h"
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
|
#include "melody_tetris.h"
|
||||||
|
|
||||||
const t_tone tusch1voice1[] = {
|
const t_tone tusch1voice1[] = {
|
||||||
{ .octave = e_O_5, .note = e_C, .length = e_L_1_4, .legato = false, .staccato = true },
|
{ .octave = e_O_5, .note = e_C, .length = e_L_1_4, .legato = false, .staccato = true },
|
||||||
@ -79,6 +80,7 @@ t_melodies tusch1 = {
|
|||||||
|
|
||||||
void playTusch1() {
|
void playTusch1() {
|
||||||
sequencerPlayMelodies(&tusch1);
|
sequencerPlayMelodies(&tusch1);
|
||||||
|
playMelodyTetrisFaster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,3 +127,7 @@ void sequencerStopMelodies(t_melodies *melodies) {
|
|||||||
schDel(melodies->taskId);
|
schDel(melodies->taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sequencerChangePace(t_melodies *melodies) {
|
||||||
|
melodies->quarterLength = 60000 / melodies->pace / SEQUENCER_PERIOD; // duration of a 1/4 tone in ms
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -64,5 +64,6 @@ typedef struct {
|
|||||||
void sequencerInit();
|
void sequencerInit();
|
||||||
void sequencerPlayMelodies(t_melodies *melodies);
|
void sequencerPlayMelodies(t_melodies *melodies);
|
||||||
void sequencerStopMelodies(t_melodies *melodies);
|
void sequencerStopMelodies(t_melodies *melodies);
|
||||||
|
void sequencerChangePace(t_melodies *melodies);
|
||||||
|
|
||||||
#endif // _SEQUENCER_H_
|
#endif // _SEQUENCER_H_
|
||||||
|
@ -9,6 +9,6 @@
|
|||||||
#define SOUND_FANFARE 0x10
|
#define SOUND_FANFARE 0x10
|
||||||
#define SOUND_LOCK 0x20
|
#define SOUND_LOCK 0x20
|
||||||
#define SOUND_MOTION 0x40
|
#define SOUND_MOTION 0x40
|
||||||
#define SOUND_SPEED_UP 0x80
|
#define SOUND_PLING 0x80
|
||||||
|
|
||||||
#endif // _SOUND_CODES_H_
|
#endif // _SOUND_CODES_H_
|
||||||
|
@ -52,10 +52,10 @@ spiCmdHandler_7:
|
|||||||
;; insert a call here
|
;; insert a call here
|
||||||
bic #SOUND_MOTION, &cmd
|
bic #SOUND_MOTION, &cmd
|
||||||
spiCmdHandler_8:
|
spiCmdHandler_8:
|
||||||
bit #SOUND_SPEED_UP, &cmd
|
bit #SOUND_PLING, &cmd
|
||||||
jz spiCmdHandler_end
|
jz spiCmdHandler_end
|
||||||
;; insert a call here
|
call #playPling
|
||||||
bic #SOUND_SPEED_UP, &cmd
|
bic #SOUND_PLING, &cmd
|
||||||
spiCmdHandler_end:
|
spiCmdHandler_end:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user