| 616 | |
| 617 | |
| 618 | void CCompiler::UpdateSamplePointers(unsigned int Origin) |
| 619 | { |
| 620 | // Rewrite sample pointer list with valid addresses |
| 621 | // |
| 622 | // TODO: rewrite this to utilize the CChunkDataBank to resolve bank numbers automatically |
| 623 | // |
| 624 | |
| 625 | Assert(m_pSamplePointersChunk != NULL); |
| 626 | |
| 627 | unsigned int Address = Origin; |
| 628 | unsigned int Bank = m_iFirstSampleBank; |
| 629 | |
| 630 | if (!m_bBankSwitched) |
| 631 | Bank = 0; // Disable DPCM bank switching |
| 632 | |
| 633 | m_pSamplePointersChunk->Clear(); |
| 634 | |
| 635 | // The list is stored in the same order as the samples vector |
| 636 | |
| 637 | for (auto pDSample : m_vSamples) { |
| 638 | unsigned int Size = pDSample->size(); |
| 639 | |
| 640 | if (m_bBankSwitched) { |
| 641 | if ((Address + Size) >= DPCM_SWITCH_ADDRESS) { |
| 642 | Address = PAGE_SAMPLES; |
| 643 | Bank += DPCM_PAGE_WINDOW; |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | // Store |
| 648 | m_pSamplePointersChunk->StoreByte(Address >> 6); |
| 649 | m_pSamplePointersChunk->StoreByte(Size >> 4); |
| 650 | m_pSamplePointersChunk->StoreByte(Bank); |
| 651 | |
| 652 | #ifdef _DEBUG |
| 653 | Print(" * DPCM sample " + std::string {pDSample->name()} + ": $" + conv::from_uint_hex(Address, 4) + |
| 654 | ", bank " + conv::from_uint(Bank) + " (" + conv::from_uint(Size) + " bytes)\n"); |
| 655 | #endif |
| 656 | Address += Size; |
| 657 | Address += AdjustSampleAddress(Address); |
| 658 | } |
| 659 | #ifdef _DEBUG |
| 660 | Print(" * DPCM sample banks: " + conv::from_uint(Bank - m_iFirstSampleBank + DPCM_PAGE_WINDOW) + "\n"); |
| 661 | #endif |
| 662 | |
| 663 | // Save last bank number for NSF header |
| 664 | m_iLastBank = Bank + 1; |
| 665 | } |
| 666 | |
| 667 | void CCompiler::UpdateFrameBanks() |
| 668 | { |