SPO600-Lab2 (Experimenting with 6502 emulator)
In this lab, I have been given a bitmap code which will fill the emulator's bitmap display with the yellow color. Later I was given some task to modify the code in such a way to get different output color for the entire display. I was also asked to show four different color in four different pages. In this display one quarter is refer to as one page. I was encouraged to do some further experiment then. So I will start from the very first task.
I assembled and run the initial code on the emulator and below is my raw code and output.
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 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
This was the initial code that was given which is supposed to produce yellow color.
Here you can see the yellow bitmap display
Calculating execution time:
Modifying the code:
1. Here at first I was asked to change the given code to fill the display with light blue instead of yellow.
For this task I have given a reference chart showing below
- $0: Black
- $1: White
- $2: Red
- $3: Cyan
- $4: Purple
- $5: Green
- $6: Blue
- $7: Yellow
- $8: Orange
- $9: Brown
- $a: Light red
- $b: Dark grey
- $c: Grey
- $d: Light green
- $e: Light blue
- $f: Light grey
2. In this task I was asked to modify the code to display four different color in four page. Each quarter of the display is a page. For this I stored the color in memory location $10. Next is when the page incremented I use increment value of $10 so that the accumulator loads with the incremented color code value of $10.
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 #$5 ; colour number
sta $10 ; store colour number to memory location $10
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
inc $10 ; increment the color number
lda $10 ; colour number
ldx $41 ; get the current page number
cpx #$06 ; compare with 6
bne loop ; continue until done all pages
Comments
Post a Comment