Posted: Fri Aug 23, 2013 2:37 am
This is an incredible demo of raycasting on a stock MD. Great job! You did a great job of converting 286 code into 68000 code. And the texture conversion is awesome, too.


Sega Megadrive/Genesis development
http://gendev.spritesmind.net/forum/
Yes, the screen buffer is organized as tiles (starts from top to down then next column and so on) so i upload the whole screen in a single frame. First i disable the display, do the DMA and then enable the display again. When the display is disabled or during Vblank, DMA can move 205 bytes/scanline, so with 82 lines will be enough (82 * 205 = 16810).You said you don't need to double buffer, this is because you can upload the whole screen in VRAM in a single frame ? If that is the case i assume you prepare your screen buffer so it is directly organized as tiles so you can ue the full DMA speed to upload in VRAM ?
I guess you can somehow do direct write in tiled organization because of the way the raytracer work. I tried to find a way to organize my bitmap buffer in the SGDK bitmap engine but i really can't find anything working efficiently :-/ Modifying the organization would require too much overhead in bitmap drawing functions as line or polygon filling so i have to manually transform the bitmap in cell during the vram upload (software transfert). At least this has the advantage of not screwing up the Z80gasega68k wrote: Yes, the screen buffer is organized as tiles (starts from top to down then next column and so on) so i upload the whole screen in a single frame. First i disable the display, do the DMA and then enable the display again. When the display is disabled or during Vblank, DMA can move 205 bytes/scanline, so with 82 lines will be enough (82 * 205 = 16810).![]()
Oh i understand of course, the sound is pretty good given you have these sample limitations ! I developed a specific driver for the bad apple demo which take care of the DMA contention but it would not work in your case as you extend the vblank (i used vint on Z80 side to detect start of blank period). But now i'm thinking about it, if you limit your frame rate to 20 FPS max (which is smooth enough and it seems to never goes higher anyway) you can divide your DMA on 3 frames and then have complete screen display and an easier DMA contention with Z80... but that would require double buffering then :-/ ok, not a good idea :pAbout the sound: i made the song with tfm music maker and the 68000 is used to play the music with a tfc replayer that i made in asm, but using only 5 channels, thus i use the sixth channel to make two-channel samples with the z80. The samples are compressed 2 to 1 and is played directly in the z80 ram, the samples are played at about 6900hz and each channel can use 3584 bytes (about 1 second),the driver uses less than 1k. I did it this way because with DMA, the samples do not sound right, because you have to stop the z80 during DMA.
I have not tested this on real hardware, if anyone can do would be great.
Combination/permutation math . . . which I don't entirely know by heart, but it's easy enough to look up. Plus there's things like this:Stef wrote:Hey Kool Kitty, nice to see you therekool kitty89 wrote: For 16 colors, the maximum number of unique combinations (including 2 of the same color -ie the base 16 colors) would be 136, not 128. Though depending on the palette actually chosen (and the colors trying to be approximated) you can get as few as 64 useful psudo colors. (it's also limited to 120 colors max if none of the base 16 colors is useful -ie the max number of dithered pseudocolors)
I was not sure at all about my 128 number, i always impress me about how i can suck when it comes to simple math calculation. How does you arrive to 136 ? I counted 128 as i just eliminate swapped chunk (01 is same than 10) but as we don't eliminate 00 11 .. FF is does 136 ?
Chilly Willy and I got into a discussion at one point over whether dithered color like that would be adequate for Doom's textures. (in the context of doing a Doom conversion on SVP or Sega CD)Well i just tested the rom and i have admit the result is really great (and smooth) ! The used palette perfectly fit the original color and i believe we can use it to draw sprites as well without much color issuesPosterising the 256x18-bit VGA palette down to 12-bit and then dithering that to 9-bit (2 9-bit colors blend/accumulate to 12-bit) is a pretty straightforward route for this. Posterizing to 12-bit might actually drop the color count to within practical 16-color dither psudocolor limits too.
IMO it looks rather nice. Using Fusions CVBS filter makes for blur very similar to what you'd get from 1-pixel offset H-blur (it's single pass horizontal blending), and it looks very nice and solid. Using the TV-mode filter in Fusion is excessively blurry though. (it's 2-pass h-blur and doesn't help blending anyway for 2-pixel dither like this)I was thinking about it but it would make the image a bit blurry, no clean edge for walls...
What sort of compression are you using? 4-bit DPCM or ADPCM? (I assume not just 4-bit linear PCM)gasega68k wrote:About the sound: i made the song with tfm music maker and the 68000 is used to play the music with a tfc replayer that i made in asm, but using only 5 channels, thus i use the sixth channel to make two-channel samples with the z80. The samples are compressed 2 to 1 and is played directly in the z80 ram, the samples are played at about 6900hz and each channel can use 3584 bytes (about 1 second),the driver uses less than 1k. I did it this way because with DMA, the samples do not sound right, because you have to stop the z80 during DMA.
I have not tested this on real hardware, if anyone can do would be great.
Could you possibly use a combination of vblank interrupt and YM2612 timers for working around extended vblank?Stef wrote:Would it help if you made a polygon renderer that used column filling rather than line filling?gasega68k wrote: I guess you can somehow do direct write in tiled organization because of the way the raytracer work. I tried to find a way to organize my bitmap buffer in the SGDK bitmap engine but i really can't find anything working efficiently :-/ Modifying the organization would require too much overhead in bitmap drawing functions as line or polygon filling so i have to manually transform the bitmap in cell during the vram upload (software transfert). At least this has the advantage of not screwing up the Z80
That'd be a pain to do for full-res 4-bit pixels, but more useful if you were willing to use paired pixels (bytes) like this set-up does. You'd lose resolution, but gain speed. (and could consider dithered color like this too)
Oh i understand of course, the sound is pretty good given you have these sample limitations ! I developed a specific driver for the bad apple demo which take care of the DMA contention but it would not work in your case as you extend the vblank (i used vint on Z80 side to detect start of blank period). But now i'm thinking about it, if you limit your frame rate to 20 FPS max (which is smooth enough and it seems to never goes higher anyway) you can divide your DMA on 3 frames and then have complete screen display and an easier DMA contention with Z80... but that would require double buffering then :-/ ok, not a good idea :p
Yeah i know it is simplistic combinations but still sometime i really have hard time to figure them :pkool kitty89 wrote: Combination/permutation math . . . which I don't entirely know by heart, but it's easy enough to look up. Plus there's things like this:
http://www.mathsisfun.com/combinatorics ... lator.html
...
Also, 16 of those colors must be 9-bit only, since they're the base colors used in the palette. (you get 120 pseudo 12-bit colors)
Raw permutations are easy here: 16 values, 2 chosen, order important, repetition allowed, so just 16^2=256.
Good to know how much the dot clock can affect the pixel blending... anyway we can't really rely on it depending the signal you use (composite, s video or RGB) the pixels won't blend the same at all, i prefer to explicitly do the blend operation with the H scroll change at each frame tech for instance so you know you have the effect whatever is the outputAnd that's what you could get for actual composite video artifact colors where the dot clock is an integer multiple of colorburst -like 7.16, 10.74, or 14.32 MHz NTSC
....
dithered transparent meshes like Chemical Plant Zone or the white explosion clouds in Earthworm Jim 2 over the dark BGs of many levels in that game)
I agree, i don't know if it's the way gasega68k did his palette but i guess it the way to get a very strong onePosterising the 256x18-bit VGA palette down to 12-bit and then dithering that to 9-bit (2 9-bit colors blend/accumulate to 12-bit) is a pretty straightforward route for this. Posterizing to 12-bit might actually drop the color count to within practical 16-color dither psudocolor limits too.
Haha a doom port on Sega CD would be awesome, probably a bit laggy though :p But yeah having a good base palette is *very* important and actually does the difference, Duke 3D could look far better with a better base palette.Chilly Willy and I got into a discussion at one point over whether dithered color like that would be adequate for Doom's textures. (in the context of doing a Doom conversion on SVP or Sega CD)
It would probably be a bit more extreme than Wolf3D's palette, but I still think that could work OK. (similar context of truncating/posterizing the 256 color 18-bit palette down to 12-bit and then using 16-color 9-bit to approximate those colors)
But don't you think that swapping pixels chunk at each frame would produce a better result that simple H pixel scroll ? This way you don't blend different "object" pixels together. Of course technically it is not as easy to do than the H scroll..IMO it looks rather nice. Using Fusions CVBS filter makes for blur very similar to what you'd get from 1-pixel offset H-blur (it's single pass horizontal blending), and it looks very nice and solid. Using the TV-mode filter in Fusion is excessively blurry though. (it's 2-pass h-blur and doesn't help blending anyway for 2-pixel dither like this)
...
Honestly, this demo looks even better with single pass H-blur than Duke 3D or Zero Tolerance. (better color usage in general)
Well i have to keep "linear memory" polygon fill to have the algo as fast as possible but anyway if we assume the scene to be 90° rotated we obtain the same result than a column filling renderer... still i don't see how that help with DMA. DMA is actually always doing *word* source memory read (even if internally it can does byte write operation when destination is VRAM) so i don't see how you can arrange tilemap and address increment register to transform the bitmap buffer (even 90° rotated) to tiles :-/Would it help if you made a polygon renderer that used column filling rather than line filling?
I could indeed make my polygon fill faster if i do byte alignment for filling operation but that reduce the X resolution and look really... "low resolution" compared to X full res.That'd be a pain to do for full-res 4-bit pixels, but more useful if you were willing to use paired pixels (bytes) like this set-up does. You'd lose resolution, but gain speed. (and could consider dithered color like this too)
You are right, that is totally possibleCould you possibly use a combination of vblank interrupt and YM2612 timers for working around extended vblank?
...
To maximize usable CPU time per frame, you'd also probably want to set different timing for 50 and 60 Hz, or set the display taller in 50 Hz so the extended vblank period is of an equal scanline count. Ie sync to v-int in either case, but make sure the actual vblank period is equal on both, so if 60 Hz has screen cut to 176 lines with 86 vblank lines, you'd want the 50 Hz screen to be set to 226 lines, and positioned such that the same timer set-up code would work. You could still leave that added space black, of course, or just tiled with a repeating 8x8 texture. (still, PAL uses slightly faster h-sync timing than NTSC, so that's a consideration too -iirc it's 15.65 vs 15.75 kHz)
Wait . . . does the v-int signal the normal start of vblank, or end of vblank?
. . . Well, in any case, the generall idea (interval timer combined with v-int) would still apply, just some of my above comments won't make sense.
Doom uses colormaps for shading, so it's just a matter of doing new palettes (regular, hurt, rad suit, and invincible palettes), and new colormaps for the shading.Stef wrote:Yeah doom use shade level, we cannot reproduce it the same way but Toy Story is actually using 3 shade levels for his 3D level and that does look greatPalette is really heavily turned around gray, purple and green colors though.
It was slight overkill to make DAMN sure the color was right. It's only an Apple 2, so it was hardly a tax on the speed. If you're gonna do it, do it right!I know that we can have more than 2 adjacent pixels for color dithering, but as you said, for simplicity reason we only assume 2 pixels chunk .
7 adjacent pixels sounds insane :p
I was talking about the depth shading, on MD we could not reproduce the same smooth shade but i guess we could get something not too badChilly Willy wrote: Doom uses colormaps for shading, so it's just a matter of doing new palettes (regular, hurt, rad suit, and invincible palettes), and new colormaps for the shading.
That is the way to doIt was slight overkill to make DAMN sure the color was right. It's only an Apple 2, so it was hardly a tax on the speed. If you're gonna do it, do it right!
So was I. On Doom, to draw at a particular shade, they merely pick 1 of 32 colormaps, each one presenting a particular shade. The colormap takes the texture pixel value as an index, and gives the new value that points to the same color at the proper shade in the same palette (assuming there is one). At really low light levels, many of the colors are pointed to the same values, giving the unsaturated look to dim parts of the level.Stef wrote:I was talking about the depth shading, on MD we could not reproduce the same smooth shade but i guess we could get something not too badChilly Willy wrote: Doom uses colormaps for shading, so it's just a matter of doing new palettes (regular, hurt, rad suit, and invincible palettes), and new colormaps for the shading.Of course others effects are just different palette