📄 nes.h
字号:
/* Copyright 2001, ESS Technology, Inc./* SCCSID @(#)nes.h 1.13 01/25/02 *//* * $Log$ *//** iNES: portable NES emulator ******************************//** **//** NES.h **//** **//** This file contains declarations relevant to the drivers **//** and NES emulation itself. See M6502.h for #defines **//** related to 6502 emulation. **//** **//** Copyright (C) Marat Fayzullin 1996-2000 **//** The contents of this file are property of Marat **//** Fayzullin and should only be used as agreed with **//** him. The file is confidential. Absolutely no **//** distribution allowed. **//*************************************************************/#ifdef INES#ifndef NES_H#define NES_H#include "m6502.h" /* 6502 emulation declarations */#define MAXSPRITES 32 /* Maximal number sprites/line */#define VBLANKON (PPU[0]&0x80)#define HBLANKON (PPU[0]&0x40)#define SPRITES16 (PPU[0]&0x20)#define VERTWRITE (PPU[0]&0x04)#define CURSCREEN (PPU[0]&0x03)#define SPRITESON (PPU[1]&0x10)#define SCREENON (PPU[1]&0x08)#define LEFTSPR (PPU[1]&0x04)#define LEFTIMG (PPU[1]&0x02)#define BGCOLOR (PPU[1]>>5) /* Sprite attributes: */#define S_VFLIP(Spr) (Spr[2]&0x80) /* 1: Vertical flip */#define S_HFLIP(Spr) (Spr[2]&0x40) /* 1: Horizontal flip */#define S_BEHIND(Spr) (Spr[2]&0x20) /* 1: Behind backgrnd */#define S_FLIP(Spr) (Spr[2]&0xC0) /* Combined flip bits */#define S_COLOR(Spr) (Spr[2]&0x03) /* Color palette 0..3 */ /* Common bit states: */#define BIT_SET(N) BitState|=(N) /* Set BitState bit */#define BIT_RES(N) BitState&=~(N) /* Reset BitState bit */#define BIT_AIM 0x01 /* Light gun aim */#define BIT_GUN 0x02 /* Light gun trigger */#define BIT_COIN 0x04 /* VS System coin in */ /* Joypad buttons: */#define JST_A 0x01 /* [A] button */#define JST_B 0x02 /* [B] button */#define JST_SELECT 0x04 /* [SELECT] button */#define JST_START 0x08 /* [START] button */#define JST_UP 0x10 /* [UP] pad */#define JST_DOWN 0x20 /* [DOWN] pad */#define JST_LEFT 0x40 /* [LEFT] pad */#define JST_RIGHT 0x80 /* [RIGHT] pad */#define JST_ALL 0xFF /* All joypad buttons */byte *P_Palette;byte *P_ZNTable;byte *P_Conv;byte *P_SRAM;int *Sprites;int *Sun_Tbl;int ScanLine ; /* Currently scanned line */int NCURLINE ; /* Current scanline of the screen */int LastHit ; /* Last line where HitFlag went up */int BitState ; /* Bit states: DISK.COIN.GUN.AIM */ int NSCROLLX ; /* Horizontal scroll offset (public) */int NSCROLLY ; /* Vertical scroll offset (private) */int JoyState[2] ;int JoyCount[2] ;int VKey ; /* NES_VRAM Address and Scroll keys */int SKey ;int JKey ; /*Joystick strobe key*/typedef struct { int VPeriod ; /* Cycles between VBlanks (262*341/3) */ int HPeriod ; /* Cycles between HBlanks (341/3) */ int PALVideo ; /* Video system type: 1=PAL, 0=NTSC */ int PalNum ; /* Number of currently used palette */ int FirstSprite ; /* First sprite to show */ int VROMPages ; /* Number of VROM banks and mask */ int VROMMask ; int ROMPages ; /* Number of NES_ROM banks and mask */ int ROMMask ; int PageN[4] ; /* Current NES_ROM pages */ int VPageN[8] ; /* Current VROM pages */ int UCount ; int PCount ; byte *VPage[16]; /* 16x1kB pointers to NES_VRAM */ unsigned char XPal[64] ; byte ChrPal[16], SprPal[16]; int spr_refresh; int chr_refresh; byte ROMType ; /* Type of NES_ROM bank switching */ byte VMirroring ; /* 1: Vertical mirroring (2000->2800) */ byte FourScreens ; /* 1: All four screen buffers present */ byte Battery ; /* 1: Battery-backed RAM at 6000-7FFF */ byte Trainer ; /* 1: 512-byte trainer at 7000-71FF */ byte VSSystem ; /* 1: VS System emulation */ byte Rev0, Rev1; } *PINES;PINES ines;/*************************************************************/byte *NES_ROM; /* NES_ROM storage (16kB banks) */byte *VROM; /* VROM storage (8kB banks) */byte *NES_RAM,*NES_VRAM; /* 64kB NES_CPU address space, 16kB NES_VRAM */M6502 NES_CPU; /* 6502 NES_CPU registers and state */byte *NES_Page[8]; /* 8x8kB pointers to RAM */byte PPU[8]; /* PPU registers */int VAddr; /* NES_VRAM access address */int VData; /* NES_VRAM data buffer for reads */byte *NES_ChrGen,*NES_SprGen; /* Pattern Tables for characters and sprites */byte *NES_ChrCol,*NES_SprCol; /* Color Tables for characters and sprites */int Delay_Period;int (*SelectROM)(register int A,register int V);byte *FYH_RAM, *FYH_PAGE[8];/** StartNES() ***********************************************//** Allocate memory, load ROM images, initialize hardware, **//** CPU and start the emulation. This function returns 0 in **//** the case of failure. **//*************************************************************/int StartNES();/** TrashNES() ***********************************************//** Free memory allocated by StartNES(). **//*************************************************************/void TrashNES(void);/** ResetNES() ***********************************************//** Reset NES CPU and hardware. **//*************************************************************/void ResetNES(void);/************************************ TO BE WRITTEN BY USER **/int NES_InitMachine(void);/** TrashMachine() *******************************************//** Deallocate all resources taken by InitMachine(). **//************************************ TO BE WRITTEN BY USER **/void NES_TrashMachine(void);/** RefreshLine() ********************************************//** Refresh a single scanline on screen, and draw sprites **//** in it. Returns 1 if intersection of sprite #0 with the **//** background occurs, 0 otherwise. **//************************************ TO BE WRITTEN BY USER **/int NES_RefreshLine(int DY,int SY);#endif /* NES_H */#endif /*INES*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -