News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

CPCTelera 1.5 Double buffering

Started by IndyUK, 19:47, 27 July 24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

IndyUK

Hi everyone,

I'm currently experimenting with CPCTelera 1.5 in particular the double buffering side of things and have hit a snag. I'm pretty sure it's me but could someone take a look at the included code and see if there's something wrong with my implementation?

include <cpctelera.h>

// Pointers to the hardware backbuffer, placed in bank 1
// of the memory (0x4000-0x7FFF)
#define SCR_BUFF  (u8*)0x4000

void main(void)
{

u8* pvmem;  // Pointer to video memory
u8 page   = 1;   // Static value to remember the last page shown (0 = page 40, 1 = page C0)

// Clean up Screen and BackBuffer filling them up with 0's
cpct_memset(CPCT_VMEM_START, 0xff, 0x4000);
cpct_memset(       SCR_BUFF, 0x00, 0x4000);

// Loop forever
while (1) {

if (page) {
cpct_setVideoMemoryPage(cpct_pageC0);  // Set video memory at banck 3 (0xC000 - 0xFFFF)
page = 0;                              // Next page = 0
} else {
cpct_setVideoMemoryPage(cpct_page40);  // Set video memory at banck 1 (0x4000 - 0x7FFF)
page = 1;                              // Next page = 1
}
}
}

Basically, what I'm trying to do is setup a double buffer and toggle between the two. It kind of works only if I don't apply the memset to the &4000;

cpct_memset(       SCR_BUFF, 0x00, 0x4000);

If I leave this in then the CPC just resets. What I can't figure out is why. It's a simple command to clear the area of memory. I tried using the &8000 range instead and that has the same effect.

BTW - I've put this together from the provided example code, which incidentally works fine.

Thanks


Arnaud

Hi @IndyUK,
you are clearing the memory area exactly where you main code is (0x4000) ;D

You can change its location in build_config.mk, for example put it at 0x1000 :

Z80CODELOC := 0x1000

IndyUK

Quote from: Arnaud on 05:45, 28 July 24you are clearing the memory area exactly where you main code is (0x4000)
Of course...what a silly mistake to make. :doh:

Forgot that CPCTelera uses &4000 as default start address. I'm so used to using &1000 in my ASM code template, I forgot to change it in the make file. In my defence though, I am trying to get to grips with CPCTelera  :D

Thanks!

BSC

I tried CPCTelera yesterday because your issue got me curious, but to no avail. The project looks really impressive and I applaud the whole team for the effort and offering this to the community, but I want to drop a few thoughts just to preserve them (and it might help me and others to use it on a Mac).

I am not sure who and how much the maintainers are present at this forum, but I think I saw someone answering questions related to CPCTelera, so I assume some kind of presence.

Advance warning: I am running MacOS 14.5 on a M2 Macbook

1. I was surprised to see the strong dependency on mono (through Arkos Tracker) which I think should be made optional per command-line-arguments. Not everyone wants to use this tracker. I believe any additional tools should be optional and not a hard requirement for the setup to work. It might break some examples, though.

2. The way setup.sh aims to detect the presence of needed libraries seems not very flexible (and not very standard compliant). It failed on my machine because it was not able to locate boost (which is actually present per homebrew, but sadly not in any of the "standard" locations like /usr/include or /usr/local/include). This could also be solved by providing arguments to the script.

3. I was generally wondering why you guys have chosen to bake your own build tooling. I did not dive too deeply into it and maybe I'm missing important information, but I was wondering why you did not choose CMake (or similar), which for example has a lot of tooling to locate / integrate dependencies.
** My website ** Some music

My hardware: ** Schneider CPC 464 with colour screen, 64k extension, 3" and 5,25 drives and more ** Amstrad CPC 6128 with M4 board, GreaseWeazle.

awergh

#4
I don't speak for the developers but I can probably guess part of the answers.
1. CPCTelera targets Arkos as part of its api so it makes sense that it is included with it as it is intended to be a complete toolchain.
The real problem is that it is Arkos 1 and not Arkos 2 which is much easier to use (in my experience) but I expect this is a time and resources problem.
Mono would also be a dependency of RGAS.

3. I asked about CMake once (I'm pretty sure) and they mentioned this would be a significant undertaking and preferred their current solution as it was easier for them to maintain (you might notice that on Windows it requires cygwin which is hardly ideal but it allows for the same build environment across all platforms).

IndyUK

Is there a (global) pointer that gets updated when the following is issued?

cpct_setVideoMemoryPage(cpct_page40);
I evaluated CPCT_VMEM_START afterwards but that still points to 0xc000.

Arnaud

Quote from: IndyUK on 21:23, 28 July 24Is there a (global) pointer that gets updated when the following is issued?

cpct_setVideoMemoryPage(cpct_page40);
I evaluated CPCT_VMEM_START afterwards but that still points to 0xc000.

Nope you have to handle yourself the video location.

IndyUK

Quote from: Arnaud on 06:18, 29 July 24Nope you have to handle yourself the video location.
I thought as much. Thanks for clarifying.

Powered by SMFPacks Menu Editor Mod