nes_port.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright 2023-2025 Dozingfiretruck
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "nes.h"
  17. /* memory */
  18. void *nes_malloc(int num){
  19. return rt_malloc(num);
  20. }
  21. void nes_free(void *address){
  22. rt_free(address);
  23. }
  24. void *nes_memcpy(void *str1, const void *str2, size_t n){
  25. return rt_memcpy(str1, str2, n);
  26. }
  27. void *nes_memset(void *str, int c, size_t n){
  28. return rt_memset(str,c,n);
  29. }
  30. int nes_memcmp(const void *str1, const void *str2, size_t n){
  31. return rt_memcmp(str1,str2,n);
  32. }
  33. #if (NES_USE_FS == 1)
  34. /* io */
  35. FILE *nes_fopen(const char * filename, const char * mode ){
  36. return fopen(filename,mode);
  37. }
  38. size_t nes_fread(void *ptr, size_t size, size_t nmemb, FILE *stream){
  39. return fread(ptr, size, nmemb,stream);
  40. }
  41. size_t nes_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream){
  42. return fwrite(ptr, size, nmemb,stream);
  43. }
  44. int nes_fseek(FILE *stream, long int offset, int whence){
  45. return fseek(stream,offset,whence);
  46. }
  47. int nes_fclose(FILE *stream ){
  48. return fclose(stream);
  49. }
  50. #endif
  51. #if (NES_ENABLE_SOUND == 1)
  52. rt_weak int nes_sound_output(uint8_t *buffer, size_t len){
  53. #error "Sound output function is not implemented!"
  54. return 0;
  55. }
  56. #endif
  57. rt_weak int nes_initex(nes_t *nes){
  58. return 0;
  59. }
  60. rt_weak int nes_deinitex(nes_t *nes){
  61. return 0;
  62. }
  63. rt_weak int nes_draw(int x1, int y1, int x2, int y2, nes_color_t* color_data){
  64. #warning "Display function is not implemented!"
  65. return 0;
  66. }
  67. #define FRAMES_PER_SECOND 1000/60
  68. rt_weak void nes_frame(nes_t* nes){
  69. }