GameBoy (Color) port of the GTA San Andreas arcade game Duality
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 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * main.c
  3. * Duality
  4. *
  5. * Copyright (C) 2025 Thomas Buck <thomas@xythobuz.de>
  6. *
  7. * Based on examples from gbdk-2020:
  8. * https://github.com/gbdk-2020/gbdk-2020/blob/develop/gbdk-lib/examples/gb/rand/rand.c
  9. *
  10. * This program 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 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program 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. * See <http://www.gnu.org/licenses/>.
  21. */
  22. #include <gbdk/platform.h>
  23. #include <gbdk/metasprites.h>
  24. #include <rand.h>
  25. #include <stdint.h>
  26. #include "maps.h"
  27. #include "obj.h"
  28. #include "sprites.h"
  29. #include "sound.h"
  30. #include "input.h"
  31. #include "game.h"
  32. static void splash(void) {
  33. disable_interrupts();
  34. DISPLAY_OFF;
  35. map_title();
  36. SHOW_BKG;
  37. SHOW_SPRITES;
  38. SPRITES_8x8;
  39. DISPLAY_ON;
  40. enable_interrupts();
  41. obj_init();
  42. obj_add(SPR_LIGHT, 42, -42, 0, 0);
  43. obj_add(SPR_DARK, -42, -42, 0, 0);
  44. while(1) {
  45. key_read();
  46. if (key_down(0xFF)) {
  47. break;
  48. }
  49. uint8_t hiwater = SPR_NUM_START;
  50. obj_draw(0, 0, &hiwater);
  51. hide_sprites_range(hiwater, MAX_HARDWARE_SPRITES);
  52. vsync();
  53. }
  54. }
  55. void main(void) {
  56. spr_init();
  57. snd_init();
  58. #ifndef DEBUG
  59. splash();
  60. #endif // DEBUG
  61. uint16_t seed = DIV_REG;
  62. waitpadup();
  63. seed |= ((uint16_t)DIV_REG) << 8;
  64. initarand(seed);
  65. game();
  66. }