2012-04-10 11:41:35 +00:00
|
|
|
void CPU::timer_step(unsigned clocks) {
|
2012-04-14 07:26:45 +00:00
|
|
|
for(unsigned c = 0; c < clocks; c++) {
|
|
|
|
for(unsigned n = 0; n < 4; n++) {
|
2013-05-05 09:21:30 +00:00
|
|
|
auto& timer = regs.timer[n];
|
2012-04-14 07:26:45 +00:00
|
|
|
if(timer.control.enable == false || timer.control.cascade == true) continue;
|
2012-04-07 08:17:49 +00:00
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
static unsigned mask[] = {0, 63, 255, 1023};
|
2012-04-14 07:26:45 +00:00
|
|
|
if((regs.clock & mask[timer.control.frequency]) == 0) {
|
|
|
|
timer_increment(n);
|
|
|
|
}
|
2012-04-07 08:17:49 +00:00
|
|
|
}
|
2012-04-14 07:26:45 +00:00
|
|
|
|
|
|
|
regs.clock++;
|
2012-04-07 08:17:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPU::timer_increment(unsigned n) {
|
2013-05-05 09:21:30 +00:00
|
|
|
auto& timer = regs.timer[n];
|
2012-04-14 07:26:45 +00:00
|
|
|
if(++timer.period == 0) {
|
|
|
|
timer.period = timer.reload;
|
|
|
|
|
|
|
|
if(timer.control.irq) regs.irq.flag.timer[n] = 1;
|
2012-04-07 08:17:49 +00:00
|
|
|
|
Update to v087r30 release.
byuu says:
Changelog:
- DMA channel masks added (some are 27-bit source/target and some are
14-bit length -- hooray, varuint_t class.)
- No more state.pending flags. Instead, we set dma.pending flag when we
want a transfer (fixes GBA Video - Pokemon audio) [Cydrak]
- fixed OBJ Vmosaic [Cydrak, krom]
- OBJ cannot read <=0x13fff in BG modes 3-5 (fixes the garbled tile at
the top-left of some games)
- DMA timing should be much closer to hardware now, but probably not
perfect
- PPU frame blending uses blargg's bit-perfect, rounded method (slower,
but what can you do?)
- GBA carts really unload now
- added nall/gba/cartridge.hpp: used when there is no manifest. Scans
ROMs for library tags, and selects the first valid one found
- added EEPROM auto-detection when EEPROM size=0. Forces disk/save state
size to 8192 (otherwise states could crash between pre and post
detect.)
- detects first read after a set read address command when the size
is zero, and sets all subsequent bit-lengths to that value, prints
detected size to terminal
- added nall/nes/cartridge.hpp: moves iNES detection out of emulation
core.
Important to note: long-term goal is to remove all
nall/(system)/cartridge.hpp detections from the core and replace with
databases. All in good time.
Anyway, the GBA workarounds should work for ~98.5% of the library, if my
pre-scanning was correct (~40 games with odd tags. I reject ones without
numeric versions now, too.)
I think we're basically at a point where we can release a new version
now. Compatibility should be relatively high (at least for a first
release), and fixes are only going to affect one or two games at a time.
I'd like to start doing some major cleaning house internally (rename
NES->Famicom, SNES->SuperFamicom and such.) Would be much wiser to do
that on a .01 WIP to minimize regressions.
The main problems with a release now:
- speed is pretty bad, haven't really optimized much yet (not sure how
much we can improve it yet, this usually isn't easy)
- sound isn't -great-, but the GBA audio sucks anyway :P
- couple of known bugs (Sonic X video, etc.)
2012-04-22 10:49:19 +00:00
|
|
|
if(apu.fifo[0].timer == n) timer_fifo_run(0);
|
|
|
|
if(apu.fifo[1].timer == n) timer_fifo_run(1);
|
2012-04-09 06:19:32 +00:00
|
|
|
|
2012-04-14 07:26:45 +00:00
|
|
|
if(n < 3 && regs.timer[n + 1].control.enable && regs.timer[n + 1].control.cascade) {
|
|
|
|
timer_increment(n + 1);
|
|
|
|
}
|
2012-04-07 08:17:49 +00:00
|
|
|
}
|
|
|
|
}
|
Update to v087r30 release.
byuu says:
Changelog:
- DMA channel masks added (some are 27-bit source/target and some are
14-bit length -- hooray, varuint_t class.)
- No more state.pending flags. Instead, we set dma.pending flag when we
want a transfer (fixes GBA Video - Pokemon audio) [Cydrak]
- fixed OBJ Vmosaic [Cydrak, krom]
- OBJ cannot read <=0x13fff in BG modes 3-5 (fixes the garbled tile at
the top-left of some games)
- DMA timing should be much closer to hardware now, but probably not
perfect
- PPU frame blending uses blargg's bit-perfect, rounded method (slower,
but what can you do?)
- GBA carts really unload now
- added nall/gba/cartridge.hpp: used when there is no manifest. Scans
ROMs for library tags, and selects the first valid one found
- added EEPROM auto-detection when EEPROM size=0. Forces disk/save state
size to 8192 (otherwise states could crash between pre and post
detect.)
- detects first read after a set read address command when the size
is zero, and sets all subsequent bit-lengths to that value, prints
detected size to terminal
- added nall/nes/cartridge.hpp: moves iNES detection out of emulation
core.
Important to note: long-term goal is to remove all
nall/(system)/cartridge.hpp detections from the core and replace with
databases. All in good time.
Anyway, the GBA workarounds should work for ~98.5% of the library, if my
pre-scanning was correct (~40 games with odd tags. I reject ones without
numeric versions now, too.)
I think we're basically at a point where we can release a new version
now. Compatibility should be relatively high (at least for a first
release), and fixes are only going to affect one or two games at a time.
I'd like to start doing some major cleaning house internally (rename
NES->Famicom, SNES->SuperFamicom and such.) Would be much wiser to do
that on a .01 WIP to minimize regressions.
The main problems with a release now:
- speed is pretty bad, haven't really optimized much yet (not sure how
much we can improve it yet, this usually isn't easy)
- sound isn't -great-, but the GBA audio sucks anyway :P
- couple of known bugs (Sonic X video, etc.)
2012-04-22 10:49:19 +00:00
|
|
|
|
|
|
|
void CPU::timer_fifo_run(unsigned n) {
|
|
|
|
apu.fifo[n].read();
|
|
|
|
if(apu.fifo[n].size > 16) return;
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
auto& dma = regs.dma[1 + n];
|
Update to v087r30 release.
byuu says:
Changelog:
- DMA channel masks added (some are 27-bit source/target and some are
14-bit length -- hooray, varuint_t class.)
- No more state.pending flags. Instead, we set dma.pending flag when we
want a transfer (fixes GBA Video - Pokemon audio) [Cydrak]
- fixed OBJ Vmosaic [Cydrak, krom]
- OBJ cannot read <=0x13fff in BG modes 3-5 (fixes the garbled tile at
the top-left of some games)
- DMA timing should be much closer to hardware now, but probably not
perfect
- PPU frame blending uses blargg's bit-perfect, rounded method (slower,
but what can you do?)
- GBA carts really unload now
- added nall/gba/cartridge.hpp: used when there is no manifest. Scans
ROMs for library tags, and selects the first valid one found
- added EEPROM auto-detection when EEPROM size=0. Forces disk/save state
size to 8192 (otherwise states could crash between pre and post
detect.)
- detects first read after a set read address command when the size
is zero, and sets all subsequent bit-lengths to that value, prints
detected size to terminal
- added nall/nes/cartridge.hpp: moves iNES detection out of emulation
core.
Important to note: long-term goal is to remove all
nall/(system)/cartridge.hpp detections from the core and replace with
databases. All in good time.
Anyway, the GBA workarounds should work for ~98.5% of the library, if my
pre-scanning was correct (~40 games with odd tags. I reject ones without
numeric versions now, too.)
I think we're basically at a point where we can release a new version
now. Compatibility should be relatively high (at least for a first
release), and fixes are only going to affect one or two games at a time.
I'd like to start doing some major cleaning house internally (rename
NES->Famicom, SNES->SuperFamicom and such.) Would be much wiser to do
that on a .01 WIP to minimize regressions.
The main problems with a release now:
- speed is pretty bad, haven't really optimized much yet (not sure how
much we can improve it yet, this usually isn't easy)
- sound isn't -great-, but the GBA audio sucks anyway :P
- couple of known bugs (Sonic X video, etc.)
2012-04-22 10:49:19 +00:00
|
|
|
if(dma.control.enable && dma.control.timingmode == 3) {
|
|
|
|
dma.pending = true;
|
|
|
|
dma.control.targetmode = 2;
|
|
|
|
dma.control.size = 1;
|
|
|
|
dma.run.length = 4;
|
|
|
|
}
|
|
|
|
}
|