home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Games / WormWars / Source / qdraw020.asm < prev    next >
Assembly Source File  |  2000-06-23  |  4KB  |  140 lines

  1. * $Filename: WormWars/Source/qdraw020.asm $
  2. * $VER:      WormWars 6.1 (16.6.100) for Amiga
  3. *
  4. * © Copyright 2000 Jilles Tjoelker. Freely distributable.
  5. *
  6. * Worm Wars is © Copyright 2000 James R. Jacobs. Freely distributable.
  7. *        _
  8. *       //        -=AMIGA=-
  9. *      //
  10. * _   //
  11. * \\ //
  12. *  \X/
  13. *
  14. * Assemble with PhxAss, see assemble.s.
  15. * Set ISO for isometric version, don't set it for normal version.
  16.  
  17.              machine 68020
  18.  
  19. SQUAREX=9 ; <=16! ; <=32 can be done with a simple modification
  20. SQUAREY=6 ; <=16! ; but >32 is more difficult
  21.  
  22. NPLANES=4 ; dynamic could be done easily
  23.  
  24. AnPInfo equr a0
  25. AnDPtr       equr a1
  26. AnPOffset equr a2
  27. AnPPtr       equr a3
  28.  
  29. DnX          equr d0
  30. DnData       equr d1
  31. DnHeight     equr d2
  32. DnPlane      equr d3
  33. DnBPR        equr d4
  34. DnScratch1   equr d5
  35. DnPlaneSZ    equr d6
  36.  
  37. ; - don't change d0-d1/a0-a1
  38. ; - # of BPR < # of PlaneSZ (for MOVEM)
  39.  
  40. regstosave   reg d2-d6/a2-a3 ; all of the above, except d0-d1/a0-a1
  41.  
  42.  IFND ISO
  43. @qdraw020:
  44.              xdef @qdraw020
  45.  ENDC
  46.  
  47.  IFD ISO
  48. @qdraw020iso:
  49.              xdef @qdraw020iso
  50.  ENDC
  51.  
  52. ; Prototype:
  53. ; void __asm qdraw020(register __a0 struct QDPlaneInfo *pi,register __d0 LONG x,register __d1 LONG y,register __a1 UWORD *data);
  54. ; or:
  55. ; void __regargs qdraw020(struct QDPlaneInfo *pi,LONG x,LONG y,WORD *data);
  56.  
  57. ; The latter needs @qdraw020. (I've done that.)
  58.  
  59. ; x&y are relative to screen bitmap, not window. Add window->TopEdge to y in C.
  60. ; The QDPlaneInfo contains information of the screen->RastPort.BitMap.
  61.  
  62.              rsreset
  63. pi_Planes    rs.l NPLANES ; copy of bm_Planes[] element 0 to 3
  64. pi_BPR       rs.l 1 ; bytesperrow
  65. pi_PlaneSZ   rs.l 1 ; bytesperrow*rows
  66.  
  67. ; struct QDPlaneInfo
  68. ; {
  69. ;            UWORD       *pi_Planes[4];
  70. ;            ULONG       pi_BPR,pi_PlaneSZ;
  71. ; };
  72.  
  73.              MOVEM.L regstosave,-(sp)
  74.  
  75.              MOVEM.L pi_BPR(AnPInfo),DnBPR/DnPlaneSZ ; # of BPR < # of PlaneSZ!
  76.  
  77.              MOVEQ #0,DnPlane
  78.  
  79.              *MOVE.L <y>,DnData ; already in there
  80.              MULU.W DnBPR,DnData
  81.              MOVEA.L DnData,AnPOffset
  82.  
  83. .planeloop:
  84.  
  85.              MOVEA.L pi_Planes(AnPInfo,DnPlane.L*4),AnPPtr
  86.              ADDA.L AnPOffset,AnPPtr
  87.  
  88.  IFND ISO
  89.  
  90.              MOVEQ #SQUAREY-1,DnHeight
  91.  
  92. .yloop:
  93.              MOVE.W (AnDPtr)+,DnData
  94.              LSR.W #16-SQUAREX,DnData ; Image left-aligned <-> BFINS right-aligned
  95.              BFINS DnData,(AnPPtr){DnX:SQUAREX}
  96.  
  97.              ADDA.L DnBPR,AnPPtr
  98.              DBF DnHeight,.yloop
  99.  
  100.  ENDC ; ISO
  101.  
  102.  IFD ISO
  103.  
  104. *For isometric: (a lot is the same; all preserve stuff is unnecessary)
  105.  
  106. ;             0123456789012345        shift       DnHei.       >>1=offset
  107. ;            0..#########.....        5           5            2
  108. ;            1..#########.....        5           4            2
  109. ;            2.#########......        6           3            1
  110. ;            3.#########......        6           2            1
  111. ;            4#########.......        7           1            0
  112. ;            5#########.......        7           0            0
  113.  
  114. ; numbers above aren't bit numbers but bitfield offsets
  115.  
  116. ; (0,0) here is reference for x&y passed, just as the old DrawImage() way.
  117.  
  118.              MOVEQ #SQUAREY-1,DnHeight
  119.  
  120. .yloop:
  121.              MOVE.L DnHeight,DnScratch1
  122.              LSR.L #1,DnScratch1
  123.              BFEXTU (AnDPtr){DnScratch1:SQUAREX},DnData
  124.              ADD.L DnX,DnScratch1
  125.              BFINS DnData,(AnPPtr){DnScratch1:SQUAREX}
  126.  
  127.              ADDQ.L #2,AnDPtr
  128.              ADDA.L DnBPR,AnPPtr
  129.              DBF DnHeight,.yloop
  130.  
  131.  ENDC ; ISO
  132.  
  133.              ADDQ.W #1,DnPlane
  134.              CMP.W #NPLANES,DnPlane
  135.              BNE .planeloop
  136.  
  137.              MOVEM.L (sp)+,regstosave
  138.  
  139.              RTS
  140.