0 Members and 1 Guest are viewing this topic.
HandleUSBEvents: ld a, (ModelID) cp 2 ; Models 2 and up have USB. jp c, ResumeInterrupt ; Leave if we don't have the hardware (also tested with NC) in a, (55h) ; Read USB status bit 0, a jr z, UnknownUSBEvent bit 2, a jr z, USBLineInterrupt bit 4, a jp z, USBProtocolInterrupt jp ResumeInterruptUnknownUSBEvent: xor a out (5Bh), a ; Unknown event, WikiTI claims you should zero port 5B to acknowledge jp ResumeInterruptUSBLineInterrupt: in a, (56h) ld c, a cpl ; xor 0FFh ld b, a in a, (57h) ld d, a and b out (57h), a ld a, d out (57h), a ; Ack the interrupt without doing anything special jp ResumeInterruptUSBProtocolInterrupt: in a, (86h) ld c, a in a, (84h) ld b, a in a, (85h) in a, (83h) in a, (82h) ; Just ack and leave, and hope that it doesn't get angry jp ResumeInterrupt
ld a, 1 ; Set flash page 1 in bank 1. out (6), a in a, (2) ;get calc version rlca ;Roll bit 7 into carry. ld a, 41h ; Set ram page 1 in bank 2. jr nc, LowerModel ; C vs NC?HigherModel: out (5),a ld a,81h out (7),a jr ReturnLowerModel: out (6), a out (7),aReturn: ret
; Initializes the kfs driverFSInit: ld a, 1 ; Set flash page 1 in bank 1. out (6), a in a, (2) ;get calc version rlca ;Roll bit 7 into carry. ld a, 41h ; Set ram page 1 in bank 2. jr nc, LowerModel ; C vs NC?HigherModel: ld a, 3 out (5),a ld a,81h out (7),a jr ReturnLowerModel: out (6), a out (7),aReturn: ret
ld a, (ModelID) cp 2 ; Models 2 and up have USB. jp c, ResumeInterrupt ; Leave if we don't have the hardware (also tested with NC)