home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / fcsp2src.zip / SP2.ASM < prev    next >
Assembly Source File  |  1993-11-26  |  21KB  |  977 lines

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