No Description

camera_move.c 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /****************************************************************************
  2. * Copyright (C) 2015-2016 by the SotS Team *
  3. * *
  4. * This file is part of Sovereign of the Skies. *
  5. * *
  6. * Sovereign of the Skies is free software: you can redistribute it *
  7. * and/or modify it *
  8. * under the terms of the GNU Lesser General Public License as published *
  9. * by the Free Software Foundation, either version 3 of the License, or *
  10. * (at your option) any later version provided you include a copy of the *
  11. * licence and this header. *
  12. * *
  13. * Sovereign of the Skies is distributed in the hope that it will be *
  14. * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of *
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  16. * GNU Lesser General Public License for more details. *
  17. * *
  18. * You should have received a copy of the GNU Lesser General Public *
  19. * License along with Sovereign of the Skies. *
  20. * If not, see <http://www.gnu.org/licenses/>. *
  21. ****************************************************************************/
  22. /**
  23. * @file camera_move.c
  24. * @author Sturmvogel
  25. * @date 15 dec 2016
  26. * @brief Scene to update the camera
  27. *
  28. * This provides implementations to move the game camera
  29. */
  30. /* === INCLUDES === */
  31. #include <game_engine.h>
  32. #include "camera_move.h"
  33. #include <callback.h>
  34. #include <fade.h>
  35. #include <config/core.h>
  36. #include <lcd.h>
  37. /* === PROTOTYPES === */
  38. /**
  39. * @brief special to handle the camera update scene
  40. */
  41. void cam_cb_move_camera();
  42. /**
  43. * @brief vblank screen update method for the camera scene
  44. */
  45. void cam_update_screen();
  46. /* === STRUCTURES === */
  47. struct cam_point {
  48. u16 x;
  49. u16 y;
  50. };
  51. /* === STATIC STRUCTURES === */
  52. struct cam_point** sav_data_map = (struct cam_point**)(0x03005008);
  53. /* === IMPLEMENTATIONS === */
  54. void cam_update_screen()
  55. {
  56. fade_update();
  57. task_exec();
  58. objc_exec();
  59. obj_sync();
  60. gpu_pal_upload();
  61. obj_gpu_sprites_upload();
  62. }
  63. void cam_sp_move_camera()
  64. {
  65. set_callback2(cam_cb_move_camera);
  66. fade_screen(0xFFFFFFFF, 0, 0, 0x10, 0x0000);
  67. vblank_handler_set(cam_update_screen);
  68. }
  69. void cam_cb_move_camera()
  70. {
  71. if((fade_controller.mix_color & 0x8000) == 0)
  72. {
  73. u16 camera_x = *var_access(CAMERA_VAR_X);
  74. u16 camera_y = *var_access(CAMERA_VAR_Y);
  75. (*sav_data_map)->x = camera_x;
  76. (*sav_data_map)->y = camera_y;
  77. //camera_move_and_redraw(camera_x, camera_y);
  78. set_callback2(callback_overworld);
  79. }
  80. }