Search
lxdream.org :: lxdream :: r131:4c25f1b20664
lxdream 0.9.1
released Jun 29
Download Now
changeset131:4c25f1b20664
parent130:279acbacc298
child132:48a8cc541742
authornkeynes
dateThu Mar 30 11:27:11 2006 +0000 (14 years ago)
Add basic AICA RTC implementation
src/aica/aica.c
src/aica/aica.h
1.1 --- a/src/aica/aica.c Thu Mar 30 11:26:45 2006 +0000
1.2 +++ b/src/aica/aica.c Thu Mar 30 11:27:11 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: aica.c,v 1.17 2006-03-14 12:45:53 nkeynes Exp $
1.6 + * $Id: aica.c,v 1.18 2006-03-30 11:27:11 nkeynes Exp $
1.7 *
1.8 * This is the core sound system (ie the bit which does the actual work)
1.9 *
1.10 @@ -18,6 +18,7 @@
1.11
1.12 #define MODULE aica_module
1.13
1.14 +#include <time.h>
1.15 #include "dream.h"
1.16 #include "dreamcast.h"
1.17 #include "mem.h"
1.18 @@ -219,6 +220,30 @@
1.19 }
1.20 }
1.21
1.22 +/* 20 years in seconds */
1.23 +#define RTC_OFFSET 631152000
1.24 +
1.25 +int32_t mmio_region_AICARTC_read( uint32_t reg )
1.26 +{
1.27 + struct timeval tv;
1.28 +
1.29 + switch( reg ) {
1.30 + case AICA_RTCHI:
1.31 + if( gettimeofday( &tv, NULL ) == 0 ) {
1.32 + return ((uint32_t)(tv.tv_sec + RTC_OFFSET)) >> 16;
1.33 + }
1.34 + break;
1.35 + case AICA_RTCLO:
1.36 + if( gettimeofday( &tv, NULL ) == 0 ) {
1.37 + return ((uint32_t)(tv.tv_sec + RTC_OFFSET)) & 0xFFFF;
1.38 + }
1.39 + break;
1.40 + }
1.41 + return 0;
1.42 +}
1.43 +
1.44 +MMIO_REGION_WRITE_STUBFN( AICARTC )
1.45 +
1.46 /**
1.47 * Translate the channel frequency to a sample rate. The frequency is a
1.48 * 14-bit floating point number, where bits 0..9 is the mantissa,
2.1 --- a/src/aica/aica.h Thu Mar 30 11:26:45 2006 +0000
2.2 +++ b/src/aica/aica.h Thu Mar 30 11:27:11 2006 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: aica.h,v 1.8 2006-01-22 22:40:05 nkeynes Exp $
2.6 + * $Id: aica.h,v 1.9 2006-03-30 11:27:11 nkeynes Exp $
2.7 *
2.8 * MMIO definitions for the AICA sound chip. Note that the regions defined
2.9 * here are relative to the SH4 memory map (0x00700000 based), rather than
2.10 @@ -45,10 +45,16 @@
2.11 LONG_PORT( 0xD04, AICA_IRQCLEAR, PORT_MRW, 0, "AICA IRQ Clear" )
2.12 MMIO_REGION_END
2.13
2.14 +MMIO_REGION_BEGIN( 0x00710000, AICARTC, "AICA Sound System RTC" )
2.15 + LONG_PORT( 0x000, AICA_RTCHI, PORT_R, 0, "RTC High 16-bits" )
2.16 + LONG_PORT( 0x004, AICA_RTCLO, PORT_R, 0, "RTC Low 16-bits" )
2.17 +MMIO_REGION_END
2.18 +
2.19 MMIO_REGION_LIST_BEGIN( spu )
2.20 MMIO_REGION( AICA0 )
2.21 MMIO_REGION( AICA1 )
2.22 MMIO_REGION( AICA2 )
2.23 + MMIO_REGION( AICARTC )
2.24 MMIO_REGION_LIST_END
2.25
2.26 void aica_init( void );
.