Author Topic: WinCPCTelera  (Read 11206 times)

0 Members and 1 Guest are viewing this topic.

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
WinCPCTelera
« on: 22: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   


* platform.png
(5.09 kB, 386x327 - viewed 432 times)
 

* pixmove.png
(13.47 kB, 300x248 - viewed 802 times)

* spacemoves.png
(8.77 kB, 386x327 - viewed 440 times)
 [ Invalid Attachment ]

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
« Last Edit: 21:38, 25 October 16 by Arnaud »

Offline AugustoRuiz

  • CPC664
  • ***
  • Posts: 121
  • Country: es
  • Liked: 156
  • Likes Given: 49
Re: WinCPCTelera
« Reply #1 on: 23:02, 29 September 16 »
This is SO great to do quick testing with debug!!!! Omfg!!!

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #2 on: 23:05, 29 September 16 »
This is SO great to do quick testing with debug!!!! Omfg!!!

Yes, you understand exactly why i'm working on it  ;)

Offline AugustoRuiz

  • CPC664
  • ***
  • Posts: 121
  • Country: es
  • Liked: 156
  • Likes Given: 49
Re: WinCPCTelera
« Reply #3 on: 23:07, 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


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!

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #4 on: 23:13, 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


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.
 
« Last Edit: 23:18, 29 September 16 by Arnaud »

Offline AugustoRuiz

  • CPC664
  • ***
  • Posts: 121
  • Country: es
  • Liked: 156
  • Likes Given: 49
Re: WinCPCTelera
« Reply #5 on: 23: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)

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #6 on: 15:09, 30 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.

Offline awergh

  • CPC6128
  • ****
  • Posts: 238
  • Country: au
  • Liked: 95
  • Likes Given: 196
Re: WinCPCTelera
« Reply #7 on: 17: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

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #8 on: 22:51, 01 October 16 »
Now mode 1 et mode 2 are working, here a great picture to show it  ;)

 
* winSDL.zip
(2.67 kB - downloaded 130 times)


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

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.
« Last Edit: 22:59, 01 October 16 by Arnaud »

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #9 on: 10: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 :

 [ Invalid Attachment ]

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #10 on: 22:23, 03 October 16 »
BitArray are now working, and a nasty bug of conversion from CPC memory video to screen coordinates is now corrected.


* bitArray1.png
(5.67 kB, 770x615 - viewed 306 times)
 [ Invalid Attachment ]

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #11 on: 22: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


* flipMode2.png
(11.83 kB, 770x615 - viewed 312 times)

* blend.png
(15.09 kB, 770x615 - viewed 305 times)


Sprite Blend seems to work :

 [ Invalid Attachment ]
« Last Edit: 23:44, 04 October 16 by Arnaud »

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #12 on: 23:13, 05 October 16 »
Double-buffer example is working, and simple tilemap is also working.


* tilemap.png
(7.15 kB, 770x615 - viewed 298 times)

* scrollhw.png
(12.55 kB, 770x615 - viewed 309 times)


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:

 [ Invalid Attachment ]

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #13 on: 16: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

Code: [Select]
#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
« Last Edit: 22:42, 08 October 16 by Arnaud »

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #14 on: 22: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.

 [ Invalid Attachment ]

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 ?)
« Last Edit: 23:15, 08 October 16 by Arnaud »

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #15 on: 17:25, 15 October 16 »
The flip masked sprite is working with a little example (animated) :

 [ Invalid Attachment ]

Also remove const attribute from generated sprites and palette, no write exception with vc++ now.
« Last Edit: 12:09, 16 October 16 by Arnaud »

Offline AmstradGamer

  • CPC464
  • **
  • Posts: 5
  • Country: es
  • Liked: 3
  • Likes Given: 13
Re: WinCPCTelera
« Reply #16 on: 19:19, 16 October 16 »
This is GREAT.  :o

Offline awergh

  • CPC6128
  • ****
  • Posts: 238
  • Country: au
  • Liked: 95
  • Likes Given: 196
Re: WinCPCTelera
« Reply #17 on: 13: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  :) ?

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #18 on: 15:02, 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.
« Last Edit: 15:07, 21 October 16 by Arnaud »

Offline awergh

  • CPC6128
  • ****
  • Posts: 238
  • Country: au
  • Liked: 95
  • Likes Given: 196
Re: WinCPCTelera
« Reply #19 on: 15:04, 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.



Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #20 on: 15:08, 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.
« Last Edit: 15:10, 21 October 16 by Arnaud »

Offline awergh

  • CPC6128
  • ****
  • Posts: 238
  • Country: au
  • Liked: 95
  • Likes Given: 196
Re: WinCPCTelera
« Reply #21 on: 15:17, 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.

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #22 on: 21: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  :)

Offline cpcuser

  • CPC664
  • ***
  • Posts: 73
  • Country: de
  • Liked: 15
  • Likes Given: 0
Re: WinCPCTelera
« Reply #23 on: 10:33, 26 October 16 »

Hi good afternoon.


Does it CPCTelera also work with the SDCC?


Thank you.Greeting

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 546
  • Country: fr
  • Liked: 456
  • Likes Given: 883
Re: WinCPCTelera
« Reply #24 on: 14:07, 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.