Lab-1 Challenges
Introduction:
In this lab, we explored the 6502 assembly language using an online emulator. The primary goal was to understand how to manipulate the bitmapped display, calculate the performance of our code, and optimize it for faster execution. We started by filling the entire screen with a solid color (yellow) and then modified the code to experiment with different colors, patterns, and performance optimizations. Finally, we tackled some optional challenges to further deepen our understanding of the 6502 assembly language and its capabilities.
Challenges:
Challenge 1:
Set all of the display pixels to the same color, except for the middle four pixels, which will be drawn in another color.
To achieve this, we need to modify the original code to fill the entire screen with one color and then change the color of the middle four pixels. The middle four pixels are located at the center of the screen, which can be calculated based on the screen resolution.
lda #$00 ; Set a pointer in memory location $40 to point to $0200
sta $40 ; ... low byte ($00) goes in address $40
lda #$02
sta $41 ; ... high byte ($02) goes into address $41
lda #$07 ; Colour number (yellow)
ldy #$00 ; Set index to 0
loop:
sta ($40),y ; Set pixel colour at the address (pointer)+Y
iny ; Increment index
bne loop ; Continue until done the page (256 pixels)
inc $41 ; Increment the page
ldx $41 ; Get the current page number
cpx #$06 ; Compare with 6
bne loop ; Continue until done all pages
; Now, change the middle four pixels to a different color (e.g., red)
lda #$02 ; Colour number (red)
sta $040E ; Set pixel colour at the middle
sta $040F
sta $0410
sta $0411
Challenge 2:
Write a program which draws lines around the edge of the display.To draw lines around the edges of the display, we need to set specific pixels to different colors. The top and bottom lines will span the entire width of the screen, while the left and right lines will span the height.
Comments
Post a Comment