remghoost

mcard.h

Dec 8th, 2022
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.04 KB | None | 0 0
  1. Here is the "mcard.h" file.
  2.  
  3.  
  4. /* This file contains the declarations for mcard.c. */
  5.  
  6. /* The maximum number of blocks in a memory card. */
  7. #define MCARD_MAX_BLOCKS 8192
  8.  
  9. /* The size of a block in a memory card. */
  10. #define MCARD_BLOCK_SIZE 512
  11.  
  12. /* The format of a memory card. */
  13. typedef enum
  14. {
  15.     MCR,    /* Memory Card Reader format */
  16.     GME     /* Game Shark Memory Manager format */
  17. } mcard_format_t;
  18.  
  19. /* The data for a memory card. */
  20. typedef struct
  21. {
  22.     mcard_format_t format;   /* The format of the memory card */
  23.     int blocks;              /* The number of blocks in the memory card */
  24.     uint8_t *data;           /* The data for the memory card */
  25. } mcard_t;
  26.  
  27. /* This function creates a new memory card. */
  28. mcard_t *mcard_new(mcard_format_t format, int blocks);
  29.  
  30. /* This function frees a memory card. */
  31. void mcard_free(mcard_t *mc);
  32.  
  33. /* This function reads a memory card from a file. */
  34. mcard_t *mcard_read(const char *filename);
  35.  
  36. /* This function writes a memory card to a file. */
  37. int mcard_write(mcard_t *mc, const char *filename);
  38.  
  39. /* This function formats a memory card. */
  40. int mcard_format(mcard_t *mc);
  41.  
  42. /* This function gets a block of data from a memory card. */
  43. int mcard_get_block(mcard_t *mc, int block, uint8_t *data);
  44.  
  45. /* This function sets a block of data in a memory card. */
  46. int mcard_set_block(mcard_t *mc, int block, uint8_t *data);
  47.  
  48. /* This function gets the size of a file in a memory card. */
  49. int mcard_get_file_size(mcard_t *mc, const char *filename);
  50.  
  51. /* This function reads a file from a memory card. */
  52. int mcard_
  53.  
  54. /* This function reads a file from a memory card. */
  55. int mcard_read_file(mcard_t *mc, const char *filename, uint8_t *data);
  56.  
  57. /* This function writes a file to a memory card. */
  58. int mcard_write_file(mcard_t *mc, const char *filename, uint8_t *data, int size);
  59.  
  60. /* This function deletes a file from a memory card. */
  61. int mcard_delete_file(mcard_t *mc, const char *filename);
  62.  
  63. /* This function prints the contents of a memory card. */
  64. void mcard_print(mcard_t *mc);
  65.  
Advertisement
Add Comment
Please, Sign In to add comment