]> 4ch.mooo.com Git - 16.git/blob - 16/starport2/SP2.ASM
refresh wwww
[16.git] / 16 / starport2 / SP2.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         .386\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     ds:a_musiccnt,1\r
159         jnc     @@0\r
160         mov     ds:a_musiccnt,music_speed\r
161         mov     cx,music_channels\r
162         mov     di,OFFSET music_patterns\r
163         xor     bx,bx\r
164 @@1:    sub     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,2\r
182         and     dl,not 3\r
183         add     ah,dl\r
184         call    a_playnote\r
185         mov     al,ds:a_chdelay[bx]\r
186         mov     ds:a_chdelaycnt[bx],al\r
187         mov     ds:[di],si\r
188 @@2:    add     di,4\r
189         inc     bx\r
190         loop    @@1\r
191 @@0:    ret\r
192 @@7:    mov     si,ds:[di+2]\r
193         jmp     @@4\r
194 a_dorow ENDP\r
195 \r
196 ;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Intro Routines ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ\r
197 \r
198 ;±±±±±±±±±±±±±±±± sin/cos ±±±±±±±±±±±±±±±±\r
199 ;entry: ax=angle (0..65535)\r
200 ; exit: ax=muller (-127..127)\r
201 addwcos:add     ax,ds:[bx] ;optimized entry for wavesets\r
202         mov     ds:[bx],ax\r
203 cos:    add     ax,16384\r
204 sin:    mov     bx,ax\r
205         mov     cx,bx\r
206         and     cx,1023\r
207         neg     cx\r
208         add     cx,1023\r
209         shr     bx,10\r
210         mov     ah,ds:sintable[bx]\r
211         xor     al,al\r
212         imul    cx\r
213         push    ax\r
214         push    dx\r
215         mov     ah,ds:sintable[bx+1]\r
216         xor     al,al\r
217         neg     cx\r
218         add     cx,1023\r
219         imul    cx\r
220         pop     bx\r
221         pop     cx\r
222         add     ax,cx\r
223         adc     dx,bx\r
224         shrd    ax,dx,11\r
225         ret\r
226 \r
227 ;±±±±±±±±±±±±±±±± rand ±±±±±±±±±±±±±±±±\r
228 ;returns a random value in range -4096..4095\r
229 rand    PROC NEAR\r
230         mov     eax,1107030247\r
231         mul     ds:seed\r
232         add     eax,97177\r
233         mov     ds:seed,eax\r
234         shr     eax,15\r
235         and     ax,8191\r
236         sub     ax,4096\r
237 ;size optimizatin, some code moved from after all rand calls\r
238         add     bx,2\r
239         mov     ds:[bx],ax\r
240         ret\r
241 rand    ENDP\r
242 \r
243 ;±±±±±±±±±±±±±±±± timer ±±±±±±±±±±±±±±±±\r
244 inittimer PROC NEAR\r
245         mov     eax,fs:[8*4]\r
246         mov     ds:oldint8,eax\r
247         mov     ax,cs\r
248         shl     eax,16\r
249         mov     ax,OFFSET intti8\r
250         mov     dx,17000 ;70hz\r
251         jmp     @@1\r
252 deinittimer:\r
253         mov     eax,ds:oldint8\r
254         xor     dx,dx\r
255 @@1:    cli\r
256         mov     fs:[8*4],eax\r
257         mov     al,036h\r
258         out     43h,al\r
259         mov     al,dl\r
260         out     40h,al\r
261         mov     al,dh\r
262         out     40h,al\r
263         sti\r
264         ret\r
265 inittimer ENDP\r
266 \r
267 intti8  PROC FAR ;timer interrupt\r
268         push    ax\r
269         mov     al,20h\r
270         out     20h,al\r
271         inc     cs:framecounter\r
272         pop     ax\r
273         iret\r
274 intti8  ENDP\r
275 \r
276 ;±±±±±±±±±±±±±±±± load indexed palette ±±±±±±±±±±±±±±\r
277 setpal  PROC NEAR\r
278         ;ds:si=pointer to colorindices\r
279         mov     dx,3c8h\r
280         xor     al,al\r
281         out     dx,al\r
282         inc     dx\r
283         mov     cx,8\r
284 @@1:    xor     bh,bh\r
285         mov     bl,ds:[si]\r
286         shr     bl,2\r
287         call    setpl2\r
288         mov     bl,ds:[si]\r
289         shl     bx,2\r
290         call    setpl2\r
291         inc     si\r
292         loop    @@1\r
293         ret\r
294 setpl2: and     bx,15*2\r
295         mov     ax,word ptr ds:col0[bx]\r
296         out     dx,al\r
297         mov     al,ah\r
298         out     dx,al\r
299         mov     al,ds:col0[bx+2]\r
300         out     dx,al\r
301         ret\r
302 setpal  ENDP\r
303 \r
304 ;±±±±±±±±±±±±±± clear & copy videobuffer to screen ±±±±±±±±±±±±±±\r
305 clearcopy PROC NEAR\r
306 ;---copy/clear buf\r
307         xor     edx,edx\r
308         mov     si,OFFSET vbuf\r
309         mov     bx,4\r
310         mov     cx,200\r
311         mov     di,-4\r
312 @@1:    mov     bp,5\r
313 @@2:    REPT    2\r
314         mov     eax,ds:[si]\r
315         add     di,bx\r
316         mov     ds:[si],edx\r
317         add     si,bx\r
318         mov     es:[di],eax\r
319         ENDM\r
320         dec     bp\r
321         jnz     @@2\r
322         add     si,bx\r
323         dec     cx\r
324         jnz     @@1\r
325         ret\r
326 clearcopy ENDP\r
327 \r
328 ;±±±±±±±±±±±±±± draw a small pixel ±±±±±±±±±±±±±±\r
329 pset1   PROC NEAR ;ds:di=destination center, si=xmask offset\r
330         mov     al,ds:colb[si]\r
331         or      ds:[di],al\r
332 @@1:    ret\r
333 pset1   ENDP\r
334 \r
335 ;±±±±±±±±±±±±±± draw a big pixel (depending on Z) ±±±±±±±±±±±±±\r
336 pset2   PROC NEAR ;ds:di=destination center, si=xmask offset\r
337         mov     ax,ds:colbww[si]\r
338         or      ds:[di+0],ax\r
339         or      ds:[di+44],ax\r
340         cmp     bp,8300 ;zcompare for size\r
341         jl      pset3\r
342         ;smaller one\r
343         mov     ax,ds:colbw[si]\r
344         or      ds:[di-44],ax\r
345         or      ds:[di+88],ax\r
346         mov     ax,ds:colbv[si]\r
347         or      ds:[di-88],ax\r
348         or      ds:[di+132],ax\r
349         ret\r
350 pset3:  ;larger one\r
351         or      ds:[di-44],ax\r
352         or      ds:[di+88],ax\r
353         mov     ax,ds:colbw[si]\r
354         or      ds:[di-88],ax\r
355         or      ds:[di+132],ax\r
356         ret\r
357 pset2   ENDP\r
358 \r
359 ;±±±±±±±±±±±±±± add a letter composed of big dots to dotlist ±±±±±±±±±±±±±\r
360 letter3d PROC NEAR\r
361         ;bx=letter\r
362         ;si=basex\r
363         ;bp=basey\r
364         sub     bx,'A'\r
365         jc      @@0\r
366         shl     bx,3\r
367         mov     di,ds:nextdot\r
368         mov     cx,8\r
369 @@1:    push    cx\r
370         push    si\r
371         mov     cx,8\r
372 @@2:    cmp     ds:font[bx],0\r
373         je      @@3\r
374         mov     ds:dots[di],si\r
375         mov     ds:dots[di+2],bp\r
376         ;zsinus\r
377         push    si\r
378         add     si,ds:sinus1\r
379         sar     si,6\r
380         and     si,63\r
381         mov     al,ds:sintable[si]\r
382         cbw\r
383         pop     si\r
384         shl     ax,2\r
385         mov     ds:dots[di+4],ax\r
386         ;\r
387         mov     word ptr ds:dots[di+6],OFFSET pset2\r
388         add     di,8\r
389         and     di,DOTNUM1*8-1\r
390 @@3:    inc     bx\r
391         add     si,LETTERDOTSPACING\r
392         loop    @@2\r
393         pop     si\r
394         add     bx,320-8\r
395         add     bp,LETTERDOTSPACING\r
396         pop     cx\r
397         loop    @@1\r
398         mov     ds:nextdot,di\r
399 @@0:    ret\r
400 letter3d ENDP\r
401 \r
402 ;±±±±±±±±±±±±±± calc 2x2 rotation matrix ±±±±±±±±±±±±±\r
403 set3drot PROC NEAR\r
404         ;ax=angle,ds:di=pointer to matrix\r
405         push    ax\r
406         call    sin\r
407         mov     ds:[di+r01-r00],ax\r
408         neg     ax\r
409         mov     ds:[di+r10-r00],ax\r
410         pop     ax\r
411         call    cos\r
412         mov     ds:[di+r00-r00],ax\r
413         mov     ds:[di+r11-r00],ax\r
414         ret\r
415 set3drot ENDP\r
416 \r
417 ;±±±±±±±±±±±± rotate point with 2x2 rotation matrix (innerpart) ±±±±±±±±±±±±±\r
418 rotate2x2i PROC NEAR\r
419         ;(di,bp)->(cx) with matrix half at ds:si\r
420         ;this is the inner part, called twice\r
421         push    bx\r
422         mov     ax,di\r
423         imul    word ptr ds:[si]\r
424         mov     cx,ax\r
425         mov     bx,dx\r
426         mov     ax,bp\r
427         imul    word ptr ds:[si+2]\r
428         add     cx,ax\r
429         adc     bx,dx\r
430         shrd    cx,bx,14\r
431         pop     bx\r
432         add     si,4\r
433         ret\r
434 rotate2x2i ENDP\r
435 \r
436 ;±±±±±±±±±±±±±± advance demo one frame (raw work) ±±±±±±±±±±±±±\r
437 doit    PROC NEAR\r
438 ;======wait for border\r
439         setborder 0\r
440         mov     dx,3dah\r
441 @@w1:   in      al,dx\r
442         test    al,8\r
443         jnz     @@w1\r
444 @@w2:   in      al,dx\r
445         test    al,8\r
446         jz      @@w2\r
447         setborder 30\r
448 ;======done\r
449         mov     si,ds:index\r
450         push    si\r
451         call    setpal\r
452         pop     si\r
453         add     si,9\r
454         cmp     si,OFFSET index4\r
455         jbe     @@i2\r
456         mov     si,OFFSET index1\r
457 @@i2:   mov     ds:index,si\r
458         mov     al,2\r
459         mov     ah,ds:[si+8]\r
460         mov     dx,3c4h\r
461         out     dx,ax\r
462         call    clearcopy\r
463 ;======do timer simulation stuff\r
464         setborder 28\r
465         xor     cx,cx\r
466         mov     ds:scrollsubber,0\r
467         xchg    cx,ds:framecounter\r
468         jcxz    @@78\r
469 @@77:   push    cx\r
470         add     ds:scrollsubber,SCROLLSPEED\r
471         call    doit70\r
472         pop     cx\r
473         loop    @@77\r
474         setborder 26\r
475 @@78:;======\r
476 ;---redraw dots\r
477         mov     cx,DOTNUM\r
478         mov     bx,OFFSET dots\r
479 @@1:    push    cx\r
480         push    bx\r
481         mov     bp,ds:[bx+2]\r
482         mov     di,ds:[bx+4]\r
483         cmp     word ptr ds:[bx+6],OFFSET pset2\r
484         jne     @@5\r
485         ;ysinus\r
486         mov     cx,ds:[bx]\r
487         mov     si,ds:sinus2\r
488         add     si,cx\r
489         sar     si,7\r
490         and     si,63\r
491         mov     al,ds:sintable[si]\r
492         cbw\r
493         shl     ax,2\r
494         add     bp,ax\r
495         ;scroll\r
496         sub     cx,ds:scrollsubber\r
497         mov     ds:[bx],cx\r
498         cmp     cx,-3900\r
499         jl      @@7\r
500         cmp     cx,3900\r
501         jg      @@7\r
502 @@5:    ;--rotate coordinates\r
503         mov     si,OFFSET r00\r
504         call    rotate2x2i\r
505         push    cx\r
506         call    rotate2x2i\r
507         pop     di\r
508         mov     bp,ds:[bx]\r
509         mov     si,OFFSET p00\r
510         push    cx\r
511         call    rotate2x2i\r
512         push    cx\r
513         call    rotate2x2i\r
514         pop     bp\r
515         pop     di\r
516         ;bp=Z, cx=X, di=Y\r
517         add     bp,ds:zadder\r
518         cmp     bp,1024\r
519         jl      @@7\r
520         ;--project\r
521         mov     ax,256\r
522         imul    di\r
523         idiv    bp\r
524         add     ax,100\r
525         mov     di,ax\r
526         mov     ax,307\r
527         imul    cx\r
528         idiv    bp\r
529         add     ax,160\r
530         mov     si,ax\r
531         ;si=SX, di=SY\r
532         mov     ax,ds:[bx+6]\r
533         cmp     si,319\r
534         ja      @@7\r
535         cmp     di,199\r
536         ja      @@7\r
537         ;calc dest address & xmask offset\r
538         add     di,di\r
539         mov     di,ds:rows[di]\r
540         add     si,si\r
541         add     di,ds:cols[si]\r
542         ;\r
543         call    ax\r
544 @@7:    pop     bx\r
545         pop     cx\r
546         add     bx,8\r
547         dec     cx\r
548         jnz     @@1\r
549         ret\r
550 doit    ENDP\r
551 \r
552 ;±±±±±±±±±±±±±± advance demo counters 1/70 sec ±±±±±±±±±±±±±\r
553 ;a separate routine is used to get frame syncronization for\r
554 ;slower machines (and slow vga cards)\r
555 doit70  PROC NEAR\r
556 ;---add sinuses & udforce\r
557         add     ds:sinus1,70\r
558         add     ds:sinus2,177\r
559         add     ds:udforced,3000\r
560 ;---set wave1\r
561         mov     bx,OFFSET wwave\r
562         mov     ax,77\r
563         call    addwcos\r
564         sar     ax,5\r
565         mov     ds:wave1,ax\r
566 ;---set zadder\r
567         mov     bx,OFFSET zwave\r
568         mov     ax,370\r
569         call    addwcos\r
570         sar     ax,3\r
571         add     ax,8888\r
572         mov     ds:zadder,ax\r
573 ;---set 3d rotate YZ\r
574         mov     bx,OFFSET udwave\r
575         mov     ax,ds:wave1\r
576         call    addwcos\r
577         imul    ds:udforce\r
578         shrd    ax,dx,8\r
579         mov     di,OFFSET r00\r
580         call    set3drot\r
581 ;---set 3d rotate XZ\r
582         mov     bx,OFFSET lrwave\r
583         mov     ax,200\r
584         call    addwcos\r
585         sar     ax,1\r
586         mov     di,OFFSET p00\r
587         call    set3drot\r
588 ;---add more text to 3d scroller\r
589         sub     ds:textcnt,SCROLLSPEED\r
590         jnc     @@t1\r
591         mov     ds:textcnt,LETTERDOTSPACING*8-1\r
592         mov     si,ds:text\r
593         mov     bl,ds:[si]\r
594         IFDEF XORTEXTS\r
595         xor     bl,17h\r
596         ENDIF\r
597         and     bx,255\r
598         jz      @@t3\r
599         inc     si\r
600         mov     ds:text,si\r
601         cmp     bl,32\r
602         jge     @@t4\r
603         shl     bx,SCROLLDELAYSHL\r
604         mov     ds:textcnt,bx\r
605         jmp     @@t1\r
606 @@t4:   mov     bp,0\r
607         mov     si,4100\r
608         call    letter3d\r
609         jmp     @@t1\r
610 @@t3:   mov     si,OFFSET text0\r
611         mov     ds:text,si\r
612 @@t1:   ;;;\r
613 ;======adlib music\r
614         jmp     a_dorow\r
615 doit70  ENDP\r
616 \r
617 ;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Main routine ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ\r
618 ;stack @ cs:0fffeh\r
619 \r
620 main    PROC NEAR\r
621 ;ÍÍÍÍÍÍÍÍÍ Zero Zerodata & Init Segs ÍÍÍÍÍÍÍ\r
622 .8086   ;;;\r
623         push    cs\r
624         push    cs\r
625         pop     ds\r
626         pop     es\r
627         mov     cx,(zeroend-zerobeg)/2\r
628         mov     di,OFFSET zerobeg\r
629         xor     ax,ax ;zero used later\r
630         rep     stosw\r
631         mov     dx,0a000h\r
632         mov     es,dx\r
633 ;segments now set: DS=code/data ES=vram\r
634 ;ÍÍÍÍÍÍÍÍÍ Check for 386 ÍÍÍÍÍÍÍÍÍ\r
635         push    sp\r
636         pop     dx\r
637         cmp     dx,sp\r
638         jz      @@o1\r
639 @@o2:   jmp     endansi ;80(1)86\r
640 .286p   ;;;\r
641 @@o1:   mov     bx,OFFSET rows\r
642         sgdt    ds:[bx]\r
643         cmp     byte ptr ds:[bx+5],0\r
644         js      @@o2\r
645 ;ÍÍÍÍÍÍÍÍÍ Check for VGA ÍÍÍÍÍÍÍÍÍ\r
646 .386p   ;;;\r
647         mov     fs,ax ;ax was zero\r
648 ;segments now set: DS=code/data ES=vram FS=zeropage\r
649         mov     ax,1a00h\r
650         int     10h\r
651         cmp     al,01ah\r
652         jne     endansi ;no vga\r
653         cmp     bl,7\r
654         jb      endansi ;no vga\r
655 ;ÍÍÍÍÍÍÍÍÍ Initialize - doinit 0 ÍÍÍÍÍÍÍÍÍ\r
656         ;copy vga font to font buffer\r
657         mov     ax,13h\r
658         int     10h\r
659         mov     cx,'Z'-'A'+1\r
660         mov     bx,16\r
661         mov     ax,'A'+0eh*256\r
662 @@a1:   int     10h\r
663         inc     al\r
664         loop    @@a1\r
665         mov     cx,8*320/2\r
666         mov     bx,OFFSET font\r
667         xor     di,di\r
668 @@a2:   mov     ax,es:[di]\r
669         mov     ds:[di+bx],ax\r
670         add     di,2\r
671         loop    @@a2\r
672 ;ÍÍÍÍÍÍÍÍÍ Initialize - vga ÍÍÍÍÍÍÍÍÍ\r
673         ;init videomode 320x200x16\r
674         mov     ax,0dh\r
675         int     10h\r
676         ;set up rows/cols/etc\r
677         mov     si,-2\r
678         mov     di,OFFSET vbuf-44\r
679         mov     bl,128\r
680         xor     bp,bp\r
681         jmp     @@b5\r
682 @@b1:   mov     ds:rows[si],di\r
683         mov     ds:colb[si],bl\r
684         mov     ds:colbww[si],cx\r
685         shr     cl,1\r
686         rcr     ch,1\r
687         mov     ds:colbw[si],dx\r
688         shr     dl,1\r
689         rcr     dh,1\r
690         mov     ds:colbv[si],ax\r
691         shr     al,1\r
692         rcr     ah,1\r
693         mov     ds:cols[si],bp\r
694         ror     bl,1\r
695         jnc     @@b4\r
696         inc     bp\r
697 @@b5:   mov     cx,0000000011111110b\r
698         mov     dx,0000000001111100b\r
699         mov     ax,0000000000111000b\r
700 @@b4:   add     di,44\r
701         add     si,2\r
702         cmp     si,(320)*2\r
703         jle     @@b1\r
704         ;set simplex palette order (16 color mode)\r
705         mov     dx,3dah\r
706         in      al,dx\r
707         mov     dl,0c0h\r
708         xor     ax,ax\r
709         mov     cx,16\r
710 @@b2:   out     dx,al\r
711         out     dx,al\r
712         inc     al\r
713         loop    @@b2\r
714         mov     al,20h\r
715         out     dx,al\r
716 ;ÍÍÍÍÍÍÍÍÍ Initialize - doinit ÍÍÍÍÍÍÍÍÍ\r
717         mov     cx,DOTNUM\r
718         mov     bx,OFFSET dots-2\r
719 @@c1:   push    cx\r
720         call    rand\r
721         call    rand\r
722         call    rand\r
723         sar     ax,2\r
724         mov     ds:[bx],ax\r
725         add     bx,2\r
726         mov     word ptr ds:[bx],OFFSET pset1\r
727         pop     cx\r
728         loop    @@c1\r
729 ;ÍÍÍÍÍÍÍÍÍ Initialize - others ÍÍÍÍÍÍÍÍÍ\r
730         call    a_init\r
731         call    inittimer\r
732 ;ÍÍÍÍÍÍÍÍÍ Do the intro stuff ÍÍÍÍÍÍÍÍÍ\r
733 again:  call    doit\r
734         mov     ah,1\r
735         int     16h\r
736         jz      again\r
737         mov     ah,0\r
738         int     16h\r
739 ;ÍÍÍÍÍÍÍÍÍ DeInitialize ÍÍÍÍÍÍÍÍÍ\r
740         call    deinittimer\r
741         call    a_init ;reinitializing adlib shuts it up\r
742 ;ÍÍÍÍÍÍÍÍÍ Display end ansi (only thing done if no 386 or vga) ÍÍÍÍÍÍÍÍÍ\r
743 endansi:mov     ax,3h\r
744         int     10h\r
745         mov     si,OFFSET endtext\r
746         push    0b800h  ;if the user has an MGA or HGC\r
747         pop     es      ;it's not my problem :-)\r
748         xor     di,di\r
749         mov     ah,0eh\r
750 @@1:    lodsb\r
751         IFDEF XORTEXTS\r
752         xor     al,17h\r
753         ENDIF\r
754         cmp     al,31\r
755         jae     @@2\r
756         mov     ah,al\r
757         jmp     @@1\r
758 @@2:    jz      @@3\r
759         stosw\r
760         jmp     @@1\r
761 @@3:    mov     ax,4c00h\r
762         int     21h\r
763 main    ENDP\r
764         \r
765 ;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Initialized (nonzero) data ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ\r
766 \r
767 ;pointer & delay counter for scrolltext\r
768 text    dw      OFFSET text0\r
769 textcnt dw      1\r
770 \r
771 ;3d rotation values (more in zerodata)\r
772 udforced LABEL DWORD\r
773         dw      0\r
774 udforce dw      64\r
775 lrwave  dw      -20000\r
776 zwave   dw      16000\r
777 \r
778 sintable LABEL BYTE ;sine table (circle is 64 units)\r
779 db 0,12,24,36,48,59,70,80,89,98,105,112,117,121,124,126,127,126\r
780 db 124,121,117,112,105,98,89,80,70,59,48,36,24,12,0,-12,-24,-36\r
781 db -48,-59,-70,-80,-89,-98,-105,-112,-117,-121,-124,-126,-127\r
782 db -126,-124,-121,-117,-112,-105,-98,-89,-80,-70,-59,-48,-36\r
783 db -24,-12,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54\r
784 db 57,59,62,65,67,70\r
785 \r
786 ;adlib player data\r
787 a_inst_table LABEL BYTE\r
788         db 20h+0,20h+1,20h+2,20h+8,20h+9,20h+10,20h+16,20h+17,20h+18\r
789 NTB equ 8192 ;+1024*1\r
790 a_note_table LABEL WORD\r
791         dw NTB+363,NTB+385,NTB+408,NTB+432,NTB+458,NTB+485\r
792         dw NTB+514,NTB+544,NTB+577,NTB+611,NTB+647,NTB+868\r
793         ;note: a zero word is expected after this table (found in col0)\r
794         \r
795 col0    db       0, 0, 0 ,0     ;background color\r
796 col1    db       0,15,35 ,0     ;delay color 3\r
797 col2    db      16,30,48 ,0     ;delay color 2\r
798 col3    db      32,45,55 ,0     ;delay color 1\r
799 col4    db      60,61,62        ;brightest color\r
800         ;1      . x . x . x . x . x . x . x . x\r
801         ;2      . . x x . . x x . . x x . . x x\r
802         ;4      . . . . x x x x . . . . x x x x\r
803         ;8      . . . . . . . . x x x x x x x x\r
804 ;palette indices for 4 palettes. Last number is bitplane to write\r
805 ;during the frame having this palette\r
806 index1  db      04h,34h,24h,34h,14h,34h,24h,34h ,1 ;1248\r
807 index2  db      03h,23h,13h,23h,44h,44h,44h,44h ,8 ;8124\r
808 index3  db      02h,12h,44h,44h,33h,33h,44h,44h ,4 ;4812\r
809 index4  db      01h,44h,33h,44h,22h,44h,33h,44h ,2 ;2481\r
810 index   dw      OFFSET index1 ;offset to current index\r
811 \r
812 ;################## Music - (tune by skaven/fc) ###################\r
813 ;generated with ST3->SIMPLEXADLIB, handoptimized by psi (283 bytes)\r
814 music_channels equ 8\r
815 music_speed equ 8\r
816 music_instruments LABEL BYTE\r
817 dw OFFSET ains6\r
818 dw OFFSET ains2\r
819 dw OFFSET ains4\r
820 dw OFFSET ains3\r
821 dw OFFSET ains3\r
822 dw OFFSET ains1\r
823 dw OFFSET ains1\r
824 dw OFFSET ains4\r
825 ains1 LABEL BYTE\r
826 db 65,194,6,0,35,242,240,240,1,0,4\r
827 ains2 LABEL BYTE\r
828 db 145,64,135,128,243,111,35,3,1,1,2\r
829 ains3 LABEL BYTE\r
830 db 225,33,17,128,17,19,34,34,0,0,12\r
831 ains4 LABEL BYTE\r
832 db 97,33,27,0,98,132,86,85,0,0,14\r
833 ains6 LABEL BYTE\r
834 db 145,64,135,136,243,111,35,3,1,1,2\r
835 music_patterns LABEL BYTE\r
836 ach0 dw OFFSET ach0d,OFFSET ach0dr\r
837 ach1 dw OFFSET ach1d,OFFSET ach1dr\r
838 ach2 dw OFFSET ach2d,OFFSET ach2dr\r
839 ach3 dw OFFSET ach3d,OFFSET ach3d\r
840 ach4 dw OFFSET ach4d,OFFSET ach4d\r
841 ach5 dw OFFSET ach5d,OFFSET ach5d\r
842 ach6 dw OFFSET ach6d,OFFSET ach6d\r
843 ach7 dw OFFSET ach7d,OFFSET ach7d\r
844 ach0d LABEL BYTE\r
845 db 081h\r
846 ach0dr LABEL BYTE\r
847 db 057h,050h,050h,055h,057h,050h,055h,057h\r
848 db 050h,055h,057h,050h,055h,057h,050h,055h\r
849 db 0\r
850 ach1d LABEL BYTE\r
851 db 081h\r
852 ach1dr LABEL BYTE\r
853 db 050h,055h,057h,050h,055h,057h,050h,055h\r
854 db 057h,050h,055h,057h,050h,055h,057h,050h\r
855 db 0\r
856 ach2d LABEL BYTE\r
857 db 0C0h,050h,084h\r
858 db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah\r
859 db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah\r
860 ach2dr LABEL BYTE\r
861 db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah\r
862 db 025h,015h,025h,015h,028h,018h,02Ah,01Ah\r
863 db 0\r
864 ach3d LABEL BYTE\r
865 db 0A0h,050h,040h,0C0h,040h,088h,040h,040h\r
866 db 03Ah,042h,090h,045h,088h,040h,042h,040h\r
867 db 047h,090h,04Ah,088h,045h,098h,040h\r
868 db 0\r
869 ach4d LABEL BYTE\r
870 db 0A0h,050h,030h,0C0h,047h,088h,047h,043h\r
871 db 042h,045h,047h,045h,048h,047h,047h,050h\r
872 db 052h,084h,050h,04Ah,088h,050h,098h,045h\r
873 db 0\r
874 ach5d LABEL BYTE\r
875 db 0C0h,020h,0A0h,010h,010h,090h,010h,02Ah\r
876 db 025h,088h,028h,02Ah,090h,010h,02Ah,025h\r
877 db 088h,028h,02Ah\r
878 db 0\r
879 ach6d LABEL BYTE\r
880 db 0C0h,020h,0A0h,020h,020h,090h,020h,01Ah\r
881 db 015h,088h,018h,01Ah,090h,020h,01Ah,015h\r
882 db 088h,018h,01Ah\r
883 db 0\r
884 ach7d LABEL BYTE\r
885 db 0C0h,00Ch,0FEh,050h,090h,00Ch,081h,04Ah\r
886 db 050h,084h,052h,055h,086h,04Ah,081h,050h\r
887 db 04Ah,086h,050h,082h,055h,098h,045h\r
888 db 0\r
889 ;#########################################################\r
890 \r
891 SCROLLSPEED equ 90\r
892 SCROLLDELAYSHL equ 9\r
893 LETTERDOTSPACING equ 128\r
894 \r
895 db 0fch\r
896 \r
897 text0   LABEL BYTE ;scrolltext (numbers are delays)\r
898         db      31,25,'CALL STARPORT',9,'FUTURE CREW WORLD HQ',9,'CDN',9,'GRAVIS EURO',9,'AND MORE',0\r
899 \r
900 endtext LABEL BYTE ;endansi... well... endansiline (numbers are colors)\r
901         db      15\r
902         db      'StarPort'\r
903         db      3,' ÄÄ ',11\r
904         db      'V32bis +358-0-8044626'\r
905         db      ' +358-0-8041133'\r
906         db      3,' ÄÄ ',15\r
907         db      'FC-WHQ'\r
908         db      31\r
909 endtext1 LABEL BYTE\r
910 \r
911 db 0fch\r
912 \r
913 ;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Uninitialized (zero) data ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ\r
914 \r
915 zerobeg LABEL WORD ;start zero clear from here\r
916 \r
917 rows    dw      320 dup(0)      ;offsets to screen rows\r
918 cols    dw      320 dup(0)      ;offsets to screen cols\r
919 colb    db      320 dup(0,0)    ;bitmasks for screen cols\r
920 colbv   dw      320 dup(0)      ;wide -"-\r
921 colbw   dw      320 dup(0)      ;wider -"-\r
922 colbww  dw      320 dup(0)      ;very wide -"-\r
923 \r
924 ALIGN 4\r
925         db      44*8 dup(0) ;negative overflow for videobuffer\r
926 vbuf    LABEL BYTE\r
927         db      44*200 dup(0) ;video buffer\r
928         db      44*8 dup(0) ;positive overflow for videobuffer\r
929 \r
930 ALIGN 4\r
931 font    LABEL BYTE\r
932         db      8 dup(320 dup(0)) ;font buffer\r
933 \r
934 \r
935 DOTNUM1 equ     256     ;number of dots used for text\r
936 DOTNUM  equ     444     ;total number of dots\r
937 ALIGN 4\r
938 dots    LABEL WORD\r
939         dw      DOTNUM dup(0,0,0,0) ;x,y,z,routine data for each dot\r
940         \r
941 ;2x2 rotation matrices\r
942 r00     dw      0\r
943 r10     dw      0\r
944 r01     dw      0\r
945 r11     dw      0\r
946 p00     dw      0\r
947 p10     dw      0\r
948 p01     dw      0\r
949 p11     dw      0\r
950 \r
951 ;zero initialized 3d rotation stuff\r
952 zadder  dw      0\r
953 wave1   dw      0\r
954 udwave  dw      0\r
955 wwave   dw      0\r
956 sinus1  dw      0\r
957 sinus2  dw      0\r
958 \r
959 ;adlib data\r
960 a_musiccnt dw   0\r
961 a_chdelaycnt db 9 dup(0)\r
962 a_chdelay db    9 dup(0)\r
963 ALIGN 2\r
964 \r
965 ;misc\r
966 nextdot dw      0\r
967 scrollsubber dw 0\r
968 framecounter dw 0\r
969 oldint8 dd      0\r
970 seed    dd      0\r
971 \r
972 padder  db      16 dup(0)\r
973 zeroend LABEL WORD ;end zero clear here\r
974 \r
975 code    ENDS\r
976         END start\r