home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / atari / st / tech / 4476 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  4.8 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!mips!darwin.sura.net!Sirius.dfn.de!zrz.tu-berlin.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!corton!loria!loria.crin.fr!eker
  2. From: eker@loria.crin.fr (Steven Eker)
  3. Newsgroups: comp.sys.atari.st.tech
  4. Subject: Re: Sprite code (Re: Second&last time: Hacking Contest)
  5. Message-ID: <446@muller.loria.fr>
  6. Date: 19 Aug 92 18:21:54 GMT
  7. References: <438@muller.loria.fr> <1992Aug06.184949.22119@infoserver.th-darmstadt.de> <439@muller.loria.fr> <1992Aug09.011934.47152@news.th-darmstadt.de> <440@muller.loria.fr> <9777@uqcspe.cs.uq.oz.au> <441@muller.loria.fr> <9817@uqcspe.cs.uq.oz.au>
  8. Sender: news@news.loria.fr
  9. Organization: CRIN (CNRS) Nancy - INRIA Lorraine
  10. Lines: 138
  11.  
  12. In article <9817@uqcspe.cs.uq.oz.au>, warwick@cs.uq.oz.au (Warwick Allison) writes:
  13.  
  14. |> Complicated?  All you do is push them onto a stack when you draw then,
  15. |> and pull them off to get the wiping order.  Usually, it is sufficient
  16. |> to just do it with code, rather than doing it dynamically:
  17. |> 
  18. |>     while (1) {
  19. |>     Sprite1.Wipe();
  20. |>     Sprite2.Wipe();
  21. |>     Sprite3.Wipe();
  22. |> 
  23. |>     Sprite3.Draw();
  24. |>     Sprite2.Draw();
  25. |>     Sprite1.Draw();
  26. |> 
  27. |>     Pages->Flip();
  28. |>     }
  29.  
  30. This is fine. but is a previous post you mentioned that sprites could be updated
  31. at different speeds which made me think you were using some arbitrary interleaving
  32. of draws & wipes. 
  33.  
  34. |> >How about:
  35. |> >    4. Wipe all sprites, Save under new positions, draw all sprites etc.
  36. |> 
  37. |> This is exactly my #1 method, except mine is encapsulated.
  38. |> 
  39. |> You are saying:
  40. |>     for each sprite 1..n { sprite.Wipe }
  41. |>     for each sprite 1..n { sprite.SaveUnder }
  42. |>     for each sprite 1..n { sprite.Draw }
  43. |> 
  44. |> I am saying:
  45. |>     for each sprite 1..n { sprite.Wipe }
  46. |>     for each sprite n..1 { sprite.DrawAndSaveUnder }
  47. |> 
  48. |> My method is superior, simply because I get the sprite.SaveUnder almost
  49. |> for free:  YOU ALREADY HAVE TO READ THE SCREEN IN ORDER TO DRAW THE SPRITE,
  50. |> so you may as well store that read data as you draw, saves reading twice.
  51.  
  52. Maybe, maybe not - it depends on your sprite drawing method. The code I originally
  53. posted only read the screen implicity with
  54.     or.w    d0,(a0)+
  55. type instructions. Now if you do it explicity you need an extra 4cy (canceling out any saving combining your save under code) and you need and an extra reg
  56. which could slow down the rest of your code.
  57.  
  58. BTW the code I posted is (slightly) faster than the 32x32 sprite code in
  59. your GNUchess port even under the most pessimistic assumptions (you did a great
  60. job on the port though...).
  61.  
  62. |> Which reminds me - was this a competition?  I wrote some VERY fast 
  63. |> sprite routines in a furious discussion with Dave B. - 60 or so
  64. |> single-bitplane 16x16 sprites at arbitrary positions on an arbitrary
  65. |> background was I believe my limit...
  66.  
  67. No, it was just a sugestion for a better competition goal than the rather
  68. pointless TOS hacking in Nat!'s competion.
  69. 60 sprites at 50Hz is quite amazing on a non-blitter ST. At 25Hz rather less so.
  70. Still I can't resist the challenge...
  71.  
  72. Steven
  73.  
  74.  
  75. *    One plane 16x16 sprites (draw code only)
  76. *
  77. *    Entry:
  78. *        a0    pointer to sprite
  79. *        a1    pointer to where to draw it
  80. *        d7    shift (0 - 15)
  81. *
  82.  
  83.     moveq    #4,d6        ; (4+1)*3+1 = 16 lines
  84. loop:
  85.     moveq    #0,d0
  86.     moveq    #0,d1
  87.     moveq    #0,d2
  88.     moveq    #0,d3
  89.     moveq    #0,d4
  90.     moveq    #0,d5
  91.     movem.w    (a0)+,d0-d5    ; get three lines of mask & sprite
  92.  
  93.     ror.l    d7,d0        ; rotate mask
  94.     and.w    (a1),d0        ; combine with bgnd
  95.     ror.l    d7,d1        ; rotate sprite
  96.     or.w    d1,d0        ; combine
  97.     move.w    d0,(a1)        ; replace
  98.     addq.w    #8,a1        ; next word
  99.     swap    d0        ; low part of mask
  100.     and.w    (a1),d0        ; combine with bgnd
  101.     swap    d1        ; low part of sprite
  102.     or.w    d1,d0        ; combine
  103.     move.w    d0,(a1)        ; replace
  104.     lea    152(a1),a1    ; next line
  105.  
  106.     ror.l    d7,d2        ; rotate mask
  107.     and.w    (a1),d2        ; combine with bgnd
  108.     ror.l    d7,d3        ; rotate sprite
  109.     or.w    d3,d2        ; combine
  110.     move.w    d2,(a1)        ; replace
  111.     addq.w    #8,a1        ; next word
  112.     swap    d2        ; low part of mask
  113.     and.w    (a1),d2        ; combine with bgnd
  114.     swap    d3        ; low part of sprite
  115.     or.w    d3,d2        ; combine
  116.     move.w    d2,(a1)        ; replace
  117.     lea    152(a1),a1    ; next line
  118.  
  119.     ror.l    d7,d4        ; rotate mask
  120.     and.w    (a1),d4        ; combine with bgnd
  121.     ror.l    d7,d5        ; rotate sprite
  122.     or.w    d5,d4        ; combine
  123.     move.w    d4,(a1)        ; replace
  124.     addq.w    #8,a1        ; next word
  125.     swap    d4        ; low part of mask
  126.     and.w    (a1),d4        ; combine with bgnd
  127.     swap    d5        ; low part of sprite
  128.     or.w    d5,d4        ; combine
  129.     move.w    d4,(a1)        ; replace
  130.     lea    152(a1),a1    ; next line
  131.  
  132.     dbra    d6,loop
  133.     moveq    #0,d0
  134.     moveq    #0,d1
  135.  
  136.     ror.l    d7,d0        ; rotate mask
  137.     and.w    (a1),d0        ; combine with bgnd
  138.     ror.l    d7,d1        ; rotate sprite
  139.     or.w    d1,d0        ; combine
  140.     move.w    d0,(a1)        ; replace
  141.     addq.w    #8,a1        ; next word
  142.     swap    d0        ; low part of mask
  143.     and.w    (a1),d0        ; combine with bgnd
  144.     swap    d1        ; low part of sprite
  145.     or.w    d1,d0        ; combine
  146.     move.w    d0,(a1)        ; replace
  147.  
  148. Come to think of it, if the sprites are only one pixel deep why not preshift
  149. the blighters???
  150.