Star Wars Returns

This commit is contained in:
Adrien Bourmault 2019-05-07 17:02:25 +02:00
parent 6c5efc6044
commit 4041ad4032
5 changed files with 50 additions and 6 deletions

View File

@ -34,6 +34,9 @@
void IoStartSpeaker(int freq); void IoStartSpeaker(int freq);
void IoQuietSpeaker(void); void IoQuietSpeaker(void);
void IoDoBeep(void); void IoDoBeep(void);
void IoDoTone(uint tone, uint time);
void IoDoStarWars(void);
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//

View File

@ -49,6 +49,7 @@ extern void IoPrintRtcTime(void);
extern ulong IoGetRtcTicks(void); extern ulong IoGetRtcTicks(void);
extern Time_t* IoGetRtcTime(void); extern Time_t* IoGetRtcTime(void);
extern char* IoGetRtcTimeChar(void); extern char* IoGetRtcTimeChar(void);
extern void IoRtcWait(uint time); // time in ms
//static char* WeekDays[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; //static char* WeekDays[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//

View File

@ -87,7 +87,7 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
IoPrintRtcTime(); IoPrintRtcTime();
IoDoBeep(); IoDoStarWars();
KernLog("Goodbye at %s\n", IoGetRtcTimeChar()); KernLog("Goodbye at %s\n", IoGetRtcTimeChar());
// End this machine's suffering // End this machine's suffering

View File

@ -252,4 +252,12 @@ void IoEnableRtc(void)
IoEnableNMI(); IoEnableNMI();
} }
void IoRtcWait(uint time) // time in ms
{
ulong frequency = 32768 >> (RtcRate-1);
ulong beginTick = IoGetRtcTicks();
while(IoGetRtcTicks() < beginTick + (frequency/1000) * time) {
KePauseCPU();
}
}

View File

@ -4,7 +4,7 @@
// Desc: Speaker functions // // Desc: Speaker functions //
// // // //
// // // //
// Copyright © 2018-2019 The OS/K Team // // Copyright © 4018-4019 The OS/K Team //
// // // //
// This file is part of OS/K. // // This file is part of OS/K. //
// // // //
@ -53,12 +53,44 @@ void IoDoBeep(void)
IoStartSpeaker(1000); IoStartSpeaker(1000);
// Worst possible way of waiting IoRtcWait(100);
// We need actual timers
ulong ticks = IoGetRtcTicks();
while (IoGetRtcTicks() < ticks + 512);
IoQuietSpeaker(); IoQuietSpeaker();
} }
void IoDoTone(uint tone, uint time)
{
IoStartSpeaker(tone);
IoRtcWait(time);
IoQuietSpeaker();
}
void IoDoStarWars(void)
{
struct Note {
uint tone;
uint time;
};
struct Note Score[36] = { {440, 200}, {110, 200}, {440, 200}, {110, 200},
{440, 200}, {110, 200}, {349, 140}, {110, 100},
{523, 60}, {110, 100}, {440, 200}, {110, 200},
{349, 140}, {110, 100}, {523, 60}, {110, 100},
{440, 200}, {110, 200},
{659, 200}, {110, 200}, {659, 200}, {110, 200},
{659, 200}, {110, 200}, {698, 140}, {110, 100},
{523, 60}, {110, 100}, {415, 200}, {110, 200},
{349, 140}, {110, 100}, {523, 60}, {110, 100},
{440, 200}, {110, 200}
} ;
for (int i=0; i<36 ; i++) {
IoDoTone(Score[i].tone, Score[i].time);
}
}