Initial commit

This commit is contained in:
Sylvain PILLOT 2022-05-13 09:34:06 +02:00
commit fc5995cb69
23 changed files with 375 additions and 0 deletions

32
CMakeLists.txt Normal file
View File

@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.15)
project(MyAddin)
include(GenerateG3A)
include(Fxconv)
find_package(Gint 2.7.1 REQUIRED)
find_package(LibProf 2.4 REQUIRED)
set(SOURCES
src/main.c
# ...
)
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets
set(ASSETS
# ...
)
set(ASSETS_cg
assets-cg/example.png
# ...
)
fxconv_declare_assets(${ASSETS} ${ASSETS_cg} WITH_METADATA)
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}})
target_compile_options(myaddin PRIVATE -Wall -Wextra -Os)
target_link_libraries(myaddin LibProf::LibProf Gint::Gint -lSDL_image_prizm -lcJPG -lcPNG -lczlib -lSDL_prizm)
if("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
generate_g3a(TARGET myaddin OUTPUT "Lumines.g3a"
NAME "Lumines" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
endif()

BIN
Lumines.g3a Normal file

Binary file not shown.

BIN
Lumines.tar.gz Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
Lumines/Blocks/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# WIP for creating a Lumines (to be pronounced Loo-Mi-Nes) for the Casio PRISM CG10/20/50 serie
This port recreated from scratch is based on the "brand new" `SDL 1.2` library just ported to that plateform.
This is a work in progress, some new should come very soon.
So stay tuned ...

22
SDL_Lumines.cbp Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="cSDL_imageApp" />
<Option pch_mode="2" />
<Option compiler="null" />
<Build>
<Target title="Release">
<Option output="bin/Release/cSDL_imageApp" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="null" />
</Target>
</Build>
<Unit filename="CMakeLists.txt" />
<Unit filename="src/main.c">
<Option compilerVar="CC" />
</Unit>
<Extensions />
</Project>
</CodeBlocks_project_file>

BIN
assets-cg/example.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -0,0 +1,3 @@
example.png:
type: bopti-image
name: img_example

BIN
assets-cg/icon-sel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
assets-cg/icon-uns.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
assets-fx/example.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1,3 @@
example.png:
type: bopti-image
name: img_example

BIN
assets-fx/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

3
build Executable file
View File

@ -0,0 +1,3 @@
rm -r build-cg
rm *.g3a
fxsdk build-cg VERBOSE=1

1
capture Executable file
View File

@ -0,0 +1 @@
fxlink -iw --quiet --fxlink-log=MyLogFile.log

2
clean Executable file
View File

@ -0,0 +1,2 @@
rm -r build-cg/
rm *.g3a

1
correct Executable file
View File

@ -0,0 +1 @@
fxsdk build-cg VERBOSE=1

BIN
icon-sel.xcf Normal file

Binary file not shown.

1
send Executable file
View File

@ -0,0 +1 @@
fxlink -sw -u *.g3a

300
src/main.c Normal file
View File

@ -0,0 +1,300 @@
#include <gint/gint.h>
#include <gint/hardware.h>
#include <gint/kmalloc.h>
#include <gint/display.h>
#include <libprof.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_gfxPrimitives.h>
#include <SDL/SDL_image.h>
#define GRID_H 10
#define GRID_W 16
#define CELL_SIZE 15
#define SCREEN_W 396
#define SCREEN_H 224
#define GRID_CENTER_X (SCREEN_W/2-40)
#define GRID_Y (SCREEN_H-14)
SDL_Surface* screen = NULL;
SDL_Surface* background = NULL;
SDL_Surface* blocks = NULL;
cSDL_Font *font;
typedef struct
{
char color;
} block;
block GridBoard[GRID_W][GRID_H];
uint32_t timerstart=0;
uint32_t currenttimer=0;
float currentX=0;
uint32_t time_frame=0;
void drawGrid( SDL_Surface *surf )
{
for(int x=0; x<GRID_W/2; x++)
{
for(int y=0; y<GRID_H; y++)
{
rectangleRGBA( surf, GRID_CENTER_X-x*CELL_SIZE, GRID_Y-y*CELL_SIZE, GRID_CENTER_X-(x+1)*CELL_SIZE, GRID_Y-(y+1)*CELL_SIZE, 0, 0, 0, 255 );
rectangleRGBA( surf, GRID_CENTER_X+x*CELL_SIZE, GRID_Y-y*CELL_SIZE, GRID_CENTER_X+(x+1)*CELL_SIZE, GRID_Y-(y+1)*CELL_SIZE, 0, 0, 0, 255 );
}
}
for(int x=0; x<=GRID_W/2; x++)
{
for(int y=0; y<=GRID_H; y++)
{
rectangleRGBA( surf, GRID_CENTER_X-x*CELL_SIZE-1, GRID_Y-y*CELL_SIZE-1, GRID_CENTER_X-x*CELL_SIZE+1, GRID_Y-y*CELL_SIZE+1, 0, 0, 0, 255 );
rectangleRGBA( surf, GRID_CENTER_X+x*CELL_SIZE-1, GRID_Y-y*CELL_SIZE-1, GRID_CENTER_X+x*CELL_SIZE+1, GRID_Y-y*CELL_SIZE+1, 0, 0, 0, 255 );
}
}
rectangleRGBA(surf, GRID_CENTER_X-GRID_W/2*CELL_SIZE-1, GRID_Y-GRID_H*CELL_SIZE-1, GRID_CENTER_X+GRID_W/2*CELL_SIZE+1, GRID_Y+1, 0, 0, 0, 255 );
}
void drawBlock( SDL_Surface *surf, unsigned int cellX, unsigned int cellY, unsigned char blockColor )
{
SDL_Rect srcrect, dstrect;
int theme = blockColor / 2;
if (blockColor%2==0)
{
srcrect.x = theme*15;
srcrect.y = 0;
srcrect.h = 14;
srcrect.w = 14;
}
else
{
srcrect.x = theme*15;
srcrect.y = 15;
srcrect.h = 14;
srcrect.w = 14;
}
dstrect.x = GRID_CENTER_X-GRID_W/2*CELL_SIZE+cellX*CELL_SIZE+1;
dstrect.y = GRID_Y-(cellY+1)*CELL_SIZE+1;
dstrect.h = 14;
dstrect.w = 14;
SDL_BlitSurface(blocks, &srcrect, surf, &dstrect);
}
void drawBackground( SDL_Surface *surf )
{
SDL_BlitSurface(background, NULL, surf, NULL);
}
void drawSweepLine( SDL_Surface *surf, uint32_t deltat, uint8_t speed, float *currentpositionX )
{
float x = *currentpositionX;
x+=(float) (deltat*speed)/100.0f;
if (x>GRID_W*CELL_SIZE) x=0;
*currentpositionX=x;
lineRGBA( surf, GRID_CENTER_X-GRID_W/2*CELL_SIZE+x-1, GRID_Y-GRID_H*CELL_SIZE-1, GRID_CENTER_X-GRID_W/2*CELL_SIZE+x-1, GRID_Y+1, 255, 0, 0, 255 );
lineRGBA( surf, GRID_CENTER_X-GRID_W/2*CELL_SIZE+x, GRID_Y-GRID_H*CELL_SIZE-1, GRID_CENTER_X-GRID_W/2*CELL_SIZE+x, GRID_Y+1, 255, 0, 0, 255 );
lineRGBA( surf, GRID_CENTER_X-GRID_W/2*CELL_SIZE+x+1, GRID_Y-GRID_H*CELL_SIZE-1, GRID_CENTER_X-GRID_W/2*CELL_SIZE+x+1, GRID_Y+1, 255, 0, 0, 255 );
}
void initBoard( void )
{
srand( 0 );
for(int x=0; x<GRID_W; x++)
{
for(int y=0; y<GRID_H; y++)
{
GridBoard[x][y].color = (char) rand()%10;
if (GridBoard[x][y].color<0) GridBoard[x][y].color=0;
if (GridBoard[x][y].color>9) GridBoard[x][y].color=9;
}
}
}
void drawBlockGrid( SDL_Surface *surf )
{
for(int x=0; x<GRID_W; x++)
{
for(int y=0; y<GRID_H; y++)
{
drawBlock( surf, x, y, (int) GridBoard[x][y].color );
}
}
}
bool canWeAllocate3Mb = false;
void increaseRAM( void )
{
char const *osv = (char*) 0x80020020;
static kmalloc_arena_t extended_ram = { 0 };
if((!strncmp(osv, "03.", 3) && osv[3] <= '6') && gint[HWCALC] == HWCALC_FXCG50) // CG-50
{
extended_ram.name = "extram";
extended_ram.is_default = true;
extended_ram.start = (void *)0x8c200000;
extended_ram.end = (void *)0x8c500000 ;
kmalloc_init_arena(&extended_ram, true);
kmalloc_add_arena(&extended_ram );
canWeAllocate3Mb = true;
}
else if (gint[HWCALC] == HWCALC_PRIZM) // CG-10/20
{
extended_ram.name = "extram";
extended_ram.is_default = true;
uint16_t *vram1, *vram2;
dgetvram(&vram1, &vram2);
dsetvram(vram1, vram1);
extended_ram.start = vram2;
extended_ram.end = (char *)vram2 + 396*224*2;
kmalloc_init_arena(&extended_ram, true);
kmalloc_add_arena(&extended_ram );
canWeAllocate3Mb = false;
}
else if (gint[HWCALC] == HWCALC_FXCG_MANAGER) // CG-50 EMULATOR
{
extended_ram.name = "extram";
extended_ram.is_default = true;
extended_ram.start = (void *)0x88200000;
extended_ram.end = (void *)0x88500000 ;
kmalloc_init_arena(&extended_ram, true);
kmalloc_add_arena(&extended_ram );
canWeAllocate3Mb = true;
}
else abort();
}
int main ( int argc, char** argv )
{
increaseRAM();
prof_init();
prof_t perf;
if (SDL_Init(SDL_INIT_VIDEO)<0) return 1;
SDL_ShowCursor(SDL_DISABLE);
screen = SDL_SetVideoMode(396, 224, 16, SDL_SWSURFACE);
//if (!screen) return 1;
IMG_Init( IMG_INIT_PNG | IMG_INIT_JPG );
font = cSDL_LoadFont(cSDL_FONT_THIN, 0, 255, 0);
background = SDL_ConvertSurface( (SDL_Surface*) gint_world_switch( GINT_CALL( IMG_Load, "./Lumines/Backgrounds/back003.jpg" ) ),
screen->format, SDL_SWSURFACE );
//if (!background) return 1;
blocks = SDL_ConvertSurface( (SDL_Surface*) gint_world_switch( GINT_CALL( IMG_Load, "./Lumines/Blocks/test.png" ) ),
screen->format, SDL_SWSURFACE );
//if (!blocks) return 1;
initBoard( );
timerstart=0;
bool done = false;
while (!done)
{
perf = prof_make();
prof_enter(perf);
currenttimer=SDL_GetTicks();
uint32_t deltatimer = currenttimer-timerstart;
timerstart=currenttimer;
// message processing loop
SDL_Event event;
while (SDL_PollEvent(&event))
{
// check for messages
switch (event.type)
{
// exit if the window is closed
case SDL_QUIT:
done = true;
break;
// check for keypresses
case SDL_KEYDOWN:
{
// exit if ESCAPE is pressed
if (event.key.keysym.sym == SDLK_PRZ_KEY_EXIT)
done = true;
break;
}
} // end switch
} // end of message processing
//SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 127, 127, 127));
drawBackground( screen );
drawGrid( screen );
/* drawBlock( screen, 0, 0, 0 );
drawBlock( screen, 0, 1, 1 );
drawBlock( screen, 2, 0, 2 );
drawBlock( screen, 2, 1, 3 );
drawBlock( screen, 4, 0, 4 );
drawBlock( screen, 4, 1, 5 );
drawBlock( screen, 6, 0, 6 );
drawBlock( screen, 6, 1, 7 );
drawBlock( screen, 8, 0, 8 );
drawBlock( screen, 8, 1, 9 );
*/
drawBlockGrid( screen );
drawSweepLine( screen, deltatimer, 10, &currentX );
cSDL_DrawString( screen, font, 10, 10, "Delta t: %d", time_frame/1000 );
cSDL_DrawString( screen, font, 10, 20, "Hello !!" );
SDL_Flip(screen);
prof_leave(perf);
time_frame = prof_time(perf);
} // end main loop
SDL_FreeSurface( blocks );
SDL_FreeSurface( background );
cSDL_FreeFont( font );
SDL_Quit();
return 0;
}