|
|
1.1 root 1: /*
2: Hatari - video.c
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
6:
7: Video hardware handling. This code handling all to do with the video chip. So, we handle
8: VBLs, HBLs, copying the ST screen to a buffer to simulate the TV raster trace, border
9: removal, palette changes per HBL, the 'video address pointer' etc...
10: */
11:
12: #include <SDL.h>
13:
14: #include "main.h"
15: #include "decode.h"
16: #include "configuration.h"
17: #include "int.h"
18: #include "keymap.h"
19: #include "m68000.h"
20: #include "memAlloc.h"
21: #include "screen.h"
22: #include "shortcut.h"
23: #include "stMemory.h"
24: #include "video.h"
25: #include "hatari-glue.h"
26:
27: long VideoAddress; /* Address of video display in ST screen space */
28: unsigned long VideoBase; /* Base address in ST Ram for screen(read on each VBL) */
29: unsigned char *VideoRaster; /* Pointer to Video raster, after VideoBase in PC address space. Use to copy data on HBL */
30: int SyncHandler_Value; /* Value to pass to 'Video_SyncHandler_xxxx' functions */
31: int nScreenRefreshRate = 50; /* 50 or 60 Hz in color, 70 Hz in mono */
32:
33:
34: /*-----------------------------------------------------------------------*/
35: /*
36: Reset video chip
37: */
38: void Video_Reset(void)
39: {
40: /* Reset addresses */
41: VideoBase = 0L;
42: VideoRaster = STRam;
43: }
44:
45: /*-----------------------------------------------------------------------*/
46: /*
47: Read Video address pointer(from current cycle count), and return 24-bit address in 'ebx'
48: */
49: unsigned long Video_ReadAddress(void)
50: {
51: VideoAddress = VideoBase;
52: return( VideoAddress );
53: }
54:
55: /*
56: * 68k prog must call host screen_draw in its vblank.
57: */
58: void Video_InterruptHandler_VBL(void)
59: {
60: /* Clear any key presses which are due to be de-bounced (held for one ST frame) */
61: Keymap_DebounceAllKeys();
62: /* Check 'Function' keys, so if press F12 we update screen correctly to Window! */
63: ShortCut_CheckKeys();
64:
65: MakeSR();
66: if ((4>FIND_IPL) && (4 > intlev ())) /* Vertical blank, level 4! */
67: {
68: ExceptionVector = EXCEPTION_VBLANK;
69: M68000_Exception(); /* VBL interrupt */
70: }
71: else
72: {
73: /* Higher priority interrupt is currently being executed(eg MFP). Set VBL to occur later */
74: if (!Int_InterruptActive(INTERRUPT_VIDEO_VBL_PENDING))
75: Int_AddAbsoluteInterrupt(100,INTERRUPT_VIDEO_VBL_PENDING);
76: }
77:
78: /* And handle any messages, check for quit message */
79: Main_EventHandler(); /* Process messages, set 'bQuitProgram' if user tries to quit */
80: /* Pass NULL interrupt function to quit cleanly */
81: if (bQuitProgram) Int_AddAbsoluteInterrupt(4, 0L);
82: }
83:
84:
85: /*-----------------------------------------------------------------------*/
86: /*
87: This doesn't make sense... I always thought if a 68000 interrupt, eg the VBL, occurs while a
88: higher priority interrupt was in service the interrupt was ignored. This does not seem to be
89: the case. This really needs checking on a real ST, but I have noticed some menu discs run
90: sound routines from the MFP timers which overlap the VBL, yet the VBL still occurs...
91: */
92: void Video_InterruptHandler_VBL_Pending(void)
93: {
94: /* Remove this interrupt from list and re-order */
95: Int_AcknowledgeInterrupt();
96:
97: MakeSR();
98: /* Check if can execute VBL */
99: if ((4>FIND_IPL) && (4 > intlev ())) /* Vertical blank, level 4! */
100: {
101: ExceptionVector = EXCEPTION_VBLANK;
102: M68000_Exception(); /* VBL interrupt */
103: }
104: else
105: Int_AddAbsoluteInterrupt(100,INTERRUPT_VIDEO_VBL_PENDING);
106: }
107:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.