home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PCGPEV10.ZIP / STARS.TXT < prev    next >
Text File  |  1994-05-10  |  24KB  |  711 lines

  1. ----------------------------- VLA.NFO -----------------------------------
  2.         ╓────────── (% VLA Presents Intro To Starfields %) ──────────╖
  3.         ║                                                            ║
  4.         ╙────────────────── Written ßy : Draeden ────────────────────╜
  5.  
  6. ───────────────────────────  VLA Members Are  ────────────────────────────────
  7.  
  8.  
  9.                         (⌐ Draeden - Main Coder ¬)
  10.                   (⌐ Lithium - Coder/Ideas/Ray Tracing ¬)
  11.                    (⌐ The Kabal - Coder/Ideas/Artwork ¬)
  12.                       (⌐ Desolation - Artwork/Ideas ¬)
  13.  
  14. ────────────────────────── The Finn - Mods/Sounds ──────────────────────────────
  15.  
  16.  
  17.    ╓─────────────────── Contact Us On These Boards: ──────────────────────╖
  18.    ║                                                                      ║
  19.    │   % Phantasm BBS .................................. (206) 232-5912   │
  20.    │   * The Deep ...................................... (305) 888-7724   │
  21.    │   * Dark Tanget Systems ........................... (206) 722-7357   │
  22.    │   * Metro Holografix .............................. (619) 277-9016   │
  23.    │                                                                      │
  24.    ║       % - World Head Quarters      * - Distribution Site             ║
  25.    ╙──────────────────────────────────────────────────────────────────────╜
  26.  
  27.      Or Via Internet Mail For The Group : tkabal@carson.u.washington.edu
  28.  
  29.                       Or to reach the other members :
  30.  
  31.                        - draeden@u.washington.edu -
  32.  
  33.                        - lithium@u.washington.edu -
  34.  
  35.                      - desolation@u.washington.edu -
  36.  
  37.  
  38.  
  39. ┌───────────┬────────────────────────────────────────────────────────────────
  40. │ STARS.TXT │
  41. └───────────┘
  42.  
  43.  
  44. ────────────────────────────────────────────────────────────────────────────
  45. ;
  46. ;     TITLE: Star field
  47. ;WRITTEN BY: DRAEDEN
  48. ;      DATE: 03/15/93
  49. ;
  50. ;     NOTES:
  51. ;
  52. ;ASSOCIATED FILES:
  53. ;
  54. ;       STARGEN.BAS =>  Basic program that generates a set of 'randomized'
  55. ;                       numbers.  Creates STARRND.DW
  56. ;
  57. ;       STARS.ASM   =>  The asm file.
  58. ;
  59. ;       STARRND.DW  =>  File that contains a set of shuffled numbers order.
  60. ;                       Used to create 'random' star field.
  61. ;
  62. ────────────────────────────────────────────────────────────────────────────
  63.  
  64.     A star field is just a series of 3d point plotted onto a 2d plane (your
  65. screen).  The movement effect is achieved by simply decreasing the Z
  66. cordinate and redisplaying the results.  The formula for the 3d to 2d
  67. conversion is:
  68.  
  69. ────────────────
  70.     ScreenX = ScreenDist * Xpos / Zpos
  71.     ScreenY = ScreenDist * Ypos / Zpos
  72. ──────────────── 
  73.  
  74.     This should make perfect sense.  As the object gets futher away, (X,Y)
  75. cordinates converge to (0,0).  The screen dist is how far away the 'eye' is
  76. from the screen, or, as I like to think of it, the window.  Naturally, as you
  77. get closer to the window, your field of view is greatly enhanced (you can see
  78. more).  But, because we can't make the monitor bigger, we have to shrink the
  79. data that is being displayed.  And when we have a large screen distance, we
  80. should see less of the virtual world, and the objects should appear bigger.
  81. When this formula is translated into assembler, you would immediatly decide
  82. that 256 is the best screen distance.  Why?  Multiplying by 256 on the 386 is
  83. as simple as this:
  84.  
  85. ──────────────── 
  86. ;we want to multiply ax by 256 and put it into dx:ax to set up for division
  87.  
  88.     movsx   dx,ah   ;3 cycles
  89.     shl     ax,8    ;3 cycles -- total 6
  90.  
  91. ;or we could do it the 'normal way'...
  92.  
  93.     mov     dx,256  ;2 cycles, but we can have any screen distance
  94.     imul    dx      ;9-22 cycles on a 386, 13-26 on a 486
  95.                     ;a total of 11-28 cycles!
  96. ──────────────── 
  97.  
  98.     If you'll take note, the 6 cycle trick is AT LEAST 5 cycles faster than
  99. the imul.  Anyway... I bet you really don't care about a few cycles at this
  100. point, so I won't spend much more time on it... 
  101.     So, as you can see, the math part of it is easy..  the hard part is the
  102. what's left.  You need a routine that creates a star, presumably random, and
  103. another routine that displays all the stars and advances them.  Well, that's
  104. how I broke it into subroutines...
  105.  
  106.     For the routine that creates the star you need it to:
  107.  
  108.     1)  See if we already have enough stars going (is NUMSTARS > MAXSTARS ?)
  109.     2)  If there's room, scan for the first open slot... 
  110.     3)  Now that we've found where to put it, create a star by getting a set
  111.         of random numbers for the (X,Y) and setting the Z to the maximum.
  112.         Also select a color for the star.
  113.  
  114.     The display routine would need to:
  115.  
  116.     1)  Erase the old star.
  117.     2)  Calculate the screen X & Y positions for the new position.  Are they 
  118.         inside the screen boundries?  If not, 'kill' the star, otherwise 
  119.         display it.  The shade of the color to use must be calculated by 
  120.         using the Z cordinate. Color = BaseColor + Zpos / 256
  121.     3)  Decrease the Zpos.
  122.  
  123.     And the main routine would:
  124.  
  125.     1)  Call MakeStars
  126.     2)  Wait for verticle retrace
  127.     3)  Call DisplayStars
  128.     4)  Check for keypress, if there is one, handle it, if its not one we're
  129.         looking for then exit program.
  130.     5)  Loop to step 1
  131.  
  132.     To impliment this, we need to create an array of records which has enough
  133. room for MAXSTARS.  The record would contain the (X,Y,Z) cordinates, the
  134. OldDi and the base color for the star.  To create a star, it first checks to
  135. see if there is room.  If there is, then we scan through the array
  136. looking%wor an open slot.  If we don't find an empty space, then we don't
  137. create a star.  We create the star by grabbing a pair of (X,Y) cordinates
  138. from the list of 'random' numbers and set the Z to MAXZPOS.  Then, increase
  139. NUMSTARS and return.
  140.  
  141.     In displaying the star, we would like to only have to calculate DI once.
  142. So we save off a copy of DI in an array after we calculate it for the drawing
  143. so that erasing the dot is really quick.  Next we calculate the new DI for
  144. the dot.  This is done by using the formula mentioned above and this one: 
  145.  
  146. ──────────────── 
  147.  
  148.     DI = ScreenY * ScreenWidth + ScreenX
  149.  
  150. ──────────────── 
  151.  
  152.     When doing the math, care must be taken to make sure that:
  153.  
  154.         a) the Zpos is not zero and X*256/ZPOS is not greater than 32767.
  155.             will cause a DIVIDE BY ZERO or a DIVIDE OVERFLOW
  156.  
  157.         b) SY and SX do not go outside the border of the screen.
  158.  
  159.     If either of these conditions are broken, the star must be terminated and
  160. calculations for that star must be aborted.  Actually, Zpos = 0 is used to
  161. signify a nonactive star.  To terminate the star, you'd simply change its
  162. zpos to 0 and decrease NUMSTARS.
  163.  
  164.     To create the different shades, I used:
  165.  
  166. ────────────────
  167.  
  168.   Color = BaseColor + Zpos/256
  169.  
  170. ────────────────
  171.  
  172.     I used 256 as the number to divide by because that enables me to do no
  173. dividing at all- I just use AH, because AH = AX / 256 (AH is the upper 8 bits
  174. of AX). This relation suggests that the MAXZPOS shoul be 16*256 for 16
  175. shades.  So, the MAXZPOS = 4096.  The palette will have to be set up so that
  176. the shades go from light to black (lower # is lighter).  Simple enough. (I
  177. hope.)
  178.  
  179. ──────────────────────────────── 
  180.         RANDOM NUMBERS
  181. ──────────────────────────────── 
  182.  
  183.     Well, not truly random numbers, but random enough for a starfield.
  184.  
  185.     The problem:
  186.         There is no way on a PC to create truly random numbers with 
  187.         great speed.
  188.  
  189.     Solution:
  190.         Don't use truly random numbers.  Use a chart of non-repeating,
  191.         shuffled numbers that fall within your desired range.  That way
  192.         the stars will be evenly spread out and the creation of a new star
  193.         is incredably fast. ( A few MOV instructions) All you have to is grab
  194.         the number and increase the NEXTRANDOM pointer.  I chose to fill in
  195.         the array half with positive numbers, half with negative with a
  196.         minimum distance of 10 from 0.  I did this so that no stars will
  197.         'hit' the screen and just vanish.  That doesn't look too good.
  198.  
  199.     Here's the BASIC file that made my numbers for me...
  200.  
  201. ──────────────── 
  202.  
  203.  
  204.     NumStars = 400
  205.     dim     RndArray(NumStars)
  206.     randomize (timer)
  207.  
  208.     'fill the array with numbers from -Numstars/2 to -10
  209.     'and from 10 to Numstars/2
  210.  
  211.     i=10
  212.     for r = 0 to NumStars/2
  213.         RndArray(r)=i
  214.         i=i+1
  215.     next
  216.  
  217.     i=-10
  218.     for r = NumStars/2 to NumStars
  219.         RndArray(r)=i
  220.         i=i-1
  221.     next
  222.  
  223.     'randomly shuffle them..
  224.  
  225.     print "Total numbers: ";NumStars
  226.     print "Shuffling - Please wait... "
  227.  
  228.     for q = 1 to numstars/5
  229.         for r = 0 to NumStars
  230.             swnum1 = int(rnd*NumStars+.5)
  231.             swap RndArray(swnum1),RndArray(r)
  232.         next
  233.     next
  234.  
  235.     'write the numbers neatly to a file
  236.  
  237.     open "starrnd.dw" for output as 1
  238.     cc= 0          ' CC is my "Column Control"
  239.     print#1, "StarRnd dw ";:print#1, using"####";RndArray(0)
  240.     for r = 1 to NumStars
  241.  
  242.         IF cc=0 THEN   ' is this the first one on the line?
  243.             print#1, "dw ";:print#1, using"####" ;RndArray(r);
  244.         ELSE 
  245.             print#1, ",";:print#1, using"####"; RndArray(r);
  246.         END IF
  247.  
  248.         cc=cc+1:if cc= 10 then cc=0:print#1," "   'goto the next line
  249.     next
  250.     close #1
  251.  
  252. ──────────────── 
  253.  
  254.     This brings up another point.  Whenever you can write a program in a
  255. higher level language to create data for you, do it.  It sure beats typing
  256. then in by hand.  For instance, the palette was made using the REPT macro,
  257. the actual data is created by the compiler at compile time.  Doing it that 
  258. way happens to be a whole lot easier than typing in every byte.
  259.  
  260.     Last minute note: I rigged the plus and minus keys up so that they
  261. control the 'Warpspeed' can be from 0 - MaxWarp, which I set to 90 or 
  262. something like that.
  263.  
  264. ─────────────────────────────────────────────────────────────────────────────
  265.  
  266.    Well, that's it for now.  See INFO.VLA for information on contacting us.
  267.  
  268.    I would like some suggestions on what to write code for.  What would you
  269.    like to see done?  What code would you like to get your hands on?
  270.  
  271.    Send question, comments, suggestions to draeden@u.washington.edu or post
  272.     on Phantasm BBS.
  273.  
  274.  
  275. ┌───────────┬────────────────────────────────────────────────────────────────
  276. │ STARS.ASM │
  277. └───────────┘
  278.  
  279.  
  280. ─────────────────────────────────────────────────────────────────────────────
  281. ;
  282. ;     TITLE: Star field
  283. ;WRITTEN BY: DRAEDEN
  284. ;      DATE: 03/15/93
  285. ;
  286. ;     NOTES: Need 386 to execute.
  287. ;
  288. ;ASSOCIATED FILES:
  289. ;
  290. ;       STARGEN.BAS =>  Basic program that generates a set of 'randomized'
  291. ;                       numbers.  Creates STARRND.DW
  292. ;
  293. ;       STARS.TXT   =>  The text file that explains starfields...
  294. ;
  295. ;       STARRND.DW  =>  File that contains a set of shuffled numbers.
  296. ;                       Used to create 'random' star field.
  297. ;
  298. ────────────────────────────────────────────────────────────────────────────
  299.  
  300.     DOSSEG
  301.     .MODEL SMALL
  302.     .STACK 200h
  303.     .CODE
  304.     .386
  305.     ASSUME CS:@CODE, DS:@CODE
  306.     LOCALS
  307.  
  308. ;=== GLOBALS
  309. ;=== Data Includes
  310.  
  311. INCLUDE starrnd.dw      ;file that has label StarRnd numbers
  312.  
  313. ;=== DATA Structures
  314.  
  315.     Star_Struc      STRUC
  316.         X       dw  0
  317.         Y       dw  0
  318.         Z       dw  0
  319.         OldDi   dw  0       ;where to erase last dot
  320.         Color   db  0       ;BASE color. a number 0-16 is added to it
  321.     Star_Struc      ENDS
  322.  
  323.     StarStrucSize = 9       ;number of bytes per entry
  324.  
  325. ;=== DATA
  326.  
  327. ScreenWidth EQU 320
  328. ScreenHeight EQU 200
  329.  
  330. NumRnds     EQU 400     ;number of random numbers defined
  331.  
  332. MaxZpos     EQU 4096
  333. MinZpos     EQU 2
  334. MaxStars    EQU 190
  335. NumColors   EQU 5       ;number of Base colors in the Color Chart
  336.  
  337. WarpSpeed   dw  15      ;how quickly the stars move toward ya
  338. MaxWarp     EQU 90
  339.  
  340. Xindex      dw  30      ;index into the StarRnd chart for X & Y
  341. Yindex      dw  230     ; -note they must be different; set em the same to
  342.                         ;see why
  343. Cindex      dw  0       ;index into ColorChart
  344.  
  345. ColorChart  db  0,16,32,48,64,80    ;a list of base colors (-1)
  346.  
  347. Stars       Star_Struc MaxStars DUP (<>) ;where all the data is held
  348. NumActive   dw  0       ;number of stars active
  349.  
  350. Palette     db  3 dup (0)   ;the palette.. first entrie is BG color (black)
  351.     i = 15
  352.     REPT    16
  353.             db  2*i,3*i,4*i
  354.         i=i-1
  355.     ENDM
  356.     i = 15
  357.     REPT    16
  358.             db  2*i,2*i,4*i
  359.         i=i-1
  360.     ENDM
  361.     i = 15
  362.     REPT    16
  363.             db  3*i,3*i,4*i
  364.         i=i-1
  365.     ENDM
  366.     i = 15
  367.     REPT    16
  368.             db  3*i,2*i,4*i
  369.         i=i-1
  370.     ENDM
  371.     i = 15
  372.     REPT    16
  373.             db  3*i,3*i,3*i
  374.         i=i-1
  375.     ENDM
  376.     i = 15
  377.     REPT    16
  378.             db  2*i,4*i,3*i
  379.         i=i-1
  380.     ENDM
  381.  
  382. ;=== Code Includes
  383. ;=== SUBROUTINES
  384.  
  385.     ;finds 1st available slot for a star and puts it there
  386. MakeStar PROC NEAR
  387.     pusha
  388.     mov     ax,cs
  389.     mov     es,ax
  390.     mov     ds,ax
  391.  
  392.     cmp     [NumActive],MaxStars    ;is there room for another star?
  393.     jae     NoEmptySpace            
  394.  
  395.     ;search for 1st available slot
  396.  
  397.     mov     si,0
  398. TryAgain:
  399.     cmp     word ptr [Stars.Z+si],0     ;is this slot empty?
  400.     je      GotOne                      ;yes, go fill it
  401.  
  402.     add     si,StarStrucSize
  403.     cmp     si,MaxStars*StarStrucSize
  404.     jb      TryAgain
  405.     jmp     NoEmptySpace
  406.  
  407. GotOne:         ;si points to the record for the star to fill
  408.     mov     di,[Yindex]         ;grab index for Ypos
  409.     add     di,di               ;multiply by 2 to make it a WORD index
  410.     mov     ax,[StarRnd+di]     ;get the number
  411.     shl     ax,3                ;multiply by 8- could been done in BAS file
  412.     mov     [Stars.Y+si],ax     ;and save off the number
  413.     
  414.     mov     di,[Xindex]         ;grab index for Xpos
  415.     add     di,di               ;... same as above, but for Xpos
  416.     mov     ax,[StarRnd+di]
  417.     shl     ax,3
  418.     mov     [Stars.X+si],ax
  419.  
  420.     mov     [Stars.Z+si],MaxZpos    ;reset Zpos to the max
  421.     inc     [NumActive]             ;we added a star so increase the counter
  422.  
  423.     mov     di,[Cindex]             ;grab the color index
  424.     mov     al,[ColorChart+di]      ;grab the BaseColor for the star
  425.     mov     [Stars.Color+si],al     ;save it in the record
  426.  
  427.     ;increase all the index pointers
  428.  
  429.     inc     [Cindex]                ;increases the color counter
  430.     cmp     [Cindex],NumColors
  431.     jb      OkColor
  432.     mov     [Cindex],0
  433. OkColor:
  434.     inc     [Yindex]                ;increases Yindex
  435.     cmp     [Yindex],NumRnds        ;note that for this one we
  436.     jb      YindNotZero             ; subtract NumRnds from Yindex if we
  437.     sub     [Yindex],NumRnds        ; go off the end of the chart
  438. YindNotZero:
  439.     inc     [Xindex]                ;increase Xindex
  440.     cmp     [Xindex],NumRnds        ;have we gone through the entire chart?
  441.     jb      XindNotZero             ;nope...
  442.  
  443. ;This clever bit of code makes more use out of the chart by increasing Yindex
  444. ; one additional unit each time Xindex goes through the entire chart... the
  445. ; result is nearly NumRND^2 random non-repeating points
  446.         
  447.     inc     [Yindex]                ;yes, so change Yindex so that we get a
  448.     mov     ax,[Yindex]             ;new set of random (x,y)
  449.     cmp     ax,[Xindex]             ;does Xindex = Yindex?
  450.     jne     NotTheSame              ;if the index were the same, you'd see 
  451.                                     ;a graph of the line Y = X, not good...
  452.     inc     [Yindex]                ;if they are the same, inc Yindex again
  453. NotTheSame:
  454.     mov     [Xindex],0              ;reset Xindex to 0
  455. XindNotZero:                        ;all done making the star...
  456.  
  457. NoEmptySpace:
  458.     popa
  459.     ret
  460. MakeStar ENDP
  461.  
  462. DisplayStars PROC NEAR
  463.     pusha
  464.     mov     ax,cs
  465.     mov     ds,ax
  466.     mov     ax,0a000h
  467.     mov     es,ax
  468.  
  469.     mov     si,0
  470. DispLoop:
  471.     mov     cx,[Stars.Z+si]
  472.     or      cx,cx                   ;if Zpos = 0 then this star is dead...
  473.     je      Cont                    ;continue to the next one- skip this one
  474.  
  475.     mov     di,[Stars.OldDi+si]     ;grab old Di
  476.     mov     byte ptr es:[di],0      ;erase the star
  477.     
  478.     cmp     cx,MinZpos
  479.     jl      TermStar                ;if Zpos < MinZpos then kill the star
  480.  
  481.     mov     ax,[Stars.Y+si]
  482.     movsx   dx,ah                   ;'multiply' Ypos by 256
  483.     shl     ax,8
  484.     
  485.     idiv    cx                      ;and divide by Zpos
  486.     add     ax,ScreenHeight/2       ;center it on the screen
  487.     mov     di,ax
  488.     cmp     di,ScreenHeight         ;see if the star is in range. 
  489.     jae     PreTermStar             ; If not, kill it
  490.     imul    di,ScreenWidth          ; DI = Y*ScreenWidth
  491.  
  492.     mov     ax,[Stars.X+si]
  493.     movsx   dx,ah                   ;multiply Xpos by 256
  494.     shl     ax,8
  495.  
  496.     idiv    cx                      ;and divide by Zpos
  497.     add     ax,ScreenWidth/2        ;center it on the screen
  498.     cmp     ax,ScreenWidth          ;are we inside the screen boundries?
  499.     jae     PreTermStar
  500.     add     di,ax                   ; DI = Y * ScreenWidth + X
  501.  
  502.     mov     [Stars.OldDi+si],di     ;save old di
  503.  
  504.     ;calculate the color below
  505.  
  506.     add     ch,cs:[Stars.Color+si]  ;i'm dividing cx (the zpos) by 256 and
  507.                                     ; putting the result in ch and adding
  508.                                     ; the base color to it in one instruction
  509.     mov     es:[di],ch              ;put the dot on the screen
  510.  
  511.     mov     ax,cs:[WarpSpeed]
  512.     sub     cs:[Stars.Z+si],ax      ;move the stars inward at WarpSpeed
  513.  
  514. Cont:
  515.     add     si,StarStrucSize        ;point to next record
  516.     cmp     si,MaxStars*StarStrucSize   ;are we done yet?
  517.     jb      DispLoop
  518.     popa
  519.     ret
  520.  
  521. PreTermStar:
  522.     mov     [Stars.Z+si],1  ;this is here so that the star will get erased
  523.     jmp     short Cont      ;next time through if I just went off and killed
  524.                             ;the star, it would leave a dot on the screen
  525. TermStar:
  526.     mov     [Stars.Z+si],0  ;this actually kills the star, after it has
  527.     dec     [NumActive]     ;been erased
  528.     jmp     short Cont
  529.  
  530. DisplayStars ENDP
  531.  
  532. ;=== CODE
  533.  
  534. START:
  535.     mov     ax,cs
  536.     mov     ds,ax
  537.     mov     es,ax
  538.  
  539.     mov     ax,0013h                ;set vid mode 320x200x256 graph
  540.     int     10h
  541.     
  542.     mov     dx,offset Palette
  543.     mov     ax,1012h                ; WRITE palette 
  544.     mov     bx,0                    
  545.     mov     cx,256                  ;write entire palette
  546.     int     10h                     ;doesn't matter if we didnt define it all
  547.  
  548. StarLoop:
  549.     call    MakeStar        ;make stars 2x as thick
  550.     call    MakeStar
  551.  
  552.     mov     dx,3dah
  553. VRT:
  554.     in      al,dx
  555.     test    al,8
  556.     jnz     VRT             ;wait until Verticle Retrace starts
  557.  
  558. NoVRT:
  559.     in      al,dx
  560.     test    al,8
  561.     jz      NoVRT           ;wait until Verticle Retrace Ends
  562.  
  563.     call    DisplayStars
  564.  
  565.     mov     ah,1            ;check to see if a char is ready
  566.     int     16h
  567.     jz      StarLoop        ;nope, continue
  568.     
  569.     mov     ah,0
  570.     int     16h             ;get the character & put in AX
  571.  
  572.     cmp     al,"+"          ;compare ASCII part (al) to see what was pressed
  573.     jne     NotPlus
  574.  
  575.     inc     [WarpSpeed]
  576.     cmp     [WarpSpeed],MaxWarp
  577.     jbe     StarLoop
  578.  
  579.     mov     [WarpSpeed],MaxWarp
  580.     jmp     StarLoop
  581.  
  582. NotPlus:
  583.     cmp     al,"-"
  584.     jne     NotMinus
  585.  
  586.     dec     [WarpSpeed]
  587.     cmp     [WarpSpeed],0
  588.     jge     StarLoop
  589.  
  590.     mov     [WarpSpeed],0
  591.     Jmp     StarLoop
  592.  
  593. NotMinus:
  594.  
  595.     mov     ax,0003h        ;set 80x25x16 char mode
  596.     int     10h
  597.     mov     ax,4c00h        ;return control to DOS
  598.     int     21h
  599. END START
  600.  
  601.  
  602.  
  603. ┌────────────┬───────────────────────────────────────────────────────────────
  604. │ STARRND.DW │
  605. └────────────┘
  606.  
  607.  
  608. StarRnd dw  166
  609. dw   67, 102,  46,-173,-154,-210,-192, 173,-196, -81 
  610. dw  -50,  36,  50,-200, -95, 209, -16,-179, -30,  18 
  611. dw  174, 197, 127,  71,  29,-121,-160,-176,  19, -52 
  612. dw -185,  89, 172,  74,-156, 157,-125, 144, -34,  69 
  613. dw   17, -40,  64, -98,-153, 125, 160, 140,-204, 141 
  614. dw  137,-165, -14, 154,-146, 119, 123, 165,-130, 168 
  615. dw -180, 143,  52, 107,-107,-102,  57,  27, 117,  37 
  616. dw  126,  15, -89, 184, 116, 183, -99,-139, 150, 188 
  617. dw   38,  90,  93,-194, 207,-187,  62,  59, 196,  12 
  618. dw -174,  54, 146,-137, 198, 162, 155,-163, -77,-144 
  619. dw  191,-132, -43, 151,-103,  20, -46,  13,-140,  31 
  620. dw  130,-169,-188, 109, -33,-150,-170,  68, -75,-201 
  621. dw -100,-171, -19, -61,-206, 149,  99, -76,-186, -44 
  622. dw -178,  34,  61,  28, 114, 199, 201, -83, -27,  63 
  623. dw  -38, 204, 208,-112,-208, 122, -90,  23,-122, 161 
  624. dw   35,-168, 170,-164,-151,  75, -60,-109,  85, 193 
  625. dw   45,-175,-134, 205, -21,  49, 133, -85, -47, -37 
  626. dw  -29, -96, -66,  73,-118, 147, -53, 120, 153,-155 
  627. dw  -11,  11,  95, -26, 134,-145, -49, -74,  42,-124
  628. dw  189, -42,  92,-167,  88,-126,-129,-108,-193, 195 
  629. dw  190,-106,-117, 203,  84, 139,-123, -94, -88,-158 
  630. dw  181, -97, -20,  82, -57, 112, -35,  14, -56, -58 
  631. dw  200,  80,-183, 106,  87,  30,  51, -28,  98, -12 
  632. dw -191,-128, -13,-184, 136,  43,-166, -62, -73,-116 
  633. dw  -31,-135,-101,  25,  41, -82, 110,  10, -45, -41 
  634. dw   97, 175, 138, 171,  72,-133,-157,  58,-104, 187 
  635. dw  192, -68, -87, 169,-110,  91, 129, 104, -70,-114 
  636. dw -138,-115,-141, -67,-195, -79, -69,  40,-147, -80 
  637. dw -119, 128, 152,-209,  83,  53, 159,  66,-190,  81 
  638. dw  -92, -10,-181, 135,  60,  33, -25,  70,  22, -72 
  639. dw  103, -23, 131,  79, -64,  55, -86, -32,-182,-136 
  640. dw   26, -54,-172,-148, 148, -65,-152,-207, -39, -71 
  641. dw   65, 179,-177,  24, 118, -59, -63,  44, 105, 206 
  642. dw  178, -84,-202, 132, 186, -17,  76, 176, -22, 177 
  643. dw -198,-159,-162,  78,  77, -55,-120,-203,-113, 156 
  644. dw -189,-197, 124, 121,-142, -15,-205,  56, 158, -18 
  645. dw  -93,-161,  39,  48, 101, -91, 182,-127, 108, 111 
  646. dw  -36,-143,  21,-149, -78, -48, 164, 202, 185, 180 
  647. dw  -51,-199, 100, 194,  32, -24, 142,  86,-111,  47
  648. dw  115,-105,  16, 167,  94, 163,  96, 113,-131, 145
  649.  
  650.  
  651. ┌─────────────┬──────────────────────────────────────────────────────────────
  652. │ STARGEN.BAS │
  653. └─────────────┘
  654.  
  655.  
  656. '
  657. 'Written by: Draeden /VLA
  658. '      Date: 03/15/93
  659. '
  660. '     Notes: Used for generating 'random' data for Stars.asm
  661. '
  662.  
  663.  
  664.         NumStars = 400
  665.         dim     RndArray(NumStars)
  666.         randomize (timer)
  667.  
  668.         'fill the array with numbers from -Numstars/2 to -10
  669.         'and from 10 to Numstars/2
  670.  
  671.         i=10
  672.         for r = 0 to NumStars/2
  673.                 RndArray(r)=i
  674.                 i=i+1
  675.         next
  676.         i=-10
  677.         for r = NumStars/2 to NumStars
  678.                 RndArray(r)=i
  679.                 i=i-1
  680.         next
  681.  
  682.         'randomly shuffle them..
  683.  
  684.         print "Total numbers: ";NumStars
  685.         print "Shuffling - Please wait... "
  686.  
  687.         for q = 1 to numstars/5
  688.                 for r = 0 to NumStars
  689.                         swnum1 = int(rnd*NumStars+.5)
  690.                         swap RndArray(swnum1),RndArray(r)
  691.                 next
  692.         next
  693.  
  694.         'write the numbers neatly to a file
  695.  
  696.         open "starrnd.dw" for output as 1
  697.         cc= 0
  698.         print#1, "StarRnd dw ";:print#1, using"####";RndArray(0)
  699.         for r = 1 to NumStars
  700.  
  701.                 IF cc=0 THEN
  702.                         print#1, "dw ";:print#1, using"####" ;RndArray(r);
  703.                 ELSE 
  704.                         print#1, ",";:print#1, using"####"; RndArray(r);
  705.                 END IF
  706.  
  707.                 cc=cc+1:if cc= 10 then cc=0:print#1," "
  708.         next
  709.         close #1
  710.  
  711.