Hello, this is the lab 2 of SPO600.
The first task in this lab that we are going to draw green line at the top and draw a blue line at the bottom.
LDA #05 ; Color Green code LDY #$00 ; Position Index on First Line TOP: STA $0200,Y ; Store color into the current Pixel INY ; Go to the next pixel CPY #32 ; Check if it gets to the pixel 32 BNE TOP ; If it didn't hit pixel 32 yet, keep going
We load a green pixel and set the start position of y at #$00. Then we store the color into the current position and set a loop to check the value of Y. If Y reached the end of the top line which is #32 then jump out of the loop.
We used the same logic to draw another blue line at the bottom.
LDA #06 ; Color Blue Code LDY #$00 ; Position Index on Last Line BOTTOM: STA $05E0,Y; Store color into the current Pixel INY ; Go to the next pixel by increase the value of Y CPY #32 ; Check if it gets to the pixel 32 BNE BOTTOM ; If it didn't reach pixel 32 yet, keep looping
In the second task we are going to print 2 vertical lines at each side the square.
LDA #$00 STA $10 LDA #$02 STA $11 LDY $00 LEFT: LDA #$07 ; Set color Yellow STA ($10),Y LDA $10 CLC ADC #$20 STA $10 LDA $11 ADC #$00 STA $11 CMP #$06 BNE LEFT
First, we create 2 pointers to video memory and set them to $10 and $11.
Second, we set the loop. Inside of the loop, we set the yellow color and put it into the current pixel.
Next, we load the accumulator and clear the carry flag. Then we add $20 into the accumulator in order to increment each line in the screen vertically. After that, we store the value $10 into the memory.
Afterwards, we load the value of $11 into the accumulator and store contents and carry flags into the memory.
At the end, we compare the content of memory with the accumulator to ensure the lines reach to the last page. If not, continue the loop.
Same idea to draw the purple line.
LDA #$1F STA $10 LDA #$02 STA $11 LDY $00 RIGHT: LDA #$04 ; Set color Purple STA ($10),Y LDA $10 CLC ADC #$20 STA $10 LDA $11 ADC #$00 STA $11 CMP #$06 BNE RIGHT