-
Notifications
You must be signed in to change notification settings - Fork 0
/
eff-cursed.s
124 lines (114 loc) · 2.44 KB
/
eff-cursed.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
;; Cursed Word effect
;;
;; Replaces the letters of the captured text with new random garbage
;; every frame.
.macpack apple2
.include "taki-effect.inc"
.include "taki-public.inc"
.include "a2-monitor.inc"
declVar varCH, 1 ; the horiz cursor position at capture start
declVar varCV, 1 ; the vert cursor position at capture start
declVar varBAS, 2 ; BASL/BASH at capture start
vTextStart = kVarSpaceNeeded
TAKI_EFFECT TE_Cursed, "CURSED", 0, 0
cmp #TAKI_DSP_INIT ; init?
bne CkColl
;; INIT
; Allocate the space we will need
effAllocate kVarSpaceNeeded
; save cursor X and Y
lda Mon_CH
effSetVar varCH
lda Mon_CV
effSetNext
lda Mon_BASL
effSetNext
lda Mon_BASH
effSetNext
rts
CkColl:
cmp #TAKI_DSP_COLLECT ; collect?
bne CkCollectEnd
;; COLLECT
lda TAKI_ZP_ACC
effAppendByte
jmp TakiIoFastOut
CkCollectEnd:
cmp #TAKI_DSP_ENDCOLLECT
bne CkTick
;; END COLLECT
lda #0
effAppendByte
UnsupportedMode:
rts
CkTick:
cmp #TAKI_DSP_TICK ; tick?
bne UnsupportedMode
;; TICK
; Save away current CH, CV, and BAS
lda Mon_CH
sta SavedCH
lda Mon_CV
sta SavedCV
lda Mon_BASL
sta SavedBAS
lda Mon_BASH
sta SavedBAS+1
; Set to our capture-start spot
effGetVar varCH
sta Mon_CH
effGetNext
sta Mon_CV
effGetNext
sta Mon_BASL
effGetNext
sta Mon_BASH
PrintLoop:
effGetNext
beq TickCleanup
pha
and #$DF ; de-lowercase
ora #$80 ; ensure normal range
cmp #$DB ; > 'Z'?
bcs @prLit ; yes -> print literal char
cmp #$C1 ; >= 'A'?
bcc @prLit ; no -> print literal char
pla
; Print garbage!
jsr RandomChar
jsr TakiIoFastOut
jmp PrintLoop
@prLit:
pla
jsr TakiIoFastOut
jmp PrintLoop
TickCleanup:
lda SavedCH
sta Mon_CH
lda SavedCV
sta Mon_CV
lda SavedBAS
sta Mon_BASL
lda SavedBAS+1
sta Mon_BASH
rts
SavedCH:
.byte 0
SavedCV:
.byte 0
SavedBAS:
.word 0
; Weights a bit higher toward punctuation and digits
RandomChar:
jsr TakiIoNextRandom
lda TakiVarRandomWord
ora #$80
cmp #$A1 ; is it a control character, or space?
bcs @notCtrl ; no -> don't adjust
adc #$21 ; (carry never set)
@notCtrl:
cmp #$FF ; DEL character?
bne @notDEL
lda #$A1 ; replace with '!'
@notDEL:
rts