ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/ps2launchargs/source/uLaunchELF/timer.c
Revision: 1101
Committed: Wed Feb 7 05:08:54 2018 UTC (7 years, 8 months ago) by iritscen
Content type: text/x-csrc
File size: 943 byte(s)
Log Message:
Added following to ps2launchargs:\n-Source code.\n-DLL needed to run ps2client.\n-Instructions for building uLaunchELF.

File Contents

# Content
1 #include "launchelf.h"
2
3 // Timer Define
4 #define T0_COUNT ((volatile unsigned long*)0x10000000)
5 #define T0_MODE ((volatile unsigned long*)0x10000010)
6
7 static int TimerInterruptID = -1;
8 static u64 TimerInterruptCount = 0;
9
10 // Timer Interrupt
11 int TimerInterrupt(int a)
12 {
13 TimerInterruptCount++;
14 *T0_MODE |= (1 << 11);
15 return -1;
16 }
17 // Timer Init
18 void TimerInit(void)
19 {
20 *T0_MODE = 0x0000;
21 TimerInterruptID = AddIntcHandler(9, TimerInterrupt, 0);
22 EnableIntc(9);
23 *T0_COUNT = 0;
24 *T0_MODE = ( 2 << 0 )+( 1 << 7 )+( 1 << 9 );
25 TimerInterruptCount = 0;
26 }
27 // Timer Count
28 u64 Timer(void)
29 {
30 u64 ticks = (*T0_COUNT + (TimerInterruptCount << 16)) * (1000.0F / ( 147456000.0F / 256.0F ));
31 return ticks;
32 }
33 // Timer End
34 void TimerEnd(void)
35 {
36 *T0_MODE = 0x0000;
37 if (TimerInterruptID >= 0){
38 DisableIntc(9);
39 RemoveIntcHandler(9, TimerInterruptID);
40 TimerInterruptID = -1;
41 }
42 TimerInterruptCount = 0;
43 }

Properties

Name Value
svn:executable *