Port of the atari800 emulator to the 3DS.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.c 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * 3ds/main.c - Nintendo 3DS port main code
  3. *
  4. * Copyright (c) 2001-2002 Jacek Poplawski
  5. * Copyright (C) 2001-2016 Atari800 development team (see DOC/CREDITS)
  6. *
  7. * This file is part of the Atari800 emulator project which emulates
  8. * the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
  9. *
  10. * Atari800 is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * Atari800 is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with Atari800; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. #include <3ds.h>
  25. #include <citro3d.h>
  26. #include <stdio.h>
  27. #include <string.h>
  28. /* Atari800 includes */
  29. #include "atari.h"
  30. #include "config.h"
  31. #include "../input.h"
  32. #include "log.h"
  33. #include "monitor.h"
  34. #include "platform.h"
  35. #include "pokeysnd.h"
  36. #ifdef SOUND
  37. #include "../sound.h"
  38. #endif
  39. #include "video.h"
  40. #include "videomode.h"
  41. static bool PLATFORM_IsNew3DS;
  42. extern int dpad_as_keyboard;
  43. int PLATFORM_Configure(char *option, char *parameters)
  44. {
  45. if (strcmp(option, "N3DS_DPAD_MODE") == 0)
  46. {
  47. sscanf(parameters, "%d", &dpad_as_keyboard);
  48. return 1;
  49. }
  50. return 0;
  51. }
  52. void PLATFORM_ConfigSave(FILE *fp)
  53. {
  54. fprintf(fp, "N3DS_DPAD_MODE=%d\n", dpad_as_keyboard);
  55. }
  56. int PLATFORM_Initialise(int *argc, char *argv[])
  57. {
  58. return TRUE;
  59. }
  60. void PLATFORM_Sleep(double s)
  61. {
  62. if (s > 0) {
  63. svcSleepThread(s * 1e9);
  64. }
  65. }
  66. double PLATFORM_Time(void)
  67. {
  68. return osGetTime() * 1e-3;
  69. }
  70. int PLATFORM_Exit(int run_monitor)
  71. {
  72. Log_flushlog();
  73. if (run_monitor) {
  74. return 1;
  75. } else {
  76. N3DS_ExitVideo();
  77. acExit();
  78. ptmSysmExit();
  79. romfsExit();
  80. }
  81. return 0;
  82. }
  83. int main(int argc, char **argv)
  84. {
  85. romfsInit();
  86. ptmSysmInit();
  87. osSetSpeedupEnable(1);
  88. APT_SetAppCpuTimeLimit(80);
  89. acInit();
  90. // set config defaults
  91. PLATFORM_IsNew3DS = PTMSYSM_CheckNew3DS();
  92. POKEYSND_enable_new_pokey = PLATFORM_IsNew3DS;
  93. N3DS_InitVideo();
  94. if (!Atari800_Initialise(&argc, argv))
  95. {
  96. printf("Atari initialisation failed!");
  97. return 0;
  98. }
  99. while (aptMainLoop()) {
  100. INPUT_key_code = PLATFORM_Keyboard();
  101. Atari800_Frame();
  102. if (Atari800_display_screen)
  103. PLATFORM_DisplayScreen();
  104. }
  105. }
  106. /*
  107. vim:ts=4:sw=4:
  108. */