News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Arnaud

WinCPCTelera

Started by Arnaud, 20:58, 29 September 16

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Arnaud

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]

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

AugustoRuiz

This is SO great to do quick testing with debug!!!! Omfg!!!

Arnaud

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  ;)

AugustoRuiz

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


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!

Arnaud

#4
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


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.

AugustoRuiz

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)

Arnaud

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.

awergh

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

Arnaud

#8
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.

Arnaud

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]

Arnaud

BitArray are now working, and a nasty bug of conversion from CPC memory video to screen coordinates is now corrected.

[attach=2] [attach=3]

Arnaud

#11
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]

Arnaud

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]

Arnaud

#13
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

Arnaud

#14
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 ?)

Arnaud

#15
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.

AmstradGamer

This is GREAT.  :o

awergh

This continues to look really good.
Any chance you can resolve the distribution issue so I can play with a newer version  :) ?

Arnaud

#18
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.

awergh

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.



Arnaud

#20
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.

awergh

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.

Arnaud

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  :)

cpcuser


Hi good afternoon.


Does it CPCTelera also work with the SDCC?


Thank you.Greeting

Arnaud

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.


Powered by SMFPacks Menu Editor Mod