PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
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 
34 #ifndef SNES_INTERRUPT_INCLUDE
35 #define SNES_INTERRUPT_INCLUDE
36 
37 #include <snes/snestypes.h>
38 
39 extern void *nmi_handler;
40 
42 #define INT_VBLENABLE (1 << 7)
44 #define INT_HVIRQ_H (1 << 4)
46 #define INT_HVIRQ_V (1 << 5)
48 #define INT_HVIRQ_HV (2 << 4)
50 #define INT_JOYPAD_ENABLE (1)
52 #define VBL_READY (1 << 7)
54 #define HBL_READY (1 << 6)
56 #define PAD_BUSY (1)
57 
71 #define REG_NMITIMEN (*(vuint8 *)0x4200)
72 
73 /*
74 
75 4207h/4208h - HTIMEL/HTIMEH - H-Count Timer Setting (W)
76 
77  15-9 Not used
78  8-0 H-Count Timer Value (0..339) (+/-1 in long/short lines) (0=leftmost)
79 
80 The H/V-IRQ flag in Bit7 of TIMEUP, Port 4211h gets set when the H-Counter gets equal to the H-Count register value.
81 
82 4209h/420Ah - VTIMEL/VTIMEH - V-Count Timer Setting (W)
83 
84  15-9 Not used
85  8-0 V-Count Timer Value (0..261/311, NTSC/PAL) (+1 in interlace) (0=top)
86 
87 The H/V-IRQ flag in Bit7 of TIMEUP, Port 4211h gets set when the V-Counter gets equal to the V-Count register value.
88 */
89 
108 #define REG_RDNMI (*(vuint8 *)0x4210)
109 
125 #define REG_TIMEUP (*(vuint8 *)0x4211)
126 
140 #define REG_HVBJOY (*(vuint8 *)0x4212)
141 
150 #define nmiSet(handler) nmi_handler = handler;
151 
158 void WaitForVBlank(void);
159 
164 #define WaitVBLFlag \
165  while ((REG_HVBJOY & VBL_READY)) \
166  ; \
167  while (!(REG_HVBJOY & VBL_READY)) \
168  { \
169  };
170 
178 void WaitNVBlank(u16 ntime);
179 
180 #endif // SNES_INTERRUPTS_INCLUDE
void WaitForVBlank(void)
Wait for vblank interrupt
void WaitNVBlank(u16 ntime)
Wait for vblank interrupt ntime times
Custom types used by libsnes.