* New upstream WIP version. * Update copyright information. * Refresh use-system-tremor.patch and remove psx-big-endian-only.patch. * Add spelling-fixes.patch based on Lintian's recommendations. * Build-depend on debhelper 9 or later and remove corresponding Lintian override.
* This program is free software; you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License as published by
5
* the Free Software Foundation; either version 2 of the License, or
6
* (at your option) any later version.
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*/
17
1
18
#include "psx.h"
19
#include "timer.h"
2
20
3
21
/*
4
22
Notes(some of it may be incomplete or wrong in subtle ways)
45
63
When the counter == 0, the compare flag is set. An IRQ will be generated if (Mode & 0x10), and the hidden IRQ done flag will be set.
46
64
*/
47
65
66
/*
67
Dec. 26, 2011 Note
68
Due to problems I've had with my GPU timing test program, timer2 appears to be unreliable(clocks are skipped?) when target mode is enabled and the full
69
33MHz clock is used(rather than 33MHz / 8). TODO: Investigate further and confirm(or not).
70
*/
71
72
/*
73
FIXME: Clock appropriately(and update events) when using SetRegister() via the debugger.
74
*/
75
48
76
namespace MDFN_IEN_PSX
49
77
{
50
78
64
92
static Timer Timers[3];
65
93
static pscpu_timestamp_t lastts;
66
94
67
void timer_moo(void)
95
static int32 CalcNextEvent(int32 next_event)
68
96
{
69
// Timers[1].Counter = 0;
97
for(int i = 0; i < 3; i++)
98
{
99
int32 target;
100
int32 count_delta;
101
102
if((i == 0 || i == 1) && (Timers[i].Mode & 0x100)) // If clocked by GPU, abort for this timer(will result in poor granularity for pixel-clock-derived timer IRQs, but whatever).
103
continue;
104
105
if(!(Timers[i].Mode & 0x10)) // If IRQ is disabled, abort for this timer.