How to read the CRTC registers?

Started by Devilmarkus, 22:06, 11 January 11

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Devilmarkus

Hello,
I need help from an emu coder:
CRTC type 1 and 0 return different values when you read their registers.
(Some are readable, others not)

So what do I need to do exactly here?

    public int readPort(int port) {
        if ((port & registerStatusMask) == registerStatusTest && CRTCType == 1) {
            if (vSyncCount != 0) {
                System.out.println("Status register read: " + vSyncCount);
                return (1 << 5);
            } else {
                return 0;
            }

        } else if ((port & registerReadMask) == registerReadTest) {
                System.out.println("register read: " + selReg);
            if (CRTCType == 1 && (selReg >= 14 && selReg <= 17)) {
                return reg[selReg];
            } else if (CRTCType == 0 && (selReg >= 12 && selReg <= 17)) {
                return reg[selReg];
            } else {
                    if (CRTCType == 1)
                        return 0x00;
            }
        }
        return 0xff;
    }


When is 0x00 and when is 0xFF?
(From Scratch demo reads and wants 0x00 from unreadable registers, "Demo Iz Art" wants 0xFF to set CRTC type 1)
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

Devilmarkus

#1
Humm... I think I found my answer:
    public int readPort(int port) {
        if ((port & registerStatusMask) == registerStatusTest && CRTCType == 1) {
            if (vSyncCount != 0) {
                System.out.println("Status register read: " + vSyncCount);
                return (1 << 5);
            } else {
                return 0;
            }

        } else if ((port & registerReadMask) == registerReadTest) {
                System.out.println("register read: " + selReg);
                int value = reg[selReg];
                if (selReg < 10 || selReg > 17) {
                    return 0x00;
                }
                if (CRTCType == 0){
                    switch (selReg){
                        case 10:
                        case 11: return value & 0x1f;
                        case 12:
                        case 14:
                        case 16: return value & 0x3f;
                        default: return value & 0xff;
                    }
                } else {
                    switch (selReg){
                        case 10:
                        case 11: return value & 0x1f;
                        case 12:
                        case 13: return 0;
                        case 16: return value & 0x3f;
                        default: return value & 0xff;
                    }
                }
        }
        return 0xff;
    }


Perhaps someone could verify this?
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

Powered by SMFPacks Menu Editor Mod