--- uae/src/svga.c 2018/04/24 16:40:03 1.1.1.3 +++ uae/src/svga.c 2018/04/24 17:16:39 1.1.1.12 @@ -16,17 +16,16 @@ #include #include -#include "config.h" #include "options.h" -#include "threaddep/penguin.h" +#include "threaddep/thread.h" #include "uae.h" #include "memory.h" -#include "custom.h" -#include "readcpu.h" -#include "newcpu.h" #include "keyboard.h" #include "xwin.h" +#include "custom.h" +#include "drawing.h" #include "keybuf.h" +#include "newcpu.h" #include "tui.h" #include "gui.h" #include "picasso96.h" @@ -203,25 +202,25 @@ void flush_line(int y) if (linear_mem == NULL) { if (target_y < modeinfo.height && target_y >= 0) { if (need_dither) { - DitherLine(dither_buf, (uae_u16 *)addr, 0, y, gfxvidinfo.width, bit_unit); + DitherLine (dither_buf, (uae_u16 *)addr, 0, y, gfxvidinfo.width, bit_unit); addr = dither_buf; } vga_drawscanline(target_y, addr); } } else { if (need_dither && target_y >= 0) { - DitherLine(linear_mem + modeinfo.linewidth * target_y, (uae_u16 *)addr, 0, y, - gfxvidinfo.width, bit_unit); + DitherLine (linear_mem + modeinfo.linewidth * target_y, (uae_u16 *)addr, 0, y, + gfxvidinfo.width, bit_unit); } } } -void flush_block(int a, int b) +void flush_block (int a, int b) { abort(); } -void flush_screen(int a, int b) +void flush_screen (int a, int b) { } @@ -237,24 +236,24 @@ static void restore_vga_colors (void) vga_setpalette (i, palette_entries[i][0], palette_entries[i][1], palette_entries[i][2]); } -static int get_color(int r, int g, int b, xcolnr *cnp) +static int get_color (int r, int g, int b, xcolnr *cnp) { if (colors_allocated == 256) return -1; *cnp = colors_allocated; - palette_entries[colors_allocated][0] = doMask(r, 6, 0); - palette_entries[colors_allocated][1] = doMask(g, 6, 0); - palette_entries[colors_allocated][2] = doMask(b, 6, 0); - vga_setpalette(colors_allocated, doMask(r, 6, 0), doMask(g, 6, 0), doMask(b, 6, 0)); + palette_entries[colors_allocated][0] = doMask (r, 6, 0); + palette_entries[colors_allocated][1] = doMask (g, 6, 0); + palette_entries[colors_allocated][2] = doMask (b, 6, 0); + vga_setpalette(colors_allocated, doMask (r, 6, 0), doMask (g, 6, 0), doMask (b, 6, 0)); colors_allocated++; return 1; } -static void init_colors(void) +static void init_colors (void) { int i; if (need_dither) { - setup_dither(bitdepth, get_color); + setup_dither (bitdepth, get_color); } else { int rw = 5, gw = 5, bw = 5; colors_allocated = 0; @@ -262,13 +261,13 @@ static void init_colors(void) switch (gfxvidinfo.pixbytes) { case 4: - alloc_colors64k(8, 8, 8, 16, 8, 0); + alloc_colors64k (8, 8, 8, 16, 8, 0); break; case 2: - alloc_colors64k(rw, gw, bw, gw+bw, bw, 0); + alloc_colors64k (rw, gw, bw, gw+bw, bw, 0); break; case 1: - alloc_colors256(get_color); + alloc_colors256 (get_color); break; default: abort(); @@ -293,9 +292,9 @@ static void init_colors(void) static int keystate[256]; -static int scancode2amiga(int scancode) +static int scancode2amiga (int scancode) { - switch(scancode) { + switch (scancode) { case SCODE_A: return AK_A; case SCODE_B: return AK_B; case SCODE_C: return AK_C; @@ -411,11 +410,11 @@ static int scancode2amiga(int scancode) return -1; } -static void my_kbd_handler(int scancode, int newstate) +static void my_kbd_handler (int scancode, int newstate) { - int akey = scancode2amiga(scancode); + int akey = scancode2amiga (scancode); - assert(scancode >= 0 && scancode < 0x100); + assert (scancode >= 0 && scancode < 0x100); if (scancode == SCODE_F12) { uae_quit (); } else if (scancode == SCODE_F11) { @@ -423,11 +422,11 @@ static void my_kbd_handler(int scancode, } if (keystate[scancode] == newstate) return; + keystate[scancode] = newstate; - if (akey == -1) { + if (akey == -1) return; - } if (newstate == KEY_EVENTPRESS) { if (akey == AK_inhibit) @@ -438,34 +437,34 @@ static void my_kbd_handler(int scancode, record_key ((akey << 1) | 1); /* "Affengriff" */ - if(keystate[AK_CTRL] && keystate[AK_LAMI] && keystate[AK_RAMI]) - uae_reset(); + if ((keystate[AK_CTRL] || keystate[AK_RCTRL]) && keystate[AK_LAMI] && keystate[AK_RAMI]) + uae_reset (); } static void leave_graphics_mode (void) { keyboard_close (); mouse_close (); - sleep(1); /* Maybe this will fix the "screen full of garbage" problem */ + sleep (1); /* Maybe this will fix the "screen full of garbage" problem */ current_vgamode = TEXT; - vga_setmode(TEXT); + vga_setmode (TEXT); } static int post_enter_graphics (void) { - vga_setmousesupport(1); - mouse_init("/dev/mouse", vga_getmousetype(), 10); + vga_setmousesupport (1); + mouse_init("/dev/mouse", vga_getmousetype (), 10); if (keyboard_init() != 0) { leave_graphics_mode (); - fprintf (stderr, "Are you sure you have a keyboard??\n"); + write_log ("Are you sure you have a keyboard??\n"); return 0; } keyboard_seteventhandler (my_kbd_handler); keyboard_translatekeys (DONT_CATCH_CTRLC); - mouse_setxrange(-1000,1000); - mouse_setyrange(-1000,1000); - mouse_setposition(0,0); + mouse_setxrange (-1000, 1000); + mouse_setyrange (-1000, 1000); + mouse_setposition (0, 0); return 1; } @@ -473,29 +472,30 @@ static int post_enter_graphics (void) static int enter_graphics_mode (int which) { int oldmode = current_vgamode; - if (vga_setmode(which) < 0) { + vga_setmode (TEXT); + if (vga_setmode (which) < 0) { sleep(1); - vga_setmode(TEXT); - fprintf(stderr, "SVGAlib doesn't like my video mode. Giving up.\n"); + vga_setmode (TEXT); + write_log ("SVGAlib doesn't like my video mode (%d). Giving up.\n", which); return 0; } current_vgamode = which; linear_mem = 0; - if ((modeinfo.flags & CAPABLE_LINEAR) && !currprefs.no_xhair) { - int val = vga_setlinearaddressing(); + if ((modeinfo.flags & CAPABLE_LINEAR) && ! currprefs.svga_no_linear) { + int val = vga_setlinearaddressing (); int new_ul = val != -1 ? !need_dither : 0; if (using_linear == -1) using_linear = new_ul; else if (using_linear != new_ul) { leave_graphics_mode (); - fprintf (stderr, "SVGAlib feeling not sure about linear modes???\n"); + write_log ("SVGAlib feeling not sure about linear modes???\n"); abort (); } if (val != -1) { - linear_mem = (char *)vga_getgraphmem(); - fprintf(stderr, "Using linear addressing: %p.\n", linear_mem); + linear_mem = (char *)vga_getgraphmem (); + write_log ("Using linear addressing: %p.\n", linear_mem); } } @@ -508,20 +508,21 @@ static int enter_graphics_mode_picasso ( if (which == oldmode) return 1; - if (vga_setmode(which) < 0) { - sleep(1); - vga_setmode(TEXT); - fprintf(stderr, "SVGAlib doesn't like my video mode. Giving up.\n"); + vga_setmode (TEXT); + if (vga_setmode (which) < 0) { + sleep (1); + vga_setmode (TEXT); + write_log ("SVGAlib doesn't like my video mode (%d). Giving up.\n", which); exit (1); } current_vgamode = which; linear_mem = 0; - if ((modeinfo.flags & CAPABLE_LINEAR) && !currprefs.no_xhair) { - int val = vga_setlinearaddressing(); + if ((modeinfo.flags & CAPABLE_LINEAR) && ! currprefs.svga_no_linear) { + int val = vga_setlinearaddressing (); if (val != -1) { - linear_mem = (char *)vga_getgraphmem(); - fprintf(stderr, "Using linear addressing: %p.\n", linear_mem); + linear_mem = (char *)vga_getgraphmem (); + write_log ("Using linear addressing: %p.\n", linear_mem); } } @@ -530,7 +531,7 @@ static int enter_graphics_mode_picasso ( return post_enter_graphics (); } -int graphics_setup(void) +int graphics_setup (void) { int i,j, count = 1; @@ -554,9 +555,9 @@ int graphics_setup(void) } } - video_mode_menu = (struct bstring *)malloc(sizeof (struct bstring)*count); - memset(video_mode_menu, 0, sizeof (struct bstring)*count); - count=0; + video_mode_menu = (struct bstring *)malloc (sizeof (struct bstring)*count); + memset (video_mode_menu, 0, sizeof (struct bstring)*count); + count = 0; for (i = 0; i < MAX_SCREEN_MODES; i++) { /* Ignore the larger modes which only make sense for Picasso screens. */ @@ -568,8 +569,8 @@ int graphics_setup(void) if (vga_mode_table[i][j] == -1) continue; - sprintf(buf, "%3dx%d, %s", x_size_table[i], y_size_table[i], - colormodes[j]); + sprintf (buf, "%3dx%d, %s", x_size_table[i], y_size_table[i], + colormodes[j]); video_mode_menu[count].val = -1; video_mode_menu[count++].data = strdup(buf); } @@ -607,7 +608,7 @@ static int select_mode_from_prefs (void) int i; if (currprefs.color_mode > 5) - fprintf(stderr, "Bad color mode selected. Using default.\n"), currprefs.color_mode = 0; + write_log ("Bad color mode selected. Using default.\n"), currprefs.color_mode = 0; mode_nr0 = 0; for (i = 1; i < MAX_SCREEN_MODES; i++) { @@ -628,17 +629,17 @@ static int select_mode_from_prefs (void) } } if (mode_nr == -1) { - fprintf(stderr, "Sorry, this combination of color and video mode is not supported.\n"); + write_log ("Sorry, this combination of color and video mode is not supported.\n"); return 0; } vgamode = vga_mode_table[mode_nr][currprefs.color_mode]; if (vgamode == -1) { - fprintf(stderr, "Bug!\n"); - abort(); + write_log ("Bug!\n"); + abort (); } - fprintf(stderr, "Desired resolution: %dx%d, using: %dx%d\n", - currprefs.gfx_width, currprefs.gfx_height, - x_size_table[mode_nr], y_size_table[mode_nr]); + write_log ("Desired resolution: %dx%d, using: %dx%d\n", + currprefs.gfx_width, currprefs.gfx_height, + x_size_table[mode_nr], y_size_table[mode_nr]); currprefs.gfx_width = x_size_table[mode_nr]; currprefs.gfx_height = y_size_table[mode_nr]; @@ -646,7 +647,7 @@ static int select_mode_from_prefs (void) return 1; } -int graphics_init(void) +int graphics_init (void) { int i; need_dither = 0; @@ -688,16 +689,17 @@ int graphics_init(void) } else { gfxvidinfo.rowbytes = (modeinfo.width * gfxvidinfo.pixbytes + 3) & ~3; #if 1 - gfxvidinfo.bufmem = malloc(gfxvidinfo.rowbytes); + gfxvidinfo.bufmem = malloc (gfxvidinfo.rowbytes); gfxvidinfo.linemem = gfxvidinfo.bufmem; - memset(gfxvidinfo.bufmem, 0, gfxvidinfo.rowbytes); + memset (gfxvidinfo.bufmem, 0, gfxvidinfo.rowbytes); #else gfxvidinfo.bufmem = malloc(gfxvidinfo.rowbytes * modeinfo.height); - memset(gfxvidinfo.bufmem, 0, gfxvidinfo.rowbytes * modeinfo.height); + memset (gfxvidinfo.bufmem, 0, gfxvidinfo.rowbytes * modeinfo.height); #endif + gfxvidinfo.emergmem = 0; } - - init_colors(); + printf ("rowbytes %d\n", gfxvidinfo.rowbytes); + init_colors (); buttonstate[0] = buttonstate[1] = buttonstate[2] = 0; for(i = 0; i < 256; i++) keystate[i] = 0; @@ -708,22 +710,22 @@ int graphics_init(void) return 1; } -void graphics_leave(void) +void graphics_leave (void) { leave_graphics_mode (); dumpcustom(); } -void handle_events(void) +void handle_events (void) { - int button = mouse_getbutton(); + int button = mouse_getbutton (); gui_requested = 0; - keyboard_update(); - mouse_update(); - lastmx += mouse_getx(); - lastmy += mouse_gety(); - mouse_setposition(0,0); + keyboard_update (); + mouse_update (); + lastmx += mouse_getx (); + lastmy += mouse_gety (); + mouse_setposition (0, 0); buttonstate[0] = button & 4; buttonstate[1] = button & 2; @@ -737,7 +739,7 @@ void handle_events(void) if (!picasso_invalid_lines[i]) continue; picasso_invalid_lines[i] = 0; - vga_drawscanline(i, addr); + vga_drawscanline (i, addr); } } #endif @@ -753,23 +755,23 @@ void handle_events(void) } } -int debuggable(void) +int check_prefs_changed_gfx (void) { return 0; } -int needmousehack(void) +int debuggable (void) { return 0; } -void LED(int on) +int needmousehack (void) { + return 0; } -void write_log (const char *buf) +void LED (int on) { - fprintf (stderr, buf); } #ifdef PICASSO96 @@ -860,7 +862,7 @@ static void set_window_for_amiga (void) restore_vga_colors (); } -void gfx_set_picasso_modeinfo (int w, int h, int depth) +void gfx_set_picasso_modeinfo (int w, int h, int depth, int rgbfmt) { vga_modeinfo *info; int i, mode; @@ -887,6 +889,9 @@ void gfx_set_picasso_modeinfo (int w, in picasso_vidinfo.depth = depth; picasso_vidinfo.pixbytes = depth>>3; picasso_vidinfo.rowbytes = info->linewidth; + picasso_vidinfo.rgbformat = (depth == 8 ? RGBFB_CHUNKY + : depth == 16 ? RGBFB_R5G6B5PC + : RGBFB_B8G8R8A8); if (screen_is_picasso) set_window_for_picasso (); } @@ -906,19 +911,30 @@ void gfx_set_picasso_state (int on) set_window_for_amiga (); } -void begindrawing (void) +uae_u8 *gfx_lock_picasso (void) { + return linear_mem; } - -void enddrawing (void) +void gfx_unlock_picasso (void) { } +#endif -uae_u8 *lockscr (void) +int lockscr (void) { - return linear_mem; + return 1; } + void unlockscr (void) { } -#endif + +void target_save_options (FILE *f, struct uae_prefs *p) +{ + fprintf (f, "svga.no_linear=%s\n", p->svga_no_linear ? "true" : "false"); +} + +int target_parse_option (struct uae_prefs *p, char *option, char *value) +{ + return (cfgfile_yesno (option, value, "no_linear", &p->svga_no_linear)); +}