Tidy up of tabbing, addition of key scanning (and ability to skip intro)

This commit is contained in:
stevenhowes
2021-03-19 20:49:38 +00:00
parent 3946f245c7
commit dac8e5fd32
5 changed files with 67 additions and 32 deletions
BIN
View File
Binary file not shown.
+12 -8
View File
@@ -7,8 +7,8 @@ Linkflags = -aif -o $@
# Final targets: # Final targets:
@.!RunImage: @.o.CTheEscape @.o.Graphics @.o.Sound C:o.stubs @.!RunImage: @.o.CTheEscape @.o.Graphics @.o.Sound @.o.Input C:o.stubs
Link $(Linkflags) @.o.CTheEscape @.o.Graphics @.o.Sound C:o.stubs Link $(Linkflags) @.o.CTheEscape @.o.Graphics @.o.Sound @.o.Input C:o.stubs
# User-editable dependencies: # User-editable dependencies:
@@ -21,7 +21,8 @@ Linkflags = -aif -o $@
cc $(ccflags) -o @.o.Graphics @.c.Graphics cc $(ccflags) -o @.o.Graphics @.c.Graphics
@.o.Sound: @.c.Sound @.o.Sound: @.c.Sound
cc $(ccflags) -o @.o.Sound @.c.Sound cc $(ccflags) -o @.o.Sound @.c.Sound
@.o.Input: @.c.Input
cc $(ccflags) -o @.o.Input @.c.Input
# Dynamic dependencies: # Dynamic dependencies:
o.Graphics: c.Graphics o.Graphics: c.Graphics
@@ -38,8 +39,11 @@ o.CTheEscape: C:h.swis
o.CTheEscape: C:h.kernel o.CTheEscape: C:h.kernel
o.CTheEscape: C:h.kernel o.CTheEscape: C:h.kernel
o.CTheEscape: h.Sound o.CTheEscape: h.Sound
o.CTheEscape: c.CTheEscape o.Input: c.Input
o.CTheEscape: C:h.swis o.Input: C:h.swis
o.CTheEscape: C:h.kernel o.Input: C:h.kernel
o.CTheEscape: C:h.kernel o.Input: C:h.kernel
o.CTheEscape: h.Sound o.Input: c.Input
o.Input: C:h.swis
o.Input: C:h.kernel
o.Input: C:h.kernel
+5 -1
View File
@@ -78,11 +78,15 @@ void intro()
currentstart += 100; currentstart += 100;
draw_sprite("tng",320,400); draw_sprite("tng",320,400);
printf("%i elements at %i bytes\n",current_element,sizeof(composition[0]));
sound_composition_start(clock()); sound_composition_start(clock());
while(sound_composition_incomplete()) while(sound_composition_incomplete())
{
sound_composition_tick(clock()); sound_composition_tick(clock());
if(input_readkey(98))
sound_composition_stop();
}
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
+20
View File
@@ -0,0 +1,20 @@
#include <stdio.h>
#include "swis.h"
#include <kernel.h>
// SWI Registers
extern _kernel_swi_regs inreg;
extern _kernel_swi_regs outreg;
int input_readkey(int key)
{
inreg.r[0] = 129;
inreg.r[1] = key ^ 255;
inreg.r[2] = 255;
_kernel_swi(OS_Byte,&inreg,&outreg);
if(outreg.r[1] == 255)
return 1;
return 0;
}
+29 -22
View File
@@ -86,6 +86,8 @@ void sound_composition_debug()
} }
} }
printf("%i elements at %i bytes each\n",current_element,sizeof(composition[0]));
printf("------------------------------\n"); printf("------------------------------\n");
} }
@@ -94,6 +96,11 @@ void sound_composition_start(int cent)
composition_startcent = cent; composition_startcent = cent;
} }
void sound_composition_stop()
{
current_playback_element = COMPOSITION_MAX;
}
void sound_composition_tick(int cents) void sound_composition_tick(int cents)
{ {
int offset_cents = cents - composition_startcent; int offset_cents = cents - composition_startcent;
@@ -103,35 +110,35 @@ void sound_composition_tick(int cents)
{ {
if(composition[i].Start <= offset_cents) if(composition[i].Start <= offset_cents)
{ {
if(composition[i].Start >= 0) if(composition[i].Start >= 0)
{ {
sound_composition_element_play(composition[i]); sound_composition_element_play(composition[i]);
current_playback_element = i + 1; current_playback_element = i + 1;
} }
} }
} }
} }
int sound_note(char* note) int sound_note(char* note)
{ {
int octave = note[1] - 48; int octave = note[1] - 48;
char *basenote = "ZZ"; char *basenote = "ZZ";
int index = 1; int index = 1;
int indexi = 0; int indexi = 0;
int len = sizeof(notes)/sizeof(notes[0]); int len = sizeof(notes)/sizeof(notes[0]);
basenote[0] = note[0]; basenote[0] = note[0];
if(strlen(note) == 3) if(strlen(note) == 3)
{ {
basenote[1] = '#'; basenote[1] = '#';
}else{ }else{
basenote[1] = 'X'; basenote[1] = 'X';
} }
for(indexi = 0; indexi < len; indexi++) for(indexi = 0; indexi < len; indexi++)
{ {
if(strcmp(notes[indexi],basenote) == 0) if(strcmp(notes[indexi],basenote) == 0)
index = indexi; index = indexi;
} }
return 41 + (4 * index) + ((octave - 2) * 48); return 41 + (4 * index) + ((octave - 2) * 48);
} }
int sound_composition_incomplete() int sound_composition_incomplete()