1 ;--------------------------------------------------------------------
\r
2 ; StarPort Intro II V1.0
\r
3 ;--------------------------------------------------------------------
\r
4 ; Copyright (C) 1993 Future Crew
\r
5 ;--------------------------------------------------------------------
\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
44 BORDERS=0 ;set to 1 for visible border-timings
\r
46 code SEGMENT para public 'CODE'
\r
52 start: cld ;filler to make the filesize exactly 1993 bytes
\r
53 cld ;filler to make the filesize exactly 1993 bytes
\r
56 ;±±±±±±±±±±±±±±±± setborder ±±±±±±±±±±±±±±±±
\r
57 ;descr: debug/change border color
\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
79 ;±±±±±±±±±±±±±±±± output data to adlib ±±±±±±±±±±±±±±
\r
80 a_lodsboutaw03: ;size optimization related entry (instrument loading)
\r
83 a_lodsboutaw: ;size optimization related entry (instrument loading)
\r
85 a_outaw PROC NEAR ;ah=reg,al=data
\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
111 @@1: call a_lodsboutaw03
\r
115 call a_lodsboutaw03
\r
119 a_loadinstrument ENDP
\r
121 ;±±±±±±±±±±±±±±±± set note on/off ±±±±±±±±±±±±±±
\r
122 a_playnote PROC NEAR
\r
123 ;bx=channel, ax=data
\r
134 ;±±±±±±±±±±±±±±±± initialize/clear/shutup adlib ±±±±±±±±±±±±±±
\r
144 mov di,OFFSET music_instruments
\r
145 @@1: mov si,ds:[di]
\r
147 call a_loadinstrument
\r
156 ;±±±±±±±±±±±±±±±± advance music one row ±±±±±±±±±±±±±±
\r
158 sub ds:a_musiccnt,1
\r
160 mov ds:a_musiccnt,music_speed
\r
161 mov cx,music_channels
\r
162 mov di,OFFSET music_patterns
\r
164 @@1: sub ds:a_chdelaycnt[bx],1
\r
174 mov ds:a_chdelay[bx],al
\r
180 mov ax,ds:a_note_table[bp]
\r
185 mov al,ds:a_chdelay[bx]
\r
186 mov ds:a_chdelaycnt[bx],al
\r
192 @@7: mov si,ds:[di+2]
\r
196 ;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Intro Routines ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
\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
210 mov ah,ds:sintable[bx]
\r
215 mov ah,ds:sintable[bx+1]
\r
227 ;±±±±±±±±±±±±±±±± rand ±±±±±±±±±±±±±±±±
\r
228 ;returns a random value in range -4096..4095
\r
237 ;size optimizatin, some code moved from after all rand calls
\r
243 ;±±±±±±±±±±±±±±±± timer ±±±±±±±±±±±±±±±±
\r
244 inittimer PROC NEAR
\r
249 mov ax,OFFSET intti8
\r
267 intti8 PROC FAR ;timer interrupt
\r
271 inc cs:framecounter
\r
276 ;±±±±±±±±±±±±±±±± load indexed palette ±±±±±±±±±±±±±±
\r
278 ;ds:si=pointer to colorindices
\r
294 setpl2: and bx,15*2
\r
295 mov ax,word ptr ds:col0[bx]
\r
299 mov al,ds:col0[bx+2]
\r
304 ;±±±±±±±±±±±±±± clear & copy videobuffer to screen ±±±±±±±±±±±±±±
\r
305 clearcopy PROC NEAR
\r
328 ;±±±±±±±±±±±±±± draw a small pixel ±±±±±±±±±±±±±±
\r
329 pset1 PROC NEAR ;ds:di=destination center, si=xmask offset
\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
340 cmp bp,8300 ;zcompare for size
\r
343 mov ax,ds:colbw[si]
\r
346 mov ax,ds:colbv[si]
\r
353 mov ax,ds:colbw[si]
\r
359 ;±±±±±±±±±±±±±± add a letter composed of big dots to dotlist ±±±±±±±±±±±±±
\r
372 @@2: cmp ds:font[bx],0
\r
375 mov ds:dots[di+2],bp
\r
381 mov al,ds:sintable[si]
\r
385 mov ds:dots[di+4],ax
\r
387 mov word ptr ds:dots[di+6],OFFSET pset2
\r
391 add si,LETTERDOTSPACING
\r
395 add bp,LETTERDOTSPACING
\r
402 ;±±±±±±±±±±±±±± calc 2x2 rotation matrix ±±±±±±±±±±±±±
\r
404 ;ax=angle,ds:di=pointer to matrix
\r
407 mov ds:[di+r01-r00],ax
\r
409 mov ds:[di+r10-r00],ax
\r
412 mov ds:[di+r00-r00],ax
\r
413 mov ds:[di+r11-r00],ax
\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
423 imul word ptr ds:[si]
\r
427 imul word ptr ds:[si+2]
\r
436 ;±±±±±±±±±±±±±± advance demo one frame (raw work) ±±±±±±±±±±±±±
\r
438 ;======wait for border
\r
454 cmp si,OFFSET index4
\r
456 mov si,OFFSET index1
\r
457 @@i2: mov ds:index,si
\r
463 ;======do timer simulation stuff
\r
466 mov ds:scrollsubber,0
\r
467 xchg cx,ds:framecounter
\r
470 add ds:scrollsubber,SCROLLSPEED
\r
483 cmp word ptr ds:[bx+6],OFFSET pset2
\r
491 mov al,ds:sintable[si]
\r
496 sub cx,ds:scrollsubber
\r
502 @@5: ;--rotate coordinates
\r
537 ;calc dest address & xmask offset
\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
556 ;---add sinuses & udforce
\r
559 add ds:udforced,3000
\r
561 mov bx,OFFSET wwave
\r
567 mov bx,OFFSET zwave
\r
573 ;---set 3d rotate YZ
\r
574 mov bx,OFFSET udwave
\r
581 ;---set 3d rotate XZ
\r
582 mov bx,OFFSET lrwave
\r
588 ;---add more text to 3d scroller
\r
589 sub ds:textcnt,SCROLLSPEED
\r
591 mov ds:textcnt,LETTERDOTSPACING*8-1
\r
603 shl bx,SCROLLDELAYSHL
\r
610 @@t3: mov si,OFFSET text0
\r
617 ;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Main routine ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
\r
621 ;ÍÍÍÍÍÍÍÍÍ Zero Zerodata & Init Segs ÍÍÍÍÍÍÍ
\r
627 mov cx,(zeroend-zerobeg)/2
\r
628 mov di,OFFSET zerobeg
\r
629 xor ax,ax ;zero used later
\r
633 ;segments now set: DS=code/data ES=vram
\r
634 ;ÍÍÍÍÍÍÍÍÍ Check for 386 ÍÍÍÍÍÍÍÍÍ
\r
639 @@o2: jmp endansi ;80(1)86
\r
641 @@o1: mov bx,OFFSET rows
\r
643 cmp byte ptr ds:[bx+5],0
\r
645 ;ÍÍÍÍÍÍÍÍÍ Check for VGA ÍÍÍÍÍÍÍÍÍ
\r
647 mov fs,ax ;ax was zero
\r
648 ;segments now set: DS=code/data ES=vram FS=zeropage
\r
652 jne endansi ;no vga
\r
655 ;ÍÍÍÍÍÍÍÍÍ Initialize - doinit 0 ÍÍÍÍÍÍÍÍÍ
\r
656 ;copy vga font to font buffer
\r
668 @@a2: mov ax,es:[di]
\r
672 ;ÍÍÍÍÍÍÍÍÍ Initialize - vga ÍÍÍÍÍÍÍÍÍ
\r
673 ;init videomode 320x200x16
\r
676 ;set up rows/cols/etc
\r
678 mov di,OFFSET vbuf-44
\r
682 @@b1: mov ds:rows[si],di
\r
684 mov ds:colbww[si],cx
\r
687 mov ds:colbw[si],dx
\r
690 mov ds:colbv[si],ax
\r
697 @@b5: mov cx,0000000011111110b
\r
698 mov dx,0000000001111100b
\r
699 mov ax,0000000000111000b
\r
704 ;set simplex palette order (16 color mode)
\r
716 ;ÍÍÍÍÍÍÍÍÍ Initialize - doinit ÍÍÍÍÍÍÍÍÍ
\r
718 mov bx,OFFSET dots-2
\r
726 mov word ptr ds:[bx],OFFSET pset1
\r
729 ;ÍÍÍÍÍÍÍÍÍ Initialize - others ÍÍÍÍÍÍÍÍÍ
\r
732 ;ÍÍÍÍÍÍÍÍÍ Do the intro stuff ÍÍÍÍÍÍÍÍÍ
\r
739 ;ÍÍÍÍÍÍÍÍÍ DeInitialize ÍÍÍÍÍÍÍÍÍ
\r
741 call a_init ;reinitializing adlib shuts it up
\r
742 ;ÍÍÍÍÍÍÍÍÍ Display end ansi (only thing done if no 386 or vga) ÍÍÍÍÍÍÍÍÍ
\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
765 ;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Initialized (nonzero) data ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
\r
767 ;pointer & delay counter for scrolltext
\r
768 text dw OFFSET text0
\r
771 ;3d rotation values (more in zerodata)
\r
772 udforced LABEL DWORD
\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
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
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
812 ;################## Music - (tune by skaven/fc) ###################
\r
813 ;generated with ST3->SIMPLEXADLIB, handoptimized by psi (283 bytes)
\r
814 music_channels equ 8
\r
816 music_instruments LABEL BYTE
\r
826 db 65,194,6,0,35,242,240,240,1,0,4
\r
828 db 145,64,135,128,243,111,35,3,1,1,2
\r
830 db 225,33,17,128,17,19,34,34,0,0,12
\r
832 db 97,33,27,0,98,132,86,85,0,0,14
\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
847 db 057h,050h,050h,055h,057h,050h,055h,057h
\r
848 db 050h,055h,057h,050h,055h,057h,050h,055h
\r
853 db 050h,055h,057h,050h,055h,057h,050h,055h
\r
854 db 057h,050h,055h,057h,050h,055h,057h,050h
\r
858 db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah
\r
859 db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah
\r
861 db 030h,020h,030h,020h,02Ah,01Ah,02Ah,01Ah
\r
862 db 025h,015h,025h,015h,028h,018h,02Ah,01Ah
\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
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
875 db 0C0h,020h,0A0h,010h,010h,090h,010h,02Ah
\r
876 db 025h,088h,028h,02Ah,090h,010h,02Ah,025h
\r
880 db 0C0h,020h,0A0h,020h,020h,090h,020h,01Ah
\r
881 db 015h,088h,018h,01Ah,090h,020h,01Ah,015h
\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
889 ;#########################################################
\r
892 SCROLLDELAYSHL equ 9
\r
893 LETTERDOTSPACING equ 128
\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
900 endtext LABEL BYTE ;endansi... well... endansiline (numbers are colors)
\r
904 db 'V32bis +358-0-8044626'
\r
905 db ' +358-0-8041133'
\r
909 endtext1 LABEL BYTE
\r
913 ;ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ Uninitialized (zero) data ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
\r
915 zerobeg LABEL WORD ;start zero clear from here
\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
925 db 44*8 dup(0) ;negative overflow for videobuffer
\r
927 db 44*200 dup(0) ;video buffer
\r
928 db 44*8 dup(0) ;positive overflow for videobuffer
\r
932 db 8 dup(320 dup(0)) ;font buffer
\r
935 DOTNUM1 equ 256 ;number of dots used for text
\r
936 DOTNUM equ 444 ;total number of dots
\r
939 dw DOTNUM dup(0,0,0,0) ;x,y,z,routine data for each dot
\r
941 ;2x2 rotation matrices
\r
951 ;zero initialized 3d rotation stuff
\r
961 a_chdelaycnt db 9 dup(0)
\r
962 a_chdelay db 9 dup(0)
\r
972 padder db 16 dup(0)
\r
973 zeroend LABEL WORD ;end zero clear here
\r