Discovery...

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Discovery...

Post by TmEE co.(TM) » Thu May 31, 2007 11:19 am

If 68K accesses VDP, it affects the bank access of z80. Yesterday I put a PCM playing in background in my game, and every more intense VDP access made the sample rate drop a little. The higher the sample rate the bigger the effect.
Also when 68K is halted in MD mode (MD has SMS mode too), z80 can't access bank, and gets halted aswell (until 68K gets unhalted). If you bomb the VDP too fast, it'll pull up DTACK! signal which halts 68K until VDP has its business done, so in that period, z80 has difficulty getting data from its bank. Thats my idea what happens, anyone different ideas ?
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Thu May 31, 2007 11:33 am

I believe that when you push too much datas to the VDP, it will lock the 68K on a BUS cycle then Z80 can't access the 68000 BUS anymore at the same time. You can avoid that by checking the VDP FIFO full/empty flag. It doesn't work on Gens (Fudged) but it does on real hardware, this permit to avoid some BUS lock to the Z80 (for 68K it doesn't change anythink as you have to wait anyway).
Last edited by Stef on Thu May 31, 2007 11:52 am, edited 1 time in total.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu May 31, 2007 11:35 am

I wonder what happens when you do a DMA
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Thu May 31, 2007 11:52 am

When u do a DMA (from 68Kram to Vram or Rom to Vram), you may halt the Z80... Because, if the Z80 try to access the cartridge during the DMA, it will crash.

I cannot confirm the way it will crash (big crash, just reset, just halt?), but many peoples around ALWAYS halt the Z80 during DMA :)

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu May 31, 2007 11:55 am

There's always something that limits MDs sound capabilities !!!Why !!!??? Why !!!??? :(
I must try it out, I want to see what happens. I believe it just halts, but you'll never know unless you try it out :wink:
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Thu May 31, 2007 12:01 pm

I beleive the best games just have a few Bytes buffer in the Z80 ram and a flag to say "dont access cartridge"/"you can access cartridge"... Since DMA's are usualy short, the playback isn't killed :D

Any idea?
BTW: i may move this thread to the "expert" section :D

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu May 31, 2007 12:10 pm

This really affects high quality samples, where you'll hear problem too well. You listened my tune, percussions will sound the same once I finish my tracker and MD Music & Sound Engine (MSE). Cymbals get really sucky when something interrupts the sound processing process, and I must keep the quality high as if I don't cymbals sound too sucky (more like Shhh Shhh not TSHHhhh...
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Thu May 31, 2007 12:14 pm

Can't you store the cymbals into Z80 ram then?
:D The sample size isn't more than 1KB, is it?

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu May 31, 2007 12:17 pm

Well, the sample set is near half a megabyte and almost half of it are cymbals... I can't do that :(
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

MERLiX
Newbie
Posts: 8
Joined: Mon Jan 15, 2007 10:45 pm

Post by MERLiX » Fri Jun 01, 2007 10:20 pm

Dont know if this is ideal for what your doing, but how about using z80 ram for 2 buffers?, it means you have to use 68k to move it though, thats what I did for my adpcm demo.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Sat Jun 02, 2007 9:40 am

Z80 does ALL the dirty work, 68K just has to load the driver and issue commands, nothing else. BTW your ADPCM demo is really nice.
There will be 2ch mixing at 22KHz, very similiar to Shiru's 4ch mixer.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Fri Jun 08, 2007 6:03 pm

Another discovery: YOU DO NOT HAVE HALT Z80 WHEN YOU ARE GOING DO A DMA TRANSFER. Z80 stops itself, and leaves a nasty gap into the sound if you transfer 320x480 pixels of tiles. But if the images are small it is not so big deal. No crashes or halts or any other issues.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Fri Jun 08, 2007 9:59 pm

I would suggest to halt, really, there are lot of "warning" in several documentations :D Some megadrive model may lockup ^^

But nice to know that a few tiles DMA doesn't affect so much a PCM playback! Good luck!

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Sat Jun 09, 2007 12:19 pm

Maybe some models do crash, but I'll leave that to be found out by beta tester, but when my game is in a half finished state...
Also, is there any DMA issues on real hardware ? My DMA routine doesn't always work correctly on Fusion and MD.

Here's my code, is there any bugs in it ? :

Code: Select all

LoadTiles:              ; D0=Start tile , D3=tiles , A0=Source address
 LSL.W  #5, D0          ; modifying routines, uses DMA
 SWAP   D0
 CLR.W  D0
 SWAP   D0
 MOVE.L D0, D2
 LSL.L  #2, D2
 CLR.W  D2
 SWAP   D2
 AND.L  #$3FFF, D0
 SWAP   D0
 OR.L   D0, D2          ; Add rest of the Address bits
 LSL.W  #4, D3
 MOVE.W D3, D0
 JSR    DoDMAtoVRAM
 RTS

DoDMAtoVRAM:            ; Does DMA to VRAM
 MOVE.L #CPORT, A1
 MOVE.L A0, D1          ; D0 = WORDs to transfer
 LSR.L  #1, D1          ; D2 = VRAM address
 MOVE.L D1, A0          ; A0 = source address
 MOVE.W D0, D1
 AND.W  #$00FF, D1      
 OR.W   #$9300, D1
 MOVE.W D1, (A1)
 LSR.W  #8, D0
 OR.W   #$9400, D0
 MOVE.W D0, (A1)
 MOVE.L A0, D0
 MOVE.W #$9500, D1
 OR.B   D0, D1
 MOVE.W D1, (A1)
 LSR.L  #8, D0
 MOVE.W #$9600, D1
 OR.B   D0, D1
 MOVE.W D1, (A1)
 LSR.L  #8, D0
 AND.B  #$7F, D0
 MOVE.W #$9700, D1
 OR.B   D0, D1
 MOVE.W D1, (A1)
 OR.L   #$40000080, D2
 MOVE.L D2, (A1)
 RTS
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

8bitwizard
Very interested
Posts: 159
Joined: Sat Feb 24, 2007 11:35 pm
Location: San Antonio, TX

Post by 8bitwizard » Tue Jun 12, 2007 6:15 am

TmEE co.(TM) wrote:Maybe some models do crash, but I'll leave that to be found out by beta tester, but when my game is in a half finished state...
Also, is there any DMA issues on real hardware ? My DMA routine doesn't always work correctly on Fusion and MD.
I don't use DMA right now (aside from the VDP memory clear at startup), but I have seen a case where a DMA fill cleared one more character cell on real hardware than on the MESS emulator. Since I thought I was doing it right and don't know why the real hardware was clearing more than I thought it should, I just disabled it in favor of a write loop.

So it is entirely possible that an emulator could be emulating DMA incorrectly.

Post Reply