aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgameblabla2017-12-26 20:53:38 -0500
committergameblabla2017-12-26 20:53:38 -0500
commitcb8a6ed34f2689f0dc862e3a9fa780074bd7cb20 (patch)
tree1803c1f8eb5e69b7d4231de57c94c1f3c2fc2464 /src
parentd1a7f112382fcc4a58de8617271298d8b9ec1fdc (diff)
downloadhydracastlelabyrinth-cb8a6ed34f2689f0dc862e3a9fa780074bd7cb20.tar.gz
hydracastlelabyrinth-cb8a6ed34f2689f0dc862e3a9fa780074bd7cb20.tar.bz2
hydracastlelabyrinth-cb8a6ed34f2689f0dc862e3a9fa780074bd7cb20.zip
GCW0 & DC commits
Diffstat (limited to 'src')
-rw-r--r--src/dreamcast_icon.h37
-rw-r--r--src/game.c126
-rw-r--r--src/ini.c9
-rw-r--r--src/main.c4
-rw-r--r--src/sdl/audio.c2
-rw-r--r--src/sdl/input.c9
6 files changed, 183 insertions, 4 deletions
diff --git a/src/dreamcast_icon.h b/src/dreamcast_icon.h
new file mode 100644
index 0000000..1e1ed7c
--- /dev/null
+++ b/src/dreamcast_icon.h
@@ -0,0 +1,37 @@
+unsigned short vmu_icon_pal[] = {
+0xF000, 0xF800, 0xFF00, 0xFFF0, 0xFFFF, 0xF000, 0xF000, 0xF000, 0xF000, 0xF000, 0xF000, 0xF000, 0xF000, 0xF000, 0xF000, 0xF000, };
+
+unsigned char vmu_icon_img[] = {
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x01,0x41,0x00,0x00,0x14,0x10,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x14,0x41,0x00,0x00,0x14,0x41,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x01,0x44,0x41,0x00,0x00,0x14,0x44,0x10,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x14,0x24,0x41,0x00,0x00,0x14,0x42,0x41,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x14,0x44,0x44,0x10,0x01,0x44,0x44,0x41,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x01,0x34,0x44,0x11,0x00,0x00,0x11,0x44,0x43,0x10,0x00,0x00,0x00,
+0x00,0x00,0x00,0x01,0x34,0x44,0x10,0x00,0x00,0x01,0x44,0x43,0x10,0x00,0x00,0x00,
+0x00,0x00,0x00,0x01,0x33,0x33,0x10,0x00,0x00,0x01,0x33,0x33,0x10,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x13,0x33,0x31,0x00,0x00,0x13,0x33,0x31,0x00,0x00,0x00,0x00,
+0x00,0x00,0x11,0x11,0x13,0x33,0x33,0x11,0x11,0x33,0x33,0x31,0x11,0x11,0x00,0x00,
+0x00,0x01,0x33,0x33,0x11,0x33,0x33,0x32,0x23,0x33,0x33,0x11,0x33,0x33,0x10,0x00,
+0x00,0x13,0x32,0x33,0x33,0x23,0x33,0x33,0x33,0x33,0x32,0x33,0x33,0x23,0x31,0x00,
+0x01,0x33,0x33,0x33,0x33,0x32,0x33,0x34,0x43,0x33,0x23,0x33,0x33,0x33,0x33,0x10,
+0x00,0x11,0x13,0x33,0x33,0x33,0x23,0x34,0x43,0x32,0x33,0x33,0x33,0x31,0x11,0x00,
+0x00,0x00,0x13,0x11,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x11,0x31,0x00,0x00,
+0x00,0x00,0x01,0x00,0x13,0x33,0x33,0x11,0x11,0x33,0x33,0x31,0x00,0x10,0x00,0x00,
+0x00,0x00,0x00,0x00,0x12,0x33,0x31,0x11,0x11,0x13,0x33,0x21,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x01,0x23,0x11,0x41,0x14,0x11,0x32,0x10,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x01,0x22,0x11,0x41,0x14,0x11,0x22,0x10,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x01,0x22,0x11,0x44,0x44,0x11,0x22,0x10,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x12,0x22,0x31,0x14,0x41,0x13,0x22,0x21,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x12,0x22,0x23,0x11,0x11,0x32,0x22,0x21,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x01,0x22,0x22,0x22,0x33,0x33,0x22,0x22,0x22,0x10,0x00,0x00,0x00,
+0x00,0x00,0x00,0x01,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x10,0x00,0x00,0x00,
+0x00,0x00,0x00,0x01,0x22,0x12,0x22,0x22,0x22,0x22,0x21,0x22,0x10,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x12,0x21,0x12,0x22,0x22,0x21,0x12,0x21,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x01,0x22,0x21,0x11,0x11,0x12,0x22,0x10,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x12,0x10,0x00,0x00,0x01,0x21,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+};
diff --git a/src/game.c b/src/game.c
index c1f74d1..21076a6 100644
--- a/src/game.c
+++ b/src/game.c
@@ -13,6 +13,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef DREAMCAST
+#include <zlib/zlib.h>
+#include "dreamcast_icon.h"
+int DC_LoadVMU(void);
+int DC_SaveVMU(void);
+#endif
int gameStep();
void gameDraw(char doDrawHud);
@@ -80,6 +86,10 @@ void game()
strcpy(savename, "data/save.tmp");
strcpy(savemap, savemap);
}
+ #ifdef DREAMCAST
+ strcpy(savename, "/ram/save.tmp");
+ strcpy(savemap, "/ram/save.map");
+ #endif
#endif
//Setup services
PHL_Init();
@@ -1412,6 +1422,9 @@ int writeSave(char* fname)
#ifdef _3DS
strcat(fullPath, "sdmc:/3ds/appdata/HydraCastleLabyrinth/");
#endif
+ #ifdef DREAMCAST
+ strcpy(fullPath, "/ram/");
+ #endif
strcat(fullPath, fname);
if ( (f = fopen(fullPath, "wb")) ) {
@@ -1480,6 +1493,10 @@ int writeSave(char* fname)
fclose(f);
}
+ #ifdef DREAMCAST
+ DC_SaveVMU();
+ #endif
+
return result;
}
@@ -1487,11 +1504,18 @@ void loadSave(char* fname)
{
FILE* f;
+ #ifdef DREAMCAST
+ DC_LoadVMU();
+ #endif
+
char fullPath[128];
strcpy(fullPath, "");
#ifdef _3DS
strcat(fullPath, "sdmc:/3ds/appdata/HydraCastleLabyrinth/");
#endif
+ #ifdef DREAMCAST
+ strcat(fullPath, "/ram/");
+ #endif
strcat(fullPath, fname);
if ((f = fopen(fullPath, "rb"))) {
@@ -1676,4 +1700,104 @@ void loadUncommonImages()
if (level == 7 || level == 8) {
images[imgMisc6020] = PHL_LoadQDA("chr60x20.bmp");
}
-} \ No newline at end of file
+}
+
+
+#ifdef DREAMCAST
+int DC_LoadVMU(void) {
+
+ unsigned long unzipsize;
+ uint8* unzipdata;
+ vmu_pkg_t pkg;
+
+ // Name of the file to open
+ file_t fd;
+ if ((fd = fs_open("/vmu/a1/hydracas", O_RDONLY)) == -1)
+ {
+ printf("error opening VMU A1, not found.\n");
+ return -1;
+ }
+
+ // Remove VMU header
+ vmu_pkg_parse(fs_mmap(fd), &pkg);
+
+ // Allocate memory for the uncompressed data
+ unzipdata = (uint8 *)malloc(524288); //512KB
+ unzipsize = 524288;
+ uncompress(unzipdata, &unzipsize, (uint8 *)pkg.data, pkg.data_len);
+
+ // Save buffer into a RAM file
+ fs_close(fd);
+
+ file_t fd2;
+ if ((fd2 = fs_open("/ram/save.map", O_WRONLY)) == -1)
+ {
+ printf("Can't create RAM file from VMU.\n");
+ return -1;
+ }
+ fs_write(fd2, unzipdata, unzipsize);
+ fs_close(fd2);
+
+ // Free unused memory
+ free(unzipdata);
+
+ return 0;
+}
+
+int DC_SaveVMU(void) {
+ vmu_pkg_t pkg;
+ uint8 *pkg_out;
+ int pkg_size;
+ file_t ft;
+
+ // Temporal for reading the file
+ file_t file;
+ int data_size;
+ unsigned long zipsize = 0;
+ uint8 *datasave;
+ uint8 *zipdata;
+
+ // Open file and copy to buffer
+ file = fs_open("/ram/save.map", O_RDONLY);
+ data_size = fs_total(file);
+ datasave = (uint8 *)malloc(data_size+1);
+ fs_read(file, datasave, data_size);
+ fs_close(file);
+
+ // Allocate some memory for compression
+ zipsize = data_size * 2;
+ zipdata = (uint8*)malloc(zipsize);
+
+ // The compressed save
+ compress(zipdata, &zipsize, datasave, data_size);
+
+ // Make the package to the VMU.
+ strcpy(pkg.desc_short, "hydra");
+ strcpy(pkg.desc_long, "Hydra Castle Labyrinth");
+ strcpy(pkg.app_id, "hydracas");
+ pkg.icon_cnt = 1;
+ memcpy((void *)&pkg.icon_pal[0],(void *)&vmu_savestate_pal,32);
+ pkg.icon_data = (const uint8*)&vmu_savestate_data;
+ pkg.icon_anim_speed = 0;
+ pkg.eyecatch_type = VMUPKG_EC_NONE;
+ pkg.data_len = zipsize;
+ pkg.data = zipdata;
+ vmu_pkg_build(&pkg, &pkg_out, &pkg_size);
+
+ // Write at A1 port
+ fs_unlink("/vmu/a1/hydracas");
+ ft = fs_open("/vmu/a1/hydracas", O_WRONLY);
+ if (!ft) {
+ return -1;
+ }
+ fs_write(ft, pkg_out, pkg_size);
+ fs_close(ft);
+
+ // Free unused memory
+ free(pkg_out);
+ free(datasave);
+ free(zipdata);
+
+ return 0;
+}
+#endif
diff --git a/src/ini.c b/src/ini.c
index d2d3f57..47118a2 100644
--- a/src/ini.c
+++ b/src/ini.c
@@ -30,6 +30,9 @@ void iniInit()
strcat(fullPath, "sdmc:/3ds/appdata/HydraCastleLabyrinth/");
#endif
strcat(fullPath, "system.ini");
+ #ifdef DREAMCAST
+ strcat(fullPath, "/ram/system.ini");
+ #endif
}
FILE* f;
@@ -61,6 +64,9 @@ void saveSettings()
strcat(fullPath, "sdmc:/3ds/appdata/HydraCastleLabyrinth/");
#endif
strcat(fullPath, "system.ini");
+ #ifdef DREAMCAST
+ strcat(fullPath, "/ram/system.ini");
+ #endif
}
FILE* f;
@@ -146,6 +152,9 @@ void loadSettings()
strcat(fullPath, "sdmc:/3ds/appdata/HydraCastleLabyrinth/");
#endif
strcat(fullPath, "system.ini");
+ #ifdef DREAMCAST
+ strcat(fullPath, "/ram/system.ini");
+ #endif
}
FILE* f;
diff --git a/src/main.c b/src/main.c
index d772bd0..1aca498 100644
--- a/src/main.c
+++ b/src/main.c
@@ -61,7 +61,7 @@ int main(int argc, char **argv)
#elif defined(ODROID)
desktopFS = 1;
#else
- screenScale = 2;
+ screenScale = 1;
#endif
useJoystick = 1;
// get command line arguments
@@ -128,4 +128,4 @@ int main(int argc, char **argv)
#endif
return 0;
-} \ No newline at end of file
+}
diff --git a/src/sdl/audio.c b/src/sdl/audio.c
index b66ce1e..20b036d 100644
--- a/src/sdl/audio.c
+++ b/src/sdl/audio.c
@@ -26,7 +26,7 @@ PHL_Music PHL_LoadMusic(char* fname, int loop)
char buff[4096];
strcpy(buff, "data/");
strcat(buff, fname);
- strcat(buff, ".mid");
+ strcat(buff, ".ogg");
ret.snd = Mix_LoadMUS(buff);
return ret;
}
diff --git a/src/sdl/input.c b/src/sdl/input.c
index bf9de55..662b85b 100644
--- a/src/sdl/input.c
+++ b/src/sdl/input.c
@@ -69,6 +69,15 @@ void Input_KeyEvent(SDL_Event* evt)
case SDLK_2: bL = w; break;
case SDLK_SPACE: bSelect = w; break;
case SDLK_RETURN: bStart = w; break;
+#elif defined(DINGUX)
+ case SDLK_LSHIFT: bFaceUp = w; break;
+ case SDLK_LALT: bFaceDown = w; break;
+ case SDLK_LCTRL: bFaceLeft = w; break;
+ case SDLK_SPACE: bFaceRight = w; break;
+ case SDLK_BACKSPACE: bR = w; break;
+ case SDLK_TAB: bL = w; break;
+ case SDLK_ESCAPE: bSelect = w; break;
+ case SDLK_RETURN: bStart = w; break;
#else
case SDLK_e: bFaceUp = w; break;
case SDLK_x: bFaceDown = w; break;