Previous 15994 Revisions Next

r1130 Wednesday 17th October, 2007 at 00:54:23 UTC by R. Belmont
Renamed m6845 CRTC stuff as "m6845" and MESS crtc6845 as "mscrtc6845" to allow coexistance with the MAME implementation while drivers get converted.
[src/mess/drivers]amstrad.c cbmb.c einstein.c pet.c
[src/mess/includes]cbmb.h crtc6845.h
[src/mess/machine]amstrad.c cbmb.c pet.c svi318.c
[src/mess/video]amstrad.c bbc.c cbmb.c cirrus.c crtc6845.c dgn_beta.c m6845.c m6845.h pc_aga.c pc_cga.c pc_cga.h pc_mda.c pc_mda.h pc_t1t.c pc_vga.c pc_video.c pc_video.h pet.c

src/mess/includes/cbmb.h
r1129r1130
234234
235235void cbm600_vh_init(void);
236236void cbm700_vh_init(void);
237void cbmb_vh_cursor(struct crtc6845_cursor *cursor);
237void cbmb_vh_cursor(struct mscrtc6845_cursor *cursor);
238238extern VIDEO_START( cbm700 );
239239extern VIDEO_UPDATE( cbmb );
240240
src/mess/includes/crtc6845.h
r1129r1130
1010
1111***************************************************************************/
1212
13#ifndef CRTC6845_H
14#define CRTC6845_H
13#ifndef MSCRTC6845_H
14#define MSCRTC6845_H
1515
1616#include "mame.h"
1717
r1129r1130
3838***************************************************************************/
3939
4040/* opaque structure representing a crtc8645 chip */
41struct crtc6845;
41struct mscrtc6845;
4242
43struct crtc6845_cursor
43struct mscrtc6845_cursor
4444{
4545   int on;
4646   int pos;
r1129r1130
4848   int bottom;
4949};
5050
51struct crtc6845_config
51struct mscrtc6845_config
5252{
5353   int freq;
54   void (*cursor_changed)(struct crtc6845_cursor *old);
54   void (*cursor_changed)(struct mscrtc6845_cursor *old);
5555   int personality;
5656};
5757
r1129r1130
6161
6262***************************************************************************/
6363
64/* generic crtc6845 instance */
65extern struct crtc6845 *crtc6845;
64/* generic mscrtc6845 instance */
65extern struct mscrtc6845 *mscrtc6845;
6666
6767/***************************************************************************
6868
r1129r1130
7070
7171***************************************************************************/
7272
73struct crtc6845 *crtc6845_init(const struct crtc6845_config *config);
73struct mscrtc6845 *mscrtc6845_init(const struct mscrtc6845_config *config);
7474
75void crtc6845_set_clock(struct crtc6845 *crtc, int freq);
75void mscrtc6845_set_clock(struct mscrtc6845 *crtc, int freq);
7676
7777/* to be called before drawing screen */
78void crtc6845_time(struct crtc6845 *crtc);
78void mscrtc6845_time(struct mscrtc6845 *crtc);
7979
80int crtc6845_get_char_columns(struct crtc6845 *crtc);
81int crtc6845_get_char_height(struct crtc6845 *crtc);
82int crtc6845_get_char_lines(struct crtc6845 *crtc);
83int crtc6845_get_start(struct crtc6845 *crtc);
84void crtc6845_set_char_columns(struct crtc6845 *crtc, UINT8 columns);
85void crtc6845_set_char_lines(struct crtc6845 *crtc, UINT8 lines);
80int mscrtc6845_get_char_columns(struct mscrtc6845 *crtc);
81int mscrtc6845_get_char_height(struct mscrtc6845 *crtc);
82int mscrtc6845_get_char_lines(struct mscrtc6845 *crtc);
83int mscrtc6845_get_start(struct mscrtc6845 *crtc);
84void mscrtc6845_set_char_columns(struct mscrtc6845 *crtc, UINT8 columns);
85void mscrtc6845_set_char_lines(struct mscrtc6845 *crtc, UINT8 lines);
8686
87int crtc6845_get_personality(struct crtc6845 *crtc);
87int mscrtc6845_get_personality(struct mscrtc6845 *crtc);
8888
8989/* cursor off, cursor on, cursor 16 frames on/off, cursor 32 frames on/off
9090   start line, end line */
91void crtc6845_get_cursor(struct crtc6845 *crtc, struct crtc6845_cursor *cursor);
91void mscrtc6845_get_cursor(struct mscrtc6845 *crtc, struct mscrtc6845_cursor *cursor);
9292
93UINT8 crtc6845_port_r(struct crtc6845 *crtc, int offset);
94int crtc6845_port_w(struct crtc6845 *crtc, int offset, UINT8 data);
93UINT8 mscrtc6845_port_r(struct mscrtc6845 *crtc, int offset);
94int mscrtc6845_port_w(struct mscrtc6845 *crtc, int offset, UINT8 data);
9595
9696/* to be called when writting to port */
97WRITE8_HANDLER ( crtc6845_0_port_w );
97WRITE8_HANDLER ( mscrtc6845_0_port_w );
9898
9999/* to be called when reading from port */
100 READ8_HANDLER ( crtc6845_0_port_r );
100 READ8_HANDLER ( mscrtc6845_0_port_r );
101101   
102102/***************************************************************************
103103
104104   6845 variant macros
105105
106106   These are used to support emulations of 6845 variants, but these will
107   be eventually merged into crtc6845.c so these are deprecated
107   be eventually merged into mscrtc6845.c so these are deprecated
108108
109109***************************************************************************/
110110
src/mess/video/dgn_beta.c
r1129r1130
113113   START_ADDR_L,      // Start address low
114114   CURS_H,         // Cursor addr High
115115   CURS_L         // CURSOR addr Low
116} crtc6845_regs;
116} m6845_regs;
117117
118118static int beta_6845_RA = 0;
119119static int beta_scr_x   = 0;
r1129r1130
164164static void beta_Set_VSync(int offset, int data);
165165static void beta_Set_DE(int offset, int data);
166166
167static struct crtc6845_interface
168beta_crtc6845_interface= {
167static struct m6845_interface
168beta_m6845_interface= {
169169   0,      // Memory Address register
170170   beta_Set_RA,   // Row Address register
171171   beta_Set_HSync,   // Horizontal status
r1129r1130
267267   
268268   if(!beta_HSync)
269269   {
270      int HT=crtc6845_get_register(H_TOTAL);         // Get H total
271      int HS=crtc6845_get_register(H_SYNC_POS);      // Get Hsync pos
272      int HW=crtc6845_get_register(H_SYNC_WIDTH)&0xF;   // Hsync width (in chars)
270      int HT=m6845_get_register(H_TOTAL);         // Get H total
271      int HS=m6845_get_register(H_SYNC_POS);      // Get Hsync pos
272      int HW=m6845_get_register(H_SYNC_WIDTH)&0xF;   // Hsync width (in chars)
273273     
274274      beta_scr_y++;
275275//      beta_scr_x=0-(((HT-HS)-HW)*8);   // Number of dots after HS to wait before start of next line
276276      beta_scr_x=0-((HT-(HS+HW))*Dots);
277277     
278278//debug_console_printf("HT=%d, HS=%d, HW=%d, (HS+HW)=%d, HT-(HS+HW)=%d\n",HT,HS,HW,(HS+HW),(HT-(HS+HW)));
279//debug_console_printf("Scanline=%d, row=%d\n",crtc6845_get_scanline_counter(),crtc6845_get_row_counter());     
279//debug_console_printf("Scanline=%d, row=%d\n",m6845_get_scanline_counter(),m6845_get_row_counter());     
280280#ifdef MAME_DEBUG
281281      HSyncMin=beta_scr_x;
282282#endif
r1129r1130
329329void init_video(void)
330330{
331331   /* initialise 6845 */
332   crtc6845_config(&beta_crtc6845_interface);
333   crtc6845_set_personality(M6845_PERSONALITY_HD6845S);
332   m6845_config(&beta_m6845_interface);
333   m6845_set_personality(M6845_PERSONALITY_HD6845S);
334334   
335335   GCtrl=0;
336336   
r1129r1130
406406
407407static void beta_plot_char_line(int x,int y, mame_bitmap *bitmap)
408408{
409   int CharsPerLine   = crtc6845_get_register(H_DISPLAYED);   // Get chars per line.
409   int CharsPerLine   = m6845_get_register(H_DISPLAYED);   // Get chars per line.
410410   unsigned char *data    = memory_region(REGION_GFX1);      // ptr to char rom
411411   int Dot;
412412   unsigned char data_byte;
r1129r1130
415415   int Offset;
416416   int FgColour;                     // Foreground colour
417417   int BgColour;                     // Background colour
418   int CursorOn      = crtc6845_cursor_enabled_r(0);
418   int CursorOn      = m6845_cursor_enabled_r(0);
419419   int Invert;
420420   int UnderLine;                     // Underline
421421   int FlashChar;                     // Flashing char
r1129r1130
427427   {   
428428      /* The beta text RAM contains alternate character and attribute bytes */
429429      /* Top two address lines from PIA, IC28 PB6,7 */
430      crtcAddr=crtc6845_memory_address_r(0)-1;
430      crtcAddr=m6845_memory_address_r(0)-1;
431431      Offset=(crtcAddr | ((GCtrl & GCtrlAddrLines)<<8))*2;
432432      if (Offset<0)
433433         Offset=0;
r1129r1130
503503void plot_gfx_pixel(int x, int y, int Dot, int Colour, mame_bitmap *bitmap)
504504{
505505   int   DoubleX      = (~GCtrl & GCtrlHiLo) ? 1 : 0;
506   int   DoubleY      = (~crtc6845_get_register(INTERLACE) & 0x03) ? 1 : 0;
506   int   DoubleY      = (~m6845_get_register(INTERLACE) & 0x03) ? 1 : 0;
507507   int   PlotX;
508508   int   PlotY;
509509   
r1129r1130
577577   if (beta_DE)
578578   {   
579579      /* Calculate address of graphics pixels */
580      crtcAddr=(crtc6845_memory_address_r(0) & 0x1FFF);
580      crtcAddr=(m6845_memory_address_r(0) & 0x1FFF);
581581      Addr=((crtcAddr<<3) | (beta_6845_RA & 0x07))*2;
582582   
583583      if(Addr<MinAddr)
r1129r1130
666666   while((beta_VSync)&&(c<ClkMax))
667667   {
668668      // Clock the 6845
669      crtc6845_clock();
669      m6845_clock();
670670      c++;
671671   }
672672
r1129r1130
676676   {
677677      while ((beta_HSync)&&(c<ClkMax))
678678      {
679         crtc6845_clock();
679         m6845_clock();
680680         c++;
681681      }
682682
r1129r1130
702702            beta_scr_x+=8;
703703
704704         // Clock the 6845
705         crtc6845_clock();
705         m6845_clock();
706706         c++;
707707      }
708708   }
r1129r1130
712712/* Read and write handlers for CPU interface to 6845 */
713713READ8_HANDLER(dgnbeta_6845_r)
714714{
715   return crtc6845_register_r(offset);
715   return m6845_register_r(offset);
716716}
717717
718718WRITE8_HANDLER(dgnbeta_6845_w)
719719{   
720720   if(offset&0x1)
721721   {
722      crtc6845_register_w(offset,data);
722      m6845_register_w(offset,data);
723723   
724724      if(VidAddr==INTERLACE)
725725      {
r1129r1130
728728   }
729729   else
730730   {
731      crtc6845_address_w(offset,data);
731      m6845_address_w(offset,data);
732732      VidAddr=data;            /* Record reg being written to */
733733   }
734734#ifdef MAME_DEBUG
src/mess/video/cbmb.c
r1129r1130
5757   video_start_generic(machine);
5858}
5959
60void cbmb_vh_cursor(struct crtc6845_cursor *cursor)
60void cbmb_vh_cursor(struct mscrtc6845_cursor *cursor)
6161{
6262   dirtybuffer[cursor->pos]=1;
6363}
r1129r1130
7171{
7272   int x, y, i;
7373   rectangle rect, rect2;
74   int w=crtc6845_get_char_columns(crtc6845);
75   int h=crtc6845_get_char_lines(crtc6845);
76   int height=crtc6845_get_char_height(crtc6845);
77   int start=crtc6845_get_start(crtc6845)&0x7ff;
78   struct crtc6845_cursor cursor;
74   int w=mscrtc6845_get_char_columns(mscrtc6845);
75   int h=mscrtc6845_get_char_lines(mscrtc6845);
76   int height=mscrtc6845_get_char_height(mscrtc6845);
77   int start=mscrtc6845_get_start(mscrtc6845)&0x7ff;
78   struct mscrtc6845_cursor cursor;
7979   int full_refresh = 1;
8080
8181   rect.min_x=Machine->screen[0].visarea.min_x;
r1129r1130
8484      memset(dirtybuffer, 1, videoram_size);
8585   }
8686
87   crtc6845_time(crtc6845);
88   crtc6845_get_cursor(crtc6845, &cursor);
87   mscrtc6845_time(mscrtc6845);
88   mscrtc6845_get_cursor(mscrtc6845, &cursor);
8989
9090   for (y=0, rect.min_y=0, rect.max_y=height-1, i=start; y<h;
9191       y++, rect.min_y+=height, rect.max_y+=height) {
src/mess/video/cirrus.c
r1129r1130
6868
6969
7070
71static void cirrus_update_8bpp(mame_bitmap *bitmap, struct crtc6845 *crtc)
71static void cirrus_update_8bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
7272{
7373   UINT16 *line;
7474   const UINT8 *vram;
r1129r1130
8787
8888
8989
90static void cirrus_update_16bpp(mame_bitmap *bitmap, struct crtc6845 *crtc)
90static void cirrus_update_16bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
9191{
9292   fatalerror("NYI");
9393}
9494
9595
9696
97static void cirrus_update_24bpp(mame_bitmap *bitmap, struct crtc6845 *crtc)
97static void cirrus_update_24bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
9898{
9999   fatalerror("NYI");
100100}
101101
102102
103103
104static void cirrus_update_32bpp(mame_bitmap *bitmap, struct crtc6845 *crtc)
104static void cirrus_update_32bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
105105{
106106   fatalerror("NYI");
107107}
src/mess/video/pc_vga.c
r1129r1130
5454static VIDEO_RESET( ega );
5555static VIDEO_RESET( vga );
5656
57static pc_video_update_proc pc_vga_choosevideomode(int *width, int *height, struct crtc6845 *crtc);
58static pc_video_update_proc pc_ega_choosevideomode(int *width, int *height, struct crtc6845 *crtc);
57static pc_video_update_proc pc_vga_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc);
58static pc_video_update_proc pc_ega_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc);
5959
6060/***************************************************************************
6161
r1129r1130
265265} vga;
266266
267267
268// to use the crtc6845 macros
268// to use the mscrtc6845 macros
269269#define REG(x) vga.crtc.data[x]
270270
271271#define DOUBLESCAN ((vga.crtc.data[9]&0x80)||((vga.crtc.data[9]&0x1f)!=0) )
r1129r1130
11721172   pc_vga_reset();
11731173}
11741174
1175static void vga_vh_text(mame_bitmap *bitmap, struct crtc6845 *crtc)
1175static void vga_vh_text(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
11761176{
11771177   UINT8 ch, attr;
11781178   UINT8 bits;
r1129r1130
12391239   }
12401240}
12411241
1242static void vga_vh_ega(mame_bitmap *bitmap, struct crtc6845 *crtc)
1242static void vga_vh_ega(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
12431243{
12441244   int pos, line, column, c, addr, i;
12451245   int height = CRTC6845_CHAR_HEIGHT;
r1129r1130
12841284   }
12851285}
12861286
1287static void vga_vh_vga(mame_bitmap *bitmap, struct crtc6845 *crtc)
1287static void vga_vh_vga(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
12881288{
12891289   int pos, line, column, c, addr, curr_addr;
12901290   UINT16 *bitmapline;
r1129r1130
13421342   }
13431343}
13441344
1345static pc_video_update_proc pc_ega_choosevideomode(int *width, int *height, struct crtc6845 *crtc)
1345static pc_video_update_proc pc_ega_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc)
13461346{
13471347   pc_video_update_proc proc = NULL;
13481348   int i;
r1129r1130
13681368   return proc;
13691369}
13701370
1371static pc_video_update_proc pc_vga_choosevideomode(int *width, int *height, struct crtc6845 *crtc)
1371static pc_video_update_proc pc_vga_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc)
13721372{
13731373   pc_video_update_proc proc = NULL;
13741374   int i;
src/mess/video/crtc6845.c
r1129r1130
6060
6161***************************************************************************/
6262
63struct crtc6845
63struct mscrtc6845
6464{
65   struct crtc6845_config config;
65   struct mscrtc6845_config config;
6666   UINT8 reg[18];
6767   UINT8 idx;
6868   double cursor_time;
r1129r1130
7575   UINT8 read_mask;
7676};
7777
78struct crtc6845 *crtc6845;
78struct mscrtc6845 *mscrtc6845;
7979
8080/***************************************************************************
8181
r1129r1130
8484***************************************************************************/
8585
8686/*-------------------------------------------------
87   crtc6845_reg_mask - an array specifying how
87   mscrtc6845_reg_mask - an array specifying how
8888   much of any given register "registers", per
8989   m6845 personality
9090-------------------------------------------------*/
9191
92static const struct reg_mask crtc6845_reg_mask[2][18] =
92static const struct reg_mask mscrtc6845_reg_mask[2][18] =
9393{
9494   {
9595      /* M6845_PERSONALITY_GENUINE */
r1129r1130
122122
123123***************************************************************************/
124124
125static void crtc6845_state_postload(void)
125static void mscrtc6845_state_postload(void)
126126{
127127   if (dirtybuffer && videoram_size)
128128      memset(dirtybuffer, 1, videoram_size);
129129}
130130
131struct crtc6845 *crtc6845_init(const struct crtc6845_config *config)
131struct mscrtc6845 *mscrtc6845_init(const struct mscrtc6845_config *config)
132132{
133   struct crtc6845 *crtc;
133   struct mscrtc6845 *crtc;
134134   int idx;
135135
136   crtc = auto_malloc(sizeof(struct crtc6845));
136   crtc = auto_malloc(sizeof(struct mscrtc6845));
137137   memset(crtc, 0, sizeof(*crtc));
138138   crtc->cursor_time = mame_time_to_double(mame_timer_get_time());
139139   crtc->config = *config;
140   crtc6845 = crtc;
140   mscrtc6845 = crtc;
141141
142142   /* Hardwire the values which can't be changed in the PC1512 version */
143143   if (config->personality == M6845_PERSONALITY_PC1512)
r1129r1130
148148      }
149149   }
150150
151   state_save_register_item_array("crtc6845", 0, crtc->reg);
152   state_save_register_item("crtc6845", 0, crtc->idx);
153   state_save_register_func_postload(crtc6845_state_postload);
151   state_save_register_item_array("mscrtc6845", 0, crtc->reg);
152   state_save_register_item("mscrtc6845", 0, crtc->idx);
153   state_save_register_func_postload(mscrtc6845_state_postload);
154154   return crtc;
155155}
156156
157157#define REG(x) (crtc->reg[x])
158158
159static int crtc6845_clocks_in_frame(struct crtc6845 *crtc)
159static int mscrtc6845_clocks_in_frame(struct mscrtc6845 *crtc)
160160{
161161   int clocks=CRTC6845_COLUMNS*CRTC6845_LINES;
162162   switch (CRTC6845_INTERLACE_MODE) {
r1129r1130
168168   }
169169}
170170
171void crtc6845_set_clock(struct crtc6845 *crtc, int freq)
171void mscrtc6845_set_clock(struct mscrtc6845 *crtc, int freq)
172172{
173173   assert(crtc);
174174   crtc->config.freq = freq;
175175}
176176
177void crtc6845_time(struct crtc6845 *crtc)
177void mscrtc6845_time(struct mscrtc6845 *crtc)
178178{
179179   double neu, ftime;
180   struct crtc6845_cursor cursor;
180   struct mscrtc6845_cursor cursor;
181181
182182   neu = mame_time_to_double(mame_timer_get_time());
183183
184   if (crtc6845_clocks_in_frame(crtc) == 0.0)
184   if (mscrtc6845_clocks_in_frame(crtc) == 0.0)
185185      return;
186186
187   ftime = crtc6845_clocks_in_frame(crtc) * 16.0 / crtc->config.freq;
187   ftime = mscrtc6845_clocks_in_frame(crtc) * 16.0 / crtc->config.freq;
188188
189189   if (CRTC6845_CURSOR_MODE==CRTC6845_CURSOR_32FRAMES)
190190      ftime*=2;
r1129r1130
192192   if (neu-crtc->cursor_time>ftime)
193193   {
194194      crtc->cursor_time += ftime;
195      crtc6845_get_cursor(crtc, &cursor);
195      mscrtc6845_get_cursor(crtc, &cursor);
196196
197197      if (crtc->config.cursor_changed)
198198         crtc->config.cursor_changed(&cursor);
r1129r1130
201201   }
202202}
203203
204int crtc6845_get_char_columns(struct crtc6845 *crtc)
204int mscrtc6845_get_char_columns(struct mscrtc6845 *crtc)
205205{
206206   return CRTC6845_CHAR_COLUMNS;
207207}
208208
209int crtc6845_get_char_height(struct crtc6845 *crtc)
209int mscrtc6845_get_char_height(struct mscrtc6845 *crtc)
210210{
211211   return CRTC6845_CHAR_HEIGHT;
212212}
213213
214int crtc6845_get_char_lines(struct crtc6845 *crtc)
214int mscrtc6845_get_char_lines(struct mscrtc6845 *crtc)
215215{
216216   return CRTC6845_CHAR_LINES;
217217}
218218
219int crtc6845_get_start(struct crtc6845 *crtc)
219int mscrtc6845_get_start(struct mscrtc6845 *crtc)
220220{
221221   return CRTC6845_VIDEO_START;
222222}
223223
224224
225void crtc6845_set_char_columns(struct crtc6845 *crtc, UINT8 columns)
225void mscrtc6845_set_char_columns(struct mscrtc6845 *crtc, UINT8 columns)
226226{
227227   crtc->reg[1] = columns;
228228}
229229
230230
231void crtc6845_set_char_lines(struct crtc6845 *crtc, UINT8 lines)
231void mscrtc6845_set_char_lines(struct mscrtc6845 *crtc, UINT8 lines)
232232{
233233   crtc->reg[6] = lines;
234234}
235235
236236
237int crtc6845_get_personality(struct crtc6845 *crtc)
237int mscrtc6845_get_personality(struct mscrtc6845 *crtc)
238238{
239239   return crtc->config.personality;
240240}
241241
242void crtc6845_get_cursor(struct crtc6845 *crtc, struct crtc6845_cursor *cursor)
242void mscrtc6845_get_cursor(struct mscrtc6845 *crtc, struct mscrtc6845_cursor *cursor)
243243{
244244   switch (CRTC6845_CURSOR_MODE) {
245245   case CRTC6845_CURSOR_OFF:
r1129r1130
261261   cursor->bottom = CRTC6845_CURSOR_BOTTOM;
262262}
263263
264UINT8 crtc6845_port_r(struct crtc6845 *crtc, int offset)
264UINT8 mscrtc6845_port_r(struct mscrtc6845 *crtc, int offset)
265265{
266266   UINT8 val = 0xff;
267267   int idx;
r1129r1130
270270   {
271271      idx = crtc->idx & 0x1f;
272272      if (idx < (sizeof(crtc->reg) / sizeof(crtc->reg[0])))
273         val = crtc->reg[idx] & crtc6845_reg_mask[crtc->config.personality][idx].read_mask;
273         val = crtc->reg[idx] & mscrtc6845_reg_mask[crtc->config.personality][idx].read_mask;
274274   }
275275   else
276276   {
r1129r1130
279279   return val;
280280}
281281
282int crtc6845_port_w(struct crtc6845 *crtc, int offset, UINT8 data)
282int mscrtc6845_port_w(struct mscrtc6845 *crtc, int offset, UINT8 data)
283283{
284   struct crtc6845_cursor cursor;
284   struct mscrtc6845_cursor cursor;
285285   int idx;
286286   UINT8 mask;
287287
r1129r1130
291291      idx = crtc->idx & 0x1f;
292292      if (idx < (sizeof(crtc->reg) / sizeof(crtc->reg[0])))
293293      {
294         mask = crtc6845_reg_mask[crtc->config.personality][idx].store_mask;
294         mask = mscrtc6845_reg_mask[crtc->config.personality][idx].store_mask;
295295         /* Don't zero out bits not covered by the mask. */
296296         crtc->reg[crtc->idx] &= ~mask;
297297         crtc->reg[crtc->idx] |= (data & mask);
r1129r1130
302302         case 0xb:
303303         case 0xe:
304304         case 0xf:
305            crtc6845_get_cursor(crtc, &cursor);
305            mscrtc6845_get_cursor(crtc, &cursor);
306306            if (crtc->config.cursor_changed)
307307               crtc->config.cursor_changed(&cursor);
308308            break;
r1129r1130
314314         if ((crtc->config.personality == M6845_PERSONALITY_PC1512) && (idx == 9))
315315         {
316316            UINT8 char_height;
317            char_height = crtc6845_get_char_height(crtc);
318            crtc6845_set_char_lines(crtc, 200 ); // / char_height);
317            char_height = mscrtc6845_get_char_height(crtc);
318            mscrtc6845_set_char_lines(crtc, 200 ); // / char_height);
319319         }
320320         return TRUE;
321321      }
r1129r1130
328328   return FALSE;
329329}
330330
331 READ8_HANDLER ( crtc6845_0_port_r )
331 READ8_HANDLER ( mscrtc6845_0_port_r )
332332{
333   return crtc6845_port_r(crtc6845, offset);
333   return mscrtc6845_port_r(mscrtc6845, offset);
334334}
335335
336WRITE8_HANDLER ( crtc6845_0_port_w )
336WRITE8_HANDLER ( mscrtc6845_0_port_w )
337337{
338   crtc6845_port_w(crtc6845, offset, data);
338   mscrtc6845_port_w(mscrtc6845, offset, data);
339339}
340340
src/mess/video/pet.c
r1129r1130
8585   return 0;
8686}
8787
88//  commodore pet crtc video circuit for 40 columns display (standard crtc6845)
88//  commodore pet crtc video circuit for 40 columns display (standard mscrtc6845)
8989VIDEO_UPDATE( pet40 )
9090{
9191   int x, y, i;
92   int w=crtc6845_get_char_columns(crtc6845);
93   int h=crtc6845_get_char_lines(crtc6845);
94   int height=crtc6845_get_char_height(crtc6845);
95   int start=crtc6845_get_start(crtc6845)&0x3ff;
92   int w=mscrtc6845_get_char_columns(mscrtc6845);
93   int h=mscrtc6845_get_char_lines(mscrtc6845);
94   int height=mscrtc6845_get_char_height(mscrtc6845);
95   int start=mscrtc6845_get_start(mscrtc6845)&0x3ff;
9696
9797   for (y=0, i=start; y<h;y++)
9898   {
r1129r1130
112112{
113113   int x, y, i;
114114   rectangle rect;
115   int w=crtc6845_get_char_columns(crtc6845);
116   int h=crtc6845_get_char_lines(crtc6845);
117   int height=crtc6845_get_char_height(crtc6845);
118   int start=crtc6845_get_start(crtc6845)&0x3ff;
115   int w=mscrtc6845_get_char_columns(mscrtc6845);
116   int h=mscrtc6845_get_char_lines(mscrtc6845);
117   int height=mscrtc6845_get_char_height(mscrtc6845);
118   int start=mscrtc6845_get_start(mscrtc6845)&0x3ff;
119119
120120   rect.min_x = Machine->screen[0].visarea.min_x;
121121   rect.max_x = Machine->screen[0].visarea.max_x;
src/mess/video/pc_video.c
r1129r1130
1919
2020***************************************************************************/
2121
22static pc_video_update_proc (*pc_choosevideomode)(int *width, int *height, struct crtc6845 *crtc);
23static struct crtc6845 *pc_crtc;
22static pc_video_update_proc (*pc_choosevideomode)(int *width, int *height, struct mscrtc6845 *crtc);
23static struct mscrtc6845 *pc_crtc;
2424static int pc_anythingdirty;
2525static int pc_current_height;
2626static int pc_current_width;
r1129r1130
3939
4040
4141
42struct crtc6845 *pc_video_start(const struct crtc6845_config *config,
43   pc_video_update_proc (*choosevideomode)(int *width, int *height, struct crtc6845 *crtc),
42struct mscrtc6845 *pc_video_start(const struct mscrtc6845_config *config,
43   pc_video_update_proc (*choosevideomode)(int *width, int *height, struct mscrtc6845 *crtc),
4444   size_t vramsize)
4545{
4646   pc_choosevideomode = choosevideomode;
r1129r1130
5454
5555   if (config)
5656   {
57      pc_crtc = crtc6845_init(config);
57      pc_crtc = mscrtc6845_init(config);
5858      if (!pc_crtc)
5959         return NULL;
6060   }
r1129r1130
7878
7979   if (pc_crtc)
8080   {
81      w = crtc6845_get_char_columns(pc_crtc);
82      h = crtc6845_get_char_height(pc_crtc) * crtc6845_get_char_lines(pc_crtc);
81      w = mscrtc6845_get_char_columns(pc_crtc);
82      h = mscrtc6845_get_char_height(pc_crtc) * mscrtc6845_get_char_lines(pc_crtc);
8383   }
8484
8585   video_update = pc_choosevideomode(&w, &h, pc_crtc);
r1129r1130
157157 *
158158 *************************************/
159159
160void pc_render_gfx_1bpp(mame_bitmap *bitmap, struct crtc6845 *crtc,
160void pc_render_gfx_1bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc,
161161   const UINT8 *vram, const UINT16 *palette, int interlace)
162162{
163163   int sx, sy, sh;
164   int   offs = crtc6845_get_start(crtc)*2;
165   int lines = crtc6845_get_char_lines(crtc);
166   int height = crtc6845_get_char_height(crtc);
167   int columns = crtc6845_get_char_columns(crtc)*2;
164   int   offs = mscrtc6845_get_start(crtc)*2;
165   int lines = mscrtc6845_get_char_lines(crtc);
166   int height = mscrtc6845_get_char_height(crtc);
167   int columns = mscrtc6845_get_char_columns(crtc)*2;
168168
169169   if (!vram)
170170      vram = videoram;
r1129r1130
197197
198198
199199
200void pc_render_gfx_2bpp(mame_bitmap *bitmap, struct crtc6845 *crtc,
200void pc_render_gfx_2bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc,
201201   const UINT8 *vram, const UINT16 *palette, int interlace)
202202{
203203   int sx, sy, sh;
204   int   offs = crtc6845_get_start(crtc)*2;
205   int lines = crtc6845_get_char_lines(crtc);
206   int height = crtc6845_get_char_height(crtc);
207   int columns = crtc6845_get_char_columns(crtc)*2;
204   int   offs = mscrtc6845_get_start(crtc)*2;
205   int lines = mscrtc6845_get_char_lines(crtc);
206   int height = mscrtc6845_get_char_height(crtc);
207   int columns = mscrtc6845_get_char_columns(crtc)*2;
208208   UINT16 *dest;
209209   const UINT8 *src;
210210
r1129r1130
238238
239239
240240
241void pc_render_gfx_4bpp(mame_bitmap *bitmap, struct crtc6845 *crtc,
241void pc_render_gfx_4bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc,
242242   const UINT8 *vram, const UINT16 *palette, int interlace)
243243{
244244   int sx, sy, sh;
245   int   offs = crtc6845_get_start(crtc)*2;
246   int lines = crtc6845_get_char_lines(crtc);
247   int height = crtc6845_get_char_height(crtc);
248   int columns = crtc6845_get_char_columns(crtc)*2;
245   int   offs = mscrtc6845_get_start(crtc)*2;
246   int lines = mscrtc6845_get_char_lines(crtc);
247   int height = mscrtc6845_get_char_height(crtc);
248   int columns = mscrtc6845_get_char_columns(crtc)*2;
249249
250250   if (!vram)
251251      vram = videoram;
src/mess/video/pc_video.h
r1129r1130
1313#include "includes/crtc6845.h"
1414
1515typedef void (*pc_video_update_proc)(mame_bitmap *bitmap,
16   struct crtc6845 *crtc);
16   struct mscrtc6845 *crtc);
1717
18struct crtc6845 *pc_video_start(const struct crtc6845_config *config,
19   pc_video_update_proc (*choosevideomode)(int *width, int *height, struct crtc6845 *crtc),
18struct mscrtc6845 *pc_video_start(const struct mscrtc6845_config *config,
19   pc_video_update_proc (*choosevideomode)(int *width, int *height, struct mscrtc6845 *crtc),
2020   size_t vramsize);
2121
2222VIDEO_UPDATE( pc_video );
r1129r1130
2626WRITE32_HANDLER( pc_video_videoram32_w );
2727
2828/* renderers */
29void pc_render_gfx_1bpp(mame_bitmap *bitmap, struct crtc6845 *crtc,
29void pc_render_gfx_1bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc,
3030   const UINT8 *vram, const UINT16 *palette, int interlace);
31void pc_render_gfx_2bpp(mame_bitmap *bitmap, struct crtc6845 *crtc,
31void pc_render_gfx_2bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc,
3232   const UINT8 *vram, const UINT16 *palette, int interlace);
33void pc_render_gfx_4bpp(mame_bitmap *bitmap, struct crtc6845 *crtc,
33void pc_render_gfx_4bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc,
3434   const UINT8 *vram, const UINT16 *palette, int interlace);
3535
3636#endif /* PC_VIDEO_H */
src/mess/video/pc_mda.c
r1129r1130
120120   if (mda.pc_blink == on) return;
121121
122122    mda.pc_blink = on;
123   offs = (crtc6845_get_start(crtc6845)*2)% videoram_size;
124   size = crtc6845_get_char_lines(crtc6845)*crtc6845_get_char_columns(crtc6845);
123   offs = (mscrtc6845_get_start(mscrtc6845)*2)% videoram_size;
124   size = mscrtc6845_get_char_lines(mscrtc6845)*mscrtc6845_get_char_columns(mscrtc6845);
125125
126126   if (dirtybuffer)
127127   {
r1129r1130
142142   }
143143}
144144
145void pc_mda_cursor(struct crtc6845_cursor *cursor)
145void pc_mda_cursor(struct mscrtc6845_cursor *cursor)
146146{
147147   if (dirtybuffer)
148148      dirtybuffer[cursor->pos*2]=1;
149149}
150150
151static struct crtc6845_config config= { 14318180 /*?*/, pc_mda_cursor };
151static struct mscrtc6845_config config= { 14318180 /*?*/, pc_mda_cursor };
152152
153153
154154/* This code seems to go through hoops to accomodate differing GfxElement
r1129r1130
257257   switch( offset )
258258   {
259259      case 0: case 2: case 4: case 6:
260         crtc6845_port_w(crtc6845, 0, data);
260         mscrtc6845_port_w(mscrtc6845, 0, data);
261261         break;
262262      case 1: case 3: case 5: case 7:
263         crtc6845_port_w(crtc6845, 1, data);
263         mscrtc6845_port_w(mscrtc6845, 1, data);
264264         break;
265265      case 8:
266266         hercules_mode_control_w(data);
r1129r1130
277277   switch( offset )
278278   {
279279      case 0: case 2: case 4: case 6:
280         data = crtc6845_port_r(crtc6845,0);
280         data = mscrtc6845_port_r(mscrtc6845,0);
281281         break;
282282      case 1: case 3: case 5: case 7:
283         data = crtc6845_port_r(crtc6845,1);
283         data = mscrtc6845_port_r(mscrtc6845,1);
284284         break;
285285      case 10:
286286         data = pc_mda_status_r();
r1129r1130
295295  The character cell size is 9x15. Column 9 is column 8 repeated for
296296  character codes 176 to 223.
297297***************************************************************************/
298static void mda_text_inten(mame_bitmap *bitmap, struct crtc6845 *crtc)
298static void mda_text_inten(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
299299{
300300   int sx, sy;
301   int   offs = crtc6845_get_start(crtc)*2;
302   int lines = crtc6845_get_char_lines(crtc);
303   int height = crtc6845_get_char_height(crtc);
304   int columns = crtc6845_get_char_columns(crtc);
301   int   offs = mscrtc6845_get_start(crtc)*2;
302   int lines = mscrtc6845_get_char_lines(crtc);
303   int height = mscrtc6845_get_char_height(crtc);
304   int columns = mscrtc6845_get_char_columns(crtc);
305305   int char_width;
306306   rectangle r;
307   struct crtc6845_cursor cursor;
307   struct mscrtc6845_cursor cursor;
308308   UINT8 attr;
309309
310310   char_width = Machine->screen[0].width / 80;
311311
312   crtc6845_time(crtc);
313   crtc6845_get_cursor(crtc, &cursor);
312   mscrtc6845_time(crtc);
313   mscrtc6845_get_cursor(crtc, &cursor);
314314
315315   for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) {
316316
r1129r1130
351351  The character cell size is 9x15. Column 9 is column 8 repeated for
352352  character codes 176 to 223.
353353***************************************************************************/
354static void mda_text_blink(mame_bitmap *bitmap, struct crtc6845 *crtc)
354static void mda_text_blink(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
355355{
356356   int sx, sy;
357   int   offs = crtc6845_get_start(crtc)*2;
358   int lines = crtc6845_get_char_lines(crtc);
359   int height = crtc6845_get_char_height(crtc);
360   int columns = crtc6845_get_char_columns(crtc);
357   int   offs = mscrtc6845_get_start(crtc)*2;
358   int lines = mscrtc6845_get_char_lines(crtc);
359   int height = mscrtc6845_get_char_height(crtc);
360   int columns = mscrtc6845_get_char_columns(crtc);
361361   rectangle r;
362   struct crtc6845_cursor cursor;
362   struct mscrtc6845_cursor cursor;
363363   int char_width;
364364
365365   char_width = Machine->screen[0].width / 80;
366366
367   crtc6845_time(crtc);
368   crtc6845_get_cursor(crtc, &cursor);
367   mscrtc6845_time(crtc);
368   mscrtc6845_get_cursor(crtc, &cursor);
369369
370370   for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) {
371371
r1129r1130
414414  bit 7 being the leftmost.
415415***************************************************************************/
416416
417static void hercules_gfx(mame_bitmap *bitmap, struct crtc6845 *crtc)
417static void hercules_gfx(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
418418{
419419   const UINT8 *vram = videoram;
420420   static const UINT16 palette[2] = {0, 10};
r1129r1130
431431  Choose the appropriate video mode
432432***************************************************************************/
433433
434pc_video_update_proc pc_mda_choosevideomode(int *width, int *height, struct crtc6845 *crtc)
434pc_video_update_proc pc_mda_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc)
435435{
436436   pc_video_update_proc proc = NULL;
437437
src/mess/video/pc_mda.h
r1129r1130
1212void pc_mda_timer(void);
1313
1414VIDEO_START ( pc_mda );
15pc_video_update_proc pc_mda_choosevideomode(int *width, int *height, struct crtc6845 *crtc);
15pc_video_update_proc pc_mda_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc);
1616
1717WRITE8_HANDLER ( pc_MDA_w );
1818READ8_HANDLER ( pc_MDA_r );
r1129r1130
2626PALETTE_INIT( pc_mda );
2727
2828//internal use
29void pc_mda_cursor(struct crtc6845_cursor *cursor);
29void pc_mda_cursor(struct mscrtc6845_cursor *cursor);
src/mess/video/pc_t1t.c
r1129r1130
2525
2626static PALETTE_INIT( pcjr );
2727static VIDEO_START( pc_t1t );
28static pc_video_update_proc pc_t1t_choosevideomode(int *width, int *height, struct crtc6845 *crtc);
28static pc_video_update_proc pc_t1t_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc);
2929
3030/***************************************************************************
3131
r1129r1130
185185   if (pcjr.pc_blink == on) return;
186186
187187    pcjr.pc_blink = on;
188   offs = (crtc6845_get_start(crtc6845)* 2) % videoram_size;
189   size = crtc6845_get_char_columns(crtc6845) * crtc6845_get_char_lines(crtc6845);
188   offs = (mscrtc6845_get_start(mscrtc6845)* 2) % videoram_size;
189   size = mscrtc6845_get_char_columns(mscrtc6845) * mscrtc6845_get_char_lines(mscrtc6845);
190190
191191   if (dirtybuffer)
192192   {
r1129r1130
208208   }
209209}
210210
211static void pc_t1t_cursor(struct crtc6845_cursor *cursor)
211static void pc_t1t_cursor(struct mscrtc6845_cursor *cursor)
212212{
213213   if (dirtybuffer)
214214      dirtybuffer[cursor->pos*2] = 1;
215215}
216216
217static struct crtc6845_config config= { 14318180 /*?*/, pc_t1t_cursor };
217static struct mscrtc6845_config config= { 14318180 /*?*/, pc_t1t_cursor };
218218
219219
220220static VIDEO_START( pc_t1t )
r1129r1130
412412   switch( offset )
413413   {
414414      case 0: case 2: case 4: case 6:
415         crtc6845_port_w(crtc6845,0,data);
415         mscrtc6845_port_w(mscrtc6845,0,data);
416416         break;
417417      case 1: case 3: case 5: case 7:
418         crtc6845_port_w(crtc6845,1,data);
418         mscrtc6845_port_w(mscrtc6845,1,data);
419419         break;
420420      case 8:
421421         pc_t1t_mode_control_w(data);
r1129r1130
448448   switch( offset )
449449   {
450450      case 0: case 2: case 4: case 6:
451         data = crtc6845_port_r(crtc6845,0);
451         data = mscrtc6845_port_r(mscrtc6845,0);
452452         break;
453453
454454      case 1: case 3: case 5: case 7:
455         data = crtc6845_port_r(crtc6845,1);
455         data = mscrtc6845_port_r(mscrtc6845,1);
456456         break;
457457
458458      case 8:
r1129r1130
517517  Draw text mode with 40x25 characters (default) with high intensity bg.
518518***************************************************************************/
519519
520static void t1t_text_inten(mame_bitmap *bitmap, struct crtc6845 *crtc)
520static void t1t_text_inten(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
521521{
522522   int sx, sy;
523   int   offs = crtc6845_get_start(crtc)*2;
524   int lines = crtc6845_get_char_lines(crtc);
525   int height = crtc6845_get_char_height(crtc);
526   int columns = crtc6845_get_char_columns(crtc);
523   int   offs = mscrtc6845_get_start(crtc)*2;
524   int lines = mscrtc6845_get_char_lines(crtc);
525   int height = mscrtc6845_get_char_height(crtc);
526   int columns = mscrtc6845_get_char_columns(crtc);
527527   rectangle r;
528   struct crtc6845_cursor cursor;
528   struct mscrtc6845_cursor cursor;
529529
530   crtc6845_time(crtc);
531   crtc6845_get_cursor(crtc, &cursor);
530   mscrtc6845_time(crtc);
531   mscrtc6845_get_cursor(crtc, &cursor);
532532
533533   for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) {
534534
r1129r1130
569569  Draw text mode with 40x25 characters (default) and blinking colors.
570570***************************************************************************/
571571
572static void t1t_text_blink(mame_bitmap *bitmap, struct crtc6845 *crtc)
572static void t1t_text_blink(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
573573{
574574   int sx, sy;
575   int   offs = crtc6845_get_start(crtc)*2;
576   int lines = crtc6845_get_char_lines(crtc);
577   int height = crtc6845_get_char_height(crtc);
578   int columns = crtc6845_get_char_columns(crtc);
575   int   offs = mscrtc6845_get_start(crtc)*2;
576   int lines = mscrtc6845_get_char_lines(crtc);
577   int height = mscrtc6845_get_char_height(crtc);
578   int columns = mscrtc6845_get_char_columns(crtc);
579579   rectangle r;
580   struct crtc6845_cursor cursor;
580   struct mscrtc6845_cursor cursor;
581581
582   crtc6845_time(crtc);
583   crtc6845_get_cursor(crtc, &cursor);
582   mscrtc6845_time(crtc);
583   mscrtc6845_get_cursor(crtc, &cursor);
584584
585585   for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height)
586586   {
r1129r1130
633633  Even scanlines are from T1T_base + 0x0000, odd from T1T_base + 0x2000
634634***************************************************************************/
635635
636static void t1t_gfx_2bpp(mame_bitmap *bitmap, struct crtc6845 *crtc)
636static void t1t_gfx_2bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
637637{
638638   static const UINT16 palette[] =
639639   {
r1129r1130
651651  The cell size is 1x1 (1 scanline is the real default)
652652  Even scanlines are from T1T_base + 0x0000, odd from T1T_base + 0x2000
653653***************************************************************************/
654static void t1t_gfx_1bpp(mame_bitmap *bitmap, struct crtc6845 *crtc)
654static void t1t_gfx_1bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
655655{
656656   int i, sx, sy, sh;
657   int   offs = crtc6845_get_start(crtc)*2;
658   int lines = crtc6845_get_char_lines(crtc);
659   int height = crtc6845_get_char_height(crtc);
660   int columns = crtc6845_get_char_columns(crtc)*2;
657   int   offs = mscrtc6845_get_start(crtc)*2;
658   int lines = mscrtc6845_get_char_lines(crtc);
659   int height = mscrtc6845_get_char_height(crtc);
660   int columns = mscrtc6845_get_char_columns(crtc)*2;
661661
662662   for (sy=0; sy<lines; sy++,offs=(offs+columns)&0x1fff) {
663663
r1129r1130
693693  CGA_base + 0x2000
694694***************************************************************************/
695695
696static void t1t_gfx_4bpp(mame_bitmap *bitmap, struct crtc6845 *crtc)
696static void t1t_gfx_4bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
697697{
698698   pc_render_gfx_4bpp(bitmap, crtc, pcjr.displayram, NULL, 4);
699699}
r1129r1130
704704  Choose the appropriate video mode
705705***************************************************************************/
706706
707static pc_video_update_proc pc_t1t_choosevideomode(int *width, int *height, struct crtc6845 *crtc)
707static pc_video_update_proc pc_t1t_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc)
708708{
709709   int xfactor = 8;
710710   int yfactor = 1;
src/mess/video/pc_aga.c
r1129r1130
77#include "video/generic.h"
88#include "memconv.h"
99
10static pc_video_update_proc pc_aga_choosevideomode(int *width, int *height, struct crtc6845 *crtc);
10static pc_video_update_proc pc_aga_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc);
1111
1212
1313gfx_layout europc_cga_charlayout =
r1129r1130
164164
165165   switch (aga.mode) {
166166   case AGA_COLOR:
167      crtc6845_set_clock(crtc6845, 10000000/*?*/);
167      mscrtc6845_set_clock(mscrtc6845, 10000000/*?*/);
168168      break;
169169   case AGA_MONO:
170      crtc6845_set_clock(crtc6845, 10000000/*?*/);
170      mscrtc6845_set_clock(mscrtc6845, 10000000/*?*/);
171171      break;
172172   case AGA_OFF:
173173      break;
r1129r1130
183183   }
184184}
185185
186static void pc_aga_cursor(struct crtc6845_cursor *cursor)
186static void pc_aga_cursor(struct mscrtc6845_cursor *cursor)
187187{
188188   switch (aga.mode) {
189189   case AGA_COLOR:
r1129r1130
200200}
201201
202202
203static struct crtc6845_config config= { 14318180 /*?*/, pc_aga_cursor };
203static struct mscrtc6845_config config= { 14318180 /*?*/, pc_aga_cursor };
204204
205205VIDEO_START( pc_aga )
206206{
r1129r1130
263263/***************************************************************************
264264  Choose the appropriate video mode
265265***************************************************************************/
266static pc_video_update_proc pc_aga_choosevideomode(int *width, int *height, struct crtc6845 *crtc)
266static pc_video_update_proc pc_aga_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc)
267267{
268268   pc_video_update_proc proc = NULL;
269269
src/mess/video/pc_cga.c
r1129r1130
252252
253253
254254
255void pc_cga_cursor(struct crtc6845_cursor *cursor)
255void pc_cga_cursor(struct mscrtc6845_cursor *cursor)
256256{
257257   if (dirtybuffer && (videoram_size > cursor->pos*2))
258258      dirtybuffer[cursor->pos*2]=1;
r1129r1130
260260
261261
262262
263static struct crtc6845_config config= { 14318180 /*?*/, pc_cga_cursor };
263static struct mscrtc6845_config config= { 14318180 /*?*/, pc_cga_cursor };
264264
265265static int internal_pc_cga_video_start(int personality)
266266{
r1129r1130
469469   switch( offset )
470470   {
471471      case 0: case 2: case 4: case 6:
472         data = crtc6845_port_r(crtc6845, 0);
472         data = mscrtc6845_port_r(mscrtc6845, 0);
473473         break;
474474      case 1: case 3: case 5: case 7:
475         data = crtc6845_port_r(crtc6845, 1);
475         data = mscrtc6845_port_r(mscrtc6845, 1);
476476         break;
477477      case 10:
478478         data = pc_cga_status_r();
r1129r1130
488488   switch(offset) {
489489   case 0: case 2: case 4: case 6:
490490   case 1: case 3: case 5: case 7:
491      if (crtc6845_port_w(crtc6845, offset, data))
491      if (mscrtc6845_port_w(mscrtc6845, offset, data))
492492      {
493493         if (dirtybuffer) memset(dirtybuffer, 1, videoram_size);
494494      }
r1129r1130
519519  The character cell size is 16x8
520520***************************************************************************/
521521
522static void cga_text_inten(mame_bitmap *bitmap, struct crtc6845 *crtc)
522static void cga_text_inten(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
523523{
524524   int sx, sy;
525   int   offs = crtc6845_get_start(crtc) * 2;
526   int lines = crtc6845_get_char_lines(crtc);
527   int height = crtc6845_get_char_height(crtc);
528   int columns = crtc6845_get_char_columns(crtc);
525   int   offs = mscrtc6845_get_start(crtc) * 2;
526   int lines = mscrtc6845_get_char_lines(crtc);
527   int height = mscrtc6845_get_char_height(crtc);
528   int columns = mscrtc6845_get_char_columns(crtc);
529529   rectangle r;
530   struct crtc6845_cursor cursor;
530   struct mscrtc6845_cursor cursor;
531531
532   crtc6845_time(crtc);
533   crtc6845_get_cursor(crtc, &cursor);
532   mscrtc6845_time(crtc);
533   mscrtc6845_get_cursor(crtc, &cursor);
534534   pc_cga_check_palette();
535535
536536   for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height)
r1129r1130
579579  The character cell size is 16x8
580580***************************************************************************/
581581
582static void cga_text_inten_alt(mame_bitmap *bitmap, struct crtc6845 *crtc)
582static void cga_text_inten_alt(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
583583{
584584   int sx, sy;
585   int   offs = crtc6845_get_start(crtc) * 2;
586   int lines = crtc6845_get_char_lines(crtc);
587   int height = crtc6845_get_char_height(crtc);
588   int columns = crtc6845_get_char_columns(crtc);
585   int   offs = mscrtc6845_get_start(crtc) * 2;
586   int lines = mscrtc6845_get_char_lines(crtc);
587   int height = mscrtc6845_get_char_height(crtc);
588   int columns = mscrtc6845_get_char_columns(crtc);
589589   rectangle r;
590   struct crtc6845_cursor cursor;
590   struct mscrtc6845_cursor cursor;
591591
592592   if (CGA_CHIPSET != CGA_CHIPSET_PC200)
593593   {
r1129r1130
595595      return;
596596   }
597597
598   crtc6845_time(crtc);
599   crtc6845_get_cursor(crtc, &cursor);
598   mscrtc6845_time(crtc);
599   mscrtc6845_get_cursor(crtc, &cursor);
600600   pc_cga_check_palette();
601601
602602   for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height)
r1129r1130
634634  Draw text mode with 40x25 characters (default) and blinking colors.
635635  The character cell size is 16x8
636636***************************************************************************/
637static void cga_text_blink(mame_bitmap *bitmap, struct crtc6845 *crtc)
637static void cga_text_blink(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
638638{
639639   int sx, sy;
640   int   offs = crtc6845_get_start(crtc)*2;
641   int lines = crtc6845_get_char_lines(crtc);
642   int height = crtc6845_get_char_height(crtc);
643   int columns = crtc6845_get_char_columns(crtc);
640   int   offs = mscrtc6845_get_start(crtc)*2;
641   int lines = mscrtc6845_get_char_lines(crtc);
642   int height = mscrtc6845_get_char_height(crtc);
643   int columns = mscrtc6845_get_char_columns(crtc);
644644   rectangle r;
645   struct crtc6845_cursor cursor;
645   struct mscrtc6845_cursor cursor;
646646
647   crtc6845_time(crtc);
648   crtc6845_get_cursor(crtc, &cursor);
647   mscrtc6845_time(crtc);
648   mscrtc6845_get_cursor(crtc, &cursor);
649649   pc_cga_check_palette();
650650
651651   for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height)
r1129r1130
706706  The character cell size is 16x8
707707***************************************************************************/
708708
709static void cga_text_blink_alt(mame_bitmap *bitmap, struct crtc6845 *crtc)
709static void cga_text_blink_alt(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
710710{
711711   int sx, sy;
712   int   offs = crtc6845_get_start(crtc)*2;
713   int lines = crtc6845_get_char_lines(crtc);
714   int height = crtc6845_get_char_height(crtc);
715   int columns = crtc6845_get_char_columns(crtc);
712   int   offs = mscrtc6845_get_start(crtc)*2;
713   int lines = mscrtc6845_get_char_lines(crtc);
714   int height = mscrtc6845_get_char_height(crtc);
715   int columns = mscrtc6845_get_char_columns(crtc);
716716   rectangle r;
717   struct crtc6845_cursor cursor;
717   struct mscrtc6845_cursor cursor;
718718   
719719   if (CGA_CHIPSET != CGA_CHIPSET_PC200)
720720   {
r1129r1130
722722      return;
723723   }
724724
725   crtc6845_time(crtc);
726   crtc6845_get_cursor(crtc, &cursor);
725   mscrtc6845_time(crtc);
726   mscrtc6845_get_cursor(crtc, &cursor);
727727   pc_cga_check_palette();
728728
729729   for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height)
r1129r1130
772772/***************************************************************************
773773  Draw graphics mode with 320x200 pixels (default) with 2 bits/pixel.
774774  Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000
775  cga fetches 2 byte per crtc6845 access (not modeled here)!
775  cga fetches 2 byte per mscrtc6845 access (not modeled here)!
776776***************************************************************************/
777777
778static void cga_gfx_2bpp(mame_bitmap *bitmap, struct crtc6845 *crtc)
778static void cga_gfx_2bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
779779{
780780   const UINT16 *palette;
781781   int colorset = cga.color_select & 0x3F;
r1129r1130
817817  Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000
818818***************************************************************************/
819819
820static void cga_gfx_1bpp(mame_bitmap *bitmap, struct crtc6845 *crtc)
820static void cga_gfx_1bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
821821{
822822   const UINT16 *palette;
823823
r1129r1130
846846}
847847
848848
849static void cga_gfx_4bpp(mame_bitmap *bitmap, struct crtc6845 *crtc, int scale)
849static void cga_gfx_4bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc, int scale)
850850{
851851   int i, sx, sy, sh;
852   int   offs = crtc6845_get_start(crtc)*2;
853   int lines = crtc6845_get_char_lines(crtc);
854   int height = crtc6845_get_char_height(crtc);
855   int columns = crtc6845_get_char_columns(crtc)*2;
852   int   offs = mscrtc6845_get_start(crtc)*2;
853   int lines = mscrtc6845_get_char_lines(crtc);
854   int height = mscrtc6845_get_char_height(crtc);
855   int columns = mscrtc6845_get_char_columns(crtc)*2;
856856
857857   pc_cga_check_palette();
858858
r1129r1130
895895 * The different scaling factors mean that the '160x200' versions of screens
896896 * are the same size as the normal colour ones.
897897 */
898static void cga_gfx_4bpph(mame_bitmap *bitmap, struct crtc6845 *crtc)
898static void cga_gfx_4bpph(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
899899{
900900   pc_cga_check_palette();
901901   cga_gfx_4bpp(bitmap, crtc, 8);
r1129r1130
903903
904904   
905905/* The lo-res graphics mode on a colour composite monitor */
906static void cga_gfx_4bppl(mame_bitmap *bitmap, struct crtc6845 *crtc)
906static void cga_gfx_4bppl(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
907907{
908908   pc_cga_check_palette();
909909   cga_gfx_4bpp(bitmap, crtc, 4);
r1129r1130
947947  Second plane at CGA_base + 0x4000 / 0x6000
948948***************************************************************************/
949949
950static void cga_pgfx_4bpp(mame_bitmap *bitmap, struct crtc6845 *crtc)
950static void cga_pgfx_4bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
951951{
952952   int i, sx, sy, sh;
953   int   offs = crtc6845_get_start(crtc)*2;
954   int lines = crtc6845_get_char_lines(crtc);
955   int height = crtc6845_get_char_height(crtc);
956   int columns = crtc6845_get_char_columns(crtc)*2;
953   int   offs = mscrtc6845_get_start(crtc)*2;
954   int lines = mscrtc6845_get_char_lines(crtc);
955   int height = mscrtc6845_get_char_height(crtc);
956   int columns = mscrtc6845_get_char_columns(crtc)*2;
957957
958958   for (sy=0; sy<lines; sy++,offs=(offs+columns)&0x1fff)
959959   {
r1129r1130
10341034/***************************************************************************
10351035  Draw graphics mode with 320x200 pixels (default) with 2 bits/pixel.
10361036  Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000
1037  cga fetches 2 byte per crtc6845 access (not modeled here)!
1037  cga fetches 2 byte per mscrtc6845 access (not modeled here)!
10381038***************************************************************************/
10391039
1040static void cga_pgfx_2bpp(mame_bitmap *bitmap, struct crtc6845 *crtc)
1040static void cga_pgfx_2bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
10411041{
10421042   int i, sx, sy, sh;
1043   int   offs = crtc6845_get_start(crtc)*2;
1044   int lines = crtc6845_get_char_lines(crtc);
1045   int height = crtc6845_get_char_height(crtc);
1046   int columns = crtc6845_get_char_columns(crtc)*2;
1043   int   offs = mscrtc6845_get_start(crtc)*2;
1044   int lines = mscrtc6845_get_char_lines(crtc);
1045   int height = mscrtc6845_get_char_height(crtc);
1046   int columns = mscrtc6845_get_char_columns(crtc)*2;
10471047   int colorset = cga.color_select & 0x3F;
10481048   const UINT16 *palette;
10491049
r1129r1130
11431143  Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000
11441144***************************************************************************/
11451145
1146static void pc1512_gfx_4bpp(mame_bitmap *bitmap, struct crtc6845 *crtc)
1146static void pc1512_gfx_4bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc)
11471147{
11481148   int i, sx, sy, sh;
1149   int   offs = crtc6845_get_start(crtc)*2;
1150   int lines = crtc6845_get_char_lines(crtc);
1151   int height = crtc6845_get_char_height(crtc);
1152   int columns = crtc6845_get_char_columns(crtc)*2;
1149   int   offs = mscrtc6845_get_start(crtc)*2;
1150   int lines = mscrtc6845_get_char_lines(crtc);
1151   int height = mscrtc6845_get_char_height(crtc);
1152   int columns = mscrtc6845_get_char_columns(crtc)*2;
11531153
11541154   for (sy=0; sy<lines; sy++,offs=(offs+columns)&0x1fff)
11551155   {
r1129r1130
11991199   if (cga.pc_blink == on) return;
12001200
12011201    cga.pc_blink = on;
1202   offs = (crtc6845_get_start(crtc6845)*2) & 0x3fff;
1203   size = crtc6845_get_char_lines(crtc6845)*crtc6845_get_char_columns(crtc6845);
1202   offs = (mscrtc6845_get_start(mscrtc6845)*2) & 0x3fff;
1203   size = mscrtc6845_get_char_lines(mscrtc6845)*mscrtc6845_get_char_columns(mscrtc6845);
12041204
12051205   if (dirtybuffer)
12061206   {
r1129r1130
12341234  Choose the appropriate video mode
12351235***************************************************************************/
12361236
1237pc_video_update_proc pc_cga_choosevideomode(int *width, int *height, struct crtc6845 *crtc)
1237pc_video_update_proc pc_cga_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc)
12381238{
12391239   pc_video_update_proc proc = NULL;
12401240   const pc_video_update_proc *procarray;
r1129r1130
12881288   {
12891289      mode = (cga.mode_control & 0x07) | ((cga.mode_control & 0x30) / 2);
12901290
1291      procarray = videoprocs[crtc6845_get_personality(crtc)];
1291      procarray = videoprocs[mscrtc6845_get_personality(crtc)];
12921292      proc = procarray[mode];
12931293
12941294      /* Plantronics high-res */
r1129r1130
13471347    * character columns register, program it manually. */
13481348
13491349   case 0x8:
1350      char_height = crtc6845_get_char_height(crtc6845);
1350      char_height = mscrtc6845_get_char_height(mscrtc6845);
13511351      if (data & 2) /* Graphics */
13521352      {
1353         crtc6845_set_char_columns(crtc6845, 40);
1353         mscrtc6845_set_char_columns(mscrtc6845, 40);
13541354      }
13551355      else
13561356      {
13571357         if (data & 1) /* 80-column */
13581358         {
1359            crtc6845_set_char_columns(crtc6845, 80);
1359            mscrtc6845_set_char_columns(mscrtc6845, 80);
13601360         }
13611361         else
13621362         {
1363            crtc6845_set_char_columns(crtc6845, 40);
1363            mscrtc6845_set_char_columns(mscrtc6845, 40);
13641364         }
13651365      }
1366      crtc6845_set_char_lines(crtc6845, 200 );
1366      mscrtc6845_set_char_lines(mscrtc6845, 200 );
13671367      pc_cga8_w(offset, data);
13681368      break;
13691369
src/mess/video/pc_cga.h
r1129r1130
1616/* has a special 640x200 in 16 color mode, 4 banks at 0xb8000 */
1717MACHINE_DRIVER_EXTERN( pcvideo_pc1512 );
1818
19pc_video_update_proc pc_cga_choosevideomode(int *width, int *height, struct crtc6845 *crtc);
19pc_video_update_proc pc_cga_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc);
2020
2121READ8_HANDLER( pc_cga8_r );
2222WRITE8_HANDLER( pc_cga8_w );
r1129r1130
3434#define CGA_FONT      (input_port_20_r(0)&3)
3535
3636//internal use
37void pc_cga_cursor(struct crtc6845_cursor *cursor);
37void pc_cga_cursor(struct mscrtc6845_cursor *cursor);
3838
3939
4040
src/mess/video/amstrad.c
r1129r1130
1616
1717#include "sound/ay8910.h"
1818
19static crtc6845_state amstrad_vidhrdw_6845_state;
19static m6845_state amstrad_vidhrdw_6845_state;
2020int prev_reg;
2121
2222extern int amstrad_plus_asic_enabled;
r1129r1130
358358{
359359   mame_bitmap *bitmap = amstrad_bitmap;
360360
361   int ma = amstrad_CRTC_MA; // crtc6845_memory_address_r(0);
362   int ra = amstrad_CRTC_RA; // crtc6845_row_address_r(0);
361   int ma = amstrad_CRTC_MA; // m6845_memory_address_r(0);
362   int ra = amstrad_CRTC_RA; // m6845_row_address_r(0);
363363   /* calc mem addr to fetch data from   based on ma, and ra */
364364   unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) |
365365         ((ra & 0x07)<<11) |
r1129r1130
416416{
417417   mame_bitmap *bitmap = amstrad_bitmap;
418418
419   int ma = amstrad_CRTC_MA; // crtc6845_memory_address_r(0);
420   int ra = amstrad_CRTC_RA; // crtc6845_row_address_r(0);
419   int ma = amstrad_CRTC_MA; // m6845_memory_address_r(0);
420   int ra = amstrad_CRTC_RA; // m6845_row_address_r(0);
421421/* calc mem addr to fetch data from   based on ma, and ra */
422422   unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) |
423423         ((ra & 0x07)<<11) |
r1129r1130
467467{
468468   mame_bitmap *bitmap = amstrad_bitmap;
469469
470   int ma = amstrad_CRTC_MA; // crtc6845_memory_address_r(0);
471   int ra = amstrad_CRTC_RA; // crtc6845_row_address_r(0);
470   int ma = amstrad_CRTC_MA; // m6845_memory_address_r(0);
471   int ra = amstrad_CRTC_RA; // m6845_row_address_r(0);
472472/* calc mem addr to fetch data from   based on ma, and ra */
473473   unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) |
474474         ((ra & 0x07)<<11) |
r1129r1130
507507{
508508   mame_bitmap *bitmap = amstrad_bitmap;
509509
510   int ma = amstrad_CRTC_MA; // crtc6845_memory_address_r(0);
511   int ra = amstrad_CRTC_RA; // crtc6845_row_address_r(0);
510   int ma = amstrad_CRTC_MA; // m6845_memory_address_r(0);
511   int ra = amstrad_CRTC_RA; // m6845_row_address_r(0);
512512/* calc mem addr to fetch data from   based on ma, and ra */
513513   unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) |
514514         ((ra & 0x07)<<11) |
r1129r1130
565565{
566566   mame_bitmap *bitmap = amstrad_bitmap;
567567
568   int ma = amstrad_CRTC_MA; // crtc6845_memory_address_r(0);
569   int ra = amstrad_CRTC_RA; // crtc6845_row_address_r(0);
568   int ma = amstrad_CRTC_MA; // m6845_memory_address_r(0);
569   int ra = amstrad_CRTC_RA; // m6845_row_address_r(0);
570570   /* calc mem addr to fetch data from   based on ma, and ra */
571571   unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) |
572572         ((ra & 0x07)<<11) |
r1129r1130
612612{
613613   mame_bitmap *bitmap = amstrad_bitmap;
614614
615   int ma = amstrad_CRTC_MA; // crtc6845_memory_address_r(0);
616   int ra = amstrad_CRTC_RA; // crtc6845_row_address_r(0);
615   int ma = amstrad_CRTC_MA; // m6845_memory_address_r(0);
616   int ra = amstrad_CRTC_RA; // m6845_row_address_r(0);
617617/* calc mem addr to fetch data from   based on ma, and ra */
618618   unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) |
619619         ((ra & 0x07)<<11) |
r1129r1130
652652{
653653   mame_bitmap *bitmap = amstrad_bitmap;
654654
655   int ma = amstrad_CRTC_MA; // crtc6845_memory_address_r(0);
656   int ra = amstrad_CRTC_RA; // crtc6845_row_address_r(0);
655   int ma = amstrad_CRTC_MA; // m6845_memory_address_r(0);
656   int ra = amstrad_CRTC_RA; // m6845_row_address_r(0);
657657/* calc mem addr to fetch data from   based on ma, and ra */
658658   unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) |
659659         ((ra & 0x07)<<11) |
r1129r1130
686686{
687687   mame_bitmap *bitmap = amstrad_bitmap;
688688
689   int ma = amstrad_CRTC_MA; // crtc6845_memory_address_r(0);
690   int ra = amstrad_CRTC_RA; // crtc6845_row_address_r(0);
689   int ma = amstrad_CRTC_MA; // m6845_memory_address_r(0);
690   int ra = amstrad_CRTC_RA; // m6845_row_address_r(0);
691691/* calc mem addr to fetch data from   based on ma, and ra */
692692   unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) |
693693         ((ra & 0x07)<<11) |
r1129r1130
730730/* execute crtc_execute_cycles of crtc */
731731void amstrad_vh_execute_crtc_cycles(int dummy)
732732{
733   crtc6845_clock(); // Clock the 6845
733   m6845_clock(); // Clock the 6845
734734   if ((x_screen_pos >= 0) && (x_screen_pos < AMSTRAD_SCREEN_WIDTH) && (y_screen_pos >= 0))
735735   {
736736      /* render the screen */
r1129r1130
771771
772772   // get display bounds from CRTC registers (sprites are bound and clipped to inside the border)
773773   rect.min_x = display_x;//(((vid.registers[0] - 1) - (vid.registers[2] - 1))*4)+8;
774   rect.max_x = rect.min_x + (crtc6845_get_register(1) * 16);
774   rect.max_x = rect.min_x + (m6845_get_register(1) * 16);
775775   rect.min_y = display_y;//(((vid.registers[4] - 1) - (vid.registers[7] - 1))*4)+4;
776   rect.max_y = rect.min_y + (crtc6845_get_register(6) * (crtc6845_get_register(9)+1));
776   rect.max_y = rect.min_y + (m6845_get_register(6) * (m6845_get_register(9)+1));
777777
778778   for(spr = 15; spr >= 0; spr--)
779779   {
r1129r1130
927927      if(display_update == 1 && amstrad_plus_asic_enabled != 0)  // first scanline
928928      {
929929         if(amstrad_plus_scroll_y != 0)
930            amstrad_screen_width = crtc6845_get_register(1) * 2;
930            amstrad_screen_width = m6845_get_register(1) * 2;
931931         display_x = x_screen_pos;
932932         display_y = y_screen_pos;
933933         display_update = 0;
r1129r1130
10001000         // CPC+/GX4000 Programmable Raster Interrupt (disabled if &6800 in ASIC RAM is 0)     
10011001         if(amstrad_plus_pri != 0)
10021002         {
1003            if(crtc6845_get_row_counter() == ((amstrad_plus_pri >> 3) & 0x1f) && crtc6845_get_scanline_counter() == (amstrad_plus_pri & 0x07)) 
1003            if(m6845_get_row_counter() == ((amstrad_plus_pri >> 3) & 0x1f) && m6845_get_scanline_counter() == (amstrad_plus_pri & 0x07)) 
10041004            {
10051005//               logerror("PRI: triggered, scanline %i, VSync width = %i\n",amstrad_scanline,vid.vertical_sync_width);
10061006               cpunum_set_input_line(0,0,ASSERT_LINE);
r1129r1130
10111011         // CPC+/GX4000 Split screen registers  (disabled if &6801 in ASIC RAM is 0)
10121012         if(amstrad_plus_split_scanline != 0)
10131013         {
1014            if(crtc6845_get_row_counter() == ((amstrad_plus_split_scanline >> 3) & 0x1f) && crtc6845_get_scanline_counter() == (amstrad_plus_split_scanline & 0x07)) // split occurs here (hopefully)
1014            if(m6845_get_row_counter() == ((amstrad_plus_split_scanline >> 3) & 0x1f) && m6845_get_scanline_counter() == (amstrad_plus_split_scanline & 0x07)) // split occurs here (hopefully)
10151015            {
1016               crtc6845_state vid;
1017               crtc6845_get_state(0,&vid);
1016               m6845_state vid;
1017               m6845_get_state(0,&vid);
10181018//               logerror("SSCR: Split screen occured at scanline %i",amstrad_plus_split_scanline);
10191019               vid.Memory_Address_of_next_Character_Row = vid.Memory_Address_of_this_Character_Row = amstrad_plus_split_address;
10201020               vid.Memory_Address = amstrad_plus_split_address;
1021               crtc6845_set_state(0,&vid);
1021               m6845_set_state(0,&vid);
10221022            }
10231023         }
10241024         // CPC+/GX4000 soft scroll register
r1129r1130
10571057}
10581058/* The cursor is not used on Amstrad. The CURSOR signal is available on the Expansion port for other hardware to use. */
10591059
1060static struct crtc6845_interface amstrad6845= {
1060static struct m6845_interface amstrad6845= {
10611061   amstrad_Set_MA, // Memory Address register
10621062   amstrad_Set_RA, // Row Address register
10631063   amstrad_Set_HS, // Horizontal status
r1129r1130
11091109{
11101110   amstrad_init_lookups();
11111111
1112   crtc6845_start();
1113   crtc6845_config(&amstrad6845);
1114   crtc6845_reset(0);
1115   crtc6845_get_state(0, &amstrad_vidhrdw_6845_state);
1112   m6845_start();
1113   m6845_config(&amstrad6845);
1114   m6845_reset(0);
1115   m6845_get_state(0, &amstrad_vidhrdw_6845_state);
11161116   
11171117   draw_function = amstrad_draw_screen_disabled;
11181118   
src/mess/video/m6845.c
r1129r1130
1
21/************************************************************************
32   crct6845
43
r1129r1130
8281#define R17_light_pen_address_L crtc.registers[17]
8382
8483
85static crtc6845_state crtc;
84static m6845_state crtc;
8685static m6845_personality_t personality;
8786
8887#if 0
8988/* VSYNC functions */
9089
9190/* timer to set vsync */
92static void *crtc6845_vsync_set_timer = NULL;
91static void *m6845_vsync_set_timer = NULL;
9392/* timer to reset vsync */
94static void *crtc6845_vsync_clear_timer = NULL;
93static void *m6845_vsync_clear_timer = NULL;
9594
96static void crtc6845_vsync_set_timer_callback(int);
97static void crtc6845_vsync_clear_timer_callback(int);
98static void crtc6845_remove_vsync_set_timer(void);
99static void crtc6845_remove_vsync_clear_timer(void);
100static void crtc6845_set_new_vsync_set_time(int);
101static void crtc6845_set_new_vsync_clear_time(int);
102static void crtc6845_recalc_cycles_to_vsync_start(void);
103static void crtc6845_recalc_cycles_to_vsync_end(void);
95static void m6845_vsync_set_timer_callback(int);
96static void m6845_vsync_clear_timer_callback(int);
97static void m6845_remove_vsync_set_timer(void);
98static void m6845_remove_vsync_clear_timer(void);
99static void m6845_set_new_vsync_set_time(int);
100static void m6845_set_new_vsync_clear_time(int);
101static void m6845_recalc_cycles_to_vsync_start(void);
102static void m6845_recalc_cycles_to_vsync_end(void);
104103
105104#endif
106105
107106// local copy of the 6845 external procedure calls
108static struct crtc6845_interface
107static struct m6845_interface
109108crct6845_calls= {
110109   0,// Memory Address register
111110   0,// Row Address register
r1129r1130
126125};
127126
128127/* set up the local copy of the 6845 external procedure calls */
129void crtc6845_config(const struct crtc6845_interface *intf)
128void m6845_config(const struct m6845_interface *intf)
130129{
131130   crct6845_calls.out_MA_func=*intf->out_MA_func;
132131   crct6845_calls.out_RA_func=*intf->out_RA_func;
r1129r1130
138137   personality = M6845_PERSONALITY_GENUINE;
139138}
140139
141void   crtc6845_start(void)
140void   m6845_start(void)
142141{
143142#if 0
144   crtc6845_vsync_set_timer = NULL;
145   crtc6845_vsync_clear_timer = NULL;
143   m6845_vsync_set_timer = NULL;
144   m6845_vsync_clear_timer = NULL;
146145#endif
147146}
148147
149148/* 6845 registers */
150149
151150/* functions to set the 6845 registers */
152void crtc6845_address_w(int offset, int data)
151void m6845_address_w(int offset, int data)
153152{
154153   crtc.address_register=data & 0x1f;
155154}
156155
157void crtc6845_get_state(int offset, crtc6845_state *state)
156void m6845_get_state(int offset, m6845_state *state)
158157{
159   memcpy(state, &crtc, sizeof(crtc6845_state));
158   memcpy(state, &crtc, sizeof(m6845_state));
160159}
161160
162void crtc6845_set_state(int offset, crtc6845_state *state)
161void m6845_set_state(int offset, m6845_state *state)
163162{
164   memcpy(&crtc, state, sizeof(crtc6845_state));
163   memcpy(&crtc, state, sizeof(m6845_state));
165164}
166165
167166
168void crtc6845_register_w(int offset, int data)
167void m6845_register_w(int offset, int data)
169168{
170169   switch (crtc.address_register)
171170   {
172171      case 0:
173172                        R0_horizontal_total=data & 0x0ff;
174//                        crtc6845_recalc_cycles_to_vsync_end();
175  //                      crtc6845_recalc_cycles_to_vsync_start();
173//                        m6845_recalc_cycles_to_vsync_end();
174  //                      m6845_recalc_cycles_to_vsync_start();
176175         break;
177176      case 1:
178177                        R1_horizontal_displayed=data & 0x0ff;
r1129r1130
192191
193192                        crtc.horizontal_sync_width = data & 0x0f;
194193
195    //                                            crtc6845_recalc_cycles_to_vsync_end();
194    //                                            m6845_recalc_cycles_to_vsync_end();
196195            }
197196                break;
198197
199198        case 4:
200199                        R4_vertical_total=data&0x7f;
201          //              crtc6845_recalc_cycles_to_vsync_start();
200          //              m6845_recalc_cycles_to_vsync_start();
202201         break;
203202      case 5:
204203         R5_vertical_total_adjust=data&0x1f;
205204
206205
207        //                crtc6845_recalc_cycles_to_vsync_start();
206        //                m6845_recalc_cycles_to_vsync_start();
208207
209208         break;
210209      case 6:
r1129r1130
212211         break;
213212      case 7:
214213         R7_vertical_sync_position=data&0x7f;
215      //                  crtc6845_recalc_cycles_to_vsync_start();
214      //                  m6845_recalc_cycles_to_vsync_start();
216215         break;
217216      case 8:
218217         R8_interlace_display_enabled=data&0xf3;
r1129r1130
220219         break;
221220      case 9:
222221         R9_scan_lines_per_character=data&0x1f;
223            //            crtc6845_recalc_cycles_to_vsync_start();
222            //            m6845_recalc_cycles_to_vsync_start();
224223         break;
225224      case 10:
226225         R10_cursor_start=data&0x7f;
r1129r1130
256255}
257256
258257
259int crtc6845_register_r(int offset)
258int m6845_register_r(int offset)
260259{
261260   int retval;
262261
r1129r1130
314313}
315314
316315
317void   crtc6845_reset(int which)
316void   m6845_reset(int which)
318317{
319318   memset(&crtc.registers[0], 0, sizeof(int)*32);
320319   crtc.address_register = 0;
r1129r1130
375374   crtc.Display_Enabled=Next_Display_Enabled;
376375}
377376
378static void crtc6845_restart_frame(void)
377static void m6845_restart_frame(void)
379378{
380379               /* no restart frame */
381380               /* End of All Vertical Character rows */
r1129r1130
390389               crtc.Memory_Address_of_next_Character_Row = crtc.Memory_Address;
391390}
392391
393void crtc6845_frameclock(void)
392void m6845_frameclock(void)
394393{
395394   crtc.Cursor_Flash_Count=(crtc.Cursor_Flash_Count+1)%50;
396395}
397396
398397/* clock the 6845 */
399void crtc6845_clock(void)
398void m6845_clock(void)
400399{
401400   /* KT - I think the compiler might generate shit code when using "%" operator! */
402401   /*crtc.Memory_Address=(crtc.Memory_Address+1)%0x4000;*/
r1129r1130
460459            }
461460            else
462461            {
463               crtc6845_restart_frame();
462               m6845_restart_frame();
464463            }
465464
466465           }
r1129r1130
520519   //         crtc.Character_Row_Counter_Reset = TRUE;
521520
522521            // KT this caused problems when R7 == 0 and R5 was set!
523            crtc6845_restart_frame();
522            m6845_restart_frame();
524523
525524            /* Check for start of Vertical Sync Pulse */
526525            if (crtc.Character_Row_Counter==R7_vertical_sync_position)
r1129r1130
657656
658657/* functions to read the 6845 outputs */
659658
660int crtc6845_memory_address_r(int offset)  { return crtc.Memory_Address; }    /* MA = Memory Address output */
661int crtc6845_row_address_r(int offset)     { return crtc.Scan_Line_Counter; } /* RA = Row Address output */
662int crtc6845_horizontal_sync_r(int offset) { return crtc.HSYNC; }             /* HS = Horizontal Sync */
663int crtc6845_vertical_sync_r(int offset)   { return crtc.VSYNC; }             /* VS = Vertical Sync */
664int crtc6845_display_enabled_r(int offset) { return crtc.Display_Delayed_Enabled; }   /* DE = Display Enabled */
665int crtc6845_cursor_enabled_r(int offset)  { return crtc.Cursor_Delayed_Status; }             /* CR = Cursor Enabled */
659int m6845_memory_address_r(int offset)  { return crtc.Memory_Address; }    /* MA = Memory Address output */
660int m6845_row_address_r(int offset)     { return crtc.Scan_Line_Counter; } /* RA = Row Address output */
661int m6845_horizontal_sync_r(int offset) { return crtc.HSYNC; }             /* HS = Horizontal Sync */
662int m6845_vertical_sync_r(int offset)   { return crtc.VSYNC; }             /* VS = Vertical Sync */
663int m6845_display_enabled_r(int offset) { return crtc.Display_Delayed_Enabled; }   /* DE = Display Enabled */
664int m6845_cursor_enabled_r(int offset)  { return crtc.Cursor_Delayed_Status; }             /* CR = Cursor Enabled */
666665
667void crtc6845_set_personality(m6845_personality_t p)
666void m6845_set_personality(m6845_personality_t p)
668667{
669668   personality = p;
670669}
671670
672// A few helper functions to help avoid heavy use of crtc6845_get/set_state()
673int crtc6845_get_register(int reg)
671// A few helper functions to help avoid heavy use of m6845_get/set_state()
672int m6845_get_register(int reg)
674673{
675674   return crtc.registers[reg];
676675}
677676
678int crtc6845_get_scanline_counter()
677int m6845_get_scanline_counter()
679678{
680679   return crtc.Scan_Line_Counter;
681680}
682681
683int crtc6845_get_row_counter()
682int m6845_get_row_counter()
684683{
685684   return crtc.Character_Row_Counter;
686685}
r1129r1130
698697
699698/* calculate the number of cycles to the next vsync */
700699/* ignores Reg 5! - to be completed */
701int     crtc6845_cycles_to_vsync(void)
700int     m6845_cycles_to_vsync(void)
702701{
703702   /* passed vertical sync position */
704703   int cycles_per_frame;
r1129r1130
734733}
735734
736735/* calculate the number of CRTC cycles for VSYNC */
737int     crtc6845_cycles_to_vsync_end(void)
736int     m6845_cycles_to_vsync_end(void)
738737{
739738        /* if we are in vsync */
740739        if (crtc.VSYNC)
r1129r1130
742741           return (R0_horizontal_total+1)*(crtc.vertical_sync_width-crtc.Vertical_Sync_Width_Counter);
743742        }
744743
745        return crtc6845_cycles_to_vsync() + ((R0_horizontal_total+1)*crtc.vertical_sync_width);
744        return m6845_cycles_to_vsync() + ((R0_horizontal_total+1)*crtc.vertical_sync_width);
746745}
747746
748747
749748/* number of crtc cycles for whole frame */
750static int crtc6845_cycles_per_frame(void)
749static int m6845_cycles_per_frame(void)
751750{
752751   int scan_lines_per_character = R9_scan_lines_per_character+1;
753752   int chars_per_line = R0_horizontal_total+1;
r1129r1130
759758}
760759
761760/* number of crtc cycles for vsync */
762static int crtc6845_vsync_length_in_cycles(void)
761static int m6845_vsync_length_in_cycles(void)
763762{
764763   int length;
765764
r1129r1130
777776
778777
779778/* remove "vsync set" timer */
780static void crtc6845_remove_vsync_set_timer(void)
779static void m6845_remove_vsync_set_timer(void)
781780{
782   if (crtc6845_vsync_set_timer!=NULL)
781   if (m6845_vsync_set_timer!=NULL)
783782   {
784      timer_remove(crtc6845_vsync_set_timer);   /* FIXME - timers should only be allocated once */
785      crtc6845_vsync_set_timer = NULL;
783      timer_remove(m6845_vsync_set_timer);   /* FIXME - timers should only be allocated once */
784      m6845_vsync_set_timer = NULL;
786785   }
787786}
788787
789788/* remove "vsync clear" timer */
790static void crtc6845_remove_vsync_clear_timer(void)
789static void m6845_remove_vsync_clear_timer(void)
791790{
792   if (crtc6845_vsync_clear_timer!=NULL)
791   if (m6845_vsync_clear_timer!=NULL)
793792   {
794      mame_timer_reset(crtc6845_vsync_clear_timer, time_never);   /* FIXME - timers should only be allocated once */
795      crtc6845_vsync_clear_timer = NULL;
793      mame_timer_reset(m6845_vsync_clear_timer, time_never);   /* FIXME - timers should only be allocated once */
794      m6845_vsync_clear_timer = NULL;
796795   }
797796}
798797
799798/* setup new time for "vsync set" */
800static void crtc6845_set_new_vsync_set_time(int cycles)
799static void m6845_set_new_vsync_set_time(int cycles)
801800{
802801   int crtc_cycles_to_vsync_start;
803802
r1129r1130
805804   cycles will be -1 */
806805   crtc_cycles_to_vsync_start = cycles;
807806
808   crtc6845_remove_vsync_set_timer();
807   m6845_remove_vsync_set_timer();
809808
810809        if (crtc_cycles_to_vsync_start!=-1)
811810   {
812                crtc6845_vsync_set_timer = mame_timer_set(MAME_TIME_IN_USEC(crtc_cycles_to_vsync_start), 0, crtc6845_vsync_set_timer_callback);
811                m6845_vsync_set_timer = mame_timer_set(MAME_TIME_IN_USEC(crtc_cycles_to_vsync_start), 0, m6845_vsync_set_timer_callback);
813812   }
814813}
815814
816815/* setup new time for "vsync clear" */
817static void crtc6845_set_new_vsync_clear_time(int cycles)
816static void m6845_set_new_vsync_clear_time(int cycles)
818817{
819818   int crtc_cycles_to_vsync_end;
820819
821   crtc6845_remove_vsync_clear_timer();
820   m6845_remove_vsync_clear_timer();
822821
823822   /* get number of cycles to end of vsync */
824823   crtc_cycles_to_vsync_end = cycles;
825824
826825   if (crtc_cycles_to_vsync_end!=-1)
827826   {
828                crtc6845_vsync_clear_timer = mame_timer_set(MAME_TIME_IN_USEC(crtc_cycles_to_vsync_end), 0, crtc6845_vsync_clear_timer_callback);
827                m6845_vsync_clear_timer = mame_timer_set(MAME_TIME_IN_USEC(crtc_cycles_to_vsync_end), 0, m6845_vsync_clear_timer_callback);
829828   }
830829}
831830
832831/* for these two below, might be better to record the current cpu time, and use that
833832to recalculate where the start/end of the vsync will next occur! */
834833
835static void crtc6845_vsync_clear_timer_callback(int dummy)
834static void m6845_vsync_clear_timer_callback(int dummy)
836835{
837836   /* clear vsync */
838837   crtc.VSYNC = 0;
r1129r1130
845844   /* the next vsync will occur in cycles per frame - vsync length in cycles */
846845   /* this will work as long as the vsync length has not been reprogrammed while the vsync was active! */
847846   /* setup time for vsync set timer */
848   crtc6845_set_new_vsync_set_time(crtc6845_cycles_per_frame()-crtc6845_vsync_length_in_cycles());
847   m6845_set_new_vsync_set_time(m6845_cycles_per_frame()-m6845_vsync_length_in_cycles());
849848
850849   /* prevent timer from being free'd and don't let it trigger again */
851   mame_timer_reset(crtc6845_vsync_clear_timer, time_never);
850   mame_timer_reset(m6845_vsync_clear_timer, time_never);
852851}
853852
854853/* called when vsync is set */
855static void crtc6845_vsync_set_timer_callback(int dummy)
854static void m6845_vsync_set_timer_callback(int dummy)
856855{
857856   /* set vsync */
858857   crtc.VSYNC = 1;
r1129r1130
866865   is active, in this case, the new vsync end will be re-calculated */
867866
868867   /* setup time for vsync clear timer */
869    crtc6845_set_new_vsync_clear_time(crtc6845_vsync_length_in_cycles());
868    m6845_set_new_vsync_clear_time(m6845_vsync_length_in_cycles());
870869
871870   /* prevent timer from being free'd and don't let it trigger again */
872   mame_timer_reset(crtc6845_vsync_set_timer, time_never);
871   mame_timer_reset(m6845_vsync_set_timer, time_never);
873872}
874static void crtc6845_recalc_cycles_to_vsync_end(void)
873static void m6845_recalc_cycles_to_vsync_end(void)
875874{
876   int cycles_to_vsync_end = crtc6845_cycles_to_vsync_end();
875   int cycles_to_vsync_end = m6845_cycles_to_vsync_end();
877876
878877   /* if we're in vsync, the end is important, otherwise we are waiting for the next vsync
879878   to start. The start is not affected by the length of the vsync */
880879   if (crtc.VSYNC)
881880   {
882      crtc6845_set_new_vsync_clear_time(cycles_to_vsync_end);
881      m6845_set_new_vsync_clear_time(cycles_to_vsync_end);
883882   }
884883}
885884
886static void crtc6845_recalc_cycles_to_vsync_start(void)
885static void m6845_recalc_cycles_to_vsync_start(void)
887886{
888   int cycles_to_vsync_start = crtc6845_cycles_to_vsync();
887   int cycles_to_vsync_start = m6845_cycles_to_vsync();
889888
890889   /* if we're not in vsync, the end is important, otherwise we are waiting for the end
891890   of the vsync */
892891   if (!crtc.VSYNC)
893892   {
894      crtc6845_set_new_vsync_set_time(cycles_to_vsync_start);
893      m6845_set_new_vsync_set_time(cycles_to_vsync_start);
895894   }
896895}
897896
898897/* ignores r5 ! to be completed */
899void crtc6845_recalc(int offset,int num_cycles)
898void m6845_recalc(int offset,int num_cycles)
900899{
901900   int cycles;
902901   int num_scan_lines;
src/mess/video/m6845.h
r1129r1130
1
21/************************************************************************
32   crct6845
43
r1129r1130
2019   M6845_PERSONALITY_PREASIC
2120} m6845_personality_t;
2221
23struct crtc6845_interface
22struct m6845_interface
2423{
2524   void (*out_MA_func)(int offset, int data);
2625   void (*out_RA_func)(int offset, int data);
r1129r1130
3130   void (*out_CRE_func)(int offset, int data);
3231};
3332
34typedef struct crtc6845_state
33typedef struct m6845_state
3534{
3635   /* Register Select */
3736   int address_register;
r1129r1130
8584   int   Vertical_Adjust_Done;
8685//   int cycles_to_vsync_start;
8786//   int cycles_to_vsync_end;
88} crtc6845_state;
87} m6845_state;
8988
9089/* set up the local copy of the 6845 external procedure calls */
91void crtc6845_config(const struct crtc6845_interface *intf);
90void m6845_config(const struct m6845_interface *intf);
9291
9392
9493/* functions to set the 6845 registers */
95int crtc6845_register_r(int offset);
96void crtc6845_address_w(int offset, int data);
97void crtc6845_register_w(int offset, int data);
94int m6845_register_r(int offset);
95void m6845_address_w(int offset, int data);
96void m6845_register_w(int offset, int data);
9897
9998
10099/* clock the 6845 */
101void crtc6845_clock(void);
100void m6845_clock(void);
102101
103102/* called every frame to advance the cursor count */
104void crtc6845_frameclock(void);
103void m6845_frameclock(void);
105104
106105/* functions to read the 6845 outputs */
107int crtc6845_memory_address_r(int offset);
108int crtc6845_row_address_r(int offset);
109int crtc6845_horizontal_sync_r(int offset);
110int crtc6845_vertical_sync_r(int offset);
111int crtc6845_display_enabled_r(int offset);
112int crtc6845_cursor_enabled_r(int offset);
106int m6845_memory_address_r(int offset);
107int m6845_row_address_r(int offset);
108int m6845_horizontal_sync_r(int offset);
109int m6845_vertical_sync_r(int offset);
110int m6845_display_enabled_r(int offset);
111int m6845_cursor_enabled_r(int offset);
113112
114void crtc6845_recalc(int offset, int cycles);
113void m6845_recalc(int offset, int cycles);
115114
116void crtc6845_set_state(int offset, crtc6845_state *state);
117void crtc6845_get_state(int offset, crtc6845_state *state);
115void m6845_set_state(int offset, m6845_state *state);
116void m6845_get_state(int offset, m6845_state *state);
118117
119void crtc6845_reset(int which);
118void m6845_reset(int which);
120119
121void crtc6845_start(void);
120void m6845_start(void);
122121
123void crtc6845_set_personality(m6845_personality_t personality);
122void m6845_set_personality(m6845_personality_t personality);
124123
125int crtc6845_get_register(int reg);
126int crtc6845_get_scanline_counter(void);
127int crtc6845_get_row_counter(void);
124int m6845_get_register(int reg);
125int m6845_get_scanline_counter(void);
126int m6845_get_row_counter(void);
src/mess/video/bbc.c
r1129r1130
220220
221221   teletext_data_w(0,(Teletext_Latch&0x3f)|((Teletext_Latch&0x40)|(BBC_DE?0:0x40)));
222222
223   meml=crtc6845_memory_address_r(0);
223   meml=m6845_memory_address_r(0);
224224
225225   if (((meml>>13)&1)==0)
226226   {
r1129r1130
393393      // the logic for the memory location address is very complicated so it
394394      // is stored in a number of look up arrays (and is calculated once at the start of the emulator).
395395      // this is actually does by the latch IC's not the Video ULA
396      meml=video_ram_lookup[crtc6845_memory_address_r(0)]|(BBC_Character_Row&0x7);
396      meml=video_ram_lookup[m6845_memory_address_r(0)]|(BBC_Character_Row&0x7);
397397
398398      if (vidmem_RAM[meml] || video_refresh )
399399      {
r1129r1130
528528}
529529
530530
531static struct crtc6845_interface
531static struct m6845_interface
532532BBC6845= {
533533   0,// Memory Address register
534534   BBC_Set_Character_Row,// Row Address register
r1129r1130
552552   switch (offset&1)
553553   {
554554      case 0:
555         crtc6845_address_w(0,data);
555         m6845_address_w(0,data);
556556         break;
557557      case 1:
558         crtc6845_register_w(0,data);
558         m6845_register_w(0,data);
559559         break;
560560   }
561561
r1129r1130
572572      case 0:
573573         break;
574574      case 1:
575         retval=crtc6845_register_r(0);
575         retval=m6845_register_r(0);
576576         break;
577577   }
578578   return retval;
r1129r1130
616616   while((BBC_VSync)&&(c<60000))
617617   {
618618      // Clock the 6845
619      crtc6845_clock();
619      m6845_clock();
620620      c++;
621621   }
622622
r1129r1130
631631      if (VideoULA_CR) BBC_Clock_CR();
632632
633633      // Clock the 6845
634      crtc6845_clock();
634      m6845_clock();
635635      c++;
636636   }
637637
r1129r1130
643643
644644void bbc_frameclock(void)
645645{
646   crtc6845_frameclock();
646   m6845_frameclock();
647647}
648648
649649/**** BBC B+ Shadow Ram change ****/
r1129r1130
669669{
670670   set_pixel_lookup();
671671   set_video_memory_lookups(16);
672   crtc6845_config(&BBC6845);
672   m6845_config(&BBC6845);
673673   saa505x_config(&BBCsaa5050);
674674
675675   BBC_Video_RAM= memory_region(REGION_CPU1);
r1129r1130
681681{
682682   set_pixel_lookup();
683683
684   crtc6845_config(&BBC6845);
684   m6845_config(&BBC6845);
685685   saa505x_config(&BBCsaa5050);
686686
687687   BBC_Video_RAM= memory_region(REGION_CPU1);
r1129r1130
695695   set_pixel_lookup();
696696
697697   set_video_memory_lookups(32);
698   crtc6845_config(&BBC6845);
698   m6845_config(&BBC6845);
699699   saa505x_config(&BBCsaa5050);
700700
701701   BBC_Video_RAM= memory_region(REGION_CPU1);
r1129r1130
708708   /* need to set up the lookups to work with the BBC B plus memory */
709709   set_pixel_lookup();
710710   set_video_memory_lookups(32);
711   crtc6845_config(&BBC6845);
711   m6845_config(&BBC6845);
712712   saa505x_config(&BBCsaa5050);
713713
714714   BBC_Video_RAM= memory_region(REGION_CPU1);
src/mess/machine/cbmb.c
r1129r1130
244244   cbm_ieee_open();
245245}
246246
247static struct crtc6845_config cbm600_crtc= { 1600000 /*?*/, cbmb_vh_cursor };
247static struct mscrtc6845_config cbm600_crtc= { 1600000 /*?*/, cbmb_vh_cursor };
248248
249249void cbm600_driver_init (void)
250250{
251251   cbmb_common_driver_init ();
252252   cbm600_vh_init();
253   crtc6845_init(&cbm600_crtc);
253   mscrtc6845_init(&cbm600_crtc);
254254}
255255
256256void cbm600pal_driver_init (void)
257257{
258258   cbmb_common_driver_init ();
259259   cbm600_vh_init();
260   crtc6845_init(&cbm600_crtc);
260   mscrtc6845_init(&cbm600_crtc);
261261}
262262
263263void cbm600hu_driver_init (void)
264264{
265265   cbmb_common_driver_init ();
266   crtc6845_init(&cbm600_crtc);
266   mscrtc6845_init(&cbm600_crtc);
267267}
268268
269static struct crtc6845_config cbm700_crtc= { 2000000 /*?*/, cbmb_vh_cursor };
269static struct mscrtc6845_config cbm700_crtc= { 2000000 /*?*/, cbmb_vh_cursor };
270270
271271void cbm700_driver_init (void)
272272{
273273   cbmb_common_driver_init ();
274274   cbm700_vh_init();
275   crtc6845_init(&cbm700_crtc);
275   mscrtc6845_init(&cbm700_crtc);
276276}
277277
278278void cbm500_driver_init (void)
src/mess/machine/pet.c
r1129r1130
231231   else if (offset<0x40) ;
232232   else if (offset<0x50) via_0_w(offset&0xf,data);
233233   else if (offset<0x80) ;
234   else if (offset<0x82) crtc6845_0_port_w(offset&1,data);
234   else if (offset<0x82) mscrtc6845_0_port_w(offset&1,data);
235235}
236236
237237static  READ8_HANDLER(cbm8096_io_r)
r1129r1130
244244   else if (offset<0x40) ;
245245   else if (offset<0x50) data=via_0_r(offset&0xf);
246246   else if (offset<0x80) ;
247   else if (offset<0x82) data=crtc6845_0_port_r(offset&1);
247   else if (offset<0x82) data=mscrtc6845_0_port_r(offset&1);
248248   return data;
249249}
250250
r1129r1130
452452   pet_vh_init();
453453}
454454
455static struct crtc6845_config crtc_pet = { 800000 /*?*/};
455static struct mscrtc6845_config crtc_pet = { 800000 /*?*/};
456456
457457DRIVER_INIT( pet40 )
458458{
459459   pet_common_driver_init ();
460460   pet_vh_init();
461   crtc6845_init(&crtc_pet);
461   mscrtc6845_init(&crtc_pet);
462462}
463463
464464DRIVER_INIT( cbm80 )
r1129r1130
470470   videoram = &pet_memory[0x8000];
471471   videoram_size = 0x800;
472472   pet80_vh_init();
473   crtc6845_init(&crtc_pet);
473   mscrtc6845_init(&crtc_pet);
474474}
475475
476476DRIVER_INIT( superpet )
r1129r1130
484484   memory_set_bank(1, 0);
485485
486486   superpet_vh_init();
487   crtc6845_init(&crtc_pet);
487   mscrtc6845_init(&crtc_pet);
488488}
489489
490490MACHINE_RESET( pet )
src/mess/machine/amstrad.c
r1129r1130
125125   /* init CRTC */
126126   for (i=0; i<18; i++)
127127   {
128                crtc6845_address_w(0,i);
129                crtc6845_register_w(0, pSnapshot[0x043+i] & 0x0ff);
128                m6845_address_w(0,i);
129                m6845_register_w(0, pSnapshot[0x043+i] & 0x0ff);
130130   }
131131
132    crtc6845_address_w(0,i);
132    m6845_address_w(0,i);
133133
134134   /* upper rom selection */
135135   AmstradCPC_SetUpperRom(pSnapshot[0x055]);
src/mess/machine/svi318.c
r1129r1130
411411   svi318_DE = data;
412412}
413413
414static struct crtc6845_interface
415svi318_crtc6845_interface= {
414static struct m6845_interface
415svi318_m6845_interface= {
416416   0,// Memory Address register
417417   svi318_Set_RA,// Row Address register
418418   svi318_Set_HSync,// Horizontal status
r1129r1130
428428   svi318_80col_ram = auto_malloc(0x800);
429429memset(svi318_80col_ram, 0x40, 0x400);
430430   /* initialise 6845 */
431   crtc6845_config(&svi318_crtc6845_interface);
431   m6845_config(&svi318_m6845_interface);
432432
433433   svi318_80col_state=(1<<2)|(1<<1);
434434}
r1129r1130
455455      unsigned char data_byte;
456456      int char_code;
457457
458      char_code = svi318_80col_ram[crtc6845_memory_address_r(0)&0x07ff];
458      char_code = svi318_80col_ram[m6845_memory_address_r(0)&0x07ff];
459459     
460460      data_byte = data[(char_code<<3) + svi318_6845_RA];
461461
r1129r1130
485485   while((svi318_VSync)&&(c<33274))
486486   {
487487      // Clock the 6845
488      crtc6845_clock();
488      m6845_clock();
489489      c++;
490490   }
491491
r1129r1130
495495   {
496496      while ((svi318_HSync)&&(c<33274))
497497      {
498         crtc6845_clock();
498         m6845_clock();
499499         c++;
500500      }
501501      // Do all the clever split mode changes in here before the next while loop
r1129r1130
511511         svi318_scr_x+=8;
512512
513513         // Clock the 6845
514         crtc6845_clock();
514         m6845_clock();
515515         c++;
516516      }
517517   }
src/mess/drivers/cbmb.c
r1129r1130
234234   AM_RANGE(0xf8000, 0xfbfff) AM_READ( MRA8_ROM )
235235   /*   {0xfc000, 0xfcfff, MRA8_ROM }, */
236236   AM_RANGE(0xfd000, 0xfd7ff) AM_READ( MRA8_ROM )
237   AM_RANGE(0xfd800, 0xfd8ff) AM_READ( crtc6845_0_port_r )
237   AM_RANGE(0xfd800, 0xfd8ff) AM_READ( mscrtc6845_0_port_r )
238238   /* disk units */
239239   AM_RANGE(0xfda00, 0xfdaff) AM_READ( sid6581_0_port_r )
240240   /* db00 coprocessor */
r1129r1130
300300   AM_RANGE(0xf6000, 0xf7fff) AM_WRITE( MWA8_ROM )
301301   AM_RANGE(0xf8000, 0xfbfff) AM_WRITE( MWA8_ROM) AM_BASE( &cbmb_basic )
302302   AM_RANGE(0xfd000, 0xfd7ff) AM_WRITE( videoram_w) AM_BASE( &videoram) AM_SIZE(&videoram_size ) /* VIDEORAM */
303   AM_RANGE(0xfd800, 0xfd8ff) AM_WRITE( crtc6845_0_port_w )
303   AM_RANGE(0xfd800, 0xfd8ff) AM_WRITE( mscrtc6845_0_port_w )
304304   /* disk units */
305305   AM_RANGE(0xfda00, 0xfdaff) AM_WRITE( sid6581_0_port_w)
306306   /* db00 coprocessor */
src/mess/drivers/pet.c
r1129r1130
142142   AM_RANGE(0xe810, 0xe813) AM_READWRITE(pia_0_r, pia_0_w)
143143   AM_RANGE(0xe820, 0xe823) AM_READWRITE(pia_1_r, pia_1_w)
144144   AM_RANGE(0xe840, 0xe84f) AM_READWRITE(via_0_r, via_0_w)
145   AM_RANGE(0xe880, 0xe881) AM_READWRITE(crtc6845_0_port_r, crtc6845_0_port_w)
145   AM_RANGE(0xe880, 0xe881) AM_READWRITE(mscrtc6845_0_port_r, mscrtc6845_0_port_w)
146146   AM_RANGE(0xf000, 0xffff) AM_ROM
147147ADDRESS_MAP_END
148148
r1129r1130
158158   AM_RANGE(0xe810, 0xe813) AM_READWRITE(pia_0_r, pia_0_w)
159159   AM_RANGE(0xe820, 0xe823) AM_READWRITE(pia_1_r, pia_1_w)
160160   AM_RANGE(0xe840, 0xe84f) AM_READWRITE(via_0_r, via_0_w)
161   AM_RANGE(0xe880, 0xe881) AM_READWRITE(crtc6845_0_port_r, crtc6845_0_port_w)
161   AM_RANGE(0xe880, 0xe881) AM_READWRITE(mscrtc6845_0_port_r, mscrtc6845_0_port_w)
162162#endif
163163   AM_RANGE(0xf000, 0xffff) AM_READ(MRA8_BANK8)
164164   AM_RANGE(0xf000, 0xffef) AM_WRITE(MWA8_BANK8)
r1129r1130
188188   AM_RANGE(0xe810, 0xe813) AM_READWRITE(pia_0_r, pia_0_w)
189189   AM_RANGE(0xe820, 0xe823) AM_READWRITE(pia_1_r, pia_1_w)
190190   AM_RANGE(0xe840, 0xe84f) AM_READWRITE(via_0_r, via_0_w)
191   AM_RANGE(0xe880, 0xe881) AM_READWRITE(crtc6845_0_port_r, crtc6845_0_port_w)
191   AM_RANGE(0xe880, 0xe881) AM_READWRITE(mscrtc6845_0_port_r, mscrtc6845_0_port_w)
192192   /* 0xefe0, 0xefe3, mos 6702 */
193193   /* 0xeff0, 0xeff3, acia6551 */
194194   AM_RANGE(0xeff8, 0xefff) AM_READWRITE(superpet_r, superpet_w)
r1129r1130
203203   AM_RANGE(0xe810, 0xe813) AM_READWRITE(pia_0_r, pia_0_w)
204204   AM_RANGE(0xe820, 0xe823) AM_READWRITE(pia_1_r, pia_1_w)
205205   AM_RANGE(0xe840, 0xe84f) AM_READWRITE(via_0_r, via_0_w)
206   AM_RANGE(0xe880, 0xe881) AM_READWRITE(crtc6845_0_port_r, crtc6845_0_port_w)
206   AM_RANGE(0xe880, 0xe881) AM_READWRITE(mscrtc6845_0_port_r, mscrtc6845_0_port_w)
207207   AM_RANGE(0xeff8, 0xefff) AM_READWRITE(superpet_r, superpet_w)
208208   AM_RANGE(0xf000, 0xffff) AM_ROM
209209ADDRESS_MAP_END
src/mess/drivers/einstein.c
r1129r1130
218218}
219219
220220
221static struct crtc6845_interface
222einstein_crtc6845_interface= {
221static struct m6845_interface
222einstein_m6845_interface= {
223223   0,// Memory Address register
224224   Einstein_Set_RA,// Row Address register
225225   Einstein_Set_HSync,// Horizontal status
r1129r1130
235235   einstein_80col_ram = auto_malloc(2048);
236236
237237   /* initialise 6845 */
238   crtc6845_config(&einstein_crtc6845_interface);
238   m6845_config(&einstein_m6845_interface);
239239
240240   einstein_80col_state=(1<<2)|(1<<1);
241241}
r1129r1130
277277         einstein_80col_ram_w(offset,data);
278278         break;
279279      case 8:
280         crtc6845_address_w(offset,data);
280         m6845_address_w(offset,data);
281281         break;
282282      case 9:
283         crtc6845_register_w(offset,data);
283         m6845_register_w(offset,data);
284284         break;
285285      default:
286286         break;
r1129r1130
16021602      unsigned char data_byte;
16031603      int char_code;
16041604
1605      char_code = einstein_80col_ram[crtc6845_memory_address_r(0)&0x07ff];
1605      char_code = einstein_80col_ram[m6845_memory_address_r(0)&0x07ff];
16061606     
16071607      data_byte = data[(char_code<<3) + Einstein_6845_RA];
16081608
r1129r1130
16321632   while((Einstein_VSync)&&(c<33274))
16331633   {
16341634      // Clock the 6845
1635      crtc6845_clock();
1635      m6845_clock();
16361636      c++;
16371637   }
16381638
r1129r1130
16421642   {
16431643      while ((Einstein_HSync)&&(c<33274))
16441644      {
1645         crtc6845_clock();
1645         m6845_clock();
16461646         c++;
16471647      }
16481648      // Do all the clever split mode changes in here before the next while loop
r1129r1130
16581658         Einstein_scr_x+=8;
16591659
16601660         // Clock the 6845
1661         crtc6845_clock();
1661         m6845_clock();
16621662         c++;
16631663      }
16641664   }
src/mess/drivers/amstrad.c
r1129r1130
9090#define SYSTEM_CPC 0
9191#define SYSTEM_PLUS 1
9292
93//int selected_crtc6845_address = 0;
93//int selected_m6845_address = 0;
9494
9595// &ff,&77,&b3,&51,&a8,&d4,&62,&39,&9c,&46,&2b,&15,&8a,&cd,&ee
9696// This is the sequence for unlocking the ASIC in the CPC+/GX4000
r1129r1130
281281   data |= (ppi_port_inputs[amstrad_ppi_PortB] & 0x1e);
282282
283283/*    Set b0 with VSync state from the CRTC */
284   data |= amstrad_CRTC_VS; // crtc6845_vertical_sync_r(0);
284   data |= amstrad_CRTC_VS; // m6845_vertical_sync_r(0);
285285
286286   return data;
287287}
r1129r1130
10511051   m6845_personality_t crtc_type;
10521052
10531053   crtc_type = readinputportbytag_safe("crtc", 0);
1054   crtc6845_set_personality(crtc_type);
1054   m6845_set_personality(crtc_type);
10551055
10561056   /* if b14 = 0 : CRTC Read selected */
10571057   if ((offset & (1<<14)) == 0)
r1129r1130
10661066            break;
10671067         case M6845_PERSONALITY_AMS40489:
10681068         case M6845_PERSONALITY_PREASIC:
1069            data = crtc6845_register_r(0);
1069            data = m6845_register_r(0);
10701070            break;
10711071         default:
10721072            break;
r1129r1130
10741074         break;
10751075      case 0x03:
10761076         /* All CRTC type : Read from selected internal 6845 register Read only */
1077         data = crtc6845_register_r(0);
1077         data = m6845_register_r(0);
10781078         break;
10791079      }
10801080   }
r1129r1130
11471147#ifdef AMSTRAD_VIDEO_EVENT_LIST
11481148           EventList_AddItemOffset((EVENT_LIST_CODE_CRTC_INDEX_WRITE<<6), data, TIME_TO_CYCLES(0,video_screen_get_vpos(0)*video_screen_get_scan_period(0)));
11491149#endif
1150        crtc6845_address_w(0,data);
1150        m6845_address_w(0,data);
11511151      if(amstrad_system_type == SYSTEM_PLUS)
11521152         amstrad_plus_seqcheck(data);
1153//          selected_crtc6845_address = (data & 0x1F);
1153//          selected_m6845_address = (data & 0x1F);
11541154      } break;
11551155        case 0x01: {/* Write to selected internal 6845 register Write Only */
11561156#ifdef AMSTRAD_VIDEO_EVENT_LIST
11571157            EventList_AddItemOffset((EVENT_LIST_CODE_CRTC_WRITE<<6), data, TIME_TO_CYCLES(0,video_screen_get_vpos(0)*video_screen_get_scan_period(0)));
11581158#endif
1159//            logerror("crtc6845 register (%02d : %04x)\n", selected_crtc6845_address, (data&0x3F));
1160        crtc6845_register_w(0,data);
1159//            logerror("m6845 register (%02d : %04x)\n", selected_m6845_address, (data&0x3F));
1160        m6845_register_w(0,data);
11611161        } break;
11621162        default: {
11631163        } break;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team