News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

CRTC and R2

Started by Lone, 18:10, 11 February 14

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Lone

Hello there,


I'm currently a bit stucked with strange behaviour of the CRTC with the Hsync.... And what I found on the web is not really helpfull in this particular case, so I'm juste asking the greatest source of knowledge on the web, which is juste here.


The problem is  : Where is really placed the HSync.


I explain : When running the "Camembert 4" demo ( http://www.cpc-power.com/index.php?page=detail&num=7737 ) on my emu, I note that the 4 first mode0 pixel of the logo is not displayed correctly. Running this demo on winape show correctly, as in other various emulator (JavaCPC desktop (great experience by the way)).


So, I just use debugging ressources, and it show the following :
R0 = 1f
R2 = 00
R3 = 04
R12& R13 = random value


Which I understand as : "This particular part of screen is &1f long, the hsync occur on the very begining of the line, and is 4 us long"
Which means, that the 4 * 2 = 8 first bytes of the screen,



Take MA_beg = memory value computed from R12&R13


MA_beg and MA_beg+1 will be in hsync (not shown)
MA_beg +2 and MA_beg+3 will be in hsync (not shown)
MA_beg +4 and MA_beg+5 will be in hsync (not shown)
MA_beg +6 and MA_beg+7 will be in hsync (not shown)
End of hsync
MA_beg +8 and MA_beg+9 will be displayed.


This is false. The first displayed bytes are MA_beg +6 and MA_beg+7.

After lots of investigations and braind damage, my best guess about that is that Hsync begin at R2-1. (which can be understood by : Hsync begin after "R2" character).
Having R2=0 has no real meaning, exept that Hsync will begin when HCC=R0....

When I do this implementation, I have the correct behaviour on a little demo...
Other possibility would be a delayed address computation (which would shift the addres computation the following way :
HCC = 0, MA = ?
HCC = 1, MA = MA_beg
HCC = 2, MA = MA_beg + 1
etc.

But I can manage to have any explanation about this...;

Is it telling something to someone ? Do we have a true god of CRTC reading this forum ? Am I totally wrong about everything from the begining ?

arnoldemu


There is a difference between the HSYNC the monitor sees and the HSYNC the CRTC generates.
HSYNC goes through the gate-array.

If HSYNC is longer than 6us, Gate-Array cuts it short and monitor only sees a length of 6.
If HSYNC is shorter than 6us, monitor sees this short HSYNC (e.g. if HSYNC width is 5, it sees 5).
This explains *why* the CRTC R3 smooth scroll works by switching between 6 and 5. It could be F and 5, I don't think it really matters.

Another thing, mode is changed by Gate-Array 2 cycles after HSYNC starts. So if HSYNC is too short, I think the mode is not changed.

Now the interrupt position is based off HSYNC. I *think* it comes at the actual end of the HSYNC.

So if CRTC hsync width is 14 cycles.

mode change happens 2 cycles after HSYNC begins.
Monitor sees a HSYNC of length 6.
Interrupt is triggered at end of HSYNC (14 cycles).

Enjoy ! :)


arnoldemu

In addition to these, if you change the colour, there is a delay, it doesn't happen exactly at the start of a us. I think the same happens with the mode, but I can't give you more details at the moment.

arnoldemu

BTW, when coding CRTC, Gate-Array and monitor emulation I run many tests on real CPCs to see the real result.

I don't go on the results from other emulators, only what a true CPC shows.


Lone

Well, thanks for your replies. I forget, but my investigations where all on the Type 1 CRTC.




I have the chance to get my own real Amstrad CPC 6128 since yesterday (but now, I'll have to negociate for some space for it as the Wife Agrement Factor for it is on a really low level...). I've already planed to do some test, as soon as I can plug it.




Munchausen

#5
[ot]Currently moving house, and the fiance agreement factor has taken me almost a year of hard work, but it looks like we've finally agreed on a room just for computers and tools, provided my bed settee goes in there so we can still sleep guests :) [/ot]


Good luck getting your emu working better!

Fran123

Quote from: arnoldemu on 18:46, 11 February 14There is a difference between the HSYNC the monitor sees and the HSYNC the CRTC generates.
HSYNC goes through the gate-array.

If HSYNC is longer than 6us, Gate-Array cuts it short and monitor only sees a length of 6.
If HSYNC is shorter than 6us, monitor sees this short HSYNC (e.g. if HSYNC width is 5, it sees 5).
This explains *why* the CRTC R3 smooth scroll works by switching between 6 and 5. It could be F and 5, I don't think it really matters.

Another thing, mode is changed by Gate-Array 2 cycles after HSYNC starts. So if HSYNC is too short, I think the mode is not changed.

Now the interrupt position is based off HSYNC. I *think* it comes at the actual end of the HSYNC.

So if CRTC hsync width is 14 cycles.

mode change happens 2 cycles after HSYNC begins.
Monitor sees a HSYNC of length 6.
Interrupt is triggered at end of HSYNC (14 cycles).

Enjoy ! :)


With so much hsync (in the crtc, gatearray and monitor) I no longer know what hsync you are talking about at any given time.

arnoldemu

Maybe this helps? Talking horizontal sync only.

horizontal sync follows this process:

CRTC->GateArray->Monitor


The CRTC outputs a HSYNC and VSYNC. The width of the HSYNC output is defined by CRTC register 3 but see Longshot's compendium document where CRTCs differ for HSYNC width 0.

The Gate-Array does this:
* If HSYNC (from CRTC) is longer than 6us, Gate-Array cuts it short and outputs a max HSYNC of length of 6.

* If HSYNC (from CRTC) is shorter than 6us, Gate-Array doesn't change it. 

The monitor sees the result from the Gate-Array but then how it reacts to this should also be considered for a more accurate result because what we see is the final result of all of this and how the monitor has reacted to it..
 
NOTE: The difference between 6 and 5 is not 1us on all CRTC. See Longshot's compendium for information.



Longshot

Regarding the duration of the signal sent to the monitor, Chapter 16.2.2 of the Compendium may be helpful. ;)

When the GATE ARRAY processes the HSYNC signal, it will display black for 2 characters, send the signal to the monitor for a maximum of 4 characters if the length programmed in R3 >= 6 (there is a lack of color, which translates to a slightly different "black"), then display black until the CRTC signals the end of Hsync to the GATE ARRAY (if R3 > 6).

When the GATE ARRAY processes the VSYNC signal, it will display black for 2 lines, then send the signal to the monitor for 4 lines (same as Hsync with color), then display black for another 20 lines.


Quote from: arnoldemu on 11:58, 27 July 25NOTE: The difference between 6 and 5 is not 1us on all CRTC. See Longshot's compendium for information.
If R3 is used to move the screen with a CTM monitor, it is indeed better to use values 4 and 5 to achieve an exact deviation of 1/2 µSec. (half a character).
Rhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!

Powered by SMFPacks Menu Editor Mod