need help understanding screen memory mapping

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

need help understanding screen memory mapping

stranger
This post was updated on .
please,with screen memory mapping the part that confuses me is "Set the (col % 16)*th* bit of word to 0 or 1" so if you were to do word= 32*(Row)1+(column) 2/16
therefore: 2/16=0.125 word=32+0=32
and since "col%16"=colmodulo 16 aka the remainder of col/16 you'd have to set the 125th bit of the 32nd memory address to zero or one? that obviously doesn't make sense so what am i misunderstanding.
Reply | Threaded
Open this post in threaded view
|

Re: need help understanding screen memory mapping

ivant
Can you point us to the place where this is written?
Reply | Threaded
Open this post in threaded view
|

Re: need help understanding screen memory mapping

stranger
elements of computing systems page 113
page 134 here https://drive.google.com/file/d/1HxjPmIZkFHl-BVW3qoz8eD9dqEuEyuBI/view
timestamped link here https://youtu.be/gTOFd80QfBU?t=682 
Reply | Threaded
Open this post in threaded view
|

Re: need help understanding screen memory mapping

ivant
Let's say you want to make pixel with coordinates (40, 31) black. (IIRC 0 is white and 1 is black). First, we need to find which word in the video memory contains the corresponding pixel. The formula is SCREEN + 32*row + col/16, where SCREEN is the address of the first word in the video memory (16384). In our case row = 31 and col = 40. Note that the division here is an integer division, which seems to be one of the things that confused you.

So the RAM address for the word containing this pixel is 16384 + 32 * 31 + 40 / 16 = 16384 + 992 + 2 = 17378.

Next, you need to determine exactly which bit in this word corresponds to the pixel. For this we use col % 16 = 40 % 16 = 8. So the 9th bit (bits start from 0) is the one that you need to set to 1 to make it black.
Reply | Threaded
Open this post in threaded view
|

Re: need help understanding screen memory mapping

stranger
This post was updated on .
thank you,i see what the way to do it is now. (correct me if i'm wrong, and in the example you just gave wouldn't 40/16=2.5,so remainder AKA "40%16"=5.? but 6th bit because they start at zero
)
Reply | Threaded
Open this post in threaded view
|

Re: need help understanding screen memory mapping

ivant
stranger wrote
thank you,i see what the way to do it is now (but in the example you just gave wouldn't 40/16=2.5,so remainder AKA "40%16"=5.? but 6th bit because they start at zero
)
That's what I meant by integer division. With integer division 40 / 16 equals 2 with remainder 8. In Python this would be written as 40 // 16.
Reply | Threaded
Open this post in threaded view
|

Re: need help understanding screen memory mapping

stranger
oooh,right thank you,i'm so sorry.