src/mess/includes/bbc.h
| r11524 | r11525 | |
| 4 | 4 | * |
| 5 | 5 | * BBC Model B |
| 6 | 6 | * |
| 7 | | * Driver by Gordon Jefferyes <mess_bbc@gjeffery.dircon.co.uk> |
| 7 | * Driver by Gordon Jefferyes <mess_bbc@romvault.com> |
| 8 | 8 | * |
| 9 | 9 | ****************************************************************************/ |
| 10 | 10 | |
| r11524 | r11525 | |
| 16 | 16 | #include "machine/i8271.h" |
| 17 | 17 | #include "machine/wd17xx.h" |
| 18 | 18 | #include "machine/upd7002.h" |
| 19 | #include "video/mc6845.h" |
| 19 | 20 | |
| 20 | | |
| 21 | 21 | class bbc_state : public driver_device |
| 22 | 22 | { |
| 23 | 23 | public: |
| r11524 | r11525 | |
| 176 | 176 | unsigned char m_pixel_bits[256]; |
| 177 | 177 | int m_BBC_HSync; |
| 178 | 178 | int m_BBC_VSync; |
| 179 | | int m_BBC_Character_Row; |
| 180 | | int m_BBC_DE; |
| 181 | 179 | device_t *m_saa505x; |
| 182 | | int m_Teletext_Latch_Input_D7; |
| 180 | |
| 181 | |
| 182 | |
| 183 | 183 | int m_Teletext_Latch; |
| 184 | | int m_VideoULA_DE; |
| 185 | 184 | int m_VideoULA_CR; |
| 186 | 185 | int m_VideoULA_CR_counter; |
| 187 | 186 | int m_videoULA_Reg; |
| r11524 | r11525 | |
| 191 | 190 | int m_videoULA_characters_per_line; |
| 192 | 191 | int m_videoULA_teletext_normal_select; |
| 193 | 192 | int m_videoULA_flash_colour_select; |
| 193 | |
| 194 | |
| 195 | |
| 194 | 196 | int m_pixels_per_byte; |
| 195 | 197 | int m_emulation_pixels_per_real_pixel; |
| 196 | 198 | int m_emulation_pixels_per_byte; |
| 199 | |
| 197 | 200 | int m_emulation_cursor_size; |
| 198 | 201 | int m_cursor_state; |
| 202 | |
| 199 | 203 | int m_videoULA_pallet0[16]; |
| 200 | 204 | int m_videoULA_pallet1[16]; |
| 201 | 205 | int *m_videoULA_pallet_lookup; |
| 206 | |
| 207 | // this is the pixel position of the start of a scanline |
| 208 | // -96 sets the screen display to the middle of emulated screen. |
| 202 | 209 | int m_x_screen_offset; |
| 203 | 210 | int m_y_screen_offset; |
| 211 | |
| 204 | 212 | void (*m_draw_function)(running_machine &machine); |
| 205 | 213 | }; |
| 206 | 214 | |
| 207 | 215 | |
| 208 | 216 | /*----------- defined in machine/bbc.c -----------*/ |
| 209 | 217 | |
| 218 | |
| 219 | extern const mc6845_interface bbc_mc6845_intf; |
| 220 | |
| 221 | |
| 210 | 222 | extern const via6522_interface bbcb_system_via; |
| 211 | 223 | extern const via6522_interface bbcb_user_via; |
| 212 | 224 | extern const wd17xx_interface bbc_wd17xx_interface; |
| r11524 | r11525 | |
| 235 | 247 | |
| 236 | 248 | |
| 237 | 249 | WRITE8_HANDLER ( bbc_memorybp1_w ); |
| 238 | | //READ8_HANDLER ( bbc_memorybp2_r ); |
| 239 | 250 | WRITE8_HANDLER ( bbc_memorybp2_w ); |
| 240 | 251 | WRITE8_HANDLER ( bbc_memorybp4_w ); |
| 241 | 252 | WRITE8_HANDLER ( bbc_memorybp4_128_w ); |
| r11524 | r11525 | |
| 244 | 255 | |
| 245 | 256 | |
| 246 | 257 | WRITE8_HANDLER ( bbc_memorybm1_w ); |
| 247 | | //READ8_HANDLER ( bbc_memorybm2_r ); |
| 248 | 258 | WRITE8_HANDLER ( bbc_memorybm2_w ); |
| 249 | 259 | WRITE8_HANDLER ( bbc_memorybm4_w ); |
| 250 | 260 | WRITE8_HANDLER ( bbc_memorybm5_w ); |
| r11524 | r11525 | |
| 255 | 265 | WRITE8_HANDLER ( bbcm_ACCCON_write ); |
| 256 | 266 | |
| 257 | 267 | |
| 258 | | //WRITE8_HANDLER ( bbc_bank4_w ); |
| 259 | | |
| 260 | 268 | /* disc support */ |
| 261 | 269 | |
| 262 | 270 | DEVICE_IMAGE_LOAD ( bbcb_cart ); |
src/mess/video/m6845.c
| r11524 | r11525 | |
| 693 | 693 | crtc.personality = p; |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | | // A few helper functions to help avoid heavy use of m6845_get/set_state() |
| 697 | 696 | int m6845_get_register(int reg) |
| 698 | 697 | { |
| 699 | 698 | return crtc.registers[reg]; |
| 700 | 699 | } |
| 701 | | |
| 702 | | int m6845_get_scanline_counter() |
| 703 | | { |
| 704 | | return crtc.Scan_Line_Counter; |
| 705 | | } |
| 706 | | |
| 707 | | int m6845_get_row_counter() |
| 708 | | { |
| 709 | | return crtc.Character_Row_Counter; |
| 710 | | } |
| 711 | | |
| 712 | | |
| 713 | | #if 0 |
| 714 | | |
| 715 | | /* KT: |
| 716 | | |
| 717 | | The following bit of code uses timers to set/reset the vsync output of the 6845. |
| 718 | | If a function has been setup in the interface it will be executed with the new vsync |
| 719 | | value. |
| 720 | | |
| 721 | | */ |
| 722 | | |
| 723 | | /* calculate the number of cycles to the next vsync */ |
| 724 | | /* ignores Reg 5! - to be completed */ |
| 725 | | int m6845_cycles_to_vsync(void) |
| 726 | | { |
| 727 | | /* passed vertical sync position */ |
| 728 | | int cycles_per_frame; |
| 729 | | |
| 730 | | int cycles_into_frame; |
| 731 | | int scans_per_character = R9_scan_lines_per_character+1; |
| 732 | | int chars_per_line = R0_horizontal_total+1; |
| 733 | | int cycles_to_vsync_start; |
| 734 | | |
| 735 | | /* calculate current position into frame as char cycles */ |
| 736 | | /* scans into frames */ |
| 737 | | cycles_into_frame = crtc.Character_Row_Counter*scans_per_character; |
| 738 | | cycles_into_frame += crtc.Scan_Line_Counter; |
| 739 | | /* scans into frames as char cycles */ |
| 740 | | cycles_into_frame *= chars_per_line; |
| 741 | | /* total cycles into frame */ |
| 742 | | cycles_into_frame += crtc.Horizontal_Counter; |
| 743 | | |
| 744 | | /* cycles to vsync start as char cycles */ |
| 745 | | cycles_to_vsync_start = R7_vertical_sync_position*scans_per_character; |
| 746 | | cycles_to_vsync_start *= chars_per_line; |
| 747 | | |
| 748 | | |
| 749 | | if (cycles_into_frame<cycles_to_vsync_start) |
| 750 | | { |
| 751 | | /* not gone past vertical sync yet! */ |
| 752 | | return cycles_to_vsync_start - cycles_into_frame; |
| 753 | | } |
| 754 | | |
| 755 | | cycles_per_frame = (R4_vertical_total+1)*scans_per_character*chars_per_line; |
| 756 | | |
| 757 | | return (cycles_per_frame - cycles_into_frame) + cycles_to_vsync_start; |
| 758 | | } |
| 759 | | |
| 760 | | /* calculate the number of CRTC cycles for VSYNC */ |
| 761 | | int m6845_cycles_to_vsync_end(void) |
| 762 | | { |
| 763 | | /* if we are in vsync */ |
| 764 | | if (crtc.VSYNC) |
| 765 | | { |
| 766 | | return (R0_horizontal_total+1)*(crtc.vertical_sync_width-crtc.Vertical_Sync_Width_Counter); |
| 767 | | } |
| 768 | | |
| 769 | | return m6845_cycles_to_vsync() + ((R0_horizontal_total+1)*crtc.vertical_sync_width); |
| 770 | | } |
| 771 | | |
| 772 | | |
| 773 | | /* number of crtc cycles for whole frame */ |
| 774 | | static int m6845_cycles_per_frame(void) |
| 775 | | { |
| 776 | | int scan_lines_per_character = R9_scan_lines_per_character+1; |
| 777 | | int chars_per_line = R0_horizontal_total+1; |
| 778 | | |
| 779 | | return /* time for all rows */ |
| 780 | | ((R4_vertical_total+1)*chars_per_line*scan_lines_per_character) |
| 781 | | /* add time for scanlines in vertical adjust */ |
| 782 | | +(R5_vertical_total_adjust*chars_per_line); |
| 783 | | } |
| 784 | | |
| 785 | | /* number of crtc cycles for vsync */ |
| 786 | | static int m6845_vsync_length_in_cycles(void) |
| 787 | | { |
| 788 | | int length; |
| 789 | | |
| 790 | | /* if length is programmed as 0, actual length for hd6845s is 16 */ |
| 791 | | length = crtc.vertical_sync_width; |
| 792 | | |
| 793 | | if (length==0) |
| 794 | | { |
| 795 | | length = 16; |
| 796 | | } |
| 797 | | |
| 798 | | /* cycles for vsync */ |
| 799 | | return (R0_horizontal_total+1)*length; |
| 800 | | } |
| 801 | | |
| 802 | | |
| 803 | | /* remove "vsync set" timer */ |
| 804 | | static void m6845_remove_vsync_set_timer(void) |
| 805 | | { |
| 806 | | if (crtc.vsync_set_timer!=NULL) |
| 807 | | { |
| 808 | | crtc.vsync_set_timer->adjust(attotime::never); |
| 809 | | } |
| 810 | | } |
| 811 | | |
| 812 | | /* remove "vsync clear" timer */ |
| 813 | | static void m6845_remove_vsync_clear_timer(void) |
| 814 | | { |
| 815 | | if (crtc.vsync_clear_timer != NULL) |
| 816 | | { |
| 817 | | crtc.vsync_clear_timer->adjust(attotime::never); |
| 818 | | } |
| 819 | | } |
| 820 | | |
| 821 | | /* setup new time for "vsync set" */ |
| 822 | | static void m6845_set_new_vsync_set_time(int cycles) |
| 823 | | { |
| 824 | | int crtc_cycles_to_vsync_start; |
| 825 | | |
| 826 | | /* get cycles to vsync start, or if vsync cannot be reached |
| 827 | | cycles will be -1 */ |
| 828 | | crtc_cycles_to_vsync_start = cycles; |
| 829 | | |
| 830 | | m6845_remove_vsync_set_timer(); |
| 831 | | |
| 832 | | //crtc.vsync_set_timer = machine.scheduler().timer_alloc(FUNC(m6845_vsync_set_timer_callback)); |
| 833 | | if (crtc_cycles_to_vsync_start!=-1) |
| 834 | | { |
| 835 | | crtc.vsync_set_timer->adjust(attotime::from_usec(crtc_cycles_to_vsync_start)); |
| 836 | | } |
| 837 | | } |
| 838 | | |
| 839 | | /* setup new time for "vsync clear" */ |
| 840 | | static void m6845_set_new_vsync_clear_time(int cycles) |
| 841 | | { |
| 842 | | int crtc_cycles_to_vsync_end; |
| 843 | | |
| 844 | | m6845_remove_vsync_clear_timer(); |
| 845 | | |
| 846 | | /* get number of cycles to end of vsync */ |
| 847 | | crtc_cycles_to_vsync_end = cycles; |
| 848 | | |
| 849 | | //crtc.vsync_clear_timer = machine.scheduler().timer_alloc(FUNC(m6845_vsync_clear_timer_callback)); |
| 850 | | if (crtc_cycles_to_vsync_end!=-1) |
| 851 | | { |
| 852 | | crtc.vsync_clear_timer->adjust(attotime::from_usec(crtc_cycles_to_vsync_end)); |
| 853 | | } |
| 854 | | } |
| 855 | | |
| 856 | | /* for these two below, might be better to record the current cpu time, and use that |
| 857 | | to recalculate where the start/end of the vsync will next occur! */ |
| 858 | | |
| 859 | | static TIMER_CALLBACK( m6845_vsync_clear_timer_callback ) |
| 860 | | { |
| 861 | | /* clear vsync */ |
| 862 | | crtc.VSYNC = 0; |
| 863 | | |
| 864 | | /* call function to let emulation "know" */ |
| 865 | | if (crtc.intf->out_VS_func) (crtc.intf->out_VS_func)(machine,0,crtc.VSYNC); /* call VS update */ |
| 866 | | |
| 867 | | |
| 868 | | /* if we got to here the vsync has just ended */ |
| 869 | | /* the next vsync will occur in cycles per frame - vsync length in cycles */ |
| 870 | | /* this will work as long as the vsync length has not been reprogrammed while the vsync was active! */ |
| 871 | | /* setup time for vsync set timer */ |
| 872 | | m6845_set_new_vsync_set_time(m6845_cycles_per_frame()-m6845_vsync_length_in_cycles()); |
| 873 | | |
| 874 | | /* prevent timer from being free'd and don't let it trigger again */ |
| 875 | | crtc.vsync_clear_timer->adjust(attotime::never); |
| 876 | | } |
| 877 | | |
| 878 | | /* called when vsync is set */ |
| 879 | | static TIMER_CALLBACK( m6845_vsync_set_timer_callback ) |
| 880 | | { |
| 881 | | /* set vsync */ |
| 882 | | crtc.VSYNC = 1; |
| 883 | | |
| 884 | | /* call function to let emulation "know" */ |
| 885 | | if (crtc.intf->out_VS_func) (crtc.intf->out_VS_func)(machine,0,crtc.VSYNC); /* call VS update */ |
| 886 | | |
| 887 | | |
| 888 | | /* if we got to here the vsync has just been set, and has just started */ |
| 889 | | /* the next timer will be in vsync length cycles unless it is reprogrammed as the VSYNC |
| 890 | | is active, in this case, the new vsync end will be re-calculated */ |
| 891 | | |
| 892 | | /* setup time for vsync clear timer */ |
| 893 | | m6845_set_new_vsync_clear_time( m6845_vsync_length_in_cycles()); |
| 894 | | |
| 895 | | /* prevent timer from being free'd and don't let it trigger again */ |
| 896 | | crtc.vsync_set_timer->reset(); |
| 897 | | } |
| 898 | | static void m6845_recalc_cycles_to_vsync_end(void) |
| 899 | | { |
| 900 | | int cycles_to_vsync_end = m6845_cycles_to_vsync_end(); |
| 901 | | |
| 902 | | /* if we're in vsync, the end is important, otherwise we are waiting for the next vsync |
| 903 | | to start. The start is not affected by the length of the vsync */ |
| 904 | | if (crtc.VSYNC) |
| 905 | | { |
| 906 | | m6845_set_new_vsync_clear_time(cycles_to_vsync_end); |
| 907 | | } |
| 908 | | } |
| 909 | | |
| 910 | | static void m6845_recalc_cycles_to_vsync_start(void) |
| 911 | | { |
| 912 | | int cycles_to_vsync_start = m6845_cycles_to_vsync(); |
| 913 | | |
| 914 | | /* if we're not in vsync, the end is important, otherwise we are waiting for the end |
| 915 | | of the vsync */ |
| 916 | | if (!crtc.VSYNC) |
| 917 | | { |
| 918 | | m6845_set_new_vsync_set_time(cycles_to_vsync_start); |
| 919 | | } |
| 920 | | } |
| 921 | | |
| 922 | | /* ignores r5 ! to be completed */ |
| 923 | | void m6845_recalc(int offset,int num_cycles) |
| 924 | | { |
| 925 | | int cycles; |
| 926 | | int num_scan_lines; |
| 927 | | int scans_into_frame; |
| 928 | | int scan_lines_per_char = (R9_scan_lines_per_character+1); |
| 929 | | int scan_lines_per_frame = (R4_vertical_total+1)*scan_lines_per_char; |
| 930 | | cycles = num_cycles + crtc.Horizontal_Counter; |
| 931 | | |
| 932 | | /* calculate number of scan-lines */ |
| 933 | | num_scan_lines = cycles/(R0_horizontal_total+1); |
| 934 | | num_scan_lines+=crtc.Scan_Line_Counter; |
| 935 | | /* set new horizontal counter */ |
| 936 | | crtc.Horizontal_Counter = cycles % (R0_horizontal_total+1); |
| 937 | | |
| 938 | | scans_into_frame = crtc.Character_Row_Counter*scan_lines_per_char; |
| 939 | | |
| 940 | | while ((scans_into_frame+num_scan_lines)>=scan_lines_per_frame) |
| 941 | | { |
| 942 | | int scans_to_end_of_frame; |
| 943 | | |
| 944 | | scans_to_end_of_frame = scan_lines_per_frame - scans_into_frame; |
| 945 | | num_scan_lines -= scans_to_end_of_frame; |
| 946 | | scans_into_frame = 0; |
| 947 | | /* subtract R5 lines here! */ |
| 948 | | |
| 949 | | } |
| 950 | | |
| 951 | | /* update row position */ |
| 952 | | crtc.Character_Row_Counter = num_scan_lines/scan_lines_per_char; |
| 953 | | /* remainder is the scan line counter */ |
| 954 | | crtc.Scan_Line_Counter = num_scan_lines % scan_lines_per_char; |
| 955 | | } |
| 956 | | |
| 957 | | #endif |
src/mess/video/bbc.c
| r11524 | r11525 | |
| 4 | 4 | MESS Driver By: |
| 5 | 5 | |
| 6 | 6 | Gordon Jefferyes |
| 7 | | mess_bbc@gjeffery.dircon.co.uk |
| 7 | mess_bbc@romvault.com |
| 8 | 8 | |
| 9 | 9 | ******************************************************************************/ |
| 10 | 10 | |
| r11524 | r11525 | |
| 12 | 12 | #include "includes/bbc.h" |
| 13 | 13 | #include "video/m6845.h" |
| 14 | 14 | #include "saa505x.h" |
| 15 | #include "video/mc6845.h" |
| 15 | 16 | |
| 17 | static MC6845_UPDATE_ROW( vid_update_row ); |
| 18 | static WRITE_LINE_DEVICE_HANDLER( vid_hsync_changed ); |
| 19 | static WRITE_LINE_DEVICE_HANDLER( vid_vsync_changed ); |
| 16 | 20 | |
| 17 | 21 | static void BBC_draw_hi_res(running_machine &machine); |
| 18 | 22 | static void BBC_draw_teletext(running_machine &machine); |
| 19 | 23 | |
| 24 | const mc6845_interface bbc_mc6845_intf = |
| 25 | { |
| 26 | "screen", /* screen number */ |
| 27 | 8, /* numbers of pixels per video memory address */ |
| 28 | NULL, /* begin_update */ |
| 29 | vid_update_row, /* update_row */ |
| 30 | NULL, /* end_update */ |
| 31 | DEVCB_NULL, /* on_de_changed */ |
| 32 | DEVCB_NULL, /* on_cur_changed */ |
| 33 | DEVCB_LINE(vid_hsync_changed), /* on_hsync_changed */ |
| 34 | DEVCB_LINE(vid_vsync_changed), /* on_vsync_changed */ |
| 35 | NULL |
| 36 | }; |
| 20 | 37 | |
| 38 | static MC6845_UPDATE_ROW( vid_update_row ) |
| 39 | { |
| 40 | int x_pos; |
| 41 | int pixelno; |
| 42 | for(x_pos=0; x_pos<x_count; x_pos++) |
| 43 | { |
| 44 | for(pixelno=0; pixelno<8; pixelno++) |
| 45 | { |
| 46 | *BITMAP_ADDR16(bitmap, y, (x_pos*8)+pixelno)=2; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | static WRITE_LINE_DEVICE_HANDLER( vid_hsync_changed ) |
| 51 | { |
| 52 | } |
| 21 | 53 | |
| 54 | static WRITE_LINE_DEVICE_HANDLER( vid_vsync_changed ) |
| 55 | { |
| 56 | } |
| 57 | |
| 58 | |
| 22 | 59 | /************************************************************************ |
| 23 | | * video memory lookup arrays. |
| 24 | | * this is a set of quick lookup arrays that stores the logic for the following: |
| 25 | | * the array to be used is selected by the output from bits 4 and 5 (C0 and C1) on IC32 74LS259 |
| 26 | | * which is controlled by the system VIA. |
| 27 | 60 | * C0 and C1 along with MA12 output from the 6845 drive 4 NAND gates in ICs 27,36 and 40 |
| 28 | 61 | * the outputs from these NAND gates (B1 to B4) along with MA8 to MA11 from the 6845 (A1 to B4) are added together |
| 29 | 62 | * in IC39 74LS283 4 bit adder to form (S1 to S4) the logic is used to loop the screen memory for hardware scrolling. |
| r11524 | r11525 | |
| 42 | 75 | { |
| 43 | 76 | // ma = output from IC2 6845 MA address |
| 44 | 77 | |
| 45 | | |
| 46 | 78 | int c0=state->m_b4_video0; // output from IC32 74LS259 bits 4 and 5 |
| 47 | 79 | int c1=state->m_b5_video1; |
| 48 | 80 | |
| r11524 | r11525 | |
| 55 | 87 | |
| 56 | 88 | // 4 bit input B on IC39 74LS283 (4 bit adder) |
| 57 | 89 | /* 3 input NAND part of IC 36 */ |
| 58 | | int b1=(~(c1&c0&ma12))&1; |
| 90 | int b1=(~(c1 & c0 & ma12)) & 1; |
| 59 | 91 | /* 2 input NAND part of IC40 (b3 is calculated before b2 and b4 because b3 feed back into b2 and b4) */ |
| 60 | | int b3=(~(c0&ma12))&1; |
| 92 | int b3=(~(c0 & ma12)) & 1; |
| 61 | 93 | /* 3 input NAND part of IC 36 */ |
| 62 | | int b2=(~(c1&b3&ma12))&1; |
| 94 | int b2=(~(c1 & b3 & ma12)) & 1; |
| 63 | 95 | /* 2 input NAND part of IC 27 */ |
| 64 | | int b4=(~(b3&ma12))&1; |
| 96 | int b4=(~(b3 & ma12)) & 1; |
| 65 | 97 | |
| 66 | | /* inputs port a to IC39 are MA8 to MA11 from the 6845 */ |
| 67 | | int a=(ma>>8)&0xf; |
| 68 | 98 | /* inputs port b to IC39 are taken from the NAND gates b1 to b4 */ |
| 69 | 99 | int b=(b1<<0)|(b2<<1)|(b3<<2)|(b4<<3); |
| 70 | 100 | |
| 101 | /* inputs port a to IC39 are MA8 to MA11 from the 6845 */ |
| 102 | int a=(ma>>8)&0xf; |
| 103 | |
| 71 | 104 | /* IC39 performs the 4 bit add with the carry input set high */ |
| 72 | 105 | int s=(a+b+1)&0xf; |
| 73 | 106 | |
| 74 | 107 | /* if MA13 (TTXVDU) is low then IC8 and IC9 are used to calculate |
| 75 | 108 | the memory location required for the hi res video. |
| 76 | | if MA13 is hight then IC10 and IC11 are used to calculate the memory location for the teletext chip |
| 77 | | Note: the RA0,RA1,RA2 inputs to IC8 in high res modes will need to be added else where */ |
| 109 | if MA13 is hight then IC10 and IC11 are used to calculate the memory location for the teletext chip*/ |
| 78 | 110 | unsigned int m; |
| 79 | 111 | if ((ma>>13)&1) |
| 80 | 112 | { |
| 113 | // IC 10 and IC 11 |
| 81 | 114 | m=((ma&0x3ff)|0x3c00)|((s&0x8)<<11); |
| 82 | 115 | } else { |
| 83 | | m=((ma&0xff)<<3)|(s<<11); |
| 116 | // IC 8 and IC 9 |
| 117 | m=((ma&0xff)<<3)|(s<<11)|(m6845_row_address_r(0)&0x7); |
| 84 | 118 | } |
| 85 | 119 | if (state->m_memorySize==16) |
| 86 | 120 | return m & 0x3fff; |
| r11524 | r11525 | |
| 90 | 124 | |
| 91 | 125 | |
| 92 | 126 | |
| 93 | | /* this is a quick lookup array that puts bits 0,2,4,6 into bits 0,1,2,3 |
| 94 | | this is used by the pallette lookup in the video ULA */ |
| 95 | 127 | |
| 96 | | static void set_pixel_lookup(bbc_state *state) |
| 97 | | { |
| 98 | | int i; |
| 99 | | for (i=0; i<256; i++) |
| 100 | | { |
| 101 | | state->m_pixel_bits[i] = (((i>>7)&1)<<3) | (((i>>5)&1)<<2) | (((i>>3)&1)<<1) | (((i>>1)&1)<<0); |
| 102 | | } |
| 103 | | } |
| 104 | 128 | |
| 105 | 129 | /************************************************************************ |
| 106 | | * Outputs from the 6845 |
| 107 | | ************************************************************************/ |
| 108 | | |
| 109 | | |
| 110 | | |
| 111 | | |
| 112 | | /************************************************************************ |
| 113 | 130 | * Teletext Interface circuits |
| 114 | 131 | ************************************************************************/ |
| 115 | | |
| 116 | | |
| 117 | | |
| 118 | 132 | static void BBC_draw_teletext(running_machine &machine) |
| 119 | 133 | { |
| 120 | 134 | bbc_state *state = machine.driver_data<bbc_state>(); |
| r11524 | r11525 | |
| 123 | 137 | //Teletext Latch bit 6 is only passed onto bits 6 on the Teletext chip if DE is true |
| 124 | 138 | //Teletext Latch bit 7 goes to LOSE on the Teletext chip |
| 125 | 139 | |
| 126 | | int meml; |
| 127 | | |
| 128 | 140 | teletext_LOSE_w(state->m_saa505x, 0, (state->m_Teletext_Latch>>7)&1); |
| 129 | 141 | |
| 130 | 142 | teletext_F1(state->m_saa505x); |
| 131 | 143 | |
| 132 | | teletext_data_w(state->m_saa505x, 0, (state->m_Teletext_Latch&0x3f)|((state->m_Teletext_Latch&0x40)|(state->m_BBC_DE?0:0x40))); |
| 144 | teletext_data_w(state->m_saa505x, 0, (state->m_Teletext_Latch&0x3f)|((state->m_Teletext_Latch&0x40)|(m6845_display_enabled_r(0)?0:0x40))); |
| 133 | 145 | |
| 134 | | meml=m6845_memory_address_r(0); |
| 146 | int meml=m6845_memory_address_r(0); |
| 135 | 147 | |
| 136 | 148 | if (((meml>>13)&1)==0) |
| 137 | 149 | { |
| 138 | 150 | state->m_Teletext_Latch=0; |
| 139 | 151 | } else { |
| 140 | | state->m_Teletext_Latch=(state->m_BBC_Video_RAM[calculate_video_address(state,meml)]&0x7f)|state->m_Teletext_Latch_Input_D7; |
| 152 | state->m_Teletext_Latch=(state->m_BBC_Video_RAM[calculate_video_address(state,meml)]&0x7f)|(m6845_display_enabled_r(0)?0x80:0); |
| 141 | 153 | } |
| 142 | 154 | |
| 143 | 155 | } |
| r11524 | r11525 | |
| 145 | 157 | * VideoULA |
| 146 | 158 | ************************************************************************/ |
| 147 | 159 | |
| 148 | | |
| 149 | | |
| 150 | | |
| 151 | 160 | static const int pixels_per_byte_set[8]={ 2,4,8,16,1,2,4,8 }; |
| 152 | 161 | |
| 153 | 162 | static const int emulation_pixels_per_real_pixel_set[4]={ 8,4,2,1 }; |
| 154 | 163 | |
| 155 | | |
| 156 | 164 | static const int width_of_cursor_set[8]={ 0,0,1,2,1,0,2,4 }; |
| 157 | 165 | |
| 166 | /* this is a quick lookup array that puts bits 0,2,4,6 into bits 0,1,2,3 |
| 167 | this is used by the pallette lookup in the video ULA */ |
| 168 | static void set_pixel_lookup(bbc_state *state) |
| 169 | { |
| 170 | int i; |
| 171 | for (i=0; i<256; i++) |
| 172 | { |
| 173 | state->m_pixel_bits[i] = (((i>>7)&1)<<3) | (((i>>5)&1)<<2) | (((i>>3)&1)<<1) | (((i>>1)&1)<<0); |
| 174 | } |
| 175 | } |
| 158 | 176 | |
| 159 | | // this is the pixel position of the start of a scanline |
| 160 | | // -96 sets the screen display to the middle of emulated screen. |
| 161 | 177 | |
| 162 | | |
| 163 | | |
| 164 | | |
| 165 | 178 | WRITE8_HANDLER ( bbc_videoULA_w ) |
| 166 | 179 | { |
| 167 | 180 | bbc_state *state = space->machine().driver_data<bbc_state>(); |
| 168 | 181 | |
| 169 | | int tpal,tcol,vpos; |
| 170 | | |
| 171 | 182 | // Make sure vpos is never <0 2008-10-11 PHS. |
| 172 | | vpos=space->machine().primary_screen->vpos(); |
| 183 | int vpos=space->machine().primary_screen->vpos(); |
| 173 | 184 | if(vpos==0) |
| 174 | 185 | space->machine().primary_screen->update_partial(vpos); |
| 175 | 186 | else |
| 176 | 187 | space->machine().primary_screen->update_partial(vpos -1 ); |
| 177 | 188 | |
| 178 | | // logerror("setting videoULA %s at %.4x size:%.4x\n",image_filename(image), addr, size); |
| 179 | 189 | logerror("setting videoULA %.4x to:%.4x at :%d \n",data,offset,space->machine().primary_screen->vpos() ); |
| 180 | 190 | |
| 181 | 191 | |
| r11524 | r11525 | |
| 218 | 228 | break; |
| 219 | 229 | // Set a pallet register in the Video ULA |
| 220 | 230 | case 1: |
| 221 | | tpal=(data>>4)&0x0f; |
| 222 | | tcol=data&0x0f; |
| 231 | int tpal=(data>>4)&0x0f; |
| 232 | int tcol=data&0x0f; |
| 223 | 233 | state->m_videoULA_pallet0[tpal]=tcol^7; |
| 224 | 234 | state->m_videoULA_pallet1[tpal]=tcol<8?tcol^7:tcol; |
| 225 | 235 | break; |
| r11524 | r11525 | |
| 278 | 288 | unsigned char i=0; |
| 279 | 289 | int sc1; |
| 280 | 290 | |
| 281 | | if (state->m_VideoULA_DE) |
| 291 | // this is IC38 and IC41 takes 6845 DisplayEnabled and 6845 RA3 |
| 292 | int DE=m6845_display_enabled_r(0) && (!(m6845_row_address_r(0)&8)); |
| 293 | |
| 294 | if (DE) |
| 282 | 295 | { |
| 283 | | |
| 284 | 296 | // read the memory location for the next screen location. |
| 297 | meml=calculate_video_address(state,m6845_memory_address_r(0)); |
| 285 | 298 | |
| 286 | | meml=calculate_video_address(state,m6845_memory_address_r(0))|(state->m_BBC_Character_Row&0x7); |
| 287 | | |
| 288 | 299 | i=state->m_BBC_Video_RAM[meml]; |
| 289 | 300 | |
| 290 | 301 | for(sc1=0;sc1<state->m_pixels_per_byte;sc1++) |
| r11524 | r11525 | |
| 311 | 322 | |
| 312 | 323 | |
| 313 | 324 | |
| 314 | | |
| 315 | | |
| 316 | | |
| 317 | 325 | /************************************************************************ |
| 318 | 326 | * BBC circuits controlled by 6845 Outputs |
| 319 | 327 | ************************************************************************/ |
| 320 | 328 | |
| 321 | | static void BBC_Set_VideoULA_DE(bbc_state *state) |
| 322 | | { |
| 323 | | state->m_VideoULA_DE=(state->m_BBC_DE) && (!(state->m_BBC_Character_Row&8)); |
| 324 | | } |
| 325 | 329 | |
| 326 | | static void BBC_Set_Teletext_DE(bbc_state *state) |
| 327 | | { |
| 328 | | state->m_Teletext_Latch_Input_D7=state->m_BBC_DE?0x80:0; |
| 329 | | } |
| 330 | | |
| 331 | | // called when the 6845 changes the character row |
| 332 | | static void BBC_Set_Character_Row(running_machine &machine, int offset, int data) |
| 333 | | { |
| 334 | | bbc_state *state = machine.driver_data<bbc_state>(); |
| 335 | | state->m_BBC_Character_Row=data; |
| 336 | | BBC_Set_VideoULA_DE(state); |
| 337 | | } |
| 338 | | |
| 339 | 330 | // called when the 6845 changes the HSync |
| 340 | 331 | static void BBC_Set_HSync(running_machine &machine, int offset, int data) |
| 341 | 332 | { |
| r11524 | r11525 | |
| 388 | 379 | |
| 389 | 380 | } |
| 390 | 381 | |
| 391 | | // called when the 6845 changes the Display Enabled |
| 392 | | static void BBC_Set_DE(running_machine &machine, int offset, int data) |
| 393 | | { |
| 394 | | bbc_state *state = machine.driver_data<bbc_state>(); |
| 395 | | state->m_BBC_DE=data; |
| 396 | | BBC_Set_VideoULA_DE(state); |
| 397 | | BBC_Set_Teletext_DE(state); |
| 398 | | |
| 399 | | } |
| 400 | | |
| 401 | | |
| 402 | 382 | // called when the 6845 changes the Cursor Enabled |
| 403 | 383 | static void BBC_Set_CRE(running_machine &machine, int offset, int data) |
| 404 | 384 | { |
| r11524 | r11525 | |
| 415 | 395 | static const struct m6845_interface BBC6845 = |
| 416 | 396 | { |
| 417 | 397 | 0,// Memory Address register |
| 418 | | BBC_Set_Character_Row,// Row Address register |
| 398 | 0,// Row Address register |
| 419 | 399 | BBC_Set_HSync,// Horizontal status |
| 420 | 400 | BBC_Set_VSync,// Vertical status |
| 421 | | BBC_Set_DE,// Display Enabled status |
| 401 | 0,// Display Enabled status |
| 422 | 402 | 0,// Cursor status |
| 423 | 403 | BBC_Set_CRE, // Cursor status Emulation |
| 424 | 404 | }; |
| r11524 | r11525 | |
| 433 | 413 | |
| 434 | 414 | WRITE8_HANDLER ( bbc_6845_w ) |
| 435 | 415 | { |
| 416 | /*device_t *mc6845 = space->machine().device("mc6845"); |
| 417 | switch(offset & 1) |
| 418 | { |
| 419 | case 0 : |
| 420 | mc6845_address_w(mc6845,0,data); |
| 421 | break; |
| 422 | case 1 : |
| 423 | mc6845_register_w(mc6845,0,data); |
| 424 | break; |
| 425 | } |
| 426 | return;*/ |
| 427 | |
| 436 | 428 | switch (offset&1) |
| 437 | 429 | { |
| 438 | 430 | case 0: |
| r11524 | r11525 | |
| 447 | 439 | |
| 448 | 440 | READ8_HANDLER (bbc_6845_r) |
| 449 | 441 | { |
| 442 | |
| 443 | /*device_t *mc6845 = space->machine().device("mc6845"); |
| 444 | |
| 445 | switch (offset&1) |
| 446 | { |
| 447 | case 0: return mc6845_status_r(mc6845,0); break; |
| 448 | case 1: return mc6845_register_r(mc6845,0); break; |
| 449 | } |
| 450 | return 0;*/ |
| 451 | |
| 450 | 452 | int retval=0; |
| 451 | 453 | |
| 452 | 454 | switch (offset&1) |
| r11524 | r11525 | |
| 471 | 473 | |
| 472 | 474 | SCREEN_UPDATE( bbc ) |
| 473 | 475 | { |
| 476 | |
| 477 | //device_t *devconf = screen->machine().device("mc6845"); |
| 478 | //mc6845_update( devconf, bitmap, cliprect); |
| 479 | |
| 480 | // return 0; |
| 481 | |
| 482 | |
| 483 | |
| 474 | 484 | bbc_state *state = screen->machine().driver_data<bbc_state>(); |
| 475 | 485 | long c; |
| 476 | 486 | |
| r11524 | r11525 | |
| 542 | 552 | state->m_x_screen_offset = -96; |
| 543 | 553 | state->m_y_screen_offset = -8; |
| 544 | 554 | |
| 545 | | state->m_VideoULA_DE = 0; |
| 546 | 555 | state->m_VideoULA_CR = 7; |
| 547 | 556 | state->m_VideoULA_CR_counter = 0; |
| 548 | 557 | |