News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Dont Thread The BOX!

Started by StatusQuo, December 07, 2011, 05:45:04 PM

Previous topic - Next topic

StatusQuo

Hey guys, I appreciate all the work that goes through here, and so far in my school semester I have been having a complete ballfield with Assembly Language. Now I just ran into an ultimate wall. So as a last minute final my professor decides to give us an assignment where i am supposed to make a BOX within DOS, that must have a title. For the first time in my life, I don't know what to do. When I approached the professor about this, he said to me, "Well a good programmer doesn't know what to do. But a bad programmer knows what to do." which left me at a  :eek ??? So anyways, long stories short, I have been seeking templates and examples of how to create a box inside the DOS box. I saw one thread here that actually made a blue DOS box, but for me it is a horrible example, simply because the coding is 16Bit,  I need to make a 32Bit coding and I seriously have no approach. This is the first time where I am actually clueless and the shrimp of my professor wants me to fail so i can come back to college and pay another 750 bucks, no thank you. If i have to read 400 pages on how to make a box then I will do it, but I guess what I'm asking for here, is not answers, but direction. Would anyone be kind enough to point to me how to even begin phase 1 of this final that i have to do?
Then God sad, "In the beginning....There was SCOPE!", Then I asked, "What is Scope?", and God said...."A Stack Frame, geeze I forgot to include you with common sense, BUT a prototype you are, too wierd to live, to rare to die...", and it was written....

dedndave

it isn't hard at all
in console mode, you are using the old IBM character set (sometimes refered to as OEM char set or "Terminal" font)
it includes "line graphics" characters for drawing single and double outline boxes, as well as filled and dithered boxes
these characters are all chr$(128) and above
there are also several other interesting graphics characters

http://telecom.tbi.net/asc-ibm.html

StatusQuo

dendave to my rescue as usual  :U . Okay i get it, so basically its ASCII characters made up of lines and blocks, yet i would ASSUME in order to do that, one would have to write a PROC that finds the cursor, and from there just draw lines and innner boxes, am I right?
Then God sad, "In the beginning....There was SCOPE!", Then I asked, "What is Scope?", and God said...."A Stack Frame, geeze I forgot to include you with common sense, BUT a prototype you are, too wierd to live, to rare to die...", and it was written....

dedndave

well - you can clear the screen, knowing that the position is 0,0 afterward   :P
but - there are also functions for getting and setting the cursor position, as well

to get the cursor position:
GetConsoleScreenBufferInfo
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683171%28v=vs.85%29.aspx

to set the cursor position:
SetConsoleCursorPosition
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686025%28v=vs.85%29.aspx

properly clearing the console screen involves using:
GetConsoleScreenBufferInfo
FillConsoleOutputCharacter
FillConsoleOutputAttribute
ScrollConsoleScreenBuffer
SetConsoleCursorPosition

there are a number of ways to do it, of course
a simple version might just fill the buffer with spaces and set the position
i think the masm32 package has a macro for this - not sure, as i never used it   :P

you can create strings using DB like so

DblHorzLine db 0CDh, 0CDh, 0CDh, 0CDh, 0

or, you can create the entire box in a memory buffer then display it a set of text lines
this is probably the method i would use

a while back, Frank and Alex were writing a program called "TestBed"
you can use the forum search tool to find some info
Frank created the box in a data file
then, when the program was run, he loaded the data file and displayed it


StatusQuo

Dave I kind of lost you when you mentioned this term:

"or, you can create the entire box in a memory buffer then display it a set of text lines
this is probably the method i would use"

Could you possibly explain that in a little bit more detail.
Then God sad, "In the beginning....There was SCOPE!", Then I asked, "What is Scope?", and God said...."A Stack Frame, geeze I forgot to include you with common sense, BUT a prototype you are, too wierd to live, to rare to die...", and it was written....

dedndave

sure
you create an empty buffer in memory
you can do this either by defining bytes in the uninitialized data section,
or by allocating memory using one of the API functions

then, you can write a simple loop to generate a series of characters for the lines at the correct addresses
fill in the corners with the appropriate characters and you haveĀ  box

for a beginner, it is probably simpler to just use DB and create the lines
your professor probably doesn't care which method you use, so long as a box appears

give me a little time - i will write a simple example...

StatusQuo

Thank you, I am going to take some little time to brain storm this and just write it out rashly, how ever it comes to mind before organization and testing. I shall return. Also,  I was wondering, the minute my professor told the class about this, a word popped in my head that I havent seen since Java. I want to go out with a bang with this professor because he is a bigot, and he makes his bigotry known. Since i am one of the three spics in the class, i figured I would give him two versions of the final, his way, and a little hit different version. I was wondering, if it is possible to make a box with the title and its lovely perks, through Inheritance. I am familiar with the term inhertience being, correct me if I am wrong, to create an object using the data off of another. My mind has been circling that threory and I guess I am jogging at the moment, one thing at a time, but i just have to ask.  :clap:
Then God sad, "In the beginning....There was SCOPE!", Then I asked, "What is Scope?", and God said...."A Stack Frame, geeze I forgot to include you with common sense, BUT a prototype you are, too wierd to live, to rare to die...", and it was written....

dedndave

here - this is pretty easy   :P

dedndave

not too sure about the "inheritance" thing
if you want to use 2 methods, use one that defines the box with DB and another with loops
you see, if the box is defined with data, the EXE can get pretty large for larger boxes
the loop method is more efficient in terms of size
even more efficient (in terms of memory usage) is to write the loops so they output directly to the screen
although, the later may be a bit sluggish

StatusQuo

So then suppose if I wanted to make a cheap programmers box border, where you would have one box over lapping the other, and the difference may come in when the box is slightly smaller than the original, to make it seem like a border,  would that be even sluggier? It would inherit simuliar data, with the negate of size being adjusted, kind of like an instance or interrupt but EHH, you see i toggle this question in my head all day.
Then God sad, "In the beginning....There was SCOPE!", Then I asked, "What is Scope?", and God said...."A Stack Frame, geeze I forgot to include you with common sense, BUT a prototype you are, too wierd to live, to rare to die...", and it was written....

dedndave

a really good approach might be to write a procedure that creates boxes of different sizes
you could pass the upper left corner X, Y, width, and height as parameters
that would make a re-usable function which could be handy

after a call, you would have to position the cursor and write the title text
so - a good feature of the function might be to position the cursor in the left-most space of the title area
you can use the passed X and Y parameters
position the cursor at X+1,Y+1

StatusQuo

That would be a good one, as a reply to your example, it is very good actually, I was on the right track, but suppose if I set the cursor again inside the box for typing, I know that would require me to reposition the cursor, and set a boundry so that it doesnt overflow. Would i be in the right track with that idea, or am I missing some sort of noobish alternative?
Then God sad, "In the beginning....There was SCOPE!", Then I asked, "What is Scope?", and God said...."A Stack Frame, geeze I forgot to include you with common sense, BUT a prototype you are, too wierd to live, to rare to die...", and it was written....

baltoro

STATUS QUO,
Inheritance is, I think, a paradigm existing in higher programming languages, such as C or C++.
You could probably simulate it in assembly language,...but, it would be kind of silly.

...And,...
Quote from: STATUS QUO...dedndave to my rescue as usual ,...
Dave is famous for this. I can't tell you how many times I've suggested some completely inadequate technique to someone's Campus Forum problem,...only to have DAVE post the correct solution within milliseconds. He's almost infallible,...in fact, I think he screws up an answer every so often just to mislead us into thinking he's normal.

In my opinion, your assembly programming professor is teaching you obsolete stuff. If you do a serious search of past posts here at the MASM Forums, you will discover that it is the Mother Lode of cutting-edge assembly programming techniques.
Baltoro

StatusQuo

I suppose so, I have done searches upon it, and i have seen simular templates of the like, but for this professor, he has a method where, IF YOU DONT DEGRADE THE PROGRAM TO THE ABSOLUTE BASIC, AND NOT USE IRVINE'S RULES, YOU WILL UNDERSTAND THE METHODS BETTER, AND HOW THINGS WORK, SO EVERTHING MUST BE DOWNGRADED, and for a 4 credit class that I need for Grad, I have to put up with his stupid rules and regulations. I figured just to draw a box would be too simple, that was my theory until I actually had to write it, and dave gave me good direction. Yet with this man he likes to give ME in particullar, last minute changes, so right now I concider this a Box with open options, as I type this, I am making the box multi-colored, another one with a different color border, and later the one that might give me trouble, is a box where I can type into, just to be prepared. I should have dropped the class when i felt that this professor doesnt like me, but I dont want to wait 6 months and pay an extra $500 for this class again. So i have been dealing with him fine until this final came up, where I figured he might try something against me, and he kind of has.
Then God sad, "In the beginning....There was SCOPE!", Then I asked, "What is Scope?", and God said...."A Stack Frame, geeze I forgot to include you with common sense, BUT a prototype you are, too wierd to live, to rare to die...", and it was written....