From: Karsten_Weiss@ibase.stgt.sub.org (Karsten Weiss)
Newsgroups: comp.sys.amiga.programmer
Subject: Re: Wolf3D -- programming aspects
Distribution: world
Date: 14 Oct 92 17:43:18 MET
Organization: Intuition-Base BBS Leonberg

 
>    For "real" texture mapping (like in Ultima-UnderWorld), I'd recommend
> generating your texture mapped polygons into a fake frame buffer, stored
> in fast ram at one byte per pixel. After the whole frame has been
rendered
> into this fake buffer, transfer it to chip ram, converting it from chunky
> to planar. This has a lot of advantages over writing your texture map
> routines to work in planar modes:
> 
 [advantages deleted]
 
Here is my version of a Chunky2BitPlane copy routine (I remember somebody
asked for it...). However, it has two restrictions:
 
- The colorbits must go reverse. From bit 7 downwards to zero if you use
  8 bits or from bit 7 to bit 4 if you use 4 bitplanes as I did in this
  example. It has to be like this because you don't have to shift the
  colorbits then. And I think this is no disadvantage because it doesn't
  matter which colorbyte the texture mapping routine copies into the
  chunky fake frame buffer.
- The routine doesn't use a table. So dithering, etc. is not possible.
  Therefor it is much faster than with a table!
 
After finishing the routine I was a little bit disappointed because I
wasn't
as fast as I hoped! On my A2000 with A2630 (25Mhz 030er) it can convert
approx. a 128x128 frame in 4 bitplanes. Another possibility I thought of
is to use the copper to double the display in y-direction with the modulo
registers. Then you could convert a 192x92 frame and it would become
a 192x192 frame on the screen (however with half the resolution). But
remebering Wolf3d on the PC it was even a worser resolution there, wasn't
it!?!?! (I only did see it for half a minute!)
 
Wrote enough - here's the routine:
 
--- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE ---
 
*******************************************************************
*** Chunky2Bitplane by Karsten Weiss in Oct 1992                ***
*******************************************************************
 
PlaneWidth     = 16
PlaneHeight    = 128
PlaneLen       = PlaneWidth*PlaneHeight
 
Chunky2BitPlane:
 
;The ChunkyByte: %12340000 (Number=BitPlaneNumber)
 
          lea  (Plane1),a0         ;BitPlanes Ptrs
          lea  (Plane2),a1
          lea  (Plane3),a2
          lea  (Plane4),a3
 
;         lea  (ChunkyPlane),a4    ;Chunky Plane Ptr
          lea  ($fc0000),a4        ;use ROM for testing...
 
          move.w    #(PlaneLen/4)-1,d7
 
.WordLoop:
          moveq     #(32/4)-1,d6   ;32 bits = 4 bytes
 
.BitLoop: move.w    (a4)+,d4       ;get 2x2 Chunky Bytes
          move.w    (a4)+,d5       ;(two different registers
                                   ;to save a 'lsl.w #4,d4'!
 
          add.w     d4,d4
          addx.l    d0,d0
          add.w     d4,d4
          addx.l    d1,d1
          add.w     d4,d4
          addx.l    d2,d2
          add.w     d4,d4
          addx.l    d3,d3
 
          lsl.w     #4,d4          ;skip unused bits
 
          add.w     d4,d4
          addx.l    d0,d0
          add.w     d4,d4
          addx.l    d1,d1
          add.w     d4,d4
          addx.l    d2,d2
          add.w     d4,d4
          addx.l    d3,d3
 
          add.w     d5,d5
          addx.l    d0,d0
          add.w     d5,d5
          addx.l    d1,d1
          add.w     d5,d5
          addx.l    d2,d2
          add.w     d5,d5
          addx.l    d3,d3
 
          lsl.w     #4,d5          ;skip unused bits
 
          add.w     d5,d5
          addx.l    d0,d0
          add.w     d5,d5
          addx.l    d1,d1
          add.w     d5,d5
          addx.l    d2,d2
          add.w     d5,d5
          addx.l    d3,d3
 
          dbf       d6,.BitLoop    ;loop until LWs are full
 
          move.l    d0,(a0)+       ;copy the calculated LWs
          move.l    d1,(a1)+       ;into the bitplanes
          move.l    d2,(a2)+
          move.l    d3,(a3)+
 
          dbf       d7,.WordLoop
 
          rts
 
--- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE --- CUT HERE ---
 
Does anybody know a better (i.e faster) way to convert from chunky to
bitplane? Please let me know!!!
If you use this routine in your program please mention me!
 
                                            CU l8er,
                                                    Karsten Weiss
 
PS: How would you have done this in C? ;-)
 
> *-------------------------------------------*---------------------------*
> |Chris Green - Graphics Software Engineer   - chrisg@commodore.COM      f
> |                  Commodore-Amiga          - uunet!cbmvax!chrisg       n
> |My opinions are my own, and do not         - icantforgettheimpression  o
> |necessarily represent those of my employer.- youmadeyouleftaholeinthe  r
> |"A screaming comes across the sky..."      - backofmyhead              d
> *-------------------------------------------*---------------------------*

-- Via DLG Pro v0.992

 
/================================================================\
| UUCP:  Karsten_Weiss@ibase.stgt.sub.org | 'Life Is Ours,       |
| FIDO:  2:247/706 (Karsten Weiss)        |  We Live It Our Way' |
| Voice: +49-(0)7192-8444                 |          (Metallica) |
\================================================================/
Newsgroups: comp.sys.amiga.programmer