Previous 15994 Revisions Next

r3934 Saturday 20th December, 2008 at 20:09:20 UTC by Nathan Woods
More "legacy" m6845 cleanups [Atari Ace]
[src/mess/video]amstrad.c m6845.c m6845.h

src/mess/video/amstrad.c
r3933r3934
1616
1717#include "sound/ay8910.h"
1818
19static m6845_state amstrad_vidhrdw_6845_state;
2019int prev_reg;
2120
2221static int amstrad_plus_dma_repeat[3];  // marks the location of the channels' last repeat
r3933r3934
11891188         {
11901189            if(m6845_get_row_counter() == ((amstrad_plus_split_scanline >> 3) & 0x1f) && m6845_get_scanline_counter() == (amstrad_plus_split_scanline & 0x07)) // split occurs here (hopefully)
11911190            {
1192               m6845_state vid;
1193               m6845_get_state(0,&vid);
1191               m6845_set_address(amstrad_plus_split_address);
11941192//               logerror("SSCR: Split screen occured at scanline %i",amstrad_plus_split_scanline);
1195               vid.Memory_Address_of_next_Character_Row = vid.Memory_Address_of_this_Character_Row = amstrad_plus_split_address;
1196               vid.Memory_Address = amstrad_plus_split_address;
1197               m6845_set_state(0,&vid);
11981193            }
11991194         }
12001195         // CPC+/GX4000 soft scroll register
r3933r3934
12931288{
12941289   amstrad_init_lookups();
12951290
1296   m6845_start();
12971291   m6845_config(&amstrad6845);
1298   m6845_reset(0);
1299   m6845_get_state(0, &amstrad_vidhrdw_6845_state);
13001292
13011293   draw_function = amstrad_draw_screen_disabled;
13021294
src/mess/video/m6845.c
r3933r3934
8080/* *** Not implemented yet *** */
8181#define R17_light_pen_address_L crtc.registers[17]
8282
83typedef struct m6845_state
84{
85   const struct m6845_interface *intf;
86   m6845_personality_t personality;
8387
88   /* Register Select */
89   int address_register;
90   /* register data */
91   int registers[32];
92   /* vertical and horizontal sync widths */
93   int vertical_sync_width, horizontal_sync_width;
94
95   int screen_start_address;         /* = R12<<8 + R13 */
96   int cursor_address;              /* = R14<<8 + R15 */
97   int light_pen_address;           /* = R16<<8 + R17 */
98
99   int scan_lines_increment;
100
101   int Horizontal_Counter;
102   int Horizontal_Counter_Reset;
103
104   int Scan_Line_Counter;
105   int Scan_Line_Counter_Reset;
106
107   int Character_Row_Counter;
108   int Character_Row_Counter_Reset;
109
110   int Horizontal_Sync_Width_Counter;
111   int Vertical_Sync_Width_Counter;
112
113   int HSYNC;
114   int VSYNC;
115
116   int Vertical_Total_Adjust_Active;
117   int Vertical_Total_Adjust_Counter;
118
119   int Memory_Address;
120   int Memory_Address_of_next_Character_Row;
121   int Memory_Address_of_this_Character_Row;
122
123   int Horizontal_Display_Enabled;
124   int Vertical_Display_Enabled;
125   int Display_Enabled;
126   int Display_Delayed_Enabled;
127
128   int Cursor_Delayed_Status;
129
130   int Cursor_Flash_Count;
131
132   int Delay_Flags;
133   int Cursor_Start_Delay;
134   int Display_Enabled_Delay;
135   int Display_Disable_Delay;
136
137   int   Vertical_Adjust_Done;
138//   int cycles_to_vsync_start;
139//   int cycles_to_vsync_end;
140} m6845_state;
141
142
84143static m6845_state crtc;
85static m6845_personality_t personality;
86144
87145#if 0
88146/* VSYNC functions */
r3933r3934
92150/* timer to reset vsync */
93151static void *m6845_vsync_clear_timer = NULL;
94152
95static void m6845_vsync_set_timer_callback(int);
96static void m6845_vsync_clear_timer_callback(int);
153static void TIMER_CALLBACK( m6845_vsync_set_timer_callback );
154static void TIMER_CALLBACK( m6845_vsync_clear_timer_callback );
97155static void m6845_remove_vsync_set_timer(void);
98156static void m6845_remove_vsync_clear_timer(void);
99157static void m6845_set_new_vsync_set_time(int);
r3933r3934
103161
104162#endif
105163
106// local copy of the 6845 external procedure calls
107static struct m6845_interface crct6845_calls =
108{
109   0,// Memory Address register
110   0,// Row Address register
111   0,// Horizontal status
112   0,// Vertical status
113   0,// Display Enabled status
114   0,// Cursor status
115
116
117   0,// Cursor status allways called
118   // As the BBC video emulation does not redraw all off the screen every time
119   // This function outputs:
120   // B1 set to 1 when at cursor position, set to 0 when past cursor
121   // B0 set to 1 when the cursor is on and 0 when the cursor is off
122   // this function is call at the cursor location even if the cursor is off
123   // this means that the cursor will get clear from the screen
124
125};
126
127164/* set up the local copy of the 6845 external procedure calls */
128165void m6845_config(const struct m6845_interface *intf)
129166{
130   crct6845_calls.out_MA_func=*intf->out_MA_func;
131   crct6845_calls.out_RA_func=*intf->out_RA_func;
132   crct6845_calls.out_HS_func=*intf->out_HS_func;
133   crct6845_calls.out_VS_func=*intf->out_VS_func;
134   crct6845_calls.out_DE_func=*intf->out_DE_func;
135   crct6845_calls.out_CR_func=*intf->out_CR_func;
136   crct6845_calls.out_CRE_func=*intf->out_CRE_func;
137   personality = M6845_PERSONALITY_GENUINE;
167   memset(&crtc, 0, sizeof(crtc));
168   crtc.intf = intf;
169   crtc.personality = M6845_PERSONALITY_GENUINE;
170   m6845_reset();
138171}
139172
140void   m6845_start(void)
141{
142#if 0
143   m6845_vsync_set_timer = NULL;
144   m6845_vsync_clear_timer = NULL;
145#endif
146}
147
148173/* 6845 registers */
149174
150175/* functions to set the 6845 registers */
r3933r3934
153178   crtc.address_register=data & 0x1f;
154179}
155180
156void m6845_get_state(int offset, m6845_state *state)
181void m6845_set_address(int address)
157182{
158   memcpy(state, &crtc, sizeof(m6845_state));
183   crtc.Memory_Address_of_next_Character_Row = address;
184   crtc.Memory_Address_of_this_Character_Row = address;
185   crtc.Memory_Address = address;
159186}
160187
161void m6845_set_state(int offset, m6845_state *state)
162{
163   memcpy(&crtc, state, sizeof(m6845_state));
164}
165188
166
167189void m6845_register_w(int offset, int data)
168190{
169191   switch (crtc.address_register)
r3933r3934
262284   switch (crtc.address_register)
263285   {
264286      case 12:
265         switch(personality)
287         switch(crtc.personality)
266288         {
267289            case M6845_PERSONALITY_UM6845:
268290            case M6845_PERSONALITY_HD6845S:
r3933r3934
278300         }
279301         break;
280302      case 13:
281         switch(personality)
303         switch(crtc.personality)
282304         {
283305            case M6845_PERSONALITY_UM6845:
284306            case M6845_PERSONALITY_HD6845S:
r3933r3934
313335}
314336
315337
316void   m6845_reset(int which)
338void m6845_reset(void)
317339{
318340   memset(&crtc.registers[0], 0, sizeof(int)*32);
319341   crtc.address_register = 0;
r3933r3934
418440      /*crtc.Scan_Line_Counter=(crtc.Scan_Line_Counter+crtc.scan_lines_increment)%32;*/
419441      crtc.Scan_Line_Counter=(crtc.Scan_Line_Counter+crtc.scan_lines_increment)&0x01f;
420442
421   if (crtc.Vertical_Total_Adjust_Active)
443      if (crtc.Vertical_Total_Adjust_Active)
422444      {
423445         /* update counter */
424446         crtc.Vertical_Total_Adjust_Counter = (crtc.Vertical_Total_Adjust_Counter+1) & 0x01f;
r3933r3934
485507         if (crtc.Character_Row_Counter==R7_vertical_sync_position)
486508         {
487509            crtc.VSYNC=True;
488            if (crct6845_calls.out_VS_func) (crct6845_calls.out_VS_func)(machine, 0,crtc.VSYNC); /* call VS update */
510            if (crtc.intf->out_VS_func) (crtc.intf->out_VS_func)(machine, 0,crtc.VSYNC); /* call VS update */
489511         }
490512
491513
r3933r3934
499521                        {
500522                                crtc.Vertical_Sync_Width_Counter=0;
501523                                crtc.VSYNC=False;
502                                if (crct6845_calls.out_VS_func) (crct6845_calls.out_VS_func)(machine, 0,crtc.VSYNC); /* call VS update */
524                                if (crtc.intf->out_VS_func) (crtc.intf->out_VS_func)(machine, 0,crtc.VSYNC); /* call VS update */
503525                        }
504526                }
505527
r3933r3934
525547            if (crtc.Character_Row_Counter==R7_vertical_sync_position)
526548            {
527549               crtc.VSYNC=True;
528               if (crct6845_calls.out_VS_func) (crct6845_calls.out_VS_func)(machine,0,crtc.VSYNC); /* call VS update */
550               if (crtc.intf->out_VS_func) (crtc.intf->out_VS_func)(machine,0,crtc.VSYNC); /* call VS update */
529551            }
530552         }
531553      }
r3933r3934
536558      {
537559         crtc.Scan_Line_Counter_Reset=True;
538560      }
539      if (crct6845_calls.out_RA_func) (crct6845_calls.out_RA_func)(0,crtc.Scan_Line_Counter); /* call RA update */
561      if (crtc.intf->out_RA_func) (crtc.intf->out_RA_func)(0,crtc.Scan_Line_Counter); /* call RA update */
540562   }
541563   /* end of vertical clock pulse */
542564
r3933r3934
568590                if (crtc.horizontal_sync_width!=0)
569591                {
570592                        crtc.HSYNC=True;
571                        if (crct6845_calls.out_HS_func) (crct6845_calls.out_HS_func)(machine, 0,crtc.HSYNC); /* call HS update */
593                        if (crtc.intf->out_HS_func) (crtc.intf->out_HS_func)(machine, 0,crtc.HSYNC); /* call HS update */
572594                }
573595        }
574596
r3933r3934
580602
581603                        crtc.Horizontal_Sync_Width_Counter=0;
582604                        crtc.HSYNC=False;
583                        if (crct6845_calls.out_HS_func) (crct6845_calls.out_HS_func)(machine, 0,crtc.HSYNC); /* call HS update */
605                        if (crtc.intf->out_HS_func) (crtc.intf->out_HS_func)(machine, 0,crtc.HSYNC); /* call HS update */
584606                }
585607        }
586   if (crct6845_calls.out_MA_func) (crct6845_calls.out_MA_func)(0,crtc.Memory_Address);   /* call MA update */
608   if (crtc.intf->out_MA_func) (crtc.intf->out_MA_func)(0,crtc.Memory_Address);   /* call MA update */
587609
588610
589611
r3933r3934
607629      {
608630         crtc.Delay_Flags=crtc.Delay_Flags^Cursor_On_Flag;
609631         crtc.Cursor_Delayed_Status=False;
610         if (crct6845_calls.out_CR_func) (crct6845_calls.out_CR_func)(0,crtc.Cursor_Delayed_Status); /* call CR update */
611         if (crct6845_calls.out_CRE_func) (crct6845_calls.out_CRE_func)(0,0); /* call CRE update */
632         if (crtc.intf->out_CR_func) (crtc.intf->out_CR_func)(0,crtc.Cursor_Delayed_Status); /* call CR update */
633         if (crtc.intf->out_CRE_func) (crtc.intf->out_CRE_func)(0,0); /* call CRE update */
612634      }
613635
614636      /* cursor enabled delay */
r3933r3934
621643            {
622644               crtc.Delay_Flags=(crtc.Delay_Flags^Cursor_Start_Delay_Flag)|Cursor_On_Flag;
623645               crtc.Cursor_Delayed_Status=True;
624               if ((crct6845_calls.out_CR_func)&&(crtc.Cursor_Flash_Count>25)) (crct6845_calls.out_CR_func)(0,crtc.Cursor_Delayed_Status); /* call CR update */
625               if (crct6845_calls.out_CRE_func) (crct6845_calls.out_CRE_func)(0,2|((crtc.Cursor_Flash_Count>25)&1)); /* call CR update */
646               if ((crtc.intf->out_CR_func)&&(crtc.Cursor_Flash_Count>25)) (crtc.intf->out_CR_func)(0,crtc.Cursor_Delayed_Status); /* call CR update */
647               if (crtc.intf->out_CRE_func) (crtc.intf->out_CRE_func)(0,2|((crtc.Cursor_Flash_Count>25)&1)); /* call CR update */
626648            }
627649         }
628650      }
r3933r3934
635657         {
636658            crtc.Delay_Flags=crtc.Delay_Flags^Display_Enabled_Delay_Flag;
637659            crtc.Display_Delayed_Enabled=True;
638            if (crct6845_calls.out_DE_func) (crct6845_calls.out_DE_func)(0,crtc.Display_Delayed_Enabled); /* call DE update */
660            if (crtc.intf->out_DE_func) (crtc.intf->out_DE_func)(0,crtc.Display_Delayed_Enabled); /* call DE update */
639661         }
640662      }
641663
r3933r3934
647669         {
648670            crtc.Delay_Flags=crtc.Delay_Flags^Display_Disable_Delay_Flag;
649671            crtc.Display_Delayed_Enabled=False;
650            if (crct6845_calls.out_DE_func) (crct6845_calls.out_DE_func)(0,crtc.Display_Delayed_Enabled); /* call DE update */
672            if (crtc.intf->out_DE_func) (crtc.intf->out_DE_func)(0,crtc.Display_Delayed_Enabled); /* call DE update */
651673         }
652674      }
653675   }
r3933r3934
665687
666688void m6845_set_personality(m6845_personality_t p)
667689{
668   personality = p;
690   crtc.personality = p;
669691}
670692
671693// A few helper functions to help avoid heavy use of m6845_get/set_state()
r3933r3934
808830
809831   if (crtc_cycles_to_vsync_start!=-1)
810832   {
811      m6845_vsync_set_timer = timer_set(machine, ATTOTIME_IN_USEC(crtc_cycles_to_vsync_start), NULL, 0, m6845_vsync_set_timer_callback);
833      m6845_vsync_set_timer = timer_set(machine, ATTOTIME_IN_USEC(crtc_cycles_to_vsync_start), machine, 0, m6845_vsync_set_timer_callback);
812834   }
813835}
814836
r3933r3934
833855
834856static TIMER_CALLBACK( m6845_vsync_clear_timer_callback )
835857{
836   const running_machine *machine = ptr;
837   
838858   /* clear vsync */
839859   crtc.VSYNC = 0;
840860
841861   /* call function to let emulation "know" */
842   if (crct6845_calls.out_VS_func) (crct6845_calls.out_VS_func)(machine,0,crtc.VSYNC); /* call VS update */
862   if (crtc.intf->out_VS_func) (crtc.intf->out_VS_func)(machine,0,crtc.VSYNC); /* call VS update */
843863
844864
845865   /* if we got to here the vsync has just ended */
r3933r3934
853873}
854874
855875/* called when vsync is set */
856static void m6845_vsync_set_timer_callback(int dummy)
876static TIMER_CALLBACK( m6845_vsync_set_timer_callback )
857877{
858878   /* set vsync */
859879   crtc.VSYNC = 1;
860880
861881   /* call function to let emulation "know" */
862   if (crct6845_calls.out_VS_func) (crct6845_calls.out_VS_func)(Machine,0,crtc.VSYNC); /* call VS update */
882   if (crtc.intf->out_VS_func) (crtc.intf->out_VS_func)(machine,0,crtc.VSYNC); /* call VS update */
863883
864884
865885   /* if we got to here the vsync has just been set, and has just started */
src/mess/video/m6845.h
r3933r3934
3030   void (*out_CRE_func)(int offset, int data);
3131};
3232
33typedef struct m6845_state
34{
35   /* Register Select */
36   int address_register;
37   /* register data */
38   int registers[32];
39   /* vertical and horizontal sync widths */
40   int vertical_sync_width, horizontal_sync_width;
41
42   int screen_start_address;         /* = R12<<8 + R13 */
43   int cursor_address;              /* = R14<<8 + R15 */
44   int light_pen_address;           /* = R16<<8 + R17 */
45
46   int scan_lines_increment;
47
48   int Horizontal_Counter;
49   int Horizontal_Counter_Reset;
50
51   int Scan_Line_Counter;
52   int Scan_Line_Counter_Reset;
53
54   int Character_Row_Counter;
55   int Character_Row_Counter_Reset;
56
57   int Horizontal_Sync_Width_Counter;
58   int Vertical_Sync_Width_Counter;
59
60   int HSYNC;
61   int VSYNC;
62
63   int Vertical_Total_Adjust_Active;
64   int Vertical_Total_Adjust_Counter;
65
66   int Memory_Address;
67   int Memory_Address_of_next_Character_Row;
68   int Memory_Address_of_this_Character_Row;
69
70   int Horizontal_Display_Enabled;
71   int Vertical_Display_Enabled;
72   int Display_Enabled;
73   int Display_Delayed_Enabled;
74
75   int Cursor_Delayed_Status;
76
77   int Cursor_Flash_Count;
78
79   int Delay_Flags;
80   int Cursor_Start_Delay;
81   int Display_Enabled_Delay;
82   int Display_Disable_Delay;
83
84   int   Vertical_Adjust_Done;
85//   int cycles_to_vsync_start;
86//   int cycles_to_vsync_end;
87} m6845_state;
88
8933/* set up the local copy of the 6845 external procedure calls */
9034void m6845_config(const struct m6845_interface *intf);
9135
r3933r3934
11458void m6845_recalc(int offset, int cycles);
11559#endif
11660
117void m6845_set_state(int offset, m6845_state *state);
118void m6845_get_state(int offset, m6845_state *state);
61void m6845_set_address(int address);
11962
120void m6845_reset(int which);
63void m6845_reset(void);
12164
122void m6845_start(void);
123
12465void m6845_set_personality(m6845_personality_t personality);
12566
12667int m6845_get_register(int reg);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team