Nintendo DMG-01 Manual - Page 37
FF01 SB, FF02 SC
View all Nintendo DMG-01 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 37 highlights
Game BoyTM CPU Manual 2.13.1. I/O Registers CPL AND $0F OR B LD B,A LD A,($FF8B) XOR B AND B LD ($FF8C),A LD A,B LD ($FF8B),A LD A,$30 LD ($FF00),A RET
Game Boy
TM
CPU Manual
2.13.1. I/O Registers
CPL
<- complement (invert)
AND $0F
<- get first 4 bits
OR B
<- put A and B together
LD B,A
<- store A in D
LD A,($FF8B)
<- read old joy data from ram
XOR B
<- toggle w/current button bit
AND B
<- get current button bit back
LD ($FF8C),A
<- save in new Joydata storage
LD A,B
<- put original value in A
LD ($FF8B),A
<- store it as old joy data
LD A,$30
<- deselect P14 and P15
LD ($FF00),A
<- RESET Joypad
RET
<- Return from Subroutine
The button values using the above method are
such:
$80 - Start
$8 - Down
$40 - Select
$4 - Up
$20 - B
$2 - Left
$10 - A
$1 - Right
Let's say we held down A, Start, and Up. The
value returned in accumulator A would be $94.
2.
FF01 (SB)
Name
- SB
Contents - Serial transfer data (R/W)
8 Bits of data to be read/written
3.
FF02 (SC)
Name
- SC
Contents - SIO control
(R/W)
by DP
Page 37