nes_port.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * MIT License
  3. *
  4. * Copyright (c) 2022 Dozingfiretruck
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all
  14. * copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. */
  24. #ifndef _NES_PORT_
  25. #define _NES_PORT_
  26. #include <stdint.h>
  27. #include <stdio.h>
  28. #include <string.h>
  29. #include "nes_conf.h"
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /* log */
  34. #ifdef __DEBUG__
  35. #define nes_printf(...) printf(__VA_ARGS__)
  36. #else
  37. #define nes_printf(...)
  38. #endif
  39. /* memory */
  40. void *nes_malloc(int num);
  41. void nes_free(void *address);
  42. void *nes_memcpy(void *str1, const void *str2, size_t n);
  43. void *nes_memset(void *str, int c, size_t n);
  44. int nes_memcmp(const void *str1, const void *str2, size_t n);
  45. #if (NES_USE_FS == 1)
  46. /* io */
  47. FILE *nes_fopen( const char * filename, const char * mode );
  48. size_t nes_fread(void *ptr, size_t size_of_elements, size_t number_of_elements, FILE *a_file);
  49. int nes_fseek(FILE *stream, long int offset, int whence);
  50. int nes_fclose( FILE *fp );
  51. #endif
  52. void nes_wait(uint32_t ms);
  53. void nes_frame(void);
  54. int nes_draw(size_t x1, size_t y1, size_t x2, size_t y2, nes_color_t* color_data);
  55. #ifdef __cplusplus
  56. }
  57. #endif
  58. #endif// _NES_PORT_