Loading from /cd and /pc

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
EnigmaticCoder
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 36
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Tue Nov 03, 2009 6:02 pm
Has thanked: 0
Been thanked: 0

Loading from /cd and /pc

Post by EnigmaticCoder »

I haven't been able to try to load from /cd yet because I don't have any cdrs, but when I load from /pc, I have big problems. I was using the romdisk, but I needed more than 12 mb of storage, so I decided to go this route. The problem is, it loads the media, especially the music, slow. Very slow.

1. Will it be this slow when using a CD?
2. Is it cauesd by big images (1024 x 512)?
3. Is it caused by the music (1.2mb)?
4. How can I fix this?

EDIT: I decided to put the music in the romdisk and the rest in /pc, but it's still slow :(
User avatar
henzenmann
Insane DCEmu
Insane DCEmu
Posts: 186
Joined: Wed Jul 12, 2006 4:58 pm
Has thanked: 0
Been thanked: 0
Contact:

Re: Loading from /cd and /pc

Post by henzenmann »

What type of connection are you using? If it is the plain old serial port coders cable, then obviously it will be rather slow... (for example the 1.2MB music file will take at least two minutes to load at 112KBit/s).
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Re: Loading from /cd and /pc

Post by BlackAura »

EnigmaticCoder wrote:1. Will it be this slow when using a CD?
No.
2. Is it cauesd by big images (1024 x 512)?
No.
3. Is it caused by the music (1.2mb)?
No.
4. How can I fix this?
Tricky...

Basically, the DCLoad connection is kind of slow.

As henzenmann said, with a serial cable, you're obviously limited by the speed of the serial cable, which is about twice the speed of a dial-up modem. A 1024x512 16-bit image (assuming it's not compressed) would take around 1:40 to transfer over a serial cable. If you're using a serial cable, it's just going to be slow. It wouldn't be any slower than loading a romdisk image across the same connection, unless the latency gets you (see below).

With a BBA or a LAN adapter, the transfer rate is much faster. If you read a file into memory in one go, it'll be very fast. You can read a multi-megabyte file in a couple of seconds, no problem. The problems start if you read a file in small pieces.

The problem is basically latency. In order to do a single read operation, the DC sends a request over the network (or serial cable) to DCLoad. DCLoad then sends a response containing whatever data the DC requested. If you read large chunks (say, the entire file all at once), that's fine - the latency is actually much better than the CD drive. If you're reading small chunks, that latency will affect every request you make. The smaller the chunks, the more requests you have to make, and the slower it goes.

Just some (completely unmeasured and unsubstantiated) example numbers - if you have a latency of 1ms, that'd restrict you to at most 1000 requests per second, or 17(ish) per frame. So if you were reading one byte at a time (the KOS PCX reader actually does this), you wouldn't be able to get much more than 1000 bytes per second. Even a 100kb file would take a minute and a half. I imagine this effect would be far worse with a serial cable.

The way to fix it, basically, is to always read large chunks of the file at once. This will slightly improve performance from a CD as well, but probably not enough to actually notice. Over a BBA, it makes a huge difference.

For example, if you use the KOS PCX reader to read a PCX file from /pc, it takes ages. Easily a minute or two for a fairly small file. If you copy the file to the ramdisk (/ram) and read it from there instead, it takes no time at all. That's probably a fairly safe workaround if you have enough RAM spare. It's also pretty easy to implement.

If you must steam something (music or videos, for example), use a buffer to reduce the number of read operations you require.
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has thanked: 1 time
Been thanked: 0
Contact:

Re: Loading from /cd and /pc

Post by SWAT »

Can you help to SD adapter and DreamShell 4.0, which can run ISO images from the SD card? There, the rate of about 500-600 kbytes per second.

Video example run http://www.dc-swat.net.ru/news/15/
Image
EnigmaticCoder
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 36
Joined: Tue Nov 03, 2009 6:02 pm
Has thanked: 0
Been thanked: 0

Re: Loading from /cd and /pc

Post by EnigmaticCoder »

I guess I should've spoke up sooner. This is solved.
Post Reply