summaryrefslogtreecommitdiff
path: root/dxr3interface.c
diff options
context:
space:
mode:
authorscop <scop>2005-03-14 12:12:01 +0000
committerscop <scop>2005-03-14 12:12:01 +0000
commitcf794d1056663715946e80c11d18de03c2f3699d (patch)
treef3f842026d0f33e1cf2509f5803b62e13549e453 /dxr3interface.c
parent8a33eabe46275b85d546df102c4989356c424a66 (diff)
downloadvdr-plugin-dxr3-cf794d1056663715946e80c11d18de03c2f3699d.tar.gz
vdr-plugin-dxr3-cf794d1056663715946e80c11d18de03c2f3699d.tar.bz2
Merge copyright infos from HEAD.
Diffstat (limited to 'dxr3interface.c')
-rw-r--r--dxr3interface.c388
1 files changed, 74 insertions, 314 deletions
diff --git a/dxr3interface.c b/dxr3interface.c
index 4211048..6226f23 100644
--- a/dxr3interface.c
+++ b/dxr3interface.c
@@ -26,7 +26,8 @@
#include "dxr3interface.h"
#include "dxr3syncbuffer.h"
-#include "dxr3osd.h"
+#include "dxr3log.h"
+#include "dxr3configdata.h"
// ==================================
const int LPCM_HEADER_LENGTH = 7;
@@ -34,16 +35,7 @@ const int ZEROBUFFER_SIZE = 4096;
uint8_t zerobuffer[ZEROBUFFER_SIZE] = {0};
// ==================================
-//! default spu palette
-static unsigned default_palette[16] =
-{
- 0xe18080, 0x2b8080, 0x847b9c, 0x51ef5a, 0x7d8080, 0xb48080,
- 0xa910a5, 0x6addca, 0xd29210, 0x1c76b8, 0x50505a, 0x30b86d,
- 0x5d4792, 0x3dafa5, 0x718947, 0xeb8080
-};
-
-// ==================================
-//! helper function to generate name
+// helper function to generate name
static const char *Dxr3Name(const char *Name, int n)
{
static char buffer[PATH_MAX];
@@ -52,7 +44,7 @@ static const char *Dxr3Name(const char *Name, int n)
}
// ==================================
-//! helper function to open the card #n
+// helper function to open the card #n
static int Dxr3Open(const char *Name, int n, int Mode)
{
const char *FileName = Dxr3Name(Name, n);
@@ -61,27 +53,26 @@ static int Dxr3Open(const char *Name, int n, int Mode)
if (fd < 0)
{
cLog::Instance() << "Unable to open " << FileName << "\n";
- return 0;
}
return fd;
}
// ==================================
-//! constructor
+// constr.
cDxr3Interface::cDxr3Interface()
{
// open control stream
m_fdControl = Dxr3Open("", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
if (!m_fdControl)
{
+ cLog::Instance() << "Unable to open the control stream!\n";
cLog::Instance() << "Please check if the dxr3 modules are loaded!\n";
- exit(1);
}
// upload microcode to dxr3
UploadMicroCode();
- ///< open 'multimedia' streams
+ // open 'multimedia' streams
m_fdVideo = Dxr3Open("_mv", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
m_fdAudio = Dxr3Open("_ma", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
m_fdSpu = Dxr3Open("_sp", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
@@ -93,10 +84,8 @@ cDxr3Interface::cDxr3Interface()
exit(1);
}
- // create clock
m_pClock = new cDxr3SysClock(m_fdControl, m_fdVideo, m_fdSpu);
- // everything ok?
if (!m_pClock)
{
cLog::Instance() << "Unable to allocate memory for m_pClock in cDxr3Interface\n";
@@ -137,7 +126,6 @@ cDxr3Interface::cDxr3Interface()
}
// ==================================
-//! destructor
cDxr3Interface::~cDxr3Interface()
{
// close filehandles
@@ -178,11 +166,11 @@ void cDxr3Interface::Stop()
// audio
// ==================================
-//! set audio-output to analog
+// set audio-output to analog
void cDxr3Interface::SetAudioAnalog()
{
- Lock();
int ioval = 0;
+ Lock();
if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_ANALOG)
{
@@ -202,12 +190,12 @@ void cDxr3Interface::SetAudioAnalog()
}
// ==================================
-//! set audio-output to digital pcm
+// set audio-output to digital pcm
void cDxr3Interface::SetAudioDigitalPCM()
{
- Lock();
int ioval = 0;
-
+ Lock();
+
if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_DIGITALPCM)
{
int prevMode = m_audioMode;
@@ -227,14 +215,13 @@ void cDxr3Interface::SetAudioDigitalPCM()
}
// ==================================
-//! set audio-output to digital ac3
+// set audio-output to digital ac3
void cDxr3Interface::SetAudioDigitalAC3()
{
- Lock();
-
if (m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
{
int ioval = 0;
+ Lock();
if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
{
@@ -245,17 +232,14 @@ void cDxr3Interface::SetAudioDigitalAC3()
}
ReOpenAudio();
}
+
+ Unlock();
}
-
- Unlock();
}
// ==================================
-//! set audiosepeed
void cDxr3Interface::SetAudioSpeed(uint32_t speed)
{
- Lock();
-
if (m_audioDataRate != speed && speed != UNKNOWN_DATA_RATE)
{
if (!m_ExternalReleased)
@@ -270,16 +254,11 @@ void cDxr3Interface::SetAudioSpeed(uint32_t speed)
}
m_audioDataRate = speed;
}
-
- Unlock();
}
// ==================================
-//! set nummber of channels
void cDxr3Interface::SetChannelCount(uint32_t count)
{
- Lock();
-
if (m_audioChannelCount != count && count != UNKNOWN_CHANNEL_COUNT)
{
if (!m_ExternalReleased)
@@ -294,16 +273,11 @@ void cDxr3Interface::SetChannelCount(uint32_t count)
}
m_audioChannelCount = count;
}
-
- Unlock();
}
// ==================================
-//! set audio sample size
void cDxr3Interface::SetAudioSampleSize(uint32_t sampleSize)
{
- Lock();
-
if (!m_ExternalReleased)
{
if (ioctl(m_fdAudio, SNDCTL_DSP_SAMPLESIZE, sampleSize))
@@ -311,58 +285,42 @@ void cDxr3Interface::SetAudioSampleSize(uint32_t sampleSize)
cLog::Instance() <<"cDxr3AbsDevice::SetAudioSampleSize Unable to set audio sample size\n";
}
}
- m_audioSampleSize = sampleSize;
-
- Unlock();
+ m_audioSampleSize = sampleSize;
}
// clock
// ==================================
void cDxr3Interface::SetSysClock(uint32_t scr)
{
- Lock();
-
if (!m_ExternalReleased)
{
m_pClock->SetSysClock(scr);
}
-
- Unlock();
}
// ==================================
uint32_t cDxr3Interface::GetSysClock() const
{
- Lock();
-
uint32_t ret = 0;
if (!m_ExternalReleased)
{
ret = m_pClock->GetSysClock();
- }
-
- Unlock();
+ }
return ret;
}
// ==================================
void cDxr3Interface::SetPts(uint32_t pts)
{
- Lock();
-
if (!m_ExternalReleased)
{
m_pClock->SetPts(pts);
}
-
- Unlock();
}
// ==================================
void cDxr3Interface::SetSpuPts(uint32_t pts)
{
- Lock();
-
pts = pts >> 1;
if (!m_ExternalReleased)
{
@@ -371,17 +329,15 @@ void cDxr3Interface::SetSpuPts(uint32_t pts)
m_pClock->SetSpuPts(pts);
}
}
-
- Unlock();
}
// state changes
// ==================================
-//! enable subpicture processing of the dxr3
+// enable subpicture proeccesing of the dxr3
void cDxr3Interface::EnableSPU()
{
- Lock();
int ioval = 0;
+ Lock();
if (!m_ExternalReleased && m_spuMode != EM8300_SPUMODE_ON)
{
@@ -396,12 +352,11 @@ void cDxr3Interface::EnableSPU()
}
// ==================================
-//! disable subpicture proeccesing of the dxr3
+// disable subpicture proeccesing of the dxr3
void cDxr3Interface::DisableSPU()
{
- Lock();
-
int ioval = 0;
+ Lock();
if (!m_ExternalReleased && m_spuMode != EM8300_SPUMODE_OFF)
{
@@ -416,11 +371,9 @@ void cDxr3Interface::DisableSPU()
}
// ==================================
-//! disable audio output of dxr3
+// disable audio output of dxr3
void cDxr3Interface::DisableAudio()
{
- Lock();
-
m_AudioActive = false;
// we wirte zero buffers to dxr3
@@ -431,15 +384,12 @@ void cDxr3Interface::DisableAudio()
if (write(m_fdAudio, zerobuffer, ZEROBUFFER_SIZE) < 0) Resuscitation();
if (write(m_fdAudio, zerobuffer, ZEROBUFFER_SIZE) < 0) Resuscitation();
}
- Unlock();
}
// ==================================
-//! enable overlay mode of the dxr3
+// enable overlay mode of the dxr3
void cDxr3Interface::EnableOverlay()
{
- Lock();
-
// first we check, if it is enable yet
if (m_OverlayActive)
{
@@ -488,32 +438,26 @@ void cDxr3Interface::EnableOverlay()
}
m_OverlayActive = true;
-
- Unlock();
}
// ==================================
-//! disable overlay mode of the dxr3
+// disable overlay mode of the dxr3
void cDxr3Interface::DisanleOverlay()
{
- Lock();
-
// is it allready disabled
if (!m_OverlayActive)
{
return;
}
-
- Unlock();
}
// set/get functions
// ==================================
-//! get aspect ratio
+// get aspect ratio
uint32_t cDxr3Interface::GetAspectRatio() const
{
- Lock();
int ioval = 0;
+ Lock();
if (!m_ExternalReleased)
{
@@ -528,12 +472,11 @@ uint32_t cDxr3Interface::GetAspectRatio() const
}
// ==================================
-//! set aspectratio
void cDxr3Interface::SetAspectRatio(uint32_t ratio)
{
- Lock();
-
static int requestCounter = 0;
+
+ Lock();
if (cDxr3ConfigData::Instance().GetForceLetterBox()) ratio = EM8300_ASPECTRATIO_16_9;
if (Setup.VideoFormat) ratio = EM8300_ASPECTRATIO_4_3;
@@ -570,14 +513,14 @@ void cDxr3Interface::SetAspectRatio(uint32_t ratio)
// play functions
// ==================================
-//! set playing mode and start sync engine
+// set playing mode and start sync engine
void cDxr3Interface::SetPlayMode()
{
- Lock();
-
em8300_register_t reg;
int ioval;
+ Lock();
+
if (!m_ExternalReleased)
{
ioval = EM8300_SUBDEVICE_AUDIO;
@@ -606,9 +549,8 @@ void cDxr3Interface::SetPlayMode()
// ==================================
void cDxr3Interface::Pause()
{
- Lock();
-
int ioval = EM8300_PLAYMODE_PAUSED;
+ Lock();
if (!m_ExternalReleased)
{
@@ -623,9 +565,8 @@ void cDxr3Interface::Pause()
// ==================================
void cDxr3Interface::SingleStep()
{
+ int ioval = EM8300_PLAYMODE_SINGLESTEP;
Lock();
-
- int ioval = EM8300_PLAYMODE_SINGLESTEP;
if (!m_ExternalReleased)
{
@@ -640,13 +581,13 @@ void cDxr3Interface::SingleStep()
// ==================================
void cDxr3Interface::PlayVideoFrame(cFixedLengthFrame* pFrame, int times)
{
- Lock();
-
int written = 0;
int count = 0;
if (m_VideoActive)
{
+ Lock();
+
if (!m_ExternalReleased)
{
for (int i = 0; i < times; i++)
@@ -670,30 +611,23 @@ void cDxr3Interface::PlayVideoFrame(cFixedLengthFrame* pFrame, int times)
written = 0;
}
}
+
+ Unlock();
+
SetAspectRatio(pFrame->GetAspectRatio());
}
-
- Unlock();
}
// ==================================
void cDxr3Interface::PlayVideoFrame(const uint8_t* pBuf, int length, int times)
{
Lock();
-
- int written = 0;
if (!m_ExternalReleased)
{
for (int i = 0; i < times; i++)
{
- // if (write(m_fdVideo, pBuf, length) < 0) Resuscitation();
-
- if ((written = write(m_fdVideo, pBuf, length) < 0)) Resuscitation();
- if (written != length)
- {
- cLog::Instance() << "cDxr3Interface::PlayVideoFrame(uint8_t* pBuf, int length): Not written = " << length - written << "\n";
- }
+ if (write(m_fdVideo, pBuf, length) < 0) Resuscitation();
}
}
@@ -703,31 +637,32 @@ void cDxr3Interface::PlayVideoFrame(const uint8_t* pBuf, int length, int times)
// ==================================
void cDxr3Interface::PlayAudioFrame(cFixedLengthFrame* pFrame)
{
- Lock();
+
+ // XXX: Call this only with we are not in external mode?
if (m_AudioActive)
{
+ Lock();
+
SetAudioSpeed(pFrame->GetDataRate());
SetChannelCount(pFrame->GetChannelCount());
if (!m_ExternalReleased)
{
- int size = pFrame->GetCount();
if (!cDxr3ConfigData::Instance().GetAc3OutPut()) ResampleVolume((short*)pFrame->GetData(), pFrame->GetCount());
-
- write(m_fdAudio, pFrame->GetData(), size);
+ write(m_fdAudio, pFrame->GetData(), pFrame->GetCount());
}
+
+ Unlock();
}
- Unlock();
}
// ==================================
void cDxr3Interface::PlayAudioFrame(uint8_t* pBuf, int length)
{
+ int written = 0;
Lock();
- int written = 0;
-
if (!m_ExternalReleased)
{
if (!cDxr3ConfigData::Instance().GetAc3OutPut()) ResampleVolume((short*)pBuf, length);
@@ -738,15 +673,12 @@ void cDxr3Interface::PlayAudioFrame(uint8_t* pBuf, int length)
cLog::Instance() << "cDxr3Interface::PlayAudioFrame(uint8_t* pBuf, int length): Not written = " << length - written << "\n";
}
}
-
Unlock();
}
// ==================================
void cDxr3Interface::PlayAudioLpcmFrame(uint8_t* pBuf, int length)
{
- Lock();
-
if (length > (LPCM_HEADER_LENGTH + 2))
{
uint8_t* pFrame = new uint8_t[length - LPCM_HEADER_LENGTH];
@@ -784,14 +716,12 @@ void cDxr3Interface::PlayAudioLpcmFrame(uint8_t* pBuf, int length)
PlayAudioFrame(pFrame, length - LPCM_HEADER_LENGTH);
delete[] pFrame;
}
-
- Unlock();
}
// external device access
// ==================================
-//! release devices, so mplayer-plugin, for instance,
-//! can access the dxr3
+// release devices, so mplayer-plugin, for instance,
+// can access the dxr3
void cDxr3Interface::ExternalReleaseDevices()
{
Lock();
@@ -814,7 +744,7 @@ void cDxr3Interface::ExternalReleaseDevices()
}
// ==================================
-//! reopen devices for using in the dxr3 plugin
+// reopen devices for using in the dxr3 plugin
void cDxr3Interface::ExternalReopenDevices()
{
Lock();
@@ -855,14 +785,14 @@ void cDxr3Interface::ExternalReopenDevices()
// tools
// ==================================
-//! play blackframe on tv
+// play blackframe on tv
void cDxr3Interface::PlayBlackFrame()
-{
- Lock();
-
+{
extern char blackframe[];
- extern int blackframeLength;
-
+ extern int blackframeLength;
+
+ Lock();
+
if (!m_ExternalReleased)
{
if (write(m_fdVideo, blackframe, blackframeLength) < 0) Resuscitation();
@@ -914,26 +844,22 @@ cOsdBase* cDxr3Interface::NewOsd(int x, int y)
#endif
// ==================================
-//! uploadroutine for microcode
+// uploadroutine for microcode
void cDxr3Interface::UploadMicroCode()
{
- Lock();
-
if (cDxr3ConfigData::Instance().GetDebug())
{
- cLog::Instance() << "cDxr3Interface::UploadMicroCode: uploading from " << MICROCODE << "...";
+ cLog::Instance() << "cDxr3Interface::UploadMicroCode: uploading...";
}
em8300_microcode_t em8300_microcode;
+ const char* MICRO_CODE_FILE = "/usr/share/misc/em8300.uc";
struct stat s;
-
- // try to open it
- // MICROCODE comes from makefile
- int UCODE = open(MICROCODE, O_RDONLY);
+ int UCODE = open(MICRO_CODE_FILE, O_RDONLY);
if (UCODE <0)
{
- cLog::Instance() << "Unable to open microcode file " << MICROCODE << " for reading\n";
+ cLog::Instance() << "Unable to open microcode file " << MICRO_CODE_FILE << " for reading\n";
exit(1);
}
@@ -971,35 +897,21 @@ void cDxr3Interface::UploadMicroCode()
delete [] (char*) em8300_microcode.ucode;
exit(1);
}
-
- // free memory to avoid memory leak
delete [] (char*) em8300_microcode.ucode;
if (cDxr3ConfigData::Instance().GetDebug())
{
cLog::Instance() << "...done\n";
}
-
- Unlock();
}
// ==================================
-//! config and setup device via ioctl calls
+// config and setup device via ioctl calls
void cDxr3Interface::ConfigureDevice()
{
- Lock();
-
- // get videomode from driver
- uint32_t videomode_from_driver = 0;
-
- if (ioctl(m_fdControl, EM8300_IOCTL_GET_VIDEOMODE, &videomode_from_driver) == -1)
- {
- cLog::Instance() << "Unable to get videomode\n";
- exit(1);
- }
+ uint32_t videomode = 0;
// set video mode
- uint32_t videomode = 0;
if (cDxr3ConfigData::Instance().GetVideoMode() == PAL)
{
videomode = EM8300_VIDEOMODE_PAL;
@@ -1025,16 +937,12 @@ void cDxr3Interface::ConfigureDevice()
}
}
- // are the two videmodes different?
- if (videomode_from_driver != videomode)
+ // make ioctl
+ if (ioctl(m_fdControl, EM8300_IOCTL_SET_VIDEOMODE, &videomode) == -1)
{
- // make ioctl
- if (ioctl(m_fdControl, EM8300_IOCTL_SET_VIDEOMODE, &videomode) == -1)
- {
- cLog::Instance() << "Unable to set videomode\n";
- exit(1);
- }
- }
+ cLog::Instance() << "Unable to set videomode\n";
+ exit(1);
+ }
// set audio mode
if (!cDxr3ConfigData::Instance().GetUseDigitalOut())
@@ -1045,16 +953,12 @@ void cDxr3Interface::ConfigureDevice()
cLog::Instance() << "cDxr3Interface::ConfigureDevice: Audiomode = Analog\n";
}
}
-
- Unlock();
}
// ==================================
-//! reset whole hardware
+// reset whole hardware
void cDxr3Interface::Resuscitation()
{
- Lock();
-
time_t startt = time(&startt);
time_t endt = 0;
m_ExternalReleased = true;
@@ -1076,16 +980,11 @@ void cDxr3Interface::Resuscitation()
}
ConfigureDevice();
-
- Unlock();
}
// ==================================
-//! pcm resampling funtcion
void cDxr3Interface::ResampleVolume(short* pcmbuf, int size)
{
- Lock();
-
if (m_volume == 0)
{
memset(pcmbuf, 0, size);
@@ -1099,15 +998,11 @@ void cDxr3Interface::ResampleVolume(short* pcmbuf, int size)
pcmbuf[i] = (((int)pcmbuf[i]) * factor) / 65536;
}
}
-
- Unlock();
}
// ==================================
void cDxr3Interface::ClearOsd()
{
- Lock();
-
encodedata ed;
int controlstart= 0;
int x1 = 0;
@@ -1145,11 +1040,6 @@ void cDxr3Interface::ClearOsd()
WriteSpu((const uint8_t*) &ed, (int) ed.count);
ClearButton();
}
-
- Unlock();
-
- // prevent osd to get pink
- SetPalette(default_palette); // ok here? Has its own un/lock
}
// ==================================
@@ -1168,8 +1058,6 @@ void cDxr3Interface::WriteSpu(const uint8_t* pBuf, int length)
// ==================================
void cDxr3Interface::SetButton(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint32_t palette)
{
- Lock();
-
em8300_button_t button;
button.color = palette >> 16;
@@ -1180,15 +1068,11 @@ void cDxr3Interface::SetButton(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t e
button.right = ex;
ioctl(m_fdSpu, EM8300_IOCTL_SPU_BUTTON, &button);
-
- Unlock();
}
// ==================================
void cDxr3Interface::ClearButton()
{
- Lock();
-
em8300_button_t button;
button.color = 0;
@@ -1199,184 +1083,60 @@ void cDxr3Interface::ClearButton()
button.right = 2;
ioctl(m_fdSpu, EM8300_IOCTL_SPU_BUTTON, &button);
-
- Unlock();
}
// ==================================
void cDxr3Interface::SetPalette(unsigned int *pal)
{
- Lock();
-
ioctl(m_fdSpu, EM8300_IOCTL_SPU_SETPALETTE, (uint8_t*)pal);
-
- Unlock();
}
// helper functions for dxr3 main osd screen
// ==================================
-//! reset dxr3 card
+// reset dxr3 card
void cDxr3Interface::ResetHardware()
{
Lock();
-
cLog::Instance() << "cDxr3Interface: Resting DXR3 hardware\n";
Resuscitation();
-
Unlock();
}
// set brightness/contrast/saturation
// ==================================
-//! set brightness
+// set brightness
void cDxr3Interface::SetBrightness(int value)
{
- Lock();
-
m_bcs.brightness = value;
if (ioctl(m_fdControl, EM8300_IOCTL_SETBCS, &m_bcs) < 0)
{
cLog::Instance() << "cDxr3Interface::SetBrightness: Unable to set brightness to " << value << "\n";
}
-
- Unlock();
}
// ==================================
-//! set contrast
+// set contrast
void cDxr3Interface::SetContrast(int value)
{
- Lock();
-
m_bcs.contrast = value;
if (ioctl(m_fdControl, EM8300_IOCTL_SETBCS, &m_bcs) < 0)
{
cLog::Instance() << "cDxr3Interface::SetContrast: Unable to set contrast to " << value << "\n";
}
-
- Unlock();
}
// ==================================
-//! set saturation
+// set saturation
void cDxr3Interface::SetSaturation(int value)
{
- Lock();
-
m_bcs.saturation = value;
if (ioctl(m_fdControl, EM8300_IOCTL_SETBCS, &m_bcs) < 0)
{
cLog::Instance() << "cDxr3Interface::SetSaturation: Unable to set saturation to " << value << "\n";
}
- Unlock();
-}
-
-// access registers
-// ==================================
-//! read a register
-long cDxr3Interface::ReadRegister(int registernum)
-{
- Lock();
-
- em8300_register_t reg;
-
- reg.microcode_register = 0;
- reg.reg = registernum;
- reg.val = 0;
-
- ioctl(m_fdControl, EM8300_IOCTL_READREG, &reg);
- return (reg.val);
-
- Unlock();
-}
-
-// ==================================
-//! write a register
-void cDxr3Interface::WriteRegister(int registernum, int val)
-{
- Lock();
-
- em8300_register_t reg;
-
- reg.microcode_register = 0;
- reg.reg = registernum;
- reg.val = val;
- ioctl(m_fdControl, EM8300_IOCTL_WRITEREG, &reg);
-
- Unlock();
-}
-
-// ==================================
-//! grabs the current tv screen
-void cDxr3Interface::GrabScreen(int w, int h, char** buf)
-{
-
-}
-
-// maybe we should copy this routine into em8300 driver
-// ==================================
-//! It appears that the follow routine copies length bytes to memory pointed to
-//! by dst.
-//! Most likely, pos contains some kind of buffer offset.
-char cDxr3Interface::Dxr3CopyYUVData(int pos, int *dst, int length)
-{
- int l1;
-
- for (l1 = 0x1000; (l1) ;--l1)
- {
- if (ReadRegister(0x1c1a) == 0)
- break;
- }
-
- if (l1 == 0)
- {
- //printf("Borked!\n");
- exit(0);
- }
-
- WriteRegister(0x1c50, 8);
- WriteRegister(0x1c51, pos & 0xffff);
- WriteRegister(0x1c52, pos >>16);
- WriteRegister(0x1c53, length);
- WriteRegister(0x1c54, length);
- WriteRegister(0x1c55, 0);
- WriteRegister(0x1c56, 1);
- WriteRegister(0x1c57, 1);
- WriteRegister(0x1c58, pos & 0xffff);
- WriteRegister(0x1c59, 0);
- WriteRegister(0x1c5a, 1);
-
- int l2 = 0;
- for (l2=0; l2 < (length>>2) ; ++l2)
- {
- *dst++ = ReadRegister(0x11800);
- }
-
- switch (length % 4)
- {
- case 3:
- *dst++ = ReadRegister(0x11000);
- break;
-
- case 2:
- *dst++ = ReadRegister(0x10800);
- break;
-
- case 1:
- *dst++ = ReadRegister(0x10000);
- break;
- }
-
- for (l1 = 0x1000; (l1) ; --l1)
- {
- if (ReadRegister(0x1c1a) == 0)
- return 1;
- }
-
- return 0;
}
// ==================================