Author Topic: Vertical overscan with CPCTelera  (Read 411 times)

0 Members and 1 Guest are viewing this topic.

Offline johnlobo

  • CPC464
  • **
  • Posts: 31
  • Country: es
    • JohnLobo at Itch.io
    • Awards
Vertical overscan with CPCTelera
« on: 11:56, 06 July 21 »
Hi all,

I'm testing overscan with CPCTelera, but I'm not being able to make it work properly.
I'm trying to widen the playing area at the top and bottom, leaving the horizontal size as it comes by default.

This is the code...

Code: [Select]
#include <cpctelera.h>
#include "sprites/poweredby-cpctelera.h"
#include "sprites/g_palette.h"

void main(void) {
   u8 *pvmem;
   
   //Init
   cpct_disableFirmware();
   cpct_setStackLocation((u8*) 0x7fff);
   cpct_setPalette(g_palette, 16);
   cpct_setVideoMode(0);
   cpct_memset((u8*)0x8000,0,0x8000);
   
   //Vertical overscan
   cpct_setCRTCReg(6, 0x22);
   cpct_setCRTCReg(7, 0x23);
   cpct_setCRTCReg(12, 0x20);

   // Test images
   pvmem = cpct_getScreenPtr((u8*) 0x8000, 0, 160);
   cpct_drawSprite(g_pow, pvmem, G_POW_W, G_POW_H);
   pvmem = cpct_getScreenPtr((u8*) 0x8000, 20, 190);
   cpct_drawSprite(g_pow, pvmem, G_POW_W, G_POW_H);
   pvmem = cpct_getScreenPtr((u8*) 0x8000, 40, 220);
   cpct_drawSprite(g_pow, pvmem, G_POW_W, G_POW_H);
   
   while (1);}

I'm changing the dimensions of the vertical displayed area and the vertical sync position, with R6 and R7, and then changing the display start address to 0x8000 with r12. But this is the result...

[attach=1,msg204496]

Apparently there is a black line at line 200, and below that line the content is repeated in the upper side of the screen.

What am I doing wrong??

Thanks in advance.
« Last Edit: 11:58, 06 July 21 by johnlobo »

Offline Axelay

  • 6128 Plus
  • ******
  • Posts: 595
  • Country: au
    • Awards
Re: Vertical overscan with CPCTelera
« Reply #1 on: 15:54, 06 July 21 »
If you are trying to use video memory from &8000 through to &ffff, you will need to set CRTC register 12 to &2c.  That will force an overflow that increments the screen base address from &20 to &30 when the offset component of the screen address reaches the maximum value of &3ff.

Offline johnlobo

  • CPC464
  • **
  • Posts: 31
  • Country: es
    • JohnLobo at Itch.io
    • Awards
Re: Vertical overscan with CPCTelera
« Reply #2 on: 18:27, 06 July 21 »
If you are trying to use video memory from &8000 through to &ffff, you will need to set CRTC register 12 to &2c.  That will force an overflow that increments the screen base address from &20 to &30 when the offset component of the screen address reaches the maximum value of &3ff.
Hi Axelay, thanks for the reply.

The situation is better after this change, because the screen is not showing some sprites duplicated, but the one printed under line 220 still goes up, and there is also something weird in the lower right corner of the second sprite, that is going up too.

 

Regards.

Offline johnlobo

  • CPC464
  • **
  • Posts: 31
  • Country: es
    • JohnLobo at Itch.io
    • Awards
Re: Vertical overscan with CPCTelera
« Reply #3 on: 18:34, 06 July 21 »
Hi Axelay, thanks for the reply.

The situation is better after this change, because the screen is not showing some sprites duplicated, but the one printed under line 220 still goes up, and there is also something weird in the lower right corner of the second sprite, that is going up too.

 

Regards.

With solidboxes we can see the problem better...

 [attach=1]

This is the code...

Code: [Select]
void main(void) {
   u8 *pvmem;
   
   //Init
   cpct_disableFirmware();
   cpct_setStackLocation((u8*) 0x7fff);
   cpct_setPalette(g_palette, 16);
   cpct_setVideoMode(0);
   cpct_memset((u8*)0x8000,0,0x8000);
   
   //Vertical overscan
   cpct_setCRTCReg(6, 0x22);
   cpct_setCRTCReg(7, 0x23);
   cpct_setCRTCReg(12, 0x2c);
   

   // Test images
   pvmem = cpct_getScreenPtr((u8*) 0x8000, 0, 160);
   cpct_drawSolidBox(pvmem, 0xff, 40, 20);
   pvmem = cpct_getScreenPtr((u8*) 0x8000, 20, 190);
   cpct_drawSolidBox(pvmem, 0xf0, 40, 20);
   pvmem = cpct_getScreenPtr((u8*) 0x8000, 40, 220);
   cpct_drawSolidBox(pvmem, 0xcc, 40, 20);
   
   while (1);
}

Offline Axelay

  • 6128 Plus
  • ******
  • Posts: 595
  • Country: au
    • Awards
Re: Vertical overscan with CPCTelera
« Reply #4 on: 12:26, 07 July 21 »
From the look of that orange box, it appears to assume &87ff is followed by &8000, so the function you are using is assuming or designed for a single 16k bank of screen, wrapped for any possible hardware scrolling presumably.  I'm sorry I'm not familiar with CPCTelera at all so I can't offer any advice on whether there are functions that deal with overscan.


If there are not, perhaps you can write to the different parts of the screen by setting a different screen base address for drawing to the top or bottom section?  Overlapping both sections might be cumbersome.  It may help to also set register 13 of the CRTC to &18.  This will force the first screen to offset by 24 characters from the base address and start at &8030.  That will mean that when it jumps from &87ff to &c000, that will be on the edge of the screen, so you wouldn't need to deal with those address jumps in the middle of a line.

Offline ronaldo

  • Dev
  • 6128 Plus
  • *****
  • Posts: 650
  • Country: es
    • Profesor Retroman
    • Awards
Re: Vertical overscan with CPCTelera
« Reply #5 on: 20:24, 07 July 21 »
I'm changing the dimensions of the vertical displayed area and the vertical sync position, with R6 and R7, and then changing the display start address to 0x8000 with r12. But this is the result...

Apparently there is a black line at line 200, and below that line the content is repeated in the upper side of the screen.

What am I doing wrong??

Thanks in advance.

Easy. Neither drawSprite, nor drawSolidBox are designed for custom screen resolutions. They only work on standard screen resolution. If you change your resolution, you need to adapt drawing functions or to create your custom ones.

Documentation says they don't work properly with the wrap-around under scrolling conditions, but it should also state that they are designed for 40x25 standard character screens. This is one of the things I'd like to improve for CPCtelera 2.0: create macro configurations for these functions to autogenerate the ones you require for your custom resolution :) .