CPCWiki forum

General Category => Programming => Topic started by: Arnaud on 20:58, 29 September 16

Title: WinCPCTelera
Post by: Arnaud on 20:58, 29 September 16
Hello,
i'm working on a Windows implementation of the API of CPCTelera.

Some time i have a bug i was not able to solve, display values on screen was not enough to understand the problem and i am not strong enough to understand assembler and CPC register on WinApe.

Here a work in progress of WinCPCTelera.

Of course there are big limitations with this implementation, the assembler part can't be compiled, there are not sound and all CPCTelera functions are not coded or cannot be implemented.
But the goal is only to be able to debug the C part of a CPCTelera project under a modern IDE with plenty of debugging tools.

Here some working examples, the only modification in the original code was to remove the const attribute in variable that are modified while execution, VC++ really don't like it  :D

You can see some pictures from CPCTelera examples, Platform Climber and Space Moves !!! All working ;D   

[attach=3]  [attach=2] [attach=4] [attach=5]

(http://www.cpcwiki.eu/forum/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYIAAAFHCAIAAAAjvdzZAAAarklEQVR4nO2dP8gmx3nAB4zRIbgYdJiz7wp/YBUupcPFVapcGKuQzPmMPghHEr5ODshHLFuYIw/IpLmDQFSluZSqz+DClSrhQpUInNRYxFIRoSTgiAgjEPem2H3fd2afmXln/87s7O/Hg7Tf7uzuvLszv++Z2X2/M9//4xcEQRAZw3z/j1+cffQlQRBElkBDBEFkDjREEETmQEMEQWQONEQQROZAQwRBZA40RBBE5kBDBEFkjmk0ZIwxxmT/MARBrDEm0JAx5s6dO2+99RYmIghiQIzVkDHm4uLi3Xff/dOf/nT//v2rV69m/0gEQawrxmroJz/5yXvvvff+++///ve//+KLL15//fXsH4kgiHVFPw1973umiebHF1544dNPP/34449fe+21mzdvfvDBB3/5y1/u3LmT/VMRRGlx7bd/OBnZK2mHMSZSpWu//cOEkzCpGjLGvPKK+fOf2/j5z82LL774+eeff/XVV+fn50899dTXvva1b3/72x9++OGdO3dCM9ZXz405f9Rdc+PBdV+Zq+fGmIurCZ/h+r2b5ki7y9Vza525eeWdE7u45fe4te3U/NK9x9nbCrGWOGmZ0jTUiMZbq8imYZGkIWPMz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AhqtSQmP208XQayoVEsqE272tlZH0JQ0dobiikoYCkTlU2NRtq69nMael9F8+G7Pro5XgZ50hoaBDVasjNiWS1zUK8AnI05AwPO3t2n9BHBGTvFdp6qrLJgzKrM3v2XX5QpqQTUhIamoMqNdQgVk4kq20W0smGPG/NBTRk758yHHPOJ33fopaTnbCtSfulNyW7XIMyVR97vfPOgyrfLKdfAQhRsYaMMePeZCkCScyG2q2eQUSqgKzzDbhecrITSqB7D1TPpBpy63PcapfRe3nOjYYGUbmGDs1mtTNEEsuD1NcgGtHov8poC0jiedBkGvIfw3cWte9ADekzxj9rqD7h0rHjhmoFp6leQw3r1pCT7/TQUOp8UPd8Q+sZ7oSiQp1tsmwo9An02UPlQyVDWwOfApLZiIYa1icje94nJRtq92qddDoDcs415rpYw0ZfF9W1UGebcVCmzx6owxgB6U8ByWxKQw2yoiYSF5D9wD7f55JjeGQkqV3X2Uu/nRNYbvcKHHl5AaGhQWxQQ2siLqByNOQ+CjgKoscfxximIVtGM0f/TwGpoKGi0dmQ58lO1qbvCki6gugdMkRDJQQaGgEaKpq4gNxsaPG6eQRE2AGpoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMoCEAyAwaAoDMtBoiCILIGP8P6EKXRAa26TcAAAAASUVORK5CYII=)For the moment i'm focused on mode 0, when the other modes will be available i'll update my code here.

Arnaud.

Link to https://github.com/Arnaud6128/wincpctelera
Title: Re: WinCPCTelera
Post by: AugustoRuiz on 21:02, 29 September 16
This is SO great to do quick testing with debug!!!! Omfg!!!
Title: Re: WinCPCTelera
Post by: Arnaud on 21:05, 29 September 16
Quote from: AugustoRuiz on 21:02, 29 September 16
This is SO great to do quick testing with debug!!!! Omfg!!!

Yes, you understand exactly why i'm working on it  ;)
Title: Re: WinCPCTelera
Post by: AugustoRuiz on 21:07, 29 September 16
Quote from: Arnaud on 20:58, 29 September 16
i'm working on a Windows implementation of the API of CPCTelera.


Hi Arnaud!


What languages/libraries are you using? Does it have to be Win only? I've developed UWOL for PC, Linux and Mac, and getting it to work on linux was a breeze with SDL2, and in Mac a little more involved, but the code to make it work is available in my github account...


https://github.com/AugustoRuiz/UWOL (https://github.com/AugustoRuiz/UWOL)


If you want I might help making it multiplatform... I'm really interested in being able to prototype/test things while developing for CPC in a quick way!
Title: Re: WinCPCTelera
Post by: Arnaud on 21:13, 29 September 16
Quote from: AugustoRuiz on 21:07, 29 September 16

Hi Arnaud!


What languages/libraries are you using? Does it have to be Win only? I've developed UWOL for PC, Linux and Mac, and getting it to work on linux was a breeze with SDL2, and in Mac a little more involved, but the code to make it work is available in my github account...


https://github.com/AugustoRuiz/UWOL (https://github.com/AugustoRuiz/UWOL)


If you want I might help making it multiplatform... I'm really interested in being able to prototype/test things while developing for CPC in a quick way!

I use only GDI, and standard windows API.


Edit : Code added, you just have to compile the 5 files in your project.
Title: Re: WinCPCTelera
Post by: AugustoRuiz on 21:19, 29 September 16
Would it be Ok to port the drawing code and window creation to SDL2 for you? Also reading the keyboard is a breeze with SDL...
(I can help with that if you want)
Title: Re: WinCPCTelera
Post by: Arnaud on 13:09, 30 September 16
Quote from: AugustoRuiz on 21:19, 29 September 16
Would it be Ok to port the drawing code and window creation to SDL2 for you? Also reading the keyboard is a breeze with SDL...
(I can help with that if you want)

Of course you can freely use or modify my code without any problem.

But i have no time to make the migration to SDL, i want to focus my work to improve this beta version, i you want to start it i will be happy to see the result.
Title: Re: WinCPCTelera
Post by: awergh on 15:50, 30 September 16
This will be super useful.  ;D  I'm in much the same position of not being that strong in Assembly language at the moment.

I've been really missing the Visual Studio debugger, while(1) printf can only go so far.


I was half thinking about doing something like is using Allegro but as you have already done it there's no need  :)
not that I have any time anyway.  :P
Title: Re: WinCPCTelera
Post by: Arnaud on 20:51, 01 October 16
Now mode 1 et mode 2 are working, here a great picture to show it  ;)

[attach=2]

I have deeply changed the structure of project, now it have exactly the same structure as CPCTelera sources instead of only one C file and H file.

I also have extracted the graphical system part (GDI for moment) from the code in a separate C file, in order to be able to change the renderer (ex : SDL)

Next small task, found a way to have approximatively the same speed of CPC (plenty of sleep to put in code  :D )
and the next big task could be the implementation of BitArray or EasyTilemap

Quote from: AugustoRuiz on 21:19, 29 September 16
Would it be Ok to port the drawing code and window creation to SDL2 for you? Also reading the keyboard is a breeze with SDL...
(I can help with that if you want)

I could need a little help, i have taken a look on SDL but it takes too many time to learn it, if you want to begin to migrate the GDI render to SDL here the file (absolutly no hurry).

Arnaud.
Title: Re: WinCPCTelera
Post by: Arnaud on 08:43, 02 October 16
I have slightly change the memory map of the CPC, instead of using 4 arrays of 16384kb i have replaced them with only one array of 65536 kb.

With this modification i can apply a video memory offset and hardware scroll works :

[attach=2]
Title: Re: WinCPCTelera
Post by: Arnaud on 20:23, 03 October 16
BitArray are now working, and a nasty bug of conversion from CPC memory video to screen coordinates is now corrected.

[attach=2] [attach=3]
Title: Re: WinCPCTelera
Post by: Arnaud on 20:57, 04 October 16
Today FlipSprite mode 0 et mode 2 are working,
for mode 1 i have to make my own test i don't know if it works but it's coded  :D

[attach=2] [attach=3]

Sprite Blend seems to work :

[attach=4]
Title: Re: WinCPCTelera
Post by: Arnaud on 21:13, 05 October 16
Double-buffer example is working, and simple tilemap is also working.

[attach=2] [attach=3]

Tilemap and hwscroll example doesn't work very well. When moving, the lines aren't redraw at the right place or wrong lines are drawn, i don't understand  :doh:

[attach=4]
Title: Re: WinCPCTelera
Post by: Arnaud on 14:06, 08 October 16
At last Hardware tile scrolling works. It was difficult to understand how simulate the CRTC low bit offset (R13).

[attachimg=1]

Here my code, i'm pretty sure it's not really the good way to do it.

This function apply the CRTC offset to an image buffer that will be drawn in the window.

- _memOffset contains the value of CRTC offset.
- buffVideo is the array of the picture
- destVideo is the array of the picture after offset


#define  CPC_SCR_CY_LINE 200
#define CPC_SCR_CX_BYTES 80

u8* destVideo = _amstrad._mode02Video;

int dstIndex = 0x4000 - _amstrad._memOffset * 2;
for (int i = 0; i < CPC_SCR_CY_LINE*CPC_SCR_CX_BYTES; i++) {
    destVideo[dstIndex++] = *buffVideo++;
    if (dstIndex > 0x3FFF)
        dstIndex = 0;
}

for (int x = 0; x <  _amstrad._memOffset * 2 ; x++) {
    for (int y = 7; y < CPC_SCR_CY_LINE + 7; y++) {
        int offsetX = CPC_SCR_CX_BYTES - x - 1;
        *(destVideo + (y - 7)*CPC_SCR_CX_BYTES + offsetX) = *(destVideo + y*CPC_SCR_CX_BYTES + offsetX);
    }
}


If there's a better implementation tell me  ;D
Title: Re: WinCPCTelera
Post by: Arnaud on 20:57, 08 October 16
Another update in the same day  :)
The maskSpritesAligned are coded, i don't use a 256-bytes aligned mask table to create transparencies but i test every pixel before drawing it. If it's the transparent color i don't draw it.

[attach=2]

Well, almost all functions of CpcTelera API are coded.

Here is the remaining work :
- Some functions are not tested (ex: cpct_hflipSpriteMaskedM0). It's an opportunity to add some examples to CpcTelera
- Verify if something was not broken with my latest modification
- Complete the random functions
- Try to simulate the CPC speed
and...
- found a way to create the rupture functionnality
- found an idea to simulate sound (write something in the console ?)
Title: Re: WinCPCTelera
Post by: Arnaud on 15:25, 15 October 16
The flip masked sprite is working with a little example (animated) :

[attach=2]

Also remove const attribute from generated sprites and palette, no write exception with vc++ now.
Title: Re: WinCPCTelera
Post by: AmstradGamer on 17:19, 16 October 16
This is GREAT.  :o
Title: Re: WinCPCTelera
Post by: awergh on 11:36, 21 October 16
This continues to look really good.
Any chance you can resolve the distribution issue so I can play with a newer version  :) ?
Title: Re: WinCPCTelera
Post by: Arnaud on 13:02, 21 October 16
Quote from: awergh on 11:36, 21 October 16
This continues to look really good.
Any chance you can resolve the distribution issue so I can play with a newer version  :) ?

No news for moment from Ronaldo but he should be really busy and CPCRetroDev results will be presented in few days.

Regarding WinCpcTelera, the cpct_keyboardStatusBuffer is now correctly updated (now keys can be redefined in SpaceMoves).

I have some minor speed issues, i've put a tempo but it's too fast or too slow according different games. The best solution would be to put a tempo inside each cpctelera function according to the Time Measure. But i'm not sure it's essential.
Title: Re: WinCPCTelera
Post by: awergh on 13:04, 21 October 16
Quote from: Arnaud on 13:02, 21 October 16
No news for moment from Ronaldo but he should be really busy and CPCRetroDev results will be presented in few days.

Regarding WinCpctelera, the


Ah well I'll just keep using the old version for my debugging.


Title: Re: WinCPCTelera
Post by: Arnaud on 13:08, 21 October 16
Quote from: awergh on 13:04, 21 October 16

Ah well I'll just keep using the old version for my debugging.



You use it, it's great !

The actual version is far better.
Title: Re: WinCPCTelera
Post by: awergh on 13:17, 21 October 16
Quote from: Arnaud on 13:08, 21 October 16
You use it, great !

The actual version is far better.


Yeah its been really helpful being able to use the visual studio debugger. There were certain dangerous things that were picked up as runtime errors that did not cause a crash but did cause a memory leak when running it on the CPC.
Title: Re: WinCPCTelera
Post by: Arnaud on 19:37, 25 October 16
Hello,
here an update with a correction of the functions cpct_px2byteM0 and cpct_px2byteM1.

And now here a link to github : https://github.com/Arnaud6128/wincpctelera

Feel free to test and report bugs or ideas  :)
Title: Re: WinCPCTelera
Post by: cpcuser on 08:33, 26 October 16

Hi good afternoon.


Does it CPCTelera also work with the SDCC?


Thank you.Greeting
Title: Re: WinCPCTelera
Post by: Arnaud on 12:07, 26 October 16
Quote from: cpcuser on 08:33, 26 October 16

Hi good afternoon.


Does it CPCTelera also work with the SDCC?


Thank you.Greeting


Yes CPCTelera is designed to work with SDCC.

Title: Re: WinCPCTelera
Post by: cpcuser on 12:32, 26 October 16

Which cpctelera do I have to download now for sdcc?



How is the cpc telara set up for the sdcc.
Can you explain the time please for a 68 year old.
I'm not so fit in there.



thank you.
greeting
Title: Re: WinCPCTelera
Post by: Arnaud on 17:26, 26 October 16
Quote from: cpcuser on 12:32, 26 October 16
Which cpctelera do I have to download now for sdcc?

How is the cpc telara set up for the sdcc.
Can you explain the time please for a 68 year old.
I'm not so fit in there.

thank you.
greeting

Install cpctelera is easy, here a link to manual :
http://lronaldo.github.io/cpctelera/files/readme-txt.html#Downloading_CPCtelera (http://lronaldo.github.io/cpctelera/files/readme-txt.html#Downloading_CPCtelera)

To sum up, you have to :
- Install and run Cygwin software https://www.cygwin.com/ (https://www.cygwin.com/) with the packages indicated in the manual
- Download and decompress cpctelera in Cygwin installation https://github.com/lronaldo/cpctelera/archive/v1.4.zip (https://github.com/lronaldo/cpctelera/archive/v1.4.zip)
- Under Cygwin console run installation with command "./setup.sh"
- SDCC and cpctelera will be installed

If you want only SDCC here a link http://sdcc.sourceforge.net/index.php#Download (http://sdcc.sourceforge.net/index.php#Download)
Title: Re: WinCPCTelera
Post by: Arnaud on 10:42, 01 November 16
Rupture is now working with interrupt :
[attach=2]

Interrupt are managed in a separate thread and i had hard work to synchronize all stuff.

Other improvement is adding the missing alternate hardware color
ex : Blue hw is 0x44 or 0x50

In internal modifications i use now only one render 8bit buffer instead of a render 1bit buffer for mode 2, 4 bits buffer for mode 0, etc.
Title: Re: WinCPCTelera
Post by: ronaldo on 12:35, 01 November 16
Really great work, @Arnaud (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1424) ! It's going to be really useful for people willing to debug their code and also for producing Windows binaries :D.
Title: Re: WinCPCTelera
Post by: Arnaud on 13:40, 01 November 16
Quote from: ronaldo on 12:35, 01 November 16
Really great work, @Arnaud (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1424) ! It's going to be really useful for people willing to debug their code and also for producing Windows binaries :D .

Windows binaries but without sound ::) . I really don't have idea how simulate CPC sound.
Title: Re: WinCPCTelera
Post by: Arnaud on 21:45, 03 November 16
A little update on String :
- The space (' ') character has now a background color
- On string larger than screen, the characters drawn after a line return are draw at the right position

And video mode change at interrupt works :
[attach=2]
Title: Re: WinCPCTelera
Post by: cpcuser on 09:44, 05 November 16

Where will that be registered under win7 : ????


SETUP_PATH=d:\cygwin......????
CPCT_MAIN_DIR=d:\cygwin\cpctelera....????
CPCT_TOOLS_DIR=d:\cygwin\cpctelera\tools...????
CPCT_SCRIPTS_DIR=d:cygwin\\cpctelera\scripts....?????


thanks
greeting

Title: Re: WinCPCTelera
Post by: Arnaud on 10:46, 05 November 16
You don't need to register or set path under windows, cpctelera is made to work only under Cygwin environment.

If you have installed properly cpctelera with installation script all is done automatically when you launch cygwin.
Title: Re: WinCPCTelera
Post by: cpcuser on 13:06, 05 November 16
Quote

[size=78%]If you have installed properly cpctelera with installation script all is done automatically when you launch cygwin.[/size]



How is it installed correctly?
Can you please explain this step by step?


I'm 68 years and do not get that fast.


thank you.
greeting
Title: Re: WinCPCTelera
Post by: Arnaud on 13:23, 05 November 16
Quote from: Arnaud on 17:26, 26 October 16
Install cpctelera is easy, here a link to manual :
http://lronaldo.github.io/cpctelera/files/readme-txt.html#Downloading_CPCtelera (http://lronaldo.github.io/cpctelera/files/readme-txt.html#Downloading_CPCtelera)

To sum up, you have to :
- Install and run Cygwin software https://www.cygwin.com/ (https://www.cygwin.com/) with the packages indicated in the manual
- Download and decompress cpctelera in Cygwin installation https://github.com/lronaldo/cpctelera/archive/v1.4.zip (https://github.com/lronaldo/cpctelera/archive/v1.4.zip)
- Under Cygwin console run installation with command "./setup.sh"
- SDCC and cpctelera will be installed

If you want only SDCC here a link http://sdcc.sourceforge.net/index.php#Download (http://sdcc.sourceforge.net/index.php#Download)

It's really well explain in cpctelera manual, here the link.
Title: Re: WinCPCTelera
Post by: cpcuser on 13:25, 05 November 16
my  programm is :


d:/cygwin64/cpctelera-1,4/setup.sh


greeting
Title: Re: WinCPCTelera
Post by: cpcuser on 13:41, 05 November 16
SETUP_PATH="d:/cygwin64/cpctelera-1.4"
CPCT_MAIN_DIR="${SETUP_PATH}/cpctelera"
CPCT_TOOLS_DIR="${CPCT_MAIN_DIR}/tools"
CPCT_SCRIPTS_DIR="${CPCT_TOOLS_DIR}/scripts"

is ok.




make not found in cygwin64.
Title: Re: WinCPCTelera
Post by: Arnaud on 13:45, 05 November 16
You should copy cpctelera in your profile not directly under Cygwin.

Here how cpctelera is installed on my PC :
[attach=2]

"cpctelera-1.4" directory : cpctelera decompressed with "setup.sh" in root
"CPC" directory :  my projects
"Utils" directory : winape

You have to install the following package with Cygwin setup:
Title: Re: WinCPCTelera
Post by: cpcuser on 14:07, 05 November 16
were are :gcc-core......


greeting
Title: Re: WinCPCTelera
Post by: SRS on 22:09, 05 November 16
it should be under "Devel" or you can type "gcc-core" at the SEARCH field and it will show you where in the packages it is stored. you need a bit of patience as the search is real slow ...
Title: Re: WinCPCTelera
Post by: cpcuser on 13:03, 06 November 16
Hi good afternoon.

Cpcgtelera is now installed with cygwin.   :)
Can you please sourcode in the forum for cpctelera?

I have notepad ++.
How are the programs of notepad ++ compiled with cpctelera?
With "make"... or .... ???

greeting

Title: Re: WinCPCTelera
Post by: Arnaud on 13:35, 06 November 16
Here in the cpctelera manual how start a project :
http://lronaldo.github.io/cpctelera/files/readme-txt.html#Starting_with_CPCtelera (http://lronaldo.github.io/cpctelera/files/readme-txt.html#Starting_with_CPCtelera)

- cpct_mkproject [my_project] will create your new project with default C files
- "make" will build your code
- "cpct_winape *.dsk" will run your program if you have installed cpct_winape
- winape path must be absolute path

Inside your project you will have a "cfg" directory with build configuration.

You have plenty of example in "examples" directory.


You should read the manual all is explain here
Title: Re: WinCPCTelera
Post by: cpcuser on 14:12, 06 November 16
I do not understand ?


How is a project done ?

error:

pebi@pebi-PC ~
$ d:/cygwin/home/pebi/cpctelera-1.4/examples/easy/box/src/cpct_mkproject main.c
-bash: d:/cygwin/home/pebi/cpctelera-1.4/examples/easy/box/src/cpct_mkproject: No such file or directory

greeting
Title: Re: WinCPCTelera
Post by: Arnaud on 14:20, 06 November 16
Quote from: cpcuser on 14:12, 06 November 16
I do not understand ??? ?

error:


pebi@pebi-PC ~
$ d:/cygwin/home/pebi/cpctelera-1.4/examples/easy/box/src/cpct_mkproject main.c
-bash: d:/cygwin/home/pebi/cpctelera-1.4/examples/easy/box/src/cpct_mkproject: No such file or directory

greeting

To build : make (no argument)
To create project : cpct_mkproject
Title: Re: WinCPCTelera
Post by: cpcuser on 14:27, 06 November 16

I do not understand :


pebi@pebi-PC ~
$ make cpct_mkproject d:/cygwin/home/pebi/cpctelera-1.4/examples/easy/box/src/main.c
make: *** Keine Regel, um ,,cpct_mkproject" zu erstellen.  Schluss.


thank you.
greeting
Title: Re: WinCPCTelera
Post by: Arnaud on 16:58, 06 November 16
A gdi palette leaks is corrected.

You should update your project with this version if use it, the system limit of 10000 gdi objects is quickly reach  :doh: .
Title: Re: WinCPCTelera
Post by: Arnaud on 22:07, 09 November 16
Special update CPCRetroDev 2016  ;D

Hair-Boy
[attach=2]

I have detected an array index of bound in the code but it don't disturb the cpc version  ;)

Sadly i can compile the winner Outlaw because it use z80 ASM unexomizer.
Title: Re: WinCPCTelera
Post by: Arnaud on 21:31, 10 November 16
VSync is really working now:
[attachimg=1]

It's so smooth now  ;D
Title: Re: WinCPCTelera
Post by: cpcuser on 15:01, 11 November 16

Hello, I now take ccz80-compiler. it is wundervoll.


This cpctelera is for me overprinted and too unclear to program a small 8-bitter with a program of about 2GByte.


greeting
Title: Re: WinCPCTelera
Post by: EgoTrip on 20:27, 11 November 16
Quote from: Arnaud on 22:07, 09 November 16
Sadly i can compile the winner Outlaw because it use z80 ASM unexomizer.

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.
Title: Re: WinCPCTelera
Post by: Arnaud on 21:17, 11 November 16
Quote from: EgoTrip on 20:27, 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/ (http://www.cpcwiki.eu/forum/programming/lz48-cruncherdecruncher/), i just adapt the compressor LZ48 from roudoudou for Cpctelera it could be a solution.
Title: Re: WinCPCTelera
Post by: Arnaud on 14:34, 13 November 16
Finally !

[attach=2][attach=3][attach=4]

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 :
#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 :
#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:
u8* cpct_getMemoryPointer(int pAddress)
{
    return (u8*) pAddress;
}


I had to speak about this solution with @ronaldo (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1227)  :D

Title: Re: WinCPCTelera
Post by: SRS on 20:40, 13 November 16
Quote from: Arnaud on 14:34, 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:
u8* cpct_getMemoryPointer(int pAddress)
{
    return (u8*) pAddress;
}


I had to speak about this solution with @ronaldo (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1227)  :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" ?
Title: Re: WinCPCTelera
Post by: Arnaud on 21:00, 14 November 16
Quote from: SRS on 20:40, 13 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.

Quote from: SRS on 20:40, 13 November 16
Can't you use exodecrunch C Sources from https://bitbucket.org/magli143/exomizer/wiki/Home (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/ (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/

Title: Re: WinCPCTelera
Post by: ronaldo on 18:29, 15 November 16
Quote from: Arnaud on 14:34, 13 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 (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1227)  :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.
Title: Re: WinCPCTelera
Post by: Arnaud on 22:09, 19 November 16
Joystick support added !

It's really better to play Outlaw with joypad  :)
Title: Re: WinCPCTelera
Post by: Arnaud on 11:24, 20 November 16
SDL support is working (for window creation, render and input keyboard / joystick).

Hope it will be useful for someone.

[attach=2]
Title: Re: WinCPCTelera
Post by: Arnaud on 08:37, 18 December 16
A little update :
It takes only 10 bytes in memory for CPC.

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

WinCpcTelera_Process()
Process windows message loop -> Do/take nothing in CPC

WinCpcTelera_Wait(X)
Tempo in ms  -> Do nothing in CPC

WinCpcTelera_PrintXXX
Draw value in console  -> Do/take nothing in CPC

[attach=2]
Title: Re: WinCPCTelera
Post by: awergh on 10: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).



(https://i.imgur.com/5ikx8Il.png)
Title: Re: WinCPCTelera
Post by: Arnaud on 21:08, 09 February 17
Hello,

Quote from: awergh on 10:58, 09 February 17
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

Quote from: awergh on 10:58, 09 February 17
This was fine just needed to comment out __sdcc_heap_init(); as it is SDCC specific.
__sdcc_heap_init() is ignored in compilation now

Quote from: awergh on 10:58, 09 February 17
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
Title: Re: WinCPCTelera
Post by: awergh on 12: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



(https://i.imgur.com/aauglCP.png)
Title: Re: WinCPCTelera
Post by: Arnaud on 19:50, 10 February 17
Quote from: awergh on 12: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.

Quote from: awergh on 12:50, 10 February 17
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:





Title: Re: WinCPCTelera
Post by: awergh on 13: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.
Title: Re: WinCPCTelera
Post by: Arnaud on 15:58, 12 February 17
Quote from: awergh on 13: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.
In fact it's a good way to found bug  ;)

Quote from: awergh on 13:47, 12 February 17
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.

Quote from: awergh on 13:47, 12 February 17
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.
Title: Re: WinCPCTelera
Post by: awergh on 09:12, 13 February 17
Quote from: Arnaud on 15:58, 12 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]
Quote from: Arnaud on 15:58, 12 February 17I 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.
Title: Re: WinCPCTelera
Post by: Arnaud on 15: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.
Title: Re: WinCPCTelera
Post by: Arnaud on 20: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
Title: Re: WinCPCTelera
Post by: awergh on 12: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.

Title: Re: WinCPCTelera
Post by: ronaldo on 11:59, 06 August 18
Quote from: awergh on 12:27, 05 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").
Title: Re: WinCPCTelera
Post by: Arnaud on 09:08, 07 August 18
Quote from: awergh on 12: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?
Thanks for reporting @awergh (http://www.cpcwiki.eu/forum/index.php?action=profile;u=249) , i forgot to commit this file, all should be ok now.

Quote from: ronaldo on 11:59, 06 August 18
I expect to be launching CPCtelera 1.5 by september.
:D
Title: Re: WinCPCTelera
Post by: awergh on 13:51, 07 August 18
Quote from: Arnaud on 09:08, 07 August 18
Thanks for reporting @awergh (http://www.cpcwiki.eu/forum/index.php?action=profile;u=249) , 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.

Quote from: ronaldo on 11:59, 06 August 18
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.
Title: Re: WinCPCTelera
Post by: ronaldo on 19:20, 07 August 18
Quote from: awergh on 13:51, 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.

Quote from: awergh on 13:51, 07 August 18: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 :) .
Title: Re: WinCPCTelera
Post by: awergh on 13: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.


#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)
    {

    }
}




Quote from: ronaldo on 19:20, 07 August 18
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).
Title: Re: WinCPCTelera
Post by: Arnaud on 16:15, 19 August 18
Hello @awergh (http://www.cpcwiki.eu/forum/index.php?action=profile;u=249),
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.
Title: Re: WinCPCTelera
Post by: awergh on 07:22, 16 June 19
So as its almost time to start an entry for CPCRetroDev 2019 I thought it was time I reported a bug I had with wincpctelera.
Just the one bug (I thought I had a few but it turned out my code was the problem even if wincptelera vs cpc did not produce exactly the same result consistently)
I saw you did some changes for CPCtelera 1.5 which I haven't checked out but it probably still applies.

So here is my example of reading a key from the user (based on one of the examples on cpcwiki somewhere).
The problem is that not all the key codes work when using wincpctelera.
The following keys are not detected: z, x, v, del, space



#include <cpctelera.h>
#include <stdio.h>

cpct_keyID getKey();
void interruptHandler();

void main(void)
{
    //default to anything
    cpct_keyID chosenKey = Key_A;
    u8 letterCount = 0;
    u8* memory = 0;
    u8* memortAlt = 0;

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

    //setup interruptHandler for keyboard scanning
    cpct_setInterruptHandler(interruptHandler);

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

    memory = cpct_getScreenPtr(CPCT_VMEM_START, 8, 12);
    memortAlt = cpct_getScreenPtr(CPCT_VMEM_START, 8, 24);

    //loop forever
    while (1)
    {
        u8 chosenCharacter = 0;

        //get the next character from the user
        chosenKey = getKey();

        switch (chosenKey)
        {
            case Key_A:
                chosenCharacter = 'a';
            break;

            case Key_B:
                chosenCharacter = 'b';
            break;

            case Key_C:
                chosenCharacter = 'c';
            break;

            case Key_D:
                chosenCharacter = 'd';
            break;

            case Key_E:
                chosenCharacter = 'e';
            break;

            case Key_F:
                chosenCharacter = 'f';
            break;

            case Key_G:
                chosenCharacter = 'g';
            break;

            case Key_H:
                chosenCharacter = 'h';
            break;

            case Key_I:
                chosenCharacter = 'i';
            break;

            case Key_J:
                chosenCharacter = 'j';
            break;

            case Key_K:
                chosenCharacter = 'k';
            break;

            case Key_L:
                chosenCharacter = 'l';
            break;

            case Key_M:
                chosenCharacter = 'm';
            break;

            case Key_N:
                chosenCharacter = 'n';
            break;

            case Key_O:
                chosenCharacter = 'o';
            break;

            case Key_P:
                chosenCharacter = 'p';
            break;

            case Key_Q:
                chosenCharacter = 'q';
            break;

            case Key_R:
                chosenCharacter = 'r';
            break;

            case Key_S:
                chosenCharacter = 's';
            break;

            case Key_T:
                chosenCharacter = 't';
            break;

            case Key_U:
                chosenCharacter = 'u';
            break;

            case Key_V:
                chosenCharacter = 'v';
            break;

            //doesnt work on wincpctelera
            case Key_W:
                chosenCharacter = 'w';
            break;

            //doesnt work on wincpctelera
            case Key_X:
                chosenCharacter = 'x';
            break;

            case Key_Y:
                chosenCharacter = 'y';
            break;

            //doesnt work on wincpctelera
            case Key_Z:
                chosenCharacter = 'z';
            break;

            //space does not work on wincpctelera
            case Key_Space:
                chosenCharacter = 0;
                cpct_drawStringM0("space", memortAlt, 1, 0);
            break;

            //del doesn't work with cpctelera but 16386 does
            //case 16386:
            case Key_Del:
                chosenCharacter = 0;
                cpct_drawStringM0("del", memortAlt, 1, 0);
            break;

            default:
                chosenCharacter = 0;
                cpct_drawStringM0("default", memortAlt, 1, 0);
            break;
        }

        if (chosenCharacter)
        {
            //draw letter
            cpct_drawCharM0(memory, 1, 0, chosenCharacter);
        }
    }
}

cpct_keyID getKey()
{
    // Traverse the keystatus vector from end to start, to help
    // the compiler better optimise this code
    u8 i = 10;
    u8* keys = cpct_keyboardStatusBuffer + 9;
    u16 keypressed = 0;

    // wait for any previous key presses to clear first
    while (cpct_isAnyKeyPressed());

    //then wait for the desired key press
    while (!cpct_isAnyKeyPressed());


    // Analyse which key has been pressed and return its keycode
    do
    {
        // We analyse groups of keys byte by byte (8 by 8, 1 bit per key)
        // If no single key is pressed in this group, all bits will be on, and the byte will be 0xFF
        // Then, XORing the byte with 0xFF will result in 0 unless some key from this group is pressed
        keypressed = *keys ^ 0xFF;

        if (keypressed)
        {
            return (keypressed << + (i - 1); // Convert to cpct_keyID format: 8 first bits = key mask, 8 next bits, keyboard row (0-9)
        }

        --keys;
    } while (--i);

    // No key was pressed
    return 0;
}

void interruptHandler()
{
    //scan for any keyboard changes
    cpct_scanKeyboard_if();
}



Have you completed your changes for CPCtelera 1.5?
I haven't decided if I should be using 1.4.2 or grabbing the latest 1.5 from github.
Title: Re: WinCPCTelera
Post by: Arnaud on 08:24, 16 June 19
Hi  @awergh (http://www.cpcwiki.eu/forum/index.php?action=profile;u=249),
thanks for reporting.

I just check my code for missing key in WinCPCTelera and all is (fortunately) OK.

;D Edit :
Effectively there is a problem, enum are stored in C in int and cpct_keyID is unsigned short.


int enumKeyZ= (i16)0x8008; -> 0xFFFF8008;
cpct_keyID  myKeyZ = getKey(); -> 0x8008;

PROBLEM : enumKeyZ != myKeyZ


I work on it.


By the way here the version of getKey() i used in my games :

cpct_keyID getKey()
{
/** From Ronaldo in cpcwiki forum */
u8* keyStatus = cpct_keyboardStatusBuffer;
u8 i;

while (!cpct_isAnyKeyPressed());

for (i = 0; i < 10; i++)
{
cpct_keyID keypressed = *keyStatus++ ^ 0xFF;
if (keypressed)
return (keypressed << 8) + i;
}

return 0;
}



Quote from: awergh on 07:22, 16 June 19
Have you completed your changes for CPCtelera 1.5?
I haven't decided if I should be using 1.4.2 or grabbing the latest 1.5 from github.

You can use WinCPCtelera with 1.5, i have migrated my projects to this version and i'm currently programming with it.

I haven't yet migrated String functions but i'll do it today (i saw you use them).

Title: Re: WinCPCTelera
Post by: awergh on 10:00, 16 June 19
Thanks for that I'll have a look once I start programming.
I decided to have some discipline this year and try to do much of my planning this month before getting into the development in July as per usual.


I wouldn't be too worried to rush with the String functions, I used them in my 2016/2017 entries and little things but I expect I will use a custom font (same as 2018) as it made memory management below 0x4000 much easier.


I think I'm convinced to go for 1.5 I'll just note which revision it is and stick to it.
I do like the idea that someone could compile my code easily if they wanted to even though there isn't much reason to do so.
Title: Re: WinCPCTelera
Post by: Arnaud on 11:11, 16 June 19
Corrections pushed :
- Solve incompatibility between cpct_keyId enum and typedef
- Update String functions for cpctelera 1.5 API
- Correction in String functions (wrong character could be displayed and mode 2 Space character was not drawn)
- Minor corrections

Thanks a lot for reporting @awergh (http://www.cpcwiki.eu/forum/index.php?action=profile;u=249)  :)


Title: Re: WinCPCTelera
Post by: awergh on 07:50, 20 July 19
I found another bug in wincpctelera.  ;D
I was trying out bitarrays for the first time and found that some elements in the arrays were not set to valid values.
So in my example below it is supposed to show a graphic in each screen position but some spots are blank.

Also I noticed that when I was trying to use cpct_drawStringM0 it didn't display anything at all! (so I used graphics for this example instead)


#include <cpctelera.h>
#include <stdio.h>


#define SCREEN_TILES_Y 12
#define SCREEN_TILES_X 20
#define TILE_HEIGHT 16
#define TILE_WIDTH_BYTES 4


const u8 xPositions[20] = { 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76 };
const u8 yPositions[12] = { 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176 };


const u8 G_magnifying_glass[64] = {
    0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00,
    0x00, 0x88, 0x00, 0x00,
    0x44, 0xCC, 0x00, 0x00,
    0x44, 0xCC, 0x00, 0x00,
    0x44, 0xCC, 0x00, 0x00,
    0x44, 0xCC, 0x00, 0x00,
    0x44, 0xCC, 0x00, 0x00,
    0x00, 0x88, 0x80, 0x00,
    0x00, 0x00, 0x80, 0x00,
    0x00, 0x00, 0x40, 0x00,
    0x00, 0x00, 0x40, 0x00,
    0x00, 0x00, 0x00, 0x80,
    0x00, 0x00, 0x00, 0x80,
    0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00 };


void main(void)
{
    u8 i = 0;
    u8 x = 0;
    u8 y = 0;
    u8* mapMemory;
    u8 position = 0;


    //declare a bitarray
    CPCT_6BITARRAY(mapCells, 240);


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


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


    //clear the screen
    cpct_clearScreen(0);


    //fill the bit array with values
    for (i = 0; i < 240; ++i)
    {
        cpct_set6Bits(mapCells, 0x11, i);
    }   


    //position is the element in the map tile array
    for (x = 0; x < SCREEN_TILES_X; ++x)
    {
        for (y = 0; y < SCREEN_TILES_Y; ++y)
        {
            u8 cellValue = cpct_get6Bits(mapCells, position);
            mapMemory = cpct_getScreenPtr(CPCT_VMEM_START, xPositions[x], yPositions[y]);


            if (cellValue)
            {
                //cpct_drawStringM0("a", mapMemory);
                cpct_drawSprite(G_magnifying_glass, mapMemory, TILE_WIDTH_BYTES, TILE_HEIGHT);
            }


            ++position;
        }
    }
   
    while (1);
}



Title: Re: WinCPCTelera
Post by: Arnaud on 21:41, 21 July 19
Hello @awergh (http://www.cpcwiki.eu/forum/index.php?action=profile;u=249),
i just uploaded my fix.

To sum up :
- Values of background and pen for the functions cpct_drawString were not initialized and set to 0 (pen must be set to 1)
- Wrong computation of bit position in byte

Thanks for testing.
Title: Re: WinCPCTelera
Post by: awergh on 13:27, 04 August 19
Hi @Arnaud (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1424)
thanks for fixing it but I broke it again  :P
I might not actually end up using bit arrays in my game but I figure you would want it to work without bugs.



#include <cpctelera.h>
#include <stdio.h>


#define SCREEN_TILES_Y 12
#define SCREEN_TILES_X 20
#define TILE_HEIGHT 16
#define TILE_WIDTH_BYTES 4


const u8 xPositions[20] = { 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76 };
const u8 yPositions[12] = { 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176 };


const u8 G_magnifying_glass[64] = {
    0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00,
    0x00, 0x88, 0x00, 0x00,
    0x44, 0xCC, 0x00, 0x00,
    0x44, 0xCC, 0x00, 0x00,
    0x44, 0xCC, 0x00, 0x00,
    0x44, 0xCC, 0x00, 0x00,
    0x44, 0xCC, 0x00, 0x00,
    0x00, 0x88, 0x80, 0x00,
    0x00, 0x00, 0x80, 0x00,
    0x00, 0x00, 0x40, 0x00,
    0x00, 0x00, 0x40, 0x00,
    0x00, 0x00, 0x00, 0x80,
    0x00, 0x00, 0x00, 0x80,
    0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00 };


void main(void)
{
    u8 i = 0;
    u8 x = 0;
    u8 y = 0;
    u8* mapMemory;
    u8 position = 0;


    //declare a bitarray
    CPCT_6BITARRAY(mapCells, 240);


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


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


    //clear the screen
    cpct_clearScreen(0);


    //fill the bit array with values
    for (i = 0; i < 240; ++i)
    {
        if (i % 3 == 0)
        {
            cpct_set6Bits(mapCells, 0x10, i);
        }
        else if (i % 3 == 1)
        {
            cpct_set6Bits(mapCells, 0x20, i);
        }
        else
        {
            cpct_set6Bits(mapCells, 0x01, i);
        }       
    }   


    //position is the element in the map tile array
    for (x = 0; x < SCREEN_TILES_X; ++x)
    {
        for (y = 0; y < SCREEN_TILES_Y; ++y)
        {
            u8 cellValue = cpct_get6Bits(mapCells, position);
            mapMemory = cpct_getScreenPtr(CPCT_VMEM_START, xPositions[x], yPositions[y]);


            if (cellValue & 0x10)
            {
                cpct_drawStringM0("c", mapMemory);
            }
            else if (cellValue & 0x20)
            {
                cpct_drawStringM0("b", mapMemory);
            }
            else if (cellValue) //blanks do not get drawn
            {
                cpct_drawStringM0("a", mapMemory);
            }


            ++position;
        }
    }
   
    while (1);
}
Title: Re: WinCPCTelera
Post by: johnlobo on 12:47, 13 August 19

Hi,


I'm trying to give a test to WinCpcTelera, but I'm quite new with Visual Studio, and I'm not been able to do it.


First, I clone the WinCpcTelera repository, and when I open the solution in Visual Studio, it asks me for confirmation to retarget the project to windows SDK 10 and Toolbox 142. I've tried to skip thsi step, and not to retarget it, but the project doesn't build... so, I confirm, it retargets, and after retargeting, apparently the project is built with no further problem.


Then, I create a new project for testing, the tipical "Welcome to CpcTelera" message. And to make it work, I change the properties of the project so that WinCpcTelera resources can be located during the build process...


Include wincpctelera dir in  VC++ Directories/Include directories
Include wincpctelera\Visual\x64\Debug\ dir in C++ Directories/Library directories
And include "WinCpcTelera.lib" in Linker/Input/Addcitional dependencies
After all this, I try to build the test... but it doesn't work. Below is part of the output of the build process..


1>main.obj : error LNK2019: unresolved external symbol _cpct_setDrawCharM1 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _cpct_drawStringM1 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _cpct_getScreenPtr referenced in function _main
1>\source\repos\wincpctelera\Visual\x64\Debug\WinCPCTelera.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
1>
1>Unused libraries:
1>  \source\repos\wincpctelera\Visual\x64\Debug\WinCPCTelera.lib


From this ouptput I presume that the include configuration has worked (no compiler errors), and the library configuration has worked too, because WinCpcTelera.lib, appears as an unused library, but for some reason, the linker can't find the cpctelera functions in the library.


Besides there is this weird warning about the library machine and the target machine...  :-S


What am I doing wrong?? Any help would be appreciated.


Thanks.

Title: Re: WinCPCTelera
Post by: Arnaud on 13:16, 13 August 19
Hi @johnlobo (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1183),
here my VS configuration from a project (in screenshot)

To sum-up my conf:
- Wincpctelera is a project static library
- Wincpctelera is a dependance of the main project
- The project is a Win32 application
- The path to the Wincpctelera headers must be set in main project.

Arnaud
Title: Re: WinCPCTelera
Post by: awergh on 14:55, 13 August 19

Just to add my thoughts as well to what Arnaud said.


I assume you are using a recent version of Visual Studio (I've used 2015-2019 with wincpctelera without issues).
Make sure you build both wincpctelera and your game in Win32 (x86) debug. (x64 and or release have not worked for me)

Title: Re: WinCPCTelera
Post by: johnlobo on 14:22, 14 August 19
Thank you both for the prompt response.


I've made some progress but it is not working yet... :-(


- I've following Arnaud instructions, and everything seem to work fine, but if I don't include Wincpctelera as a reference for the main project, I still get the unresolve external symbol error.
- After including Wincpctelera as a reference, everything seems to build fine, but when executed, it just shows an empty console window (see screenshot).


- I've tested it in VS 2017 & VS 2019 with the same results.


The process I follow is pretty simple


1) download Wincpctelera
2) create an empty project and add "main.c" file
3) add Wincpctelera to the test project solution
5) retarget Wincpctelera project to user newer windows SDK
6) add Wincpctelera as a reference of the test project
7) set Wincpctelera dir as additional include dir for the test project
8 ) build and execute the test project (wincpctelera is also built during the process).


The result of this process is an empty console window

Title: Re: WinCPCTelera
Post by: Arnaud on 15:12, 14 August 19
Obviously there is a problem in the Window application creation.

Try to put a break point here :

winGDI.c

void wincpct_createWindowApp()


To see why the Window is not visible.
Title: Re: WinCPCTelera
Post by: johnlobo on 00:25, 16 August 19
Well, I don't know exactily what I did, because I've tried different combination of changes in the configuration of the solution, but at the end it works.Thank you very much for your help.
Now that I'm able to execute cpctelera code, I've notice some differences between what it's shown in wincpctelera and winape in some of the tests.
This is the code of the first test...

#include <cpctelera.h>

#define BG_COLOR 0

void drawWindow(u8 x, u8 y, u8 width, u8 height, u8 fgColor, u8 bgColor)
{
    u8 *pvideo;


    // top and bottom fgColor horizontal lines
    pvideo = cpct_getScreenPtr(CPCT_VMEM_START, x + 1, y);
    cpct_drawSolidBox(pvideo, cpct_px2byteM0(fgColor, fgColor), width - 4, 2);
    pvideo = cpct_getScreenPtr(CPCT_VMEM_START, x + 1, y + height);
    cpct_drawSolidBox(pvideo, cpct_px2byteM0(fgColor, fgColor), width - 4, 2);
    // top and bottom BG_COLOR horizontal lines
    pvideo = cpct_getScreenPtr(CPCT_VMEM_START, x + 1, y + 2);
    cpct_drawSolidBox(pvideo, cpct_px2byteM0(BG_COLOR, BG_COLOR), width - 4, 2);
    pvideo = cpct_getScreenPtr(CPCT_VMEM_START, x + 1, y + height - 2);
    cpct_drawSolidBox(pvideo, cpct_px2byteM0(BG_COLOR, BG_COLOR), width - 4, 2);
    // Internal box
    pvideo = cpct_getScreenPtr(CPCT_VMEM_START, x + 1, y + 4);
    cpct_drawSolidBox(pvideo, cpct_px2byteM0(bgColor, bgColor), width - 4, height - 6);

    // top left corner
    pvideo = cpct_getScreenPtr(CPCT_VMEM_START, x, y + 2);
    cpct_drawSolidBox(pvideo, cpct_px2byteM0(BG_COLOR, fgColor), 1, 2);

    // left vertical line
    pvideo = cpct_getScreenPtr(CPCT_VMEM_START, x, y + 4);
    cpct_drawSolidBox(pvideo, cpct_px2byteM0(fgColor, BG_COLOR), 1, height - 6);

    //bottom left corner
    pvideo = cpct_getScreenPtr(CPCT_VMEM_START, x, y + height - 2);
    cpct_drawSolidBox(pvideo, cpct_px2byteM0(BG_COLOR, fgColor), 1, 2);
    // top right corner
    pvideo = cpct_getScreenPtr(CPCT_VMEM_START, x + width - 3, y + 2);
    cpct_drawSolidBox(pvideo, cpct_px2byteM0(fgColor, BG_COLOR), 1, 2);
    // right vertical line
    pvideo = cpct_getScreenPtr(CPCT_VMEM_START, x + width - 3, y + 4);
    cpct_drawSolidBox(pvideo, cpct_px2byteM0(BG_COLOR, fgColor), 1, height - 6);
    // bottom right corner
    pvideo = cpct_getScreenPtr(CPCT_VMEM_START, x + width - 3, y + height - 2);
    cpct_drawSolidBox(pvideo, cpct_px2byteM0(fgColor, BG_COLOR), 1, 2);
}

void main(void) {

    cpct_disableFirmware();

    cpct_setVideoMode(0);

    drawWindow(3, 95, 21, 80, 1, 2);

    // Loop forever
    while (1);
}

And the result of both enpoints is in the snapshot attached.
Apparently the differece is related to the coordinates of the function cpct_drawSolidBox.
Title: Re: WinCPCTelera
Post by: Arnaud on 08:08, 16 August 19
Hi @johnlobo (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1183),
it's nice that Wincpctelera finally works with you ;)

Thank for reporting,
the bug is solve (the two Bytes of cpct_px2byteM0 were inverted).

You can download the corrected file cpct_sprites.c directly on git.

I'am also working to correct the BitArray but it's not obvious.
Title: Re: WinCPCTelera
Post by: johnlobo on 10:49, 16 August 19
Hi Arnaud,


Could it be possible to have in WinCPCTelera "cpct_waitHalts"??. This function is in the developer branch, and it's basically a delay function.




cpct_waitHalts
Waits for a given number of halt assembler instructions to be executed.


C Definition
void cpct_waitHalts (u8 n) __z88dk_fastcall;


Input Parameters (1 Byte)
(1B B) n Number of halts to wait



As a workaround for my project I have included a define in the helper to call wincpct_wait, but it's not accurate.



Title: Re: WinCPCTelera
Post by: Arnaud on 12:00, 16 August 19
Hi,
cpct_waitHalts added and tested.

Can you confirm it works also for your code ?

Title: Re: WinCPCTelera
Post by: johnlobo on 12:47, 16 August 19
Hi Arnaud,


Yes it works in my code. No errors shown, but it goes extraordinarilly fast, much more than in the emulator... is that normal??



Title: Re: WinCPCTelera
Post by: Arnaud on 13:41, 16 August 19
Quote from: johnlobo on 12:47, 16 August 19
Hi Arnaud,


Yes it works in my code. No errors shown, but it goes extraordinarilly fast, much more than in the emulator... is that normal??

Yes and no  :D

WinCPCtelera uses a Window timer with an accuracy 2-5ms and don't have realistic tempo in the cpctelera functions.
Tempo are added in some functions but i haven't found yet the best solution (it's either too slow or too fast)

But you can try to add some wincpct_wait in WinCPCTelera functions and if timing seems better i'll put in my code.

What generaly do, it's put a cpct_waitVSYNC in my main loop.



Title: Re: WinCPCTelera
Post by: johnlobo on 14:54, 16 August 19

Ok.

In my project all the events synced with delays (mainly animations) now go really, really fast.
Only to get  a rough idea of how fast they go, I've added a multiplyer to the index in the loop of waitHalts, and the value that more or less gives me a similar feeling to the emaulator is 2750. This means, that if in my code I have to wait for 25 halts to trigger something, in the windows code, that number is converted to 68.750.


But, that's not really a problem for my purposes because all of them go at the same pace, so I will leave it like this, and if something wierd else happens, I will let you know.


Title: Re: WinCPCTelera
Post by: Arnaud on 15:05, 16 August 19
@johnlobo (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1183) can you try to modify in WinGDI.c :

static DWORD WINAPI wincpct_interruptFunction(LPVOID lpParam)
{
SAmstrad* amstrad = (SAmstrad*)lpParam;
DWORD time = timeGetTime();

while (_runInterrupt)
{
if (timeGetTime() - time > INTERRUPT_MS)
{
time = timeGetTime();

if (amstrad->_internalTimer == INTERRUPT_PER_VBL)
{
amstrad->_internalTimer = 0;
SetEvent(_vsyncEvent);
wincpct_redraw();

wincpct_getAsyncJoystickState();
}

if (amstrad->_interruptFunction != NULL)
amstrad->_interruptFunction();

wincpct_renderScreen(amstrad->_internalTimer++);

SetEvent(_EndInterruptEvent);
}

wincpct_wait(5);
}

return 0;
}


If think SetEvent was misplaced :

SetEvent(_EndInterruptEvent);

Title: Re: WinCPCTelera
Post by: johnlobo on 15:24, 16 August 19
I did it... but same result... :-(  Still too fast.
Title: Re: WinCPCTelera
Post by: awergh on 15:12, 30 August 19
So I decided to play with decrunching.
Has cpct_zx7b_decrunch been fully implemented in wincpctelera (I see that cpct_zx7b_decrunch_s isn't available but I assume I can just use the other function)?


I tried using cpct_zx7b_decrunch but I get a write access violation, I haven't reproduced the issue for you yet as I wanted to know if the implementation was complete.
Title: Re: WinCPCTelera
Post by: Arnaud on 17:17, 30 August 19
Hi @awergh (http://www.cpcwiki.eu/forum/index.php?action=profile;u=249),
yes cpct_zx7b_decrunch is fully integrated in Wincpctelera and tested.

But..
.. source and destination were inverted  :)
And of course it worked well with my own test.

cpct_zx7b_decrunch(void* dest_end, const void* source_end)
dest_end and source_end are both last byte pointer of your array

Correction uploaded, could you confirm it works, please ?
Thanks,
Arnaud

Title: Re: WinCPCTelera
Post by: awergh on 02:31, 31 August 19

Hi @Arnaud (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1424)

Thanks for fixing it, yes it is working now. :) 
I am curious that it worked for you with the parameters the wrong way round as I would imagine there can't be that many situations where that would work.
Although I haven't actually looked into the algorithm to understand how it works.


Title: Re: WinCPCTelera
Post by: Arnaud on 07:34, 31 August 19
Quote from: awergh on 02:31, 31 August 19
Hi @Arnaud (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1424)

Thanks for fixing it, yes it is working now. :) 
I am curious that it worked for you with the parameters the wrong way round as I would imagine there can't be that many situations where that would work.
Although I haven't actually looked into the algorithm to understand how it works.

The parameters were inverted according to cpctelera but not wincpctelera and as my test was ok, i didn't see the problem, because my sprite was correctly deflated.

Nice ! Another important functionnality working.
Title: Re: WinCPCTelera
Post by: awergh on 15:41, 21 September 19

Hi @Arnaud (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1424)


So I discovered another decrunching problem with wincpctelera.


Turns out if you try to decrunch something twice it crashes.
In WinAPE all works fine as normal.



   cpct_zx7b_decrunch(destinationEnd, crunchedDataEnd);
   cpct_zx7b_decrunch(destinationEnd, crunchedDataEnd);



Unhandled exception at 0x77C00E43 (ntdll.dll) in wincpct_decrunch.exe: 0xC0000374: A heap has been corrupted (parameters: 0x77C3E930). occurred
Exception thrown at 0x77B66D94 (ntdll.dll) in wincpct_decrunch.exe: 0xC0000005: Access violation reading location 0xFFFFFFF8.
Unhandled exception at 0x77B66D94 (ntdll.dll) in wincpct_decrunch.exe: 0xC0000005: Access violation reading location 0xFFFFFFF8.


My full example


#include <cpctelera.h>


const u8 palette_[16] = {0x4, 0xa, 0x13, 0xc, 0x14, 0xb, 0x15, 0xd, 0x6, 0x1e, 0x1f, 0x7, 0x12, 0x19, 0x0, 0x16};


const u8 G_flower[1024] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xCF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCE, 0xCD, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x00, 0x45, 0xCE, 0xCD, 0x8A,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x22, 0x00, 0x00, 0x00, 0x45, 0xCC, 0xCC, 0x8A,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x45, 0xCC, 0xCC, 0x8A,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00, 0x45, 0xCE, 0xCC, 0x8A,
0x00, 0x11, 0x33, 0x22, 0x00, 0x00, 0x22, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0xCE, 0xCC, 0x8A,
0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x22, 0x00, 0x11, 0x22, 0x00, 0x00, 0x00, 0xCE, 0xCC, 0x8A,
0x00, 0x00, 0x00, 0x11, 0x22, 0x11, 0x22, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x67, 0xCC, 0x8A,
0x00, 0x00, 0x00, 0x00, 0x22, 0x11, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x11, 0x67, 0xCD, 0x8A,
0x00, 0x00, 0x00, 0x00, 0x33, 0x11, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x11, 0x45, 0xCD, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x11, 0x22, 0x00, 0x33, 0x45, 0xCF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x22, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x33, 0x00, 0x00, 0x00, 0x00, 0x11, 0x33, 0x22, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x11, 0x22, 0x00, 0x22, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x33, 0x22, 0x00, 0x22, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x33, 0x00, 0x00, 0x22, 0x33, 0x00, 0x00, 0x11, 0x22, 0x00, 0x11, 0x22, 0x00, 0x00,
0x00, 0x11, 0x33, 0x00, 0x00, 0x33, 0xBB, 0x00, 0x00, 0x33, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
0x00, 0x11, 0xBB, 0x00, 0x11, 0x33, 0xBB, 0x00, 0x00, 0x33, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00,
0x00, 0x33, 0xBB, 0x00, 0x33, 0x77, 0xBB, 0x00, 0x11, 0x33, 0x00, 0x11, 0x22, 0x00, 0x00, 0x00,
0x00, 0x77, 0xBB, 0x00, 0x77, 0xFF, 0x33, 0x00, 0x33, 0x33, 0x00, 0x11, 0x22, 0x00, 0x00, 0x33,
0x11, 0x77, 0xBB, 0x11, 0x77, 0xFF, 0x22, 0x00, 0x77, 0x22, 0x00, 0x33, 0x22, 0x00, 0x11, 0x22,
0x11, 0xFF, 0xBB, 0x11, 0xFF, 0xFF, 0x22, 0x00, 0x77, 0x22, 0x00, 0x33, 0x00, 0x00, 0x33, 0x00,
0x11, 0xFF, 0xBB, 0x33, 0xFF, 0xFF, 0x22, 0x00, 0x77, 0x22, 0x00, 0x33, 0x00, 0x00, 0x33, 0x00,
0x11, 0xFF, 0xBB, 0x77, 0xFF, 0xFF, 0x22, 0x11, 0x77, 0x22, 0x11, 0x33, 0x00, 0x11, 0x33, 0x00,
0x11, 0xFF, 0xBB, 0xFF, 0xFF, 0xFF, 0x22, 0x11, 0xFF, 0x22, 0x11, 0xBB, 0x00, 0x11, 0xBB, 0x00,
0x33, 0xFF, 0xBB, 0xFF, 0xFF, 0xFF, 0x22, 0x11,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, 0xB0, 0x2D, 0x83,
    0x2F, 0x6F, 0x1F, 0xDA, 0x81, 0x0F, 0x8B, 0x31, 0x0F, 0xBB, 0xCC, 0x0F, 0x7C, 0x1E, 0x00, 0x7C,
    0x45, 0x5F, 0x0F, 0x78, 0xBB, 0x0F, 0x00, 0x0F, 0x6B, 0x25, 0xDD, 0xB3, 0x48, 0xCE, 0x0F, 0x35,
    0x1D, 0x33, 0x42, 0x66, 0x67, 0xCC, 0x0F, 0xC8, 0x37, 0x0F, 0x7E, 0x9F, 0x8C, 0x67, 0xCD, 0x8A,
    0x25, 0x08, 0x0F, 0x07, 0xC3, 0x45, 0xCD, 0x0F, 0x64, 0xC8, 0x85, 0x0D, 0x45, 0xCF, 0x0F, 0x9D,
    0x11, 0x1A, 0xD1, 0x0F, 0xB8, 0xDC, 0xC2, 0xD6, 0xC2, 0x22, 0x0F, 0x5A, 0x33, 0x41, 0x0F, 0x89,
    0x04, 0xE8, 0x11, 0x0E, 0x2E, 0x0F, 0xEE, 0x03, 0xEA, 0x69, 0x12, 0x00, 0xBF, 0x16, 0x22, 0x12,
    0xAE, 0x51, 0x0F, 0xDD, 0x06, 0x0F, 0xCD, 0x11, 0x0F, 0xD4, 0x78, 0x0B, 0x6E, 0x41, 0x8E, 0x00,
    0x7B, 0x2F, 0xD1, 0x64, 0x9C, 0x0F, 0x00, 0x7B, 0xA3, 0x33, 0x06, 0xD1, 0x21, 0x12, 0x1E, 0x9F,
    0x11, 0x88, 0x60, 0x0F, 0x22, 0x53, 0x11, 0x36, 0x78, 0xE7, 0x0F, 0xA3, 0x9B, 0xB1, 0x02, 0x0F,
    0x02, 0x9F, 0x00, 0x0F, 0x7F, 0x0F, 0xF6, 0x77, 0x22, 0x02, 0x65, 0x33, 0x0C, 0x0F, 0xBD, 0x0C,
    0xB8, 0x0F, 0x8B, 0x33, 0x0F, 0x16, 0x11, 0x0F, 0xA5, 0x33, 0x02, 0x0F, 0x7A, 0x0C, 0x0F, 0xF5,
    0x11, 0x0F, 0x55, 0x00, 0xE2, 0x02, 0x33, 0x0F, 0x1B, 0xBB, 0x4C, 0xB4, 0x0F, 0x03, 0x22, 0x77,
    0x42, 0x0F, 0x72, 0x33, 0x0F, 0xAA, 0x11, 0x77, 0x0F, 0xA5, 0x0A, 0x07, 0x00, 0x06, 0x05, 0xEF,
    0x0F, 0x07, 0x37, 0x0F, 0x7C, 0x77, 0x0F, 0xB5, 0x15, 0x0A, 0xBE, 0x11, 0x25, 0x0F, 0xD2, 0x33,
    0x1A, 0xD5, 0x04, 0xB8, 0x12, 0xBB, 0x0F, 0x2B, 0x33, 0x04, 0xB4, 0xBB, 0x0F, 0x42, 0x77, 0x00,
    0x94, 0xAA, 0xFF};


const u8 compressed_flower2[284] = {
    0x58, 0x55, 0x00, 0x4D, 0x0F, 0xD0, 0x00, 0x55, 0x27, 0x0F, 0x69, 0x03, 0xE8, 0x4C, 0x0F, 0xBB,
    0x0B, 0x0F, 0x6E, 0xA0, 0x40, 0x0F, 0x46, 0x00, 0x0F, 0x36, 0xBD, 0x80, 0x72, 0x0F, 0x72, 0xEA,
    0x0F, 0x34, 0x34, 0x38, 0xC0, 0x0F, 0x02, 0xDA, 0x0F, 0x18, 0x08, 0xFD, 0x65, 0x2B, 0xDD, 0x0F,
    0x5C, 0x80, 0x0F, 0x34, 0x55, 0x0F, 0x6A, 0xD6, 0x85, 0x0B, 0x75, 0x3F, 0x18, 0x77, 0x4E, 0x0F,
    0xD7, 0x4E, 0x75, 0x0F, 0x5D, 0x20, 0x0F, 0x7D, 0x4E, 0x5D, 0xC0, 0xC0, 0x0F, 0x19, 0xFF, 0x5E,
    0xA5, 0x40, 0x80, 0x0F, 0xAC, 0x26, 0x17, 0x69, 0x0A, 0xEB, 0x4F, 0xE9, 0x0A, 0x0F, 0xFA, 0x00,
    0x55, 0x0F, 0x4A, 0xFF, 0x0F, 0x95, 0xAA, 0x0F, 0x5A, 0x06, 0x0C, 0x0F, 0xFC, 0xFF, 0x45, 0x43,
    0xA3, 0x3E, 0x23, 0xA7, 0xAA, 0x03, 0x1A, 0x07, 0x74, 0xFF, 0x0F, 0x8D, 0x44, 0x0F, 0xBE, 0x03,
    0xEA, 0x02, 0xE0, 0x0F, 0x03, 0xEE, 0x02, 0x0F, 0x7A, 0xA2, 0x03, 0x0F, 0x87, 0x23, 0x07, 0x66,
    0x0F, 0x38, 0xAA, 0x04, 0x13, 0x0F, 0xFA, 0x2E, 0x22, 0x0F, 0x37, 0xFF, 0x00, 0x33, 0x4A, 0xF2,
    0x24, 0x25, 0x0F, 0xF9, 0x24, 0x9A, 0x0A, 0x25, 0x00, 0xF9, 0x00, 0x0F, 0x4A, 0x0A, 0x7E, 0x05,
    0x0C, 0xFF, 0x55, 0x00, 0x33, 0x14, 0xC4, 0x1B, 0x35, 0xF8, 0x06, 0xAA, 0x5E, 0x6B, 0x0F, 0x57,
    0x87, 0x22, 0x0F, 0xD8, 0x11, 0x77, 0x20, 0x40, 0xAA, 0x33, 0x1A, 0x4B, 0x59, 0x9A, 0x8F, 0xB0,
    0x11, 0x03, 0x04, 0x0F, 0xDE, 0x05, 0xD5, 0x99, 0x85, 0x04, 0xC5, 0x0F, 0xFF, 0x26, 0xD7, 0x13,
    0x05, 0xE9, 0x2D, 0x5C, 0xF8, 0x72, 0x1A, 0x4C, 0xAE, 0x02, 0x62, 0x3C, 0xEF, 0x0F, 0xBA, 0x38,
    0x05, 0x0A, 0xFB, 0x36, 0x1A, 0xE3, 0x02, 0x05, 0x06, 0xFE, 0xBB, 0x06, 0x77, 0x14, 0xD6, 0x08,
    0xBB, 0x0A, 0x04, 0xEE, 0x00, 0x28, 0x03, 0xDF, 0x0F, 0x08, 0xD3, 0x13, 0x77, 0x5D, 0x10, 0x00,
    0x05, 0x3F, 0x33, 0x09, 0x4A, 0xBB, 0x33, 0x77, 0x00, 0xB1, 0x8A, 0xFF};


// Experimented with decrunching a graphic and displaying it on screen.
void main(void)
{
   u8* memory;
   
   // Location to store the decrunched graphic.
   u8 plantGraphic[1024];


   // The end of the crunched flower (arraypointer + size - 1) as a u16 pointer.
   void* crunchedDataEnd = compressed_flower2 + 284 - 1;


   // The end of the destination graphic (arraypointer + size - 1) as a u16 pointer.
   void* destinationEnd = plantGraphic + 1024 - 1;


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


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


   cpct_setPalette(palette_, 16);


   memory = cpct_getScreenPtr(CPCT_VMEM_START, 4, 4);


   // Decrunch the crunched flower into the destination array
#ifdef WINCPCTELERA
   cpct_zx7b_decrunch(destinationEnd, crunchedDataEnd);


   cpct_zx7b_decrunch(destinationEnd, crunchedDataEnd);
#else
   cpct_zx7b_decrunch_s(destinationEnd, crunchedDataEnd);


   cpct_zx7b_decrunch_s(destinationEnd, crunchedDataEnd);
#endif


   // Draw the plant graphic continaing the decrunched flower.
   cpct_drawSprite(plantGraphic, memory, 16, 64);


   // Loop forever
   while (1);
}


Title: Re: WinCPCTelera
Post by: Arnaud on 16:12, 21 September 19
Hi @awergh (http://www.cpcwiki.eu/forum/index.php?action=profile;u=249), 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 :)





Title: Re: WinCPCTelera
Post by: 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 .
Title: Re: WinCPCTelera
Post by: Arnaud on 16:28, 21 September 19
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.
Title: Re: WinCPCTelera
Post by: 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?
Title: Re: WinCPCTelera
Post by: Arnaud on 17:46, 17 November 19
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.
Title: Re: WinCPCTelera
Post by: 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
Title: Re: WinCPCTelera
Post by: Arnaud on 19:48, 18 November 19
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 ?
Title: Re: WinCPCTelera
Post by: awergh on 08:16, 19 November 19
Quote from: Arnaud on 19:48, 18 November 19
Repo updated.
Can you try if it works now please ?


All good now  :)
Title: Re: WinCPCTelera
Post by: funkheld on 09:04, 20 November 19

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
Title: Re: WinCPCTelera
Post by: awergh on 14:02, 11 August 20
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, 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2A, 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)
   {
       
   }
}
Title: Re: WinCPCTelera
Post by: Arnaud on 14:16, 11 August 20
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.
Title: Re: WinCPCTelera
Post by: 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.



#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)
   {
       
   }
}
Title: Re: WinCPCTelera
Post by: Arnaud on 19:33, 11 August 20
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.
Title: Re: WinCPCTelera
Post by: 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  :)
Title: Re: WinCPCTelera
Post by: Arnaud on 20:47, 11 August 20
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.
Title: Re: WinCPCTelera
Post by: teopl on 21:04, 11 August 20
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 :)
Title: Re: WinCPCTelera
Post by: 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.
Title: Re: WinCPCTelera
Post by: Arnaud on 14:59, 12 August 20
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  :)
Title: Re: WinCPCTelera
Post by: Arnaud on 10:12, 13 August 20
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.
Title: Re: WinCPCTelera
Post by: funkheld on 10:19, 13 August 20

hello, that is good.


thank you.
greeting
Title: Re: WinCPCTelera
Post by: Arnaud on 10:43, 13 August 20
 :)
[attach=1]
Title: Re: WinCPCTelera
Post by: awergh on 12:33, 13 August 20
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.
Title: Re: WinCPCTelera
Post by: Arnaud on 19:29, 13 August 20
Repository updated, all is OK with my projects.
Title: Re: WinCPCTelera
Post by: teopl on 20:58, 13 August 20
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... :)
Title: Re: WinCPCTelera
Post by: funkheld on 08:02, 14 August 20

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


greeting
Title: Re: WinCPCTelera
Post by: Arnaud on 08:20, 14 August 20
Quote from: teopl on 20:58, 13 August 20
What else can cause lag - input, drawing, some thread being stuck... I don't know

Can you send me your wincpctelera project including your game code, i really don't understand what slow down your game.

Quote from: funkheld on 08:02, 14 August 20
I think we windows users want to play with wincpctelera and not debug. here an equivalence should be established between cpctelera and wincpctelera.

I'm agree, but this is not an emulator just an API for windows and reproduce the CPC timing is this way is really hard. But the source code is provided if anybody can see how improve it, it will be welcome :)




Well it's not perfect but playable and with some manual tempos tweaks it can reaches something near of CPC speed. It's what i'm doing when it's too fast.
Title: Re: WinCPCTelera
Post by: awergh on 14:02, 14 August 20
Decrunching to video memory works great  :) , but there are some other graphical issues.
Looking at my previous projects I have similar issues with all of them but on a positive note I see that the scrolling works for my first game.


Last years game seems to move really fast as well, it is not just graphically off.



Title: Re: WinCPCTelera
Post by: Arnaud on 17:24, 14 August 20
Thanks a lot to send me your project, with it i fixed a some bugs and i made wincpctelera x64 compatible.

Testing is in progress but background color is fixed and the speed is slow down.
Title: Re: WinCPCTelera
Post by: teopl on 21:14, 14 August 20
Quote from: Arnaud on 08:20, 14 August 20Can you send me your wincpctelera project including your game code, i really don't understand what slow down your game.

Like most people I also lack time to finish the project and to debug in more detail. Until then windows port is not in my focus, but thanks for your help, I will probably need it at some point and contact you :)
Title: Re: WinCPCTelera
Post by: Arnaud on 09:55, 15 August 20
Repo updated :
- Fix cpct_px2byteM0 and cpct_px2byteM1 (now it's same pixel encoding as cpctelera)
- Slow down sprite display
- Fix x64 warning compilation

Tested with fitzroy 3 and 4, DeeperWarrens and my current cpcretrodev project.
Title: Re: WinCPCTelera
Post by: awergh on 14:11, 15 August 20
My new project now looks right now.
Fitzroy 3 feels like everything is working as it should.
In Fitzroy 4 it looks right but I move multiple times instead of once with each key press making the game unplayable.
In 1 and 2 on the menus you cannot see which item is selected.
Also in 2 the hud appears to be the wrong colour (not matching the background).

I am guessing you haven't updated cpct_drawStringM0 following your changes.
I don't use it in my games any more so thats why its not a problem for my newer games.
Title: Re: WinCPCTelera
Post by: Arnaud on 07:13, 16 August 20
 
Quote from: awergh on 14:11, 15 August 20
I am guessing you haven't updated cpct_drawStringM0 following your changes.
I don't use it in my games any more so thats why its not a problem for my newer games.
Yes the cpct_drawString functions have changed in cpctelera 1.5.0, but with code correction the menu seems OK
[attach=1,msg191265]

Quote from: awergh on 14:11, 15 August 20In Fitzroy 4 it looks right but I move multiple times instead of once with each key press making the game unplayable.
I can't found the right temporisation in draw functions because if there are too many calls the game will be too slow. In this case the only good solution is to put a manual tempo in main loop.


Well good news, no more bug  :D
Title: Re: WinCPCTelera
Post by: awergh on 08:44, 16 August 20
Looks good  :) .

It occurs to me that 1,2 were using cpctelera 1.4.0 and 3 was 1.4.2 and only 4 was on a version of 1.5.
That suggests to me that the API has been very stable.
I can see merit in updating projects to the latest version but I haven't really seen much need.

Perhaps there is a way you could allow the speed to be tuned as a wincpctelera specific function or something.
Or I could just put a dodgy wait in to fix the problem.
That said because it is last years project I am not really likely to touch it again unless I wanted to port it to another platform or something.
Title: Re: WinCPCTelera
Post by: Arnaud on 17:00, 16 August 20
Quote from: awergh on 08:44, 16 August 20Perhaps there is a way you could allow the speed to be tuned as a wincpctelera specific function or something.
Or I could just put a dodgy wait in to fix the problem.

I could create a Wincpetelera function helper WinCpcTelera_Slowdown() but it would be nearly the same function as WinCpcTelera_Wait(X).
And put a wait in the main loop could solve speed problem and it's not that horrible  :D
Title: Re: WinCPCTelera
Post by: awergh on 05:59, 01 July 23
Hi @Arnaud, I thought it was time to update my cpctelera\wincpctelera installs and it looks like there are some files missing in the latest commit on github.

Currently I cannot build the solution because these files are missing.
_helper\wincpctelera_loader.c
_compressors\zx1\wincpct\ZX1Decrunch.c
_compressors\zx1\wincpct\ZX1Decrunch.h
Title: Re: WinCPCTelera
Post by: Arnaud on 06:44, 01 July 23
Hi @awergh,
some local files not commited (i feel like at work :D), thank for reporting.
Title: Re: WinCPCTelera
Post by: Typhon on 16:47, 22 November 23
I'm currently stepping into the world of CPCTelera development but on Linux, and WinCPCTelera would be very useful for me if I ported it to Linux and use either SDL or SFML (I'm much more familiar with the latter). So I might have a look to see if that is doable. 
Title: Re: WinCPCTelera
Post by: robcfg on 16:51, 22 November 23
While I think that being able to make it work on Linux (and MacOS probably as a bonus) it's a good thing, maybe it would be faster for you to run it under Wine.

Edit: I see that it already works with SDL (https://github.com/Arnaud6128/wincpctelera), so it may be an easy port.
Powered by SMFPacks Menu Editor Mod