PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
Loading...
Searching...
No Matches
interrupt.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------------------
2
3 Interrupt registers and vector pointers
4
5 Copyright (C) 2012-2017
6 Alekmaul
7
8 This software is provided 'as-is', without any express or implied
9 warranty. In no event will the authors be held liable for any
10 damages arising from the use of this software.
11
12 Permission is granted to anyone to use this software for any
13 purpose, including commercial applications, and to alter it and
14 redistribute it freely, subject to the following restrictions:
15
16 1. The origin of this software must not be misrepresented; you
17 must not claim that you wrote the original software. If you use
18 this software in a product, an acknowledgment in the product
19 documentation would be appreciated but is not required.
20
21 2. Altered source versions must be plainly marked as such, and
22 must not be misrepresented as being the original software.
23
24 3. This notice may not be removed or altered from any source
25 distribution.
26
27
28---------------------------------------------------------------------------------*/
29
64#ifndef SNES_INTERRUPT_INCLUDE
65#define SNES_INTERRUPT_INCLUDE
66
67#include <snes/snestypes.h>
68
83extern u8 vblank_flag;
84
97extern u16 lag_frame_counter;
98
113extern void *nmi_handler;
114
116#define INT_VBLENABLE (1 << 7)
118#define INT_HVIRQ_H (1 << 4)
120#define INT_HVIRQ_V (1 << 5)
122#define INT_HVIRQ_HV (2 << 4)
124#define INT_JOYPAD_ENABLE (1)
126#define VBL_READY (1 << 7)
128#define HBL_READY (1 << 6)
130#define PAD_BUSY (1)
131
145#define REG_NMITIMEN (*(vuint8 *)0x4200)
146
147/*
148
1494207h/4208h - HTIMEL/HTIMEH - H-Count Timer Setting (W)
150
151 15-9 Not used
152 8-0 H-Count Timer Value (0..339) (+/-1 in long/short lines) (0=leftmost)
153
154The H/V-IRQ flag in Bit7 of TIMEUP, Port 4211h gets set when the H-Counter gets equal to the H-Count register value.
155
1564209h/420Ah - VTIMEL/VTIMEH - V-Count Timer Setting (W)
157
158 15-9 Not used
159 8-0 V-Count Timer Value (0..261/311, NTSC/PAL) (+1 in interlace) (0=top)
160
161The H/V-IRQ flag in Bit7 of TIMEUP, Port 4211h gets set when the V-Counter gets equal to the V-Count register value.
162*/
163
182#define REG_RDNMI (*(vuint8 *)0x4210)
183
199#define REG_TIMEUP (*(vuint8 *)0x4211)
200
214#define REG_HVBJOY (*(vuint8 *)0x4212)
215
231void nmiSet(void (*vblankRoutine)(void));
232
242void WaitForVBlank(void);
243
248#define WaitVBLFlag \
249 while ((REG_HVBJOY & VBL_READY)) \
250 ; \
251 while (!(REG_HVBJOY & VBL_READY)) \
252 { \
253 };
254
262void WaitNVBlank(u16 ntime);
263
264#endif // SNES_INTERRUPTS_INCLUDE
void nmiSet(void(*vblankRoutine)(void))
Sets the nmi_handler (VBlank routine).
u16 lag_frame_counter
Lag-frame counter.
void * nmi_handler
VBlank routine.
u8 vblank_flag
VBlank ISR flag.
void WaitForVBlank(void)
Waits for a VBlank interrupt.
void WaitNVBlank(u16 ntime)
Wait for vblank interrupt ntime times
Custom types used by libsnes.