diff --git a/Source/HBIOS/ch376-native/base-drv/ch376_init.c.s b/Source/HBIOS/ch376-native/base-drv/ch376_init.c.s index 2081c4db..e6eb0011 100644 --- a/Source/HBIOS/ch376-native/base-drv/ch376_init.c.s +++ b/Source/HBIOS/ch376-native/base-drv/ch376_init.c.s @@ -55,22 +55,22 @@ _wait_for_state: add ix,sp dec sp ld (ix-1),a - ld b, l ;source-doc/base-drv/ch376_init.c:5: uint16_t r = state; - ld e, b + ld c,l + ld e,l ;source-doc/base-drv/ch376_init.c:7: for (uint8_t i = 0; i < loop_counter; i++) { ld d,0x00 - ld c,d + ld b,d l_wait_for_state_00108: - ld a, c + ld a, b sub (ix-1) jr NC,l_wait_for_state_00106 ;source-doc/base-drv/ch376_init.c:8: if (state == desired_state) ld a,(ix+4) - sub b + sub c jr Z,l_wait_for_state_00106 ;source-doc/base-drv/ch376_init.c:11: if (i & 1) - bit 0, c + bit 0, b jr Z,l_wait_for_state_00104 ;source-doc/base-drv/ch376_init.c:12: print_string("\b $"); push bc @@ -87,16 +87,14 @@ l_wait_for_state_00104: l_wait_for_state_00105: ;source-doc/base-drv/ch376_init.c:16: r = usb_init(state); push bc - push bc - inc sp + ld l, c call _usb_init - inc sp ex de, hl pop bc ;source-doc/base-drv/ch376_init.c:17: state = r & 255; - ld b, e + ld c, e ;source-doc/base-drv/ch376_init.c:7: for (uint8_t i = 0; i < loop_counter; i++) { - inc c + inc b jr l_wait_for_state_00108 l_wait_for_state_00106: ;source-doc/base-drv/ch376_init.c:20: return r; @@ -142,16 +140,15 @@ l__chnative_init_00114: ld l,0x00 ld a,(ix-1) call _wait_for_state - ld b, e ;source-doc/base-drv/ch376_init.c:31: state = r & 255; ;source-doc/base-drv/ch376_init.c:33: print_string("\bPRESENT (VER $"); - push bc + push de ld hl,ch376_init_str_3 call _print_string + pop de ;source-doc/base-drv/ch376_init.c:35: r = usb_init(state); - inc sp + ld l, e call _usb_init - inc sp ex de, hl ;source-doc/base-drv/ch376_init.c:36: state = r & 255; ld c, e @@ -186,10 +183,9 @@ l__chnative_init_00102: ld l, c ld a,(ix-1) call _wait_for_state - ld b, e ;source-doc/base-drv/ch376_init.c:49: state = r & 255; ;source-doc/base-drv/ch376_init.c:51: if (state == 2) { - ld a, b + ld a, e sub 0x02 jr NZ,l__chnative_init_00104 ;source-doc/base-drv/ch376_init.c:52: print_string("\bDISCONNECTED$"); @@ -199,20 +195,20 @@ l__chnative_init_00102: jr l__chnative_init_00111 l__chnative_init_00104: ;source-doc/base-drv/ch376_init.c:56: print_string("\bCONNECTED$"); - push bc + push de ld hl,ch376_init_str_9 call _print_string + pop de ;source-doc/base-drv/ch376_init.c:59: r = usb_init(state); - inc sp + ld l, e call _usb_init - inc sp ex de, hl ;source-doc/base-drv/ch376_init.c:60: state = r & 255; - ld b, e + ld c, e ;source-doc/base-drv/ch376_init.c:62: for (uint8_t i = 0; i < loop_counter; i++) { - ld c,0x00 + ld b,0x00 l__chnative_init_00109: - ld a, c + ld a, b sub (ix-1) jr NC,l__chnative_init_00111 ;source-doc/base-drv/ch376_init.c:63: if (r >> 8 != 0) @@ -226,16 +222,14 @@ l__chnative_init_00109: pop bc ;source-doc/base-drv/ch376_init.c:67: r = usb_init(state); push bc - push bc - inc sp + ld l, c call _usb_init - inc sp ex de, hl pop bc ;source-doc/base-drv/ch376_init.c:68: state = r & 255; - ld b, e + ld c, e ;source-doc/base-drv/ch376_init.c:62: for (uint8_t i = 0; i < loop_counter; i++) { - inc c + inc b jr l__chnative_init_00109 l__chnative_init_00111: ;source-doc/base-drv/ch376_init.c:70: } 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 09fd1e9b..1d3054c2 100644 --- a/Source/HBIOS/ch376-native/base-drv/usb_init.c.s +++ b/Source/HBIOS/ch376-native/base-drv/usb_init.c.s @@ -83,20 +83,17 @@ _usb_host_bus_reset: ld l,0x00 ;source-doc/base-drv/usb_init.c:20: } ret -;source-doc/base-drv/usb_init.c:24: uint16_t usb_init(uint8_t state) { +;source-doc/base-drv/usb_init.c:24: uint16_t usb_init(uint8_t state) __z88dk_fastcall { ; --------------------------------- ; Function usb_init ; --------------------------------- _usb_init: - push ix - ld ix,0 - add ix,sp ;source-doc/base-drv/usb_init.c:27: USB_MODULE_LEDS = 0x03; ld a,0x03 ld bc,_USB_MODULE_LEDS out (c), a ;source-doc/base-drv/usb_init.c:29: if (state == 0) { - ld a,(ix+4) + ld a, l or a jr NZ,l_usb_init_00104 ;source-doc/base-drv/usb_init.c:30: ch_cmd_reset_all(); @@ -124,7 +121,7 @@ l_usb_init_00102: jr l_usb_init_00113 l_usb_init_00104: ;source-doc/base-drv/usb_init.c:41: if (state == 1) { - ld a,(ix+4) + ld a, l dec a jr NZ,l_usb_init_00106 ;source-doc/base-drv/usb_init.c:42: r = ch_cmd_get_ic_version(); @@ -140,7 +137,7 @@ l_usb_init_00104: jr l_usb_init_00113 l_usb_init_00106: ;source-doc/base-drv/usb_init.c:48: if (state == 2) { - ld a,(ix+4) + ld a, l sub 0x02 jr NZ,l_usb_init_00159 ld a,0x01 @@ -196,15 +193,11 @@ l_usb_init_00112: ld a,0x00 ld bc,_USB_MODULE_LEDS out (c), a -;source-doc/base-drv/usb_init.c:68: return (uint16_t)count_of_devices() << 8 | state + 1; +;source-doc/base-drv/usb_init.c:68: return (uint16_t)count_of_devices() << 8 | 4; call _count_of_devices - ld c,(ix+4) - ld b,0x00 - inc bc - or b ld h, a - ld l, c + xor a + ld l,0x04 l_usb_init_00113: ;source-doc/base-drv/usb_init.c:69: } - pop ix ret diff --git a/Source/HBIOS/ch376-native/source-doc/base-drv/usb_init.c b/Source/HBIOS/ch376-native/source-doc/base-drv/usb_init.c index 319f9416..3585cc28 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/usb_init.c +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/usb_init.c @@ -21,7 +21,7 @@ static usb_error usb_host_bus_reset(void) { #define ERASE_LINE "\x1B\x6C\r$" -uint16_t usb_init(uint8_t state) { +uint16_t usb_init(uint8_t state) __z88dk_fastcall { uint8_t r; USB_MODULE_LEDS = 0x03; @@ -65,5 +65,5 @@ uint16_t usb_init(uint8_t state) { } enumerate_all_devices(); USB_MODULE_LEDS = 0x00; - return (uint16_t)count_of_devices() << 8 | state + 1; + return (uint16_t)count_of_devices() << 8 | 4; } diff --git a/Source/HBIOS/ch376-native/source-doc/base-drv/usb_init.h b/Source/HBIOS/ch376-native/source-doc/base-drv/usb_init.h index 08808955..ed6af87d 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/usb_init.h +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/usb_init.h @@ -3,6 +3,6 @@ #include -extern uint16_t usb_init(uint8_t state); +extern uint16_t usb_init(uint8_t state) __z88dk_fastcall; #endif