VRAM transfers + Good sound

Discussion in 'Showroom Archive' started by TmEE, Sep 25, 2012.

Thread Status:
Not open for further replies.
  1. TmEE

    TmEE Mélodie is powerful ! Member

    Joined:
    Feb 28, 2009
    Messages:
    111
    Location:
    Estonia, Rapla
    http://tiido.rocketcat.info/BitShit/ANIM.BIN


    I had quite a bit of fun getting things to a point where animation is still fast and sound does not suffer from VDP FIFO overflow induced system halts. On MD you can write VRAM anytime, there will be no lost data unlike SMS and I think SNES, but there's a catch :


    When the FIFO is full and another write is coming in, !DTACK won't be released and the 68K side will be halted. This normally is not a problem, but when Z80 does a ROM access, it will be halted too.


    This means goodbye timings so there will be considerable jitter in any PCM playback that may happen. DMA is fastest way to send data to VRAM but it takes the bus for the duration of DMA which will not work out at all for the Z80, unless there's some elaborate buffering scheme worked out that buffers data while there are no VDP access and plays it during DMA or intense FIFO overflowing


    In this demo I start off sending data in tile quantities using 68K loop (68K cannot overwhelm VDP in VBL) and Z80 won't be closed off from the bus. I switch to slow update loop when there's active display, since there will be very few access slots per line and you can easily overflow the FIFO.


    I coded a new WAV playback program for this one, my old code is just horrible haha.


    You supply the address of the file, and the driver looks up the lenght and will do automatic looping. One thing I could add is automatic sample rate adjustment, but it is not very high on my priorities list.


    In any case I am very happy with it, it took me a while to do but it works like a charm ^^


    Sound sample is 26.5KHz, so this means it sounds best on real hardware !


    Emulators seem to have problems with high PCM rates, everything is noticably scratchier (writes getting missed or such).
     
  2. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,870
    Welp, works for me, congratulations, it sounds very crystal clear!


    My only doubt is, will manual transfers be quick enough for a fully functional game? I suppose that's the kick in the jaw, quality loss vs speed loss =$
     
  3. TmEE

    TmEE Mélodie is powerful ! Member

    Joined:
    Feb 28, 2009
    Messages:
    111
    Location:
    Estonia, Rapla
    Manual transfers are not going to be enugh for action games... but when you make sure that DMA won't exceed VBL one can buffer samptes to last VBL worth when DMA works its mädzik it can work out.


    Only problemo are catching VBL before DMA starts and making PCM async enough from rest of the code...
     
Thread Status:
Not open for further replies.