Пример #1
0
        private void initialise()
        {
            m_isPlaying = state_t.STOPPED;

            m_c64.reset();

            sidplayfp.SidTuneInfo tuneInfo = m_tune.getInfo();

            UInt32 size = (UInt32)(tuneInfo.loadAddr()) + tuneInfo.c64dataLen() - 1;

            if (size > 0xffff)
            {
                throw new configError(ERR_UNSUPPORTED_SIZE);
            }

            psiddrv driver = new psiddrv(m_tune.getInfo());

            if (!driver.drvReloc())
            {
                throw new configError(driver.errorString());
            }

            m_info.m_driverAddr   = driver.driverAddr();
            m_info.m_driverLength = driver.driverLength();

            sidmemory sm = m_c64.getMemInterface();

            driver.install(ref sm, videoSwitch);

            sm = m_c64.getMemInterface();
            if (!m_tune.placeSidTuneInC64mem(ref sm))
            {
                throw new configError(m_tune.statusString());
            }

            m_c64.resetCpu();
            //Console.WriteLine("{0:x}", sm.readMemByte(0x17e3));
        }
Пример #2
0
        public bool drvReloc()
        {
            Int32 startlp = m_tuneInfo.loadAddr() >> 8;
            Int32 endlp   = (Int32)((m_tuneInfo.loadAddr() + (m_tuneInfo.c64dataLen() - 1)) >> 8);

            byte relocStartPage = m_tuneInfo.relocStartPage();
            byte relocPages     = m_tuneInfo.relocPages();

            if (m_tuneInfo.compatibility() == sidplayfp.SidTuneInfo.compatibility_t.COMPATIBILITY_BASIC)
            {
                // The psiddrv is only used for initialisation and to
                // autorun basic tunes as running the kernel falls
                // into a manual load/run mode
                relocStartPage = 0x04;
                relocPages     = 0x03;
            }

            // Check for free space in tune
            if (relocStartPage == 0xff)
            {
                relocPages = 0;
            }
            // Check if we need to find the reloc addr
            else if (relocStartPage == 0)
            {
                relocPages = 0;
                // find area where to dump the driver in.
                // It's only 1 block long, so any free block we can find
                // between $0400 and $d000 will do.
                for (int i = 4; i < 0xd0; i++)
                {
                    if (i >= startlp && i <= endlp)
                    {
                        continue;
                    }

                    if (i >= 0xa0 && i <= 0xbf)
                    {
                        continue;
                    }

                    relocStartPage = (byte)i;
                    relocPages     = 1;
                    break;
                }
            }

            if (relocPages < 1)
            {
                m_errorString = ERR_PSIDDRV_NO_SPACE;
                return(false);
            }

            // Place psid driver into ram
            UInt16 relocAddr = (UInt16)(relocStartPage << 8);

            reloc_driver = psid_driver;
            reloc_size   = psid_driver.Length;

            reloc65 relocator = new reloc65();

            relocator.setReloc(reloc65.segment_t.TEXT, relocAddr - 10);
            relocator.setExtract(reloc65.segment_t.TEXT);
            if (!relocator.reloc(ref reloc_driver, ref reloc_size))
            {
                m_errorString = ERR_PSIDDRV_RELOC;
                return(false);
            }

            // Adjust size to not included initialisation data.
            reloc_size -= 10;

            m_driverAddr   = relocAddr;
            m_driverLength = (UInt16)reloc_size;
            // Round length to end of page
            m_driverLength += 0xff;
            m_driverLength &= 0xff00;

            return(true);
        }