--- trunk/src/devices/dev_vga.c 2007/10/08 16:18:38 12 +++ trunk/src/devices/dev_vga.c 2007/10/08 16:18:51 14 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: dev_vga.c,v 1.77 2005/07/15 07:34:06 debug Exp $ + * $Id: dev_vga.c,v 1.81 2005/10/07 22:10:52 debug Exp $ * * VGA charcell and graphics device. * @@ -58,8 +58,6 @@ #define MAX_RETRACE_SCANLINES 420 #define N_IS1_READ_THRESHOLD 50 -#define VGA_MEM_MAXY 60 -#define VGA_MEM_ALLOCY 60 #define GFX_ADDR_WINDOW 0x18000 #define VGA_FB_ADDR 0x1c00000000ULL @@ -471,20 +469,32 @@ void dev_vga_tick(struct cpu *cpu, void *extra) { struct vga_data *d = extra; - uint64_t low = (uint64_t)-1, high; + int64_t low = -1, high; vga_update_cursor(cpu->machine, d); /* TODO: text vs graphics tick? */ - memory_device_dyntrans_access(cpu, cpu->mem, extra, &low, &high); + memory_device_dyntrans_access(cpu, cpu->mem, extra, + (uint64_t *) &low, (uint64_t *) &high); - if ((int64_t)low != -1) { + if (low != -1) { + int base = ((d->crtc_reg[VGA_CRTC_START_ADDR_HIGH] << 8) + + d->crtc_reg[VGA_CRTC_START_ADDR_LOW]) * 2; + int new_u_y1, new_u_y2; debug("[ dev_vga_tick: bintrans access, %llx .. %llx ]\n", (long long)low, (long long)high); + low -= base; + high -= base; d->update_x1 = 0; d->update_x2 = d->max_x - 1; - d->update_y1 = (low/2) / d->max_x; - d->update_y2 = ((high/2) / d->max_x) + 1; + new_u_y1 = (low/2) / d->max_x; + new_u_y2 = ((high/2) / d->max_x) + 1; + if (new_u_y1 < d->update_y1) + d->update_y1 = new_u_y1; + if (new_u_y2 > d->update_y2) + d->update_y2 = new_u_y2; + if (d->update_y2 < 0) + d->update_y2 = 0; if (d->update_y2 >= d->max_y) d->update_y2 = d->max_y - 1; d->modified = 1; @@ -1132,7 +1142,7 @@ uint64_t videomem_base, uint64_t control_base, char *name) { struct vga_data *d; - int i, x,y, tmpi; + int i, tmpi; size_t allocsize; d = malloc(sizeof(struct vga_data)); @@ -1152,11 +1162,11 @@ d->pixel_repy = 1; d->cur_mode = MODE_CHARCELL; d->crtc_reg[0xff] = 0x03; - d->charcells_size = d->max_x * VGA_MEM_MAXY * 2; + d->charcells_size = 0x8000; d->gfx_mem_size = 1; /* Nothing, as we start in text mode */ - /* Allocate in 4KB pages, to make it possible to use bintrans: */ - allocsize = ((d->charcells_size - 1) | 0xfff) + 1; + /* Allocate in full pages, to make it possible to use bintrans: */ + allocsize = ((d->charcells_size-1) | (machine->arch_pagesize-1)) + 1; d->charcells = malloc(d->charcells_size); d->charcells_outputed = malloc(d->charcells_size); d->gfx_mem = malloc(d->gfx_mem_size); @@ -1166,13 +1176,9 @@ exit(1); } - for (y=0; ymax_x; x++) { - char ch = ' '; - i = (x + d->max_x * y) * 2; - d->charcells[i] = ch; - d->charcells[i+1] = 0x07; /* Default color */ - } + for (i=0; icharcells_size; i+=2) { + d->charcells[i] = ' '; + d->charcells[i+1] = 0x07; /* Default color */ } memset(d->charcells_outputed, 0, d->charcells_size);