|
-
Apr 6th, 2003, 06:55 AM
#1
Thread Starter
Hyperactive Member
Draw line and randomize
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
-
Apr 9th, 2003, 09:11 AM
#2
Thread Starter
Hyperactive Member
-
Apr 15th, 2003, 06:43 AM
#3
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?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 15th, 2003, 01:36 PM
#4
Thread Starter
Hyperactive Member
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
-
Apr 15th, 2003, 01:55 PM
#5
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 15th, 2003, 01:55 PM
#6
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 16th, 2003, 02:48 AM
#7
Thread Starter
Hyperactive Member
-
Apr 16th, 2003, 09:49 AM
#8
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 4th, 2003, 03:00 AM
#9
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?
He is not talking about one register he is talking
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.
-
May 4th, 2003, 10:43 AM
#10
He's talking of a line so he needs two coordinate set, so what you say is wrong.
Anyway, that was cleared up already.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 5th, 2003, 03:18 AM
#11
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.
-
May 5th, 2003, 04:53 AM
#12
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.
Three should be the number to count to.
Not four, neither two, except inorder to count on to three.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 5th, 2003, 01:31 PM
#13
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.
-
May 6th, 2003, 04:20 PM
#14
Thread Starter
Hyperactive Member
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
-
May 9th, 2003, 04:05 AM
#15
Thread Starter
Hyperactive Member
-
May 11th, 2003, 03:55 AM
#16
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.
-
May 12th, 2003, 06:53 AM
#17
To give you an idea: that's the code of rand() in the VC++ CRT:
Code:
return(((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
Of course this is a quite poor algorithm since it only gives you a 15-bit number.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 19th, 2003, 08:00 PM
#18
Fanatic Member
Random number algorithm
Interesting lecture that has some pretty good stuff for random number generation.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|