;Optimized versions of descriptor-sending code per device, to speed up device enumeration include "settings.inc" include "ti83plus.inc" include "equates.inc" SEGMENT Main GLOBALS ON EXTERN cancelUSBHook,WaitTimer20ms,SetupOutPipe,SetupInPipe,WaitPort82,DispHexHL EXTERN P1_READY,P2_READY,P3_READY,P4_READY EXTERN maxPacketSize,jailbreakState,portCur PUBLIC SendDevice1ConfigDescriptor SendDevice1ConfigDescriptor: di ld a,1 out (20h),a ;Are we on the last descriptor with length > 8? If so, device 1 is ready ld a,(inputBuffer+2) cp 3 jr nz,$F ld hl,(inputBuffer+6) ld de,8 or a sbc hl,de jr z,$F ld a,P1_READY ld (jailbreakState),a $$: ld hl,(inputBuffer+6) ;Are we using a separate packet for the config descriptor? If not, skip this step ld de,8 or a sbc hl,de jr nz,$F ld hl,8 ld (descSize),hl ld de,(shortConfigDescAddress) jr continueConfigDescriptor $$: ld hl,0F00h ld (descSize),hl ld de,(configDescAddress) continueConfigDescriptor: xor a out (8Eh),a ld a,40h out (91h),a call d1DelayPort82 d1descriptorOutLoop: ld hl,maxPacketSize ld b,(hl) ld a,(descSize+1) or a jr nz,d1descriptorOutBig ld a,(descSize) cp b jr c,$F d1descriptorOutBig: ld hl,(descSize) ld bc,(maxPacketSize) ld b,0 or a sbc hl,bc ld (descSize),hl ld b,c jr d1continueOutput $$: ld b,a ld hl,0 ld (descSize),hl d1continueOutput: $$: ld a,(de) out (0A0h),a inc de djnz $B ld hl,(descSize) ld a,h or l jr nz,$F jr d1finishControlOutput $$: xor a out (8Eh),a ld a,2 out (91h),a call d1DelayPort82 jr d1descriptorOutLoop d1finishControlOutput: xor a out (8Eh),a ld a,0Ah out (91h),a call WaitPort82 call WaitPort82 call WaitTimer20ms call WaitTimer20ms call WaitTimer20ms jr cancelUSBHook d1DelayPort82: push bc ld bc,08FFh $$: in a,(82h) bit 0,a jr nz,$F ex hl,(sp) ex hl,(sp) dec bc ld a,b or c jr nz,$B $$: pop bc ret