1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #include "general.h"
5 #include "fileoutput.h"
6
7 /*
8
9 Ringtone Tools - Copyright 2001-2005 Michael Kohn (mike@mikekohn.net)
10 This falls under the Kohnian license. Please read
11 it at http://ringtonetools.mikekohn.net/
12
13 This program is NOT opensourced. You may not use any part
14 of this program for your own software.
15
16 */
17
18 /* Kyocera KWS */
19
write_kws_header(FILE * out,struct note_t * note)20 void write_kws_header(FILE *out, struct note_t *note)
21 {
22
23 }
24
write_kws_note(FILE * out,struct note_t * note)25 void write_kws_note(FILE *out, struct note_t *note)
26 {
27 int d,a,b;
28
29 ring_stack[stackptr++]=note->tone+(note->scale*12);
30
31 if (note->tone!=0)
32 { ring_stack[stackptr++]=0x04; }
33 else
34 { ring_stack[stackptr++]=0x00; }
35
36 d=(int)(((float)60000/(float)note->bpm)*(float)((float)4/(float)(1<<note->length)));
37
38 if (note->modifier==1)
39 { d=d+(d/2); }
40 else
41 if (note->modifier==2)
42 { d=d+(d/2)+(d/4); }
43
44 a=d&255;
45 b=(d>>8)&255;
46
47 a=a^(b<<1);
48
49 ring_stack[stackptr++]=a;
50 ring_stack[stackptr++]=b;
51 }
52
write_kws_footer(FILE * out,struct note_t * note)53 void write_kws_footer(FILE *out, struct note_t *note)
54 {
55 int data_length;
56 int a,b,d;
57
58 if (note->pause!=0)
59 {
60 ring_stack[stackptr++]=0;
61 ring_stack[stackptr++]=0;
62
63 d=(int)(((float)60000/(float)note->bpm)*(float)((float)4/(float)(1<<2)));
64 d=d*note->pause;
65
66 a=d&255;
67 b=(d>>8)&255;
68
69 a=a^(b<<1);
70
71 ring_stack[stackptr++]=a;
72 ring_stack[stackptr++]=b;
73
74 note->note_count++;
75 }
76
77 data_length=stackptr+10;
78 write_long(out,(data_length^0xffffffff));
79 write_word(out,note->note_count);
80
81 for (d=0; d<stackptr; d++) putc(ring_stack[d],out);
82
83 write_long(out,(data_length^0xffffffff));
84 }
85
86
87
88