Discussion:
QUERY: programming duke graphics help...woes :S
(too old to reply)
KevinGPO
2006-02-03 13:12:22 UTC
Permalink
I just programming Duke Nukem 3D source code and trying to understand
the drawing graphics routines. In the (game folder) game.c: main()
function somewhere halfway down there's displayrooms() and
displayrest(). I understand displayrooms() handles the 3D rendering,
while displayrest() handles map-mode, first-person weapon-holding hand,
& status bar.

What I want to do is program to display the actual sprites of all map
objects during map-view-mode.

In displayrest() function definition calls drawmapview() for colored
map, and drawoverheadmap() for the wire-frame map.

In file menues.c: drawoverheadmap() function there's a call to
rotatesprite() to draw the colorful duke sprite in the middle of the
screen. How can we use the same function to draw the other map sprites
at their correct locations in map-view-mode?



Other queries:
1. What is significant with show2dsector[i>>3]&(1<<(i&7)) ? I see this
pattern all over the place to test/decide whether to show a map object
or not. However I do not understand why bit-shift to the right 3
places, and bitmask AND on 7, then bit-shift to left by 1 place?

2. What is significant with calling the sintable[(spr->ang)&2047] with
2047 all the time?



Anyone's help most appreciated.
Tom Breton
2006-02-10 00:37:03 UTC
Permalink
Post by KevinGPO
I just programming Duke Nukem 3D source code and trying to understand
the drawing graphics routines. In the (game folder) game.c: main()
Haven't looked at them carefully enough to answer you.

[...]
Post by KevinGPO
1. What is significant with show2dsector[i>>3]&(1<<(i&7)) ? I see this
pattern all over the place to test/decide whether to show a map object
or not. However I do not understand why bit-shift to the right 3
places, and bitmask AND on 7, then bit-shift to left by 1 place?
I'm answering on the fly, so please excuse any misformatting.

He's using the lower 3 bits of "i" to select a bit in the rest of i.
Post by KevinGPO
2. What is significant with calling the sintable[(spr->ang)&2047] with
2047 all the time?
It masks out unwanted bits that are too high, thus it prevents the table from being accessed with too-large indexes by accident.


HTH.

Tom, the calm-eyed visionary

Loading...