forked from MEGA65/open-roms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path88B1D1C891D188
44 lines (35 loc) · 1.5 KB
/
88B1D1C891D188
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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.