Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;idk if it'll work but it needs to work on GB and GBC and not just GBC with the unused pin and special register
- ld a, $01
- ldh [rSC], a ;internal clock, don't start transfer yet
- ld a, $40 ;01000000
- ldh [rSB], a
- ;and then...
- ld a, $81 ;start the transfer with the internal clock
- ldh [rSC], a
- waitforstart:
- ldh a, [rSB]
- bit 6, a ;bit 6 is the bit I set
- jr nz, waitforstart ;wait until the bit gets shifted out so we know the keyboard has to resend its stuff
- xor a
- ldh [rSC], a ;now start the transfer with external clock WITHOUT the transfer bit set
- waitforbit:
- ldh a, [rSB]
- bit 7, a ;since the register shifted left in order to inhibit communication, I check this bit until it shifts again, which means the start bit is shifted in
- ld a, $01
- ldh [rSB], a ;put a 1 in bit 0 to keep the data line high to idle at the end?
- jr nz, waitforbit
- ld a, $80
- ldh [rSC], a ;set the transfer bit to reset the bit counter
- ;*do something here while waiting for the keyboard to send its data*
- ;pretend this gets executed when the serial interrupt fires off
- serialinterrupt:
- ldh a, [rSB]
- push af ;just find a way to store it somewhere
- ld a, $01
- ldh [rSC], a ;the communication shouldn't be inhibited because the clock line is high, so it's idling
- ;do 1 or 2 keys per frame
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement