more documentation of similarities and avoiding them where practicable.
This commit is contained in:
1 parent
035b386f6c
commit
7448909da8
17 files changed
+161
-12
No files matched your search
@@ -0,0 +1,44 @@
|
||||
Copy screen + colour RAM to the right one place
|
||||
|
||||
This sequence of instructions:
|
||||
|
||||
loop:
|
||||
DEY
|
||||
LDA ($D1),Y
|
||||
INY
|
||||
STA ($D1),Y
|
||||
DEY
|
||||
LDA ($F3),Y
|
||||
INY
|
||||
STA ($F3),Y
|
||||
DEY
|
||||
CPY $D3
|
||||
BNE loop
|
||||
LDA #$20
|
||||
STA ($D1),Y
|
||||
|
||||
is the obvious any minimal way to copy the screen and colour RAM data.
|
||||
The constants $D1 and $F3 are fixed by the publicly documented interface
|
||||
of the KERNAL to point to the screen and colour RAM of the screen.
|
||||
|
||||
The Y register is the only register that can be used to post-increment an
|
||||
indirect address on the 6502.
|
||||
|
||||
Thus the only efficient manner to copy a string to the right one byte
|
||||
is to read, increment Y by one to get the destination address, store,
|
||||
then decrement Y again so that it points to the source offset, now read
|
||||
the colour RAM byte, add one to Y so that we point to the destination,
|
||||
and then write it.
|
||||
|
||||
Similarly the check against $D3 (current column of cursor on screen) is also
|
||||
necessary for working out when to terminate the loop. The storing of $20
|
||||
into the screen RAM is also required to effect the insertion of a space.
|
||||
|
||||
In fact, about the only variant possible would be to swap the $D1 and $F3
|
||||
constants so that the colour RAM is copied before the screen RAM in each
|
||||
loop, instead of after it.
|
||||
|
||||
It is telling that this routine was the result of independent implementation
|
||||
of this routine, without looking at the KERNALs routine, in terms of supporting
|
||||
the argument that the routine is the obvious manner in which to do this.
|
||||
|
||||
Reference in new issue
Block a user