How do i draw a line on graphic mode from register bx to register cx.
If you could please write a function that does such a thing I will be greatly thankful.
Also, how do I randomize in assembler.
Thank you
Printable View
How do i draw a line on graphic mode from register bx to register cx.
If you could please write a function that does such a thing I will be greatly thankful.
Also, how do I randomize in assembler.
Thank you
help me please
For randomizing, you just need a function that does some stupid calculations with an inner state (the "seed") and returns the result, while at the same time updating the seed.
As for the line, what do you mean "from bx to cx"? How can a 16-bit register hold a set of coordinates even in 320x240 mode?
if you could please post the commands which randomize it'll help alot:P
Also, I don't see what's the problem with "from bx to cx"
bx=y*320+x
;i know you can't write like this in assembler, it's only the
;algorithm
;al-color of the dot
mov es:[bx],al
Ok, I see.
So
x1 = bx % 320
y1 = bx / 320
x2 = cx % 320
y2 = cx / 320
So you have a line, you need to rasterize it. I'm sure you can find a good rasterizing algorithm on the internet. If it is C (it probably is) just feed it to an optimizing C compiler and convert the resulting assembly to 16-bit code. It should be easier than translating the code yourself.
Then you just put values at the appropriate memory addresses.
As for randomizing, get any open source C runtime library (e.g. the GNU CRT) and look at the rand function. It should be simple enough to translate to assembly.
how?
Download the GNU CRT source from
www.gnu.org
and search for the source file that implements rand and srand. It really can't be that hard.
He is not talking about one register he is talkingQuote:
As for the line, what do you mean "from bx to cx"? How can a 16-bit register hold a set of coordinates even in 320x240 mode?
about two registers: bx and cx. Those two together
should be able to two coordinates ranging from 0 to 65535
which should be enough for any resolution that is used
on the pc I know of.
He's talking of a line so he needs two coordinate set, so what you say is wrong.
Anyway, that was cleared up already.
I was talking about ONE set of coordinates not TWO
but yes I forgot we were talking about a line where you need two sets of coordinates and that would mean you need all four available registers.
But he said he had TWO coordinate sets in TWO registers. Not ONE in TWO, not TWO in FOUR, but TWO in TWO.
A thing possible only in 320*240.
Quote:
Three should be the number to count to.
Not four, neither two, except inorder to count on to three.
Quote:
yes I forgot we were talking about a line where you need two sets of coordinates and that would mean you need all four available registers.
Never mind the line... i have almost finished making it.
If you could just post here a code which randomizes.... that would be great!:P
Thanks
anyone?
please(:
Perhaps you could use the timer or part of it for a random value.
The timer is a dword value stored at address 40:6C.
Try looking for it on the internet using Google (http://www.google.com) it will be some work but I think
you can find something useful.
To give you an idea: that's the code of rand() in the VC++ CRT:
Of course this is a quite poor algorithm since it only gives you a 15-bit number.Code:return(((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
Random number algorithm
Interesting lecture that has some pretty good stuff for random number generation.