How to resolve the algorithm Colour pinstripe/Display step by step in the 6502 Assembly programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Colour pinstripe/Display step by step in the 6502 Assembly programming language

Table of Contents

Problem Statement

The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.

The pinstripes should either follow the system palette sequence,   or a sequence that includes: black,   red,   green,   blue,   magenta,   cyan,   yellow,   and   white:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Colour pinstripe/Display step by step in the 6502 Assembly programming language

Source code in the 6502 programming language

define color $00
define looptemp $01

loop_1wide:
lda color
sta $0200,x
inc color
inx
bne loop_1wide

loop_2wide:
lda color
sta $0300,x
inx
sta $0300,x
inc color
inx
bne loop_2wide

lda #0
tax
tay
sta color
sta looptemp   ;reset ram

loop_3wide:
lda color
sta $0400,x
inc looptemp
inx

sta $0400,x
inc looptemp
inx

sta $0400,x
inc looptemp
inc color
inx

lda looptemp
cmp #$1e
bne loop_3wide

lda color    ;loop overhead
sta $0400,x  ;can't fit all of this stripe.
	     ;two columns will have to do.
inx
lda color
sta $0400,x
inx

lda #0
sta color
sta looptemp  ;reset color and looptemp
iny
cpy #$08      ;check secondary loop counter
bne loop_3wide

lda #0
tax
tay
sta color
sta looptemp   ;reset ram

loop_4wide:
lda color
sta $0500,x
inx
inc looptemp

sta $0500,x
inx
inc looptemp

sta $0500,x
inx
inc looptemp

sta $0500,x
inc color
inc looptemp
inx

lda looptemp
cmp #$20
bne loop_4wide
lda #0
sta looptemp
sta color

iny
cpy #$8
bcc loop_4wide

brk        ;program end

  

You may also check:How to resolve the algorithm Sorting algorithms/Permutation sort step by step in the D programming language
You may also check:How to resolve the algorithm Balanced brackets step by step in the Ya programming language
You may also check:How to resolve the algorithm Metallic ratios step by step in the Visual Basic .NET programming language
You may also check:How to resolve the algorithm Sierpinski triangle step by step in the Forth programming language
You may also check:How to resolve the algorithm Five weekends step by step in the C# programming language