-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwedge.asm
91 lines (74 loc) · 2.54 KB
/
wedge.asm
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
; 2021.01.03
;
; marcel timm, rhinodevel
chrget = $70
chrgot = $76
txtptr = $77 ; two bytes.
buf = $0200 ; basic input buffer's address.
cas_buf1 = $027a
cmd_char = 255 ; command symbol.
spc_char = $20 ; "empty" character to be used in string.
str_len = 16 ; size of command string stored at label "str".
; use the three free bytes behind installed wedge jump:
;
savex = chrget+3 ; saved x register content.
savey = chrget+4 ; saved y register content.
;= chrget+5
addr = cas_buf1
len = addr+2
str = len+2
* = addr
; wedge installer (space reused later for address, length and command string):
lda #$4c ; jmp
sta chrget
lda #<wedge
sta chrget+1
lda #>wedge
sta chrget+2
rts
byte 0
byte 0
byte 0
byte 0
byte 0
byte 0
byte 0
; the wedge:
wedge inc txtptr ; increment here, because of code overwritten at chrget
bne savexy ; with jump to wedge.
inc txtptr+1
savexy sty savey ; save original x and y register contents.
stx savex
lda txtptr ; exec. cmd. in basic direct mode, only.
cmp #<buf ; original basic functionality of cmd. char. must still
bne to_basic ; work (e.g. pi symbol as constant).
lda txtptr+1
cmp #>buf
bne to_basic
ldy #0 ; check, if current character is the command sign.
lda (txtptr),y
cmp #cmd_char
bne to_basic
inc txtptr ; save at most "str_len" count of characters from input
next_i lda (txtptr),y ; buffer to "str".
beq fill_i
sta str,y
iny
cpy #str_len
bne next_i
lda (txtptr),y ; there must be a terminating zero following,
bne to_basic ; go to basic with character right after cmd. sign,
; otherwise.
fill_i tya ; increment txtptr by count of read characters
clc ; and fill remaining places in "str" array with spaces.
adc txtptr
sta txtptr
lda #spc_char
next_f cpy #str_len
beq to_basic
sta str,y
iny
jmp next_f
to_basic ldy savey ; restore saved register values and let basic handle
ldx savex ; character from input buffer txtptr currently points
jmp chrgot ; to.