0038h: jr 006Ah ;go somewhere else temporarily 003Ah: ... 006Ah: ex af,af' exx in a,(55h) ;USB status port xor 0FFh and 1Fh jr z,003Ah ;no activity at all bit 0,(iy+3Ah) jr z,0082h ;no USB hook active ld b,2Ch ld c,a call 0327h ;try calling it jr z,00D9h ;it told us to abort 0082h: in a,(56h) ;USB status port #2 ld b,a or a jr z,00ADh ;nothing of interest bit onRunning,(iy+onFlags) jp z,01DDh in a,(7) cp 81h jp nz,01DDh ld a,b bit 4,a jp nz,011Fh bit 5,a jp nz,0124h bit 6,a jr nz,0110h bit 7,a jr nz,0115h bit 1,a jr nz,011Ah 00ADh: in a,(55h) ld b,a and 11h xor 11h jp z,003Ah in a,(7) cp 81h jp nz,01DDh bit 4,b jp z,0145h ;data waiting or something jr 010Bh 00D9h: push af ld a,8 out (3),a pop af out (3),a ld a,0Bh bit 0,(iy+16h) jr z,00EBh add a,4 out (3),a ex af,af' exx ei reti 010Bh: call 3DCFh jr 0148h 0145h: call 3DFFh 0148h: bit 3,(iy+09h) jp z,01DDh jr 00D9h 01DDh: res shift2nd,(iy+shiftFlags) push hl sub a push af ld a,8 out (3),a ;write to port 3 twice? pop af out (3),a jr 09A4h 0327h: ld hl,9BD4h ;USB activity hook pointer ld e,(hl) inc hl ld d,(hl) inc hl ld a,(hl) cp 0FFh jr z,0342h ;if page is 0FFh, disable and die? push bc ld (9C83h),a ex de,hl call 1ABDh ;get (AHL) in B inc hl ld a,b cp 83h pop bc jr z,0349h ;valid, so call it 0342h: res 0,(iy+3Ah) or 1 ret 0349h: ld (9C84h),hl call 093Fh ld a,b or a ret 093Fh: in a,(6) push af ld a,(9C83h) out (6),a ld hl,094Fh push hl ld hl,(9C84h) jp (hl) 094Fh: pop af out (6),a ret 09A4h: ld a,6 out (4),a in a,(2) and 80h jr z,09B4h in a,(7) cp 81h jr 09BAh 09B4h: in a,(7) and 4Fh cp 41h 09BAh: jp nz,0B22h ;whoa, not on the right page, so freak out bit shift2nd,(iy+shiftFlags) jp z,0A4Eh ;always take this jump? bit 5,(iy+33h) jr nz,09D0h bit 7,(iy+28h) jr z,09D5h set 3,(iy+28h) ret 0A4Eh: res 7,(iy+0Fh) call _ApdSetup bit 3,(iy+09h) jp nz,0B1Dh set 3,(iy+09h) ld hl,89F8h ;iy+08h bit 4,(hl) res 4,(hl) jp nz,0AF5h res 1,(iy+12h) bit 2,(iy+24h) jr z,0A79h bit 2,(hl) jp z,_resetRam ld sp,(85BCh) call _resetStacks call 3C9Dh call 3CA3h xor a ld (85DEh),a call 0D5Eh call 0CEDh call 0458h jr c,0AE7h cp 1 jr nz,0ABEh ld a,l cp 0F9h jr nz,0AE7h ld a,0Bh call 0E03h scf ccf B_CALL 531Dh jr z,0AE7h xor a ld (867Fh),a ld (867Dh),a B_CALL 5323h ld a,3 call _SetAppRestrictions B_CALL 5320h jr 0AE7h cp 4 jr nz,0AE7h ld a,l cp 0F3h jr nz,0AE7h ld a,0Bh call 0E03h scf B_CALL 531Dh jr z,0AE7h ld hl,0 ld (844Bh),hl ld hl,4231h call _PutS call 3CB5h call 3CBBh jp 0BDCh 0AE7h: call 3CC1h bit 6,(iy+0Ch) call nz,3CC7h ei jp _Mon 0B22h: ld a,6 ;freak out right about here out (4),a ld a,0C0h out (0),a in a,(2) and 80h ld a,41h jr z,0B3Bh ld a,1 out (20h),a xor a out (0Fh),a ld a,81h out (7),a call 0E02h ld iy,89F0h call 26CDh ;NZIf83Plus call z,3CDFh ld hl,(85BEh) ld de,A55Ah call 1B0Fh jp z,0D6Ch ld a,1Fh call 26CDh ;NZIf83Plus jr nz,0B5Fh ld a,17h 0B5Fh: ld (8447h),a call 0C24h ld de,(85BEh) call 1B0Fh jr nz,0B8Ah dec de ld (85BEh),de call 3CE5h call 0DB3h ld a,0Bh out (3),a res 4,(iy+08h) call 3CEBh call 0C43h jp 0A5Ch ;holy crap, no more reset stuff, please