Skip to content

Commit b6e627e

Browse files
authored
Apply suggestions from code review
Tweaking some comments on the assembly routines
1 parent 4beca78 commit b6e627e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/vga/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -485,19 +485,19 @@ impl RenderEngine {
485485
// }
486486

487487
// So I wrote it by hand in assembly instead, saving two clock cycles per loop
488-
// We have 320x8 input and must produce 320x32 output
488+
// We have 640x4 (320x8) input and must produce 320x32 output
489489
unsafe {
490490
core::arch::asm!(
491491
"0:",
492492
// load a byte from line_start_bytes
493493
"ldrb {tmp}, [{lsb}]",
494494
// multiply it by sizeof(u32)
495495
"lsls {tmp}, {tmp}, #0x2",
496-
// load a 32-bit word from CHUNKY4_COLOUR_LOOKUP[lsb]
496+
// load a 32-bit RGB pair from CHUNKY4_COLOUR_LOOKUP
497497
"ldr {tmp}, [{chunky}, {tmp}]",
498-
// store the 32-bit word to the scanline buffer, and increment
498+
// store the 32-bit RGB pair to the scanline buffer, and increment
499499
"stm {slbp}!, {{ {tmp} }}",
500-
// increment the lsb
500+
// increment the pointer to the start of the line
501501
"adds {lsb}, {lsb}, #0x1",
502502
// loop until we're done
503503
"cmp {lsb}, {lsb_max}",
@@ -551,14 +551,14 @@ impl RenderEngine {
551551
"ldrb {tmp}, [{lsb}]",
552552
// multiply it by sizeof(u16)
553553
"lsls {tmp}, {tmp}, #0x1",
554-
// load a 32-bit word from the palette
554+
// load a single 16-bit RGB value from the palette
555555
"ldrh {tmp}, [{palette}, {tmp}]",
556-
// double it up
556+
// double it up to make a 32-bit RGB pair containing two identical pixels
557557
"lsls {tmp2}, {tmp}, #16",
558558
"adds {tmp}, {tmp}, {tmp2}",
559-
// store the 32-bit word to the scanline buffer, and increment
559+
// store the 32-bit RGB pair to the scanline buffer, and increment
560560
"stm {slbp}!, {{ {tmp} }}",
561-
// increment the lsb
561+
// increment the pointer to the start of the line
562562
"adds {lsb}, {lsb}, #0x1",
563563
// loop until we're done
564564
"cmp {lsb}, {lsb_max}",
@@ -572,7 +572,7 @@ impl RenderEngine {
572572
);
573573
}
574574
} else {
575-
// Single-width mode.
575+
// Single-width mode. This won't run fast enough on an RP2040, but no supported mode uses it.
576576
// one RGB pixel per byte
577577
for col in 0..line_len_bytes / 2 {
578578
unsafe {

0 commit comments

Comments
 (0)