Page 1 of 2
3d - no graphics
Posted: Wed Jun 24, 2009 1:06 pm
by VolTeK
i was wondering if any one has tried making 3-d boxes out of characters, no graphics, no plotting pixels? sound cool, but worth it? or would it look like a wreck on the screen, if not (if it doesnt look bad on the screen) it sounds like a good challenge to be taken upon.
Re: 3d - no graphics
Posted: Wed Jun 24, 2009 1:11 pm
by NickJohnson
I think I've seen it done before. You can either use filled in or shaded "characters" sort of like pixels, or do an ASCII-art style thing (which is definitely more complex). I'm not sure how well the ASCII-art kind of thing would work on the PC text console though - nothing matches up correctly, most notably the slashes and backslashes.
Either way, it would be hard to give much of a 3D impression, but you could do some sort of low-res 2D vector graphics. Or just write a VGA driver. Your choice.
Re: 3d - no graphics
Posted: Wed Jun 24, 2009 1:14 pm
by VolTeK
i think i would go with 2D, but im not using slashes, i am using boxes (looks better to me).
Re: 3d - no graphics
Posted: Wed Jun 24, 2009 1:30 pm
by NickJohnson
I mean, it's really just a matter of resolution. If all you're doing is making Tetris, text mode graphics are perfect. But if you want to do something actually graphical, you are probably going to be much happier with VGA mode in the end. It would be sort of interesting to try and make 3D graphics with text mode, but you would get generally crappy pictures of simple objects at best - nothing much beyond proof-of-concept stuff. It's like how you *can* make a car with square wheels, but you're not going to be able to sell it to anyone.
Re: 3d - no graphics
Posted: Wed Jun 24, 2009 2:11 pm
by Combuster
From the archives of one wretched programmer:
Like this?
Re: 3d - no graphics
Posted: Wed Jun 24, 2009 2:22 pm
by Troy Martin
Combuster: It would work loads better in 8x8 mode
square "pixels" ftw!
Re: 3d - no graphics
Posted: Wed Jun 24, 2009 2:26 pm
by Combuster
This does 8x9 pixels with a 16x9 font. No VGA code, always works
Re: 3d - no graphics
Posted: Wed Jun 24, 2009 2:27 pm
by Troy Martin
Hehe. Although it appears that the top half of the "pixels" are actually a real pixel shorter than the bottom half. In 8x8 it's like 320x200 just blown up. A lot.
Re: 3d - no graphics
Posted: Wed Jun 24, 2009 2:55 pm
by earlz
You could always use a font set(if you configure it right, you can choose from 512 characters, but only 8 colors) perfected for such a thing, or make one yourself, all it is is a bitmap font.
*pulls out old pmode adapted geezer code from JouleOS(2006)
Code: Select all
void set_plane(unsigned p)
{
unsigned char pmask;
p &= 3;
pmask = 1 << p;
/* set read plane */
outportb(VGA_GC_INDEX, 4);
outportb(VGA_GC_DATA, p);
/* set write plane */
outportb(VGA_SEQ_INDEX, 2);
outportb(VGA_SEQ_DATA, pmask);
}
void write_regs(unsigned char *regs)
{
unsigned i;
/* write MISCELLANEOUS reg */
outportb(VGA_MISC_WRITE, *regs);
regs++;
/* write SEQUENCER regs */
for(i = 0; i < VGA_NUM_SEQ_REGS; i++)
{
outportb(VGA_SEQ_INDEX, i);
outportb(VGA_SEQ_DATA, *regs);
regs++;
}
/* unlock CRTC registers */
outportb(VGA_CRTC_INDEX, 0x03);
outportb(VGA_CRTC_DATA, inportb(VGA_CRTC_DATA) | 0x80);
outportb(VGA_CRTC_INDEX, 0x11);
outportb(VGA_CRTC_DATA, inportb(VGA_CRTC_DATA) & ~0x80);
/* make sure they remain unlocked */
regs[0x03] |= 0x80;
regs[0x11] &= ~0x80;
/* write CRTC regs */
for(i = 0; i < VGA_NUM_CRTC_REGS; i++)
{
outportb(VGA_CRTC_INDEX, i);
outportb(VGA_CRTC_DATA, *regs);
regs++;
}
/* write GRAPHICS CONTROLLER regs */
for(i = 0; i < VGA_NUM_GC_REGS; i++)
{
outportb(VGA_GC_INDEX, i);
outportb(VGA_GC_DATA, *regs);
regs++;
}
/* write ATTRIBUTE CONTROLLER regs */
for(i = 0; i < VGA_NUM_AC_REGS; i++)
{
(void)inportb(VGA_INSTAT_READ);
outportb(VGA_AC_INDEX, i);
outportb(VGA_AC_WRITE, *regs);
regs++;
}
/* lock 16-color palette and unblank display */
(void)inportb(VGA_INSTAT_READ);
outportb(VGA_AC_INDEX, 0x20);
}
static void vmemwr(unsigned dst_off, unsigned char *src, unsigned count)
{
memcpy(dst_off|0xB8000, src, count);
}
void write_font(unsigned char *buf, unsigned font_height) //buf is pointer to our font.
{
unsigned char seq2, seq4, gc4, gc5, gc6;
unsigned i;
/* save registers
set_plane() modifies GC 4 and SEQ 2, so save them as well */
outportb(VGA_SEQ_INDEX, 2);
seq2 = inportb(VGA_SEQ_DATA);
outportb(VGA_SEQ_INDEX, 4);
seq4 = inportb(VGA_SEQ_DATA);
/* turn off even-odd addressing (set flat addressing)
assume: chain-4 addressing already off */
outportb(VGA_SEQ_DATA, seq4 | 0x04);
outportb(VGA_GC_INDEX, 4);
gc4 = inportb(VGA_GC_DATA);
outportb(VGA_GC_INDEX, 5);
gc5 = inportb(VGA_GC_DATA);
/* turn off even-odd addressing */
outportb(VGA_GC_DATA, gc5 & ~0x10);
outportb(VGA_GC_INDEX, 6);
gc6 = inportb(VGA_GC_DATA);
/* turn off even-odd addressing */
outportb(VGA_GC_DATA, gc6 & ~0x02);
/* write font to plane P4 */
set_plane(2);
/* write font 0 */
for(i = 0; i < 256; i++)
{
vmemwr(16384u * 0 + i * 32, buf, font_height);
buf += font_height;
}
#if 0
/* write font 1 */
for(i = 0; i < 256; i++)
{
vmemwr(16384u * 1 + i * 32, buf, font_height);
buf += font_height;
}
#endif
/* restore registers */
outportb(VGA_SEQ_INDEX, 2);
outportb(VGA_SEQ_DATA, seq2);
outportb(VGA_SEQ_INDEX, 4);
outportb(VGA_SEQ_DATA, seq4);
outportb(VGA_GC_INDEX, 4);
outportb(VGA_GC_DATA, gc4);
outportb(VGA_GC_INDEX, 5);
outportb(VGA_GC_DATA, gc5);
outportb(VGA_GC_INDEX, 6);
outportb(VGA_GC_DATA, gc6);
}
Re: 3d - no graphics
Posted: Wed Jun 24, 2009 3:05 pm
by Combuster
If you allow something as complex as font reprogramming, you could just as well use graphics mode. Besides, you can only put two pixels in a character cell since that's the amount of color data you can put in the text buffer.
Speaking of which, for the best results, set a 4x8 font with codepage 437 and then use the left-right pair of box-drawing characters. Again, setting mode 13 is easier.
Re: 3d - no graphics
Posted: Wed Jun 24, 2009 3:32 pm
by VolTeK
Combuster wrote:Like this?
yes thats it, i want to construct a macro that the user can just put in some parameters and make a shape like that and give it an effect to make it at an angle or some kind a 3-d effect, it would ask the user for a color for each side of the shape depending upon how many sides there will be, but at the momen, i havent come up with even making a window with one macro, (i make my windows line by line, but with a macro to make each line)
untill i can create the whole (one macro does it all) effect on a window i will start on this project
Re: 3d - no graphics
Posted: Thu Jun 25, 2009 4:21 am
by Combuster
having a putpixel for any (80x50x3 included) resolution just works
Re: 3d - no graphics
Posted: Thu Jun 25, 2009 7:00 am
by Love4Boobies
GhostXoPCorp wrote:Combuster wrote:Like this?
yes thats it, i want to construct a macro that the user can just put in some parameters and make a shape like that and give it an effect to make it at an angle or some kind a 3-d effect, it would ask the user for a color for each side of the shape depending upon how many sides there will be, but at the momen, i havent come up with even making a window with one macro, (i make my windows line by line, but with a macro to make each line)
untill i can create the whole (one macro does it all) effect on a window i will start on this project
You keep mentioning macros... Sometimes function calls might be a better idea than macros (like in the 2 cases mentioned above).
Re: 3d - no graphics
Posted: Thu Jun 25, 2009 8:34 am
by gravaera
I understand what you're saying. That may or may not be useful during the absolute earliest stages of development, but if I were you, I'd concentrate on altering the charset od the driver (plane 0, 1, etc) to create a Text User Interface. (Google it)
It's a lot more efficient, and less stressful once you get past the reprogramming part. And you could use it for stylish bootup screens and whatnot, and other UI services that you may need before you initialize GFX mode.
Anyway: wish you luck.
Re: 3d - no graphics
Posted: Thu Jun 25, 2009 6:26 pm
by VolTeK
You keep mentioning macros... Sometimes function calls might be a better idea than macros (like in the 2 cases mentioned above).
i was going to put macro this, macro that after every thing, i know i used macro to many times, but what else was i going to use, i am an assemby programmer, never was much in to any other language, i figured macro was the proper way to say it.
sorry if that is a little annoying, i thought it was myself.
isnt a function call in assembly
call <function>
a macro is
<function> thats why i use macros, it easier to me to use, less time to type the extra stuff(makes me a little bit lazy)
but what ever works