News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Changing CRTC Reg 9

Started by Xifos, 14:13, 07 August 14

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Xifos

Hi everyone,

I have a question about CRTC R9 when using asic split screen.
I know that (R4+1)x(R9+1)+R5=312 scanlines.

If i setup a split screen at line 192.
Then i set two PRI :
one at line 192 which set R9 to 3 (panel score)
the second one at line 208 which set back R9 to 7 (main screen)

When doing that, are not 16 scanlines missing ?
Do i have to set R4 to 38+2 to have 312 scanlines ?

Because i only have winape, i'm not sure what's really going on...

:)

Xifos

#1
Mmmm...
I have just read on cpcwiki that using PRI and setting R9 to another value than 7 will alter PRI triggering...
:/

EDIT :
All right...
I found on this forum that Fano did have the problem before me.
Using PRI and changing R9 (to have 4k or 8k split screen) is not easy.
I have my answer.
:(

arnoldemu

#2
Quote from: Xifos on 17:24, 07 August 14
Mmmm...
I have just read on cpcwiki that using PRI and setting R9 to another value than 7 will alter PRI triggering...
:/
Correct.

PRI assumes 8 lines per CRTC char always.

So you must change your numbers to work with this.

Keep your first PRI at line 192. This is good because 192 divided by 8 has no remainder. This makes it easier.

You now set R9=3. (4 lines per character)

You want to show 16 scanlines, R9=3, so there are 16/4 CRTC char lines in total.

PRI assumes 8 lines per char for it's comparison, so you need to work out a line number that will work based on this by splitting  So you need to tell it a different number.

You now need 192+( 4 * 8 ). You need to set PRI to 224.

So now you do have 16 scanlines missing, your screen will be short.

Yes you need to set 38+2 for 312 lines.

Conclusion: If you are using PRI or split screen and you want to change R9, now you must think in terms of CRTC char lines and number of lines for each char and convert it so PRI will accept it.




My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Xifos

Thanks.

I quiclky tried to set a PRI at 224, it worked as you said.
:)

And you confirmed that R4 must be corrected to have 312 scanlines.
I was wondering about that because when using asic split screen, you don't build two screens (and set R4+R4'=38) as on the old cpc...

But what would happen if the first pri was set to 190 ?
(not divided by 8 )

arnoldemu

Think like this:
VCC = vertical character counter inside CRTC (Range 0..R4-1)
RC = raster counter inside CRTC (Range 0..R9-1)
Line is the scanline you could from top to bottom.

R9=3 (4 lines per char)

Line 0: VCC=0,  RC=0, PRI=0
Line 1: VCC=0,  RC=1, PRI=1
Line 2: VCC=0,  RC=2, PRI=2
Line 3: VCC=0,  RC=3, PRI=3
Line 4: VCC=1,  RC=0, PRI=8
Line 5: VCC=1,  RC=1, PRI=9
Line 6: VCC=1,  RC=2, PRI=10
Line 7: VCC=1,  RC=3, PRI=11
Line 8: VCC=2,  RC=0, PRI=16
Line 9: VCC=2,  RC=1, PRI=17
Line 10: VCC=2,  RC=2, PRI=18


Now if you use R9=15 (16 lines per char)

Line 0: VCC=0,  RC=0, PRI=0 ***
Line 1: VCC=0,  RC=1, PRI=1
Line 2: VCC=0,  RC=2, PRI=2
Line 3: VCC=0,  RC=3, PRI=3
Line 4: VCC=0,  RC=4, PRI=4
Line 5: VCC=0,  RC=5, PRI=5
Line 6: VCC=0,  RC=6, PRI=6
Line 7: VCC=0,  RC=7, PRI=7
Line 8: VCC=0,  RC=0, PRI=0 ***
Line 9: VCC=0,  RC=1, PRI=1
Line 10: VCC=0,  RC=2, PRI=2
Line 11: VCC=0,  RC=3, PRI=3
Line 12: VCC=0,  RC=4, PRI=4
Line 13: VCC=0,  RC=5, PRI=5
Line 14: VCC=0,  RC=2, PRI=6
Line 15: VCC=0,  RC=3, PRI=7
Line 16: VCC=1,  RC=0, PRI=8
Line 17: VCC=1,  RC=1, PRI=9

See how the VCC and RC are used?

See how it can be triggered twice. I marked two lines that are the same. So if you chose to have PRI here, it would trigger 2 times.


If you change R9 then the screen becomes taller or shorter. You have the same number of character lines, but less or more lines for each character. Now you find that there is less or more than 312 lines total. So to correct this you must do something to add lines or remove them so that the 312 total is always reached.

Ok, say that the entire screen had R9=3. You set PRI to be 190.

190/8 = 23 remainder 6

VCC= 23. RC=6.
No PRI because Maximum for RC is 3, 6 can never be reached. PRI never matches.



My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Xifos

#5
Quote from: arnoldemu on 21:14, 07 August 14
Now if you use R9=15 (16 lines per char)

Line 0: VCC=0,  RC=0, PRI=0 ***
Line 1: VCC=0,  RC=1, PRI=1
Line 2: VCC=0,  RC=2, PRI=2
Line 3: VCC=0,  RC=3, PRI=3
Line 4: VCC=0,  RC=4, PRI=4
Line 5: VCC=0,  RC=5, PRI=5
Line 6: VCC=0,  RC=6, PRI=6
Line 7: VCC=0,  RC=7, PRI=7
Line 8: VCC=0,  RC=0, PRI=0 ***
Line 9: VCC=0,  RC=1, PRI=1
Line 10: VCC=0,  RC=2, PRI=2
Line 11: VCC=0,  RC=3, PRI=3
Line 12: VCC=0,  RC=4, PRI=4
Line 13: VCC=0,  RC=5, PRI=5
Line 14: VCC=0,  RC=2, PRI=6
Line 15: VCC=0,  RC=3, PRI=7
Line 16: VCC=1,  RC=0, PRI=8
Line 17: VCC=1,  RC=1, PRI=9

See how the VCC and RC are used?

See how it can be triggered twice. I marked two lines that are the same. So if you chose to have PRI here, it would trigger 2 times.

In your exemple, you set R9 to 15, but RC is reset at line 8 ?
I 'm lost !

But thanks for your answers, i think i will get it soon or later...
:)

The timings for PRI are the same on Winape and real cpc plus ?

Xifos

Oh i think i got it.

PRI line = VCC*8+RC

then if R9=1

VCC=0 RC=0 PRI=0
VCC=0 RC=1 PRI=1
VCC=1 RC=0 PRI=8
VCC=1 RC=1 PRI=9

(we lost PRI lines)

arnoldemu

Quote from: Xifos on 08:04, 08 August 14
Oh i think i got it.

PRI line = VCC*8+RC

then if R9=1

VCC=0 RC=0 PRI=0
VCC=0 RC=1 PRI=1
VCC=1 RC=0 PRI=8
VCC=1 RC=1 PRI=9

(we lost PRI lines)
Yes!
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

arnoldemu

#8
Quote from: Xifos on 22:48, 07 August 14
In your exemple, you set R9 to 15, but RC is reset at line 8 ?
I 'm lost !

But thanks for your answers, i think i will get it soon or later...
:)

The timings for PRI are the same on Winape and real cpc plus ?
Yes, Inside the CRTC the RC counter goes from 0-15 in this example. But the output is not fully connected on CPC, so it repeats every 8 lines.

When ASIC uses RC it does the same. i.e. RC & 0x07.


Timings: Yes, I believe Winape is accurate.

I updated the arnold V documentation to describe how PRI is computed. Please see it on the wiki.


My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Xifos

Thanks arnoldemu !

Now i have two last questions, but for the fun !
;)

1) what happen if on a normal screen, i set a PRI at line 190 which set R9 to 1 (or 3) ?
The PRI will trigger since before R9=7.
So when it triggers, VCC=23 and RC=6. I set R9 to 1.
Are VCC and RC reset the line after ?

2) how compute missing scanlines ?

line 192, interrupt, R9=1

VCC=24 RC=0 PRI=192
VCC=24 RC=1 PRI=193
VCC=25 RC=0 PRI=200
VCC=25 RC=1 PRI=201
VCC=26 RC=0 PRI=208
VCC=26 RC=1 PRI=209
VCC=27 RC=0 PRI=216
VCC=27 RC=1 PRI=217
PRI=224, interrupt, R9 back to 7 (VCC=28 RC=0)

VCC went from 24 to 28, but only 8 real scanlines where displayed (as if VCC went only to 25)
Is it right to say : 24 scanlines are missing ?
And R4 must be added 3 ?

And R7 must be added 3 to keep the screen at the same place ?

I know i'm asking much.
:)

arnoldemu

Quote from: Xifos on 09:58, 08 August 14
Thanks arnoldemu !

Now i have two last questions, but for the fun !
;)

1) what happen if on a normal screen, i set a PRI at line 190 which set R9 to 1 (or 3) ?
The PRI will trigger since before R9=7.
So when it triggers, VCC=23 and RC=6. I set R9 to 1.
Are VCC and RC reset the line after ?
Two possibilities:

a) RC inside CRTC will "overflow". RC=6 but you set R9 to 1 which is less. The internal counter can't match. It will continue to count. Internally it's max is 32. So it will count up to 31, then reset back to 0. VCC will then increment. Visually you will see the graphics repeat.

VCC = 23, Internal_RC = 6
VCC = 23, Internal_RC=7
VCC=23,Internal_RC=8
.
.
.
VCC=23,Internal_RC=31
VCC=24,Internal_RC=0


b)
VCC = 23, Internal_RC = 6
VCC = 24, Internal_RC = 0

I can't remember, but from testing I *think* case b happens.


Quote from: Xifos on 09:58, 08 August 14
2) how compute missing scanlines ?

line 192, interrupt, R9=1

VCC=24 RC=0 PRI=192
VCC=24 RC=1 PRI=193
VCC=25 RC=0 PRI=200
VCC=25 RC=1 PRI=201
VCC=26 RC=0 PRI=208
VCC=26 RC=1 PRI=209
VCC=27 RC=0 PRI=216
VCC=27 RC=1 PRI=217
PRI=224, interrupt, R9 back to 7 (VCC=28 RC=0)

VCC went from 24 to 28, but only 8 real scanlines where displayed (as if VCC went only to 25)
Is it right to say : 24 scanlines are missing ?
And R4 must be added 3 ?

And R7 must be added 3 to keep the screen at the same place ?
Yes correct.

R4 must be increased because VCC has increased more because you have made the chars shorter (less lines for the chars). So you compensate for the way VCC has counted.
In addition, because R7 is compared with VCC, if you didn't increase it then you are correct the screen will move.

If you made R9>7, then you should decrease VCC and also decrease R7.

You made it easier for yourself because your second area is exactly divisible by 8. If it was not, then you have to change R4, R7 and R5 and it becomes more complicated. My advice to others, make your areas divisible by 8, then when R9=7 you can add to R4 and R7 and work it out more easily.



Quote from: Xifos on 09:58, 08 August 14
I know i'm asking much.
:)
No problem at all.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Powered by SMFPacks Menu Editor Mod