home *** CD-ROM | disk | FTP | other *** search
/ Assembly 1994 - The 3rd Phase / ASMROM94.mdf / sources / hstars.txt < prev    next >
Text File  |  1994-11-12  |  4KB  |  88 lines

  1. ─────────────────────────────────────────────────────────────────────────────
  2. ;
  3. ;     TITLE: Horizontal Star field
  4. ;WRITTEN BY: DRAEDEN
  5. ;      DATE: 04/16/93
  6. ;
  7. ;     NOTES: Need a 286+ to execute.
  8. ;
  9. ;ASSOCIATED FILES:
  10. ;
  11. ;       HSTAR.ASM   =>  ASM code for horizontal starfield
  12. ;
  13. ;       HSTAR.BAS   =>  Basic program that generates a set of 'random' star
  14. ;                       locations.  Creates the file 'HSTARS.DW'
  15. ;
  16. ;       HSTAR.TXT   =>  This file
  17. ;
  18. ;       HSTARS.DW   =>  Holds the star location data (the structured info)
  19. ;                       Created by HSTAR.BAS
  20. ;
  21. ────────────────────────────────────────────────────────────────────────────
  22.  
  23.     The horizontal starfield is simply a series of dots that are moved in the
  24. X direction in either the positive or negative direction.  That is all that
  25. this ASM file does.  It simply takes a (X,Y) position, adds a velocity to the
  26. position and keeps it in bounds.  Different from before, I've introduced a
  27. well known (to graphics programmers) thing.  A look-up chart.  In this case
  28. I use the look up chart to find the offset for a particular Y pos.  This way
  29. is MUCH faster than the old [imul di,320] and it is more flexable.
  30. Here's how I did it in detail:
  31.  
  32. ────────────────
  33.  
  34.     mov di,[Ypos]               ;get the ypos
  35.     add di,di                   ;multiply the ypos by 2, so I can use it to
  36.                                 ; look up WORD sized data
  37.     mov di,[YOffsetChart + di]  ;and grab the offset and put it in DI
  38.  
  39. ────────────────
  40.  
  41.     I can use DI as both a source and a destination for much the same reason
  42. that you can do that in any language.  I have to use DI to get the data
  43. before it can be put in DI.  Hmmm... That may be confusing.  Nevermind.
  44.  
  45.     ANYway, if you've already looked at the source, you've probably noticed
  46. that the Display procedure is awfully large.  This is because I chose to just
  47. repeat the same block over 4 times instead of having to get clever and write
  48. a little loop.  Everyone knows what happens when you get clever.  You lose a
  49. foot. :)
  50.  
  51.     All the data was created by the small BASIC program that was included.
  52. If you don't like the current layout of the stars, run the basic program-
  53. it'll give you a new set.
  54.  
  55.     This code is not 100% perfect.  It's up to you to fix it up.  I did that
  56. 'cause I was feelin' awfully lazy last night when I decided to finally write
  57. this.  Here are some suggestions on how to fix it up:
  58.  
  59.     1)  Fix the main subroutine so that instead of being 4 repeated blocks, 
  60.         its just 1 small loop.
  61.  
  62.     2)  Change it so that you can have "fractional" speeds.  This would be
  63.         done by just changing the size of the Xpos from a WORD to a DWORD and
  64.         changing the velocity to a DWORD.  Then you'd set 10000h = 1 unit
  65.         (just use the high word as the Xpos.)
  66.  
  67.             For instance, a velocity of 1/2 would be = 08000h
  68.  
  69.     3)  After you fix it into a loop and give it a non-integer velocity, 
  70.         make it so you can add multiple layers. (more than 4)
  71.  
  72.     
  73.     After you make these improvements, you'd have a way-cool h-starfield.
  74.  
  75.  
  76.     Kinda a short DOC, but then again, the program isn't that complicated nor
  77. are the concepts contained within. 
  78.  
  79. ─────────────────────────────────────────────────────────────────────────────
  80.  
  81.    Well, that's it for now.  See INFO.VLA for information on contacting us.
  82.  
  83.    I would like some suggestions on what to write code for.  What would you
  84.    like to see done?  What code would you like to get your hands on?
  85.  
  86.    Send question, comments, suggestions to draeden@u.washington.edu or post
  87.     on Phantasm BBS.
  88.