OSDN Git Service

b68f35b6b08078fa46a33aaa883582bfd47e3e26
[csp-qt/common_source_project-fm7.git] / source / src / vm / ys6464a / display.cpp
1 /*
2         SHINKO SANGYO YS-6464A Emulator 'eYS-6464A'
3
4         Author : Takeda.Toshiya
5         Date   : 2009.12.30 -
6
7         [ display ]
8 */
9
10 #include "display.h"
11
12 static const int pat_7seg_led[40][28] = {
13         {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0},
14         {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0},
15         {0,0,0,0,0,6,6,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,2,2},
16         {0,0,0,0,0,6,6,6,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,2,2,2},
17         {0,0,0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2},
18         {0,0,0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2},
19         {0,0,0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2},
20         {0,0,0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2},
21         {0,0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0},
22         {0,0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0},
23         {0,0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0},
24         {0,0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0},
25         {0,0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0},
26         {0,0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0},
27         {0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0,0},
28         {0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0,0},
29         {0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0,0},
30         {0,0,0,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,0,0},
31         {0,0,0,6,6,6,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,2,2,2,0,0},
32         {0,0,0,6,6,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,2,2,0,0},
33         {0,0,5,5,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,3,3,0,0,0},
34         {0,0,5,5,5,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,3,3,3,0,0,0},
35         {0,0,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0},
36         {0,0,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0},
37         {0,0,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0},
38         {0,0,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0},
39         {0,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0},
40         {0,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0},
41         {0,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0},
42         {0,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0},
43         {0,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0},
44         {0,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0},
45         {5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0,0},
46         {5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0,0},
47         {5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0,0},
48         {5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0,0},
49         {5,5,5,0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,3,3,3,0,0,0,0,0},
50         {5,5,0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,3,3,0,8,8,8,0},
51         {0,0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,8,8,8,8,8},
52         {0,0,0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,8,8,8,0},
53 };
54
55 void DISPLAY::initialize()
56 {
57         memset(seg, 0, sizeof(seg));
58         pb = pc = 0;
59         
60         // register event
61         register_vline_event(this);
62 }
63
64 void DISPLAY::event_vline(int v, int clock)
65 {
66         if(!v) {
67                 memset(seg, 0, sizeof(seg));
68         }
69         switch(pc & 0xf0) {
70         case 0x80:
71         case 0x90:
72         case 0xa0:
73         case 0xb0:
74         case 0xc0:
75         case 0xd0:
76                 for(int i = 0; i < 8; i++) {
77                         if(~pb & (1 << i)) {
78                                 seg[(pc >> 4) & 7][i]++;
79                         }
80                 }
81                 break;
82         }
83 }
84
85 void DISPLAY::write_signal(int id, uint32 data, uint32 mask)
86 {
87         if(id == SIG_DISPLAY_PORT_B) {
88                 pb = data;
89         } else if(id == SIG_DISPLAY_PORT_C) {
90                 pc = data & 0xf0;
91         }
92 }
93
94 void DISPLAY::draw_screen()
95 {
96         // draw 7-seg LEDs
97         scrntype col_h, col_l;
98         scrntype col[9];
99         
100         col_h = RGB_COLOR(255, 0, 0);
101         col_l = RGB_COLOR(107, 0, 0);
102         col[0] = RGB_COLOR(38, 8, 0);
103         
104         for(int i = 0; i < 6; i++) {
105                 for(int j = 0; j < 8; j++) {
106                         col[j + 1] = (seg[i][j] > 8) ? col_h : col_l;
107                 }
108                 for(int y = 0; y < 40; y++) {
109                         scrntype* dest = emu->screen_buffer(ranges[i].y + y) + ranges[i].x;
110                         for(int x = 0; x < 28; x++) {
111                                 dest[x] = col[pat_7seg_led[y][x]];
112                         }
113                 }
114         }
115 }
116