Archived

This topic is now archived and is closed to further replies.

ASCII Fishtank Mini Contest!

Recommended Posts

I''ve been doing a test run at things since I''ve never done anything in ascii before (besides the typical enter data program). Right now I''m using djgpp for simplicity, and using the functions gotoxy(), putch(), clrscr(), etc. I know there is a faster way. Can someone point me in the right direction? I tried the asm posted above, but I just don''t have the patience to get that to work in djgpp... Would creating a pointer to that location in memory work?

Always remember, you''''re unique. Just like everyone else.

Share on other sites
Do what Micalson says below
       .-.       | |     __| |__     \     /      \   /       \ /        v

[edited by - TwistedMatrix on October 29, 2002 9:32:53 PM]

Share on other sites
quote:
Original post by Greven
I''ve been doing a test run at things since I''ve never done anything in ascii before (besides the typical enter data program). Right now I''m using djgpp for simplicity, and using the functions gotoxy(), putch(), clrscr(), etc. I know there is a faster way. Can someone point me in the right direction? I tried the asm posted above, but I just don''t have the patience to get that to work in djgpp... Would creating a pointer to that location in memory work?

Always remember, you''re unique. Just like everyone else.

Yes. Just forget the asm stuff you saw at the beginning of the post and concentrate on the video info at the bottom. The raw data for the textmode display is mapped to memory location B800:0000 (segment B800). The data stored there is organized into records of 2 bytes each. The first byte in each record is the ASCII character, the second byte is the color (lowest bits are foreground, middle are background and the top bit is for the blink attribute). You could either assign a point to that directly or allocate a back buffer and copy it to that location (which would avoid flickering if your app does a lot of erasing and redrawing)

Share on other sites
quote:
Yes. Just forget the asm stuff you saw at the beginning of the post and concentrate on the video info at the bottom. The raw data for the textmode display is mapped to memory location B800:0000 (segment B800). The data stored there is organized into records of 2 bytes each. The first byte in each record is the ASCII character, the second byte is the color (lowest bits are foreground, middle are background and the top bit is for the blink attribute). You could either assign a point to that directly or allocate a back buffer and copy it to that location (which would avoid flickering if your app does a lot of erasing and redrawing)

thanks! (seriously) I didn''t even know about the blinking attribute until you just said somthing... I probly wont do very well in this compo since this is my first full-scale c/c++ project. But I am learning alot as I go.

eg. I just figure out what -> is used for.

-= Twisted Matrix =-

Share on other sites
Trying to figure out a good way to access the text memory buffer. (still using djgpp) I found dosmemput() in go32, and that appears to be a nice function where I can give it my buffer of data, it''s length (in bytes), and the offset to put it at. Would this work well? Otherwise, how would I create a pointer to point to a specific memory location without MK_FP... It''s been *way* to long since I''ve done DOS programming

Always remember, you''''re unique. Just like everyone else.

Share on other sites
it''s *that* simple :
char far * PT_VIDEO = (char far *)0xb8000000;

Gee, I wish I had a bit of time to submit an entry, it''s *SO* the kind of things I like to do !!! arrrrrrrh

Sancte Isidore ora pro nobis !

Share on other sites
quote:
Original post by TwistedMatrix
urm? If you are compiling your program with BC.exe, your program will likely already have bugs. might want to try the compiler/linker from VBDOS. syntax is the same, but less buggy than the qb45 compiler.

Didn''t realise that it was buggy. Haven''t encoutered any bugs in anything that I''ve written yet, so maybe it is only with certain commands.
quote:
PS> using LOCATE and PRINT, your video will have to be updated 2000 to 4000 (if using 80x50) times a loop. I imagine that will be a problem for you. Then again, mabey not.

That''s true with almost any method - a loop will be needed. I can probably use a smaller window or different systems. Who says the fish have to be fish-shaped?

--Thomas McCorkell

Just what is Karma? Is it a way to rate people? A way of assigning privilege levels? Or is karma just an anti-spam system?

Share on other sites
quote:
Original post by ahw
it''s *that* simple :
char far * PT_VIDEO = (char far *)0xb8000000;

Nope. Sorry djgpp doesn''t know what far is. That''s the problem I''m having. How do you assign a far pointer in djgpp?

Always remember, you''''re unique. Just like everyone else.

Share on other sites
quote:

DJGPP is a complete 32-bit...

It would appear DJGPP uses protected mode, in which case there is no such thing as near (same segment) and far (different segment).

Share on other sites
Should the fish tank have food in it? What if one of the fish dies? What should happen then? Another thing, can I put a big fish in the tank that eats all of the other fish? Actually I want to put an electric eel in the tank... that would be cool!

Share on other sites
A little warning to anybody else thinking of using QuickBASIC...
Don''t bother going to the MSDN site . As far as they are concerned, QuickBASIC does not exist. It is a figment of your imagination.
A site I found which covers QuickBASIC is QB45.com.
Hope this helps anyone thinking of using QuickBASIC.

--Thomas McCorkell

Six inches tall, and armed to the teeth, a fine soldier he made
And his name was Boggy B.
~ the Wormsong

Share on other sites
quote:
Original post by Greven
Nope. Sorry djgpp doesn't know what far is. That's the problem I'm having. How do you assign a far pointer in djgpp?

Always remember, you're unique. Just like everyone else.

You need to disable protection, like so:

  #include <sys/nearptr.h>__djgpp_nearptr_enable();  textmemory=(char *)(0xb8000 + __djgpp_conventional_base);__djgpp_nearptr_disable();

Also, to use assembly in DJGPP do this (this is a conversion of the assembly code I posted on the previous page):

  union REGS regs;regs.h.ax = 0x1202;	  regs.h.bl = 0x30;	  int86(0x10,&regs,&regs);regs.h.ax = 0x3;	  	  int86(0x10,&regs,&regs);regs.h.ax = 0x1110;	  regs.h.bx = 0x800;	  regs.h.cx = 0xA;	  regs.h.dx = 0x0;	  int86(0x10,&regs,&regs);

[edited by - michalson on October 30, 2002 4:09:30 PM]

Share on other sites
-> Greven <-
Im a newbie 2, i am using DJGPP also for this compo and would be happy to help you get started.

I have MSN messenger. My handle is 'camos85@hotmail.com' which you can add (If you have it), if not you should probly go get it, its alot smaller than ICQ (2.somthing MB's)

I am in the process of switching emails (I have had the same one for 5 years and its gets alot of SPAM) or i would give you my email address.

ttyl

[edited by - TwistedMatrix on October 30, 2002 4:21:26 PM]

Share on other sites
quote:
Original post by Anonymous Poster
Should the fish tank have food in it? What if one of the fish dies? What should happen then? Another thing, can I put a big fish in the tank that eats all of the other fish? Actually I want to put an electric eel in the tank... that would be cool!

Anything you want, being creative is all part of the contest.

Share on other sites
Why don''t use guys make the fish tank program using a console
program. That would be a lot easier... wouldn''t it?

Share on other sites
quote:
-michalson wrote
Also, to use assembly in DJGPP do this (this is a conversion of the assembly code I posted on the previous page):

union REGS regs;regs.h.ax = 0x1202; regs.h.bl = 0x30; int86(0x10,®s,®s);regs.h.ax = 0x3; int86(0x10,®s,®s);regs.h.ax = 0x1110; regs.h.bx = 0x800; regs.h.cx = 0xA; regs.h.dx = 0x0; int86(0x10,®s,®s);

Um, lets not confuse the guy anymore than he already is. That is not assembly. It''s a software interrupt function. they are not even close to being the same thing.

-= Twisted Matrix =-

Share on other sites
quote:
Original post by TwistedMatrix
Um, lets not confuse the guy anymore than he already is. That is not assembly. It''s a software interrupt function. they are not even close to being the same thing.

-= Twisted Matrix =-

They are exactly the same thing. The usage of software interrupts is a hardwired feature of the x86 cpu though the INT and IRET opcodes and the interrupt vector lookup table. The earlier example I posted was of the real assembly to use those interrupts, and as I stated the above was a conversion to use DJGPP''s abstraction layer, which while not true assembly code is designed to allow the programmer to access the platform dependent x86 registers and some of its opcodes (such as the INT opcode).

Share on other sites
quote:
Original post by TwistedMatrix
Im a newbie 2, i am using DJGPP also for this compo and would be happy to help you get started.

Just to clear the air, I''m not a newbie I do MFC/Win32, but it''s been about 7 years since I''ve touched DOS programming. And at work now I don''t have Visual Studio like at home so I''m using djgpp (new thing for me). Just thought I''d clarify

Michalson, You sir, are a god. Plain and simple. Thanks!

Always remember, you''''re unique. Just like everyone else.

Share on other sites
Do any of you realize that DevC++ and VC++ have conio? No need for QB or DJGPP here in my mind...

Share on other sites
Ok… let me clarify

In DJGPP

First to set 80x50 text mode and get a pointer to the memory

      #include <sys/nearptr.h>int main(){//set 80x50 union REGS regs;regs.h.ax = 0x1202;	  regs.h.bl = 0x30;	  int86(0x10,®s,®s);regs.h.ax = 0x3;	  	  int86(0x10,®s,®s);regs.h.ax = 0x1110;	  regs.h.bx = 0x800;	  regs.h.cx = 0xA;	  regs.h.dx = 0x0;	  int86(0x10,®s,®s);//get pointer to screen__djgpp_nearptr_enable();  textmemory=(char *)(0xb8000 + __djgpp_conventional_base);__djgpp_nearptr_disable();return 0;}

Is this right?
And also is there any thing I have to clean up before I exit (Like set it back into standard screen mode?)

Thanks for any help

[edited by - Abob on October 30, 2002 10:39:51 PM]

[edited by - Abob on October 30, 2002 10:40:47 PM]

Share on other sites
Greven, i was using ''newbie'' in a general sense. Dont take it to offense. (I have also been a programmer for 4 years) Im just new to Win32 and pmode programming.
Anyways, Im glad you figured out what you needed. I am doing it a different way. I didnt know about that FAR heap ptr thingine until now (Still dont know really). Let me know if I can help (I will let EVERYONE know when I need help you can be sure of that! )

>> Michalson
Dude using INT86 is basicly just the same thing as calling some inline assembly to preform a sofware int, I know this. But you said and I quote: "Also, to use assembly in DJGPP do this"
Some assemblers can have up to 100''s of opcodes. INT86 does not allow use of all these opcodes. It has a specific function.

Not that it matters, but since you made a big deal out of It...

-= Twisted Matrix =-

Share on other sites
quote:
Original post by Abob
Is this right?
And also is there any thing I have to clean up before I exit (Like set it back into standard screen mode?)

Thanks for any help

If you want to be nice and neat about it (won''t really matter under Windows since it closes when you are done) you could set the screenmode back to 80x25 by using:

regs.h.ax = 0x3;
int86(0x10,&regs,&regs);

Share on other sites
quote:
Original post by AtelierVisca
But I agree that Michalson is keeping a pretty tight lip on his technique...

Mua-ha-ha

www.coldcity.com
code, pics, life

Share on other sites
quote:
Original post by IainC
Mua-ha-ha

www.coldcity.com
code, pics, life

Boo! You should kept that until after the competion. Besides, you''re using a round about method. Since you are simply calculating the difference in RGB color space it would be easier to just code colorDifference=Sqr(R1-R2)+Sqr(G1-G2)+Sqr(B1-B2). Of course there is another method that will give more accurate results than your RGB color space comparision.

Share on other sites
quote:
Original post by Michalson
Boo! You should kept that until after the competion. Besides, you''re using a round about method. Since you are simply calculating the difference in RGB color space it would be easier to just code colorDifference=Sqr(R1-R2)+Sqr(G1-G2)+Sqr(B1-B2). Of course there is another method that will give more accurate results than your RGB color space comparision.

Why don''t you share this other technique? Hell, I''ll even withdraw from the contest if you think I''m going to use it for the fishtank... I''m really just curious as to how it all works, not in using it against contestants.

To quote myself from an earlier post: the ascii renderer would require the fish to be huge so that they didn''t show up as little blurred blobs.

- James

Share on other sites
This topic is now closed to further replies.

• Forum Statistics

• Total Topics
628362
• Total Posts
2982266

• 10
• 9
• 13
• 24
• 11