home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / rec / games / programm / 5222 < prev    next >
Encoding:
Text File  |  1992-12-30  |  4.0 KB  |  128 lines

  1. Newsgroups: rec.games.programmer
  2. Path: sparky!uunet!psinntp!blkbox!collins
  3. From: collins@blkbox (Chad R. Collins)
  4. Subject: Re: Copying whole screens for Page Flipping
  5. Organization: The Black Box, PO Box 591822 Houston, TX 77259-1822 
  6. Date: Wed, 30 Dec 1992 03:25:32 GMT
  7. Message-ID: <1992Dec30.032532.17218@blkbox>
  8. References: <85893@ut-emx.uucp>
  9. Lines: 117
  10.  
  11. baylor@ccwf.cc.utexas.edu (Baylor) writes:
  12.  
  13.  
  14. >    Me and my finicky Pascal compiler can't get some code
  15. >to work. I'm trying to page flip and to do it, i want to copy 
  16. >everything from page 0 to page 1. Below is a hard-coded routine
  17. >to copy all of page 0 to page 1, hoping of course page 1
  18. >starts at 0a000:8000.
  19. >    And it don't work - it sometimes does nothing (page 1
  20. >stays the same) or else only icons with bit 0 set (like blue,
  21. >gray purple colors) are copied, but when they copy they make 
  22. >solid white icons. I assume somehow only bit 0 is being copied over,
  23. >which is why page 2 only has black and white images on it.
  24. >    I don't have the hang of switching planes, and since i 
  25. >have to copy from a plane from dest to plane on source, i hope
  26. >1 plane switch does tha plane switching for both source and dest.
  27. >If any of you have any ideas about what i could look at, please 
  28. >let me know.
  29. >    Kinda makes me wish i had an amiga...
  30.  
  31.  
  32.  
  33.  
  34. >Procedure Copy_Page; assembler;
  35. >(* Updates global variable Vis_Page                 *)
  36. >(* ES:DI - Destination (to)   DS:SI - Source (from) *)
  37. >(* CX    - Plane Loop         CX    - Row Loop      *)
  38. > const
  39. >      ScreenWidth          = 320;
  40. >      ScreenHeight         = 200;
  41.  
  42. >      Sequencer_Index      = $3C4;
  43. >      Color_Plane_Index    = $02;
  44. >      CurrentPlane : byte  = 8;
  45.  
  46. >      Screen_Offset        = $0A000;
  47. >      ScreenBytes          = ScreenWidth div 8; (* Bytes per scanline *)
  48. >      PlaneBytes           = ScreenBytes*ScreenHeight;
  49. >      PlaneWords           = PlaneBytes div 2;
  50. >      Page_1_Offset        = ScreenBytes*ScreenHeight;
  51. >(* var
  52. >    CurrentPlane : byte;*)
  53. >  Asm
  54. >     push ds
  55. >     push es
  56.  
  57. >     cld
  58.  
  59. >     mov  CurrentPlane,8
  60. >     mov  cx,4   (* Num Planes *)
  61.  
  62. >     mov ax,Screen_Offset
  63. >     mov ds,ax
  64.  
  65. >     mov ax,Screen_Offset
  66. >     mov es,ax
  67.  
  68. > @@Set_Address:
  69. >     mov di,Page_1_Offset
  70. >     xor si,si
  71.  
  72. >     @@Plane_Loop:
  73. >         push cx           (* Save Plane Number *)
  74.  
  75. >         mov dx,Sequencer_Index    (* set plane *)
  76. >         mov al,Color_Plane_Index
  77. >         out dx,al
  78. >         inc dx
  79. >         mov al,CurrentPlane
  80. >         out dx,al
  81.  
  82. >         mov cx,PlaneWords  (* copy that plane *)
  83. >         rep movsw
  84.  
  85. >         shr CurrentPlane,1    (* next plane *)
  86. >         pop cx                (* set cx back to planes *)
  87.  
  88. >         loop @@Set_Address
  89.  
  90. >     pop es
  91. >     pop ds
  92. >  End;
  93.     Well- 1) I dont know assembly and 2) nor do I know Pascal so I
  94. don't know EXACTLEY what you are doing, but it seems to me you are going
  95. about the whole thing in the wrong way. You don't have to copy each
  96. plane seperately... that is the advantage of a 32-bit VGA card, you get
  97. to copy 4 bytes at a time. First, you need to set the Map Mask register
  98. so that you write to all four planes and then do the normal block
  99. memory move. Each time you read a byte from the video memory, each
  100. plane's byte is loaded into the latch registers and then the latch
  101. registers are written to the video memory. More than likely, the problems
  102. you are having are due to the registers not being set right. I would
  103. check and make sure the Bit and Map Mask registers are set up right.
  104.  
  105. Chad R. Collins
  106. collins@blkbox.com
  107.  
  108. P.S.- this is the subroutine I use to choose the plane to write to...
  109. it is written in C, but you should be able to translate it pretty
  110. easily...
  111.  
  112. void select_plane(char plane)
  113. {
  114.         asm {
  115.                 mov dx, 0x3c4
  116.                 mov al, 2
  117.                 out dx, al
  118.                 inc dx
  119.                 mov al, [plane]
  120.                 out dx, al
  121.         }
  122. }
  123.  
  124. So, for plane one, set plane = 1, for plane two plane = 2, plane three 
  125. plane = 4, plane four plane = 8... You can select multiple planes by
  126. adding them toghther, so setting plane = 15 selects all four planes.
  127.  
  128.