src/mess/includes/crtc6845.h
| r1129 | r1130 | |
| 10 | 10 | |
| 11 | 11 | ***************************************************************************/ |
| 12 | 12 | |
| 13 | | #ifndef CRTC6845_H |
| 14 | | #define CRTC6845_H |
| 13 | #ifndef MSCRTC6845_H |
| 14 | #define MSCRTC6845_H |
| 15 | 15 | |
| 16 | 16 | #include "mame.h" |
| 17 | 17 | |
| r1129 | r1130 | |
| 38 | 38 | ***************************************************************************/ |
| 39 | 39 | |
| 40 | 40 | /* opaque structure representing a crtc8645 chip */ |
| 41 | | struct crtc6845; |
| 41 | struct mscrtc6845; |
| 42 | 42 | |
| 43 | | struct crtc6845_cursor |
| 43 | struct mscrtc6845_cursor |
| 44 | 44 | { |
| 45 | 45 | int on; |
| 46 | 46 | int pos; |
| r1129 | r1130 | |
| 48 | 48 | int bottom; |
| 49 | 49 | }; |
| 50 | 50 | |
| 51 | | struct crtc6845_config |
| 51 | struct mscrtc6845_config |
| 52 | 52 | { |
| 53 | 53 | int freq; |
| 54 | | void (*cursor_changed)(struct crtc6845_cursor *old); |
| 54 | void (*cursor_changed)(struct mscrtc6845_cursor *old); |
| 55 | 55 | int personality; |
| 56 | 56 | }; |
| 57 | 57 | |
| r1129 | r1130 | |
| 61 | 61 | |
| 62 | 62 | ***************************************************************************/ |
| 63 | 63 | |
| 64 | | /* generic crtc6845 instance */ |
| 65 | | extern struct crtc6845 *crtc6845; |
| 64 | /* generic mscrtc6845 instance */ |
| 65 | extern struct mscrtc6845 *mscrtc6845; |
| 66 | 66 | |
| 67 | 67 | /*************************************************************************** |
| 68 | 68 | |
| r1129 | r1130 | |
| 70 | 70 | |
| 71 | 71 | ***************************************************************************/ |
| 72 | 72 | |
| 73 | | struct crtc6845 *crtc6845_init(const struct crtc6845_config *config); |
| 73 | struct mscrtc6845 *mscrtc6845_init(const struct mscrtc6845_config *config); |
| 74 | 74 | |
| 75 | | void crtc6845_set_clock(struct crtc6845 *crtc, int freq); |
| 75 | void mscrtc6845_set_clock(struct mscrtc6845 *crtc, int freq); |
| 76 | 76 | |
| 77 | 77 | /* to be called before drawing screen */ |
| 78 | | void crtc6845_time(struct crtc6845 *crtc); |
| 78 | void mscrtc6845_time(struct mscrtc6845 *crtc); |
| 79 | 79 | |
| 80 | | int crtc6845_get_char_columns(struct crtc6845 *crtc); |
| 81 | | int crtc6845_get_char_height(struct crtc6845 *crtc); |
| 82 | | int crtc6845_get_char_lines(struct crtc6845 *crtc); |
| 83 | | int crtc6845_get_start(struct crtc6845 *crtc); |
| 84 | | void crtc6845_set_char_columns(struct crtc6845 *crtc, UINT8 columns); |
| 85 | | void crtc6845_set_char_lines(struct crtc6845 *crtc, UINT8 lines); |
| 80 | int mscrtc6845_get_char_columns(struct mscrtc6845 *crtc); |
| 81 | int mscrtc6845_get_char_height(struct mscrtc6845 *crtc); |
| 82 | int mscrtc6845_get_char_lines(struct mscrtc6845 *crtc); |
| 83 | int mscrtc6845_get_start(struct mscrtc6845 *crtc); |
| 84 | void mscrtc6845_set_char_columns(struct mscrtc6845 *crtc, UINT8 columns); |
| 85 | void mscrtc6845_set_char_lines(struct mscrtc6845 *crtc, UINT8 lines); |
| 86 | 86 | |
| 87 | | int crtc6845_get_personality(struct crtc6845 *crtc); |
| 87 | int mscrtc6845_get_personality(struct mscrtc6845 *crtc); |
| 88 | 88 | |
| 89 | 89 | /* cursor off, cursor on, cursor 16 frames on/off, cursor 32 frames on/off |
| 90 | 90 | start line, end line */ |
| 91 | | void crtc6845_get_cursor(struct crtc6845 *crtc, struct crtc6845_cursor *cursor); |
| 91 | void mscrtc6845_get_cursor(struct mscrtc6845 *crtc, struct mscrtc6845_cursor *cursor); |
| 92 | 92 | |
| 93 | | UINT8 crtc6845_port_r(struct crtc6845 *crtc, int offset); |
| 94 | | int crtc6845_port_w(struct crtc6845 *crtc, int offset, UINT8 data); |
| 93 | UINT8 mscrtc6845_port_r(struct mscrtc6845 *crtc, int offset); |
| 94 | int mscrtc6845_port_w(struct mscrtc6845 *crtc, int offset, UINT8 data); |
| 95 | 95 | |
| 96 | 96 | /* to be called when writting to port */ |
| 97 | | WRITE8_HANDLER ( crtc6845_0_port_w ); |
| 97 | WRITE8_HANDLER ( mscrtc6845_0_port_w ); |
| 98 | 98 | |
| 99 | 99 | /* to be called when reading from port */ |
| 100 | | READ8_HANDLER ( crtc6845_0_port_r ); |
| 100 | READ8_HANDLER ( mscrtc6845_0_port_r ); |
| 101 | 101 | |
| 102 | 102 | /*************************************************************************** |
| 103 | 103 | |
| 104 | 104 | 6845 variant macros |
| 105 | 105 | |
| 106 | 106 | 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 |
| 108 | 108 | |
| 109 | 109 | ***************************************************************************/ |
| 110 | 110 | |
src/mess/video/dgn_beta.c
| r1129 | r1130 | |
| 113 | 113 | START_ADDR_L, // Start address low |
| 114 | 114 | CURS_H, // Cursor addr High |
| 115 | 115 | CURS_L // CURSOR addr Low |
| 116 | | } crtc6845_regs; |
| 116 | } m6845_regs; |
| 117 | 117 | |
| 118 | 118 | static int beta_6845_RA = 0; |
| 119 | 119 | static int beta_scr_x = 0; |
| r1129 | r1130 | |
| 164 | 164 | static void beta_Set_VSync(int offset, int data); |
| 165 | 165 | static void beta_Set_DE(int offset, int data); |
| 166 | 166 | |
| 167 | | static struct crtc6845_interface |
| 168 | | beta_crtc6845_interface= { |
| 167 | static struct m6845_interface |
| 168 | beta_m6845_interface= { |
| 169 | 169 | 0, // Memory Address register |
| 170 | 170 | beta_Set_RA, // Row Address register |
| 171 | 171 | beta_Set_HSync, // Horizontal status |
| r1129 | r1130 | |
| 267 | 267 | |
| 268 | 268 | if(!beta_HSync) |
| 269 | 269 | { |
| 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) |
| 273 | 273 | |
| 274 | 274 | beta_scr_y++; |
| 275 | 275 | // beta_scr_x=0-(((HT-HS)-HW)*8); // Number of dots after HS to wait before start of next line |
| 276 | 276 | beta_scr_x=0-((HT-(HS+HW))*Dots); |
| 277 | 277 | |
| 278 | 278 | //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()); |
| 280 | 280 | #ifdef MAME_DEBUG |
| 281 | 281 | HSyncMin=beta_scr_x; |
| 282 | 282 | #endif |
| r1129 | r1130 | |
| 329 | 329 | void init_video(void) |
| 330 | 330 | { |
| 331 | 331 | /* 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); |
| 334 | 334 | |
| 335 | 335 | GCtrl=0; |
| 336 | 336 | |
| r1129 | r1130 | |
| 406 | 406 | |
| 407 | 407 | static void beta_plot_char_line(int x,int y, mame_bitmap *bitmap) |
| 408 | 408 | { |
| 409 | | int CharsPerLine = crtc6845_get_register(H_DISPLAYED); // Get chars per line. |
| 409 | int CharsPerLine = m6845_get_register(H_DISPLAYED); // Get chars per line. |
| 410 | 410 | unsigned char *data = memory_region(REGION_GFX1); // ptr to char rom |
| 411 | 411 | int Dot; |
| 412 | 412 | unsigned char data_byte; |
| r1129 | r1130 | |
| 415 | 415 | int Offset; |
| 416 | 416 | int FgColour; // Foreground colour |
| 417 | 417 | int BgColour; // Background colour |
| 418 | | int CursorOn = crtc6845_cursor_enabled_r(0); |
| 418 | int CursorOn = m6845_cursor_enabled_r(0); |
| 419 | 419 | int Invert; |
| 420 | 420 | int UnderLine; // Underline |
| 421 | 421 | int FlashChar; // Flashing char |
| r1129 | r1130 | |
| 427 | 427 | { |
| 428 | 428 | /* The beta text RAM contains alternate character and attribute bytes */ |
| 429 | 429 | /* 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; |
| 431 | 431 | Offset=(crtcAddr | ((GCtrl & GCtrlAddrLines)<<8))*2; |
| 432 | 432 | if (Offset<0) |
| 433 | 433 | Offset=0; |
| r1129 | r1130 | |
| 503 | 503 | void plot_gfx_pixel(int x, int y, int Dot, int Colour, mame_bitmap *bitmap) |
| 504 | 504 | { |
| 505 | 505 | 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; |
| 507 | 507 | int PlotX; |
| 508 | 508 | int PlotY; |
| 509 | 509 | |
| r1129 | r1130 | |
| 577 | 577 | if (beta_DE) |
| 578 | 578 | { |
| 579 | 579 | /* Calculate address of graphics pixels */ |
| 580 | | crtcAddr=(crtc6845_memory_address_r(0) & 0x1FFF); |
| 580 | crtcAddr=(m6845_memory_address_r(0) & 0x1FFF); |
| 581 | 581 | Addr=((crtcAddr<<3) | (beta_6845_RA & 0x07))*2; |
| 582 | 582 | |
| 583 | 583 | if(Addr<MinAddr) |
| r1129 | r1130 | |
| 666 | 666 | while((beta_VSync)&&(c<ClkMax)) |
| 667 | 667 | { |
| 668 | 668 | // Clock the 6845 |
| 669 | | crtc6845_clock(); |
| 669 | m6845_clock(); |
| 670 | 670 | c++; |
| 671 | 671 | } |
| 672 | 672 | |
| r1129 | r1130 | |
| 676 | 676 | { |
| 677 | 677 | while ((beta_HSync)&&(c<ClkMax)) |
| 678 | 678 | { |
| 679 | | crtc6845_clock(); |
| 679 | m6845_clock(); |
| 680 | 680 | c++; |
| 681 | 681 | } |
| 682 | 682 | |
| r1129 | r1130 | |
| 702 | 702 | beta_scr_x+=8; |
| 703 | 703 | |
| 704 | 704 | // Clock the 6845 |
| 705 | | crtc6845_clock(); |
| 705 | m6845_clock(); |
| 706 | 706 | c++; |
| 707 | 707 | } |
| 708 | 708 | } |
| r1129 | r1130 | |
| 712 | 712 | /* Read and write handlers for CPU interface to 6845 */ |
| 713 | 713 | READ8_HANDLER(dgnbeta_6845_r) |
| 714 | 714 | { |
| 715 | | return crtc6845_register_r(offset); |
| 715 | return m6845_register_r(offset); |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | WRITE8_HANDLER(dgnbeta_6845_w) |
| 719 | 719 | { |
| 720 | 720 | if(offset&0x1) |
| 721 | 721 | { |
| 722 | | crtc6845_register_w(offset,data); |
| 722 | m6845_register_w(offset,data); |
| 723 | 723 | |
| 724 | 724 | if(VidAddr==INTERLACE) |
| 725 | 725 | { |
| r1129 | r1130 | |
| 728 | 728 | } |
| 729 | 729 | else |
| 730 | 730 | { |
| 731 | | crtc6845_address_w(offset,data); |
| 731 | m6845_address_w(offset,data); |
| 732 | 732 | VidAddr=data; /* Record reg being written to */ |
| 733 | 733 | } |
| 734 | 734 | #ifdef MAME_DEBUG |
src/mess/video/crtc6845.c
| r1129 | r1130 | |
| 60 | 60 | |
| 61 | 61 | ***************************************************************************/ |
| 62 | 62 | |
| 63 | | struct crtc6845 |
| 63 | struct mscrtc6845 |
| 64 | 64 | { |
| 65 | | struct crtc6845_config config; |
| 65 | struct mscrtc6845_config config; |
| 66 | 66 | UINT8 reg[18]; |
| 67 | 67 | UINT8 idx; |
| 68 | 68 | double cursor_time; |
| r1129 | r1130 | |
| 75 | 75 | UINT8 read_mask; |
| 76 | 76 | }; |
| 77 | 77 | |
| 78 | | struct crtc6845 *crtc6845; |
| 78 | struct mscrtc6845 *mscrtc6845; |
| 79 | 79 | |
| 80 | 80 | /*************************************************************************** |
| 81 | 81 | |
| r1129 | r1130 | |
| 84 | 84 | ***************************************************************************/ |
| 85 | 85 | |
| 86 | 86 | /*------------------------------------------------- |
| 87 | | crtc6845_reg_mask - an array specifying how |
| 87 | mscrtc6845_reg_mask - an array specifying how |
| 88 | 88 | much of any given register "registers", per |
| 89 | 89 | m6845 personality |
| 90 | 90 | -------------------------------------------------*/ |
| 91 | 91 | |
| 92 | | static const struct reg_mask crtc6845_reg_mask[2][18] = |
| 92 | static const struct reg_mask mscrtc6845_reg_mask[2][18] = |
| 93 | 93 | { |
| 94 | 94 | { |
| 95 | 95 | /* M6845_PERSONALITY_GENUINE */ |
| r1129 | r1130 | |
| 122 | 122 | |
| 123 | 123 | ***************************************************************************/ |
| 124 | 124 | |
| 125 | | static void crtc6845_state_postload(void) |
| 125 | static void mscrtc6845_state_postload(void) |
| 126 | 126 | { |
| 127 | 127 | if (dirtybuffer && videoram_size) |
| 128 | 128 | memset(dirtybuffer, 1, videoram_size); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | | struct crtc6845 *crtc6845_init(const struct crtc6845_config *config) |
| 131 | struct mscrtc6845 *mscrtc6845_init(const struct mscrtc6845_config *config) |
| 132 | 132 | { |
| 133 | | struct crtc6845 *crtc; |
| 133 | struct mscrtc6845 *crtc; |
| 134 | 134 | int idx; |
| 135 | 135 | |
| 136 | | crtc = auto_malloc(sizeof(struct crtc6845)); |
| 136 | crtc = auto_malloc(sizeof(struct mscrtc6845)); |
| 137 | 137 | memset(crtc, 0, sizeof(*crtc)); |
| 138 | 138 | crtc->cursor_time = mame_time_to_double(mame_timer_get_time()); |
| 139 | 139 | crtc->config = *config; |
| 140 | | crtc6845 = crtc; |
| 140 | mscrtc6845 = crtc; |
| 141 | 141 | |
| 142 | 142 | /* Hardwire the values which can't be changed in the PC1512 version */ |
| 143 | 143 | if (config->personality == M6845_PERSONALITY_PC1512) |
| r1129 | r1130 | |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
| 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); |
| 154 | 154 | return crtc; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | #define REG(x) (crtc->reg[x]) |
| 158 | 158 | |
| 159 | | static int crtc6845_clocks_in_frame(struct crtc6845 *crtc) |
| 159 | static int mscrtc6845_clocks_in_frame(struct mscrtc6845 *crtc) |
| 160 | 160 | { |
| 161 | 161 | int clocks=CRTC6845_COLUMNS*CRTC6845_LINES; |
| 162 | 162 | switch (CRTC6845_INTERLACE_MODE) { |
| r1129 | r1130 | |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | | void crtc6845_set_clock(struct crtc6845 *crtc, int freq) |
| 171 | void mscrtc6845_set_clock(struct mscrtc6845 *crtc, int freq) |
| 172 | 172 | { |
| 173 | 173 | assert(crtc); |
| 174 | 174 | crtc->config.freq = freq; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | | void crtc6845_time(struct crtc6845 *crtc) |
| 177 | void mscrtc6845_time(struct mscrtc6845 *crtc) |
| 178 | 178 | { |
| 179 | 179 | double neu, ftime; |
| 180 | | struct crtc6845_cursor cursor; |
| 180 | struct mscrtc6845_cursor cursor; |
| 181 | 181 | |
| 182 | 182 | neu = mame_time_to_double(mame_timer_get_time()); |
| 183 | 183 | |
| 184 | | if (crtc6845_clocks_in_frame(crtc) == 0.0) |
| 184 | if (mscrtc6845_clocks_in_frame(crtc) == 0.0) |
| 185 | 185 | return; |
| 186 | 186 | |
| 187 | | ftime = crtc6845_clocks_in_frame(crtc) * 16.0 / crtc->config.freq; |
| 187 | ftime = mscrtc6845_clocks_in_frame(crtc) * 16.0 / crtc->config.freq; |
| 188 | 188 | |
| 189 | 189 | if (CRTC6845_CURSOR_MODE==CRTC6845_CURSOR_32FRAMES) |
| 190 | 190 | ftime*=2; |
| r1129 | r1130 | |
| 192 | 192 | if (neu-crtc->cursor_time>ftime) |
| 193 | 193 | { |
| 194 | 194 | crtc->cursor_time += ftime; |
| 195 | | crtc6845_get_cursor(crtc, &cursor); |
| 195 | mscrtc6845_get_cursor(crtc, &cursor); |
| 196 | 196 | |
| 197 | 197 | if (crtc->config.cursor_changed) |
| 198 | 198 | crtc->config.cursor_changed(&cursor); |
| r1129 | r1130 | |
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | | int crtc6845_get_char_columns(struct crtc6845 *crtc) |
| 204 | int mscrtc6845_get_char_columns(struct mscrtc6845 *crtc) |
| 205 | 205 | { |
| 206 | 206 | return CRTC6845_CHAR_COLUMNS; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | | int crtc6845_get_char_height(struct crtc6845 *crtc) |
| 209 | int mscrtc6845_get_char_height(struct mscrtc6845 *crtc) |
| 210 | 210 | { |
| 211 | 211 | return CRTC6845_CHAR_HEIGHT; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | | int crtc6845_get_char_lines(struct crtc6845 *crtc) |
| 214 | int mscrtc6845_get_char_lines(struct mscrtc6845 *crtc) |
| 215 | 215 | { |
| 216 | 216 | return CRTC6845_CHAR_LINES; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | | int crtc6845_get_start(struct crtc6845 *crtc) |
| 219 | int mscrtc6845_get_start(struct mscrtc6845 *crtc) |
| 220 | 220 | { |
| 221 | 221 | return CRTC6845_VIDEO_START; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | |
| 225 | | void crtc6845_set_char_columns(struct crtc6845 *crtc, UINT8 columns) |
| 225 | void mscrtc6845_set_char_columns(struct mscrtc6845 *crtc, UINT8 columns) |
| 226 | 226 | { |
| 227 | 227 | crtc->reg[1] = columns; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | |
| 231 | | void crtc6845_set_char_lines(struct crtc6845 *crtc, UINT8 lines) |
| 231 | void mscrtc6845_set_char_lines(struct mscrtc6845 *crtc, UINT8 lines) |
| 232 | 232 | { |
| 233 | 233 | crtc->reg[6] = lines; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | |
| 237 | | int crtc6845_get_personality(struct crtc6845 *crtc) |
| 237 | int mscrtc6845_get_personality(struct mscrtc6845 *crtc) |
| 238 | 238 | { |
| 239 | 239 | return crtc->config.personality; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | | void crtc6845_get_cursor(struct crtc6845 *crtc, struct crtc6845_cursor *cursor) |
| 242 | void mscrtc6845_get_cursor(struct mscrtc6845 *crtc, struct mscrtc6845_cursor *cursor) |
| 243 | 243 | { |
| 244 | 244 | switch (CRTC6845_CURSOR_MODE) { |
| 245 | 245 | case CRTC6845_CURSOR_OFF: |
| r1129 | r1130 | |
| 261 | 261 | cursor->bottom = CRTC6845_CURSOR_BOTTOM; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | | UINT8 crtc6845_port_r(struct crtc6845 *crtc, int offset) |
| 264 | UINT8 mscrtc6845_port_r(struct mscrtc6845 *crtc, int offset) |
| 265 | 265 | { |
| 266 | 266 | UINT8 val = 0xff; |
| 267 | 267 | int idx; |
| r1129 | r1130 | |
| 270 | 270 | { |
| 271 | 271 | idx = crtc->idx & 0x1f; |
| 272 | 272 | 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; |
| 274 | 274 | } |
| 275 | 275 | else |
| 276 | 276 | { |
| r1129 | r1130 | |
| 279 | 279 | return val; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | | int crtc6845_port_w(struct crtc6845 *crtc, int offset, UINT8 data) |
| 282 | int mscrtc6845_port_w(struct mscrtc6845 *crtc, int offset, UINT8 data) |
| 283 | 283 | { |
| 284 | | struct crtc6845_cursor cursor; |
| 284 | struct mscrtc6845_cursor cursor; |
| 285 | 285 | int idx; |
| 286 | 286 | UINT8 mask; |
| 287 | 287 | |
| r1129 | r1130 | |
| 291 | 291 | idx = crtc->idx & 0x1f; |
| 292 | 292 | if (idx < (sizeof(crtc->reg) / sizeof(crtc->reg[0]))) |
| 293 | 293 | { |
| 294 | | mask = crtc6845_reg_mask[crtc->config.personality][idx].store_mask; |
| 294 | mask = mscrtc6845_reg_mask[crtc->config.personality][idx].store_mask; |
| 295 | 295 | /* Don't zero out bits not covered by the mask. */ |
| 296 | 296 | crtc->reg[crtc->idx] &= ~mask; |
| 297 | 297 | crtc->reg[crtc->idx] |= (data & mask); |
| r1129 | r1130 | |
| 302 | 302 | case 0xb: |
| 303 | 303 | case 0xe: |
| 304 | 304 | case 0xf: |
| 305 | | crtc6845_get_cursor(crtc, &cursor); |
| 305 | mscrtc6845_get_cursor(crtc, &cursor); |
| 306 | 306 | if (crtc->config.cursor_changed) |
| 307 | 307 | crtc->config.cursor_changed(&cursor); |
| 308 | 308 | break; |
| r1129 | r1130 | |
| 314 | 314 | if ((crtc->config.personality == M6845_PERSONALITY_PC1512) && (idx == 9)) |
| 315 | 315 | { |
| 316 | 316 | 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); |
| 319 | 319 | } |
| 320 | 320 | return TRUE; |
| 321 | 321 | } |
| r1129 | r1130 | |
| 328 | 328 | return FALSE; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | | READ8_HANDLER ( crtc6845_0_port_r ) |
| 331 | READ8_HANDLER ( mscrtc6845_0_port_r ) |
| 332 | 332 | { |
| 333 | | return crtc6845_port_r(crtc6845, offset); |
| 333 | return mscrtc6845_port_r(mscrtc6845, offset); |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | | WRITE8_HANDLER ( crtc6845_0_port_w ) |
| 336 | WRITE8_HANDLER ( mscrtc6845_0_port_w ) |
| 337 | 337 | { |
| 338 | | crtc6845_port_w(crtc6845, offset, data); |
| 338 | mscrtc6845_port_w(mscrtc6845, offset, data); |
| 339 | 339 | } |
| 340 | 340 | |
src/mess/video/pc_video.c
| r1129 | r1130 | |
| 19 | 19 | |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | |
| 22 | | static pc_video_update_proc (*pc_choosevideomode)(int *width, int *height, struct crtc6845 *crtc); |
| 23 | | static struct crtc6845 *pc_crtc; |
| 22 | static pc_video_update_proc (*pc_choosevideomode)(int *width, int *height, struct mscrtc6845 *crtc); |
| 23 | static struct mscrtc6845 *pc_crtc; |
| 24 | 24 | static int pc_anythingdirty; |
| 25 | 25 | static int pc_current_height; |
| 26 | 26 | static int pc_current_width; |
| r1129 | r1130 | |
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | |
| 42 | | struct crtc6845 *pc_video_start(const struct crtc6845_config *config, |
| 43 | | pc_video_update_proc (*choosevideomode)(int *width, int *height, struct crtc6845 *crtc), |
| 42 | struct mscrtc6845 *pc_video_start(const struct mscrtc6845_config *config, |
| 43 | pc_video_update_proc (*choosevideomode)(int *width, int *height, struct mscrtc6845 *crtc), |
| 44 | 44 | size_t vramsize) |
| 45 | 45 | { |
| 46 | 46 | pc_choosevideomode = choosevideomode; |
| r1129 | r1130 | |
| 54 | 54 | |
| 55 | 55 | if (config) |
| 56 | 56 | { |
| 57 | | pc_crtc = crtc6845_init(config); |
| 57 | pc_crtc = mscrtc6845_init(config); |
| 58 | 58 | if (!pc_crtc) |
| 59 | 59 | return NULL; |
| 60 | 60 | } |
| r1129 | r1130 | |
| 78 | 78 | |
| 79 | 79 | if (pc_crtc) |
| 80 | 80 | { |
| 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); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | video_update = pc_choosevideomode(&w, &h, pc_crtc); |
| r1129 | r1130 | |
| 157 | 157 | * |
| 158 | 158 | *************************************/ |
| 159 | 159 | |
| 160 | | void pc_render_gfx_1bpp(mame_bitmap *bitmap, struct crtc6845 *crtc, |
| 160 | void pc_render_gfx_1bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc, |
| 161 | 161 | const UINT8 *vram, const UINT16 *palette, int interlace) |
| 162 | 162 | { |
| 163 | 163 | 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; |
| 168 | 168 | |
| 169 | 169 | if (!vram) |
| 170 | 170 | vram = videoram; |
| r1129 | r1130 | |
| 197 | 197 | |
| 198 | 198 | |
| 199 | 199 | |
| 200 | | void pc_render_gfx_2bpp(mame_bitmap *bitmap, struct crtc6845 *crtc, |
| 200 | void pc_render_gfx_2bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc, |
| 201 | 201 | const UINT8 *vram, const UINT16 *palette, int interlace) |
| 202 | 202 | { |
| 203 | 203 | 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; |
| 208 | 208 | UINT16 *dest; |
| 209 | 209 | const UINT8 *src; |
| 210 | 210 | |
| r1129 | r1130 | |
| 238 | 238 | |
| 239 | 239 | |
| 240 | 240 | |
| 241 | | void pc_render_gfx_4bpp(mame_bitmap *bitmap, struct crtc6845 *crtc, |
| 241 | void pc_render_gfx_4bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc, |
| 242 | 242 | const UINT8 *vram, const UINT16 *palette, int interlace) |
| 243 | 243 | { |
| 244 | 244 | 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; |
| 249 | 249 | |
| 250 | 250 | if (!vram) |
| 251 | 251 | vram = videoram; |
src/mess/video/pc_mda.c
| r1129 | r1130 | |
| 120 | 120 | if (mda.pc_blink == on) return; |
| 121 | 121 | |
| 122 | 122 | 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); |
| 125 | 125 | |
| 126 | 126 | if (dirtybuffer) |
| 127 | 127 | { |
| r1129 | r1130 | |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | | void pc_mda_cursor(struct crtc6845_cursor *cursor) |
| 145 | void pc_mda_cursor(struct mscrtc6845_cursor *cursor) |
| 146 | 146 | { |
| 147 | 147 | if (dirtybuffer) |
| 148 | 148 | dirtybuffer[cursor->pos*2]=1; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | | static struct crtc6845_config config= { 14318180 /*?*/, pc_mda_cursor }; |
| 151 | static struct mscrtc6845_config config= { 14318180 /*?*/, pc_mda_cursor }; |
| 152 | 152 | |
| 153 | 153 | |
| 154 | 154 | /* This code seems to go through hoops to accomodate differing GfxElement |
| r1129 | r1130 | |
| 257 | 257 | switch( offset ) |
| 258 | 258 | { |
| 259 | 259 | case 0: case 2: case 4: case 6: |
| 260 | | crtc6845_port_w(crtc6845, 0, data); |
| 260 | mscrtc6845_port_w(mscrtc6845, 0, data); |
| 261 | 261 | break; |
| 262 | 262 | case 1: case 3: case 5: case 7: |
| 263 | | crtc6845_port_w(crtc6845, 1, data); |
| 263 | mscrtc6845_port_w(mscrtc6845, 1, data); |
| 264 | 264 | break; |
| 265 | 265 | case 8: |
| 266 | 266 | hercules_mode_control_w(data); |
| r1129 | r1130 | |
| 277 | 277 | switch( offset ) |
| 278 | 278 | { |
| 279 | 279 | case 0: case 2: case 4: case 6: |
| 280 | | data = crtc6845_port_r(crtc6845,0); |
| 280 | data = mscrtc6845_port_r(mscrtc6845,0); |
| 281 | 281 | break; |
| 282 | 282 | case 1: case 3: case 5: case 7: |
| 283 | | data = crtc6845_port_r(crtc6845,1); |
| 283 | data = mscrtc6845_port_r(mscrtc6845,1); |
| 284 | 284 | break; |
| 285 | 285 | case 10: |
| 286 | 286 | data = pc_mda_status_r(); |
| r1129 | r1130 | |
| 295 | 295 | The character cell size is 9x15. Column 9 is column 8 repeated for |
| 296 | 296 | character codes 176 to 223. |
| 297 | 297 | ***************************************************************************/ |
| 298 | | static void mda_text_inten(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 298 | static void mda_text_inten(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 299 | 299 | { |
| 300 | 300 | 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); |
| 305 | 305 | int char_width; |
| 306 | 306 | rectangle r; |
| 307 | | struct crtc6845_cursor cursor; |
| 307 | struct mscrtc6845_cursor cursor; |
| 308 | 308 | UINT8 attr; |
| 309 | 309 | |
| 310 | 310 | char_width = Machine->screen[0].width / 80; |
| 311 | 311 | |
| 312 | | crtc6845_time(crtc); |
| 313 | | crtc6845_get_cursor(crtc, &cursor); |
| 312 | mscrtc6845_time(crtc); |
| 313 | mscrtc6845_get_cursor(crtc, &cursor); |
| 314 | 314 | |
| 315 | 315 | for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) { |
| 316 | 316 | |
| r1129 | r1130 | |
| 351 | 351 | The character cell size is 9x15. Column 9 is column 8 repeated for |
| 352 | 352 | character codes 176 to 223. |
| 353 | 353 | ***************************************************************************/ |
| 354 | | static void mda_text_blink(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 354 | static void mda_text_blink(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 355 | 355 | { |
| 356 | 356 | 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); |
| 361 | 361 | rectangle r; |
| 362 | | struct crtc6845_cursor cursor; |
| 362 | struct mscrtc6845_cursor cursor; |
| 363 | 363 | int char_width; |
| 364 | 364 | |
| 365 | 365 | char_width = Machine->screen[0].width / 80; |
| 366 | 366 | |
| 367 | | crtc6845_time(crtc); |
| 368 | | crtc6845_get_cursor(crtc, &cursor); |
| 367 | mscrtc6845_time(crtc); |
| 368 | mscrtc6845_get_cursor(crtc, &cursor); |
| 369 | 369 | |
| 370 | 370 | for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) { |
| 371 | 371 | |
| r1129 | r1130 | |
| 414 | 414 | bit 7 being the leftmost. |
| 415 | 415 | ***************************************************************************/ |
| 416 | 416 | |
| 417 | | static void hercules_gfx(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 417 | static void hercules_gfx(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 418 | 418 | { |
| 419 | 419 | const UINT8 *vram = videoram; |
| 420 | 420 | static const UINT16 palette[2] = {0, 10}; |
| r1129 | r1130 | |
| 431 | 431 | Choose the appropriate video mode |
| 432 | 432 | ***************************************************************************/ |
| 433 | 433 | |
| 434 | | pc_video_update_proc pc_mda_choosevideomode(int *width, int *height, struct crtc6845 *crtc) |
| 434 | pc_video_update_proc pc_mda_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc) |
| 435 | 435 | { |
| 436 | 436 | pc_video_update_proc proc = NULL; |
| 437 | 437 | |
src/mess/video/pc_t1t.c
| r1129 | r1130 | |
| 25 | 25 | |
| 26 | 26 | static PALETTE_INIT( pcjr ); |
| 27 | 27 | static VIDEO_START( pc_t1t ); |
| 28 | | static pc_video_update_proc pc_t1t_choosevideomode(int *width, int *height, struct crtc6845 *crtc); |
| 28 | static pc_video_update_proc pc_t1t_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc); |
| 29 | 29 | |
| 30 | 30 | /*************************************************************************** |
| 31 | 31 | |
| r1129 | r1130 | |
| 185 | 185 | if (pcjr.pc_blink == on) return; |
| 186 | 186 | |
| 187 | 187 | 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); |
| 190 | 190 | |
| 191 | 191 | if (dirtybuffer) |
| 192 | 192 | { |
| r1129 | r1130 | |
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | | static void pc_t1t_cursor(struct crtc6845_cursor *cursor) |
| 211 | static void pc_t1t_cursor(struct mscrtc6845_cursor *cursor) |
| 212 | 212 | { |
| 213 | 213 | if (dirtybuffer) |
| 214 | 214 | dirtybuffer[cursor->pos*2] = 1; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | | static struct crtc6845_config config= { 14318180 /*?*/, pc_t1t_cursor }; |
| 217 | static struct mscrtc6845_config config= { 14318180 /*?*/, pc_t1t_cursor }; |
| 218 | 218 | |
| 219 | 219 | |
| 220 | 220 | static VIDEO_START( pc_t1t ) |
| r1129 | r1130 | |
| 412 | 412 | switch( offset ) |
| 413 | 413 | { |
| 414 | 414 | case 0: case 2: case 4: case 6: |
| 415 | | crtc6845_port_w(crtc6845,0,data); |
| 415 | mscrtc6845_port_w(mscrtc6845,0,data); |
| 416 | 416 | break; |
| 417 | 417 | case 1: case 3: case 5: case 7: |
| 418 | | crtc6845_port_w(crtc6845,1,data); |
| 418 | mscrtc6845_port_w(mscrtc6845,1,data); |
| 419 | 419 | break; |
| 420 | 420 | case 8: |
| 421 | 421 | pc_t1t_mode_control_w(data); |
| r1129 | r1130 | |
| 448 | 448 | switch( offset ) |
| 449 | 449 | { |
| 450 | 450 | case 0: case 2: case 4: case 6: |
| 451 | | data = crtc6845_port_r(crtc6845,0); |
| 451 | data = mscrtc6845_port_r(mscrtc6845,0); |
| 452 | 452 | break; |
| 453 | 453 | |
| 454 | 454 | case 1: case 3: case 5: case 7: |
| 455 | | data = crtc6845_port_r(crtc6845,1); |
| 455 | data = mscrtc6845_port_r(mscrtc6845,1); |
| 456 | 456 | break; |
| 457 | 457 | |
| 458 | 458 | case 8: |
| r1129 | r1130 | |
| 517 | 517 | Draw text mode with 40x25 characters (default) with high intensity bg. |
| 518 | 518 | ***************************************************************************/ |
| 519 | 519 | |
| 520 | | static void t1t_text_inten(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 520 | static void t1t_text_inten(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 521 | 521 | { |
| 522 | 522 | 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); |
| 527 | 527 | rectangle r; |
| 528 | | struct crtc6845_cursor cursor; |
| 528 | struct mscrtc6845_cursor cursor; |
| 529 | 529 | |
| 530 | | crtc6845_time(crtc); |
| 531 | | crtc6845_get_cursor(crtc, &cursor); |
| 530 | mscrtc6845_time(crtc); |
| 531 | mscrtc6845_get_cursor(crtc, &cursor); |
| 532 | 532 | |
| 533 | 533 | for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) { |
| 534 | 534 | |
| r1129 | r1130 | |
| 569 | 569 | Draw text mode with 40x25 characters (default) and blinking colors. |
| 570 | 570 | ***************************************************************************/ |
| 571 | 571 | |
| 572 | | static void t1t_text_blink(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 572 | static void t1t_text_blink(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 573 | 573 | { |
| 574 | 574 | 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); |
| 579 | 579 | rectangle r; |
| 580 | | struct crtc6845_cursor cursor; |
| 580 | struct mscrtc6845_cursor cursor; |
| 581 | 581 | |
| 582 | | crtc6845_time(crtc); |
| 583 | | crtc6845_get_cursor(crtc, &cursor); |
| 582 | mscrtc6845_time(crtc); |
| 583 | mscrtc6845_get_cursor(crtc, &cursor); |
| 584 | 584 | |
| 585 | 585 | for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) |
| 586 | 586 | { |
| r1129 | r1130 | |
| 633 | 633 | Even scanlines are from T1T_base + 0x0000, odd from T1T_base + 0x2000 |
| 634 | 634 | ***************************************************************************/ |
| 635 | 635 | |
| 636 | | static void t1t_gfx_2bpp(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 636 | static void t1t_gfx_2bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 637 | 637 | { |
| 638 | 638 | static const UINT16 palette[] = |
| 639 | 639 | { |
| r1129 | r1130 | |
| 651 | 651 | The cell size is 1x1 (1 scanline is the real default) |
| 652 | 652 | Even scanlines are from T1T_base + 0x0000, odd from T1T_base + 0x2000 |
| 653 | 653 | ***************************************************************************/ |
| 654 | | static void t1t_gfx_1bpp(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 654 | static void t1t_gfx_1bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 655 | 655 | { |
| 656 | 656 | 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; |
| 661 | 661 | |
| 662 | 662 | for (sy=0; sy<lines; sy++,offs=(offs+columns)&0x1fff) { |
| 663 | 663 | |
| r1129 | r1130 | |
| 693 | 693 | CGA_base + 0x2000 |
| 694 | 694 | ***************************************************************************/ |
| 695 | 695 | |
| 696 | | static void t1t_gfx_4bpp(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 696 | static void t1t_gfx_4bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 697 | 697 | { |
| 698 | 698 | pc_render_gfx_4bpp(bitmap, crtc, pcjr.displayram, NULL, 4); |
| 699 | 699 | } |
| r1129 | r1130 | |
| 704 | 704 | Choose the appropriate video mode |
| 705 | 705 | ***************************************************************************/ |
| 706 | 706 | |
| 707 | | static pc_video_update_proc pc_t1t_choosevideomode(int *width, int *height, struct crtc6845 *crtc) |
| 707 | static pc_video_update_proc pc_t1t_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc) |
| 708 | 708 | { |
| 709 | 709 | int xfactor = 8; |
| 710 | 710 | int yfactor = 1; |
src/mess/video/pc_cga.c
| r1129 | r1130 | |
| 252 | 252 | |
| 253 | 253 | |
| 254 | 254 | |
| 255 | | void pc_cga_cursor(struct crtc6845_cursor *cursor) |
| 255 | void pc_cga_cursor(struct mscrtc6845_cursor *cursor) |
| 256 | 256 | { |
| 257 | 257 | if (dirtybuffer && (videoram_size > cursor->pos*2)) |
| 258 | 258 | dirtybuffer[cursor->pos*2]=1; |
| r1129 | r1130 | |
| 260 | 260 | |
| 261 | 261 | |
| 262 | 262 | |
| 263 | | static struct crtc6845_config config= { 14318180 /*?*/, pc_cga_cursor }; |
| 263 | static struct mscrtc6845_config config= { 14318180 /*?*/, pc_cga_cursor }; |
| 264 | 264 | |
| 265 | 265 | static int internal_pc_cga_video_start(int personality) |
| 266 | 266 | { |
| r1129 | r1130 | |
| 469 | 469 | switch( offset ) |
| 470 | 470 | { |
| 471 | 471 | case 0: case 2: case 4: case 6: |
| 472 | | data = crtc6845_port_r(crtc6845, 0); |
| 472 | data = mscrtc6845_port_r(mscrtc6845, 0); |
| 473 | 473 | break; |
| 474 | 474 | case 1: case 3: case 5: case 7: |
| 475 | | data = crtc6845_port_r(crtc6845, 1); |
| 475 | data = mscrtc6845_port_r(mscrtc6845, 1); |
| 476 | 476 | break; |
| 477 | 477 | case 10: |
| 478 | 478 | data = pc_cga_status_r(); |
| r1129 | r1130 | |
| 488 | 488 | switch(offset) { |
| 489 | 489 | case 0: case 2: case 4: case 6: |
| 490 | 490 | case 1: case 3: case 5: case 7: |
| 491 | | if (crtc6845_port_w(crtc6845, offset, data)) |
| 491 | if (mscrtc6845_port_w(mscrtc6845, offset, data)) |
| 492 | 492 | { |
| 493 | 493 | if (dirtybuffer) memset(dirtybuffer, 1, videoram_size); |
| 494 | 494 | } |
| r1129 | r1130 | |
| 519 | 519 | The character cell size is 16x8 |
| 520 | 520 | ***************************************************************************/ |
| 521 | 521 | |
| 522 | | static void cga_text_inten(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 522 | static void cga_text_inten(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 523 | 523 | { |
| 524 | 524 | 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); |
| 529 | 529 | rectangle r; |
| 530 | | struct crtc6845_cursor cursor; |
| 530 | struct mscrtc6845_cursor cursor; |
| 531 | 531 | |
| 532 | | crtc6845_time(crtc); |
| 533 | | crtc6845_get_cursor(crtc, &cursor); |
| 532 | mscrtc6845_time(crtc); |
| 533 | mscrtc6845_get_cursor(crtc, &cursor); |
| 534 | 534 | pc_cga_check_palette(); |
| 535 | 535 | |
| 536 | 536 | for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) |
| r1129 | r1130 | |
| 579 | 579 | The character cell size is 16x8 |
| 580 | 580 | ***************************************************************************/ |
| 581 | 581 | |
| 582 | | static void cga_text_inten_alt(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 582 | static void cga_text_inten_alt(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 583 | 583 | { |
| 584 | 584 | 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); |
| 589 | 589 | rectangle r; |
| 590 | | struct crtc6845_cursor cursor; |
| 590 | struct mscrtc6845_cursor cursor; |
| 591 | 591 | |
| 592 | 592 | if (CGA_CHIPSET != CGA_CHIPSET_PC200) |
| 593 | 593 | { |
| r1129 | r1130 | |
| 595 | 595 | return; |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | | crtc6845_time(crtc); |
| 599 | | crtc6845_get_cursor(crtc, &cursor); |
| 598 | mscrtc6845_time(crtc); |
| 599 | mscrtc6845_get_cursor(crtc, &cursor); |
| 600 | 600 | pc_cga_check_palette(); |
| 601 | 601 | |
| 602 | 602 | for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) |
| r1129 | r1130 | |
| 634 | 634 | Draw text mode with 40x25 characters (default) and blinking colors. |
| 635 | 635 | The character cell size is 16x8 |
| 636 | 636 | ***************************************************************************/ |
| 637 | | static void cga_text_blink(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 637 | static void cga_text_blink(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 638 | 638 | { |
| 639 | 639 | 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); |
| 644 | 644 | rectangle r; |
| 645 | | struct crtc6845_cursor cursor; |
| 645 | struct mscrtc6845_cursor cursor; |
| 646 | 646 | |
| 647 | | crtc6845_time(crtc); |
| 648 | | crtc6845_get_cursor(crtc, &cursor); |
| 647 | mscrtc6845_time(crtc); |
| 648 | mscrtc6845_get_cursor(crtc, &cursor); |
| 649 | 649 | pc_cga_check_palette(); |
| 650 | 650 | |
| 651 | 651 | for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) |
| r1129 | r1130 | |
| 706 | 706 | The character cell size is 16x8 |
| 707 | 707 | ***************************************************************************/ |
| 708 | 708 | |
| 709 | | static void cga_text_blink_alt(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 709 | static void cga_text_blink_alt(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 710 | 710 | { |
| 711 | 711 | 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); |
| 716 | 716 | rectangle r; |
| 717 | | struct crtc6845_cursor cursor; |
| 717 | struct mscrtc6845_cursor cursor; |
| 718 | 718 | |
| 719 | 719 | if (CGA_CHIPSET != CGA_CHIPSET_PC200) |
| 720 | 720 | { |
| r1129 | r1130 | |
| 722 | 722 | return; |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | | crtc6845_time(crtc); |
| 726 | | crtc6845_get_cursor(crtc, &cursor); |
| 725 | mscrtc6845_time(crtc); |
| 726 | mscrtc6845_get_cursor(crtc, &cursor); |
| 727 | 727 | pc_cga_check_palette(); |
| 728 | 728 | |
| 729 | 729 | for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) |
| r1129 | r1130 | |
| 772 | 772 | /*************************************************************************** |
| 773 | 773 | Draw graphics mode with 320x200 pixels (default) with 2 bits/pixel. |
| 774 | 774 | 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)! |
| 776 | 776 | ***************************************************************************/ |
| 777 | 777 | |
| 778 | | static void cga_gfx_2bpp(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 778 | static void cga_gfx_2bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 779 | 779 | { |
| 780 | 780 | const UINT16 *palette; |
| 781 | 781 | int colorset = cga.color_select & 0x3F; |
| r1129 | r1130 | |
| 817 | 817 | Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000 |
| 818 | 818 | ***************************************************************************/ |
| 819 | 819 | |
| 820 | | static void cga_gfx_1bpp(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 820 | static void cga_gfx_1bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 821 | 821 | { |
| 822 | 822 | const UINT16 *palette; |
| 823 | 823 | |
| r1129 | r1130 | |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | |
| 849 | | static void cga_gfx_4bpp(mame_bitmap *bitmap, struct crtc6845 *crtc, int scale) |
| 849 | static void cga_gfx_4bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc, int scale) |
| 850 | 850 | { |
| 851 | 851 | 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; |
| 856 | 856 | |
| 857 | 857 | pc_cga_check_palette(); |
| 858 | 858 | |
| r1129 | r1130 | |
| 895 | 895 | * The different scaling factors mean that the '160x200' versions of screens |
| 896 | 896 | * are the same size as the normal colour ones. |
| 897 | 897 | */ |
| 898 | | static void cga_gfx_4bpph(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 898 | static void cga_gfx_4bpph(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 899 | 899 | { |
| 900 | 900 | pc_cga_check_palette(); |
| 901 | 901 | cga_gfx_4bpp(bitmap, crtc, 8); |
| r1129 | r1130 | |
| 903 | 903 | |
| 904 | 904 | |
| 905 | 905 | /* The lo-res graphics mode on a colour composite monitor */ |
| 906 | | static void cga_gfx_4bppl(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 906 | static void cga_gfx_4bppl(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 907 | 907 | { |
| 908 | 908 | pc_cga_check_palette(); |
| 909 | 909 | cga_gfx_4bpp(bitmap, crtc, 4); |
| r1129 | r1130 | |
| 947 | 947 | Second plane at CGA_base + 0x4000 / 0x6000 |
| 948 | 948 | ***************************************************************************/ |
| 949 | 949 | |
| 950 | | static void cga_pgfx_4bpp(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 950 | static void cga_pgfx_4bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 951 | 951 | { |
| 952 | 952 | 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; |
| 957 | 957 | |
| 958 | 958 | for (sy=0; sy<lines; sy++,offs=(offs+columns)&0x1fff) |
| 959 | 959 | { |
| r1129 | r1130 | |
| 1034 | 1034 | /*************************************************************************** |
| 1035 | 1035 | Draw graphics mode with 320x200 pixels (default) with 2 bits/pixel. |
| 1036 | 1036 | 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)! |
| 1038 | 1038 | ***************************************************************************/ |
| 1039 | 1039 | |
| 1040 | | static void cga_pgfx_2bpp(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 1040 | static void cga_pgfx_2bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 1041 | 1041 | { |
| 1042 | 1042 | 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; |
| 1047 | 1047 | int colorset = cga.color_select & 0x3F; |
| 1048 | 1048 | const UINT16 *palette; |
| 1049 | 1049 | |
| r1129 | r1130 | |
| 1143 | 1143 | Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000 |
| 1144 | 1144 | ***************************************************************************/ |
| 1145 | 1145 | |
| 1146 | | static void pc1512_gfx_4bpp(mame_bitmap *bitmap, struct crtc6845 *crtc) |
| 1146 | static void pc1512_gfx_4bpp(mame_bitmap *bitmap, struct mscrtc6845 *crtc) |
| 1147 | 1147 | { |
| 1148 | 1148 | 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; |
| 1153 | 1153 | |
| 1154 | 1154 | for (sy=0; sy<lines; sy++,offs=(offs+columns)&0x1fff) |
| 1155 | 1155 | { |
| r1129 | r1130 | |
| 1199 | 1199 | if (cga.pc_blink == on) return; |
| 1200 | 1200 | |
| 1201 | 1201 | 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); |
| 1204 | 1204 | |
| 1205 | 1205 | if (dirtybuffer) |
| 1206 | 1206 | { |
| r1129 | r1130 | |
| 1234 | 1234 | Choose the appropriate video mode |
| 1235 | 1235 | ***************************************************************************/ |
| 1236 | 1236 | |
| 1237 | | pc_video_update_proc pc_cga_choosevideomode(int *width, int *height, struct crtc6845 *crtc) |
| 1237 | pc_video_update_proc pc_cga_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc) |
| 1238 | 1238 | { |
| 1239 | 1239 | pc_video_update_proc proc = NULL; |
| 1240 | 1240 | const pc_video_update_proc *procarray; |
| r1129 | r1130 | |
| 1288 | 1288 | { |
| 1289 | 1289 | mode = (cga.mode_control & 0x07) | ((cga.mode_control & 0x30) / 2); |
| 1290 | 1290 | |
| 1291 | | procarray = videoprocs[crtc6845_get_personality(crtc)]; |
| 1291 | procarray = videoprocs[mscrtc6845_get_personality(crtc)]; |
| 1292 | 1292 | proc = procarray[mode]; |
| 1293 | 1293 | |
| 1294 | 1294 | /* Plantronics high-res */ |
| r1129 | r1130 | |
| 1347 | 1347 | * character columns register, program it manually. */ |
| 1348 | 1348 | |
| 1349 | 1349 | case 0x8: |
| 1350 | | char_height = crtc6845_get_char_height(crtc6845); |
| 1350 | char_height = mscrtc6845_get_char_height(mscrtc6845); |
| 1351 | 1351 | if (data & 2) /* Graphics */ |
| 1352 | 1352 | { |
| 1353 | | crtc6845_set_char_columns(crtc6845, 40); |
| 1353 | mscrtc6845_set_char_columns(mscrtc6845, 40); |
| 1354 | 1354 | } |
| 1355 | 1355 | else |
| 1356 | 1356 | { |
| 1357 | 1357 | if (data & 1) /* 80-column */ |
| 1358 | 1358 | { |
| 1359 | | crtc6845_set_char_columns(crtc6845, 80); |
| 1359 | mscrtc6845_set_char_columns(mscrtc6845, 80); |
| 1360 | 1360 | } |
| 1361 | 1361 | else |
| 1362 | 1362 | { |
| 1363 | | crtc6845_set_char_columns(crtc6845, 40); |
| 1363 | mscrtc6845_set_char_columns(mscrtc6845, 40); |
| 1364 | 1364 | } |
| 1365 | 1365 | } |
| 1366 | | crtc6845_set_char_lines(crtc6845, 200 ); |
| 1366 | mscrtc6845_set_char_lines(mscrtc6845, 200 ); |
| 1367 | 1367 | pc_cga8_w(offset, data); |
| 1368 | 1368 | break; |
| 1369 | 1369 | |
src/mess/video/amstrad.c
| r1129 | r1130 | |
| 16 | 16 | |
| 17 | 17 | #include "sound/ay8910.h" |
| 18 | 18 | |
| 19 | | static crtc6845_state amstrad_vidhrdw_6845_state; |
| 19 | static m6845_state amstrad_vidhrdw_6845_state; |
| 20 | 20 | int prev_reg; |
| 21 | 21 | |
| 22 | 22 | extern int amstrad_plus_asic_enabled; |
| r1129 | r1130 | |
| 358 | 358 | { |
| 359 | 359 | mame_bitmap *bitmap = amstrad_bitmap; |
| 360 | 360 | |
| 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); |
| 363 | 363 | /* calc mem addr to fetch data from based on ma, and ra */ |
| 364 | 364 | unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) | |
| 365 | 365 | ((ra & 0x07)<<11) | |
| r1129 | r1130 | |
| 416 | 416 | { |
| 417 | 417 | mame_bitmap *bitmap = amstrad_bitmap; |
| 418 | 418 | |
| 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); |
| 421 | 421 | /* calc mem addr to fetch data from based on ma, and ra */ |
| 422 | 422 | unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) | |
| 423 | 423 | ((ra & 0x07)<<11) | |
| r1129 | r1130 | |
| 467 | 467 | { |
| 468 | 468 | mame_bitmap *bitmap = amstrad_bitmap; |
| 469 | 469 | |
| 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); |
| 472 | 472 | /* calc mem addr to fetch data from based on ma, and ra */ |
| 473 | 473 | unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) | |
| 474 | 474 | ((ra & 0x07)<<11) | |
| r1129 | r1130 | |
| 507 | 507 | { |
| 508 | 508 | mame_bitmap *bitmap = amstrad_bitmap; |
| 509 | 509 | |
| 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); |
| 512 | 512 | /* calc mem addr to fetch data from based on ma, and ra */ |
| 513 | 513 | unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) | |
| 514 | 514 | ((ra & 0x07)<<11) | |
| r1129 | r1130 | |
| 565 | 565 | { |
| 566 | 566 | mame_bitmap *bitmap = amstrad_bitmap; |
| 567 | 567 | |
| 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); |
| 570 | 570 | /* calc mem addr to fetch data from based on ma, and ra */ |
| 571 | 571 | unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) | |
| 572 | 572 | ((ra & 0x07)<<11) | |
| r1129 | r1130 | |
| 612 | 612 | { |
| 613 | 613 | mame_bitmap *bitmap = amstrad_bitmap; |
| 614 | 614 | |
| 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); |
| 617 | 617 | /* calc mem addr to fetch data from based on ma, and ra */ |
| 618 | 618 | unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) | |
| 619 | 619 | ((ra & 0x07)<<11) | |
| r1129 | r1130 | |
| 652 | 652 | { |
| 653 | 653 | mame_bitmap *bitmap = amstrad_bitmap; |
| 654 | 654 | |
| 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); |
| 657 | 657 | /* calc mem addr to fetch data from based on ma, and ra */ |
| 658 | 658 | unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) | |
| 659 | 659 | ((ra & 0x07)<<11) | |
| r1129 | r1130 | |
| 686 | 686 | { |
| 687 | 687 | mame_bitmap *bitmap = amstrad_bitmap; |
| 688 | 688 | |
| 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); |
| 691 | 691 | /* calc mem addr to fetch data from based on ma, and ra */ |
| 692 | 692 | unsigned int addr = (((ma>>(4+8)) & 0x03)<<14) | |
| 693 | 693 | ((ra & 0x07)<<11) | |
| r1129 | r1130 | |
| 730 | 730 | /* execute crtc_execute_cycles of crtc */ |
| 731 | 731 | void amstrad_vh_execute_crtc_cycles(int dummy) |
| 732 | 732 | { |
| 733 | | crtc6845_clock(); // Clock the 6845 |
| 733 | m6845_clock(); // Clock the 6845 |
| 734 | 734 | if ((x_screen_pos >= 0) && (x_screen_pos < AMSTRAD_SCREEN_WIDTH) && (y_screen_pos >= 0)) |
| 735 | 735 | { |
| 736 | 736 | /* render the screen */ |
| r1129 | r1130 | |
| 771 | 771 | |
| 772 | 772 | // get display bounds from CRTC registers (sprites are bound and clipped to inside the border) |
| 773 | 773 | 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); |
| 775 | 775 | 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)); |
| 777 | 777 | |
| 778 | 778 | for(spr = 15; spr >= 0; spr--) |
| 779 | 779 | { |
| r1129 | r1130 | |
| 927 | 927 | if(display_update == 1 && amstrad_plus_asic_enabled != 0) // first scanline |
| 928 | 928 | { |
| 929 | 929 | if(amstrad_plus_scroll_y != 0) |
| 930 | | amstrad_screen_width = crtc6845_get_register(1) * 2; |
| 930 | amstrad_screen_width = m6845_get_register(1) * 2; |
| 931 | 931 | display_x = x_screen_pos; |
| 932 | 932 | display_y = y_screen_pos; |
| 933 | 933 | display_update = 0; |
| r1129 | r1130 | |
| 1000 | 1000 | // CPC+/GX4000 Programmable Raster Interrupt (disabled if &6800 in ASIC RAM is 0) |
| 1001 | 1001 | if(amstrad_plus_pri != 0) |
| 1002 | 1002 | { |
| 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)) |
| 1004 | 1004 | { |
| 1005 | 1005 | // logerror("PRI: triggered, scanline %i, VSync width = %i\n",amstrad_scanline,vid.vertical_sync_width); |
| 1006 | 1006 | cpunum_set_input_line(0,0,ASSERT_LINE); |
| r1129 | r1130 | |
| 1011 | 1011 | // CPC+/GX4000 Split screen registers (disabled if &6801 in ASIC RAM is 0) |
| 1012 | 1012 | if(amstrad_plus_split_scanline != 0) |
| 1013 | 1013 | { |
| 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) |
| 1015 | 1015 | { |
| 1016 | | crtc6845_state vid; |
| 1017 | | crtc6845_get_state(0,&vid); |
| 1016 | m6845_state vid; |
| 1017 | m6845_get_state(0,&vid); |
| 1018 | 1018 | // logerror("SSCR: Split screen occured at scanline %i",amstrad_plus_split_scanline); |
| 1019 | 1019 | vid.Memory_Address_of_next_Character_Row = vid.Memory_Address_of_this_Character_Row = amstrad_plus_split_address; |
| 1020 | 1020 | vid.Memory_Address = amstrad_plus_split_address; |
| 1021 | | crtc6845_set_state(0,&vid); |
| 1021 | m6845_set_state(0,&vid); |
| 1022 | 1022 | } |
| 1023 | 1023 | } |
| 1024 | 1024 | // CPC+/GX4000 soft scroll register |
| r1129 | r1130 | |
| 1057 | 1057 | } |
| 1058 | 1058 | /* The cursor is not used on Amstrad. The CURSOR signal is available on the Expansion port for other hardware to use. */ |
| 1059 | 1059 | |
| 1060 | | static struct crtc6845_interface amstrad6845= { |
| 1060 | static struct m6845_interface amstrad6845= { |
| 1061 | 1061 | amstrad_Set_MA, // Memory Address register |
| 1062 | 1062 | amstrad_Set_RA, // Row Address register |
| 1063 | 1063 | amstrad_Set_HS, // Horizontal status |
| r1129 | r1130 | |
| 1109 | 1109 | { |
| 1110 | 1110 | amstrad_init_lookups(); |
| 1111 | 1111 | |
| 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); |
| 1116 | 1116 | |
| 1117 | 1117 | draw_function = amstrad_draw_screen_disabled; |
| 1118 | 1118 | |
src/mess/video/m6845.c
| r1129 | r1130 | |
| 1 | | |
| 2 | 1 | /************************************************************************ |
| 3 | 2 | crct6845 |
| 4 | 3 | |
| r1129 | r1130 | |
| 82 | 81 | #define R17_light_pen_address_L crtc.registers[17] |
| 83 | 82 | |
| 84 | 83 | |
| 85 | | static crtc6845_state crtc; |
| 84 | static m6845_state crtc; |
| 86 | 85 | static m6845_personality_t personality; |
| 87 | 86 | |
| 88 | 87 | #if 0 |
| 89 | 88 | /* VSYNC functions */ |
| 90 | 89 | |
| 91 | 90 | /* timer to set vsync */ |
| 92 | | static void *crtc6845_vsync_set_timer = NULL; |
| 91 | static void *m6845_vsync_set_timer = NULL; |
| 93 | 92 | /* timer to reset vsync */ |
| 94 | | static void *crtc6845_vsync_clear_timer = NULL; |
| 93 | static void *m6845_vsync_clear_timer = NULL; |
| 95 | 94 | |
| 96 | | static void crtc6845_vsync_set_timer_callback(int); |
| 97 | | static void crtc6845_vsync_clear_timer_callback(int); |
| 98 | | static void crtc6845_remove_vsync_set_timer(void); |
| 99 | | static void crtc6845_remove_vsync_clear_timer(void); |
| 100 | | static void crtc6845_set_new_vsync_set_time(int); |
| 101 | | static void crtc6845_set_new_vsync_clear_time(int); |
| 102 | | static void crtc6845_recalc_cycles_to_vsync_start(void); |
| 103 | | static void crtc6845_recalc_cycles_to_vsync_end(void); |
| 95 | static void m6845_vsync_set_timer_callback(int); |
| 96 | static void m6845_vsync_clear_timer_callback(int); |
| 97 | static void m6845_remove_vsync_set_timer(void); |
| 98 | static void m6845_remove_vsync_clear_timer(void); |
| 99 | static void m6845_set_new_vsync_set_time(int); |
| 100 | static void m6845_set_new_vsync_clear_time(int); |
| 101 | static void m6845_recalc_cycles_to_vsync_start(void); |
| 102 | static void m6845_recalc_cycles_to_vsync_end(void); |
| 104 | 103 | |
| 105 | 104 | #endif |
| 106 | 105 | |
| 107 | 106 | // local copy of the 6845 external procedure calls |
| 108 | | static struct crtc6845_interface |
| 107 | static struct m6845_interface |
| 109 | 108 | crct6845_calls= { |
| 110 | 109 | 0,// Memory Address register |
| 111 | 110 | 0,// Row Address register |
| r1129 | r1130 | |
| 126 | 125 | }; |
| 127 | 126 | |
| 128 | 127 | /* set up the local copy of the 6845 external procedure calls */ |
| 129 | | void crtc6845_config(const struct crtc6845_interface *intf) |
| 128 | void m6845_config(const struct m6845_interface *intf) |
| 130 | 129 | { |
| 131 | 130 | crct6845_calls.out_MA_func=*intf->out_MA_func; |
| 132 | 131 | crct6845_calls.out_RA_func=*intf->out_RA_func; |
| r1129 | r1130 | |
| 138 | 137 | personality = M6845_PERSONALITY_GENUINE; |
| 139 | 138 | } |
| 140 | 139 | |
| 141 | | void crtc6845_start(void) |
| 140 | void m6845_start(void) |
| 142 | 141 | { |
| 143 | 142 | #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; |
| 146 | 145 | #endif |
| 147 | 146 | } |
| 148 | 147 | |
| 149 | 148 | /* 6845 registers */ |
| 150 | 149 | |
| 151 | 150 | /* functions to set the 6845 registers */ |
| 152 | | void crtc6845_address_w(int offset, int data) |
| 151 | void m6845_address_w(int offset, int data) |
| 153 | 152 | { |
| 154 | 153 | crtc.address_register=data & 0x1f; |
| 155 | 154 | } |
| 156 | 155 | |
| 157 | | void crtc6845_get_state(int offset, crtc6845_state *state) |
| 156 | void m6845_get_state(int offset, m6845_state *state) |
| 158 | 157 | { |
| 159 | | memcpy(state, &crtc, sizeof(crtc6845_state)); |
| 158 | memcpy(state, &crtc, sizeof(m6845_state)); |
| 160 | 159 | } |
| 161 | 160 | |
| 162 | | void crtc6845_set_state(int offset, crtc6845_state *state) |
| 161 | void m6845_set_state(int offset, m6845_state *state) |
| 163 | 162 | { |
| 164 | | memcpy(&crtc, state, sizeof(crtc6845_state)); |
| 163 | memcpy(&crtc, state, sizeof(m6845_state)); |
| 165 | 164 | } |
| 166 | 165 | |
| 167 | 166 | |
| 168 | | void crtc6845_register_w(int offset, int data) |
| 167 | void m6845_register_w(int offset, int data) |
| 169 | 168 | { |
| 170 | 169 | switch (crtc.address_register) |
| 171 | 170 | { |
| 172 | 171 | case 0: |
| 173 | 172 | 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(); |
| 176 | 175 | break; |
| 177 | 176 | case 1: |
| 178 | 177 | R1_horizontal_displayed=data & 0x0ff; |
| r1129 | r1130 | |
| 192 | 191 | |
| 193 | 192 | crtc.horizontal_sync_width = data & 0x0f; |
| 194 | 193 | |
| 195 | | // crtc6845_recalc_cycles_to_vsync_end(); |
| 194 | // m6845_recalc_cycles_to_vsync_end(); |
| 196 | 195 | } |
| 197 | 196 | break; |
| 198 | 197 | |
| 199 | 198 | case 4: |
| 200 | 199 | R4_vertical_total=data&0x7f; |
| 201 | | // crtc6845_recalc_cycles_to_vsync_start(); |
| 200 | // m6845_recalc_cycles_to_vsync_start(); |
| 202 | 201 | break; |
| 203 | 202 | case 5: |
| 204 | 203 | R5_vertical_total_adjust=data&0x1f; |
| 205 | 204 | |
| 206 | 205 | |
| 207 | | // crtc6845_recalc_cycles_to_vsync_start(); |
| 206 | // m6845_recalc_cycles_to_vsync_start(); |
| 208 | 207 | |
| 209 | 208 | break; |
| 210 | 209 | case 6: |
| r1129 | r1130 | |
| 212 | 211 | break; |
| 213 | 212 | case 7: |
| 214 | 213 | R7_vertical_sync_position=data&0x7f; |
| 215 | | // crtc6845_recalc_cycles_to_vsync_start(); |
| 214 | // m6845_recalc_cycles_to_vsync_start(); |
| 216 | 215 | break; |
| 217 | 216 | case 8: |
| 218 | 217 | R8_interlace_display_enabled=data&0xf3; |
| r1129 | r1130 | |
| 220 | 219 | break; |
| 221 | 220 | case 9: |
| 222 | 221 | R9_scan_lines_per_character=data&0x1f; |
| 223 | | // crtc6845_recalc_cycles_to_vsync_start(); |
| 222 | // m6845_recalc_cycles_to_vsync_start(); |
| 224 | 223 | break; |
| 225 | 224 | case 10: |
| 226 | 225 | R10_cursor_start=data&0x7f; |
| r1129 | r1130 | |
| 256 | 255 | } |
| 257 | 256 | |
| 258 | 257 | |
| 259 | | int crtc6845_register_r(int offset) |
| 258 | int m6845_register_r(int offset) |
| 260 | 259 | { |
| 261 | 260 | int retval; |
| 262 | 261 | |
| r1129 | r1130 | |
| 314 | 313 | } |
| 315 | 314 | |
| 316 | 315 | |
| 317 | | void crtc6845_reset(int which) |
| 316 | void m6845_reset(int which) |
| 318 | 317 | { |
| 319 | 318 | memset(&crtc.registers[0], 0, sizeof(int)*32); |
| 320 | 319 | crtc.address_register = 0; |
| r1129 | r1130 | |
| 375 | 374 | crtc.Display_Enabled=Next_Display_Enabled; |
| 376 | 375 | } |
| 377 | 376 | |
| 378 | | static void crtc6845_restart_frame(void) |
| 377 | static void m6845_restart_frame(void) |
| 379 | 378 | { |
| 380 | 379 | /* no restart frame */ |
| 381 | 380 | /* End of All Vertical Character rows */ |
| r1129 | r1130 | |
| 390 | 389 | crtc.Memory_Address_of_next_Character_Row = crtc.Memory_Address; |
| 391 | 390 | } |
| 392 | 391 | |
| 393 | | void crtc6845_frameclock(void) |
| 392 | void m6845_frameclock(void) |
| 394 | 393 | { |
| 395 | 394 | crtc.Cursor_Flash_Count=(crtc.Cursor_Flash_Count+1)%50; |
| 396 | 395 | } |
| 397 | 396 | |
| 398 | 397 | /* clock the 6845 */ |
| 399 | | void crtc6845_clock(void) |
| 398 | void m6845_clock(void) |
| 400 | 399 | { |
| 401 | 400 | /* KT - I think the compiler might generate shit code when using "%" operator! */ |
| 402 | 401 | /*crtc.Memory_Address=(crtc.Memory_Address+1)%0x4000;*/ |
| r1129 | r1130 | |
| 460 | 459 | } |
| 461 | 460 | else |
| 462 | 461 | { |
| 463 | | crtc6845_restart_frame(); |
| 462 | m6845_restart_frame(); |
| 464 | 463 | } |
| 465 | 464 | |
| 466 | 465 | } |
| r1129 | r1130 | |
| 520 | 519 | // crtc.Character_Row_Counter_Reset = TRUE; |
| 521 | 520 | |
| 522 | 521 | // KT this caused problems when R7 == 0 and R5 was set! |
| 523 | | crtc6845_restart_frame(); |
| 522 | m6845_restart_frame(); |
| 524 | 523 | |
| 525 | 524 | /* Check for start of Vertical Sync Pulse */ |
| 526 | 525 | if (crtc.Character_Row_Counter==R7_vertical_sync_position) |
| r1129 | r1130 | |
| 657 | 656 | |
| 658 | 657 | /* functions to read the 6845 outputs */ |
| 659 | 658 | |
| 660 | | int crtc6845_memory_address_r(int offset) { return crtc.Memory_Address; } /* MA = Memory Address output */ |
| 661 | | int crtc6845_row_address_r(int offset) { return crtc.Scan_Line_Counter; } /* RA = Row Address output */ |
| 662 | | int crtc6845_horizontal_sync_r(int offset) { return crtc.HSYNC; } /* HS = Horizontal Sync */ |
| 663 | | int crtc6845_vertical_sync_r(int offset) { return crtc.VSYNC; } /* VS = Vertical Sync */ |
| 664 | | int crtc6845_display_enabled_r(int offset) { return crtc.Display_Delayed_Enabled; } /* DE = Display Enabled */ |
| 665 | | int crtc6845_cursor_enabled_r(int offset) { return crtc.Cursor_Delayed_Status; } /* CR = Cursor Enabled */ |
| 659 | int m6845_memory_address_r(int offset) { return crtc.Memory_Address; } /* MA = Memory Address output */ |
| 660 | int m6845_row_address_r(int offset) { return crtc.Scan_Line_Counter; } /* RA = Row Address output */ |
| 661 | int m6845_horizontal_sync_r(int offset) { return crtc.HSYNC; } /* HS = Horizontal Sync */ |
| 662 | int m6845_vertical_sync_r(int offset) { return crtc.VSYNC; } /* VS = Vertical Sync */ |
| 663 | int m6845_display_enabled_r(int offset) { return crtc.Display_Delayed_Enabled; } /* DE = Display Enabled */ |
| 664 | int m6845_cursor_enabled_r(int offset) { return crtc.Cursor_Delayed_Status; } /* CR = Cursor Enabled */ |
| 666 | 665 | |
| 667 | | void crtc6845_set_personality(m6845_personality_t p) |
| 666 | void m6845_set_personality(m6845_personality_t p) |
| 668 | 667 | { |
| 669 | 668 | personality = p; |
| 670 | 669 | } |
| 671 | 670 | |
| 672 | | // A few helper functions to help avoid heavy use of crtc6845_get/set_state() |
| 673 | | int crtc6845_get_register(int reg) |
| 671 | // A few helper functions to help avoid heavy use of m6845_get/set_state() |
| 672 | int m6845_get_register(int reg) |
| 674 | 673 | { |
| 675 | 674 | return crtc.registers[reg]; |
| 676 | 675 | } |
| 677 | 676 | |
| 678 | | int crtc6845_get_scanline_counter() |
| 677 | int m6845_get_scanline_counter() |
| 679 | 678 | { |
| 680 | 679 | return crtc.Scan_Line_Counter; |
| 681 | 680 | } |
| 682 | 681 | |
| 683 | | int crtc6845_get_row_counter() |
| 682 | int m6845_get_row_counter() |
| 684 | 683 | { |
| 685 | 684 | return crtc.Character_Row_Counter; |
| 686 | 685 | } |
| r1129 | r1130 | |
| 698 | 697 | |
| 699 | 698 | /* calculate the number of cycles to the next vsync */ |
| 700 | 699 | /* ignores Reg 5! - to be completed */ |
| 701 | | int crtc6845_cycles_to_vsync(void) |
| 700 | int m6845_cycles_to_vsync(void) |
| 702 | 701 | { |
| 703 | 702 | /* passed vertical sync position */ |
| 704 | 703 | int cycles_per_frame; |
| r1129 | r1130 | |
| 734 | 733 | } |
| 735 | 734 | |
| 736 | 735 | /* calculate the number of CRTC cycles for VSYNC */ |
| 737 | | int crtc6845_cycles_to_vsync_end(void) |
| 736 | int m6845_cycles_to_vsync_end(void) |
| 738 | 737 | { |
| 739 | 738 | /* if we are in vsync */ |
| 740 | 739 | if (crtc.VSYNC) |
| r1129 | r1130 | |
| 742 | 741 | return (R0_horizontal_total+1)*(crtc.vertical_sync_width-crtc.Vertical_Sync_Width_Counter); |
| 743 | 742 | } |
| 744 | 743 | |
| 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); |
| 746 | 745 | } |
| 747 | 746 | |
| 748 | 747 | |
| 749 | 748 | /* number of crtc cycles for whole frame */ |
| 750 | | static int crtc6845_cycles_per_frame(void) |
| 749 | static int m6845_cycles_per_frame(void) |
| 751 | 750 | { |
| 752 | 751 | int scan_lines_per_character = R9_scan_lines_per_character+1; |
| 753 | 752 | int chars_per_line = R0_horizontal_total+1; |
| r1129 | r1130 | |
| 759 | 758 | } |
| 760 | 759 | |
| 761 | 760 | /* number of crtc cycles for vsync */ |
| 762 | | static int crtc6845_vsync_length_in_cycles(void) |
| 761 | static int m6845_vsync_length_in_cycles(void) |
| 763 | 762 | { |
| 764 | 763 | int length; |
| 765 | 764 | |
| r1129 | r1130 | |
| 777 | 776 | |
| 778 | 777 | |
| 779 | 778 | /* remove "vsync set" timer */ |
| 780 | | static void crtc6845_remove_vsync_set_timer(void) |
| 779 | static void m6845_remove_vsync_set_timer(void) |
| 781 | 780 | { |
| 782 | | if (crtc6845_vsync_set_timer!=NULL) |
| 781 | if (m6845_vsync_set_timer!=NULL) |
| 783 | 782 | { |
| 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; |
| 786 | 785 | } |
| 787 | 786 | } |
| 788 | 787 | |
| 789 | 788 | /* remove "vsync clear" timer */ |
| 790 | | static void crtc6845_remove_vsync_clear_timer(void) |
| 789 | static void m6845_remove_vsync_clear_timer(void) |
| 791 | 790 | { |
| 792 | | if (crtc6845_vsync_clear_timer!=NULL) |
| 791 | if (m6845_vsync_clear_timer!=NULL) |
| 793 | 792 | { |
| 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; |
| 796 | 795 | } |
| 797 | 796 | } |
| 798 | 797 | |
| 799 | 798 | /* setup new time for "vsync set" */ |
| 800 | | static void crtc6845_set_new_vsync_set_time(int cycles) |
| 799 | static void m6845_set_new_vsync_set_time(int cycles) |
| 801 | 800 | { |
| 802 | 801 | int crtc_cycles_to_vsync_start; |
| 803 | 802 | |
| r1129 | r1130 | |
| 805 | 804 | cycles will be -1 */ |
| 806 | 805 | crtc_cycles_to_vsync_start = cycles; |
| 807 | 806 | |
| 808 | | crtc6845_remove_vsync_set_timer(); |
| 807 | m6845_remove_vsync_set_timer(); |
| 809 | 808 | |
| 810 | 809 | if (crtc_cycles_to_vsync_start!=-1) |
| 811 | 810 | { |
| 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); |
| 813 | 812 | } |
| 814 | 813 | } |
| 815 | 814 | |
| 816 | 815 | /* setup new time for "vsync clear" */ |
| 817 | | static void crtc6845_set_new_vsync_clear_time(int cycles) |
| 816 | static void m6845_set_new_vsync_clear_time(int cycles) |
| 818 | 817 | { |
| 819 | 818 | int crtc_cycles_to_vsync_end; |
| 820 | 819 | |
| 821 | | crtc6845_remove_vsync_clear_timer(); |
| 820 | m6845_remove_vsync_clear_timer(); |
| 822 | 821 | |
| 823 | 822 | /* get number of cycles to end of vsync */ |
| 824 | 823 | crtc_cycles_to_vsync_end = cycles; |
| 825 | 824 | |
| 826 | 825 | if (crtc_cycles_to_vsync_end!=-1) |
| 827 | 826 | { |
| 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); |
| 829 | 828 | } |
| 830 | 829 | } |
| 831 | 830 | |
| 832 | 831 | /* for these two below, might be better to record the current cpu time, and use that |
| 833 | 832 | to recalculate where the start/end of the vsync will next occur! */ |
| 834 | 833 | |
| 835 | | static void crtc6845_vsync_clear_timer_callback(int dummy) |
| 834 | static void m6845_vsync_clear_timer_callback(int dummy) |
| 836 | 835 | { |
| 837 | 836 | /* clear vsync */ |
| 838 | 837 | crtc.VSYNC = 0; |
| r1129 | r1130 | |
| 845 | 844 | /* the next vsync will occur in cycles per frame - vsync length in cycles */ |
| 846 | 845 | /* this will work as long as the vsync length has not been reprogrammed while the vsync was active! */ |
| 847 | 846 | /* 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()); |
| 849 | 848 | |
| 850 | 849 | /* 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); |
| 852 | 851 | } |
| 853 | 852 | |
| 854 | 853 | /* called when vsync is set */ |
| 855 | | static void crtc6845_vsync_set_timer_callback(int dummy) |
| 854 | static void m6845_vsync_set_timer_callback(int dummy) |
| 856 | 855 | { |
| 857 | 856 | /* set vsync */ |
| 858 | 857 | crtc.VSYNC = 1; |
| r1129 | r1130 | |
| 866 | 865 | is active, in this case, the new vsync end will be re-calculated */ |
| 867 | 866 | |
| 868 | 867 | /* 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()); |
| 870 | 869 | |
| 871 | 870 | /* 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); |
| 873 | 872 | } |
| 874 | | static void crtc6845_recalc_cycles_to_vsync_end(void) |
| 873 | static void m6845_recalc_cycles_to_vsync_end(void) |
| 875 | 874 | { |
| 876 | | int cycles_to_vsync_end = crtc6845_cycles_to_vsync_end(); |
| 875 | int cycles_to_vsync_end = m6845_cycles_to_vsync_end(); |
| 877 | 876 | |
| 878 | 877 | /* if we're in vsync, the end is important, otherwise we are waiting for the next vsync |
| 879 | 878 | to start. The start is not affected by the length of the vsync */ |
| 880 | 879 | if (crtc.VSYNC) |
| 881 | 880 | { |
| 882 | | crtc6845_set_new_vsync_clear_time(cycles_to_vsync_end); |
| 881 | m6845_set_new_vsync_clear_time(cycles_to_vsync_end); |
| 883 | 882 | } |
| 884 | 883 | } |
| 885 | 884 | |
| 886 | | static void crtc6845_recalc_cycles_to_vsync_start(void) |
| 885 | static void m6845_recalc_cycles_to_vsync_start(void) |
| 887 | 886 | { |
| 888 | | int cycles_to_vsync_start = crtc6845_cycles_to_vsync(); |
| 887 | int cycles_to_vsync_start = m6845_cycles_to_vsync(); |
| 889 | 888 | |
| 890 | 889 | /* if we're not in vsync, the end is important, otherwise we are waiting for the end |
| 891 | 890 | of the vsync */ |
| 892 | 891 | if (!crtc.VSYNC) |
| 893 | 892 | { |
| 894 | | crtc6845_set_new_vsync_set_time(cycles_to_vsync_start); |
| 893 | m6845_set_new_vsync_set_time(cycles_to_vsync_start); |
| 895 | 894 | } |
| 896 | 895 | } |
| 897 | 896 | |
| 898 | 897 | /* ignores r5 ! to be completed */ |
| 899 | | void crtc6845_recalc(int offset,int num_cycles) |
| 898 | void m6845_recalc(int offset,int num_cycles) |
| 900 | 899 | { |
| 901 | 900 | int cycles; |
| 902 | 901 | int num_scan_lines; |
src/mess/video/m6845.h
| r1129 | r1130 | |
| 1 | | |
| 2 | 1 | /************************************************************************ |
| 3 | 2 | crct6845 |
| 4 | 3 | |
| r1129 | r1130 | |
| 20 | 19 | M6845_PERSONALITY_PREASIC |
| 21 | 20 | } m6845_personality_t; |
| 22 | 21 | |
| 23 | | struct crtc6845_interface |
| 22 | struct m6845_interface |
| 24 | 23 | { |
| 25 | 24 | void (*out_MA_func)(int offset, int data); |
| 26 | 25 | void (*out_RA_func)(int offset, int data); |
| r1129 | r1130 | |
| 31 | 30 | void (*out_CRE_func)(int offset, int data); |
| 32 | 31 | }; |
| 33 | 32 | |
| 34 | | typedef struct crtc6845_state |
| 33 | typedef struct m6845_state |
| 35 | 34 | { |
| 36 | 35 | /* Register Select */ |
| 37 | 36 | int address_register; |
| r1129 | r1130 | |
| 85 | 84 | int Vertical_Adjust_Done; |
| 86 | 85 | // int cycles_to_vsync_start; |
| 87 | 86 | // int cycles_to_vsync_end; |
| 88 | | } crtc6845_state; |
| 87 | } m6845_state; |
| 89 | 88 | |
| 90 | 89 | /* set up the local copy of the 6845 external procedure calls */ |
| 91 | | void crtc6845_config(const struct crtc6845_interface *intf); |
| 90 | void m6845_config(const struct m6845_interface *intf); |
| 92 | 91 | |
| 93 | 92 | |
| 94 | 93 | /* functions to set the 6845 registers */ |
| 95 | | int crtc6845_register_r(int offset); |
| 96 | | void crtc6845_address_w(int offset, int data); |
| 97 | | void crtc6845_register_w(int offset, int data); |
| 94 | int m6845_register_r(int offset); |
| 95 | void m6845_address_w(int offset, int data); |
| 96 | void m6845_register_w(int offset, int data); |
| 98 | 97 | |
| 99 | 98 | |
| 100 | 99 | /* clock the 6845 */ |
| 101 | | void crtc6845_clock(void); |
| 100 | void m6845_clock(void); |
| 102 | 101 | |
| 103 | 102 | /* called every frame to advance the cursor count */ |
| 104 | | void crtc6845_frameclock(void); |
| 103 | void m6845_frameclock(void); |
| 105 | 104 | |
| 106 | 105 | /* functions to read the 6845 outputs */ |
| 107 | | int crtc6845_memory_address_r(int offset); |
| 108 | | int crtc6845_row_address_r(int offset); |
| 109 | | int crtc6845_horizontal_sync_r(int offset); |
| 110 | | int crtc6845_vertical_sync_r(int offset); |
| 111 | | int crtc6845_display_enabled_r(int offset); |
| 112 | | int crtc6845_cursor_enabled_r(int offset); |
| 106 | int m6845_memory_address_r(int offset); |
| 107 | int m6845_row_address_r(int offset); |
| 108 | int m6845_horizontal_sync_r(int offset); |
| 109 | int m6845_vertical_sync_r(int offset); |
| 110 | int m6845_display_enabled_r(int offset); |
| 111 | int m6845_cursor_enabled_r(int offset); |
| 113 | 112 | |
| 114 | | void crtc6845_recalc(int offset, int cycles); |
| 113 | void m6845_recalc(int offset, int cycles); |
| 115 | 114 | |
| 116 | | void crtc6845_set_state(int offset, crtc6845_state *state); |
| 117 | | void crtc6845_get_state(int offset, crtc6845_state *state); |
| 115 | void m6845_set_state(int offset, m6845_state *state); |
| 116 | void m6845_get_state(int offset, m6845_state *state); |
| 118 | 117 | |
| 119 | | void crtc6845_reset(int which); |
| 118 | void m6845_reset(int which); |
| 120 | 119 | |
| 121 | | void crtc6845_start(void); |
| 120 | void m6845_start(void); |
| 122 | 121 | |
| 123 | | void crtc6845_set_personality(m6845_personality_t personality); |
| 122 | void m6845_set_personality(m6845_personality_t personality); |
| 124 | 123 | |
| 125 | | int crtc6845_get_register(int reg); |
| 126 | | int crtc6845_get_scanline_counter(void); |
| 127 | | int crtc6845_get_row_counter(void); |
| 124 | int m6845_get_register(int reg); |
| 125 | int m6845_get_scanline_counter(void); |
| 126 | int m6845_get_row_counter(void); |
src/mess/drivers/pet.c
| r1129 | r1130 | |
| 142 | 142 | AM_RANGE(0xe810, 0xe813) AM_READWRITE(pia_0_r, pia_0_w) |
| 143 | 143 | AM_RANGE(0xe820, 0xe823) AM_READWRITE(pia_1_r, pia_1_w) |
| 144 | 144 | 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) |
| 146 | 146 | AM_RANGE(0xf000, 0xffff) AM_ROM |
| 147 | 147 | ADDRESS_MAP_END |
| 148 | 148 | |
| r1129 | r1130 | |
| 158 | 158 | AM_RANGE(0xe810, 0xe813) AM_READWRITE(pia_0_r, pia_0_w) |
| 159 | 159 | AM_RANGE(0xe820, 0xe823) AM_READWRITE(pia_1_r, pia_1_w) |
| 160 | 160 | 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) |
| 162 | 162 | #endif |
| 163 | 163 | AM_RANGE(0xf000, 0xffff) AM_READ(MRA8_BANK8) |
| 164 | 164 | AM_RANGE(0xf000, 0xffef) AM_WRITE(MWA8_BANK8) |
| r1129 | r1130 | |
| 188 | 188 | AM_RANGE(0xe810, 0xe813) AM_READWRITE(pia_0_r, pia_0_w) |
| 189 | 189 | AM_RANGE(0xe820, 0xe823) AM_READWRITE(pia_1_r, pia_1_w) |
| 190 | 190 | 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) |
| 192 | 192 | /* 0xefe0, 0xefe3, mos 6702 */ |
| 193 | 193 | /* 0xeff0, 0xeff3, acia6551 */ |
| 194 | 194 | AM_RANGE(0xeff8, 0xefff) AM_READWRITE(superpet_r, superpet_w) |
| r1129 | r1130 | |
| 203 | 203 | AM_RANGE(0xe810, 0xe813) AM_READWRITE(pia_0_r, pia_0_w) |
| 204 | 204 | AM_RANGE(0xe820, 0xe823) AM_READWRITE(pia_1_r, pia_1_w) |
| 205 | 205 | 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) |
| 207 | 207 | AM_RANGE(0xeff8, 0xefff) AM_READWRITE(superpet_r, superpet_w) |
| 208 | 208 | AM_RANGE(0xf000, 0xffff) AM_ROM |
| 209 | 209 | ADDRESS_MAP_END |