ayush_shyam wrote
I have been trying to implementing mid point algorithm for circles, breaking the algorithm/code down i realized the problem of coordinate systems.
By pointers i mean trying to set the M values of the corresponding pixel to 1 to change it to a dark colour. So basically i was implying the mapping to each pixel when i told that.
What i m trying to achieve is to draw a circle of arbitrary radius
Around center of the cpeu emulator screen. To which i m facing the issue of implementation stumbling on coordinate system defenitions and pixel mappin according to the developed coordinate system.
So, if I understand you correctly, your assembly language program will be limited to drawing a circle of a user-specified radius centered in the middle of the screen.
Are you wanting to draw a filled circle, or just the circle outline?
Are you only drawing a black circle, or does the user get to specify color?
How does the radius get passed to your code?
Are you assuming that the radius is small enough so that the entire circle fits on the screen?
What do you want to have happen if part of the circle goes off the screen?
These are all interface specification issues that should be thought of ahead of time. They don't all have to be addressed in their final form all at once, however. For instance, you can say that, for now, you will assume that the requested radius is small enough so that the entire circle is on the screen and then go back later and decide how to handle situations in which it isn't.
The mapping between the RAM and the screen is explicitly spelled out in Section 4.2.5.
You have to decide what "the center" of the screen is. Since the screen dimensions are an even number, the center is located between two rows and two columns. Since you probably don't want to get into fractional pixel locations, you have to decide which of the slightly-off-center pixels you want to declare as the center of your circle.
The screen dimensions are 512x256, so I let's say that you want <256,128> to be the center.
So that's row 256 (with Row 0 at the top) and column 256 (with Col 0 at the left).
The RAM cell that controls this pixel is:
RAM[16384 + r*32 + c/16] = RAM[16384+4096+16] = RAM[20496].
The bit within that memory cell that controls that pixel is c%16 = 0 (or the lsb).
Do you understand how to set/clear individual bits within a word without affecting the others?