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
| handle_key: # 0x17c
push r16
mov r30, r24
lds r24, last_key
cp r30, r24
breq do_ret # return if same as last key
cpi r30, 0xFF
breq do_ret # return if no/wrong key
lds r24, index
subi r24, 0xFF # index++
sts index, r24
sts last_key, r30 # save last_key
ldi r25, 0
ldi r22, 0xE8
ldi r23, 0
rcall mul_16 # write_pos = index * 0x00e8
ldi r22, 0xBF
ldi r23, 0x5A
rcall div_mod2 # wraped = write_pos % 0x5abf
# tmp = write_pos / 0x5abf
movw r18, r24
subi r18, 0xFF # wraped++
sbci r19, 0xFF
movw r24, r18
ldi r22, 0x84
ldi r23, 0
rcall div_mod # x = wraped % 0x0084
# y = wraped / 0x0084
mov r18, r22
mov r20, r24
mov r24, r30
ldi r22, 0x19
rcall mul_8 # val = key * 0x19
mov r16, r24
mov r24, r20
mov r22, r18
rcall send_data # send_data(x,y,x,y, val)
lds r24, index
ldi r22, 0x19
rcall mul_8 # val = index * 0x25
mov r16, r24
ldi r24, 0
ldi r22, 0
ldi r20, 0
ldi r18, 0
rcall send_data # send_data(0,0,0,0,val)
do_ret:
pop r16
ret
|