diff --git a/CMakeLists.txt b/CMakeLists.txt index e4141d76..69cd2402 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,16 +21,30 @@ add_executable(${CMAKE_PROJECT_NAME}.elf target_link_libraries(${CMAKE_PROJECT_NAME}.elf SDL2_image SDL2 + EGL + glapi + drm_nouveau jpeg png z nx m + stdc++ -specs=${DEVKITPRO}/libnx/switch.specs ) add_custom_target(${CMAKE_PROJECT_NAME}.nro DEPENDS ${CMAKE_PROJECT_NAME}.elf - COMMAND nacptool --create "${CMAKE_PROJECT_NAME}" "usineur" "1.0" ${CMAKE_PROJECT_NAME}.nacp + COMMAND nacptool --create "${CMAKE_PROJECT_NAME}" "usineur" "1.1" ${CMAKE_PROJECT_NAME}.nacp COMMAND elf2nro ${CMAKE_PROJECT_NAME}.elf ${CMAKE_PROJECT_NAME}.nro --icon=${CMAKE_SOURCE_DIR}/res/icon.jpg --nacp=${CMAKE_PROJECT_NAME}.nacp ) + +add_custom_target(send + COMMAND curl -T ${CMAKE_PROJECT_NAME}.nro ftp://$(SWITCHIP):5000/switch/${CMAKE_PROJECT_NAME}/ + DEPENDS ${CMAKE_PROJECT_NAME}.nro +) + +add_custom_target(nxlink + COMMAND nxlink -a $(SWITCHIP) ${CMAKE_PROJECT_NAME}.nro -s -p ${CMAKE_PROJECT_NAME}/${CMAKE_PROJECT_NAME}.nro + DEPENDS ${CMAKE_PROJECT_NAME}.nro +) diff --git a/src/proto.h b/src/proto.h index 58e93bc0..80084bc3 100644 --- a/src/proto.h +++ b/src/proto.h @@ -466,7 +466,7 @@ void __pascal far draw_table(int which_table); void __pascal far draw_wipes(int which); void __pascal far draw_back_fore(int which_table,int index); void __pascal far draw_mid(int index); -void __pascal far draw_image(image_type far *image,image_type far *mask,int xpos,int ypos,int blit); +void __pascal far draw_image_1(image_type far *image,image_type far *mask,int xpos,int ypos,int blit); void __pascal far draw_wipe(int index); void __pascal far calc_gate_pos(); void __pascal far draw_gate_back(); diff --git a/src/seg000.c b/src/seg000.c index 7b1f05d9..d8da221f 100644 --- a/src/seg000.c +++ b/src/seg000.c @@ -22,6 +22,10 @@ The authors of this program may be contacted at http://forum.princed.org #include #include +#ifdef __SWITCH__ +#include +#endif + // data:461E dat_type * dathandle; @@ -30,6 +34,10 @@ word need_redraw_because_flipped; // seg000:0000 void far pop_main() { +#ifdef NXLINK + socketInitializeDefault(); + nxlinkStdio(); +#endif if (check_param("--version") || check_param("-v")) { printf ("SDLPoP v%s\n", SDLPOP_VERSION); exit(0); diff --git a/src/seg008.c b/src/seg008.c index 8979bf6f..bc4da932 100644 --- a/src/seg008.c +++ b/src/seg008.c @@ -900,7 +900,7 @@ void __pascal far draw_back_fore(int which_table,int index) { mask = chtab->images[chtab->n_images / 2 + table_entry->id]; } */ - draw_image(image, mask, table_entry->xh * 8 + table_entry->xl, table_entry->y, table_entry->blit); + draw_image_1(image, mask, table_entry->xh * 8 + table_entry->xl, table_entry->y, table_entry->blit); } @@ -989,7 +989,7 @@ void __pascal far draw_mid(int index) { add_peel(round_xpos_to_byte(xpos, 0), round_xpos_to_byte(image->w/*width*/ + xpos, 1), ypos, image->h/*height*/); } //printf("Midtable: drawing (chtab %d, image %d) at (x=%d, y=%d)\n",chtab_id,image_id,xpos,ypos); // debug - draw_image(image, mask, xpos, ypos, blit); + draw_image_1(image, mask, xpos, ypos, blit); if (chtab_flip_clip[chtab_id]) { reset_clip_rect(); @@ -1004,7 +1004,7 @@ void __pascal far draw_mid(int index) { } // seg008:167B -void __pascal far draw_image(image_type far *image,image_type far *mask,int xpos,int ypos,int blit) { +void __pascal far draw_image_1(image_type far *image,image_type far *mask,int xpos,int ypos,int blit) { rect_type rect; switch (blit) { case blitters_10h_transp: diff --git a/src/seg009.c b/src/seg009.c index 3c13d6f4..60752c8e 100644 --- a/src/seg009.c +++ b/src/seg009.c @@ -41,16 +41,7 @@ The authors of this program may be contacted at http://forum.princed.org #define BTN_UP 13 #define BTN_RIGHT 14 #define BTN_DOWN 15 - -int access(const char *pathname, int mode) -{ - struct stat st; - - if (stat(pathname, &st) < 0) - return -1; - - return 0; -} +#include #endif // Most functions in this file are different from those in the original game. @@ -279,6 +270,9 @@ void __pascal far restore_stuff() { // seg009:0E33 int __pascal far key_test_quit() { +#ifdef NXLINK + socketExit(); +#endif word key; key = read_key(); if (key == (SDL_SCANCODE_Q | WITH_CTRL)) { // ctrl-q @@ -1482,6 +1476,13 @@ void __pascal far draw_text_cursor(int xpos,int ypos,int color) { // seg009:053C int __pascal far input_str(const rect_type far *rect,char *buffer,int max_length,const char *initial,int has_initial,int arg_4,int color,int bgcolor) { +#ifdef __SWITCH__ + SwkbdConfig kbd; + swkbdCreate(&kbd, 0); + swkbdConfigMakePresetDefault(&kbd); + swkbdShow(&kbd, buffer, max_length); + return strlen(buffer); +#endif short length; word key; short cursor_visible; @@ -2279,19 +2280,19 @@ void __pascal far set_gr_mode(byte grmode) { #ifdef SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING SDL_SetHint(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "1"); #endif -#ifdef __SWITCH__ - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK) != 0) { -#else if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE | SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC ) != 0) { -#endif sdlperror("SDL_Init"); quit(1); } //SDL_EnableUNICODE(1); //deprecated Uint32 flags = 0; +#ifdef __SWITCH__ + start_fullscreen = 1; +#else if (!start_fullscreen) start_fullscreen = check_param("full") != NULL; +#endif if (start_fullscreen) flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; flags |= SDL_WINDOW_RESIZABLE; flags |= SDL_WINDOW_ALLOW_HIGHDPI; // for Retina displays @@ -2309,11 +2310,7 @@ void __pascal far set_gr_mode(byte grmode) { pop_window_width, pop_window_height, flags); // Make absolutely sure that VSync will be off, to prevent timer issues. SDL_SetHint(SDL_HINT_RENDER_VSYNC, "0"); -#ifdef __SWITCH__ - renderer_ = SDL_CreateRenderer(window_, -1 , SDL_RENDERER_SOFTWARE); -#else renderer_ = SDL_CreateRenderer(window_, -1 , SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); -#endif SDL_RendererInfo renderer_info; if (SDL_GetRendererInfo(renderer_, &renderer_info) == 0) { if (renderer_info.flags & SDL_RENDERER_TARGETTEXTURE) {