Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[24a79e]: src / libxineadec / nosefart / nes6502.h Maximize Restore History

Download this file

nes6502.h    158 lines (135 with data), 4.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com)
**
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of version 2 of the GNU Library General
** Public License as published by the Free Software Foundation.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Library General Public License for more details. To obtain a
** copy of the GNU Library General Public License, write to the Free
** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
** Any permitted reproduction of these routines, in whole or in part,
** must bear this legend.
**
**
** nes6502.h
**
** NES custom 6502 CPU definitions / prototypes
** $Id: nes6502.h,v 1.2 2003/12/05 15:55:01 f1rmb Exp $
*/
/* straitm */
#include "types.h"
/* NOTE: 16-bit addresses avoided like the plague: use 32-bit values
** wherever humanly possible
*/
#ifndef _NES6502_H_
#define _NES6502_H_
/* Define this to enable decimal mode in ADC / SBC (not needed in NES) */
/*#define NES6502_DECIMAL*/
/* number of bank pointers the CPU emulation core handles */
#ifdef NSF_PLAYER
#define NES6502_4KBANKS
#endif
#ifdef NES6502_4KBANKS
#define NES6502_NUMBANKS 16
#define NES6502_BANKSHIFT 12
#else
#define NES6502_NUMBANKS 8
#define NES6502_BANKSHIFT 13
#endif
#define NES6502_BANKMASK ((0x10000 / NES6502_NUMBANKS) - 1)
/* Add memory access control flags. This is a ram shadow memory that holds
* for each memory bytes access flags for read, write and execute access.
* The nes6502_mem_access holds all new access (all mode all location). It is
* used to determine if the player has loop in playing time calculation.
*/
#ifdef NES6502_MEM_ACCESS_CTRL
extern uint8 nes6502_mem_access;
# define NES6502_READ_ACCESS 1
# define NES6502_WRITE_ACCESS 2
# define NES6502_EXE_ACCESS 4
#endif /* #ifdef NES6502_MEM_ACCESS_CTRL */
/* P (flag) register bitmasks */
#define N_FLAG 0x80
#define V_FLAG 0x40
#define R_FLAG 0x20 /* Reserved, always 1 */
#define B_FLAG 0x10
#define D_FLAG 0x08
#define I_FLAG 0x04
#define Z_FLAG 0x02
#define C_FLAG 0x01
/* Vector addresses */
#define NMI_VECTOR 0xFFFA
#define RESET_VECTOR 0xFFFC
#define IRQ_VECTOR 0xFFFE
/* cycle counts for interrupts */
#define INT_CYCLES 7
#define RESET_CYCLES 6
#define NMI_MASK 0x01
#define IRQ_MASK 0x02
/* Stack is located on 6502 page 1 */
#define STACK_OFFSET 0x0100
typedef struct
{
uint32 min_range, max_range;
uint8 (*read_func)(uint32 address);
} nes6502_memread;
typedef struct
{
uint32 min_range, max_range;
void (*write_func)(uint32 address, uint8 value);
} nes6502_memwrite;
typedef struct
{
uint8 * mem_page[NES6502_NUMBANKS]; /* memory page pointers */
#ifdef NES6502_MEM_ACCESS_CTRL
uint8 * acc_mem_page[NES6502_NUMBANKS]; /* memory access page pointer */
#endif
nes6502_memread *read_handler;
nes6502_memwrite *write_handler;
int dma_cycles;
uint32 pc_reg;
uint8 a_reg, p_reg, x_reg, y_reg, s_reg;
uint8 int_pending;
} nes6502_context;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Functions which govern the 6502's execution */
extern void nes6502_init(void);
extern void nes6502_reset(void);
extern int nes6502_execute(int total_cycles);
extern void nes6502_nmi(void);
extern void nes6502_irq(void);
extern uint8 nes6502_getbyte(uint32 address);
extern uint32 nes6502_getcycles(boolean reset_flag);
extern void nes6502_setdma(int cycles);
#ifdef NES6502_MEM_ACCESS_CTRL
extern void nes6502_chk_mem_access(uint8 * access, int flags);
#else
#define nes6502_chk_mem_access(access,flags)
#endif
/* Context get/set */
extern void nes6502_setcontext(nes6502_context *cpu);
extern void nes6502_getcontext(nes6502_context *cpu);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _NES6502_H_ */
/*
** $Log: nes6502.h,v $
** Revision 1.2 2003/12/05 15:55:01 f1rmb
** cleanup phase II. use xprintf when it's relevant, use xine_xmalloc when it's relevant too. Small other little fix (can't remember). Change few internal function prototype because it xine_t pointer need to be used if some xine's internal sections. NOTE: libdvd{nav,read} is still too noisy, i will take a look to made it quit, without invasive changes. To be continued...
**
** Revision 1.1 2003/01/08 07:04:35 tmmm
** initial import of Nosefart sources
**
** Revision 1.4 2000/06/09 15:12:25 matt
** initial revision
**
*/