News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_redbox

Programming the CRTC

Started by redbox, 23:21, 16 February 10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

redbox

I want to setup the CRTC so that the display is shrunk from 40 chars wide to 38 and centred, such as:


ld bc,&bc00+1 ;CRTC register 1
out (c),c
ld bc,&bd00+38 ;set width to 38 characters
out (c),c

ld bc,&bc00+2 ;CRTC register 2
out (c),c
ld bc,&bd00+45 ;set horizontal position
out (c),c


I want to do this so that I can then have 1 char either side to print to which isn't visible (similar to when you stretch the width to 50 chars and only 48 are visible).  However, in this case I need to offset the video RAM so that the visible screen starts with &C002 and ends in &C04D.  Then I can write to &C000/1 and &C04E/F without it being seen on the screen.

Is this possible?

Trebmint

I assume you're still talking the plus? Therefore you can use the bit 7 of 6804h to mask out the software scroll which turns the first 2 bytes of every line to the border colour. You should in theory only need to do this on one side of the screen not both

redbox

Quote from: Trebmint on 23:38, 16 February 10
I assume you're still talking the plus? Therefore you can use the bit 7 of 6804h to mask out the software scroll which turns the first 2 bytes of every line to the border colour. You should in theory only need to do this on one side of the screen not both

Yes, I do mean on the Plus and I haven't seen about bit 7 before, will give it a go.

I found an example in the RP11 Diagnostic Cartridge:


        ld      a,80h                   ;bring border in by 2
        ld      (6804h),a

        ld      bc,0BC06h
        out     (c),c                   ;point at 6845 vertical displayed reg

        ld      bc,0BD18h               ;normally its 19h (25), make it 24
        out     (c),c                   ;brings bottom border up



redbox

Appears to work perfectly.

Thanks!

Trebmint

If you have the border wrap sorted you can set the screen up to use the magic 32x32 character dimensions for 16384 bytes that gives you the ideal scroller. Plus since it's MOD 32 it makes calculating the charcter positions so much easier.

screentop + ((x_char_pos mod 32)*2) + ((y_char_pos mod 32)*64)

Thats correct isn't it?

redbox

Quote from: Trebmint on 09:54, 17 February 10
If you have the border wrap sorted you can set the screen up to use the magic 32x32 character dimensions for 16384 bytes that gives you the ideal scroller. Plus since it's MOD 32 it makes calculating the charcter positions so much easier.

Yes, I was thinking about this when reading the wiki entries for hardware scrolling and fast sprites on a normal CPC.

I have been writing the routine so that you can scroll left or right from any point and it deals with the wrap around when it occurs.  I do realise though that if I use the 32x32 size screen and only allow scrolling back left once you've gone right I can avoid the wrap around which will make things much faster.  However, this does limit the number of 'screens' you can use for the width of the playing area, but it might be worth it for the speed increase?

If I use the bit 7 trick to hide the first two characters of the border, wouldn't this reduce the visible area to 30x32 though, which is quite small...?

Quote from: Trebmint on 09:54, 17 February 10
screentop + ((x_char_pos mod 32)*2) + ((y_char_pos mod 32)*64)

Looks right to me, although I haven't been using software sprites yet :)

Trebmint

the bit 7 only covers 1 character so it would be 31x32. Really means you can draw just 1 byte width at a time for a vertical strip, which is annoying, but adequate whn doing a 50fps update (not going to move 100 fat pixels a second are you!)

Geco

Hello

I would like to ask if the following code is working on a real CPC also, or can cause HW error ( as I read that writing to &BExx port can cause error) and I should change to other solution?

crtcreg ld      a,(hl)
        inc     hl
        or      a
        ret     z
        ld      b,0bdh
crtcwrt outi
        ld      b,0beh
        outi
        dec     a
        jr      nz,crtcwrt

For me it is strange behaviour, but it works on emulators in in this setup, for all other registers I used the normal port values.

arnoldemu

Quote from: Geco on 13:27, 07 March 16
Hello

I would like to ask if the following code is working on a real CPC also, or can cause HW error ( as I read that writing to &BExx port can cause error) and I should change to other solution?

crtcreg ld      a,(hl)
        inc     hl
        or      a
        ret     z
        ld      b,0bdh
crtcwrt outi
        ld      b,0beh
        outi
        dec     a
        jr      nz,crtcwrt

For me it is strange behaviour, but it works on emulators in in this setup, for all other registers I used the normal port values.
outi decrements b before using the port.
So bd becomes bc and be becomes bd. Code is good.

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

Geco

Thank you very much, I thought that it decrements after :oops:

Powered by SMFPacks Menu Editor Mod