home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Emulation / AmigaVGB / GB.h < prev    next >
C/C++ Source or Header  |  2000-07-06  |  7KB  |  141 lines

  1. /** VGB: portable GameBoy emulator ***************************/
  2. /**                                                         **/
  3. /**                           GB.h                          **/
  4. /**                                                         **/
  5. /** This file contains definitions for the GameBoy hardware **/
  6. /** emulation.                                              **/
  7. /**                                                         **/
  8. /** Copyright (C) Marat Fayzullin 1995                      **/
  9. /**     You are not allowed to distribute this software     **/
  10. /**     commercially. Please, notify me, if you make any    **/   
  11. /**     changes to this file.                               **/
  12. /*************************************************************/
  13.  
  14. #include "Z80.h"            /* CPU emulation declarations    */
  15.  
  16. /* #define UNIX  */         /* Compile iNES for for Unix/X   */
  17. /* #define MSDOS */         /* Compile iNES for MSDOS/VGA    */
  18. /* #define MITSHM */        /* Use MIT SHM extensions for X  */
  19.  
  20. #ifndef UNIX
  21. #undef MITSHM
  22. #endif
  23.  
  24. #define NORAM     0x00      /* Byte to be returned from      */
  25.                             /* non-existing pages and ports  */
  26. #define MAXCHEAT  256       /* Maximal number of GG cheats   */
  27.  
  28. #define VBL_IFLAG 0x01
  29. #define LCD_IFLAG 0x02
  30. #define TIM_IFLAG 0x04
  31. #define SIO_IFLAG 0x08
  32. #define EXT_IFLAG 0x10
  33.  
  34. #define JOYPAD  RAM[0xFF00] /* Joystick: 1.1.P15.P14.P13.P12.P11.P10      */
  35. #define SIODATA RAM[0xFF01] /* Serial IO data buffer                      */
  36. #define SIOCONT RAM[0xFF02] /* Serial IO control register                 */
  37. #define DIVREG  RAM[0xFF04] /* Divider register (???)                     */
  38. #define TIMECNT RAM[0xFF05] /* Timer counter. Gen. int. when it overflows */
  39. #define TIMEMOD RAM[0xFF06] /* New value of TimeCount after it overflows  */
  40. #define TIMEFRQ RAM[0xFF07] /* Timer frequency and start/stop switch      */
  41. #define IFLAGS  RAM[0xFF0F] /* Interrupt flags: 0.0.0.JST.SIO.TIM.LCD.VBL */
  42. #define ISWITCH RAM[0xFFFF] /* Switches to enable/disable interrupts      */
  43. #define LCDCONT RAM[0xFF40] /* LCD control register                       */
  44. #define LCDSTAT RAM[0xFF41] /* LCD status register                        */
  45. #define SCROLLY RAM[0xFF42] /* Starting Y position of the background      */
  46. #define SCROLLX RAM[0xFF43] /* Starting X position of the background      */
  47. #define CURLINE RAM[0xFF44] /* Current screen line being scanned          */
  48. #define CMPLINE RAM[0xFF45] /* Gen. int. when scan reaches this line      */
  49. #define BGRDPAL RAM[0xFF47] /* Background palette                         */
  50. #define SPR0PAL RAM[0xFF48] /* Sprite palette #0                          */
  51. #define SPR1PAL RAM[0xFF49] /* Sprite palette #1                          */
  52. #define WNDPOSY RAM[0xFF4A] /* Window Y position                          */
  53. #define WNDPOSX RAM[0xFF4B] /* Window X position                          */
  54.  
  55.  
  56. extern byte Verbose;          /* Verboseness level                        */
  57.  
  58. extern byte *RAM;             /* Pointer to Z80 address space (64kB)      */
  59.  
  60. extern byte UPeriod;          /* Number of VBlanks per screen update      */
  61. extern int  VPeriod;          /* Number of Z80 cycles between VBlanks     */
  62.  
  63. extern byte LineDelay;        /* When 1, CMPLINE interrupts are delayed   */
  64. extern byte CheckCRC;         /* When 1, check cartridge CRC on loading   */
  65. extern byte AutoA,AutoB;      /* When 1, autofire emulation for A,B       */
  66.  
  67. extern char *SndName;         /* Name for the soundtrack log file         */
  68.  
  69. extern int CheatCount;        /* Current number of cheats in the list     */
  70.  
  71. extern byte BPal[4];          /* Background palette                       */
  72. extern byte SPal0[4],SPal1[4];/* Sprite palettes                          */
  73.  
  74. extern byte *ChrGen;          /* Character generator                      */
  75. extern byte *BgdTab,*WndTab;  /* Background and window character tables   */
  76.  
  77. extern byte IMask;            /* A mask to reset a bit in IFLAGS          */
  78.  
  79. /****************************************************************/
  80. /*** Initialize and start GameBoy emulation. This function    ***/
  81. /*** returns 0 in the case of failure.                        ***/
  82. /****************************************************************/
  83. int StartGB(char *CartName);
  84.  
  85. /****************************************************************/
  86. /*** Free resources allocated by StartGB().                   ***/
  87. /****************************************************************/
  88. void TrashGB(void);
  89.  
  90. /****************************************************************/
  91. /*** Add a cheat to the cheat list [call before StartGB()].   ***/
  92. /****************************************************************/
  93. int AddCheat(char *Cheat);
  94.  
  95. /****************************************************************/
  96. /*** Allocate resources needed by the machine-dependent code. ***/
  97. /************************************** TO BE WRITTEN BY USER ***/
  98. int InitMachine(void);
  99.  
  100. /****************************************************************/
  101. /*** Deallocate all resources taken by InitMachine().         ***/
  102. /************************************** TO BE WRITTEN BY USER ***/
  103. void TrashMachine(void);
  104.  
  105. /****************************************************************/
  106. /*** Refresh screen.                                          ***/
  107. /************************************** TO BE WRITTEN BY USER ***/
  108. void RefreshScreen(void);
  109.  
  110. /****************************************************************/
  111. /*** Refresh line Y [0-143].                                  ***/
  112. /************************************** TO BE WRITTEN BY USER ***/
  113. void RefreshLine(byte Y);
  114.  
  115. /****************************************************************/
  116. /*** Refresh sprites.                                         ***/
  117. /************************************** TO BE WRITTEN BY USER ***/
  118. void RefreshSprites(void);
  119.  
  120. /****************************************************************/
  121. /*** Get joystick state: START.SELECT.B.A.D.U.L.R.            ***/
  122. /************************************** TO BE WRITTEN BY USER ***/
  123. byte Joystick(void);
  124.  
  125. /****************************************************************/
  126. /*** Write value into sound chip register (Reg #0 at FF10h).  ***/
  127. /************************************** TO BE WRITTEN BY USER ***/
  128. void Sound(byte R,byte V);
  129.  
  130. /****************************************************************/
  131. /*** Send a byte onto the serial line. Returns 1 on success,  ***/
  132. /*** 0 otherwise.                                             ***/
  133. /************************************** TO BE WRITTEN BY USER ***/
  134. byte SIOSend(byte V);
  135.  
  136. /****************************************************************/
  137. /*** Receive a byte from the serial line. Returns 1 on        ***/
  138. /*** success, 0 otherwise.                                    ***/
  139. /************************************** TO BE WRITTEN BY USER ***/
  140. byte SIOReceive(byte *V);
  141.