Question: Task 2 : Paint a number ( 1 0 marks ) The template for this task contains data for bitmaps of the digits 0 -
Task : Paint a number marks The template for this task contains data for bitmaps of the digits stored at the label DigitPixels. Each digit consists of x pixels of data. The first words are the first row of pixels, the next words are the second row, and so on For example, the digit is represented as FFFF FFFF FFFF FFFF FFFF FFFF FFFF You can see the pattern here, the zeros paint the shape of the character in black, with the background in white FFFF Your task is to write a subroutine called SubDrawDigit that paints a digit into the graphics memory. The beginning of the subroutine should be structured as follows: DigitDataAddress, HEX DigitDisplayAddress, HEX SubDrawDigit, HEX In the DigitDataAddress argument, you will pass the address of the first pixel data for the digit you want to paint, as defined in the DigitPixels. In the DigitDisplayAddress argument, you will provide the address of the topleft corner in the graphic memory where you wish to start painting the digit. For example, to paint the digit starting from the second pixel in the second row, we could use the following code: Load DigitPixelsAddr Store DigitDataAddress Load Display Store DigitDisplayAddress JnS SubDrawDigit Halt Display HEX F Note that the address Flabel Display lies exactly words after the start of the graphics memory. This means were skipping the first row words and the first pixel in the second row word Here we simply use DigitPixelsAddr to refer to the first character for the digit For the other characters, we would have to add a corresponding offset into the DigitPixels memory.
To paint a digit in your subroutine, you can follow this recipe: Each digit consists of pixels columns x rows You need to loop through these pixels, loading each one from the DigitPixels definition and storing it in the graphics memory. Your subroutine should contain two nested loops: o Outer Loop Rows: Loop through each row of the digit. o Inner Loop Columns: Within the outer loop, loop through each column of the current row. Retrieve the corresponding pixel data from DigitDataAddress Store the pixel data at the correct graphics memory address eg DigitDisplayAddress plus the current row offset and current column offset Once you have copied all pixels from the DigitPixels definition into the graphics memory, you can exit the subroutine. Your subroutine must include sufficient comments to help others such as the person marking your assignment in understanding the purpose of your code.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
