-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcmds.asm
137 lines (132 loc) · 2.98 KB
/
cmds.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
#import "globals.asm"
#import "userport-drv.asm"
#import "screen.asm"
// .segment _cmds
noop:
rts
prep_cmd:
tax // cmd nr now in x
lda #0
clc
!: adc #4 // all commands have exactly 4 chars
dex
bne !-
tax
ldy #0
!:
lda cmd_start,x
sta cmd_lit,y
inx
iny
cpy #4
bne !-
rts
echo:
lda #$1
jsr prep_cmd
ldx #0
stx parport.len + 1
ldx #4
!l: lda cmd_lit,x
beq !+
inx
jmp !l-
!: inx // send also the '0' char
stx parport.len
stx cmd_tmp
poke16_(parport.buffer, cmd_lit)
jsr parport.write_buffer
ldx cmd_tmp
dex // 4 chars command + '0'
dex
dex
dex
dex
lda #$0
sta gl.dest_mem,x // terminate string
stx cmd_args
ldx #0
stx cmd_args + 1
jsr do_rcv
rts
dump1:
lda #$02
jsr prep_cmd
ldx #6
uport_write_f(cmd_lit)
do_rcv:
uport_read(gl.dest_mem, cmd_args)
rts
read:
lda #$03
jmp dump1
rts
mandel:
lda #$04
jsr prep_cmd
ldx #10 // 4 byte cmd, 2x3byte for coordinates
uport_write_f(cmd_lit)
//poke16_(cmd_args, 8000)
//uport_sread(gl.dest_mem, cmd_args)
jsr gfx.do_cmds_entry
rts
dump2:
lda #$05
jsr prep_cmd
ldx #6
uport_write_f(cmd_lit)
// dump back our rcv buffer with requested length
uport_write(gl.dest_mem, cmd_args)
rts
irc_:
lda #$06
jsr prep_cmd
ldx #4
uport_write_f(cmd_lit)
rts
dump3:
lda #$02
jsr prep_cmd
ldx #6
uport_write_f(cmd_lit)
uport_sread(gl.dest_mem, cmd_args)
rts
do_arith:
lda #$08
jsr prep_cmd
ldx gfx.cmd_len
uport_write_f(cmd_lit) // XXX be smarter and optimze
//uport_write(cmd_lit, gfx.cmd_len)
//poke16_(cmd_args, 6)
//uport_sread(STD.FAC1, cmd_args) // expect one FLPT result
ldx #6
uport_sread_f(STD.FAC1) // expect one FLPT result
rts
do_espplot:
lda #$09
jsr prep_cmd
ldx #5
uport_write_f(cmd_lit)
jsr gfx.do_cmds_entry
rts
// numeric int args: max 16bit in little endian format
// string args: '0' as terminator
// commands must have exactly 4 chars
cmd_tmp: .byte $00
cmd: .byte $00 // poke the cmd nr. here
cmd_start:
cmd_init: .text "INIT" /* INIT<1|0> gfx on or off */
cmd_sndstr: .text "ECHO" /* ECHO<addr> */
cmd_dump1: .text "DUM1" /* DUM1<len> */
cmd_read: .text "READ"
cmd_mandel: .text "MAND" /* MAND<16bx8by> */
cmd_dump2: .text "DUM2" /* DUM2<len> */
cmd_irc: .text "IRC_" /* IRC_ */
cmd_dump3: .text "DUM3" /* DUM3<len> - synchronous read*/
cmd_arith: .text "ARIT" /* ARIT<fn-code byte><args> - uC math funcs */
cmd_esppl: .text "PLOT" /* PLOT<plot# as one byte> */
.align $100 // needed to support optimized write
cmd_lit: .fill 4, $00 // here the command is put
cmd_args: .fill 256, i // poke the args here
cmd_inv: .text "INVALID COMMAND."
.byte $00