CPCWiki forum

General Category => Programming => Topic started by: CPCLER on 12:45, 02 July 09

Title: Overscan
Post by: CPCLER on 12:45, 02 July 09
Hi there

I need to setup a overscan screen on the CPC with screen memory from &8000 - &FFFF but somehow I can't make work.

I know I made it work a while back, but somehow have forgotten how it works. I used the below bit of code from the CPCWIKI. It had something to do with the MA11 and MA10 bit? ???

Hope someone can help!

Regards,
CPCLER

Code: [Select]
;; This example shows a simple method for a overscan
;; screen.
;;
;; This example will work on CPC, CPC  and KC Compact.
;;
;; This example uses the 6845 CRTC, and shows how
;; 32k of pixel data can be displayed by the CRTC.
;; This example is compatible with CRTC type 2. (MC6845)
;;
;; the screen is 48x35 visible characters in dimension,
;; and each character is 8 scanlines tall.
;; the visible window is moved so that the display
;; will fill the entire monitor screen.
;; The screen base address is initialised, so that
;; MA11=MA10=1, and the internal MA counter of the CRTC will
;; change MA12 during the display, and cause the CRTC to display
;; data from a 32k range. The actual visible display uses approx
;; 24k of RAM. After this setup, the screen does not need to
;; re-initialised for the overscan to be maintained.
;;
;; the screen is setup for a PAL display.
;;
;; This example will compile with the MAXAM assembler
;; or the built-in assembler of WinAPE32.
;;
;; Kevin Thacker 2002

;; the origin of this source code is not important
org &4000

;; initialise a display window of 48x35 characters
;; each character is 8 scanlines tall

;; set character height to 8 scanlines
ld bc,&bc09
out (c),c
ld bc,&bd00 7
out (c),c

;; set default horizontal total (set horizontal total to 64 CRTC characters
;; = 64 microseconds)
ld bc,&bc00
out (c),c
ld bc,&bd00 &3f
out (c),c

;; set default vertical total (set vertical total to 39 CRTC character-lines)
ld bc,&bc04
out (c),c
ld bc,&bd00 38
out (c),c

;; setup default horizontal and vertical sync widths
ld bc,&bc03
out (c),c
ld bc,&bd00 &8e
out (c),c

;; setup default vertical adjust
ld bc,&bc05
out (c),c
ld bc,&bd00
out (c),c

;; setup default interlace & skew
ld bc,&bc08
out (c),c
ld bc,&bd00
out (c),c

;; set width of display window
ld bc,&bc01
out (c),c
ld bc,&bd00 48
out (c),c

;; set horizontal sync position; and therefore the
;; horizontal position of the display window
;; within the monitor display
ld bc,&bc02
out (c),c
ld bc,&bd00 48
out (c),c

;; set height of display window
ld bc,&bc06
out (c),c
ld bc,&bd00 35
out (c),c

;; set vertical sync position; and therefore the
;; vertical position of the display window
;; within the monitor display
ld bc,&bc07
out (c),c
ld bc,&bd00 35
out (c),c

;; set display start
;; force MA11=MA10=1, so that the internal MA
;; counter will increment enough to change MA12.

;; the displayed data is &0000-&7fff
ld bc,&bc0c
out (c),c
ld bc,&bd00 &0c
out (c),c
ld bc,&bc0d
out (c),c
ld bc,&bd00 0
out (c),c

ret
Title: Re: Overscan
Post by: Executioner on 13:23, 02 July 09
I need to setup a overscan screen on the CPC with screen memory from &8000 - &FFFF but somehow I can't make work.

Just out &bc00,12:out &bd00,&2c will do it (ie. #0c = #0000..7fff, #1c=#4000..#bfff, #2c=#8000..#ffff and #3c=#c000..#3fff).

Cheers,
Richard
Title: Re: Overscan
Post by: CPCLER on 19:43, 02 July 09
Thanks alot!

/CPCLER

Just out &bc00,12:out &bd00,&2c will do it (ie. #0c = #0000..7fff, #1c=#4000..#bfff, #2c=#8000..#ffff and #3c=#c000..#3fff).

Cheers,
Richard
Title: Re: Overscan
Post by: Joseman on 00:32, 08 July 09
Hi

Only point out that out &bc00,12 is mistaken, out &bc00,0c (hex)

a little mistake, but perhaps can confuse somebody...

regards
Joseman
Title: Re: Overscan
Post by: Executioner on 12:01, 08 July 09
Only point out that out &bc00,12 is mistaken, out &bc00,0c (hex)

&0c is the same as 12 decimal. what you've typed above will only generate a syntax error in BASIC since you missed the & character. I could have typed out &bc00,&c but I usually refer to the register number in decimal, even though my brain works almost equally well in hexadecimal.
Title: Re: Overscan
Post by: CPCLER on 15:55, 08 July 09
Hi Executioner

I noticed this and it worked like a charm!

Thanks,
CPCLER

&0c is the same as 12 decimal. what you've typed above will only generate a syntax error in BASIC since you missed the & character. I could have typed out &bc00,&c but I usually refer to the register number in decimal, even though my brain works almost equally well in hexadecimal.
Title: Re: Overscan
Post by: Joseman on 01:48, 09 July 09
Hi all

I've playing with overscan this days, and  i think that more or less i achieved it, but, the image that the cpc displays have some "extrange" behaviour on the center of the image.
the image was converted with convimgcpc:

what is wrong? the conversion?



Title: Re: Overscan
Post by: Devilmarkus on 02:32, 09 July 09
Hi all

I've playing with overscan this days, and  i think that more or less i achieved it, but, the image that the cpc displays have some "extrange" behaviour on the center of the image.
the image was converted with convimgcpc:

what is wrong? the conversion?

How did you load it?
Title: Re: Overscan
Post by: Joseman on 02:43, 09 July 09
Hi

with a simple cas_in_direct :S

Title: Re: Overscan
Post by: Executioner on 07:52, 09 July 09
with a simple cas_in_direct :S

Unfortunately, the memory used by the overscan screen will overlap the upper firmware jumpblock and stack if you map it from #8000 to #ffff. This is fine if you're doing it from machine code and you move the stack etc, but it can't easily be done from BASIC. You have very limited options to use overscan from BASIC:

1. Set the screen start just higher than BASIC (#0170) and keep your BASIC program very small.

2. Use an interrupt routine to change the screen address part way through the screen, in which case you may as well not use the 32K screen mode at all.

3. Don't use BASIC, do it from machine code with your own disc/tape loaders.

Title: Re: Overscan
Post by: CPCLER on 13:14, 09 July 09
Now the topic is on overscan..  :D

Is there a call to calculate the address of the byte on the line below. Just like the firmware call &bc26, just for overscan screens.

/CPCLER

Unfortunately, the memory used by the overscan screen will overlap the upper firmware jumpblock and stack if you map it from #8000 to #ffff. This is fine if you're doing it from machine code and you move the stack etc, but it can't easily be done from BASIC. You have very limited options to use overscan from BASIC:

1. Set the screen start just higher than BASIC (#0170) and keep your BASIC program very small.

2. Use an interrupt routine to change the screen address part way through the screen, in which case you may as well not use the 32K screen mode at all.

3. Don't use BASIC, do it from machine code with your own disc/tape loaders.
Title: Re: Overscan
Post by: Joseman on 14:10, 09 July 09
Unfortunately, the memory used by the overscan screen will overlap the upper firmware jumpblock and stack if you map it from #8000 to #ffff. This is fine if you're doing it from machine code and you move the stack etc, but it can't easily be done from BASIC. You have very limited options to use overscan from BASIC:

1. Set the screen start just higher than BASIC (#0170) and keep your BASIC program very small.

2. Use an interrupt routine to change the screen address part way through the screen, in which case you may as well not use the 32K screen mode at all.

3. Don't use BASIC, do it from machine code with your own disc/tape loaders.

Hi Executioner

I'm doing all from machine code (with winape assembler  :D ) and a few calls to the firmware (cas in open, cas in direct, cas in close).

Changed the screen memory to start on &40, and then load with cas in direct all de 32 k's screen, then, i suppose that none of the firmware or any important call of the cpc are affected...

even played with the registers to move the screen horizontally en vertically, all seems to work fine, except this nasty garbage...

what can be happening?

Regards
Joseman
Title: Re: Overscan
Post by: Executioner on 04:44, 10 July 09
Changed the screen memory to start on &40, and then load with cas in direct all de 32 k's screen, then, i suppose that none of the firmware or any important call of the cpc are affected...

If that's the case, it should be ok, unless either the data is corrupted or it has the wrong address mapping. The addresses used for 32K starting at #0040 are:

#0040..#07ff, #4000..#47ff    - Scan 0
#0840..#0fff, #4800..#4fff     - Scan 1
#1040..#17ff, #5000..#57ff    - Scan 2
#1840..#1fff, #5800..#5fff     - Scan 3
#2040..#27ff, #6000..#67ff    - Scan 2
 #2840..#2fff, #6800..#6fff     - Scan 3
#3040..#37ff, #7000..#77ff    - Scan 2
 #3840..#3fff, #7800..#7fff     - Scan 3

With an offset of #40,  the break (eg. #7ff .. #4000) will wrap part way through a scan line (depending on you Register 1 setting). It's usually best to avoid this by adjusting the start address slightly. I'd suggest creating a table with all the scan line addresses pre-calculated so you can work out the next scan line address. Alternatively, if you know the format of the original data, you may be able to either move parts of it after loading or create a data file with the correct desired memory layout.
Title: Re: Overscan
Post by: mr_lou on 18:26, 12 June 10
mkay, now it's my turn to try loading an overscan image.
I managed to compile the code here (http://cpcwiki.eu/index.php/Programming:Overscan), and even figured out how to do the OUT codes afterwards in BASIC to load the image at a certain address. But as far as I understand I need to move some firmware or stack or whatever, which I have no clue how to do. As a result the image doesn't load completely and since I have no clue about assembler code I'm stuck.

Can someone please post the source that simply allows me to load an overscan image at &8000 ? Or whatever address you feel like using. Just as long as I can load the image from BASIC afterwards. :) Thanks.
Title: Re: Overscan
Post by: mr_lou on 20:05, 12 June 10
Doh! Nevermind!

Turns out CpcConvImg saves a binary file, which can be viewed just by doing RUN"file.scr"

To me it's just not that logical that an .SCR file can be executed, so obviously I tried to load it other ways.

Anyway. No need for any source code then.
Title: Re: Overscan
Post by: mr_lou on 21:28, 12 June 10
Bummer. The binary file ConvImgCpc saves, isn't compatible with CRTC 2.

So I'm still on the lookout for some way to transfer my overscan image from GIF on my PC to my CPC. I'll be checking out Claudia as soon as Eliot mails me the latest version, since the older version doesn't work with CRTC 2 either.

Other procedures are most welcome too.
Title: Re: Overscan
Post by: fano on 13:29, 13 June 10
I have another method with "my_cpc_toolkit" that accept gif but it's only for Windows.Anyway ,send me the gif , i'll convert it.
Else i have some overscan code in my archives if you want.
Title: Re: Overscan
Post by: mr_lou on 16:05, 13 June 10
Thanks for the suggestion fano.

I downloaded my_cpc_toolkit and converted my image with it.

This can seemingly also be done with ConvImgCpc.


But when trying to load these linear conversions, all I get is noise.

This is what I do from BASIC

MEMORY &1FFFF
LOAD"OVERSCAN.BIN (http://cpcwiki.eu/index.php/Programming:Overscan)",&4000  ' Kevin Thackers code from the Wiki
CALL &4000
OUT &BC00,12
OUT &BD00,&1C
LOAD "IMAGE.PM0",&2000

What am I doing wrong?
Title: Re: Overscan
Post by: fano on 23:57, 13 June 10
This is normal , you need some 'drawing' code.I'll try to post that tomorow , that should be usefull for the wiki too  ;)
Title: Re: Overscan
Post by: mr_lou on 08:07, 14 June 10
That would be great.

I've also written Demoniak, asking for a new release of ConvImgCpc that saves binary overscan files with CRTC 2 support, but I've been told he's not that active anymore, so I don't think that'll happen.
Title: Re: Overscan
Post by: fano on 08:44, 14 June 10
Demoniak is still present at phenixinformatique.

This a bit of code that show an image in 192*272 (mode 0) or 384*272 (mode 1).You image MUST have theses dimensions.

You just have to setup your palette "color_config" label (firmware colors) and to change image at the end of the file "image" label.
You can change the graphical mode with changing "ld BC,#7F8C" to "   ld BC,#7F8C+mode_you_want".

It is not firmware friendly because the screen start at #8000.



Attachments Displayed Below Message Body

  tst_overscanb.txt  

Title: Re: Overscan
Post by: mr_lou on 08:51, 14 June 10
Thanks a lot fano.

I will try this out when I get home from work today.

Do I just insert Kevin's code above it somehow?
Title: Re: Overscan
Post by: fano on 09:11, 14 June 10
Not needed, the code is self suffisant  ;)
Title: Re: Overscan
Post by: eliot on 11:39, 14 June 10
The CRTC configuration won't work on CRTC 2 : you have to add  the register 3 at a lower value than &8e, (as &89!) in .crtc_config  : #3,#89  

 
Title: Re: Overscan
Post by: fano on 13:31, 14 June 10
Thanks Eliot ! i'll correct this ;) (was not aware about this incompatibility as my type 2 does not still own a disk drive)
Title: Re: Overscan
Post by: arnoldemu on 18:10, 14 June 10
That would be great.

I've also written Demoniak, asking for a new release of ConvImgCpc that saves binary overscan files with CRTC 2 support, but I've been told he's not that active anymore, so I don't think that'll happen.
After talking with Mr.Lou and dissassembling the file from convimgcpc, I saw that CRTC register 3 is not touched.
So for him, he can set it before and then run the file to display the picture.

OUT &BC00,3 : OUT &BD00,&89

Simple :)
Title: Re: Overscan
Post by: mr_lou on 18:14, 14 June 10
Yea, that was a really easy fix!!!

Thanks a lot.  ;D

OUT &BC00,3
OUT &BD00,&89
RUN"CONVIMGCPC-OUTPUT-FILE.SCR"

Good to know. Will test later if this also fixed some slideshows that doesn't run on my CPC464. You never know.  :)
Title: Re: Overscan
Post by: Devilmarkus on 18:42, 14 June 10
RUN"CONVIMGCPC-OUTPUT-FILE.SCR"

RUN" ?!?
This would let your CPC reset after viewing the image.
Better:
OPENOUT"D":MEMORY &1FF:LOAD"CONVIMGCPC-OUTPUT-FILE.SCR",&200:CALL &811
Title: Re: Overscan
Post by: mr_lou on 18:58, 14 June 10
Better:
OPENOUT"D":MEMORY &1FF:LOAD"CONVIMGCPC-OUTPUT-FILE.SCR",&200:CALL &811

That's good to know! Thanks.

However, my BASIC loader contains other stuff as well, so I get a MEMORY FULL because my BASIC loader is too big.
Title: Re: Overscan
Post by: Devilmarkus on 14:25, 16 June 10
Good news: I patched the overscan code for CRTC type 2 CPC's.
So it's compatible now for all CPC types.
It also returns to basic when screen is showing.

How to load JavaCPC Paint-Overscan screen?
OPENOUT"D":MEMORY &1FF:LOAD"MYFILE.SCR",&200:CALL &811:CALL &BB18:CALL &831

CALL &831 is used  to restore the CRTC registers.

Sad: The JavaCPC-Paint stored overscan screens are not ConvImgCPC compatible now :(
But i'll send the source to Demoniak as soon as I see him.

JavaCPC Paint will be able to load ConvImgCPC generated overscan screens, too. So it's easy to convert them to the new routine:
- Create an overscan screen with ConvImgCPC
- Load it into JavaCPC-Overscan paint
- Store it back

You can directly drag & drop your SCR file into JavaCPC Paint.

JavaCPC with this new code will be available on request or wait until it's release.