News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Arnaud

WinCPCTelera

Started by Arnaud, 20:58, 29 September 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Arnaud

Hi @awergh, well see ;)

A variable (bit_mask) wasn't not reset before decompressing data.

Just set bit_mask = 0 in this function (cpct_zx7b_decrunch.c) to solve the problem.

static void computeOutputSize()
{
  int length;
  output_size = 1;
  bit_mask = 0;


Repository is updated and thanks for reporting :)






awergh

That was quick, thanks for fixing it  ;D
Now that it is 1:20AM it must be bed time  :P .

Arnaud

Quote from: awergh on 16:19, 21 September 19
That was quick, thanks for fixing it  ;D
Now that it is 1:20AM it must be bed time  :P .
It was an easy one.
Good night, it's 5:30PM in France.

awergh

So I am playing with using the Fkeys for movement.
Do you think it would be better to map these to the numpad so it matches the layout of the CPC (this is what winape does) rather than where the F keys are actually located on a PC keyboard?

Arnaud

#104
Quote from: awergh on 13:52, 17 November 19
So I am playing with using the Fkeys for movement.
Do you think it would be better to map these to the numpad so it matches the layout of the CPC (this is what winape does) rather than where the F keys are actually located on a PC keyboard?

Good idea.
Repo updated, i also corrected missing functions of cpct_zx7b_decrunch.

awergh

So I tried to compile the latest version from github and got an error
Error   C2371    'cpct_zx7b_decrunch': redefinition; different basic types

Arnaud

Quote from: awergh on 11:51, 18 November 19
So I tried to compile the latest version from github and got an error
Error   C2371    'cpct_zx7b_decrunch': redefinition; different basic types

Repo updated.
Can you try if it works now please ?

awergh

Quote from: Arnaud on 19:48, 18 November 19
Repo updated.
Can you try if it works now please ?


All good now  :)

funkheld


Hi good afternoon.
you can prepare wincpctelera user friendly for windows, you just have to install it and then it works.


At the moment it is a mess as it is offered.
too much of a change for the customer


Thank you,
greeting

awergh

#109
Not sure if there is something special for wincpctelera specifically I need to do but if I decrunch my screen sized array to video memory (eg loading screen) I get an access violation.

Exception thrown: write access violation.
output was 0xFFFF.
(function: reverseOutputData, line 165 of cpct_zx7b_decrunch.c)



#include <cpctelera.h>

const u8 g_test[546] =
{
    0x58, 0x55, 0x00, 0x5D, 0x11, 0x03, 0x71, 0xFF, 0x0F, 0x80, 0x4F, 0xD0, 0xA2, 0xC0, 0xFF, 0xF2,
    0x04, 0x11, 0x71, 0xA3, 0x59, 0x40, 0xA5, 0xEF, 0xA3, 0x02, 0xFF, 0xFA, 0x2A, 0x40, 0x28, 0xFF,
    0x1F, 0x15, 0x40, 0x04, 0xA2, 0x23, 0xF8, 0xF6, 0x23, 0x6A, 0xB1, 0xEC, 0x88, 0x09, 0x2A, 0xA2,
    0xAC, 0xC7, 0x9B, 0x88, 0xC0, 0x87, 0xCA, 0x01, 0xF0, 0xC7, 0x57, 0xF5, 0x89, 0x57, 0xC0, 0xC0,
    0x00, 0x59, 0x40, 0xC1, 0xCD, 0x5C, 0xFF, 0x5F, 0x80, 0x54, 0xFF, 0x1E, 0x80, 0x11, 0xB8, 0xA3,
    0xAC, 0xC0, 0xBF, 0xDA, 0x51, 0xD0, 0xFD, 0x4E, 0x15, 0x40, 0xE4, 0xFF, 0xAB, 0xC0, 0x2F, 0xAA,
    0x55, 0xFF, 0x7D, 0x54, 0xC0, 0x2B, 0x95, 0xA0, 0xE1, 0xBC, 0xAA, 0x40, 0x28, 0x46, 0x24, 0x74,
    0x55, 0xC0, 0xA8, 0xE5, 0x22, 0x40, 0x48, 0xA8, 0x13, 0xC0, 0x41, 0xD6, 0x19, 0x08, 0x40, 0xC0,
    0x72, 0xB1, 0x29, 0x20, 0xD2, 0x00, 0x3F, 0x82, 0x82, 0x3C, 0xEF, 0xC3, 0xA2, 0xC0, 0xFF, 0xF2,
    0x55, 0x11, 0xC1, 0xC0, 0x55, 0xFF, 0x3E, 0x20, 0x22, 0xBE, 0xAC, 0xEA, 0xFF, 0xA9, 0xA0, 0x20,
    0x2D, 0x07, 0x4E, 0xE8, 0xAA, 0xC0, 0xF2, 0xDA, 0x40, 0x27, 0x5D, 0x55, 0xFF, 0x0F, 0x4C, 0xD4,
    0x55, 0x1F, 0x5D, 0x4B, 0x13, 0xC0, 0x41, 0xCA, 0x9C, 0xAA, 0x12, 0x21, 0x48, 0x18, 0x00, 0x83,
    0x7E, 0xEA, 0xFD, 0x83, 0x28, 0x3C, 0xC0, 0x38, 0xFF, 0x0F, 0x05, 0x00, 0xE4, 0xFF, 0x89, 0x03,
    0xE0, 0xEE, 0xB4, 0x0A, 0xD1, 0xFF, 0x7B, 0x02, 0x80, 0x4F, 0xA9, 0xE2, 0xD6, 0xAC, 0x80, 0x2A,
    0xFF, 0x4F, 0x55, 0xC0, 0xE4, 0xFF, 0x8B, 0x80, 0x2A, 0xA2, 0x48, 0xD4, 0xB0, 0x18, 0x23, 0xD4,
    0xE7, 0xE5, 0x51, 0x40, 0x51, 0x54, 0xA2, 0xC9, 0xFE, 0x0A, 0x40, 0x88, 0xEE, 0x46, 0xED, 0x9C,
    0x55, 0x00, 0x4D, 0xB7, 0x1F, 0x44, 0x3C, 0xC1, 0xFF, 0x7D, 0x51, 0x80, 0xFF, 0x79, 0x82, 0x80,
    0xC8, 0xFF, 0x07, 0x02, 0xC1, 0x95, 0x6B, 0x02, 0x75, 0xFF, 0x3D, 0x15, 0xB4, 0xDF, 0x53, 0x15,
    0xFF, 0x3D, 0x55, 0x35, 0x97, 0x78, 0x5E, 0x04, 0x4D, 0xD8, 0xF7, 0x44, 0x31, 0xF9, 0x57, 0xC0,
    0xD5, 0xC8, 0x2E, 0x82, 0x32, 0x23, 0x95, 0x87, 0x80, 0x4A, 0xCF, 0xD7, 0xA0, 0xFE, 0xFA, 0x2A,
    0x22, 0x00, 0x0E, 0xBE, 0xCE, 0xAD, 0x39, 0xEE, 0xFF, 0x83, 0x40, 0x20, 0xFF, 0x5F, 0x05, 0xDE,
    0x6F, 0x51, 0x14, 0x12, 0x77, 0xC0, 0x55, 0xEE, 0xE4, 0xB1, 0x8F, 0x82, 0xFF, 0x7A, 0xAA, 0x40,
    0x20, 0xFF, 0x1F, 0x50, 0x98, 0x8D, 0x50, 0x80, 0xE4, 0xFF, 0xA1, 0xC0, 0x26, 0xA0, 0x50, 0x40,
    0x90, 0xFF, 0x87, 0x82, 0x80, 0xD9, 0x32, 0x45, 0x17, 0x5D, 0xD5, 0xA0, 0x06, 0x0F, 0x35, 0xFE,
    0x3D, 0x15, 0x11, 0x80, 0x11, 0xAD, 0x03, 0x39, 0xBE, 0xFF, 0x27, 0x82, 0xC0, 0xFF, 0x7C, 0x41,
    0x3B, 0xDC, 0xAE, 0x03, 0x10, 0xF5, 0xE2, 0x09, 0x40, 0x00, 0x50, 0x2A, 0xA8, 0xFF, 0xAF, 0xA2,
    0x80, 0xFF, 0xF2, 0x55, 0x90, 0x8F, 0x57, 0x40, 0x41, 0xFF, 0x3E, 0x80, 0x40, 0x2A, 0x28, 0x41,
    0x99, 0x77, 0x55, 0x40, 0xA3, 0x41, 0x8A, 0xCB, 0xEE, 0xAA, 0x16, 0xAE, 0x49, 0x1A, 0xA8, 0xC4,
    0xBA, 0xEA, 0xFE, 0x00, 0xA7, 0x0A, 0x62, 0x92, 0x11, 0xEE, 0x80, 0x4F, 0xAA, 0x45, 0x40, 0x11,
    0xB5, 0x04, 0xFA, 0x8D, 0xAC, 0x11, 0x62, 0xAA, 0x80, 0x9D, 0x22, 0x40, 0x12, 0x57, 0xC0, 0x75,
    0xD8, 0xA9, 0xA0, 0x40, 0xC2, 0x28, 0x15, 0x40, 0x04, 0x9E, 0xAB, 0x80, 0xA0, 0xA3, 0x49, 0x15,
    0x71, 0x57, 0x35, 0x99, 0x4E, 0x76, 0x14, 0x80, 0x14, 0xB5, 0xAB, 0x77, 0xE0, 0x20, 0x4D, 0xAE,
    0x25, 0x60, 0x08, 0x40, 0xE4, 0x82, 0x21, 0xD0, 0x55, 0xE0, 0x85, 0x45, 0x40, 0x4B, 0xD0, 0x82,
    0x40, 0x16, 0x0A, 0xC0, 0x80, 0x48, 0x91, 0x44, 0x80, 0x0C, 0x95, 0x40, 0xC0, 0x00, 0xC8, 0x8A,
    0xA0, 0x00
};

// End address of video memory.
#define VIDEO_MEMORY_END (void*)(0xFFFF)

void main(void)
{
   u8* memory = cpct_getScreenPtr(CPCT_VMEM_START, 20, 96);
   u16* crunchedDataEnd = g_test + 546 - 1;

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

   // Set video mode to mode 0.
   cpct_setVideoMode(0);

   // Decrunch the crunched map into video memory.
   cpct_zx7b_decrunch_s(VIDEO_MEMORY_END, crunchedDataEnd);

   // Loop forever
   while (1)
   {
       
   }
}

Arnaud

#110
Simply use helper macro WinCpcTelera_GetMemPtr to convert CPC memory address to Windows memory address.


// Decrunch the crunched map into video memory.
u8* vmemEnd = WinCpcTelera_GetMemPtr(VIDEO_MEMORY_END);
cpct_zx7b_decrunch_s(vmemEnd, crunchedDataEnd);


With SDCC/CPCTelera WinCpcTelera_GetMemPtr is an empty macro.

awergh

That was quick  :) .
So I tried that but have a problem, as you can see I got a different result with wincpctelera to with cpctelera.



#include <cpctelera.h>

const u8 g_test[546] =
{
    0x58, 0x55, 0x00, 0x5D, 0x11, 0x03, 0x71, 0xFF, 0x0F, 0x80, 0x4F, 0xD0, 0xA2, 0xC0, 0xFF, 0xF2,
    0x04, 0x11, 0x71, 0xA3, 0x59, 0x40, 0xA5, 0xEF, 0xA3, 0x02, 0xFF, 0xFA, 0x2A, 0x40, 0x28, 0xFF,
    0x1F, 0x15, 0x40, 0x04, 0xA2, 0x23, 0xF8, 0xF6, 0x23, 0x6A, 0xB1, 0xEC, 0x88, 0x09, 0x2A, 0xA2,
    0xAC, 0xC7, 0x9B, 0x88, 0xC0, 0x87, 0xCA, 0x01, 0xF0, 0xC7, 0x57, 0xF5, 0x89, 0x57, 0xC0, 0xC0,
    0x00, 0x59, 0x40, 0xC1, 0xCD, 0x5C, 0xFF, 0x5F, 0x80, 0x54, 0xFF, 0x1E, 0x80, 0x11, 0xB8, 0xA3,
    0xAC, 0xC0, 0xBF, 0xDA, 0x51, 0xD0, 0xFD, 0x4E, 0x15, 0x40, 0xE4, 0xFF, 0xAB, 0xC0, 0x2F, 0xAA,
    0x55, 0xFF, 0x7D, 0x54, 0xC0, 0x2B, 0x95, 0xA0, 0xE1, 0xBC, 0xAA, 0x40, 0x28, 0x46, 0x24, 0x74,
    0x55, 0xC0, 0xA8, 0xE5, 0x22, 0x40, 0x48, 0xA8, 0x13, 0xC0, 0x41, 0xD6, 0x19, 0x08, 0x40, 0xC0,
    0x72, 0xB1, 0x29, 0x20, 0xD2, 0x00, 0x3F, 0x82, 0x82, 0x3C, 0xEF, 0xC3, 0xA2, 0xC0, 0xFF, 0xF2,
    0x55, 0x11, 0xC1, 0xC0, 0x55, 0xFF, 0x3E, 0x20, 0x22, 0xBE, 0xAC, 0xEA, 0xFF, 0xA9, 0xA0, 0x20,
    0x2D, 0x07, 0x4E, 0xE8, 0xAA, 0xC0, 0xF2, 0xDA, 0x40, 0x27, 0x5D, 0x55, 0xFF, 0x0F, 0x4C, 0xD4,
    0x55, 0x1F, 0x5D, 0x4B, 0x13, 0xC0, 0x41, 0xCA, 0x9C, 0xAA, 0x12, 0x21, 0x48, 0x18, 0x00, 0x83,
    0x7E, 0xEA, 0xFD, 0x83, 0x28, 0x3C, 0xC0, 0x38, 0xFF, 0x0F, 0x05, 0x00, 0xE4, 0xFF, 0x89, 0x03,
    0xE0, 0xEE, 0xB4, 0x0A, 0xD1, 0xFF, 0x7B, 0x02, 0x80, 0x4F, 0xA9, 0xE2, 0xD6, 0xAC, 0x80, 0x2A,
    0xFF, 0x4F, 0x55, 0xC0, 0xE4, 0xFF, 0x8B, 0x80, 0x2A, 0xA2, 0x48, 0xD4, 0xB0, 0x18, 0x23, 0xD4,
    0xE7, 0xE5, 0x51, 0x40, 0x51, 0x54, 0xA2, 0xC9, 0xFE, 0x0A, 0x40, 0x88, 0xEE, 0x46, 0xED, 0x9C,
    0x55, 0x00, 0x4D, 0xB7, 0x1F, 0x44, 0x3C, 0xC1, 0xFF, 0x7D, 0x51, 0x80, 0xFF, 0x79, 0x82, 0x80,
    0xC8, 0xFF, 0x07, 0x02, 0xC1, 0x95, 0x6B, 0x02, 0x75, 0xFF, 0x3D, 0x15, 0xB4, 0xDF, 0x53, 0x15,
    0xFF, 0x3D, 0x55, 0x35, 0x97, 0x78, 0x5E, 0x04, 0x4D, 0xD8, 0xF7, 0x44, 0x31, 0xF9, 0x57, 0xC0,
    0xD5, 0xC8, 0x2E, 0x82, 0x32, 0x23, 0x95, 0x87, 0x80, 0x4A, 0xCF, 0xD7, 0xA0, 0xFE, 0xFA, 0x2A,
    0x22, 0x00, 0x0E, 0xBE, 0xCE, 0xAD, 0x39, 0xEE, 0xFF, 0x83, 0x40, 0x20, 0xFF, 0x5F, 0x05, 0xDE,
    0x6F, 0x51, 0x14, 0x12, 0x77, 0xC0, 0x55, 0xEE, 0xE4, 0xB1, 0x8F, 0x82, 0xFF, 0x7A, 0xAA, 0x40,
    0x20, 0xFF, 0x1F, 0x50, 0x98, 0x8D, 0x50, 0x80, 0xE4, 0xFF, 0xA1, 0xC0, 0x26, 0xA0, 0x50, 0x40,
    0x90, 0xFF, 0x87, 0x82, 0x80, 0xD9, 0x32, 0x45, 0x17, 0x5D, 0xD5, 0xA0, 0x06, 0x0F, 0x35, 0xFE,
    0x3D, 0x15, 0x11, 0x80, 0x11, 0xAD, 0x03, 0x39, 0xBE, 0xFF, 0x27, 0x82, 0xC0, 0xFF, 0x7C, 0x41,
    0x3B, 0xDC, 0xAE, 0x03, 0x10, 0xF5, 0xE2, 0x09, 0x40, 0x00, 0x50, 0x2A, 0xA8, 0xFF, 0xAF, 0xA2,
    0x80, 0xFF, 0xF2, 0x55, 0x90, 0x8F, 0x57, 0x40, 0x41, 0xFF, 0x3E, 0x80, 0x40, 0x2A, 0x28, 0x41,
    0x99, 0x77, 0x55, 0x40, 0xA3, 0x41, 0x8A, 0xCB, 0xEE, 0xAA, 0x16, 0xAE, 0x49, 0x1A, 0xA8, 0xC4,
    0xBA, 0xEA, 0xFE, 0x00, 0xA7, 0x0A, 0x62, 0x92, 0x11, 0xEE, 0x80, 0x4F, 0xAA, 0x45, 0x40, 0x11,
    0xB5, 0x04, 0xFA, 0x8D, 0xAC, 0x11, 0x62, 0xAA, 0x80, 0x9D, 0x22, 0x40, 0x12, 0x57, 0xC0, 0x75,
    0xD8, 0xA9, 0xA0, 0x40, 0xC2, 0x28, 0x15, 0x40, 0x04, 0x9E, 0xAB, 0x80, 0xA0, 0xA3, 0x49, 0x15,
    0x71, 0x57, 0x35, 0x99, 0x4E, 0x76, 0x14, 0x80, 0x14, 0xB5, 0xAB, 0x77, 0xE0, 0x20, 0x4D, 0xAE,
    0x25, 0x60, 0x08, 0x40, 0xE4, 0x82, 0x21, 0xD0, 0x55, 0xE0, 0x85, 0x45, 0x40, 0x4B, 0xD0, 0x82,
    0x40, 0x16, 0x0A, 0xC0, 0x80, 0x48, 0x91, 0x44, 0x80, 0x0C, 0x95, 0x40, 0xC0, 0x00, 0xC8, 0x8A,
    0xA0, 0x00
};

// End address of video memory.
#define VIDEO_MEMORY_END (void*)(0xFFFF)

void main(void)
{
   u8* memory = cpct_getScreenPtr(CPCT_VMEM_START, 20, 96);
   void* crunchedDataEnd = g_test + 546 - 1;

#ifdef WINCPCTELERA
   void* memoryEnd = WinCpcTelera_GetMemPtr(VIDEO_MEMORY_END);
#endif

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

   // Set video mode to mode 0.
   cpct_setVideoMode(0);

   // Decrunch the crunched map into video memory.
#ifdef WINCPCTELERA
   cpct_zx7b_decrunch_s(memoryEnd, crunchedDataEnd);
#else
   cpct_zx7b_decrunch_s(VIDEO_MEMORY_END, crunchedDataEnd);
#endif

   // Loop forever
   while (1)
   {
       
   }
}

Arnaud

#112
Quote from: awergh on 14:36, 11 August 20
That was quick  :) .
So I tried that but have a problem, as you can see I got a different result with wincpctelera to with cpctelera.

I think i see the problem, as you know Wincpctelera is not a cpc emulator and the video memory layout is linear (the screen is just a 32bpp sprite) and when you directly deflate cpc screen in video memory of wincpctelera, well you seen what's happened  :)
There is not easy solution for now, but your code is working both on CPC and on Windows the rendering is simply not good with wincpctelera.

teopl

Since in windows memory is not an issue, you can in case of wincpctelera:

- compress the image in sprite (not screen) format (or even not compress at all for wincpctelera)
- decompress it in temp buffer
- use regular sprite draw
I guess you know already, you can use:

#ifdef WINCPCTELERA

to detect if you are on windows. I have this all over the code  :)

Arnaud

#114
Quote from: teopl on 20:34, 11 August 20
Since in windows memory is not an issue, you can in case of wincpctelera:

- compress the image in sprite (not screen) format (or even not compress at all for wincpctelera)
- decompress it in temp buffer
- use regular sprite draw
I guess you know already, you can use:

#ifdef WINCPCTELERA

to detect if you are on windows. I have this all over the code  :)

Yes you're right, but there's another small problem (and having to use a large memory area for temporary can be another problem), cpct_drawSprite can only draw a max width sprite of 64.
For full screen sprite you'll have to split your sprite into two parts (or more) not great but it'll work.

teopl

Yes, although I could swore that I had titlescreen in wincpctelera at some point, now I don't remember what I did...

Anyway, for a long time I don't use titlescreen for wincpctelera (I don't use it while developing in cpctelera also) because I don't need to see it every time :)

awergh

Ah ok, I tend to think they are the same except if you do something your not supposed to do in which case it will fail differently.
I will probably split it up but only once I have finalised the image as my methodology for taking the image and compressing it is a little bit convoluted so I'd rather avoid doing it too often.

Arnaud

Quote from: awergh on 14:49, 12 August 20
Ah ok, I tend to think they are the same except if you do something your not supposed to do in which case it will fail differently.
I will probably split it up but only once I have finalised the image as my methodology for taking the image and compressing it is a little bit convoluted so I'd rather avoid doing it too often.

Yes it's the problem, sometime i write specific code in order to have compatibility between wincpctelera and cpctelera.
And sometime things are not correctly drawn but i know it's not a bug from my game, it's a wincpctelera limitation.

Wincpctelera if far to be perfectly compatible, but it's main goal is to help to debug the C part of project  :)

Arnaud

Finally i'm working on a more compatible version of wincpctelera, the use of video memory will be identical to cpc and the conversion to 32bpp will be only internal and to display on PC screen.

funkheld


hello, that is good.


thank you.
greeting

Arnaud

 :)
[attach=1]

awergh

Great work :)
Wincpctelera continues to improve as a fantastic debugging tool.
Without it I'd probably need a lot more ifdefs to make my code Visual Studio compatible.

Arnaud

Repository updated, all is OK with my projects.

teopl

I would really like to publish my game on windows using the same code like for cpc and currently it looks very close to that goal, but still not fully ready.

I didn't debug in detail to see what exactly is missing but main issue for my game is latency when you play and I think main reason is that interrupt is not called exactly 300 times per second in equal time diff.

What else can cause lag - input, drawing, some thread being stuck... I don't know

As for music, we can use external lib for playing, I implemented music with this with no problem https://github.com/dr-soft/miniaudio

But imagine cpc games going on steam... :)

funkheld


I think we windows users want to play with wincpctelera and not debug. here an equivalence should be established between cpctelera and wincpctelera.


greeting

Powered by SMFPacks Menu Editor Mod