diff --git a/Source/HBIOS/Config/RCEZ80_std.asm b/Source/HBIOS/Config/RCEZ80_std.asm index e9f7d2db..c6ba7487 100644 --- a/Source/HBIOS/Config/RCEZ80_std.asm +++ b/Source/HBIOS/Config/RCEZ80_std.asm @@ -54,9 +54,9 @@ FPSW_ENABLE .SET FALSE ; FP: ENABLES FRONT PANEL SWITCHES CRTACT .SET FALSE ; ACTIVATE CRT (VDU,CVDU,PROPIO,ETC) AT STARTUP VDAEMU_SERKBD .SET $FF ; VDA EMULATION: SERIAL KBD UNIT #, OR $FF FOR HW KBD ;; -TMSENABLE .SET FALSE ; TMS: ENABLE TMS9918 VIDEO/KBD DRIVER (TMS.ASM) -TMSMODE .SET TMSMODE_MSX ; TMS: DRIVER MODE: TMSMODE_[SCG|N8|MSX|MSXKBD|MSXMKY|MBC|COLECO|DUO|NABU] -TMS80COLS .SET FALSE ; TMS: ENABLE 80 COLUMN SCREEN, REQUIRES V9958 +TMSENABLE .SET TRUE ; TMS: ENABLE TMS9918 VIDEO/KBD DRIVER (TMS.ASM) +TMSMODE .SET TMSMODE_MSXUKY ; TMS: DRIVER MODE: TMSMODE_[SCG|N8|MSX|MSXKBD|MSXMKY|MBC|COLECO|DUO|NABU|MSXUKY] +TMS80COLS .SET TRUE ; TMS: ENABLE 80 COLUMN SCREEN, REQUIRES V9958 TMSTIMENABLE .SET FALSE ; TMS: ENABLE TIMER INTERRUPTS (REQUIRES IM1) VRCENABLE .SET FALSE ; VRC: ENABLE VGARC VIDEO/KBD DRIVER (VRC.ASM) EFENABLE .SET FALSE ; EF: ENABLE EF9345 VIDEO DRIVER (EF.ASM) @@ -89,3 +89,5 @@ CH1USBENABLE .SET FALSE ; CH376: ENABLE CH376 USB DRIVER CHNATIVEENABLE .SET TRUE ; CH376: ENABLE CH376 NATIVE USB DRIVER CHSCSIENABLE .SET TRUE ; CH376: ENABLE CH376 NATIVE MASS STORAGE DEVICES (REQUIRES CHNATIVEENABLE) CHUFIENABLE .SET TRUE ; CH376: ENABLE CH376 NATIVE UFI FLOPPY DISK DEVICES (REQUIRES CHNATIVEENABLE) + +EZ80TIMER .SET EZ80TMR_INT ; EZ80: TIMER TICK MODEL: EZ80TMR_[INT|FIRM] diff --git a/Source/HBIOS/cfg_RCEZ80.asm b/Source/HBIOS/cfg_RCEZ80.asm index 508548ae..b31bd5d2 100644 --- a/Source/HBIOS/cfg_RCEZ80.asm +++ b/Source/HBIOS/cfg_RCEZ80.asm @@ -249,7 +249,7 @@ VDUENABLE .SET FALSE ; VDU: ENABLE VDU VIDEO/KBD DRIVER (VDU.ASM) CVDUENABLE .SET FALSE ; CVDU: ENABLE CVDU VIDEO/KBD DRIVER (CVDU.ASM) GDCENABLE .SET FALSE ; GDC: ENABLE 7220 GDC VIDEO/KBD DRIVER (GDC.ASM) TMSENABLE .SET FALSE ; TMS: ENABLE TMS9918 VIDEO/KBD DRIVER (TMS.ASM) -TMSMODE .SET TMSMODE_MSX ; TMS: DRIVER MODE: TMSMODE_[SCG|N8|MSX|MSXKBD|MSXMKY|MBC|COLECO|DUO|NABU] +TMSMODE .SET TMSMODE_MSX ; TMS: DRIVER MODE: TMSMODE_[SCG|N8|MSX|MSXKBD|MSXMKY|MBC|COLECO|DUO|NABU|MSXUKY] TMS80COLS .SET FALSE ; TMS: ENABLE 80 COLUMN SCREEN, REQUIRES V9958 TMSTIMENABLE .SET FALSE ; TMS: ENABLE TIMER INTERRUPTS (REQUIRES IM1) VGAENABLE .SET FALSE ; VGA: ENABLE VGA VIDEO/KBD DRIVER (VGA.ASM) diff --git a/Source/HBIOS/ch376-native/Makefile b/Source/HBIOS/ch376-native/Makefile index 78963327..27dd21f7 100644 --- a/Source/HBIOS/ch376-native/Makefile +++ b/Source/HBIOS/ch376-native/Makefile @@ -18,7 +18,7 @@ ZCC := zcc +z80 -vn -startup=0 -clib=sdcc_iy -crt0 $(SRC)crt.asm -compiler=sdcc ASSDIR := ./ -all: $(ASSDIR)base-drv.s $(ASSDIR)scsi-drv.s $(ASSDIR)ufi-drv.s +all: $(ASSDIR)base-drv.s $(ASSDIR)scsi-drv.s $(ASSDIR)ufi-drv.s $(ASSDIR)keyboard.s clean: @rm -rf base-drv @@ -52,6 +52,15 @@ $(ASSDIR)ufi-drv.s: echo '#include "'ch376-native/ufi-drv/$${dep}'"' >> $(ASSDIR)ufi-drv.s done +$(ASSDIR)keyboard.s: + @echo "Creating keyboard.s" + echo "; Generated File -- not to be modify directly" > $(ASSDIR)keyboard.s + for dep in $^; do + dep=$${dep#*/} + dep=$${dep#*/} + echo '#include "'ch376-native/keyboard/$${dep}'"' >> $(ASSDIR)keyboard.s + done + $(ASSDIR)%.c.s: $(ASSDIR)%.c.asm @mkdir -p $(dir $@) echo "Converting $< to $@" @@ -70,6 +79,7 @@ endef $(ASSDIR)base-drv/%.c.asm: $(SRC)base-drv/%.c; $(compile) $(ASSDIR)scsi-drv/%.c.asm: $(SRC)scsi-drv/%.c; $(compile) +$(ASSDIR)keyboard/%.c.asm: $(SRC)keyboard/%.c; $(compile) $(ASSDIR)ufi-drv/%.c.asm: $(SRC)ufi-drv/%.c; $(compile) $(ASSDIR)%.c.asm: $(SRC)%.c; $(compile) $(ASSDIR)libraries/delay/%.c.asm: ../apps/libraries/delay/%.c; $(compile) @@ -133,6 +143,17 @@ deps: printf "ufi-drv/$$file.s " >> ${SRC}/depends.d done + printf "\r\n" >> ${SRC}/depends.d + # # configure keyboard.s to all .s files + printf "##\r\n" >> ${SRC}/depends.d + printf "./keyboard.s: " >> ${SRC}/depends.d + (cd ${SRC}/keyboard && find -name "*.c") | while read -r file; do + file_no_ext="$${file%.*}" + file_no_ext=$${file_no_ext#./} + filename=$$(basename $$file_no_ext) + printf "keyboard/$$file.s " >> ${SRC}/depends.d + done + echo "" >> ${SRC}/depends.d echo "${SRC}depends.d created" diff --git a/Source/HBIOS/ch376-native/base-drv.s b/Source/HBIOS/ch376-native/base-drv.s index 6aa5aa97..45005e37 100644 --- a/Source/HBIOS/ch376-native/base-drv.s +++ b/Source/HBIOS/ch376-native/base-drv.s @@ -7,7 +7,6 @@ #include "ch376-native/base-drv/enumerate_hub.c.s" #include "ch376-native/base-drv/usb-base-drv.c.s" #include "ch376-native/base-drv/transfers.c.s" -#include "ch376-native/base-drv/print.c.s" #include "ch376-native/base-drv/ch376.c.s" #include "ch376-native/base-drv/protocol.c.s" #include "ch376-native/base-drv/work-area.c.s" diff --git a/Source/HBIOS/ch376-native/base-drv/class_hid.c.s b/Source/HBIOS/ch376-native/base-drv/class_hid.c.s new file mode 100644 index 00000000..6d750eec --- /dev/null +++ b/Source/HBIOS/ch376-native/base-drv/class_hid.c.s @@ -0,0 +1,254 @@ +; +; Generated from source-doc/base-drv/./class_hid.c.asm -- not to be modify directly +; +; +;-------------------------------------------------------- +; File Created by SDCC : free open source ISO C Compiler +; Version 4.4.0 #14648 (Linux) +;-------------------------------------------------------- +; Processed by Z88DK +;-------------------------------------------------------- + + +;-------------------------------------------------------- +; Public variables in this module +;-------------------------------------------------------- +;-------------------------------------------------------- +; Externals used +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +_CH376_DATA_PORT .EQU 0xff88 +_CH376_COMMAND_PORT .EQU 0xff89 +_USB_MODULE_LEDS .EQU 0xff8a +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- + +#IF 0 + +; .area _INITIALIZED removed by z88dk + + +#ENDIF + +;-------------------------------------------------------- +; absolute external ram data +;-------------------------------------------------------- +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- +;-------------------------------------------------------- +; Home +;-------------------------------------------------------- +;-------------------------------------------------------- +; code +;-------------------------------------------------------- +;source-doc/base-drv/./class_hid.c:6: usb_error hid_set_protocol(const device_config_keyboard *const dev, const uint8_t protocol) __sdcccall(1) { +; --------------------------------- +; Function hid_set_protocol +; --------------------------------- +_hid_set_protocol: + push ix + ld ix,0 + add ix,sp + push af + push af + push af + push af + ex de, hl +;source-doc/base-drv/./class_hid.c:9: cmd = cmd_hid_set; + push de + ex de, hl + ld hl,2 + add hl, sp + ex de, hl + ld hl,_cmd_hid_set + ld bc,0x0008 + ldir + pop de +;source-doc/base-drv/./class_hid.c:11: cmd.bRequest = HID_SET_PROTOCOL; + ld (ix-7),0x0b +;source-doc/base-drv/./class_hid.c:12: cmd.bValue[0] = protocol; + ld a,(ix+4) + ld (ix-6),a +;source-doc/base-drv/./class_hid.c:14: result = usb_control_transfer(&cmd, NULL, dev->address, dev->max_packet_size); + ld l, e + ld h, d + inc hl + ld c, (hl) + ex de, hl + ld a, (hl) + rlca + rlca + rlca + rlca + and 0x0f + ld h, c + push hl + inc sp + push af + inc sp + ld hl,0x0000 + push hl + ld hl,4 + add hl, sp + push hl + call _usb_control_transfer + pop af + pop af + pop af + ld a, l +;source-doc/base-drv/./class_hid.c:16: RETURN_CHECK(result); +;source-doc/base-drv/./class_hid.c:17: } + ld sp, ix + pop ix + pop hl + inc sp + jp (hl) +_cmd_hid_set: + DEFB +0x21 + DEFB +0x0b + DEFB +0x00 + DEFB +0x00 + DEFB +0x00 + DEFB +0x00 + DEFW +0x0000 +;source-doc/base-drv/./class_hid.c:19: usb_error hid_set_idle(const device_config_keyboard *const dev, const uint8_t duration) __sdcccall(1) { +; --------------------------------- +; Function hid_set_idle +; --------------------------------- +_hid_set_idle: + push ix + ld ix,0 + add ix,sp + push af + push af + push af + push af + ex de, hl +;source-doc/base-drv/./class_hid.c:22: cmd = cmd_hid_set; + push de + ex de, hl + ld hl,2 + add hl, sp + ex de, hl + ld hl,_cmd_hid_set + ld bc,0x0008 + ldir + pop de +;source-doc/base-drv/./class_hid.c:24: cmd.bRequest = HID_SET_IDLE; + ld (ix-7),0x0a +;source-doc/base-drv/./class_hid.c:25: cmd.bValue[0] = duration; + ld a,(ix+4) + ld (ix-6),a +;source-doc/base-drv/./class_hid.c:27: result = usb_control_transfer(&cmd, NULL, dev->address, dev->max_packet_size); + ld l, e + ld h, d + inc hl + ld c, (hl) + ex de, hl + ld a, (hl) + rlca + rlca + rlca + rlca + and 0x0f + ld h, c + push hl + inc sp + push af + inc sp + ld hl,0x0000 + push hl + ld hl,4 + add hl, sp + push hl + call _usb_control_transfer + pop af + pop af + pop af + ld a, l +;source-doc/base-drv/./class_hid.c:29: RETURN_CHECK(result); +;source-doc/base-drv/./class_hid.c:30: } + ld sp, ix + pop ix + pop hl + inc sp + jp (hl) +;source-doc/base-drv/./class_hid.c:32: usb_error hid_get_input_report(const device_config_keyboard *const dev, uint8_t const *report) __sdcccall(1) { +; --------------------------------- +; Function hid_get_input_report +; --------------------------------- +_hid_get_input_report: + push ix + ld ix,0 + add ix,sp + ld c, l + ld b, h + ld hl, -9 + add hl, sp + ld sp, hl + ld l, c + ld h, b +;source-doc/base-drv/./class_hid.c:35: cmd = cmd_hid_set; + push de + push hl + ex de, hl + ld hl,4 + add hl, sp + ex de, hl + ld hl,_cmd_hid_set + ld bc,0x0008 + ldir + pop bc + pop de +;source-doc/base-drv/./class_hid.c:37: cmd.bmRequestType = 0xA1; + ld (ix-9),0xa1 +;source-doc/base-drv/./class_hid.c:38: cmd.bValue[0] = 1; + ld (ix-7),0x01 +;source-doc/base-drv/./class_hid.c:39: cmd.bValue[1] = 1; + ld (ix-6),0x01 +;source-doc/base-drv/./class_hid.c:40: cmd.bRequest = HID_GET_REPORT; + ld (ix-8),0x01 +;source-doc/base-drv/./class_hid.c:41: cmd.wLength = 8; + ld (ix-3),0x08 + xor a + ld (ix-2),a +;source-doc/base-drv/./class_hid.c:43: result = usb_control_transfer(&cmd, report, dev->address, dev->max_packet_size); + ld l, c + ld h, b + inc hl + ld a, (hl) + ld (ix-1),a + ld l, c + ld h, b + ld a, (hl) + rlca + rlca + rlca + rlca + and 0x0f + ld h,(ix-1) + push hl + inc sp + push af + inc sp + push de + ld hl,4 + add hl, sp + push hl + call _usb_control_transfer + pop af + pop af + pop af + ld a, l +;source-doc/base-drv/./class_hid.c:45: RETURN_CHECK(result); +;source-doc/base-drv/./class_hid.c:46: } + ld sp, ix + pop ix + ret diff --git a/Source/HBIOS/ch376-native/base-drv/usb-base-drv.c.s b/Source/HBIOS/ch376-native/base-drv/usb-base-drv.c.s index 242ccf70..3728d20a 100644 --- a/Source/HBIOS/ch376-native/base-drv/usb-base-drv.c.s +++ b/Source/HBIOS/ch376-native/base-drv/usb-base-drv.c.s @@ -33,8 +33,6 @@ _USB_MODULE_LEDS .EQU 0xff8a ; .area _INITIALIZED removed by z88dk -_storage_count: - DEFS 1 #ENDIF @@ -87,5 +85,3 @@ _chnative_seek: pop hl pop bc jp (hl) -_storage_count: - DEFB +0x00 diff --git a/Source/HBIOS/ch376-native/base-drv/usb-init.c.s b/Source/HBIOS/ch376-native/base-drv/usb-init.c.s index db185d27..5145ebfc 100644 --- a/Source/HBIOS/ch376-native/base-drv/usb-init.c.s +++ b/Source/HBIOS/ch376-native/base-drv/usb-init.c.s @@ -94,7 +94,7 @@ _usb_host_bus_reset: _chnative_init: ;source-doc/base-drv/./usb-init.c:26: memset(get_usb_work_area(), 0, sizeof(_usb_state)); ld hl,_x - ld b,0x69 + ld b,0x63 l_chnative_init_00139: ld (hl),0x00 inc hl diff --git a/Source/HBIOS/ch376-native/base-drv/usb_state.c.s b/Source/HBIOS/ch376-native/base-drv/usb_state.c.s index d1352853..b292e052 100644 --- a/Source/HBIOS/ch376-native/base-drv/usb_state.c.s +++ b/Source/HBIOS/ch376-native/base-drv/usb_state.c.s @@ -92,8 +92,8 @@ l_find_device_config_00106: ret _device_config_sizes: DEFB +0x00 - DEFB +0x11 - DEFB +0x11 + DEFB +0x10 + DEFB +0x10 DEFB +0x0c DEFB +0x06 DEFB 0x00 @@ -175,7 +175,7 @@ l_next_device_config_00102: add hl, de ex de, hl ;source-doc/base-drv/./usb_state.c:61: if (result >= (device_config *)&usb_state->device_configs_end) - ld hl,0x0068 + ld hl,0x0062 add hl, bc ld a, e sub l @@ -193,79 +193,41 @@ l_next_device_config_00105: ; Function get_usb_device_config ; --------------------------------- _get_usb_device_config: - push ix - ld ix,0 - add ix,sp - push af - ld (ix-1),a + ld c, a ;source-doc/base-drv/./usb_state.c:69: const _usb_state *const usb_state = get_usb_work_area(); -;source-doc/base-drv/./usb_state.c:71: uint8_t counter = 1; - ld (ix-2),0x01 ;source-doc/base-drv/./usb_state.c:73: for (device_config *p = first_device_config(usb_state); p; p = next_device_config(usb_state, p)) { + push bc ld hl,_x call _first_device_config - ld c,0x01 -l_get_usb_device_config_00112: + pop bc + ld b,0x01 +l_get_usb_device_config_00107: ld a, d or e jr Z,l_get_usb_device_config_00105 -;source-doc/base-drv/./usb_state.c:74: if (p->type == USB_IS_FLOPPY) { +;source-doc/base-drv/./usb_state.c:74: if (p->type != USB_NOT_SUPPORTED) { ld l, e ld h, d ld a, (hl) and 0x0f - dec a - jr NZ,l_get_usb_device_config_00113 + jr Z,l_get_usb_device_config_00108 ;source-doc/base-drv/./usb_state.c:75: if (counter == device_index) - ld a,(ix-1) - sub c + ld a, c + sub b ;source-doc/base-drv/./usb_state.c:76: return p; - jr Z,l_get_usb_device_config_00117 + jr Z,l_get_usb_device_config_00109 ;source-doc/base-drv/./usb_state.c:77: counter++; - inc c - ld (ix-2),c -l_get_usb_device_config_00113: + inc b +l_get_usb_device_config_00108: ;source-doc/base-drv/./usb_state.c:73: for (device_config *p = first_device_config(usb_state); p; p = next_device_config(usb_state, p)) { push bc ld hl,_x call _next_device_config pop bc - jr l_get_usb_device_config_00112 + jr l_get_usb_device_config_00107 l_get_usb_device_config_00105: -;source-doc/base-drv/./usb_state.c:81: for (device_config *p = first_device_config(usb_state); p; p = next_device_config(usb_state, p)) { - ld hl,_x - call _first_device_config - ld c,(ix-2) -l_get_usb_device_config_00115: - ld a, d - or e - jr Z,l_get_usb_device_config_00110 -;source-doc/base-drv/./usb_state.c:82: if (p->type == USB_IS_MASS_STORAGE) { - ld l, e - ld h, d - ld a, (hl) - and 0x0f - sub 0x02 - jr NZ,l_get_usb_device_config_00116 -;source-doc/base-drv/./usb_state.c:83: if (counter == device_index) - ld a,(ix-1) - sub c -;source-doc/base-drv/./usb_state.c:84: return p; - jr Z,l_get_usb_device_config_00117 -;source-doc/base-drv/./usb_state.c:85: counter++; - inc c -l_get_usb_device_config_00116: -;source-doc/base-drv/./usb_state.c:81: for (device_config *p = first_device_config(usb_state); p; p = next_device_config(usb_state, p)) { - push bc - ld hl,_x - call _next_device_config - pop bc - jr l_get_usb_device_config_00115 -l_get_usb_device_config_00110: -;source-doc/base-drv/./usb_state.c:89: return NULL; // is not a usb device +;source-doc/base-drv/./usb_state.c:81: return NULL; // is not a usb device ld de,0x0000 -l_get_usb_device_config_00117: -;source-doc/base-drv/./usb_state.c:90: } - ld sp, ix - pop ix +l_get_usb_device_config_00109: +;source-doc/base-drv/./usb_state.c:82: } ret diff --git a/Source/HBIOS/ch376-native/base-drv/work-area.c.s b/Source/HBIOS/ch376-native/base-drv/work-area.c.s index e084ee41..23f946c7 100644 --- a/Source/HBIOS/ch376-native/base-drv/work-area.c.s +++ b/Source/HBIOS/ch376-native/base-drv/work-area.c.s @@ -34,7 +34,7 @@ _USB_MODULE_LEDS .EQU 0xff8a ; .area _INITIALIZED removed by z88dk _x: - DEFS 105 + DEFS 99 #ENDIF @@ -149,10 +149,4 @@ _x: DEFB 0x00 DEFB 0x00 DEFB 0x00 - DEFB 0x00 - DEFB 0x00 - DEFB 0x00 - DEFB 0x00 - DEFB 0x00 - DEFB 0x00 DEFB +0x00 diff --git a/Source/HBIOS/ch376-native/keyboard.s b/Source/HBIOS/ch376-native/keyboard.s new file mode 100644 index 00000000..5e459709 --- /dev/null +++ b/Source/HBIOS/ch376-native/keyboard.s @@ -0,0 +1,3 @@ +; Generated File -- not to be modify directly +#include "ch376-native/keyboard/kyb-init.c.s" +#include "ch376-native/keyboard/class_hid.c.s" diff --git a/Source/HBIOS/ch376-native/keyboard/class_hid.c.s b/Source/HBIOS/ch376-native/keyboard/class_hid.c.s new file mode 100644 index 00000000..38fa0e15 --- /dev/null +++ b/Source/HBIOS/ch376-native/keyboard/class_hid.c.s @@ -0,0 +1,254 @@ +; +; Generated from source-doc/keyboard/./class_hid.c.asm -- not to be modify directly +; +; +;-------------------------------------------------------- +; File Created by SDCC : free open source ISO C Compiler +; Version 4.4.0 #14648 (Linux) +;-------------------------------------------------------- +; Processed by Z88DK +;-------------------------------------------------------- + + +;-------------------------------------------------------- +; Public variables in this module +;-------------------------------------------------------- +;-------------------------------------------------------- +; Externals used +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +_CH376_DATA_PORT .EQU 0xff88 +_CH376_COMMAND_PORT .EQU 0xff89 +_USB_MODULE_LEDS .EQU 0xff8a +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- + +#IF 0 + +; .area _INITIALIZED removed by z88dk + + +#ENDIF + +;-------------------------------------------------------- +; absolute external ram data +;-------------------------------------------------------- +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- +;-------------------------------------------------------- +; Home +;-------------------------------------------------------- +;-------------------------------------------------------- +; code +;-------------------------------------------------------- +;source-doc/keyboard/./class_hid.c:6: usb_error hid_set_protocol(const device_config_keyboard *const dev, const uint8_t protocol) __sdcccall(1) { +; --------------------------------- +; Function hid_set_protocol +; --------------------------------- +_hid_set_protocol: + push ix + ld ix,0 + add ix,sp + push af + push af + push af + push af + ex de, hl +;source-doc/keyboard/./class_hid.c:9: cmd = cmd_hid_set; + push de + ex de, hl + ld hl,2 + add hl, sp + ex de, hl + ld hl,_cmd_hid_set + ld bc,0x0008 + ldir + pop de +;source-doc/keyboard/./class_hid.c:11: cmd.bRequest = HID_SET_PROTOCOL; + ld (ix-7),0x0b +;source-doc/keyboard/./class_hid.c:12: cmd.bValue[0] = protocol; + ld a,(ix+4) + ld (ix-6),a +;source-doc/keyboard/./class_hid.c:14: result = usb_control_transfer(&cmd, NULL, dev->address, dev->max_packet_size); + ld l, e + ld h, d + inc hl + ld c, (hl) + ex de, hl + ld a, (hl) + rlca + rlca + rlca + rlca + and 0x0f + ld h, c + push hl + inc sp + push af + inc sp + ld hl,0x0000 + push hl + ld hl,4 + add hl, sp + push hl + call _usb_control_transfer + pop af + pop af + pop af + ld a, l +;source-doc/keyboard/./class_hid.c:16: RETURN_CHECK(result); +;source-doc/keyboard/./class_hid.c:17: } + ld sp, ix + pop ix + pop hl + inc sp + jp (hl) +_cmd_hid_set: + DEFB +0x21 + DEFB +0x0b + DEFB +0x00 + DEFB +0x00 + DEFB +0x00 + DEFB +0x00 + DEFW +0x0000 +;source-doc/keyboard/./class_hid.c:19: usb_error hid_set_idle(const device_config_keyboard *const dev, const uint8_t duration) __sdcccall(1) { +; --------------------------------- +; Function hid_set_idle +; --------------------------------- +_hid_set_idle: + push ix + ld ix,0 + add ix,sp + push af + push af + push af + push af + ex de, hl +;source-doc/keyboard/./class_hid.c:22: cmd = cmd_hid_set; + push de + ex de, hl + ld hl,2 + add hl, sp + ex de, hl + ld hl,_cmd_hid_set + ld bc,0x0008 + ldir + pop de +;source-doc/keyboard/./class_hid.c:24: cmd.bRequest = HID_SET_IDLE; + ld (ix-7),0x0a +;source-doc/keyboard/./class_hid.c:25: cmd.bValue[0] = duration; + ld a,(ix+4) + ld (ix-6),a +;source-doc/keyboard/./class_hid.c:27: result = usb_control_transfer(&cmd, NULL, dev->address, dev->max_packet_size); + ld l, e + ld h, d + inc hl + ld c, (hl) + ex de, hl + ld a, (hl) + rlca + rlca + rlca + rlca + and 0x0f + ld h, c + push hl + inc sp + push af + inc sp + ld hl,0x0000 + push hl + ld hl,4 + add hl, sp + push hl + call _usb_control_transfer + pop af + pop af + pop af + ld a, l +;source-doc/keyboard/./class_hid.c:29: RETURN_CHECK(result); +;source-doc/keyboard/./class_hid.c:30: } + ld sp, ix + pop ix + pop hl + inc sp + jp (hl) +;source-doc/keyboard/./class_hid.c:32: usb_error hid_get_input_report(const device_config_keyboard *const dev, uint8_t const *report) __sdcccall(1) { +; --------------------------------- +; Function hid_get_input_report +; --------------------------------- +_hid_get_input_report: + push ix + ld ix,0 + add ix,sp + ld c, l + ld b, h + ld hl, -9 + add hl, sp + ld sp, hl + ld l, c + ld h, b +;source-doc/keyboard/./class_hid.c:35: cmd = cmd_hid_set; + push de + push hl + ex de, hl + ld hl,4 + add hl, sp + ex de, hl + ld hl,_cmd_hid_set + ld bc,0x0008 + ldir + pop bc + pop de +;source-doc/keyboard/./class_hid.c:37: cmd.bmRequestType = 0xA1; + ld (ix-9),0xa1 +;source-doc/keyboard/./class_hid.c:38: cmd.bValue[0] = 1; + ld (ix-7),0x01 +;source-doc/keyboard/./class_hid.c:39: cmd.bValue[1] = 1; + ld (ix-6),0x01 +;source-doc/keyboard/./class_hid.c:40: cmd.bRequest = HID_GET_REPORT; + ld (ix-8),0x01 +;source-doc/keyboard/./class_hid.c:41: cmd.wLength = 8; + ld (ix-3),0x08 + xor a + ld (ix-2),a +;source-doc/keyboard/./class_hid.c:43: result = usb_control_transfer(&cmd, report, dev->address, dev->max_packet_size); + ld l, c + ld h, b + inc hl + ld a, (hl) + ld (ix-1),a + ld l, c + ld h, b + ld a, (hl) + rlca + rlca + rlca + rlca + and 0x0f + ld h,(ix-1) + push hl + inc sp + push af + inc sp + push de + ld hl,4 + add hl, sp + push hl + call _usb_control_transfer + pop af + pop af + pop af + ld a, l +;source-doc/keyboard/./class_hid.c:45: RETURN_CHECK(result); +;source-doc/keyboard/./class_hid.c:46: } + ld sp, ix + pop ix + ret diff --git a/Source/HBIOS/ch376-native/keyboard/kyb-init.c.s b/Source/HBIOS/ch376-native/keyboard/kyb-init.c.s new file mode 100644 index 00000000..ac8491a6 --- /dev/null +++ b/Source/HBIOS/ch376-native/keyboard/kyb-init.c.s @@ -0,0 +1,134 @@ +; +; Generated from source-doc/keyboard/./kyb-init.c.asm -- not to be modify directly +; +; +;-------------------------------------------------------- +; File Created by SDCC : free open source ISO C Compiler +; Version 4.4.0 #14648 (Linux) +;-------------------------------------------------------- +; Processed by Z88DK +;-------------------------------------------------------- + + +;-------------------------------------------------------- +; Public variables in this module +;-------------------------------------------------------- +;-------------------------------------------------------- +; Externals used +;-------------------------------------------------------- +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +_CH376_DATA_PORT .EQU 0xff88 +_CH376_COMMAND_PORT .EQU 0xff89 +_USB_MODULE_LEDS .EQU 0xff8a +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- + +#IF 0 + +; .area _INITIALIZED removed by z88dk + + +#ENDIF + +;-------------------------------------------------------- +; absolute external ram data +;-------------------------------------------------------- +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- +;-------------------------------------------------------- +; Home +;-------------------------------------------------------- +;-------------------------------------------------------- +; code +;-------------------------------------------------------- +;source-doc/keyboard/./kyb-init.c:8: void keyboard_init(void) { +; --------------------------------- +; Function keyboard_init +; --------------------------------- +_keyboard_init: +;source-doc/keyboard/./kyb-init.c:10: uint8_t index = 1; +;source-doc/keyboard/./kyb-init.c:11: do { + ld bc,0x0101 +l_keyboard_init_00105: +;source-doc/keyboard/./kyb-init.c:12: device_config_keyboard *const keyboard_config = (device_config_keyboard *)get_usb_device_config(index); + push bc + ld a, b + call _get_usb_device_config + pop bc +;source-doc/keyboard/./kyb-init.c:14: if (keyboard_config == NULL) + ld a, d + or e + jr Z,l_keyboard_init_00107 +;source-doc/keyboard/./kyb-init.c:17: const usb_device_type t = keyboard_config->type; + ld l, e + ld h, d + ld a, (hl) + and 0x0f +;source-doc/keyboard/./kyb-init.c:19: if (t == USB_IS_KEYBOARD) { + sub 0x04 + jr NZ,l_keyboard_init_00106 +;source-doc/keyboard/./kyb-init.c:20: print_string("\r\nUSB: KEYBOARD @ $"); + push bc + push de + ld hl,kyb_init_str_0 + call _print_string + pop de + pop bc +;source-doc/keyboard/./kyb-init.c:21: print_uint16(index); + ld h,0x00 + push de + ld l, c + call _print_uint16 + ld hl,kyb_init_str_1 + call _print_string + pop de +;source-doc/keyboard/./kyb-init.c:25: hid_set_protocol(keyboard_config, 1); + push de + ld a,0x01 + push af + inc sp + ex de,hl + call _hid_set_protocol + pop de +;source-doc/keyboard/./kyb-init.c:26: hid_set_idle(keyboard_config, 0x80); + ld a,0x80 + push af + inc sp + ex de, hl + call _hid_set_idle +;source-doc/keyboard/./kyb-init.c:27: return; + jr l_keyboard_init_00108 +l_keyboard_init_00106: +;source-doc/keyboard/./kyb-init.c:29: } while (++index != MAX_NUMBER_OF_DEVICES + 1); + inc b + ld a,b + ld c,a + sub 0x07 + jr NZ,l_keyboard_init_00105 +l_keyboard_init_00107: +;source-doc/keyboard/./kyb-init.c:31: print_string("\r\nUSB: KEYBOARD: NOT FOUND$"); + ld hl,kyb_init_str_2 + jp _print_string +l_keyboard_init_00108: +;source-doc/keyboard/./kyb-init.c:32: } + ret +kyb_init_str_0: + DEFB 0x0d + DEFB 0x0a + DEFM "USB: KEYBOARD @ $" + DEFB 0x00 +kyb_init_str_1: + DEFM " $" + DEFB 0x00 +kyb_init_str_2: + DEFB 0x0d + DEFB 0x0a + DEFM "USB: KEYBOARD: NOT FOUND$" + DEFB 0x00 diff --git a/Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s b/Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s index 025f5a54..78c5ef49 100644 --- a/Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s +++ b/Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s @@ -56,7 +56,7 @@ _chscsi_init: push ix ld ix,0 add ix,sp - push af + dec sp ;source-doc/scsi-drv/./scsi-init.c:15: do { ld (ix-1),0x01 l_chscsi_init_00105: @@ -75,7 +75,7 @@ l_chscsi_init_00105: ;source-doc/scsi-drv/./scsi-init.c:23: if (t == USB_IS_MASS_STORAGE) { sub 0x02 jr NZ,l_chscsi_init_00106 -;source-doc/scsi-drv/./scsi-init.c:24: print_string("\r\n MASS STORAGE @ $"); +;source-doc/scsi-drv/./scsi-init.c:24: print_string("\r\nUSB: MASS STORAGE @ $"); push de ld hl,scsi_init_str_0 call _print_string @@ -88,17 +88,6 @@ l_chscsi_init_00105: ld hl,scsi_init_str_1 call _print_string pop de -;source-doc/scsi-drv/./scsi-init.c:28: storage_device->drive_index = storage_count++; - ld hl,0x0010 - add hl, de - ld c, l - ld b, h - ld hl,_storage_count - ld a, (hl) - ld (ix-2),a - inc (hl) - ld a,(ix-2) - ld (bc), a ;source-doc/scsi-drv/./scsi-init.c:29: scsi_sense_init(storage_device); push de push de @@ -116,13 +105,13 @@ l_chscsi_init_00106: jr NZ,l_chscsi_init_00105 l_chscsi_init_00108: ;source-doc/scsi-drv/./scsi-init.c:34: } - ld sp, ix + inc sp pop ix ret scsi_init_str_0: DEFB 0x0d DEFB 0x0a - DEFM " MASS STORAGE @ $" + DEFM "USB: MASS STORAGE @ $" DEFB 0x00 scsi_init_str_1: DEFM " $" diff --git a/Source/HBIOS/ch376-native/source-doc/base-drv/dev_transfers.h b/Source/HBIOS/ch376-native/source-doc/base-drv/dev_transfers.h index 23cf0001..0c0a92eb 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/dev_transfers.h +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/dev_transfers.h @@ -39,7 +39,7 @@ typedef struct { COMMON_DEVICE_CONFIG // bytes: 0-2 endpoint_param endpoints[3]; // bytes: 3-5, 6-8, 9-11 bulk in/out and interrupt uint32_t current_lba; // bytes 12-15 - uint8_t drive_index; // byte 16 + // uint8_t drive_index; // byte 16 } device_config_storage; typedef struct { diff --git a/Source/HBIOS/ch376-native/source-doc/base-drv/usb-base-drv.c b/Source/HBIOS/ch376-native/source-doc/base-drv/usb-base-drv.c index 84b14855..a0ce48b2 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/usb-base-drv.c +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/usb-base-drv.c @@ -1,7 +1,7 @@ #include "usb-base-drv.h" -/* The total number of mounted storage devices (scsi and ufi) */ -uint8_t storage_count = 0; +/* The total number of mounted devices (scsi, ufi and keyboard) */ +// uint8_t usb_device_count = 0; uint8_t chnative_seek(const uint32_t lba, device_config_storage *const storage_device) __sdcccall(1) { storage_device->current_lba = lba; diff --git a/Source/HBIOS/ch376-native/source-doc/base-drv/usb-base-drv.h b/Source/HBIOS/ch376-native/source-doc/base-drv/usb-base-drv.h index 3d2abd53..0f1e89fc 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/usb-base-drv.h +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/usb-base-drv.h @@ -4,7 +4,7 @@ #include #include -extern uint8_t storage_count; +// extern uint8_t usb_device_count; extern uint8_t chnative_seek(const uint32_t lba, device_config_storage *const storage_device) __sdcccall(1); diff --git a/Source/HBIOS/ch376-native/source-doc/base-drv/usb_state.c b/Source/HBIOS/ch376-native/source-doc/base-drv/usb_state.c index 1138c9fe..fe6709b9 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/usb_state.c +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/usb_state.c @@ -71,15 +71,7 @@ device_config *get_usb_device_config(const uint8_t device_index) __sdcccall(1) { uint8_t counter = 1; for (device_config *p = first_device_config(usb_state); p; p = next_device_config(usb_state, p)) { - if (p->type == USB_IS_FLOPPY) { - if (counter == device_index) - return p; - counter++; - } - } - - for (device_config *p = first_device_config(usb_state); p; p = next_device_config(usb_state, p)) { - if (p->type == USB_IS_MASS_STORAGE) { + if (p->type != USB_NOT_SUPPORTED) { if (counter == device_index) return p; counter++; diff --git a/Source/HBIOS/ch376-native/source-doc/convert-for-uz80as.sh b/Source/HBIOS/ch376-native/source-doc/convert-for-uz80as.sh index 8c1a1286..c94c67c0 100755 --- a/Source/HBIOS/ch376-native/source-doc/convert-for-uz80as.sh +++ b/Source/HBIOS/ch376-native/source-doc/convert-for-uz80as.sh @@ -29,6 +29,7 @@ sed -E \ -e 's/\s+or\s+a,\((ix\+[0-9-]+)\)/\tor\t\(\1\)/g' \ -e 's/\s+or\s+a,\((ix\-[0-9-]+)\)/\tor\t\(\1\)/g' \ -e 's/\s+or\s+a,\((iy\+[0-9-]+)\)/\tor\t\(\1\)/g' \ + -e 's/\s+or\s+a,\((hl)\)/\tor\t\(\1\)/g' \ -e 's/\s+cp\s+a,(0x[0-9A-Fa-f]{2})/\tcp\t\1/g' \ -e 's/\s+or\s+a,(0x[0-9A-Fa-f]{2})/\tor\t\1/g' \ -e 's/\s+xor\s+a,(0x[0-9A-Fa-f]{2})/\txor\t\1/g' \ diff --git a/Source/HBIOS/ch376-native/source-doc/depends.d b/Source/HBIOS/ch376-native/source-doc/depends.d index 6f457cee..9c073580 100644 --- a/Source/HBIOS/ch376-native/source-doc/depends.d +++ b/Source/HBIOS/ch376-native/source-doc/depends.d @@ -6,20 +6,23 @@ ./base-drv/enumerate_storage.c: base-drv/enumerate_storage.c ././source-doc/base-drv/enumerate_storage.h ././source-doc/base-drv/protocol.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h ./base-drv/enumerate_hub.c: base-drv/enumerate_hub.c ././source-doc/base-drv/enumerate_hub.h ././source-doc/base-drv/enumerate.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/protocol.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h ././source-doc/base-drv/usb_state.h ././source-doc/base-drv/class_hub.h ././source-doc/base-drv/work-area.h ./base-drv/usb-base-drv.c: base-drv/usb-base-drv.c ././source-doc/base-drv/usb-base-drv.h ././source-doc/base-drv//ch376inc.h ././source-doc/base-drv//delay.h -./base-drv/transfers.c: base-drv/transfers.c ././source-doc/base-drv/transfers.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/z80.h ././source-doc/base-drv/print.h -./base-drv/print.c: base-drv/print.c ././source-doc/base-drv/print.h -./base-drv/ch376.c: base-drv/ch376.c ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/print.h -./base-drv/protocol.c: base-drv/protocol.c ././source-doc/base-drv/protocol.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h ././source-doc/base-drv/print.h +./base-drv/transfers.c: base-drv/transfers.c ././source-doc/base-drv/transfers.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/z80.h ././source-doc/base-drv/ez80-helpers.h ././source-doc/base-drv/print.h +./base-drv/ch376.c: base-drv/ch376.c ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/ez80-helpers.h ././source-doc/base-drv/print.h +./base-drv/protocol.c: base-drv/protocol.c ././source-doc/base-drv/protocol.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h ././source-doc/base-drv/ez80-helpers.h ././source-doc/base-drv/print.h ./base-drv/work-area.c: base-drv/work-area.c ././source-doc/base-drv/usb_state.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/protocol.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h ./base-drv/usb-init.c: base-drv/usb-init.c ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/enumerate.h ././source-doc/base-drv/protocol.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h ././source-doc/base-drv/usb_state.h ././source-doc/base-drv/print.h ././source-doc/base-drv/work-area.h ././source-doc/base-drv/z80.h ./ufi-drv/ufi-init.c: ufi-drv/ufi-init.c ././source-doc/ufi-drv/class_ufi.h ././source-doc/base-drv//transfers.h ././source-doc/ufi-drv/usb_cbi.h ./ufi-drv/usb_cbi.c: ufi-drv/usb_cbi.c ././source-doc/ufi-drv/usb_cbi.h ./ufi-drv/class_ufi.c: ufi-drv/class_ufi.c ././source-doc/ufi-drv/class_ufi.h ././source-doc/base-drv//transfers.h ././source-doc/ufi-drv/usb_cbi.h +./keyboard/kyb-init.c: keyboard/kyb-init.c ././source-doc/base-drv//ch376inc.h ././source-doc/base-drv//delay.h ././source-doc/keyboard/class_hid.h ././source-doc/keyboard/class_hid_keyboard.h +./keyboard/class_hid.c: keyboard/class_hid.c ././source-doc/keyboard/class_hid.h ././source-doc/base-drv//transfers.h ./scsi-drv/scsi-init.c: scsi-drv/scsi-init.c ././source-doc/scsi-drv/class_scsi.h ././source-doc/base-drv//ch376inc.h ././source-doc/base-drv//delay.h ././source-doc/base-drv//transfers.h ./scsi-drv/class_scsi.c: scsi-drv/class_scsi.c ././source-doc/scsi-drv/class_scsi.h ././source-doc/base-drv//ch376inc.h ././source-doc/base-drv//delay.h ././source-doc/base-drv//transfers.h ## -./base-drv.s: base-drv/./dev_transfers.c.s base-drv/./enumerate.c.s base-drv/./usb_state.c.s base-drv/./class_hub.c.s base-drv/./enumerate_storage.c.s base-drv/./enumerate_hub.c.s base-drv/./usb-base-drv.c.s base-drv/./transfers.c.s base-drv/./print.c.s base-drv/./ch376.c.s base-drv/./protocol.c.s base-drv/./work-area.c.s base-drv/./usb-init.c.s +./base-drv.s: base-drv/./dev_transfers.c.s base-drv/./enumerate.c.s base-drv/./usb_state.c.s base-drv/./class_hub.c.s base-drv/./enumerate_storage.c.s base-drv/./enumerate_hub.c.s base-drv/./usb-base-drv.c.s base-drv/./transfers.c.s base-drv/./ch376.c.s base-drv/./protocol.c.s base-drv/./work-area.c.s base-drv/./usb-init.c.s ## ./scsi-drv.s: scsi-drv/./scsi-init.c.s scsi-drv/./class_scsi.c.s ## -./ufi-drv.s: ufi-drv/./ufi-init.c.s ufi-drv/./usb_cbi.c.s ufi-drv/./class_ufi.c.s +./ufi-drv.s: ufi-drv/./ufi-init.c.s ufi-drv/./usb_cbi.c.s ufi-drv/./class_ufi.c.s +## +./keyboard.s: keyboard/./kyb-init.c.s keyboard/./class_hid.c.s diff --git a/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid.c b/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid.c new file mode 100644 index 00000000..b8ccd822 --- /dev/null +++ b/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid.c @@ -0,0 +1,46 @@ +#include "class_hid.h" +#include + +const setup_packet cmd_hid_set = {0x21, HID_SET_PROTOCOL, {0, 0}, {0, 0}, 0}; + +usb_error hid_set_protocol(const device_config_keyboard *const dev, const uint8_t protocol) __sdcccall(1) { + usb_error result; + setup_packet cmd; + cmd = cmd_hid_set; + + cmd.bRequest = HID_SET_PROTOCOL; + cmd.bValue[0] = protocol; + + result = usb_control_transfer(&cmd, NULL, dev->address, dev->max_packet_size); + + RETURN_CHECK(result); +} + +usb_error hid_set_idle(const device_config_keyboard *const dev, const uint8_t duration) __sdcccall(1) { + usb_error result; + setup_packet cmd; + cmd = cmd_hid_set; + + cmd.bRequest = HID_SET_IDLE; + cmd.bValue[0] = duration; + + result = usb_control_transfer(&cmd, NULL, dev->address, dev->max_packet_size); + + RETURN_CHECK(result); +} + +usb_error hid_get_input_report(const device_config_keyboard *const dev, uint8_t const *report) __sdcccall(1) { + usb_error result; + setup_packet cmd; + cmd = cmd_hid_set; + + cmd.bmRequestType = 0xA1; + cmd.bValue[0] = 1; + cmd.bValue[1] = 1; + cmd.bRequest = HID_GET_REPORT; + cmd.wLength = 8; + + result = usb_control_transfer(&cmd, report, dev->address, dev->max_packet_size); + + RETURN_CHECK(result); +} diff --git a/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid.h b/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid.h new file mode 100644 index 00000000..d3771b79 --- /dev/null +++ b/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid.h @@ -0,0 +1,21 @@ +#ifndef __CLASS_HID_H__ +#define __CLASS_HID_H__ + +#include "ch376.h" +#include "protocol.h" + +#define HID_GET_REPORT 0x01 +#define HID_GET_IDLE 0x02 +#define HID_GET_PROTOCOL 0x03 +#define HID_SET_REPORT 0x09 +#define HID_SET_IDLE 0x0A +#define HID_SET_PROTOCOL 0x0B + +#define HID_BOOT_PROTOCOL 0x00 +#define HID_REPORT_PROTOCOL 0x01 + +extern usb_error hid_set_protocol(const device_config_keyboard *const dev, const uint8_t protocol) __sdcccall(1); +extern usb_error hid_set_idle(const device_config_keyboard *const dev, const uint8_t duration) __sdcccall(1); +extern usb_error hid_get_input_report(const device_config_keyboard *const dev, uint8_t const *report) __sdcccall(1); + +#endif diff --git a/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid_keyboard.h b/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid_keyboard.h new file mode 100644 index 00000000..50efed90 --- /dev/null +++ b/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid_keyboard.h @@ -0,0 +1,24 @@ +#ifndef __CLASS_HID_KEYBOARD_H__ +#define __CLASS_HID_KEYBOARD_H__ + +#include + +typedef struct { + uint8_t bModifierKeys; + uint8_t bReserved; + uint8_t keyCode[6]; +} keyboard_report; + +#define KEY_MOD_LCTRL 0x01 +#define KEY_MOD_LSHIFT 0x02 +#define KEY_MOD_LALT 0x04 +#define KEY_MOD_LMETA 0x08 +#define KEY_MOD_RCTRL 0x10 +#define KEY_MOD_RSHIFT 0x20 +#define KEY_MOD_RALT 0x40 +#define KEY_MOD_RMETA 0x80 + +extern char scancodes_table[128]; +extern char scancode_to_char(const uint8_t modifier_keys, const uint8_t code) __sdcccall(1); + +#endif diff --git a/Source/HBIOS/ch376-native/source-doc/keyboard/kyb-init.c b/Source/HBIOS/ch376-native/source-doc/keyboard/kyb-init.c new file mode 100644 index 00000000..6b4bfa82 --- /dev/null +++ b/Source/HBIOS/ch376-native/source-doc/keyboard/kyb-init.c @@ -0,0 +1,54 @@ +#include "class_hid.h" +#include "class_hid_keyboard.h" +#include +#include +#include +#include + +void keyboard_init(void) { + + uint8_t index = 1; + do { + device_config_keyboard *const keyboard_config = (device_config_keyboard *)get_usb_device_config(index); + + if (keyboard_config == NULL) + break; + + const usb_device_type t = keyboard_config->type; + + if (t == USB_IS_KEYBOARD) { + print_string("\r\nUSB: KEYBOARD @ $"); + print_uint16(index); + print_string(" $"); + + // keyboard_config->drive_index = usb_device_count++; + hid_set_protocol(keyboard_config, 1); + hid_set_idle(keyboard_config, 0x80); + return; + } + } while (++index != MAX_NUMBER_OF_DEVICES + 1); + + print_string("\r\nUSB: KEYBOARD: NOT FOUND$"); +} + +// void drv_timi_keyboard(void) { +// _usb_state *const p = get_usb_work_area(); +// if (p->active) +// return; + +// p->active = true; + +// device_config_keyboard *const keyboard_config = (device_config_keyboard *)find_device_config(USB_IS_KEYBOARD); + +// keyboard_report report; + +// ch_configure_nak_retry_disable(); +// const usb_error result = usbdev_data_in_transfer_ep0((device_config *)keyboard_config, (uint8_t *)report, 8); +// ch_configure_nak_retry_3s(); +// if (result == 0) { +// const char c = scancode_to_char(report.bModifierKeys, report.keyCode[0]); +// key_put_into_buf(c); +// } + +// p->active = false; +// } diff --git a/Source/HBIOS/ch376-native/source-doc/scsi-drv/scsi-init.c b/Source/HBIOS/ch376-native/source-doc/scsi-drv/scsi-init.c index 8128f4ca..37f951a4 100644 --- a/Source/HBIOS/ch376-native/source-doc/scsi-drv/scsi-init.c +++ b/Source/HBIOS/ch376-native/source-doc/scsi-drv/scsi-init.c @@ -21,11 +21,11 @@ void chscsi_init(void) { const usb_device_type t = storage_device->type; if (t == USB_IS_MASS_STORAGE) { - print_string("\r\n MASS STORAGE @ $"); + print_string("\r\nUSB: MASS STORAGE @ $"); print_uint16(index); print_string(" $"); - storage_device->drive_index = storage_count++; + // storage_device->drive_index = usb_device_count++; scsi_sense_init(storage_device); dio_add_entry(ch_scsi_fntbl, storage_device); } diff --git a/Source/HBIOS/ch376-native/source-doc/ufi-drv/ufi-init.c b/Source/HBIOS/ch376-native/source-doc/ufi-drv/ufi-init.c index ec82dc90..00123530 100644 --- a/Source/HBIOS/ch376-native/source-doc/ufi-drv/ufi-init.c +++ b/Source/HBIOS/ch376-native/source-doc/ufi-drv/ufi-init.c @@ -20,11 +20,9 @@ void chufi_init(void) { const usb_device_type t = storage_device->type; if (t == USB_IS_FLOPPY) { - print_string("\r\n FLOPPY @ $"); + print_string("\r\nUSB: FLOPPY @ $"); print_uint16(index); print_string(" $"); - storage_device->drive_index = storage_count++; - // scsi_sense_init(storage_device); dio_add_entry(ch_ufi_fntbl, storage_device); } diff --git a/Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s b/Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s index 33bbebd2..13311dc6 100644 --- a/Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s +++ b/Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s @@ -56,7 +56,7 @@ _chufi_init: push ix ld ix,0 add ix,sp - push af + dec sp ;source-doc/ufi-drv/./ufi-init.c:14: do { ld (ix-1),0x01 l_chufi_init_00105: @@ -75,7 +75,7 @@ l_chufi_init_00105: ;source-doc/ufi-drv/./ufi-init.c:22: if (t == USB_IS_FLOPPY) { dec a jr NZ,l_chufi_init_00106 -;source-doc/ufi-drv/./ufi-init.c:23: print_string("\r\n FLOPPY @ $"); +;source-doc/ufi-drv/./ufi-init.c:23: print_string("\r\nUSB: FLOPPY @ $"); push de ld hl,ufi_init_str_0 call _print_string @@ -88,40 +88,29 @@ l_chufi_init_00105: ld hl,ufi_init_str_1 call _print_string pop de -;source-doc/ufi-drv/./ufi-init.c:26: storage_device->drive_index = storage_count++; - ld hl,0x0010 - add hl, de - ld c, l - ld b, h - ld hl,_storage_count - ld a, (hl) - ld (ix-2),a - inc (hl) - ld a,(ix-2) - ld (bc), a -;source-doc/ufi-drv/./ufi-init.c:28: dio_add_entry(ch_ufi_fntbl, storage_device); +;source-doc/ufi-drv/./ufi-init.c:26: dio_add_entry(ch_ufi_fntbl, storage_device); ld hl,_ch_ufi_fntbl call _dio_add_entry l_chufi_init_00106: -;source-doc/ufi-drv/./ufi-init.c:31: } while (++index != MAX_NUMBER_OF_DEVICES + 1); +;source-doc/ufi-drv/./ufi-init.c:29: } while (++index != MAX_NUMBER_OF_DEVICES + 1); inc (ix-1) ld a,(ix-1) sub 0x07 jr NZ,l_chufi_init_00105 l_chufi_init_00108: -;source-doc/ufi-drv/./ufi-init.c:32: } - ld sp, ix +;source-doc/ufi-drv/./ufi-init.c:30: } + inc sp pop ix ret ufi_init_str_0: DEFB 0x0d DEFB 0x0a - DEFM " FLOPPY @ $" + DEFM "USB: FLOPPY @ $" DEFB 0x00 ufi_init_str_1: DEFM " $" DEFB 0x00 -;source-doc/ufi-drv/./ufi-init.c:34: uint32_t chufi_get_cap(device_config *const dev) { +;source-doc/ufi-drv/./ufi-init.c:32: uint32_t chufi_get_cap(device_config *const dev) { ; --------------------------------- ; Function chufi_get_cap ; --------------------------------- @@ -132,7 +121,7 @@ _chufi_get_cap: ld hl, -72 add hl, sp ld sp, hl -;source-doc/ufi-drv/./ufi-init.c:36: memset(&response, 0, sizeof(ufi_format_capacities_response)); +;source-doc/ufi-drv/./ufi-init.c:34: memset(&response, 0, sizeof(ufi_format_capacities_response)); ld hl,0 add hl, sp ld b,0x24 @@ -140,7 +129,7 @@ l_chufi_get_cap_00112: ld (hl),0x00 inc hl djnz l_chufi_get_cap_00112 -;source-doc/ufi-drv/./ufi-init.c:38: wait_for_device_ready(dev, 25); +;source-doc/ufi-drv/./ufi-init.c:36: wait_for_device_ready(dev, 25); ld a,0x19 push af inc sp @@ -150,7 +139,7 @@ l_chufi_get_cap_00112: call _wait_for_device_ready pop af inc sp -;source-doc/ufi-drv/./ufi-init.c:42: ufi_inquiry(dev, &inquiry); +;source-doc/ufi-drv/./ufi-init.c:40: ufi_inquiry(dev, &inquiry); ld hl,36 add hl, sp push hl @@ -159,7 +148,7 @@ l_chufi_get_cap_00112: push hl call _ufi_inquiry pop af -;source-doc/ufi-drv/./ufi-init.c:44: wait_for_device_ready(dev, 15); +;source-doc/ufi-drv/./ufi-init.c:42: wait_for_device_ready(dev, 15); ld h,0x0f ex (sp),hl inc sp @@ -169,7 +158,7 @@ l_chufi_get_cap_00112: call _wait_for_device_ready pop af inc sp -;source-doc/ufi-drv/./ufi-init.c:46: const usb_error result = ufi_read_frmt_caps(dev, &response); +;source-doc/ufi-drv/./ufi-init.c:44: const usb_error result = ufi_read_frmt_caps(dev, &response); ld hl,0 add hl, sp push hl @@ -180,27 +169,27 @@ l_chufi_get_cap_00112: pop af pop af ld a, l -;source-doc/ufi-drv/./ufi-init.c:47: if (result != USB_ERR_OK) +;source-doc/ufi-drv/./ufi-init.c:45: if (result != USB_ERR_OK) or a jr Z,l_chufi_get_cap_00102 -;source-doc/ufi-drv/./ufi-init.c:48: return 0; +;source-doc/ufi-drv/./ufi-init.c:46: return 0; ld hl,0x0000 ld e, l ld d, l jr l_chufi_get_cap_00103 l_chufi_get_cap_00102: -;source-doc/ufi-drv/./ufi-init.c:50: return convert_from_msb_first(response.descriptors[0].number_of_blocks); +;source-doc/ufi-drv/./ufi-init.c:48: return convert_from_msb_first(response.descriptors[0].number_of_blocks); ld hl,4 add hl, sp push hl call _convert_from_msb_first pop af l_chufi_get_cap_00103: -;source-doc/ufi-drv/./ufi-init.c:51: } +;source-doc/ufi-drv/./ufi-init.c:49: } ld sp, ix pop ix ret -;source-doc/ufi-drv/./ufi-init.c:53: uint8_t chufi_read(device_config_storage *const dev, uint8_t *const buffer) { +;source-doc/ufi-drv/./ufi-init.c:51: uint8_t chufi_read(device_config_storage *const dev, uint8_t *const buffer) { ; --------------------------------- ; Function chufi_read ; --------------------------------- @@ -211,7 +200,7 @@ _chufi_read: ld hl, -20 add hl, sp ld sp, hl -;source-doc/ufi-drv/./ufi-init.c:55: if (wait_for_device_ready((device_config *)dev, 20) != 0) +;source-doc/ufi-drv/./ufi-init.c:53: if (wait_for_device_ready((device_config *)dev, 20) != 0) ld c,(ix+4) ld b,(ix+5) push bc @@ -227,18 +216,18 @@ _chufi_read: ld a, e or a jr Z,l_chufi_read_00102 -;source-doc/ufi-drv/./ufi-init.c:56: return -1; // Not READY! +;source-doc/ufi-drv/./ufi-init.c:54: return -1; // Not READY! ld l,0xff jr l_chufi_read_00109 l_chufi_read_00102: -;source-doc/ufi-drv/./ufi-init.c:61: memset(&sense_codes, 0, sizeof(sense_codes)); +;source-doc/ufi-drv/./ufi-init.c:59: memset(&sense_codes, 0, sizeof(sense_codes)); ld hl,0 add hl, sp xor a ld (hl), a inc hl ld (hl), a -;source-doc/ufi-drv/./ufi-init.c:63: if (ufi_read_write_sector((device_config *)dev, false, dev->current_lba, 1, buffer, (uint8_t *)&sense_codes) != USB_ERR_OK) +;source-doc/ufi-drv/./ufi-init.c:61: if (ufi_read_write_sector((device_config *)dev, false, dev->current_lba, 1, buffer, (uint8_t *)&sense_codes) != USB_ERR_OK) ld e,(ix+4) ld d,(ix+5) ld hl,12 @@ -271,11 +260,11 @@ l_chufi_read_00102: pop bc or a jr Z,l_chufi_read_00104 -;source-doc/ufi-drv/./ufi-init.c:64: return -1; // general error +;source-doc/ufi-drv/./ufi-init.c:62: return -1; // general error ld l,0xff jr l_chufi_read_00109 l_chufi_read_00104: -;source-doc/ufi-drv/./ufi-init.c:67: memset(&response, 0, sizeof(response)); +;source-doc/ufi-drv/./ufi-init.c:65: memset(&response, 0, sizeof(response)); push bc ld hl,4 add hl, sp @@ -285,7 +274,7 @@ l_chufi_read_00139: inc hl djnz l_chufi_read_00139 pop bc -;source-doc/ufi-drv/./ufi-init.c:69: if ((result = ufi_request_sense((device_config *)dev, &response)) != USB_ERR_OK) +;source-doc/ufi-drv/./ufi-init.c:67: if ((result = ufi_request_sense((device_config *)dev, &response)) != USB_ERR_OK) ld hl,2 add hl, sp push hl @@ -296,29 +285,29 @@ l_chufi_read_00139: ld a, l or a jr Z,l_chufi_read_00106 -;source-doc/ufi-drv/./ufi-init.c:70: return -1; // error +;source-doc/ufi-drv/./ufi-init.c:68: return -1; // error ld l,0xff jr l_chufi_read_00109 l_chufi_read_00106: -;source-doc/ufi-drv/./ufi-init.c:74: const uint8_t sense_key = response.sense_key; +;source-doc/ufi-drv/./ufi-init.c:72: const uint8_t sense_key = response.sense_key; ld hl,4 add hl, sp ld a, (hl) -;source-doc/ufi-drv/./ufi-init.c:76: if (sense_key != 0) +;source-doc/ufi-drv/./ufi-init.c:74: if (sense_key != 0) and 0x0f jr Z,l_chufi_read_00108 -;source-doc/ufi-drv/./ufi-init.c:77: return -1; +;source-doc/ufi-drv/./ufi-init.c:75: return -1; ld l,0xff jr l_chufi_read_00109 l_chufi_read_00108: -;source-doc/ufi-drv/./ufi-init.c:79: return USB_ERR_OK; +;source-doc/ufi-drv/./ufi-init.c:77: return USB_ERR_OK; ld l,0x00 l_chufi_read_00109: -;source-doc/ufi-drv/./ufi-init.c:80: } +;source-doc/ufi-drv/./ufi-init.c:78: } ld sp, ix pop ix ret -;source-doc/ufi-drv/./ufi-init.c:82: usb_error chufi_write(device_config_storage *const dev, uint8_t *const buffer) { +;source-doc/ufi-drv/./ufi-init.c:80: usb_error chufi_write(device_config_storage *const dev, uint8_t *const buffer) { ; --------------------------------- ; Function chufi_write ; --------------------------------- @@ -329,7 +318,7 @@ _chufi_write: ld hl, -20 add hl, sp ld sp, hl -;source-doc/ufi-drv/./ufi-init.c:84: if (wait_for_device_ready((device_config *)dev, 20) != 0) +;source-doc/ufi-drv/./ufi-init.c:82: if (wait_for_device_ready((device_config *)dev, 20) != 0) ld c,(ix+4) ld b,(ix+5) push bc @@ -345,18 +334,18 @@ _chufi_write: ld a, e or a jr Z,l_chufi_write_00102 -;source-doc/ufi-drv/./ufi-init.c:85: return -1; // Not READY! +;source-doc/ufi-drv/./ufi-init.c:83: return -1; // Not READY! ld l,0xff jr l_chufi_write_00109 l_chufi_write_00102: -;source-doc/ufi-drv/./ufi-init.c:89: memset(&sense_codes, 0, sizeof(sense_codes)); +;source-doc/ufi-drv/./ufi-init.c:87: memset(&sense_codes, 0, sizeof(sense_codes)); ld hl,0 add hl, sp xor a ld (hl), a inc hl ld (hl), a -;source-doc/ufi-drv/./ufi-init.c:90: if ((ufi_read_write_sector((device_config *)dev, true, dev->current_lba, 1, buffer, (uint8_t *)&sense_codes)) != USB_ERR_OK) { +;source-doc/ufi-drv/./ufi-init.c:88: if ((ufi_read_write_sector((device_config *)dev, true, dev->current_lba, 1, buffer, (uint8_t *)&sense_codes)) != USB_ERR_OK) { ld e,(ix+4) ld d,(ix+5) ld hl,12 @@ -389,11 +378,11 @@ l_chufi_write_00102: pop bc or a jr Z,l_chufi_write_00104 -;source-doc/ufi-drv/./ufi-init.c:91: return -1; +;source-doc/ufi-drv/./ufi-init.c:89: return -1; ld l,0xff jr l_chufi_write_00109 l_chufi_write_00104: -;source-doc/ufi-drv/./ufi-init.c:95: memset(&response, 0, sizeof(response)); +;source-doc/ufi-drv/./ufi-init.c:93: memset(&response, 0, sizeof(response)); push bc ld hl,4 add hl, sp @@ -403,7 +392,7 @@ l_chufi_write_00139: inc hl djnz l_chufi_write_00139 pop bc -;source-doc/ufi-drv/./ufi-init.c:97: if ((ufi_request_sense((device_config *)dev, &response)) != USB_ERR_OK) { +;source-doc/ufi-drv/./ufi-init.c:95: if ((ufi_request_sense((device_config *)dev, &response)) != USB_ERR_OK) { ld hl,2 add hl, sp push hl @@ -414,25 +403,25 @@ l_chufi_write_00139: ld a, l or a jr Z,l_chufi_write_00106 -;source-doc/ufi-drv/./ufi-init.c:98: return -1; +;source-doc/ufi-drv/./ufi-init.c:96: return -1; ld l,0xff jr l_chufi_write_00109 l_chufi_write_00106: -;source-doc/ufi-drv/./ufi-init.c:103: const uint8_t sense_key = response.sense_key; +;source-doc/ufi-drv/./ufi-init.c:101: const uint8_t sense_key = response.sense_key; ld hl,4 add hl, sp ld a, (hl) -;source-doc/ufi-drv/./ufi-init.c:105: if (sense_key != 0) +;source-doc/ufi-drv/./ufi-init.c:103: if (sense_key != 0) and 0x0f jr Z,l_chufi_write_00108 -;source-doc/ufi-drv/./ufi-init.c:106: return -1; +;source-doc/ufi-drv/./ufi-init.c:104: return -1; ld l,0xff jr l_chufi_write_00109 l_chufi_write_00108: -;source-doc/ufi-drv/./ufi-init.c:108: return USB_ERR_OK; +;source-doc/ufi-drv/./ufi-init.c:106: return USB_ERR_OK; ld l,0x00 l_chufi_write_00109: -;source-doc/ufi-drv/./ufi-init.c:109: } +;source-doc/ufi-drv/./ufi-init.c:107: } ld sp, ix pop ix ret diff --git a/Source/HBIOS/ch376kyb.asm b/Source/HBIOS/ch376kyb.asm new file mode 100644 index 00000000..9111a045 --- /dev/null +++ b/Source/HBIOS/ch376kyb.asm @@ -0,0 +1,90 @@ +; +;================================================================================================== +; CH376 NATIVE USB KEYBOARD DRIVER +;================================================================================================== +; + +#DEFINE DEFM .DB +#DEFINE DEFB .DB +#DEFINE DEFW .DW + +#IF (SYSTIM == TM_NONE) + .ECHO "*** ERROR: MKY REQUIRES SYSTEM TIMER -- NONE CONFIGURED!!!\n" + !!! ; FORCE AN ASSEMBLY ERROR +#ENDIF + +#include "./ch376-native/keyboard.s" + + +CHUKB_INIT .EQU _keyboard_init + +; ### Function 0x4C -- Keyboard Status (VDAKST) +; +; Inputs: +; None +; +; Outputs: +; A: Status / Codes Pending +; +; Return a count of the number of key Codes Pending (A) in the keyboard buffer. +; If it is not possible to determine the actual number in the buffer, it is +; acceptable to return 1 to indicate there are key codes available to read and +; 0 if there are none available. +; The value returned in register A is used as both a Status (A) code and the +; return value. Negative values (bit 7 set) indicate a standard HBIOS result +; (error) code. Otherwise, the return value represents the number of key codes +; pending. +; +UKY_STAT: + XOR A + RET + +; ### Function 0x4D -- Video Keyboard Flush (VDAKFL) +; +; Inputs: +; C: Video Unit +; +; Outputs: +; A: standard HBIOS result code +; +; Purged and all contents discarded. The Status (A) is a standard HBIOS result code. +; +UKY_FLUSH: + RET +; +; ### Function 0x4E -- Video Keyboard Read (VDAKRD) +; +; Inputs: +; None +; +; Outputs: +; A: Status +; C: Scancode +; D: Keystate +; E: Keycode +; +; Read the next key data from the keyboard. If a buffer is used, return the next key code in the buffer. +; If no key data is available, this function will wait indefinitely for a keypress. The Status (A) is a +; standard HBIOS result code. +; +; The Scancode (C) value is the raw scancode from the keyboard for the keypress. Scancodes are from +; the PS/2 scancode set 2 standard. +; +; The Keystate (D) is a bitmap representing the value of all modifier keys and shift states as they +; existed at the time of the keystroke. The bitmap is defined as: +; +; Bit Keystate Indication +; 7 Key pressed was from the num pad +; 6 Caps Lock was active +; 5 Num Lock was active +; 4 Scroll Lock was active +; 3 Windows key was held down +; 2 Alt key was held down +; 1 Control key was held down +; 0 Shift key was held down +; +; The Keycode (E) is generally returned as appropriate ASCII values, if possible. Special keys, like +; function keys and arrows, are returned as reserved codes as described at the start of this section. +; +UKY_READ: + RET diff --git a/Source/HBIOS/hbios.asm b/Source/HBIOS/hbios.asm index 3c8c9031..2cee1798 100644 --- a/Source/HBIOS/hbios.asm +++ b/Source/HBIOS/hbios.asm @@ -3979,6 +3979,11 @@ HB_PCINITTBLLEN .EQU (($ - HB_PCINITTBL) / 2) ; HB_INITTBL: ; +#IF (CHNATIVEENABLE) + ; NEED TO ENUMERATE USB DEVICES EARLY, SO THAT ACTUAL DRIVERS + ; WILL BE ABLE TO FIND THEM. + .DW CHNATIVE_INIT +#ENDIF #IF (KIOENABLE) .DW KIO_INIT #ENDIF @@ -4165,9 +4170,6 @@ HB_INITTBL: #IF (ESPENABLE) .DW ESP_INIT #ENDIF -#IF (CHNATIVEENABLE) - .DW CHNATIVE_INIT -#ENDIF #IF (CHSCSIENABLE) .DW CHSCSI_INIT #ENDIF @@ -9258,6 +9260,15 @@ SIZ_MKY .EQU $ - ORG_MKY MEMECHO " bytes.\n" #ENDIF ; +#IF (USBKYBENABLE) +ORG_UKY .EQU $ + #INCLUDE "ch376kyb.asm" +SIZ_UKY .EQU $ - ORG_UKY + MEMECHO "CH376 USB Keyboard occupies " + MEMECHO SIZ_UKY + MEMECHO " bytes.\n" +#ENDIF +; #IF (NABUKBENABLE) ORG_NABUKB .EQU $ #INCLUDE "nabukb.asm" diff --git a/Source/HBIOS/std.asm b/Source/HBIOS/std.asm index fe9b96df..9984c221 100644 --- a/Source/HBIOS/std.asm +++ b/Source/HBIOS/std.asm @@ -283,6 +283,7 @@ TMSMODE_MBC .EQU 6 ; MBC V9938/58 VIDEO BOARD TMSMODE_COLECO .EQU 7 ; COLECOVISION PORT MAPPING TMSMODE_DUO .EQU 8 ; DUODYNE PORT MAPPING TMSMODE_NABU .EQU 9 ; NABU +TMSMODE_MSXUKY .EQU 10 ; STD MSX PORTS + USB KEYBOARD ; ; CVDU VIDEO MODE SELECTIONS ; @@ -537,6 +538,7 @@ PPKENABLE .EQU FALSE ; PPK KEYBOARD DRIVER MKYENABLE .EQU FALSE ; MSX KEYBOARD DRIVER NABUKBENABLE .EQU FALSE ; NABU KEYBOARD DRIVER FVKBDENABLE .EQU FALSE ; FPGA KEYBOARD DRIVER +USBKYBENABLE .EQU TRUE ; USB KEYBOARD DRIVER ; ; VIDEO MODES ; diff --git a/Source/HBIOS/tms.asm b/Source/HBIOS/tms.asm index 679bddf1..b31d063a 100644 --- a/Source/HBIOS/tms.asm +++ b/Source/HBIOS/tms.asm @@ -48,6 +48,7 @@ TMSKBD_KBD .EQU 1 TMSKBD_PPK .EQU 2 TMSKBD_MKY .EQU 3 TMSKBD_NABU .EQU 4 +TMSKBD_USB .EQU 5 ; TMSKBD .EQU TMSKBD_NONE ; ASSUME NONE ; @@ -93,6 +94,13 @@ TMSKBD .SET TMSKBD_MKY ; MSX KEYBOARD DEVECHO "MSXMKY" #ENDIF ; +#IF (TMSMODE == TMSMODE_MSXUKY) +TMS_DATREG .EQU $98 ; READ/WRITE DATA +TMS_CMDREG .EQU $99 ; READ STATUS / WRITE REG SEL +TMSKBD .SET TMSKBD_USB ; MSX KEYBOARD + DEVECHO "MSX-USB_KYB" +#ENDIF +; #IF (TMSMODE == TMSMODE_MBC) TMS_DATREG .EQU $98 ; READ/WRITE DATA TMS_CMDREG .EQU $99 ; READ STATUS / WRITE REG SEL @@ -183,6 +191,11 @@ NABUKBENABLE .SET TRUE ; INCLUDE NABU KEYBOARD SUPPORT DEVECHO "NABU" #ENDIF ; +#IF (TMSKBD == TMSKBD_USB) +USBKYBENABLE .SET TRUE ; INCLUDE USB KEYBOARD SUPPORT + DEVECHO "USB-KYB" +#ENDIF +; #IF (TMSTIMENABLE & (INTMODE > 0)) DEVECHO ", INTERRUPTS ENABLED" #ENDIF @@ -310,6 +323,9 @@ TMS_INIT1: #IF (TMSKBD == TMSKBD_NABU) CALL NABUKB_INIT ; INITIALIZE NABU KEYBOARD DRIVER #ENDIF +#IF (TMSKBD == TMSKBD_USB) + CALL CHUKB_INIT +#ENDIF #IF (TMSTIMENABLE & (INTMODE > 0)) ; @@ -393,6 +409,11 @@ TMS_FNTBL: .DW MKY_FLUSH .DW MKY_READ #ENDIF +#IF (TMSKBD == TMSKBD_USB) + .DW UKY_STAT + .DW UKY_FLUSH + .DW UKY_READ +#ENDIF #IF (TMSKBD == TMSKBD_NABU) .DW NABUKB_STAT .DW NABUKB_FLUSH @@ -1155,7 +1176,6 @@ TMS_TSTINT: RET TMS_INTHNDL: - CALL HB_TIMINT ; RETURN NZ - HANDLED OR $FF RET