-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewmem.s
563 lines (363 loc) · 6.95 KB
/
viewmem.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
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
view_inputs:
;d1 = controls trg
move.l VAR_MEMV_MODE,d0
;check if mode switched
btst.l #5,d1
beq .skip
cmp.l #2,d0
bne .skip2
move.l #-1,d0
.skip2:
addq.l #1,d0
move.l d0,VAR_MEMV_MODE
.skip:
cmp.l #MODE_VIEW,d0
bne .not_simple
;simple viewer
lea VAR_MEMV,a0
btst #0,d1
beq .c1
subi.l #8,(a0)
.c1:
btst #1,d1
beq .c2
addi.l #8,(a0)
.c2:
btst #2,d1
beq .c3
subi.l #2,(a0)
.c3:
btst #3,d1
beq .c4
addi.l #2,(a0)
.c4:
rts
.not_simple:
cmp.l #MODE_EDIT,d0
bne .modmem
; user u/d/l/r to mvoe highlight and u/d/l/r +fire to modify mem value
move.l VAR_INPUT,d2
btst.l #4,d2
bne .fire
;jesli bylo fire, to zapisz dana!
jsr memv_calc_edit_address
move.l VAR_MEMV_FIRE,d2
or.l d2,d2
beq .nowrite
;write do pamieci
move.w VAR_MEMV_DT,d0
move.w d0,(a0)
.nowrite:
moveq.l #0,d2
move.l d2,VAR_MEMV_FIRE
;modify cursor
move.l VAR_MEMV_Y, d2 ; cursor y
btst #0,d1
beq .noydec
cmp.l #0,d2
bne .n0_1
move.l #10,d2
.n0_1:
sub.l #1,d2
.noydec:
btst #1,d1
beq .noyinc
cmp.l #9,d2
bne .no9
move.l #-1,d2
.no9:
add.l #1,d2
.noyinc:
move.l d2,VAR_MEMV_Y
;now x
move.l VAR_MEMV_X, d2 ; cursor y
btst #2,d1
beq .noxdec
cmp.l #0,d2
bne .n0_2
move.l #4,d2
.n0_2:
sub.l #1,d2
.noxdec:
btst #3,d1
beq .noxinc
cmp.l #3,d2
bne .no4
move.l #-1,d2
.no4:
add.l #1,d2
.noxinc:
move.l d2,VAR_MEMV_X
moveq.l #0, d0
move.l d0,VAR_MEMV_FLASH
jsr memv_calc_edit_address
move.w (a0),d0
move.w d0,VAR_MEMV_DT
rts
.fire:
; if fire==0, read from mem, otherwise use old value
move.l VAR_MEMV_FIRE,d2
or.l d2,d2
bne .nocopy
;move.l VAR_MEMV_EA,a0
.nocopy:
;set fire to 1
moveq.l #1,d2
move.l d2,VAR_MEMV_FIRE
;check controls
move.w VAR_MEMV_DT,d0
move.l VAR_MEMV_EDITP,d2
move.l #NUM_WORD,d3
jsr edit_num
move.w VAR_MEMV_DT,d3
move.l VAR_MEMV_EDITP,d4
move.w d0,VAR_MEMV_DT
move.l d2,VAR_MEMV_EDITP
cmp.w d3,d0
bne .clear
cmp.l d4,d2
beq .skip_clear
.clear:
moveq.l #0, d0
move.l d0,VAR_MEMV_FLASH
.skip_clear:
move.l #VAR_MEMV_FLASH,a0
add.l #1,(a0)
rts
.modmem:
; modify address
move.l VAR_MEMV,d0
move.l VAR_MEMV_ADDRP,d2
move.l #NUM_DWORD,d3
jsr edit_num
;move.l #$fffffffe,d3
;and.l d3,d0 ;to prevent address error!
move.l VAR_MEMV,d3
move.l VAR_MEMV_ADDRP,d4
move.l d0,VAR_MEMV
move.l d2,VAR_MEMV_ADDRP
cmp.w d3,d0
bne .clear2
cmp.l d4,d2
beq .skip_clear2
.clear2:
moveq.l #0, d0
move.l d0,VAR_MEMV_AFLASH
.skip_clear2:
move.l #VAR_MEMV_AFLASH,a0
add.l #1,(a0)
rts
memv_calc_edit_address:
; calc address = start +2*x 8*y
move.l VAR_MEMV,d0
and.l #$fffffffe,d0
move.l d0,a0
move.l VAR_MEMV_X,d0
add.l d0,d0
add.l d0,a0
move.l VAR_MEMV_Y,d0
lsl.l #3,d0
add.l d0,a0
move.l a0,VAR_MEMV_EA ;store for viewer
rts
print_count:
;inputs
move.l #COUNT_Y,d1
move.l #COUNT_X,d0
move.w #COLOR_GREEN,d2
lea txt_mode_inputs,a0
jsr print_text
add.w #3,d0
move.l d0,d5
move.l VAR_INPUT, d0
jsr extract_bits
move.l d5,d0
move.w #COLOR_WHITE,d2
lea TMP_STRING,a0
jsr print_text
add.l #9,d0
;dsw
move.w #COLOR_GREEN,d2
lea txt_mode_switch,a0
jsr print_text
add.w #3,d0
move.l d0,d5
move.w ADDR_DSW, d0
jsr extract_bits
move.l d5,d0
move.w #COLOR_WHITE,d2
lea TMP_STRING,a0
jsr print_text
add.l #9,d0
;frame counter
move.w #COLOR_RED,d2
move.l VAR_FRAMECNT,d3
move.l #5, d4
jsr print_num
move.l #MNAME_X,d0
move.l #MNAME_Y,d1
move.w #COLOR_GREEN,d2
lea txt_mname,a0
jsr print_text
addi.l #12,d0
move.w #COLOR_WHITE,d2
lea module_list, a0
move.l VAR_MODULE,d4
lsl.l #2,d4
move.l (a0,d4),a0
move.l (a0),a0
jsr print_text
rts
txt_mname:
dc.b "ACTIVE MOD: ",0
print_status:
move.l #STATUS_X,d0
move.l #STATUS_Y,d1
move.w #COLOR_GREEN,d2
lea txt_mode,a0
jsr print_text
addq.l #2,d0
;mode type
moveq.l #0,d7
move.l VAR_MEMV_MODE,d5
cmp.l #MODE_VIEW,d5
bne .not_view
lea txt_mode_view,a0
bra .end_mode
.not_view:
cmp.l #MODE_EDIT,d5
bne .not_edit
lea txt_mode_edit,a0
bra .end_mode
.not_edit:
lea txt_mode_modify,a0
moveq.l #1,d7
.end_mode
move.w #COLOR_WHITE,d2
jsr print_text
addq.l #2,d0
move.w #COLOR_GREEN,d2
lea txt_mode_address,a0
jsr print_text
addq.l #2,d0
;print address here
move.l VAR_MEMV,d3
move.w #8,d4
move.w #COLOR_WHITE,d2
or.l d7,d7 ; set to 1 on edit mode
beq .printnoedit
move.w #COLOR_WHITE,d2
;check for edited
move.w #COLOR_RED,d2
move.l VAR_MEMV_AFLASH,d7
btst.l #4,d7
beq .printnoedit
movem.l D5, -(A7)
movem.l VAR_MEMV_ADDRP,d5
jsr print_flashing_num
movem.l (A7)+, D5
bra .skipadp
.printnoedit:
jsr print_num
.skipadp:
add.l #9,d0
move.w #COLOR_GREEN,d2
lea txt_mode_data,a0
jsr print_text
addq.l #2,d0
move.l VAR_MEMV,d3
and.l #$fffffffe,d3
move.l d3,a1
move.w (a1),d3
move.w #4,d4
move.w #COLOR_WHITE,d2
jsr print_num
addq.l #5,d0
move.w #COLOR_GREEN,d2
lea txt_mode_commands,a0
jsr print_text
addq.l #2,d0
move.w #COLOR_WHITE,d2
move.l VAR_MTYPE,d3
move.w #4,d4
jsr print_num
rts
txt_mode:
dc.b "M: ",0
txt_mode_view:
dc.b "V",0
txt_mode_edit:
dc.b "E",0
txt_mode_modify:
dc.b "A",0
txt_mode_data:
dc.b "D:",0
txt_mode_address:
dc.b "A:",0
txt_mode_switch:
dc.b "SW:",0
txt_mode_inputs:
dc.b "IN:",0
txt_mode_commands:
dc.b "C:",0
view_mem:
movem.l D0-D7/A0-A6, -(A7)
move.l VAR_MEMV,d1
and.l #$fffffffe,d1
move.l d1,a1
move.w #VIEWER_Y,d1
move.l #9,d6
.loopy:
move.w #1,d0
move.l a1,d3
move.l #8,d4
move.w #COLOR_GREEN,d2
jsr print_num
add.w #8,d0
move.w #COLOR_WHITE,d2
moveq.l #$3a,d3
jsr print_char
add.w #2,d0
move.l #3,d5
.loopx:
move.w (a1)+,d3
move.w #4,d4
move.w #COLOR_WHITE,d2
;check for edited
move.l VAR_MEMV_MODE,d7
cmp.l #MODE_EDIT,d7
bne .skipred
move.l VAR_MEMV_EA,d7
add.l #2,d7
cmp.l d7,a1
bne .skipred
move.w #COLOR_RED,d2
move.l VAR_MEMV_FIRE,d7
or.l d7,d7
beq .skipred
move.w VAR_MEMV_DT,d3 ;print buffered value
move.l VAR_MEMV_FLASH,d7
btst.l #4,d7
beq .skipred
movem.l D5, -(A7)
movem.l VAR_MEMV_EDITP,d5
jsr print_flashing_num
movem.l (A7)+, D5
bra .omin
.skipred:
jsr print_num
.omin:
add.w #4,d0
;3a 2d
move.w #COLOR_WHITE,d2
moveq.l #$2d,d3
cmp.w #0,d5
beq .skip
jsr print_char
.skip:
add.w #1,d0
dbra d5,.loopx
add.w #1,d1
dbra d6,.loopy
movem.l (A7)+, D0-D7/A0-A6
rts