nes.h
1 /* 2 ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) 3 ** 4 ** 5 ** This program is free software; you can redistribute it and/or 6 ** modify it under the terms of version 2 of the GNU Library General 7 ** Public License as published by the Free Software Foundation. 8 ** 9 ** This program is distributed in the hope that it will be useful, 10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 ** Library General Public License for more details. To obtain a 13 ** copy of the GNU Library General Public License, write to the Free 14 ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 ** 16 ** Any permitted reproduction of these routines, in whole or in part, 17 ** must bear this legend. 18 ** 19 ** 20 ** nes.h 21 ** 22 ** NES hardware related definitions / prototypes 23 ** $Id: nes.h,v 1.2 2001/04/27 14:37:11 neil Exp $ 24 */ 25 26 #ifndef _NES_H_ 27 #define _NES_H_ 28 29 #include "noftypes.h" 30 #include "nes_apu.h" 31 #include "nes_mmc.h" 32 #include "nes_ppu.h" 33 #include "nes_rom.h" 34 #include "nes6502.h" 35 #include "bitmap.h" 36 37 /* Visible (NTSC) screen height */ 38 #ifndef NES_VISIBLE_HEIGHT 39 #define NES_VISIBLE_HEIGHT 224 40 #endif /* !NES_VISIBLE_HEIGHT */ 41 #define NES_SCREEN_WIDTH 256 42 #define NES_SCREEN_HEIGHT 240 43 44 /* NTSC = 60Hz, PAL = 50Hz */ 45 #ifdef PAL 46 #define NES_REFRESH_RATE 50 47 #else /* !PAL */ 48 #define NES_REFRESH_RATE 60 49 #endif /* !PAL */ 50 51 #define MAX_MEM_HANDLERS 32 52 53 enum 54 { 55 SOFT_RESET, 56 HARD_RESET 57 }; 58 59 60 typedef struct nes_s 61 { 62 /* hardware things */ 63 nes6502_context *cpu; 64 nes6502_memread readhandler[MAX_MEM_HANDLERS]; 65 nes6502_memwrite writehandler[MAX_MEM_HANDLERS]; 66 67 ppu_t *ppu; 68 apu_t *apu; 69 mmc_t *mmc; 70 rominfo_t *rominfo; 71 72 /* video buffer */ 73 /* For the ESP32, it costs too much memory to render to a separate buffer and blit that to the main buffer. 74 Instead, the code has been modified to directly grab the primary buffer from the video subsystem and render 75 there, saving us about 64K of memory. */ 76 // bitmap_t *vidbuf; 77 78 bool fiq_occurred; 79 uint8 fiq_state; 80 int fiq_cycles; 81 82 int scanline; 83 84 /* Timing stuff */ 85 float scanline_cycles; 86 bool autoframeskip; 87 88 /* control */ 89 bool poweroff; 90 bool pause; 91 92 } nes_t; 93 94 95 extern int nes_isourfile(const char *filename); 96 97 /* temp hack */ 98 extern nes_t *nes_getcontextptr(void); 99 100 /* Function prototypes */ 101 extern void nes_getcontext(nes_t *machine); 102 extern void nes_setcontext(nes_t *machine); 103 104 extern nes_t *nes_create(void); 105 extern void nes_destroy(nes_t **machine); 106 extern int nes_insertcart(const char *filename, nes_t *machine); 107 108 extern void nes_setfiq(uint8 state); 109 extern void nes_nmi(void); 110 extern void nes_irq(void); 111 extern void nes_emulate(void); 112 113 extern void nes_reset(int reset_type); 114 115 extern void nes_poweroff(void); 116 extern void nes_togglepause(void); 117 118 #endif /* _NES_H_ */ 119 120 /* 121 ** $Log: nes.h,v $ 122 ** Revision 1.2 2001/04/27 14:37:11 neil 123 ** wheeee 124 ** 125 ** Revision 1.1.1.1 2001/04/27 07:03:54 neil 126 ** initial 127 ** 128 ** Revision 1.8 2000/11/26 15:51:13 matt 129 ** frame IRQ emulation 130 ** 131 ** Revision 1.7 2000/11/25 20:30:39 matt 132 ** scanline emulation simplifications/timing fixes 133 ** 134 ** Revision 1.6 2000/11/25 01:52:17 matt 135 ** bool stinks sometimes 136 ** 137 ** Revision 1.5 2000/11/09 14:07:28 matt 138 ** state load fixed, state save mostly fixed 139 ** 140 ** Revision 1.4 2000/10/29 14:36:45 matt 141 ** nes_clearframeirq is static 142 ** 143 ** Revision 1.3 2000/10/25 01:23:08 matt 144 ** basic system autodetection 145 ** 146 ** Revision 1.2 2000/10/25 00:23:16 matt 147 ** makefiles updated for new directory structure 148 ** 149 ** Revision 1.1 2000/10/24 12:20:28 matt 150 ** changed directory structure 151 ** 152 ** Revision 1.26 2000/10/23 17:51:10 matt 153 ** adding fds support 154 ** 155 ** Revision 1.25 2000/10/23 15:53:08 matt 156 ** better system handling 157 ** 158 ** Revision 1.24 2000/10/22 19:16:15 matt 159 ** more sane timer ISR / autoframeskip 160 ** 161 ** Revision 1.23 2000/10/21 19:26:59 matt 162 ** many more cleanups 163 ** 164 ** Revision 1.22 2000/10/10 13:58:15 matt 165 ** stroustrup squeezing his way in the door 166 ** 167 ** Revision 1.21 2000/10/08 17:53:36 matt 168 ** minor accuracy changes 169 ** 170 ** Revision 1.20 2000/09/15 04:58:07 matt 171 ** simplifying and optimizing APU core 172 ** 173 ** Revision 1.19 2000/09/08 11:57:29 matt 174 ** no more nes_fiq 175 ** 176 ** Revision 1.18 2000/08/11 02:43:50 matt 177 ** moved frame irq stuff out of APU into here 178 ** 179 ** Revision 1.17 2000/07/31 04:27:59 matt 180 ** one million cleanups 181 ** 182 ** Revision 1.16 2000/07/30 04:32:32 matt 183 ** emulation of the NES frame IRQ 184 ** 185 ** Revision 1.15 2000/07/27 01:17:09 matt 186 ** nes_insertrom -> nes_insertcart 187 ** 188 ** Revision 1.14 2000/07/26 21:36:16 neil 189 ** Big honkin' change -- see the mailing list 190 ** 191 ** Revision 1.13 2000/07/25 02:25:53 matt 192 ** safer xxx_destroy calls 193 ** 194 ** Revision 1.12 2000/07/23 15:13:13 matt 195 ** autoframeskip is now a member variable of nes_t 196 ** 197 ** Revision 1.11 2000/07/17 05:12:55 matt 198 ** nes_ppu.c is no longer a scary place to be-- cleaner & faster 199 ** 200 ** Revision 1.10 2000/07/17 01:52:28 matt 201 ** made sure last line of all source files is a newline 202 ** 203 ** Revision 1.9 2000/07/16 09:48:58 neil 204 ** Make visible height compile-time configurable in the Makefile 205 ** 206 ** Revision 1.8 2000/07/11 04:31:55 matt 207 ** less magic number nastiness for screen dimensions 208 ** 209 ** Revision 1.7 2000/07/11 02:40:36 matt 210 ** forgot to remove framecounter 211 ** 212 ** Revision 1.6 2000/07/11 02:38:25 matt 213 ** encapsulated memory address handlers into nes/nsf 214 ** 215 ** Revision 1.5 2000/07/10 13:50:50 matt 216 ** added function nes_irq() 217 ** 218 ** Revision 1.4 2000/06/09 15:12:26 matt 219 ** initial revision 220 ** 221 */