]> 4ch.mooo.com Git - 16.git/blob - 16/fcsp2src/sp16.asm
more
[16.git] / 16 / fcsp2src / sp16.asm
1 ;--------------------------------------------------------------------\r
2 ;                  StarPort Intro II V1.0\r
3 ;--------------------------------------------------------------------\r
4 ;              Copyright (C) 1993 Future Crew\r
5 ;--------------------------------------------------------------------\r
6 ;                        code: Psi\r
7 ;                       music: Skaven\r
8 ;--------------------------------------------------------------------\r
9 ;    This code is released to the public domain. You can do\r
10 ;    whatever you like with this code, but remember, that if\r
11 ;    you are just planning on making another small intro by\r
12 ;    changing a few lines of code, be prepared to enter the\r
13 ;    worldwide lamers' club. However, if you are looking at\r
14 ;    this code in hope of learning something new, go right\r
15 ;    ahead. That's exactly why this source was released.\r
16 ;    (BTW: I don't claim there's anything new to find here,\r
17 ;    but it's always worth looking, right?)\r
18 ;--------------------------------------------------------------------\r
19 ;    The code is optimized mainly for size but also a little\r
20 ;    for speed. The goal was to get this little bbs intro to\r
21 ;    under 2K, and 1993 bytes sounded like a good size. Well,\r
22 ;    it wasn't easy, and there are surely places left one could\r
23 ;    squeeze a few extra bytes off...\r
24 ;      Making a small intro is not hard. Making a small intro\r
25 ;    with a nice feel is very hard, and you have to sacrifice\r
26 ;    ideas to fit the intro to the limits you have set. I had\r
27 ;    a lot of plans (a background piccy for example), but well,\r
28 ;    the size limit came first.\r
29 ;      I hope you enjoy my choice of size/feature ratio in this\r
30 ;    intro! In case you are interested, this was a three evening\r
31 ;    project (the last one spent testing).\r
32 ;--------------------------------------------------------------------\r
33 ;    You can compile this with TASM, but the resulting COM-file\r
34 ;    will be a lot larger than the released version. This is\r
35 ;    because all the zero data is included to the result. The\r
36 ;    released version was first compiled to a COM file, and then\r
37 ;    a separate postprocessing program was ran which removed all\r
38 ;    the zero data from the end of the file. If you are just\r
39 ;    experimenting, recompiling is as easy as MAKE.BAT. If you\r
40 ;    want to make this small again, you have to do some work as\r
41 ;    well, and make your own postprocessor.\r
42 ;--------------------------------------------------------------------\r
43 \r
44 BORDERS=0       ;set to 1 for visible border-timings\r
45 \r
46 code    SEGMENT para public 'CODE'\r
47         ASSUME cs:code\r
48 ;       LOCALS\r
49         .8087\r
50 \r
51 ORG     100h\r
52 start:  cld     ;filler to make the filesize exactly 1993 bytes\r
53         cld     ;filler to make the filesize exactly 1993 bytes\r
54         jmp     main\r
55 \r
56 ;±±±±±±±±±±±±±±±± setborder ±±±±±±±±±±±±±±±±\r
57 ;descr: debug/change border color\r
58 setborder MACRO col\r
59         IF BORDERS\r
60         push    ax\r
61         push    dx\r
62         mov     dx,3dah\r
63         in      al,dx\r
64         mov     dx,3c0h\r
65         mov     al,11h+32\r
66         out     dx,al\r
67         mov     al,col\r
68         out     dx,al\r
69         pop     dx\r
70         pop     ax\r
71         ENDIF\r
72         ENDM\r
73 \r
74 ;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Simplex Adlib Player ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ\r
75 ;this doesn't just read raw data to output to adlib like the one\r
76 ;used in the last starport intro. This player really does have\r
77 ;note & instrument data it reads and processes!\r
78 \r
79 ;±±±±±±±±±±±±±±±± output data to adlib ±±±±±±±±±±±±±±\r
80 a_lodsboutaw03: ;size optimization related entry (instrument loading)\r
81         call    a_lodsboutaw\r
82         add     ah,3\r
83 a_lodsboutaw: ;size optimization related entry (instrument loading)\r
84         lodsb\r
85 a_outaw PROC NEAR ;ah=reg,al=data\r
86         push    ax\r
87         push    cx\r
88         xchg    al,ah\r
89         mov     dx,388h\r
90         out     dx,al\r
91         mov     cx,7\r
92         call    a_wait\r
93         mov     dx,389h\r
94         mov     al,ah\r
95         out     dx,al\r
96         mov     cx,30\r
97         call    a_wait\r
98         pop     cx\r
99         pop     ax\r
100         ret\r
101 a_wait: in      al,dx\r
102         loop    a_wait\r
103         ret\r
104 a_outaw ENDP\r
105 \r
106 ;±±±±±±±±±±±±±±±± load instrument to adlib ±±±±±±±±±±±±±±\r
107 a_loadinstrument PROC NEAR\r
108         ;bx=channel, ds:si=offset to instrument data\r
109         mov     ah,ds:a_inst_table[bx]\r
110         mov     cx,4\r
111 @@1:    call    a_lodsboutaw03\r
112         add     ah,20h-3\r
113         loop    @@1\r
114         add     ah,40h\r
115         call    a_lodsboutaw03\r
116         mov     ah,bl\r
117         add     ah,0c0h\r
118         jmp     a_lodsboutaw\r
119 a_loadinstrument ENDP\r
120 \r
121 ;±±±±±±±±±±±±±±±± set note on/off ±±±±±±±±±±±±±±\r
122 a_playnote PROC NEAR\r
123         ;bx=channel, ax=data\r
124         push    bx\r
125         xchg    ah,bl\r
126         add     ah,0a0h\r
127         call    a_outaw\r
128         mov     al,bl\r
129         add     ah,010h\r
130         pop     bx\r
131         jmp     a_outaw\r
132 a_playnote ENDP\r
133 \r
134 ;±±±±±±±±±±±±±±±± initialize/clear/shutup adlib ±±±±±±±±±±±±±±\r
135 a_init PROC NEAR\r
136         mov     ax,00120h\r
137         call    a_outaw\r
138         mov     ax,00800h\r
139         call    a_outaw\r
140         mov     ah,0bdh\r
141         call    a_outaw\r
142         mov     bp,9\r
143         xor     bx,bx\r
144         mov     di,OFFSET music_instruments\r
145 @@1_:   mov     si,ds:[di]\r
146         add     di,2\r
147         call    a_loadinstrument\r
148         xor     ax,ax\r
149         call    a_playnote\r
150         inc     bx\r
151         dec     bp\r
152         jnz     @@1_\r
153         ret\r
154 a_init ENDP\r
155 \r
156 ;±±±±±±±±±±±±±±±± advance music one row ±±±±±±±±±±±±±±\r
157 a_dorow PROC NEAR\r
158         sub     byte ptr ds:a_musiccnt,1;;;;\r
159         jnc     @@0\r
160         mov     byte ptr ds:a_musiccnt,8;;;;music_speed\r
161         mov     cx,music_channels\r
162         mov     di,OFFSET music_patterns\r
163         xor     bx,bx\r
164 @@1__:  sub     byte ptr ds:a_chdelaycnt[bx],1;;;;\r
165         jns     @@2\r
166         mov     si,ds:[di]\r
167         xor     ax,ax\r
168         call    a_playnote\r
169 @@4:    lodsb\r
170         or      al,al\r
171         jz      @@7\r
172         jns     @@6\r
173         sub     al,81h\r
174         mov     ds:a_chdelay[bx],al\r
175         lodsb\r
176 @@6:    mov     dl,al\r
177         and     ax,15\r
178         mov     bp,ax\r
179         add     bp,bp\r
180         mov     ax,ds:a_note_table[bp]\r
181         shr     dl,1\r
182         shr     dl,1\r
183         and     dl,not 3\r
184         add     ah,dl\r
185         call    a_playnote\r
186         mov     al,ds:a_chdelay[bx]\r
187         mov     ds:a_chdelaycnt[bx],al\r
188         mov     ds:[di],si\r
189 @@2:    add     di,4\r
190         inc     bx\r
191         loop    @@1__\r
192 @@0:    ret\r
193 @@7:    mov     si,ds:[di+2]\r
194         jmp     @@4\r
195 a_dorow ENDP\r
196 \r
197 ;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Intro Routines ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ\r
198 \r
199 ;±±±±±±±±±±±±±±±± sin/cos ±±±±±±±±±±±±±±±±\r
200 ;entry: ax=angle (0..65535)\r
201 ; exit: ax=muller (-127..127)\r
202 addwcos:add     ax,ds:[bx] ;optimized entry for wavesets\r
203         mov     ds:[bx],ax\r
204 cos:    add     ax,16384\r
205 sin:    mov     bx,ax\r
206         mov     cx,bx\r
207         and     cx,1023\r
208         neg     cx\r
209         add     cx,1023\r
210         shr     bx,1\r
211         shr     bx,1\r
212         shr     bx,1\r
213         shr     bx,1\r
214         shr     bx,1\r
215         shr     bx,1\r
216         shr     bx,1\r
217         shr     bx,1\r
218         shr     bx,1\r
219         shr     bx,1\r
220         mov     ah,ds:sintable[bx]\r
221         xor     al,al\r
222         imul    cx\r
223         push    ax\r
224         push    dx\r
225         mov     ah,ds:sintable[bx+1]\r
226         xor     al,al\r
227         neg     cx\r
228         add     cx,1023\r
229         imul    cx\r
230         pop     bx\r
231         pop     cx\r
232         add     ax,cx\r
233         adc     dx,bx\r
234 ;       shrd    ax,dx,11;;;;;;;;\r
235         ret\r
236 \r
237 ;±±±±±±±±±±±±±±±± rand ±±±±±±±±±±±±±±±±\r
238 ;returns a random value in range -4096..4095\r
239 rand    PROC NEAR\r
240         mov     ax,1107;;;;;;;;;030247\r
241         mul     ds:seed\r
242         add     ax,9717;;;;;;;;7\r
243         mov     ds:seed,ax\r
244         shr     ax,1\r
245         shr     ax,1\r
246         shr     ax,1\r
247         shr     ax,1\r
248         shr     ax,1\r
249         shr     ax,1\r
250         shr     ax,1\r
251         shr     ax,1\r
252         shr     ax,1\r
253         shr     ax,1\r
254         shr     ax,1\r
255         shr     ax,1\r
256         shr     ax,1\r
257         shr     ax,1\r
258         shr     ax,1\r
259         and     ax,8191\r
260         sub     ax,4096\r
261 ;size optimizatin, some code moved from after all rand calls\r
262         add     bx,2\r
263         mov     ds:[bx],ax\r
264         ret\r
265 rand    ENDP\r
266 \r
267 ;±±±±±±±±±±±±±±±± timer ±±±±±±±±±±±±±±±±\r
268 inittimer PROC NEAR\r
269         mov     ax,fs:[8*4]\r
270         mov     ds:oldint8,ax\r
271         mov     ax,cs\r
272         shl     ax,1\r
273         shl     ax,1\r
274         shl     ax,1\r
275         shl     ax,1\r
276         shl     ax,1\r
277         shl     ax,1\r
278         shl     ax,1\r
279         shl     ax,1\r
280         shl     ax,1\r
281         shl     ax,1\r
282         shl     ax,1\r
283         shl     ax,1\r
284         shl     ax,1\r
285         shl     ax,1\r
286         shl     ax,1\r
287         shl     ax,1\r
288         mov     ax,OFFSET intti8\r
289         mov     dx,17000 ;70hz\r
290         jmp     @@1___\r
291 deinittimer:\r
292         mov     ax,ds:oldint8\r
293         xor     dx,dx\r
294 @@1___: cli\r
295         mov     fs:[8*4],ax\r
296         mov     al,036h\r
297         out     43h,al\r
298         mov     al,dl\r
299         out     40h,al\r
300         mov     al,dh\r
301         out     40h,al\r
302         sti\r
303         ret\r
304 inittimer ENDP\r
305 \r
306 intti8  PROC FAR ;timer interrupt\r
307         push    ax\r
308         mov     al,20h\r
309         out     20h,al\r
310         inc     [word ptr cs:framecounter];;;;\r
311         pop     ax\r
312         iret\r
313 intti8  ENDP\r
314 \r
315 ;±±±±±±±±±±±±±±±± load indexed palette ±±±±±±±±±±±±±±\r
316 setpal  PROC NEAR\r
317         ;ds:si=pointer to colorindices\r
318         mov     dx,3c8h\r
319         xor     al,al\r
320         out     dx,al\r
321         inc     dx\r
322         mov     cx,8\r
323 @@1____:        xor     bh,bh\r
324         mov     bl,ds:[si]\r
325         shr     bl,1\r
326         shr     bl,1\r
327         call    setpl2\r
328         mov     bl,ds:[si]\r
329         shl     bx,1\r
330         shl     bx,1\r
331         call    setpl2\r
332         inc     si\r
333         loop    @@1____\r
334         ret\r
335 setpl2: and     bx,15*2\r
336         mov     ax,word ptr ds:col0[bx]\r
337         out     dx,al\r
338         mov     al,ah\r
339         out     dx,al\r
340         mov     al,ds:col0[bx+2]\r
341         out     dx,al\r
342         ret\r
343 setpal  ENDP\r
344 \r
345 ;±±±±±±±±±±±±±± clear & copy videobuffer to screen ±±±±±±±±±±±±±±\r
346 clearcopy PROC NEAR\r
347 ;---copy/clear buf\r
348         xor     dx,dx\r
349         mov     si,OFFSET vbuf\r
350         mov     bx,4\r
351         mov     cx,200\r
352         mov     di,-4\r
353 @@1_____:       mov     bp,5\r
354 @@2_:   REPT    2\r
355         mov     ax,ds:[si]\r
356         add     di,bx\r
357         mov     ds:[si],dx\r
358         add     si,bx\r
359         mov     es:[di],ax\r
360         ENDM\r
361         dec     bp\r
362         jnz     @@2_\r
363         add     si,bx\r
364         dec     cx\r
365         jnz     @@1_____\r
366         ret\r
367 clearcopy ENDP\r
368 \r
369 ;±±±±±±±±±±±±±± draw a small pixel ±±±±±±±±±±±±±±\r
370 pset1   PROC NEAR ;ds:di=destination center, si=xmask offset\r
371         mov     al,ds:colb[si]\r
372         or      ds:[di],al\r
373         ret     ;;;;@@1:\r
374 pset1   ENDP\r
375 \r
376 ;±±±±±±±±±±±±±± draw a big pixel (depending on Z) ±±±±±±±±±±±±±\r
377 pset2   PROC NEAR ;ds:di=destination center, si=xmask offset\r
378         mov     ax,ds:colbww[si]\r
379         or      ds:[di+0],ax\r
380         or      ds:[di+44],ax\r
381         cmp     bp,8300 ;zcompare for size\r
382         jl      pset3\r
383         ;smaller one\r
384         mov     ax,ds:colbw[si]\r
385         or      ds:[di-44],ax\r
386         or      ds:[di+88],ax\r
387         mov     ax,ds:colbv[si]\r
388         or      ds:[di-88],ax\r
389         or      ds:[di+132],ax\r
390         ret\r
391 pset3:  ;larger one\r
392         or      ds:[di-44],ax\r
393         or      ds:[di+88],ax\r
394         mov     ax,ds:colbw[si]\r
395         or      ds:[di-88],ax\r
396         or      ds:[di+132],ax\r
397         ret\r
398 pset2   ENDP\r
399 \r
400 ;±±±±±±±±±±±±±± add a letter composed of big dots to dotlist ±±±±±±±±±±±±±\r
401 letter3d PROC NEAR\r
402         ;bx=letter\r
403         ;si=basex\r
404         ;bp=basey\r
405         sub     bx,'A'\r
406         jc      @@0__\r
407         shl     bx,1\r
408         shl     bx,1\r
409         shl     bx,1\r
410         mov     di,ds:nextdot\r
411         mov     cx,8\r
412 @@1_______:     push    cx\r
413         push    si\r
414         mov     cx,8\r
415 @@2__:  cmp     byte ptr ds:font[bx],0;;;;\r
416         je      @@3\r
417         mov     ds:dots[di],si\r
418         mov     ds:dots[di+2],bp\r
419         ;zsinus\r
420         push    si\r
421         add     si,ds:sinus1\r
422         sar     si,1\r
423         sar     si,1\r
424         sar     si,1\r
425         sar     si,1\r
426         sar     si,1\r
427         sar     si,1\r
428         and     si,63\r
429         mov     al,ds:sintable[si]\r
430         cbw\r
431         pop     si\r
432         shl     ax,1\r
433         shl     ax,1\r
434         mov     ds:dots[di+4],ax\r
435         ;\r
436         mov     word ptr ds:dots[di+6],OFFSET pset2\r
437         add     di,8\r
438         and     di,2047;;;;DOTNUM1*8-1\r
439 @@3:    inc     bx\r
440         add     si,LETTERDOTSPACING\r
441         loop    @@2__\r
442         pop     si\r
443         add     bx,320-8\r
444         add     bp,LETTERDOTSPACING\r
445         pop     cx\r
446         loop    @@1_______\r
447         mov     ds:nextdot,di\r
448 @@0__:  ret\r
449 letter3d ENDP\r
450 \r
451 ;±±±±±±±±±±±±±± calc 2x2 rotation matrix ±±±±±±±±±±±±±\r
452 set3drot PROC NEAR\r
453         ;ax=angle,ds:di=pointer to matrix\r
454         push    ax\r
455         call    sin\r
456         mov     ds:[di+r01-r00],ax\r
457         neg     ax\r
458         mov     ds:[di+r10-r00],ax\r
459         pop     ax\r
460         call    cos\r
461         mov     ds:[di+r00-r00],ax\r
462         mov     ds:[di+r11-r00],ax\r
463         ret\r
464 set3drot ENDP\r
465 \r
466 ;±±±±±±±±±±±± rotate point with 2x2 rotation matrix (innerpart) ±±±±±±±±±±±±±\r
467 rotate2x2i PROC NEAR\r
468         ;(di,bp)->(cx) with matrix half at ds:si\r
469         ;this is the inner part, called twice\r
470         push    bx\r
471         mov     ax,di\r
472         imul    word ptr ds:[si]\r
473         mov     cx,ax\r
474         mov     bx,dx\r
475         mov     ax,bp\r
476         imul    word ptr ds:[si+2]\r
477         add     cx,ax\r
478         adc     bx,dx\r
479 ;       shrd    cx,bx,14;;;;;;;;\r
480         pop     bx\r
481         add     si,4\r
482         ret\r
483 rotate2x2i ENDP\r
484 \r
485 ;±±±±±±±±±±±±±± advance demo one frame (raw work) ±±±±±±±±±±±±±\r
486 doit    PROC NEAR\r
487 ;======wait for border\r
488         setborder 0\r
489         mov     dx,3dah\r
490 @@w1:   in      al,dx\r
491         test    al,8\r
492         jnz     @@w1\r
493 @@w2:   in      al,dx\r
494         test    al,8\r
495         jz      @@w2\r
496         setborder 30\r
497 ;======done\r
498         mov     si,ds:index\r
499         push    si\r
500         call    setpal\r
501         pop     si\r
502         add     si,9\r
503         cmp     si,OFFSET index4\r
504         jbe     @@i2\r
505         mov     si,OFFSET index1\r
506 @@i2:   mov     ds:index,si\r
507         mov     al,2\r
508         mov     ah,ds:[si+8]\r
509         mov     dx,3c4h\r
510         out     dx,ax\r
511         call    clearcopy\r
512 ;======do timer simulation stuff\r
513         setborder 28\r
514         xor     cx,cx\r
515         mov     byte ptr ds:scrollsubber,0;;;;\r
516         xchg    cx,ds:framecounter\r
517         jcxz    @@78\r
518 @@77:   push    cx\r
519         add     byte ptr ds:scrollsubber,90;;;;;SCROLLSPEED\r
520         call    doit70\r
521         pop     cx\r
522         loop    @@77\r
523         setborder 26\r
524 @@78:;======\r
525 ;---redraw dots\r
526         mov     cx,DOTNUM\r
527         mov     bx,OFFSET dots\r
528 @@1________:    push    cx\r
529         push    bx\r
530         mov     bp,ds:[bx+2]\r
531         mov     di,ds:[bx+4]\r
532         cmp     word ptr ds:[bx+6],OFFSET pset2\r
533         jne     @@5\r
534         ;ysinus\r
535         mov     cx,ds:[bx]\r
536         mov     si,ds:sinus2\r
537         add     si,cx\r
538         sar     si,1\r
539         sar     si,1\r
540         sar     si,1\r
541         sar     si,1\r
542         sar     si,1\r
543         sar     si,1\r
544         sar     si,1\r
545         and     si,63\r
546         mov     al,ds:sintable[si]\r
547         cbw\r
548         shl     ax,1\r
549         shl     ax,1\r
550         add     bp,ax\r
551         ;scroll\r
552         sub     cx,ds:scrollsubber\r
553         mov     ds:[bx],cx\r
554         cmp     cx,-3900\r
555         jl      @@7_\r
556         cmp     cx,3900\r
557         jg      @@7_\r
558 @@5:    ;--rotate coordinates\r
559         mov     si,OFFSET r00\r
560         call    rotate2x2i\r
561         push    cx\r
562         call    rotate2x2i\r
563         pop     di\r
564         mov     bp,ds:[bx]\r
565         mov     si,OFFSET p00\r
566         push    cx\r
567         call    rotate2x2i\r
568         push    cx\r
569         call    rotate2x2i\r
570         pop     bp\r
571         pop     di\r
572         ;bp=Z, cx=X, di=Y\r
573         add     bp,ds:zadder\r
574         cmp     bp,1024\r
575         jl      @@7_\r
576         ;--project\r
577         mov     ax,256\r
578         imul    di\r
579         idiv    bp\r
580         add     ax,100\r
581         mov     di,ax\r
582         mov     ax,307\r
583         imul    cx\r
584         idiv    bp\r
585         add     ax,160\r
586         mov     si,ax\r
587         ;si=SX, di=SY\r
588         mov     ax,ds:[bx+6]\r
589         cmp     si,319\r
590         ja      @@7_\r
591         cmp     di,199\r
592         ja      @@7_\r
593         ;calc dest address & xmask offset\r
594         add     di,di\r
595         mov     di,ds:rows[di]\r
596         add     si,si\r
597         add     di,ds:cols[si]\r
598         ;\r
599         call    ax\r
600 @@7_:   pop     bx\r
601         pop     cx\r
602         add     bx,8\r
603         dec     cx\r
604         jnz     @@1________\r
605         ret\r
606 doit    ENDP\r
607 \r
608 ;±±±±±±±±±±±±±± advance demo counters 1/70 sec ±±±±±±±±±±±±±\r
609 ;a separate routine is used to get frame syncronization for\r
610 ;slower machines (and slow vga cards)\r
611 doit70  PROC NEAR\r
612 ;---add sinuses & udforce\r
613         add     byte ptr ds:sinus1,70;;;;\r
614         add     byte ptr ds:sinus2,177;;;;\r
615         add     word ptr ds:udforced,3000;;;;\r
616 ;---set wave1\r
617         mov     bx,OFFSET wwave\r
618         mov     ax,77\r
619         call    addwcos\r
620         sar     ax,1\r
621         sar     ax,1\r
622         sar     ax,1\r
623         sar     ax,1\r
624         sar     ax,1\r
625         mov     ds:wave1,ax\r
626 ;---set zadder\r
627         mov     bx,OFFSET zwave\r
628         mov     ax,370\r
629         call    addwcos\r
630         sar     ax,1\r
631         sar     ax,1\r
632         sar     ax,1\r
633         add     ax,8888\r
634         mov     ds:zadder,ax\r
635 ;---set 3d rotate YZ\r
636         mov     bx,OFFSET udwave\r
637         mov     ax,ds:wave1\r
638         call    addwcos\r
639         imul    word ptr ds:udforce;;;;\r
640 ;       shrd    ax,dx,8;;;;;;;;\r
641         mov     di,OFFSET r00\r
642         call    set3drot\r
643 ;---set 3d rotate XZ\r
644         mov     bx,OFFSET lrwave\r
645         mov     ax,200\r
646         call    addwcos\r
647         sar     ax,1\r
648         mov     di,OFFSET p00\r
649         call    set3drot\r
650 ;---add more text to 3d scroller\r
651         sub     byte ptr ds:textcnt,90;;;;SCROLLSPEED\r
652         jnc     @@t1\r
653         mov     word ptr ds:textcnt,1023;;;;LETTERDOTSPACING*8-1\r
654         mov     si,ds:text\r
655         mov     bl,ds:[si]\r
656         IFDEF XORTEXTS\r
657         xor     bl,17h\r
658         ENDIF\r
659         and     bx,255\r
660         jz      @@t3\r
661         inc     si\r
662         mov     ds:text,si\r
663         cmp     bl,32\r
664         jge     @@t4\r
665         shl     bx,1;;;;SCROLLDELAYSHL\r
666         shl     bx,1\r
667         shl     bx,1\r
668         shl     bx,1\r
669         shl     bx,1\r
670         shl     bx,1\r
671         shl     bx,1\r
672         shl     bx,1\r
673         shl     bx,1\r
674         mov     ds:textcnt,bx\r
675         jmp     @@t1\r
676 @@t4:   mov     bp,0\r
677         mov     si,4100\r
678         call    letter3d\r
679         jmp     @@t1\r
680 @@t3:   mov     si,OFFSET text0\r
681         mov     ds:text,si\r
682 @@t1:   ;;;\r
683 ;======adlib music\r
684         jmp     a_dorow\r
685 doit70  ENDP\r
686 \r
687 ;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Main routine ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ\r
688 ;stack @ cs:0fffeh\r
689 \r
690 main    PROC NEAR\r
691 ;ÍÍÍÍÍÍÍÍÍ Zero Zerodata & Init Segs ÍÍÍÍÍÍÍ\r
692 .8086   ;;;\r
693         push    cs\r
694         push    cs\r
695         pop     ds\r
696         pop     es\r
697         mov     cx,(zeroend-zerobeg)/2\r
698         mov     di,OFFSET zerobeg\r
699         xor     ax,ax ;zero used later\r
700         rep     stosw\r
701         mov     dx,0a000h\r
702         mov     es,dx\r
703 ;segments now set: DS=code/data ES=vram\r
704 ;ÍÍÍÍÍÍÍÍÍ Check for 386 ÍÍÍÍÍÍÍÍÍ\r
705         push    sp\r
706         pop     dx\r
707         cmp     dx,sp\r
708         jz      @@o1\r
709 @@o2:   jmp     endansi ;80(1)86\r
710 .286p   ;;;\r
711 @@o1:   mov     bx,OFFSET rows\r
712         sgdt    ds:[bx]\r
713         cmp     byte ptr ds:[bx+5],0\r
714         js      @@o2\r
715 ;ÍÍÍÍÍÍÍÍÍ Check for VGA ÍÍÍÍÍÍÍÍÍ\r
716 .386p   ;;;\r
717         mov     fs,ax ;ax was zero\r
718 ;segments now set: DS=code/data ES=vram FS=zeropage\r
719         mov     ax,1a00h\r
720         int     10h\r
721         cmp     al,01ah\r
722         jne     endansi ;no vga\r
723         cmp     bl,7\r
724         jb      endansi ;no vga\r
725 ;ÍÍÍÍÍÍÍÍÍ Initialize - doinit 0 ÍÍÍÍÍÍÍÍÍ\r
726         ;copy vga font to font buffer\r
727         mov     ax,13h\r
728         int     10h\r
729         mov     cx,'Z'-'A'+1\r
730         mov     bx,16\r
731         mov     ax,'A'+0eh*256\r
732 @@a1:   int     10h\r
733         inc     al\r
734         loop    @@a1\r
735         mov     cx,8*320/2\r
736         mov     bx,OFFSET font\r
737         xor     di,di\r
738 @@a2:   mov     ax,es:[di]\r
739         mov     ds:[di+bx],ax\r
740         add     di,2\r
741         loop    @@a2\r
742 ;ÍÍÍÍÍÍÍÍÍ Initialize - vga ÍÍÍÍÍÍÍÍÍ\r
743         ;init videomode 320x200x16\r
744         mov     ax,0dh\r
745         int     10h\r
746         ;set up rows/cols/etc\r
747         mov     si,-2\r
748         mov     di,OFFSET vbuf-44\r
749         mov     bl,128\r
750         xor     bp,bp\r
751         jmp     @@b5\r
752 @@b1:   mov     ds:rows[si],di\r
753         mov     ds:colb[si],bl\r
754         mov     ds:colbww[si],cx\r
755         shr     cl,1\r
756         rcr     ch,1\r
757         mov     ds:colbw[si],dx\r
758         shr     dl,1\r
759         rcr     dh,1\r
760         mov     ds:colbv[si],ax\r
761         shr     al,1\r
762         rcr     ah,1\r
763         mov     ds:cols[si],bp\r
764         ror     bl,1\r
765         jnc     @@b4\r
766         inc     bp\r
767 @@b5:   mov     cx,0000000011111110b\r
768         mov     dx,0000000001111100b\r
769         mov     ax,0000000000111000b\r
770 @@b4:   add     di,44\r
771         add     si,2\r
772         cmp     si,(320)*2\r
773         jle     @@b1\r
774         ;set simplex palette order (16 color mode)\r
775         mov     dx,3dah\r
776         in      al,dx\r
777         mov     dl,0c0h\r
778         xor     ax,ax\r
779         mov     cx,16\r
780 @@b2:   out     dx,al\r
781         out     dx,al\r
782         inc     al\r
783         loop    @@b2\r
784         mov     al,20h\r
785         out     dx,al\r
786 ;ÍÍÍÍÍÍÍÍÍ Initialize - doinit ÍÍÍÍÍÍÍÍÍ\r
787         mov     cx,DOTNUM\r
788         mov     bx,OFFSET dots-2\r
789 @@c1:   push    cx\r
790         call    rand\r
791         call    rand\r
792         call    rand\r
793         sar     ax,2\r
794         mov     ds:[bx],ax\r
795         add     bx,2\r
796         mov     word ptr ds:[bx],OFFSET pset1\r
797         pop     cx\r
798         loop    @@c1\r
799 ;ÍÍÍÍÍÍÍÍÍ Initialize - others ÍÍÍÍÍÍÍÍÍ\r
800         call    a_init\r
801         call    inittimer\r
802 ;ÍÍÍÍÍÍÍÍÍ Do the intro stuff ÍÍÍÍÍÍÍÍÍ\r
803 again:  call    doit\r
804         mov     ah,1\r
805         int     16h\r
806         jz      again\r
807         mov     ah,0\r
808         int     16h\r
809 ;ÍÍÍÍÍÍÍÍÍ DeInitialize ÍÍÍÍÍÍÍÍÍ\r
810         call    deinittimer\r
811         call    a_init ;reinitializing adlib shuts it up\r
812 ;ÍÍÍÍÍÍÍÍÍ Display end ansi (only thing done if no 386 or vga) ÍÍÍÍÍÍÍÍÍ\r
813 endansi:mov     ax,3h\r
814         int     10h\r
815         mov     si,OFFSET endtext\r
816         push    0b800h  ;if the user has an MGA or HGC\r
817         pop     es      ;it's not my problem :-)\r
818         xor     di,di\r
819         mov     ah,0eh\r
820 @@1__________:  lodsb\r
821         IFDEF XORTEXTS\r
822         xor     al,17h\r
823         ENDIF\r
824         cmp     al,31\r
825         jae     @@2___\r
826         mov     ah,al\r
827         jmp     @@1__________\r
828 @@2___: jz      @@3__\r
829         stosw\r
830         jmp     @@1__________\r
831 @@3__:  mov     ax,4c00h\r
832         int     21h\r
833 main    ENDP\r
834 \r
835 ;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Initialized (nonzero) data ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ\r
836 \r
837 ;pointer & delay counter for scrolltext\r
838 text    dw      OFFSET text0\r
839 textcnt dw      1\r
840 \r
841 ;3d rotation values (more in zerodata)\r
842 udforced LABEL DWORD\r
843         dw      0\r
844 udforce dw      64\r
845 lrwave  dw      -20000\r
846 zwave   dw      16000\r
847 \r
848 sintable LABEL BYTE ;sine table (circle is 64 units)\r
849 db 0,12,24,36,48,59,70,80,89,98,105,112,117,121,124,126,127,126\r
850 db 124,121,117,112,105,98,89,80,70,59,48,36,24,12,0,-12,-24,-36\r
851 db -48,-59,-70,-80,-89,-98,-105,-112,-117,-121,-124,-126,-127\r
852 db -126,-124,-121,-117,-112,-105,-98,-89,-80,-70,-59,-48,-36\r
853 db -24,-12,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54\r
854 db 57,59,62,65,67,70\r
855 \r
856 ;adlib player data\r
857 a_inst_table LABEL BYTE\r
858         db 20h+0,20h+1,20h+2,20h+8,20h+9,20h+10,20h+16,20h+17,20h+18\r
859 NTB equ 8192 ;+1024*1\r
860 a_note_table LABEL WORD\r
861         dw NTB+363,NTB+385,NTB+408,NTB+432,NTB+458,NTB+485\r
862         dw NTB+514,NTB+544,NTB+577,NTB+611,NTB+647,NTB+868\r
863         ;note: a zero word is expected after this table (found in col0)\r
864 \r
865 col0    db       0, 0, 0 ,0     ;background color\r
866 col1    db       0,15,35 ,0     ;delay color 3\r
867 col2    db      16,30,48 ,0     ;delay color 2\r
868 col3    db      32,45,55 ,0     ;delay color 1\r
869 col4    db      60,61,62        ;brightest color\r
870         ;1      . x . x . x . x . x . x . x . x\r
871         ;2      . . x x . . x x . . x x . . x x\r
872         ;4      . . . . x x x x . . . . x x x x\r
873         ;8      . . . . . . . . x x x x x x x x\r
874 ;palette indices for 4 palettes. Last number is bitplane to write\r
875 ;during the frame having this palette\r
876 index1  db      04h,34h,24h,34h,14h,34h,24h,34h ,1 ;1248\r
877 index2  db      03h,23h,13h,23h,44h,44h,44h,44h ,8 ;8124\r
878 index3  db      02h,12h,44h,44h,33h,33h,44h,44h ,4 ;4812\r
879 index4  db      01h,44h,33h,44h,22h,44h,33h,44h ,2 ;2481\r
880 index   dw      OFFSET index1 ;offset to current index\r
881 \r
882 ;################## Music - (tune by skaven/fc) ###################\r
883 ;generated with ST3->SIMPLEXADLIB, handoptimized by psi (283 bytes)\r
884 music_channels equ 8\r
885 music_speed equ 8\r
886 music_instruments LABEL BYTE\r
887 dw OFFSET ains6\r
888 dw OFFSET ains2\r
889 dw OFFSET ains4\r
890 dw OFFSET ains3\r
891 dw OFFSET ains3\r
892 dw OFFSET ains1\r
893 dw OFFSET ains1\r
894 dw OFFSET ains4\r
895 ains1 LABEL BYTE\r
896 db 65,194,6,0,35,242,240,240,1,0,4\r
897 ains2 LABEL BYTE\r
898 db 145,64,135,128,243,111,35,3,1,1,2\r
899 ains3 LABEL BYTE\r
900 db 225,33,17,128,17,19,34,34,0,0,12\r
901 ains4 LABEL BYTE\r
902 db 97,33,27,0,98,132,86,85,0,0,14\r
903 ains6 LABEL BYTE\r
904 db 145,64,135,136,243,111,35,3,1,1,2\r
905 music_patterns LABEL BYTE\r
906 ach0 dw OFFSET ach0d,OFFSET ach0dr\r
907 ach1 dw OFFSET ach1d,OFFSET ach1dr\r
908 ach2 dw OFFSET ach2d,OFFSET ach2dr\r
909 ach3 dw OFFSET ach3d,OFFSET ach3d\r
910 ach4 dw OFFSET ach4d,OFFSET ach4d\r
911 ach5 dw OFFSET ach5d,OFFSET ach5d\r
912 ach6 dw OFFSET ach6d,OFFSET ach6d\r
913 ach7 dw OFFSET ach7d,OFFSET ach7d\r
914 ach0d LABEL BYTE\r
915 db 081h\r
916 ach0dr LABEL BYTE\r
917 db 057h,050h,050h,055h,057h,050h,055h,057h\r
918 db 050h,055h,057h,050h,055h,057h,050h,055h\r
919 db 0\r
920 ach1d LABEL BYTE\r
921 db 081h\r
922 ach1dr LABEL BYTE\r
923 db 050h,055h,057h,050h,055h,057h,050h,055h\r
924 db 057h,050h,055h,057h,050h,055h,057h,050h\r
925 db 0\r
926 ach2d LABEL BYTE\r
927 db 0C0h,050h,084h\r
928 db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah\r
929 db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah\r
930 ach2dr LABEL BYTE\r
931 db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah\r
932 db 025h,015h,025h,015h,028h,018h,02Ah,01Ah\r
933 db 0\r
934 ach3d LABEL BYTE\r
935 db 0A0h,050h,040h,0C0h,040h,088h,040h,040h\r
936 db 03Ah,042h,090h,045h,088h,040h,042h,040h\r
937 db 047h,090h,04Ah,088h,045h,098h,040h\r
938 db 0\r
939 ach4d LABEL BYTE\r
940 db 0A0h,050h,030h,0C0h,047h,088h,047h,043h\r
941 db 042h,045h,047h,045h,048h,047h,047h,050h\r
942 db 052h,084h,050h,04Ah,088h,050h,098h,045h\r
943 db 0\r
944 ach5d LABEL BYTE\r
945 db 0C0h,020h,0A0h,010h,010h,090h,010h,02Ah\r
946 db 025h,088h,028h,02Ah,090h,010h,02Ah,025h\r
947 db 088h,028h,02Ah\r
948 db 0\r
949 ach6d LABEL BYTE\r
950 db 0C0h,020h,0A0h,020h,020h,090h,020h,01Ah\r
951 db 015h,088h,018h,01Ah,090h,020h,01Ah,015h\r
952 db 088h,018h,01Ah\r
953 db 0\r
954 ach7d LABEL BYTE\r
955 db 0C0h,00Ch,0FEh,050h,090h,00Ch,081h,04Ah\r
956 db 050h,084h,052h,055h,086h,04Ah,081h,050h\r
957 db 04Ah,086h,050h,082h,055h,098h,045h\r
958 db 0\r
959 ;#########################################################\r
960 \r
961 SCROLLSPEED equ 90\r
962 SCROLLDELAYSHL equ 9\r
963 LETTERDOTSPACING equ 128\r
964 \r
965 db 0fch\r
966 \r
967 text0   LABEL BYTE ;scrolltext (numbers are delays)\r
968         db      31,25,'CALL STARPORT',9,'FUTURE CREW WORLD HQ',9,'CDN',9,'GRAVIS EURO',9,'AND MORE',0\r
969 \r
970 endtext LABEL BYTE ;endansi... well... endansiline (numbers are colors)\r
971         db      15\r
972         db      'StarPort'\r
973         db      3,' ÄÄ ',11\r
974         db      'V32bis +358-0-8044626'\r
975         db      ' +358-0-8041133'\r
976         db      3,' ÄÄ ',15\r
977         db      'FC-WHQ'\r
978         db      31\r
979 endtext1 LABEL BYTE\r
980 \r
981 db 0fch\r
982 \r
983 ;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Uninitialized (zero) data ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ\r
984 \r
985 zerobeg LABEL WORD ;start zero clear from here\r
986 \r
987 rows    dw      320 dup(0)      ;offsets to screen rows\r
988 cols    dw      320 dup(0)      ;offsets to screen cols\r
989 colb    db      320 dup(0,0)    ;bitmasks for screen cols\r
990 colbv   dw      320 dup(0)      ;wide -"-\r
991 colbw   dw      320 dup(0)      ;wider -"-\r
992 colbww  dw      320 dup(0)      ;very wide -"-\r
993 \r
994 ALIGN 4\r
995         db      44*8 dup(0) ;negative overflow for videobuffer\r
996 vbuf    LABEL BYTE\r
997         db      44*200 dup(0) ;video buffer\r
998         db      44*8 dup(0) ;positive overflow for videobuffer\r
999 \r
1000 ALIGN 4\r
1001 font    LABEL BYTE\r
1002         db      8 dup(320 dup(0)) ;font buffer\r
1003 \r
1004 \r
1005 DOTNUM1 equ     256     ;number of dots used for text\r
1006 DOTNUM  equ     444     ;total number of dots\r
1007 ALIGN 4\r
1008 dots    LABEL WORD\r
1009         dw      DOTNUM dup(0,0,0,0) ;x,y,z,routine data for each dot\r
1010 \r
1011 ;2x2 rotation matrices\r
1012 r00     dw      0\r
1013 r10     dw      0\r
1014 r01     dw      0\r
1015 r11     dw      0\r
1016 p00     dw      0\r
1017 p10     dw      0\r
1018 p01     dw      0\r
1019 p11     dw      0\r
1020 \r
1021 ;zero initialized 3d rotation stuff\r
1022 zadder  dw      0\r
1023 wave1   dw      0\r
1024 udwave  dw      0\r
1025 wwave   dw      0\r
1026 sinus1  dw      0\r
1027 sinus2  dw      0\r
1028 \r
1029 ;adlib data\r
1030 a_musiccnt dw   0\r
1031 a_chdelaycnt db 9 dup(0)\r
1032 a_chdelay db    9 dup(0)\r
1033 ALIGN 2\r
1034 \r
1035 ;misc\r
1036 nextdot dw      0\r
1037 scrollsubber dw 0\r
1038 framecounter dw 0\r
1039 oldint8 dw      0;;;;;;;;\r
1040 seed    dw      0;;;;;;;;\r
1041 \r
1042 padder  db      16 dup(0)\r
1043 zeroend LABEL WORD ;end zero clear here\r
1044 \r
1045 code    ENDS\r
1046         END start\r