News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Arnaud

WinCPCTelera

Started by Arnaud, 20:58, 29 September 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Arnaud

#75
Hi  @awergh,
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).


awergh

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.

Arnaud

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



awergh

#78
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);
}




Arnaud

Hello @awergh,
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.

awergh

#80
Hi @Arnaud
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);
}

johnlobo


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.


Arnaud

Hi @johnlobo,
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

awergh


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)


johnlobo

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


Arnaud

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.

johnlobo

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.

Arnaud

Hi @johnlobo,
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.

johnlobo

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.




Arnaud

Hi,
cpct_waitHalts added and tested.

Can you confirm it works also for your code ?


johnlobo

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??




Arnaud

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




johnlobo


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.



Arnaud

#93
@johnlobo 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);


johnlobo

I did it... but same result... :-(  Still too fast.

awergh

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.

Arnaud

#96
Hi @awergh,
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


awergh

#97

Hi @Arnaud

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.



Arnaud

Quote from: awergh on 02:31, 31 August 19
Hi @Arnaud

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.

awergh


Hi @Arnaud


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, 0xFF, 0x22, 0x11, 0xBB, 0x00, 0x33, 0xBB, 0x00,
0x77, 0xFF, 0xBB, 0xFF, 0xFF, 0xFF, 0x22, 0x11, 0xFF, 0x22, 0x11, 0xBB, 0x00, 0x77, 0xBB, 0x00,
0x77, 0xFF, 0xBB, 0xFF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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);
}



Powered by SMFPacks Menu Editor Mod