DosBox, few minds about "DMA segbound wrapping"

Developer's Forum, for discussion of bugs, code, and other developmental aspects of DOSBox.

DosBox, few minds about "DMA segbound wrapping"

Postby DosWorld » 2019-1-10 @ 12:07

Hello!

Sorry, may be I am wrond with forum area, but here I can rights to make a post.

I have stable %subj% error and, imho, could help fix it.

1. My source code (small game) often reproduce this error. Problem good reproduced with Sound Blaster (FX) using (play FX at 8-bit mono). But works fine with real hardware (SB AWE32 => SB16, Terratec EWS-64 XXL => SB Pro). I can provide source code and binaries to reproduce it.

2. Imho, Root cause of problem. Dma controller is divided on two parts. First part (first 4 channels), aka "low dma" works in 8bit mode all time, and "hight dma" works into 16-bit mode. As I see source code of dosbox - dosbox work in 16bit mode with "low dma" channels (segment/offset wrapping). This is reason why it cause (segment/offset wrapping for 16-bit dma into 8-bit dma channels).

Here is documentation https://homepages.cae.wisc.edu/~brodsky ... ml#DMAProg

For 8-bit data, offset should be in bytes the start of a 64kb page:

5. Write the offset of the buffer, low byte followed by high byte. For sixteen bit data, the offset should be in words from the start of a 128kbyte page. The easiest method for computing 16-bit parameters is to divide the linear address by two before calculating offset.

Code: Select all
if SixteenBit then
    begin
      BufOffset := (LinearAddr div 2) mod 65536;
      Port[BaseAddrPort] := Lo(BufOffset);
      Port[BaseAddrPort] := Hi(BufOffset);
    end
  else
    begin
      BufOffset := LinearAddr mod 65536;
      Port[BaseAddrPort] := Lo(BufOffset);
      Port[BaseAddrPort] := Hi(BufOffset);
    end;


...

7. Write the buffer page to the DMA page register.
Code: Select all
  Port[PagePort] := LinearAddr div 65536;



3. If this point of view is ok, I can try prepare patch for it.
Last edited by DosWorld on 2019-1-10 @ 16:58, edited 1 time in total.
CPU: Amd K6/450, RAM: 256M, VIDEO: S3Trio V+, SOUND: EWS64XXL/64M
CPU: iP/100, RAM: 16M, VIDEO: S3Trio V+, SOUND: SB AWE32
IBM Aptiva, CPU i486DX/80, RAM: 96M
Compaq Contura 4/25 2820D, CPU: i486SX/25, RAM: 4M, VGA.
HP 200LX/2M
User avatar
DosWorld
Newbie
 
Posts: 16
Joined: 2018-11-26 @ 04:13

Re: DosBox, few minds about "DMA segbound wrapping"

Postby cyclone3d » 2019-1-10 @ 16:12

Hopefully the DOSBOX team sees this and replies to your question.

Which version of DOSBOX are you using?
User avatar
cyclone3d
l33t
 
Posts: 3038
Joined: 2015-4-08 @ 06:06
Location: Huntsville, AL USA

Re: DosBox, few minds about "DMA segbound wrapping"

Postby ripsaw8080 » 2019-1-10 @ 16:46

The code in dma.cpp is perhaps not easy to understand, but I assure you that DOSBox does differentiate between 8-bit and 16-bit DMA channels. If you do decide to investigate improvements for DMA, please be sure you are working with current source.

FYI, the wrapping only causes a log message in SVN, not an error exit as in 0.74(-2). Also, there is a new "ems=emm386" setting in SVN which can eliminate the wrapping in some cases. Though games will continue to work, audio glitches may still occur as a result of wrapping.
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4380
Joined: 2006-4-25 @ 23:24

Re: DosBox, few minds about "DMA segbound wrapping"

Postby DosWorld » 2019-1-10 @ 16:47

cyclone3d wrote:Hopefully the DOSBOX team sees this and replies to your question.

Which version of DOSBOX are you using?


I am check source code from current trunk into SVN.

My binary dosbox version is:
DOSBox version 0.74
Copyright 2002-2010 DOSBox Team, published under GNU GPL.

This is ubuntu x64 from 18.04.1 LTS (Bionic Beaver) repo.
CPU: Amd K6/450, RAM: 256M, VIDEO: S3Trio V+, SOUND: EWS64XXL/64M
CPU: iP/100, RAM: 16M, VIDEO: S3Trio V+, SOUND: SB AWE32
IBM Aptiva, CPU i486DX/80, RAM: 96M
Compaq Contura 4/25 2820D, CPU: i486SX/25, RAM: 4M, VGA.
HP 200LX/2M
User avatar
DosWorld
Newbie
 
Posts: 16
Joined: 2018-11-26 @ 04:13

Re: DosBox, few minds about "DMA segbound wrapping"

Postby DosWorld » 2019-1-10 @ 17:04

ripsaw8080 wrote:FYI, the wrapping only causes a log message in SVN, not an error exit as in 0.74(-2). Also, there is a new "ems=emm386" setting in SVN which can eliminate the wrapping in some cases. Though games will continue to work, audio glitches may still occur as a result of wrapping.

Hmm... second time I am meet "emm", in this context. Yes, I have a problem with emm386, when do sb-programming. In this case, emm386 halt my PC and show screen with message - suggest to add parameter D=64, when run emm386.exe from config.sys. (DEVICE=EMM386.EXE D=64). I am not use EMS/XMS in my game. After I am add D=64, I am forgot about any problems with emm386.exe.

What I find about this parameter:
Code: Select all
D=nnn
Specifies how many kilobytes of memory should be reserved for buffered direct memory access (DMA). Discounting floppy-disk DMA, this value should reflect the largest DMA transfer that will occur while EMM386 is active. Valid values for nnn are in the range 16 through 256. The default value is 32.


Here is my code to calculate page/offset:
in: AX = ofs, BX = seg
out: AX = ofs, BL = page

usualy I am play seg:0000 (zero offset)

Code: Select all
PUSH   AX
PUSH   BX
XCHG   AX,BX
SHL   AX,4
ADD   AX,BX
MOV   DX,AX
POP   BX
POP   AX
SHR   AX,4
ADD   AX,BX
SHR   AX,12
MOV   BL,AL
MOV   AX,DX

Hmm... when I change page/offset (I do it!) - possible step over segment... Ok, I known how to handle this. But what do here emm386?

PS: I am investigate dosbox source more - yes, looks ok. I am was wrong, sorry.
PPS: I am change my code to be sure - dont do step over page. Also remvoe D=64 from config. Emm386 show warrning. So, problem looks like in another place and deeper. :(
CPU: Amd K6/450, RAM: 256M, VIDEO: S3Trio V+, SOUND: EWS64XXL/64M
CPU: iP/100, RAM: 16M, VIDEO: S3Trio V+, SOUND: SB AWE32
IBM Aptiva, CPU i486DX/80, RAM: 96M
Compaq Contura 4/25 2820D, CPU: i486SX/25, RAM: 4M, VGA.
HP 200LX/2M
User avatar
DosWorld
Newbie
 
Posts: 16
Joined: 2018-11-26 @ 04:13


Return to DOSBox Development

Who is online

Users browsing this forum: Exabot [Bot] and 0 guests