diff --git a/!RunImage,ff8 b/!RunImage,ff8 index 8e3a50b..95a74c3 100644 Binary files a/!RunImage,ff8 and b/!RunImage,ff8 differ diff --git a/Makefile,fe1 b/Makefile,fe1 index 78a5da3..44b226f 100644 --- a/Makefile,fe1 +++ b/Makefile,fe1 @@ -7,8 +7,8 @@ Linkflags = -aif -o $@ # Final targets: -@.!RunImage: @.o.CTheEscape @.o.Graphics @.o.Sound C:o.stubs - Link $(Linkflags) @.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 @.o.Input C:o.stubs # User-editable dependencies: @@ -21,7 +21,8 @@ Linkflags = -aif -o $@ cc $(ccflags) -o @.o.Graphics @.c.Graphics @.o.Sound: @.c.Sound cc $(ccflags) -o @.o.Sound @.c.Sound - +@.o.Input: @.c.Input + cc $(ccflags) -o @.o.Input @.c.Input # Dynamic dependencies: 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: h.Sound -o.CTheEscape: c.CTheEscape -o.CTheEscape: C:h.swis -o.CTheEscape: C:h.kernel -o.CTheEscape: 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 +o.Input: c.Input +o.Input: C:h.swis +o.Input: C:h.kernel +o.Input: C:h.kernel diff --git a/c/CTheEscape b/c/CTheEscape index 4a749c6..28396d8 100644 --- a/c/CTheEscape +++ b/c/CTheEscape @@ -78,11 +78,15 @@ void intro() currentstart += 100; draw_sprite("tng",320,400); - printf("%i elements at %i bytes\n",current_element,sizeof(composition[0])); sound_composition_start(clock()); while(sound_composition_incomplete()) + { sound_composition_tick(clock()); + + if(input_readkey(98)) + sound_composition_stop(); + } } int main(int argc, char *argv[]) diff --git a/c/Input b/c/Input new file mode 100644 index 0000000..472f4cf --- /dev/null +++ b/c/Input @@ -0,0 +1,20 @@ +#include +#include "swis.h" +#include + +// 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; +} diff --git a/c/Sound b/c/Sound index 50f09af..34f77fb 100644 --- a/c/Sound +++ b/c/Sound @@ -85,6 +85,8 @@ void sound_composition_debug() ); } } + + printf("%i elements at %i bytes each\n",current_element,sizeof(composition[0])); printf("------------------------------\n"); } @@ -94,6 +96,11 @@ void sound_composition_start(int cent) composition_startcent = cent; } +void sound_composition_stop() +{ + current_playback_element = COMPOSITION_MAX; +} + void sound_composition_tick(int cents) { 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 >= 0) - { + if(composition[i].Start >= 0) + { sound_composition_element_play(composition[i]); - current_playback_element = i + 1; - } + current_playback_element = i + 1; + } } } } int sound_note(char* note) { - int octave = note[1] - 48; - char *basenote = "ZZ"; - int index = 1; - int indexi = 0; - int len = sizeof(notes)/sizeof(notes[0]); - basenote[0] = note[0]; - if(strlen(note) == 3) - { - basenote[1] = '#'; - }else{ - basenote[1] = 'X'; - } - for(indexi = 0; indexi < len; indexi++) - { - if(strcmp(notes[indexi],basenote) == 0) - index = indexi; - } - return 41 + (4 * index) + ((octave - 2) * 48); + int octave = note[1] - 48; + char *basenote = "ZZ"; + int index = 1; + int indexi = 0; + int len = sizeof(notes)/sizeof(notes[0]); + basenote[0] = note[0]; + if(strlen(note) == 3) + { + basenote[1] = '#'; + }else{ + basenote[1] = 'X'; + } + for(indexi = 0; indexi < len; indexi++) + { + if(strcmp(notes[indexi],basenote) == 0) + index = indexi; + } + return 41 + (4 * index) + ((octave - 2) * 48); } int sound_composition_incomplete() @@ -140,4 +147,4 @@ int sound_composition_incomplete() return 0; else return 1; -} +}