Platform game written for the GHI/OutrageousCircuits RETRO game device. Navigate the caves collecting all the pickups and avoiding the creatures and haunted mine carts that patrol the caves. Oh and remember to watch out for the poisonous plants... This game demonstrates the ability to have multiple animated sprites where the sprites can overlap the background environment. See how the player moves past the fence and climbs the wall in the 3rd screen.

Dependencies:   mbed

Committer:
taylorza
Date:
Sat Dec 27 23:24:30 2014 +0000
Revision:
3:a93fe5f207f5
Working before fixed point audio

Who changed what in which revision?

UserRevisionLine numberNew contents of line
taylorza 3:a93fe5f207f5 1 #ifndef __SOUNDBLOCK_H__
taylorza 3:a93fe5f207f5 2 #define __SOUNDBLOCK_H__
taylorza 3:a93fe5f207f5 3
taylorza 3:a93fe5f207f5 4 #define FP_SCALE 1000
taylorza 3:a93fe5f207f5 5 #define US_PER_BIT 38
taylorza 3:a93fe5f207f5 6 #define SEC_PER_BIT (US_PER_BIT / 1000000)
taylorza 3:a93fe5f207f5 7
taylorza 3:a93fe5f207f5 8 #define TONE(stepCount, stepDuration, pitch, pitchSlide, duty, dutySlide) SoundBlock(SoundBlock::Tone, stepCount, stepDuration, pitch, pitchSlide, duty, dutySlide)
taylorza 3:a93fe5f207f5 9 #define NOISE(stepCount, stepDuration, pitch, pitchSlide) SoundBlock(SoundBlock::Noise, stepCount, stepDuration, pitch, pitchSlide, 128, 0)
taylorza 3:a93fe5f207f5 10 #define PAUSE(stepCount, stepDuration) SoundBlock(SoundBlock::Pause, stepCount, stepDuration, 0, 0, 0, 0)
taylorza 3:a93fe5f207f5 11
taylorza 3:a93fe5f207f5 12 #define CREATE_EFFECT(name) \
taylorza 3:a93fe5f207f5 13 static const SoundBlock name[] = \
taylorza 3:a93fe5f207f5 14 { \
taylorza 3:a93fe5f207f5 15
taylorza 3:a93fe5f207f5 16 #define END_EFFECT \
taylorza 3:a93fe5f207f5 17 };
taylorza 3:a93fe5f207f5 18
taylorza 3:a93fe5f207f5 19 #define EFFECT(name) name, sizeof(name)/sizeof(SoundBlock)
taylorza 3:a93fe5f207f5 20
taylorza 3:a93fe5f207f5 21 class SoundChannel;
taylorza 3:a93fe5f207f5 22
taylorza 3:a93fe5f207f5 23 class SoundBlock
taylorza 3:a93fe5f207f5 24 {
taylorza 3:a93fe5f207f5 25 public:
taylorza 3:a93fe5f207f5 26 enum ToneType {Tone, Noise, Pause};
taylorza 3:a93fe5f207f5 27
taylorza 3:a93fe5f207f5 28 public:
taylorza 3:a93fe5f207f5 29 SoundBlock(ToneType toneType, uint16_t stepCount, uint16_t stepDuration, uint16_t pitch, int16_t pitchSlide, uint8_t duty, int8_t dutySlide);
taylorza 3:a93fe5f207f5 30 SoundBlock(ToneType toneType, uint16_t stepCount, uint16_t stepDuration);
taylorza 3:a93fe5f207f5 31
taylorza 3:a93fe5f207f5 32 protected:
taylorza 3:a93fe5f207f5 33 SoundBlock();
taylorza 3:a93fe5f207f5 34
taylorza 3:a93fe5f207f5 35 private:
taylorza 3:a93fe5f207f5 36 void initialize(ToneType toneType, uint16_t stepCount, uint16_t stepDuration, uint16_t pitch, int16_t pitchSlide, uint8_t duty, int8_t dutySlide);
taylorza 3:a93fe5f207f5 37
taylorza 3:a93fe5f207f5 38 protected:
taylorza 3:a93fe5f207f5 39 inline ToneType getToneType() { return _toneType; }
taylorza 3:a93fe5f207f5 40 inline uint16_t getStepCount() { return _stepCount; }
taylorza 3:a93fe5f207f5 41 inline uint16_t getStepDuration() { return _stepDuration; }
taylorza 3:a93fe5f207f5 42 inline float getPitch(int16_t offset) { return 1000000.0f / (float)(_pitch + offset) / (float)US_PER_BIT; }
taylorza 3:a93fe5f207f5 43 inline int16_t getPitchSlide() {return _pitchSlide; }
taylorza 3:a93fe5f207f5 44 inline uint8_t getDuty(int8_t offset) { return (uint8_t)(_duty + offset); }
taylorza 3:a93fe5f207f5 45 inline int8_t getDutySlide() { return _dutySlide; }
taylorza 3:a93fe5f207f5 46
taylorza 3:a93fe5f207f5 47 private:
taylorza 3:a93fe5f207f5 48 ToneType _toneType;
taylorza 3:a93fe5f207f5 49 uint16_t _stepCount;
taylorza 3:a93fe5f207f5 50 uint16_t _stepDuration;
taylorza 3:a93fe5f207f5 51 uint16_t _pitch;
taylorza 3:a93fe5f207f5 52 int16_t _pitchSlide;
taylorza 3:a93fe5f207f5 53 uint8_t _duty;
taylorza 3:a93fe5f207f5 54 int8_t _dutySlide;
taylorza 3:a93fe5f207f5 55
taylorza 3:a93fe5f207f5 56 friend class SoundChannel;
taylorza 3:a93fe5f207f5 57 };
taylorza 3:a93fe5f207f5 58 #endif //__SOUNDBLOCK_H__
taylorza 3:a93fe5f207f5 59