OSDN Git Service

[VM][WIP] Pre-process to apply new state framework.Still not buildable.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pasopia / display.cpp
index 6a92623..2f4dd47 100644 (file)
@@ -39,7 +39,7 @@ void DISPLAY::initialize()
        register_frame_event(this);
 }
 
-void DISPLAY::write_io8(uint32 addr, uint32 data)
+void DISPLAY::write_io8(uint32_t addr, uint32_t data)
 {
        switch(addr & 0xff) {
        case 0x10:
@@ -51,7 +51,7 @@ void DISPLAY::write_io8(uint32 addr, uint32 data)
        }
 }
 
-void DISPLAY::write_signal(int id, uint32 data, uint32 mask)
+void DISPLAY::write_signal(int id, uint32_t data, uint32_t mask)
 {
        // from 8255-1 port.a
        mode = data;
@@ -65,7 +65,7 @@ void DISPLAY::event_frame()
 void DISPLAY::draw_screen()
 {
        if((regs[8] & 0x30) != 0x30) {
-               uint16 src = ((regs[12] << 8) | regs[13]) & 0x7ff;
+               uint16_t src = ((regs[12] << 8) | regs[13]) & 0x7ff;
                if((regs[8] & 0xc0) == 0xc0) {
                        cursor = -1;
                } else {
@@ -106,20 +106,22 @@ void DISPLAY::draw_screen()
        }
        
        // copy to real screen
-       uint16 bcol = palette_pc[mode & 7];
+       emu->set_vm_screen_lines(200);
+       
+       uint16_t bcol = palette_pc[mode & 7];
+       emu->set_vm_screen_lines(200);
        for(int y = 0; y < 200; y++) {
-               scrntype* dest0 = emu->screen_buffer(y * 2 + 0);
-               scrntype* dest1 = emu->screen_buffer(y * 2 + 1);
-               uint8* src = screen[y];
+               scrntype_t* dest0 = emu->get_screen_buffer(y * 2 + 0);
+               scrntype_t* dest1 = emu->get_screen_buffer(y * 2 + 1);
+               uint8_t* src = screen[y];
                
-               if((dest0 == NULL) || (dest1 == NULL)) continue;
                for(int x = 0; x < 640; x++) {
                        dest0[x] = palette_pc[src[x] & 7];
                }
                if(config.scan_line) {
-                       memset(dest1, 0, 640 * sizeof(scrntype));
+                       memset(dest1, 0, 640 * sizeof(scrntype_t));
                } else {
-                       memcpy(dest1, dest0, 640 * sizeof(scrntype));
+                       memcpy(dest1, dest0, 640 * sizeof(scrntype_t));
                }
        }
        emu->screen_skip_line(true);
@@ -127,27 +129,27 @@ void DISPLAY::draw_screen()
 
 #define IS_ATTRIB(d) (((d) & 0xf8) == 0xf8)
 
-void DISPLAY::draw_screen0_normal(uint16 src)
+void DISPLAY::draw_screen0_normal(uint16_t src)
 {
        // screen 0, normal char (80chars)
-       uint16 src_t = src & 0x7ff;
-       uint8 c_b = mode & 7;
+       uint16_t src_t = src & 0x7ff;
+       uint8_t c_b = mode & 7;
        int width = regs[1] - 1;
        
        for(int y = 0; y < 200; y += 8) {
-               uint8 c_t = IS_ATTRIB(vram[src_t]) ? (vram[src_t] & 7) : 7;
+               uint8_t c_t = IS_ATTRIB(vram[src_t]) ? (vram[src_t] & 7) : 7;
                src_t = (src_t & 0x3800) | ((src_t + 1) & 0x7ff);
                
                for(int x = 0; x < width; x++) {
-                       uint8 code = vram[src_t];
+                       uint8_t code = vram[src_t];
                        if(IS_ATTRIB(code)) {
                                c_t = code & 7;
                        }
-                       uint8* font_base = &font[code << 3];
+                       uint8_t* font_base = &font[code << 3];
                        
                        for(int l = 0; l < 8; l++) {
-                               uint8 p = font_base[l];
-                               uint8* d = &screen[y + l][x << 3];
+                               uint8_t p = font_base[l];
+                               uint8_t* d = &screen[y + l][x << 3];
                                
                                d[0] = (p & 0x80) ? c_t : c_b;
                                d[1] = (p & 0x40) ? c_t : c_b;
@@ -171,27 +173,27 @@ void DISPLAY::draw_screen0_normal(uint16 src)
        }
 }
 
-void DISPLAY::draw_screen0_wide(uint16 src)
+void DISPLAY::draw_screen0_wide(uint16_t src)
 {
        // screen 0, wide char (36chars)
-       uint16 src_t = src & 0x7ff;
-       uint8 c_b = mode & 7;
+       uint16_t src_t = src & 0x7ff;
+       uint8_t c_b = mode & 7;
        int width = regs[1] - 1;
        
        for(int y = 0; y < 192; y += 8) {
-               uint8 c_t = IS_ATTRIB(vram[src_t]) ? (vram[src_t] & 7) : 7;
+               uint8_t c_t = IS_ATTRIB(vram[src_t]) ? (vram[src_t] & 7) : 7;
                src_t = (src_t & 0x3800) | ((src_t + 1) & 0x7ff);
                
                for(int x = 0; x < width; x++) {
-                       uint8 code = vram[src_t];
+                       uint8_t code = vram[src_t];
                        if(IS_ATTRIB(code)) {
                                c_t = code & 7;
                        }
-                       uint8* font_base = &font[code << 3];
+                       uint8_t* font_base = &font[code << 3];
                        
                        for(int l = 0; l < 8; l++) {
-                               uint8 p = font_base[l];
-                               uint8* d = &screen[y + l][x << 4];
+                               uint8_t p = font_base[l];
+                               uint8_t* d = &screen[y + l][x << 4];
                                
                                d[ 0] = d[ 1] = (p & 0x80) ? c_t : c_b;
                                d[ 2] = d[ 3] = (p & 0x40) ? c_t : c_b;
@@ -215,18 +217,18 @@ void DISPLAY::draw_screen0_wide(uint16 src)
        }
 }
 
-void DISPLAY::draw_screen1_normal(uint16 src)
+void DISPLAY::draw_screen1_normal(uint16_t src)
 {
        // screen 1, normal char (80chars)
-       uint16 src_t = src & 0x7ff;
-       uint8 c_b = mode & 7;
+       uint16_t src_t = src & 0x7ff;
+       uint8_t c_b = mode & 7;
        int width = regs[1] - 1;
-       uint8 c_t[8] = {7, 7, 7, 7, 7, 7, 7, 7};
+       uint8_t c_t[8] = {7, 7, 7, 7, 7, 7, 7, 7};
        
        for(int y = 0; y < 200; y += 8) {
                // character data is set for every other line in scren 1
                for(int i = 0; i < 8; i += 2) {
-                       uint8 t = vram[src_t + (i * 0x800)];
+                       uint8_t t = vram[src_t + (i * 0x800)];
                        if(IS_ATTRIB(t)) {
                                c_t[i] = c_t[i + 1] = t & 7;
                        }
@@ -235,10 +237,10 @@ void DISPLAY::draw_screen1_normal(uint16 src)
                
                for(int x = 0; x < width; x++) {
                        bool is_graph[8];
-                       uint8 attr_t[8];
-                       uint8 code[8];
+                       uint8_t attr_t[8];
+                       uint8_t code[8];
                        for(int i = 0; i < 8; i += 2) {
-                               uint16 t = (src_t + (i * 0x800)) & 0x3fff;
+                               uint16_t t = (src_t + (i * 0x800)) & 0x3fff;
                                is_graph[i] = is_graph[i + 1] = (attr[t] != 0);
                                attr_t[i] = attr_t[i + 1] = attr[t];
                                code[i] = code[i + 1] = vram[t];
@@ -247,12 +249,12 @@ void DISPLAY::draw_screen1_normal(uint16 src)
                        for(int l = 0; l < 8; l++) {
                                // change line color if vram data is text and is attribute character
                                // note: check only first line
-                               uint8 code_t = code[l];
+                               uint8_t code_t = code[l];
                                if(!is_graph[l] && IS_ATTRIB(code_t)) {
                                        c_t[l] = code_t & 7;
                                }
-                               uint8* font_base = &font[code_t << 3];
-                               uint8 c_l = c_t[l], c_r = c_t[l], p = font_base[l];
+                               uint8_t* font_base = &font[code_t << 3];
+                               uint8_t c_l = c_t[l], c_r = c_t[l], p = font_base[l];
                                if(is_graph[l]) {
                                        if(attr_t[l]) {
                                                p = code_t;
@@ -263,7 +265,7 @@ void DISPLAY::draw_screen1_normal(uint16 src)
                                                p = 0;
                                        }
                                }
-                               uint8* d = &screen[y + l][x << 3];
+                               uint8_t* d = &screen[y + l][x << 3];
                                
                                d[0] = (p & 0x80) ? c_l : c_b;
                                d[1] = (p & 0x40) ? c_l : c_b;
@@ -287,18 +289,18 @@ void DISPLAY::draw_screen1_normal(uint16 src)
        }
 }
 
-void DISPLAY::draw_screen1_wide(uint16 src)
+void DISPLAY::draw_screen1_wide(uint16_t src)
 {
        // screen 1, wide char (36chars)
-       uint16 src_t = src & 0x7ff;
-       uint8 c_b = mode & 7;
+       uint16_t src_t = src & 0x7ff;
+       uint8_t c_b = mode & 7;
        int width = regs[1] - 1;
-       uint8 c_t[8] = {7, 7, 7, 7, 7, 7, 7, 7};
+       uint8_t c_t[8] = {7, 7, 7, 7, 7, 7, 7, 7};
        
        for(int y = 0; y < 192; y += 8) {
                // character data is set for every other line in scren 1
                for(int i = 0; i < 8; i += 2) {
-                       uint8 t = vram[src_t + (i * 0x800)];
+                       uint8_t t = vram[src_t + (i * 0x800)];
                        if(IS_ATTRIB(t)) {
                                c_t[i] = c_t[i + 1] = t & 7;
                        }
@@ -307,10 +309,10 @@ void DISPLAY::draw_screen1_wide(uint16 src)
                
                for(int x = 0; x < width; x++) {
                        bool is_graph[8];
-                       uint8 attr_t[8];
-                       uint8 code[8];
+                       uint8_t attr_t[8];
+                       uint8_t code[8];
                        for(int i = 0; i < 8; i += 2) {
-                               uint16 t = (src_t + (i * 0x800)) & 0x3fff;
+                               uint16_t t = (src_t + (i * 0x800)) & 0x3fff;
                                is_graph[i] = is_graph[i + 1] = (attr[t] != 0);
                                attr_t[i] = attr_t[i + 1] = attr[t];
                                code[i] = code[i + 1] = vram[t];
@@ -319,12 +321,12 @@ void DISPLAY::draw_screen1_wide(uint16 src)
                        for(int l = 0; l < 8; l++) {
                                // change line color if vram data is text and is attribute character
                                // note: check only first line
-                               uint8 code_t = code[l];
+                               uint8_t code_t = code[l];
                                if(!is_graph[l] && IS_ATTRIB(code_t)) {
                                        c_t[l] = code_t & 7;
                                }
-                               uint8* font_base = &font[code_t << 3];
-                               uint8 c_l = c_t[l], c_r = c_t[l], p = font_base[l];
+                               uint8_t* font_base = &font[code_t << 3];
+                               uint8_t c_l = c_t[l], c_r = c_t[l], p = font_base[l];
                                if(is_graph[l]) {
                                        if(attr_t[l]) {
                                                p = code_t;
@@ -335,7 +337,7 @@ void DISPLAY::draw_screen1_wide(uint16 src)
                                                p = 0;
                                        }
                                }
-                               uint8* d = &screen[y + l][x << 4];
+                               uint8_t* d = &screen[y + l][x << 4];
                                
                                d[ 0] = d[ 1] = (p & 0x80) ? c_l : c_b;
                                d[ 2] = d[ 3] = (p & 0x40) ? c_l : c_b;
@@ -359,18 +361,18 @@ void DISPLAY::draw_screen1_wide(uint16 src)
        }
 }
 
-void DISPLAY::draw_screen2_normal(uint16 src)
+void DISPLAY::draw_screen2_normal(uint16_t src)
 {
        // screen 2, normal char (80chars)
-       uint16 src_t = src & 0x7ff;
-       uint8 c_b = mode & 7;
+       uint16_t src_t = src & 0x7ff;
+       uint8_t c_b = mode & 7;
        int width = regs[1] - 1;
-       uint8 c_t[8] = {7, 7, 7, 7, 7, 7, 7, 7};
+       uint8_t c_t[8] = {7, 7, 7, 7, 7, 7, 7, 7};
        
        for(int y = 0; y < 200; y += 8) {
                // character data is set for every line in scren 2
                for(int i = 0; i < 8; i++) {
-                       uint8 t = vram[src_t + (i * 0x800)];
+                       uint8_t t = vram[src_t + (i * 0x800)];
                        if(IS_ATTRIB(t)) {
                                c_t[i] = t & 7;
                        }
@@ -378,28 +380,28 @@ void DISPLAY::draw_screen2_normal(uint16 src)
                src_t = (src_t & 0x3800) | ((src_t + 1) & 0x7ff);
                
                for(int x = 0; x < width; x++) {
-                       uint16 src_g = src_t;
+                       uint16_t src_g = src_t;
                        bool is_graph[8];
-                       uint8 code[8];
+                       uint8_t code[8];
                        for(int i = 0; i < 8; i++) {
-                               uint16 t = (src_t + (i * 0x800)) & 0x3fff;
+                               uint16_t t = (src_t + (i * 0x800)) & 0x3fff;
                                is_graph[i] = (attr[t] != 0);
                                code[i] = vram[t];
                        }
                        
                        for(int l = 0; l < 8; l++) {
                                // change line color if vram data is text and is attribute character
-                               uint8 code_t = code[l];
+                               uint8_t code_t = code[l];
                                if(!is_graph[l] && (0xf8 <= code_t) && (code_t <= 0xff)) {
                                        c_t[l] = code_t & 7;
                                }
-                               uint8 c_l = c_t[l], c_r = c_t[l];
+                               uint8_t c_l = c_t[l], c_r = c_t[l];
                                
-                               uint8* font_base = &font[code_t << 3];
-                               uint8 p = is_graph[l] ? (attr[src_g] ? vram[src_g] : 0) : font_base[l];
+                               uint8_t* font_base = &font[code_t << 3];
+                               uint8_t p = is_graph[l] ? (attr[src_g] ? vram[src_g] : 0) : font_base[l];
                                src_g = (src_g + 0x800) & 0x3fff;
-                               uint8 c_p = is_graph[l] ? 7 : c_t[l];
-                               uint8* d = &screen[y + l][x << 3];
+                               uint8_t c_p = /*is_graph[l] ? 7 : */c_t[l];
+                               uint8_t* d = &screen[y + l][x << 3];
                                
                                d[0] = (p & 0x80) ? c_p : c_b;
                                d[1] = (p & 0x40) ? c_p : c_b;
@@ -423,18 +425,18 @@ void DISPLAY::draw_screen2_normal(uint16 src)
        }
 }
 
-void DISPLAY::draw_screen2_wide(uint16 src)
+void DISPLAY::draw_screen2_wide(uint16_t src)
 {
        // screen 0, wide char (36chars)
-       uint16 src_t = src & 0x7ff;
-       uint8 c_b = mode & 7;
+       uint16_t src_t = src & 0x7ff;
+       uint8_t c_b = mode & 7;
        int width = regs[1] - 1;
-       uint8 c_t[8] = {7, 7, 7, 7, 7, 7, 7, 7};
+       uint8_t c_t[8] = {7, 7, 7, 7, 7, 7, 7, 7};
        
        for(int y = 0; y < 192; y += 8) {
                // character data is set for every line in scren 2
                for(int i = 0; i < 8; i++) {
-                       uint8 t = vram[src_t + (i * 0x800)];
+                       uint8_t t = vram[src_t + (i * 0x800)];
                        if(IS_ATTRIB(t)) {
                                c_t[i] = t & 7;
                        }
@@ -442,27 +444,27 @@ void DISPLAY::draw_screen2_wide(uint16 src)
                src_t = (src_t & 0x3800) | ((src_t + 1) & 0x7ff);
                
                for(int x = 0; x < width; x++) {
-                       uint16 src_g = src_t;
+                       uint16_t src_g = src_t;
                        bool is_graph[8];
-                       uint8 code[8];
+                       uint8_t code[8];
                        for(int i = 0; i < 8; i++) {
-                               uint16 t = (src_t + (i * 0x800)) & 0x3fff;
+                               uint16_t t = (src_t + (i * 0x800)) & 0x3fff;
                                is_graph[i] = (attr[t] != 0);
                                code[i] = vram[t];
                        }
                        for(int l = 0; l < 8; l++) {
                                // change line color if vram data is text and is attribute character
-                               uint8 code_t = code[l];
+                               uint8_t code_t = code[l];
                                if(!is_graph[l] && IS_ATTRIB(code_t)) {
                                        c_t[l] = code_t & 7;
                                }
-                               uint8 c_l = c_t[l], c_r = c_t[l];
+                               uint8_t c_l = c_t[l], c_r = c_t[l];
                                
-                               uint8* font_base = &font[code_t << 3];
-                               uint8 p = is_graph[l] ? (attr[src_g] ? vram[src_g] : 0) : font_base[l];
+                               uint8_t* font_base = &font[code_t << 3];
+                               uint8_t p = is_graph[l] ? (attr[src_g] ? vram[src_g] : 0) : font_base[l];
                                src_g = (src_g + 0x800) & 0x3fff;
-                               uint8 c_p = is_graph[l] ? 7 : c_t[l];
-                               uint8* d = &screen[y + l][x << 4];
+                               uint8_t c_p = /*is_graph[l] ? 7 : */c_t[l];
+                               uint8_t* d = &screen[y + l][x << 4];
                                
                                d[ 0] = d[ 1] = (p & 0x80) ? c_p : c_b;
                                d[ 2] = d[ 3] = (p & 0x40) ? c_p : c_b;
@@ -486,18 +488,18 @@ void DISPLAY::draw_screen2_wide(uint16 src)
        }
 }
 
-void DISPLAY::draw_screen15_normal(uint16 src)
+void DISPLAY::draw_screen15_normal(uint16_t src)
 {
        // screen 2, normal char (80chars)
-       uint16 src_t = src & 0x7ff;
-       uint8 c_b = mode & 7;
+       uint16_t src_t = src & 0x7ff;
+       uint8_t c_b = mode & 7;
        int width = regs[1] - 1;
-       uint8 c_t[8] = {7, 7, 7, 7, 7, 7, 7, 7};
+       uint8_t c_t[8] = {7, 7, 7, 7, 7, 7, 7, 7};
        
        for(int y = 0; y < 200; y += 8) {
                // character data is set for every line in scren 1.5
                for(int i = 0; i < 8; i++) {
-                       uint8 t = vram[src_t + (i * 0x800)];
+                       uint8_t t = vram[src_t + (i * 0x800)];
                        if(IS_ATTRIB(t)) {
                                c_t[i] = t & 7;
                        }
@@ -506,22 +508,22 @@ void DISPLAY::draw_screen15_normal(uint16 src)
                
                for(int x = 0; x < width; x++) {
                        bool is_graph[8];
-                       uint8 attr_t[8];
-                       uint8 code[8];
+                       uint8_t attr_t[8];
+                       uint8_t code[8];
                        for(int i = 0; i < 8; i++) {
-                               uint16 t = (src_t + (i * 0x800)) & 0x3fff;
+                               uint16_t t = (src_t + (i * 0x800)) & 0x3fff;
                                is_graph[i] = (attr[t] != 0);
                                attr_t[i] = attr[t];
                                code[i] = vram[t];
                        }
                        for(int l = 0; l < 8; l++) {
                                // change line color if vram data is text and is attribute character
-                               uint8 code_t = code[l];
+                               uint8_t code_t = code[l];
                                if(!is_graph[l] && IS_ATTRIB(code_t)) {
                                        c_t[l] = code_t & 7;
                                }
-                               uint8* font_base = &font[code_t << 3];
-                               uint8 c_l = c_t[l], c_r = c_t[l], p = font_base[l];
+                               uint8_t* font_base = &font[code_t << 3];
+                               uint8_t c_l = c_t[l], c_r = c_t[l], p = font_base[l];
                                if(is_graph[l]) {
                                        if(attr_t[l]) {
                                                p = code_t;
@@ -532,7 +534,7 @@ void DISPLAY::draw_screen15_normal(uint16 src)
                                                p = 0;
                                        }
                                }
-                               uint8* d = &screen[y + l][x << 3];
+                               uint8_t* d = &screen[y + l][x << 3];
                                
                                d[0] = (p & 0x80) ? c_l : c_b;
                                d[1] = (p & 0x40) ? c_l : c_b;
@@ -556,18 +558,18 @@ void DISPLAY::draw_screen15_normal(uint16 src)
        }
 }
 
-void DISPLAY::draw_screen15_wide(uint16 src)
+void DISPLAY::draw_screen15_wide(uint16_t src)
 {
        // screen 0, normal char (80chars)
-       uint16 src_t = src & 0x7ff;
-       uint8 c_b = mode & 7;
+       uint16_t src_t = src & 0x7ff;
+       uint8_t c_b = mode & 7;
        int width = regs[1] - 1;
-       uint8 c_t[8] = {7, 7, 7, 7, 7, 7, 7, 7};
+       uint8_t c_t[8] = {7, 7, 7, 7, 7, 7, 7, 7};
        
        for(int y = 0; y < 192; y += 8) {
                // character data is set for every line in scren 1.5
                for(int i = 0; i < 8; i++) {
-                       uint8 t = vram[src_t + (i * 0x800)];
+                       uint8_t t = vram[src_t + (i * 0x800)];
                        if(IS_ATTRIB(t)) {
                                c_t[i] = t & 7;
                        }
@@ -576,10 +578,10 @@ void DISPLAY::draw_screen15_wide(uint16 src)
                
                for(int x = 0; x < width; x++) {
                        bool is_graph[8];
-                       uint8 attr_t[8];
-                       uint8 code[8];
+                       uint8_t attr_t[8];
+                       uint8_t code[8];
                        for(int i = 0; i < 8; i++) {
-                               uint16 t = (src_t + (i * 0x800)) & 0x3fff;
+                               uint16_t t = (src_t + (i * 0x800)) & 0x3fff;
                                is_graph[i] = (attr[t] != 0);
                                attr_t[i] = attr[t];
                                code[i] = vram[t];
@@ -587,12 +589,12 @@ void DISPLAY::draw_screen15_wide(uint16 src)
                        
                        for(int l = 0; l < 8; l++) {
                                // change line color if vram data is text and is attribute character
-                               uint8 code_t = code[l];
+                               uint8_t code_t = code[l];
                                if(!is_graph[l] && IS_ATTRIB(code_t)) {
                                        c_t[l] = code_t & 7;
                                }
-                               uint8* font_base = &font[code_t << 3];
-                               uint8 c_l = c_t[l], c_r = c_t[l], p = font_base[l];
+                               uint8_t* font_base = &font[code_t << 3];
+                               uint8_t c_l = c_t[l], c_r = c_t[l], p = font_base[l];
                                if(is_graph[l]) {
                                        if(attr_t[l]) {
                                                p = code_t;
@@ -603,7 +605,7 @@ void DISPLAY::draw_screen15_wide(uint16 src)
                                                p = 0;
                                        }
                                }
-                               uint8* d = &screen[y + l][x << 4];
+                               uint8_t* d = &screen[y + l][x << 4];
                                
                                d[ 0] = d[ 1] = (p & 0x80) ? c_l : c_b;
                                d[ 2] = d[ 3] = (p & 0x40) ? c_l : c_b;
@@ -629,27 +631,63 @@ void DISPLAY::draw_screen15_wide(uint16 src)
 
 #define STATE_VERSION  1
 
+#include "../../statesub.h"
+
+void DISPLAY::decl_state()
+{
+       enter_decl_state(STATE_VERSION);
+
+       DECL_STATE_ENTRY_UINT8(mode);
+       DECL_STATE_ENTRY_UINT16(cursor);
+       DECL_STATE_ENTRY_UINT16(cblink);
+       
+       leave_decl_state();
+}
+
 void DISPLAY::save_state(FILEIO* state_fio)
 {
-       state_fio->FputUint32(STATE_VERSION);
-       state_fio->FputInt32(this_device_id);
+       if(state_entry != NULL) {
+               state_entry->save_state(state_fio);
+       }
+//     state_fio->FputUint32(STATE_VERSION);
+//     state_fio->FputInt32(this_device_id);
        
-       state_fio->FputUint8(mode);
-       state_fio->FputUint16(cursor);
-       state_fio->FputUint16(cblink);
+//     state_fio->FputUint8(mode);
+//     state_fio->FputUint16(cursor);
+//     state_fio->FputUint16(cblink);
 }
 
 bool DISPLAY::load_state(FILEIO* state_fio)
 {
-       if(state_fio->FgetUint32() != STATE_VERSION) {
-               return false;
+       bool mb = false;
+       if(state_entry != NULL) {
+               mb = state_entry->load_state(state_fio);
        }
-       if(state_fio->FgetInt32() != this_device_id) {
+       if(!mb) {
                return false;
        }
-       mode = state_fio->FgetUint8();
-       cursor = state_fio->FgetUint16();
-       cblink = state_fio->FgetUint16();
+//     if(state_fio->FgetUint32() != STATE_VERSION) {
+//             return false;
+//     }
+//     if(state_fio->FgetInt32() != this_device_id) {
+//             return false;
+//     }
+//     mode = state_fio->FgetUint8();
+//     cursor = state_fio->FgetUint16();
+//     cblink = state_fio->FgetUint16();
        return true;
 }
 
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
+{
+       if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+               return false;
+       }
+       if(!state_fio->StateCheckInt32(this_device_id)) {
+               return false;
+       }
+       state_fio->StateUint8(mode);
+       state_fio->StateUint16(cursor);
+       state_fio->StateUint16(cblink);
+       return true;
+}