Author Topic: WinCPCTelera  (Read 6884 times)

0 Members and 1 Guest are viewing this topic.

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 403
  • Country: fr
  • Liked: 276
Re: WinCPCTelera
« Reply #50 on: 22:17, 11 November 16 »
Will you be implementing it? My games also use it, so if I ever want to build a windows version of my games (assuming that becomes a thing) I won't be able to.

Here http://www.cpcwiki.eu/forum/programming/lz48-cruncherdecruncher/, i just adapt the compressor LZ48 from roudoudou for Cpctelera it could be a solution.
« Last Edit: 22:28, 11 November 16 by Arnaud »

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 403
  • Country: fr
  • Liked: 276
Re: WinCPCTelera
« Reply #51 on: 15:34, 13 November 16 »
Finally !


* outlaw_intro2.png
(12.57 kB, 770x579 - viewed 181 times)

* outlaw_game.png
(33.58 kB, 770x579 - viewed 173 times)
[ Invalid Attachment ]

As usual when a new project is compiled i found bugs :
- Some virtual keys were missing ('O' or 'I' for example)
- In the function cpct_drawSpriteMaskedAlignedTable the mask was applied to the byte and not to the pixel

This time i had to modify the original code to make Outlaw working :
- I replaced buffer compressed with Exomizer (Exoopt) with buffer compressed with LZ48 (i have decruncher C code only for LZ48)

- But the main problem was the direct access to CPC memory :

ex from Outlaw code :
Code: [Select]
#define LEVEL_TILEMAPS_ADDRESS 0x0AC0 //1296 bytes
#define G_levelTilemaps (u8*)LEVEL_TILEMAPS_ADDRESS

u8* tilemap = G_levelTilemaps + map * 20 * 16;

The tilemap pointer is corrupt because the data at the address 0x0AC0 can't be directly read or write, under Windows this memory area is forbidden.

To make the code working here my modifications :
Code: [Select]
#define LEVEL_TILEMAPS_ADDRESS 0x0AC0 //1296 bytes
u8* G_levelTilemaps;

void initMemory()
{
    G_levelTilemaps = GetMemory((void*)LEVEL_TILEMAPS_ADDRESS);
}

I had to call a WinCpcTelera function (GetMemory) in order to have a pointer of the "CPC memory" and store it in a variable.

The solution to have compatibility between cpcTelera and winCpcTelera could be the use of a optional function to handle CPC memory.

ex for cpctelera:
Code: [Select]
u8* cpct_getMemoryPointer(int pAddress)
{
    return (u8*) pAddress;
}

I had to speak about this solution with @ronaldo  :D

« Last Edit: 19:15, 13 November 16 by Arnaud »

Offline SRS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 500
  • Country: de
  • Schneider CPC464 - what else ?
  • Liked: 480
Re: WinCPCTelera
« Reply #52 on: 21:40, 13 November 16 »
I had to call a WinCpcTelera function (GetMemory) in order to have a pointer of the "CPC memory" and store it in a variable.

The solution to have compatibility between cpcTelera and winCpcTelera could be the use of a optional function to handle CPC memory.

ex for cpctelera:
Code: [Select]
u8* cpct_getMemoryPointer(int pAddress)
{
    return (u8*) pAddress;
}

I had to speak about this solution with @ronaldo  :D

I'd prefer if it would be a MACRO instead of function for speed issue on CPC.

Can't you use exodecrunch C Sources from https://bitbucket.org/magli143/exomizer/wiki/Home -> in the ZIP "RAWDECRS" ?
« Last Edit: 21:49, 13 November 16 by SRS »

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 403
  • Country: fr
  • Liked: 276
Re: WinCPCTelera
« Reply #53 on: 22:00, 14 November 16 »
I'd prefer if it would be a MACRO instead of function for speed issue on CPC.

I can't use macro with the wincpctelera for this part, with macro the address is computed at compilation time but for Windows the allocation and the address of a variable is set at runtime.

Can't you use exodecrunch C Sources from https://bitbucket.org/magli143/exomizer/wiki/Home -> in the ZIP "RAWDECRS" ?

I need sources of exoopt.exe and they are only in asm : https://sourceforge.net/p/emuscriptoria/code/HEAD/tree/deexo/

I tried to convert in C in primitive way but i'm not skilled enough in asm : http://www.cpcwiki.eu/forum/programming/exoopt-cpc_unexo-in-c/


Offline ronaldo

  • Dev
  • 6128 Plus
  • *****
  • Posts: 576
  • Country: es
    • Fremos Blog
  • Liked: 766
Re: WinCPCTelera
« Reply #54 on: 19:29, 15 November 16 »

This time i had to modify the original code to make Outlaw working :
- I replaced buffer compressed with Exomizer (Exoopt) with buffer compressed with LZ48 (i have decruncher C code only for LZ48)
- But the main problem was the direct access to CPC memory :
I had to speak about this solution with @ronaldo  :D
At this point you are hitting some limitations of your approach. Programs are free to use Amstrad CPC resources at will, and there is no unified approach to prevent developers from doing it. If is possible to provide functions, as you suggest, but there is no warranty that developers will use them. In fact, as programmers wanted to be closer to hardware, they will use less approaches like a function to get a pointer to memory.

This means that technically exigent games will not work in WinCPCtelera, using this approach.  However, your approach is nice for most software already developed and probably most that will be. More indepth approaches will require much more time to develop.

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 403
  • Country: fr
  • Liked: 276
Re: WinCPCTelera
« Reply #55 on: 23:09, 19 November 16 »
Joystick support added !

It's really better to play Outlaw with joypad  :)

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 403
  • Country: fr
  • Liked: 276
Re: WinCPCTelera
« Reply #56 on: 12:24, 20 November 16 »
SDL support is working (for window creation, render and input keyboard / joystick).

Hope it will be useful for someone.

 [ Invalid Attachment ]
« Last Edit: 17:17, 20 November 16 by Arnaud »

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 403
  • Country: fr
  • Liked: 276
Re: WinCPCTelera
« Reply #57 on: 09:37, 18 December 16 »
A little update :
  • Correction of cpct_memset when used in VRam, data are now filled in the right order.
  • I added a file helper for both cpctelera and wincpctelera project in order to keep compatibility and add some debug tools with same code.
It takes only 10 bytes in memory for CPC.

Code: [Select]
u8* WinCpcTelera_GetMemPtr(u16 memAddress);Get memory pointer of specific address -> just cast u16 in u8* in CPC

Code: [Select]
WinCpcTelera_Process()Process windows message loop -> Do/take nothing in CPC

Code: [Select]
WinCpcTelera_Wait(X)Tempo in ms  -> Do nothing in CPC

Code: [Select]
WinCpcTelera_PrintXXXDraw value in console  -> Do/take nothing in CPC

 [ Invalid Attachment ]
« Last Edit: 11:44, 18 December 16 by Arnaud »

Offline awergh

  • CPC6128
  • ****
  • Posts: 179
  • Country: au
  • Liked: 38
Re: WinCPCTelera
« Reply #58 on: 11:58, 09 February 17 »
So its been a little while since I've looked at this. (I can be so slack sometimes)
In compiling wincpctelera it was a bit confusing with cpct_sprites.c as as there are two source files with the same name (one which would work and one which would cause link errors).


Anyway after resolving that and building a lib file I compiled the game I wrote for CPCRetroDev2016.
This was fine just needed to comment out __sdcc_heap_init(); as it is SDCC specific.


On the first level everything seemed fine but once I got to level 2 performance was really bad. It turns out if I exit the level (ESC) and go back into it repeatedly there is a memory leak.
This didn't happen when I was using an early version of wincpctelera (it was super useful then for resolving the memory leaks) so I'm assuming there must be some other reason then my code which works fine with cpctelera on a real CPC.


I don't think I did anything particularly out of the ordinary (Unless I did things in a way I wasn't supposed to which is quite possible.) except perhaps scrolling which also does not work as expected.
Here are the snapshots heaps snapshots from Visual Studio for reference starting from the menu and then quiting until the game stopped working (screen goes white nothing seems to work anymore).




« Last Edit: 10:59, 10 February 17 by awergh »

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 403
  • Country: fr
  • Liked: 276
Re: WinCPCTelera
« Reply #59 on: 22:08, 09 February 17 »
Hello,

In compiling wincpctelera it was a bit confusing with cpct_sprites.c as as there are two source files with the same name (one which would work and one which would cause link errors).

Thanks for reporting, it's a commit error, cpct_sprites.c shall not be duplicated in String directory

This was fine just needed to comment out __sdcc_heap_init(); as it is SDCC specific.
__sdcc_heap_init() is ignored in compilation now

On the first level everything seemed fine but once I got to level 2 performance was really bad. It turns out if I exit the level (ESC) and go back into it repeatedly there is a memory leak.
This didn't happen when I was using an early version of wincpctelera (it was super useful then for resolving the memory leaks) so I'm assuming there must be some other reason then my code which works fine with cpctelera on a real CPC.
I compiled your game and i have not the problem with the new version of Wincpctelera, could you try with the last one please ?

Wincpctelera is just updated on Github.

Some other corrections :
- Correction of cpct_keyboardStatusBuffer[], the buffer is updated with the right key code.
- Add missing palette default colors (only 4 colors were defined)
- Add/Use double buffer in GDI / SDL render
- Remove some useless functions
« Last Edit: 22:11, 09 February 17 by Arnaud »

Offline awergh

  • CPC6128
  • ****
  • Posts: 179
  • Country: au
  • Liked: 38
Re: WinCPCTelera
« Reply #60 on: 13:50, 10 February 17 »
So tried it out and it runs much better, the game is playable to the end, and feels much like it should playing on CPC.
However the scrolling is still not quite right. Things really are hard to hit when the projectile doesn't go in a straight line.  :P




Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 403
  • Country: fr
  • Liked: 276
Re: WinCPCTelera
« Reply #61 on: 20:50, 10 February 17 »
So tried it out and it runs much better, the game is playable to the end, and feels much like it should playing on CPC.

Good news.

However the scrolling is still not quite right. Things really are hard to hit when the projectile doesn't go in a straight line.  :P

Well, i done a nasty hack to simulate hardware scroll, it works very well on the CPCTelera example but not perfectly in your game.  :(

I have to think once again how simulate the video ram  :doh:


 



Offline awergh

  • CPC6128
  • ****
  • Posts: 179
  • Country: au
  • Liked: 38
Re: WinCPCTelera
« Reply #62 on: 14:47, 12 February 17 »
Isn't it typical though, you work hard at making something perfect and then someone has to break it and you have to rethink how to do it.


I can't say I have any advice of how to get it to work. I had actually considered whether to port my game to Windows with Allegro as a programming exercise but I never decided if I go for the code reuse route or the write in an OO way using C++. I would say that watching the video about the making Retro City Rampage for MS-DOS the other day that I was more motivated to do multiple ports.
I haven't looked at how you did hardware scroll but I imagine I would just move the columns of the screen around to simulate scrolling.

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 403
  • Country: fr
  • Liked: 276
Re: WinCPCTelera
« Reply #63 on: 16:58, 12 February 17 »
Isn't it typical though, you work hard at making something perfect and then someone has to break it and you have to rethink how to do it.

In fact it's a good way to found bug  ;)

I can't say I have any advice of how to get it to work. I had actually considered whether to port my game to Windows with Allegro as a programming exercise but I never decided if I go for the code reuse route or the write in an OO way using C++. I would say that watching the video about the making Retro City Rampage for MS-DOS the other day that I was more motivated to do multiple ports.

I you want to have a version of WinCPCTelera with scrolling working for your code, it's easy, i just have to comment some code.

I haven't looked at how you did hardware scroll but I imagine I would just move the columns of the screen around to simulate scrolling.
When i do hardware scrolling the video buffer is a bitmap, and applied a byte offset move one line.
On CPC it's 8 lines of offset, and as you said, to do that i moved columns to simulate the effect.

Offline awergh

  • CPC6128
  • ****
  • Posts: 179
  • Country: au
  • Liked: 38
Re: WinCPCTelera
« Reply #64 on: 10:12, 13 February 17 »
In fact it's a good way to found bug  ;)
 

I'm glad you see it that way and are looking to make WinCPCtelera the best it can be :)

[/size]
I you want to have a version of WinCPCTelera with scrolling working for your code, it's easy, i just have to comment some code.
When i do hardware scrolling the video buffer is a bitmap, and applied a byte offset move one line.
On CPC it's 8 lines of offset, and as you said, to do that i moved columns to simulate the effect.


I'm happy to wait for you to release something you are completely happy with for its robustness.
Thinking about writing multiple versions is mostly just me thinking aloud.

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 403
  • Country: fr
  • Liked: 276
Re: WinCPCTelera
« Reply #65 on: 17:10, 05 May 17 »
I updated Wincpctelera with compressors support :
- Exomizer (not the optimized version) from Magnus Lind
- Lz48 from Roudoudou

In the _compressor directory you'll find, the decompressor code for cpctelera (asm), the decompressor code for Wincpctelera (full C version) and the executable compressor (Windows) for each.

You just have to add the source code of the compressor you want in your project in order to use it.

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 403
  • Country: fr
  • Liked: 276
Re: WinCPCTelera
« Reply #66 on: 22:17, 20 July 17 »
WinCPCTelera is compatible with the latest version of CPCTelera 1.4.2.

It support the updated API and the memory paging.

Hope it help for the CPCRetrodev 2017 developper  ;)

https://github.com/Arnaud6128/wincpctelera/releases

Offline awergh

  • CPC6128
  • ****
  • Posts: 179
  • Country: au
  • Liked: 38
Re: WinCPCTelera
« Reply #67 on: 14:27, 05 August 18 »

So I just tried to compile WinCPCtelera 1.4.2 and have got an error that banks.h is missing.
Was the file missed when adding to Git or something?


I feel like I really should have tried this a bit sooner given its over a year since you updated it.
I only switched to CPCtelera 1.4.2 this year as I had already started with 1.4 last year when it came out and didn't wish to change anything at that point.


Offline ronaldo

  • Dev
  • 6128 Plus
  • *****
  • Posts: 576
  • Country: es
    • Fremos Blog
  • Liked: 766
Re: WinCPCTelera
« Reply #68 on: 13:59, 06 August 18 »
I feel like I really should have tried this a bit sooner given its over a year since you updated it.
I only switched to CPCtelera 1.4.2 this year as I had already started with 1.4 last year when it came out and didn't wish to change anything at that point.
I expect to be launching CPCtelera 1.5 by september. It will have many new features and improvements. They are already available if you get current CPCtelera development branch. It is mostly stable at this momment (No bugs that I know, although they may always appear at some point, that's why I say "mostly").

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 403
  • Country: fr
  • Liked: 276
Re: WinCPCTelera
« Reply #69 on: 11:08, 07 August 18 »
So I just tried to compile WinCPCtelera 1.4.2 and have got an error that banks.h is missing.
Was the file missed when adding to Git or something?
Thanks for reporting @awergh , i forgot to commit this file, all should be ok now.

I expect to be launching CPCtelera 1.5 by september.
:D

Offline awergh

  • CPC6128
  • ****
  • Posts: 179
  • Country: au
  • Liked: 38
Re: WinCPCTelera
« Reply #70 on: 15:51, 07 August 18 »
Thanks for reporting @awergh , i forgot to commit this file, all should be ok now.

Excellent all good now.  :)


Question I've found previously with last years project and the current progress I've made this year that I need to do a full rebuild every time I make a code change otherwise it doesn't run as expected. For example I'll have a struct that was previously initialised earlier will suddenly be all 0 when I go to use it.
Rebuilding/clean build will fix the problem and everything will work fine. Building normally with CPCtelera never has a problem.

I expect to be launching CPCtelera 1.5 by september. It will have many new features and improvements. They are already available if you get current CPCtelera development branch. It is mostly stable at this momment (No bugs that I know, although they may always appear at some point, that's why I say "mostly").

:D  Glad to hear that a new version is coming although I suspect I will decide to go with the safest route and keep everything the same rather than switching part way unless there is a feature that I have to have.

Offline ronaldo

  • Dev
  • 6128 Plus
  • *****
  • Posts: 576
  • Country: es
    • Fremos Blog
  • Liked: 766
Re: WinCPCTelera
« Reply #71 on: 21:20, 07 August 18 »
Question I've found previously with last years project and the current progress I've made this year that I need to do a full rebuild every time I make a code change otherwise it doesn't run as expected. For example I'll have a struct that was previously initialised earlier will suddenly be all 0 when I go to use it.
This is usually due to an existing bug in iDSK. The new version of CPCtelera has a workaround and no need to completely rebuild every time.

:D  Glad to hear that a new version is coming although I suspect I will decide to go with the safest route and keep everything the same rather than switching part way unless there is a feature that I have to have.
Well, you may find some of the new features quite interesting. Concretely, I have finished right now the integration of ZX7B with the build system. Now automating the compression of files into an array that you can later decrunch during execution is as easy as converting assets. Moreover, it has the same advantages: when sources are changed, a simple 'make' command generates the new version of the compressed array.
Still some work to do on documenting it, but I'm quite sure it will be a killer feature :) .

Offline awergh

  • CPC6128
  • ****
  • Posts: 179
  • Country: au
  • Liked: 38
Re: WinCPCTelera
« Reply #72 on: 15:03, 19 August 18 »

So I've found another bug in WinCPCtelera (you did tell me this was a good thing  ;D )
I have been experimenting with copying the video memory from one location with cpct_memcpy and displaying it elsewhere.
When running it in WinAPE everything works correctly however when using WinCPCtelera it displays the junk whenever you change direction.
So initially there is junk and then it is good until you change direction and then junk is drawn again but is ok after that.

Code: [Select]
#include <cpctelera.h>

#define TILE_HEIGHT 16
#define TILE_WIDTH_BYTES 4

const u8 G_background_test[64] = {
0xA3, 0xF3, 0xF3, 0x53,
0xA3, 0xF3, 0xF3, 0x53,
0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03,
0xA3, 0xF3, 0xF3, 0x53,
0xA3, 0xF3, 0xF3, 0x53,
0xA3, 0xF3, 0xF3, 0x53,
0xA3, 0xF3, 0xF3, 0x53,
0xA3, 0xF3, 0xF3, 0x53,
0xA3, 0xF3, 0xF3, 0x53,
0xA3, 0xF3, 0xF3, 0x53,
0xA3, 0xF3, 0xF3, 0x53,
0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03,
0xA3, 0xF3, 0xF3, 0x53,
0xA3, 0xF3, 0xF3, 0x53};

const u8 G_background_test2[64] = {
0x53, 0xF3, 0xF3, 0xA3,
0x53, 0xF3, 0xF3, 0xA3,
0xA3, 0xF3, 0xF3, 0x53,
0xA3, 0xA3, 0x53, 0x53,
0xF3, 0x53, 0xA3, 0xF3,
0xF3, 0x53, 0xA3, 0xF3,
0xA3, 0xA3, 0x53, 0x53,
0xA3, 0xF3, 0x53, 0x53,
0xA3, 0xA3, 0xF3, 0x53,
0xA3, 0xA3, 0x53, 0x53,
0xF3, 0x53, 0xA3, 0xF3,
0xF3, 0x53, 0xA3, 0xF3,
0xA3, 0xA3, 0x53, 0x53,
0xA3, 0xF3, 0xF3, 0x53,
0x53, 0xF3, 0xF3, 0xA3,
0x53, 0xF3, 0xF3, 0xA3 };

void main(void)
{
    // Pointer to video memory
    u8* memory; 
    u8 spriteCopy[64];
    u8 i = 0;

    //disable the firmware to prevent it from interfering with setVideoMode
    cpct_disableFirmware();

    //set video mode to mode 0
    cpct_setVideoMode(0);

    // Clear Screen
    cpct_memset(CPCT_VMEM_START, 0, 0x4000);

    //draws G_background_test to (24,24)
    memory = cpct_getScreenPtr(CPCT_VMEM_START, 24, 24);
    cpct_drawSprite(G_background_test, memory, TILE_WIDTH_BYTES, TILE_HEIGHT);

    //copy the content of 24,24 into spriteCopy (this must be done one line at a time)
    for(i=0; i<TILE_HEIGHT; ++i)
    {
        cpct_memcpy(spriteCopy + (i * TILE_WIDTH_BYTES), cpct_getScreenPtr(CPCT_VMEM_START, 24, 24+i), TILE_WIDTH_BYTES);
    }

    //draw G_background_test2 to (24,24) (this is drawing over the old sprite)
    cpct_drawSprite(G_background_test2, memory, TILE_WIDTH_BYTES, TILE_HEIGHT);

    //draw the previously copied memory to (30,24)
    memory = cpct_getScreenPtr(CPCT_VMEM_START, 30, 24);
    cpct_drawSprite(spriteCopy, memory, TILE_WIDTH_BYTES, TILE_HEIGHT);

    // Loop forever
    while (1)
    {

    }
}



This is usually due to an existing bug in iDSK. The new version of CPCtelera has a workaround and no need to completely rebuild every time.
Hmm ok although I was assuming this was related to WinCPCtelera in this instance but its manageable so it's not huge concern (especially when build times are fast with only a few source files).

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 403
  • Country: fr
  • Liked: 276
Re: WinCPCTelera
« Reply #73 on: 18:15, 19 August 18 »
Hello @awergh,
thanks for reporting  ;)

Effectively the cpct_memcpy doesn't works between Video and Memory a convertion is needed.
I have updated cpct_video.c, cpct_memutils.c and winCpctelera.h to solve your problem, but i think i have to work more on this issue.
« Last Edit: 18:18, 19 August 18 by Arnaud »