home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sys / amiga / demos / 1716 < prev    next >
Encoding:
Text File  |  1992-11-17  |  6.6 KB  |  157 lines

  1. Nntp-Posting-Host: kolsaas.ifi.uio.no
  2. Newsgroups: alt.sys.amiga.demos
  3. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!darwin.sura.net!Sirius.dfn.de!mailgzrz.TU-Berlin.DE!news.netmbx.de!Germany.EU.net!mcsun!sunic!aun.uninett.no!nuug!ifi.uio.no!larshaug
  4. From: larshaug@ifi.uio.no (Lars Haugseth)
  5. Subject: Re: Writing a StarField. Which method is best?
  6. Message-ID: <1992Nov18.115111.8537@ifi.uio.no>
  7. Sender: larshaug@ifi.uio.no (Lars Haugseth)
  8. Organization: Dept. of Informatics, University of Oslo, Norway
  9. References: <1992Nov7.104910.60476@cc.usu.edu> <1992Nov11.131803.1276@ifi.uio.no> <1992Nov17.211753.11335@ntg.com>
  10. Date: Wed, 18 Nov 1992 11:51:11 GMT
  11. Lines: 143
  12. Originator: larshaug@kolsaas.ifi.uio.no
  13.  
  14.  
  15. In article <1992Nov17.211753.11335@ntg.com>, ewhac@ntg.com (Leo 'Bols Ewhac' Schwab) writes:
  16. > In article <1992Nov11.131803.1276@ifi.uio.no> larshaug@ifi.uio.no (Lars Haugseth) writes:
  17. > >Here is a small 3D-stars routine, with sine-table and all...
  18. >     Not to denigrate Lars' contribution to the community, but I thought
  19. > I'd try to make a few (hopefully constructive) comments on the coding style.
  20. > I've noticed a variety of practices in this and other pieces of demo code
  21. > which cause me to sit back and go, "Why?"
  22. > >No flames about coding-technique, please. After all, this is
  23. > >alt.sys.amiga.DEMOS ;-)
  24. > >
  25. >     Well, okay, but my philosophy in writing demos and hacks was to
  26. > learn how the system worked, and then be able to make constructive use of
  27. > that knowledge later, without getting bitten in the future.  Although some
  28. > of my *old* stuff made some invalid assumptions and looks ugly in some
  29. > configurations, they all still work (even "Viacom," the most brutal of the
  30. > lot).
  31. >     Part of this was following the programming standards.  Another was
  32. > writing code I felt was readable by myself and others.  Both of these are
  33. > religious issues to be sure, but what I'd like to point out below are just a
  34. > few simple things that I believe would help make demo code much easier to
  35. > write, *read*, maintain, and share.  (I like to share my stuff, you see;
  36. > that's why I believe it's important.)
  37. > >START    move.l    4.w,a6
  38. > >    move.l    156(a6),a1
  39. >         ^^^
  40. >     Okay.  Why isn't this a symbolic offset?  That is, why didn't you
  41. > say:
  42. >     move.l    IntVects+6*IV_SIZE+IV_DATA(a6),a1
  43.  
  44. Because demo-coders usually use a floppy-based system when writing
  45. programs, so it's a pain in the ass to use includes. Especially in
  46. routines like this where the includes are used in perhaps 10 lines
  47. of the source. I *don't* do like this when doing more "serious" stuff.
  48.  
  49.  
  50. >     Granted, this is more verbose, but it tells me exactly what you're
  51. > fetching; the iv_Data field from the seventh interrupt vector in ExecBase.
  52. > However, the real weirdness comes in with:
  53. > >    move.l    38(a1),OLDCP
  54. >     Translated, this is:
  55. >     move.l    gb_copinit(a1),OLDCP
  56. >     Basically, what the programmer has done is dive into the Exec
  57. > interrupt tables, pull out the iv_Data field from the "Blitter finished"
  58. > interrupt structure, made the *assumption* that this pointer is maintained
  59. > by Graphics and points to GfxBase, then fetches the copinit pointer from
  60. > GfxBase and saves it for later restoration.
  61. >     Excuse me but:        Ack!
  62. >     Why didn't you just open graphics.library?  Yes, it takes slightly
  63. > more code and is slower, but it gets executed only once, and you are
  64. > guaranteed that you will always get a pointer to GfxBase.  Future versions
  65. > of Graphics may (and probably will) put a completely different pointer in
  66. > the interrupt vector.  What if some other program in the system has made use
  67. > of that vector (which is perfectly legal)?  Poof! you die.
  68.  
  69. No, this small useless code dies, I do not 8). Anyway, I agree with you
  70. on this one. Shame on me! 8)
  71.  
  72. > >    bsr    SBUFFER
  73. > >    bsr    VBLANK
  74. > >    move.l    #COPPER,$DFF080
  75. >             ^^^^^^^
  76. >     Again, why not a symbolic offset?  I don't have the custom hardware
  77. > addresses memorized (sorry).  On the other hand, if you had said:
  78.  
  79. See above...
  80.  
  81. >     move.l    #COPPER,_cop1lc
  82. >     I'd know what you were doing without hunting through my RKM.
  83. >     I'm also the kinda guy who would suggest using Graphics to create
  84. > three Views rather than using a custom hard-coded copper list.
  85. >     [Actually, I have a theory about how one might incorporate such
  86. > copper lists into Intuition displays, but I haven't actually tried it out
  87. > yet...
  88.  
  89. But would I manage that many stars if I should use the system-routines
  90. for everything? The whole point of my routine is to make it as
  91. fast as possible.
  92.  
  93. > >    move.w    #$7FFF,$DFF09A        [ Disable all interrupts ]
  94. >     ARGH!  Why?  It's a STARFIELD!  It's not like you're modifying
  95. > system lists or trying to DMA hard disk data at breakneck speeds.  So why
  96. > put the system at risk?  Besides, I might be trying to download more demos
  97. > :-).
  98.  
  99. I want it to run at 50 frames pr. second... 8)
  100.  
  101. >     Example:  CDTV's CD-ROM device driver (cdtv.device) is written in
  102. > such a way that multitasking and interrupts *must* remain alive.  The CD-ROM
  103. > drive communicates with CDTV via interrupts.  If they are turned off for any
  104. > great length of time, cdtv.device will either DIE completely, or lose sync
  105. > with the CD-ROM drive and force it to reset (which takes *4* seconds).
  106. >     Speaking entirely personally, I'd really prefer not to kill the
  107. > system for a few extra stars.
  108.  
  109. A few??? Well... 8)
  110.  
  111. Anyway, remember that I never would have posted this on
  112. comp.sys.amiga.programmer (to avoid followups like yours 8)
  113.  
  114. > --------
  115. >     However, lest you think I'm only here to bash Euro coders to a pulp,
  116. > I think the core algorithm is interesting, and I'll probably spend a fair
  117. > amount of time studying it.  Also, there's nothing preventing a persnickety
  118. > compatibility freak (like me :-) ) from diving in and making it live more
  119. > peacefully with the system (at the cost of some stars).
  120.  
  121. Thanks! 8) Maybe you could send the result to me, so I too can learn 
  122. something from all this? 8)
  123.  
  124. >     While I realize these are merely demos and not intended to be
  125. > paragons of Perfect Programming Practice, I personally believe there are
  126. > acceptable tradeoffs between RAW UNADULTERATED SPEED and "nice" code.
  127. >     These are, of course, suggestions, and are completely ignorable.
  128.  
  129. I wouldn't say that 8)
  130.  
  131. > The demos aren't any less interesting to watch.
  132.  
  133. When I get a dh0: (Isn't it hd0: on the 4000?) , you'll never see
  134. those offsets as numbers again.. 8)
  135.  
  136. > _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
  137. > Leo L. Schwab -- The Guy in The Cape                    ewhac@ntg.com
  138. >  \_ -_          Recumbent Bikes:                ..or..  ewhac@well.sf.ca.us
  139. > O----^o       The Only Way To Fly.                     (pronounced "EH-wack")
  140. >  "Work FOR?  I don't work FOR anybody!  I'm just having fun."  -- The Doctor
  141.