News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

CRTC Screen sizing

Started by IndyUK, 17:43, 17 November 21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

IndyUK

Hi folks

I've been experimenting with manipulating the CRTC registers using BASIC to try and understand how it works. So I tried the following BASIC instruction

OUT &BC00, 6:OUT &BD00, 20

Worked fine. However, what I noticed was although the screen display shrunk (20 character lines), the physical screen didn't. How do I set the screen so that both the display and physical match?

Thanks

roudoudou


there is 272 lines visible => so 34 lines of char
96 bytes width instead of 80 as default

you may have a borderless screen (even with Basic running) but as the visible screen is (approx) 24K, the memory will loop
also you need to move the beginning of the screen so there is more registers to set
My pronouns are RASM and ACE

andycadley

I'm not sure I follow what you mean when you say the physical size didn't change.


There are always the same number of actual scan lines (well more or less, you can fiddle it slightly and get away with a mistimed frame flyback but not by much). The result of this is that the size of a pixel row isn't ever going to change. If you reduce the height of the screen in characters, you just get more border at the bottom of the screen - it doesn't scale up the characters to fit the space previously, if that's what you were hoping for.

IndyUK

My apologies. I probably did a bad job in trying to explain things.


If you see the attached screenshot. There you will see the shorter height screen (20 chars lines worth). That part is fine, howver, the issue is that when you take the cursor past the bottom of the (new) bottom height (pressing the down cursor), it doesn't scroll. What I found is that the physical chars lines are still 25 i.e. I still have to move 5 lines down after the cursor disappears for the bottom of the screen to scroll up. In other words, the view has (virtually) changed but the physical lines are still 25.

I hope that makes things a bit more clearer.

Thanks

roudoudou

you may define a WINDOWin mode 1
WINDOW 1,40,1,20
and the 5 extra-hidden-lines will be ignored
My pronouns are RASM and ACE

andycadley

Ah, right. BASIC doesn't actually know anything about changes to the screen size like that, so blindly assumes all the defaults still exist. There were various RSXs back in the day which would not only handle resizing the screen, but also make the firmware aware of the changes. I distinctly remember Sprites Alive having some support for it, but I'm sure there were others too.

eto

Quote from: IndyUK on 21:27, 17 November 21What I found is that the physical chars lines are still 25

I also recognized that when I set the screen width to 256 pixels: BASIC continues to work with the standard mode. It works but the screen is messed up easily. I would expect the firmware routines are not flexible but hard coded to the standard screen sizes and if you change the screen size to a custom resolution, you also need to use your own drawing routines.

IndyUK

Quote from: andycadley on 23:30, 17 November 21Ah, right. BASIC doesn't actually know anything about changes to the screen size like that, so blindly assumes all the defaults still exist.



Oh I see. So even though this can be set via BASIC, BASIC doesn't acknowledge the change. Would doing the same via Assembly work better you think?

eto

Quote from: IndyUK on 16:05, 18 November 21


Oh I see. So even though this can be set via BASIC, BASIC doesn't acknowledge the change. Would doing the same via Assembly work better you think?


No, with OUT you are talking to the hardware directly. It's exactly the same as doing it in Assembler. Afaik the firmware simply doesn't include any routines to adapt to non-standard resolutions and continues to calculate screen addresses based on the normal resolutions.

IndyUK

I know that many CPC games were designed to run using the physical screen size of ZX Spectrum. Does anyone have the CRTC values for those that I can try? It would be interesting to see if that screen was setup, how many chars lines does that have.

roudoudou

Quote from: IndyUK on 18:24, 18 November 21
I know that many CPC games were designed to run using the physical screen size of ZX Spectrum. Does anyone have the CRTC values for those that I can try? It would be interesting to see if that screen was setup, how many chars lines does that have.
run any game
press pause and debug (winape, RVM, CPCEC, ...) and look at registers
2 for horizontal position
7 for vertical position
6 for vertical displayed char lines / sometimes look at register 9 different of value 7 => visible lines = (reg9+1 x reg6)
1 for horizontal displayed lines (MANY times 32 for 64 bytes width or 128 mode 0 pixels or 256 mode 1 pixels)
My pronouns are RASM and ACE

eto

Quote from: IndyUK on 18:24, 18 November 21
I know that many CPC games were designed to run using the physical screen size of ZX Spectrum. Does anyone have the CRTC values for those that I can try? It would be interesting to see if that screen was setup, how many chars lines does that have.


Speccy has a resolution of 256x192. Screen width is then 64 bytes.

The following code sets a screen resolution of 256x240 and centers the screen:



10 mode 1
20 out &bc00,1:out &bd00,32:rem screen width = 32 words = 256 pixels, default=40
30 out &bc00,6:out &bd00,30:rem screen height = 30 words = 240 pixels, default=25
40 out &bc00,2:out &bd00,42:rem center screen horizontally, default =46
50 out &bc00,4:out &bd00,35:rem center vertically, default= 38


Based on this article here: https://cpcrulez.fr/coding_src-list-graphic-elmar_krieger-special_effects-der_videocontroller_und_das_gate-array_im_CPC_AI.htm

German, but probably easy to translate with Google.

IndyUK

Quote from: roudoudou on 18:39, 18 November 21
run any game
press pause and debug (winape, RVM, CPCEC, ...) and look at registers
2 for horizontal position
7 for vertical position
6 for vertical displayed char lines / sometimes look at register 9 different of value 7 => visible lines = (reg9+1 x reg6)
1 for horizontal displayed lines (MANY times 32 for 64 bytes width or 128 mode 0 pixels or 256 mode 1 pixels)

That was a fantastic suggestion. Never thought of using the Register screen to get the values. I loaded Manic Miner, noted and applied the differences from the standard and hey presto! a perfect small screen. Thank you very much.

IndyUK

Hi

Thanks to you guys here, I have managed to get 2 screens setup by manipulating the CRTC registers. They are both centeralised and stable, although the text is all over the place, probably because of BASIC's hard coded width of 40 chars, the video memory still appears to follow the same layout, minus the width max (from &4f to &3f). I was able to use my screen fill routine to flood fill the screen perfectly. I did a quick timer on the flood fill routine and got the following;

144296 micro-secs in Tall screen
107084 micro-secs in Short screen

Same width, just height and screen placement varies.

I used the WinApe in-built Timer function in the debugger screen to capture the time. Would you say that is fast in enough for games? BTW, I used the Stack method of filling the screen.

Thanks

Brundij

#14
Quote from: IndyUK on 18:24, 18 November 21
I know that many CPC games were designed to run using the physical screen size of ZX Spectrum. Does anyone have the CRTC values for those that I can try? It would be interesting to see if that screen was setup, how many chars lines does that have.
Here are the register values I use to fit spectrum size screens in the slideshow cdt's I make. Uncommented ones are better left alone. You can also experiment on the fly with Retro Virtual Machine. Click on the Hammer button which is the debug mode. Then on the CPC button. You can alter the registers and watch the changes live.

SPECTRUM SIZE: 24 lines, 256 x 192

&3F   
&20   ;; R1 - Horizontal Displayed  (32 chars wide)
&2A   ;; R2 - Horizontal Sync Position (centralises screen)
&8E   ;; R3 - Horizontal and Vertical Sync Widths
&26   
&00   
&18   ;; R6 - Number of lines displayed
&1E   ;; R7 - Heigth at which line 1 is drawn. Increase number to go up, decrease to go down
&00
&07
&00
&00
&30
&00
&00
&00


STANDARD SIZE (for comparison) 25 lines, 320 x 200
&3F   
&28    ;; R1 - Horizontal Displayed  (40 chars wide)
&2E    ;; R2 - Horizontal Sync Position (centralises screen)
&8E    ;; R3 - Horizontal and Vertical Sync Widths
&26
&00
&19    ;; R6 - Number of lines displayed
&1E    ;; R7 - Heigth at which line 1 is drawn. Increase number to go up, decrease to go down
&00
&07
&00
&00
&30
&00
&00
&00

lmimmfn

pedantic but:
&28    ;; R1 - Horizontal Displayed  (32 chars wide)
text should be "40 chars wide"
6128 for the win!!!

Brundij

Quote from: lmimmfn on 17:46, 08 December 21
pedantic but:
&28    ;; R1 - Horizontal Displayed  (32 chars wide)
text should be "40 chars wide"
You're right it's the comment for the zx screen size  ;)  Already fixed.

Powered by SMFPacks Menu Editor Mod