cd_sys.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /***********************************************************
  2. * *
  3. * This source was taken from the Gens project *
  4. * Written by Stéphane Dallongeville *
  5. * Copyright (c) 2002 by Stéphane Dallongeville *
  6. * Modified/adapted for PicoDrive by notaz, 2007 *
  7. * *
  8. ***********************************************************/
  9. #ifndef _CD_SYS_H
  10. #define _CD_SYS_H
  11. #include "cd_file.h"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #define INT_TO_BCDB(c) \
  16. ((c) > 99)?(0x99):((((c) / 10) << 4) + ((c) % 10));
  17. #define INT_TO_BCDW(c) \
  18. ((c) > 99)?(0x0909):((((c) / 10) << 8) + ((c) % 10));
  19. #define BCDB_TO_INT(c) \
  20. (((c) >> 4) * 10) + ((c) & 0xF);
  21. #define BCDW_TO_INT(c) \
  22. (((c) >> 8) * 10) + ((c) & 0xF);
  23. typedef struct
  24. {
  25. unsigned char M;
  26. unsigned char S;
  27. unsigned char F;
  28. } _msf;
  29. typedef struct
  30. {
  31. // unsigned char Type; // always 1 (data) for 1st track, 0 (audio) for others
  32. // unsigned char Num; // unused
  33. _msf MSF;
  34. //
  35. char ftype; // TYPE_ISO, TYPE_BIN, TYPE_MP3
  36. void *F;
  37. int Length;
  38. short KBtps; // kbytes per sec for mp3s (bitrate / 1000 / 8)
  39. short pad;
  40. } _scd_track;
  41. typedef struct
  42. {
  43. // unsigned char First_Track; // always 1
  44. _scd_track Tracks[100];
  45. unsigned int Last_Track;
  46. } _scd_toc;
  47. typedef struct {
  48. unsigned int Status_CDD;
  49. unsigned int Status_CDC;
  50. int Cur_LBA;
  51. unsigned int Cur_Track;
  52. int File_Add_Delay;
  53. char CDD_Complete;
  54. int pad[6];
  55. } _scd;
  56. PICO_INTERNAL void LBA_to_MSF(int lba, _msf *MSF);
  57. PICO_INTERNAL int Track_to_LBA(int track);
  58. // moved to Pico.h
  59. // int Insert_CD(char *iso_name, int is_bin);
  60. // void Stop_CD(void);
  61. PICO_INTERNAL void Check_CD_Command(void);
  62. PICO_INTERNAL int Init_CD_Driver(void);
  63. PICO_INTERNAL void End_CD_Driver(void);
  64. PICO_INTERNAL void Reset_CD(void);
  65. PICO_INTERNAL int Get_Status_CDD_c0(void);
  66. PICO_INTERNAL int Stop_CDD_c1(void);
  67. PICO_INTERNAL int Get_Pos_CDD_c20(void);
  68. PICO_INTERNAL int Get_Track_Pos_CDD_c21(void);
  69. PICO_INTERNAL int Get_Current_Track_CDD_c22(void);
  70. PICO_INTERNAL int Get_Total_Lenght_CDD_c23(void);
  71. PICO_INTERNAL int Get_First_Last_Track_CDD_c24(void);
  72. PICO_INTERNAL int Get_Track_Adr_CDD_c25(void);
  73. PICO_INTERNAL int Play_CDD_c3(void);
  74. PICO_INTERNAL int Seek_CDD_c4(void);
  75. PICO_INTERNAL int Pause_CDD_c6(void);
  76. PICO_INTERNAL int Resume_CDD_c7(void);
  77. PICO_INTERNAL int Fast_Foward_CDD_c8(void);
  78. PICO_INTERNAL int Fast_Rewind_CDD_c9(void);
  79. PICO_INTERNAL int CDD_cA(void);
  80. PICO_INTERNAL int Close_Tray_CDD_cC(void);
  81. PICO_INTERNAL int Open_Tray_CDD_cD(void);
  82. PICO_INTERNAL int CDD_Def(void);
  83. #ifdef __cplusplus
  84. };
  85. #endif
  86. #endif