|
|
1.1 root 1: /*
2: 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: */
8: const char Video_fileid[] = "Hatari video.c : " __DATE__ " " __TIME__;
9:
10: #include <SDL_endian.h>
11:
12: #include "main.h"
13: #include "configuration.h"
14: #include "cycles.h"
15: #include "cycInt.h"
16: #include "ioMem.h"
17: #include "m68000.h"
18: #include "memorySnapShot.h"
19: #include "screen.h"
20: #include "screenSnapShot.h"
21: #include "shortcut.h"
22: #include "nextMemory.h"
23: #include "video.h"
24: #include "avi_record.h"
25:
26:
27: /*--------------------------------------------------------------*/
28: /* Local functions prototypes */
29: /*--------------------------------------------------------------*/
30:
31: static void Video_SetSystemTimings ( void );
32:
33: static Uint32 Video_CalculateAddress ( void );
34: static int Video_GetMMUStartCycle ( int DisplayStartCycle );
35: static void Video_WriteToShifter ( Uint8 Res );
36: static void Video_Sync_SetDefaultStartEnd ( Uint8 Freq , int HblCounterVideo , int LineCycles );
37:
38: static int Video_HBL_GetPos ( void );
39: static void Video_EndHBL ( void );
40: static void Video_StartHBL ( void );
41:
42: static void Video_StoreFirstLinePalette(void);
43: static void Video_StoreResolution(int y);
44: static void Video_CopyScreenLineMono(void);
45: static void Video_CopyScreenLineColor(void);
46: static void Video_CopyVDIScreen(void);
47: static void Video_SetHBLPaletteMaskPointers(void);
48:
49: static void Video_UpdateTTPalette(int bpp);
50: static void Video_DrawScreen(void);
51:
52: static void Video_ResetShifterTimings(void);
53: static void Video_InitShifterLines(void);
54: static void Video_ClearOnVBL(void);
55:
56: static void Video_AddInterrupt ( int Pos , interrupt_id Handler );
57: static void Video_AddInterruptHBL ( int Pos );
58:
59: static void Video_ColorReg_WriteWord(Uint32 addr);
60:
61: int nScanlinesPerFrame = 400; /* Number of scan lines per frame */
62: int nCyclesPerLine = 512;
63:
64: /*-----------------------------------------------------------------------*/
65: /**
66: * Save/Restore snapshot of local variables('MemorySnapShot_Store' handles type)
67: */
68: void Video_MemorySnapShot_Capture(bool bSave)
69: {
70: }
71:
72:
73: /*-----------------------------------------------------------------------*/
74: /**
75: * Reset video chip
76: */
77: void Video_Reset(void)
78: {
79: Video_StartInterrupts(0);
80: }
81:
82:
83: /*-----------------------------------------------------------------------*/
84: /**
85: * Reset the GLUE chip responsible for generating the H/V sync signals.
86: * When the 68000 RESET instruction is called, frequency and resolution
87: * should be reset to 0.
88: */
89: void Video_Reset_Glue(void)
90: {
91: }
92:
93:
94: /*-----------------------------------------------------------------------*/
95: /*
96: * Set specific video timings, depending on the system being emulated.
97: */
98: static void Video_SetSystemTimings(void)
99: {
100: Video_StartInterrupts(0);
101: }
102:
103:
104: /*-----------------------------------------------------------------------*/
105: /**
106: * Convert the elapsed number of cycles since the start of the VBL
107: * into the corresponding HBL number and the cycle position in the current
108: * HBL. We use the starting cycle position of the closest HBL to compute
109: * the cycle position on the line (this allows to mix lines with different
110: * values for nCyclesPerLine).
111: * We can have 2 cases on the limit where the real video line count can be
112: * different from nHBL :
113: * - when reading video address between cycle 0 and 12, LineCycle will be <0,
114: * so we need to use the data from line nHBL-1
115: * - if LineCycle >= nCyclesPerLine, this means the HBL int was not processed
116: * yet, so the video line number is in fact nHBL+1
117: */
118:
119: void Video_ConvertPosition ( int FrameCycles , int *pHBL , int *pLineCycles )
120: {
121: }
122:
123:
124: void Video_GetPosition ( int *pFrameCycles , int *pHBL , int *pLineCycles )
125: {
126: }
127:
128:
129: void Video_GetPosition_OnWriteAccess ( int *pFrameCycles , int *pHBL , int *pLineCycles )
130: {
131: }
132:
133:
134: void Video_GetPosition_OnReadAccess ( int *pFrameCycles , int *pHBL , int *pLineCycles )
135: {
136: }
137:
138:
139: /*-----------------------------------------------------------------------*/
140: /**
141: * Calculate and return video address pointer.
142: */
143: static Uint32 Video_CalculateAddress ( void )
144: {
145: return 0;
146: }
147:
148:
149: /*-----------------------------------------------------------------------*/
150: /**
151: * Calculate the cycle where the STF/STE's MMU starts reading
152: * data to send them to the shifter.
153: * On STE, if hscroll is used, prefetch will cause this position to
154: * happen 16 cycles earlier.
155: * This function should use the same logic as in Video_CalculateAddress.
156: * NOTE : this function is not completly accurate, as even when there's
157: * no hscroll (on STF) the mmu starts reading 16 cycles before display starts.
158: * But it's good enough to emulate writing to ff8205/07/09 on STE.
159: */
160: static int Video_GetMMUStartCycle ( int DisplayStartCycle )
161: {
162: return 0;
163: }
164:
165:
166: /*-----------------------------------------------------------------------*/
167: /**
168: * Write to VideoShifter (0xff8260), resolution bits
169: */
170: static void Video_WriteToShifter ( Uint8 Res )
171: {
172: }
173:
174:
175:
176: /*-----------------------------------------------------------------------*/
177: /**
178: * Set some default values for DisplayStartCycle/DisplayEndCycle
179: * when changing frequency in lo/med res (testing orders are important
180: * because the line can already have some borders changed).
181: * This is necessary as some freq changes can modify start/end
182: * even if they're not made at the exact borders' positions.
183: * These values will be modified later if some borders are changed.
184: */
185: static void Video_Sync_SetDefaultStartEnd ( Uint8 Freq , int HblCounterVideo , int LineCycles )
186: {
187: }
188:
189:
190: /*-----------------------------------------------------------------------*/
191: /**
192: * Write to VideoSync (0xff820a), Hz setting
193: */
194: void Video_Sync_WriteByte ( void )
195: {
196: }
197:
198:
199: /*-----------------------------------------------------------------------*/
200: /**
201: * Compute the cycle position where the HBL should happen on each line.
202: * In low/med res, the position depends on the video frequency (50/60 Hz)
203: * In high res, the position is always the same.
204: * This position also gives the number of CPU cycles per video line.
205: */
206: static int Video_HBL_GetPos ( void )
207: {
208: return 0;
209: }
210:
211:
212: /*-----------------------------------------------------------------------*/
213: /**
214: * Compute the cycle position where the timer B should happen on each
215: * visible line.
216: * We compute Timer B position for the given LineNumber, using start/end
217: * display cycles from ShifterLines[ LineNumber ].
218: * The position depends on the start of line / end of line positions
219: * (which depend on the current frequency / border tricks) and
220: * on the value of the bit 3 in the MFP's AER.
221: * If bit is 0, timer B will count end of line events (usual case),
222: * but if bit is 1, timer B will count start of line events (eg Seven Gates Of Jambala)
223: */
224: int Video_TimerB_GetPos ( int LineNumber )
225: {
226: return 0;
227: }
228:
229:
230: /*-----------------------------------------------------------------------*/
231: /**
232: * HBL interrupt : this occurs at the end of every line, on cycle 512 (in 50 Hz)
233: * It takes 56 cycles to handle the 68000's exception.
234: */
235: void Video_InterruptHandler_HBL ( void )
236: {
237: }
238:
239:
240: /*-----------------------------------------------------------------------*/
241: /**
242: * Check at end of each HBL to see if any Shifter hardware tricks have been attempted
243: * and copy the line to the screen buffer.
244: * This is the place to check if top/bottom border were removed, as well as if some
245: * left/right border changes were not validated before.
246: * NOTE : the tests must be made with nHBL in ascending order.
247: */
248: static void Video_EndHBL(void)
249: {
250: }
251:
252:
253: /*-----------------------------------------------------------------------*/
254: /**
255: * Set default values for the next HBL, depending on the current res/freq.
256: * We set the number of cycles per line, as well as some default values
257: * for display start/end cycle.
258: */
259: static void Video_StartHBL(void)
260: {
261: }
262:
263:
264: /*-----------------------------------------------------------------------*/
265: /**
266: * End Of Line interrupt
267: * This interrupt is started on cycle position 404 in 50 Hz and on cycle
268: * position 400 in 60 Hz. 50 Hz display ends at cycle 376 and 60 Hz displays
269: * ends at cycle 372. This means the EndLine interrupt happens 28 cycles
270: * after DisplayEndCycle.
271: * Note that if bit 3 of MFP AER is 1, then timer B will count start of line
272: * instead of end of line (at cycle 52+28 or 56+28)
273: */
274: void Video_InterruptHandler_EndLine(void)
275: {
276: }
277:
278:
279:
280:
281: /*-----------------------------------------------------------------------*/
282: /**
283: * Store whole palette on first line so have reference to work from
284: */
285: static void Video_StoreFirstLinePalette(void)
286: {
287: }
288:
289:
290: /*-----------------------------------------------------------------------*/
291: /**
292: * Store resolution on each line (used to test if mixed low/medium resolutions)
293: */
294: static void Video_StoreResolution(int y)
295: {
296: }
297:
298:
299: /*-----------------------------------------------------------------------*/
300: /**
301: * Copy one line of monochrome screen into buffer for conversion later.
302: */
303: static void Video_CopyScreenLineMono(void)
304: {
305: }
306:
307:
308: /*-----------------------------------------------------------------------*/
309: /**
310: * Copy one line of color screen into buffer for conversion later.
311: * Possible lines may be top/bottom border, and/or left/right borders.
312: */
313: static void Video_CopyScreenLineColor(void)
314: {
315: }
316:
317:
318: /*-----------------------------------------------------------------------*/
319: /**
320: * Copy extended GEM resolution screen
321: */
322: static void Video_CopyVDIScreen(void)
323: {
324: }
325:
326:
327: /*-----------------------------------------------------------------------*/
328: /**
329: * Clear raster line table to store changes in palette/resolution on a line
330: * basic. Called once on VBL interrupt.
331: */
332: void Video_SetScreenRasters(void)
333: {
334: }
335:
336:
337: /*-----------------------------------------------------------------------*/
338: /**
339: * Set pointers to HBLPalette tables to store correct colours/resolutions
340: */
341: static void Video_SetHBLPaletteMaskPointers(void)
342: {
343: }
344:
345:
346: /*-----------------------------------------------------------------------*/
347: /**
348: * Set video shifter timing variables according to screen refresh rate.
349: * Note: The following equation must be satisfied for correct timings:
350: *
351: * nCyclesPerLine * nScanlinesPerFrame * nScreenRefreshRate = 8 MHz
352: */
353: static void Video_ResetShifterTimings(void)
354: {
355: }
356:
357:
358: /*-----------------------------------------------------------------------*/
359: /**
360: * Clear the array indicating the state of each video line.
361: */
362: static void Video_InitShifterLines ( void )
363: {
364: }
365:
366:
367: /*-----------------------------------------------------------------------*/
368: /**
369: * Called on VBL, set registers ready for frame
370: */
371: static void Video_ClearOnVBL(void)
372: {
373: }
374:
375:
376: /*-----------------------------------------------------------------------*/
377: /**
378: * Get width, height and bpp according to TT-Resolution
379: */
380: void Video_GetTTRes(int *width, int *height, int *bpp)
381: {
382: }
383:
384:
385: /*-----------------------------------------------------------------------*/
386: /**
387: * Convert TT palette to SDL palette
388: */
389: static void Video_UpdateTTPalette(int bpp)
390: {
391: }
392:
393:
394: /*-----------------------------------------------------------------------*/
395: /**
396: * Update TT palette and blit TT screen using VIDEL code.
397: * @return true if the screen contents changed
398: */
399: bool Video_RenderTTScreen(void)
400: {
401: return true;
402: }
403:
404:
405: /*-----------------------------------------------------------------------*/
406: /**
407: * Draw screen (either with ST/STE shifter drawing functions or with
408: * Videl drawing functions)
409: */
410: static void Video_DrawScreen(void)
411: {
412: // memcpy(pNEXTScreen, NEXTVideo, (1024*768)/8);
413: Screen_Draw();
414: }
415:
416:
417: /*-----------------------------------------------------------------------*/
418: /**
419: * Start HBL, Timer B and VBL interrupts.
420: */
421:
422:
423: /**
424: * Start HBL or Timer B interrupt at position Pos. If position Pos was
425: * already reached, then the interrupt is set on the next line.
426: */
427:
428: static void Video_AddInterrupt ( int Pos , interrupt_id Handler )
429: {
430: }
431:
432:
433: static void Video_AddInterruptHBL ( int Pos )
434: {
435: }
436:
437:
438: void Video_AddInterruptTimerB ( int Pos )
439: {
440: }
441:
442:
443: /**
444: * Add some video interrupts to handle the first HBL and the first Timer B
445: */
446: void Video_StartInterrupts ( int PendingCyclesOver )
447: {
448: int CyclesPerVBL;
449:
450: CyclesPerVBL = CYCLES_PER_FRAME;
451: CycInt_AddRelativeInterrupt(CyclesPerVBL, INT_CPU_CYCLE, INTERRUPT_VIDEO_VBL);
452: }
453:
454:
455: /*-----------------------------------------------------------------------*/
456: /**
457: * VBL interrupt : set new interrupts, draw screen, generate sound,
458: * reset counters, ...
459: */
460: void Video_InterruptHandler_VBL ( void )
461: {
462: CycInt_AcknowledgeInterrupt();
463: Video_DrawScreen();
464: Main_EventHandler();
465: CycInt_AddRelativeInterrupt(CYCLES_PER_FRAME, INT_CPU_CYCLE, INTERRUPT_VIDEO_VBL);
466: }
467:
468:
469: /*-----------------------------------------------------------------------*/
470: /**
471: * Write to video address base high, med and low register (0xff8201/03/0d).
472: * On STE, when a program writes to high or med registers, base low register
473: * is reset to zero.
474: */
475: void Video_ScreenBaseSTE_WriteByte(void)
476: {
477: }
478:
479: /*-----------------------------------------------------------------------*/
480: /**
481: * Read video address counter and update ff8205/07/09
482: */
483: void Video_ScreenCounter_ReadByte(void)
484: {
485: }
486:
487: /*-----------------------------------------------------------------------*/
488: /**
489: */
490: void Video_ScreenCounter_WriteByte(void)
491: {
492: }
493:
494: /*-----------------------------------------------------------------------*/
495: /**
496: * Read video sync register (0xff820a)
497: */
498: void Video_Sync_ReadByte(void)
499: {
500: }
501:
502: /*-----------------------------------------------------------------------*/
503: /**
504: * Read video base address low byte (0xff820d). A plain ST can only store
505: * screen addresses rounded to 256 bytes (i.e. no lower byte).
506: */
507: void Video_BaseLow_ReadByte(void)
508: {
509: }
510:
511: /*-----------------------------------------------------------------------*/
512: /**
513: * Read video line width register (0xff820f)
514: */
515: void Video_LineWidth_ReadByte(void)
516: {
517: }
518:
519: /*-----------------------------------------------------------------------*/
520: /**
521: * Read video shifter mode register (0xff8260)
522: */
523: void Video_ShifterMode_ReadByte(void)
524: {
525: }
526:
527: /*-----------------------------------------------------------------------*/
528: /**
529: * Read horizontal scroll register (0xff8265)
530: */
531: void Video_HorScroll_Read(void)
532: {
533: }
534:
535: /*-----------------------------------------------------------------------*/
536: /**
537: * Write video line width register (0xff820f) - STE only.
538: * Content of LineWidth is added to the shifter counter when display is
539: * turned off (start of the right border, usually at cycle 376)
540: */
541: void Video_LineWidth_WriteByte(void)
542: {
543: }
544:
545: /*-----------------------------------------------------------------------*/
546: /**
547: */
548: static void Video_ColorReg_WriteWord(Uint32 addr)
549: {
550: }
551:
552: void Video_Color0_WriteWord(void)
553: {
554: }
555:
556: void Video_Color1_WriteWord(void)
557: {
558: }
559:
560: void Video_Color2_WriteWord(void)
561: {
562: }
563:
564: void Video_Color3_WriteWord(void)
565: {
566: }
567:
568: void Video_Color4_WriteWord(void)
569: {
570: }
571:
572: void Video_Color5_WriteWord(void)
573: {
574: }
575:
576: void Video_Color6_WriteWord(void)
577: {
578: }
579:
580: void Video_Color7_WriteWord(void)
581: {
582: }
583:
584: void Video_Color8_WriteWord(void)
585: {
586: }
587:
588: void Video_Color9_WriteWord(void)
589: {
590: }
591:
592: void Video_Color10_WriteWord(void)
593: {
594: }
595:
596: void Video_Color11_WriteWord(void)
597: {
598: }
599:
600: void Video_Color12_WriteWord(void)
601: {
602: }
603:
604: void Video_Color13_WriteWord(void)
605: {
606: }
607:
608: void Video_Color14_WriteWord(void)
609: {
610: }
611:
612: void Video_Color15_WriteWord(void)
613: {
614: }
615:
616:
617: /*-----------------------------------------------------------------------*/
618: /**
619: * Write video shifter mode register (0xff8260)
620: */
621: void Video_ShifterMode_WriteByte(void)
622: {
623: }
624:
625: /*-----------------------------------------------------------------------*/
626: /**
627: */
628:
629: void Video_HorScroll_Write_8264(void)
630: {
631: }
632:
633: void Video_HorScroll_Write_8265(void)
634: {
635: }
636:
637: void Video_HorScroll_Write(void)
638: {
639: }
640:
641: /*-----------------------------------------------------------------------*/
642: /**
643: * Write to TT shifter mode register (0xff8262)
644: */
645: void Video_TTShiftMode_WriteWord(void)
646: {
647: }
648:
649: /*-----------------------------------------------------------------------*/
650: /**
651: * Write to TT color register (0xff8400)
652: */
653: void Video_TTColorRegs_WriteWord(void)
654: {
655: }
656:
657: /*-----------------------------------------------------------------------*/
658: /**
659: * Write to ST color register on TT (0xff8240)
660: */
661: void Video_TTColorSTRegs_WriteWord(void)
662: {
663: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.