mirror of
https://github.com/jeremysrand/a2bejwld.git
synced 2024-06-01 14:41:38 +00:00
Add some sound to the game.
This commit is contained in:
parent
45688cb6ba
commit
3cd2430203
|
@ -11,6 +11,7 @@
|
|||
#include <conio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "anim.h"
|
||||
|
@ -67,6 +68,7 @@ typedef void (*tVblWaitFunction)(void);
|
|||
// Globals
|
||||
|
||||
static tVblWaitFunction gVblWait = vblWait;
|
||||
static bool gPlaySounds = true;
|
||||
|
||||
static tStarAnimState gStarAnimState;
|
||||
static tClearGemAnimState gClearGemAnimState;
|
||||
|
@ -95,6 +97,37 @@ void animInit(void)
|
|||
}
|
||||
|
||||
|
||||
void toggleSound(void)
|
||||
{
|
||||
gPlaySounds = !gPlaySounds;
|
||||
}
|
||||
|
||||
|
||||
void badThingHappened(void)
|
||||
{
|
||||
if (gPlaySounds)
|
||||
printf("\007");
|
||||
}
|
||||
|
||||
|
||||
void playSound(int8_t startFreq, int8_t duration)
|
||||
{
|
||||
int8_t freq;
|
||||
|
||||
if (!gPlaySounds)
|
||||
return;
|
||||
|
||||
while (duration > 0) {
|
||||
asm ("STA %w", 0xc030);
|
||||
freq = startFreq;
|
||||
while (freq > 0) {
|
||||
freq--;
|
||||
}
|
||||
duration--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void drawGemAtSquare(tSquare square)
|
||||
{
|
||||
switch (gemTypeAtSquare(square)) {
|
||||
|
@ -289,6 +322,7 @@ void endClearGemAnim(void)
|
|||
|
||||
bit = 1;
|
||||
offset = 0;
|
||||
playSound(30, 10);
|
||||
gVblWait();
|
||||
for (square = 0; square < NUM_SQUARES; square++) {
|
||||
if ((gClearGemAnimState.squaresToClear[offset] & bit) != 0) {
|
||||
|
@ -306,6 +340,7 @@ void endClearGemAnim(void)
|
|||
|
||||
bit = 1;
|
||||
offset = 0;
|
||||
playSound(25, 15);
|
||||
gVblWait();
|
||||
for (square = 0; square < NUM_SQUARES; square++) {
|
||||
if ((gClearGemAnimState.squaresToClear[offset] & bit) != 0) {
|
||||
|
@ -323,6 +358,7 @@ void endClearGemAnim(void)
|
|||
|
||||
bit = 1;
|
||||
offset = 0;
|
||||
playSound(20, 20);
|
||||
gVblWait();
|
||||
for (square = 0; square < NUM_SQUARES; square++) {
|
||||
if ((gClearGemAnimState.squaresToClear[offset] & bit) != 0) {
|
||||
|
@ -340,6 +376,7 @@ void endClearGemAnim(void)
|
|||
|
||||
bit = 1;
|
||||
offset = 0;
|
||||
playSound(30, 10);
|
||||
gVblWait();
|
||||
for (square = 0; square < NUM_SQUARES; square++) {
|
||||
if ((gClearGemAnimState.squaresToClear[offset] & bit) != 0) {
|
||||
|
@ -357,6 +394,7 @@ void endClearGemAnim(void)
|
|||
|
||||
bit = 1;
|
||||
offset = 0;
|
||||
playSound(30, 10);
|
||||
gVblWait();
|
||||
for (square = 0; square < NUM_SQUARES; square++) {
|
||||
if ((gClearGemAnimState.squaresToClear[offset] & bit) != 0) {
|
||||
|
@ -374,6 +412,7 @@ void endClearGemAnim(void)
|
|||
|
||||
bit = 1;
|
||||
offset = 0;
|
||||
playSound(30, 10);
|
||||
gVblWait();
|
||||
for (square = 0; square < NUM_SQUARES; square++) {
|
||||
if ((gClearGemAnimState.squaresToClear[offset] & bit) != 0) {
|
||||
|
@ -391,6 +430,7 @@ void endClearGemAnim(void)
|
|||
|
||||
bit = 1;
|
||||
offset = 0;
|
||||
playSound(30, 10);
|
||||
gVblWait();
|
||||
for (square = 0; square < NUM_SQUARES; square++) {
|
||||
if ((gClearGemAnimState.squaresToClear[offset] & bit) != 0) {
|
||||
|
@ -600,6 +640,7 @@ void endDropAnim(void)
|
|||
|
||||
if (gemInfo->y == gemInfo->endY) {
|
||||
gemInfo->landed = true;
|
||||
playSound(1, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,5 +38,8 @@ extern void dropSquareFromTo(tSquare srcSquare, tSquare tgtSquare, tGemType gemT
|
|||
extern void dropSquareFromOffscreen(tSquare tgtSquare, tGemType gemType, bool starred);
|
||||
extern void endDropAnim(void);
|
||||
|
||||
extern void toggleSound(void);
|
||||
extern void badThingHappened(void);
|
||||
|
||||
|
||||
#endif /* defined(__a2bejwld__anim__) */
|
||||
|
|
|
@ -39,6 +39,7 @@ typedef struct tGameCallbacks {
|
|||
void (*addClearAtSquare)(tSquare square);
|
||||
void (*undoClearAtSquare)(tSquare square);
|
||||
void (*endClearGemAnim)(void);
|
||||
|
||||
void (*swapSquares)(tSquare square1, tGemType gemType1, bool starred1,
|
||||
tSquare square2, tGemType gemType2, bool starred2);
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ static void refreshLevel(tLevel level);
|
|||
// Globals
|
||||
|
||||
static tSquare gSelectedSquare = 0;
|
||||
static bool gPlaySounds = true;
|
||||
static uint8_t gScoreBar = 0;
|
||||
|
||||
static tGameCallbacks gCallbacks = {
|
||||
|
@ -60,13 +59,6 @@ static void showAndClearDblLoRes(void)
|
|||
}
|
||||
|
||||
|
||||
static void badThingHappened(void)
|
||||
{
|
||||
if (gPlaySounds)
|
||||
printf("\007");
|
||||
}
|
||||
|
||||
|
||||
void printInstructions(void)
|
||||
{
|
||||
|
||||
|
@ -301,9 +293,9 @@ static void endGame(void)
|
|||
{
|
||||
mixedTextMode();
|
||||
videomode(VIDEOMODE_80x24);
|
||||
cputsxy(0, 20, " No more moves - GAME OVER!!");
|
||||
cputsxy(0, 20, " No more moves - GAME OVER!!");
|
||||
gotoxy(0,21);
|
||||
cprintf( " You made it to level %u", getLevel());
|
||||
cprintf( " You made it to level %u", getLevel());
|
||||
cputsxy(0,23, " Play again (Y/N)?");
|
||||
|
||||
while (true) {
|
||||
|
@ -345,8 +337,8 @@ static void refreshLevel(tLevel level)
|
|||
mixedTextMode();
|
||||
videomode(VIDEOMODE_80x24);
|
||||
gotoxy(0, 20);
|
||||
cprintf( " Completed level %u!!", level);
|
||||
cputsxy(0,22, " Press space to continue to the next level...");
|
||||
cprintf( " Completed level %u!!", level);
|
||||
cputsxy(0,22, " Press space to continue to the next level...");
|
||||
|
||||
while (waiting) {
|
||||
switch (cgetc()) {
|
||||
|
@ -503,7 +495,7 @@ void playGame(void)
|
|||
|
||||
case 's':
|
||||
case 'S':
|
||||
gPlaySounds = !gPlaySounds;
|
||||
toggleSound();
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
|
|
Loading…
Reference in New Issue
Block a user