View Single Post
Old 28 December 2022, 21:32   #8
emiespo
Registered User
 
Join Date: Jul 2017
Location: Oxford
Posts: 107
Quote:
Originally Posted by balrogsoft View Post
I got the answer, one view, two bitmaps, creating two copperlist for each bitmap and changing the copper list of the view every frame, as explained here, good reading indeed:
Hi all, I can confirm this technique also works on 1.3, however I have a slightly more complex use-case... I'm trying to write a CDXL player, so it means I need to also change the palette with each frame.

And, of course, this doesn't seem to be working (not to mention that audio also is very hard to keep in sync with audio.device, but this is a separate topic).

Before I go back to killing the OS (seems the only viable alternative), is there anything I might be missing?

This is roughly the main loop:

Code:
    // Use the currently loaded buffer
    struct CdxlFrame* frame = animData->frame[currentBuffer];
    // start playing the audio.
    playSample(frame->audioData, frame->header->cdxl_frequency == 0 ? 11025 : frame->header->cdxl_frequency, frame->header->cdxl_audioSize);
    WaitTOF();
    swapBuffers(&screenData->dblBufferData, currentBuffer,  frame->paletteData);

    // read next frame while we wait for sound to finish playing
    readFrame(animData, currentBuffer);
    waitSampleEnd();
    currentBuffer ^= 1;
the swap buffers function simply swaps the copper lists and loads new colours:

Code:
inline void swapBuffers(struct DoubleBufferGfxData* dblBufferData, UWORD buffer, UWORD* palette) {
    struct View* view = &dblBufferData->view;
    view->LOFCprList = dblBufferData->LOFCpr[buffer];
    LoadRGB4(&dblBufferData->viewPort, palette, 16);
    LoadView(view);
}
...however colours are not being reloaded as expected with this method. I assume this is because they are somewhat associated to the initial copper list. It seems that they *do change* for some frames, but the rest have wrong colours (resulting in the dreaded HAM fringes).

Is there a way to have proper colour reload? Maybe using custom copper lists? (which basically would get me closer to not using the OS...).

EDIT: it seems that investigating the ViewPort structure led me to the solution. I added this to the code above:

Code:
viewPort->DspIns = dblBufferData->dspIns[buffer];
and now LoadRGB4() would actually load colours as expected. Fun as before trying this "faster" approach I tried with RethinkDisplay() and although I could see the colours updating, I would also see annoying flickering.

Last edited by emiespo; 29 December 2022 at 00:53.
emiespo is offline  
 
Page generated in 0.04203 seconds with 11 queries