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},
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},
55 void DISPLAY::initialize()
57 memset(seg, 0, sizeof(seg));
61 register_vline_event(this);
64 void DISPLAY::event_vline(int v, int clock)
67 memset(seg, 0, sizeof(seg));
76 for(int i = 0; i < 8; i++) {
78 seg[(pc >> 4) & 7][i]++;
85 void DISPLAY::write_signal(int id, uint32_t data, uint32_t mask)
87 if(id == SIG_DISPLAY_PORT_B) {
89 } else if(id == SIG_DISPLAY_PORT_C) {
94 void DISPLAY::draw_screen()
97 scrntype_t col_h, col_l;
100 col_h = RGB_COLOR(255, 0, 0);
101 col_l = RGB_COLOR(107, 0, 0);
102 col[0] = RGB_COLOR(38, 8, 0);
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;
108 for(int y = 0; y < 40; y++) {
109 scrntype_t* dest = emu->get_screen_buffer(vm_ranges[i].y + y) + vm_ranges[i].x;
110 for(int x = 0; x < 28; x++) {
111 dest[x] = col[pat_7seg_led[y][x]];
117 #define STATE_VERSION 1
119 #include "../../statesub.h"
121 void DISPLAY::decl_state()
123 enter_decl_state(STATE_VERSION);
125 DECL_STATE_ENTRY_2D_ARRAY(seg, 6, 8);
126 DECL_STATE_ENTRY_UINT8(pb);
127 DECL_STATE_ENTRY_UINT8(pc);
132 void DISPLAY::save_state(FILEIO* state_fio)
134 if(state_entry != NULL) {
135 state_entry->save_state(state_fio);
137 // state_fio->FputUint32(STATE_VERSION);
138 // state_fio->FputInt32(this_device_id);
140 // state_fio->Fwrite(seg, sizeof(seg), 1);
141 // state_fio->FputUint8(pb);
142 // state_fio->FputUint8(pc);
145 bool DISPLAY::load_state(FILEIO* state_fio)
148 if(state_entry != NULL) {
149 mb = state_entry->load_state(state_fio);
154 // if(state_fio->FgetUint32() != STATE_VERSION) {
157 // if(state_fio->FgetInt32() != this_device_id) {
160 // state_fio->Fread(seg, sizeof(seg), 1);
161 // pb = state_fio->FgetUint8();
162 // pc = state_fio->FgetUint8();
166 bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
168 if(!state_fio->StateCheckUint32(STATE_VERSION)) {
171 if(!state_fio->StateCheckInt32(this_device_id)) {
174 state_fio->StateBuffer(seg, sizeof(seg), 1);
175 state_fio->StateUint8(pb);
176 state_fio->StateUint8(pc);