Skip to content

Commit 1986b91

Browse files
committed
Added tool for changing the arrow key configuration
1 parent 850f91e commit 1986b91

File tree

5 files changed

+108
-0
lines changed

5 files changed

+108
-0
lines changed

arch/nano-z80/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ By default, only drive `A:` is formatted. To use the additional drives, run `mkf
2121

2222
UART B (the one on the TTL UART header) supports changing baudrates, this can be done either using the `baudrate.com` tool or from inside `nanoterm`.
2323

24+
The USB keyboard arrow key configuration defaults to ADM3A key codes. This can be changed to WordStar or EMACS/MINCE key codes with the `arrowkey.com` tool.
25+
2426
If you put the SD-card in a SD-card reader on a Linux machine, the diskdefs file in the
2527
cpmish root allows you to read and write files to the A: drive, e.g.:
2628

arch/nano-z80/build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"colorfg.com": "arch/nano-z80/tools+colorfg",
7979
"colorbg.com": "arch/nano-z80/tools+colorbg",
8080
"cls.com" : "arch/nano-z80/tools+cls",
81+
"arrowkey.com" : "arch/nano-z80/tools+arrowkey",
8182
},
8283
)
8384

arch/nano-z80/include/nano-z80.lib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ USB_GAME_BUT2 equ $07 ; USB gamepad buttons reg 2
5151
USB_NEW_REP equ $08 ; USB new report available
5252
USB_DEV_TYPE equ $09 ; USB device type
5353
USB_ERROR equ $0a ; USB error
54+
USB_ARROWKEY equ $0b ; USB keyboard arrow key configuration
5455
KB_AVAIL equ $74 ; Keyboard character available, non-banked
5556
KB_CHAR equ $75 ; Keyboard character, non-banked
5657

arch/nano-z80/tools/arrowkey.z80

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
maclib addresses
2+
3+
IOBANK = 0x7f
4+
IO_SELECT_USB = 0x02
5+
USB_ARROWKEY = 0x0b
6+
7+
8+
cseg
9+
org 0x100
10+
11+
call print_string_inline
12+
db "nano-z80 arrow key configuration tool"
13+
db 13,10
14+
db 13,10
15+
db "Current arrow key setting: "
16+
db 0
17+
; Print the current setting
18+
ld a, IO_SELECT_USB
19+
out (IOBANK), a
20+
in a,(USB_ARROWKEY)
21+
22+
cp 0
23+
jr nz, checkws
24+
call print_string_inline
25+
db "ADM3A"
26+
db 0
27+
jr check_done
28+
checkws:
29+
cp 1
30+
jr nz, checkemacs
31+
call print_string_inline
32+
db "WordStar"
33+
db 0
34+
jr check_done
35+
checkemacs:
36+
cp 2
37+
jr nz, check_3
38+
call print_string_inline
39+
db "EMACS/MINCE"
40+
db 0
41+
jr check_done
42+
check_3:
43+
; No check needed
44+
call print_string_inline
45+
db "ADM3A (redundant)"
46+
db 0
47+
check_done:
48+
call print_string_inline
49+
db 13,10,13,10
50+
db "Please select new configuration:"
51+
db 13,10
52+
db "1: ADM3A"
53+
db 13,10
54+
db "2: WordStar"
55+
db 13,10
56+
db "3: EMACS/MINCE"
57+
db 13,10,0
58+
59+
; Get input
60+
call BBASE+0x09 ; CONIN
61+
cp '1'
62+
jr c, illegal_input
63+
cp '4'
64+
jr c, accepted_input
65+
jr illegal_input
66+
accepted_input:
67+
dec a
68+
ld b, a
69+
ld a, IO_SELECT_USB
70+
out (IOBANK), a
71+
ld a, b
72+
out (USB_ARROWKEY), a
73+
call print_string_inline
74+
db 13,10
75+
db "Configuration updated"
76+
db 0
77+
ret
78+
79+
illegal_input:
80+
call print_string_inline
81+
db 13,10
82+
db "Illegal selection"
83+
db 0
84+
ret
85+
print_string_inline:
86+
pop hl
87+
ld a,(hl)
88+
inc hl
89+
push hl
90+
cp 0
91+
ret z
92+
ld c, a
93+
call BBASE+0x0c ; CONOUT
94+
jr print_string_inline
95+
96+

arch/nano-z80/tools/build.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
],
3838
)
3939

40+
zmac(
41+
name="arrowkey",
42+
relocatable=False,
43+
src="./arrowkey.z80",
44+
deps=[
45+
"arch/nano-z80+addresses",
46+
],
47+
)
4048

4149
ackprogram(
4250
name="nanoterm",

0 commit comments

Comments
 (0)