DEV Community

Joyce Wei
Joyce Wei

Posted on

SPO600 Lab2 - Experiments

This section is going to modify the starter code in order to do some experiment with the bitmap.

Starter Code

 LDA #$00 ; set a pointer at $40 to point to $0200 STA $40 LDA #$02 STA $41 LDA #$07 ; colour number LDY #$00 ; set index to 0 loop: STA ($40),y ; set pixel at the address (pointer)+Y INY ; increment index BNE loop ; continue until done the page INC $41 ; increment 1 page LDX $41 ; get current page number CPX #$06 ; compare with 6 BNE loop ; continue until done the page 
Enter fullscreen mode Exit fullscreen mode

Starter Code Result

Experiment 1

 LDA #$00 ; set a pointer at $40 to point to $0200 STA $40 LDA #$02 STA $41 LDA #$07 ; colour number LDY #$00 ; set index to 0 loop: TYA ; experiment 1 STA ($40),y ; set pixel at the address (pointer)+Y INY ; increment index BNE loop ; continue until done the page INC $41 ; increment 1 page LDX $41 ; get current page number CPX #$06 ; compare with 6 BNE loop ; continue until done the page 
Enter fullscreen mode Exit fullscreen mode

Experiment 1

After adding "TYA" after the "loop" label and before the "STA ($40),y", there are 32 vertical lines with 16 different colours displayed on the bitmap.

This is because "TYA" means "Transfer Y to A" and our accumulator(A) is holding the colour. Since we are incrementing the Y register after "TYA", the colour will change every time the value of Y register is incremented. Moreover, there are only 16 colours available and the bitmap has 32 columns so the vertical lines will be displayed.

Experiment 2

 LDA #$00 ; set a pointer at $40 to point to $0200 STA $40 LDA #$02 STA $41 LDA #$07 ; colour number LDY #$00 ; set index to 0 loop: TYA ; experiment 1 LSR ; experiment 2 STA ($40),y ; set pixel at the address (pointer)+Y INY ; increment index BNE loop ; continue until done the page INC $41 ; increment 1 page LDX $41 ; get current page number CPX #$06 ; compare with 6 BNE loop ; continue until done the page 
Enter fullscreen mode Exit fullscreen mode

Experiment 2

The instruction "LSR" means "Logical Shift Right" which will shift every bits one position to the right, this will result the vertical lines with one pixel wider.

Experiment 2-2

As we adding more "LSR" instruction, the wider the pixels will be.

Top comments (0)