⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m6502.h

📁 ESS3890+SL原代码(1*16内存)
💻 H
字号:
/* Copyright 2001, ESS Technology, Inc./* SCCSID @(#)m6502.h	1.7 04/13/02 *//* * $Log$ *//** M6502: portable 6502 emulator ****************************//**                                                         **//**                         M6502.h                         **//**                                                         **//** This file contains declarations relevant to emulation   **//** of 6502 CPU.                                            **//**                                                         **//** Copyright (C) Marat Fayzullin 1996-2000                 **//**               Alex Krasivsky  1996                      **//**     You are not allowed to distribute this software     **//**     commercially. Please, notify me, if you make any    **/   /**     changes to this file.                               **//*************************************************************/#ifdef INES#ifndef M6502_H#define M6502_H                               /* Compilation options:       *//* #define FAST_RDOP */        /* Separate Op6502()/Rd6502() *//* #define DEBUG */            /* Compile debugging version  *//* #define LSB_FIRST */        /* Compile for low-endian CPU */                               /* Loop6502() returns:        */#define NES_INT_NONE  0            /* No interrupt required      */#define NES_INT_IRQ	  1            /* Standard IRQ interrupt     */#define NES_INT_NMI	  2            /* Non-maskable interrupt     */#define NES_INT_QUIT  3            /* Exit the emulation         */                               /* 6502 status flags:         */#define	NES_C_FLAG	  0x01         /* 1: Carry occured           */#define	NES_Z_FLAG	  0x02         /* 1: Result is zero          */#define	NES_I_FLAG	  0x04         /* 1: Interrupts disabled     */#define	NES_D_FLAG	  0x08         /* 1: Decimal mode            */#define	NES_B_FLAG	  0x10         /* Break [0 on stk after int] */#define	NES_R_FLAG	  0x20         /* Always 1                   */#define	NES_V_FLAG	  0x40         /* 1: Overflow occured        */#define	NES_N_FLAG	  0x80         /* 1: Result is negative      *//** Simple Datatypes *****************************************//** NOTICE: sizeof(byte)=1 and sizeof(word)=2               **//*************************************************************/#ifndef BYTE_TYPE_DEFINED#define BYTE_TYPE_DEFINEDtypedef unsigned char byte;#endif#ifndef WORD_TYPE_DEFINED#define WORD_TYPE_DEFINEDtypedef unsigned short word;#endif/** Structured Datatypes *************************************//** NOTICE: #define LSB_FIRST for machines where least      **//**         signifcant byte goes first.                     **//*************************************************************/#if 0typedef union{#ifdef LSB_FIRST  struct { byte l,h; } B;#else  struct { byte h,l; } B;#endif  word W;} NES_pair;#endiftypedef struct{  int P;  byte S;     /* CPU registers and program counter   */  int IPeriod,ICount; /* Set IPeriod to number of CPU cycles */                      /* between calls to Loop6502()         */  int IRequest;      /* Set to the NES_INT_IRQ when pending IRQ */  int AfterCLI;      /* Private, don't touch                */  int IBackup;        /* Private, don't touch                */} M6502;/** Reset6502() **********************************************//** This function can be used to reset the registers before **//** starting execution with Run6502(). It sets registers to **//** their initial values.                                   **//*************************************************************/void Reset6502(M6502 *R);/** Int6502() ************************************************//** This function will generate interrupt of a given type.  **//** NES_INT_NMI will cause a non-maskable interrupt. NES_INT_IRQ    **//** will cause a normal interrupt, unless NES_I_FLAG set in R.  **//*************************************************************/void Int6502(M6502 *R,register int Type);/** Run6502() ************************************************//** This function will run 6502 code until Loop6502() call  **//** returns NES_INT_QUIT. It will return the PC at which        **//** emulation stopped, and current register values in R.    **//*************************************************************/word Run6502(register M6502 *R);word Run6502_R(register M6502 *R);/** Rd6502()/Wr6502/Op6502() *********************************//** These functions are called when access to RAM occurs.   **//** They allow to control memory access. Op6502 is the same **//** as Rd6502, but used to read *opcodes* only, when many   **//** checks can be skipped to make it fast. It is only       **//** required if there is a #define FAST_RDOP.               **//************************************ TO BE WRITTEN BY USER **/void Wr6502(register int Addr,register int Value);int Rd6502(register int Addr);/** Loop6502() ***********************************************//** 6502 emulation calls this function periodically to      **//** check if the system hardware requires any interrupts.   **//** This function must return one of following values:      **//** NES_INT_NONE, NES_INT_IRQ, NES_INT_NMI, or NES_INT_QUIT to exit the     **//** emulation loop.                                         **//************************************ TO BE WRITTEN BY USER **/int Loop6502(M6502 *R);#endif /* M6502_H */#endif /*INES*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -