News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Devilmarkus

CRTC-ports - read/write only?

Started by Devilmarkus, 23:00, 20 November 09

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Devilmarkus

Hi together,
Megachur gave me a DSK with a music compilation on it.
He told me, that 1 tune causes a crash in JavaCPC.
So I asked him for sources.
I compiled the sources, and played the music manually. I saw the screen moving.
The music was ripped from the game "Night Shift".
Then I also tried the game itself.
Result: When music begun to play, the graphics were corrupted.

So I searched in CRTC emulation and fixed the bug:

Grim writes in his CRTC-docs, that Ports >=&BE00 are read only.
Because this info I modified this code:
  public void writePort(int port, int value) {
    if (port >= 0xbe00){
        if (debug)
            System.err.println("Port "+Util.hex(port)+" is Read-Only!");
        return;
    }
    if ((port & registerSelectMask) == registerSelectTest){
      selReg = value & 0x1f;
      if (debug)
          System.out.println("CRTC-Port register selection from port:"+port+ " selReg:"+selReg);
    }
    else{
      setRegister(selReg,value);
      if (debug)
          System.out.println("CRTC-Port register write from port:"+port+ " selReg:"+selReg + " written value:"+value);
    }
}


This solved the problem.

The question I have now is:
Is this bugfix correct here in CRTC emulation or not?
@Executioner: I don't understand the port mappings in CPC.java. Maybe it need to be fixed there?

Cruel bug with really funny result! We first suggested, that the z80 emulation was bad here.
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Executioner

That looks like it should fix the problem for the CPC implementation, but it's not actually correct. The correct code should be:

if ((port & registerSelectMask) == registerSelectTest)
      selReg = value & 0x1f;
else if ((port & registerWriteMask) == registerWriteTest)
      setRegister(selReg, value);


Of course, you need to add the new variables and a set routine similar to setRegisterSelectMask() called setRegisterWriteMask() which must be called from CPC.java. eg.

crtc.setRegisterSelectMask(0x0300, 0x0000);
crtc.setRegisterWriteMask(0x0300, 0x0100);

Devilmarkus

#2
Quote from: Executioner on 02:24, 23 November 09
Of course, you need to add the new variables and a set routine similar to setRegisterSelectMask() called setRegisterWriteMask() which must be called from CPC.java. eg.

crtc.setRegisterSelectMask(0x0300, 0x0000);
crtc.setRegisterWriteMask(0x0300, 0x0100);


Thanks for advice.

Please also explain me, what do the values mean in here. (0x0300, 0x0000, 0x0100)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Executioner

Quote from: Devilmarkus on 11:01, 23 November 09
Please also explain me, what do the values mean in here. (0x0300, 0x0000, 0x0100)

The test routine (in writePort) does a bitwise AND of the first value, then tests for equality with the second. So it takes the input value BC00..BFFF, AND's it with 0x300 to give one of 0x0000, 0x0100, 0x0200, 0x0300 and then compares that with 0x0000 for register select or 0x0100 for register write.

Cheers,
Richard

Powered by SMFPacks Menu Editor Mod