2010-08-09 13:28:56 +00:00
|
|
|
#ifdef SA1_CPP
|
|
|
|
|
|
|
|
//====================
|
|
|
|
//direct data transfer
|
|
|
|
//====================
|
|
|
|
|
|
|
|
void SA1::dma_normal() {
|
|
|
|
while(mmio.dtc--) {
|
|
|
|
uint8 data = regs.mdr;
|
|
|
|
uint32 dsa = mmio.dsa++;
|
|
|
|
uint32 dda = mmio.dda++;
|
|
|
|
|
|
|
|
//source and destination cannot be the same
|
|
|
|
if(mmio.sd == DMA::SourceBWRAM && mmio.dd == DMA::DestBWRAM) continue;
|
|
|
|
if(mmio.sd == DMA::SourceIRAM && mmio.dd == DMA::DestIRAM ) continue;
|
|
|
|
|
|
|
|
switch(mmio.sd) {
|
|
|
|
case DMA::SourceROM: {
|
|
|
|
if((dsa & 0x408000) == 0x008000 || (dsa & 0xc00000) == 0xc00000) {
|
2011-01-16 13:22:51 +00:00
|
|
|
data = bus_read(dsa);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case DMA::SourceBWRAM: {
|
|
|
|
if((dsa & 0x40e000) == 0x006000 || (dsa & 0xf00000) == 0x400000) {
|
2011-01-16 13:22:51 +00:00
|
|
|
data = bus_read(dsa);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case DMA::SourceIRAM: {
|
Update to v074r11 release.
byuu says:
Changelog:
- debugger compiles on all three profiles
- libsnes compiles on all three platforms (no API changes to libsnes)
- memory.cpp : namespace memory removed (wram -> cpu, apuram -> smp,
vram, oam, cgram -> ppu)
- sa1.cpp : namespace memory removed (SA-1 specific functions merged
inline to SA1::bus_read,write)
- GameBoy: added serial link support with interrupts and proper 8192hz
timing, but obviously it acts as if no other GB is connected to it
- GameBoy: added STAT OAM interrupt, and better STAT d1,d0 mode values
- UI: since Qt is dead, I've renamed the config files back to bsnes.cfg
and bsnes-geometry.cfg
- SA1: IRAM was not syncing to CPU on SA-1 side
- PPU/Accuracy and PPU/Performance needed Sprite oam renamed to Sprite
sprite; so that I could add uint8 oam[544]
- makes more sense anyway, OAM = object attribute memory, obj or
sprite are better names for Sprite rendering class
- more cleanup
2011-01-24 09:03:17 +00:00
|
|
|
data = iram.read(dsa & 0x07ff);
|
2010-08-09 13:28:56 +00:00
|
|
|
} break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(mmio.dd) {
|
|
|
|
case DMA::DestBWRAM: {
|
|
|
|
if((dda & 0x40e000) == 0x006000 || (dda & 0xf00000) == 0x400000) {
|
2011-01-16 13:22:51 +00:00
|
|
|
bus_write(dda, data);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case DMA::DestIRAM: {
|
Update to v074r11 release.
byuu says:
Changelog:
- debugger compiles on all three profiles
- libsnes compiles on all three platforms (no API changes to libsnes)
- memory.cpp : namespace memory removed (wram -> cpu, apuram -> smp,
vram, oam, cgram -> ppu)
- sa1.cpp : namespace memory removed (SA-1 specific functions merged
inline to SA1::bus_read,write)
- GameBoy: added serial link support with interrupts and proper 8192hz
timing, but obviously it acts as if no other GB is connected to it
- GameBoy: added STAT OAM interrupt, and better STAT d1,d0 mode values
- UI: since Qt is dead, I've renamed the config files back to bsnes.cfg
and bsnes-geometry.cfg
- SA1: IRAM was not syncing to CPU on SA-1 side
- PPU/Accuracy and PPU/Performance needed Sprite oam renamed to Sprite
sprite; so that I could add uint8 oam[544]
- makes more sense anyway, OAM = object attribute memory, obj or
sprite are better names for Sprite rendering class
- more cleanup
2011-01-24 09:03:17 +00:00
|
|
|
iram.write(dda & 0x07ff, data);
|
2010-08-09 13:28:56 +00:00
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mmio.dma_irqfl = true;
|
|
|
|
if(mmio.dma_irqen) mmio.dma_irqcl = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//((byte & 6) << 3) + (byte & 1) explanation:
|
|
|
|
//transforms a byte index (0-7) into a planar index:
|
|
|
|
//result[] = { 0, 1, 16, 17, 32, 33, 48, 49 };
|
|
|
|
//works for 2bpp, 4bpp and 8bpp modes
|
|
|
|
|
|
|
|
//===========================
|
|
|
|
//type-1 character conversion
|
|
|
|
//===========================
|
|
|
|
|
|
|
|
void SA1::dma_cc1() {
|
Update to v074r11 release.
byuu says:
Changelog:
- debugger compiles on all three profiles
- libsnes compiles on all three platforms (no API changes to libsnes)
- memory.cpp : namespace memory removed (wram -> cpu, apuram -> smp,
vram, oam, cgram -> ppu)
- sa1.cpp : namespace memory removed (SA-1 specific functions merged
inline to SA1::bus_read,write)
- GameBoy: added serial link support with interrupts and proper 8192hz
timing, but obviously it acts as if no other GB is connected to it
- GameBoy: added STAT OAM interrupt, and better STAT d1,d0 mode values
- UI: since Qt is dead, I've renamed the config files back to bsnes.cfg
and bsnes-geometry.cfg
- SA1: IRAM was not syncing to CPU on SA-1 side
- PPU/Accuracy and PPU/Performance needed Sprite oam renamed to Sprite
sprite; so that I could add uint8 oam[544]
- makes more sense anyway, OAM = object attribute memory, obj or
sprite are better names for Sprite rendering class
- more cleanup
2011-01-24 09:03:17 +00:00
|
|
|
cpubwram.dma = true;
|
2010-08-09 13:28:56 +00:00
|
|
|
mmio.chdma_irqfl = true;
|
|
|
|
if(mmio.chdma_irqen) {
|
|
|
|
mmio.chdma_irqcl = 0;
|
|
|
|
cpu.regs.irq = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8 SA1::dma_cc1_read(unsigned addr) {
|
|
|
|
//16 bytes/char (2bpp); 32 bytes/char (4bpp); 64 bytes/char (8bpp)
|
|
|
|
unsigned charmask = (1 << (6 - mmio.dmacb)) - 1;
|
|
|
|
|
|
|
|
if((addr & charmask) == 0) {
|
|
|
|
//buffer next character to I-RAM
|
|
|
|
unsigned bpp = 2 << (2 - mmio.dmacb);
|
|
|
|
unsigned bpl = (8 << mmio.dmasize) >> mmio.dmacb;
|
2012-07-08 02:57:34 +00:00
|
|
|
unsigned bwmask = bwram.size() - 1;
|
2010-08-09 13:28:56 +00:00
|
|
|
unsigned tile = ((addr - mmio.dsa) & bwmask) >> (6 - mmio.dmacb);
|
|
|
|
unsigned ty = (tile >> mmio.dmasize);
|
|
|
|
unsigned tx = tile & ((1 << mmio.dmasize) - 1);
|
|
|
|
unsigned bwaddr = mmio.dsa + ty * 8 * bpl + tx * bpp;
|
|
|
|
|
|
|
|
for(unsigned y = 0; y < 8; y++) {
|
|
|
|
uint64 data = 0;
|
|
|
|
for(unsigned byte = 0; byte < bpp; byte++) {
|
2012-07-08 02:57:34 +00:00
|
|
|
data |= (uint64)bwram.read((bwaddr + byte) & bwmask) << (byte << 3);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
bwaddr += bpl;
|
|
|
|
|
|
|
|
uint8 out[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
|
|
|
for(unsigned x = 0; x < 8; x++) {
|
|
|
|
out[0] |= (data & 1) << (7 - x); data >>= 1;
|
|
|
|
out[1] |= (data & 1) << (7 - x); data >>= 1;
|
|
|
|
if(mmio.dmacb == 2) continue;
|
|
|
|
out[2] |= (data & 1) << (7 - x); data >>= 1;
|
|
|
|
out[3] |= (data & 1) << (7 - x); data >>= 1;
|
|
|
|
if(mmio.dmacb == 1) continue;
|
|
|
|
out[4] |= (data & 1) << (7 - x); data >>= 1;
|
|
|
|
out[5] |= (data & 1) << (7 - x); data >>= 1;
|
|
|
|
out[6] |= (data & 1) << (7 - x); data >>= 1;
|
|
|
|
out[7] |= (data & 1) << (7 - x); data >>= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(unsigned byte = 0; byte < bpp; byte++) {
|
|
|
|
unsigned p = mmio.dda + (y << 1) + ((byte & 6) << 3) + (byte & 1);
|
Update to v074r11 release.
byuu says:
Changelog:
- debugger compiles on all three profiles
- libsnes compiles on all three platforms (no API changes to libsnes)
- memory.cpp : namespace memory removed (wram -> cpu, apuram -> smp,
vram, oam, cgram -> ppu)
- sa1.cpp : namespace memory removed (SA-1 specific functions merged
inline to SA1::bus_read,write)
- GameBoy: added serial link support with interrupts and proper 8192hz
timing, but obviously it acts as if no other GB is connected to it
- GameBoy: added STAT OAM interrupt, and better STAT d1,d0 mode values
- UI: since Qt is dead, I've renamed the config files back to bsnes.cfg
and bsnes-geometry.cfg
- SA1: IRAM was not syncing to CPU on SA-1 side
- PPU/Accuracy and PPU/Performance needed Sprite oam renamed to Sprite
sprite; so that I could add uint8 oam[544]
- makes more sense anyway, OAM = object attribute memory, obj or
sprite are better names for Sprite rendering class
- more cleanup
2011-01-24 09:03:17 +00:00
|
|
|
iram.write(p & 0x07ff, out[byte]);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Update to v074r11 release.
byuu says:
Changelog:
- debugger compiles on all three profiles
- libsnes compiles on all three platforms (no API changes to libsnes)
- memory.cpp : namespace memory removed (wram -> cpu, apuram -> smp,
vram, oam, cgram -> ppu)
- sa1.cpp : namespace memory removed (SA-1 specific functions merged
inline to SA1::bus_read,write)
- GameBoy: added serial link support with interrupts and proper 8192hz
timing, but obviously it acts as if no other GB is connected to it
- GameBoy: added STAT OAM interrupt, and better STAT d1,d0 mode values
- UI: since Qt is dead, I've renamed the config files back to bsnes.cfg
and bsnes-geometry.cfg
- SA1: IRAM was not syncing to CPU on SA-1 side
- PPU/Accuracy and PPU/Performance needed Sprite oam renamed to Sprite
sprite; so that I could add uint8 oam[544]
- makes more sense anyway, OAM = object attribute memory, obj or
sprite are better names for Sprite rendering class
- more cleanup
2011-01-24 09:03:17 +00:00
|
|
|
return iram.read((mmio.dda + (addr & charmask)) & 0x07ff);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================
|
|
|
|
//type-2 character conversion
|
|
|
|
//===========================
|
|
|
|
|
|
|
|
void SA1::dma_cc2() {
|
|
|
|
//select register file index (0-7 or 8-15)
|
|
|
|
const uint8 *brf = &mmio.brf[(dma.line & 1) << 3];
|
|
|
|
unsigned bpp = 2 << (2 - mmio.dmacb);
|
|
|
|
unsigned addr = mmio.dda & 0x07ff;
|
|
|
|
addr &= ~((1 << (7 - mmio.dmacb)) - 1);
|
|
|
|
addr += (dma.line & 8) * bpp;
|
|
|
|
addr += (dma.line & 7) * 2;
|
|
|
|
|
|
|
|
for(unsigned byte = 0; byte < bpp; byte++) {
|
|
|
|
uint8 output = 0;
|
|
|
|
for(unsigned bit = 0; bit < 8; bit++) {
|
|
|
|
output |= ((brf[bit] >> byte) & 1) << (7 - bit);
|
|
|
|
}
|
Update to v074r11 release.
byuu says:
Changelog:
- debugger compiles on all three profiles
- libsnes compiles on all three platforms (no API changes to libsnes)
- memory.cpp : namespace memory removed (wram -> cpu, apuram -> smp,
vram, oam, cgram -> ppu)
- sa1.cpp : namespace memory removed (SA-1 specific functions merged
inline to SA1::bus_read,write)
- GameBoy: added serial link support with interrupts and proper 8192hz
timing, but obviously it acts as if no other GB is connected to it
- GameBoy: added STAT OAM interrupt, and better STAT d1,d0 mode values
- UI: since Qt is dead, I've renamed the config files back to bsnes.cfg
and bsnes-geometry.cfg
- SA1: IRAM was not syncing to CPU on SA-1 side
- PPU/Accuracy and PPU/Performance needed Sprite oam renamed to Sprite
sprite; so that I could add uint8 oam[544]
- makes more sense anyway, OAM = object attribute memory, obj or
sprite are better names for Sprite rendering class
- more cleanup
2011-01-24 09:03:17 +00:00
|
|
|
iram.write(addr + ((byte & 6) << 3) + (byte & 1), output);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dma.line = (dma.line + 1) & 15;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|