-
Notifications
You must be signed in to change notification settings - Fork 1
/
editEcho.asm
230 lines (199 loc) · 3.59 KB
/
editEcho.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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
editEchoTable:
.IF SRAM_MAP=32
lda #SRAM_ECHO_BANK
jsr setMMC1r1
.ENDIF
lda echoFirstRow
clc
adc echoCursorY
tax
lda echoRowsIndex,x
clc
adc echoCursorX
sta echoIndex
tay
ldx echoCursorX
lda writeScreen ;need to write screen?
beq @a
jsr writeEchoScreen ;yes
dec writeScreen ;if writeScreen was 1, only write main window, else
beq @a ; write header and title too
jsr writeEchoHeaderFooter
dec writeScreen ;reset screen writing flag
lda #$01
sta dmaUpdateHeader
sta dmaUpdateTitle
@a: jsr globalKeys ;global keys
lda writeScreen ;if mode has changed, this flag will be !=0
beq @b
jmp editEchoExit ;if changed, don't do any more keys
@b: jsr processKeys
.IF SRAM_MAP=32
lda #SRAM_ECHO_BANK
jsr setMMC1r1
.ENDIF
ldy echoIndex
jsr echoKeysTapA
jsr echoKeysTapB
jsr echoKeysHoldA_UDLR
jsr moveAroundEditor
editEchoExit:
updateCursor echoCursorX,echoCursorY,echoCursorColumns,echoCursorRows,echoColumnCursorType
jmp editorLoop
echoKeysHoldA_UDLR:
lda PAD1_fireb;keysHoldB
beq @noB
rts
@noB: lda PAD1_firea;keysHoldA ;hold A + U/D/L/R = modify value
bne @holdA
lda editBufferFlag
beq @x
lda editBuffer
sta SRAM_ECHOES,y
@notEditing: lda #$00
sta editBufferFlag
beq @x
@holdA: lda editBufferFlag
bne @editing
inc editBufferFlag
lda SRAM_ECHOES,y
sta editBuffer
@editing: lda keysRepeatLR
ora PAD1_dlr
bne @addValue
lda keysRepeatUD
ora PAD1_dud
beq @x
bpl @addNeg
ldy echoCursorX
lda echoPositiveAdd,y
ldy echoIndex
jmp @addValue
@addNeg: ldy echoCursorX
lda echoNegativeAdd,y
ldy echoIndex
@addValue: clc
;adc SRAM_ECHOES,y
;sta SRAM_ECHOES,y
adc editBuffer
sta editBuffer
ldx echoCursorX
sta editEchoLastValue,x
jsr editEchoUpdateScreenValue
@x: rts
echoKeysTapB:
lda PAD1_sel
beq @x
lda keysTapB
beq @x
lda #$00
sta SRAM_ECHOES,y
sta editBuffer
jmp editEchoUpdateScreenValue
@x: rts
echoKeysTapA: ldx echoCursorX
lda keysTapA
beq @x
.IF 0=1
lda PAD1_fireb
beq @notDel
lda #$00
sta SRAM_ECHOES,y
sta editBuffer
jmp editEchoUpdateScreenValue
.ENDIF
@notDel:
lda editEchoLastValue,x
ldy echoIndex
sta SRAM_ECHOES,y
sta editBuffer
jsr editEchoUpdateScreenValue
@x: rts
echoNegativeAdd:
.BYTE -16,-16,-16,-16
echoPositiveAdd:
.BYTE 16,16,16,16
editEchoUpdateScreenValue:
pha
ldx echoCursorY
lda rowOffsetEcho,x
ldx echoCursorX
clc
adc columnOffsetEcho,x
tax
pla
jsr phexWindow
rts
writeEchoScreen:
ldx #$00
ldy echoFirstRow ;first write row numbers to buffer
@a: tya
jsr phexRow
iny
cpx #$20
bcc @a
ldy echoFirstRow
lda echoRowsIndex,y
tay
ldx #$00
@b: lda SRAM_ECHOES,y
jsr phexWindow
lda #CHR_SPACE
sta windowBuffer,x
inx
iny
lda SRAM_ECHOES,y
jsr phexWindow
lda #CHR_SPACE
sta windowBuffer,x
inx
iny
lda SRAM_ECHOES,y
jsr phexWindow
lda #CHR_SPACE
sta windowBuffer,x
inx
lda #CHR_SPACE
sta windowBuffer,x
inx
sta windowBuffer,x
inx
sta windowBuffer,x
inx
sta windowBuffer,x
inx
sta windowBuffer,x
inx
iny
cpx #224
bcc @b
@x: rts
writeEchoHeaderFooter:
ldx #$00 ;write header and title bars to buffer
@c: lda titleEcho,x
sta titleBuffer,x
lda headerEcho,x
sta headerBuffer,x
inx
cpx #$11
bne @c
rts
echoCursorColumns:
.REPEAT 3,i
.BYTE $53+(i*24)
.ENDREPEAT
echoCursorRows:
.REPEAT 16,i
.BYTE $28+(i*8)
.ENDREPEAT
rowOffsetEcho:
.REPEAT 16,i
.BYTE i*14
.ENDREPEAT
columnOffsetEcho:
.BYTE 0,3,6
;
;0 = no cursor, 1=8x8, 2=8x16, 3=8x24
;
echoColumnCursorType:
.BYTE 2,2,2