bsnes/processor/upd96050/memory.cpp

65 lines
1.2 KiB
C++

uint8 uPD96050::sr_read() {
return regs.sr >> 8;
}
void uPD96050::sr_write(uint8 data) {
}
uint8 uPD96050::dr_read() {
if(regs.sr.drc == 0) {
//16-bit
if(regs.sr.drs == 0) {
regs.sr.drs = 1;
return regs.dr >> 0;
} else {
regs.sr.rqm = 0;
regs.sr.drs = 0;
return regs.dr >> 8;
}
} else {
//8-bit
regs.sr.rqm = 0;
return regs.dr >> 0;
}
}
void uPD96050::dr_write(uint8 data) {
if(regs.sr.drc == 0) {
//16-bit
if(regs.sr.drs == 0) {
regs.sr.drs = 1;
regs.dr = (regs.dr & 0xff00) | (data << 0);
} else {
regs.sr.rqm = 0;
regs.sr.drs = 0;
regs.dr = (data << 8) | (regs.dr & 0x00ff);
}
} else {
//8-bit
regs.sr.rqm = 0;
regs.dr = (regs.dr & 0xff00) | (data << 0);
}
}
uint8 uPD96050::dp_read(uint12 addr) {
bool hi = addr & 1;
addr = (addr >> 1) & 2047;
if(hi == false) {
return dataRAM[addr] >> 0;
} else {
return dataRAM[addr] >> 8;
}
}
void uPD96050::dp_write(uint12 addr, uint8 data) {
bool hi = addr & 1;
addr = (addr >> 1) & 2047;
if(hi == false) {
dataRAM[addr] = (dataRAM[addr] & 0xff00) | (data << 0);
} else {
dataRAM[addr] = (dataRAM[addr] & 0x00ff) | (data << 8);
}
}