/
word4.s
78 lines (75 loc) · 1.06 KB
/
word4.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
67
68
69
70
71
72
73
74
75
76
77
78
;
; Game specific code
;
;
; Pick right routine for word size. This one does 4 chars
; Check wordbuf matches our word. Both are zero padded for simplicity
;
wordeq:
pshx
ldd ,x
anda #$7f
cmpa wordbuf
bne notmatch
cmpb wordbuf+1
bne notmatch
ldd 2,x
cmpa wordbuf+2
bne notmatch
cmpb wordbuf+3
notmatch:
pulx
rts
;
; Copy a word into the wordbuf (max 4 letter matches)
;
copy_word:
jsr skip_spaces
stx nounbuf ; we always scan noun second so this is ok
ldd ,x
std wordbuf
ldd 2,x
std wordbuf+2
pshx
bsr word_clear ; clear end of word buf to zero for matching
pulx
ldaa #32
copymove:
cmpa ,x ; Space
beq nextsp ; Word over
tst ,x ; End
beq nextsp ; Word over
inx ; Move on a byte
bra copymove ; Keep looking
nextsp:
rts
;
; Clear tail of 4 char word
;
word_clear:
ldx #wordbuf
wordclr4l:
ldaa ,x
beq padrest
cmpa #32
beq padrest
inx
cpx #wordbuf+4
bne wordclr4l
; >= 4 letters
rts
padrest:
ldaa #32
padrestl:
staa ,x
inx
cpx #wordbuf+4
bne padrestl
rts
copy_abbrev:
ldd ,x
std linebuf
ldd 2,x
std linebuf+2
clr linebuf+4
rts