-
Notifications
You must be signed in to change notification settings - Fork 1
/
soft80_cpeeks.s
66 lines (58 loc) · 1.24 KB
/
soft80_cpeeks.s
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// 2017-12-27, groepaz
//
// void cpeeks (char* s, unsigned length)//
//
#import "soft80.inc"
soft80_cpeeks:
eor #<$FFFF // counting a word upward is faster
sta ptr2 // so, we use -(length + 1)
txa
eor #>$FFFF
sta ptr2+1
//jsr popax
brk
sta ptr1
stx ptr1+1
// save current cursor position
lda CURS_X
pha
lda CURS_Y
pha
// get the string
lp:
jsr soft80_cpeekc
ldy #0
sta (ptr1),y
// advance cursor position
ldy CURS_X
ldx CURS_Y
iny
cpy #charsperline
bne !sk2+
ldy #0
inx
!sk2:
sty CURS_X
stx CURS_Y
clc
jsr soft80_kplot
inc ptr1
bne !sk+
inc ptr1+1
!sk:
inc ptr2
bne lp
inc ptr2+1
bne lp
// terminate the string
lda #0
ldy #0
sta (ptr1),y
// restore the cursor position
pla
tax // CURS_Y
pla
tay // CURS_X
clc
jmp soft80_kplot