From 44781b9b003c574195b3abd990102cef720a9f7a Mon Sep 17 00:00:00 2001 From: mibi88 Date: Sun, 11 Dec 2022 17:46:12 +0100 Subject: [PATCH] v.0.1 --- CMakeLists.txt | 46 +++++++++ assets-fx/fxconv-metadata.txt | 9 ++ assets-fx/game_over.png | Bin 0 -> 875 bytes assets-fx/icon.png | Bin 0 -> 1201 bytes assets-fx/maps/fxconv-metadata.txt | 3 + assets-fx/maps/map1.png | Bin 0 -> 7477 bytes assets-fx/menu/fxconv-metadata.txt | 12 +++ assets-fx/menu/play.png | Bin 0 -> 131 bytes assets-fx/menu/play_s.png | Bin 0 -> 114 bytes assets-fx/menu/quit.png | Bin 0 -> 109 bytes assets-fx/menu/quit_s.png | Bin 0 -> 109 bytes assets-fx/timer/1.png | Bin 0 -> 98 bytes assets-fx/timer/2.png | Bin 0 -> 119 bytes assets-fx/timer/3.png | Bin 0 -> 116 bytes assets-fx/timer/fxconv-metadata.txt | 9 ++ assets-fx/title.png | Bin 0 -> 904 bytes assets-fx/you_won.png | Bin 0 -> 834 bytes src/core.c | 146 ++++++++++++++++++++++++++++ src/core.h | 91 +++++++++++++++++ src/includes.h | 32 ++++++ src/init.c | 46 +++++++++ src/init.h | 26 +++++ src/main.c | 113 +++++++++++++++++++++ src/main.h | 30 ++++++ src/tools.c | 51 ++++++++++ src/tools.h | 28 ++++++ 26 files changed, 642 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 assets-fx/fxconv-metadata.txt create mode 100644 assets-fx/game_over.png create mode 100644 assets-fx/icon.png create mode 100644 assets-fx/maps/fxconv-metadata.txt create mode 100644 assets-fx/maps/map1.png create mode 100644 assets-fx/menu/fxconv-metadata.txt create mode 100644 assets-fx/menu/play.png create mode 100644 assets-fx/menu/play_s.png create mode 100644 assets-fx/menu/quit.png create mode 100644 assets-fx/menu/quit_s.png create mode 100644 assets-fx/timer/1.png create mode 100644 assets-fx/timer/2.png create mode 100644 assets-fx/timer/3.png create mode 100644 assets-fx/timer/fxconv-metadata.txt create mode 100644 assets-fx/title.png create mode 100644 assets-fx/you_won.png create mode 100644 src/core.c create mode 100644 src/core.h create mode 100644 src/includes.h create mode 100644 src/init.c create mode 100644 src/init.h create mode 100644 src/main.c create mode 100644 src/main.h create mode 100644 src/tools.c create mode 100644 src/tools.h diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..25d2feb --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,46 @@ +# Configure with [fxsdk build-fx] or [fxsdk build-cg], which provide the +# toolchain file and module path of the fxSDK + +cmake_minimum_required(VERSION 3.15) +project(MyAddin) + +include(GenerateG1A) +include(Fxconv) +find_package(Gint 2.1 REQUIRED) + +set(SOURCES + src/core.c + src/init.c + src/tools.c + src/main.c + # ... +) +# Shared assets, fx-9860G-only assets and fx-CG-50-only assets +set(ASSETS + # ... +) +set(ASSETS_fx + assets-fx/maps/map1.png + assets-fx/title.png + assets-fx/game_over.png + assets-fx/you_won.png + assets-fx/menu/play.png + assets-fx/menu/play_s.png + assets-fx/menu/quit.png + assets-fx/menu/quit_s.png + assets-fx/timer/3.png + assets-fx/timer/2.png + assets-fx/timer/1.png + # ... +) + +fxconv_declare_assets(${ASSETS} ${ASSETS_fx} WITH_METADATA) + +add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}}) +target_compile_options(myaddin PRIVATE -Wall -Wextra -Os) +target_link_libraries(myaddin Gint::Gint) + +if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G) + generate_g1a(TARGET myaddin OUTPUT "METROSI4.G1A" + NAME "Metro Siberia 4" ICON assets-fx/icon.png) +endif() diff --git a/assets-fx/fxconv-metadata.txt b/assets-fx/fxconv-metadata.txt new file mode 100644 index 0000000..4834fea --- /dev/null +++ b/assets-fx/fxconv-metadata.txt @@ -0,0 +1,9 @@ +title.png: + type: bopti-image + name: title +game_over.png: + type: bopti-image + name: game_over +you_won.png: + type: bopti-image + name: you_won diff --git a/assets-fx/game_over.png b/assets-fx/game_over.png new file mode 100644 index 0000000000000000000000000000000000000000..a5a074860a18f00d9fcfe62ded9f8259b8374c77 GIT binary patch literal 875 zcmV-x1C;!UP)`rExj6Pd}^FjGQp0)!#6wqy;eo|{% zg7$lO26kKdfC?vA#;%hGFdmGwP+=Xjr>G^tkQ3Z_!_lwJ)p&u4ugvU;4kvgP zvX962S3{WuKX!uaMUc*ShR(t9POwCR&X=an!5Dd4P002ovPDHLkV1g+1 Bn)3hv literal 0 HcmV?d00001 diff --git a/assets-fx/icon.png b/assets-fx/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..07d1f736e5cc39938bb4c34f5fea388f871ec210 GIT binary patch literal 1201 zcmeAS@N?(olHy`uVBq!ia0vp^azHH1!3-of6!`ivFfcO&_=LFr|NkE-G73gRU}S~> zxAOLf3=E76B|(0{z`QV`LEYCED}bpW!PCVtL}TLA3DH6f3LH$2|4q*`IvSfv|z6o0*IYy$IB>HHyh_Ul#y_HSYSM+$Ql9#w^^iAlB?P zXZLEwgJIp8Lqq`so;cBb+GA>QOGyn6G{h2*7A3?A#iE!>#{Rh*Gc!@F23vrM5_1%LkHnwCdVnuUO? zQ@Al(_l$&%aaX@v*SbxiqGE*@oYkKdew@*Xy%P@FM?358WyULnt+NhNqZ|R9WeNoy zQ|Et?xK2)C+&o11;USONy5}Su-_&o5$h^Fc#D1&tioLd9D;|y&2Z;gzGIKUGfwRVi zCC55rFBZYsn>8=iDr&mLXfmVt@}K>y??-4UP5uDiOafx%=06rQ~rc6P;uV#S-`fo;j6J$RQPAF*P-L%+`GwJys7T zx0h_~3T9m6c0`ADCU$Iv(W;{oSP6D@1tVgvaL>aN*=RypCD5Y722Z50XpP`-9mAH z8oKT%&c&xnAbe{5IL%4$TLj3mZ6}sT=L%Z1fhuejihf`W5Hv&Ga}jN~m)#4y{O+@Y zI%|UEnQ5G`R*l)b=M^gygK(>euxYC-J5?2n;hT}tB8J8oWrKbZ*O_q20f94wo=_Yc zk#9q3Ju+5>;&sf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UqYff8}9$S#obq0>*H=)jbz ztqjns2%0AE*}n8&Z(M+fI|Bmpy62;UX^NGk%U4eWxaIp^u?pP%pZ{yZ*MlgBzs)MqrQ`9X@?mV8luH9w$w%*wo1Q(aVy;>60#ko5N2LdC5FCu7_>0c zFHHI*{+J;eYxOR}cQM@Ujie6{mV4U=2#iV706|%HYJgVnb%mk^m;6RYb_Z_XMGsbn z&P0Wx7ZYS0$^g9%8x;7v|5YTgZT>@u*Xh3ytnMu2&N?-Fu1c7e50I^AlsM90CUAfc z&}9?%!6|Tg5U9M01F?tZLt%{0MTKGn^0e+hFlYX*M>{K<00000NkvXXu0mjfz1`wW literal 0 HcmV?d00001 diff --git a/assets-fx/menu/fxconv-metadata.txt b/assets-fx/menu/fxconv-metadata.txt new file mode 100644 index 0000000..09de0da --- /dev/null +++ b/assets-fx/menu/fxconv-metadata.txt @@ -0,0 +1,12 @@ +play.png: + type: bopti-image + name: menu_play +play_s.png: + type: bopti-image + name: menu_play_inv +quit.png: + type: bopti-image + name: menu_quit +quit_s.png: + type: bopti-image + name: menu_quit_inv diff --git a/assets-fx/menu/play.png b/assets-fx/menu/play.png new file mode 100644 index 0000000000000000000000000000000000000000..b2d4f78f196cc683935fa91eaf3f0f1bf5f87d9a GIT binary patch literal 131 zcmeAS@N?(olHy`uVBq!ia0vp^8bHj+0VEhwQw^1Xl$WQAV~E7m-U*Ie2Ml-)FOm87 zUp~FPta<9rE7JuGHp)c*E3FNGnGh4QKtaJ{mp`NOU5<}ZZ#^BQ9l7LA+2)+x*(=+2 e_}b1xpN>l}n$9gBvt9fs$aGIvKbLh*2~7ZzH!LLp literal 0 HcmV?d00001 diff --git a/assets-fx/menu/play_s.png b/assets-fx/menu/play_s.png new file mode 100644 index 0000000000000000000000000000000000000000..44a54ab32d770a4aeb779833c56fabb5184a7c81 GIT binary patch literal 114 zcmeAS@N?(olHy`uVBq!ia0vp^8bHj+0VEhwQw^1Xl%=POV~E7mwdWN17!(AU4_f~F z|6EC7hcd@1EwkHQ|2;XJwlFh`dc?-_ESWa*)>h+nw~W~D?24}p^_{zgpYeepKQqWM MPgg&ebxsLQ04hWvxBvhE literal 0 HcmV?d00001 diff --git a/assets-fx/menu/quit.png b/assets-fx/menu/quit.png new file mode 100644 index 0000000000000000000000000000000000000000..b90e9408dfedb444a1568e582daae50aa73d7990 GIT binary patch literal 109 zcmeAS@N?(olHy`uVBq!ia0vp^8bHj+0VEhwQw^1Xl!>Q{V~E7m-u{ie3Q{V~E7mD2r|dh)z4*} HQ$iB}*xDeQ literal 0 HcmV?d00001 diff --git a/assets-fx/timer/1.png b/assets-fx/timer/1.png new file mode 100644 index 0000000000000000000000000000000000000000..a5127dff6e28b5bcb23c4fdf5cd48bbc79484345 GIT binary patch literal 98 zcmeAS@N?(olHy`uVBq!ia0vp^AT}Qd3y|Ei%2feKX?nUihDc0JPWf@ZfiXhDz(rDW vhJcUT4ucqhNLyiMF@qhfg6GnYh$%3Him*!0;MaBoYGUwo^>bP0l+XkK%eNK! literal 0 HcmV?d00001 diff --git a/assets-fx/timer/2.png b/assets-fx/timer/2.png new file mode 100644 index 0000000000000000000000000000000000000000..e49a41eb90d1999192ac5647ea6172c2b17dd3bd GIT binary patch literal 119 zcmeAS@N?(olHy`uVBq!ia0vp^AT}Qd3y|Ei%2feK*?GD+hDc1^+V9E7puoYryzPJe zPPr*N9$by{n8g&F*wyr?OG5dn&%4OP1y{T4&qUPgFLAM)lq71v`fscGRmPudxYV}$ S{L=xN#Ng@b=d#Wzp$Pz_btee` literal 0 HcmV?d00001 diff --git a/assets-fx/timer/3.png b/assets-fx/timer/3.png new file mode 100644 index 0000000000000000000000000000000000000000..c4add709aec154cb2022274294333087980f36f9 GIT binary patch literal 116 zcmeAS@N?(olHy`uVBq!ia0vp^AT}Qd3y|Ei%2feKS$n!ThDc0JPWf@ZfiXhDz(rCr zLP3P*Py0%ju+t|#%x`RLbKK%}>ud zef#YH=oStE9tFA;9Z~&~lhxCM@5J;uzn=$hkwmc`F{lD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HI;$0d`fBMWfsIFh|8hr z`-P*%!CXHwd#=Er6FByMK@EdE6s5zr(qTOK5=n{jsk@f^K5=d(aH-MUVR0#fO31uV*Hbeb4oh#7croj6?t5$>+Xb`2svKs0{_^0qC zl>vhjEXN8f|A1|V+SRa<@IYrLNT8~S(I56mAk+lwY+$vOe_(Ked8{ftpgb5Up~5_7 zAHzz5CMUS^%0CcGVy3^BVSV8NfdaO30&|*u3>yiGPmEv*;q54Pf;$NhG#;7R0b3uN zvv`56j?C1c!U^t$iZeqiAy0xIJHh!P$e+#(&4cZoV2%V^9h$1a2Xdr1wW$}JX8-^I M07*qoM6N<$f}G)ZAOHXW literal 0 HcmV?d00001 diff --git a/src/core.c b/src/core.c new file mode 100644 index 0000000..733107b --- /dev/null +++ b/src/core.c @@ -0,0 +1,146 @@ +/* + * Metro Siberia 4 - A sequel to Dark Storm's Metro Siberia 3 for CASIO calculators. + * Copyright (C) 2015 Dark Storm + * Copyright (C) 2022 Mibi88 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + +#include "includes.h" + +Ship ship; +extern bopti_image_t map_1; +extern bopti_image_t timer_3; +extern bopti_image_t timer_2; +extern bopti_image_t timer_1; + +int dgetpixel(int x, int y) // Thanks to Lephenixnoir +{ + int offset = (y << 2) + (x >> 5); + return (int)(gint_vram[offset] << (x & 31)) < 0 ? C_BLACK : C_WHITE; +} + +int play_game(void) +{ + int collision = 0, ticks = 0, timer = 3; + init_ship(); + ship.scrolling.x = 0; + ship.scrolling.y = 0; + while(timer != 0){ + dclear(C_WHITE); + int i; + dimage(-ship.scrolling.x, 0, &map_1); + calculate_tops(); + for(i = 0; i != 3; i++) + dline(ship.tops[i].x, ship.tops[i].y, ship.tops[(i + 1) % 3].x, ship.tops[(i + 1) % 3].y, C_BLACK); + if(timer == 3){ + dimage(59, 25, &timer_3); + }else if(timer == 2){ + dimage(59, 25, &timer_2); + }else if(timer == 1){ + dimage(59, 25, &timer_1); + } + dupdate(); + sleep_ms(1000); + timer--; + } + + while(1) + { + clearevents(); + if(keydown(KEY_SHIFT) || keydown(KEY_EXE)){ // Go up + ship.thrust = false; + } + if(keydown(KEY_EXIT)){ + return 2; + } + sleep_ms(20); + calculate_tops(); + dclear(C_WHITE); + collision = move(); + draw(); + ship.thrust = true; + clearevents(); + if(ship.scrolling.x >= 3328){ + return 1; + } + if(collision == 1){ + return 0; + } + } + +} + +void draw(void) +{ + static Vector smoke_cubes[5]; + int i; + + for(i = 0; i != 3; i++) + dline(ship.tops[i].x, ship.tops[i].y, ship.tops[(i + 1) % 3].x, ship.tops[(i + 1) % 3].y, C_BLACK); + + dupdate(); +} + +int move(void) +{ + int i; + ship.acceleration.y = - GRAVITY * (float)(TIMER_PHYSIC) / 1000; + if(ship.thrust) ship.acceleration.y += THRUST * (float)(TIMER_PHYSIC) / 1000; + + ship.speed.x += ship.acceleration.x; + ship.speed.y += ship.acceleration.y; + + ship.position.x += ship.speed.x; + ship.position.y += ship.speed.y; + + ship.scrolling.x = ship.position.x; + + dimage(-ship.scrolling.x, 0, &map_1); + + // collision + for(i=0;i!=3;i++){ + if(dgetpixel(ship.tops[i].x, ship.tops[i].y) == C_BLACK){ + return 1; + } + if(ship.tops[i].y<0 || ship.tops[i].y>64){ + return 1; + } + } + return 0; +} + + +void calculate_tops(void) +{ + Vector tmp; + float angle = 15.0; + int i; + + angle = _atan(ship.speed.y / ship.speed.x); + + init_tops(); + + for(i = 0; i != 3; i++) + { + tmp.x = ship.tops[i].x; + tmp.y = ship.tops[i].y; + + ship.tops[i].x = tmp.x * cos(angle) + tmp.y * sin(angle); + ship.tops[i].y = tmp.y * cos(angle) - tmp.x * sin(angle); + + ship.tops[i].x += MARGIN; + ship.tops[i].y += ship.position.y; + } +} diff --git a/src/core.h b/src/core.h new file mode 100644 index 0000000..3f1e72e --- /dev/null +++ b/src/core.h @@ -0,0 +1,91 @@ +/* + * Metro Siberia 4 - A sequel to Dark Storm's Metro Siberia 3 for CASIO calculators. + * Copyright (C) 2015 Dark Storm + * Copyright (C) 2022 Mibi88 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + +#ifndef _ENGINE_H +#define _ENGINE_H + +/* Global defines */ + +#ifndef NULL + #define NULL (void*)(0) +#endif + +// Timers delays +#define TIMER_PHYSIC 25 + +// Physic constants +#define GRAVITY 0.981 // px . s^{-2} +#define THRUST 2.0 * GRAVITY // px . s^{-2} +#define HORIZONTAL_SPEED 20.0 // px . s^{-1} + +// Margin before the ship +#define MARGIN 32 + +// Relative position of tops of the ship +/*#define SHIP_TOP_1_X 10 +#define SHIP_TOP_1_Y 0 +#define SHIP_TOP_2_X -5 +#define SHIP_TOP_2_Y 5 +#define SHIP_TOP_3_X -5 +#define SHIP_TOP_3_Y -5*/ +#define SHIP_TOP_1_X 9 +#define SHIP_TOP_1_Y 0 +#define SHIP_TOP_2_X 0 +#define SHIP_TOP_2_Y 3 +#define SHIP_TOP_3_X 0 +#define SHIP_TOP_3_Y -3 + +#define MENU_MAX 1 + +/* Enumerations */ + +// Menu entries + +#define PLAY 0 +#define QUIT 1 + +/* Structures */ +typedef struct { float x, y; } Vector; + +typedef struct +{ + Vector position; + Vector speed; + Vector acceleration; + Vector scrolling; + bool thrust; + + Vector tops[3]; +} Ship; + +typedef struct +{ + int x, y; +} Camera; + + +/* Functions */ + +int play_game(void); +void draw(void); +int move(void); + +void calculate_tops(void); + +#endif // _ENGINE_H diff --git a/src/includes.h b/src/includes.h new file mode 100644 index 0000000..1a940c7 --- /dev/null +++ b/src/includes.h @@ -0,0 +1,32 @@ +/* + * Metro Siberia 4 - A sequel to Dark Storm's Metro Siberia 3 for CASIO calculators. + * Copyright (C) 2015 Dark Storm + * Copyright (C) 2022 Mibi88 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + +#define DEBUG + +#include +#include +#include +#include +#include + +#include "tools.h" + +#include "core.h" +#include "main.h" +#include "init.h" diff --git a/src/init.c b/src/init.c new file mode 100644 index 0000000..45b416d --- /dev/null +++ b/src/init.c @@ -0,0 +1,46 @@ +/* + * Metro Siberia 4 - A sequel to Dark Storm's Metro Siberia 3 for CASIO calculators. + * Copyright (C) 2015 Dark Storm + * Copyright (C) 2022 Mibi88 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + +#include "includes.h" + +extern Ship ship; + +void init_ship(void) +{ + ship.position.x = 0; + ship.position.y = 32; + + ship.speed.x = HORIZONTAL_SPEED / TIMER_PHYSIC; + ship.speed.y = 0; + + ship.acceleration.x = 0; + ship.acceleration.y = 0; + + ship.thrust = false; +} + +void init_tops(void) +{ + ship.tops[0].x = SHIP_TOP_1_X; + ship.tops[0].y = SHIP_TOP_1_Y; + ship.tops[1].x = SHIP_TOP_2_X; + ship.tops[1].y = SHIP_TOP_2_Y; + ship.tops[2].x = SHIP_TOP_3_X; + ship.tops[2].y = SHIP_TOP_3_Y; +} diff --git a/src/init.h b/src/init.h new file mode 100644 index 0000000..1c25e24 --- /dev/null +++ b/src/init.h @@ -0,0 +1,26 @@ +/* + * Metro Siberia 4 - A sequel to Dark Storm's Metro Siberia 3 for CASIO calculators. + * Copyright (C) 2015 Dark Storm + * Copyright (C) 2022 Mibi88 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + +#ifndef _INIT_H +#define _INIT_H + +void init_ship(void); +void init_tops(void); + +#endif // _INIT_H diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..0fc9ae0 --- /dev/null +++ b/src/main.c @@ -0,0 +1,113 @@ +/* + * Metro Siberia 4 - A sequel to Dark Storm's Metro Siberia 3 for CASIO calculators. + * Copyright (C) 2015 Dark Storm + * Copyright (C) 2022 Mibi88 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + +#include "includes.h" + +int selection, stat; + +extern bopti_image_t title; +extern bopti_image_t game_over; +extern bopti_image_t you_won; +extern bopti_image_t menu_play; +extern bopti_image_t menu_play_inv; +extern bopti_image_t menu_quit; +extern bopti_image_t menu_quit_inv; + +void waitkey(int key){ + clearevents(); + while(keydown(key)){ + clearevents(); + } +} + +void end(){ + dclear(C_WHITE); + if(stat == 0){ + dimage(0, 0, &game_over); + }else if(stat == 1){ + dimage(0, 0, &you_won); + } + if(stat == 0 || stat == 1){ + dupdate(); + stat = 0; + clearevents(); + while(!keydown(KEY_EXIT)){ + clearevents(); + if(keydown(KEY_SHIFT)) + break; + clearevents(); + if(keydown(KEY_EXE)) + break; + clearevents(); + } + }else{ + return; + } +} + +int main(void) +{ + selection = PLAY; + stat = 0; + while(1){ + dclear(C_WHITE); + if(selection != PLAY){ + dimage(70, 22, &menu_play); + }else{ + dimage(70, 22, &menu_play_inv); + } + if(selection != QUIT){ + dimage(70, 32, &menu_quit); + }else{ + dimage(70, 32, &menu_quit_inv); + } + clearevents(); + if(keydown(KEY_SHIFT) || keydown(KEY_EXE)){ + if(selection == PLAY){ + play_game(); + end(); + waitkey(KEY_SHIFT); + waitkey(KEY_EXE); + selection = PLAY; + stat = 0; + }else if(selection == QUIT){ + return 1; + } + waitkey(KEY_SHIFT); + waitkey(KEY_EXE); + }else if(keydown(KEY_UP)){ + if(selection != 0){ + selection--; + }else{ + selection = MENU_MAX; + } + waitkey(KEY_UP); + }else if(keydown(KEY_DOWN)){ + if(selection != MENU_MAX){ + selection++; + }else{ + selection = 0; + } + waitkey(KEY_DOWN); + } + dimage(0, 0, &title); + dupdate(); + } + return 1; +} diff --git a/src/main.h b/src/main.h new file mode 100644 index 0000000..fba955b --- /dev/null +++ b/src/main.h @@ -0,0 +1,30 @@ +/* + * Metro Siberia 4 - A sequel to Dark Storm's Metro Siberia 3 for CASIO calculators. + * Copyright (C) 2015 Dark Storm + * Copyright (C) 2022 Mibi88 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + +#ifndef _MAIN_H + +#define _MAIN_H + +/* Functions */ + +int main(void); +void waitkey(int key); +void end(void); + +#endif diff --git a/src/tools.c b/src/tools.c new file mode 100644 index 0000000..38b917f --- /dev/null +++ b/src/tools.c @@ -0,0 +1,51 @@ +/* + * Metro Siberia 4 - A sequel to Dark Storm's Metro Siberia 3 for CASIO calculators. + * Copyright (C) 2015 Dark Storm + * Copyright (C) 2022 Mibi88 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + +#include "includes.h" + +char* _itoa(int i, char b[]) +{ + char const digit[] = "0123456789"; + char* p = b; + if(i<0){ + *p++ = '-'; + i *= -1; + } + int shifter = i; + do{ //Move to where representation ends + ++p; + shifter = shifter/10; + }while(shifter); + *p = '\0'; + do{ //Move back, inserting digits as u go + *--p = digit[i%10]; + i = i/10; + }while(i); + return b; +} + + +#define PI 3.14159 +#define M_PI_4 0.78539 +#define FABS(x) ((x<0)?-x:x) + +float _atan(float x) +{ + return (x * (M_PI_4 - ((FABS(x) - 1) * (0.2447 + 0.0663 * FABS(x))))); +} diff --git a/src/tools.h b/src/tools.h new file mode 100644 index 0000000..9a44e9c --- /dev/null +++ b/src/tools.h @@ -0,0 +1,28 @@ +/* + * Metro Siberia 4 - A sequel to Dark Storm's Metro Siberia 3 for CASIO calculators. + * Copyright (C) 2015 Dark Storm + * Copyright (C) 2022 Mibi88 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + +#ifndef _TOOLS_H +#define _TOOLS_H +#include + +/* Functions */ +char* _itoa(int i, char str[]); +float _atan(float x); + +#endif