0
|
1 #include "fisimusa.h"
|
|
2
|
|
3 #ifdef MSDOS
|
|
4 #include <dos.h>
|
|
5 #endif
|
|
6
|
|
7 #define NUMCH 3
|
|
8
|
|
9 char cord=0,cpat=0,crow=0,drmt=0xff,drms=0;
|
|
10
|
|
11 char auditype;
|
|
12
|
|
13 int plrbeep[2];
|
|
14 int musatempo=5;
|
|
15
|
|
16 #ifdef MSDOS
|
|
17
|
|
18 /***************** h00KiNG nEW iNTERRuPT hANDLeRs **************/
|
|
19
|
|
20 #define setadlib adlib
|
|
21
|
|
22 unsigned int taimeri;
|
|
23
|
|
24 void interrupt int_8();
|
|
25 void interrupt (*old_int8)();
|
|
26
|
|
27 kellovauhti(char spiidi)
|
|
28 {
|
|
29 disable();
|
|
30 outportb(0x43,0x36);
|
|
31 outportb(0x40,0x00);
|
|
32 outportb(0x40,spiidi);
|
|
33 enable();
|
|
34 }
|
|
35
|
|
36 timer_on()
|
|
37 { taimeri=0;
|
|
38
|
|
39 if(auditype){initsound();
|
|
40 cpat=patord[0];}
|
|
41 disable();
|
|
42 old_int8=getvect(0x08);
|
|
43 setvect(0x08,int_8);
|
|
44 enable();
|
|
45 kellovauhti(64);
|
|
46 }
|
|
47
|
|
48 timer_off()
|
|
49 {
|
|
50 disable();
|
|
51 setvect(0x08,old_int8);
|
|
52 enable();
|
|
53 kellovauhti(0);
|
|
54
|
|
55 if(auditype)initsound();
|
|
56 }
|
|
57
|
|
58 void interrupt int_8()
|
|
59 {
|
|
60 taimeri++;
|
|
61 if (!(taimeri&3)) (*old_int8)(); else outport(0x20,0x20);
|
|
62 if(auditype)playtick();
|
|
63 }
|
|
64
|
|
65 /**********************************************************/
|
|
66 /******************* pLAYVVERr RUTiNE ********************/
|
|
67
|
|
68 char instru[2][11]={
|
|
69 0xa1,0xa1,0xff,0xff,0x0f,0x0f,0x03,0x03,0x01,0x00,0x00, /* bass? */
|
|
70 0xa2,0xa2,0xff,0xff,0x0f,0x0f,0x03,0x03,0x01,0x00,0x00, /* ohrgan */
|
|
71 };
|
|
72
|
|
73 adl_ldinstr(int kanava,int i)
|
|
74 {
|
|
75 char*ins=instru[i];
|
|
76 char osotte[11] = {
|
|
77 0x20,0x23,0x60,0x63,0x80,0x83,0xe0,0xe3,0xc0,0x40,0x43 };
|
|
78 char *tmp=ins; char l;
|
|
79 for(l=0;l<11;l++) adlib(kanava+osotte[l],*tmp++);
|
|
80 }
|
|
81
|
|
82 initsound()
|
|
83 {
|
|
84 int l;
|
|
85
|
|
86 if(auditype==1) nosound();
|
|
87
|
|
88 if(auditype==2){
|
|
89 for(l=0;l<244;l++) adlib(l,0);
|
|
90 adlib(0x01,0x20);
|
|
91 adl_ldinstr(0,1);
|
|
92 adl_ldinstr(1,1);
|
|
93 adl_ldinstr(2,1);}
|
|
94
|
|
95 }
|
|
96 #endif
|
|
97
|
|
98 int freku[12] = {
|
|
99 0x157,0x16b,0x181,0x198,0x1b0,0x1ca,
|
|
100 0x1e5,0x202,0x220,0x241,0x263,0x287
|
|
101 };
|
|
102 char plst=0;
|
|
103
|
|
104 /**********************
|
|
105 **********************/
|
|
106
|
|
107 playtick()
|
|
108 {
|
|
109 plst++;
|
|
110
|
|
111 #ifdef MSDOS
|
|
112
|
|
113 if(auditype==1){
|
|
114 if(plst==musatempo/3){
|
|
115 if (plrbeep[0]) sound(plrbeep[0]>>3);
|
|
116 else
|
|
117 if(plrbeep[0])sound(plrbeep[0]>>3);else nosound();
|
|
118 }
|
|
119 if(plst==musatempo/2){
|
|
120 if (plrbeep[1]) sound(plrbeep[1]>>3);
|
|
121 else
|
|
122 if(plrbeep[2])sound(plrbeep[2]>>3);else nosound();
|
|
123 }
|
|
124
|
|
125 }
|
|
126
|
|
127 if (auditype==2){int l;for(l=0;l<NUMCH;l++)
|
|
128 if (plrbeep[l]<0xf0){
|
|
129 adlib(0x40+l,2);
|
|
130 adlib(0x43+l,1);}}
|
|
131
|
|
132 #endif
|
|
133
|
|
134 if (plst==musatempo) { uusinuotti(); plst=0; }
|
|
135 }
|
|
136
|
|
137 /*char ison[3]={1,1,1};*/
|
|
138 char hvilk[3]={0xfe,0xfe,0xfe};
|
|
139
|
|
140 int lizayz=0;
|
|
141
|
|
142 uusinuotti()
|
|
143 {
|
|
144 int l;
|
|
145 unsigned char mark,mkrl;
|
|
146
|
|
147 for(l=0;l<NUMCH;l++) {
|
|
148
|
|
149 mkrl=mark=trax[cpat][l][crow];
|
|
150
|
|
151 if(mark<0xf0)mkrl=mark+=lizayz;
|
|
152
|
|
153 if (auditype==2) plrbeep[l]=mark;
|
|
154
|
|
155 if(mark==0xfa){musatempo=8;lizayz=-16;}
|
|
156
|
|
157 if (mark==0xfb)if(auditype==2){
|
|
158 if(crow&1)mark=0xfe;else
|
|
159 mark=hvilk[l];
|
|
160 plrbeep[l]=mark;
|
|
161 }
|
|
162
|
|
163 if (mark==0xfe)
|
|
164 #ifdef MSDOS
|
|
165 {if(auditype==2){adlib(0x40+l,63);
|
|
166 adlib(0x43+l,63);}
|
|
167 else plrbeep[l]=0;
|
|
168 /*ison[l]=0;*/
|
|
169 }
|
|
170 #else
|
|
171 gbsound(l,0);
|
|
172 #endif
|
|
173
|
|
174 if (mark==0xfd) musatempo=16;
|
|
175 if (mark==0xfc) musatempo=4;
|
|
176
|
|
177 if (mark<0xf0) {
|
|
178
|
|
179 if(mark==mkrl)hvilk[l]=mark;
|
|
180 if((mark&15)>=12)mark+=4;
|
|
181
|
|
182 #ifdef MSDOS
|
|
183
|
|
184 /********* ADLiB ********/
|
|
185
|
|
186 if(auditype==2){
|
|
187
|
|
188 int hum=(freku[mark&15]) /* note */
|
|
189 |(32*256)| /* key on */
|
|
190 (((mark&(255-15))-32) *64); /* octave */
|
|
191
|
|
192 adlib(0xb0+l,hum>>8);
|
|
193 adlib(0xa0+l,hum&255);
|
|
194 adlib(0x40+l,12);
|
|
195 adlib(0x43+l,15);
|
|
196 }
|
|
197
|
|
198 /******** iBM sPEAKER *****/
|
|
199
|
|
200 if(auditype==1){
|
|
201
|
|
202 plrbeep[l]=freku[mark&15];
|
|
203 plrbeep[l]<<=((( (mark&(255-15)) >>4)&15)-2);
|
|
204
|
|
205 /*
|
|
206 if (plrbeep[0]) sound(plrbeep[0]>>3);
|
|
207 else if (plrbeep[1]) sound(plrbeep[1]>>3);
|
|
208 else nosound();*/
|
|
209
|
|
210 }
|
|
211
|
|
212 /*********************/
|
|
213
|
|
214 #else
|
|
215 gbsound(l,(mark&15)+((mark>>4)*12));
|
|
216 #endif
|
|
217
|
|
218 } }
|
|
219
|
|
220 crow++; if (crow==64) {
|
|
221 crow=0;cord++;
|
|
222 cpat=patord[cord];
|
|
223 if (cpat==99) { cord=0; cpat=patord[cord]; }}
|
|
224 }
|